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