1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #include <rte_table_stub.h>
6 #include <rte_table_lpm.h>
7 #include <rte_table_lpm_ipv6.h>
8 #include <rte_table_hash.h>
9 #include <rte_table_array.h>
10 #include <rte_pipeline.h>
13 #include <rte_table_acl.h>
16 #include <rte_port_ring.h>
17 #include <rte_port_ethdev.h>
18 #include <rte_port_source_sink.h>
23 #define RING_SIZE 4096
27 #define TEST_RING_FULL_EMTPY_ITER 8
31 #define RING_RX rings_rx[0]
32 #define RING_RX_2 rings_rx[1]
33 #define RING_TX rings_tx[0]
34 #define RING_TX_2 rings_tx[1]
35 #define PORT_RX_RING_SIZE 128
36 #define PORT_TX_RING_SIZE 512
37 #define RING_RX_SIZE 128
38 #define RING_TX_SIZE 128
39 #define POOL_BUFFER_SIZE RTE_MBUF_DEFAULT_BUF_SIZE
40 #define POOL_SIZE (32 * 1024)
41 #define POOL_CACHE_SIZE 256
44 #define MAX_DUMMY_PORTS 2
45 #define MP_NAME "dummy_port_mempool"
46 #define MBUF_COUNT (8000 * MAX_DUMMY_PORTS)
47 #define MP_CACHE_SZ 256
52 #define APP_METADATA_OFFSET(offset) (sizeof(struct rte_mbuf) + (offset))
54 #define RING_ENQUEUE(ring, value) do { \
56 uint32_t *k32, *signature; \
59 m = rte_pktmbuf_alloc(pool); \
62 signature = RTE_MBUF_METADATA_UINT32_PTR(m, \
63 APP_METADATA_OFFSET(0)); \
64 key = RTE_MBUF_METADATA_UINT8_PTR(m, \
65 APP_METADATA_OFFSET(32)); \
66 k32 = (uint32_t *) key; \
68 *signature = pipeline_test_hash(key, NULL, 0, 0); \
69 rte_ring_enqueue((ring), m); \
72 #define RUN_PIPELINE(pipeline) do { \
73 rte_pipeline_run((pipeline)); \
74 rte_pipeline_flush((pipeline)); \
77 #define VERIFY(var, value) do { \
78 if ((var) != -(value)) \
82 #define VERIFY_TRAFFIC(ring, sent, expected) do { \
86 for (i = 0; i < (sent); i++) { \
87 if (!rte_ring_dequeue((ring), &mbuf)) { \
91 rte_pktmbuf_free((struct rte_mbuf *)mbuf); \
96 printf("Expected %d, got %d\n", expected, n); \
97 if (n != (expected)) { \
102 /* Function definitions */
103 uint64_t pipeline_test_hash(
105 __attribute__((unused)) void *key_mask,
106 __attribute__((unused)) uint32_t key_size,
107 __attribute__((unused)) uint64_t seed);
109 /* Extern variables */
110 extern struct rte_pipeline *p;
111 extern struct rte_ring *rings_rx[N_PORTS];
112 extern struct rte_ring *rings_tx[N_PORTS];
113 extern struct rte_mempool *pool;
114 extern uint32_t port_in_id[N_PORTS];
115 extern uint32_t port_out_id[N_PORTS];
116 extern uint32_t port_out_id_type[3];
117 extern uint32_t table_id[N_PORTS*2];
118 extern uint64_t override_hit_mask;
119 extern uint64_t override_miss_mask;
120 extern uint64_t non_reserved_actions_hit;
121 extern uint64_t non_reserved_actions_miss;
122 extern uint8_t connect_miss_action_to_port_out;
123 extern uint8_t connect_miss_action_to_table;
124 extern uint32_t table_entry_default_action;
125 extern uint32_t table_entry_hit_action;
126 extern uint32_t table_entry_miss_action;
127 extern rte_pipeline_port_in_action_handler port_in_action;
128 extern rte_pipeline_port_out_action_handler port_out_action;
129 extern rte_pipeline_table_action_handler_hit action_handler_hit;
130 extern rte_pipeline_table_action_handler_miss action_handler_miss;
132 /* Global data types */
139 /* Internal pipeline structures */
141 struct rte_port_in_ops ops;
147 struct rte_port_out {
148 struct rte_port_out_ops ops;
153 struct rte_table_ops ops;
154 rte_pipeline_table_action_handler_hit f_action;
155 uint32_t table_next_id;
156 uint32_t table_next_id_valid;
157 uint8_t actions_lookup_miss[RTE_CACHE_LINE_SIZE];
158 uint32_t action_data_size;
162 #define RTE_PIPELINE_MAX_NAME_SZ 124
164 struct rte_pipeline {
165 char name[RTE_PIPELINE_MAX_NAME_SZ];
167 struct rte_port_in ports_in[16];
168 struct rte_port_out ports_out[16];
169 struct rte_table tables[64];
170 uint32_t num_ports_in;
171 uint32_t num_ports_out;
173 struct rte_mbuf *pkts[RTE_PORT_IN_BURST_SIZE_MAX];
174 struct rte_table_entry *actions[RTE_PORT_IN_BURST_SIZE_MAX];
175 uint64_t mask_action[64];
176 uint32_t mask_actions;