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