1 /*- 2 * BSD LICENSE 3 * 4 * Copyright(c) 2010-2012 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 * version: DPDK.L.1.2.3-3 34 */ 35 36 #include <errno.h> 37 #include <getopt.h> 38 #include <stdarg.h> 39 #include <stdio.h> 40 #include <stdlib.h> 41 #include <signal.h> 42 #include <string.h> 43 #include <time.h> 44 #include <fcntl.h> 45 #include <sys/types.h> 46 #include <errno.h> 47 48 #include <sys/queue.h> 49 #include <sys/stat.h> 50 51 #include <stdint.h> 52 #include <unistd.h> 53 #include <inttypes.h> 54 55 #include <rte_common.h> 56 #include <rte_byteorder.h> 57 #include <rte_log.h> 58 #include <rte_debug.h> 59 #include <rte_cycles.h> 60 #include <rte_memory.h> 61 #include <rte_memzone.h> 62 #include <rte_launch.h> 63 #include <rte_tailq.h> 64 #include <rte_eal.h> 65 #include <rte_per_lcore.h> 66 #include <rte_lcore.h> 67 #include <rte_atomic.h> 68 #include <rte_branch_prediction.h> 69 #include <rte_ring.h> 70 #include <rte_mempool.h> 71 #include <rte_interrupts.h> 72 #include <rte_pci.h> 73 #include <rte_ether.h> 74 #include <rte_ethdev.h> 75 #include <rte_string_fns.h> 76 #include <cmdline_parse.h> 77 #include <cmdline_parse_etheraddr.h> 78 79 #include "testpmd.h" 80 81 static void 82 usage(char* progname) 83 { 84 printf("usage: %s [--interactive|-i] [--help|-h] | [" 85 "--coremask=COREMASK --portmask=PORTMASK --numa " 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= ]\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\n"); 106 printf(" --portmask=PORTMASK: hexadecimal bitmask of ports used " 107 "by the packet forwarding test\n"); 108 printf(" --numa: enable NUMA-aware allocation of RX/TX rings and of " 109 " RX memory buffers (mbufs)\n"); 110 printf(" --mbuf-size=N set the data size of mbuf to N bytes\n"); 111 printf(" --max-pkt-len=N set the maximum size of packet to N bytes\n"); 112 printf(" --pkt-filter-mode=N: set Flow director mode " 113 "( N: none (default mode) or signature or perfect)\n"); 114 printf(" --pkt-filter-report-hash=N: set Flow director report mode " 115 "( N: none or match (default) or always)\n"); 116 printf(" --pkt-filter-size=N: set Flow director mode " 117 "( N: 64K (default mode) or 128K or 256K)\n"); 118 printf(" --pkt-filter-flexbytes-offset=N: set flexbytes-offset." 119 " The offset is defined in word units counted from the" 120 " first byte of the destination Ethernet MAC address." 121 " 0 <= N <= 32\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 printf(" --crc-strip: enable CRC stripping by hardware\n"); 128 printf(" --enable-rx-cksum: enable rx hardware checksum offload\n"); 129 printf(" --disable-hw-vlan: disable hardware vlan\n"); 130 printf(" --disable-rss: disable rss\n"); 131 printf(" --port-topology=N: set port topology (N: paired (default) or " 132 "chained)\n"); 133 printf(" --rss-ip: set RSS functions to IPv4/IPv6 only \n"); 134 printf(" --rss-udp: set RSS functions to IPv4/IPv6 + UDP\n"); 135 printf(" --rxq=N set the number of RX queues per port to N\n"); 136 printf(" --rxd=N set the number of descriptors in RX rings to N\n"); 137 printf(" --txq=N set the number of TX queues per port to N\n"); 138 printf(" --txd=N set the number of descriptors in TX rings to N\n"); 139 printf(" --burst=N set the number of packets per burst to N\n"); 140 printf(" --mbcache=N set the cache of mbuf memory pool to N\n"); 141 printf(" --rxpt=N set prefetch threshold register of RX rings to N" 142 " (0 <= N <= 16)\n"); 143 printf(" --rxht=N set the host threshold register of RX rings to N" 144 " (0 <= N <= 16)\n"); 145 printf(" --rxfreet=N set the free threshold of RX descriptors to N" 146 " (0 <= N < value of rxd)\n"); 147 printf(" --rxwt=N set the write-back threshold register of RX rings" 148 " to N (0 <= N <= 16)\n"); 149 printf(" --txpt=N set the prefetch threshold register of TX rings" 150 " to N (0 <= N <= 16)\n"); 151 printf(" --txht=N set the nhost threshold register of TX rings to N" 152 " (0 <= N <= 16)\n"); 153 printf(" --txwt=N set the write-back threshold register of TX rings" 154 " to N (0 <= N <= 16)\n"); 155 printf(" --txfreet=N set the transmit free threshold of TX rings to N" 156 " (0 <= N <= value of txd)\n"); 157 printf(" --txrst=N set the transmit RS bit threshold of TX rings to N" 158 " (0 <= N <= value of txd)\n"); 159 } 160 161 static int 162 init_peer_eth_addrs(char *config_filename) 163 { 164 FILE *config_file; 165 portid_t i; 166 char buf[50]; 167 168 config_file = fopen(config_filename, "r"); 169 if (config_file == NULL) { 170 perror("open log file failed\n"); 171 return -1; 172 } 173 174 for (i = 0; i < RTE_MAX_ETHPORTS; i++) { 175 176 if (fgets(buf, sizeof(buf), config_file) == NULL) 177 break; 178 179 if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i]) < 0 ){ 180 printf("bad format of mac address on line %d\n", i); 181 fclose(config_file); 182 return -1; 183 } 184 } 185 fclose(config_file); 186 nb_peer_eth_addrs = (portid_t) i; 187 return 0; 188 } 189 190 /* 191 * Parse the coremask given as argument (hexadecimal string) and set 192 * the global configuration of forwarding cores. 193 */ 194 static void 195 parse_fwd_coremask(const char *coremask) 196 { 197 char *end; 198 unsigned long long int cm; 199 200 /* parse hexadecimal string */ 201 end = NULL; 202 cm = strtoull(coremask, &end, 16); 203 if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0')) 204 rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n"); 205 else 206 set_fwd_lcores_mask((uint64_t) cm); 207 } 208 209 /* 210 * Parse the coremask given as argument (hexadecimal string) and set 211 * the global configuration of forwarding cores. 212 */ 213 static void 214 parse_fwd_portmask(const char *portmask) 215 { 216 char *end; 217 unsigned long long int pm; 218 219 /* parse hexadecimal string */ 220 end = NULL; 221 pm = strtoull(portmask, &end, 16); 222 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) 223 rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n"); 224 else 225 set_fwd_ports_mask((uint64_t) pm); 226 } 227 228 void 229 launch_args_parse(int argc, char** argv) 230 { 231 int n, opt; 232 char **argvopt; 233 int opt_idx; 234 static struct option lgopts[] = { 235 { "help", 0, 0, 0 }, 236 { "interactive", 0, 0, 0 }, 237 { "eth-peers-configfile", 1, 0, 0 }, 238 { "eth-peer", 1, 0, 0 }, 239 { "ports", 1, 0, 0 }, 240 { "nb-cores", 1, 0, 0 }, 241 { "nb-ports", 1, 0, 0 }, 242 { "coremask", 1, 0, 0 }, 243 { "portmask", 1, 0, 0 }, 244 { "numa", 0, 0, 0 }, 245 { "mbuf-size", 1, 0, 0 }, 246 { "max-pkt-len", 1, 0, 0 }, 247 { "pkt-filter-mode", 1, 0, 0 }, 248 { "pkt-filter-report-hash", 1, 0, 0 }, 249 { "pkt-filter-size", 1, 0, 0 }, 250 { "pkt-filter-flexbytes-offset",1, 0, 0 }, 251 { "pkt-filter-drop-queue", 1, 0, 0 }, 252 { "crc-strip", 0, 0, 0 }, 253 { "disable-hw-vlan", 0, 0, 0 }, 254 { "disable-rss", 0, 0, 0 }, 255 { "port-topology", 1, 0, 0 }, 256 { "rss-ip", 0, 0, 0 }, 257 { "rss-udp", 0, 0, 0 }, 258 { "rxq", 1, 0, 0 }, 259 { "txq", 1, 0, 0 }, 260 { "rxd", 1, 0, 0 }, 261 { "txd", 1, 0, 0 }, 262 { "burst", 1, 0, 0 }, 263 { "mbcache", 1, 0, 0 }, 264 { "txpt", 1, 0, 0 }, 265 { "txht", 1, 0, 0 }, 266 { "txwt", 1, 0, 0 }, 267 { "txfreet", 1, 0, 0 }, 268 { "txrst", 1, 0, 0 }, 269 { "rxpt", 1, 0, 0 }, 270 { "rxht", 1, 0, 0 }, 271 { "rxwt", 1, 0, 0 }, 272 { "rxfreet", 1, 0, 0 }, 273 { 0, 0, 0, 0 }, 274 }; 275 276 argvopt = argv; 277 278 while ((opt = getopt_long(argc, argvopt, "ih", 279 lgopts, &opt_idx)) != EOF) { 280 switch (opt) { 281 case 'i': 282 printf("Interactive-mode selected\n"); 283 interactive = 1; 284 break; 285 case 0: /*long options */ 286 if (!strcmp(lgopts[opt_idx].name, "help")) { 287 usage(argv[0]); 288 rte_exit(EXIT_SUCCESS, "Displayed help\n"); 289 } 290 if (!strcmp(lgopts[opt_idx].name, "interactive")) { 291 printf("Interactive-mode selected\n"); 292 interactive = 1; 293 } 294 if (!strcmp(lgopts[opt_idx].name, 295 "eth-peers-configfile")) { 296 if (init_peer_eth_addrs(optarg) != 0) 297 rte_exit(EXIT_FAILURE, 298 "Cannot open logfile\n"); 299 } 300 if (!strcmp(lgopts[opt_idx].name, "eth-peer")) { 301 char *port_end; 302 uint8_t c, peer_addr[6]; 303 304 errno = 0; 305 n = strtoul(optarg, &port_end, 10); 306 if (errno != 0 || port_end == optarg || *port_end++ != ',') 307 rte_exit(EXIT_FAILURE, 308 "Invalid eth-peer: %s", optarg); 309 if (n >= RTE_MAX_ETHPORTS) 310 rte_exit(EXIT_FAILURE, 311 "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n", 312 n, RTE_MAX_ETHPORTS); 313 314 if (cmdline_parse_etheraddr(NULL, port_end, &peer_addr) < 0 ) 315 rte_exit(EXIT_FAILURE, 316 "Invalid ethernet address: %s\n", 317 port_end); 318 for (c = 0; c < 6; c++) 319 peer_eth_addrs[n].addr_bytes[c] = 320 peer_addr[c]; 321 nb_peer_eth_addrs++; 322 } 323 if (!strcmp(lgopts[opt_idx].name, "nb-ports")) { 324 n = atoi(optarg); 325 if (n > 0 && n <= nb_ports) 326 nb_fwd_ports = (uint8_t) n; 327 else 328 rte_exit(EXIT_FAILURE, 329 "nb-ports should be > 0 and <= %d\n", 330 nb_ports); 331 } 332 if (!strcmp(lgopts[opt_idx].name, "nb-cores")) { 333 n = atoi(optarg); 334 if (n > 0 && n <= nb_lcores) 335 nb_fwd_lcores = (uint8_t) n; 336 else 337 rte_exit(EXIT_FAILURE, 338 "nb-cores should be > 0 and <= %d\n", 339 nb_lcores); 340 } 341 if (!strcmp(lgopts[opt_idx].name, "coremask")) 342 parse_fwd_coremask(optarg); 343 if (!strcmp(lgopts[opt_idx].name, "portmask")) 344 parse_fwd_portmask(optarg); 345 if (!strcmp(lgopts[opt_idx].name, "numa")) 346 numa_support = 1; 347 if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) { 348 n = atoi(optarg); 349 if (n > 0 && n <= 0xFFFF) 350 mbuf_data_size = (uint16_t) n; 351 else 352 rte_exit(EXIT_FAILURE, 353 "mbuf-size should be > 0 and < 65536\n"); 354 } 355 if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) { 356 n = atoi(optarg); 357 if (n >= ETHER_MIN_LEN) { 358 rx_mode.max_rx_pkt_len = (uint32_t) n; 359 if (n > ETHER_MAX_LEN) 360 rx_mode.jumbo_frame = 1; 361 } else 362 rte_exit(EXIT_FAILURE, 363 "Invalid max-pkt-len=%d - should be > %d\n", 364 n, ETHER_MIN_LEN); 365 } 366 if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) { 367 if (!strcmp(optarg, "signature")) 368 fdir_conf.mode = 369 RTE_FDIR_MODE_SIGNATURE; 370 else if (!strcmp(optarg, "perfect")) 371 fdir_conf.mode = RTE_FDIR_MODE_PERFECT; 372 else if (!strcmp(optarg, "none")) 373 fdir_conf.mode = RTE_FDIR_MODE_NONE; 374 else 375 rte_exit(EXIT_FAILURE, 376 "pkt-mode-invalid %s invalid - must be: " 377 "none, signature or perfect\n", 378 optarg); 379 } 380 if (!strcmp(lgopts[opt_idx].name, 381 "pkt-filter-report-hash")) { 382 if (!strcmp(optarg, "none")) 383 fdir_conf.status = 384 RTE_FDIR_NO_REPORT_STATUS; 385 else if (!strcmp(optarg, "match")) 386 fdir_conf.status = 387 RTE_FDIR_REPORT_STATUS; 388 else if (!strcmp(optarg, "always")) 389 fdir_conf.status = 390 RTE_FDIR_REPORT_STATUS_ALWAYS; 391 else 392 rte_exit(EXIT_FAILURE, 393 "pkt-filter-report-hash %s invalid " 394 "- must be: none or match or always\n", 395 optarg); 396 } 397 if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) { 398 if (!strcmp(optarg, "64K")) 399 fdir_conf.pballoc = 400 RTE_FDIR_PBALLOC_64K; 401 else if (!strcmp(optarg, "128K")) 402 fdir_conf.pballoc = 403 RTE_FDIR_PBALLOC_128K; 404 else if (!strcmp(optarg, "256K")) 405 fdir_conf.pballoc = 406 RTE_FDIR_PBALLOC_256K; 407 else 408 rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -" 409 " must be: 64K or 128K or 256K\n", 410 optarg); 411 } 412 if (!strcmp(lgopts[opt_idx].name, 413 "pkt-filter-flexbytes-offset")) { 414 n = atoi(optarg); 415 if ( n >= 0 && n <= (int) 32) 416 fdir_conf.flexbytes_offset = 417 (uint8_t) n; 418 else 419 rte_exit(EXIT_FAILURE, 420 "flexbytes %d invalid - must" 421 "be >= 0 && <= 32\n", n); 422 } 423 if (!strcmp(lgopts[opt_idx].name, 424 "pkt-filter-drop-queue")) { 425 n = atoi(optarg); 426 if (n >= 0) 427 fdir_conf.drop_queue = (uint8_t) n; 428 else 429 rte_exit(EXIT_FAILURE, 430 "drop queue %d invalid - must" 431 "be >= 0 \n", n); 432 } 433 if (!strcmp(lgopts[opt_idx].name, "crc-strip")) 434 rx_mode.hw_strip_crc = 1; 435 if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum")) 436 rx_mode.hw_ip_checksum = 1; 437 if (!strcmp(lgopts[opt_idx].name, "disable-hw-vlan")) 438 rx_mode.hw_vlan_filter = 0; 439 if (!strcmp(lgopts[opt_idx].name, "disable-rss")) 440 rss_hf = 0; 441 if (!strcmp(lgopts[opt_idx].name, "port-topology")) { 442 if (!strcmp(optarg, "paired")) 443 port_topology = PORT_TOPOLOGY_PAIRED; 444 else if (!strcmp(optarg, "chained")) 445 port_topology = PORT_TOPOLOGY_CHAINED; 446 else 447 rte_exit(EXIT_FAILURE, "port-topology %s invalid -" 448 " must be: paired or chained \n", 449 optarg); 450 } 451 if (!strcmp(lgopts[opt_idx].name, "rss-ip")) 452 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6; 453 if (!strcmp(lgopts[opt_idx].name, "rss-udp")) 454 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | 455 ETH_RSS_IPV4_UDP; 456 if (!strcmp(lgopts[opt_idx].name, "rxq")) { 457 n = atoi(optarg); 458 if (n >= 1 && n <= (int) MAX_QUEUE_ID) 459 nb_rxq = (queueid_t) n; 460 else 461 rte_exit(EXIT_FAILURE, "rxq %d invalid - must be" 462 " >= 1 && <= %d\n", n, 463 (int) MAX_QUEUE_ID); 464 } 465 if (!strcmp(lgopts[opt_idx].name, "txq")) { 466 n = atoi(optarg); 467 if (n >= 1 && n <= (int) MAX_QUEUE_ID) 468 nb_txq = (queueid_t) n; 469 else 470 rte_exit(EXIT_FAILURE, "txq %d invalid - must be" 471 " >= 1 && <= %d\n", n, 472 (int) MAX_QUEUE_ID); 473 } 474 if (!strcmp(lgopts[opt_idx].name, "rxd")) { 475 n = atoi(optarg); 476 if (n > 0) 477 nb_rxd = (uint16_t) n; 478 else 479 rte_exit(EXIT_FAILURE, "rxd must be > 0\n"); 480 } 481 if (!strcmp(lgopts[opt_idx].name, "txd")) { 482 n = atoi(optarg); 483 if (n > 0) 484 nb_txd = (uint16_t) n; 485 else 486 rte_exit(EXIT_FAILURE, "txd must be in > 0\n"); 487 } 488 if (!strcmp(lgopts[opt_idx].name, "burst")) { 489 n = atoi(optarg); 490 if ((n >= 1) && (n <= MAX_PKT_BURST)) 491 nb_pkt_per_burst = (uint16_t) n; 492 else 493 rte_exit(EXIT_FAILURE, 494 "burst must >= 1 and <= %d]", 495 MAX_PKT_BURST); 496 } 497 if (!strcmp(lgopts[opt_idx].name, "mbcache")) { 498 n = atoi(optarg); 499 if ((n >= 0) && 500 (n <= RTE_MEMPOOL_CACHE_MAX_SIZE)) 501 mb_mempool_cache = (uint16_t) n; 502 else 503 rte_exit(EXIT_FAILURE, 504 "mbcache must be >= 0 and <= %d\n", 505 RTE_MEMPOOL_CACHE_MAX_SIZE); 506 } 507 if (!strcmp(lgopts[opt_idx].name, "txpt")) { 508 n = atoi(optarg); 509 if (n >= 0) 510 tx_thresh.pthresh = (uint8_t)n; 511 else 512 rte_exit(EXIT_FAILURE, "txpt must be >= 0\n"); 513 } 514 if (!strcmp(lgopts[opt_idx].name, "txht")) { 515 n = atoi(optarg); 516 if (n >= 0) 517 tx_thresh.hthresh = (uint8_t)n; 518 else 519 rte_exit(EXIT_FAILURE, "txht must be >= 0\n"); 520 } 521 if (!strcmp(lgopts[opt_idx].name, "txwt")) { 522 n = atoi(optarg); 523 if (n >= 0) 524 tx_thresh.wthresh = (uint8_t)n; 525 else 526 rte_exit(EXIT_FAILURE, "txwt must be >= 0\n"); 527 } 528 if (!strcmp(lgopts[opt_idx].name, "txfreet")) { 529 n = atoi(optarg); 530 if (n >= 0) 531 tx_free_thresh = (uint16_t)n; 532 else 533 rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n"); 534 } 535 if (!strcmp(lgopts[opt_idx].name, "txrst")) { 536 n = atoi(optarg); 537 if (n >= 0) 538 tx_rs_thresh = (uint16_t)n; 539 else 540 rte_exit(EXIT_FAILURE, "txrst must be >= 0\n"); 541 } 542 if (!strcmp(lgopts[opt_idx].name, "rxpt")) { 543 n = atoi(optarg); 544 if (n >= 0) 545 rx_thresh.pthresh = (uint8_t)n; 546 else 547 rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n"); 548 } 549 if (!strcmp(lgopts[opt_idx].name, "rxht")) { 550 n = atoi(optarg); 551 if (n >= 0) 552 rx_thresh.hthresh = (uint8_t)n; 553 else 554 rte_exit(EXIT_FAILURE, "rxht must be >= 0\n"); 555 } 556 if (!strcmp(lgopts[opt_idx].name, "rxwt")) { 557 n = atoi(optarg); 558 if (n >= 0) 559 rx_thresh.wthresh = (uint8_t)n; 560 else 561 rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n"); 562 } 563 if (!strcmp(lgopts[opt_idx].name, "rxd")) { 564 n = atoi(optarg); 565 if (n > 0) { 566 if (rx_free_thresh >= n) 567 rte_exit(EXIT_FAILURE, 568 "rxd must be > " 569 "rx_free_thresh(%d)\n", 570 (int)rx_free_thresh); 571 else 572 nb_rxd = (uint16_t) n; 573 } else 574 rte_exit(EXIT_FAILURE, 575 "rxd(%d) invalid - must be > 0\n", 576 n); 577 } 578 if (!strcmp(lgopts[opt_idx].name, "txd")) { 579 n = atoi(optarg); 580 if (n > 0) 581 nb_txd = (uint16_t) n; 582 else 583 rte_exit(EXIT_FAILURE, "txd must be in > 0\n"); 584 } 585 if (!strcmp(lgopts[opt_idx].name, "txpt")) { 586 n = atoi(optarg); 587 if (n >= 0) 588 tx_thresh.pthresh = (uint8_t)n; 589 else 590 rte_exit(EXIT_FAILURE, "txpt must be >= 0\n"); 591 } 592 if (!strcmp(lgopts[opt_idx].name, "txht")) { 593 n = atoi(optarg); 594 if (n >= 0) 595 tx_thresh.hthresh = (uint8_t)n; 596 else 597 rte_exit(EXIT_FAILURE, "txht must be >= 0\n"); 598 } 599 if (!strcmp(lgopts[opt_idx].name, "txwt")) { 600 n = atoi(optarg); 601 if (n >= 0) 602 tx_thresh.wthresh = (uint8_t)n; 603 else 604 rte_exit(EXIT_FAILURE, "txwt must be >= 0\n"); 605 } 606 if (!strcmp(lgopts[opt_idx].name, "rxpt")) { 607 n = atoi(optarg); 608 if (n >= 0) 609 rx_thresh.pthresh = (uint8_t)n; 610 else 611 rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n"); 612 } 613 if (!strcmp(lgopts[opt_idx].name, "rxht")) { 614 n = atoi(optarg); 615 if (n >= 0) 616 rx_thresh.hthresh = (uint8_t)n; 617 else 618 rte_exit(EXIT_FAILURE, "rxht must be >= 0\n"); 619 } 620 if (!strcmp(lgopts[opt_idx].name, "rxwt")) { 621 n = atoi(optarg); 622 if (n >= 0) 623 rx_thresh.wthresh = (uint8_t)n; 624 else 625 rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n"); 626 } 627 if (!strcmp(lgopts[opt_idx].name, "rxfreet")) { 628 n = atoi(optarg); 629 if (n >= 0) 630 rx_free_thresh = (uint16_t)n; 631 else 632 rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n"); 633 } 634 break; 635 case 'h': 636 usage(argv[0]); 637 rte_exit(EXIT_SUCCESS, "Displayed help\n"); 638 break; 639 default: 640 usage(argv[0]); 641 rte_exit(EXIT_FAILURE, 642 "Command line is incomplete or incorrect\n"); 643 break; 644 } 645 } 646 } 647