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