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. */ 228*fd5392d8SEli Britstein uint64_t id; /**< Flow rule ID. */ 22977e7939aSAlexander Kozyrev struct port_table *table; /**< Flow table. */ 230938a184aSAdrien Mazarguil struct rte_flow *flow; /**< Opaque flow object returned by PMD. */ 231de956d5eSMatan Azrad struct rte_flow_conv_rule rule; /**< Saved flow rule description. */ 232de956d5eSMatan Azrad enum age_action_context_type age_type; /**< Age action context type. */ 23344b257ffSAdrien Mazarguil uint8_t data[]; /**< Storage for flow rule description */ 234938a184aSAdrien Mazarguil }; 235938a184aSAdrien Mazarguil 2364b61b877SBing Zhao /* Descriptor for indirect action */ 2374b61b877SBing Zhao struct port_indirect_action { 2384b61b877SBing Zhao struct port_indirect_action *next; /**< Next flow in list. */ 2394b61b877SBing Zhao uint32_t id; /**< Indirect action ID. */ 24055509e3aSAndrey Vesnovaty enum rte_flow_action_type type; /**< Action type. */ 24172a3dec7SGregory Etelson union { 24272a3dec7SGregory Etelson struct rte_flow_action_handle *handle; 24372a3dec7SGregory Etelson /**< Indirect action handle. */ 24472a3dec7SGregory Etelson struct rte_flow_action_list_handle *list_handle; 24572a3dec7SGregory Etelson /**< Indirect action list handle*/ 24672a3dec7SGregory Etelson }; 247de956d5eSMatan Azrad enum age_action_context_type age_type; /**< Age action context type. */ 24855509e3aSAndrey Vesnovaty }; 24955509e3aSAndrey Vesnovaty 250c9dc0384SSuanming Mou /* Descriptor for action query data. */ 251c9dc0384SSuanming Mou union port_action_query { 252c9dc0384SSuanming Mou struct rte_flow_query_count count; 253c9dc0384SSuanming Mou struct rte_flow_query_age age; 254c9dc0384SSuanming Mou struct rte_flow_action_conntrack ct; 2553e3edab5SGregory Etelson struct rte_flow_query_quota quota; 256c9dc0384SSuanming Mou }; 257c9dc0384SSuanming Mou 258c9dc0384SSuanming Mou /* Descriptor for queue job. */ 259c9dc0384SSuanming Mou struct queue_job { 260c9dc0384SSuanming Mou uint32_t type; /**< Job type. */ 261c9dc0384SSuanming Mou union { 262c9dc0384SSuanming Mou struct port_flow *pf; 263c9dc0384SSuanming Mou struct port_indirect_action *pia; 264c9dc0384SSuanming Mou }; 265c9dc0384SSuanming Mou union port_action_query query; 266c9dc0384SSuanming Mou }; 267c9dc0384SSuanming Mou 2681b9f2746SGregory Etelson struct port_flow_tunnel { 2691b9f2746SGregory Etelson LIST_ENTRY(port_flow_tunnel) chain; 2701b9f2746SGregory Etelson struct rte_flow_action *pmd_actions; 2711b9f2746SGregory Etelson struct rte_flow_item *pmd_items; 2721b9f2746SGregory Etelson uint32_t id; 2731b9f2746SGregory Etelson uint32_t num_pmd_actions; 2741b9f2746SGregory Etelson uint32_t num_pmd_items; 2751b9f2746SGregory Etelson struct rte_flow_tunnel tunnel; 2761b9f2746SGregory Etelson struct rte_flow_action *actions; 2771b9f2746SGregory Etelson struct rte_flow_item *items; 2781b9f2746SGregory Etelson }; 2791b9f2746SGregory Etelson 2801b9f2746SGregory Etelson struct tunnel_ops { 2811b9f2746SGregory Etelson uint32_t id; 2821b9f2746SGregory Etelson char type[16]; 2831b9f2746SGregory Etelson uint32_t enabled:1; 2841b9f2746SGregory Etelson uint32_t actions:1; 2851b9f2746SGregory Etelson uint32_t items:1; 2861b9f2746SGregory Etelson }; 2871b9f2746SGregory Etelson 28863b72657SIvan Ilchenko /** Information for an extended statistics to show. */ 28963b72657SIvan Ilchenko struct xstat_display_info { 29063b72657SIvan Ilchenko /** Supported xstats IDs in the order of xstats_display */ 29163b72657SIvan Ilchenko uint64_t *ids_supp; 29263b72657SIvan Ilchenko size_t ids_supp_sz; 29363b72657SIvan Ilchenko uint64_t *prev_values; 29463b72657SIvan Ilchenko uint64_t *curr_values; 29563b72657SIvan Ilchenko uint64_t prev_ns; 29663b72657SIvan Ilchenko bool allocated; 29763b72657SIvan Ilchenko }; 29863b72657SIvan Ilchenko 2993c4426dbSDmitry Kozlyuk /** RX queue configuration and state. */ 3003c4426dbSDmitry Kozlyuk struct port_rxqueue { 3013c4426dbSDmitry Kozlyuk struct rte_eth_rxconf conf; 3023c4426dbSDmitry Kozlyuk uint8_t state; /**< RTE_ETH_QUEUE_STATE_* value. */ 3033c4426dbSDmitry Kozlyuk }; 3043c4426dbSDmitry Kozlyuk 3053c4426dbSDmitry Kozlyuk /** TX queue configuration and state. */ 3063c4426dbSDmitry Kozlyuk struct port_txqueue { 3073c4426dbSDmitry Kozlyuk struct rte_eth_txconf conf; 3083c4426dbSDmitry Kozlyuk uint8_t state; /**< RTE_ETH_QUEUE_STATE_* value. */ 3093c4426dbSDmitry Kozlyuk }; 3103c4426dbSDmitry Kozlyuk 311af75078fSIntel /** 312af75078fSIntel * The data structure associated with each port. 313af75078fSIntel */ 314af75078fSIntel struct rte_port { 3151bcb7ba9SDavid Marchand struct rte_eth_dev_info dev_info; /**< Device info + driver name */ 316af75078fSIntel struct rte_eth_conf dev_conf; /**< Port configuration. */ 3176d13ea8eSOlivier Matz struct rte_ether_addr eth_addr; /**< Port ethernet address */ 318af75078fSIntel struct rte_eth_stats stats; /**< Last port statistics */ 319af75078fSIntel unsigned int socket_id; /**< For NUMA support */ 3203eecba26SShahaf Shuler uint16_t parse_tunnel:1; /**< Parse internal headers */ 3210f62d635SJianfeng Tan uint16_t tso_segsz; /**< Segmentation offload MSS for non-tunneled packets. */ 3220f62d635SJianfeng Tan uint16_t tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */ 32392ebda07SHelin Zhang uint16_t tx_vlan_id;/**< The tag ID */ 32492ebda07SHelin Zhang uint16_t tx_vlan_id_outer;/**< The outer tag ID */ 325ce8d5614SIntel volatile uint16_t port_status; /**< port started or not */ 3264f1ed78eSThomas Monjalon uint8_t need_setup; /**< port just attached */ 327ce8d5614SIntel uint8_t need_reconfig; /**< need reconfiguring port or not */ 328ce8d5614SIntel uint8_t need_reconfig_queues; /**< need reconfiguring queues or not */ 329ce8d5614SIntel uint8_t rss_flag; /**< enable rss or not */ 3307741e4cfSIntel uint8_t dcb_flag; /**< enable dcb */ 3319e6b36c3SDavid Marchand uint16_t nb_rx_desc[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue rx desc number */ 3329e6b36c3SDavid Marchand uint16_t nb_tx_desc[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue tx desc number */ 3333c4426dbSDmitry Kozlyuk struct port_rxqueue rxq[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue Rx config and state */ 3343c4426dbSDmitry Kozlyuk struct port_txqueue txq[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue Tx config and state */ 3356d13ea8eSOlivier Matz struct rte_ether_addr *mc_addr_pool; /**< pool of multicast addrs */ 3368fff6675SIvan Boule uint32_t mc_addr_nb; /**< nb. of addr. in mc_addr_pool */ 3379ad3a41aSAlexander Kozyrev queueid_t queue_nb; /**< nb. of queues for flow rules */ 3389ad3a41aSAlexander Kozyrev uint32_t queue_sz; /**< size of a queue for flow rules */ 339e46372d7SHuisong Li uint8_t slave_flag : 1, /**< bonding slave port */ 340236bc417SGregory Etelson bond_flag : 1, /**< port is bond device */ 3417c06f1abSHuisong Li fwd_mac_swap : 1, /**< swap packet MAC before forward */ 3427c06f1abSHuisong Li update_conf : 1; /**< need to update bonding device configuration */ 34304cc665fSAlexander Kozyrev struct port_template *pattern_templ_list; /**< Pattern templates. */ 34404cc665fSAlexander Kozyrev struct port_template *actions_templ_list; /**< Actions templates. */ 345c4b38873SAlexander Kozyrev struct port_table *table_list; /**< Flow tables. */ 346938a184aSAdrien Mazarguil struct port_flow *flow_list; /**< Associated flows. */ 3474b61b877SBing Zhao struct port_indirect_action *actions_list; 3484b61b877SBing Zhao /**< Associated indirect actions. */ 3491b9f2746SGregory Etelson LIST_HEAD(, port_flow_tunnel) flow_tunnel_list; 3509e6b36c3SDavid Marchand const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1]; 3519e6b36c3SDavid Marchand const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1]; 352c18feafaSDekel Peled /**< metadata value to insert in Tx packets. */ 3539bf26e13SViacheslav Ovsiienko uint32_t tx_metadata; 3549e6b36c3SDavid Marchand const struct rte_eth_rxtx_callback *tx_set_md_cb[RTE_MAX_QUEUES_PER_PORT+1]; 355b57b66a9SOri Kam /**< dynamic flags. */ 356b57b66a9SOri Kam uint64_t mbuf_dynf; 357b57b66a9SOri Kam const struct rte_eth_rxtx_callback *tx_set_dynf_cb[RTE_MAX_QUEUES_PER_PORT+1]; 35863b72657SIvan Ilchenko struct xstat_display_info xstats_info; 359af75078fSIntel }; 360af75078fSIntel 361af75078fSIntel /** 362af75078fSIntel * The data structure associated with each forwarding logical core. 363af75078fSIntel * The logical cores are internally numbered by a core index from 0 to 364af75078fSIntel * the maximum number of logical cores - 1. 365af75078fSIntel * The system CPU identifier of all logical cores are setup in a global 366af75078fSIntel * CPU id. configuration table. 367af75078fSIntel */ 368af75078fSIntel struct fwd_lcore { 3696970401eSDavid Marchand #ifdef RTE_LIB_GSO 37052f38a20SJiayu Hu struct rte_gso_ctx gso_ctx; /**< GSO context */ 3716970401eSDavid Marchand #endif 372af75078fSIntel struct rte_mempool *mbp; /**< The mbuf pool to use by this core */ 3736970401eSDavid Marchand #ifdef RTE_LIB_GRO 374b7091f1dSJiayu Hu void *gro_ctx; /**< GRO context */ 3756970401eSDavid Marchand #endif 376af75078fSIntel streamid_t stream_idx; /**< index of 1st stream in "fwd_streams" */ 377af75078fSIntel streamid_t stream_nb; /**< number of streams in "fwd_streams" */ 378af75078fSIntel lcoreid_t cpuid_idx; /**< index of logical core in CPU id table */ 379af75078fSIntel volatile char stopped; /**< stop forwarding when set */ 38099a4974aSRobin Jarry uint64_t total_cycles; /**< used with --record-core-cycles */ 381af75078fSIntel }; 382af75078fSIntel 383af75078fSIntel /* 384af75078fSIntel * Forwarding mode operations: 385af75078fSIntel * - IO forwarding mode (default mode) 386af75078fSIntel * Forwards packets unchanged. 387af75078fSIntel * 388af75078fSIntel * - MAC forwarding mode 389af75078fSIntel * Set the source and the destination Ethernet addresses of packets 390af75078fSIntel * before forwarding them. 391af75078fSIntel * 392af75078fSIntel * - IEEE1588 forwarding mode 393af75078fSIntel * Check that received IEEE1588 Precise Time Protocol (PTP) packets are 394af75078fSIntel * filtered and timestamped by the hardware. 395af75078fSIntel * Forwards packets unchanged on the same port. 396af75078fSIntel * Check that sent IEEE1588 PTP packets are timestamped by the hardware. 397af75078fSIntel */ 398a78040c9SAlvin Zhang typedef int (*port_fwd_begin_t)(portid_t pi); 399af75078fSIntel typedef void (*port_fwd_end_t)(portid_t pi); 4003c4426dbSDmitry Kozlyuk typedef void (*stream_init_t)(struct fwd_stream *fs); 40106c20561SDavid Marchand typedef bool (*packet_fwd_t)(struct fwd_stream *fs); 402af75078fSIntel 403af75078fSIntel struct fwd_engine { 404af75078fSIntel const char *fwd_mode_name; /**< Forwarding mode name. */ 405af75078fSIntel port_fwd_begin_t port_fwd_begin; /**< NULL if nothing special to do. */ 406af75078fSIntel port_fwd_end_t port_fwd_end; /**< NULL if nothing special to do. */ 4073c4426dbSDmitry Kozlyuk stream_init_t stream_init; /**< NULL if nothing special to do. */ 408af75078fSIntel packet_fwd_t packet_fwd; /**< Mandatory. */ 4091d343c19SMike Pattrick const char *status; /**< NULL if nothing to display. */ 410af75078fSIntel }; 411af75078fSIntel 412180ba023SDavid Marchand void common_fwd_stream_init(struct fwd_stream *fs); 413180ba023SDavid Marchand 41459f3a8acSGregory Etelson #define FLEX_ITEM_MAX_SAMPLES_NUM 16 41559f3a8acSGregory Etelson #define FLEX_ITEM_MAX_LINKS_NUM 16 41659f3a8acSGregory Etelson #define FLEX_MAX_FLOW_PATTERN_LENGTH 64 41759f3a8acSGregory Etelson #define FLEX_MAX_PARSERS_NUM 8 41859f3a8acSGregory Etelson #define FLEX_MAX_PATTERNS_NUM 64 41959f3a8acSGregory Etelson #define FLEX_PARSER_ERR ((struct flex_item *)-1) 42059f3a8acSGregory Etelson 42159f3a8acSGregory Etelson struct flex_item { 42259f3a8acSGregory Etelson struct rte_flow_item_flex_conf flex_conf; 42359f3a8acSGregory Etelson struct rte_flow_item_flex_handle *flex_handle; 42459f3a8acSGregory Etelson uint32_t flex_id; 42559f3a8acSGregory Etelson }; 42659f3a8acSGregory Etelson 42759f3a8acSGregory Etelson struct flex_pattern { 42859f3a8acSGregory Etelson struct rte_flow_item_flex spec, mask; 42959f3a8acSGregory Etelson uint8_t spec_pattern[FLEX_MAX_FLOW_PATTERN_LENGTH]; 43059f3a8acSGregory Etelson uint8_t mask_pattern[FLEX_MAX_FLOW_PATTERN_LENGTH]; 43159f3a8acSGregory Etelson }; 43259f3a8acSGregory Etelson extern struct flex_item *flex_items[RTE_MAX_ETHPORTS][FLEX_MAX_PARSERS_NUM]; 43359f3a8acSGregory Etelson extern struct flex_pattern flex_patterns[FLEX_MAX_PATTERNS_NUM]; 43459f3a8acSGregory Etelson 435bf56fce1SZhihong Wang #define BURST_TX_WAIT_US 1 436bf56fce1SZhihong Wang #define BURST_TX_RETRIES 64 437bf56fce1SZhihong Wang 438bf56fce1SZhihong Wang extern uint32_t burst_tx_delay_time; 439bf56fce1SZhihong Wang extern uint32_t burst_tx_retry_num; 440bf56fce1SZhihong Wang 441af75078fSIntel extern struct fwd_engine io_fwd_engine; 442af75078fSIntel extern struct fwd_engine mac_fwd_engine; 443d47388f1SCyril Chemparathy extern struct fwd_engine mac_swap_engine; 444e9e23a61SCyril Chemparathy extern struct fwd_engine flow_gen_engine; 445af75078fSIntel extern struct fwd_engine rx_only_engine; 446af75078fSIntel extern struct fwd_engine tx_only_engine; 447af75078fSIntel extern struct fwd_engine csum_fwd_engine; 448168dfa61SIvan Boule extern struct fwd_engine icmp_echo_engine; 4493c156061SJens Freimann extern struct fwd_engine noisy_vnf_engine; 4502564abdaSShiri Kuzin extern struct fwd_engine five_tuple_swap_fwd_engine; 451af75078fSIntel #ifdef RTE_LIBRTE_IEEE1588 452af75078fSIntel extern struct fwd_engine ieee1588_fwd_engine; 453af75078fSIntel #endif 45459840375SXueming Li extern struct fwd_engine shared_rxq_engine; 455af75078fSIntel 456af75078fSIntel extern struct fwd_engine * fwd_engines[]; /**< NULL terminated array. */ 45730626defSXiaoyu Min extern cmdline_parse_inst_t cmd_set_raw; 458739e045bSXiaoyu Min extern cmdline_parse_inst_t cmd_show_set_raw; 459739e045bSXiaoyu Min extern cmdline_parse_inst_t cmd_show_set_raw_all; 46059f3a8acSGregory Etelson extern cmdline_parse_inst_t cmd_set_flex_is_pattern; 46159f3a8acSGregory Etelson extern cmdline_parse_inst_t cmd_set_flex_spec_pattern; 462af75078fSIntel 46359fcf854SShahaf Shuler extern uint16_t mempool_flags; 46459fcf854SShahaf Shuler 465af75078fSIntel /** 466af75078fSIntel * Forwarding Configuration 467af75078fSIntel * 468af75078fSIntel */ 469af75078fSIntel struct fwd_config { 470af75078fSIntel struct fwd_engine *fwd_eng; /**< Packet forwarding mode. */ 471af75078fSIntel streamid_t nb_fwd_streams; /**< Nb. of forward streams to process. */ 472af75078fSIntel lcoreid_t nb_fwd_lcores; /**< Nb. of logical cores to launch. */ 473af75078fSIntel portid_t nb_fwd_ports; /**< Nb. of ports involved. */ 474af75078fSIntel }; 475af75078fSIntel 476900550deSIntel /** 477900550deSIntel * DCB mode enable 478900550deSIntel */ 479900550deSIntel enum dcb_mode_enable 480900550deSIntel { 481900550deSIntel DCB_VT_ENABLED, 482900550deSIntel DCB_ENABLED 483900550deSIntel }; 484900550deSIntel 485a4fd5eeeSElza Mathew extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */ 486a4fd5eeeSElza Mathew 487af75078fSIntel /* globals used for configuration */ 488bc700b67SDharmik Thakkar extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */ 4890e4b1963SDharmik Thakkar extern uint8_t record_burst_stats; /**< Enables display of RX and TX bursts */ 490af75078fSIntel extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */ 491285fd101SOlivier Matz extern int testpmd_logtype; /**< Log type for testpmd logs */ 492af75078fSIntel extern uint8_t interactive; 493ca7feb22SCyril Chemparathy extern uint8_t auto_start; 49499cabef0SPablo de Lara extern uint8_t tx_first; 49581ef862bSAllain Legacy extern char cmdline_filename[PATH_MAX]; /**< offline commands file */ 496af75078fSIntel extern uint8_t numa_support; /**< set by "--numa" parameter */ 497af75078fSIntel extern uint16_t port_topology; /**< set by "--port-topology" parameter */ 4987741e4cfSIntel extern uint8_t no_flush_rx; /**<set by "--no-flush-rx" parameter */ 4997ee3e944SVasily Philipov extern uint8_t flow_isolate_all; /**< set by "--flow-isolate-all */ 500543df472SChengwen Feng extern uint8_t no_flow_flush; /**< set by "--disable-flow-flush" parameter */ 501c7f5dba7SAnatoly Burakov extern uint8_t mp_alloc_type; 502c7f5dba7SAnatoly Burakov /**< set by "--mp-anon" or "--mp-alloc" parameter */ 503b7b78a08SAjit Khaparde extern uint32_t eth_link_speed; 504bc202406SDavid Marchand extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */ 5056937d210SStephen Hemminger extern uint8_t no_device_start; /**<set by "--disable-device-start" parameter */ 5062950a769SDeclan Doherty extern volatile int test_done; /* stop packet forwarding when set to 1. */ 5078ea656f8SGaetan Rivet extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */ 508284c908cSGaetan Rivet extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */ 5093af72783SGaetan Rivet extern uint32_t event_print_mask; 5103af72783SGaetan Rivet /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */ 5114f1ed78eSThomas Monjalon extern bool setup_on_probe_event; /**< disabled by port setup-on iterator */ 512e505d84cSAnatoly Burakov extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */ 513e505d84cSAnatoly Burakov extern int do_mlockall; /**< set by "--mlockall" or "--no-mlockall" parameter */ 514b0a9354aSPavan Nikhilesh extern uint8_t clear_ptypes; /**< disabled by set ptype cmd */ 515af75078fSIntel 516b6ea6408SIntel /* 517b6ea6408SIntel * Store specified sockets on which memory pool to be used by ports 518b6ea6408SIntel * is allocated. 519b6ea6408SIntel */ 52063531389SGeorgios Katsikas extern uint8_t port_numa[RTE_MAX_ETHPORTS]; 521b6ea6408SIntel 522b6ea6408SIntel /* 523b6ea6408SIntel * Store specified sockets on which RX ring to be used by ports 524b6ea6408SIntel * is allocated. 525b6ea6408SIntel */ 52663531389SGeorgios Katsikas extern uint8_t rxring_numa[RTE_MAX_ETHPORTS]; 527b6ea6408SIntel 528b6ea6408SIntel /* 529b6ea6408SIntel * Store specified sockets on which TX ring to be used by ports 530b6ea6408SIntel * is allocated. 531b6ea6408SIntel */ 53263531389SGeorgios Katsikas extern uint8_t txring_numa[RTE_MAX_ETHPORTS]; 533b6ea6408SIntel 534b6ea6408SIntel extern uint8_t socket_num; 535b6ea6408SIntel 536af75078fSIntel /* 537af75078fSIntel * Configuration of logical cores: 538af75078fSIntel * nb_fwd_lcores <= nb_cfg_lcores <= nb_lcores 539af75078fSIntel */ 540af75078fSIntel extern lcoreid_t nb_lcores; /**< Number of logical cores probed at init time. */ 541af75078fSIntel extern lcoreid_t nb_cfg_lcores; /**< Number of configured logical cores. */ 542af75078fSIntel extern lcoreid_t nb_fwd_lcores; /**< Number of forwarding logical cores. */ 543af75078fSIntel extern unsigned int fwd_lcores_cpuids[RTE_MAX_LCORE]; 544c9cafcc8SShahaf Shuler extern unsigned int num_sockets; 545c9cafcc8SShahaf Shuler extern unsigned int socket_ids[RTE_MAX_NUMA_NODES]; 546af75078fSIntel 547af75078fSIntel /* 548af75078fSIntel * Configuration of Ethernet ports: 549af75078fSIntel * nb_fwd_ports <= nb_cfg_ports <= nb_ports 550af75078fSIntel */ 551af75078fSIntel extern portid_t nb_ports; /**< Number of ethernet ports probed at init time. */ 552af75078fSIntel extern portid_t nb_cfg_ports; /**< Number of configured ports. */ 553af75078fSIntel extern portid_t nb_fwd_ports; /**< Number of forwarding ports. */ 554af75078fSIntel extern portid_t fwd_ports_ids[RTE_MAX_ETHPORTS]; 555af75078fSIntel extern struct rte_port *ports; 556af75078fSIntel 557af75078fSIntel extern struct rte_eth_rxmode rx_mode; 558fd8c20aaSShahaf Shuler extern struct rte_eth_txmode tx_mode; 559fd8c20aaSShahaf Shuler 5608a387fa8SHelin Zhang extern uint64_t rss_hf; 561af75078fSIntel 5621c69df45SOri Kam extern queueid_t nb_hairpinq; 563af75078fSIntel extern queueid_t nb_rxq; 564af75078fSIntel extern queueid_t nb_txq; 565af75078fSIntel 566af75078fSIntel extern uint16_t nb_rxd; 567af75078fSIntel extern uint16_t nb_txd; 568af75078fSIntel 569f2c5125aSPablo de Lara extern int16_t rx_free_thresh; 570f2c5125aSPablo de Lara extern int8_t rx_drop_en; 571f2c5125aSPablo de Lara extern int16_t tx_free_thresh; 572f2c5125aSPablo de Lara extern int16_t tx_rs_thresh; 573af75078fSIntel 5741d343c19SMike Pattrick extern enum noisy_fwd_mode noisy_fwd_mode; 5751d343c19SMike Pattrick extern const char * const noisy_fwd_mode_desc[]; 5763c156061SJens Freimann extern uint16_t noisy_tx_sw_bufsz; 5773c156061SJens Freimann extern uint16_t noisy_tx_sw_buf_flush_time; 5783c156061SJens Freimann extern uint64_t noisy_lkup_mem_sz; 5793c156061SJens Freimann extern uint64_t noisy_lkup_num_writes; 5803c156061SJens Freimann extern uint64_t noisy_lkup_num_reads; 5813c156061SJens Freimann extern uint64_t noisy_lkup_num_reads_writes; 5823c156061SJens Freimann 583900550deSIntel extern uint8_t dcb_config; 584900550deSIntel 58526cbb419SViacheslav Ovsiienko extern uint32_t mbuf_data_size_n; 58626cbb419SViacheslav Ovsiienko extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT]; 58726cbb419SViacheslav Ovsiienko /**< Mbuf data space size. */ 588c8798818SIntel extern uint32_t param_total_num_mbufs; 589af75078fSIntel 590cfea1f30SPablo de Lara extern uint16_t stats_period; 59162d3216dSReshma Pattan 59263b72657SIvan Ilchenko extern struct rte_eth_xstat_name *xstats_display; 59363b72657SIvan Ilchenko extern unsigned int xstats_display_num; 59463b72657SIvan Ilchenko 59523095155SDariusz Sosnowski extern uint32_t hairpin_mode; 59601817b10SBing Zhao 597a8d0d473SBruce Richardson #ifdef RTE_LIB_LATENCYSTATS 59862d3216dSReshma Pattan extern uint8_t latencystats_enabled; 59962d3216dSReshma Pattan extern lcoreid_t latencystats_lcore_id; 60062d3216dSReshma Pattan #endif 60162d3216dSReshma Pattan 602a8d0d473SBruce Richardson #ifdef RTE_LIB_BITRATESTATS 603e25e6c70SRemy Horton extern lcoreid_t bitrate_lcore_id; 604e25e6c70SRemy Horton extern uint8_t bitrate_enabled; 605e25e6c70SRemy Horton #endif 606e25e6c70SRemy Horton 6071bb4a528SFerruh Yigit extern uint32_t max_rx_pkt_len; 6081bb4a528SFerruh Yigit 609af75078fSIntel /* 6100f2096d7SViacheslav Ovsiienko * Configuration of packet segments used to scatter received packets 6110f2096d7SViacheslav Ovsiienko * if some of split features is configured. 6120f2096d7SViacheslav Ovsiienko */ 61352e2e7edSYuan Wang extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT]; 6140f2096d7SViacheslav Ovsiienko extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT]; 6150f2096d7SViacheslav Ovsiienko extern uint8_t rx_pkt_nb_segs; /**< Number of segments to split */ 61691c78e09SViacheslav Ovsiienko extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT]; 61791c78e09SViacheslav Ovsiienko extern uint8_t rx_pkt_nb_offs; /**< Number of specified offsets */ 6180f2096d7SViacheslav Ovsiienko 619a4bf5421SHanumanth Pothula extern uint8_t multi_rx_mempool; /**< Enables multi-rx-mempool feature. */ 620a4bf5421SHanumanth Pothula 6210f2096d7SViacheslav Ovsiienko /* 622af75078fSIntel * Configuration of packet segments used by the "txonly" processing engine. 623af75078fSIntel */ 624af75078fSIntel #define TXONLY_DEF_PACKET_LEN 64 625af75078fSIntel extern uint16_t tx_pkt_length; /**< Length of TXONLY packet */ 626af75078fSIntel extern uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT]; /**< Seg. lengths */ 627af75078fSIntel extern uint8_t tx_pkt_nb_segs; /**< Number of segments in TX packets */ 6284940344dSViacheslav Ovsiienko extern uint32_t tx_pkt_times_intra; 6294940344dSViacheslav Ovsiienko extern uint32_t tx_pkt_times_inter; 630af75078fSIntel 63179bec05bSKonstantin Ananyev enum tx_pkt_split { 63279bec05bSKonstantin Ananyev TX_PKT_SPLIT_OFF, 63379bec05bSKonstantin Ananyev TX_PKT_SPLIT_ON, 63479bec05bSKonstantin Ananyev TX_PKT_SPLIT_RND, 63579bec05bSKonstantin Ananyev }; 63679bec05bSKonstantin Ananyev 63779bec05bSKonstantin Ananyev extern enum tx_pkt_split tx_pkt_split; 63879bec05bSKonstantin Ananyev 63982010ef5SYongseok Koh extern uint8_t txonly_multi_flow; 64082010ef5SYongseok Koh 641f4d178c1SXueming Li extern uint32_t rxq_share; 642f4d178c1SXueming Li 643af75078fSIntel extern uint16_t nb_pkt_per_burst; 6446c02043eSIgor Russkikh extern uint16_t nb_pkt_flowgen_clones; 645861e7684SZhihong Wang extern int nb_flows_flowgen; 646af75078fSIntel extern uint16_t mb_mempool_cache; 647f2c5125aSPablo de Lara extern int8_t rx_pthresh; 648f2c5125aSPablo de Lara extern int8_t rx_hthresh; 649f2c5125aSPablo de Lara extern int8_t rx_wthresh; 650f2c5125aSPablo de Lara extern int8_t tx_pthresh; 651f2c5125aSPablo de Lara extern int8_t tx_hthresh; 652f2c5125aSPablo de Lara extern int8_t tx_wthresh; 653af75078fSIntel 654bf5b2126SStephen Hemminger extern uint16_t tx_udp_src_port; 655bf5b2126SStephen Hemminger extern uint16_t tx_udp_dst_port; 656bf5b2126SStephen Hemminger 657bf5b2126SStephen Hemminger extern uint32_t tx_ip_src_addr; 658bf5b2126SStephen Hemminger extern uint32_t tx_ip_dst_addr; 659bf5b2126SStephen Hemminger 660af75078fSIntel extern struct fwd_config cur_fwd_config; 661af75078fSIntel extern struct fwd_engine *cur_fwd_eng; 662bf56fce1SZhihong Wang extern uint32_t retry_enabled; 663af75078fSIntel extern struct fwd_lcore **fwd_lcores; 664af75078fSIntel extern struct fwd_stream **fwd_streams; 665af75078fSIntel 66639e5e20fSXueming Li extern uint16_t vxlan_gpe_udp_port; /**< UDP port of tunnel VXLAN-GPE. */ 667ea0e711bSOphir Munk extern uint16_t geneve_udp_port; /**< UDP port of tunnel GENEVE. */ 66839e5e20fSXueming Li 669af75078fSIntel extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */ 6706d13ea8eSOlivier Matz extern struct rte_ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS]; 671af75078fSIntel 67257e85242SBruce Richardson extern uint32_t burst_tx_delay_time; /**< Burst tx delay time(us) for mac-retry. */ 67357e85242SBruce Richardson extern uint32_t burst_tx_retry_num; /**< Burst tx retry number for mac-retry. */ 67457e85242SBruce Richardson 6756970401eSDavid Marchand #ifdef RTE_LIB_GRO 676b7091f1dSJiayu Hu #define GRO_DEFAULT_ITEM_NUM_PER_FLOW 32 677b7091f1dSJiayu Hu #define GRO_DEFAULT_FLOW_NUM (RTE_GRO_MAX_BURST_ITEM_NUM / \ 678b7091f1dSJiayu Hu GRO_DEFAULT_ITEM_NUM_PER_FLOW) 679b7091f1dSJiayu Hu 680b7091f1dSJiayu Hu #define GRO_DEFAULT_FLUSH_CYCLES 1 681b7091f1dSJiayu Hu #define GRO_MAX_FLUSH_CYCLES 4 682b7091f1dSJiayu Hu 683b40f8d78SJiayu Hu struct gro_status { 684b40f8d78SJiayu Hu struct rte_gro_param param; 685b40f8d78SJiayu Hu uint8_t enable; 686b40f8d78SJiayu Hu }; 687b40f8d78SJiayu Hu extern struct gro_status gro_ports[RTE_MAX_ETHPORTS]; 688b7091f1dSJiayu Hu extern uint8_t gro_flush_cycles; 6896970401eSDavid Marchand #endif /* RTE_LIB_GRO */ 690b40f8d78SJiayu Hu 6916970401eSDavid Marchand #ifdef RTE_LIB_GSO 69252f38a20SJiayu Hu #define GSO_MAX_PKT_BURST 2048 69352f38a20SJiayu Hu struct gso_status { 69452f38a20SJiayu Hu uint8_t enable; 69552f38a20SJiayu Hu }; 69652f38a20SJiayu Hu extern struct gso_status gso_ports[RTE_MAX_ETHPORTS]; 69752f38a20SJiayu Hu extern uint16_t gso_max_segment_size; 6986970401eSDavid Marchand #endif /* RTE_LIB_GSO */ 69952f38a20SJiayu Hu 7001960be7dSNelio Laranjeiro /* VXLAN encap/decap parameters. */ 7011960be7dSNelio Laranjeiro struct vxlan_encap_conf { 7021960be7dSNelio Laranjeiro uint32_t select_ipv4:1; 7031960be7dSNelio Laranjeiro uint32_t select_vlan:1; 70462e8a5a8SViacheslav Ovsiienko uint32_t select_tos_ttl:1; 7051960be7dSNelio Laranjeiro uint8_t vni[3]; 7061960be7dSNelio Laranjeiro rte_be16_t udp_src; 7071960be7dSNelio Laranjeiro rte_be16_t udp_dst; 7081960be7dSNelio Laranjeiro rte_be32_t ipv4_src; 7091960be7dSNelio Laranjeiro rte_be32_t ipv4_dst; 7101960be7dSNelio Laranjeiro uint8_t ipv6_src[16]; 7111960be7dSNelio Laranjeiro uint8_t ipv6_dst[16]; 7121960be7dSNelio Laranjeiro rte_be16_t vlan_tci; 71362e8a5a8SViacheslav Ovsiienko uint8_t ip_tos; 71462e8a5a8SViacheslav Ovsiienko uint8_t ip_ttl; 71535b2d13fSOlivier Matz uint8_t eth_src[RTE_ETHER_ADDR_LEN]; 71635b2d13fSOlivier Matz uint8_t eth_dst[RTE_ETHER_ADDR_LEN]; 7171960be7dSNelio Laranjeiro }; 718f6e63e59SFerruh Yigit 719f6e63e59SFerruh Yigit extern struct vxlan_encap_conf vxlan_encap_conf; 7201960be7dSNelio Laranjeiro 721dcd962fcSNelio Laranjeiro /* NVGRE encap/decap parameters. */ 722dcd962fcSNelio Laranjeiro struct nvgre_encap_conf { 723dcd962fcSNelio Laranjeiro uint32_t select_ipv4:1; 724dcd962fcSNelio Laranjeiro uint32_t select_vlan:1; 725dcd962fcSNelio Laranjeiro uint8_t tni[3]; 726dcd962fcSNelio Laranjeiro rte_be32_t ipv4_src; 727dcd962fcSNelio Laranjeiro rte_be32_t ipv4_dst; 728dcd962fcSNelio Laranjeiro uint8_t ipv6_src[16]; 729dcd962fcSNelio Laranjeiro uint8_t ipv6_dst[16]; 730dcd962fcSNelio Laranjeiro rte_be16_t vlan_tci; 73135b2d13fSOlivier Matz uint8_t eth_src[RTE_ETHER_ADDR_LEN]; 73235b2d13fSOlivier Matz uint8_t eth_dst[RTE_ETHER_ADDR_LEN]; 733dcd962fcSNelio Laranjeiro }; 734f6e63e59SFerruh Yigit 735f6e63e59SFerruh Yigit extern struct nvgre_encap_conf nvgre_encap_conf; 736dcd962fcSNelio Laranjeiro 737a1191d39SOri Kam /* L2 encap parameters. */ 738a1191d39SOri Kam struct l2_encap_conf { 739a1191d39SOri Kam uint32_t select_ipv4:1; 740a1191d39SOri Kam uint32_t select_vlan:1; 741a1191d39SOri Kam rte_be16_t vlan_tci; 74235b2d13fSOlivier Matz uint8_t eth_src[RTE_ETHER_ADDR_LEN]; 74335b2d13fSOlivier Matz uint8_t eth_dst[RTE_ETHER_ADDR_LEN]; 744a1191d39SOri Kam }; 745f6e63e59SFerruh Yigit extern struct l2_encap_conf l2_encap_conf; 746a1191d39SOri Kam 747a1191d39SOri Kam /* L2 decap parameters. */ 748a1191d39SOri Kam struct l2_decap_conf { 749a1191d39SOri Kam uint32_t select_vlan:1; 750a1191d39SOri Kam }; 751f6e63e59SFerruh Yigit extern struct l2_decap_conf l2_decap_conf; 752a1191d39SOri Kam 7533e77031bSOri Kam /* MPLSoGRE encap parameters. */ 7543e77031bSOri Kam struct mplsogre_encap_conf { 7553e77031bSOri Kam uint32_t select_ipv4:1; 7563e77031bSOri Kam uint32_t select_vlan:1; 7573e77031bSOri Kam uint8_t label[3]; 7583e77031bSOri Kam rte_be32_t ipv4_src; 7593e77031bSOri Kam rte_be32_t ipv4_dst; 7603e77031bSOri Kam uint8_t ipv6_src[16]; 7613e77031bSOri Kam uint8_t ipv6_dst[16]; 7623e77031bSOri Kam rte_be16_t vlan_tci; 76335b2d13fSOlivier Matz uint8_t eth_src[RTE_ETHER_ADDR_LEN]; 76435b2d13fSOlivier Matz uint8_t eth_dst[RTE_ETHER_ADDR_LEN]; 7653e77031bSOri Kam }; 766f6e63e59SFerruh Yigit extern struct mplsogre_encap_conf mplsogre_encap_conf; 7673e77031bSOri Kam 7683e77031bSOri Kam /* MPLSoGRE decap parameters. */ 7693e77031bSOri Kam struct mplsogre_decap_conf { 7703e77031bSOri Kam uint32_t select_ipv4:1; 7713e77031bSOri Kam uint32_t select_vlan:1; 7723e77031bSOri Kam }; 773f6e63e59SFerruh Yigit extern struct mplsogre_decap_conf mplsogre_decap_conf; 7743e77031bSOri Kam 775a1191d39SOri Kam /* MPLSoUDP encap parameters. */ 776a1191d39SOri Kam struct mplsoudp_encap_conf { 777a1191d39SOri Kam uint32_t select_ipv4:1; 778a1191d39SOri Kam uint32_t select_vlan:1; 779a1191d39SOri Kam uint8_t label[3]; 780a1191d39SOri Kam rte_be16_t udp_src; 781a1191d39SOri Kam rte_be16_t udp_dst; 782a1191d39SOri Kam rte_be32_t ipv4_src; 783a1191d39SOri Kam rte_be32_t ipv4_dst; 784a1191d39SOri Kam uint8_t ipv6_src[16]; 785a1191d39SOri Kam uint8_t ipv6_dst[16]; 786a1191d39SOri Kam rte_be16_t vlan_tci; 78735b2d13fSOlivier Matz uint8_t eth_src[RTE_ETHER_ADDR_LEN]; 78835b2d13fSOlivier Matz uint8_t eth_dst[RTE_ETHER_ADDR_LEN]; 789a1191d39SOri Kam }; 790f6e63e59SFerruh Yigit extern struct mplsoudp_encap_conf mplsoudp_encap_conf; 791a1191d39SOri Kam 792a1191d39SOri Kam /* MPLSoUDP decap parameters. */ 793a1191d39SOri Kam struct mplsoudp_decap_conf { 794a1191d39SOri Kam uint32_t select_ipv4:1; 795a1191d39SOri Kam uint32_t select_vlan:1; 796a1191d39SOri Kam }; 797f6e63e59SFerruh Yigit extern struct mplsoudp_decap_conf mplsoudp_decap_conf; 798a1191d39SOri Kam 799f9295aa2SXiaoyu Min extern enum rte_eth_rx_mq_mode rx_mq_mode; 800f9295aa2SXiaoyu Min 8014d07cbefSBing Zhao extern struct rte_flow_action_conntrack conntrack_context; 8024d07cbefSBing Zhao 803a550baf2SMin Hu (Connor) extern int proc_id; 804a550baf2SMin Hu (Connor) extern unsigned int num_procs; 805a550baf2SMin Hu (Connor) 806a550baf2SMin Hu (Connor) static inline bool 807a550baf2SMin Hu (Connor) is_proc_primary(void) 808a550baf2SMin Hu (Connor) { 809a550baf2SMin Hu (Connor) return rte_eal_process_type() == RTE_PROC_PRIMARY; 810a550baf2SMin Hu (Connor) } 811a550baf2SMin Hu (Connor) 81299a4974aSRobin Jarry static inline struct fwd_lcore * 81399a4974aSRobin Jarry lcore_to_fwd_lcore(uint16_t lcore_id) 814af75078fSIntel { 815af75078fSIntel unsigned int i; 816af75078fSIntel 81799a4974aSRobin Jarry for (i = 0; i < cur_fwd_config.nb_fwd_lcores; ++i) { 81899a4974aSRobin Jarry if (fwd_lcores_cpuids[i] == lcore_id) 81999a4974aSRobin Jarry return fwd_lcores[i]; 820af75078fSIntel } 821af75078fSIntel 82299a4974aSRobin Jarry return NULL; 82399a4974aSRobin Jarry } 8242df00d56SHariprasad Govindharajan 825af75078fSIntel static inline struct fwd_lcore * 826af75078fSIntel current_fwd_lcore(void) 827af75078fSIntel { 82899a4974aSRobin Jarry struct fwd_lcore *fc = lcore_to_fwd_lcore(rte_lcore_id()); 82999a4974aSRobin Jarry 83099a4974aSRobin Jarry if (fc == NULL) 83199a4974aSRobin Jarry rte_panic("lcore_id of current thread not found in fwd_lcores_cpuids\n"); 83299a4974aSRobin Jarry 83399a4974aSRobin Jarry return fc; 834af75078fSIntel } 835af75078fSIntel 83699a4974aSRobin Jarry void 83799a4974aSRobin Jarry parse_fwd_portlist(const char *port); 83899a4974aSRobin Jarry 839af75078fSIntel /* Mbuf Pools */ 840af75078fSIntel static inline void 84126cbb419SViacheslav Ovsiienko mbuf_poolname_build(unsigned int sock_id, char *mp_name, 84226cbb419SViacheslav Ovsiienko int name_size, uint16_t idx) 843af75078fSIntel { 84426cbb419SViacheslav Ovsiienko if (!idx) 84526cbb419SViacheslav Ovsiienko snprintf(mp_name, name_size, 84626cbb419SViacheslav Ovsiienko MBUF_POOL_NAME_PFX "_%u", sock_id); 84726cbb419SViacheslav Ovsiienko else 84826cbb419SViacheslav Ovsiienko snprintf(mp_name, name_size, 84926cbb419SViacheslav Ovsiienko MBUF_POOL_NAME_PFX "_%hu_%hu", (uint16_t)sock_id, idx); 850af75078fSIntel } 851af75078fSIntel 852af75078fSIntel static inline struct rte_mempool * 85326cbb419SViacheslav Ovsiienko mbuf_pool_find(unsigned int sock_id, uint16_t idx) 854af75078fSIntel { 855af75078fSIntel char pool_name[RTE_MEMPOOL_NAMESIZE]; 856af75078fSIntel 85726cbb419SViacheslav Ovsiienko mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name), idx); 858693f715dSHuawei Xie return rte_mempool_lookup((const char *)pool_name); 859af75078fSIntel } 860af75078fSIntel 861d3dae396SDavid Marchand static inline uint16_t 862d3dae396SDavid Marchand common_fwd_stream_receive(struct fwd_stream *fs, struct rte_mbuf **burst, 863d3dae396SDavid Marchand unsigned int nb_pkts) 8640e4b1963SDharmik Thakkar { 865d3dae396SDavid Marchand uint16_t nb_rx; 866d3dae396SDavid Marchand 867d3dae396SDavid Marchand nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, burst, nb_pkts); 8680e4b1963SDharmik Thakkar if (record_burst_stats) 8690e4b1963SDharmik Thakkar fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; 870d3dae396SDavid Marchand fs->rx_packets += nb_rx; 871d3dae396SDavid Marchand return nb_rx; 8720e4b1963SDharmik Thakkar } 8730e4b1963SDharmik Thakkar 874655131ccSDavid Marchand static inline uint16_t 875655131ccSDavid Marchand common_fwd_stream_transmit(struct fwd_stream *fs, struct rte_mbuf **burst, 876655131ccSDavid Marchand unsigned int nb_pkts) 8770e4b1963SDharmik Thakkar { 878655131ccSDavid Marchand uint16_t nb_tx; 879655131ccSDavid Marchand uint32_t retry; 880655131ccSDavid Marchand 881655131ccSDavid Marchand nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, burst, nb_pkts); 882655131ccSDavid Marchand /* 883655131ccSDavid Marchand * Retry if necessary 884655131ccSDavid Marchand */ 885655131ccSDavid Marchand if (unlikely(nb_tx < nb_pkts) && fs->retry_enabled) { 886655131ccSDavid Marchand retry = 0; 887655131ccSDavid Marchand while (nb_tx < nb_pkts && retry++ < burst_tx_retry_num) { 888655131ccSDavid Marchand rte_delay_us(burst_tx_delay_time); 889655131ccSDavid Marchand nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, 890655131ccSDavid Marchand &burst[nb_tx], nb_pkts - nb_tx); 891655131ccSDavid Marchand } 892655131ccSDavid Marchand } 893655131ccSDavid Marchand fs->tx_packets += nb_tx; 8940e4b1963SDharmik Thakkar if (record_burst_stats) 8950e4b1963SDharmik Thakkar fs->tx_burst_stats.pkt_burst_spread[nb_tx]++; 896655131ccSDavid Marchand if (unlikely(nb_tx < nb_pkts)) { 897655131ccSDavid Marchand fs->fwd_dropped += (nb_pkts - nb_tx); 898655131ccSDavid Marchand rte_pktmbuf_free_bulk(&burst[nb_tx], nb_pkts - nb_tx); 899655131ccSDavid Marchand } 900655131ccSDavid Marchand 901655131ccSDavid Marchand return nb_tx; 9020e4b1963SDharmik Thakkar } 9030e4b1963SDharmik Thakkar 904af75078fSIntel /* Prototypes */ 905761f7ae1SJie Zhou unsigned int parse_item_list(const char *str, const char *item_name, 906950d1516SBruce Richardson unsigned int max_items, 907950d1516SBruce Richardson unsigned int *parsed_items, int check_unique_values); 90852e2e7edSYuan Wang unsigned int parse_hdrs_list(const char *str, const char *item_name, 90952e2e7edSYuan Wang unsigned int max_item, 91023f2dfd3SYuan Wang unsigned int *parsed_items); 911af75078fSIntel void launch_args_parse(int argc, char** argv); 9120100a038SDavid Marchand void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 91381ef862bSAllain Legacy void cmdline_read_from_file(const char *filename); 914592ab76fSDavid Marchand int init_cmdline(void); 915af75078fSIntel void prompt(void); 916d3a274ceSZhihong Wang void prompt_exit(void); 917af75078fSIntel void nic_stats_display(portid_t port_id); 918af75078fSIntel void nic_stats_clear(portid_t port_id); 919bfd5051bSOlivier Matz void nic_xstats_display(portid_t port_id); 920bfd5051bSOlivier Matz void nic_xstats_clear(portid_t port_id); 92155e51c96SNithin Dabilpuram void device_infos_display(const char *identifier); 922af75078fSIntel void port_infos_display(portid_t port_id); 9234bfcbcf5SEmma Finn void port_summary_display(portid_t port_id); 9246b67721dSDavid Liu void port_eeprom_display(portid_t port_id); 9256b67721dSDavid Liu void port_module_eeprom_display(portid_t port_id); 9264bfcbcf5SEmma Finn void port_summary_header_display(void); 927ab3257e1SKonstantin Ananyev void rx_queue_infos_display(portid_t port_idi, uint16_t queue_id); 928ab3257e1SKonstantin Ananyev void tx_queue_infos_display(portid_t port_idi, uint16_t queue_id); 929af75078fSIntel void fwd_lcores_config_display(void); 93065744833SXueming Li bool pkt_fwd_shared_rxq_check(void); 9310c0db76fSBernard Iremonger void pkt_fwd_config_display(struct fwd_config *cfg); 932af75078fSIntel void rxtx_config_display(void); 933af75078fSIntel void fwd_config_setup(void); 934af75078fSIntel void set_def_fwd_config(void); 935a21d5a4bSDeclan Doherty void reconfig(portid_t new_port_id, unsigned socket_id); 936013af9b6SIntel int init_fwd_streams(void); 93703ce2c53SMatan Azrad void update_fwd_ports(portid_t new_pid); 938013af9b6SIntel 939aac6f11fSWisam Jaddo void set_fwd_eth_peer(portid_t port_id, char *peer_addr); 940aac6f11fSWisam Jaddo 941ae03d0d1SIvan Boule void port_mtu_set(portid_t port_id, uint16_t mtu); 94272a3dec7SGregory Etelson int port_action_handle_create(portid_t port_id, uint32_t id, bool indirect_list, 9434b61b877SBing Zhao const struct rte_flow_indir_action_conf *conf, 94455509e3aSAndrey Vesnovaty const struct rte_flow_action *action); 9454b61b877SBing Zhao int port_action_handle_destroy(portid_t port_id, 94655509e3aSAndrey Vesnovaty uint32_t n, const uint32_t *action); 947f7352c17SDmitry Kozlyuk int port_action_handle_flush(portid_t port_id); 9484b61b877SBing Zhao struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id, 94955509e3aSAndrey Vesnovaty uint32_t id); 9504b61b877SBing Zhao int port_action_handle_update(portid_t port_id, uint32_t id, 95155509e3aSAndrey Vesnovaty const struct rte_flow_action *action); 9523e3edab5SGregory Etelson void 9533e3edab5SGregory Etelson port_action_handle_query_update(portid_t port_id, uint32_t id, 9543e3edab5SGregory Etelson enum rte_flow_query_update_mode qu_mode, 9553e3edab5SGregory Etelson const struct rte_flow_action *action); 9569ad3a41aSAlexander Kozyrev int port_flow_get_info(portid_t port_id); 9579ad3a41aSAlexander Kozyrev int port_flow_configure(portid_t port_id, 9589ad3a41aSAlexander Kozyrev const struct rte_flow_port_attr *port_attr, 9599ad3a41aSAlexander Kozyrev uint16_t nb_queue, 9609ad3a41aSAlexander Kozyrev const struct rte_flow_queue_attr *queue_attr); 96104cc665fSAlexander Kozyrev int port_flow_pattern_template_create(portid_t port_id, uint32_t id, 96204cc665fSAlexander Kozyrev const struct rte_flow_pattern_template_attr *attr, 96304cc665fSAlexander Kozyrev const struct rte_flow_item *pattern); 96404cc665fSAlexander Kozyrev int port_flow_pattern_template_destroy(portid_t port_id, uint32_t n, 96504cc665fSAlexander Kozyrev const uint32_t *template); 9666d736e05SSuanming Mou int port_flow_pattern_template_flush(portid_t port_id); 96704cc665fSAlexander Kozyrev int port_flow_actions_template_create(portid_t port_id, uint32_t id, 96804cc665fSAlexander Kozyrev const struct rte_flow_actions_template_attr *attr, 96904cc665fSAlexander Kozyrev const struct rte_flow_action *actions, 97004cc665fSAlexander Kozyrev const struct rte_flow_action *masks); 97104cc665fSAlexander Kozyrev int port_flow_actions_template_destroy(portid_t port_id, uint32_t n, 97204cc665fSAlexander Kozyrev const uint32_t *template); 9736d736e05SSuanming Mou int port_flow_actions_template_flush(portid_t port_id); 974c4b38873SAlexander Kozyrev int port_flow_template_table_create(portid_t port_id, uint32_t id, 975c4b38873SAlexander Kozyrev const struct rte_flow_template_table_attr *table_attr, 976c4b38873SAlexander Kozyrev uint32_t nb_pattern_templates, uint32_t *pattern_templates, 977c4b38873SAlexander Kozyrev uint32_t nb_actions_templates, uint32_t *actions_templates); 978c4b38873SAlexander Kozyrev int port_flow_template_table_destroy(portid_t port_id, 979c4b38873SAlexander Kozyrev uint32_t n, const uint32_t *table); 9806d736e05SSuanming Mou int port_flow_template_table_flush(portid_t port_id); 981ecdc927bSAlexander Kozyrev int port_queue_flow_create(portid_t port_id, queueid_t queue_id, 98260261a00SAlexander Kozyrev bool postpone, uint32_t table_id, uint32_t rule_idx, 983ecdc927bSAlexander Kozyrev uint32_t pattern_idx, uint32_t actions_idx, 984ecdc927bSAlexander Kozyrev const struct rte_flow_item *pattern, 985ecdc927bSAlexander Kozyrev const struct rte_flow_action *actions); 986ecdc927bSAlexander Kozyrev int port_queue_flow_destroy(portid_t port_id, queueid_t queue_id, 987*fd5392d8SEli Britstein bool postpone, uint32_t n, const uint64_t *rule); 98877e7939aSAlexander Kozyrev int port_queue_flow_update(portid_t port_id, queueid_t queue_id, 98977e7939aSAlexander Kozyrev bool postpone, uint32_t rule_idx, uint32_t actions_idx, 99077e7939aSAlexander Kozyrev const struct rte_flow_action *actions); 991d906fff5SAlexander Kozyrev int port_queue_action_handle_create(portid_t port_id, uint32_t queue_id, 992d906fff5SAlexander Kozyrev bool postpone, uint32_t id, 993d906fff5SAlexander Kozyrev const struct rte_flow_indir_action_conf *conf, 994d906fff5SAlexander Kozyrev const struct rte_flow_action *action); 995d906fff5SAlexander Kozyrev int port_queue_action_handle_destroy(portid_t port_id, 996d906fff5SAlexander Kozyrev uint32_t queue_id, bool postpone, 997d906fff5SAlexander Kozyrev uint32_t n, const uint32_t *action); 998d906fff5SAlexander Kozyrev int port_queue_action_handle_update(portid_t port_id, uint32_t queue_id, 999d906fff5SAlexander Kozyrev bool postpone, uint32_t id, 1000d906fff5SAlexander Kozyrev const struct rte_flow_action *action); 1001c9dc0384SSuanming Mou int port_queue_action_handle_query(portid_t port_id, uint32_t queue_id, 1002c9dc0384SSuanming Mou bool postpone, uint32_t id); 10033e3edab5SGregory Etelson void 10043e3edab5SGregory Etelson port_queue_action_handle_query_update(portid_t port_id, 10053e3edab5SGregory Etelson uint32_t queue_id, bool postpone, 10063e3edab5SGregory Etelson uint32_t id, 10073e3edab5SGregory Etelson enum rte_flow_query_update_mode qu_mode, 10083e3edab5SGregory Etelson const struct rte_flow_action *action); 10099cbbee14SAlexander Kozyrev int port_queue_flow_push(portid_t port_id, queueid_t queue_id); 1010f9bf7dffSAlexander Kozyrev int port_queue_flow_pull(portid_t port_id, queueid_t queue_id); 1011966eb55eSMichael Baum void port_queue_flow_aged(portid_t port_id, uint32_t queue_id, uint8_t destroy); 1012938a184aSAdrien Mazarguil int port_flow_validate(portid_t port_id, 1013938a184aSAdrien Mazarguil const struct rte_flow_attr *attr, 1014938a184aSAdrien Mazarguil const struct rte_flow_item *pattern, 10151b9f2746SGregory Etelson const struct rte_flow_action *actions, 10161b9f2746SGregory Etelson const struct tunnel_ops *tunnel_ops); 1017938a184aSAdrien Mazarguil int port_flow_create(portid_t port_id, 1018938a184aSAdrien Mazarguil const struct rte_flow_attr *attr, 1019938a184aSAdrien Mazarguil const struct rte_flow_item *pattern, 10201b9f2746SGregory Etelson const struct rte_flow_action *actions, 10211b9f2746SGregory Etelson const struct tunnel_ops *tunnel_ops); 10224b61b877SBing Zhao int port_action_handle_query(portid_t port_id, uint32_t id); 10230e459ffaSDong Zhou void update_age_action_context(const struct rte_flow_action *actions, 10240e459ffaSDong Zhou struct port_flow *pf); 102568629be3SKe Zhang int mcast_addr_pool_destroy(portid_t port_id); 1026*fd5392d8SEli Britstein int port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule); 1027938a184aSAdrien Mazarguil int port_flow_flush(portid_t port_id); 1028bf085dcbSHaifei Luo int port_flow_dump(portid_t port_id, bool dump_all, 1029*fd5392d8SEli Britstein uint64_t rule, const char *file_name); 1030*fd5392d8SEli Britstein int port_flow_query(portid_t port_id, uint64_t rule, 1031fb8fd96dSDeclan Doherty const struct rte_flow_action *action); 1032938a184aSAdrien Mazarguil void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group); 10330e459ffaSDong Zhou void port_flow_aged(portid_t port_id, uint8_t destroy); 10341b9f2746SGregory Etelson const char *port_flow_tunnel_type(struct rte_flow_tunnel *tunnel); 10351b9f2746SGregory Etelson struct port_flow_tunnel * 10361b9f2746SGregory Etelson port_flow_locate_tunnel(uint16_t port_id, struct rte_flow_tunnel *tun); 10371b9f2746SGregory Etelson void port_flow_tunnel_list(portid_t port_id); 10381b9f2746SGregory Etelson void port_flow_tunnel_destroy(portid_t port_id, uint32_t tunnel_id); 10391b9f2746SGregory Etelson void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops); 1040323f811aSAdrien Mazarguil int port_flow_isolate(portid_t port_id, int set); 1041f29fa2c5SHaifei Luo int port_meter_policy_add(portid_t port_id, uint32_t policy_id, 1042f29fa2c5SHaifei Luo const struct rte_flow_action *actions); 10439c4a0c18SAlexander Kozyrev struct rte_flow_meter_profile *port_meter_profile_get_by_id(portid_t port_id, 10449c4a0c18SAlexander Kozyrev uint32_t id); 10459c4a0c18SAlexander Kozyrev struct rte_flow_meter_policy *port_meter_policy_get_by_id(portid_t port_id, 10469c4a0c18SAlexander Kozyrev uint32_t id); 1047af75078fSIntel 1048af75078fSIntel void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id); 1049af75078fSIntel void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id); 1050af75078fSIntel 1051013af9b6SIntel int set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc); 1052013af9b6SIntel int set_fwd_lcores_mask(uint64_t lcoremask); 1053af75078fSIntel void set_fwd_lcores_number(uint16_t nb_lc); 1054af75078fSIntel 1055af75078fSIntel void set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt); 1056af75078fSIntel void set_fwd_ports_mask(uint64_t portmask); 1057af75078fSIntel void set_fwd_ports_number(uint16_t nb_pt); 1058a8ef3e3aSBernard Iremonger int port_is_forwarding(portid_t port_id); 1059af75078fSIntel 1060a47aa8b9SIntel void rx_vlan_strip_set(portid_t port_id, int on); 1061a47aa8b9SIntel void rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t queue_id, int on); 1062a47aa8b9SIntel 1063a47aa8b9SIntel void rx_vlan_filter_set(portid_t port_id, int on); 1064af75078fSIntel void rx_vlan_all_filter_set(portid_t port_id, int on); 10652a0b4198SVivek Sharma void rx_vlan_qinq_strip_set(portid_t port_id, int on); 106664b01ee0SMichal Jastrzebski int rx_vft_set(portid_t port_id, uint16_t vlan_id, int on); 1067a47aa8b9SIntel void vlan_extend_set(portid_t port_id, int on); 106819b16e2fSHelin Zhang void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type, 106919b16e2fSHelin Zhang uint16_t tp_id); 1070af75078fSIntel void tx_vlan_set(portid_t port_id, uint16_t vlan_id); 107192ebda07SHelin Zhang void tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer); 1072af75078fSIntel void tx_vlan_reset(portid_t port_id); 1073529ba951SHelin Zhang void tx_vlan_pvid_set(portid_t port_id, uint16_t vlan_id, int on); 1074ed30d9b6SIntel 1075ed30d9b6SIntel void set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value); 1076ed30d9b6SIntel 1077a4fd5eeeSElza Mathew void set_xstats_hide_zero(uint8_t on_off); 1078a4fd5eeeSElza Mathew 1079bc700b67SDharmik Thakkar void set_record_core_cycles(uint8_t on_off); 10800e4b1963SDharmik Thakkar void set_record_burst_stats(uint8_t on_off); 1081af75078fSIntel void set_verbose_level(uint16_t vb_level); 10820f2096d7SViacheslav Ovsiienko void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs); 108352e2e7edSYuan Wang void set_rx_pkt_hdrs(unsigned int *seg_protos, unsigned int nb_segs); 108452e2e7edSYuan Wang void show_rx_pkt_hdrs(void); 10850f2096d7SViacheslav Ovsiienko void show_rx_pkt_segments(void); 108691c78e09SViacheslav Ovsiienko void set_rx_pkt_offsets(unsigned int *seg_offsets, unsigned int nb_offs); 108791c78e09SViacheslav Ovsiienko void show_rx_pkt_offsets(void); 10880f2096d7SViacheslav Ovsiienko void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs); 108979bec05bSKonstantin Ananyev void show_tx_pkt_segments(void); 10904940344dSViacheslav Ovsiienko void set_tx_pkt_times(unsigned int *tx_times); 10914940344dSViacheslav Ovsiienko void show_tx_pkt_times(void); 109279bec05bSKonstantin Ananyev void set_tx_pkt_split(const char *name); 1093ce0a4a1dSJie Zhou int parse_fec_mode(const char *name, uint32_t *fec_capa); 1094b19da32eSMin Hu (Connor) void show_fec_capability(uint32_t num, struct rte_eth_fec_capa *speed_fec_capa); 1095af75078fSIntel void set_nb_pkt_per_burst(uint16_t pkt_burst); 1096769ce6b1SThomas Monjalon char *list_pkt_forwarding_modes(void); 1097bf56fce1SZhihong Wang char *list_pkt_forwarding_retry_modes(void); 1098af75078fSIntel void set_pkt_forwarding_mode(const char *fwd_mode); 1099af75078fSIntel void start_packet_forwarding(int with_tx_first); 110053324971SDavid Marchand void fwd_stats_display(void); 110153324971SDavid Marchand void fwd_stats_reset(void); 1102af75078fSIntel void stop_packet_forwarding(void); 1103cfae07fdSOuyang Changchun void dev_set_link_up(portid_t pid); 1104cfae07fdSOuyang Changchun void dev_set_link_down(portid_t pid); 1105ce8d5614SIntel void init_port_config(void); 110641b05095SBernard Iremonger void set_port_slave_flag(portid_t slave_pid); 110741b05095SBernard Iremonger void clear_port_slave_flag(portid_t slave_pid); 11080e545d30SBernard Iremonger uint8_t port_is_bonding_slave(portid_t slave_pid); 11090e545d30SBernard Iremonger 11101a572499SJingjing Wu int init_port_dcb_config(portid_t pid, enum dcb_mode_enable dcb_mode, 11111a572499SJingjing Wu enum rte_eth_nb_tcs num_tcs, 11121a572499SJingjing Wu uint8_t pfc_en); 1113148f963fSBruce Richardson int start_port(portid_t pid); 1114ce8d5614SIntel void stop_port(portid_t pid); 1115ce8d5614SIntel void close_port(portid_t pid); 111697f1e196SWei Dai void reset_port(portid_t pid); 1117edab33b1STetsuya Mukawa void attach_port(char *identifier); 11185edee5f6SThomas Monjalon void detach_devargs(char *identifier); 1119f8e5baa2SThomas Monjalon void detach_port_device(portid_t port_id); 1120ce8d5614SIntel int all_ports_stopped(void); 11216018eb8cSShahaf Shuler int port_is_stopped(portid_t port_id); 11225f4ec54fSChen Jing D(Mark) int port_is_started(portid_t port_id); 1123af75078fSIntel void pmd_test_exit(void); 11241be514fbSAndrew Rybchenko #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) 1125af75078fSIntel void fdir_get_infos(portid_t port_id); 11261be514fbSAndrew Rybchenko #endif 112766c59490SHelin Zhang void port_rss_reta_info(portid_t port_id, 112866c59490SHelin Zhang struct rte_eth_rss_reta_entry64 *reta_conf, 112966c59490SHelin Zhang uint16_t nb_entries); 11306a18e1afSOuyang Changchun 11317741e4cfSIntel void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on); 1132af75078fSIntel 11332befc67fSViacheslav Ovsiienko int 11342befc67fSViacheslav Ovsiienko rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, 11352befc67fSViacheslav Ovsiienko uint16_t nb_rx_desc, unsigned int socket_id, 11362befc67fSViacheslav Ovsiienko struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp); 11372befc67fSViacheslav Ovsiienko 11383a26e41eSSatha Rao int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint32_t rate); 11393a26e41eSSatha Rao int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint32_t rate, 11406a18e1afSOuyang Changchun uint64_t q_msk); 11416a18e1afSOuyang Changchun 1142bc70e559SSpike Du int set_rxq_avail_thresh(portid_t port_id, uint16_t queue_id, 1143bc70e559SSpike Du uint8_t avail_thresh); 1144bc70e559SSpike Du 11455b4557ecSFerruh Yigit void port_rss_hash_conf_show(portid_t port_id, int show_rss_key); 11468205e241SNelio Laranjeiro void port_rss_hash_key_update(portid_t port_id, char rss_type[], 11473529e8f3SNatanael Copa uint8_t *hash_key, uint8_t hash_key_len); 11485f4ec54fSChen Jing D(Mark) int rx_queue_id_is_invalid(queueid_t rxq_id); 11495f4ec54fSChen Jing D(Mark) int tx_queue_id_is_invalid(queueid_t txq_id); 11506970401eSDavid Marchand #ifdef RTE_LIB_GRO 1151b7091f1dSJiayu Hu void setup_gro(const char *onoff, portid_t port_id); 1152b7091f1dSJiayu Hu void setup_gro_flush_cycles(uint8_t cycles); 1153b7091f1dSJiayu Hu void show_gro(portid_t port_id); 11546970401eSDavid Marchand #endif 11556970401eSDavid Marchand #ifdef RTE_LIB_GSO 115652f38a20SJiayu Hu void setup_gso(const char *mode, portid_t port_id); 11576970401eSDavid Marchand #endif 11586f51deb9SIvan Ilchenko int eth_dev_info_get_print_err(uint16_t port_id, 11596f51deb9SIvan Ilchenko struct rte_eth_dev_info *dev_info); 1160655eae01SJie Wang int eth_dev_conf_get_print_err(uint16_t port_id, 1161655eae01SJie Wang struct rte_eth_conf *dev_conf); 116234fc1051SIvan Ilchenko void eth_set_promisc_mode(uint16_t port_id, int enable); 11638835806dSIvan Ilchenko void eth_set_allmulticast_mode(uint16_t port, int enable); 1164e661a08bSIgor Romanov int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link); 1165a5279d25SIgor Romanov int eth_macaddr_get_print_err(uint16_t port_id, 1166a5279d25SIgor Romanov struct rte_ether_addr *mac_addr); 11676f51deb9SIvan Ilchenko 1168e1d44d0aSKalesh AP /* Functions to display the set of MAC addresses added to a port*/ 1169e1d44d0aSKalesh AP void show_macs(portid_t port_id); 1170e1d44d0aSKalesh AP void show_mcast_macs(portid_t port_id); 117116321de0SIvan Boule 11728fff6675SIvan Boule /* Functions to manage the set of filtered Multicast MAC addresses */ 11736d13ea8eSOlivier Matz void mcast_addr_add(portid_t port_id, struct rte_ether_addr *mc_addr); 11746d13ea8eSOlivier Matz void mcast_addr_remove(portid_t port_id, struct rte_ether_addr *mc_addr); 117528caa76aSZhiyong Yang void port_dcb_info_display(portid_t port_id); 11768fff6675SIvan Boule 11779999dc6fSKirill Rybalchenko uint8_t *open_file(const char *file_path, uint32_t *size); 11789999dc6fSKirill Rybalchenko int save_file(const char *file_path, uint8_t *buf, uint32_t size); 11799999dc6fSKirill Rybalchenko int close_file(uint8_t *buf); 1180a92a5a2cSBeilei Xing 1181edab33b1STetsuya Mukawa enum print_warning { 1182edab33b1STetsuya Mukawa ENABLED_WARN = 0, 1183edab33b1STetsuya Mukawa DISABLED_WARN 1184edab33b1STetsuya Mukawa }; 1185edab33b1STetsuya Mukawa int port_id_is_invalid(portid_t port_id, enum print_warning warning); 11868f3c4176SMatan Azrad void print_valid_ports(void); 1187c9cafcc8SShahaf Shuler int new_socket_id(unsigned int socket_id); 1188edab33b1STetsuya Mukawa 11893f7311baSWei Dai queueid_t get_allowed_max_nb_rxq(portid_t *pid); 11903f7311baSWei Dai int check_nb_rxq(queueid_t rxq); 119136db4f6cSWei Dai queueid_t get_allowed_max_nb_txq(portid_t *pid); 119236db4f6cSWei Dai int check_nb_txq(queueid_t txq); 119399e040d3SLijun Ou int check_nb_rxd(queueid_t rxd); 119499e040d3SLijun Ou int check_nb_txd(queueid_t txd); 11951c69df45SOri Kam queueid_t get_allowed_max_nb_hairpinq(portid_t *pid); 11961c69df45SOri Kam int check_nb_hairpinq(queueid_t hairpinq); 11973f7311baSWei Dai 1198c77ad9deSRaslan Darawsheh uint16_t dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], 1199c77ad9deSRaslan Darawsheh uint16_t nb_pkts, __rte_unused uint16_t max_pkts, 1200c77ad9deSRaslan Darawsheh __rte_unused void *user_param); 1201c77ad9deSRaslan Darawsheh 1202c77ad9deSRaslan Darawsheh uint16_t dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], 1203c77ad9deSRaslan Darawsheh uint16_t nb_pkts, __rte_unused void *user_param); 1204c77ad9deSRaslan Darawsheh 1205c77ad9deSRaslan Darawsheh void add_rx_dump_callbacks(portid_t portid); 1206c77ad9deSRaslan Darawsheh void remove_rx_dump_callbacks(portid_t portid); 1207c77ad9deSRaslan Darawsheh void add_tx_dump_callbacks(portid_t portid); 1208c77ad9deSRaslan Darawsheh void remove_tx_dump_callbacks(portid_t portid); 1209b5b38ed8SRaslan Darawsheh void configure_rxtx_dump_callbacks(uint16_t verbose); 1210d862c45bSRaslan Darawsheh 12111e45c908SDekel Peled uint16_t tx_pkt_set_md(uint16_t port_id, __rte_unused uint16_t queue, 12121e45c908SDekel Peled struct rte_mbuf *pkts[], uint16_t nb_pkts, 12131e45c908SDekel Peled __rte_unused void *user_param); 12141e45c908SDekel Peled void add_tx_md_callback(portid_t portid); 12151e45c908SDekel Peled void remove_tx_md_callback(portid_t portid); 12161e45c908SDekel Peled 1217b57b66a9SOri Kam uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue, 1218b57b66a9SOri Kam struct rte_mbuf *pkts[], uint16_t nb_pkts, 1219b57b66a9SOri Kam __rte_unused void *user_param); 1220b57b66a9SOri Kam void add_tx_dynf_callback(portid_t portid); 1221b57b66a9SOri Kam void remove_tx_dynf_callback(portid_t portid); 1222b563c142SFerruh Yigit int update_mtu_from_frame_size(portid_t portid, uint32_t max_rx_pktlen); 122359f3a8acSGregory Etelson void flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename); 122459f3a8acSGregory Etelson void flex_item_destroy(portid_t port_id, uint16_t flex_id); 122559f3a8acSGregory Etelson void port_flex_item_flush(portid_t port_id); 1226b57b66a9SOri Kam 12272566c33cSGregory Etelson extern int flow_parse(const char *src, void *result, unsigned int size, 12282566c33cSGregory Etelson struct rte_flow_attr **attr, 12292566c33cSGregory Etelson struct rte_flow_item **pattern, 12302566c33cSGregory Etelson struct rte_flow_action **actions); 12312566c33cSGregory Etelson 12329ad341b5SHuisong Li uint64_t str_to_rsstypes(const char *str); 12333c23ee6cSHuisong Li const char *rsstypes_to_str(uint64_t rss_type); 12343c23ee6cSHuisong Li 1235119786aaSFerruh Yigit uint16_t str_to_flowtype(const char *string); 1236119786aaSFerruh Yigit const char *flowtype_to_str(uint16_t flow_type); 1237119786aaSFerruh Yigit 1238592ab76fSDavid Marchand /* For registering driver specific testpmd commands. */ 1239592ab76fSDavid Marchand struct testpmd_driver_commands { 1240592ab76fSDavid Marchand TAILQ_ENTRY(testpmd_driver_commands) next; 1241592ab76fSDavid Marchand struct { 1242592ab76fSDavid Marchand cmdline_parse_inst_t *ctx; 1243592ab76fSDavid Marchand const char *help; 1244592ab76fSDavid Marchand } commands[]; 1245592ab76fSDavid Marchand }; 1246592ab76fSDavid Marchand 1247592ab76fSDavid Marchand void testpmd_add_driver_commands(struct testpmd_driver_commands *c); 1248592ab76fSDavid Marchand #define TESTPMD_ADD_DRIVER_COMMANDS(c) \ 1249592ab76fSDavid Marchand RTE_INIT(__##c) \ 1250592ab76fSDavid Marchand { \ 1251592ab76fSDavid Marchand testpmd_add_driver_commands(&c); \ 1252592ab76fSDavid Marchand } 1253592ab76fSDavid Marchand 1254af75078fSIntel /* 1255af75078fSIntel * Work-around of a compilation error with ICC on invocations of the 1256af75078fSIntel * rte_be_to_cpu_16() function. 1257af75078fSIntel */ 1258af75078fSIntel #ifdef __GCC__ 1259af75078fSIntel #define RTE_BE_TO_CPU_16(be_16_v) rte_be_to_cpu_16((be_16_v)) 1260af75078fSIntel #define RTE_CPU_TO_BE_16(cpu_16_v) rte_cpu_to_be_16((cpu_16_v)) 1261af75078fSIntel #else 126244eb9456SThomas Monjalon #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN 1263af75078fSIntel #define RTE_BE_TO_CPU_16(be_16_v) (be_16_v) 1264af75078fSIntel #define RTE_CPU_TO_BE_16(cpu_16_v) (cpu_16_v) 1265af75078fSIntel #else 1266af75078fSIntel #define RTE_BE_TO_CPU_16(be_16_v) \ 1267af75078fSIntel (uint16_t) ((((be_16_v) & 0xFF) << 8) | ((be_16_v) >> 8)) 1268af75078fSIntel #define RTE_CPU_TO_BE_16(cpu_16_v) \ 1269af75078fSIntel (uint16_t) ((((cpu_16_v) & 0xFF) << 8) | ((cpu_16_v) >> 8)) 1270af75078fSIntel #endif 1271af75078fSIntel #endif /* __GCC__ */ 1272af75078fSIntel 1273285fd101SOlivier Matz #define TESTPMD_LOG(level, fmt, args...) \ 1274285fd101SOlivier Matz rte_log(RTE_LOG_ ## level, testpmd_logtype, "testpmd: " fmt, ## args) 1275285fd101SOlivier Matz 1276af75078fSIntel #endif /* _TESTPMD_H_ */ 1277