Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2017 Intel Corporation
3 : : */
4 : :
5 : : #ifndef _TESTPMD_H_
6 : : #define _TESTPMD_H_
7 : :
8 : : #include <stdbool.h>
9 : :
10 : : #ifdef RTE_LIB_GRO
11 : : #include <rte_gro.h>
12 : : #endif
13 : : #ifdef RTE_LIB_GSO
14 : : #include <rte_gso.h>
15 : : #endif
16 : : #include <rte_os_shim.h>
17 : : #include <rte_ethdev.h>
18 : : #include <rte_flow.h>
19 : : #include <rte_mbuf_dyn.h>
20 : :
21 : : #include <cmdline.h>
22 : : #include <cmdline_parse.h>
23 : :
24 : : #include <sys/queue.h>
25 : : #ifdef RTE_HAS_JANSSON
26 : : #include <jansson.h>
27 : : #endif
28 : :
29 : : #define RTE_PORT_ALL (~(portid_t)0x0)
30 : :
31 : : #define RTE_PORT_STOPPED (uint16_t)0
32 : : #define RTE_PORT_STARTED (uint16_t)1
33 : : #define RTE_PORT_CLOSED (uint16_t)2
34 : : #define RTE_PORT_HANDLING (uint16_t)3
35 : :
36 : : extern uint8_t cl_quit;
37 : : extern volatile uint8_t f_quit;
38 : :
39 : : /*
40 : : * It is used to allocate the memory for hash key.
41 : : * The hash key size is NIC dependent.
42 : : */
43 : : #define RSS_HASH_KEY_LENGTH 64
44 : :
45 : : /*
46 : : * Default size of the mbuf data buffer to receive standard 1518-byte
47 : : * Ethernet frames in a mono-segment memory buffer.
48 : : */
49 : : #define DEFAULT_MBUF_DATA_SIZE RTE_MBUF_DEFAULT_BUF_SIZE
50 : : /**< Default size of mbuf data buffer. */
51 : :
52 : : /*
53 : : * The maximum number of segments per packet is used when creating
54 : : * scattered transmit packets composed of a list of mbufs.
55 : : */
56 : : #define RTE_MAX_SEGS_PER_PKT 255 /**< nb_segs is a 8-bit unsigned char. */
57 : :
58 : : /*
59 : : * The maximum number of segments per packet is used to configure
60 : : * buffer split feature, also specifies the maximum amount of
61 : : * optional Rx pools to allocate mbufs to split.
62 : : */
63 : : #define MAX_SEGS_BUFFER_SPLIT 8 /**< nb_segs is a 8-bit unsigned char. */
64 : :
65 : : /* The prefix of the mbuf pool names created by the application. */
66 : : #define MBUF_POOL_NAME_PFX "mb_pool"
67 : :
68 : : #define RX_DESC_MAX 2048
69 : : #define TX_DESC_MAX 2048
70 : :
71 : : #define MAX_PKT_BURST 512
72 : : #define DEF_PKT_BURST 32
73 : :
74 : : #define DEF_MBUF_CACHE 250
75 : :
76 : : #define RTE_CACHE_LINE_SIZE_ROUNDUP(size) \
77 : : (RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / RTE_CACHE_LINE_SIZE))
78 : :
79 : : #define NUMA_NO_CONFIG 0xFF
80 : : #define UMA_NO_CONFIG 0xFF
81 : :
82 : : #define MIN_TOTAL_NUM_MBUFS 1024
83 : :
84 : : /* Maximum number of pools supported per Rx queue */
85 : : #define MAX_MEMPOOL 8
86 : :
87 : : typedef uint32_t lcoreid_t;
88 : : typedef uint16_t portid_t;
89 : : typedef uint16_t queueid_t;
90 : : typedef uint16_t streamid_t;
91 : :
92 : : enum {
93 : : PORT_TOPOLOGY_PAIRED,
94 : : PORT_TOPOLOGY_CHAINED,
95 : : PORT_TOPOLOGY_LOOP,
96 : : };
97 : :
98 : : enum {
99 : : MP_ALLOC_NATIVE, /**< allocate and populate mempool natively */
100 : : MP_ALLOC_ANON,
101 : : /**< allocate mempool natively, but populate using anonymous memory */
102 : : MP_ALLOC_XMEM,
103 : : /**< allocate and populate mempool using anonymous memory */
104 : : MP_ALLOC_XMEM_HUGE,
105 : : /**< allocate and populate mempool using anonymous hugepage memory */
106 : : MP_ALLOC_XBUF
107 : : /**< allocate mempool natively, use rte_pktmbuf_pool_create_extbuf */
108 : : };
109 : :
110 : : enum {
111 : : QUEUE_JOB_TYPE_FLOW_CREATE,
112 : : QUEUE_JOB_TYPE_FLOW_DESTROY,
113 : : QUEUE_JOB_TYPE_FLOW_TRANSFER,
114 : : QUEUE_JOB_TYPE_FLOW_UPDATE,
115 : : QUEUE_JOB_TYPE_ACTION_CREATE,
116 : : QUEUE_JOB_TYPE_ACTION_DESTROY,
117 : : QUEUE_JOB_TYPE_ACTION_UPDATE,
118 : : QUEUE_JOB_TYPE_ACTION_QUERY,
119 : : };
120 : :
121 : : enum noisy_fwd_mode {
122 : : NOISY_FWD_MODE_IO,
123 : : NOISY_FWD_MODE_MAC,
124 : : NOISY_FWD_MODE_MACSWAP,
125 : : NOISY_FWD_MODE_5TSWAP,
126 : : NOISY_FWD_MODE_MAX,
127 : : };
128 : :
129 : : /**
130 : : * Command line arguments parser sets `hairpin_multiport_mode` to True
131 : : * if explicit hairpin map configuration mode was used.
132 : : */
133 : : extern bool hairpin_multiport_mode;
134 : :
135 : : /** Hairpin maps list. */
136 : : struct hairpin_map;
137 : : extern void hairpin_add_multiport_map(struct hairpin_map *map);
138 : :
139 : : /**
140 : : * The data structure associated with RX and TX packet burst statistics
141 : : * that are recorded for each forwarding stream.
142 : : */
143 : : struct pkt_burst_stats {
144 : : unsigned int pkt_burst_spread[MAX_PKT_BURST + 1];
145 : : };
146 : :
147 : :
148 : : #define TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE 64
149 : : /** Information for a given RSS type. */
150 : : struct rss_type_info {
151 : : const char *str; /**< Type name. */
152 : : uint64_t rss_type; /**< Type value. */
153 : : };
154 : :
155 : : /**
156 : : * RSS type information table.
157 : : *
158 : : * An entry with a NULL type name terminates the list.
159 : : */
160 : : extern const struct rss_type_info rss_type_table[];
161 : :
162 : : /**
163 : : * Dynf name array.
164 : : *
165 : : * Array that holds the name for each dynf.
166 : : */
167 : : extern char dynf_names[64][RTE_MBUF_DYN_NAMESIZE];
168 : :
169 : : /**
170 : : * The data structure associated with a forwarding stream between a receive
171 : : * port/queue and a transmit port/queue.
172 : : */
173 : : struct fwd_stream {
174 : : /* "read-only" data */
175 : : portid_t rx_port; /**< port to poll for received packets */
176 : : queueid_t rx_queue; /**< RX queue to poll on "rx_port" */
177 : : portid_t tx_port; /**< forwarding port of received packets */
178 : : queueid_t tx_queue; /**< TX queue to send forwarded packets */
179 : : streamid_t peer_addr; /**< index of peer ethernet address of packets */
180 : : bool disabled; /**< the stream is disabled and should not run */
181 : :
182 : : unsigned int retry_enabled;
183 : :
184 : : /* "read-write" results */
185 : : uint64_t rx_packets; /**< received packets */
186 : : uint64_t tx_packets; /**< received packets transmitted */
187 : : uint64_t fwd_dropped; /**< received packets not forwarded */
188 : : uint64_t rx_bad_ip_csum ; /**< received packets has bad ip checksum */
189 : : uint64_t rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
190 : : uint64_t rx_bad_outer_l4_csum;
191 : : /**< received packets has bad outer l4 checksum */
192 : : uint64_t rx_bad_outer_ip_csum;
193 : : /**< received packets having bad outer ip checksum */
194 : : uint64_t ts_skew; /**< TX scheduling timestamp */
195 : : #ifdef RTE_LIB_GRO
196 : : unsigned int gro_times; /**< GRO operation times */
197 : : #endif
198 : : uint64_t busy_cycles; /**< used with --record-core-cycles */
199 : : struct pkt_burst_stats rx_burst_stats;
200 : : struct pkt_burst_stats tx_burst_stats;
201 : : struct fwd_lcore *lcore; /**< Lcore being scheduled. */
202 : : /**< Rx queue information for recycling mbufs */
203 : : struct rte_eth_recycle_rxq_info recycle_rxq_info;
204 : : };
205 : :
206 : : /**
207 : : * Age action context types, must be included inside the age action
208 : : * context structure.
209 : : */
210 : : enum age_action_context_type {
211 : : ACTION_AGE_CONTEXT_TYPE_FLOW,
212 : : ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION,
213 : : };
214 : :
215 : : /** Descriptor for a template. */
216 : : struct port_template {
217 : : struct port_template *next; /**< Next template in list. */
218 : : struct port_template *tmp; /**< Temporary linking. */
219 : : uint32_t id; /**< Template ID. */
220 : : union {
221 : : struct rte_flow_pattern_template *pattern_template;
222 : : struct rte_flow_actions_template *actions_template;
223 : : } template; /**< PMD opaque template object */
224 : : };
225 : :
226 : : /** Descriptor for a flow table. */
227 : : struct port_table {
228 : : struct port_table *next; /**< Next table in list. */
229 : : struct port_table *tmp; /**< Temporary linking. */
230 : : uint32_t id; /**< Table ID. */
231 : : uint32_t nb_pattern_templates; /**< Number of pattern templates. */
232 : : uint32_t nb_actions_templates; /**< Number of actions templates. */
233 : : struct rte_flow_template_table_attr attr; /**< Table attributes. */
234 : : struct rte_flow_template_table *table; /**< PMD opaque template object */
235 : : };
236 : :
237 : : /** Descriptor for a single flow. */
238 : : struct port_flow {
239 : : struct port_flow *next; /**< Next flow in list. */
240 : : struct port_flow *tmp; /**< Temporary linking. */
241 : : uint64_t id; /**< Flow rule ID. */
242 : : uint64_t user_id; /**< User rule ID. */
243 : : struct port_table *table; /**< Flow table. */
244 : : struct rte_flow *flow; /**< Opaque flow object returned by PMD. */
245 : : struct rte_flow_conv_rule rule; /**< Saved flow rule description. */
246 : : enum age_action_context_type age_type; /**< Age action context type. */
247 : : uint8_t data[]; /**< Storage for flow rule description */
248 : : };
249 : :
250 : : /* Descriptor for indirect action */
251 : : struct port_indirect_action {
252 : : struct port_indirect_action *next; /**< Next flow in list. */
253 : : uint32_t id; /**< Indirect action ID. */
254 : : enum rte_flow_action_type type; /**< Action type. */
255 : : union {
256 : : struct rte_flow_action_handle *handle;
257 : : /**< Indirect action handle. */
258 : : struct rte_flow_action_list_handle *list_handle;
259 : : /**< Indirect action list handle*/
260 : : };
261 : : enum age_action_context_type age_type; /**< Age action context type. */
262 : : };
263 : :
264 : : /* Descriptor for action query data. */
265 : : union port_action_query {
266 : : struct rte_flow_query_count count;
267 : : struct rte_flow_query_age age;
268 : : struct rte_flow_action_conntrack ct;
269 : : struct rte_flow_query_quota quota;
270 : : };
271 : :
272 : : /* Descriptor for queue job. */
273 : : struct queue_job {
274 : : uint32_t type; /**< Job type. */
275 : : union {
276 : : struct port_flow *pf;
277 : : struct port_indirect_action *pia;
278 : : };
279 : : union port_action_query query;
280 : : };
281 : :
282 : : struct port_flow_tunnel {
283 : : LIST_ENTRY(port_flow_tunnel) chain;
284 : : struct rte_flow_action *pmd_actions;
285 : : struct rte_flow_item *pmd_items;
286 : : uint32_t id;
287 : : uint32_t num_pmd_actions;
288 : : uint32_t num_pmd_items;
289 : : struct rte_flow_tunnel tunnel;
290 : : struct rte_flow_action *actions;
291 : : struct rte_flow_item *items;
292 : : };
293 : :
294 : : struct tunnel_ops {
295 : : uint32_t id;
296 : : char type[16];
297 : : uint32_t enabled:1;
298 : : uint32_t actions:1;
299 : : uint32_t items:1;
300 : : };
301 : :
302 : : /** Information for an extended statistics to show. */
303 : : struct xstat_display_info {
304 : : /** Supported xstats IDs in the order of xstats_display */
305 : : uint64_t *ids_supp;
306 : : size_t ids_supp_sz;
307 : : uint64_t *prev_values;
308 : : uint64_t *curr_values;
309 : : uint64_t prev_ns;
310 : : bool allocated;
311 : : };
312 : :
313 : : /** RX queue configuration and state. */
314 : : struct port_rxqueue {
315 : : struct rte_eth_rxconf conf;
316 : : uint8_t state; /**< RTE_ETH_QUEUE_STATE_* value. */
317 : : };
318 : :
319 : : /** TX queue configuration and state. */
320 : : struct port_txqueue {
321 : : struct rte_eth_txconf conf;
322 : : uint8_t state; /**< RTE_ETH_QUEUE_STATE_* value. */
323 : : };
324 : :
325 : : /**
326 : : * The data structure associated with each port.
327 : : */
328 : : struct rte_port {
329 : : struct rte_eth_dev_info dev_info; /**< Device info + driver name */
330 : : struct rte_eth_conf dev_conf; /**< Port configuration. */
331 : : struct rte_ether_addr eth_addr; /**< Port ethernet address */
332 : : struct rte_eth_stats stats; /**< Last port statistics */
333 : : unsigned int socket_id; /**< For NUMA support */
334 : : uint16_t parse_tunnel:1; /**< Parse internal headers */
335 : : uint16_t tso_segsz; /**< Segmentation offload MSS for non-tunneled packets. */
336 : : uint16_t tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */
337 : : uint16_t tx_vlan_id;/**< The tag ID */
338 : : uint16_t tx_vlan_id_outer;/**< The outer tag ID */
339 : : volatile uint16_t port_status; /**< port started or not */
340 : : uint8_t need_setup; /**< port just attached */
341 : : uint8_t need_reconfig; /**< need reconfiguring port or not */
342 : : uint8_t need_reconfig_queues; /**< need reconfiguring queues or not */
343 : : uint8_t rss_flag; /**< enable rss or not */
344 : : uint8_t dcb_flag; /**< enable dcb */
345 : : uint16_t nb_rx_desc[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue rx desc number */
346 : : uint16_t nb_tx_desc[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue tx desc number */
347 : : struct port_rxqueue rxq[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue Rx config and state */
348 : : struct port_txqueue txq[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue Tx config and state */
349 : : struct rte_ether_addr *mc_addr_pool; /**< pool of multicast addrs */
350 : : uint32_t mc_addr_nb; /**< nb. of addr. in mc_addr_pool */
351 : : queueid_t queue_nb; /**< nb. of queues for flow rules */
352 : : uint32_t queue_sz; /**< size of a queue for flow rules */
353 : : uint8_t member_flag : 1, /**< bonding member port */
354 : : bond_flag : 1, /**< port is bond device */
355 : : fwd_mac_swap : 1, /**< swap packet MAC before forward */
356 : : update_conf : 1; /**< need to update bonding device configuration */
357 : : struct port_template *pattern_templ_list; /**< Pattern templates. */
358 : : struct port_template *actions_templ_list; /**< Actions templates. */
359 : : struct port_table *table_list; /**< Flow tables. */
360 : : struct port_flow *flow_list; /**< Associated flows. */
361 : : struct port_indirect_action *actions_list;
362 : : /**< Associated indirect actions. */
363 : : LIST_HEAD(, port_flow_tunnel) flow_tunnel_list;
364 : : const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1];
365 : : const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1];
366 : : /**< metadata value to insert in Tx packets. */
367 : : uint32_t tx_metadata;
368 : : const struct rte_eth_rxtx_callback *tx_set_md_cb[RTE_MAX_QUEUES_PER_PORT+1];
369 : : /**< dynamic flags. */
370 : : uint64_t mbuf_dynf;
371 : : const struct rte_eth_rxtx_callback *tx_set_dynf_cb[RTE_MAX_QUEUES_PER_PORT+1];
372 : : struct xstat_display_info xstats_info;
373 : : };
374 : :
375 : : /**
376 : : * The data structure associated with each forwarding logical core.
377 : : * The logical cores are internally numbered by a core index from 0 to
378 : : * the maximum number of logical cores - 1.
379 : : * The system CPU identifier of all logical cores are setup in a global
380 : : * CPU id. configuration table.
381 : : */
382 : : struct fwd_lcore {
383 : : #ifdef RTE_LIB_GSO
384 : : struct rte_gso_ctx gso_ctx; /**< GSO context */
385 : : #endif
386 : : struct rte_mempool *mbp; /**< The mbuf pool to use by this core */
387 : : #ifdef RTE_LIB_GRO
388 : : void *gro_ctx; /**< GRO context */
389 : : #endif
390 : : streamid_t stream_idx; /**< index of 1st stream in "fwd_streams" */
391 : : streamid_t stream_nb; /**< number of streams in "fwd_streams" */
392 : : lcoreid_t cpuid_idx; /**< index of logical core in CPU id table */
393 : : volatile char stopped; /**< stop forwarding when set */
394 : : uint64_t total_cycles; /**< used with --record-core-cycles */
395 : : };
396 : :
397 : : /*
398 : : * Forwarding mode operations:
399 : : * - IO forwarding mode (default mode)
400 : : * Forwards packets unchanged.
401 : : *
402 : : * - MAC forwarding mode
403 : : * Set the source and the destination Ethernet addresses of packets
404 : : * before forwarding them.
405 : : *
406 : : * - IEEE1588 forwarding mode
407 : : * Check that received IEEE1588 Precise Time Protocol (PTP) packets are
408 : : * filtered and timestamped by the hardware.
409 : : * Forwards packets unchanged on the same port.
410 : : * Check that sent IEEE1588 PTP packets are timestamped by the hardware.
411 : : */
412 : : typedef int (*port_fwd_begin_t)(portid_t pi);
413 : : typedef void (*port_fwd_end_t)(portid_t pi);
414 : : typedef void (*stream_init_t)(struct fwd_stream *fs);
415 : : typedef bool (*packet_fwd_t)(struct fwd_stream *fs);
416 : :
417 : : struct fwd_engine {
418 : : const char *fwd_mode_name; /**< Forwarding mode name. */
419 : : port_fwd_begin_t port_fwd_begin; /**< NULL if nothing special to do. */
420 : : port_fwd_end_t port_fwd_end; /**< NULL if nothing special to do. */
421 : : stream_init_t stream_init; /**< NULL if nothing special to do. */
422 : : packet_fwd_t packet_fwd; /**< Mandatory. */
423 : : const char *status; /**< NULL if nothing to display. */
424 : : };
425 : :
426 : : void common_fwd_stream_init(struct fwd_stream *fs);
427 : :
428 : : #define FLEX_ITEM_MAX_SAMPLES_NUM 16
429 : : #define FLEX_ITEM_MAX_LINKS_NUM 16
430 : : #define FLEX_MAX_FLOW_PATTERN_LENGTH 64
431 : : #define FLEX_MAX_PARSERS_NUM 8
432 : : #define FLEX_MAX_PATTERNS_NUM 64
433 : : #define FLEX_PARSER_ERR ((struct flex_item *)-1)
434 : :
435 : : struct flex_item {
436 : : struct rte_flow_item_flex_conf flex_conf;
437 : : struct rte_flow_item_flex_handle *flex_handle;
438 : : uint32_t flex_id;
439 : : };
440 : :
441 : : struct flex_pattern {
442 : : struct rte_flow_item_flex spec, mask;
443 : : uint8_t spec_pattern[FLEX_MAX_FLOW_PATTERN_LENGTH];
444 : : uint8_t mask_pattern[FLEX_MAX_FLOW_PATTERN_LENGTH];
445 : : };
446 : : extern struct flex_item *flex_items[RTE_MAX_ETHPORTS][FLEX_MAX_PARSERS_NUM];
447 : : extern struct flex_pattern flex_patterns[FLEX_MAX_PATTERNS_NUM];
448 : :
449 : : #define BURST_TX_WAIT_US 1
450 : : #define BURST_TX_RETRIES 64
451 : :
452 : : extern uint32_t burst_tx_delay_time;
453 : : extern uint32_t burst_tx_retry_num;
454 : :
455 : : extern struct fwd_engine io_fwd_engine;
456 : : extern struct fwd_engine mac_fwd_engine;
457 : : extern struct fwd_engine mac_swap_engine;
458 : : extern struct fwd_engine flow_gen_engine;
459 : : extern struct fwd_engine rx_only_engine;
460 : : extern struct fwd_engine tx_only_engine;
461 : : extern struct fwd_engine csum_fwd_engine;
462 : : extern struct fwd_engine icmp_echo_engine;
463 : : extern struct fwd_engine noisy_vnf_engine;
464 : : extern struct fwd_engine five_tuple_swap_fwd_engine;
465 : : extern struct fwd_engine recycle_mbufs_engine;
466 : : #ifdef RTE_LIBRTE_IEEE1588
467 : : extern struct fwd_engine ieee1588_fwd_engine;
468 : : #endif
469 : : extern struct fwd_engine shared_rxq_engine;
470 : :
471 : : extern struct fwd_engine * fwd_engines[]; /**< NULL terminated array. */
472 : : extern cmdline_parse_inst_t cmd_set_raw;
473 : : extern cmdline_parse_inst_t cmd_show_set_raw;
474 : : extern cmdline_parse_inst_t cmd_show_set_raw_all;
475 : : extern cmdline_parse_inst_t cmd_set_flex_is_pattern;
476 : : extern cmdline_parse_inst_t cmd_set_flex_spec_pattern;
477 : :
478 : : extern uint16_t mempool_flags;
479 : :
480 : : /**
481 : : * Forwarding Configuration
482 : : *
483 : : */
484 : : struct fwd_config {
485 : : struct fwd_engine *fwd_eng; /**< Packet forwarding mode. */
486 : : streamid_t nb_fwd_streams; /**< Nb. of forward streams to process. */
487 : : lcoreid_t nb_fwd_lcores; /**< Nb. of logical cores to launch. */
488 : : portid_t nb_fwd_ports; /**< Nb. of ports involved. */
489 : : };
490 : :
491 : : /**
492 : : * DCB mode enable
493 : : */
494 : : enum dcb_mode_enable
495 : : {
496 : : DCB_VT_ENABLED,
497 : : DCB_ENABLED
498 : : };
499 : :
500 : : extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */
501 : : extern uint8_t xstats_hide_disabled; /**< Hide disabled xstat for xstats display */
502 : : extern uint8_t xstats_show_state; /**< Show xstat state in xstats display */
503 : :
504 : : /* globals used for configuration */
505 : : extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */
506 : : extern uint8_t record_burst_stats; /**< Enables display of RX and TX bursts */
507 : : extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */
508 : : extern int testpmd_logtype; /**< Log type for testpmd logs */
509 : : extern uint8_t interactive;
510 : : extern uint8_t auto_start;
511 : : extern uint8_t tx_first;
512 : : extern char cmdline_filename[PATH_MAX]; /**< offline commands file */
513 : : extern uint8_t numa_support; /**< set by "--numa" parameter */
514 : : extern uint16_t port_topology; /**< set by "--port-topology" parameter */
515 : : extern uint8_t no_flush_rx; /**<set by "--no-flush-rx" parameter */
516 : : extern uint8_t flow_isolate_all; /**< set by "--flow-isolate-all */
517 : : extern uint8_t no_flow_flush; /**< set by "--disable-flow-flush" parameter */
518 : : extern uint8_t mp_alloc_type;
519 : : /**< set by "--mp-anon" or "--mp-alloc" parameter */
520 : : extern uint32_t eth_link_speed;
521 : : extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */
522 : : extern uint8_t no_device_start; /**<set by "--disable-device-start" parameter */
523 : : extern volatile int test_done; /* stop packet forwarding when set to 1. */
524 : : extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
525 : : extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
526 : : extern uint32_t event_print_mask;
527 : : /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */
528 : : extern bool setup_on_probe_event; /**< disabled by port setup-on iterator */
529 : : extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */
530 : : extern int do_mlockall; /**< set by "--mlockall" or "--no-mlockall" parameter */
531 : : extern uint8_t clear_ptypes; /**< disabled by set ptype cmd */
532 : :
533 : : /*
534 : : * Store specified sockets on which memory pool to be used by ports
535 : : * is allocated.
536 : : */
537 : : extern uint8_t port_numa[RTE_MAX_ETHPORTS];
538 : :
539 : : /*
540 : : * Store specified sockets on which RX ring to be used by ports
541 : : * is allocated.
542 : : */
543 : : extern uint8_t rxring_numa[RTE_MAX_ETHPORTS];
544 : :
545 : : /*
546 : : * Store specified sockets on which TX ring to be used by ports
547 : : * is allocated.
548 : : */
549 : : extern uint8_t txring_numa[RTE_MAX_ETHPORTS];
550 : :
551 : : extern uint8_t socket_num;
552 : :
553 : : /*
554 : : * Configuration of logical cores:
555 : : * nb_fwd_lcores <= nb_cfg_lcores <= nb_lcores
556 : : */
557 : : extern lcoreid_t nb_lcores; /**< Number of logical cores probed at init time. */
558 : : extern lcoreid_t nb_cfg_lcores; /**< Number of configured logical cores. */
559 : : extern lcoreid_t nb_fwd_lcores; /**< Number of forwarding logical cores. */
560 : : extern unsigned int fwd_lcores_cpuids[RTE_MAX_LCORE];
561 : : extern unsigned int num_sockets;
562 : : extern unsigned int socket_ids[RTE_MAX_NUMA_NODES];
563 : :
564 : : /*
565 : : * Configuration of Ethernet ports:
566 : : * nb_fwd_ports <= nb_cfg_ports <= nb_ports
567 : : */
568 : : extern portid_t nb_ports; /**< Number of ethernet ports probed at init time. */
569 : : extern portid_t nb_cfg_ports; /**< Number of configured ports. */
570 : : extern portid_t nb_fwd_ports; /**< Number of forwarding ports. */
571 : : extern portid_t fwd_ports_ids[RTE_MAX_ETHPORTS];
572 : : extern struct rte_port *ports;
573 : :
574 : : extern struct rte_eth_rxmode rx_mode;
575 : : extern struct rte_eth_txmode tx_mode;
576 : :
577 : : extern uint64_t rss_hf;
578 : :
579 : : extern queueid_t nb_hairpinq;
580 : : extern queueid_t nb_rxq;
581 : : extern queueid_t nb_txq;
582 : :
583 : : extern uint16_t nb_rxd;
584 : : extern uint16_t nb_txd;
585 : :
586 : : extern int16_t rx_free_thresh;
587 : : extern int8_t rx_drop_en;
588 : : extern int16_t tx_free_thresh;
589 : : extern int16_t tx_rs_thresh;
590 : :
591 : : extern enum noisy_fwd_mode noisy_fwd_mode;
592 : : extern const char * const noisy_fwd_mode_desc[];
593 : : extern uint16_t noisy_tx_sw_bufsz;
594 : : extern uint16_t noisy_tx_sw_buf_flush_time;
595 : : extern uint64_t noisy_lkup_mem_sz;
596 : : extern uint64_t noisy_lkup_num_writes;
597 : : extern uint64_t noisy_lkup_num_reads;
598 : : extern uint64_t noisy_lkup_num_reads_writes;
599 : :
600 : : extern uint8_t dcb_config;
601 : :
602 : : extern uint32_t mbuf_data_size_n;
603 : : extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT];
604 : : /**< Mbuf data space size. */
605 : : extern uint32_t param_total_num_mbufs;
606 : :
607 : : extern uint16_t stats_period;
608 : :
609 : : extern struct rte_eth_xstat_name *xstats_display;
610 : : extern unsigned int xstats_display_num;
611 : :
612 : : extern uint32_t hairpin_mode;
613 : :
614 : : #ifdef RTE_LIB_LATENCYSTATS
615 : : extern uint8_t latencystats_enabled;
616 : : extern lcoreid_t latencystats_lcore_id;
617 : : #endif
618 : :
619 : : #ifdef RTE_LIB_BITRATESTATS
620 : : extern lcoreid_t bitrate_lcore_id;
621 : : extern uint8_t bitrate_enabled;
622 : : #endif
623 : :
624 : : extern uint32_t max_rx_pkt_len;
625 : :
626 : : /*
627 : : * Configuration of packet segments used to scatter received packets
628 : : * if some of split features is configured.
629 : : */
630 : : extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
631 : : extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
632 : : extern uint8_t rx_pkt_nb_segs; /**< Number of segments to split */
633 : : extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
634 : : extern uint8_t rx_pkt_nb_offs; /**< Number of specified offsets */
635 : :
636 : : extern uint8_t multi_rx_mempool; /**< Enables multi-rx-mempool feature. */
637 : :
638 : : /*
639 : : * Configuration of packet segments used by the "txonly" processing engine.
640 : : */
641 : : #define TXONLY_DEF_PACKET_LEN 64
642 : : extern uint16_t tx_pkt_length; /**< Length of TXONLY packet */
643 : : extern uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT]; /**< Seg. lengths */
644 : : extern uint8_t tx_pkt_nb_segs; /**< Number of segments in TX packets */
645 : : extern uint32_t tx_pkt_times_intra;
646 : : extern uint32_t tx_pkt_times_inter;
647 : :
648 : : enum tx_pkt_split {
649 : : TX_PKT_SPLIT_OFF,
650 : : TX_PKT_SPLIT_ON,
651 : : TX_PKT_SPLIT_RND,
652 : : };
653 : :
654 : : extern enum tx_pkt_split tx_pkt_split;
655 : :
656 : : extern uint8_t txonly_multi_flow;
657 : :
658 : : extern uint32_t rxq_share;
659 : :
660 : : extern uint16_t nb_pkt_per_burst;
661 : : extern uint16_t nb_pkt_flowgen_clones;
662 : : extern int nb_flows_flowgen;
663 : : extern uint16_t mb_mempool_cache;
664 : : extern int8_t rx_pthresh;
665 : : extern int8_t rx_hthresh;
666 : : extern int8_t rx_wthresh;
667 : : extern int8_t tx_pthresh;
668 : : extern int8_t tx_hthresh;
669 : : extern int8_t tx_wthresh;
670 : :
671 : : extern uint16_t tx_udp_src_port;
672 : : extern uint16_t tx_udp_dst_port;
673 : :
674 : : extern uint32_t tx_ip_src_addr;
675 : : extern uint32_t tx_ip_dst_addr;
676 : :
677 : : extern struct fwd_config cur_fwd_config;
678 : : extern struct fwd_engine *cur_fwd_eng;
679 : : extern uint32_t retry_enabled;
680 : : extern struct fwd_lcore **fwd_lcores;
681 : : extern struct fwd_stream **fwd_streams;
682 : :
683 : : extern uint16_t vxlan_gpe_udp_port; /**< UDP port of tunnel VXLAN-GPE. */
684 : : extern uint16_t geneve_udp_port; /**< UDP port of tunnel GENEVE. */
685 : :
686 : : extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */
687 : : extern struct rte_ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS];
688 : :
689 : : extern uint32_t burst_tx_delay_time; /**< Burst tx delay time(us) for mac-retry. */
690 : : extern uint32_t burst_tx_retry_num; /**< Burst tx retry number for mac-retry. */
691 : :
692 : : #ifdef RTE_LIB_GRO
693 : : #define GRO_DEFAULT_ITEM_NUM_PER_FLOW 32
694 : : #define GRO_DEFAULT_FLOW_NUM (RTE_GRO_MAX_BURST_ITEM_NUM / \
695 : : GRO_DEFAULT_ITEM_NUM_PER_FLOW)
696 : :
697 : : #define GRO_DEFAULT_FLUSH_CYCLES 1
698 : : #define GRO_MAX_FLUSH_CYCLES 4
699 : :
700 : : struct gro_status {
701 : : struct rte_gro_param param;
702 : : uint8_t enable;
703 : : };
704 : : extern struct gro_status gro_ports[RTE_MAX_ETHPORTS];
705 : : extern uint8_t gro_flush_cycles;
706 : : #endif /* RTE_LIB_GRO */
707 : :
708 : : #ifdef RTE_LIB_GSO
709 : : #define GSO_MAX_PKT_BURST 2048
710 : : struct gso_status {
711 : : uint8_t enable;
712 : : };
713 : : extern struct gso_status gso_ports[RTE_MAX_ETHPORTS];
714 : : extern uint16_t gso_max_segment_size;
715 : : #endif /* RTE_LIB_GSO */
716 : :
717 : : /* VXLAN encap/decap parameters. */
718 : : struct vxlan_encap_conf {
719 : : uint32_t select_ipv4:1;
720 : : uint32_t select_vlan:1;
721 : : uint32_t select_tos_ttl:1;
722 : : uint8_t vni[3];
723 : : rte_be16_t udp_src;
724 : : rte_be16_t udp_dst;
725 : : rte_be32_t ipv4_src;
726 : : rte_be32_t ipv4_dst;
727 : : struct rte_ipv6_addr ipv6_src;
728 : : struct rte_ipv6_addr ipv6_dst;
729 : : rte_be16_t vlan_tci;
730 : : uint8_t ip_tos;
731 : : uint8_t ip_ttl;
732 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
733 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
734 : : };
735 : :
736 : : extern struct vxlan_encap_conf vxlan_encap_conf;
737 : :
738 : : /* NVGRE encap/decap parameters. */
739 : : struct nvgre_encap_conf {
740 : : uint32_t select_ipv4:1;
741 : : uint32_t select_vlan:1;
742 : : uint8_t tni[3];
743 : : rte_be32_t ipv4_src;
744 : : rte_be32_t ipv4_dst;
745 : : struct rte_ipv6_addr ipv6_src;
746 : : struct rte_ipv6_addr ipv6_dst;
747 : : rte_be16_t vlan_tci;
748 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
749 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
750 : : };
751 : :
752 : : extern struct nvgre_encap_conf nvgre_encap_conf;
753 : :
754 : : /* L2 encap parameters. */
755 : : struct l2_encap_conf {
756 : : uint32_t select_ipv4:1;
757 : : uint32_t select_vlan:1;
758 : : rte_be16_t vlan_tci;
759 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
760 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
761 : : };
762 : : extern struct l2_encap_conf l2_encap_conf;
763 : :
764 : : /* L2 decap parameters. */
765 : : struct l2_decap_conf {
766 : : uint32_t select_vlan:1;
767 : : };
768 : : extern struct l2_decap_conf l2_decap_conf;
769 : :
770 : : /* MPLSoGRE encap parameters. */
771 : : struct mplsogre_encap_conf {
772 : : uint32_t select_ipv4:1;
773 : : uint32_t select_vlan:1;
774 : : uint8_t label[3];
775 : : rte_be32_t ipv4_src;
776 : : rte_be32_t ipv4_dst;
777 : : struct rte_ipv6_addr ipv6_src;
778 : : struct rte_ipv6_addr ipv6_dst;
779 : : rte_be16_t vlan_tci;
780 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
781 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
782 : : };
783 : : extern struct mplsogre_encap_conf mplsogre_encap_conf;
784 : :
785 : : /* MPLSoGRE decap parameters. */
786 : : struct mplsogre_decap_conf {
787 : : uint32_t select_ipv4:1;
788 : : uint32_t select_vlan:1;
789 : : };
790 : : extern struct mplsogre_decap_conf mplsogre_decap_conf;
791 : :
792 : : /* MPLSoUDP encap parameters. */
793 : : struct mplsoudp_encap_conf {
794 : : uint32_t select_ipv4:1;
795 : : uint32_t select_vlan:1;
796 : : uint8_t label[3];
797 : : rte_be16_t udp_src;
798 : : rte_be16_t udp_dst;
799 : : rte_be32_t ipv4_src;
800 : : rte_be32_t ipv4_dst;
801 : : struct rte_ipv6_addr ipv6_src;
802 : : struct rte_ipv6_addr ipv6_dst;
803 : : rte_be16_t vlan_tci;
804 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
805 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
806 : : };
807 : : extern struct mplsoudp_encap_conf mplsoudp_encap_conf;
808 : :
809 : : /* MPLSoUDP decap parameters. */
810 : : struct mplsoudp_decap_conf {
811 : : uint32_t select_ipv4:1;
812 : : uint32_t select_vlan:1;
813 : : };
814 : : extern struct mplsoudp_decap_conf mplsoudp_decap_conf;
815 : :
816 : : extern enum rte_eth_rx_mq_mode rx_mq_mode;
817 : :
818 : : extern struct rte_flow_action_conntrack conntrack_context;
819 : :
820 : : extern int proc_id;
821 : : extern unsigned int num_procs;
822 : :
823 : : static inline bool
824 : : is_proc_primary(void)
825 : : {
826 : 0 : return rte_eal_process_type() == RTE_PROC_PRIMARY;
827 : : }
828 : :
829 : : static inline struct fwd_lcore *
830 : : lcore_to_fwd_lcore(uint16_t lcore_id)
831 : : {
832 : : unsigned int i;
833 : :
834 : 0 : for (i = 0; i < cur_fwd_config.nb_fwd_lcores; ++i) {
835 : 0 : if (fwd_lcores_cpuids[i] == lcore_id)
836 : 0 : return fwd_lcores[i];
837 : : }
838 : :
839 : : return NULL;
840 : : }
841 : :
842 : : static inline struct fwd_lcore *
843 : 0 : current_fwd_lcore(void)
844 : : {
845 : : struct fwd_lcore *fc = lcore_to_fwd_lcore(rte_lcore_id());
846 : :
847 : 0 : if (fc == NULL)
848 : 0 : rte_panic("lcore_id of current thread not found in fwd_lcores_cpuids\n");
849 : :
850 : 0 : return fc;
851 : : }
852 : :
853 : : void
854 : : parse_fwd_portlist(const char *port);
855 : :
856 : : /* Mbuf Pools */
857 : : static inline void
858 : 0 : mbuf_poolname_build(unsigned int sock_id, char *mp_name,
859 : : int name_size, uint16_t idx)
860 : : {
861 : 0 : if (!idx)
862 : 0 : snprintf(mp_name, name_size,
863 : : MBUF_POOL_NAME_PFX "_%u", sock_id);
864 : : else
865 : 0 : snprintf(mp_name, name_size,
866 : : MBUF_POOL_NAME_PFX "_%hu_%hu", (uint16_t)sock_id, idx);
867 : 0 : }
868 : :
869 : : static inline struct rte_mempool *
870 : : mbuf_pool_find(unsigned int sock_id, uint16_t idx)
871 : : {
872 : : char pool_name[RTE_MEMPOOL_NAMESIZE];
873 : :
874 : 0 : mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name), idx);
875 : 0 : return rte_mempool_lookup((const char *)pool_name);
876 : : }
877 : :
878 : : static inline uint16_t
879 : 0 : common_fwd_stream_receive(struct fwd_stream *fs, struct rte_mbuf **burst,
880 : : unsigned int nb_pkts)
881 : : {
882 : : uint16_t nb_rx;
883 : :
884 : 0 : nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, burst, nb_pkts);
885 : 0 : if (record_burst_stats)
886 : 0 : fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
887 : 0 : fs->rx_packets += nb_rx;
888 : 0 : return nb_rx;
889 : : }
890 : :
891 : : static inline uint16_t
892 : 0 : common_fwd_stream_transmit(struct fwd_stream *fs, struct rte_mbuf **burst,
893 : : unsigned int nb_pkts)
894 : : {
895 : : uint16_t nb_tx;
896 : : uint32_t retry;
897 : :
898 : 0 : nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, burst, nb_pkts);
899 : : /*
900 : : * Retry if necessary
901 : : */
902 : 0 : if (unlikely(nb_tx < nb_pkts) && fs->retry_enabled) {
903 : : retry = 0;
904 : 0 : while (nb_tx < nb_pkts && retry++ < burst_tx_retry_num) {
905 : 0 : rte_delay_us(burst_tx_delay_time);
906 : 0 : nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue,
907 : 0 : &burst[nb_tx], nb_pkts - nb_tx);
908 : : }
909 : : }
910 : 0 : fs->tx_packets += nb_tx;
911 : 0 : if (record_burst_stats)
912 : 0 : fs->tx_burst_stats.pkt_burst_spread[nb_tx]++;
913 : 0 : if (unlikely(nb_tx < nb_pkts)) {
914 : 0 : fs->fwd_dropped += (nb_pkts - nb_tx);
915 : 0 : rte_pktmbuf_free_bulk(&burst[nb_tx], nb_pkts - nb_tx);
916 : : }
917 : :
918 : 0 : return nb_tx;
919 : : }
920 : :
921 : : /* Prototypes */
922 : : unsigned int parse_item_list(const char *str, const char *item_name,
923 : : unsigned int max_items,
924 : : unsigned int *parsed_items, int check_unique_values);
925 : : unsigned int parse_hdrs_list(const char *str, const char *item_name,
926 : : unsigned int max_item,
927 : : unsigned int *parsed_items);
928 : : void launch_args_parse(int argc, char** argv);
929 : : void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
930 : : void cmdline_read_from_file(const char *filename);
931 : : int init_cmdline(void);
932 : : void prompt(void);
933 : : void prompt_exit(void);
934 : : void nic_stats_display(portid_t port_id);
935 : : void nic_stats_clear(portid_t port_id);
936 : : void nic_xstats_display(portid_t port_id);
937 : : void nic_xstats_clear(portid_t port_id);
938 : : void nic_xstats_set_counter(portid_t port_id, char *counter_name, int on);
939 : : void device_infos_display(const char *identifier);
940 : : void port_infos_display(portid_t port_id);
941 : : void port_summary_display(portid_t port_id);
942 : : void port_eeprom_display(portid_t port_id);
943 : : void port_eeprom_set(portid_t port_id, uint32_t magic, uint32_t offset,
944 : : uint32_t length, uint8_t *value);
945 : : void port_module_eeprom_display(portid_t port_id);
946 : : void port_summary_header_display(void);
947 : : void rx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
948 : : void tx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
949 : : void fwd_lcores_config_display(void);
950 : : bool pkt_fwd_shared_rxq_check(void);
951 : : void pkt_fwd_config_display(struct fwd_config *cfg);
952 : : void rxtx_config_display(void);
953 : : void fwd_config_setup(void);
954 : : void set_def_fwd_config(void);
955 : : void reconfig(portid_t new_port_id, unsigned socket_id);
956 : : int init_fwd_streams(void);
957 : : void update_fwd_ports(portid_t new_pid);
958 : :
959 : : void set_fwd_eth_peer(portid_t port_id, char *peer_addr);
960 : : void set_dev_led(portid_t port_id, bool active);
961 : :
962 : : void port_mtu_set(portid_t port_id, uint16_t mtu);
963 : : int port_action_handle_create(portid_t port_id, uint32_t id, bool indirect_list,
964 : : const struct rte_flow_indir_action_conf *conf,
965 : : const struct rte_flow_action *action);
966 : : int port_action_handle_destroy(portid_t port_id,
967 : : uint32_t n, const uint32_t *action);
968 : : int port_action_handle_flush(portid_t port_id);
969 : : struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id,
970 : : uint32_t id);
971 : : int port_action_handle_update(portid_t port_id, uint32_t id,
972 : : const struct rte_flow_action *action);
973 : : void
974 : : port_action_handle_query_update(portid_t port_id, uint32_t id,
975 : : enum rte_flow_query_update_mode qu_mode,
976 : : const struct rte_flow_action *action);
977 : : int port_flow_get_info(portid_t port_id);
978 : : int port_flow_configure(portid_t port_id,
979 : : const struct rte_flow_port_attr *port_attr,
980 : : uint16_t nb_queue,
981 : : const struct rte_flow_queue_attr *queue_attr);
982 : : int port_flow_pattern_template_create(portid_t port_id, uint32_t id,
983 : : const struct rte_flow_pattern_template_attr *attr,
984 : : const struct rte_flow_item *pattern);
985 : : int port_flow_pattern_template_destroy(portid_t port_id, uint32_t n,
986 : : const uint32_t *template);
987 : : int port_flow_pattern_template_flush(portid_t port_id);
988 : : int port_flow_actions_template_create(portid_t port_id, uint32_t id,
989 : : const struct rte_flow_actions_template_attr *attr,
990 : : const struct rte_flow_action *actions,
991 : : const struct rte_flow_action *masks);
992 : : int port_flow_actions_template_destroy(portid_t port_id, uint32_t n,
993 : : const uint32_t *template);
994 : : int port_flow_actions_template_flush(portid_t port_id);
995 : : int port_flow_template_table_create(portid_t port_id, uint32_t id,
996 : : const struct rte_flow_template_table_attr *table_attr,
997 : : uint32_t nb_pattern_templates, uint32_t *pattern_templates,
998 : : uint32_t nb_actions_templates, uint32_t *actions_templates);
999 : : int port_flow_template_table_destroy(portid_t port_id,
1000 : : uint32_t n, const uint32_t *table);
1001 : : int port_queue_flow_update_resized(portid_t port_id, queueid_t queue_id,
1002 : : bool postpone, uint32_t flow_id);
1003 : : int port_flow_template_table_flush(portid_t port_id);
1004 : : int port_flow_template_table_resize_complete(portid_t port_id, uint32_t table_id);
1005 : : int port_flow_template_table_resize(portid_t port_id,
1006 : : uint32_t table_id, uint32_t flows_num);
1007 : : int port_queue_group_set_miss_actions(portid_t port_id, const struct rte_flow_attr *attr,
1008 : : const struct rte_flow_action *actions);
1009 : : int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
1010 : : bool postpone, uint32_t table_id, uint32_t rule_idx,
1011 : : uint32_t pattern_idx, uint32_t actions_idx,
1012 : : const struct rte_flow_item *pattern,
1013 : : const struct rte_flow_action *actions);
1014 : : int port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,
1015 : : bool postpone, uint32_t n, const uint64_t *rule);
1016 : : int port_queue_flow_update(portid_t port_id, queueid_t queue_id,
1017 : : bool postpone, uint32_t rule_idx, uint32_t actions_idx,
1018 : : const struct rte_flow_action *actions);
1019 : : int port_queue_action_handle_create(portid_t port_id, uint32_t queue_id,
1020 : : bool postpone, uint32_t id,
1021 : : bool indirect_list,
1022 : : const struct rte_flow_indir_action_conf *conf,
1023 : : const struct rte_flow_action *action);
1024 : : int port_queue_action_handle_destroy(portid_t port_id,
1025 : : uint32_t queue_id, bool postpone,
1026 : : uint32_t n, const uint32_t *action);
1027 : : int port_queue_action_handle_update(portid_t port_id, uint32_t queue_id,
1028 : : bool postpone, uint32_t id,
1029 : : const struct rte_flow_action *action);
1030 : : int port_queue_action_handle_query(portid_t port_id, uint32_t queue_id,
1031 : : bool postpone, uint32_t id);
1032 : : void
1033 : : port_queue_action_handle_query_update(portid_t port_id,
1034 : : uint32_t queue_id, bool postpone,
1035 : : uint32_t id,
1036 : : enum rte_flow_query_update_mode qu_mode,
1037 : : const struct rte_flow_action *action);
1038 : : int port_queue_flow_push(portid_t port_id, queueid_t queue_id);
1039 : : int port_queue_flow_pull(portid_t port_id, queueid_t queue_id);
1040 : : int port_flow_hash_calc(portid_t port_id, uint32_t table_id,
1041 : : uint8_t pattern_template_index, const struct rte_flow_item pattern[]);
1042 : : int port_flow_hash_calc_encap(portid_t port_id,
1043 : : enum rte_flow_encap_hash_field encap_hash_field,
1044 : : const struct rte_flow_item pattern[]);
1045 : : void port_queue_flow_aged(portid_t port_id, uint32_t queue_id, uint8_t destroy);
1046 : : int port_flow_validate(portid_t port_id,
1047 : : const struct rte_flow_attr *attr,
1048 : : const struct rte_flow_item *pattern,
1049 : : const struct rte_flow_action *actions,
1050 : : const struct tunnel_ops *tunnel_ops);
1051 : : int port_flow_create(portid_t port_id,
1052 : : const struct rte_flow_attr *attr,
1053 : : const struct rte_flow_item *pattern,
1054 : : const struct rte_flow_action *actions,
1055 : : const struct tunnel_ops *tunnel_ops,
1056 : : uintptr_t user_id);
1057 : : int port_action_handle_query(portid_t port_id, uint32_t id);
1058 : : void update_age_action_context(const struct rte_flow_action *actions,
1059 : : struct port_flow *pf);
1060 : : int mcast_addr_pool_destroy(portid_t port_id);
1061 : : int port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule,
1062 : : bool is_user_id);
1063 : : int port_flow_update(portid_t port_id, uint32_t rule,
1064 : : const struct rte_flow_action *actions, bool is_user_id);
1065 : : int port_flow_flush(portid_t port_id);
1066 : : int port_flow_dump(portid_t port_id, bool dump_all,
1067 : : uint64_t rule, const char *file_name,
1068 : : bool is_user_id);
1069 : : int port_flow_query(portid_t port_id, uint64_t rule,
1070 : : const struct rte_flow_action *action, bool is_user_id);
1071 : : void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group);
1072 : : void port_flow_aged(portid_t port_id, uint8_t destroy);
1073 : : const char *port_flow_tunnel_type(struct rte_flow_tunnel *tunnel);
1074 : : struct port_flow_tunnel *
1075 : : port_flow_locate_tunnel(uint16_t port_id, struct rte_flow_tunnel *tun);
1076 : : void port_flow_tunnel_list(portid_t port_id);
1077 : : void port_flow_tunnel_destroy(portid_t port_id, uint32_t tunnel_id);
1078 : : void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops);
1079 : : int port_flow_isolate(portid_t port_id, int set);
1080 : : int port_meter_policy_add(portid_t port_id, uint32_t policy_id,
1081 : : const struct rte_flow_action *actions);
1082 : : struct rte_flow_meter_profile *port_meter_profile_get_by_id(portid_t port_id,
1083 : : uint32_t id);
1084 : : struct rte_flow_meter_policy *port_meter_policy_get_by_id(portid_t port_id,
1085 : : uint32_t id);
1086 : :
1087 : : void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id);
1088 : : void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id);
1089 : :
1090 : : int set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc);
1091 : : int set_fwd_lcores_mask(uint64_t lcoremask);
1092 : : void set_fwd_lcores_number(uint16_t nb_lc);
1093 : :
1094 : : void set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt);
1095 : : void set_fwd_ports_mask(uint64_t portmask);
1096 : : void set_fwd_ports_number(uint16_t nb_pt);
1097 : : int port_is_forwarding(portid_t port_id);
1098 : :
1099 : : void rx_vlan_strip_set(portid_t port_id, int on);
1100 : : void rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t queue_id, int on);
1101 : :
1102 : : void rx_vlan_filter_set(portid_t port_id, int on);
1103 : : void rx_vlan_all_filter_set(portid_t port_id, int on);
1104 : : void rx_vlan_qinq_strip_set(portid_t port_id, int on);
1105 : : int rx_vft_set(portid_t port_id, uint16_t vlan_id, int on);
1106 : : void vlan_extend_set(portid_t port_id, int on);
1107 : : void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
1108 : : uint16_t tp_id);
1109 : : void tx_vlan_set(portid_t port_id, uint16_t vlan_id);
1110 : : void tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer);
1111 : : void tx_vlan_reset(portid_t port_id);
1112 : : void tx_vlan_pvid_set(portid_t port_id, uint16_t vlan_id, int on);
1113 : :
1114 : : void set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value);
1115 : :
1116 : : void set_xstats_hide_zero(uint8_t on_off);
1117 : : void set_xstats_show_state(uint8_t on_off);
1118 : : void set_xstats_hide_disabled(uint8_t on_off);
1119 : :
1120 : : void set_record_core_cycles(uint8_t on_off);
1121 : : void set_record_burst_stats(uint8_t on_off);
1122 : : void set_verbose_level(uint16_t vb_level);
1123 : : void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
1124 : : void set_rx_pkt_hdrs(unsigned int *seg_protos, unsigned int nb_segs);
1125 : : void show_rx_pkt_hdrs(void);
1126 : : void show_rx_pkt_segments(void);
1127 : : void set_rx_pkt_offsets(unsigned int *seg_offsets, unsigned int nb_offs);
1128 : : void show_rx_pkt_offsets(void);
1129 : : void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
1130 : : void show_tx_pkt_segments(void);
1131 : : void set_tx_pkt_times(unsigned int *tx_times);
1132 : : void show_tx_pkt_times(void);
1133 : : void set_tx_pkt_split(const char *name);
1134 : : int parse_fec_mode(const char *name, uint32_t *fec_capa);
1135 : : void show_fec_capability(uint32_t num, struct rte_eth_fec_capa *speed_fec_capa);
1136 : : void set_nb_pkt_per_burst(uint16_t pkt_burst);
1137 : : char *list_pkt_forwarding_modes(void);
1138 : : char *list_pkt_forwarding_retry_modes(void);
1139 : : void set_pkt_forwarding_mode(const char *fwd_mode);
1140 : : void start_packet_forwarding(int with_tx_first);
1141 : : void fwd_stats_display(void);
1142 : : void fwd_stats_reset(void);
1143 : : void stop_packet_forwarding(void);
1144 : : void dev_set_link_up(portid_t pid);
1145 : : void dev_set_link_down(portid_t pid);
1146 : : void init_port_config(void);
1147 : : void set_port_member_flag(portid_t member_pid);
1148 : : void clear_port_member_flag(portid_t member_pid);
1149 : : uint8_t port_is_bonding_member(portid_t member_pid);
1150 : :
1151 : : int init_port_dcb_config(portid_t pid, enum dcb_mode_enable dcb_mode,
1152 : : enum rte_eth_nb_tcs num_tcs,
1153 : : uint8_t pfc_en);
1154 : : int start_port(portid_t pid);
1155 : : void stop_port(portid_t pid);
1156 : : void close_port(portid_t pid);
1157 : : void reset_port(portid_t pid);
1158 : : void attach_port(char *identifier);
1159 : : void detach_devargs(char *identifier);
1160 : : void detach_port_device(portid_t port_id);
1161 : : int all_ports_stopped(void);
1162 : : int port_is_stopped(portid_t port_id);
1163 : : int port_is_started(portid_t port_id);
1164 : : void pmd_test_exit(void);
1165 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
1166 : : void fdir_get_infos(portid_t port_id);
1167 : : #endif
1168 : : void port_rss_reta_info(portid_t port_id,
1169 : : struct rte_eth_rss_reta_entry64 *reta_conf,
1170 : : uint16_t nb_entries);
1171 : :
1172 : : void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);
1173 : :
1174 : : int
1175 : : rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
1176 : : uint16_t nb_rx_desc, unsigned int socket_id,
1177 : : struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp);
1178 : :
1179 : : int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint32_t rate);
1180 : : int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint32_t rate,
1181 : : uint64_t q_msk);
1182 : :
1183 : : int set_rxq_avail_thresh(portid_t port_id, uint16_t queue_id,
1184 : : uint8_t avail_thresh);
1185 : :
1186 : : void port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_algo);
1187 : : void port_rss_hash_key_update(portid_t port_id, char rss_type[],
1188 : : uint8_t *hash_key, uint8_t hash_key_len);
1189 : : int rx_queue_id_is_invalid(queueid_t rxq_id);
1190 : : int tx_queue_id_is_invalid(queueid_t txq_id);
1191 : : #ifdef RTE_LIB_GRO
1192 : : void setup_gro(const char *onoff, portid_t port_id);
1193 : : void setup_gro_flush_cycles(uint8_t cycles);
1194 : : void show_gro(portid_t port_id);
1195 : : #endif
1196 : : #ifdef RTE_LIB_GSO
1197 : : void setup_gso(const char *mode, portid_t port_id);
1198 : : #endif
1199 : : int eth_dev_info_get_print_err(uint16_t port_id,
1200 : : struct rte_eth_dev_info *dev_info);
1201 : : int eth_dev_conf_get_print_err(uint16_t port_id,
1202 : : struct rte_eth_conf *dev_conf);
1203 : : void eth_set_promisc_mode(uint16_t port_id, int enable);
1204 : : void eth_set_allmulticast_mode(uint16_t port, int enable);
1205 : : int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link);
1206 : : int eth_macaddr_get_print_err(uint16_t port_id,
1207 : : struct rte_ether_addr *mac_addr);
1208 : :
1209 : : /* Functions to display the set of MAC addresses added to a port*/
1210 : : void show_macs(portid_t port_id);
1211 : : void show_mcast_macs(portid_t port_id);
1212 : :
1213 : : /* Functions to manage the set of filtered Multicast MAC addresses */
1214 : : void mcast_addr_add(portid_t port_id, struct rte_ether_addr *mc_addr);
1215 : : void mcast_addr_remove(portid_t port_id, struct rte_ether_addr *mc_addr);
1216 : : void mcast_addr_flush(portid_t port_id);
1217 : : void port_dcb_info_display(portid_t port_id);
1218 : :
1219 : : uint8_t *open_file(const char *file_path, uint32_t *size);
1220 : : int save_file(const char *file_path, uint8_t *buf, uint32_t size);
1221 : : int close_file(uint8_t *buf);
1222 : :
1223 : : enum print_warning {
1224 : : ENABLED_WARN = 0,
1225 : : DISABLED_WARN
1226 : : };
1227 : : int port_id_is_invalid(portid_t port_id, enum print_warning warning);
1228 : : void print_valid_ports(void);
1229 : : int new_socket_id(unsigned int socket_id);
1230 : :
1231 : : queueid_t get_allowed_max_nb_rxq(portid_t *pid);
1232 : : int check_nb_rxq(queueid_t rxq);
1233 : : queueid_t get_allowed_max_nb_txq(portid_t *pid);
1234 : : int check_nb_txq(queueid_t txq);
1235 : : int check_nb_rxd(queueid_t rxd);
1236 : : int check_nb_txd(queueid_t txd);
1237 : : queueid_t get_allowed_max_nb_hairpinq(portid_t *pid);
1238 : : int check_nb_hairpinq(queueid_t hairpinq);
1239 : :
1240 : : uint16_t dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
1241 : : uint16_t nb_pkts, __rte_unused uint16_t max_pkts,
1242 : : __rte_unused void *user_param);
1243 : :
1244 : : uint16_t dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
1245 : : uint16_t nb_pkts, __rte_unused void *user_param);
1246 : :
1247 : : void add_rx_dump_callbacks(portid_t portid);
1248 : : void remove_rx_dump_callbacks(portid_t portid);
1249 : : void add_tx_dump_callbacks(portid_t portid);
1250 : : void remove_tx_dump_callbacks(portid_t portid);
1251 : : void configure_rxtx_dump_callbacks(uint16_t verbose);
1252 : :
1253 : : uint16_t tx_pkt_set_md(uint16_t port_id, __rte_unused uint16_t queue,
1254 : : struct rte_mbuf *pkts[], uint16_t nb_pkts,
1255 : : __rte_unused void *user_param);
1256 : : void add_tx_md_callback(portid_t portid);
1257 : : void remove_tx_md_callback(portid_t portid);
1258 : :
1259 : : uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,
1260 : : struct rte_mbuf *pkts[], uint16_t nb_pkts,
1261 : : __rte_unused void *user_param);
1262 : : void add_tx_dynf_callback(portid_t portid);
1263 : : void remove_tx_dynf_callback(portid_t portid);
1264 : : int update_mtu_from_frame_size(portid_t portid, uint32_t max_rx_pktlen);
1265 : : void flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename);
1266 : : void flex_item_destroy(portid_t port_id, uint16_t flex_id);
1267 : : void port_flex_item_flush(portid_t port_id);
1268 : :
1269 : : extern int flow_parse(const char *src, void *result, unsigned int size,
1270 : : struct rte_flow_attr **attr,
1271 : : struct rte_flow_item **pattern,
1272 : : struct rte_flow_action **actions);
1273 : : int setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi);
1274 : : int hairpin_bind(uint16_t cfg_pi, portid_t *pl, portid_t *peer_pl);
1275 : : void hairpin_map_usage(void);
1276 : : int parse_hairpin_map(const char *hpmap);
1277 : :
1278 : : uint64_t str_to_rsstypes(const char *str);
1279 : : const char *rsstypes_to_str(uint64_t rss_type);
1280 : :
1281 : : uint16_t str_to_flowtype(const char *string);
1282 : : const char *flowtype_to_str(uint16_t flow_type);
1283 : :
1284 : : /* For registering driver specific testpmd commands. */
1285 : : struct testpmd_driver_commands {
1286 : : TAILQ_ENTRY(testpmd_driver_commands) next;
1287 : : struct {
1288 : : cmdline_parse_inst_t *ctx;
1289 : : const char *help;
1290 : : } commands[];
1291 : : };
1292 : :
1293 : : void testpmd_add_driver_commands(struct testpmd_driver_commands *c);
1294 : : #define TESTPMD_ADD_DRIVER_COMMANDS(c) \
1295 : : RTE_INIT(__##c) \
1296 : : { \
1297 : : testpmd_add_driver_commands(&c); \
1298 : : }
1299 : :
1300 : : #define RTE_BE_TO_CPU_16(be_16_v) rte_be_to_cpu_16((be_16_v))
1301 : : #define RTE_CPU_TO_BE_16(cpu_16_v) rte_cpu_to_be_16((cpu_16_v))
1302 : :
1303 : : #define TESTPMD_LOG(level, fmt, ...) \
1304 : : rte_log(RTE_LOG_ ## level, testpmd_logtype, "testpmd: " fmt, ## __VA_ARGS__)
1305 : :
1306 : : #endif /* _TESTPMD_H_ */
|