1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation
10 #include <rte_port_ring.h>
11 #include <rte_table_stub.h>
12 #include <rte_pipeline.h>
17 app_main_loop_worker_pipeline_stub(void) {
18 struct rte_pipeline_params pipeline_params = {
20 .socket_id = rte_socket_id(),
23 struct rte_pipeline *p;
24 uint32_t port_in_id[APP_MAX_PORTS];
25 uint32_t port_out_id[APP_MAX_PORTS];
26 uint32_t table_id[APP_MAX_PORTS];
29 RTE_LOG(INFO, USER1, "Core %u is doing work (pipeline with stub "
30 "tables)\n", rte_lcore_id());
32 /* Pipeline configuration */
33 p = rte_pipeline_create(&pipeline_params);
35 rte_panic("Unable to configure the pipeline\n");
37 /* Input port configuration */
38 for (i = 0; i < app.n_ports; i++) {
39 struct rte_port_ring_reader_params port_ring_params = {
40 .ring = app.rings_rx[i],
43 struct rte_pipeline_port_in_params port_params = {
44 .ops = &rte_port_ring_reader_ops,
45 .arg_create = (void *) &port_ring_params,
48 .burst_size = app.burst_size_worker_read,
51 if (rte_pipeline_port_in_create(p, &port_params,
53 rte_panic("Unable to configure input port for "
57 /* Output port configuration */
58 for (i = 0; i < app.n_ports; i++) {
59 struct rte_port_ring_writer_params port_ring_params = {
60 .ring = app.rings_tx[i],
61 .tx_burst_sz = app.burst_size_worker_write,
64 struct rte_pipeline_port_out_params port_params = {
65 .ops = &rte_port_ring_writer_ops,
66 .arg_create = (void *) &port_ring_params,
71 if (rte_pipeline_port_out_create(p, &port_params,
73 rte_panic("Unable to configure output port for "
77 /* Table configuration */
78 for (i = 0; i < app.n_ports; i++) {
79 struct rte_pipeline_table_params table_params = {
80 .ops = &rte_table_stub_ops,
83 .f_action_miss = NULL,
85 .action_data_size = 0,
88 if (rte_pipeline_table_create(p, &table_params, &table_id[i]))
89 rte_panic("Unable to configure table %u\n", i);
92 /* Interconnecting ports and tables */
93 for (i = 0; i < app.n_ports; i++)
94 if (rte_pipeline_port_in_connect_to_table(p, port_in_id[i],
96 rte_panic("Unable to connect input port %u to "
97 "table %u\n", port_in_id[i], table_id[i]);
99 /* Add entries to tables */
100 for (i = 0; i < app.n_ports; i++) {
101 struct rte_pipeline_table_entry entry = {
102 .action = RTE_PIPELINE_ACTION_PORT,
103 {.port_id = port_out_id[i ^ 1]},
105 struct rte_pipeline_table_entry *default_entry_ptr;
107 if (rte_pipeline_table_default_entry_add(p, table_id[i], &entry,
109 rte_panic("Unable to add default entry to table %u\n",
113 /* Enable input ports */
114 for (i = 0; i < app.n_ports; i++)
115 if (rte_pipeline_port_in_enable(p, port_in_id[i]))
116 rte_panic("Unable to enable input port %u\n",
119 /* Check pipeline consistency */
120 if (rte_pipeline_check(p) < 0)
121 rte_panic("Pipeline consistency check failed\n");
131 if ((i & APP_FLUSH) == 0)
132 rte_pipeline_flush(p);