1af75078fSIntel /*- 2af75078fSIntel * BSD LICENSE 3af75078fSIntel * 4e9d48c00SBruce Richardson * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. 5af75078fSIntel * All rights reserved. 6af75078fSIntel * 7af75078fSIntel * Redistribution and use in source and binary forms, with or without 8af75078fSIntel * modification, are permitted provided that the following conditions 9af75078fSIntel * are met: 10af75078fSIntel * 11af75078fSIntel * * Redistributions of source code must retain the above copyright 12af75078fSIntel * notice, this list of conditions and the following disclaimer. 13af75078fSIntel * * Redistributions in binary form must reproduce the above copyright 14af75078fSIntel * notice, this list of conditions and the following disclaimer in 15af75078fSIntel * the documentation and/or other materials provided with the 16af75078fSIntel * distribution. 17af75078fSIntel * * Neither the name of Intel Corporation nor the names of its 18af75078fSIntel * contributors may be used to endorse or promote products derived 19af75078fSIntel * from this software without specific prior written permission. 20af75078fSIntel * 21af75078fSIntel * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22af75078fSIntel * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23af75078fSIntel * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24af75078fSIntel * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25af75078fSIntel * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26af75078fSIntel * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27af75078fSIntel * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28af75078fSIntel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29af75078fSIntel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30af75078fSIntel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31af75078fSIntel * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32af75078fSIntel */ 33af75078fSIntel 34af75078fSIntel #ifndef _TESTPMD_H_ 35af75078fSIntel #define _TESTPMD_H_ 36af75078fSIntel 37af75078fSIntel /* icc on baremetal gives us troubles with function named 'main' */ 38af75078fSIntel #ifdef RTE_EXEC_ENV_BAREMETAL 39af75078fSIntel #define main _main 40af75078fSIntel int main(int argc, char **argv); 41af75078fSIntel #endif 42af75078fSIntel 43ce8d5614SIntel #define RTE_PORT_ALL (~(portid_t)0x0) 44ce8d5614SIntel 45ce8d5614SIntel #define RTE_TEST_RX_DESC_MAX 2048 46ce8d5614SIntel #define RTE_TEST_TX_DESC_MAX 2048 47ce8d5614SIntel 48ce8d5614SIntel #define RTE_PORT_STOPPED (uint16_t)0 49ce8d5614SIntel #define RTE_PORT_STARTED (uint16_t)1 50ce8d5614SIntel #define RTE_PORT_CLOSED (uint16_t)2 51ce8d5614SIntel #define RTE_PORT_HANDLING (uint16_t)3 52ce8d5614SIntel 53af75078fSIntel /* 54af75078fSIntel * Default size of the mbuf data buffer to receive standard 1518-byte 55af75078fSIntel * Ethernet frames in a mono-segment memory buffer. 56af75078fSIntel */ 57af75078fSIntel #define DEFAULT_MBUF_DATA_SIZE 2048 /**< Default size of mbuf data buffer. */ 58af75078fSIntel 59af75078fSIntel /* 60af75078fSIntel * The maximum number of segments per packet is used when creating 61af75078fSIntel * scattered transmit packets composed of a list of mbufs. 62af75078fSIntel */ 63ea672a8bSOlivier Matz #define RTE_MAX_SEGS_PER_PKT 255 /**< nb_segs is a 8-bit unsigned char. */ 64af75078fSIntel 65af75078fSIntel #define MAX_PKT_BURST 512 66836853d3SCunming Liang #define DEF_PKT_BURST 32 67af75078fSIntel 68e9378bbcSCunming Liang #define DEF_MBUF_CACHE 250 69e9378bbcSCunming Liang 70af75078fSIntel #define CACHE_LINE_SIZE_ROUNDUP(size) \ 71af75078fSIntel (CACHE_LINE_SIZE * ((size + CACHE_LINE_SIZE - 1) / CACHE_LINE_SIZE)) 72af75078fSIntel 73b6ea6408SIntel #define NUMA_NO_CONFIG 0xFF 74b6ea6408SIntel #define UMA_NO_CONFIG 0xFF 75b6ea6408SIntel 76af75078fSIntel typedef uint8_t lcoreid_t; 77af75078fSIntel typedef uint8_t portid_t; 78af75078fSIntel typedef uint16_t queueid_t; 79af75078fSIntel typedef uint16_t streamid_t; 80af75078fSIntel 81af75078fSIntel #define MAX_QUEUE_ID ((1 << (sizeof(queueid_t) * 8)) - 1) 82af75078fSIntel 83af75078fSIntel enum { 84af75078fSIntel PORT_TOPOLOGY_PAIRED, 853e2006d6SCyril Chemparathy PORT_TOPOLOGY_CHAINED, 863e2006d6SCyril Chemparathy PORT_TOPOLOGY_LOOP, 87af75078fSIntel }; 88af75078fSIntel 89af75078fSIntel #ifdef RTE_TEST_PMD_RECORD_BURST_STATS 90af75078fSIntel /** 91af75078fSIntel * The data structure associated with RX and TX packet burst statistics 92af75078fSIntel * that are recorded for each forwarding stream. 93af75078fSIntel */ 94af75078fSIntel struct pkt_burst_stats { 95af75078fSIntel unsigned int pkt_burst_spread[MAX_PKT_BURST]; 96af75078fSIntel }; 97af75078fSIntel #endif 98af75078fSIntel 99af75078fSIntel /** 100af75078fSIntel * The data structure associated with a forwarding stream between a receive 101af75078fSIntel * port/queue and a transmit port/queue. 102af75078fSIntel */ 103af75078fSIntel struct fwd_stream { 104af75078fSIntel /* "read-only" data */ 105af75078fSIntel portid_t rx_port; /**< port to poll for received packets */ 106af75078fSIntel queueid_t rx_queue; /**< RX queue to poll on "rx_port" */ 107af75078fSIntel portid_t tx_port; /**< forwarding port of received packets */ 108af75078fSIntel queueid_t tx_queue; /**< TX queue to send forwarded packets */ 109af75078fSIntel streamid_t peer_addr; /**< index of peer ethernet address of packets */ 110af75078fSIntel 111af75078fSIntel /* "read-write" results */ 112af75078fSIntel unsigned int rx_packets; /**< received packets */ 113af75078fSIntel unsigned int tx_packets; /**< received packets transmitted */ 114af75078fSIntel unsigned int fwd_dropped; /**< received packets not forwarded */ 115af75078fSIntel unsigned int rx_bad_ip_csum ; /**< received packets has bad ip checksum */ 116af75078fSIntel unsigned int rx_bad_l4_csum ; /**< received packets has bad l4 checksum */ 117af75078fSIntel #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES 118af75078fSIntel uint64_t core_cycles; /**< used for RX and TX processing */ 119af75078fSIntel #endif 120af75078fSIntel #ifdef RTE_TEST_PMD_RECORD_BURST_STATS 121af75078fSIntel struct pkt_burst_stats rx_burst_stats; 122af75078fSIntel struct pkt_burst_stats tx_burst_stats; 123af75078fSIntel #endif 124af75078fSIntel }; 125af75078fSIntel 126cf543fdbSOlivier Matz /** Offload IP checksum in csum forward engine */ 127cf543fdbSOlivier Matz #define TESTPMD_TX_OFFLOAD_IP_CKSUM 0x0001 128cf543fdbSOlivier Matz /** Offload UDP checksum in csum forward engine */ 129cf543fdbSOlivier Matz #define TESTPMD_TX_OFFLOAD_UDP_CKSUM 0x0002 130cf543fdbSOlivier Matz /** Offload TCP checksum in csum forward engine */ 131cf543fdbSOlivier Matz #define TESTPMD_TX_OFFLOAD_TCP_CKSUM 0x0004 132cf543fdbSOlivier Matz /** Offload SCTP checksum in csum forward engine */ 133cf543fdbSOlivier Matz #define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 13451f694ddSOlivier Matz /** Offload VxLAN checksum in csum forward engine */ 13551f694ddSOlivier Matz #define TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 0x0010 136cf543fdbSOlivier Matz /** Insert VLAN header in forward engine */ 13751f694ddSOlivier Matz #define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0020 13851f694ddSOlivier Matz 139af75078fSIntel /** 140af75078fSIntel * The data structure associated with each port. 141af75078fSIntel */ 142af75078fSIntel struct rte_port { 143af75078fSIntel struct rte_eth_dev_info dev_info; /**< PCI info + driver name */ 144af75078fSIntel struct rte_eth_conf dev_conf; /**< Port configuration. */ 145af75078fSIntel struct ether_addr eth_addr; /**< Port ethernet address */ 146af75078fSIntel struct rte_eth_stats stats; /**< Last port statistics */ 147af75078fSIntel uint64_t tx_dropped; /**< If no descriptor in TX ring */ 148af75078fSIntel struct fwd_stream *rx_stream; /**< Port RX stream, if unique */ 149af75078fSIntel struct fwd_stream *tx_stream; /**< Port TX stream, if unique */ 150af75078fSIntel unsigned int socket_id; /**< For NUMA support */ 151cf543fdbSOlivier Matz uint16_t tx_ol_flags;/**< TX Offload Flags (TESTPMD_TX_OFFLOAD...). */ 152*b51c4753SOlivier Matz uint16_t tso_segsz; /**< MSS for segmentation offload. */ 153af75078fSIntel uint16_t tx_vlan_id; /**< Tag Id. in TX VLAN packets. */ 154af75078fSIntel void *fwd_ctx; /**< Forwarding mode context */ 155af75078fSIntel uint64_t rx_bad_ip_csum; /**< rx pkts with bad ip checksum */ 156af75078fSIntel uint64_t rx_bad_l4_csum; /**< rx pkts with bad l4 checksum */ 157ed30d9b6SIntel uint8_t tx_queue_stats_mapping_enabled; 158ed30d9b6SIntel uint8_t rx_queue_stats_mapping_enabled; 159ce8d5614SIntel volatile uint16_t port_status; /**< port started or not */ 160ce8d5614SIntel uint8_t need_reconfig; /**< need reconfiguring port or not */ 161ce8d5614SIntel uint8_t need_reconfig_queues; /**< need reconfiguring queues or not */ 162ce8d5614SIntel uint8_t rss_flag; /**< enable rss or not */ 1637741e4cfSIntel uint8_t dcb_flag; /**< enable dcb */ 164ce8d5614SIntel struct rte_eth_rxconf rx_conf; /**< rx configuration */ 165ce8d5614SIntel struct rte_eth_txconf tx_conf; /**< tx configuration */ 166af75078fSIntel }; 167af75078fSIntel 168af75078fSIntel /** 169af75078fSIntel * The data structure associated with each forwarding logical core. 170af75078fSIntel * The logical cores are internally numbered by a core index from 0 to 171af75078fSIntel * the maximum number of logical cores - 1. 172af75078fSIntel * The system CPU identifier of all logical cores are setup in a global 173af75078fSIntel * CPU id. configuration table. 174af75078fSIntel */ 175af75078fSIntel struct fwd_lcore { 176af75078fSIntel struct rte_mempool *mbp; /**< The mbuf pool to use by this core */ 177af75078fSIntel streamid_t stream_idx; /**< index of 1st stream in "fwd_streams" */ 178af75078fSIntel streamid_t stream_nb; /**< number of streams in "fwd_streams" */ 179af75078fSIntel lcoreid_t cpuid_idx; /**< index of logical core in CPU id table */ 180af75078fSIntel queueid_t tx_queue; /**< TX queue to send forwarded packets */ 181af75078fSIntel volatile char stopped; /**< stop forwarding when set */ 182af75078fSIntel }; 183af75078fSIntel 184af75078fSIntel /* 185af75078fSIntel * Forwarding mode operations: 186af75078fSIntel * - IO forwarding mode (default mode) 187af75078fSIntel * Forwards packets unchanged. 188af75078fSIntel * 189af75078fSIntel * - MAC forwarding mode 190af75078fSIntel * Set the source and the destination Ethernet addresses of packets 191af75078fSIntel * before forwarding them. 192af75078fSIntel * 193af75078fSIntel * - IEEE1588 forwarding mode 194af75078fSIntel * Check that received IEEE1588 Precise Time Protocol (PTP) packets are 195af75078fSIntel * filtered and timestamped by the hardware. 196af75078fSIntel * Forwards packets unchanged on the same port. 197af75078fSIntel * Check that sent IEEE1588 PTP packets are timestamped by the hardware. 198af75078fSIntel */ 199af75078fSIntel typedef void (*port_fwd_begin_t)(portid_t pi); 200af75078fSIntel typedef void (*port_fwd_end_t)(portid_t pi); 201af75078fSIntel typedef void (*packet_fwd_t)(struct fwd_stream *fs); 202af75078fSIntel 203af75078fSIntel struct fwd_engine { 204af75078fSIntel const char *fwd_mode_name; /**< Forwarding mode name. */ 205af75078fSIntel port_fwd_begin_t port_fwd_begin; /**< NULL if nothing special to do. */ 206af75078fSIntel port_fwd_end_t port_fwd_end; /**< NULL if nothing special to do. */ 207af75078fSIntel packet_fwd_t packet_fwd; /**< Mandatory. */ 208af75078fSIntel }; 209af75078fSIntel 210af75078fSIntel extern struct fwd_engine io_fwd_engine; 211af75078fSIntel extern struct fwd_engine mac_fwd_engine; 21257e85242SBruce Richardson extern struct fwd_engine mac_retry_fwd_engine; 213d47388f1SCyril Chemparathy extern struct fwd_engine mac_swap_engine; 214e9e23a61SCyril Chemparathy extern struct fwd_engine flow_gen_engine; 215af75078fSIntel extern struct fwd_engine rx_only_engine; 216af75078fSIntel extern struct fwd_engine tx_only_engine; 217af75078fSIntel extern struct fwd_engine csum_fwd_engine; 218168dfa61SIvan Boule extern struct fwd_engine icmp_echo_engine; 219af75078fSIntel #ifdef RTE_LIBRTE_IEEE1588 220af75078fSIntel extern struct fwd_engine ieee1588_fwd_engine; 221af75078fSIntel #endif 222af75078fSIntel 223af75078fSIntel extern struct fwd_engine * fwd_engines[]; /**< NULL terminated array. */ 224af75078fSIntel 225af75078fSIntel /** 226af75078fSIntel * Forwarding Configuration 227af75078fSIntel * 228af75078fSIntel */ 229af75078fSIntel struct fwd_config { 230af75078fSIntel struct fwd_engine *fwd_eng; /**< Packet forwarding mode. */ 231af75078fSIntel streamid_t nb_fwd_streams; /**< Nb. of forward streams to process. */ 232af75078fSIntel lcoreid_t nb_fwd_lcores; /**< Nb. of logical cores to launch. */ 233af75078fSIntel portid_t nb_fwd_ports; /**< Nb. of ports involved. */ 234af75078fSIntel }; 235af75078fSIntel 236900550deSIntel /** 237900550deSIntel * DCB mode enable 238900550deSIntel */ 239900550deSIntel enum dcb_mode_enable 240900550deSIntel { 241900550deSIntel DCB_VT_ENABLED, 242900550deSIntel DCB_ENABLED 243900550deSIntel }; 244900550deSIntel 245900550deSIntel /* 246900550deSIntel * DCB general config info 247900550deSIntel */ 248900550deSIntel struct dcb_config { 249900550deSIntel enum dcb_mode_enable dcb_mode; 250900550deSIntel uint8_t vt_en; 251900550deSIntel enum rte_eth_nb_tcs num_tcs; 252900550deSIntel uint8_t pfc_en; 253900550deSIntel }; 254900550deSIntel 255900550deSIntel /* 256900550deSIntel * In DCB io FWD mode, 128 RX queue to 128 TX queue mapping 257900550deSIntel */ 258900550deSIntel enum dcb_queue_mapping_mode { 259900550deSIntel DCB_VT_Q_MAPPING = 0, 260900550deSIntel DCB_4_TCS_Q_MAPPING, 261900550deSIntel DCB_8_TCS_Q_MAPPING 262900550deSIntel }; 263900550deSIntel 264ed30d9b6SIntel #define MAX_TX_QUEUE_STATS_MAPPINGS 1024 /* MAX_PORT of 32 @ 32 tx_queues/port */ 265ed30d9b6SIntel #define MAX_RX_QUEUE_STATS_MAPPINGS 4096 /* MAX_PORT of 32 @ 128 rx_queues/port */ 266ed30d9b6SIntel 267ed30d9b6SIntel struct queue_stats_mappings { 268ed30d9b6SIntel uint8_t port_id; 269ed30d9b6SIntel uint16_t queue_id; 270ed30d9b6SIntel uint8_t stats_counter_id; 271ed30d9b6SIntel } __rte_cache_aligned; 272ed30d9b6SIntel 273ed30d9b6SIntel extern struct queue_stats_mappings tx_queue_stats_mappings_array[]; 274ed30d9b6SIntel extern struct queue_stats_mappings rx_queue_stats_mappings_array[]; 275ed30d9b6SIntel 276ed30d9b6SIntel /* Assign both tx and rx queue stats mappings to the same default values */ 277ed30d9b6SIntel extern struct queue_stats_mappings *tx_queue_stats_mappings; 278ed30d9b6SIntel extern struct queue_stats_mappings *rx_queue_stats_mappings; 279ed30d9b6SIntel 280ed30d9b6SIntel extern uint16_t nb_tx_queue_stats_mappings; 281ed30d9b6SIntel extern uint16_t nb_rx_queue_stats_mappings; 282ed30d9b6SIntel 283af75078fSIntel /* globals used for configuration */ 284af75078fSIntel extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */ 285af75078fSIntel extern uint8_t interactive; 286ca7feb22SCyril Chemparathy extern uint8_t auto_start; 287af75078fSIntel extern uint8_t numa_support; /**< set by "--numa" parameter */ 288af75078fSIntel extern uint16_t port_topology; /**< set by "--port-topology" parameter */ 2897741e4cfSIntel extern uint8_t no_flush_rx; /**<set by "--no-flush-rx" parameter */ 290148f963fSBruce Richardson extern uint8_t mp_anon; /**< set by "--mp-anon" parameter */ 291bc202406SDavid Marchand extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */ 2922950a769SDeclan Doherty extern volatile int test_done; /* stop packet forwarding when set to 1. */ 293af75078fSIntel 2947b7e5ba7SIntel #ifdef RTE_NIC_BYPASS 2957b7e5ba7SIntel extern uint32_t bypass_timeout; /**< Store the NIC bypass watchdog timeout */ 2967b7e5ba7SIntel #endif 2977b7e5ba7SIntel 298b6ea6408SIntel #define MAX_SOCKET 2 /*MAX SOCKET:currently, it is 2 */ 299b6ea6408SIntel 300b6ea6408SIntel /* 301b6ea6408SIntel * Store specified sockets on which memory pool to be used by ports 302b6ea6408SIntel * is allocated. 303b6ea6408SIntel */ 304b6ea6408SIntel uint8_t port_numa[RTE_MAX_ETHPORTS]; 305b6ea6408SIntel 306b6ea6408SIntel /* 307b6ea6408SIntel * Store specified sockets on which RX ring to be used by ports 308b6ea6408SIntel * is allocated. 309b6ea6408SIntel */ 310b6ea6408SIntel uint8_t rxring_numa[RTE_MAX_ETHPORTS]; 311b6ea6408SIntel 312b6ea6408SIntel /* 313b6ea6408SIntel * Store specified sockets on which TX ring to be used by ports 314b6ea6408SIntel * is allocated. 315b6ea6408SIntel */ 316b6ea6408SIntel uint8_t txring_numa[RTE_MAX_ETHPORTS]; 317b6ea6408SIntel 318b6ea6408SIntel extern uint8_t socket_num; 319b6ea6408SIntel 320af75078fSIntel /* 321af75078fSIntel * Configuration of logical cores: 322af75078fSIntel * nb_fwd_lcores <= nb_cfg_lcores <= nb_lcores 323af75078fSIntel */ 324af75078fSIntel extern lcoreid_t nb_lcores; /**< Number of logical cores probed at init time. */ 325af75078fSIntel extern lcoreid_t nb_cfg_lcores; /**< Number of configured logical cores. */ 326af75078fSIntel extern lcoreid_t nb_fwd_lcores; /**< Number of forwarding logical cores. */ 327af75078fSIntel extern unsigned int fwd_lcores_cpuids[RTE_MAX_LCORE]; 328af75078fSIntel 329af75078fSIntel /* 330af75078fSIntel * Configuration of Ethernet ports: 331af75078fSIntel * nb_fwd_ports <= nb_cfg_ports <= nb_ports 332af75078fSIntel */ 333af75078fSIntel extern portid_t nb_ports; /**< Number of ethernet ports probed at init time. */ 334af75078fSIntel extern portid_t nb_cfg_ports; /**< Number of configured ports. */ 335af75078fSIntel extern portid_t nb_fwd_ports; /**< Number of forwarding ports. */ 336af75078fSIntel extern portid_t fwd_ports_ids[RTE_MAX_ETHPORTS]; 337af75078fSIntel extern struct rte_port *ports; 338af75078fSIntel 339af75078fSIntel extern struct rte_eth_rxmode rx_mode; 3408a387fa8SHelin Zhang extern uint64_t rss_hf; 341af75078fSIntel 342af75078fSIntel extern queueid_t nb_rxq; 343af75078fSIntel extern queueid_t nb_txq; 344af75078fSIntel 345af75078fSIntel extern uint16_t nb_rxd; 346af75078fSIntel extern uint16_t nb_txd; 347af75078fSIntel 348af75078fSIntel extern uint16_t rx_free_thresh; 349ce8d5614SIntel extern uint8_t rx_drop_en; 350af75078fSIntel extern uint16_t tx_free_thresh; 351af75078fSIntel extern uint16_t tx_rs_thresh; 352ce8d5614SIntel extern uint32_t txq_flags; 353af75078fSIntel 354900550deSIntel extern uint8_t dcb_config; 355900550deSIntel extern uint8_t dcb_test; 356900550deSIntel extern enum dcb_queue_mapping_mode dcb_q_mapping; 357900550deSIntel 358af75078fSIntel extern uint16_t mbuf_data_size; /**< Mbuf data space size. */ 359c8798818SIntel extern uint32_t param_total_num_mbufs; 360af75078fSIntel 361af75078fSIntel extern struct rte_fdir_conf fdir_conf; 362af75078fSIntel 363af75078fSIntel /* 364af75078fSIntel * Configuration of packet segments used by the "txonly" processing engine. 365af75078fSIntel */ 366af75078fSIntel #define TXONLY_DEF_PACKET_LEN 64 367af75078fSIntel extern uint16_t tx_pkt_length; /**< Length of TXONLY packet */ 368af75078fSIntel extern uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT]; /**< Seg. lengths */ 369af75078fSIntel extern uint8_t tx_pkt_nb_segs; /**< Number of segments in TX packets */ 370af75078fSIntel 371af75078fSIntel extern uint16_t nb_pkt_per_burst; 372af75078fSIntel extern uint16_t mb_mempool_cache; 373af75078fSIntel extern struct rte_eth_thresh rx_thresh; 374af75078fSIntel extern struct rte_eth_thresh tx_thresh; 375af75078fSIntel 376af75078fSIntel extern struct fwd_config cur_fwd_config; 377af75078fSIntel extern struct fwd_engine *cur_fwd_eng; 378af75078fSIntel extern struct fwd_lcore **fwd_lcores; 379af75078fSIntel extern struct fwd_stream **fwd_streams; 380af75078fSIntel 381af75078fSIntel extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */ 382af75078fSIntel extern struct ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS]; 383af75078fSIntel 38457e85242SBruce Richardson extern uint32_t burst_tx_delay_time; /**< Burst tx delay time(us) for mac-retry. */ 38557e85242SBruce Richardson extern uint32_t burst_tx_retry_num; /**< Burst tx retry number for mac-retry. */ 38657e85242SBruce Richardson 387af75078fSIntel static inline unsigned int 388af75078fSIntel lcore_num(void) 389af75078fSIntel { 390af75078fSIntel unsigned int i; 391af75078fSIntel 392af75078fSIntel for (i = 0; i < RTE_MAX_LCORE; ++i) 393af75078fSIntel if (fwd_lcores_cpuids[i] == rte_lcore_id()) 394af75078fSIntel return i; 395af75078fSIntel 396af75078fSIntel rte_panic("lcore_id of current thread not found in fwd_lcores_cpuids\n"); 397af75078fSIntel } 398af75078fSIntel 399af75078fSIntel static inline struct fwd_lcore * 400af75078fSIntel current_fwd_lcore(void) 401af75078fSIntel { 402af75078fSIntel return fwd_lcores[lcore_num()]; 403af75078fSIntel } 404af75078fSIntel 405af75078fSIntel /* Mbuf Pools */ 406af75078fSIntel static inline void 407af75078fSIntel mbuf_poolname_build(unsigned int sock_id, char* mp_name, int name_size) 408af75078fSIntel { 4096f41fe75SStephen Hemminger snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id); 410af75078fSIntel } 411af75078fSIntel 412af75078fSIntel static inline struct rte_mempool * 413af75078fSIntel mbuf_pool_find(unsigned int sock_id) 414af75078fSIntel { 415af75078fSIntel char pool_name[RTE_MEMPOOL_NAMESIZE]; 416af75078fSIntel 417af75078fSIntel mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name)); 418af75078fSIntel return (rte_mempool_lookup((const char *)pool_name)); 419af75078fSIntel } 420af75078fSIntel 421af75078fSIntel /** 422af75078fSIntel * Read/Write operations on a PCI register of a port. 423af75078fSIntel */ 424af75078fSIntel static inline uint32_t 425af75078fSIntel port_pci_reg_read(struct rte_port *port, uint32_t reg_off) 426af75078fSIntel { 427af75078fSIntel void *reg_addr; 428af75078fSIntel uint32_t reg_v; 429af75078fSIntel 430eee16c96SStephen Hemminger reg_addr = (void *) 431eee16c96SStephen Hemminger ((char *)port->dev_info.pci_dev->mem_resource[0].addr + 432af75078fSIntel reg_off); 433af75078fSIntel reg_v = *((volatile uint32_t *)reg_addr); 434af75078fSIntel return rte_le_to_cpu_32(reg_v); 435af75078fSIntel } 436af75078fSIntel 437af75078fSIntel #define port_id_pci_reg_read(pt_id, reg_off) \ 438af75078fSIntel port_pci_reg_read(&ports[(pt_id)], (reg_off)) 439af75078fSIntel 440af75078fSIntel static inline void 441af75078fSIntel port_pci_reg_write(struct rte_port *port, uint32_t reg_off, uint32_t reg_v) 442af75078fSIntel { 443af75078fSIntel void *reg_addr; 444af75078fSIntel 445eee16c96SStephen Hemminger reg_addr = (void *) 446eee16c96SStephen Hemminger ((char *)port->dev_info.pci_dev->mem_resource[0].addr + 447af75078fSIntel reg_off); 448af75078fSIntel *((volatile uint32_t *)reg_addr) = rte_cpu_to_le_32(reg_v); 449af75078fSIntel } 450af75078fSIntel 451af75078fSIntel #define port_id_pci_reg_write(pt_id, reg_off, reg_value) \ 452af75078fSIntel port_pci_reg_write(&ports[(pt_id)], (reg_off), (reg_value)) 453af75078fSIntel 454af75078fSIntel /* Prototypes */ 455af75078fSIntel void launch_args_parse(int argc, char** argv); 456af75078fSIntel void prompt(void); 457af75078fSIntel void nic_stats_display(portid_t port_id); 458af75078fSIntel void nic_stats_clear(portid_t port_id); 459bfd5051bSOlivier Matz void nic_xstats_display(portid_t port_id); 460bfd5051bSOlivier Matz void nic_xstats_clear(portid_t port_id); 461ed30d9b6SIntel void nic_stats_mapping_display(portid_t port_id); 462af75078fSIntel void port_infos_display(portid_t port_id); 463af75078fSIntel void fwd_lcores_config_display(void); 464af75078fSIntel void fwd_config_display(void); 465af75078fSIntel void rxtx_config_display(void); 466af75078fSIntel void fwd_config_setup(void); 467af75078fSIntel void set_def_fwd_config(void); 468a21d5a4bSDeclan Doherty void reconfig(portid_t new_port_id, unsigned socket_id); 469013af9b6SIntel int init_fwd_streams(void); 470013af9b6SIntel 471ae03d0d1SIvan Boule void port_mtu_set(portid_t port_id, uint16_t mtu); 472af75078fSIntel void port_reg_bit_display(portid_t port_id, uint32_t reg_off, uint8_t bit_pos); 473af75078fSIntel void port_reg_bit_set(portid_t port_id, uint32_t reg_off, uint8_t bit_pos, 474af75078fSIntel uint8_t bit_v); 475af75078fSIntel void port_reg_bit_field_display(portid_t port_id, uint32_t reg_off, 476af75078fSIntel uint8_t bit1_pos, uint8_t bit2_pos); 477af75078fSIntel void port_reg_bit_field_set(portid_t port_id, uint32_t reg_off, 478af75078fSIntel uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value); 479af75078fSIntel void port_reg_display(portid_t port_id, uint32_t reg_off); 480af75078fSIntel void port_reg_set(portid_t port_id, uint32_t reg_off, uint32_t value); 481af75078fSIntel 482af75078fSIntel void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id); 483af75078fSIntel void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id); 484af75078fSIntel 485013af9b6SIntel int set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc); 486013af9b6SIntel int set_fwd_lcores_mask(uint64_t lcoremask); 487af75078fSIntel void set_fwd_lcores_number(uint16_t nb_lc); 488af75078fSIntel 489af75078fSIntel void set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt); 490af75078fSIntel void set_fwd_ports_mask(uint64_t portmask); 491af75078fSIntel void set_fwd_ports_number(uint16_t nb_pt); 492af75078fSIntel 493a47aa8b9SIntel void rx_vlan_strip_set(portid_t port_id, int on); 494a47aa8b9SIntel void rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t queue_id, int on); 495a47aa8b9SIntel 496a47aa8b9SIntel void rx_vlan_filter_set(portid_t port_id, int on); 497af75078fSIntel void rx_vlan_all_filter_set(portid_t port_id, int on); 498a47aa8b9SIntel void rx_vft_set(portid_t port_id, uint16_t vlan_id, int on); 499a47aa8b9SIntel void vlan_extend_set(portid_t port_id, int on); 500a47aa8b9SIntel void vlan_tpid_set(portid_t port_id, uint16_t tp_id); 501af75078fSIntel void tx_vlan_set(portid_t port_id, uint16_t vlan_id); 502af75078fSIntel void tx_vlan_reset(portid_t port_id); 503529ba951SHelin Zhang void tx_vlan_pvid_set(portid_t port_id, uint16_t vlan_id, int on); 504ed30d9b6SIntel 505ed30d9b6SIntel void set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value); 506ed30d9b6SIntel 507af75078fSIntel void set_verbose_level(uint16_t vb_level); 508af75078fSIntel void set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs); 509af75078fSIntel void set_nb_pkt_per_burst(uint16_t pkt_burst); 510769ce6b1SThomas Monjalon char *list_pkt_forwarding_modes(void); 511af75078fSIntel void set_pkt_forwarding_mode(const char *fwd_mode); 512af75078fSIntel void start_packet_forwarding(int with_tx_first); 513af75078fSIntel void stop_packet_forwarding(void); 514cfae07fdSOuyang Changchun void dev_set_link_up(portid_t pid); 515cfae07fdSOuyang Changchun void dev_set_link_down(portid_t pid); 516ce8d5614SIntel void init_port_config(void); 517900550deSIntel int init_port_dcb_config(portid_t pid,struct dcb_config *dcb_conf); 518148f963fSBruce Richardson int start_port(portid_t pid); 519ce8d5614SIntel void stop_port(portid_t pid); 520ce8d5614SIntel void close_port(portid_t pid); 521ce8d5614SIntel int all_ports_stopped(void); 5225f4ec54fSChen Jing D(Mark) int port_is_started(portid_t port_id); 523af75078fSIntel void pmd_test_exit(void); 524af75078fSIntel 525af75078fSIntel void fdir_add_signature_filter(portid_t port_id, uint8_t queue_id, 526af75078fSIntel struct rte_fdir_filter *fdir_filter); 527af75078fSIntel void fdir_update_signature_filter(portid_t port_id, uint8_t queue_id, 528af75078fSIntel struct rte_fdir_filter *fdir_filter); 529af75078fSIntel void fdir_remove_signature_filter(portid_t port_id, 530af75078fSIntel struct rte_fdir_filter *fdir_filter); 531af75078fSIntel void fdir_get_infos(portid_t port_id); 532af75078fSIntel void fdir_add_perfect_filter(portid_t port_id, uint16_t soft_id, 533af75078fSIntel uint8_t queue_id, uint8_t drop, 534af75078fSIntel struct rte_fdir_filter *fdir_filter); 535af75078fSIntel void fdir_update_perfect_filter(portid_t port_id, uint16_t soft_id, 536af75078fSIntel uint8_t queue_id, uint8_t drop, 537af75078fSIntel struct rte_fdir_filter *fdir_filter); 538af75078fSIntel void fdir_remove_perfect_filter(portid_t port_id, uint16_t soft_id, 539af75078fSIntel struct rte_fdir_filter *fdir_filter); 540af75078fSIntel void fdir_set_masks(portid_t port_id, struct rte_fdir_masks *fdir_masks); 541aeca06dfSJingjing Wu void fdir_set_flex_mask(portid_t port_id, 542aeca06dfSJingjing Wu struct rte_eth_fdir_flex_mask *cfg); 54397b74464SJingjing Wu void fdir_set_flex_payload(portid_t port_id, 54497b74464SJingjing Wu struct rte_eth_flex_payload_cfg *cfg); 54566c59490SHelin Zhang void port_rss_reta_info(portid_t port_id, 54666c59490SHelin Zhang struct rte_eth_rss_reta_entry64 *reta_conf, 54766c59490SHelin Zhang uint16_t nb_entries); 5486a18e1afSOuyang Changchun 5497741e4cfSIntel void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on); 5507741e4cfSIntel void set_vf_rx_vlan(portid_t port_id, uint16_t vlan_id, 5517741e4cfSIntel uint64_t vf_mask, uint8_t on); 552af75078fSIntel 5536a18e1afSOuyang Changchun int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate); 5546a18e1afSOuyang Changchun int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate, 5556a18e1afSOuyang Changchun uint64_t q_msk); 5566a18e1afSOuyang Changchun 55716321de0SIvan Boule void port_rss_hash_conf_show(portid_t port_id, int show_rss_key); 558f79959eaSIvan Boule void port_rss_hash_key_update(portid_t port_id, uint8_t *hash_key); 5590db70a80SJingjing Wu void get_syn_filter(uint8_t port_id); 5600db70a80SJingjing Wu void get_ethertype_filter(uint8_t port_id, uint16_t index); 5610db70a80SJingjing Wu void get_2tuple_filter(uint8_t port_id, uint16_t index); 5620db70a80SJingjing Wu void get_5tuple_filter(uint8_t port_id, uint16_t index); 5630db70a80SJingjing Wu void get_flex_filter(uint8_t port_id, uint16_t index); 5645f4ec54fSChen Jing D(Mark) int port_id_is_invalid(portid_t port_id); 5655f4ec54fSChen Jing D(Mark) int rx_queue_id_is_invalid(queueid_t rxq_id); 5665f4ec54fSChen Jing D(Mark) int tx_queue_id_is_invalid(queueid_t txq_id); 56716321de0SIvan Boule 568af75078fSIntel /* 569af75078fSIntel * Work-around of a compilation error with ICC on invocations of the 570af75078fSIntel * rte_be_to_cpu_16() function. 571af75078fSIntel */ 572af75078fSIntel #ifdef __GCC__ 573af75078fSIntel #define RTE_BE_TO_CPU_16(be_16_v) rte_be_to_cpu_16((be_16_v)) 574af75078fSIntel #define RTE_CPU_TO_BE_16(cpu_16_v) rte_cpu_to_be_16((cpu_16_v)) 575af75078fSIntel #else 576af75078fSIntel #ifdef __big_endian__ 577af75078fSIntel #define RTE_BE_TO_CPU_16(be_16_v) (be_16_v) 578af75078fSIntel #define RTE_CPU_TO_BE_16(cpu_16_v) (cpu_16_v) 579af75078fSIntel #else 580af75078fSIntel #define RTE_BE_TO_CPU_16(be_16_v) \ 581af75078fSIntel (uint16_t) ((((be_16_v) & 0xFF) << 8) | ((be_16_v) >> 8)) 582af75078fSIntel #define RTE_CPU_TO_BE_16(cpu_16_v) \ 583af75078fSIntel (uint16_t) ((((cpu_16_v) & 0xFF) << 8) | ((cpu_16_v) >> 8)) 584af75078fSIntel #endif 585af75078fSIntel #endif /* __GCC__ */ 586af75078fSIntel 587af75078fSIntel #endif /* _TESTPMD_H_ */ 588