xref: /dpdk/app/test-pmd/testpmd.h (revision 8ac3a1cd3ebdf54d9bae0dba0b3b8aa5b3f5339a)
1174a1631SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2174a1631SBruce Richardson  * Copyright(c) 2010-2017 Intel Corporation
3af75078fSIntel  */
4af75078fSIntel 
5af75078fSIntel #ifndef _TESTPMD_H_
6af75078fSIntel #define _TESTPMD_H_
7af75078fSIntel 
84f1ed78eSThomas Monjalon #include <stdbool.h>
94f1ed78eSThomas Monjalon 
106970401eSDavid Marchand #ifdef RTE_LIB_GRO
11b40f8d78SJiayu Hu #include <rte_gro.h>
126970401eSDavid Marchand #endif
136970401eSDavid Marchand #ifdef RTE_LIB_GSO
1452f38a20SJiayu Hu #include <rte_gso.h>
156970401eSDavid Marchand #endif
16761f7ae1SJie Zhou #include <rte_os_shim.h>
17592ab76fSDavid Marchand #include <rte_ethdev.h>
18592ab76fSDavid Marchand #include <rte_flow.h>
19592ab76fSDavid Marchand #include <rte_mbuf_dyn.h>
20592ab76fSDavid Marchand 
2130626defSXiaoyu Min #include <cmdline.h>
22592ab76fSDavid Marchand #include <cmdline_parse.h>
23592ab76fSDavid Marchand 
241b9f2746SGregory Etelson #include <sys/queue.h>
2559f3a8acSGregory Etelson #ifdef RTE_HAS_JANSSON
2659f3a8acSGregory Etelson #include <jansson.h>
2759f3a8acSGregory Etelson #endif
2885c18dcbSGaetan Rivet 
29ce8d5614SIntel #define RTE_PORT_ALL            (~(portid_t)0x0)
30ce8d5614SIntel 
31ce8d5614SIntel #define RTE_PORT_STOPPED        (uint16_t)0
32ce8d5614SIntel #define RTE_PORT_STARTED        (uint16_t)1
33ce8d5614SIntel #define RTE_PORT_CLOSED         (uint16_t)2
34ce8d5614SIntel #define RTE_PORT_HANDLING       (uint16_t)3
35ce8d5614SIntel 
363889a322SHuisong Li extern uint8_t cl_quit;
370fd1386cSStephen Hemminger extern volatile uint8_t f_quit;
383889a322SHuisong Li 
39af75078fSIntel /*
400f6f219eSMohammad Abdul Awal  * It is used to allocate the memory for hash key.
410f6f219eSMohammad Abdul Awal  * The hash key size is NIC dependent.
420f6f219eSMohammad Abdul Awal  */
430f6f219eSMohammad Abdul Awal #define RSS_HASH_KEY_LENGTH 64
440f6f219eSMohammad Abdul Awal 
450f6f219eSMohammad Abdul Awal /*
46af75078fSIntel  * Default size of the mbuf data buffer to receive standard 1518-byte
47af75078fSIntel  * Ethernet frames in a mono-segment memory buffer.
48af75078fSIntel  */
49824cb29cSKonstantin Ananyev #define DEFAULT_MBUF_DATA_SIZE RTE_MBUF_DEFAULT_BUF_SIZE
50824cb29cSKonstantin Ananyev /**< Default size of mbuf data buffer. */
51af75078fSIntel 
52af75078fSIntel /*
53af75078fSIntel  * The maximum number of segments per packet is used when creating
54af75078fSIntel  * scattered transmit packets composed of a list of mbufs.
55af75078fSIntel  */
56ea672a8bSOlivier Matz #define RTE_MAX_SEGS_PER_PKT 255 /**< nb_segs is a 8-bit unsigned char. */
57af75078fSIntel 
5826cbb419SViacheslav Ovsiienko /*
5926cbb419SViacheslav Ovsiienko  * The maximum number of segments per packet is used to configure
6026cbb419SViacheslav Ovsiienko  * buffer split feature, also specifies the maximum amount of
6126cbb419SViacheslav Ovsiienko  * optional Rx pools to allocate mbufs to split.
6226cbb419SViacheslav Ovsiienko  */
6326cbb419SViacheslav Ovsiienko #define MAX_SEGS_BUFFER_SPLIT 8 /**< nb_segs is a 8-bit unsigned char. */
6426cbb419SViacheslav Ovsiienko 
6526cbb419SViacheslav Ovsiienko /* The prefix of the mbuf pool names created by the application. */
6626cbb419SViacheslav Ovsiienko #define MBUF_POOL_NAME_PFX "mb_pool"
6726cbb419SViacheslav Ovsiienko 
684ed89049SDavid Marchand #define RX_DESC_MAX    2048
694ed89049SDavid Marchand #define TX_DESC_MAX    2048
704ed89049SDavid Marchand 
71af75078fSIntel #define MAX_PKT_BURST 512
72836853d3SCunming Liang #define DEF_PKT_BURST 32
73af75078fSIntel 
74e9378bbcSCunming Liang #define DEF_MBUF_CACHE 250
75e9378bbcSCunming Liang 
76fdf20fa7SSergio Gonzalez Monroy #define RTE_CACHE_LINE_SIZE_ROUNDUP(size) \
77fdf20fa7SSergio Gonzalez Monroy 	(RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / RTE_CACHE_LINE_SIZE))
78af75078fSIntel 
79b6ea6408SIntel #define NUMA_NO_CONFIG 0xFF
80b6ea6408SIntel #define UMA_NO_CONFIG  0xFF
81b6ea6408SIntel 
8257d91f5bSMingxia Liu #define MIN_TOTAL_NUM_MBUFS 1024
8357d91f5bSMingxia Liu 
844f04edcdSHanumanth Pothula /* Maximum number of pools supported per Rx queue */
854f04edcdSHanumanth Pothula #define MAX_MEMPOOL 8
864f04edcdSHanumanth Pothula 
87af75078fSIntel typedef uint8_t  lcoreid_t;
88f8244c63SZhiyong Yang typedef uint16_t portid_t;
89af75078fSIntel typedef uint16_t queueid_t;
90af75078fSIntel typedef uint16_t streamid_t;
91af75078fSIntel 
92af75078fSIntel enum {
93af75078fSIntel 	PORT_TOPOLOGY_PAIRED,
943e2006d6SCyril Chemparathy 	PORT_TOPOLOGY_CHAINED,
953e2006d6SCyril Chemparathy 	PORT_TOPOLOGY_LOOP,
96af75078fSIntel };
97af75078fSIntel 
98c7f5dba7SAnatoly Burakov enum {
99c7f5dba7SAnatoly Burakov 	MP_ALLOC_NATIVE, /**< allocate and populate mempool natively */
100c7f5dba7SAnatoly Burakov 	MP_ALLOC_ANON,
101c7f5dba7SAnatoly Burakov 	/**< allocate mempool natively, but populate using anonymous memory */
102c7f5dba7SAnatoly Burakov 	MP_ALLOC_XMEM,
103c7f5dba7SAnatoly Burakov 	/**< allocate and populate mempool using anonymous memory */
10472512e18SViacheslav Ovsiienko 	MP_ALLOC_XMEM_HUGE,
105c7f5dba7SAnatoly Burakov 	/**< allocate and populate mempool using anonymous hugepage memory */
10672512e18SViacheslav Ovsiienko 	MP_ALLOC_XBUF
10772512e18SViacheslav Ovsiienko 	/**< allocate mempool natively, use rte_pktmbuf_pool_create_extbuf */
108c7f5dba7SAnatoly Burakov };
109c7f5dba7SAnatoly Burakov 
110c9dc0384SSuanming Mou enum {
111c9dc0384SSuanming Mou 	QUEUE_JOB_TYPE_FLOW_CREATE,
112c9dc0384SSuanming Mou 	QUEUE_JOB_TYPE_FLOW_DESTROY,
11377e7939aSAlexander Kozyrev 	QUEUE_JOB_TYPE_FLOW_UPDATE,
114c9dc0384SSuanming Mou 	QUEUE_JOB_TYPE_ACTION_CREATE,
115c9dc0384SSuanming Mou 	QUEUE_JOB_TYPE_ACTION_DESTROY,
116c9dc0384SSuanming Mou 	QUEUE_JOB_TYPE_ACTION_UPDATE,
117c9dc0384SSuanming Mou 	QUEUE_JOB_TYPE_ACTION_QUERY,
118c9dc0384SSuanming Mou };
119c9dc0384SSuanming Mou 
1201d343c19SMike Pattrick enum noisy_fwd_mode {
1211d343c19SMike Pattrick 	NOISY_FWD_MODE_IO,
1221d343c19SMike Pattrick 	NOISY_FWD_MODE_MAC,
1231d343c19SMike Pattrick 	NOISY_FWD_MODE_MACSWAP,
1241d343c19SMike Pattrick 	NOISY_FWD_MODE_5TSWAP,
1251d343c19SMike Pattrick 	NOISY_FWD_MODE_MAX,
1261d343c19SMike Pattrick };
1271d343c19SMike Pattrick 
128af75078fSIntel /**
129af75078fSIntel  * The data structure associated with RX and TX packet burst statistics
130af75078fSIntel  * that are recorded for each forwarding stream.
131af75078fSIntel  */
132af75078fSIntel struct pkt_burst_stats {
1336a8b64fdSEli Britstein 	unsigned int pkt_burst_spread[MAX_PKT_BURST + 1];
134af75078fSIntel };
135af75078fSIntel 
13644a37f3cSFerruh Yigit 
13744a37f3cSFerruh Yigit #define TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE 64
138f4d623f9SAdrien Mazarguil /** Information for a given RSS type. */
139f4d623f9SAdrien Mazarguil struct rss_type_info {
140f4d623f9SAdrien Mazarguil 	const char *str; /**< Type name. */
141f4d623f9SAdrien Mazarguil 	uint64_t rss_type; /**< Type value. */
142f4d623f9SAdrien Mazarguil };
143f4d623f9SAdrien Mazarguil 
144f4d623f9SAdrien Mazarguil /**
145f4d623f9SAdrien Mazarguil  * RSS type information table.
146f4d623f9SAdrien Mazarguil  *
147f4d623f9SAdrien Mazarguil  * An entry with a NULL type name terminates the list.
148f4d623f9SAdrien Mazarguil  */
149f4d623f9SAdrien Mazarguil extern const struct rss_type_info rss_type_table[];
150f4d623f9SAdrien Mazarguil 
151af75078fSIntel /**
152b57b66a9SOri Kam  * Dynf name array.
153b57b66a9SOri Kam  *
154b57b66a9SOri Kam  * Array that holds the name for each dynf.
155b57b66a9SOri Kam  */
156b57b66a9SOri Kam extern char dynf_names[64][RTE_MBUF_DYN_NAMESIZE];
157b57b66a9SOri Kam 
158b57b66a9SOri Kam /**
159af75078fSIntel  * The data structure associated with a forwarding stream between a receive
160af75078fSIntel  * port/queue and a transmit port/queue.
161af75078fSIntel  */
162af75078fSIntel struct fwd_stream {
163af75078fSIntel 	/* "read-only" data */
164af75078fSIntel 	portid_t   rx_port;   /**< port to poll for received packets */
165af75078fSIntel 	queueid_t  rx_queue;  /**< RX queue to poll on "rx_port" */
166af75078fSIntel 	portid_t   tx_port;   /**< forwarding port of received packets */
167af75078fSIntel 	queueid_t  tx_queue;  /**< TX queue to send forwarded packets */
168af75078fSIntel 	streamid_t peer_addr; /**< index of peer ethernet address of packets */
1693c4426dbSDmitry Kozlyuk 	bool       disabled;  /**< the stream is disabled and should not run */
170af75078fSIntel 
171bf56fce1SZhihong Wang 	unsigned int retry_enabled;
172bf56fce1SZhihong Wang 
173af75078fSIntel 	/* "read-write" results */
174c185d42cSDavid Marchand 	uint64_t rx_packets;  /**< received packets */
175c185d42cSDavid Marchand 	uint64_t tx_packets;  /**< received packets transmitted */
176c185d42cSDavid Marchand 	uint64_t fwd_dropped; /**< received packets not forwarded */
177c185d42cSDavid Marchand 	uint64_t rx_bad_ip_csum ; /**< received packets has bad ip checksum */
178c185d42cSDavid Marchand 	uint64_t rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
179c185d42cSDavid Marchand 	uint64_t rx_bad_outer_l4_csum;
18058d475b7SJerin Jacob 	/**< received packets has bad outer l4 checksum */
181d139cf23SLance Richardson 	uint64_t rx_bad_outer_ip_csum;
182d139cf23SLance Richardson 	/**< received packets having bad outer ip checksum */
1839fac5ca8SViacheslav Ovsiienko 	uint64_t ts_skew; /**< TX scheduling timestamp */
1846970401eSDavid Marchand #ifdef RTE_LIB_GRO
185b7091f1dSJiayu Hu 	unsigned int gro_times;	/**< GRO operation times */
1866970401eSDavid Marchand #endif
18799a4974aSRobin Jarry 	uint64_t busy_cycles; /**< used with --record-core-cycles */
188af75078fSIntel 	struct pkt_burst_stats rx_burst_stats;
189af75078fSIntel 	struct pkt_burst_stats tx_burst_stats;
19065744833SXueming Li 	struct fwd_lcore *lcore; /**< Lcore being scheduled. */
191af75078fSIntel };
192af75078fSIntel 
193de956d5eSMatan Azrad /**
194de956d5eSMatan Azrad  * Age action context types, must be included inside the age action
195de956d5eSMatan Azrad  * context structure.
196de956d5eSMatan Azrad  */
197de956d5eSMatan Azrad enum age_action_context_type {
198de956d5eSMatan Azrad 	ACTION_AGE_CONTEXT_TYPE_FLOW,
1994b61b877SBing Zhao 	ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION,
200de956d5eSMatan Azrad };
201de956d5eSMatan Azrad 
20204cc665fSAlexander Kozyrev /** Descriptor for a template. */
20304cc665fSAlexander Kozyrev struct port_template {
20404cc665fSAlexander Kozyrev 	struct port_template *next; /**< Next template in list. */
20504cc665fSAlexander Kozyrev 	struct port_template *tmp; /**< Temporary linking. */
20604cc665fSAlexander Kozyrev 	uint32_t id; /**< Template ID. */
20704cc665fSAlexander Kozyrev 	union {
20804cc665fSAlexander Kozyrev 		struct rte_flow_pattern_template *pattern_template;
20904cc665fSAlexander Kozyrev 		struct rte_flow_actions_template *actions_template;
21004cc665fSAlexander Kozyrev 	} template; /**< PMD opaque template object */
21104cc665fSAlexander Kozyrev };
21204cc665fSAlexander Kozyrev 
213c4b38873SAlexander Kozyrev /** Descriptor for a flow table. */
214c4b38873SAlexander Kozyrev struct port_table {
215c4b38873SAlexander Kozyrev 	struct port_table *next; /**< Next table in list. */
216c4b38873SAlexander Kozyrev 	struct port_table *tmp; /**< Temporary linking. */
217c4b38873SAlexander Kozyrev 	uint32_t id; /**< Table ID. */
218c4b38873SAlexander Kozyrev 	uint32_t nb_pattern_templates; /**< Number of pattern templates. */
219c4b38873SAlexander Kozyrev 	uint32_t nb_actions_templates; /**< Number of actions templates. */
220f4f7ba1aSAlexander Kozyrev 	struct rte_flow_attr flow_attr; /**< Flow attributes. */
221c4b38873SAlexander Kozyrev 	struct rte_flow_template_table *table; /**< PMD opaque template object */
222c4b38873SAlexander Kozyrev };
223c4b38873SAlexander Kozyrev 
224938a184aSAdrien Mazarguil /** Descriptor for a single flow. */
225938a184aSAdrien Mazarguil struct port_flow {
226938a184aSAdrien Mazarguil 	struct port_flow *next; /**< Next flow in list. */
227938a184aSAdrien Mazarguil 	struct port_flow *tmp; /**< Temporary linking. */
228fd5392d8SEli Britstein 	uint64_t id; /**< Flow rule ID. */
229*8ac3a1cdSEli Britstein 	uint64_t user_id; /**< User rule ID. */
23077e7939aSAlexander Kozyrev 	struct port_table *table; /**< Flow table. */
231938a184aSAdrien Mazarguil 	struct rte_flow *flow; /**< Opaque flow object returned by PMD. */
232de956d5eSMatan Azrad 	struct rte_flow_conv_rule rule; /**< Saved flow rule description. */
233de956d5eSMatan Azrad 	enum age_action_context_type age_type; /**< Age action context type. */
23444b257ffSAdrien Mazarguil 	uint8_t data[]; /**< Storage for flow rule description */
235938a184aSAdrien Mazarguil };
236938a184aSAdrien Mazarguil 
2374b61b877SBing Zhao /* Descriptor for indirect action */
2384b61b877SBing Zhao struct port_indirect_action {
2394b61b877SBing Zhao 	struct port_indirect_action *next; /**< Next flow in list. */
2404b61b877SBing Zhao 	uint32_t id; /**< Indirect action ID. */
24155509e3aSAndrey Vesnovaty 	enum rte_flow_action_type type; /**< Action type. */
24272a3dec7SGregory Etelson 	union {
24372a3dec7SGregory Etelson 		struct rte_flow_action_handle *handle;
24472a3dec7SGregory Etelson 		/**< Indirect action handle. */
24572a3dec7SGregory Etelson 		struct rte_flow_action_list_handle *list_handle;
24672a3dec7SGregory Etelson 		/**< Indirect action list handle*/
24772a3dec7SGregory Etelson 	};
248de956d5eSMatan Azrad 	enum age_action_context_type age_type; /**< Age action context type. */
24955509e3aSAndrey Vesnovaty };
25055509e3aSAndrey Vesnovaty 
251c9dc0384SSuanming Mou /* Descriptor for action query data. */
252c9dc0384SSuanming Mou union port_action_query {
253c9dc0384SSuanming Mou 	struct rte_flow_query_count count;
254c9dc0384SSuanming Mou 	struct rte_flow_query_age age;
255c9dc0384SSuanming Mou 	struct rte_flow_action_conntrack ct;
2563e3edab5SGregory Etelson 	struct rte_flow_query_quota quota;
257c9dc0384SSuanming Mou };
258c9dc0384SSuanming Mou 
259c9dc0384SSuanming Mou /* Descriptor for queue job. */
260c9dc0384SSuanming Mou struct queue_job {
261c9dc0384SSuanming Mou 	uint32_t type; /**< Job type. */
262c9dc0384SSuanming Mou 	union {
263c9dc0384SSuanming Mou 		struct port_flow *pf;
264c9dc0384SSuanming Mou 		struct port_indirect_action *pia;
265c9dc0384SSuanming Mou 	};
266c9dc0384SSuanming Mou 	union port_action_query query;
267c9dc0384SSuanming Mou };
268c9dc0384SSuanming Mou 
2691b9f2746SGregory Etelson struct port_flow_tunnel {
2701b9f2746SGregory Etelson 	LIST_ENTRY(port_flow_tunnel) chain;
2711b9f2746SGregory Etelson 	struct rte_flow_action *pmd_actions;
2721b9f2746SGregory Etelson 	struct rte_flow_item   *pmd_items;
2731b9f2746SGregory Etelson 	uint32_t id;
2741b9f2746SGregory Etelson 	uint32_t num_pmd_actions;
2751b9f2746SGregory Etelson 	uint32_t num_pmd_items;
2761b9f2746SGregory Etelson 	struct rte_flow_tunnel tunnel;
2771b9f2746SGregory Etelson 	struct rte_flow_action *actions;
2781b9f2746SGregory Etelson 	struct rte_flow_item *items;
2791b9f2746SGregory Etelson };
2801b9f2746SGregory Etelson 
2811b9f2746SGregory Etelson struct tunnel_ops {
2821b9f2746SGregory Etelson 	uint32_t id;
2831b9f2746SGregory Etelson 	char type[16];
2841b9f2746SGregory Etelson 	uint32_t enabled:1;
2851b9f2746SGregory Etelson 	uint32_t actions:1;
2861b9f2746SGregory Etelson 	uint32_t items:1;
2871b9f2746SGregory Etelson };
2881b9f2746SGregory Etelson 
28963b72657SIvan Ilchenko /** Information for an extended statistics to show. */
29063b72657SIvan Ilchenko struct xstat_display_info {
29163b72657SIvan Ilchenko 	/** Supported xstats IDs in the order of xstats_display */
29263b72657SIvan Ilchenko 	uint64_t *ids_supp;
29363b72657SIvan Ilchenko 	size_t   ids_supp_sz;
29463b72657SIvan Ilchenko 	uint64_t *prev_values;
29563b72657SIvan Ilchenko 	uint64_t *curr_values;
29663b72657SIvan Ilchenko 	uint64_t prev_ns;
29763b72657SIvan Ilchenko 	bool	 allocated;
29863b72657SIvan Ilchenko };
29963b72657SIvan Ilchenko 
3003c4426dbSDmitry Kozlyuk /** RX queue configuration and state. */
3013c4426dbSDmitry Kozlyuk struct port_rxqueue {
3023c4426dbSDmitry Kozlyuk 	struct rte_eth_rxconf conf;
3033c4426dbSDmitry Kozlyuk 	uint8_t state; /**< RTE_ETH_QUEUE_STATE_* value. */
3043c4426dbSDmitry Kozlyuk };
3053c4426dbSDmitry Kozlyuk 
3063c4426dbSDmitry Kozlyuk /** TX queue configuration and state. */
3073c4426dbSDmitry Kozlyuk struct port_txqueue {
3083c4426dbSDmitry Kozlyuk 	struct rte_eth_txconf conf;
3093c4426dbSDmitry Kozlyuk 	uint8_t state; /**< RTE_ETH_QUEUE_STATE_* value. */
3103c4426dbSDmitry Kozlyuk };
3113c4426dbSDmitry Kozlyuk 
312af75078fSIntel /**
313af75078fSIntel  * The data structure associated with each port.
314af75078fSIntel  */
315af75078fSIntel struct rte_port {
3161bcb7ba9SDavid Marchand 	struct rte_eth_dev_info dev_info;   /**< Device info + driver name */
317af75078fSIntel 	struct rte_eth_conf     dev_conf;   /**< Port configuration. */
3186d13ea8eSOlivier Matz 	struct rte_ether_addr       eth_addr;   /**< Port ethernet address */
319af75078fSIntel 	struct rte_eth_stats    stats;      /**< Last port statistics */
320af75078fSIntel 	unsigned int            socket_id;  /**< For NUMA support */
3213eecba26SShahaf Shuler 	uint16_t		parse_tunnel:1; /**< Parse internal headers */
3220f62d635SJianfeng Tan 	uint16_t                tso_segsz;  /**< Segmentation offload MSS for non-tunneled packets. */
3230f62d635SJianfeng Tan 	uint16_t                tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */
32492ebda07SHelin Zhang 	uint16_t                tx_vlan_id;/**< The tag ID */
32592ebda07SHelin Zhang 	uint16_t                tx_vlan_id_outer;/**< The outer tag ID */
326ce8d5614SIntel 	volatile uint16_t        port_status;    /**< port started or not */
3274f1ed78eSThomas Monjalon 	uint8_t                 need_setup;     /**< port just attached */
328ce8d5614SIntel 	uint8_t                 need_reconfig;  /**< need reconfiguring port or not */
329ce8d5614SIntel 	uint8_t                 need_reconfig_queues; /**< need reconfiguring queues or not */
330ce8d5614SIntel 	uint8_t                 rss_flag;   /**< enable rss or not */
3317741e4cfSIntel 	uint8_t                 dcb_flag;   /**< enable dcb */
3329e6b36c3SDavid Marchand 	uint16_t                nb_rx_desc[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue rx desc number */
3339e6b36c3SDavid Marchand 	uint16_t                nb_tx_desc[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue tx desc number */
3343c4426dbSDmitry Kozlyuk 	struct port_rxqueue     rxq[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue Rx config and state */
3353c4426dbSDmitry Kozlyuk 	struct port_txqueue     txq[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue Tx config and state */
3366d13ea8eSOlivier Matz 	struct rte_ether_addr   *mc_addr_pool; /**< pool of multicast addrs */
3378fff6675SIvan Boule 	uint32_t                mc_addr_nb; /**< nb. of addr. in mc_addr_pool */
3389ad3a41aSAlexander Kozyrev 	queueid_t               queue_nb; /**< nb. of queues for flow rules */
3399ad3a41aSAlexander Kozyrev 	uint32_t                queue_sz; /**< size of a queue for flow rules */
340e46372d7SHuisong Li 	uint8_t                 slave_flag : 1, /**< bonding slave port */
341236bc417SGregory Etelson 				bond_flag : 1, /**< port is bond device */
3427c06f1abSHuisong Li 				fwd_mac_swap : 1, /**< swap packet MAC before forward */
3437c06f1abSHuisong Li 				update_conf : 1; /**< need to update bonding device configuration */
34404cc665fSAlexander Kozyrev 	struct port_template    *pattern_templ_list; /**< Pattern templates. */
34504cc665fSAlexander Kozyrev 	struct port_template    *actions_templ_list; /**< Actions templates. */
346c4b38873SAlexander Kozyrev 	struct port_table       *table_list; /**< Flow tables. */
347938a184aSAdrien Mazarguil 	struct port_flow        *flow_list; /**< Associated flows. */
3484b61b877SBing Zhao 	struct port_indirect_action *actions_list;
3494b61b877SBing Zhao 	/**< Associated indirect actions. */
3501b9f2746SGregory Etelson 	LIST_HEAD(, port_flow_tunnel) flow_tunnel_list;
3519e6b36c3SDavid Marchand 	const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1];
3529e6b36c3SDavid Marchand 	const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1];
353c18feafaSDekel Peled 	/**< metadata value to insert in Tx packets. */
3549bf26e13SViacheslav Ovsiienko 	uint32_t		tx_metadata;
3559e6b36c3SDavid Marchand 	const struct rte_eth_rxtx_callback *tx_set_md_cb[RTE_MAX_QUEUES_PER_PORT+1];
356b57b66a9SOri Kam 	/**< dynamic flags. */
357b57b66a9SOri Kam 	uint64_t		mbuf_dynf;
358b57b66a9SOri Kam 	const struct rte_eth_rxtx_callback *tx_set_dynf_cb[RTE_MAX_QUEUES_PER_PORT+1];
35963b72657SIvan Ilchenko 	struct xstat_display_info xstats_info;
360af75078fSIntel };
361af75078fSIntel 
362af75078fSIntel /**
363af75078fSIntel  * The data structure associated with each forwarding logical core.
364af75078fSIntel  * The logical cores are internally numbered by a core index from 0 to
365af75078fSIntel  * the maximum number of logical cores - 1.
366af75078fSIntel  * The system CPU identifier of all logical cores are setup in a global
367af75078fSIntel  * CPU id. configuration table.
368af75078fSIntel  */
369af75078fSIntel struct fwd_lcore {
3706970401eSDavid Marchand #ifdef RTE_LIB_GSO
37152f38a20SJiayu Hu 	struct rte_gso_ctx gso_ctx;     /**< GSO context */
3726970401eSDavid Marchand #endif
373af75078fSIntel 	struct rte_mempool *mbp; /**< The mbuf pool to use by this core */
3746970401eSDavid Marchand #ifdef RTE_LIB_GRO
375b7091f1dSJiayu Hu 	void *gro_ctx;		/**< GRO context */
3766970401eSDavid Marchand #endif
377af75078fSIntel 	streamid_t stream_idx;   /**< index of 1st stream in "fwd_streams" */
378af75078fSIntel 	streamid_t stream_nb;    /**< number of streams in "fwd_streams" */
379af75078fSIntel 	lcoreid_t  cpuid_idx;    /**< index of logical core in CPU id table */
380af75078fSIntel 	volatile char stopped;   /**< stop forwarding when set */
38199a4974aSRobin Jarry 	uint64_t total_cycles;   /**< used with --record-core-cycles */
382af75078fSIntel };
383af75078fSIntel 
384af75078fSIntel /*
385af75078fSIntel  * Forwarding mode operations:
386af75078fSIntel  *   - IO forwarding mode (default mode)
387af75078fSIntel  *     Forwards packets unchanged.
388af75078fSIntel  *
389af75078fSIntel  *   - MAC forwarding mode
390af75078fSIntel  *     Set the source and the destination Ethernet addresses of packets
391af75078fSIntel  *     before forwarding them.
392af75078fSIntel  *
393af75078fSIntel  *   - IEEE1588 forwarding mode
394af75078fSIntel  *     Check that received IEEE1588 Precise Time Protocol (PTP) packets are
395af75078fSIntel  *     filtered and timestamped by the hardware.
396af75078fSIntel  *     Forwards packets unchanged on the same port.
397af75078fSIntel  *     Check that sent IEEE1588 PTP packets are timestamped by the hardware.
398af75078fSIntel  */
399a78040c9SAlvin Zhang typedef int (*port_fwd_begin_t)(portid_t pi);
400af75078fSIntel typedef void (*port_fwd_end_t)(portid_t pi);
4013c4426dbSDmitry Kozlyuk typedef void (*stream_init_t)(struct fwd_stream *fs);
40206c20561SDavid Marchand typedef bool (*packet_fwd_t)(struct fwd_stream *fs);
403af75078fSIntel 
404af75078fSIntel struct fwd_engine {
405af75078fSIntel 	const char       *fwd_mode_name; /**< Forwarding mode name. */
406af75078fSIntel 	port_fwd_begin_t port_fwd_begin; /**< NULL if nothing special to do. */
407af75078fSIntel 	port_fwd_end_t   port_fwd_end;   /**< NULL if nothing special to do. */
4083c4426dbSDmitry Kozlyuk 	stream_init_t    stream_init;    /**< NULL if nothing special to do. */
409af75078fSIntel 	packet_fwd_t     packet_fwd;     /**< Mandatory. */
4101d343c19SMike Pattrick 	const char       *status;        /**< NULL if nothing to display. */
411af75078fSIntel };
412af75078fSIntel 
413180ba023SDavid Marchand void common_fwd_stream_init(struct fwd_stream *fs);
414180ba023SDavid Marchand 
41559f3a8acSGregory Etelson #define FLEX_ITEM_MAX_SAMPLES_NUM 16
41659f3a8acSGregory Etelson #define FLEX_ITEM_MAX_LINKS_NUM 16
41759f3a8acSGregory Etelson #define FLEX_MAX_FLOW_PATTERN_LENGTH 64
41859f3a8acSGregory Etelson #define FLEX_MAX_PARSERS_NUM 8
41959f3a8acSGregory Etelson #define FLEX_MAX_PATTERNS_NUM 64
42059f3a8acSGregory Etelson #define FLEX_PARSER_ERR ((struct flex_item *)-1)
42159f3a8acSGregory Etelson 
42259f3a8acSGregory Etelson struct flex_item {
42359f3a8acSGregory Etelson 	struct rte_flow_item_flex_conf flex_conf;
42459f3a8acSGregory Etelson 	struct rte_flow_item_flex_handle *flex_handle;
42559f3a8acSGregory Etelson 	uint32_t flex_id;
42659f3a8acSGregory Etelson };
42759f3a8acSGregory Etelson 
42859f3a8acSGregory Etelson struct flex_pattern {
42959f3a8acSGregory Etelson 	struct rte_flow_item_flex spec, mask;
43059f3a8acSGregory Etelson 	uint8_t spec_pattern[FLEX_MAX_FLOW_PATTERN_LENGTH];
43159f3a8acSGregory Etelson 	uint8_t mask_pattern[FLEX_MAX_FLOW_PATTERN_LENGTH];
43259f3a8acSGregory Etelson };
43359f3a8acSGregory Etelson extern struct flex_item *flex_items[RTE_MAX_ETHPORTS][FLEX_MAX_PARSERS_NUM];
43459f3a8acSGregory Etelson extern struct flex_pattern flex_patterns[FLEX_MAX_PATTERNS_NUM];
43559f3a8acSGregory Etelson 
436bf56fce1SZhihong Wang #define BURST_TX_WAIT_US 1
437bf56fce1SZhihong Wang #define BURST_TX_RETRIES 64
438bf56fce1SZhihong Wang 
439bf56fce1SZhihong Wang extern uint32_t burst_tx_delay_time;
440bf56fce1SZhihong Wang extern uint32_t burst_tx_retry_num;
441bf56fce1SZhihong Wang 
442af75078fSIntel extern struct fwd_engine io_fwd_engine;
443af75078fSIntel extern struct fwd_engine mac_fwd_engine;
444d47388f1SCyril Chemparathy extern struct fwd_engine mac_swap_engine;
445e9e23a61SCyril Chemparathy extern struct fwd_engine flow_gen_engine;
446af75078fSIntel extern struct fwd_engine rx_only_engine;
447af75078fSIntel extern struct fwd_engine tx_only_engine;
448af75078fSIntel extern struct fwd_engine csum_fwd_engine;
449168dfa61SIvan Boule extern struct fwd_engine icmp_echo_engine;
4503c156061SJens Freimann extern struct fwd_engine noisy_vnf_engine;
4512564abdaSShiri Kuzin extern struct fwd_engine five_tuple_swap_fwd_engine;
452af75078fSIntel #ifdef RTE_LIBRTE_IEEE1588
453af75078fSIntel extern struct fwd_engine ieee1588_fwd_engine;
454af75078fSIntel #endif
45559840375SXueming Li extern struct fwd_engine shared_rxq_engine;
456af75078fSIntel 
457af75078fSIntel extern struct fwd_engine * fwd_engines[]; /**< NULL terminated array. */
45830626defSXiaoyu Min extern cmdline_parse_inst_t cmd_set_raw;
459739e045bSXiaoyu Min extern cmdline_parse_inst_t cmd_show_set_raw;
460739e045bSXiaoyu Min extern cmdline_parse_inst_t cmd_show_set_raw_all;
46159f3a8acSGregory Etelson extern cmdline_parse_inst_t cmd_set_flex_is_pattern;
46259f3a8acSGregory Etelson extern cmdline_parse_inst_t cmd_set_flex_spec_pattern;
463af75078fSIntel 
46459fcf854SShahaf Shuler extern uint16_t mempool_flags;
46559fcf854SShahaf Shuler 
466af75078fSIntel /**
467af75078fSIntel  * Forwarding Configuration
468af75078fSIntel  *
469af75078fSIntel  */
470af75078fSIntel struct fwd_config {
471af75078fSIntel 	struct fwd_engine *fwd_eng; /**< Packet forwarding mode. */
472af75078fSIntel 	streamid_t nb_fwd_streams;  /**< Nb. of forward streams to process. */
473af75078fSIntel 	lcoreid_t  nb_fwd_lcores;   /**< Nb. of logical cores to launch. */
474af75078fSIntel 	portid_t   nb_fwd_ports;    /**< Nb. of ports involved. */
475af75078fSIntel };
476af75078fSIntel 
477900550deSIntel /**
478900550deSIntel  * DCB mode enable
479900550deSIntel  */
480900550deSIntel enum dcb_mode_enable
481900550deSIntel {
482900550deSIntel 	DCB_VT_ENABLED,
483900550deSIntel 	DCB_ENABLED
484900550deSIntel };
485900550deSIntel 
486a4fd5eeeSElza Mathew extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */
487a4fd5eeeSElza Mathew 
488af75078fSIntel /* globals used for configuration */
489bc700b67SDharmik Thakkar extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */
4900e4b1963SDharmik Thakkar extern uint8_t record_burst_stats; /**< Enables display of RX and TX bursts */
491af75078fSIntel extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */
492285fd101SOlivier Matz extern int testpmd_logtype; /**< Log type for testpmd logs */
493af75078fSIntel extern uint8_t  interactive;
494ca7feb22SCyril Chemparathy extern uint8_t  auto_start;
49599cabef0SPablo de Lara extern uint8_t  tx_first;
49681ef862bSAllain Legacy extern char cmdline_filename[PATH_MAX]; /**< offline commands file */
497af75078fSIntel extern uint8_t  numa_support; /**< set by "--numa" parameter */
498af75078fSIntel extern uint16_t port_topology; /**< set by "--port-topology" parameter */
4997741e4cfSIntel extern uint8_t no_flush_rx; /**<set by "--no-flush-rx" parameter */
5007ee3e944SVasily Philipov extern uint8_t flow_isolate_all; /**< set by "--flow-isolate-all */
501543df472SChengwen Feng extern uint8_t no_flow_flush; /**< set by "--disable-flow-flush" parameter */
502c7f5dba7SAnatoly Burakov extern uint8_t  mp_alloc_type;
503c7f5dba7SAnatoly Burakov /**< set by "--mp-anon" or "--mp-alloc" parameter */
504b7b78a08SAjit Khaparde extern uint32_t eth_link_speed;
505bc202406SDavid Marchand extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */
5066937d210SStephen Hemminger extern uint8_t no_device_start; /**<set by "--disable-device-start" parameter */
5072950a769SDeclan Doherty extern volatile int test_done; /* stop packet forwarding when set to 1. */
5088ea656f8SGaetan Rivet extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
509284c908cSGaetan Rivet extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
5103af72783SGaetan Rivet extern uint32_t event_print_mask;
5113af72783SGaetan Rivet /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */
5124f1ed78eSThomas Monjalon extern bool setup_on_probe_event; /**< disabled by port setup-on iterator */
513e505d84cSAnatoly Burakov extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */
514e505d84cSAnatoly Burakov extern int do_mlockall; /**< set by "--mlockall" or "--no-mlockall" parameter */
515b0a9354aSPavan Nikhilesh extern uint8_t clear_ptypes; /**< disabled by set ptype cmd */
516af75078fSIntel 
517b6ea6408SIntel /*
518b6ea6408SIntel  * Store specified sockets on which memory pool to be used by ports
519b6ea6408SIntel  * is allocated.
520b6ea6408SIntel  */
52163531389SGeorgios Katsikas extern uint8_t port_numa[RTE_MAX_ETHPORTS];
522b6ea6408SIntel 
523b6ea6408SIntel /*
524b6ea6408SIntel  * Store specified sockets on which RX ring to be used by ports
525b6ea6408SIntel  * is allocated.
526b6ea6408SIntel  */
52763531389SGeorgios Katsikas extern uint8_t rxring_numa[RTE_MAX_ETHPORTS];
528b6ea6408SIntel 
529b6ea6408SIntel /*
530b6ea6408SIntel  * Store specified sockets on which TX ring to be used by ports
531b6ea6408SIntel  * is allocated.
532b6ea6408SIntel  */
53363531389SGeorgios Katsikas extern uint8_t txring_numa[RTE_MAX_ETHPORTS];
534b6ea6408SIntel 
535b6ea6408SIntel extern uint8_t socket_num;
536b6ea6408SIntel 
537af75078fSIntel /*
538af75078fSIntel  * Configuration of logical cores:
539af75078fSIntel  * nb_fwd_lcores <= nb_cfg_lcores <= nb_lcores
540af75078fSIntel  */
541af75078fSIntel extern lcoreid_t nb_lcores; /**< Number of logical cores probed at init time. */
542af75078fSIntel extern lcoreid_t nb_cfg_lcores; /**< Number of configured logical cores. */
543af75078fSIntel extern lcoreid_t nb_fwd_lcores; /**< Number of forwarding logical cores. */
544af75078fSIntel extern unsigned int fwd_lcores_cpuids[RTE_MAX_LCORE];
545c9cafcc8SShahaf Shuler extern unsigned int num_sockets;
546c9cafcc8SShahaf Shuler extern unsigned int socket_ids[RTE_MAX_NUMA_NODES];
547af75078fSIntel 
548af75078fSIntel /*
549af75078fSIntel  * Configuration of Ethernet ports:
550af75078fSIntel  * nb_fwd_ports <= nb_cfg_ports <= nb_ports
551af75078fSIntel  */
552af75078fSIntel extern portid_t nb_ports; /**< Number of ethernet ports probed at init time. */
553af75078fSIntel extern portid_t nb_cfg_ports; /**< Number of configured ports. */
554af75078fSIntel extern portid_t nb_fwd_ports; /**< Number of forwarding ports. */
555af75078fSIntel extern portid_t fwd_ports_ids[RTE_MAX_ETHPORTS];
556af75078fSIntel extern struct rte_port *ports;
557af75078fSIntel 
558af75078fSIntel extern struct rte_eth_rxmode rx_mode;
559fd8c20aaSShahaf Shuler extern struct rte_eth_txmode tx_mode;
560fd8c20aaSShahaf Shuler 
5618a387fa8SHelin Zhang extern uint64_t rss_hf;
562af75078fSIntel 
5631c69df45SOri Kam extern queueid_t nb_hairpinq;
564af75078fSIntel extern queueid_t nb_rxq;
565af75078fSIntel extern queueid_t nb_txq;
566af75078fSIntel 
567af75078fSIntel extern uint16_t nb_rxd;
568af75078fSIntel extern uint16_t nb_txd;
569af75078fSIntel 
570f2c5125aSPablo de Lara extern int16_t rx_free_thresh;
571f2c5125aSPablo de Lara extern int8_t rx_drop_en;
572f2c5125aSPablo de Lara extern int16_t tx_free_thresh;
573f2c5125aSPablo de Lara extern int16_t tx_rs_thresh;
574af75078fSIntel 
5751d343c19SMike Pattrick extern enum noisy_fwd_mode noisy_fwd_mode;
5761d343c19SMike Pattrick extern const char * const noisy_fwd_mode_desc[];
5773c156061SJens Freimann extern uint16_t noisy_tx_sw_bufsz;
5783c156061SJens Freimann extern uint16_t noisy_tx_sw_buf_flush_time;
5793c156061SJens Freimann extern uint64_t noisy_lkup_mem_sz;
5803c156061SJens Freimann extern uint64_t noisy_lkup_num_writes;
5813c156061SJens Freimann extern uint64_t noisy_lkup_num_reads;
5823c156061SJens Freimann extern uint64_t noisy_lkup_num_reads_writes;
5833c156061SJens Freimann 
584900550deSIntel extern uint8_t dcb_config;
585900550deSIntel 
58626cbb419SViacheslav Ovsiienko extern uint32_t mbuf_data_size_n;
58726cbb419SViacheslav Ovsiienko extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT];
58826cbb419SViacheslav Ovsiienko /**< Mbuf data space size. */
589c8798818SIntel extern uint32_t param_total_num_mbufs;
590af75078fSIntel 
591cfea1f30SPablo de Lara extern uint16_t stats_period;
59262d3216dSReshma Pattan 
59363b72657SIvan Ilchenko extern struct rte_eth_xstat_name *xstats_display;
59463b72657SIvan Ilchenko extern unsigned int xstats_display_num;
59563b72657SIvan Ilchenko 
59623095155SDariusz Sosnowski extern uint32_t hairpin_mode;
59701817b10SBing Zhao 
598a8d0d473SBruce Richardson #ifdef RTE_LIB_LATENCYSTATS
59962d3216dSReshma Pattan extern uint8_t latencystats_enabled;
60062d3216dSReshma Pattan extern lcoreid_t latencystats_lcore_id;
60162d3216dSReshma Pattan #endif
60262d3216dSReshma Pattan 
603a8d0d473SBruce Richardson #ifdef RTE_LIB_BITRATESTATS
604e25e6c70SRemy Horton extern lcoreid_t bitrate_lcore_id;
605e25e6c70SRemy Horton extern uint8_t bitrate_enabled;
606e25e6c70SRemy Horton #endif
607e25e6c70SRemy Horton 
6081bb4a528SFerruh Yigit extern uint32_t max_rx_pkt_len;
6091bb4a528SFerruh Yigit 
610af75078fSIntel /*
6110f2096d7SViacheslav Ovsiienko  * Configuration of packet segments used to scatter received packets
6120f2096d7SViacheslav Ovsiienko  * if some of split features is configured.
6130f2096d7SViacheslav Ovsiienko  */
61452e2e7edSYuan Wang extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
6150f2096d7SViacheslav Ovsiienko extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
6160f2096d7SViacheslav Ovsiienko extern uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
61791c78e09SViacheslav Ovsiienko extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
61891c78e09SViacheslav Ovsiienko extern uint8_t  rx_pkt_nb_offs; /**< Number of specified offsets */
6190f2096d7SViacheslav Ovsiienko 
620a4bf5421SHanumanth Pothula extern uint8_t multi_rx_mempool; /**< Enables multi-rx-mempool feature. */
621a4bf5421SHanumanth Pothula 
6220f2096d7SViacheslav Ovsiienko /*
623af75078fSIntel  * Configuration of packet segments used by the "txonly" processing engine.
624af75078fSIntel  */
625af75078fSIntel #define TXONLY_DEF_PACKET_LEN 64
626af75078fSIntel extern uint16_t tx_pkt_length; /**< Length of TXONLY packet */
627af75078fSIntel extern uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT]; /**< Seg. lengths */
628af75078fSIntel extern uint8_t  tx_pkt_nb_segs; /**< Number of segments in TX packets */
6294940344dSViacheslav Ovsiienko extern uint32_t tx_pkt_times_intra;
6304940344dSViacheslav Ovsiienko extern uint32_t tx_pkt_times_inter;
631af75078fSIntel 
63279bec05bSKonstantin Ananyev enum tx_pkt_split {
63379bec05bSKonstantin Ananyev 	TX_PKT_SPLIT_OFF,
63479bec05bSKonstantin Ananyev 	TX_PKT_SPLIT_ON,
63579bec05bSKonstantin Ananyev 	TX_PKT_SPLIT_RND,
63679bec05bSKonstantin Ananyev };
63779bec05bSKonstantin Ananyev 
63879bec05bSKonstantin Ananyev extern enum tx_pkt_split tx_pkt_split;
63979bec05bSKonstantin Ananyev 
64082010ef5SYongseok Koh extern uint8_t txonly_multi_flow;
64182010ef5SYongseok Koh 
642f4d178c1SXueming Li extern uint32_t rxq_share;
643f4d178c1SXueming Li 
644af75078fSIntel extern uint16_t nb_pkt_per_burst;
6456c02043eSIgor Russkikh extern uint16_t nb_pkt_flowgen_clones;
646861e7684SZhihong Wang extern int nb_flows_flowgen;
647af75078fSIntel extern uint16_t mb_mempool_cache;
648f2c5125aSPablo de Lara extern int8_t rx_pthresh;
649f2c5125aSPablo de Lara extern int8_t rx_hthresh;
650f2c5125aSPablo de Lara extern int8_t rx_wthresh;
651f2c5125aSPablo de Lara extern int8_t tx_pthresh;
652f2c5125aSPablo de Lara extern int8_t tx_hthresh;
653f2c5125aSPablo de Lara extern int8_t tx_wthresh;
654af75078fSIntel 
655bf5b2126SStephen Hemminger extern uint16_t tx_udp_src_port;
656bf5b2126SStephen Hemminger extern uint16_t tx_udp_dst_port;
657bf5b2126SStephen Hemminger 
658bf5b2126SStephen Hemminger extern uint32_t tx_ip_src_addr;
659bf5b2126SStephen Hemminger extern uint32_t tx_ip_dst_addr;
660bf5b2126SStephen Hemminger 
661af75078fSIntel extern struct fwd_config cur_fwd_config;
662af75078fSIntel extern struct fwd_engine *cur_fwd_eng;
663bf56fce1SZhihong Wang extern uint32_t retry_enabled;
664af75078fSIntel extern struct fwd_lcore  **fwd_lcores;
665af75078fSIntel extern struct fwd_stream **fwd_streams;
666af75078fSIntel 
66739e5e20fSXueming Li extern uint16_t vxlan_gpe_udp_port; /**< UDP port of tunnel VXLAN-GPE. */
668ea0e711bSOphir Munk extern uint16_t geneve_udp_port; /**< UDP port of tunnel GENEVE. */
66939e5e20fSXueming Li 
670af75078fSIntel extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */
6716d13ea8eSOlivier Matz extern struct rte_ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS];
672af75078fSIntel 
67357e85242SBruce Richardson extern uint32_t burst_tx_delay_time; /**< Burst tx delay time(us) for mac-retry. */
67457e85242SBruce Richardson extern uint32_t burst_tx_retry_num;  /**< Burst tx retry number for mac-retry. */
67557e85242SBruce Richardson 
6766970401eSDavid Marchand #ifdef RTE_LIB_GRO
677b7091f1dSJiayu Hu #define GRO_DEFAULT_ITEM_NUM_PER_FLOW 32
678b7091f1dSJiayu Hu #define GRO_DEFAULT_FLOW_NUM (RTE_GRO_MAX_BURST_ITEM_NUM / \
679b7091f1dSJiayu Hu 		GRO_DEFAULT_ITEM_NUM_PER_FLOW)
680b7091f1dSJiayu Hu 
681b7091f1dSJiayu Hu #define GRO_DEFAULT_FLUSH_CYCLES 1
682b7091f1dSJiayu Hu #define GRO_MAX_FLUSH_CYCLES 4
683b7091f1dSJiayu Hu 
684b40f8d78SJiayu Hu struct gro_status {
685b40f8d78SJiayu Hu 	struct rte_gro_param param;
686b40f8d78SJiayu Hu 	uint8_t enable;
687b40f8d78SJiayu Hu };
688b40f8d78SJiayu Hu extern struct gro_status gro_ports[RTE_MAX_ETHPORTS];
689b7091f1dSJiayu Hu extern uint8_t gro_flush_cycles;
6906970401eSDavid Marchand #endif /* RTE_LIB_GRO */
691b40f8d78SJiayu Hu 
6926970401eSDavid Marchand #ifdef RTE_LIB_GSO
69352f38a20SJiayu Hu #define GSO_MAX_PKT_BURST 2048
69452f38a20SJiayu Hu struct gso_status {
69552f38a20SJiayu Hu 	uint8_t enable;
69652f38a20SJiayu Hu };
69752f38a20SJiayu Hu extern struct gso_status gso_ports[RTE_MAX_ETHPORTS];
69852f38a20SJiayu Hu extern uint16_t gso_max_segment_size;
6996970401eSDavid Marchand #endif /* RTE_LIB_GSO */
70052f38a20SJiayu Hu 
7011960be7dSNelio Laranjeiro /* VXLAN encap/decap parameters. */
7021960be7dSNelio Laranjeiro struct vxlan_encap_conf {
7031960be7dSNelio Laranjeiro 	uint32_t select_ipv4:1;
7041960be7dSNelio Laranjeiro 	uint32_t select_vlan:1;
70562e8a5a8SViacheslav Ovsiienko 	uint32_t select_tos_ttl:1;
7061960be7dSNelio Laranjeiro 	uint8_t vni[3];
7071960be7dSNelio Laranjeiro 	rte_be16_t udp_src;
7081960be7dSNelio Laranjeiro 	rte_be16_t udp_dst;
7091960be7dSNelio Laranjeiro 	rte_be32_t ipv4_src;
7101960be7dSNelio Laranjeiro 	rte_be32_t ipv4_dst;
7111960be7dSNelio Laranjeiro 	uint8_t ipv6_src[16];
7121960be7dSNelio Laranjeiro 	uint8_t ipv6_dst[16];
7131960be7dSNelio Laranjeiro 	rte_be16_t vlan_tci;
71462e8a5a8SViacheslav Ovsiienko 	uint8_t ip_tos;
71562e8a5a8SViacheslav Ovsiienko 	uint8_t ip_ttl;
71635b2d13fSOlivier Matz 	uint8_t eth_src[RTE_ETHER_ADDR_LEN];
71735b2d13fSOlivier Matz 	uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
7181960be7dSNelio Laranjeiro };
719f6e63e59SFerruh Yigit 
720f6e63e59SFerruh Yigit extern struct vxlan_encap_conf vxlan_encap_conf;
7211960be7dSNelio Laranjeiro 
722dcd962fcSNelio Laranjeiro /* NVGRE encap/decap parameters. */
723dcd962fcSNelio Laranjeiro struct nvgre_encap_conf {
724dcd962fcSNelio Laranjeiro 	uint32_t select_ipv4:1;
725dcd962fcSNelio Laranjeiro 	uint32_t select_vlan:1;
726dcd962fcSNelio Laranjeiro 	uint8_t tni[3];
727dcd962fcSNelio Laranjeiro 	rte_be32_t ipv4_src;
728dcd962fcSNelio Laranjeiro 	rte_be32_t ipv4_dst;
729dcd962fcSNelio Laranjeiro 	uint8_t ipv6_src[16];
730dcd962fcSNelio Laranjeiro 	uint8_t ipv6_dst[16];
731dcd962fcSNelio Laranjeiro 	rte_be16_t vlan_tci;
73235b2d13fSOlivier Matz 	uint8_t eth_src[RTE_ETHER_ADDR_LEN];
73335b2d13fSOlivier Matz 	uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
734dcd962fcSNelio Laranjeiro };
735f6e63e59SFerruh Yigit 
736f6e63e59SFerruh Yigit extern struct nvgre_encap_conf nvgre_encap_conf;
737dcd962fcSNelio Laranjeiro 
738a1191d39SOri Kam /* L2 encap parameters. */
739a1191d39SOri Kam struct l2_encap_conf {
740a1191d39SOri Kam 	uint32_t select_ipv4:1;
741a1191d39SOri Kam 	uint32_t select_vlan:1;
742a1191d39SOri Kam 	rte_be16_t vlan_tci;
74335b2d13fSOlivier Matz 	uint8_t eth_src[RTE_ETHER_ADDR_LEN];
74435b2d13fSOlivier Matz 	uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
745a1191d39SOri Kam };
746f6e63e59SFerruh Yigit extern struct l2_encap_conf l2_encap_conf;
747a1191d39SOri Kam 
748a1191d39SOri Kam /* L2 decap parameters. */
749a1191d39SOri Kam struct l2_decap_conf {
750a1191d39SOri Kam 	uint32_t select_vlan:1;
751a1191d39SOri Kam };
752f6e63e59SFerruh Yigit extern struct l2_decap_conf l2_decap_conf;
753a1191d39SOri Kam 
7543e77031bSOri Kam /* MPLSoGRE encap parameters. */
7553e77031bSOri Kam struct mplsogre_encap_conf {
7563e77031bSOri Kam 	uint32_t select_ipv4:1;
7573e77031bSOri Kam 	uint32_t select_vlan:1;
7583e77031bSOri Kam 	uint8_t label[3];
7593e77031bSOri Kam 	rte_be32_t ipv4_src;
7603e77031bSOri Kam 	rte_be32_t ipv4_dst;
7613e77031bSOri Kam 	uint8_t ipv6_src[16];
7623e77031bSOri Kam 	uint8_t ipv6_dst[16];
7633e77031bSOri Kam 	rte_be16_t vlan_tci;
76435b2d13fSOlivier Matz 	uint8_t eth_src[RTE_ETHER_ADDR_LEN];
76535b2d13fSOlivier Matz 	uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
7663e77031bSOri Kam };
767f6e63e59SFerruh Yigit extern struct mplsogre_encap_conf mplsogre_encap_conf;
7683e77031bSOri Kam 
7693e77031bSOri Kam /* MPLSoGRE decap parameters. */
7703e77031bSOri Kam struct mplsogre_decap_conf {
7713e77031bSOri Kam 	uint32_t select_ipv4:1;
7723e77031bSOri Kam 	uint32_t select_vlan:1;
7733e77031bSOri Kam };
774f6e63e59SFerruh Yigit extern struct mplsogre_decap_conf mplsogre_decap_conf;
7753e77031bSOri Kam 
776a1191d39SOri Kam /* MPLSoUDP encap parameters. */
777a1191d39SOri Kam struct mplsoudp_encap_conf {
778a1191d39SOri Kam 	uint32_t select_ipv4:1;
779a1191d39SOri Kam 	uint32_t select_vlan:1;
780a1191d39SOri Kam 	uint8_t label[3];
781a1191d39SOri Kam 	rte_be16_t udp_src;
782a1191d39SOri Kam 	rte_be16_t udp_dst;
783a1191d39SOri Kam 	rte_be32_t ipv4_src;
784a1191d39SOri Kam 	rte_be32_t ipv4_dst;
785a1191d39SOri Kam 	uint8_t ipv6_src[16];
786a1191d39SOri Kam 	uint8_t ipv6_dst[16];
787a1191d39SOri Kam 	rte_be16_t vlan_tci;
78835b2d13fSOlivier Matz 	uint8_t eth_src[RTE_ETHER_ADDR_LEN];
78935b2d13fSOlivier Matz 	uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
790a1191d39SOri Kam };
791f6e63e59SFerruh Yigit extern struct mplsoudp_encap_conf mplsoudp_encap_conf;
792a1191d39SOri Kam 
793a1191d39SOri Kam /* MPLSoUDP decap parameters. */
794a1191d39SOri Kam struct mplsoudp_decap_conf {
795a1191d39SOri Kam 	uint32_t select_ipv4:1;
796a1191d39SOri Kam 	uint32_t select_vlan:1;
797a1191d39SOri Kam };
798f6e63e59SFerruh Yigit extern struct mplsoudp_decap_conf mplsoudp_decap_conf;
799a1191d39SOri Kam 
800f9295aa2SXiaoyu Min extern enum rte_eth_rx_mq_mode rx_mq_mode;
801f9295aa2SXiaoyu Min 
8024d07cbefSBing Zhao extern struct rte_flow_action_conntrack conntrack_context;
8034d07cbefSBing Zhao 
804a550baf2SMin Hu (Connor) extern int proc_id;
805a550baf2SMin Hu (Connor) extern unsigned int num_procs;
806a550baf2SMin Hu (Connor) 
807a550baf2SMin Hu (Connor) static inline bool
808a550baf2SMin Hu (Connor) is_proc_primary(void)
809a550baf2SMin Hu (Connor) {
810a550baf2SMin Hu (Connor) 	return rte_eal_process_type() == RTE_PROC_PRIMARY;
811a550baf2SMin Hu (Connor) }
812a550baf2SMin Hu (Connor) 
81399a4974aSRobin Jarry static inline struct fwd_lcore *
81499a4974aSRobin Jarry lcore_to_fwd_lcore(uint16_t lcore_id)
815af75078fSIntel {
816af75078fSIntel 	unsigned int i;
817af75078fSIntel 
81899a4974aSRobin Jarry 	for (i = 0; i < cur_fwd_config.nb_fwd_lcores; ++i) {
81999a4974aSRobin Jarry 		if (fwd_lcores_cpuids[i] == lcore_id)
82099a4974aSRobin Jarry 			return fwd_lcores[i];
821af75078fSIntel 	}
822af75078fSIntel 
82399a4974aSRobin Jarry 	return NULL;
82499a4974aSRobin Jarry }
8252df00d56SHariprasad Govindharajan 
826af75078fSIntel static inline struct fwd_lcore *
827af75078fSIntel current_fwd_lcore(void)
828af75078fSIntel {
82999a4974aSRobin Jarry 	struct fwd_lcore *fc = lcore_to_fwd_lcore(rte_lcore_id());
83099a4974aSRobin Jarry 
83199a4974aSRobin Jarry 	if (fc == NULL)
83299a4974aSRobin Jarry 		rte_panic("lcore_id of current thread not found in fwd_lcores_cpuids\n");
83399a4974aSRobin Jarry 
83499a4974aSRobin Jarry 	return fc;
835af75078fSIntel }
836af75078fSIntel 
83799a4974aSRobin Jarry void
83899a4974aSRobin Jarry parse_fwd_portlist(const char *port);
83999a4974aSRobin Jarry 
840af75078fSIntel /* Mbuf Pools */
841af75078fSIntel static inline void
84226cbb419SViacheslav Ovsiienko mbuf_poolname_build(unsigned int sock_id, char *mp_name,
84326cbb419SViacheslav Ovsiienko 		    int name_size, uint16_t idx)
844af75078fSIntel {
84526cbb419SViacheslav Ovsiienko 	if (!idx)
84626cbb419SViacheslav Ovsiienko 		snprintf(mp_name, name_size,
84726cbb419SViacheslav Ovsiienko 			 MBUF_POOL_NAME_PFX "_%u", sock_id);
84826cbb419SViacheslav Ovsiienko 	else
84926cbb419SViacheslav Ovsiienko 		snprintf(mp_name, name_size,
85026cbb419SViacheslav Ovsiienko 			 MBUF_POOL_NAME_PFX "_%hu_%hu", (uint16_t)sock_id, idx);
851af75078fSIntel }
852af75078fSIntel 
853af75078fSIntel static inline struct rte_mempool *
85426cbb419SViacheslav Ovsiienko mbuf_pool_find(unsigned int sock_id, uint16_t idx)
855af75078fSIntel {
856af75078fSIntel 	char pool_name[RTE_MEMPOOL_NAMESIZE];
857af75078fSIntel 
85826cbb419SViacheslav Ovsiienko 	mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name), idx);
859693f715dSHuawei Xie 	return rte_mempool_lookup((const char *)pool_name);
860af75078fSIntel }
861af75078fSIntel 
862d3dae396SDavid Marchand static inline uint16_t
863d3dae396SDavid Marchand common_fwd_stream_receive(struct fwd_stream *fs, struct rte_mbuf **burst,
864d3dae396SDavid Marchand 	unsigned int nb_pkts)
8650e4b1963SDharmik Thakkar {
866d3dae396SDavid Marchand 	uint16_t nb_rx;
867d3dae396SDavid Marchand 
868d3dae396SDavid Marchand 	nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, burst, nb_pkts);
8690e4b1963SDharmik Thakkar 	if (record_burst_stats)
8700e4b1963SDharmik Thakkar 		fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
871d3dae396SDavid Marchand 	fs->rx_packets += nb_rx;
872d3dae396SDavid Marchand 	return nb_rx;
8730e4b1963SDharmik Thakkar }
8740e4b1963SDharmik Thakkar 
875655131ccSDavid Marchand static inline uint16_t
876655131ccSDavid Marchand common_fwd_stream_transmit(struct fwd_stream *fs, struct rte_mbuf **burst,
877655131ccSDavid Marchand 	unsigned int nb_pkts)
8780e4b1963SDharmik Thakkar {
879655131ccSDavid Marchand 	uint16_t nb_tx;
880655131ccSDavid Marchand 	uint32_t retry;
881655131ccSDavid Marchand 
882655131ccSDavid Marchand 	nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, burst, nb_pkts);
883655131ccSDavid Marchand 	/*
884655131ccSDavid Marchand 	 * Retry if necessary
885655131ccSDavid Marchand 	 */
886655131ccSDavid Marchand 	if (unlikely(nb_tx < nb_pkts) && fs->retry_enabled) {
887655131ccSDavid Marchand 		retry = 0;
888655131ccSDavid Marchand 		while (nb_tx < nb_pkts && retry++ < burst_tx_retry_num) {
889655131ccSDavid Marchand 			rte_delay_us(burst_tx_delay_time);
890655131ccSDavid Marchand 			nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue,
891655131ccSDavid Marchand 				&burst[nb_tx], nb_pkts - nb_tx);
892655131ccSDavid Marchand 		}
893655131ccSDavid Marchand 	}
894655131ccSDavid Marchand 	fs->tx_packets += nb_tx;
8950e4b1963SDharmik Thakkar 	if (record_burst_stats)
8960e4b1963SDharmik Thakkar 		fs->tx_burst_stats.pkt_burst_spread[nb_tx]++;
897655131ccSDavid Marchand 	if (unlikely(nb_tx < nb_pkts)) {
898655131ccSDavid Marchand 		fs->fwd_dropped += (nb_pkts - nb_tx);
899655131ccSDavid Marchand 		rte_pktmbuf_free_bulk(&burst[nb_tx], nb_pkts - nb_tx);
900655131ccSDavid Marchand 	}
901655131ccSDavid Marchand 
902655131ccSDavid Marchand 	return nb_tx;
9030e4b1963SDharmik Thakkar }
9040e4b1963SDharmik Thakkar 
905af75078fSIntel /* Prototypes */
906761f7ae1SJie Zhou unsigned int parse_item_list(const char *str, const char *item_name,
907950d1516SBruce Richardson 			unsigned int max_items,
908950d1516SBruce Richardson 			unsigned int *parsed_items, int check_unique_values);
90952e2e7edSYuan Wang unsigned int parse_hdrs_list(const char *str, const char *item_name,
91052e2e7edSYuan Wang 			unsigned int max_item,
91123f2dfd3SYuan Wang 			unsigned int *parsed_items);
912af75078fSIntel void launch_args_parse(int argc, char** argv);
9130100a038SDavid Marchand void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
91481ef862bSAllain Legacy void cmdline_read_from_file(const char *filename);
915592ab76fSDavid Marchand int init_cmdline(void);
916af75078fSIntel void prompt(void);
917d3a274ceSZhihong Wang void prompt_exit(void);
918af75078fSIntel void nic_stats_display(portid_t port_id);
919af75078fSIntel void nic_stats_clear(portid_t port_id);
920bfd5051bSOlivier Matz void nic_xstats_display(portid_t port_id);
921bfd5051bSOlivier Matz void nic_xstats_clear(portid_t port_id);
92255e51c96SNithin Dabilpuram void device_infos_display(const char *identifier);
923af75078fSIntel void port_infos_display(portid_t port_id);
9244bfcbcf5SEmma Finn void port_summary_display(portid_t port_id);
9256b67721dSDavid Liu void port_eeprom_display(portid_t port_id);
9266b67721dSDavid Liu void port_module_eeprom_display(portid_t port_id);
9274bfcbcf5SEmma Finn void port_summary_header_display(void);
928ab3257e1SKonstantin Ananyev void rx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
929ab3257e1SKonstantin Ananyev void tx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
930af75078fSIntel void fwd_lcores_config_display(void);
93165744833SXueming Li bool pkt_fwd_shared_rxq_check(void);
9320c0db76fSBernard Iremonger void pkt_fwd_config_display(struct fwd_config *cfg);
933af75078fSIntel void rxtx_config_display(void);
934af75078fSIntel void fwd_config_setup(void);
935af75078fSIntel void set_def_fwd_config(void);
936a21d5a4bSDeclan Doherty void reconfig(portid_t new_port_id, unsigned socket_id);
937013af9b6SIntel int init_fwd_streams(void);
93803ce2c53SMatan Azrad void update_fwd_ports(portid_t new_pid);
939013af9b6SIntel 
940aac6f11fSWisam Jaddo void set_fwd_eth_peer(portid_t port_id, char *peer_addr);
941aac6f11fSWisam Jaddo 
942ae03d0d1SIvan Boule void port_mtu_set(portid_t port_id, uint16_t mtu);
94372a3dec7SGregory Etelson int port_action_handle_create(portid_t port_id, uint32_t id, bool indirect_list,
9444b61b877SBing Zhao 			      const struct rte_flow_indir_action_conf *conf,
94555509e3aSAndrey Vesnovaty 			      const struct rte_flow_action *action);
9464b61b877SBing Zhao int port_action_handle_destroy(portid_t port_id,
94755509e3aSAndrey Vesnovaty 			       uint32_t n, const uint32_t *action);
948f7352c17SDmitry Kozlyuk int port_action_handle_flush(portid_t port_id);
9494b61b877SBing Zhao struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id,
95055509e3aSAndrey Vesnovaty 							    uint32_t id);
9514b61b877SBing Zhao int port_action_handle_update(portid_t port_id, uint32_t id,
95255509e3aSAndrey Vesnovaty 			      const struct rte_flow_action *action);
9533e3edab5SGregory Etelson void
9543e3edab5SGregory Etelson port_action_handle_query_update(portid_t port_id, uint32_t id,
9553e3edab5SGregory Etelson 				enum rte_flow_query_update_mode qu_mode,
9563e3edab5SGregory Etelson 				const struct rte_flow_action *action);
9579ad3a41aSAlexander Kozyrev int port_flow_get_info(portid_t port_id);
9589ad3a41aSAlexander Kozyrev int port_flow_configure(portid_t port_id,
9599ad3a41aSAlexander Kozyrev 			const struct rte_flow_port_attr *port_attr,
9609ad3a41aSAlexander Kozyrev 			uint16_t nb_queue,
9619ad3a41aSAlexander Kozyrev 			const struct rte_flow_queue_attr *queue_attr);
96204cc665fSAlexander Kozyrev int port_flow_pattern_template_create(portid_t port_id, uint32_t id,
96304cc665fSAlexander Kozyrev 				      const struct rte_flow_pattern_template_attr *attr,
96404cc665fSAlexander Kozyrev 				      const struct rte_flow_item *pattern);
96504cc665fSAlexander Kozyrev int port_flow_pattern_template_destroy(portid_t port_id, uint32_t n,
96604cc665fSAlexander Kozyrev 				       const uint32_t *template);
9676d736e05SSuanming Mou int port_flow_pattern_template_flush(portid_t port_id);
96804cc665fSAlexander Kozyrev int port_flow_actions_template_create(portid_t port_id, uint32_t id,
96904cc665fSAlexander Kozyrev 				      const struct rte_flow_actions_template_attr *attr,
97004cc665fSAlexander Kozyrev 				      const struct rte_flow_action *actions,
97104cc665fSAlexander Kozyrev 				      const struct rte_flow_action *masks);
97204cc665fSAlexander Kozyrev int port_flow_actions_template_destroy(portid_t port_id, uint32_t n,
97304cc665fSAlexander Kozyrev 				       const uint32_t *template);
9746d736e05SSuanming Mou int port_flow_actions_template_flush(portid_t port_id);
975c4b38873SAlexander Kozyrev int port_flow_template_table_create(portid_t port_id, uint32_t id,
976c4b38873SAlexander Kozyrev 		   const struct rte_flow_template_table_attr *table_attr,
977c4b38873SAlexander Kozyrev 		   uint32_t nb_pattern_templates, uint32_t *pattern_templates,
978c4b38873SAlexander Kozyrev 		   uint32_t nb_actions_templates, uint32_t *actions_templates);
979c4b38873SAlexander Kozyrev int port_flow_template_table_destroy(portid_t port_id,
980c4b38873SAlexander Kozyrev 			    uint32_t n, const uint32_t *table);
9816d736e05SSuanming Mou int port_flow_template_table_flush(portid_t port_id);
982ecdc927bSAlexander Kozyrev int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
98360261a00SAlexander Kozyrev 			   bool postpone, uint32_t table_id, uint32_t rule_idx,
984ecdc927bSAlexander Kozyrev 			   uint32_t pattern_idx, uint32_t actions_idx,
985ecdc927bSAlexander Kozyrev 			   const struct rte_flow_item *pattern,
986ecdc927bSAlexander Kozyrev 			   const struct rte_flow_action *actions);
987ecdc927bSAlexander Kozyrev int port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,
988fd5392d8SEli Britstein 			    bool postpone, uint32_t n, const uint64_t *rule);
98977e7939aSAlexander Kozyrev int port_queue_flow_update(portid_t port_id, queueid_t queue_id,
99077e7939aSAlexander Kozyrev 			   bool postpone, uint32_t rule_idx, uint32_t actions_idx,
99177e7939aSAlexander Kozyrev 			   const struct rte_flow_action *actions);
992d906fff5SAlexander Kozyrev int port_queue_action_handle_create(portid_t port_id, uint32_t queue_id,
993d906fff5SAlexander Kozyrev 			bool postpone, uint32_t id,
994d906fff5SAlexander Kozyrev 			const struct rte_flow_indir_action_conf *conf,
995d906fff5SAlexander Kozyrev 			const struct rte_flow_action *action);
996d906fff5SAlexander Kozyrev int port_queue_action_handle_destroy(portid_t port_id,
997d906fff5SAlexander Kozyrev 				     uint32_t queue_id, bool postpone,
998d906fff5SAlexander Kozyrev 				     uint32_t n, const uint32_t *action);
999d906fff5SAlexander Kozyrev int port_queue_action_handle_update(portid_t port_id, uint32_t queue_id,
1000d906fff5SAlexander Kozyrev 				    bool postpone, uint32_t id,
1001d906fff5SAlexander Kozyrev 				    const struct rte_flow_action *action);
1002c9dc0384SSuanming Mou int port_queue_action_handle_query(portid_t port_id, uint32_t queue_id,
1003c9dc0384SSuanming Mou 				   bool postpone, uint32_t id);
10043e3edab5SGregory Etelson void
10053e3edab5SGregory Etelson port_queue_action_handle_query_update(portid_t port_id,
10063e3edab5SGregory Etelson 				      uint32_t queue_id, bool postpone,
10073e3edab5SGregory Etelson 				      uint32_t id,
10083e3edab5SGregory Etelson 				      enum rte_flow_query_update_mode qu_mode,
10093e3edab5SGregory Etelson 				      const struct rte_flow_action *action);
10109cbbee14SAlexander Kozyrev int port_queue_flow_push(portid_t port_id, queueid_t queue_id);
1011f9bf7dffSAlexander Kozyrev int port_queue_flow_pull(portid_t port_id, queueid_t queue_id);
1012966eb55eSMichael Baum void port_queue_flow_aged(portid_t port_id, uint32_t queue_id, uint8_t destroy);
1013938a184aSAdrien Mazarguil int port_flow_validate(portid_t port_id,
1014938a184aSAdrien Mazarguil 		       const struct rte_flow_attr *attr,
1015938a184aSAdrien Mazarguil 		       const struct rte_flow_item *pattern,
10161b9f2746SGregory Etelson 		       const struct rte_flow_action *actions,
10171b9f2746SGregory Etelson 		       const struct tunnel_ops *tunnel_ops);
1018938a184aSAdrien Mazarguil int port_flow_create(portid_t port_id,
1019938a184aSAdrien Mazarguil 		     const struct rte_flow_attr *attr,
1020938a184aSAdrien Mazarguil 		     const struct rte_flow_item *pattern,
10211b9f2746SGregory Etelson 		     const struct rte_flow_action *actions,
1022*8ac3a1cdSEli Britstein 		     const struct tunnel_ops *tunnel_ops,
1023*8ac3a1cdSEli Britstein 		     uintptr_t user_id);
10244b61b877SBing Zhao int port_action_handle_query(portid_t port_id, uint32_t id);
10250e459ffaSDong Zhou void update_age_action_context(const struct rte_flow_action *actions,
10260e459ffaSDong Zhou 		     struct port_flow *pf);
102768629be3SKe Zhang int mcast_addr_pool_destroy(portid_t port_id);
1028*8ac3a1cdSEli Britstein int port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule,
1029*8ac3a1cdSEli Britstein 		      bool is_user_id);
1030938a184aSAdrien Mazarguil int port_flow_flush(portid_t port_id);
1031bf085dcbSHaifei Luo int port_flow_dump(portid_t port_id, bool dump_all,
1032*8ac3a1cdSEli Britstein 			uint64_t rule, const char *file_name,
1033*8ac3a1cdSEli Britstein 			bool is_user_id);
1034fd5392d8SEli Britstein int port_flow_query(portid_t port_id, uint64_t rule,
1035*8ac3a1cdSEli Britstein 		    const struct rte_flow_action *action, bool is_user_id);
1036938a184aSAdrien Mazarguil void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group);
10370e459ffaSDong Zhou void port_flow_aged(portid_t port_id, uint8_t destroy);
10381b9f2746SGregory Etelson const char *port_flow_tunnel_type(struct rte_flow_tunnel *tunnel);
10391b9f2746SGregory Etelson struct port_flow_tunnel *
10401b9f2746SGregory Etelson port_flow_locate_tunnel(uint16_t port_id, struct rte_flow_tunnel *tun);
10411b9f2746SGregory Etelson void port_flow_tunnel_list(portid_t port_id);
10421b9f2746SGregory Etelson void port_flow_tunnel_destroy(portid_t port_id, uint32_t tunnel_id);
10431b9f2746SGregory Etelson void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops);
1044323f811aSAdrien Mazarguil int port_flow_isolate(portid_t port_id, int set);
1045f29fa2c5SHaifei Luo int port_meter_policy_add(portid_t port_id, uint32_t policy_id,
1046f29fa2c5SHaifei Luo 		const struct rte_flow_action *actions);
10479c4a0c18SAlexander Kozyrev struct rte_flow_meter_profile *port_meter_profile_get_by_id(portid_t port_id,
10489c4a0c18SAlexander Kozyrev 							    uint32_t id);
10499c4a0c18SAlexander Kozyrev struct rte_flow_meter_policy *port_meter_policy_get_by_id(portid_t port_id,
10509c4a0c18SAlexander Kozyrev 							  uint32_t id);
1051af75078fSIntel 
1052af75078fSIntel void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id);
1053af75078fSIntel void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id);
1054af75078fSIntel 
1055013af9b6SIntel int set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc);
1056013af9b6SIntel int set_fwd_lcores_mask(uint64_t lcoremask);
1057af75078fSIntel void set_fwd_lcores_number(uint16_t nb_lc);
1058af75078fSIntel 
1059af75078fSIntel void set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt);
1060af75078fSIntel void set_fwd_ports_mask(uint64_t portmask);
1061af75078fSIntel void set_fwd_ports_number(uint16_t nb_pt);
1062a8ef3e3aSBernard Iremonger int port_is_forwarding(portid_t port_id);
1063af75078fSIntel 
1064a47aa8b9SIntel void rx_vlan_strip_set(portid_t port_id, int on);
1065a47aa8b9SIntel void rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t queue_id, int on);
1066a47aa8b9SIntel 
1067a47aa8b9SIntel void rx_vlan_filter_set(portid_t port_id, int on);
1068af75078fSIntel void rx_vlan_all_filter_set(portid_t port_id, int on);
10692a0b4198SVivek Sharma void rx_vlan_qinq_strip_set(portid_t port_id, int on);
107064b01ee0SMichal Jastrzebski int rx_vft_set(portid_t port_id, uint16_t vlan_id, int on);
1071a47aa8b9SIntel void vlan_extend_set(portid_t port_id, int on);
107219b16e2fSHelin Zhang void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
107319b16e2fSHelin Zhang 		   uint16_t tp_id);
1074af75078fSIntel void tx_vlan_set(portid_t port_id, uint16_t vlan_id);
107592ebda07SHelin Zhang void tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer);
1076af75078fSIntel void tx_vlan_reset(portid_t port_id);
1077529ba951SHelin Zhang void tx_vlan_pvid_set(portid_t port_id, uint16_t vlan_id, int on);
1078ed30d9b6SIntel 
1079ed30d9b6SIntel void set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value);
1080ed30d9b6SIntel 
1081a4fd5eeeSElza Mathew void set_xstats_hide_zero(uint8_t on_off);
1082a4fd5eeeSElza Mathew 
1083bc700b67SDharmik Thakkar void set_record_core_cycles(uint8_t on_off);
10840e4b1963SDharmik Thakkar void set_record_burst_stats(uint8_t on_off);
1085af75078fSIntel void set_verbose_level(uint16_t vb_level);
10860f2096d7SViacheslav Ovsiienko void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
108752e2e7edSYuan Wang void set_rx_pkt_hdrs(unsigned int *seg_protos, unsigned int nb_segs);
108852e2e7edSYuan Wang void show_rx_pkt_hdrs(void);
10890f2096d7SViacheslav Ovsiienko void show_rx_pkt_segments(void);
109091c78e09SViacheslav Ovsiienko void set_rx_pkt_offsets(unsigned int *seg_offsets, unsigned int nb_offs);
109191c78e09SViacheslav Ovsiienko void show_rx_pkt_offsets(void);
10920f2096d7SViacheslav Ovsiienko void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
109379bec05bSKonstantin Ananyev void show_tx_pkt_segments(void);
10944940344dSViacheslav Ovsiienko void set_tx_pkt_times(unsigned int *tx_times);
10954940344dSViacheslav Ovsiienko void show_tx_pkt_times(void);
109679bec05bSKonstantin Ananyev void set_tx_pkt_split(const char *name);
1097ce0a4a1dSJie Zhou int parse_fec_mode(const char *name, uint32_t *fec_capa);
1098b19da32eSMin Hu (Connor) void show_fec_capability(uint32_t num, struct rte_eth_fec_capa *speed_fec_capa);
1099af75078fSIntel void set_nb_pkt_per_burst(uint16_t pkt_burst);
1100769ce6b1SThomas Monjalon char *list_pkt_forwarding_modes(void);
1101bf56fce1SZhihong Wang char *list_pkt_forwarding_retry_modes(void);
1102af75078fSIntel void set_pkt_forwarding_mode(const char *fwd_mode);
1103af75078fSIntel void start_packet_forwarding(int with_tx_first);
110453324971SDavid Marchand void fwd_stats_display(void);
110553324971SDavid Marchand void fwd_stats_reset(void);
1106af75078fSIntel void stop_packet_forwarding(void);
1107cfae07fdSOuyang Changchun void dev_set_link_up(portid_t pid);
1108cfae07fdSOuyang Changchun void dev_set_link_down(portid_t pid);
1109ce8d5614SIntel void init_port_config(void);
111041b05095SBernard Iremonger void set_port_slave_flag(portid_t slave_pid);
111141b05095SBernard Iremonger void clear_port_slave_flag(portid_t slave_pid);
11120e545d30SBernard Iremonger uint8_t port_is_bonding_slave(portid_t slave_pid);
11130e545d30SBernard Iremonger 
11141a572499SJingjing Wu int init_port_dcb_config(portid_t pid, enum dcb_mode_enable dcb_mode,
11151a572499SJingjing Wu 		     enum rte_eth_nb_tcs num_tcs,
11161a572499SJingjing Wu 		     uint8_t pfc_en);
1117148f963fSBruce Richardson int start_port(portid_t pid);
1118ce8d5614SIntel void stop_port(portid_t pid);
1119ce8d5614SIntel void close_port(portid_t pid);
112097f1e196SWei Dai void reset_port(portid_t pid);
1121edab33b1STetsuya Mukawa void attach_port(char *identifier);
11225edee5f6SThomas Monjalon void detach_devargs(char *identifier);
1123f8e5baa2SThomas Monjalon void detach_port_device(portid_t port_id);
1124ce8d5614SIntel int all_ports_stopped(void);
11256018eb8cSShahaf Shuler int port_is_stopped(portid_t port_id);
11265f4ec54fSChen Jing D(Mark) int port_is_started(portid_t port_id);
1127af75078fSIntel void pmd_test_exit(void);
11281be514fbSAndrew Rybchenko #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
1129af75078fSIntel void fdir_get_infos(portid_t port_id);
11301be514fbSAndrew Rybchenko #endif
113166c59490SHelin Zhang void port_rss_reta_info(portid_t port_id,
113266c59490SHelin Zhang 			struct rte_eth_rss_reta_entry64 *reta_conf,
113366c59490SHelin Zhang 			uint16_t nb_entries);
11346a18e1afSOuyang Changchun 
11357741e4cfSIntel void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);
1136af75078fSIntel 
11372befc67fSViacheslav Ovsiienko int
11382befc67fSViacheslav Ovsiienko rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
11392befc67fSViacheslav Ovsiienko 	       uint16_t nb_rx_desc, unsigned int socket_id,
11402befc67fSViacheslav Ovsiienko 	       struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp);
11412befc67fSViacheslav Ovsiienko 
11423a26e41eSSatha Rao int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint32_t rate);
11433a26e41eSSatha Rao int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint32_t rate,
11446a18e1afSOuyang Changchun 				uint64_t q_msk);
11456a18e1afSOuyang Changchun 
1146bc70e559SSpike Du int set_rxq_avail_thresh(portid_t port_id, uint16_t queue_id,
1147bc70e559SSpike Du 			 uint8_t avail_thresh);
1148bc70e559SSpike Du 
11495b4557ecSFerruh Yigit void port_rss_hash_conf_show(portid_t port_id, int show_rss_key);
11508205e241SNelio Laranjeiro void port_rss_hash_key_update(portid_t port_id, char rss_type[],
11513529e8f3SNatanael Copa 			      uint8_t *hash_key, uint8_t hash_key_len);
11525f4ec54fSChen Jing D(Mark) int rx_queue_id_is_invalid(queueid_t rxq_id);
11535f4ec54fSChen Jing D(Mark) int tx_queue_id_is_invalid(queueid_t txq_id);
11546970401eSDavid Marchand #ifdef RTE_LIB_GRO
1155b7091f1dSJiayu Hu void setup_gro(const char *onoff, portid_t port_id);
1156b7091f1dSJiayu Hu void setup_gro_flush_cycles(uint8_t cycles);
1157b7091f1dSJiayu Hu void show_gro(portid_t port_id);
11586970401eSDavid Marchand #endif
11596970401eSDavid Marchand #ifdef RTE_LIB_GSO
116052f38a20SJiayu Hu void setup_gso(const char *mode, portid_t port_id);
11616970401eSDavid Marchand #endif
11626f51deb9SIvan Ilchenko int eth_dev_info_get_print_err(uint16_t port_id,
11636f51deb9SIvan Ilchenko 			struct rte_eth_dev_info *dev_info);
1164655eae01SJie Wang int eth_dev_conf_get_print_err(uint16_t port_id,
1165655eae01SJie Wang 			struct rte_eth_conf *dev_conf);
116634fc1051SIvan Ilchenko void eth_set_promisc_mode(uint16_t port_id, int enable);
11678835806dSIvan Ilchenko void eth_set_allmulticast_mode(uint16_t port, int enable);
1168e661a08bSIgor Romanov int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link);
1169a5279d25SIgor Romanov int eth_macaddr_get_print_err(uint16_t port_id,
1170a5279d25SIgor Romanov 			struct rte_ether_addr *mac_addr);
11716f51deb9SIvan Ilchenko 
1172e1d44d0aSKalesh AP /* Functions to display the set of MAC addresses added to a port*/
1173e1d44d0aSKalesh AP void show_macs(portid_t port_id);
1174e1d44d0aSKalesh AP void show_mcast_macs(portid_t port_id);
117516321de0SIvan Boule 
11768fff6675SIvan Boule /* Functions to manage the set of filtered Multicast MAC addresses */
11776d13ea8eSOlivier Matz void mcast_addr_add(portid_t port_id, struct rte_ether_addr *mc_addr);
11786d13ea8eSOlivier Matz void mcast_addr_remove(portid_t port_id, struct rte_ether_addr *mc_addr);
117928caa76aSZhiyong Yang void port_dcb_info_display(portid_t port_id);
11808fff6675SIvan Boule 
11819999dc6fSKirill Rybalchenko uint8_t *open_file(const char *file_path, uint32_t *size);
11829999dc6fSKirill Rybalchenko int save_file(const char *file_path, uint8_t *buf, uint32_t size);
11839999dc6fSKirill Rybalchenko int close_file(uint8_t *buf);
1184a92a5a2cSBeilei Xing 
1185edab33b1STetsuya Mukawa enum print_warning {
1186edab33b1STetsuya Mukawa 	ENABLED_WARN = 0,
1187edab33b1STetsuya Mukawa 	DISABLED_WARN
1188edab33b1STetsuya Mukawa };
1189edab33b1STetsuya Mukawa int port_id_is_invalid(portid_t port_id, enum print_warning warning);
11908f3c4176SMatan Azrad void print_valid_ports(void);
1191c9cafcc8SShahaf Shuler int new_socket_id(unsigned int socket_id);
1192edab33b1STetsuya Mukawa 
11933f7311baSWei Dai queueid_t get_allowed_max_nb_rxq(portid_t *pid);
11943f7311baSWei Dai int check_nb_rxq(queueid_t rxq);
119536db4f6cSWei Dai queueid_t get_allowed_max_nb_txq(portid_t *pid);
119636db4f6cSWei Dai int check_nb_txq(queueid_t txq);
119799e040d3SLijun Ou int check_nb_rxd(queueid_t rxd);
119899e040d3SLijun Ou int check_nb_txd(queueid_t txd);
11991c69df45SOri Kam queueid_t get_allowed_max_nb_hairpinq(portid_t *pid);
12001c69df45SOri Kam int check_nb_hairpinq(queueid_t hairpinq);
12013f7311baSWei Dai 
1202c77ad9deSRaslan Darawsheh uint16_t dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
1203c77ad9deSRaslan Darawsheh 		      uint16_t nb_pkts, __rte_unused uint16_t max_pkts,
1204c77ad9deSRaslan Darawsheh 		      __rte_unused void *user_param);
1205c77ad9deSRaslan Darawsheh 
1206c77ad9deSRaslan Darawsheh uint16_t dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
1207c77ad9deSRaslan Darawsheh 		      uint16_t nb_pkts, __rte_unused void *user_param);
1208c77ad9deSRaslan Darawsheh 
1209c77ad9deSRaslan Darawsheh void add_rx_dump_callbacks(portid_t portid);
1210c77ad9deSRaslan Darawsheh void remove_rx_dump_callbacks(portid_t portid);
1211c77ad9deSRaslan Darawsheh void add_tx_dump_callbacks(portid_t portid);
1212c77ad9deSRaslan Darawsheh void remove_tx_dump_callbacks(portid_t portid);
1213b5b38ed8SRaslan Darawsheh void configure_rxtx_dump_callbacks(uint16_t verbose);
1214d862c45bSRaslan Darawsheh 
12151e45c908SDekel Peled uint16_t tx_pkt_set_md(uint16_t port_id, __rte_unused uint16_t queue,
12161e45c908SDekel Peled 		       struct rte_mbuf *pkts[], uint16_t nb_pkts,
12171e45c908SDekel Peled 		       __rte_unused void *user_param);
12181e45c908SDekel Peled void add_tx_md_callback(portid_t portid);
12191e45c908SDekel Peled void remove_tx_md_callback(portid_t portid);
12201e45c908SDekel Peled 
1221b57b66a9SOri Kam uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,
1222b57b66a9SOri Kam 			 struct rte_mbuf *pkts[], uint16_t nb_pkts,
1223b57b66a9SOri Kam 			 __rte_unused void *user_param);
1224b57b66a9SOri Kam void add_tx_dynf_callback(portid_t portid);
1225b57b66a9SOri Kam void remove_tx_dynf_callback(portid_t portid);
1226b563c142SFerruh Yigit int update_mtu_from_frame_size(portid_t portid, uint32_t max_rx_pktlen);
122759f3a8acSGregory Etelson void flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename);
122859f3a8acSGregory Etelson void flex_item_destroy(portid_t port_id, uint16_t flex_id);
122959f3a8acSGregory Etelson void port_flex_item_flush(portid_t port_id);
1230b57b66a9SOri Kam 
12312566c33cSGregory Etelson extern int flow_parse(const char *src, void *result, unsigned int size,
12322566c33cSGregory Etelson 		      struct rte_flow_attr **attr,
12332566c33cSGregory Etelson 		      struct rte_flow_item **pattern,
12342566c33cSGregory Etelson 		      struct rte_flow_action **actions);
12352566c33cSGregory Etelson 
12369ad341b5SHuisong Li uint64_t str_to_rsstypes(const char *str);
12373c23ee6cSHuisong Li const char *rsstypes_to_str(uint64_t rss_type);
12383c23ee6cSHuisong Li 
1239119786aaSFerruh Yigit uint16_t str_to_flowtype(const char *string);
1240119786aaSFerruh Yigit const char *flowtype_to_str(uint16_t flow_type);
1241119786aaSFerruh Yigit 
1242592ab76fSDavid Marchand /* For registering driver specific testpmd commands. */
1243592ab76fSDavid Marchand struct testpmd_driver_commands {
1244592ab76fSDavid Marchand 	TAILQ_ENTRY(testpmd_driver_commands) next;
1245592ab76fSDavid Marchand 	struct {
1246592ab76fSDavid Marchand 		cmdline_parse_inst_t *ctx;
1247592ab76fSDavid Marchand 		const char *help;
1248592ab76fSDavid Marchand 	} commands[];
1249592ab76fSDavid Marchand };
1250592ab76fSDavid Marchand 
1251592ab76fSDavid Marchand void testpmd_add_driver_commands(struct testpmd_driver_commands *c);
1252592ab76fSDavid Marchand #define TESTPMD_ADD_DRIVER_COMMANDS(c) \
1253592ab76fSDavid Marchand RTE_INIT(__##c) \
1254592ab76fSDavid Marchand { \
1255592ab76fSDavid Marchand 	testpmd_add_driver_commands(&c); \
1256592ab76fSDavid Marchand }
1257592ab76fSDavid Marchand 
1258af75078fSIntel /*
1259af75078fSIntel  * Work-around of a compilation error with ICC on invocations of the
1260af75078fSIntel  * rte_be_to_cpu_16() function.
1261af75078fSIntel  */
1262af75078fSIntel #ifdef __GCC__
1263af75078fSIntel #define RTE_BE_TO_CPU_16(be_16_v)  rte_be_to_cpu_16((be_16_v))
1264af75078fSIntel #define RTE_CPU_TO_BE_16(cpu_16_v) rte_cpu_to_be_16((cpu_16_v))
1265af75078fSIntel #else
126644eb9456SThomas Monjalon #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
1267af75078fSIntel #define RTE_BE_TO_CPU_16(be_16_v)  (be_16_v)
1268af75078fSIntel #define RTE_CPU_TO_BE_16(cpu_16_v) (cpu_16_v)
1269af75078fSIntel #else
1270af75078fSIntel #define RTE_BE_TO_CPU_16(be_16_v) \
1271af75078fSIntel 	(uint16_t) ((((be_16_v) & 0xFF) << 8) | ((be_16_v) >> 8))
1272af75078fSIntel #define RTE_CPU_TO_BE_16(cpu_16_v) \
1273af75078fSIntel 	(uint16_t) ((((cpu_16_v) & 0xFF) << 8) | ((cpu_16_v) >> 8))
1274af75078fSIntel #endif
1275af75078fSIntel #endif /* __GCC__ */
1276af75078fSIntel 
1277285fd101SOlivier Matz #define TESTPMD_LOG(level, fmt, args...) \
1278285fd101SOlivier Matz 	rte_log(RTE_LOG_ ## level, testpmd_logtype, "testpmd: " fmt, ## args)
1279285fd101SOlivier Matz 
1280af75078fSIntel #endif /* _TESTPMD_H_ */
1281