1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
9 #ifndef APP_MAX_SOCKETS
10 #define APP_MAX_SOCKETS 2
13 #ifndef APP_MAX_LCORES
14 #define APP_MAX_LCORES RTE_MAX_LCORE
17 #ifndef APP_MAX_NIC_PORTS
18 #define APP_MAX_NIC_PORTS RTE_MAX_ETHPORTS
21 #ifndef APP_MAX_RX_QUEUES_PER_NIC_PORT
22 #define APP_MAX_RX_QUEUES_PER_NIC_PORT 128
25 #ifndef APP_MAX_TX_QUEUES_PER_NIC_PORT
26 #define APP_MAX_TX_QUEUES_PER_NIC_PORT 128
29 #ifndef APP_MAX_IO_LCORES
30 #if (APP_MAX_LCORES > 16)
31 #define APP_MAX_IO_LCORES 16
33 #define APP_MAX_IO_LCORES APP_MAX_LCORES
36 #if (APP_MAX_IO_LCORES > APP_MAX_LCORES)
37 #error "APP_MAX_IO_LCORES is too big"
40 #ifndef APP_MAX_NIC_RX_QUEUES_PER_IO_LCORE
41 #define APP_MAX_NIC_RX_QUEUES_PER_IO_LCORE 16
44 #ifndef APP_MAX_NIC_TX_PORTS_PER_IO_LCORE
45 #define APP_MAX_NIC_TX_PORTS_PER_IO_LCORE 16
47 #if (APP_MAX_NIC_TX_PORTS_PER_IO_LCORE > APP_MAX_NIC_PORTS)
48 #error "APP_MAX_NIC_TX_PORTS_PER_IO_LCORE too big"
51 #ifndef APP_MAX_WORKER_LCORES
52 #if (APP_MAX_LCORES > 16)
53 #define APP_MAX_WORKER_LCORES 16
55 #define APP_MAX_WORKER_LCORES APP_MAX_LCORES
58 #if (APP_MAX_WORKER_LCORES > APP_MAX_LCORES)
59 #error "APP_MAX_WORKER_LCORES is too big"
64 #ifndef APP_DEFAULT_MBUF_DATA_SIZE
65 #define APP_DEFAULT_MBUF_DATA_SIZE RTE_MBUF_DEFAULT_BUF_SIZE
68 #ifndef APP_DEFAULT_MEMPOOL_BUFFERS
69 #define APP_DEFAULT_MEMPOOL_BUFFERS 8192 * 4
72 #ifndef APP_DEFAULT_MEMPOOL_CACHE_SIZE
73 #define APP_DEFAULT_MEMPOOL_CACHE_SIZE 256
77 #ifndef APP_MAX_LPM_RULES
78 #define APP_MAX_LPM_RULES 1024
82 #ifndef APP_DEFAULT_NIC_RX_RING_SIZE
83 #define APP_DEFAULT_NIC_RX_RING_SIZE 1024
87 * RX and TX Prefetch, Host, and Write-back threshold values should be
88 * carefully set for optimal performance. Consult the network
89 * controller's datasheet and supporting DPDK documentation for guidance
90 * on how these parameters should be set.
92 #ifndef APP_DEFAULT_NIC_RX_PTHRESH
93 #define APP_DEFAULT_NIC_RX_PTHRESH 8
96 #ifndef APP_DEFAULT_NIC_RX_HTHRESH
97 #define APP_DEFAULT_NIC_RX_HTHRESH 8
100 #ifndef APP_DEFAULT_NIC_RX_WTHRESH
101 #define APP_DEFAULT_NIC_RX_WTHRESH 4
104 #ifndef APP_DEFAULT_NIC_RX_FREE_THRESH
105 #define APP_DEFAULT_NIC_RX_FREE_THRESH 64
108 #ifndef APP_DEFAULT_NIC_RX_DROP_EN
109 #define APP_DEFAULT_NIC_RX_DROP_EN 0
113 #ifndef APP_DEFAULT_NIC_TX_RING_SIZE
114 #define APP_DEFAULT_NIC_TX_RING_SIZE 1024
118 * These default values are optimized for use with the Intel(R) 82599 10 GbE
119 * Controller and the DPDK ixgbe PMD. Consider using other values for other
120 * network controllers and/or network drivers.
122 #ifndef APP_DEFAULT_NIC_TX_PTHRESH
123 #define APP_DEFAULT_NIC_TX_PTHRESH 36
126 #ifndef APP_DEFAULT_NIC_TX_HTHRESH
127 #define APP_DEFAULT_NIC_TX_HTHRESH 0
130 #ifndef APP_DEFAULT_NIC_TX_WTHRESH
131 #define APP_DEFAULT_NIC_TX_WTHRESH 0
134 #ifndef APP_DEFAULT_NIC_TX_FREE_THRESH
135 #define APP_DEFAULT_NIC_TX_FREE_THRESH 0
138 #ifndef APP_DEFAULT_NIC_TX_RS_THRESH
139 #define APP_DEFAULT_NIC_TX_RS_THRESH 0
143 #ifndef APP_DEFAULT_RING_RX_SIZE
144 #define APP_DEFAULT_RING_RX_SIZE 1024
147 #ifndef APP_DEFAULT_RING_TX_SIZE
148 #define APP_DEFAULT_RING_TX_SIZE 1024
152 #ifndef APP_MBUF_ARRAY_SIZE
153 #define APP_MBUF_ARRAY_SIZE 512
156 #ifndef APP_DEFAULT_BURST_SIZE_IO_RX_READ
157 #define APP_DEFAULT_BURST_SIZE_IO_RX_READ 144
159 #if (APP_DEFAULT_BURST_SIZE_IO_RX_READ > APP_MBUF_ARRAY_SIZE)
160 #error "APP_DEFAULT_BURST_SIZE_IO_RX_READ is too big"
163 #ifndef APP_DEFAULT_BURST_SIZE_IO_RX_WRITE
164 #define APP_DEFAULT_BURST_SIZE_IO_RX_WRITE 144
166 #if (APP_DEFAULT_BURST_SIZE_IO_RX_WRITE > APP_MBUF_ARRAY_SIZE)
167 #error "APP_DEFAULT_BURST_SIZE_IO_RX_WRITE is too big"
170 #ifndef APP_DEFAULT_BURST_SIZE_IO_TX_READ
171 #define APP_DEFAULT_BURST_SIZE_IO_TX_READ 144
173 #if (APP_DEFAULT_BURST_SIZE_IO_TX_READ > APP_MBUF_ARRAY_SIZE)
174 #error "APP_DEFAULT_BURST_SIZE_IO_TX_READ is too big"
177 #ifndef APP_DEFAULT_BURST_SIZE_IO_TX_WRITE
178 #define APP_DEFAULT_BURST_SIZE_IO_TX_WRITE 144
180 #if (APP_DEFAULT_BURST_SIZE_IO_TX_WRITE > APP_MBUF_ARRAY_SIZE)
181 #error "APP_DEFAULT_BURST_SIZE_IO_TX_WRITE is too big"
184 #ifndef APP_DEFAULT_BURST_SIZE_WORKER_READ
185 #define APP_DEFAULT_BURST_SIZE_WORKER_READ 144
187 #if ((2 * APP_DEFAULT_BURST_SIZE_WORKER_READ) > APP_MBUF_ARRAY_SIZE)
188 #error "APP_DEFAULT_BURST_SIZE_WORKER_READ is too big"
191 #ifndef APP_DEFAULT_BURST_SIZE_WORKER_WRITE
192 #define APP_DEFAULT_BURST_SIZE_WORKER_WRITE 144
194 #if (APP_DEFAULT_BURST_SIZE_WORKER_WRITE > APP_MBUF_ARRAY_SIZE)
195 #error "APP_DEFAULT_BURST_SIZE_WORKER_WRITE is too big"
198 /* Load balancing logic */
199 #ifndef APP_DEFAULT_IO_RX_LB_POS
200 #define APP_DEFAULT_IO_RX_LB_POS 29
202 #if (APP_DEFAULT_IO_RX_LB_POS >= 64)
203 #error "APP_DEFAULT_IO_RX_LB_POS is too big"
206 struct app_mbuf_array {
207 struct rte_mbuf *array[APP_MBUF_ARRAY_SIZE];
211 enum app_lcore_type {
212 e_APP_LCORE_DISABLED = 0,
217 struct app_lcore_params_io {
224 } nic_queues[APP_MAX_NIC_RX_QUEUES_PER_IO_LCORE];
225 uint32_t n_nic_queues;
228 struct rte_ring *rings[APP_MAX_WORKER_LCORES];
231 /* Internal buffers */
232 struct app_mbuf_array mbuf_in;
233 struct app_mbuf_array mbuf_out[APP_MAX_WORKER_LCORES];
234 uint8_t mbuf_out_flush[APP_MAX_WORKER_LCORES];
237 uint32_t nic_queues_count[APP_MAX_NIC_RX_QUEUES_PER_IO_LCORE];
238 uint32_t nic_queues_iters[APP_MAX_NIC_RX_QUEUES_PER_IO_LCORE];
239 uint32_t rings_count[APP_MAX_WORKER_LCORES];
240 uint32_t rings_iters[APP_MAX_WORKER_LCORES];
246 struct rte_ring *rings[APP_MAX_NIC_PORTS][APP_MAX_WORKER_LCORES];
249 uint16_t nic_ports[APP_MAX_NIC_TX_PORTS_PER_IO_LCORE];
250 uint32_t n_nic_ports;
252 /* Internal buffers */
253 struct app_mbuf_array mbuf_out[APP_MAX_NIC_TX_PORTS_PER_IO_LCORE];
254 uint8_t mbuf_out_flush[APP_MAX_NIC_TX_PORTS_PER_IO_LCORE];
257 uint32_t rings_count[APP_MAX_NIC_PORTS][APP_MAX_WORKER_LCORES];
258 uint32_t rings_iters[APP_MAX_NIC_PORTS][APP_MAX_WORKER_LCORES];
259 uint32_t nic_ports_count[APP_MAX_NIC_TX_PORTS_PER_IO_LCORE];
260 uint32_t nic_ports_iters[APP_MAX_NIC_TX_PORTS_PER_IO_LCORE];
264 struct app_lcore_params_worker {
266 struct rte_ring *rings_in[APP_MAX_IO_LCORES];
268 struct rte_ring *rings_out[APP_MAX_NIC_PORTS];
271 struct rte_lpm *lpm_table;
274 /* Internal buffers */
275 struct app_mbuf_array mbuf_in;
276 struct app_mbuf_array mbuf_out[APP_MAX_NIC_PORTS];
277 uint8_t mbuf_out_flush[APP_MAX_NIC_PORTS];
280 uint32_t rings_in_count[APP_MAX_IO_LCORES];
281 uint32_t rings_in_iters[APP_MAX_IO_LCORES];
282 uint32_t rings_out_count[APP_MAX_NIC_PORTS];
283 uint32_t rings_out_iters[APP_MAX_NIC_PORTS];
286 struct app_lcore_params {
288 struct app_lcore_params_io io;
289 struct app_lcore_params_worker worker;
291 enum app_lcore_type type;
292 struct rte_mempool *pool;
293 } __rte_cache_aligned;
295 struct app_lpm_rule {
303 struct app_lcore_params lcore_params[APP_MAX_LCORES];
306 uint8_t nic_rx_queue_mask[APP_MAX_NIC_PORTS][APP_MAX_RX_QUEUES_PER_NIC_PORT];
307 uint8_t nic_tx_port_mask[APP_MAX_NIC_PORTS];
310 struct rte_mempool *pools[APP_MAX_SOCKETS];
313 struct rte_lpm *lpm_tables[APP_MAX_SOCKETS];
314 struct app_lpm_rule lpm_rules[APP_MAX_LPM_RULES];
315 uint32_t n_lpm_rules;
318 uint32_t nic_rx_ring_size;
319 uint32_t nic_tx_ring_size;
320 uint32_t ring_rx_size;
321 uint32_t ring_tx_size;
324 uint32_t burst_size_io_rx_read;
325 uint32_t burst_size_io_rx_write;
326 uint32_t burst_size_io_tx_read;
327 uint32_t burst_size_io_tx_write;
328 uint32_t burst_size_worker_read;
329 uint32_t burst_size_worker_write;
333 } __rte_cache_aligned;
335 extern struct app_params app;
337 int app_parse_args(int argc, char **argv);
338 void app_print_usage(void);
340 int app_lcore_main_loop(void *arg);
342 int app_get_nic_rx_queues_per_port(uint16_t port);
343 int app_get_lcore_for_nic_rx(uint16_t port, uint8_t queue,
344 uint32_t *lcore_out);
345 int app_get_lcore_for_nic_tx(uint16_t port, uint32_t *lcore_out);
346 int app_is_socket_used(uint32_t socket);
347 uint32_t app_get_lcores_io_rx(void);
348 uint32_t app_get_lcores_worker(void);
349 void app_print_params(void);
351 #endif /* _MAIN_H_ */