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