]> git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/app/test/test_table.h
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / dpdk / app / test / test_table.h
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
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
16 * distribution.
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.
20 *
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.
32 */
33
34 #include <rte_table_stub.h>
35 #include <rte_table_lpm.h>
36 #include <rte_table_lpm_ipv6.h>
37 #include <rte_table_hash.h>
38 #include <rte_table_array.h>
39 #include <rte_pipeline.h>
40
41 #ifdef RTE_LIBRTE_ACL
42 #include <rte_table_acl.h>
43 #endif
44
45 #include <rte_port_ring.h>
46 #include <rte_port_ethdev.h>
47 #include <rte_port_source_sink.h>
48
49 #ifndef TEST_TABLE_H_
50 #define TEST_TABLE_H_
51
52 #define RING_SIZE 4096
53 #define MAX_BULK 32
54 #define N 65536
55 #define TIME_S 5
56 #define TEST_RING_FULL_EMTPY_ITER 8
57 #define N_PORTS 2
58 #define N_PKTS 2
59 #define N_PKTS_EXT 6
60 #define RING_RX rings_rx[0]
61 #define RING_RX_2 rings_rx[1]
62 #define RING_TX rings_tx[0]
63 #define RING_TX_2 rings_tx[1]
64 #define PORT_RX_RING_SIZE 128
65 #define PORT_TX_RING_SIZE 512
66 #define RING_RX_SIZE 128
67 #define RING_TX_SIZE 128
68 #define POOL_BUFFER_SIZE RTE_MBUF_DEFAULT_BUF_SIZE
69 #define POOL_SIZE (32 * 1024)
70 #define POOL_CACHE_SIZE 256
71 #define BURST_SIZE 8
72 #define WORKER_TYPE 1
73 #define MAX_DUMMY_PORTS 2
74 #define MP_NAME "dummy_port_mempool"
75 #define MBUF_COUNT (8000 * MAX_DUMMY_PORTS)
76 #define MP_CACHE_SZ 256
77 #define MP_SOCKET 0
78 #define MP_FLAGS 0
79
80 /* Macros */
81 #define APP_METADATA_OFFSET(offset) (sizeof(struct rte_mbuf) + (offset))
82
83 #define RING_ENQUEUE(ring, value) do { \
84 struct rte_mbuf *m; \
85 uint32_t *k32, *signature; \
86 uint8_t *key; \
87 \
88 m = rte_pktmbuf_alloc(pool); \
89 if (m == NULL) \
90 return -1; \
91 signature = RTE_MBUF_METADATA_UINT32_PTR(m, \
92 APP_METADATA_OFFSET(0)); \
93 key = RTE_MBUF_METADATA_UINT8_PTR(m, \
94 APP_METADATA_OFFSET(32)); \
95 k32 = (uint32_t *) key; \
96 k32[0] = (value); \
97 *signature = pipeline_test_hash(key, 0, 0); \
98 rte_ring_enqueue((ring), m); \
99 } while (0)
100
101 #define RUN_PIPELINE(pipeline) do { \
102 rte_pipeline_run((pipeline)); \
103 rte_pipeline_flush((pipeline)); \
104 } while (0)
105
106 #define VERIFY(var, value) do { \
107 if ((var) != -(value)) \
108 return var; \
109 } while (0)
110
111 #define VERIFY_TRAFFIC(ring, sent, expected) do { \
112 unsigned i, n = 0; \
113 void *mbuf = NULL; \
114 \
115 for (i = 0; i < (sent); i++) { \
116 if (!rte_ring_dequeue((ring), &mbuf)) { \
117 if (mbuf == NULL) \
118 continue; \
119 n++; \
120 rte_pktmbuf_free((struct rte_mbuf *)mbuf); \
121 } \
122 else \
123 break; \
124 } \
125 printf("Expected %d, got %d\n", expected, n); \
126 if (n != (expected)) { \
127 return -21; \
128 } \
129 } while (0)
130
131 /* Function definitions */
132 uint64_t pipeline_test_hash(
133 void *key,
134 __attribute__((unused)) uint32_t key_size,
135 __attribute__((unused)) uint64_t seed);
136
137 /* Extern variables */
138 extern struct rte_pipeline *p;
139 extern struct rte_ring *rings_rx[N_PORTS];
140 extern struct rte_ring *rings_tx[N_PORTS];
141 extern struct rte_mempool *pool;
142 extern uint32_t port_in_id[N_PORTS];
143 extern uint32_t port_out_id[N_PORTS];
144 extern uint32_t port_out_id_type[3];
145 extern uint32_t table_id[N_PORTS*2];
146 extern uint64_t override_hit_mask;
147 extern uint64_t override_miss_mask;
148 extern uint64_t non_reserved_actions_hit;
149 extern uint64_t non_reserved_actions_miss;
150 extern uint8_t connect_miss_action_to_port_out;
151 extern uint8_t connect_miss_action_to_table;
152 extern uint32_t table_entry_default_action;
153 extern uint32_t table_entry_hit_action;
154 extern uint32_t table_entry_miss_action;
155 extern rte_pipeline_port_in_action_handler port_in_action;
156 extern rte_pipeline_port_out_action_handler port_out_action;
157 extern rte_pipeline_table_action_handler_hit action_handler_hit;
158 extern rte_pipeline_table_action_handler_miss action_handler_miss;
159
160 /* Global data types */
161 struct manage_ops {
162 uint32_t op_id;
163 void *op_data;
164 int expected_result;
165 };
166
167 /* Internal pipeline structures */
168 struct rte_port_in {
169 struct rte_port_in_ops ops;
170 uint32_t burst_size;
171 uint32_t table_id;
172 void *h_port;
173 };
174
175 struct rte_port_out {
176 struct rte_port_out_ops ops;
177 void *h_port;
178 };
179
180 struct rte_table {
181 struct rte_table_ops ops;
182 rte_pipeline_table_action_handler_hit f_action;
183 uint32_t table_next_id;
184 uint32_t table_next_id_valid;
185 uint8_t actions_lookup_miss[RTE_CACHE_LINE_SIZE];
186 uint32_t action_data_size;
187 void *h_table;
188 };
189
190 #define RTE_PIPELINE_MAX_NAME_SZ 124
191
192 struct rte_pipeline {
193 char name[RTE_PIPELINE_MAX_NAME_SZ];
194 uint32_t socket_id;
195 struct rte_port_in ports_in[16];
196 struct rte_port_out ports_out[16];
197 struct rte_table tables[64];
198 uint32_t num_ports_in;
199 uint32_t num_ports_out;
200 uint32_t num_tables;
201 struct rte_mbuf *pkts[RTE_PORT_IN_BURST_SIZE_MAX];
202 struct rte_table_entry *actions[RTE_PORT_IN_BURST_SIZE_MAX];
203 uint64_t mask_action[64];
204 uint32_t mask_actions;
205 };
206 #endif