1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2017 Intel Corporation 3 */ 4 5 #include <errno.h> 6 #include <getopt.h> 7 #include <stdarg.h> 8 #include <stdio.h> 9 #include <stdlib.h> 10 #include <signal.h> 11 #include <string.h> 12 #include <time.h> 13 #include <fcntl.h> 14 #include <sys/types.h> 15 16 #include <sys/queue.h> 17 #include <sys/stat.h> 18 19 #include <stdint.h> 20 #include <unistd.h> 21 #include <inttypes.h> 22 23 #include <rte_common.h> 24 #include <rte_byteorder.h> 25 #include <rte_log.h> 26 #include <rte_debug.h> 27 #include <rte_cycles.h> 28 #include <rte_memory.h> 29 #include <rte_launch.h> 30 #include <rte_eal.h> 31 #include <rte_per_lcore.h> 32 #include <rte_lcore.h> 33 #include <rte_atomic.h> 34 #include <rte_branch_prediction.h> 35 #include <rte_mempool.h> 36 #include <rte_interrupts.h> 37 #include <rte_pci.h> 38 #include <rte_ether.h> 39 #include <rte_ethdev.h> 40 #include <rte_string_fns.h> 41 #ifdef RTE_NET_BOND 42 #include <rte_eth_bond.h> 43 #endif 44 #include <rte_flow.h> 45 46 #include "testpmd.h" 47 48 static void 49 usage(char* progname) 50 { 51 printf("\nUsage: %s [EAL options] -- [testpmd options]\n\n", 52 progname); 53 #ifdef RTE_LIB_CMDLINE 54 printf(" --interactive: run in interactive mode.\n"); 55 printf(" --cmdline-file: execute cli commands before startup.\n"); 56 #endif 57 printf(" --auto-start: start forwarding on init " 58 "[always when non-interactive].\n"); 59 printf(" --help: display this message and quit.\n"); 60 printf(" --tx-first: start forwarding sending a burst first " 61 "(only if interactive is disabled).\n"); 62 printf(" --stats-period=PERIOD: statistics will be shown " 63 "every PERIOD seconds (only if interactive is disabled).\n"); 64 printf(" --nb-cores=N: set the number of forwarding cores " 65 "(1 <= N <= %d).\n", nb_lcores); 66 printf(" --nb-ports=N: set the number of forwarding ports " 67 "(1 <= N <= %d).\n", nb_ports); 68 printf(" --coremask=COREMASK: hexadecimal bitmask of cores running " 69 "the packet forwarding test. The main lcore is reserved for " 70 "command line parsing only, and cannot be masked on for " 71 "packet forwarding.\n"); 72 printf(" --portmask=PORTMASK: hexadecimal bitmask of ports used " 73 "by the packet forwarding test.\n"); 74 printf(" --portlist=PORTLIST: list of forwarding ports\n"); 75 printf(" --numa: enable NUMA-aware allocation of RX/TX rings and of " 76 "RX memory buffers (mbufs).\n"); 77 printf(" --no-numa: disable NUMA-aware allocation.\n"); 78 printf(" --port-numa-config=(port,socket)[,(port,socket)]: " 79 "specify the socket on which the memory pool " 80 "used by the port will be allocated.\n"); 81 printf(" --ring-numa-config=(port,flag,socket)[,(port,flag,socket)]: " 82 "specify the socket on which the TX/RX rings for " 83 "the port will be allocated " 84 "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n"); 85 printf(" --socket-num=N: set socket from which all memory is allocated " 86 "in NUMA mode.\n"); 87 printf(" --mbuf-size=N,[N1[,..Nn]: set the data size of mbuf to " 88 "N bytes. If multiple numbers are specified the extra pools " 89 "will be created to receive with packet split features\n"); 90 printf(" --total-num-mbufs=N: set the number of mbufs to be allocated " 91 "in mbuf pools.\n"); 92 printf(" --max-pkt-len=N: set the maximum size of packet to N bytes.\n"); 93 printf(" --max-lro-pkt-size=N: set the maximum LRO aggregated packet " 94 "size to N bytes.\n"); 95 #ifdef RTE_LIB_CMDLINE 96 printf(" --eth-peers-configfile=name: config file with ethernet addresses " 97 "of peer ports.\n"); 98 printf(" --eth-peer=X,M:M:M:M:M:M: set the MAC address of the X peer " 99 "port (0 <= X < %d).\n", RTE_MAX_ETHPORTS); 100 #endif 101 printf(" --pkt-filter-mode=N: set Flow Director mode " 102 "(N: none (default mode) or signature or perfect).\n"); 103 printf(" --pkt-filter-report-hash=N: set Flow Director report mode " 104 "(N: none or match (default) or always).\n"); 105 printf(" --pkt-filter-size=N: set Flow Director mode " 106 "(N: 64K (default mode) or 128K or 256K).\n"); 107 printf(" --pkt-filter-drop-queue=N: set drop-queue. " 108 "In perfect mode, when you add a rule with queue = -1 " 109 "the packet will be enqueued into the rx drop-queue. " 110 "If the drop-queue doesn't exist, the packet is dropped. " 111 "By default drop-queue=127.\n"); 112 #ifdef RTE_LIB_LATENCYSTATS 113 printf(" --latencystats=N: enable latency and jitter statistcs " 114 "monitoring on forwarding lcore id N.\n"); 115 #endif 116 printf(" --disable-crc-strip: disable CRC stripping by hardware.\n"); 117 printf(" --enable-scatter: enable scattered Rx.\n"); 118 printf(" --enable-lro: enable large receive offload.\n"); 119 printf(" --enable-rx-cksum: enable rx hardware checksum offload.\n"); 120 printf(" --enable-rx-timestamp: enable rx hardware timestamp offload.\n"); 121 printf(" --enable-hw-vlan: enable hardware vlan.\n"); 122 printf(" --enable-hw-vlan-filter: enable hardware vlan filter.\n"); 123 printf(" --enable-hw-vlan-strip: enable hardware vlan strip.\n"); 124 printf(" --enable-hw-vlan-extend: enable hardware vlan extend.\n"); 125 printf(" --enable-hw-qinq-strip: enable hardware qinq strip.\n"); 126 printf(" --enable-drop-en: enable per queue packet drop.\n"); 127 printf(" --disable-rss: disable rss.\n"); 128 printf(" --port-topology=<paired|chained|loop>: set port topology (paired " 129 "is default).\n"); 130 printf(" --forward-mode=N: set forwarding mode (N: %s).\n", 131 list_pkt_forwarding_modes()); 132 printf(" --forward-mode=5tswap: set forwarding mode to " 133 "swap L2,L3,L4 for MAC, IPv4/IPv6 and TCP/UDP only.\n"); 134 printf(" --rss-ip: set RSS functions to IPv4/IPv6 only .\n"); 135 printf(" --rss-udp: set RSS functions to IPv4/IPv6 + UDP.\n"); 136 printf(" --rss-level-inner: set RSS hash level to innermost\n"); 137 printf(" --rss-level-outer: set RSS hash level to outermost\n"); 138 printf(" --rxq=N: set the number of RX queues per port to N.\n"); 139 printf(" --rxd=N: set the number of descriptors in RX rings to N.\n"); 140 printf(" --txq=N: set the number of TX queues per port to N.\n"); 141 printf(" --txd=N: set the number of descriptors in TX rings to N.\n"); 142 printf(" --hairpinq=N: set the number of hairpin queues per port to " 143 "N.\n"); 144 printf(" --burst=N: set the number of packets per burst to N.\n"); 145 printf(" --flowgen-clones=N: set the number of single packet clones to send in flowgen mode. Should be less than burst value.\n"); 146 printf(" --mbcache=N: set the cache of mbuf memory pool to N.\n"); 147 printf(" --rxpt=N: set prefetch threshold register of RX rings to N.\n"); 148 printf(" --rxht=N: set the host threshold register of RX rings to N.\n"); 149 printf(" --rxfreet=N: set the free threshold of RX descriptors to N " 150 "(0 <= N < value of rxd).\n"); 151 printf(" --rxwt=N: set the write-back threshold register of RX rings to N.\n"); 152 printf(" --txpt=N: set the prefetch threshold register of TX rings to N.\n"); 153 printf(" --txht=N: set the nhost threshold register of TX rings to N.\n"); 154 printf(" --txwt=N: set the write-back threshold register of TX rings to N.\n"); 155 printf(" --txfreet=N: set the transmit free threshold of TX rings to N " 156 "(0 <= N <= value of txd).\n"); 157 printf(" --txrst=N: set the transmit RS bit threshold of TX rings to N " 158 "(0 <= N <= value of txd).\n"); 159 printf(" --no-flush-rx: Don't flush RX streams before forwarding." 160 " Used mainly with PCAP drivers.\n"); 161 printf(" --rxoffs=X[,Y]*: set RX segment offsets for split.\n"); 162 printf(" --rxpkts=X[,Y]*: set RX segment sizes to split.\n"); 163 printf(" --txpkts=X[,Y]*: set TX segment sizes" 164 " or total packet length.\n"); 165 printf(" --txonly-multi-flow: generate multiple flows in txonly mode\n"); 166 printf(" --tx-ip=src,dst: IP addresses in Tx-only mode\n"); 167 printf(" --tx-udp=src[,dst]: UDP ports in Tx-only mode\n"); 168 printf(" --eth-link-speed: force link speed.\n"); 169 printf(" --disable-link-check: disable check on link status when " 170 "starting/stopping ports.\n"); 171 printf(" --disable-device-start: do not automatically start port\n"); 172 printf(" --no-lsc-interrupt: disable link status change interrupt.\n"); 173 printf(" --no-rmv-interrupt: disable device removal interrupt.\n"); 174 printf(" --bitrate-stats=N: set the logical core N to perform " 175 "bit-rate calculation.\n"); 176 printf(" --print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|flow_aged|all>: " 177 "enable print of designated event or all of them.\n"); 178 printf(" --mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|flow_aged|all>: " 179 "disable print of designated event or all of them.\n"); 180 printf(" --flow-isolate-all: " 181 "requests flow API isolated mode on all ports at initialization time.\n"); 182 printf(" --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n"); 183 printf(" --rx-offloads=0xXXXXXXXX: hexadecimal bitmask of RX queue offloads\n"); 184 printf(" --hot-plug: enable hot plug for device.\n"); 185 printf(" --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\n"); 186 printf(" --geneve-parsed-port=N: UPD port to parse GENEVE tunnel protocol\n"); 187 #ifndef RTE_EXEC_ENV_WINDOWS 188 printf(" --mlockall: lock all memory\n"); 189 printf(" --no-mlockall: do not lock all memory\n"); 190 #endif 191 printf(" --mp-alloc <native|anon|xmem|xmemhuge>: mempool allocation method.\n" 192 " native: use regular DPDK memory to create and populate mempool\n" 193 " anon: use regular DPDK memory to create and anonymous memory to populate mempool\n" 194 " xmem: use anonymous memory to create and populate mempool\n" 195 " xmemhuge: use anonymous hugepage memory to create and populate mempool\n"); 196 printf(" --noisy-tx-sw-buffer-size=N: size of FIFO buffer\n"); 197 printf(" --noisy-tx-sw-buffer-flushtime=N: flush FIFO after N ms\n"); 198 printf(" --noisy-lkup-memory=N: allocate N MB of VNF memory\n"); 199 printf(" --noisy-lkup-num-writes=N: do N random writes per packet\n"); 200 printf(" --noisy-lkup-num-reads=N: do N random reads per packet\n"); 201 printf(" --noisy-lkup-num-reads-writes=N: do N random reads and writes per packet\n"); 202 printf(" --no-iova-contig: mempool memory can be IOVA non contiguous. " 203 "valid only with --mp-alloc=anon\n"); 204 printf(" --rx-mq-mode=0xX: hexadecimal bitmask of RX mq mode can be " 205 "enabled\n"); 206 printf(" --record-core-cycles: enable measurement of CPU cycles.\n"); 207 printf(" --record-burst-stats: enable display of RX and TX bursts.\n"); 208 printf(" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n" 209 " 0x10 - explicit Tx rule, 0x02 - hairpin ports paired\n" 210 " 0x01 - hairpin ports loop, 0x00 - hairpin port self\n"); 211 } 212 213 #ifdef RTE_LIB_CMDLINE 214 static int 215 init_peer_eth_addrs(const char *config_filename) 216 { 217 FILE *config_file; 218 portid_t i; 219 char buf[50]; 220 221 config_file = fopen(config_filename, "r"); 222 if (config_file == NULL) { 223 perror("Failed to open eth config file\n"); 224 return -1; 225 } 226 227 for (i = 0; i < RTE_MAX_ETHPORTS; i++) { 228 229 if (fgets(buf, sizeof(buf), config_file) == NULL) 230 break; 231 232 if (rte_ether_unformat_addr(buf, &peer_eth_addrs[i]) < 0) { 233 fprintf(stderr, "Bad MAC address format on line %d\n", 234 i + 1); 235 fclose(config_file); 236 return -1; 237 } 238 } 239 fclose(config_file); 240 nb_peer_eth_addrs = (portid_t) i; 241 return 0; 242 } 243 #endif 244 245 /* 246 * Parse the coremask given as argument (hexadecimal string) and set 247 * the global configuration of forwarding cores. 248 */ 249 static void 250 parse_fwd_coremask(const char *coremask) 251 { 252 char *end; 253 unsigned long long int cm; 254 255 /* parse hexadecimal string */ 256 end = NULL; 257 cm = strtoull(coremask, &end, 16); 258 if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0')) 259 rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n"); 260 else if (set_fwd_lcores_mask((uint64_t) cm) < 0) 261 rte_exit(EXIT_FAILURE, "coremask is not valid\n"); 262 } 263 264 /* 265 * Parse the coremask given as argument (hexadecimal string) and set 266 * the global configuration of forwarding cores. 267 */ 268 static void 269 parse_fwd_portmask(const char *portmask) 270 { 271 char *end; 272 unsigned long long int pm; 273 274 /* parse hexadecimal string */ 275 end = NULL; 276 pm = strtoull(portmask, &end, 16); 277 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) 278 rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n"); 279 else 280 set_fwd_ports_mask((uint64_t) pm); 281 } 282 283 static void 284 print_invalid_socket_id_error(void) 285 { 286 unsigned int i = 0; 287 288 fprintf(stderr, "Invalid socket id, options are: "); 289 for (i = 0; i < num_sockets; i++) { 290 fprintf(stderr, "%u%s", socket_ids[i], 291 (i == num_sockets - 1) ? "\n" : ","); 292 } 293 } 294 295 static int 296 parse_portnuma_config(const char *q_arg) 297 { 298 char s[256]; 299 const char *p, *p0 = q_arg; 300 char *end; 301 uint8_t i, socket_id; 302 portid_t port_id; 303 unsigned size; 304 enum fieldnames { 305 FLD_PORT = 0, 306 FLD_SOCKET, 307 _NUM_FLD 308 }; 309 unsigned long int_fld[_NUM_FLD]; 310 char *str_fld[_NUM_FLD]; 311 312 /* reset from value set at definition */ 313 while ((p = strchr(p0,'(')) != NULL) { 314 ++p; 315 if((p0 = strchr(p,')')) == NULL) 316 return -1; 317 318 size = p0 - p; 319 if(size >= sizeof(s)) 320 return -1; 321 322 snprintf(s, sizeof(s), "%.*s", size, p); 323 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 324 return -1; 325 for (i = 0; i < _NUM_FLD; i++) { 326 errno = 0; 327 int_fld[i] = strtoul(str_fld[i], &end, 0); 328 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255) 329 return -1; 330 } 331 port_id = (portid_t)int_fld[FLD_PORT]; 332 if (port_id_is_invalid(port_id, ENABLED_WARN) || 333 port_id == (portid_t)RTE_PORT_ALL) { 334 print_valid_ports(); 335 return -1; 336 } 337 socket_id = (uint8_t)int_fld[FLD_SOCKET]; 338 if (new_socket_id(socket_id)) { 339 if (num_sockets >= RTE_MAX_NUMA_NODES) { 340 print_invalid_socket_id_error(); 341 return -1; 342 } 343 socket_ids[num_sockets++] = socket_id; 344 } 345 port_numa[port_id] = socket_id; 346 } 347 348 return 0; 349 } 350 351 static int 352 parse_ringnuma_config(const char *q_arg) 353 { 354 char s[256]; 355 const char *p, *p0 = q_arg; 356 char *end; 357 uint8_t i, ring_flag, socket_id; 358 portid_t port_id; 359 unsigned size; 360 enum fieldnames { 361 FLD_PORT = 0, 362 FLD_FLAG, 363 FLD_SOCKET, 364 _NUM_FLD 365 }; 366 unsigned long int_fld[_NUM_FLD]; 367 char *str_fld[_NUM_FLD]; 368 #define RX_RING_ONLY 0x1 369 #define TX_RING_ONLY 0x2 370 #define RXTX_RING 0x3 371 372 /* reset from value set at definition */ 373 while ((p = strchr(p0,'(')) != NULL) { 374 ++p; 375 if((p0 = strchr(p,')')) == NULL) 376 return -1; 377 378 size = p0 - p; 379 if(size >= sizeof(s)) 380 return -1; 381 382 snprintf(s, sizeof(s), "%.*s", size, p); 383 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 384 return -1; 385 for (i = 0; i < _NUM_FLD; i++) { 386 errno = 0; 387 int_fld[i] = strtoul(str_fld[i], &end, 0); 388 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255) 389 return -1; 390 } 391 port_id = (portid_t)int_fld[FLD_PORT]; 392 if (port_id_is_invalid(port_id, ENABLED_WARN) || 393 port_id == (portid_t)RTE_PORT_ALL) { 394 print_valid_ports(); 395 return -1; 396 } 397 socket_id = (uint8_t)int_fld[FLD_SOCKET]; 398 if (new_socket_id(socket_id)) { 399 if (num_sockets >= RTE_MAX_NUMA_NODES) { 400 print_invalid_socket_id_error(); 401 return -1; 402 } 403 socket_ids[num_sockets++] = socket_id; 404 } 405 ring_flag = (uint8_t)int_fld[FLD_FLAG]; 406 if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) { 407 fprintf(stderr, 408 "Invalid ring-flag=%d config for port =%d\n", 409 ring_flag,port_id); 410 return -1; 411 } 412 413 switch (ring_flag & RXTX_RING) { 414 case RX_RING_ONLY: 415 rxring_numa[port_id] = socket_id; 416 break; 417 case TX_RING_ONLY: 418 txring_numa[port_id] = socket_id; 419 break; 420 case RXTX_RING: 421 rxring_numa[port_id] = socket_id; 422 txring_numa[port_id] = socket_id; 423 break; 424 default: 425 fprintf(stderr, 426 "Invalid ring-flag=%d config for port=%d\n", 427 ring_flag,port_id); 428 break; 429 } 430 } 431 432 return 0; 433 } 434 435 static int 436 parse_event_printing_config(const char *optarg, int enable) 437 { 438 uint32_t mask = 0; 439 440 if (!strcmp(optarg, "unknown")) 441 mask = UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN; 442 else if (!strcmp(optarg, "intr_lsc")) 443 mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_LSC; 444 else if (!strcmp(optarg, "queue_state")) 445 mask = UINT32_C(1) << RTE_ETH_EVENT_QUEUE_STATE; 446 else if (!strcmp(optarg, "intr_reset")) 447 mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET; 448 else if (!strcmp(optarg, "vf_mbox")) 449 mask = UINT32_C(1) << RTE_ETH_EVENT_VF_MBOX; 450 else if (!strcmp(optarg, "ipsec")) 451 mask = UINT32_C(1) << RTE_ETH_EVENT_IPSEC; 452 else if (!strcmp(optarg, "macsec")) 453 mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC; 454 else if (!strcmp(optarg, "intr_rmv")) 455 mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV; 456 else if (!strcmp(optarg, "dev_probed")) 457 mask = UINT32_C(1) << RTE_ETH_EVENT_NEW; 458 else if (!strcmp(optarg, "dev_released")) 459 mask = UINT32_C(1) << RTE_ETH_EVENT_DESTROY; 460 else if (!strcmp(optarg, "flow_aged")) 461 mask = UINT32_C(1) << RTE_ETH_EVENT_FLOW_AGED; 462 else if (!strcmp(optarg, "all")) 463 mask = ~UINT32_C(0); 464 else { 465 fprintf(stderr, "Invalid event: %s\n", optarg); 466 return -1; 467 } 468 if (enable) 469 event_print_mask |= mask; 470 else 471 event_print_mask &= ~mask; 472 return 0; 473 } 474 475 static int 476 parse_link_speed(int n) 477 { 478 uint32_t speed = ETH_LINK_SPEED_FIXED; 479 480 switch (n) { 481 case 1000: 482 speed |= ETH_LINK_SPEED_1G; 483 break; 484 case 10000: 485 speed |= ETH_LINK_SPEED_10G; 486 break; 487 case 25000: 488 speed |= ETH_LINK_SPEED_25G; 489 break; 490 case 40000: 491 speed |= ETH_LINK_SPEED_40G; 492 break; 493 case 50000: 494 speed |= ETH_LINK_SPEED_50G; 495 break; 496 case 100000: 497 speed |= ETH_LINK_SPEED_100G; 498 break; 499 case 200000: 500 speed |= ETH_LINK_SPEED_200G; 501 break; 502 case 100: 503 case 10: 504 default: 505 fprintf(stderr, "Unsupported fixed speed\n"); 506 return 0; 507 } 508 509 return speed; 510 } 511 512 void 513 launch_args_parse(int argc, char** argv) 514 { 515 int n, opt; 516 char **argvopt; 517 int opt_idx; 518 portid_t pid; 519 enum { TX, RX }; 520 /* Default offloads for all ports. */ 521 uint64_t rx_offloads = rx_mode.offloads; 522 uint64_t tx_offloads = tx_mode.offloads; 523 struct rte_eth_dev_info dev_info; 524 uint16_t rec_nb_pkts; 525 int ret; 526 527 static struct option lgopts[] = { 528 { "help", 0, 0, 0 }, 529 #ifdef RTE_LIB_CMDLINE 530 { "interactive", 0, 0, 0 }, 531 { "cmdline-file", 1, 0, 0 }, 532 { "auto-start", 0, 0, 0 }, 533 { "eth-peers-configfile", 1, 0, 0 }, 534 { "eth-peer", 1, 0, 0 }, 535 #endif 536 { "tx-first", 0, 0, 0 }, 537 { "stats-period", 1, 0, 0 }, 538 { "nb-cores", 1, 0, 0 }, 539 { "nb-ports", 1, 0, 0 }, 540 { "coremask", 1, 0, 0 }, 541 { "portmask", 1, 0, 0 }, 542 { "portlist", 1, 0, 0 }, 543 { "numa", 0, 0, 0 }, 544 { "no-numa", 0, 0, 0 }, 545 { "mp-anon", 0, 0, 0 }, /* deprecated */ 546 { "port-numa-config", 1, 0, 0 }, 547 { "ring-numa-config", 1, 0, 0 }, 548 { "socket-num", 1, 0, 0 }, 549 { "mbuf-size", 1, 0, 0 }, 550 { "total-num-mbufs", 1, 0, 0 }, 551 { "max-pkt-len", 1, 0, 0 }, 552 { "max-lro-pkt-size", 1, 0, 0 }, 553 { "pkt-filter-mode", 1, 0, 0 }, 554 { "pkt-filter-report-hash", 1, 0, 0 }, 555 { "pkt-filter-size", 1, 0, 0 }, 556 { "pkt-filter-drop-queue", 1, 0, 0 }, 557 #ifdef RTE_LIB_LATENCYSTATS 558 { "latencystats", 1, 0, 0 }, 559 #endif 560 #ifdef RTE_LIB_BITRATESTATS 561 { "bitrate-stats", 1, 0, 0 }, 562 #endif 563 { "disable-crc-strip", 0, 0, 0 }, 564 { "enable-lro", 0, 0, 0 }, 565 { "enable-rx-cksum", 0, 0, 0 }, 566 { "enable-rx-timestamp", 0, 0, 0 }, 567 { "enable-scatter", 0, 0, 0 }, 568 { "enable-hw-vlan", 0, 0, 0 }, 569 { "enable-hw-vlan-filter", 0, 0, 0 }, 570 { "enable-hw-vlan-strip", 0, 0, 0 }, 571 { "enable-hw-vlan-extend", 0, 0, 0 }, 572 { "enable-hw-qinq-strip", 0, 0, 0 }, 573 { "enable-drop-en", 0, 0, 0 }, 574 { "disable-rss", 0, 0, 0 }, 575 { "port-topology", 1, 0, 0 }, 576 { "forward-mode", 1, 0, 0 }, 577 { "rss-ip", 0, 0, 0 }, 578 { "rss-udp", 0, 0, 0 }, 579 { "rss-level-outer", 0, 0, 0 }, 580 { "rss-level-inner", 0, 0, 0 }, 581 { "rxq", 1, 0, 0 }, 582 { "txq", 1, 0, 0 }, 583 { "rxd", 1, 0, 0 }, 584 { "txd", 1, 0, 0 }, 585 { "hairpinq", 1, 0, 0 }, 586 { "hairpin-mode", 1, 0, 0 }, 587 { "burst", 1, 0, 0 }, 588 { "flowgen-clones", 1, 0, 0 }, 589 { "mbcache", 1, 0, 0 }, 590 { "txpt", 1, 0, 0 }, 591 { "txht", 1, 0, 0 }, 592 { "txwt", 1, 0, 0 }, 593 { "txfreet", 1, 0, 0 }, 594 { "txrst", 1, 0, 0 }, 595 { "rxpt", 1, 0, 0 }, 596 { "rxht", 1, 0, 0 }, 597 { "rxwt", 1, 0, 0 }, 598 { "rxfreet", 1, 0, 0 }, 599 { "no-flush-rx", 0, 0, 0 }, 600 { "flow-isolate-all", 0, 0, 0 }, 601 { "rxoffs", 1, 0, 0 }, 602 { "rxpkts", 1, 0, 0 }, 603 { "txpkts", 1, 0, 0 }, 604 { "txonly-multi-flow", 0, 0, 0 }, 605 { "eth-link-speed", 1, 0, 0 }, 606 { "disable-link-check", 0, 0, 0 }, 607 { "disable-device-start", 0, 0, 0 }, 608 { "no-lsc-interrupt", 0, 0, 0 }, 609 { "no-rmv-interrupt", 0, 0, 0 }, 610 { "print-event", 1, 0, 0 }, 611 { "mask-event", 1, 0, 0 }, 612 { "tx-offloads", 1, 0, 0 }, 613 { "rx-offloads", 1, 0, 0 }, 614 { "hot-plug", 0, 0, 0 }, 615 { "vxlan-gpe-port", 1, 0, 0 }, 616 { "geneve-parsed-port", 1, 0, 0 }, 617 #ifndef RTE_EXEC_ENV_WINDOWS 618 { "mlockall", 0, 0, 0 }, 619 { "no-mlockall", 0, 0, 0 }, 620 #endif 621 { "mp-alloc", 1, 0, 0 }, 622 { "tx-ip", 1, 0, 0 }, 623 { "tx-udp", 1, 0, 0 }, 624 { "noisy-tx-sw-buffer-size", 1, 0, 0 }, 625 { "noisy-tx-sw-buffer-flushtime", 1, 0, 0 }, 626 { "noisy-lkup-memory", 1, 0, 0 }, 627 { "noisy-lkup-num-writes", 1, 0, 0 }, 628 { "noisy-lkup-num-reads", 1, 0, 0 }, 629 { "noisy-lkup-num-reads-writes", 1, 0, 0 }, 630 { "no-iova-contig", 0, 0, 0 }, 631 { "rx-mq-mode", 1, 0, 0 }, 632 { "record-core-cycles", 0, 0, 0 }, 633 { "record-burst-stats", 0, 0, 0 }, 634 { 0, 0, 0, 0 }, 635 }; 636 637 argvopt = argv; 638 639 #ifdef RTE_LIB_CMDLINE 640 #define SHORTOPTS "i" 641 #else 642 #define SHORTOPTS "" 643 #endif 644 while ((opt = getopt_long(argc, argvopt, SHORTOPTS "ah", 645 lgopts, &opt_idx)) != EOF) { 646 switch (opt) { 647 #ifdef RTE_LIB_CMDLINE 648 case 'i': 649 printf("Interactive-mode selected\n"); 650 interactive = 1; 651 break; 652 #endif 653 case 'a': 654 printf("Auto-start selected\n"); 655 auto_start = 1; 656 break; 657 658 case 0: /*long options */ 659 if (!strcmp(lgopts[opt_idx].name, "help")) { 660 usage(argv[0]); 661 exit(EXIT_SUCCESS); 662 } 663 #ifdef RTE_LIB_CMDLINE 664 if (!strcmp(lgopts[opt_idx].name, "interactive")) { 665 printf("Interactive-mode selected\n"); 666 interactive = 1; 667 } 668 if (!strcmp(lgopts[opt_idx].name, "cmdline-file")) { 669 printf("CLI commands to be read from %s\n", 670 optarg); 671 strlcpy(cmdline_filename, optarg, 672 sizeof(cmdline_filename)); 673 } 674 if (!strcmp(lgopts[opt_idx].name, "auto-start")) { 675 printf("Auto-start selected\n"); 676 auto_start = 1; 677 } 678 if (!strcmp(lgopts[opt_idx].name, "tx-first")) { 679 printf("Ports to start sending a burst of " 680 "packets first\n"); 681 tx_first = 1; 682 } 683 if (!strcmp(lgopts[opt_idx].name, "stats-period")) { 684 char *end = NULL; 685 unsigned int n; 686 687 n = strtoul(optarg, &end, 10); 688 if ((optarg[0] == '\0') || (end == NULL) || 689 (*end != '\0')) 690 break; 691 692 stats_period = n; 693 break; 694 } 695 if (!strcmp(lgopts[opt_idx].name, 696 "eth-peers-configfile")) { 697 if (init_peer_eth_addrs(optarg) != 0) 698 rte_exit(EXIT_FAILURE, 699 "Cannot open logfile\n"); 700 } 701 if (!strcmp(lgopts[opt_idx].name, "eth-peer")) { 702 char *port_end; 703 704 errno = 0; 705 n = strtoul(optarg, &port_end, 10); 706 if (errno != 0 || port_end == optarg || *port_end++ != ',') 707 rte_exit(EXIT_FAILURE, 708 "Invalid eth-peer: %s", optarg); 709 if (n >= RTE_MAX_ETHPORTS) 710 rte_exit(EXIT_FAILURE, 711 "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n", 712 n, RTE_MAX_ETHPORTS); 713 714 if (rte_ether_unformat_addr(port_end, 715 &peer_eth_addrs[n]) < 0) 716 rte_exit(EXIT_FAILURE, 717 "Invalid ethernet address: %s\n", 718 port_end); 719 nb_peer_eth_addrs++; 720 } 721 #endif 722 if (!strcmp(lgopts[opt_idx].name, "tx-ip")) { 723 struct in_addr in; 724 char *end; 725 726 end = strchr(optarg, ','); 727 if (end == optarg || !end) 728 rte_exit(EXIT_FAILURE, 729 "Invalid tx-ip: %s", optarg); 730 731 *end++ = 0; 732 if (inet_pton(AF_INET, optarg, &in) == 0) 733 rte_exit(EXIT_FAILURE, 734 "Invalid source IP address: %s\n", 735 optarg); 736 tx_ip_src_addr = rte_be_to_cpu_32(in.s_addr); 737 738 if (inet_pton(AF_INET, end, &in) == 0) 739 rte_exit(EXIT_FAILURE, 740 "Invalid destination IP address: %s\n", 741 optarg); 742 tx_ip_dst_addr = rte_be_to_cpu_32(in.s_addr); 743 } 744 if (!strcmp(lgopts[opt_idx].name, "tx-udp")) { 745 char *end = NULL; 746 747 errno = 0; 748 n = strtoul(optarg, &end, 10); 749 if (errno != 0 || end == optarg || 750 n > UINT16_MAX || 751 !(*end == '\0' || *end == ',')) 752 rte_exit(EXIT_FAILURE, 753 "Invalid UDP port: %s\n", 754 optarg); 755 tx_udp_src_port = n; 756 if (*end == ',') { 757 char *dst = end + 1; 758 759 n = strtoul(dst, &end, 10); 760 if (errno != 0 || end == dst || 761 n > UINT16_MAX || *end) 762 rte_exit(EXIT_FAILURE, 763 "Invalid destination UDP port: %s\n", 764 dst); 765 tx_udp_dst_port = n; 766 } else { 767 tx_udp_dst_port = n; 768 } 769 770 } 771 if (!strcmp(lgopts[opt_idx].name, "nb-ports")) { 772 n = atoi(optarg); 773 if (n > 0 && n <= nb_ports) 774 nb_fwd_ports = n; 775 else 776 rte_exit(EXIT_FAILURE, 777 "Invalid port %d\n", n); 778 } 779 if (!strcmp(lgopts[opt_idx].name, "nb-cores")) { 780 n = atoi(optarg); 781 if (n > 0 && n <= nb_lcores) 782 nb_fwd_lcores = (uint8_t) n; 783 else 784 rte_exit(EXIT_FAILURE, 785 "nb-cores should be > 0 and <= %d\n", 786 nb_lcores); 787 } 788 if (!strcmp(lgopts[opt_idx].name, "coremask")) 789 parse_fwd_coremask(optarg); 790 if (!strcmp(lgopts[opt_idx].name, "portmask")) 791 parse_fwd_portmask(optarg); 792 if (!strcmp(lgopts[opt_idx].name, "portlist")) 793 parse_fwd_portlist(optarg); 794 if (!strcmp(lgopts[opt_idx].name, "no-numa")) 795 numa_support = 0; 796 if (!strcmp(lgopts[opt_idx].name, "numa")) 797 numa_support = 1; 798 if (!strcmp(lgopts[opt_idx].name, "mp-anon")) { 799 mp_alloc_type = MP_ALLOC_ANON; 800 } 801 if (!strcmp(lgopts[opt_idx].name, "mp-alloc")) { 802 if (!strcmp(optarg, "native")) 803 mp_alloc_type = MP_ALLOC_NATIVE; 804 else if (!strcmp(optarg, "anon")) 805 mp_alloc_type = MP_ALLOC_ANON; 806 else if (!strcmp(optarg, "xmem")) 807 mp_alloc_type = MP_ALLOC_XMEM; 808 else if (!strcmp(optarg, "xmemhuge")) 809 mp_alloc_type = MP_ALLOC_XMEM_HUGE; 810 else if (!strcmp(optarg, "xbuf")) 811 mp_alloc_type = MP_ALLOC_XBUF; 812 else 813 rte_exit(EXIT_FAILURE, 814 "mp-alloc %s invalid - must be: " 815 "native, anon, xmem or xmemhuge\n", 816 optarg); 817 } 818 if (!strcmp(lgopts[opt_idx].name, "port-numa-config")) { 819 if (parse_portnuma_config(optarg)) 820 rte_exit(EXIT_FAILURE, 821 "invalid port-numa configuration\n"); 822 } 823 if (!strcmp(lgopts[opt_idx].name, "ring-numa-config")) 824 if (parse_ringnuma_config(optarg)) 825 rte_exit(EXIT_FAILURE, 826 "invalid ring-numa configuration\n"); 827 if (!strcmp(lgopts[opt_idx].name, "socket-num")) { 828 n = atoi(optarg); 829 if (!new_socket_id((uint8_t)n)) { 830 socket_num = (uint8_t)n; 831 } else { 832 print_invalid_socket_id_error(); 833 rte_exit(EXIT_FAILURE, 834 "Invalid socket id"); 835 } 836 } 837 if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) { 838 unsigned int mb_sz[MAX_SEGS_BUFFER_SPLIT]; 839 unsigned int nb_segs, i; 840 841 nb_segs = parse_item_list(optarg, "mbuf-size", 842 MAX_SEGS_BUFFER_SPLIT, mb_sz, 0); 843 if (nb_segs <= 0) 844 rte_exit(EXIT_FAILURE, 845 "bad mbuf-size\n"); 846 for (i = 0; i < nb_segs; i++) { 847 if (mb_sz[i] <= 0 || mb_sz[i] > 0xFFFF) 848 rte_exit(EXIT_FAILURE, 849 "mbuf-size should be " 850 "> 0 and < 65536\n"); 851 mbuf_data_size[i] = (uint16_t) mb_sz[i]; 852 } 853 mbuf_data_size_n = nb_segs; 854 } 855 if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) { 856 n = atoi(optarg); 857 if (n > 1024) 858 param_total_num_mbufs = (unsigned)n; 859 else 860 rte_exit(EXIT_FAILURE, 861 "total-num-mbufs should be > 1024\n"); 862 } 863 if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) { 864 n = atoi(optarg); 865 if (n >= RTE_ETHER_MIN_LEN) 866 rx_mode.max_rx_pkt_len = (uint32_t) n; 867 else 868 rte_exit(EXIT_FAILURE, 869 "Invalid max-pkt-len=%d - should be > %d\n", 870 n, RTE_ETHER_MIN_LEN); 871 } 872 if (!strcmp(lgopts[opt_idx].name, "max-lro-pkt-size")) { 873 n = atoi(optarg); 874 rx_mode.max_lro_pkt_size = (uint32_t) n; 875 } 876 if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) { 877 if (!strcmp(optarg, "signature")) 878 fdir_conf.mode = 879 RTE_FDIR_MODE_SIGNATURE; 880 else if (!strcmp(optarg, "perfect")) 881 fdir_conf.mode = RTE_FDIR_MODE_PERFECT; 882 else if (!strcmp(optarg, "perfect-mac-vlan")) 883 fdir_conf.mode = RTE_FDIR_MODE_PERFECT_MAC_VLAN; 884 else if (!strcmp(optarg, "perfect-tunnel")) 885 fdir_conf.mode = RTE_FDIR_MODE_PERFECT_TUNNEL; 886 else if (!strcmp(optarg, "none")) 887 fdir_conf.mode = RTE_FDIR_MODE_NONE; 888 else 889 rte_exit(EXIT_FAILURE, 890 "pkt-mode-invalid %s invalid - must be: " 891 "none, signature, perfect, perfect-mac-vlan" 892 " or perfect-tunnel\n", 893 optarg); 894 } 895 if (!strcmp(lgopts[opt_idx].name, 896 "pkt-filter-report-hash")) { 897 if (!strcmp(optarg, "none")) 898 fdir_conf.status = 899 RTE_FDIR_NO_REPORT_STATUS; 900 else if (!strcmp(optarg, "match")) 901 fdir_conf.status = 902 RTE_FDIR_REPORT_STATUS; 903 else if (!strcmp(optarg, "always")) 904 fdir_conf.status = 905 RTE_FDIR_REPORT_STATUS_ALWAYS; 906 else 907 rte_exit(EXIT_FAILURE, 908 "pkt-filter-report-hash %s invalid " 909 "- must be: none or match or always\n", 910 optarg); 911 } 912 if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) { 913 if (!strcmp(optarg, "64K")) 914 fdir_conf.pballoc = 915 RTE_FDIR_PBALLOC_64K; 916 else if (!strcmp(optarg, "128K")) 917 fdir_conf.pballoc = 918 RTE_FDIR_PBALLOC_128K; 919 else if (!strcmp(optarg, "256K")) 920 fdir_conf.pballoc = 921 RTE_FDIR_PBALLOC_256K; 922 else 923 rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -" 924 " must be: 64K or 128K or 256K\n", 925 optarg); 926 } 927 if (!strcmp(lgopts[opt_idx].name, 928 "pkt-filter-drop-queue")) { 929 n = atoi(optarg); 930 if (n >= 0) 931 fdir_conf.drop_queue = (uint8_t) n; 932 else 933 rte_exit(EXIT_FAILURE, 934 "drop queue %d invalid - must" 935 "be >= 0 \n", n); 936 } 937 #ifdef RTE_LIB_LATENCYSTATS 938 if (!strcmp(lgopts[opt_idx].name, 939 "latencystats")) { 940 n = atoi(optarg); 941 if (n >= 0) { 942 latencystats_lcore_id = (lcoreid_t) n; 943 latencystats_enabled = 1; 944 } else 945 rte_exit(EXIT_FAILURE, 946 "invalid lcore id %d for latencystats" 947 " must be >= 0\n", n); 948 } 949 #endif 950 #ifdef RTE_LIB_BITRATESTATS 951 if (!strcmp(lgopts[opt_idx].name, "bitrate-stats")) { 952 n = atoi(optarg); 953 if (n >= 0) { 954 bitrate_lcore_id = (lcoreid_t) n; 955 bitrate_enabled = 1; 956 } else 957 rte_exit(EXIT_FAILURE, 958 "invalid lcore id %d for bitrate stats" 959 " must be >= 0\n", n); 960 } 961 #endif 962 if (!strcmp(lgopts[opt_idx].name, "disable-crc-strip")) 963 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC; 964 if (!strcmp(lgopts[opt_idx].name, "enable-lro")) 965 rx_offloads |= DEV_RX_OFFLOAD_TCP_LRO; 966 if (!strcmp(lgopts[opt_idx].name, "enable-scatter")) 967 rx_offloads |= DEV_RX_OFFLOAD_SCATTER; 968 if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum")) 969 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM; 970 if (!strcmp(lgopts[opt_idx].name, 971 "enable-rx-timestamp")) 972 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP; 973 if (!strcmp(lgopts[opt_idx].name, "enable-hw-vlan")) 974 rx_offloads |= DEV_RX_OFFLOAD_VLAN; 975 976 if (!strcmp(lgopts[opt_idx].name, 977 "enable-hw-vlan-filter")) 978 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; 979 980 if (!strcmp(lgopts[opt_idx].name, 981 "enable-hw-vlan-strip")) 982 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; 983 984 if (!strcmp(lgopts[opt_idx].name, 985 "enable-hw-vlan-extend")) 986 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; 987 988 if (!strcmp(lgopts[opt_idx].name, 989 "enable-hw-qinq-strip")) 990 rx_offloads |= DEV_RX_OFFLOAD_QINQ_STRIP; 991 992 if (!strcmp(lgopts[opt_idx].name, "enable-drop-en")) 993 rx_drop_en = 1; 994 995 if (!strcmp(lgopts[opt_idx].name, "disable-rss")) 996 rss_hf = 0; 997 if (!strcmp(lgopts[opt_idx].name, "port-topology")) { 998 if (!strcmp(optarg, "paired")) 999 port_topology = PORT_TOPOLOGY_PAIRED; 1000 else if (!strcmp(optarg, "chained")) 1001 port_topology = PORT_TOPOLOGY_CHAINED; 1002 else if (!strcmp(optarg, "loop")) 1003 port_topology = PORT_TOPOLOGY_LOOP; 1004 else 1005 rte_exit(EXIT_FAILURE, "port-topology %s invalid -" 1006 " must be: paired, chained or loop\n", 1007 optarg); 1008 } 1009 if (!strcmp(lgopts[opt_idx].name, "forward-mode")) 1010 set_pkt_forwarding_mode(optarg); 1011 if (!strcmp(lgopts[opt_idx].name, "rss-ip")) 1012 rss_hf = ETH_RSS_IP; 1013 if (!strcmp(lgopts[opt_idx].name, "rss-udp")) 1014 rss_hf = ETH_RSS_UDP; 1015 if (!strcmp(lgopts[opt_idx].name, "rss-level-inner")) 1016 rss_hf |= ETH_RSS_LEVEL_INNERMOST; 1017 if (!strcmp(lgopts[opt_idx].name, "rss-level-outer")) 1018 rss_hf |= ETH_RSS_LEVEL_OUTERMOST; 1019 if (!strcmp(lgopts[opt_idx].name, "rxq")) { 1020 n = atoi(optarg); 1021 if (n >= 0 && check_nb_rxq((queueid_t)n) == 0) 1022 nb_rxq = (queueid_t) n; 1023 else 1024 rte_exit(EXIT_FAILURE, "rxq %d invalid - must be" 1025 " >= 0 && <= %u\n", n, 1026 get_allowed_max_nb_rxq(&pid)); 1027 } 1028 if (!strcmp(lgopts[opt_idx].name, "txq")) { 1029 n = atoi(optarg); 1030 if (n >= 0 && check_nb_txq((queueid_t)n) == 0) 1031 nb_txq = (queueid_t) n; 1032 else 1033 rte_exit(EXIT_FAILURE, "txq %d invalid - must be" 1034 " >= 0 && <= %u\n", n, 1035 get_allowed_max_nb_txq(&pid)); 1036 } 1037 if (!strcmp(lgopts[opt_idx].name, "hairpinq")) { 1038 n = atoi(optarg); 1039 if (n >= 0 && 1040 check_nb_hairpinq((queueid_t)n) == 0) 1041 nb_hairpinq = (queueid_t) n; 1042 else 1043 rte_exit(EXIT_FAILURE, "txq %d invalid - must be" 1044 " >= 0 && <= %u\n", n, 1045 get_allowed_max_nb_hairpinq 1046 (&pid)); 1047 if ((n + nb_txq) < 0 || 1048 check_nb_txq((queueid_t)(n + nb_txq)) != 0) 1049 rte_exit(EXIT_FAILURE, "txq + hairpinq " 1050 "%d invalid - must be" 1051 " >= 0 && <= %u\n", 1052 n + nb_txq, 1053 get_allowed_max_nb_txq(&pid)); 1054 if ((n + nb_rxq) < 0 || 1055 check_nb_rxq((queueid_t)(n + nb_rxq)) != 0) 1056 rte_exit(EXIT_FAILURE, "rxq + hairpinq " 1057 "%d invalid - must be" 1058 " >= 0 && <= %u\n", 1059 n + nb_rxq, 1060 get_allowed_max_nb_rxq(&pid)); 1061 } 1062 if (!nb_rxq && !nb_txq) { 1063 rte_exit(EXIT_FAILURE, "Either rx or tx queues should " 1064 "be non-zero\n"); 1065 } 1066 if (!strcmp(lgopts[opt_idx].name, "hairpin-mode")) { 1067 char *end = NULL; 1068 unsigned int n; 1069 1070 errno = 0; 1071 n = strtoul(optarg, &end, 0); 1072 if (errno != 0 || end == optarg) 1073 rte_exit(EXIT_FAILURE, "hairpin mode invalid\n"); 1074 else 1075 hairpin_mode = (uint16_t)n; 1076 } 1077 if (!strcmp(lgopts[opt_idx].name, "burst")) { 1078 n = atoi(optarg); 1079 if (n == 0) { 1080 /* A burst size of zero means that the 1081 * PMD should be queried for 1082 * recommended Rx burst size. Since 1083 * testpmd uses a single size for all 1084 * ports, port 0 is queried for the 1085 * value, on the assumption that all 1086 * ports are of the same NIC model. 1087 */ 1088 ret = eth_dev_info_get_print_err( 1089 0, 1090 &dev_info); 1091 if (ret != 0) 1092 return; 1093 1094 rec_nb_pkts = dev_info 1095 .default_rxportconf.burst_size; 1096 1097 if (rec_nb_pkts == 0) 1098 rte_exit(EXIT_FAILURE, 1099 "PMD does not recommend a burst size. " 1100 "Provided value must be between " 1101 "1 and %d\n", MAX_PKT_BURST); 1102 else if (rec_nb_pkts > MAX_PKT_BURST) 1103 rte_exit(EXIT_FAILURE, 1104 "PMD recommended burst size of %d" 1105 " exceeds maximum value of %d\n", 1106 rec_nb_pkts, MAX_PKT_BURST); 1107 printf("Using PMD-provided burst value of %d\n", 1108 rec_nb_pkts); 1109 nb_pkt_per_burst = rec_nb_pkts; 1110 } else if (n > MAX_PKT_BURST) 1111 rte_exit(EXIT_FAILURE, 1112 "burst must be between1 and %d\n", 1113 MAX_PKT_BURST); 1114 else 1115 nb_pkt_per_burst = (uint16_t) n; 1116 } 1117 if (!strcmp(lgopts[opt_idx].name, "flowgen-clones")) { 1118 n = atoi(optarg); 1119 if (n >= 0) 1120 nb_pkt_flowgen_clones = (uint16_t) n; 1121 else 1122 rte_exit(EXIT_FAILURE, 1123 "clones must be >= 0 and <= current burst\n"); 1124 } 1125 if (!strcmp(lgopts[opt_idx].name, "mbcache")) { 1126 n = atoi(optarg); 1127 if ((n >= 0) && 1128 (n <= RTE_MEMPOOL_CACHE_MAX_SIZE)) 1129 mb_mempool_cache = (uint16_t) n; 1130 else 1131 rte_exit(EXIT_FAILURE, 1132 "mbcache must be >= 0 and <= %d\n", 1133 RTE_MEMPOOL_CACHE_MAX_SIZE); 1134 } 1135 if (!strcmp(lgopts[opt_idx].name, "txfreet")) { 1136 n = atoi(optarg); 1137 if (n >= 0) 1138 tx_free_thresh = (int16_t)n; 1139 else 1140 rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n"); 1141 } 1142 if (!strcmp(lgopts[opt_idx].name, "txrst")) { 1143 n = atoi(optarg); 1144 if (n >= 0) 1145 tx_rs_thresh = (int16_t)n; 1146 else 1147 rte_exit(EXIT_FAILURE, "txrst must be >= 0\n"); 1148 } 1149 if (!strcmp(lgopts[opt_idx].name, "rxd")) { 1150 n = atoi(optarg); 1151 if (n > 0) { 1152 if (rx_free_thresh >= n) 1153 rte_exit(EXIT_FAILURE, 1154 "rxd must be > " 1155 "rx_free_thresh(%d)\n", 1156 (int)rx_free_thresh); 1157 else 1158 nb_rxd = (uint16_t) n; 1159 } else 1160 rte_exit(EXIT_FAILURE, 1161 "rxd(%d) invalid - must be > 0\n", 1162 n); 1163 } 1164 if (!strcmp(lgopts[opt_idx].name, "txd")) { 1165 n = atoi(optarg); 1166 if (n > 0) 1167 nb_txd = (uint16_t) n; 1168 else 1169 rte_exit(EXIT_FAILURE, "txd must be in > 0\n"); 1170 } 1171 if (!strcmp(lgopts[opt_idx].name, "txpt")) { 1172 n = atoi(optarg); 1173 if (n >= 0) 1174 tx_pthresh = (int8_t)n; 1175 else 1176 rte_exit(EXIT_FAILURE, "txpt must be >= 0\n"); 1177 } 1178 if (!strcmp(lgopts[opt_idx].name, "txht")) { 1179 n = atoi(optarg); 1180 if (n >= 0) 1181 tx_hthresh = (int8_t)n; 1182 else 1183 rte_exit(EXIT_FAILURE, "txht must be >= 0\n"); 1184 } 1185 if (!strcmp(lgopts[opt_idx].name, "txwt")) { 1186 n = atoi(optarg); 1187 if (n >= 0) 1188 tx_wthresh = (int8_t)n; 1189 else 1190 rte_exit(EXIT_FAILURE, "txwt must be >= 0\n"); 1191 } 1192 if (!strcmp(lgopts[opt_idx].name, "rxpt")) { 1193 n = atoi(optarg); 1194 if (n >= 0) 1195 rx_pthresh = (int8_t)n; 1196 else 1197 rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n"); 1198 } 1199 if (!strcmp(lgopts[opt_idx].name, "rxht")) { 1200 n = atoi(optarg); 1201 if (n >= 0) 1202 rx_hthresh = (int8_t)n; 1203 else 1204 rte_exit(EXIT_FAILURE, "rxht must be >= 0\n"); 1205 } 1206 if (!strcmp(lgopts[opt_idx].name, "rxwt")) { 1207 n = atoi(optarg); 1208 if (n >= 0) 1209 rx_wthresh = (int8_t)n; 1210 else 1211 rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n"); 1212 } 1213 if (!strcmp(lgopts[opt_idx].name, "rxfreet")) { 1214 n = atoi(optarg); 1215 if (n >= 0) 1216 rx_free_thresh = (int16_t)n; 1217 else 1218 rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n"); 1219 } 1220 if (!strcmp(lgopts[opt_idx].name, "rxoffs")) { 1221 unsigned int seg_off[MAX_SEGS_BUFFER_SPLIT]; 1222 unsigned int nb_offs; 1223 1224 nb_offs = parse_item_list 1225 (optarg, "rxpkt offsets", 1226 MAX_SEGS_BUFFER_SPLIT, 1227 seg_off, 0); 1228 if (nb_offs > 0) 1229 set_rx_pkt_offsets(seg_off, nb_offs); 1230 else 1231 rte_exit(EXIT_FAILURE, "bad rxoffs\n"); 1232 } 1233 if (!strcmp(lgopts[opt_idx].name, "rxpkts")) { 1234 unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT]; 1235 unsigned int nb_segs; 1236 1237 nb_segs = parse_item_list 1238 (optarg, "rxpkt segments", 1239 MAX_SEGS_BUFFER_SPLIT, 1240 seg_len, 0); 1241 if (nb_segs > 0) 1242 set_rx_pkt_segments(seg_len, nb_segs); 1243 else 1244 rte_exit(EXIT_FAILURE, "bad rxpkts\n"); 1245 } 1246 if (!strcmp(lgopts[opt_idx].name, "txpkts")) { 1247 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 1248 unsigned int nb_segs; 1249 1250 nb_segs = parse_item_list(optarg, "txpkt segments", 1251 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 1252 if (nb_segs > 0) 1253 set_tx_pkt_segments(seg_lengths, nb_segs); 1254 else 1255 rte_exit(EXIT_FAILURE, "bad txpkts\n"); 1256 } 1257 if (!strcmp(lgopts[opt_idx].name, "txonly-multi-flow")) 1258 txonly_multi_flow = 1; 1259 if (!strcmp(lgopts[opt_idx].name, "no-flush-rx")) 1260 no_flush_rx = 1; 1261 if (!strcmp(lgopts[opt_idx].name, "eth-link-speed")) { 1262 n = atoi(optarg); 1263 if (n >= 0 && parse_link_speed(n) > 0) 1264 eth_link_speed = parse_link_speed(n); 1265 } 1266 if (!strcmp(lgopts[opt_idx].name, "disable-link-check")) 1267 no_link_check = 1; 1268 if (!strcmp(lgopts[opt_idx].name, "disable-device-start")) 1269 no_device_start = 1; 1270 if (!strcmp(lgopts[opt_idx].name, "no-lsc-interrupt")) 1271 lsc_interrupt = 0; 1272 if (!strcmp(lgopts[opt_idx].name, "no-rmv-interrupt")) 1273 rmv_interrupt = 0; 1274 if (!strcmp(lgopts[opt_idx].name, "flow-isolate-all")) 1275 flow_isolate_all = 1; 1276 if (!strcmp(lgopts[opt_idx].name, "tx-offloads")) { 1277 char *end = NULL; 1278 n = strtoull(optarg, &end, 16); 1279 if (n >= 0) 1280 tx_offloads = (uint64_t)n; 1281 else 1282 rte_exit(EXIT_FAILURE, 1283 "tx-offloads must be >= 0\n"); 1284 } 1285 1286 if (!strcmp(lgopts[opt_idx].name, "rx-offloads")) { 1287 char *end = NULL; 1288 n = strtoull(optarg, &end, 16); 1289 if (n >= 0) 1290 rx_offloads = (uint64_t)n; 1291 else 1292 rte_exit(EXIT_FAILURE, 1293 "rx-offloads must be >= 0\n"); 1294 } 1295 1296 if (!strcmp(lgopts[opt_idx].name, "vxlan-gpe-port")) { 1297 n = atoi(optarg); 1298 if (n >= 0) 1299 vxlan_gpe_udp_port = (uint16_t)n; 1300 else 1301 rte_exit(EXIT_FAILURE, 1302 "vxlan-gpe-port must be >= 0\n"); 1303 } 1304 if (!strcmp(lgopts[opt_idx].name, 1305 "geneve-parsed-port")) { 1306 n = atoi(optarg); 1307 if (n >= 0) 1308 geneve_udp_port = (uint16_t)n; 1309 else 1310 rte_exit(EXIT_FAILURE, 1311 "geneve-parsed-port must be >= 0\n"); 1312 } 1313 if (!strcmp(lgopts[opt_idx].name, "print-event")) 1314 if (parse_event_printing_config(optarg, 1)) { 1315 rte_exit(EXIT_FAILURE, 1316 "invalid print-event argument\n"); 1317 } 1318 if (!strcmp(lgopts[opt_idx].name, "mask-event")) 1319 if (parse_event_printing_config(optarg, 0)) { 1320 rte_exit(EXIT_FAILURE, 1321 "invalid mask-event argument\n"); 1322 } 1323 if (!strcmp(lgopts[opt_idx].name, "hot-plug")) 1324 hot_plug = 1; 1325 if (!strcmp(lgopts[opt_idx].name, "mlockall")) 1326 do_mlockall = 1; 1327 if (!strcmp(lgopts[opt_idx].name, "no-mlockall")) 1328 do_mlockall = 0; 1329 if (!strcmp(lgopts[opt_idx].name, 1330 "noisy-tx-sw-buffer-size")) { 1331 n = atoi(optarg); 1332 if (n >= 0) 1333 noisy_tx_sw_bufsz = n; 1334 else 1335 rte_exit(EXIT_FAILURE, 1336 "noisy-tx-sw-buffer-size must be >= 0\n"); 1337 } 1338 if (!strcmp(lgopts[opt_idx].name, 1339 "noisy-tx-sw-buffer-flushtime")) { 1340 n = atoi(optarg); 1341 if (n >= 0) 1342 noisy_tx_sw_buf_flush_time = n; 1343 else 1344 rte_exit(EXIT_FAILURE, 1345 "noisy-tx-sw-buffer-flushtime must be >= 0\n"); 1346 } 1347 if (!strcmp(lgopts[opt_idx].name, 1348 "noisy-lkup-memory")) { 1349 n = atoi(optarg); 1350 if (n >= 0) 1351 noisy_lkup_mem_sz = n; 1352 else 1353 rte_exit(EXIT_FAILURE, 1354 "noisy-lkup-memory must be >= 0\n"); 1355 } 1356 if (!strcmp(lgopts[opt_idx].name, 1357 "noisy-lkup-num-writes")) { 1358 n = atoi(optarg); 1359 if (n >= 0) 1360 noisy_lkup_num_writes = n; 1361 else 1362 rte_exit(EXIT_FAILURE, 1363 "noisy-lkup-num-writes must be >= 0\n"); 1364 } 1365 if (!strcmp(lgopts[opt_idx].name, 1366 "noisy-lkup-num-reads")) { 1367 n = atoi(optarg); 1368 if (n >= 0) 1369 noisy_lkup_num_reads = n; 1370 else 1371 rte_exit(EXIT_FAILURE, 1372 "noisy-lkup-num-reads must be >= 0\n"); 1373 } 1374 if (!strcmp(lgopts[opt_idx].name, 1375 "noisy-lkup-num-reads-writes")) { 1376 n = atoi(optarg); 1377 if (n >= 0) 1378 noisy_lkup_num_reads_writes = n; 1379 else 1380 rte_exit(EXIT_FAILURE, 1381 "noisy-lkup-num-reads-writes must be >= 0\n"); 1382 } 1383 if (!strcmp(lgopts[opt_idx].name, "no-iova-contig")) 1384 mempool_flags = MEMPOOL_F_NO_IOVA_CONTIG; 1385 1386 if (!strcmp(lgopts[opt_idx].name, "rx-mq-mode")) { 1387 char *end = NULL; 1388 n = strtoul(optarg, &end, 16); 1389 if (n >= 0 && n <= ETH_MQ_RX_VMDQ_DCB_RSS) 1390 rx_mq_mode = (enum rte_eth_rx_mq_mode)n; 1391 else 1392 rte_exit(EXIT_FAILURE, 1393 "rx-mq-mode must be >= 0 and <= %d\n", 1394 ETH_MQ_RX_VMDQ_DCB_RSS); 1395 } 1396 if (!strcmp(lgopts[opt_idx].name, "record-core-cycles")) 1397 record_core_cycles = 1; 1398 if (!strcmp(lgopts[opt_idx].name, "record-burst-stats")) 1399 record_burst_stats = 1; 1400 break; 1401 case 'h': 1402 usage(argv[0]); 1403 exit(EXIT_SUCCESS); 1404 break; 1405 default: 1406 usage(argv[0]); 1407 fprintf(stderr, "Invalid option: %s\n", argv[optind]); 1408 rte_exit(EXIT_FAILURE, 1409 "Command line is incomplete or incorrect\n"); 1410 break; 1411 } 1412 } 1413 1414 if (optind != argc) { 1415 usage(argv[0]); 1416 fprintf(stderr, "Invalid parameter: %s\n", argv[optind]); 1417 rte_exit(EXIT_FAILURE, "Command line is incorrect\n"); 1418 } 1419 1420 /* Set offload configuration from command line parameters. */ 1421 rx_mode.offloads = rx_offloads; 1422 tx_mode.offloads = tx_offloads; 1423 1424 if (mempool_flags & MEMPOOL_F_NO_IOVA_CONTIG && 1425 mp_alloc_type != MP_ALLOC_ANON) { 1426 TESTPMD_LOG(WARNING, "cannot use no-iova-contig without " 1427 "mp-alloc=anon. mempool no-iova-contig is " 1428 "ignored\n"); 1429 mempool_flags = 0; 1430 } 1431 } 1432