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