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_hash_cuckoo.h>
10 #include <rte_table_array.h>
11 #include <rte_pipeline.h>
14 #include <rte_table_acl.h>
17 #include <rte_port_ring.h>
18 #include <rte_port_ethdev.h>
19 #include <rte_port_source_sink.h>
24 #define RING_SIZE 4096
28 #define TEST_RING_FULL_EMTPY_ITER 8
32 #define RING_RX rings_rx[0]
33 #define RING_RX_2 rings_rx[1]
34 #define RING_TX rings_tx[0]
35 #define RING_TX_2 rings_tx[1]
36 #define PORT_RX_RING_SIZE 128
37 #define PORT_TX_RING_SIZE 512
38 #define RING_RX_SIZE 128
39 #define RING_TX_SIZE 128
40 #define POOL_BUFFER_SIZE RTE_MBUF_DEFAULT_BUF_SIZE
41 #define POOL_SIZE (32 * 1024)
42 #define POOL_CACHE_SIZE 256
45 #define MAX_DUMMY_PORTS 2
46 #define MP_NAME "dummy_port_mempool"
47 #define MBUF_COUNT (8000 * MAX_DUMMY_PORTS)
48 #define MP_CACHE_SZ 256
53 #define APP_METADATA_OFFSET(offset) (sizeof(struct rte_mbuf) + (offset))
55 #define RING_ENQUEUE(ring, value) do { \
57 uint32_t *k32, *signature; \
60 m = rte_pktmbuf_alloc(pool); \
63 signature = RTE_MBUF_METADATA_UINT32_PTR(m, \
64 APP_METADATA_OFFSET(0)); \
65 key = RTE_MBUF_METADATA_UINT8_PTR(m, \
66 APP_METADATA_OFFSET(32)); \
67 k32 = (uint32_t *) key; \
69 *signature = pipeline_test_hash(key, NULL, 0, 0); \
70 rte_ring_enqueue((ring), m); \
73 #define RUN_PIPELINE(pipeline) do { \
74 rte_pipeline_run((pipeline)); \
75 rte_pipeline_flush((pipeline)); \
78 #define VERIFY(var, value) do { \
79 if ((var) != -(value)) \
83 #define VERIFY_TRAFFIC(ring, sent, expected) do { \
87 for (i = 0; i < (sent); i++) { \
88 if (!rte_ring_dequeue((ring), &mbuf)) { \
92 rte_pktmbuf_free((struct rte_mbuf *)mbuf); \
97 printf("Expected %d, got %d\n", expected, n); \
98 if (n != (expected)) { \
103 /* Function definitions */
104 uint64_t pipeline_test_hash(
106 __rte_unused void *key_mask,
107 __rte_unused uint32_t key_size,
108 __rte_unused uint64_t seed);
110 uint32_t pipeline_test_hash_cuckoo(
112 __rte_unused uint32_t key_size,
113 __rte_unused uint32_t seed);
115 /* Extern variables */
116 extern struct rte_pipeline *p;
117 extern struct rte_ring *rings_rx[N_PORTS];
118 extern struct rte_ring *rings_tx[N_PORTS];
119 extern struct rte_mempool *pool;
120 extern uint32_t port_in_id[N_PORTS];
121 extern uint32_t port_out_id[N_PORTS];
122 extern uint32_t port_out_id_type[3];
123 extern uint32_t table_id[N_PORTS*2];
124 extern uint64_t override_hit_mask;
125 extern uint64_t override_miss_mask;
126 extern uint64_t non_reserved_actions_hit;
127 extern uint64_t non_reserved_actions_miss;
128 extern uint8_t connect_miss_action_to_port_out;
129 extern uint8_t connect_miss_action_to_table;
130 extern uint32_t table_entry_default_action;
131 extern uint32_t table_entry_hit_action;
132 extern uint32_t table_entry_miss_action;
133 extern rte_pipeline_port_in_action_handler port_in_action;
134 extern rte_pipeline_port_out_action_handler port_out_action;
135 extern rte_pipeline_table_action_handler_hit action_handler_hit;
136 extern rte_pipeline_table_action_handler_miss action_handler_miss;
138 /* Global data types */
145 /* Internal pipeline structures */
147 struct rte_port_in_ops ops;
153 struct rte_port_out {
154 struct rte_port_out_ops ops;
159 struct rte_table_ops ops;
160 rte_pipeline_table_action_handler_hit f_action;
161 uint32_t table_next_id;
162 uint32_t table_next_id_valid;
163 uint8_t actions_lookup_miss[RTE_CACHE_LINE_SIZE];
164 uint32_t action_data_size;
168 #define RTE_PIPELINE_MAX_NAME_SZ 124
170 struct rte_pipeline {
171 char name[RTE_PIPELINE_MAX_NAME_SZ];
173 struct rte_port_in ports_in[16];
174 struct rte_port_out ports_out[16];
175 struct rte_table tables[64];
176 uint32_t num_ports_in;
177 uint32_t num_ports_out;
179 struct rte_mbuf *pkts[RTE_PORT_IN_BURST_SIZE_MAX];
180 struct rte_table_entry *actions[RTE_PORT_IN_BURST_SIZE_MAX];
181 uint64_t mask_action[64];
182 uint32_t mask_actions;