4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <rte_common.h>
39 #include <rte_byteorder.h>
41 #include <rte_malloc.h>
42 #include <rte_ethdev.h>
44 #include <rte_ether.h>
47 #include <rte_port_ethdev.h>
48 #include <rte_port_ring.h>
49 #include <rte_port_ras.h>
50 #include <rte_table_stub.h>
51 #include <rte_pipeline.h>
56 app_main_loop_pipeline_ipv4_ras(void) {
57 struct rte_pipeline *p;
58 uint32_t port_in_id[APP_MAX_PORTS];
59 uint32_t port_out_id[APP_MAX_PORTS];
60 uint32_t table_id[APP_MAX_PORTS];
63 uint32_t core_id = rte_lcore_id();
64 struct app_core_params *core_params = app_get_core_params(core_id);
66 if ((core_params == NULL) ||
67 (core_params->core_type != APP_CORE_IPV4_RAS)) {
68 rte_panic("Core %u misconfiguration\n", core_id);
71 RTE_LOG(INFO, USER1, "Core %u is doing IPv4 reassembly\n", core_id);
73 /* Pipeline configuration */
74 struct rte_pipeline_params pipeline_params = {
76 .socket_id = rte_socket_id(),
79 p = rte_pipeline_create(&pipeline_params);
81 rte_panic("%s: Unable to configure the pipeline\n", __func__);
83 /* Input port configuration */
84 for (i = 0; i < app.n_ports; i++) {
85 struct rte_port_ring_reader_params port_ring_params = {
86 .ring = app.rings[core_params->swq_in[i]],
89 struct rte_pipeline_port_in_params port_params = {
90 .ops = &rte_port_ring_reader_ops,
91 .arg_create = (void *) &port_ring_params,
94 .burst_size = app.bsz_swq_rd,
97 if (rte_pipeline_port_in_create(p, &port_params,
99 rte_panic("%s: Unable to configure input port %i\n",
103 /* Output port configuration */
104 for (i = 0; i < app.n_ports; i++) {
105 struct rte_port_ring_writer_params port_ring_ipv4_ras_params = {
106 .ring = app.rings[core_params->swq_out[i]],
107 .tx_burst_sz = app.bsz_swq_wr,
110 struct rte_pipeline_port_out_params port_params = {
111 .ops = &rte_port_ring_writer_ipv4_ras_ops,
112 .arg_create = (void *) &port_ring_ipv4_ras_params,
114 .f_action_bulk = NULL,
118 if (rte_pipeline_port_out_create(p, &port_params,
120 rte_panic("%s: Unable to configure output port %i\n",
124 /* Table configuration */
125 for (i = 0; i < app.n_ports; i++) {
126 struct rte_pipeline_table_params table_params = {
127 .ops = &rte_table_stub_ops,
129 .f_action_hit = NULL,
130 .f_action_miss = NULL,
132 .action_data_size = 0,
135 if (rte_pipeline_table_create(p, &table_params, &table_id[i]))
136 rte_panic("%s: Unable to configure table %u\n",
137 __func__, table_id[i]);
140 /* Interconnecting ports and tables */
141 for (i = 0; i < app.n_ports; i++)
142 if (rte_pipeline_port_in_connect_to_table(p, port_in_id[i],
144 rte_panic("%s: Unable to connect input port %u to "
145 "table %u\n", __func__, port_in_id[i],
148 /* Add entries to tables */
149 for (i = 0; i < app.n_ports; i++) {
150 struct rte_pipeline_table_entry default_entry = {
151 .action = RTE_PIPELINE_ACTION_PORT,
152 {.port_id = port_out_id[i]},
155 struct rte_pipeline_table_entry *default_entry_ptr;
157 if (rte_pipeline_table_default_entry_add(p, table_id[i],
160 rte_panic("%s: Unable to add default entry to "
161 "table %u\n", __func__, table_id[i]);
164 /* Enable input ports */
165 for (i = 0; i < app.n_ports; i++)
166 if (rte_pipeline_port_in_enable(p, port_in_id[i]))
167 rte_panic("Unable to enable input port %u\n",
170 /* Check pipeline consistency */
171 if (rte_pipeline_check(p) < 0)
172 rte_panic("%s: Pipeline consistency check failed\n", __func__);
178 if ((i & APP_FLUSH) == 0)
179 rte_pipeline_flush(p);