1 /*- 2 * BSD LICENSE 3 * 4 * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * * Neither the name of Intel Corporation nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * 33 */ 34 35 #include <errno.h> 36 #include <getopt.h> 37 #include <stdarg.h> 38 #include <stdio.h> 39 #include <stdlib.h> 40 #include <signal.h> 41 #include <string.h> 42 #include <time.h> 43 #include <fcntl.h> 44 #include <sys/types.h> 45 #include <errno.h> 46 47 #include <sys/queue.h> 48 #include <sys/stat.h> 49 50 #include <stdint.h> 51 #include <unistd.h> 52 #include <inttypes.h> 53 54 #include <rte_common.h> 55 #include <rte_byteorder.h> 56 #include <rte_log.h> 57 #include <rte_debug.h> 58 #include <rte_cycles.h> 59 #include <rte_memory.h> 60 #include <rte_memzone.h> 61 #include <rte_launch.h> 62 #include <rte_tailq.h> 63 #include <rte_eal.h> 64 #include <rte_per_lcore.h> 65 #include <rte_lcore.h> 66 #include <rte_atomic.h> 67 #include <rte_branch_prediction.h> 68 #include <rte_ring.h> 69 #include <rte_mempool.h> 70 #include <rte_interrupts.h> 71 #include <rte_pci.h> 72 #include <rte_ether.h> 73 #include <rte_ethdev.h> 74 #include <rte_string_fns.h> 75 #include <cmdline_parse.h> 76 #include <cmdline_parse_etheraddr.h> 77 78 #include "testpmd.h" 79 80 static void 81 usage(char* progname) 82 { 83 printf("usage: %s [--interactive|-i] [--help|-h] | [" 84 "--coremask=COREMASK --portmask=PORTMASK --numa " 85 "--mbuf-size= | --total-num-mbufs= | " 86 "--eth-peers-configfile= | " 87 "--eth-peer=X,M:M:M:M:M:M | --nb-cores= | --nb-ports= | " 88 "--pkt-filter-mode= |" 89 "--rss-ip | --rss-udp | " 90 "--rxpt= | --rxht= | --rxwt= | --rxfreet= | " 91 "--txpt= | --txht= | --txwt= | --txfreet= | " 92 "--txrst= | --txqflags= ]\n", 93 progname); 94 printf(" --interactive: run in interactive mode\n"); 95 printf(" --help: display this message and quit\n"); 96 printf(" --eth-peers-configfile=name of file with ethernet addresses " 97 "of peer ports\n"); 98 printf(" --eth-peer=X,M:M:M:M:M:M set the mac address of the X peer " 99 "port (0 <= X < %d)\n", RTE_MAX_ETHPORTS); 100 printf(" --nb-cores=N set the number of forwarding cores" 101 " (1 <= N <= %d)\n", nb_lcores); 102 printf(" --nb-ports=N set the number of forwarding ports" 103 " (1 <= N <= %d)\n", nb_ports); 104 printf(" --coremask=COREMASK: hexadecimal bitmask of cores running " 105 "the packet forwarding test. The master lcore is reserved for " 106 "command line parsing only, and can not be masked on for running" 107 "the packet forwarding\n"); 108 printf(" --portmask=PORTMASK: hexadecimal bitmask of ports used " 109 "by the packet forwarding test\n"); 110 printf(" --numa: enable NUMA-aware allocation of RX/TX rings and of " 111 " RX memory buffers (mbufs)\n"); 112 printf(" --mbuf-size=N set the data size of mbuf to N bytes\n"); 113 printf(" --total-num-mbufs=N set the number of mbufs to be allocated " 114 "in mbuf pools\n"); 115 printf(" --max-pkt-len=N set the maximum size of packet to N bytes\n"); 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-flexbytes-offset=N: set flexbytes-offset." 123 " The offset is defined in word units counted from the" 124 " first byte of the destination Ethernet MAC address." 125 " 0 <= N <= 32\n"); 126 printf(" --pkt-filter-drop-queue=N: set drop-queue." 127 " In perfect mode, when you add a rule with queue -1" 128 " the packet will be enqueued into the rx drop-queue." 129 " If the drop-queue doesn't exist, the packet is dropped." 130 " By default drop-queue=127\n"); 131 printf(" --crc-strip: enable CRC stripping by hardware\n"); 132 printf(" --enable-rx-cksum: enable rx hardware checksum offload\n"); 133 printf(" --disable-hw-vlan: disable hardware vlan\n"); 134 printf(" --enable-drop-en: enable per queue packet drop\n"); 135 printf(" --disable-rss: disable rss\n"); 136 printf(" --port-topology=N: set port topology (N: paired (default) or " 137 "chained)\n"); 138 printf(" --rss-ip: set RSS functions to IPv4/IPv6 only \n"); 139 printf(" --rss-udp: set RSS functions to IPv4/IPv6 + UDP\n"); 140 printf(" --rxq=N set the number of RX queues per port to N\n"); 141 printf(" --rxd=N set the number of descriptors in RX rings to N\n"); 142 printf(" --txq=N set the number of TX queues per port to N\n"); 143 printf(" --txd=N set the number of descriptors in TX rings to N\n"); 144 printf(" --burst=N set the number of packets per burst to N\n"); 145 printf(" --mbcache=N set the cache of mbuf memory pool to N\n"); 146 printf(" --rxpt=N set prefetch threshold register of RX rings to N" 147 " (0 <= N <= 16)\n"); 148 printf(" --rxht=N set the host threshold register of RX rings to N" 149 " (0 <= N <= 16)\n"); 150 printf(" --rxfreet=N set the free threshold of RX descriptors to N" 151 " (0 <= N < value of rxd)\n"); 152 printf(" --rxwt=N set the write-back threshold register of RX rings" 153 " to N (0 <= N <= 16)\n"); 154 printf(" --txpt=N set the prefetch threshold register of TX rings" 155 " to N (0 <= N <= 16)\n"); 156 printf(" --txht=N set the nhost threshold register of TX rings to N" 157 " (0 <= N <= 16)\n"); 158 printf(" --txwt=N set the write-back threshold register of TX rings" 159 " to N (0 <= N <= 16)\n"); 160 printf(" --txfreet=N set the transmit free threshold of TX rings to N" 161 " (0 <= N <= value of txd)\n"); 162 printf(" --txrst=N set the transmit RS bit threshold of TX rings to N" 163 " (0 <= N <= value of txd)\n"); 164 printf(" --txqflags=0xXXXXXXXX hexidecimal bitmask of TX queue flags" 165 " (0 <= N <= 0x7FFFFFFF)\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 } 173 174 static int 175 init_peer_eth_addrs(char *config_filename) 176 { 177 FILE *config_file; 178 portid_t i; 179 char buf[50]; 180 181 config_file = fopen(config_filename, "r"); 182 if (config_file == NULL) { 183 perror("open log file failed\n"); 184 return -1; 185 } 186 187 for (i = 0; i < RTE_MAX_ETHPORTS; i++) { 188 189 if (fgets(buf, sizeof(buf), config_file) == NULL) 190 break; 191 192 if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i]) < 0 ){ 193 printf("bad format of mac address on line %d\n", i); 194 fclose(config_file); 195 return -1; 196 } 197 } 198 fclose(config_file); 199 nb_peer_eth_addrs = (portid_t) i; 200 return 0; 201 } 202 203 /* 204 * Parse the coremask given as argument (hexadecimal string) and set 205 * the global configuration of forwarding cores. 206 */ 207 static void 208 parse_fwd_coremask(const char *coremask) 209 { 210 char *end; 211 unsigned long long int cm; 212 213 /* parse hexadecimal string */ 214 end = NULL; 215 cm = strtoull(coremask, &end, 16); 216 if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0')) 217 rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n"); 218 else if (set_fwd_lcores_mask((uint64_t) cm) < 0) 219 rte_exit(EXIT_FAILURE, "coremask is not valid\n"); 220 } 221 222 /* 223 * Parse the coremask given as argument (hexadecimal string) and set 224 * the global configuration of forwarding cores. 225 */ 226 static void 227 parse_fwd_portmask(const char *portmask) 228 { 229 char *end; 230 unsigned long long int pm; 231 232 /* parse hexadecimal string */ 233 end = NULL; 234 pm = strtoull(portmask, &end, 16); 235 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) 236 rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n"); 237 else 238 set_fwd_ports_mask((uint64_t) pm); 239 } 240 241 242 static int 243 parse_queue_stats_mapping_config(const char *q_arg, int is_rx) 244 { 245 char s[256]; 246 const char *p, *p0 = q_arg; 247 char *end; 248 enum fieldnames { 249 FLD_PORT = 0, 250 FLD_QUEUE, 251 FLD_STATS_COUNTER, 252 _NUM_FLD 253 }; 254 unsigned long int_fld[_NUM_FLD]; 255 char *str_fld[_NUM_FLD]; 256 int i; 257 unsigned size; 258 259 /* reset from value set at definition */ 260 is_rx ? (nb_rx_queue_stats_mappings = 0) : (nb_tx_queue_stats_mappings = 0); 261 262 while ((p = strchr(p0,'(')) != NULL) { 263 ++p; 264 if((p0 = strchr(p,')')) == NULL) 265 return -1; 266 267 size = p0 - p; 268 if(size >= sizeof(s)) 269 return -1; 270 271 rte_snprintf(s, sizeof(s), "%.*s", size, p); 272 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 273 return -1; 274 for (i = 0; i < _NUM_FLD; i++){ 275 errno = 0; 276 int_fld[i] = strtoul(str_fld[i], &end, 0); 277 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255) 278 return -1; 279 } 280 /* Check mapping field is in correct range (0..RTE_ETHDEV_QUEUE_STAT_CNTRS-1) */ 281 if (int_fld[FLD_STATS_COUNTER] >= RTE_ETHDEV_QUEUE_STAT_CNTRS) { 282 printf("Stats counter not in the correct range 0..%d\n", 283 RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); 284 return -1; 285 } 286 287 if (is_rx ? (nb_rx_queue_stats_mappings >= MAX_RX_QUEUE_STATS_MAPPINGS) : 288 (nb_tx_queue_stats_mappings >= MAX_TX_QUEUE_STATS_MAPPINGS)) { 289 printf("exceeded max number of %s queue statistics mappings: %hu\n", 290 is_rx ? "RX" : "TX", 291 is_rx ? nb_rx_queue_stats_mappings : nb_tx_queue_stats_mappings); 292 return -1; 293 } 294 if (!is_rx) { 295 tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id = 296 (uint8_t)int_fld[FLD_PORT]; 297 tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id = 298 (uint8_t)int_fld[FLD_QUEUE]; 299 tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].stats_counter_id = 300 (uint8_t)int_fld[FLD_STATS_COUNTER]; 301 ++nb_tx_queue_stats_mappings; 302 } 303 else { 304 rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id = 305 (uint8_t)int_fld[FLD_PORT]; 306 rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id = 307 (uint8_t)int_fld[FLD_QUEUE]; 308 rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].stats_counter_id = 309 (uint8_t)int_fld[FLD_STATS_COUNTER]; 310 ++nb_rx_queue_stats_mappings; 311 } 312 313 } 314 /* Reassign the rx/tx_queue_stats_mappings pointer to point to this newly populated array rather */ 315 /* than to the default array (that was set at its definition) */ 316 is_rx ? (rx_queue_stats_mappings = rx_queue_stats_mappings_array) : 317 (tx_queue_stats_mappings = tx_queue_stats_mappings_array); 318 return 0; 319 } 320 321 322 void 323 launch_args_parse(int argc, char** argv) 324 { 325 int n, opt; 326 char **argvopt; 327 int opt_idx; 328 enum { TX, RX }; 329 330 static struct option lgopts[] = { 331 { "help", 0, 0, 0 }, 332 { "interactive", 0, 0, 0 }, 333 { "eth-peers-configfile", 1, 0, 0 }, 334 { "eth-peer", 1, 0, 0 }, 335 { "ports", 1, 0, 0 }, 336 { "nb-cores", 1, 0, 0 }, 337 { "nb-ports", 1, 0, 0 }, 338 { "coremask", 1, 0, 0 }, 339 { "portmask", 1, 0, 0 }, 340 { "numa", 0, 0, 0 }, 341 { "mbuf-size", 1, 0, 0 }, 342 { "total-num-mbufs", 1, 0, 0 }, 343 { "max-pkt-len", 1, 0, 0 }, 344 { "pkt-filter-mode", 1, 0, 0 }, 345 { "pkt-filter-report-hash", 1, 0, 0 }, 346 { "pkt-filter-size", 1, 0, 0 }, 347 { "pkt-filter-flexbytes-offset",1, 0, 0 }, 348 { "pkt-filter-drop-queue", 1, 0, 0 }, 349 { "crc-strip", 0, 0, 0 }, 350 { "enable-rx-cksum", 0, 0, 0 }, 351 { "disable-hw-vlan", 0, 0, 0 }, 352 { "enable-drop-en", 0, 0, 0 }, 353 { "disable-rss", 0, 0, 0 }, 354 { "port-topology", 1, 0, 0 }, 355 { "rss-ip", 0, 0, 0 }, 356 { "rss-udp", 0, 0, 0 }, 357 { "rxq", 1, 0, 0 }, 358 { "txq", 1, 0, 0 }, 359 { "rxd", 1, 0, 0 }, 360 { "txd", 1, 0, 0 }, 361 { "burst", 1, 0, 0 }, 362 { "mbcache", 1, 0, 0 }, 363 { "txpt", 1, 0, 0 }, 364 { "txht", 1, 0, 0 }, 365 { "txwt", 1, 0, 0 }, 366 { "txfreet", 1, 0, 0 }, 367 { "txrst", 1, 0, 0 }, 368 { "txqflags", 1, 0, 0 }, 369 { "rxpt", 1, 0, 0 }, 370 { "rxht", 1, 0, 0 }, 371 { "rxwt", 1, 0, 0 }, 372 { "rxfreet", 1, 0, 0 }, 373 { "tx-queue-stats-mapping", 1, 0, 0 }, 374 { "rx-queue-stats-mapping", 1, 0, 0 }, 375 { 0, 0, 0, 0 }, 376 }; 377 378 argvopt = argv; 379 380 while ((opt = getopt_long(argc, argvopt, "ih", 381 lgopts, &opt_idx)) != EOF) { 382 switch (opt) { 383 case 'i': 384 printf("Interactive-mode selected\n"); 385 interactive = 1; 386 break; 387 case 0: /*long options */ 388 if (!strcmp(lgopts[opt_idx].name, "help")) { 389 usage(argv[0]); 390 rte_exit(EXIT_SUCCESS, "Displayed help\n"); 391 } 392 if (!strcmp(lgopts[opt_idx].name, "interactive")) { 393 printf("Interactive-mode selected\n"); 394 interactive = 1; 395 } 396 if (!strcmp(lgopts[opt_idx].name, 397 "eth-peers-configfile")) { 398 if (init_peer_eth_addrs(optarg) != 0) 399 rte_exit(EXIT_FAILURE, 400 "Cannot open logfile\n"); 401 } 402 if (!strcmp(lgopts[opt_idx].name, "eth-peer")) { 403 char *port_end; 404 uint8_t c, peer_addr[6]; 405 406 errno = 0; 407 n = strtoul(optarg, &port_end, 10); 408 if (errno != 0 || port_end == optarg || *port_end++ != ',') 409 rte_exit(EXIT_FAILURE, 410 "Invalid eth-peer: %s", optarg); 411 if (n >= RTE_MAX_ETHPORTS) 412 rte_exit(EXIT_FAILURE, 413 "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n", 414 n, RTE_MAX_ETHPORTS); 415 416 if (cmdline_parse_etheraddr(NULL, port_end, &peer_addr) < 0 ) 417 rte_exit(EXIT_FAILURE, 418 "Invalid ethernet address: %s\n", 419 port_end); 420 for (c = 0; c < 6; c++) 421 peer_eth_addrs[n].addr_bytes[c] = 422 peer_addr[c]; 423 nb_peer_eth_addrs++; 424 } 425 if (!strcmp(lgopts[opt_idx].name, "nb-ports")) { 426 n = atoi(optarg); 427 if (n > 0 && n <= nb_ports) 428 nb_fwd_ports = (uint8_t) n; 429 else 430 rte_exit(EXIT_FAILURE, 431 "nb-ports should be > 0 and <= %d\n", 432 nb_ports); 433 } 434 if (!strcmp(lgopts[opt_idx].name, "nb-cores")) { 435 n = atoi(optarg); 436 if (n > 0 && n <= nb_lcores) 437 nb_fwd_lcores = (uint8_t) n; 438 else 439 rte_exit(EXIT_FAILURE, 440 "nb-cores should be > 0 and <= %d\n", 441 nb_lcores); 442 } 443 if (!strcmp(lgopts[opt_idx].name, "coremask")) 444 parse_fwd_coremask(optarg); 445 if (!strcmp(lgopts[opt_idx].name, "portmask")) 446 parse_fwd_portmask(optarg); 447 if (!strcmp(lgopts[opt_idx].name, "numa")) 448 numa_support = 1; 449 if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) { 450 n = atoi(optarg); 451 if (n > 0 && n <= 0xFFFF) 452 mbuf_data_size = (uint16_t) n; 453 else 454 rte_exit(EXIT_FAILURE, 455 "mbuf-size should be > 0 and < 65536\n"); 456 } 457 if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) { 458 n = atoi(optarg); 459 if (n > 1024) 460 param_total_num_mbufs = (unsigned)n; 461 else 462 rte_exit(EXIT_FAILURE, 463 "total-num-mbufs should be > 1024\n"); 464 } 465 if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) { 466 n = atoi(optarg); 467 if (n >= ETHER_MIN_LEN) { 468 rx_mode.max_rx_pkt_len = (uint32_t) n; 469 if (n > ETHER_MAX_LEN) 470 rx_mode.jumbo_frame = 1; 471 } else 472 rte_exit(EXIT_FAILURE, 473 "Invalid max-pkt-len=%d - should be > %d\n", 474 n, ETHER_MIN_LEN); 475 } 476 if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) { 477 if (!strcmp(optarg, "signature")) 478 fdir_conf.mode = 479 RTE_FDIR_MODE_SIGNATURE; 480 else if (!strcmp(optarg, "perfect")) 481 fdir_conf.mode = RTE_FDIR_MODE_PERFECT; 482 else if (!strcmp(optarg, "none")) 483 fdir_conf.mode = RTE_FDIR_MODE_NONE; 484 else 485 rte_exit(EXIT_FAILURE, 486 "pkt-mode-invalid %s invalid - must be: " 487 "none, signature or perfect\n", 488 optarg); 489 } 490 if (!strcmp(lgopts[opt_idx].name, 491 "pkt-filter-report-hash")) { 492 if (!strcmp(optarg, "none")) 493 fdir_conf.status = 494 RTE_FDIR_NO_REPORT_STATUS; 495 else if (!strcmp(optarg, "match")) 496 fdir_conf.status = 497 RTE_FDIR_REPORT_STATUS; 498 else if (!strcmp(optarg, "always")) 499 fdir_conf.status = 500 RTE_FDIR_REPORT_STATUS_ALWAYS; 501 else 502 rte_exit(EXIT_FAILURE, 503 "pkt-filter-report-hash %s invalid " 504 "- must be: none or match or always\n", 505 optarg); 506 } 507 if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) { 508 if (!strcmp(optarg, "64K")) 509 fdir_conf.pballoc = 510 RTE_FDIR_PBALLOC_64K; 511 else if (!strcmp(optarg, "128K")) 512 fdir_conf.pballoc = 513 RTE_FDIR_PBALLOC_128K; 514 else if (!strcmp(optarg, "256K")) 515 fdir_conf.pballoc = 516 RTE_FDIR_PBALLOC_256K; 517 else 518 rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -" 519 " must be: 64K or 128K or 256K\n", 520 optarg); 521 } 522 if (!strcmp(lgopts[opt_idx].name, 523 "pkt-filter-flexbytes-offset")) { 524 n = atoi(optarg); 525 if ( n >= 0 && n <= (int) 32) 526 fdir_conf.flexbytes_offset = 527 (uint8_t) n; 528 else 529 rte_exit(EXIT_FAILURE, 530 "flexbytes %d invalid - must" 531 "be >= 0 && <= 32\n", n); 532 } 533 if (!strcmp(lgopts[opt_idx].name, 534 "pkt-filter-drop-queue")) { 535 n = atoi(optarg); 536 if (n >= 0) 537 fdir_conf.drop_queue = (uint8_t) n; 538 else 539 rte_exit(EXIT_FAILURE, 540 "drop queue %d invalid - must" 541 "be >= 0 \n", n); 542 } 543 if (!strcmp(lgopts[opt_idx].name, "crc-strip")) 544 rx_mode.hw_strip_crc = 1; 545 if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum")) 546 rx_mode.hw_ip_checksum = 1; 547 548 if (!strcmp(lgopts[opt_idx].name, "disable-hw-vlan")) { 549 rx_mode.hw_vlan_filter = 0; 550 rx_mode.hw_vlan_strip = 0; 551 rx_mode.hw_vlan_extend = 0; 552 } 553 554 if (!strcmp(lgopts[opt_idx].name, "enable-drop-en")) 555 rx_drop_en = 1; 556 557 if (!strcmp(lgopts[opt_idx].name, "disable-rss")) 558 rss_hf = 0; 559 if (!strcmp(lgopts[opt_idx].name, "port-topology")) { 560 if (!strcmp(optarg, "paired")) 561 port_topology = PORT_TOPOLOGY_PAIRED; 562 else if (!strcmp(optarg, "chained")) 563 port_topology = PORT_TOPOLOGY_CHAINED; 564 else 565 rte_exit(EXIT_FAILURE, "port-topology %s invalid -" 566 " must be: paired or chained \n", 567 optarg); 568 } 569 if (!strcmp(lgopts[opt_idx].name, "rss-ip")) 570 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6; 571 if (!strcmp(lgopts[opt_idx].name, "rss-udp")) 572 rss_hf = ETH_RSS_IPV4 | 573 ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP; 574 if (!strcmp(lgopts[opt_idx].name, "rxq")) { 575 n = atoi(optarg); 576 if (n >= 1 && n <= (int) MAX_QUEUE_ID) 577 nb_rxq = (queueid_t) n; 578 else 579 rte_exit(EXIT_FAILURE, "rxq %d invalid - must be" 580 " >= 1 && <= %d\n", n, 581 (int) MAX_QUEUE_ID); 582 } 583 if (!strcmp(lgopts[opt_idx].name, "txq")) { 584 n = atoi(optarg); 585 if (n >= 1 && n <= (int) MAX_QUEUE_ID) 586 nb_txq = (queueid_t) n; 587 else 588 rte_exit(EXIT_FAILURE, "txq %d invalid - must be" 589 " >= 1 && <= %d\n", n, 590 (int) MAX_QUEUE_ID); 591 } 592 if (!strcmp(lgopts[opt_idx].name, "rxd")) { 593 n = atoi(optarg); 594 if (n > 0) 595 nb_rxd = (uint16_t) n; 596 else 597 rte_exit(EXIT_FAILURE, "rxd must be > 0\n"); 598 } 599 if (!strcmp(lgopts[opt_idx].name, "txd")) { 600 n = atoi(optarg); 601 if (n > 0) 602 nb_txd = (uint16_t) n; 603 else 604 rte_exit(EXIT_FAILURE, "txd must be in > 0\n"); 605 } 606 if (!strcmp(lgopts[opt_idx].name, "burst")) { 607 n = atoi(optarg); 608 if ((n >= 1) && (n <= MAX_PKT_BURST)) 609 nb_pkt_per_burst = (uint16_t) n; 610 else 611 rte_exit(EXIT_FAILURE, 612 "burst must >= 1 and <= %d]", 613 MAX_PKT_BURST); 614 } 615 if (!strcmp(lgopts[opt_idx].name, "mbcache")) { 616 n = atoi(optarg); 617 if ((n >= 0) && 618 (n <= RTE_MEMPOOL_CACHE_MAX_SIZE)) 619 mb_mempool_cache = (uint16_t) n; 620 else 621 rte_exit(EXIT_FAILURE, 622 "mbcache must be >= 0 and <= %d\n", 623 RTE_MEMPOOL_CACHE_MAX_SIZE); 624 } 625 if (!strcmp(lgopts[opt_idx].name, "txpt")) { 626 n = atoi(optarg); 627 if (n >= 0) 628 tx_thresh.pthresh = (uint8_t)n; 629 else 630 rte_exit(EXIT_FAILURE, "txpt must be >= 0\n"); 631 } 632 if (!strcmp(lgopts[opt_idx].name, "txht")) { 633 n = atoi(optarg); 634 if (n >= 0) 635 tx_thresh.hthresh = (uint8_t)n; 636 else 637 rte_exit(EXIT_FAILURE, "txht must be >= 0\n"); 638 } 639 if (!strcmp(lgopts[opt_idx].name, "txwt")) { 640 n = atoi(optarg); 641 if (n >= 0) 642 tx_thresh.wthresh = (uint8_t)n; 643 else 644 rte_exit(EXIT_FAILURE, "txwt must be >= 0\n"); 645 } 646 if (!strcmp(lgopts[opt_idx].name, "txfreet")) { 647 n = atoi(optarg); 648 if (n >= 0) 649 tx_free_thresh = (uint16_t)n; 650 else 651 rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n"); 652 } 653 if (!strcmp(lgopts[opt_idx].name, "txrst")) { 654 n = atoi(optarg); 655 if (n >= 0) 656 tx_rs_thresh = (uint16_t)n; 657 else 658 rte_exit(EXIT_FAILURE, "txrst must be >= 0\n"); 659 } 660 if (!strcmp(lgopts[opt_idx].name, "txqflags")) { 661 char *end = NULL; 662 n = strtoul(optarg, &end, 16); 663 if (n >= 0) 664 txq_flags = (uint32_t)n; 665 else 666 rte_exit(EXIT_FAILURE, 667 "txqflags must be >= 0\n"); 668 } 669 if (!strcmp(lgopts[opt_idx].name, "rxpt")) { 670 n = atoi(optarg); 671 if (n >= 0) 672 rx_thresh.pthresh = (uint8_t)n; 673 else 674 rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n"); 675 } 676 if (!strcmp(lgopts[opt_idx].name, "rxht")) { 677 n = atoi(optarg); 678 if (n >= 0) 679 rx_thresh.hthresh = (uint8_t)n; 680 else 681 rte_exit(EXIT_FAILURE, "rxht must be >= 0\n"); 682 } 683 if (!strcmp(lgopts[opt_idx].name, "rxwt")) { 684 n = atoi(optarg); 685 if (n >= 0) 686 rx_thresh.wthresh = (uint8_t)n; 687 else 688 rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n"); 689 } 690 if (!strcmp(lgopts[opt_idx].name, "rxd")) { 691 n = atoi(optarg); 692 if (n > 0) { 693 if (rx_free_thresh >= n) 694 rte_exit(EXIT_FAILURE, 695 "rxd must be > " 696 "rx_free_thresh(%d)\n", 697 (int)rx_free_thresh); 698 else 699 nb_rxd = (uint16_t) n; 700 } else 701 rte_exit(EXIT_FAILURE, 702 "rxd(%d) invalid - must be > 0\n", 703 n); 704 } 705 if (!strcmp(lgopts[opt_idx].name, "txd")) { 706 n = atoi(optarg); 707 if (n > 0) 708 nb_txd = (uint16_t) n; 709 else 710 rte_exit(EXIT_FAILURE, "txd must be in > 0\n"); 711 } 712 if (!strcmp(lgopts[opt_idx].name, "txpt")) { 713 n = atoi(optarg); 714 if (n >= 0) 715 tx_thresh.pthresh = (uint8_t)n; 716 else 717 rte_exit(EXIT_FAILURE, "txpt must be >= 0\n"); 718 } 719 if (!strcmp(lgopts[opt_idx].name, "txht")) { 720 n = atoi(optarg); 721 if (n >= 0) 722 tx_thresh.hthresh = (uint8_t)n; 723 else 724 rte_exit(EXIT_FAILURE, "txht must be >= 0\n"); 725 } 726 if (!strcmp(lgopts[opt_idx].name, "txwt")) { 727 n = atoi(optarg); 728 if (n >= 0) 729 tx_thresh.wthresh = (uint8_t)n; 730 else 731 rte_exit(EXIT_FAILURE, "txwt must be >= 0\n"); 732 } 733 if (!strcmp(lgopts[opt_idx].name, "rxpt")) { 734 n = atoi(optarg); 735 if (n >= 0) 736 rx_thresh.pthresh = (uint8_t)n; 737 else 738 rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n"); 739 } 740 if (!strcmp(lgopts[opt_idx].name, "rxht")) { 741 n = atoi(optarg); 742 if (n >= 0) 743 rx_thresh.hthresh = (uint8_t)n; 744 else 745 rte_exit(EXIT_FAILURE, "rxht must be >= 0\n"); 746 } 747 if (!strcmp(lgopts[opt_idx].name, "rxwt")) { 748 n = atoi(optarg); 749 if (n >= 0) 750 rx_thresh.wthresh = (uint8_t)n; 751 else 752 rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n"); 753 } 754 if (!strcmp(lgopts[opt_idx].name, "rxfreet")) { 755 n = atoi(optarg); 756 if (n >= 0) 757 rx_free_thresh = (uint16_t)n; 758 else 759 rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n"); 760 } 761 if (!strcmp(lgopts[opt_idx].name, "tx-queue-stats-mapping")) { 762 if (parse_queue_stats_mapping_config(optarg, TX)) { 763 rte_exit(EXIT_FAILURE, 764 "invalid TX queue statistics mapping config entered\n"); 765 } 766 } 767 if (!strcmp(lgopts[opt_idx].name, "rx-queue-stats-mapping")) { 768 if (parse_queue_stats_mapping_config(optarg, RX)) { 769 rte_exit(EXIT_FAILURE, 770 "invalid RX queue statistics mapping config entered\n"); 771 } 772 } 773 break; 774 case 'h': 775 usage(argv[0]); 776 rte_exit(EXIT_SUCCESS, "Displayed help\n"); 777 break; 778 default: 779 usage(argv[0]); 780 rte_exit(EXIT_FAILURE, 781 "Command line is incomplete or incorrect\n"); 782 break; 783 } 784 } 785 } 786