4 * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
44 #include <sys/types.h>
47 #include <sys/queue.h>
54 #include <rte_common.h>
55 #include <rte_byteorder.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>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.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>
83 printf("usage: %s [--interactive|-i] [--help|-h] | ["
84 "--coremask=COREMASK --portmask=PORTMASK --numa "
85 "--mbuf-size= | --total-num-mbufs= | "
86 "--nb-cores= | --nb-ports= | "
87 "--eth-peers-configfile= | "
88 "--eth-peer=X,M:M:M:M:M:M | "
89 "--pkt-filter-mode= |"
90 "--rss-ip | --rss-udp | "
91 "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
92 "--txpt= | --txht= | --txwt= | --txfreet= | "
93 "--txrst= | --txqflags= ]\n",
95 printf(" --interactive: run in interactive mode.\n");
96 printf(" --help: display this message and quit.\n");
97 printf(" --nb-cores=N: set the number of forwarding cores "
98 "(1 <= N <= %d).\n", nb_lcores);
99 printf(" --nb-ports=N: set the number of forwarding ports "
100 "(1 <= N <= %d).\n", nb_ports);
101 printf(" --coremask=COREMASK: hexadecimal bitmask of cores running "
102 "the packet forwarding test. The master lcore is reserved for "
103 "command line parsing only, and cannot be masked on for "
104 "packet forwarding.\n");
105 printf(" --portmask=PORTMASK: hexadecimal bitmask of ports used "
106 "by the packet forwarding test.\n");
107 printf(" --numa: enable NUMA-aware allocation of RX/TX rings and of "
108 "RX memory buffers (mbufs).\n");
109 printf(" --port-numa-config=(port,socket)[,(port,socket)]: "
110 "specify the socket on which the memory pool "
111 "used by the port will be allocated.\n");
112 printf(" --ring-numa-config=(port,flag,socket)[,(port,flag,socket)]: "
113 "specify the socket on which the TX/RX rings for "
114 "the port will be allocated "
115 "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
116 printf(" --socket-num=N: set socket from which all memory is allocated "
118 printf(" --mbuf-size=N: set the data size of mbuf to N bytes.\n");
119 printf(" --total-num-mbufs=N: set the number of mbufs to be allocated "
121 printf(" --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
122 printf(" --eth-peers-configfile=name: config file with ethernet addresses "
124 printf(" --eth-peer=X,M:M:M:M:M:M: set the MAC address of the X peer "
125 "port (0 <= X < %d).\n", RTE_MAX_ETHPORTS);
126 printf(" --pkt-filter-mode=N: set Flow Director mode "
127 "(N: none (default mode) or signature or perfect).\n");
128 printf(" --pkt-filter-report-hash=N: set Flow Director report mode "
129 "(N: none or match (default) or always).\n");
130 printf(" --pkt-filter-size=N: set Flow Director mode "
131 "(N: 64K (default mode) or 128K or 256K).\n");
132 printf(" --pkt-filter-flexbytes-offset=N: set flexbytes-offset. "
133 "The offset is defined in word units counted from the "
134 "first byte of the destination Ethernet MAC address. "
136 printf(" --pkt-filter-drop-queue=N: set drop-queue. "
137 "In perfect mode, when you add a rule with queue = -1 "
138 "the packet will be enqueued into the rx drop-queue. "
139 "If the drop-queue doesn't exist, the packet is dropped. "
140 "By default drop-queue=127.\n");
141 printf(" --crc-strip: enable CRC stripping by hardware.\n");
142 printf(" --enable-rx-cksum: enable rx hardware checksum offload.\n");
143 printf(" --disable-hw-vlan: disable hardware vlan.\n");
144 printf(" --enable-drop-en: enable per queue packet drop.\n");
145 printf(" --disable-rss: disable rss.\n");
146 printf(" --port-topology=N: set port topology (N: paired (default) or "
148 printf(" --rss-ip: set RSS functions to IPv4/IPv6 only .\n");
149 printf(" --rss-udp: set RSS functions to IPv4/IPv6 + UDP.\n");
150 printf(" --rxq=N: set the number of RX queues per port to N.\n");
151 printf(" --rxd=N: set the number of descriptors in RX rings to N.\n");
152 printf(" --txq=N: set the number of TX queues per port to N.\n");
153 printf(" --txd=N: set the number of descriptors in TX rings to N.\n");
154 printf(" --burst=N: set the number of packets per burst to N.\n");
155 printf(" --mbcache=N: set the cache of mbuf memory pool to N.\n");
156 printf(" --rxpt=N: set prefetch threshold register of RX rings to N "
157 "(0 <= N <= 16).\n");
158 printf(" --rxht=N: set the host threshold register of RX rings to N "
159 "(0 <= N <= 16).\n");
160 printf(" --rxfreet=N: set the free threshold of RX descriptors to N "
161 "(0 <= N < value of rxd).\n");
162 printf(" --rxwt=N: set the write-back threshold register of RX rings "
163 "to N (0 <= N <= 16).\n");
164 printf(" --txpt=N: set the prefetch threshold register of TX rings "
165 "to N (0 <= N <= 16).\n");
166 printf(" --txht=N: set the nhost threshold register of TX rings to N "
167 "(0 <= N <= 16).\n");
168 printf(" --txwt=N: set the write-back threshold register of TX rings "
169 "to N (0 <= N <= 16).\n");
170 printf(" --txfreet=N: set the transmit free threshold of TX rings to N "
171 "(0 <= N <= value of txd).\n");
172 printf(" --txrst=N: set the transmit RS bit threshold of TX rings to N "
173 "(0 <= N <= value of txd).\n");
174 printf(" --txqflags=0xXXXXXXXX: hexadecimal bitmask of TX queue flags "
175 "(0 <= N <= 0x7FFFFFFF).\n");
176 printf(" --tx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: "
177 "tx queues statistics counters mapping "
178 "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
179 printf(" --rx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: "
180 "rx queues statistics counters mapping "
181 "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
185 init_peer_eth_addrs(char *config_filename)
191 config_file = fopen(config_filename, "r");
192 if (config_file == NULL) {
193 perror("Failed to open eth config file\n");
197 for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
199 if (fgets(buf, sizeof(buf), config_file) == NULL)
202 if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i]) < 0 ){
203 printf("Bad MAC address format on line %d\n", i+1);
209 nb_peer_eth_addrs = (portid_t) i;
214 * Parse the coremask given as argument (hexadecimal string) and set
215 * the global configuration of forwarding cores.
218 parse_fwd_coremask(const char *coremask)
221 unsigned long long int cm;
223 /* parse hexadecimal string */
225 cm = strtoull(coremask, &end, 16);
226 if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0'))
227 rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n");
228 else if (set_fwd_lcores_mask((uint64_t) cm) < 0)
229 rte_exit(EXIT_FAILURE, "coremask is not valid\n");
233 * Parse the coremask given as argument (hexadecimal string) and set
234 * the global configuration of forwarding cores.
237 parse_fwd_portmask(const char *portmask)
240 unsigned long long int pm;
242 /* parse hexadecimal string */
244 pm = strtoull(portmask, &end, 16);
245 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
246 rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n");
248 set_fwd_ports_mask((uint64_t) pm);
253 parse_queue_stats_mapping_config(const char *q_arg, int is_rx)
256 const char *p, *p0 = q_arg;
264 unsigned long int_fld[_NUM_FLD];
265 char *str_fld[_NUM_FLD];
269 /* reset from value set at definition */
270 is_rx ? (nb_rx_queue_stats_mappings = 0) : (nb_tx_queue_stats_mappings = 0);
272 while ((p = strchr(p0,'(')) != NULL) {
274 if((p0 = strchr(p,')')) == NULL)
278 if(size >= sizeof(s))
281 rte_snprintf(s, sizeof(s), "%.*s", size, p);
282 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
284 for (i = 0; i < _NUM_FLD; i++){
286 int_fld[i] = strtoul(str_fld[i], &end, 0);
287 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
290 /* Check mapping field is in correct range (0..RTE_ETHDEV_QUEUE_STAT_CNTRS-1) */
291 if (int_fld[FLD_STATS_COUNTER] >= RTE_ETHDEV_QUEUE_STAT_CNTRS) {
292 printf("Stats counter not in the correct range 0..%d\n",
293 RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
297 if (is_rx ? (nb_rx_queue_stats_mappings >= MAX_RX_QUEUE_STATS_MAPPINGS) :
298 (nb_tx_queue_stats_mappings >= MAX_TX_QUEUE_STATS_MAPPINGS)) {
299 printf("exceeded max number of %s queue statistics mappings: %hu\n",
301 is_rx ? nb_rx_queue_stats_mappings : nb_tx_queue_stats_mappings);
305 tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id =
306 (uint8_t)int_fld[FLD_PORT];
307 tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id =
308 (uint8_t)int_fld[FLD_QUEUE];
309 tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].stats_counter_id =
310 (uint8_t)int_fld[FLD_STATS_COUNTER];
311 ++nb_tx_queue_stats_mappings;
314 rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id =
315 (uint8_t)int_fld[FLD_PORT];
316 rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id =
317 (uint8_t)int_fld[FLD_QUEUE];
318 rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].stats_counter_id =
319 (uint8_t)int_fld[FLD_STATS_COUNTER];
320 ++nb_rx_queue_stats_mappings;
324 /* Reassign the rx/tx_queue_stats_mappings pointer to point to this newly populated array rather */
325 /* than to the default array (that was set at its definition) */
326 is_rx ? (rx_queue_stats_mappings = rx_queue_stats_mappings_array) :
327 (tx_queue_stats_mappings = tx_queue_stats_mappings_array);
332 parse_portnuma_config(const char *q_arg)
335 const char *p, *p0 = q_arg;
337 uint8_t i,port_id,socket_id;
344 unsigned long int_fld[_NUM_FLD];
345 char *str_fld[_NUM_FLD];
347 /* reset from value set at definition */
348 while ((p = strchr(p0,'(')) != NULL) {
350 if((p0 = strchr(p,')')) == NULL)
354 if(size >= sizeof(s))
357 rte_snprintf(s, sizeof(s), "%.*s", size, p);
358 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
360 for (i = 0; i < _NUM_FLD; i++) {
362 int_fld[i] = strtoul(str_fld[i], &end, 0);
363 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
366 port_id = (uint8_t)int_fld[FLD_PORT];
367 if (port_id >= nb_ports) {
368 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
371 socket_id = (uint8_t)int_fld[FLD_SOCKET];
372 if(socket_id >= MAX_SOCKET) {
373 printf("Invalid socket id, range is [0, %d]\n",
377 port_numa[port_id] = socket_id;
384 parse_ringnuma_config(const char *q_arg)
387 const char *p, *p0 = q_arg;
389 uint8_t i,port_id,ring_flag,socket_id;
397 unsigned long int_fld[_NUM_FLD];
398 char *str_fld[_NUM_FLD];
399 #define RX_RING_ONLY 0x1
400 #define TX_RING_ONLY 0x2
401 #define RXTX_RING 0x3
403 /* reset from value set at definition */
404 while ((p = strchr(p0,'(')) != NULL) {
406 if((p0 = strchr(p,')')) == NULL)
410 if(size >= sizeof(s))
413 rte_snprintf(s, sizeof(s), "%.*s", size, p);
414 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
416 for (i = 0; i < _NUM_FLD; i++) {
418 int_fld[i] = strtoul(str_fld[i], &end, 0);
419 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
422 port_id = (uint8_t)int_fld[FLD_PORT];
423 if (port_id >= nb_ports) {
424 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
427 socket_id = (uint8_t)int_fld[FLD_SOCKET];
428 if (socket_id >= MAX_SOCKET) {
429 printf("Invalid socket id, range is [0, %d]\n",
433 ring_flag = (uint8_t)int_fld[FLD_FLAG];
434 if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) {
435 printf("Invalid ring-flag=%d config for port =%d\n",
440 switch (ring_flag & RXTX_RING) {
442 rxring_numa[port_id] = socket_id;
445 txring_numa[port_id] = socket_id;
448 rxring_numa[port_id] = socket_id;
449 txring_numa[port_id] = socket_id;
452 printf("Invalid ring-flag=%d config for port=%d\n",
462 launch_args_parse(int argc, char** argv)
469 static struct option lgopts[] = {
471 { "interactive", 0, 0, 0 },
472 { "eth-peers-configfile", 1, 0, 0 },
473 { "eth-peer", 1, 0, 0 },
474 { "ports", 1, 0, 0 },
475 { "nb-cores", 1, 0, 0 },
476 { "nb-ports", 1, 0, 0 },
477 { "coremask", 1, 0, 0 },
478 { "portmask", 1, 0, 0 },
480 { "port-numa-config", 1, 0, 0 },
481 { "ring-numa-config", 1, 0, 0 },
482 { "socket-num", 1, 0, 0 },
483 { "mbuf-size", 1, 0, 0 },
484 { "total-num-mbufs", 1, 0, 0 },
485 { "max-pkt-len", 1, 0, 0 },
486 { "pkt-filter-mode", 1, 0, 0 },
487 { "pkt-filter-report-hash", 1, 0, 0 },
488 { "pkt-filter-size", 1, 0, 0 },
489 { "pkt-filter-flexbytes-offset",1, 0, 0 },
490 { "pkt-filter-drop-queue", 1, 0, 0 },
491 { "crc-strip", 0, 0, 0 },
492 { "enable-rx-cksum", 0, 0, 0 },
493 { "disable-hw-vlan", 0, 0, 0 },
494 { "enable-drop-en", 0, 0, 0 },
495 { "disable-rss", 0, 0, 0 },
496 { "port-topology", 1, 0, 0 },
497 { "rss-ip", 0, 0, 0 },
498 { "rss-udp", 0, 0, 0 },
503 { "burst", 1, 0, 0 },
504 { "mbcache", 1, 0, 0 },
508 { "txfreet", 1, 0, 0 },
509 { "txrst", 1, 0, 0 },
510 { "txqflags", 1, 0, 0 },
514 { "rxfreet", 1, 0, 0 },
515 { "tx-queue-stats-mapping", 1, 0, 0 },
516 { "rx-queue-stats-mapping", 1, 0, 0 },
522 while ((opt = getopt_long(argc, argvopt, "ih",
523 lgopts, &opt_idx)) != EOF) {
526 printf("Interactive-mode selected\n");
529 case 0: /*long options */
530 if (!strcmp(lgopts[opt_idx].name, "help")) {
532 rte_exit(EXIT_SUCCESS, "Displayed help\n");
534 if (!strcmp(lgopts[opt_idx].name, "interactive")) {
535 printf("Interactive-mode selected\n");
538 if (!strcmp(lgopts[opt_idx].name,
539 "eth-peers-configfile")) {
540 if (init_peer_eth_addrs(optarg) != 0)
541 rte_exit(EXIT_FAILURE,
542 "Cannot open logfile\n");
544 if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
546 uint8_t c, peer_addr[6];
549 n = strtoul(optarg, &port_end, 10);
550 if (errno != 0 || port_end == optarg || *port_end++ != ',')
551 rte_exit(EXIT_FAILURE,
552 "Invalid eth-peer: %s", optarg);
553 if (n >= RTE_MAX_ETHPORTS)
554 rte_exit(EXIT_FAILURE,
555 "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n",
556 n, RTE_MAX_ETHPORTS);
558 if (cmdline_parse_etheraddr(NULL, port_end, &peer_addr) < 0 )
559 rte_exit(EXIT_FAILURE,
560 "Invalid ethernet address: %s\n",
562 for (c = 0; c < 6; c++)
563 peer_eth_addrs[n].addr_bytes[c] =
567 if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
569 if (n > 0 && n <= nb_ports)
570 nb_fwd_ports = (uint8_t) n;
572 rte_exit(EXIT_FAILURE,
573 "nb-ports should be > 0 and <= %d\n",
576 if (!strcmp(lgopts[opt_idx].name, "nb-cores")) {
578 if (n > 0 && n <= nb_lcores)
579 nb_fwd_lcores = (uint8_t) n;
581 rte_exit(EXIT_FAILURE,
582 "nb-cores should be > 0 and <= %d\n",
585 if (!strcmp(lgopts[opt_idx].name, "coremask"))
586 parse_fwd_coremask(optarg);
587 if (!strcmp(lgopts[opt_idx].name, "portmask"))
588 parse_fwd_portmask(optarg);
589 if (!strcmp(lgopts[opt_idx].name, "numa")) {
591 memset(port_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS);
592 memset(rxring_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS);
593 memset(txring_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS);
595 if (!strcmp(lgopts[opt_idx].name, "port-numa-config")) {
596 if (parse_portnuma_config(optarg))
597 rte_exit(EXIT_FAILURE,
598 "invalid port-numa configuration\n");
600 if (!strcmp(lgopts[opt_idx].name, "ring-numa-config"))
601 if (parse_ringnuma_config(optarg))
602 rte_exit(EXIT_FAILURE,
603 "invalid ring-numa configuration\n");
604 if (!strcmp(lgopts[opt_idx].name, "socket-num")) {
607 socket_num = (uint8_t)n;
609 rte_exit(EXIT_FAILURE,
610 "The socket number should be < %d\n",
613 if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
615 if (n > 0 && n <= 0xFFFF)
616 mbuf_data_size = (uint16_t) n;
618 rte_exit(EXIT_FAILURE,
619 "mbuf-size should be > 0 and < 65536\n");
621 if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
624 param_total_num_mbufs = (unsigned)n;
626 rte_exit(EXIT_FAILURE,
627 "total-num-mbufs should be > 1024\n");
629 if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
631 if (n >= ETHER_MIN_LEN) {
632 rx_mode.max_rx_pkt_len = (uint32_t) n;
633 if (n > ETHER_MAX_LEN)
634 rx_mode.jumbo_frame = 1;
636 rte_exit(EXIT_FAILURE,
637 "Invalid max-pkt-len=%d - should be > %d\n",
640 if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) {
641 if (!strcmp(optarg, "signature"))
643 RTE_FDIR_MODE_SIGNATURE;
644 else if (!strcmp(optarg, "perfect"))
645 fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
646 else if (!strcmp(optarg, "none"))
647 fdir_conf.mode = RTE_FDIR_MODE_NONE;
649 rte_exit(EXIT_FAILURE,
650 "pkt-mode-invalid %s invalid - must be: "
651 "none, signature or perfect\n",
654 if (!strcmp(lgopts[opt_idx].name,
655 "pkt-filter-report-hash")) {
656 if (!strcmp(optarg, "none"))
658 RTE_FDIR_NO_REPORT_STATUS;
659 else if (!strcmp(optarg, "match"))
661 RTE_FDIR_REPORT_STATUS;
662 else if (!strcmp(optarg, "always"))
664 RTE_FDIR_REPORT_STATUS_ALWAYS;
666 rte_exit(EXIT_FAILURE,
667 "pkt-filter-report-hash %s invalid "
668 "- must be: none or match or always\n",
671 if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) {
672 if (!strcmp(optarg, "64K"))
674 RTE_FDIR_PBALLOC_64K;
675 else if (!strcmp(optarg, "128K"))
677 RTE_FDIR_PBALLOC_128K;
678 else if (!strcmp(optarg, "256K"))
680 RTE_FDIR_PBALLOC_256K;
682 rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -"
683 " must be: 64K or 128K or 256K\n",
686 if (!strcmp(lgopts[opt_idx].name,
687 "pkt-filter-flexbytes-offset")) {
689 if ( n >= 0 && n <= (int) 32)
690 fdir_conf.flexbytes_offset =
693 rte_exit(EXIT_FAILURE,
694 "flexbytes %d invalid - must"
695 "be >= 0 && <= 32\n", n);
697 if (!strcmp(lgopts[opt_idx].name,
698 "pkt-filter-drop-queue")) {
701 fdir_conf.drop_queue = (uint8_t) n;
703 rte_exit(EXIT_FAILURE,
704 "drop queue %d invalid - must"
707 if (!strcmp(lgopts[opt_idx].name, "crc-strip"))
708 rx_mode.hw_strip_crc = 1;
709 if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
710 rx_mode.hw_ip_checksum = 1;
712 if (!strcmp(lgopts[opt_idx].name, "disable-hw-vlan")) {
713 rx_mode.hw_vlan_filter = 0;
714 rx_mode.hw_vlan_strip = 0;
715 rx_mode.hw_vlan_extend = 0;
718 if (!strcmp(lgopts[opt_idx].name, "enable-drop-en"))
721 if (!strcmp(lgopts[opt_idx].name, "disable-rss"))
723 if (!strcmp(lgopts[opt_idx].name, "port-topology")) {
724 if (!strcmp(optarg, "paired"))
725 port_topology = PORT_TOPOLOGY_PAIRED;
726 else if (!strcmp(optarg, "chained"))
727 port_topology = PORT_TOPOLOGY_CHAINED;
729 rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
730 " must be: paired or chained \n",
733 if (!strcmp(lgopts[opt_idx].name, "rss-ip"))
734 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
735 if (!strcmp(lgopts[opt_idx].name, "rss-udp"))
736 rss_hf = ETH_RSS_IPV4 |
737 ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
738 if (!strcmp(lgopts[opt_idx].name, "rxq")) {
740 if (n >= 1 && n <= (int) MAX_QUEUE_ID)
741 nb_rxq = (queueid_t) n;
743 rte_exit(EXIT_FAILURE, "rxq %d invalid - must be"
744 " >= 1 && <= %d\n", n,
747 if (!strcmp(lgopts[opt_idx].name, "txq")) {
749 if (n >= 1 && n <= (int) MAX_QUEUE_ID)
750 nb_txq = (queueid_t) n;
752 rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
753 " >= 1 && <= %d\n", n,
756 if (!strcmp(lgopts[opt_idx].name, "rxd")) {
759 nb_rxd = (uint16_t) n;
761 rte_exit(EXIT_FAILURE, "rxd must be > 0\n");
763 if (!strcmp(lgopts[opt_idx].name, "txd")) {
766 nb_txd = (uint16_t) n;
768 rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
770 if (!strcmp(lgopts[opt_idx].name, "burst")) {
772 if ((n >= 1) && (n <= MAX_PKT_BURST))
773 nb_pkt_per_burst = (uint16_t) n;
775 rte_exit(EXIT_FAILURE,
776 "burst must >= 1 and <= %d]",
779 if (!strcmp(lgopts[opt_idx].name, "mbcache")) {
782 (n <= RTE_MEMPOOL_CACHE_MAX_SIZE))
783 mb_mempool_cache = (uint16_t) n;
785 rte_exit(EXIT_FAILURE,
786 "mbcache must be >= 0 and <= %d\n",
787 RTE_MEMPOOL_CACHE_MAX_SIZE);
789 if (!strcmp(lgopts[opt_idx].name, "txpt")) {
792 tx_thresh.pthresh = (uint8_t)n;
794 rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
796 if (!strcmp(lgopts[opt_idx].name, "txht")) {
799 tx_thresh.hthresh = (uint8_t)n;
801 rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
803 if (!strcmp(lgopts[opt_idx].name, "txwt")) {
806 tx_thresh.wthresh = (uint8_t)n;
808 rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
810 if (!strcmp(lgopts[opt_idx].name, "txfreet")) {
813 tx_free_thresh = (uint16_t)n;
815 rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n");
817 if (!strcmp(lgopts[opt_idx].name, "txrst")) {
820 tx_rs_thresh = (uint16_t)n;
822 rte_exit(EXIT_FAILURE, "txrst must be >= 0\n");
824 if (!strcmp(lgopts[opt_idx].name, "txqflags")) {
826 n = strtoul(optarg, &end, 16);
828 txq_flags = (uint32_t)n;
830 rte_exit(EXIT_FAILURE,
831 "txqflags must be >= 0\n");
833 if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
836 rx_thresh.pthresh = (uint8_t)n;
838 rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
840 if (!strcmp(lgopts[opt_idx].name, "rxht")) {
843 rx_thresh.hthresh = (uint8_t)n;
845 rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
847 if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
850 rx_thresh.wthresh = (uint8_t)n;
852 rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
854 if (!strcmp(lgopts[opt_idx].name, "rxd")) {
857 if (rx_free_thresh >= n)
858 rte_exit(EXIT_FAILURE,
860 "rx_free_thresh(%d)\n",
861 (int)rx_free_thresh);
863 nb_rxd = (uint16_t) n;
865 rte_exit(EXIT_FAILURE,
866 "rxd(%d) invalid - must be > 0\n",
869 if (!strcmp(lgopts[opt_idx].name, "txd")) {
872 nb_txd = (uint16_t) n;
874 rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
876 if (!strcmp(lgopts[opt_idx].name, "txpt")) {
879 tx_thresh.pthresh = (uint8_t)n;
881 rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
883 if (!strcmp(lgopts[opt_idx].name, "txht")) {
886 tx_thresh.hthresh = (uint8_t)n;
888 rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
890 if (!strcmp(lgopts[opt_idx].name, "txwt")) {
893 tx_thresh.wthresh = (uint8_t)n;
895 rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
897 if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
900 rx_thresh.pthresh = (uint8_t)n;
902 rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
904 if (!strcmp(lgopts[opt_idx].name, "rxht")) {
907 rx_thresh.hthresh = (uint8_t)n;
909 rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
911 if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
914 rx_thresh.wthresh = (uint8_t)n;
916 rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
918 if (!strcmp(lgopts[opt_idx].name, "rxfreet")) {
921 rx_free_thresh = (uint16_t)n;
923 rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n");
925 if (!strcmp(lgopts[opt_idx].name, "tx-queue-stats-mapping")) {
926 if (parse_queue_stats_mapping_config(optarg, TX)) {
927 rte_exit(EXIT_FAILURE,
928 "invalid TX queue statistics mapping config entered\n");
931 if (!strcmp(lgopts[opt_idx].name, "rx-queue-stats-mapping")) {
932 if (parse_queue_stats_mapping_config(optarg, RX)) {
933 rte_exit(EXIT_FAILURE,
934 "invalid RX queue statistics mapping config entered\n");
940 rte_exit(EXIT_SUCCESS, "Displayed help\n");
944 rte_exit(EXIT_FAILURE,
945 "Command line is incomplete or incorrect\n");