4 * Copyright(c) 2010-2014 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.
43 #include <sys/types.h>
46 #include <sys/queue.h>
53 #include <rte_common.h>
54 #include <rte_byteorder.h>
56 #include <rte_debug.h>
57 #include <rte_cycles.h>
58 #include <rte_memory.h>
59 #include <rte_memzone.h>
60 #include <rte_launch.h>
61 #include <rte_tailq.h>
63 #include <rte_per_lcore.h>
64 #include <rte_lcore.h>
65 #include <rte_atomic.h>
66 #include <rte_branch_prediction.h>
68 #include <rte_mempool.h>
69 #include <rte_interrupts.h>
71 #include <rte_ether.h>
72 #include <rte_ethdev.h>
73 #include <rte_string_fns.h>
74 #ifdef RTE_LIBRTE_CMDLINE
75 #include <cmdline_parse.h>
76 #include <cmdline_parse_etheraddr.h>
78 #ifdef RTE_LIBRTE_PMD_BOND
79 #include <rte_eth_bond.h>
88 #ifdef RTE_LIBRTE_CMDLINE
91 "[--help|-h] | [--auto-start|-a] | ["
92 "--coremask=COREMASK --portmask=PORTMASK --numa "
93 "--mbuf-size= | --total-num-mbufs= | "
94 "--nb-cores= | --nb-ports= | "
95 #ifdef RTE_LIBRTE_CMDLINE
96 "--eth-peers-configfile= | "
97 "--eth-peer=X,M:M:M:M:M:M | "
99 "--pkt-filter-mode= |"
100 "--rss-ip | --rss-udp | "
101 "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
102 "--txpt= | --txht= | --txwt= | --txfreet= | "
103 "--txrst= | --txqflags= ]\n",
105 #ifdef RTE_LIBRTE_CMDLINE
106 printf(" --interactive: run in interactive mode.\n");
108 printf(" --auto-start: start forwarding on init "
109 "[always when non-interactive].\n");
110 printf(" --help: display this message and quit.\n");
111 printf(" --nb-cores=N: set the number of forwarding cores "
112 "(1 <= N <= %d).\n", nb_lcores);
113 printf(" --nb-ports=N: set the number of forwarding ports "
114 "(1 <= N <= %d).\n", nb_ports);
115 printf(" --coremask=COREMASK: hexadecimal bitmask of cores running "
116 "the packet forwarding test. The master lcore is reserved for "
117 "command line parsing only, and cannot be masked on for "
118 "packet forwarding.\n");
119 printf(" --portmask=PORTMASK: hexadecimal bitmask of ports used "
120 "by the packet forwarding test.\n");
121 printf(" --numa: enable NUMA-aware allocation of RX/TX rings and of "
122 "RX memory buffers (mbufs).\n");
123 printf(" --port-numa-config=(port,socket)[,(port,socket)]: "
124 "specify the socket on which the memory pool "
125 "used by the port will be allocated.\n");
126 printf(" --ring-numa-config=(port,flag,socket)[,(port,flag,socket)]: "
127 "specify the socket on which the TX/RX rings for "
128 "the port will be allocated "
129 "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
130 printf(" --socket-num=N: set socket from which all memory is allocated "
132 printf(" --mbuf-size=N: set the data size of mbuf to N bytes.\n");
133 printf(" --total-num-mbufs=N: set the number of mbufs to be allocated "
135 printf(" --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
136 #ifdef RTE_LIBRTE_CMDLINE
137 printf(" --eth-peers-configfile=name: config file with ethernet addresses "
139 printf(" --eth-peer=X,M:M:M:M:M:M: set the MAC address of the X peer "
140 "port (0 <= X < %d).\n", RTE_MAX_ETHPORTS);
142 printf(" --pkt-filter-mode=N: set Flow Director mode "
143 "(N: none (default mode) or signature or perfect).\n");
144 printf(" --pkt-filter-report-hash=N: set Flow Director report mode "
145 "(N: none or match (default) or always).\n");
146 printf(" --pkt-filter-size=N: set Flow Director mode "
147 "(N: 64K (default mode) or 128K or 256K).\n");
148 printf(" --pkt-filter-flexbytes-offset=N: set flexbytes-offset. "
149 "The offset is defined in word units counted from the "
150 "first byte of the destination Ethernet MAC address. "
152 printf(" --pkt-filter-drop-queue=N: set drop-queue. "
153 "In perfect mode, when you add a rule with queue = -1 "
154 "the packet will be enqueued into the rx drop-queue. "
155 "If the drop-queue doesn't exist, the packet is dropped. "
156 "By default drop-queue=127.\n");
157 printf(" --crc-strip: enable CRC stripping by hardware.\n");
158 printf(" --enable-rx-cksum: enable rx hardware checksum offload.\n");
159 printf(" --disable-hw-vlan: disable hardware vlan.\n");
160 printf(" --enable-drop-en: enable per queue packet drop.\n");
161 printf(" --disable-rss: disable rss.\n");
162 printf(" --port-topology=N: set port topology (N: paired (default) or "
164 printf(" --forward-mode=N: set forwarding mode (N: %s).\n",
165 list_pkt_forwarding_modes());
166 printf(" --rss-ip: set RSS functions to IPv4/IPv6 only .\n");
167 printf(" --rss-udp: set RSS functions to IPv4/IPv6 + UDP.\n");
168 printf(" --rxq=N: set the number of RX queues per port to N.\n");
169 printf(" --rxd=N: set the number of descriptors in RX rings to N.\n");
170 printf(" --txq=N: set the number of TX queues per port to N.\n");
171 printf(" --txd=N: set the number of descriptors in TX rings to N.\n");
172 printf(" --burst=N: set the number of packets per burst to N.\n");
173 printf(" --mbcache=N: set the cache of mbuf memory pool to N.\n");
174 printf(" --rxpt=N: set prefetch threshold register of RX rings to N.\n");
175 printf(" --rxht=N: set the host threshold register of RX rings to N.\n");
176 printf(" --rxfreet=N: set the free threshold of RX descriptors to N "
177 "(0 <= N < value of rxd).\n");
178 printf(" --rxwt=N: set the write-back threshold register of RX rings to N.\n");
179 printf(" --txpt=N: set the prefetch threshold register of TX rings to N.\n");
180 printf(" --txht=N: set the nhost threshold register of TX rings to N.\n");
181 printf(" --txwt=N: set the write-back threshold register of TX rings to N.\n");
182 printf(" --txfreet=N: set the transmit free threshold of TX rings to N "
183 "(0 <= N <= value of txd).\n");
184 printf(" --txrst=N: set the transmit RS bit threshold of TX rings to N "
185 "(0 <= N <= value of txd).\n");
186 printf(" --txqflags=0xXXXXXXXX: hexadecimal bitmask of TX queue flags "
187 "(0 <= N <= 0x7FFFFFFF).\n");
188 printf(" --tx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: "
189 "tx queues statistics counters mapping "
190 "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
191 printf(" --rx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: "
192 "rx queues statistics counters mapping "
193 "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
194 printf(" --no-flush-rx: Don't flush RX streams before forwarding."
195 " Used mainly with PCAP drivers.\n");
196 printf(" --txpkts=X[,Y]*: set TX segment sizes.\n");
197 printf(" --disable-link-check: disable check on link status when "
198 "starting/stopping ports.\n");
201 #ifdef RTE_LIBRTE_CMDLINE
203 init_peer_eth_addrs(char *config_filename)
209 config_file = fopen(config_filename, "r");
210 if (config_file == NULL) {
211 perror("Failed to open eth config file\n");
215 for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
217 if (fgets(buf, sizeof(buf), config_file) == NULL)
220 if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i],
221 sizeof(peer_eth_addrs[i])) < 0) {
222 printf("Bad MAC address format on line %d\n", i+1);
228 nb_peer_eth_addrs = (portid_t) i;
234 * Parse the coremask given as argument (hexadecimal string) and set
235 * the global configuration of forwarding cores.
238 parse_fwd_coremask(const char *coremask)
241 unsigned long long int cm;
243 /* parse hexadecimal string */
245 cm = strtoull(coremask, &end, 16);
246 if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0'))
247 rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n");
248 else if (set_fwd_lcores_mask((uint64_t) cm) < 0)
249 rte_exit(EXIT_FAILURE, "coremask is not valid\n");
253 * Parse the coremask given as argument (hexadecimal string) and set
254 * the global configuration of forwarding cores.
257 parse_fwd_portmask(const char *portmask)
260 unsigned long long int pm;
262 /* parse hexadecimal string */
264 pm = strtoull(portmask, &end, 16);
265 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
266 rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n");
268 set_fwd_ports_mask((uint64_t) pm);
273 parse_queue_stats_mapping_config(const char *q_arg, int is_rx)
276 const char *p, *p0 = q_arg;
284 unsigned long int_fld[_NUM_FLD];
285 char *str_fld[_NUM_FLD];
289 /* reset from value set at definition */
290 is_rx ? (nb_rx_queue_stats_mappings = 0) : (nb_tx_queue_stats_mappings = 0);
292 while ((p = strchr(p0,'(')) != NULL) {
294 if((p0 = strchr(p,')')) == NULL)
298 if(size >= sizeof(s))
301 snprintf(s, sizeof(s), "%.*s", size, p);
302 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
304 for (i = 0; i < _NUM_FLD; i++){
306 int_fld[i] = strtoul(str_fld[i], &end, 0);
307 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
310 /* Check mapping field is in correct range (0..RTE_ETHDEV_QUEUE_STAT_CNTRS-1) */
311 if (int_fld[FLD_STATS_COUNTER] >= RTE_ETHDEV_QUEUE_STAT_CNTRS) {
312 printf("Stats counter not in the correct range 0..%d\n",
313 RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
318 if ((nb_tx_queue_stats_mappings >=
319 MAX_TX_QUEUE_STATS_MAPPINGS)) {
320 printf("exceeded max number of TX queue "
321 "statistics mappings: %hu\n",
322 nb_tx_queue_stats_mappings);
325 tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id =
326 (uint8_t)int_fld[FLD_PORT];
327 tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id =
328 (uint8_t)int_fld[FLD_QUEUE];
329 tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].stats_counter_id =
330 (uint8_t)int_fld[FLD_STATS_COUNTER];
331 ++nb_tx_queue_stats_mappings;
334 if ((nb_rx_queue_stats_mappings >=
335 MAX_RX_QUEUE_STATS_MAPPINGS)) {
336 printf("exceeded max number of RX queue "
337 "statistics mappings: %hu\n",
338 nb_rx_queue_stats_mappings);
341 rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id =
342 (uint8_t)int_fld[FLD_PORT];
343 rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id =
344 (uint8_t)int_fld[FLD_QUEUE];
345 rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].stats_counter_id =
346 (uint8_t)int_fld[FLD_STATS_COUNTER];
347 ++nb_rx_queue_stats_mappings;
351 /* Reassign the rx/tx_queue_stats_mappings pointer to point to this newly populated array rather */
352 /* than to the default array (that was set at its definition) */
353 is_rx ? (rx_queue_stats_mappings = rx_queue_stats_mappings_array) :
354 (tx_queue_stats_mappings = tx_queue_stats_mappings_array);
359 parse_portnuma_config(const char *q_arg)
362 const char *p, *p0 = q_arg;
364 uint8_t i,port_id,socket_id;
371 unsigned long int_fld[_NUM_FLD];
372 char *str_fld[_NUM_FLD];
374 /* reset from value set at definition */
375 while ((p = strchr(p0,'(')) != NULL) {
377 if((p0 = strchr(p,')')) == NULL)
381 if(size >= sizeof(s))
384 snprintf(s, sizeof(s), "%.*s", size, p);
385 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
387 for (i = 0; i < _NUM_FLD; i++) {
389 int_fld[i] = strtoul(str_fld[i], &end, 0);
390 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
393 port_id = (uint8_t)int_fld[FLD_PORT];
394 if (port_id >= nb_ports) {
395 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
398 socket_id = (uint8_t)int_fld[FLD_SOCKET];
399 if(socket_id >= MAX_SOCKET) {
400 printf("Invalid socket id, range is [0, %d]\n",
404 port_numa[port_id] = socket_id;
411 parse_ringnuma_config(const char *q_arg)
414 const char *p, *p0 = q_arg;
416 uint8_t i,port_id,ring_flag,socket_id;
424 unsigned long int_fld[_NUM_FLD];
425 char *str_fld[_NUM_FLD];
426 #define RX_RING_ONLY 0x1
427 #define TX_RING_ONLY 0x2
428 #define RXTX_RING 0x3
430 /* reset from value set at definition */
431 while ((p = strchr(p0,'(')) != NULL) {
433 if((p0 = strchr(p,')')) == NULL)
437 if(size >= sizeof(s))
440 snprintf(s, sizeof(s), "%.*s", size, p);
441 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
443 for (i = 0; i < _NUM_FLD; i++) {
445 int_fld[i] = strtoul(str_fld[i], &end, 0);
446 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
449 port_id = (uint8_t)int_fld[FLD_PORT];
450 if (port_id >= nb_ports) {
451 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
454 socket_id = (uint8_t)int_fld[FLD_SOCKET];
455 if (socket_id >= MAX_SOCKET) {
456 printf("Invalid socket id, range is [0, %d]\n",
460 ring_flag = (uint8_t)int_fld[FLD_FLAG];
461 if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) {
462 printf("Invalid ring-flag=%d config for port =%d\n",
467 switch (ring_flag & RXTX_RING) {
469 rxring_numa[port_id] = socket_id;
472 txring_numa[port_id] = socket_id;
475 rxring_numa[port_id] = socket_id;
476 txring_numa[port_id] = socket_id;
479 printf("Invalid ring-flag=%d config for port=%d\n",
489 launch_args_parse(int argc, char** argv)
496 static struct option lgopts[] = {
498 #ifdef RTE_LIBRTE_CMDLINE
499 { "interactive", 0, 0, 0 },
500 { "auto-start", 0, 0, 0 },
501 { "eth-peers-configfile", 1, 0, 0 },
502 { "eth-peer", 1, 0, 0 },
504 { "ports", 1, 0, 0 },
505 { "nb-cores", 1, 0, 0 },
506 { "nb-ports", 1, 0, 0 },
507 { "coremask", 1, 0, 0 },
508 { "portmask", 1, 0, 0 },
510 { "mp-anon", 0, 0, 0 },
511 { "port-numa-config", 1, 0, 0 },
512 { "ring-numa-config", 1, 0, 0 },
513 { "socket-num", 1, 0, 0 },
514 { "mbuf-size", 1, 0, 0 },
515 { "total-num-mbufs", 1, 0, 0 },
516 { "max-pkt-len", 1, 0, 0 },
517 { "pkt-filter-mode", 1, 0, 0 },
518 { "pkt-filter-report-hash", 1, 0, 0 },
519 { "pkt-filter-size", 1, 0, 0 },
520 { "pkt-filter-flexbytes-offset",1, 0, 0 },
521 { "pkt-filter-drop-queue", 1, 0, 0 },
522 { "crc-strip", 0, 0, 0 },
523 { "enable-rx-cksum", 0, 0, 0 },
524 { "disable-hw-vlan", 0, 0, 0 },
525 { "enable-drop-en", 0, 0, 0 },
526 { "disable-rss", 0, 0, 0 },
527 { "port-topology", 1, 0, 0 },
528 { "forward-mode", 1, 0, 0 },
529 { "rss-ip", 0, 0, 0 },
530 { "rss-udp", 0, 0, 0 },
535 { "burst", 1, 0, 0 },
536 { "mbcache", 1, 0, 0 },
540 { "txfreet", 1, 0, 0 },
541 { "txrst", 1, 0, 0 },
542 { "txqflags", 1, 0, 0 },
546 { "rxfreet", 1, 0, 0 },
547 { "tx-queue-stats-mapping", 1, 0, 0 },
548 { "rx-queue-stats-mapping", 1, 0, 0 },
549 { "no-flush-rx", 0, 0, 0 },
550 { "txpkts", 1, 0, 0 },
551 { "disable-link-check", 0, 0, 0 },
557 #ifdef RTE_LIBRTE_CMDLINE
558 #define SHORTOPTS "i"
562 while ((opt = getopt_long(argc, argvopt, SHORTOPTS "ah",
563 lgopts, &opt_idx)) != EOF) {
565 #ifdef RTE_LIBRTE_CMDLINE
567 printf("Interactive-mode selected\n");
572 printf("Auto-start selected\n");
576 case 0: /*long options */
577 if (!strcmp(lgopts[opt_idx].name, "help")) {
579 rte_exit(EXIT_SUCCESS, "Displayed help\n");
581 #ifdef RTE_LIBRTE_CMDLINE
582 if (!strcmp(lgopts[opt_idx].name, "interactive")) {
583 printf("Interactive-mode selected\n");
586 if (!strcmp(lgopts[opt_idx].name, "auto-start")) {
587 printf("Auto-start selected\n");
590 if (!strcmp(lgopts[opt_idx].name,
591 "eth-peers-configfile")) {
592 if (init_peer_eth_addrs(optarg) != 0)
593 rte_exit(EXIT_FAILURE,
594 "Cannot open logfile\n");
596 if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
598 uint8_t c, peer_addr[6];
601 n = strtoul(optarg, &port_end, 10);
602 if (errno != 0 || port_end == optarg || *port_end++ != ',')
603 rte_exit(EXIT_FAILURE,
604 "Invalid eth-peer: %s", optarg);
605 if (n >= RTE_MAX_ETHPORTS)
606 rte_exit(EXIT_FAILURE,
607 "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n",
608 n, RTE_MAX_ETHPORTS);
610 if (cmdline_parse_etheraddr(NULL, port_end,
611 &peer_addr, sizeof(peer_addr)) < 0)
612 rte_exit(EXIT_FAILURE,
613 "Invalid ethernet address: %s\n",
615 for (c = 0; c < 6; c++)
616 peer_eth_addrs[n].addr_bytes[c] =
621 if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
623 if (n > 0 && n <= nb_ports)
624 nb_fwd_ports = (uint8_t) n;
626 rte_exit(EXIT_FAILURE,
627 "nb-ports should be > 0 and <= %d\n",
630 if (!strcmp(lgopts[opt_idx].name, "nb-cores")) {
632 if (n > 0 && n <= nb_lcores)
633 nb_fwd_lcores = (uint8_t) n;
635 rte_exit(EXIT_FAILURE,
636 "nb-cores should be > 0 and <= %d\n",
639 if (!strcmp(lgopts[opt_idx].name, "coremask"))
640 parse_fwd_coremask(optarg);
641 if (!strcmp(lgopts[opt_idx].name, "portmask"))
642 parse_fwd_portmask(optarg);
643 if (!strcmp(lgopts[opt_idx].name, "numa")) {
645 memset(port_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS);
646 memset(rxring_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS);
647 memset(txring_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS);
649 if (!strcmp(lgopts[opt_idx].name, "mp-anon")) {
652 if (!strcmp(lgopts[opt_idx].name, "port-numa-config")) {
653 if (parse_portnuma_config(optarg))
654 rte_exit(EXIT_FAILURE,
655 "invalid port-numa configuration\n");
657 if (!strcmp(lgopts[opt_idx].name, "ring-numa-config"))
658 if (parse_ringnuma_config(optarg))
659 rte_exit(EXIT_FAILURE,
660 "invalid ring-numa configuration\n");
661 if (!strcmp(lgopts[opt_idx].name, "socket-num")) {
664 socket_num = (uint8_t)n;
666 rte_exit(EXIT_FAILURE,
667 "The socket number should be < %d\n",
670 if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
672 if (n > 0 && n <= 0xFFFF)
673 mbuf_data_size = (uint16_t) n;
675 rte_exit(EXIT_FAILURE,
676 "mbuf-size should be > 0 and < 65536\n");
678 if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
681 param_total_num_mbufs = (unsigned)n;
683 rte_exit(EXIT_FAILURE,
684 "total-num-mbufs should be > 1024\n");
686 if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
688 if (n >= ETHER_MIN_LEN) {
689 rx_mode.max_rx_pkt_len = (uint32_t) n;
690 if (n > ETHER_MAX_LEN)
691 rx_mode.jumbo_frame = 1;
693 rte_exit(EXIT_FAILURE,
694 "Invalid max-pkt-len=%d - should be > %d\n",
697 if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) {
698 if (!strcmp(optarg, "signature"))
700 RTE_FDIR_MODE_SIGNATURE;
701 else if (!strcmp(optarg, "perfect"))
702 fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
703 else if (!strcmp(optarg, "none"))
704 fdir_conf.mode = RTE_FDIR_MODE_NONE;
706 rte_exit(EXIT_FAILURE,
707 "pkt-mode-invalid %s invalid - must be: "
708 "none, signature or perfect\n",
711 if (!strcmp(lgopts[opt_idx].name,
712 "pkt-filter-report-hash")) {
713 if (!strcmp(optarg, "none"))
715 RTE_FDIR_NO_REPORT_STATUS;
716 else if (!strcmp(optarg, "match"))
718 RTE_FDIR_REPORT_STATUS;
719 else if (!strcmp(optarg, "always"))
721 RTE_FDIR_REPORT_STATUS_ALWAYS;
723 rte_exit(EXIT_FAILURE,
724 "pkt-filter-report-hash %s invalid "
725 "- must be: none or match or always\n",
728 if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) {
729 if (!strcmp(optarg, "64K"))
731 RTE_FDIR_PBALLOC_64K;
732 else if (!strcmp(optarg, "128K"))
734 RTE_FDIR_PBALLOC_128K;
735 else if (!strcmp(optarg, "256K"))
737 RTE_FDIR_PBALLOC_256K;
739 rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -"
740 " must be: 64K or 128K or 256K\n",
743 if (!strcmp(lgopts[opt_idx].name,
744 "pkt-filter-flexbytes-offset")) {
746 if ( n >= 0 && n <= (int) 32)
747 fdir_conf.flexbytes_offset =
750 rte_exit(EXIT_FAILURE,
751 "flexbytes %d invalid - must"
752 "be >= 0 && <= 32\n", n);
754 if (!strcmp(lgopts[opt_idx].name,
755 "pkt-filter-drop-queue")) {
758 fdir_conf.drop_queue = (uint8_t) n;
760 rte_exit(EXIT_FAILURE,
761 "drop queue %d invalid - must"
764 if (!strcmp(lgopts[opt_idx].name, "crc-strip"))
765 rx_mode.hw_strip_crc = 1;
766 if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
767 rx_mode.hw_ip_checksum = 1;
769 if (!strcmp(lgopts[opt_idx].name, "disable-hw-vlan")) {
770 rx_mode.hw_vlan_filter = 0;
771 rx_mode.hw_vlan_strip = 0;
772 rx_mode.hw_vlan_extend = 0;
775 if (!strcmp(lgopts[opt_idx].name, "enable-drop-en"))
778 if (!strcmp(lgopts[opt_idx].name, "disable-rss"))
780 if (!strcmp(lgopts[opt_idx].name, "port-topology")) {
781 if (!strcmp(optarg, "paired"))
782 port_topology = PORT_TOPOLOGY_PAIRED;
783 else if (!strcmp(optarg, "chained"))
784 port_topology = PORT_TOPOLOGY_CHAINED;
785 else if (!strcmp(optarg, "loop"))
786 port_topology = PORT_TOPOLOGY_LOOP;
788 rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
789 " must be: paired or chained \n",
792 if (!strcmp(lgopts[opt_idx].name, "forward-mode"))
793 set_pkt_forwarding_mode(optarg);
794 if (!strcmp(lgopts[opt_idx].name, "rss-ip"))
796 if (!strcmp(lgopts[opt_idx].name, "rss-udp"))
797 rss_hf = ETH_RSS_UDP;
798 if (!strcmp(lgopts[opt_idx].name, "rxq")) {
800 if (n >= 1 && n <= (int) MAX_QUEUE_ID)
801 nb_rxq = (queueid_t) n;
803 rte_exit(EXIT_FAILURE, "rxq %d invalid - must be"
804 " >= 1 && <= %d\n", n,
807 if (!strcmp(lgopts[opt_idx].name, "txq")) {
809 if (n >= 1 && n <= (int) MAX_QUEUE_ID)
810 nb_txq = (queueid_t) n;
812 rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
813 " >= 1 && <= %d\n", n,
816 if (!strcmp(lgopts[opt_idx].name, "burst")) {
818 if ((n >= 1) && (n <= MAX_PKT_BURST))
819 nb_pkt_per_burst = (uint16_t) n;
821 rte_exit(EXIT_FAILURE,
822 "burst must >= 1 and <= %d]",
825 if (!strcmp(lgopts[opt_idx].name, "mbcache")) {
828 (n <= RTE_MEMPOOL_CACHE_MAX_SIZE))
829 mb_mempool_cache = (uint16_t) n;
831 rte_exit(EXIT_FAILURE,
832 "mbcache must be >= 0 and <= %d\n",
833 RTE_MEMPOOL_CACHE_MAX_SIZE);
835 if (!strcmp(lgopts[opt_idx].name, "txfreet")) {
838 tx_free_thresh = (int16_t)n;
840 rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n");
842 if (!strcmp(lgopts[opt_idx].name, "txrst")) {
845 tx_rs_thresh = (int16_t)n;
847 rte_exit(EXIT_FAILURE, "txrst must be >= 0\n");
849 if (!strcmp(lgopts[opt_idx].name, "txqflags")) {
851 n = strtoul(optarg, &end, 16);
853 txq_flags = (int32_t)n;
855 rte_exit(EXIT_FAILURE,
856 "txqflags must be >= 0\n");
858 if (!strcmp(lgopts[opt_idx].name, "rxd")) {
861 if (rx_free_thresh >= n)
862 rte_exit(EXIT_FAILURE,
864 "rx_free_thresh(%d)\n",
865 (int)rx_free_thresh);
867 nb_rxd = (uint16_t) n;
869 rte_exit(EXIT_FAILURE,
870 "rxd(%d) invalid - must be > 0\n",
873 if (!strcmp(lgopts[opt_idx].name, "txd")) {
876 nb_txd = (uint16_t) n;
878 rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
880 if (!strcmp(lgopts[opt_idx].name, "txpt")) {
883 tx_pthresh = (int8_t)n;
885 rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
887 if (!strcmp(lgopts[opt_idx].name, "txht")) {
890 tx_hthresh = (int8_t)n;
892 rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
894 if (!strcmp(lgopts[opt_idx].name, "txwt")) {
897 tx_wthresh = (int8_t)n;
899 rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
901 if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
904 rx_pthresh = (int8_t)n;
906 rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
908 if (!strcmp(lgopts[opt_idx].name, "rxht")) {
911 rx_hthresh = (int8_t)n;
913 rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
915 if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
918 rx_wthresh = (int8_t)n;
920 rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
922 if (!strcmp(lgopts[opt_idx].name, "rxfreet")) {
925 rx_free_thresh = (int16_t)n;
927 rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n");
929 if (!strcmp(lgopts[opt_idx].name, "tx-queue-stats-mapping")) {
930 if (parse_queue_stats_mapping_config(optarg, TX)) {
931 rte_exit(EXIT_FAILURE,
932 "invalid TX queue statistics mapping config entered\n");
935 if (!strcmp(lgopts[opt_idx].name, "rx-queue-stats-mapping")) {
936 if (parse_queue_stats_mapping_config(optarg, RX)) {
937 rte_exit(EXIT_FAILURE,
938 "invalid RX queue statistics mapping config entered\n");
941 if (!strcmp(lgopts[opt_idx].name, "txpkts")) {
942 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
943 unsigned int nb_segs;
945 nb_segs = parse_item_list(optarg, "txpkt segments",
946 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
948 set_tx_pkt_segments(seg_lengths, nb_segs);
950 rte_exit(EXIT_FAILURE, "bad txpkts\n");
952 if (!strcmp(lgopts[opt_idx].name, "no-flush-rx"))
954 if (!strcmp(lgopts[opt_idx].name, "disable-link-check"))
960 rte_exit(EXIT_SUCCESS, "Displayed help\n");
964 rte_exit(EXIT_FAILURE,
965 "Command line is incomplete or incorrect\n");