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