app/testpmd: fix supported RSS offload display
[dpdk.git] / app / test-pmd / testpmd.h
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 #include <rte_pci.h>
11 #include <rte_bus_pci.h>
12 #ifdef RTE_LIB_GRO
13 #include <rte_gro.h>
14 #endif
15 #ifdef RTE_LIB_GSO
16 #include <rte_gso.h>
17 #endif
18 #include <rte_os_shim.h>
19 #include <rte_ethdev.h>
20 #include <rte_flow.h>
21 #include <rte_mbuf_dyn.h>
22
23 #include <cmdline.h>
24 #include <cmdline_parse.h>
25
26 #include <sys/queue.h>
27 #ifdef RTE_HAS_JANSSON
28 #include <jansson.h>
29 #endif
30
31 #define RTE_PORT_ALL            (~(portid_t)0x0)
32
33 #define RTE_TEST_RX_DESC_MAX    2048
34 #define RTE_TEST_TX_DESC_MAX    2048
35
36 #define RTE_PORT_STOPPED        (uint16_t)0
37 #define RTE_PORT_STARTED        (uint16_t)1
38 #define RTE_PORT_CLOSED         (uint16_t)2
39 #define RTE_PORT_HANDLING       (uint16_t)3
40
41 extern uint8_t cl_quit;
42
43 /*
44  * It is used to allocate the memory for hash key.
45  * The hash key size is NIC dependent.
46  */
47 #define RSS_HASH_KEY_LENGTH 64
48
49 /*
50  * Default size of the mbuf data buffer to receive standard 1518-byte
51  * Ethernet frames in a mono-segment memory buffer.
52  */
53 #define DEFAULT_MBUF_DATA_SIZE RTE_MBUF_DEFAULT_BUF_SIZE
54 /**< Default size of mbuf data buffer. */
55
56 /*
57  * The maximum number of segments per packet is used when creating
58  * scattered transmit packets composed of a list of mbufs.
59  */
60 #define RTE_MAX_SEGS_PER_PKT 255 /**< nb_segs is a 8-bit unsigned char. */
61
62 /*
63  * The maximum number of segments per packet is used to configure
64  * buffer split feature, also specifies the maximum amount of
65  * optional Rx pools to allocate mbufs to split.
66  */
67 #define MAX_SEGS_BUFFER_SPLIT 8 /**< nb_segs is a 8-bit unsigned char. */
68
69 /* The prefix of the mbuf pool names created by the application. */
70 #define MBUF_POOL_NAME_PFX "mb_pool"
71
72 #define MAX_PKT_BURST 512
73 #define DEF_PKT_BURST 32
74
75 #define DEF_MBUF_CACHE 250
76
77 #define RTE_CACHE_LINE_SIZE_ROUNDUP(size) \
78         (RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / RTE_CACHE_LINE_SIZE))
79
80 #define NUMA_NO_CONFIG 0xFF
81 #define UMA_NO_CONFIG  0xFF
82
83 #define MIN_TOTAL_NUM_MBUFS 1024
84
85 typedef uint8_t  lcoreid_t;
86 typedef uint16_t portid_t;
87 typedef uint16_t queueid_t;
88 typedef uint16_t streamid_t;
89
90 enum {
91         PORT_TOPOLOGY_PAIRED,
92         PORT_TOPOLOGY_CHAINED,
93         PORT_TOPOLOGY_LOOP,
94 };
95
96 enum {
97         MP_ALLOC_NATIVE, /**< allocate and populate mempool natively */
98         MP_ALLOC_ANON,
99         /**< allocate mempool natively, but populate using anonymous memory */
100         MP_ALLOC_XMEM,
101         /**< allocate and populate mempool using anonymous memory */
102         MP_ALLOC_XMEM_HUGE,
103         /**< allocate and populate mempool using anonymous hugepage memory */
104         MP_ALLOC_XBUF
105         /**< allocate mempool natively, use rte_pktmbuf_pool_create_extbuf */
106 };
107
108 /**
109  * The data structure associated with RX and TX packet burst statistics
110  * that are recorded for each forwarding stream.
111  */
112 struct pkt_burst_stats {
113         unsigned int pkt_burst_spread[MAX_PKT_BURST + 1];
114 };
115
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;   /**< PCI 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 /**
803  * Read/Write operations on a PCI register of a port.
804  */
805 static inline uint32_t
806 port_pci_reg_read(struct rte_port *port, uint32_t reg_off)
807 {
808         const struct rte_pci_device *pci_dev;
809         const struct rte_bus *bus;
810         void *reg_addr;
811         uint32_t reg_v;
812
813         if (!port->dev_info.device) {
814                 fprintf(stderr, "Invalid device\n");
815                 return 0;
816         }
817
818         bus = rte_bus_find_by_device(port->dev_info.device);
819         if (bus && !strcmp(bus->name, "pci")) {
820                 pci_dev = RTE_DEV_TO_PCI(port->dev_info.device);
821         } else {
822                 fprintf(stderr, "Not a PCI device\n");
823                 return 0;
824         }
825
826         reg_addr = ((char *)pci_dev->mem_resource[0].addr + reg_off);
827         reg_v = *((volatile uint32_t *)reg_addr);
828         return rte_le_to_cpu_32(reg_v);
829 }
830
831 #define port_id_pci_reg_read(pt_id, reg_off) \
832         port_pci_reg_read(&ports[(pt_id)], (reg_off))
833
834 static inline void
835 port_pci_reg_write(struct rte_port *port, uint32_t reg_off, uint32_t reg_v)
836 {
837         const struct rte_pci_device *pci_dev;
838         const struct rte_bus *bus;
839         void *reg_addr;
840
841         if (!port->dev_info.device) {
842                 fprintf(stderr, "Invalid device\n");
843                 return;
844         }
845
846         bus = rte_bus_find_by_device(port->dev_info.device);
847         if (bus && !strcmp(bus->name, "pci")) {
848                 pci_dev = RTE_DEV_TO_PCI(port->dev_info.device);
849         } else {
850                 fprintf(stderr, "Not a PCI device\n");
851                 return;
852         }
853
854         reg_addr = ((char *)pci_dev->mem_resource[0].addr + reg_off);
855         *((volatile uint32_t *)reg_addr) = rte_cpu_to_le_32(reg_v);
856 }
857
858 #define port_id_pci_reg_write(pt_id, reg_off, reg_value) \
859         port_pci_reg_write(&ports[(pt_id)], (reg_off), (reg_value))
860
861 static inline void
862 get_start_cycles(uint64_t *start_tsc)
863 {
864         if (record_core_cycles)
865                 *start_tsc = rte_rdtsc();
866 }
867
868 static inline void
869 get_end_cycles(struct fwd_stream *fs, uint64_t start_tsc)
870 {
871         if (record_core_cycles)
872                 fs->core_cycles += rte_rdtsc() - start_tsc;
873 }
874
875 static inline void
876 inc_rx_burst_stats(struct fwd_stream *fs, uint16_t nb_rx)
877 {
878         if (record_burst_stats)
879                 fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
880 }
881
882 static inline void
883 inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)
884 {
885         if (record_burst_stats)
886                 fs->tx_burst_stats.pkt_burst_spread[nb_tx]++;
887 }
888
889 /* Prototypes */
890 unsigned int parse_item_list(const char *str, const char *item_name,
891                         unsigned int max_items,
892                         unsigned int *parsed_items, int check_unique_values);
893 void launch_args_parse(int argc, char** argv);
894 void cmdline_read_from_file(const char *filename);
895 int init_cmdline(void);
896 void prompt(void);
897 void prompt_exit(void);
898 void nic_stats_display(portid_t port_id);
899 void nic_stats_clear(portid_t port_id);
900 void nic_xstats_display(portid_t port_id);
901 void nic_xstats_clear(portid_t port_id);
902 void device_infos_display(const char *identifier);
903 void port_infos_display(portid_t port_id);
904 void port_summary_display(portid_t port_id);
905 void port_eeprom_display(portid_t port_id);
906 void port_module_eeprom_display(portid_t port_id);
907 void port_summary_header_display(void);
908 void rx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
909 void tx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
910 void fwd_lcores_config_display(void);
911 bool pkt_fwd_shared_rxq_check(void);
912 void pkt_fwd_config_display(struct fwd_config *cfg);
913 void rxtx_config_display(void);
914 void fwd_config_setup(void);
915 void set_def_fwd_config(void);
916 void reconfig(portid_t new_port_id, unsigned socket_id);
917 int init_fwd_streams(void);
918 void update_fwd_ports(portid_t new_pid);
919
920 void set_fwd_eth_peer(portid_t port_id, char *peer_addr);
921
922 void port_mtu_set(portid_t port_id, uint16_t mtu);
923 void port_reg_bit_display(portid_t port_id, uint32_t reg_off, uint8_t bit_pos);
924 void port_reg_bit_set(portid_t port_id, uint32_t reg_off, uint8_t bit_pos,
925                       uint8_t bit_v);
926 void port_reg_bit_field_display(portid_t port_id, uint32_t reg_off,
927                                 uint8_t bit1_pos, uint8_t bit2_pos);
928 void port_reg_bit_field_set(portid_t port_id, uint32_t reg_off,
929                             uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value);
930 void port_reg_display(portid_t port_id, uint32_t reg_off);
931 void port_reg_set(portid_t port_id, uint32_t reg_off, uint32_t value);
932 int port_action_handle_create(portid_t port_id, uint32_t id,
933                               const struct rte_flow_indir_action_conf *conf,
934                               const struct rte_flow_action *action);
935 int port_action_handle_destroy(portid_t port_id,
936                                uint32_t n, const uint32_t *action);
937 int port_action_handle_flush(portid_t port_id);
938 struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id,
939                                                             uint32_t id);
940 int port_action_handle_update(portid_t port_id, uint32_t id,
941                               const struct rte_flow_action *action);
942 int port_flow_get_info(portid_t port_id);
943 int port_flow_configure(portid_t port_id,
944                         const struct rte_flow_port_attr *port_attr,
945                         uint16_t nb_queue,
946                         const struct rte_flow_queue_attr *queue_attr);
947 int port_flow_pattern_template_create(portid_t port_id, uint32_t id,
948                                       const struct rte_flow_pattern_template_attr *attr,
949                                       const struct rte_flow_item *pattern);
950 int port_flow_pattern_template_destroy(portid_t port_id, uint32_t n,
951                                        const uint32_t *template);
952 int port_flow_actions_template_create(portid_t port_id, uint32_t id,
953                                       const struct rte_flow_actions_template_attr *attr,
954                                       const struct rte_flow_action *actions,
955                                       const struct rte_flow_action *masks);
956 int port_flow_actions_template_destroy(portid_t port_id, uint32_t n,
957                                        const uint32_t *template);
958 int port_flow_template_table_create(portid_t port_id, uint32_t id,
959                    const struct rte_flow_template_table_attr *table_attr,
960                    uint32_t nb_pattern_templates, uint32_t *pattern_templates,
961                    uint32_t nb_actions_templates, uint32_t *actions_templates);
962 int port_flow_template_table_destroy(portid_t port_id,
963                             uint32_t n, const uint32_t *table);
964 int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
965                            bool postpone, uint32_t table_id,
966                            uint32_t pattern_idx, uint32_t actions_idx,
967                            const struct rte_flow_item *pattern,
968                            const struct rte_flow_action *actions);
969 int port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,
970                             bool postpone, uint32_t n, const uint32_t *rule);
971 int port_queue_action_handle_create(portid_t port_id, uint32_t queue_id,
972                         bool postpone, uint32_t id,
973                         const struct rte_flow_indir_action_conf *conf,
974                         const struct rte_flow_action *action);
975 int port_queue_action_handle_destroy(portid_t port_id,
976                                      uint32_t queue_id, bool postpone,
977                                      uint32_t n, const uint32_t *action);
978 int port_queue_action_handle_update(portid_t port_id, uint32_t queue_id,
979                                     bool postpone, uint32_t id,
980                                     const struct rte_flow_action *action);
981 int port_queue_flow_push(portid_t port_id, queueid_t queue_id);
982 int port_queue_flow_pull(portid_t port_id, queueid_t queue_id);
983 int port_flow_validate(portid_t port_id,
984                        const struct rte_flow_attr *attr,
985                        const struct rte_flow_item *pattern,
986                        const struct rte_flow_action *actions,
987                        const struct tunnel_ops *tunnel_ops);
988 int port_flow_create(portid_t port_id,
989                      const struct rte_flow_attr *attr,
990                      const struct rte_flow_item *pattern,
991                      const struct rte_flow_action *actions,
992                      const struct tunnel_ops *tunnel_ops);
993 int port_action_handle_query(portid_t port_id, uint32_t id);
994 void update_age_action_context(const struct rte_flow_action *actions,
995                      struct port_flow *pf);
996 int mcast_addr_pool_destroy(portid_t port_id);
997 int port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule);
998 int port_flow_flush(portid_t port_id);
999 int port_flow_dump(portid_t port_id, bool dump_all,
1000                         uint32_t rule, const char *file_name);
1001 int port_flow_query(portid_t port_id, uint32_t rule,
1002                     const struct rte_flow_action *action);
1003 void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group);
1004 void port_flow_aged(portid_t port_id, uint8_t destroy);
1005 const char *port_flow_tunnel_type(struct rte_flow_tunnel *tunnel);
1006 struct port_flow_tunnel *
1007 port_flow_locate_tunnel(uint16_t port_id, struct rte_flow_tunnel *tun);
1008 void port_flow_tunnel_list(portid_t port_id);
1009 void port_flow_tunnel_destroy(portid_t port_id, uint32_t tunnel_id);
1010 void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops);
1011 int port_flow_isolate(portid_t port_id, int set);
1012 int port_meter_policy_add(portid_t port_id, uint32_t policy_id,
1013                 const struct rte_flow_action *actions);
1014
1015 void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id);
1016 void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id);
1017
1018 int set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc);
1019 int set_fwd_lcores_mask(uint64_t lcoremask);
1020 void set_fwd_lcores_number(uint16_t nb_lc);
1021
1022 void set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt);
1023 void set_fwd_ports_mask(uint64_t portmask);
1024 void set_fwd_ports_number(uint16_t nb_pt);
1025 int port_is_forwarding(portid_t port_id);
1026
1027 void rx_vlan_strip_set(portid_t port_id, int on);
1028 void rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t queue_id, int on);
1029
1030 void rx_vlan_filter_set(portid_t port_id, int on);
1031 void rx_vlan_all_filter_set(portid_t port_id, int on);
1032 void rx_vlan_qinq_strip_set(portid_t port_id, int on);
1033 int rx_vft_set(portid_t port_id, uint16_t vlan_id, int on);
1034 void vlan_extend_set(portid_t port_id, int on);
1035 void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
1036                    uint16_t tp_id);
1037 void tx_vlan_set(portid_t port_id, uint16_t vlan_id);
1038 void tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer);
1039 void tx_vlan_reset(portid_t port_id);
1040 void tx_vlan_pvid_set(portid_t port_id, uint16_t vlan_id, int on);
1041
1042 void set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value);
1043
1044 void set_xstats_hide_zero(uint8_t on_off);
1045
1046 void set_record_core_cycles(uint8_t on_off);
1047 void set_record_burst_stats(uint8_t on_off);
1048 void set_verbose_level(uint16_t vb_level);
1049 void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
1050 void show_rx_pkt_segments(void);
1051 void set_rx_pkt_offsets(unsigned int *seg_offsets, unsigned int nb_offs);
1052 void show_rx_pkt_offsets(void);
1053 void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
1054 void show_tx_pkt_segments(void);
1055 void set_tx_pkt_times(unsigned int *tx_times);
1056 void show_tx_pkt_times(void);
1057 void set_tx_pkt_split(const char *name);
1058 int parse_fec_mode(const char *name, uint32_t *fec_capa);
1059 void show_fec_capability(uint32_t num, struct rte_eth_fec_capa *speed_fec_capa);
1060 void set_nb_pkt_per_burst(uint16_t pkt_burst);
1061 char *list_pkt_forwarding_modes(void);
1062 char *list_pkt_forwarding_retry_modes(void);
1063 void set_pkt_forwarding_mode(const char *fwd_mode);
1064 void start_packet_forwarding(int with_tx_first);
1065 void fwd_stats_display(void);
1066 void fwd_stats_reset(void);
1067 void stop_packet_forwarding(void);
1068 void dev_set_link_up(portid_t pid);
1069 void dev_set_link_down(portid_t pid);
1070 void init_port_config(void);
1071 void set_port_slave_flag(portid_t slave_pid);
1072 void clear_port_slave_flag(portid_t slave_pid);
1073 uint8_t port_is_bonding_slave(portid_t slave_pid);
1074
1075 int init_port_dcb_config(portid_t pid, enum dcb_mode_enable dcb_mode,
1076                      enum rte_eth_nb_tcs num_tcs,
1077                      uint8_t pfc_en);
1078 int start_port(portid_t pid);
1079 void stop_port(portid_t pid);
1080 void close_port(portid_t pid);
1081 void reset_port(portid_t pid);
1082 void attach_port(char *identifier);
1083 void detach_devargs(char *identifier);
1084 void detach_port_device(portid_t port_id);
1085 int all_ports_stopped(void);
1086 int port_is_stopped(portid_t port_id);
1087 int port_is_started(portid_t port_id);
1088 void pmd_test_exit(void);
1089 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
1090 void fdir_get_infos(portid_t port_id);
1091 #endif
1092 void fdir_set_flex_mask(portid_t port_id,
1093                            struct rte_eth_fdir_flex_mask *cfg);
1094 void fdir_set_flex_payload(portid_t port_id,
1095                            struct rte_eth_flex_payload_cfg *cfg);
1096 void port_rss_reta_info(portid_t port_id,
1097                         struct rte_eth_rss_reta_entry64 *reta_conf,
1098                         uint16_t nb_entries);
1099
1100 void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);
1101
1102 int
1103 rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
1104                uint16_t nb_rx_desc, unsigned int socket_id,
1105                struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp);
1106
1107 int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate);
1108 int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
1109                                 uint64_t q_msk);
1110
1111 int set_rxq_avail_thresh(portid_t port_id, uint16_t queue_id,
1112                          uint8_t avail_thresh);
1113
1114 void port_rss_hash_conf_show(portid_t port_id, int show_rss_key);
1115 void port_rss_hash_key_update(portid_t port_id, char rss_type[],
1116                               uint8_t *hash_key, uint8_t hash_key_len);
1117 int rx_queue_id_is_invalid(queueid_t rxq_id);
1118 int tx_queue_id_is_invalid(queueid_t txq_id);
1119 #ifdef RTE_LIB_GRO
1120 void setup_gro(const char *onoff, portid_t port_id);
1121 void setup_gro_flush_cycles(uint8_t cycles);
1122 void show_gro(portid_t port_id);
1123 #endif
1124 #ifdef RTE_LIB_GSO
1125 void setup_gso(const char *mode, portid_t port_id);
1126 #endif
1127 int eth_dev_info_get_print_err(uint16_t port_id,
1128                         struct rte_eth_dev_info *dev_info);
1129 int eth_dev_conf_get_print_err(uint16_t port_id,
1130                         struct rte_eth_conf *dev_conf);
1131 void eth_set_promisc_mode(uint16_t port_id, int enable);
1132 void eth_set_allmulticast_mode(uint16_t port, int enable);
1133 int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link);
1134 int eth_macaddr_get_print_err(uint16_t port_id,
1135                         struct rte_ether_addr *mac_addr);
1136
1137 /* Functions to display the set of MAC addresses added to a port*/
1138 void show_macs(portid_t port_id);
1139 void show_mcast_macs(portid_t port_id);
1140
1141 /* Functions to manage the set of filtered Multicast MAC addresses */
1142 void mcast_addr_add(portid_t port_id, struct rte_ether_addr *mc_addr);
1143 void mcast_addr_remove(portid_t port_id, struct rte_ether_addr *mc_addr);
1144 void port_dcb_info_display(portid_t port_id);
1145
1146 uint8_t *open_file(const char *file_path, uint32_t *size);
1147 int save_file(const char *file_path, uint8_t *buf, uint32_t size);
1148 int close_file(uint8_t *buf);
1149
1150 enum print_warning {
1151         ENABLED_WARN = 0,
1152         DISABLED_WARN
1153 };
1154 int port_id_is_invalid(portid_t port_id, enum print_warning warning);
1155 void print_valid_ports(void);
1156 int new_socket_id(unsigned int socket_id);
1157
1158 queueid_t get_allowed_max_nb_rxq(portid_t *pid);
1159 int check_nb_rxq(queueid_t rxq);
1160 queueid_t get_allowed_max_nb_txq(portid_t *pid);
1161 int check_nb_txq(queueid_t txq);
1162 int check_nb_rxd(queueid_t rxd);
1163 int check_nb_txd(queueid_t txd);
1164 queueid_t get_allowed_max_nb_hairpinq(portid_t *pid);
1165 int check_nb_hairpinq(queueid_t hairpinq);
1166
1167 uint16_t dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
1168                       uint16_t nb_pkts, __rte_unused uint16_t max_pkts,
1169                       __rte_unused void *user_param);
1170
1171 uint16_t dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
1172                       uint16_t nb_pkts, __rte_unused void *user_param);
1173
1174 void add_rx_dump_callbacks(portid_t portid);
1175 void remove_rx_dump_callbacks(portid_t portid);
1176 void add_tx_dump_callbacks(portid_t portid);
1177 void remove_tx_dump_callbacks(portid_t portid);
1178 void configure_rxtx_dump_callbacks(uint16_t verbose);
1179
1180 uint16_t tx_pkt_set_md(uint16_t port_id, __rte_unused uint16_t queue,
1181                        struct rte_mbuf *pkts[], uint16_t nb_pkts,
1182                        __rte_unused void *user_param);
1183 void add_tx_md_callback(portid_t portid);
1184 void remove_tx_md_callback(portid_t portid);
1185
1186 uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,
1187                          struct rte_mbuf *pkts[], uint16_t nb_pkts,
1188                          __rte_unused void *user_param);
1189 void add_tx_dynf_callback(portid_t portid);
1190 void remove_tx_dynf_callback(portid_t portid);
1191 int update_mtu_from_frame_size(portid_t portid, uint32_t max_rx_pktlen);
1192 int update_jumbo_frame_offload(portid_t portid);
1193 void flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename);
1194 void flex_item_destroy(portid_t port_id, uint16_t flex_id);
1195 void port_flex_item_flush(portid_t port_id);
1196
1197 extern int flow_parse(const char *src, void *result, unsigned int size,
1198                       struct rte_flow_attr **attr,
1199                       struct rte_flow_item **pattern,
1200                       struct rte_flow_action **actions);
1201
1202 const char *rsstypes_to_str(uint64_t rss_type);
1203
1204 /* For registering driver specific testpmd commands. */
1205 struct testpmd_driver_commands {
1206         TAILQ_ENTRY(testpmd_driver_commands) next;
1207         struct {
1208                 cmdline_parse_inst_t *ctx;
1209                 const char *help;
1210         } commands[];
1211 };
1212
1213 void testpmd_add_driver_commands(struct testpmd_driver_commands *c);
1214 #define TESTPMD_ADD_DRIVER_COMMANDS(c) \
1215 RTE_INIT(__##c) \
1216 { \
1217         testpmd_add_driver_commands(&c); \
1218 }
1219
1220 /*
1221  * Work-around of a compilation error with ICC on invocations of the
1222  * rte_be_to_cpu_16() function.
1223  */
1224 #ifdef __GCC__
1225 #define RTE_BE_TO_CPU_16(be_16_v)  rte_be_to_cpu_16((be_16_v))
1226 #define RTE_CPU_TO_BE_16(cpu_16_v) rte_cpu_to_be_16((cpu_16_v))
1227 #else
1228 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
1229 #define RTE_BE_TO_CPU_16(be_16_v)  (be_16_v)
1230 #define RTE_CPU_TO_BE_16(cpu_16_v) (cpu_16_v)
1231 #else
1232 #define RTE_BE_TO_CPU_16(be_16_v) \
1233         (uint16_t) ((((be_16_v) & 0xFF) << 8) | ((be_16_v) >> 8))
1234 #define RTE_CPU_TO_BE_16(cpu_16_v) \
1235         (uint16_t) ((((cpu_16_v) & 0xFF) << 8) | ((cpu_16_v) >> 8))
1236 #endif
1237 #endif /* __GCC__ */
1238
1239 #define TESTPMD_LOG(level, fmt, args...) \
1240         rte_log(RTE_LOG_ ## level, testpmd_logtype, "testpmd: " fmt, ## args)
1241
1242 #endif /* _TESTPMD_H_ */