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