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