app/testpmd: add --flow-isolate-all option
[dpdk.git] / app / test-pmd / parameters.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2017 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 #include <errno.h>
35 #include <getopt.h>
36 #include <stdarg.h>
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <signal.h>
40 #include <string.h>
41 #include <time.h>
42 #include <fcntl.h>
43 #include <sys/types.h>
44 #include <errno.h>
45
46 #include <sys/queue.h>
47 #include <sys/stat.h>
48
49 #include <stdint.h>
50 #include <unistd.h>
51 #include <inttypes.h>
52
53 #include <rte_common.h>
54 #include <rte_byteorder.h>
55 #include <rte_log.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_eal.h>
62 #include <rte_per_lcore.h>
63 #include <rte_lcore.h>
64 #include <rte_atomic.h>
65 #include <rte_branch_prediction.h>
66 #include <rte_mempool.h>
67 #include <rte_interrupts.h>
68 #include <rte_pci.h>
69 #include <rte_ether.h>
70 #include <rte_ethdev.h>
71 #include <rte_string_fns.h>
72 #ifdef RTE_LIBRTE_CMDLINE
73 #include <cmdline_parse.h>
74 #include <cmdline_parse_etheraddr.h>
75 #endif
76 #ifdef RTE_LIBRTE_PMD_BOND
77 #include <rte_eth_bond.h>
78 #endif
79 #include <rte_flow.h>
80
81 #include "testpmd.h"
82
83 static void
84 usage(char* progname)
85 {
86         printf("usage: %s "
87 #ifdef RTE_LIBRTE_CMDLINE
88                "[--interactive|-i] "
89                "[--cmdline-file=FILENAME] "
90 #endif
91                "[--help|-h] | [--auto-start|-a] | ["
92                "--tx-first | --stats-period=PERIOD | "
93                "--coremask=COREMASK --portmask=PORTMASK --numa "
94                "--mbuf-size= | --total-num-mbufs= | "
95                "--nb-cores= | --nb-ports= | "
96 #ifdef RTE_LIBRTE_CMDLINE
97                "--eth-peers-configfile= | "
98                "--eth-peer=X,M:M:M:M:M:M | "
99 #endif
100                "--pkt-filter-mode= |"
101                "--rss-ip | --rss-udp | "
102                "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
103                "--txpt= | --txht= | --txwt= | --txfreet= | "
104                "--txrst= | --txqflags= ]\n",
105                progname);
106 #ifdef RTE_LIBRTE_CMDLINE
107         printf("  --interactive: run in interactive mode.\n");
108         printf("  --cmdline-file: execute cli commands before startup.\n");
109 #endif
110         printf("  --auto-start: start forwarding on init "
111                "[always when non-interactive].\n");
112         printf("  --help: display this message and quit.\n");
113         printf("  --tx-first: start forwarding sending a burst first "
114                "(only if interactive is disabled).\n");
115         printf("  --stats-period=PERIOD: statistics will be shown "
116                "every PERIOD seconds (only if interactive is disabled).\n");
117         printf("  --nb-cores=N: set the number of forwarding cores "
118                "(1 <= N <= %d).\n", nb_lcores);
119         printf("  --nb-ports=N: set the number of forwarding ports "
120                "(1 <= N <= %d).\n", nb_ports);
121         printf("  --coremask=COREMASK: hexadecimal bitmask of cores running "
122                "the packet forwarding test. The master lcore is reserved for "
123                "command line parsing only, and cannot be masked on for "
124                "packet forwarding.\n");
125         printf("  --portmask=PORTMASK: hexadecimal bitmask of ports used "
126                "by the packet forwarding test.\n");
127         printf("  --numa: enable NUMA-aware allocation of RX/TX rings and of "
128                "RX memory buffers (mbufs).\n");
129         printf("  --port-numa-config=(port,socket)[,(port,socket)]: "
130                "specify the socket on which the memory pool "
131                "used by the port will be allocated.\n");
132         printf("  --ring-numa-config=(port,flag,socket)[,(port,flag,socket)]: "
133                "specify the socket on which the TX/RX rings for "
134                "the port will be allocated "
135                "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
136         printf("  --socket-num=N: set socket from which all memory is allocated "
137                "in NUMA mode.\n");
138         printf("  --mbuf-size=N: set the data size of mbuf to N bytes.\n");
139         printf("  --total-num-mbufs=N: set the number of mbufs to be allocated "
140                "in mbuf pools.\n");
141         printf("  --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
142 #ifdef RTE_LIBRTE_CMDLINE
143         printf("  --eth-peers-configfile=name: config file with ethernet addresses "
144                "of peer ports.\n");
145         printf("  --eth-peer=X,M:M:M:M:M:M: set the MAC address of the X peer "
146                "port (0 <= X < %d).\n", RTE_MAX_ETHPORTS);
147 #endif
148         printf("  --pkt-filter-mode=N: set Flow Director mode "
149                "(N: none (default mode) or signature or perfect).\n");
150         printf("  --pkt-filter-report-hash=N: set Flow Director report mode "
151                "(N: none  or match (default) or always).\n");
152         printf("  --pkt-filter-size=N: set Flow Director mode "
153                "(N: 64K (default mode) or 128K or 256K).\n");
154         printf("  --pkt-filter-drop-queue=N: set drop-queue. "
155                "In perfect mode, when you add a rule with queue = -1 "
156                "the packet will be enqueued into the rx drop-queue. "
157                "If the drop-queue doesn't exist, the packet is dropped. "
158                "By default drop-queue=127.\n");
159 #ifdef RTE_LIBRTE_LATENCY_STATS
160         printf("  --latencystats=N: enable latency and jitter statistcs "
161                "monitoring on forwarding lcore id N.\n");
162 #endif
163         printf("  --disable-crc-strip: disable CRC stripping by hardware.\n");
164         printf("  --enable-lro: enable large receive offload.\n");
165         printf("  --enable-rx-cksum: enable rx hardware checksum offload.\n");
166         printf("  --disable-hw-vlan: disable hardware vlan.\n");
167         printf("  --disable-hw-vlan-filter: disable hardware vlan filter.\n");
168         printf("  --disable-hw-vlan-strip: disable hardware vlan strip.\n");
169         printf("  --disable-hw-vlan-extend: disable hardware vlan extend.\n");
170         printf("  --enable-drop-en: enable per queue packet drop.\n");
171         printf("  --disable-rss: disable rss.\n");
172         printf("  --port-topology=N: set port topology (N: paired (default) or "
173                "chained).\n");
174         printf("  --forward-mode=N: set forwarding mode (N: %s).\n",
175                list_pkt_forwarding_modes());
176         printf("  --rss-ip: set RSS functions to IPv4/IPv6 only .\n");
177         printf("  --rss-udp: set RSS functions to IPv4/IPv6 + UDP.\n");
178         printf("  --rxq=N: set the number of RX queues per port to N.\n");
179         printf("  --rxd=N: set the number of descriptors in RX rings to N.\n");
180         printf("  --txq=N: set the number of TX queues per port to N.\n");
181         printf("  --txd=N: set the number of descriptors in TX rings to N.\n");
182         printf("  --burst=N: set the number of packets per burst to N.\n");
183         printf("  --mbcache=N: set the cache of mbuf memory pool to N.\n");
184         printf("  --rxpt=N: set prefetch threshold register of RX rings to N.\n");
185         printf("  --rxht=N: set the host threshold register of RX rings to N.\n");
186         printf("  --rxfreet=N: set the free threshold of RX descriptors to N "
187                "(0 <= N < value of rxd).\n");
188         printf("  --rxwt=N: set the write-back threshold register of RX rings to N.\n");
189         printf("  --txpt=N: set the prefetch threshold register of TX rings to N.\n");
190         printf("  --txht=N: set the nhost threshold register of TX rings to N.\n");
191         printf("  --txwt=N: set the write-back threshold register of TX rings to N.\n");
192         printf("  --txfreet=N: set the transmit free threshold of TX rings to N "
193                "(0 <= N <= value of txd).\n");
194         printf("  --txrst=N: set the transmit RS bit threshold of TX rings to N "
195                "(0 <= N <= value of txd).\n");
196         printf("  --txqflags=0xXXXXXXXX: hexadecimal bitmask of TX queue flags "
197                "(0 <= N <= 0x7FFFFFFF).\n");
198         printf("  --tx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: "
199                "tx queues statistics counters mapping "
200                "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
201         printf("  --rx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: "
202                "rx queues statistics counters mapping "
203                "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
204         printf("  --no-flush-rx: Don't flush RX streams before forwarding."
205                " Used mainly with PCAP drivers.\n");
206         printf("  --txpkts=X[,Y]*: set TX segment sizes"
207                 " or total packet length.\n");
208         printf("  --disable-link-check: disable check on link status when "
209                "starting/stopping ports.\n");
210         printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
211         printf("  --no-rmv-interrupt: disable device removal interrupt.\n");
212         printf("  --bitrate-stats=N: set the logical core N to perform "
213                 "bit-rate calculation.\n");
214         printf("  --print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>: "
215                "enable print of designated event or all of them.");
216         printf("  --mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>: "
217                "disable print of designated event or all of them.");
218         printf("  --flow-isolate-all: "
219                "requests flow API isolated mode on all ports at initialization time.");
220 }
221
222 #ifdef RTE_LIBRTE_CMDLINE
223 static int
224 init_peer_eth_addrs(char *config_filename)
225 {
226         FILE *config_file;
227         portid_t i;
228         char buf[50];
229
230         config_file = fopen(config_filename, "r");
231         if (config_file == NULL) {
232                 perror("Failed to open eth config file\n");
233                 return -1;
234         }
235
236         for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
237
238                 if (fgets(buf, sizeof(buf), config_file) == NULL)
239                         break;
240
241                 if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i],
242                                 sizeof(peer_eth_addrs[i])) < 0) {
243                         printf("Bad MAC address format on line %d\n", i+1);
244                         fclose(config_file);
245                         return -1;
246                 }
247         }
248         fclose(config_file);
249         nb_peer_eth_addrs = (portid_t) i;
250         return 0;
251 }
252 #endif
253
254 /*
255  * Parse the coremask given as argument (hexadecimal string) and set
256  * the global configuration of forwarding cores.
257  */
258 static void
259 parse_fwd_coremask(const char *coremask)
260 {
261         char *end;
262         unsigned long long int cm;
263
264         /* parse hexadecimal string */
265         end = NULL;
266         cm = strtoull(coremask, &end, 16);
267         if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0'))
268                 rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n");
269         else if (set_fwd_lcores_mask((uint64_t) cm) < 0)
270                 rte_exit(EXIT_FAILURE, "coremask is not valid\n");
271 }
272
273 /*
274  * Parse the coremask given as argument (hexadecimal string) and set
275  * the global configuration of forwarding cores.
276  */
277 static void
278 parse_fwd_portmask(const char *portmask)
279 {
280         char *end;
281         unsigned long long int pm;
282
283         /* parse hexadecimal string */
284         end = NULL;
285         pm = strtoull(portmask, &end, 16);
286         if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
287                 rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n");
288         else
289                 set_fwd_ports_mask((uint64_t) pm);
290 }
291
292
293 static int
294 parse_queue_stats_mapping_config(const char *q_arg, int is_rx)
295 {
296         char s[256];
297         const char *p, *p0 = q_arg;
298         char *end;
299         enum fieldnames {
300                 FLD_PORT = 0,
301                 FLD_QUEUE,
302                 FLD_STATS_COUNTER,
303                 _NUM_FLD
304         };
305         unsigned long int_fld[_NUM_FLD];
306         char *str_fld[_NUM_FLD];
307         int i;
308         unsigned size;
309
310         /* reset from value set at definition */
311         is_rx ? (nb_rx_queue_stats_mappings = 0) : (nb_tx_queue_stats_mappings = 0);
312
313         while ((p = strchr(p0,'(')) != NULL) {
314                 ++p;
315                 if((p0 = strchr(p,')')) == NULL)
316                         return -1;
317
318                 size = p0 - p;
319                 if(size >= sizeof(s))
320                         return -1;
321
322                 snprintf(s, sizeof(s), "%.*s", size, p);
323                 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
324                         return -1;
325                 for (i = 0; i < _NUM_FLD; i++){
326                         errno = 0;
327                         int_fld[i] = strtoul(str_fld[i], &end, 0);
328                         if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
329                                 return -1;
330                 }
331                 /* Check mapping field is in correct range (0..RTE_ETHDEV_QUEUE_STAT_CNTRS-1) */
332                 if (int_fld[FLD_STATS_COUNTER] >= RTE_ETHDEV_QUEUE_STAT_CNTRS) {
333                         printf("Stats counter not in the correct range 0..%d\n",
334                                         RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
335                         return -1;
336                 }
337
338                 if (!is_rx) {
339                         if ((nb_tx_queue_stats_mappings >=
340                                                 MAX_TX_QUEUE_STATS_MAPPINGS)) {
341                                 printf("exceeded max number of TX queue "
342                                                 "statistics mappings: %hu\n",
343                                                 nb_tx_queue_stats_mappings);
344                                 return -1;
345                         }
346                         tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id =
347                                 (uint8_t)int_fld[FLD_PORT];
348                         tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id =
349                                 (uint8_t)int_fld[FLD_QUEUE];
350                         tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].stats_counter_id =
351                                 (uint8_t)int_fld[FLD_STATS_COUNTER];
352                         ++nb_tx_queue_stats_mappings;
353                 }
354                 else {
355                         if ((nb_rx_queue_stats_mappings >=
356                                                 MAX_RX_QUEUE_STATS_MAPPINGS)) {
357                                 printf("exceeded max number of RX queue "
358                                                 "statistics mappings: %hu\n",
359                                                 nb_rx_queue_stats_mappings);
360                                 return -1;
361                         }
362                         rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id =
363                                 (uint8_t)int_fld[FLD_PORT];
364                         rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id =
365                                 (uint8_t)int_fld[FLD_QUEUE];
366                         rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].stats_counter_id =
367                                 (uint8_t)int_fld[FLD_STATS_COUNTER];
368                         ++nb_rx_queue_stats_mappings;
369                 }
370
371         }
372 /* Reassign the rx/tx_queue_stats_mappings pointer to point to this newly populated array rather */
373 /* than to the default array (that was set at its definition) */
374         is_rx ? (rx_queue_stats_mappings = rx_queue_stats_mappings_array) :
375                 (tx_queue_stats_mappings = tx_queue_stats_mappings_array);
376         return 0;
377 }
378
379 static void
380 print_invalid_socket_id_error(void)
381 {
382         unsigned int i = 0;
383
384         printf("Invalid socket id, options are: ");
385         for (i = 0; i < num_sockets; i++) {
386                 printf("%u%s", socket_ids[i],
387                       (i == num_sockets - 1) ? "\n" : ",");
388         }
389 }
390
391 static int
392 parse_portnuma_config(const char *q_arg)
393 {
394         char s[256];
395         const char *p, *p0 = q_arg;
396         char *end;
397         uint8_t i,port_id,socket_id;
398         unsigned size;
399         enum fieldnames {
400                 FLD_PORT = 0,
401                 FLD_SOCKET,
402                 _NUM_FLD
403         };
404         unsigned long int_fld[_NUM_FLD];
405         char *str_fld[_NUM_FLD];
406         portid_t pid;
407
408         /* reset from value set at definition */
409         while ((p = strchr(p0,'(')) != NULL) {
410                 ++p;
411                 if((p0 = strchr(p,')')) == NULL)
412                         return -1;
413
414                 size = p0 - p;
415                 if(size >= sizeof(s))
416                         return -1;
417
418                 snprintf(s, sizeof(s), "%.*s", size, p);
419                 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
420                         return -1;
421                 for (i = 0; i < _NUM_FLD; i++) {
422                         errno = 0;
423                         int_fld[i] = strtoul(str_fld[i], &end, 0);
424                         if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
425                                 return -1;
426                 }
427                 port_id = (uint8_t)int_fld[FLD_PORT];
428                 if (port_id_is_invalid(port_id, ENABLED_WARN)) {
429                         printf("Valid port range is [0");
430                         RTE_ETH_FOREACH_DEV(pid)
431                                 printf(", %d", pid);
432                         printf("]\n");
433                         return -1;
434                 }
435                 socket_id = (uint8_t)int_fld[FLD_SOCKET];
436                 if (new_socket_id(socket_id)) {
437                         print_invalid_socket_id_error();
438                         return -1;
439                 }
440                 port_numa[port_id] = socket_id;
441         }
442
443         return 0;
444 }
445
446 static int
447 parse_ringnuma_config(const char *q_arg)
448 {
449         char s[256];
450         const char *p, *p0 = q_arg;
451         char *end;
452         uint8_t i,port_id,ring_flag,socket_id;
453         unsigned size;
454         enum fieldnames {
455                 FLD_PORT = 0,
456                 FLD_FLAG,
457                 FLD_SOCKET,
458                 _NUM_FLD
459         };
460         unsigned long int_fld[_NUM_FLD];
461         char *str_fld[_NUM_FLD];
462         portid_t pid;
463         #define RX_RING_ONLY 0x1
464         #define TX_RING_ONLY 0x2
465         #define RXTX_RING    0x3
466
467         /* reset from value set at definition */
468         while ((p = strchr(p0,'(')) != NULL) {
469                 ++p;
470                 if((p0 = strchr(p,')')) == NULL)
471                         return -1;
472
473                 size = p0 - p;
474                 if(size >= sizeof(s))
475                         return -1;
476
477                 snprintf(s, sizeof(s), "%.*s", size, p);
478                 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
479                         return -1;
480                 for (i = 0; i < _NUM_FLD; i++) {
481                         errno = 0;
482                         int_fld[i] = strtoul(str_fld[i], &end, 0);
483                         if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
484                                 return -1;
485                 }
486                 port_id = (uint8_t)int_fld[FLD_PORT];
487                 if (port_id_is_invalid(port_id, ENABLED_WARN)) {
488                         printf("Valid port range is [0");
489                         RTE_ETH_FOREACH_DEV(pid)
490                                 printf(", %d", pid);
491                         printf("]\n");
492                         return -1;
493                 }
494                 socket_id = (uint8_t)int_fld[FLD_SOCKET];
495                 if (new_socket_id(socket_id)) {
496                         print_invalid_socket_id_error();
497                         return -1;
498                 }
499                 ring_flag = (uint8_t)int_fld[FLD_FLAG];
500                 if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) {
501                         printf("Invalid ring-flag=%d config for port =%d\n",
502                                 ring_flag,port_id);
503                         return -1;
504                 }
505
506                 switch (ring_flag & RXTX_RING) {
507                 case RX_RING_ONLY:
508                         rxring_numa[port_id] = socket_id;
509                         break;
510                 case TX_RING_ONLY:
511                         txring_numa[port_id] = socket_id;
512                         break;
513                 case RXTX_RING:
514                         rxring_numa[port_id] = socket_id;
515                         txring_numa[port_id] = socket_id;
516                         break;
517                 default:
518                         printf("Invalid ring-flag=%d config for port=%d\n",
519                                 ring_flag,port_id);
520                         break;
521                 }
522         }
523
524         return 0;
525 }
526
527 static int
528 parse_event_printing_config(const char *optarg, int enable)
529 {
530         uint32_t mask = 0;
531
532         if (!strcmp(optarg, "unknown"))
533                 mask = UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN;
534         else if (!strcmp(optarg, "intr_lsc"))
535                 mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_LSC;
536         else if (!strcmp(optarg, "queue_state"))
537                 mask = UINT32_C(1) << RTE_ETH_EVENT_QUEUE_STATE;
538         else if (!strcmp(optarg, "intr_reset"))
539                 mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET;
540         else if (!strcmp(optarg, "vf_mbox"))
541                 mask = UINT32_C(1) << RTE_ETH_EVENT_VF_MBOX;
542         else if (!strcmp(optarg, "macsec"))
543                 mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
544         else if (!strcmp(optarg, "intr_rmv"))
545                 mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
546         else if (!strcmp(optarg, "all"))
547                 mask = ~UINT32_C(0);
548         else {
549                 fprintf(stderr, "Invalid event: %s\n", optarg);
550                 return -1;
551         }
552         if (enable)
553                 event_print_mask |= mask;
554         else
555                 event_print_mask &= ~mask;
556         return 0;
557 }
558
559 void
560 launch_args_parse(int argc, char** argv)
561 {
562         int n, opt;
563         char **argvopt;
564         int opt_idx;
565         enum { TX, RX };
566
567         static struct option lgopts[] = {
568                 { "help",                       0, 0, 0 },
569 #ifdef RTE_LIBRTE_CMDLINE
570                 { "interactive",                0, 0, 0 },
571                 { "cmdline-file",               1, 0, 0 },
572                 { "auto-start",                 0, 0, 0 },
573                 { "eth-peers-configfile",       1, 0, 0 },
574                 { "eth-peer",                   1, 0, 0 },
575 #endif
576                 { "tx-first",                   0, 0, 0 },
577                 { "stats-period",               1, 0, 0 },
578                 { "ports",                      1, 0, 0 },
579                 { "nb-cores",                   1, 0, 0 },
580                 { "nb-ports",                   1, 0, 0 },
581                 { "coremask",                   1, 0, 0 },
582                 { "portmask",                   1, 0, 0 },
583                 { "numa",                       0, 0, 0 },
584                 { "no-numa",                    0, 0, 0 },
585                 { "mp-anon",                    0, 0, 0 },
586                 { "port-numa-config",           1, 0, 0 },
587                 { "ring-numa-config",           1, 0, 0 },
588                 { "socket-num",                 1, 0, 0 },
589                 { "mbuf-size",                  1, 0, 0 },
590                 { "total-num-mbufs",            1, 0, 0 },
591                 { "max-pkt-len",                1, 0, 0 },
592                 { "pkt-filter-mode",            1, 0, 0 },
593                 { "pkt-filter-report-hash",     1, 0, 0 },
594                 { "pkt-filter-size",            1, 0, 0 },
595                 { "pkt-filter-drop-queue",      1, 0, 0 },
596 #ifdef RTE_LIBRTE_LATENCY_STATS
597                 { "latencystats",               1, 0, 0 },
598 #endif
599 #ifdef RTE_LIBRTE_BITRATE
600                 { "bitrate-stats",              1, 0, 0 },
601 #endif
602                 { "disable-crc-strip",          0, 0, 0 },
603                 { "enable-lro",                 0, 0, 0 },
604                 { "enable-rx-cksum",            0, 0, 0 },
605                 { "enable-scatter",             0, 0, 0 },
606                 { "disable-hw-vlan",            0, 0, 0 },
607                 { "disable-hw-vlan-filter",     0, 0, 0 },
608                 { "disable-hw-vlan-strip",      0, 0, 0 },
609                 { "disable-hw-vlan-extend",     0, 0, 0 },
610                 { "enable-drop-en",            0, 0, 0 },
611                 { "disable-rss",                0, 0, 0 },
612                 { "port-topology",              1, 0, 0 },
613                 { "forward-mode",               1, 0, 0 },
614                 { "rss-ip",                     0, 0, 0 },
615                 { "rss-udp",                    0, 0, 0 },
616                 { "rxq",                        1, 0, 0 },
617                 { "txq",                        1, 0, 0 },
618                 { "rxd",                        1, 0, 0 },
619                 { "txd",                        1, 0, 0 },
620                 { "burst",                      1, 0, 0 },
621                 { "mbcache",                    1, 0, 0 },
622                 { "txpt",                       1, 0, 0 },
623                 { "txht",                       1, 0, 0 },
624                 { "txwt",                       1, 0, 0 },
625                 { "txfreet",                    1, 0, 0 },
626                 { "txrst",                      1, 0, 0 },
627                 { "txqflags",                   1, 0, 0 },
628                 { "rxpt",                       1, 0, 0 },
629                 { "rxht",                       1, 0, 0 },
630                 { "rxwt",                       1, 0, 0 },
631                 { "rxfreet",                    1, 0, 0 },
632                 { "tx-queue-stats-mapping",     1, 0, 0 },
633                 { "rx-queue-stats-mapping",     1, 0, 0 },
634                 { "no-flush-rx",        0, 0, 0 },
635                 { "flow-isolate-all",           0, 0, 0 },
636                 { "txpkts",                     1, 0, 0 },
637                 { "disable-link-check",         0, 0, 0 },
638                 { "no-lsc-interrupt",           0, 0, 0 },
639                 { "no-rmv-interrupt",           0, 0, 0 },
640                 { "print-event",                1, 0, 0 },
641                 { "mask-event",                 1, 0, 0 },
642                 { 0, 0, 0, 0 },
643         };
644
645         argvopt = argv;
646
647 #ifdef RTE_LIBRTE_CMDLINE
648 #define SHORTOPTS "i"
649 #else
650 #define SHORTOPTS ""
651 #endif
652         while ((opt = getopt_long(argc, argvopt, SHORTOPTS "ah",
653                                  lgopts, &opt_idx)) != EOF) {
654                 switch (opt) {
655 #ifdef RTE_LIBRTE_CMDLINE
656                 case 'i':
657                         printf("Interactive-mode selected\n");
658                         interactive = 1;
659                         break;
660 #endif
661                 case 'a':
662                         printf("Auto-start selected\n");
663                         auto_start = 1;
664                         break;
665
666                 case 0: /*long options */
667                         if (!strcmp(lgopts[opt_idx].name, "help")) {
668                                 usage(argv[0]);
669                                 rte_exit(EXIT_SUCCESS, "Displayed help\n");
670                         }
671 #ifdef RTE_LIBRTE_CMDLINE
672                         if (!strcmp(lgopts[opt_idx].name, "interactive")) {
673                                 printf("Interactive-mode selected\n");
674                                 interactive = 1;
675                         }
676                         if (!strcmp(lgopts[opt_idx].name, "cmdline-file")) {
677                                 printf("CLI commands to be read from %s\n",
678                                        optarg);
679                                 snprintf(cmdline_filename,
680                                          sizeof(cmdline_filename), "%s",
681                                          optarg);
682                         }
683                         if (!strcmp(lgopts[opt_idx].name, "auto-start")) {
684                                 printf("Auto-start selected\n");
685                                 auto_start = 1;
686                         }
687                         if (!strcmp(lgopts[opt_idx].name, "tx-first")) {
688                                 printf("Ports to start sending a burst of "
689                                                 "packets first\n");
690                                 tx_first = 1;
691                         }
692                         if (!strcmp(lgopts[opt_idx].name, "stats-period")) {
693                                 char *end = NULL;
694                                 unsigned int n;
695
696                                 n = strtoul(optarg, &end, 10);
697                                 if ((optarg[0] == '\0') || (end == NULL) ||
698                                                 (*end != '\0'))
699                                         break;
700
701                                 stats_period = n;
702                                 break;
703                         }
704                         if (!strcmp(lgopts[opt_idx].name,
705                                     "eth-peers-configfile")) {
706                                 if (init_peer_eth_addrs(optarg) != 0)
707                                         rte_exit(EXIT_FAILURE,
708                                                  "Cannot open logfile\n");
709                         }
710                         if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
711                                 char *port_end;
712                                 uint8_t c, peer_addr[6];
713
714                                 errno = 0;
715                                 n = strtoul(optarg, &port_end, 10);
716                                 if (errno != 0 || port_end == optarg || *port_end++ != ',')
717                                         rte_exit(EXIT_FAILURE,
718                                                  "Invalid eth-peer: %s", optarg);
719                                 if (n >= RTE_MAX_ETHPORTS)
720                                         rte_exit(EXIT_FAILURE,
721                                                  "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n",
722                                                  n, RTE_MAX_ETHPORTS);
723
724                                 if (cmdline_parse_etheraddr(NULL, port_end,
725                                                 &peer_addr, sizeof(peer_addr)) < 0)
726                                         rte_exit(EXIT_FAILURE,
727                                                  "Invalid ethernet address: %s\n",
728                                                  port_end);
729                                 for (c = 0; c < 6; c++)
730                                         peer_eth_addrs[n].addr_bytes[c] =
731                                                 peer_addr[c];
732                                 nb_peer_eth_addrs++;
733                         }
734 #endif
735                         if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
736                                 n = atoi(optarg);
737                                 if (n > 0 && n <= nb_ports)
738                                         nb_fwd_ports = (uint8_t) n;
739                                 else
740                                         rte_exit(EXIT_FAILURE,
741                                                  "Invalid port %d\n", n);
742                         }
743                         if (!strcmp(lgopts[opt_idx].name, "nb-cores")) {
744                                 n = atoi(optarg);
745                                 if (n > 0 && n <= nb_lcores)
746                                         nb_fwd_lcores = (uint8_t) n;
747                                 else
748                                         rte_exit(EXIT_FAILURE,
749                                                  "nb-cores should be > 0 and <= %d\n",
750                                                  nb_lcores);
751                         }
752                         if (!strcmp(lgopts[opt_idx].name, "coremask"))
753                                 parse_fwd_coremask(optarg);
754                         if (!strcmp(lgopts[opt_idx].name, "portmask"))
755                                 parse_fwd_portmask(optarg);
756                         if (!strcmp(lgopts[opt_idx].name, "no-numa"))
757                                 numa_support = 0;
758                         if (!strcmp(lgopts[opt_idx].name, "numa"))
759                                 numa_support = 1;
760                         if (!strcmp(lgopts[opt_idx].name, "mp-anon")) {
761                                 mp_anon = 1;
762                         }
763                         if (!strcmp(lgopts[opt_idx].name, "port-numa-config")) {
764                                 if (parse_portnuma_config(optarg))
765                                         rte_exit(EXIT_FAILURE,
766                                            "invalid port-numa configuration\n");
767                         }
768                         if (!strcmp(lgopts[opt_idx].name, "ring-numa-config"))
769                                 if (parse_ringnuma_config(optarg))
770                                         rte_exit(EXIT_FAILURE,
771                                            "invalid ring-numa configuration\n");
772                         if (!strcmp(lgopts[opt_idx].name, "socket-num")) {
773                                 n = atoi(optarg);
774                                 if (!new_socket_id((uint8_t)n)) {
775                                         socket_num = (uint8_t)n;
776                                 } else {
777                                         print_invalid_socket_id_error();
778                                         rte_exit(EXIT_FAILURE,
779                                                 "Invalid socket id");
780                                 }
781                         }
782                         if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
783                                 n = atoi(optarg);
784                                 if (n > 0 && n <= 0xFFFF)
785                                         mbuf_data_size = (uint16_t) n;
786                                 else
787                                         rte_exit(EXIT_FAILURE,
788                                                  "mbuf-size should be > 0 and < 65536\n");
789                         }
790                         if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
791                                 n = atoi(optarg);
792                                 if (n > 1024)
793                                         param_total_num_mbufs = (unsigned)n;
794                                 else
795                                         rte_exit(EXIT_FAILURE,
796                                                  "total-num-mbufs should be > 1024\n");
797                         }
798                         if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
799                                 n = atoi(optarg);
800                                 if (n >= ETHER_MIN_LEN) {
801                                         rx_mode.max_rx_pkt_len = (uint32_t) n;
802                                         if (n > ETHER_MAX_LEN)
803                                             rx_mode.jumbo_frame = 1;
804                                 } else
805                                         rte_exit(EXIT_FAILURE,
806                                                  "Invalid max-pkt-len=%d - should be > %d\n",
807                                                  n, ETHER_MIN_LEN);
808                         }
809                         if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) {
810                                 if (!strcmp(optarg, "signature"))
811                                         fdir_conf.mode =
812                                                 RTE_FDIR_MODE_SIGNATURE;
813                                 else if (!strcmp(optarg, "perfect"))
814                                         fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
815                                 else if (!strcmp(optarg, "perfect-mac-vlan"))
816                                         fdir_conf.mode = RTE_FDIR_MODE_PERFECT_MAC_VLAN;
817                                 else if (!strcmp(optarg, "perfect-tunnel"))
818                                         fdir_conf.mode = RTE_FDIR_MODE_PERFECT_TUNNEL;
819                                 else if (!strcmp(optarg, "none"))
820                                         fdir_conf.mode = RTE_FDIR_MODE_NONE;
821                                 else
822                                         rte_exit(EXIT_FAILURE,
823                                                  "pkt-mode-invalid %s invalid - must be: "
824                                                  "none, signature, perfect, perfect-mac-vlan"
825                                                  " or perfect-tunnel\n",
826                                                  optarg);
827                         }
828                         if (!strcmp(lgopts[opt_idx].name,
829                                     "pkt-filter-report-hash")) {
830                                 if (!strcmp(optarg, "none"))
831                                         fdir_conf.status =
832                                                 RTE_FDIR_NO_REPORT_STATUS;
833                                 else if (!strcmp(optarg, "match"))
834                                         fdir_conf.status =
835                                                 RTE_FDIR_REPORT_STATUS;
836                                 else if (!strcmp(optarg, "always"))
837                                         fdir_conf.status =
838                                                 RTE_FDIR_REPORT_STATUS_ALWAYS;
839                                 else
840                                         rte_exit(EXIT_FAILURE,
841                                                  "pkt-filter-report-hash %s invalid "
842                                                  "- must be: none or match or always\n",
843                                                  optarg);
844                         }
845                         if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) {
846                                 if (!strcmp(optarg, "64K"))
847                                         fdir_conf.pballoc =
848                                                 RTE_FDIR_PBALLOC_64K;
849                                 else if (!strcmp(optarg, "128K"))
850                                         fdir_conf.pballoc =
851                                                 RTE_FDIR_PBALLOC_128K;
852                                 else if (!strcmp(optarg, "256K"))
853                                         fdir_conf.pballoc =
854                                                 RTE_FDIR_PBALLOC_256K;
855                                 else
856                                         rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -"
857                                                  " must be: 64K or 128K or 256K\n",
858                                                  optarg);
859                         }
860                         if (!strcmp(lgopts[opt_idx].name,
861                                     "pkt-filter-drop-queue")) {
862                                 n = atoi(optarg);
863                                 if (n >= 0)
864                                         fdir_conf.drop_queue = (uint8_t) n;
865                                 else
866                                         rte_exit(EXIT_FAILURE,
867                                                  "drop queue %d invalid - must"
868                                                  "be >= 0 \n", n);
869                         }
870 #ifdef RTE_LIBRTE_LATENCY_STATS
871                         if (!strcmp(lgopts[opt_idx].name,
872                                     "latencystats")) {
873                                 n = atoi(optarg);
874                                 if (n >= 0) {
875                                         latencystats_lcore_id = (lcoreid_t) n;
876                                         latencystats_enabled = 1;
877                                 } else
878                                         rte_exit(EXIT_FAILURE,
879                                                  "invalid lcore id %d for latencystats"
880                                                  " must be >= 0\n", n);
881                         }
882 #endif
883 #ifdef RTE_LIBRTE_BITRATE
884                         if (!strcmp(lgopts[opt_idx].name, "bitrate-stats")) {
885                                 n = atoi(optarg);
886                                 if (n >= 0) {
887                                         bitrate_lcore_id = (lcoreid_t) n;
888                                         bitrate_enabled = 1;
889                                 } else
890                                         rte_exit(EXIT_FAILURE,
891                                                  "invalid lcore id %d for bitrate stats"
892                                                  " must be >= 0\n", n);
893                         }
894 #endif
895                         if (!strcmp(lgopts[opt_idx].name, "disable-crc-strip"))
896                                 rx_mode.hw_strip_crc = 0;
897                         if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
898                                 rx_mode.enable_lro = 1;
899                         if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
900                                 rx_mode.enable_scatter = 1;
901                         if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
902                                 rx_mode.hw_ip_checksum = 1;
903
904                         if (!strcmp(lgopts[opt_idx].name, "disable-hw-vlan")) {
905                                 rx_mode.hw_vlan_filter = 0;
906                                 rx_mode.hw_vlan_strip  = 0;
907                                 rx_mode.hw_vlan_extend = 0;
908                         }
909
910                         if (!strcmp(lgopts[opt_idx].name,
911                                         "disable-hw-vlan-filter"))
912                                 rx_mode.hw_vlan_filter = 0;
913
914                         if (!strcmp(lgopts[opt_idx].name,
915                                         "disable-hw-vlan-strip"))
916                                 rx_mode.hw_vlan_strip  = 0;
917
918                         if (!strcmp(lgopts[opt_idx].name,
919                                         "disable-hw-vlan-extend"))
920                                 rx_mode.hw_vlan_extend = 0;
921
922                         if (!strcmp(lgopts[opt_idx].name, "enable-drop-en"))
923                                 rx_drop_en = 1;
924
925                         if (!strcmp(lgopts[opt_idx].name, "disable-rss"))
926                                 rss_hf = 0;
927                         if (!strcmp(lgopts[opt_idx].name, "port-topology")) {
928                                 if (!strcmp(optarg, "paired"))
929                                         port_topology = PORT_TOPOLOGY_PAIRED;
930                                 else if (!strcmp(optarg, "chained"))
931                                         port_topology = PORT_TOPOLOGY_CHAINED;
932                                 else if (!strcmp(optarg, "loop"))
933                                         port_topology = PORT_TOPOLOGY_LOOP;
934                                 else
935                                         rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
936                                                  " must be: paired or chained \n",
937                                                  optarg);
938                         }
939                         if (!strcmp(lgopts[opt_idx].name, "forward-mode"))
940                                 set_pkt_forwarding_mode(optarg);
941                         if (!strcmp(lgopts[opt_idx].name, "rss-ip"))
942                                 rss_hf = ETH_RSS_IP;
943                         if (!strcmp(lgopts[opt_idx].name, "rss-udp"))
944                                 rss_hf = ETH_RSS_UDP;
945                         if (!strcmp(lgopts[opt_idx].name, "rxq")) {
946                                 n = atoi(optarg);
947                                 if (n >= 0 && n <= (int) MAX_QUEUE_ID)
948                                         nb_rxq = (queueid_t) n;
949                                 else
950                                         rte_exit(EXIT_FAILURE, "rxq %d invalid - must be"
951                                                   " >= 0 && <= %d\n", n,
952                                                   (int) MAX_QUEUE_ID);
953                         }
954                         if (!strcmp(lgopts[opt_idx].name, "txq")) {
955                                 n = atoi(optarg);
956                                 if (n >= 0 && n <= (int) MAX_QUEUE_ID)
957                                         nb_txq = (queueid_t) n;
958                                 else
959                                         rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
960                                                   " >= 0 && <= %d\n", n,
961                                                   (int) MAX_QUEUE_ID);
962                         }
963                         if (!nb_rxq && !nb_txq) {
964                                 rte_exit(EXIT_FAILURE, "Either rx or tx queues should "
965                                                 "be non-zero\n");
966                         }
967                         if (!strcmp(lgopts[opt_idx].name, "burst")) {
968                                 n = atoi(optarg);
969                                 if ((n >= 1) && (n <= MAX_PKT_BURST))
970                                         nb_pkt_per_burst = (uint16_t) n;
971                                 else
972                                         rte_exit(EXIT_FAILURE,
973                                                  "burst must >= 1 and <= %d]",
974                                                  MAX_PKT_BURST);
975                         }
976                         if (!strcmp(lgopts[opt_idx].name, "mbcache")) {
977                                 n = atoi(optarg);
978                                 if ((n >= 0) &&
979                                     (n <= RTE_MEMPOOL_CACHE_MAX_SIZE))
980                                         mb_mempool_cache = (uint16_t) n;
981                                 else
982                                         rte_exit(EXIT_FAILURE,
983                                                  "mbcache must be >= 0 and <= %d\n",
984                                                  RTE_MEMPOOL_CACHE_MAX_SIZE);
985                         }
986                         if (!strcmp(lgopts[opt_idx].name, "txfreet")) {
987                                 n = atoi(optarg);
988                                 if (n >= 0)
989                                         tx_free_thresh = (int16_t)n;
990                                 else
991                                         rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n");
992                         }
993                         if (!strcmp(lgopts[opt_idx].name, "txrst")) {
994                                 n = atoi(optarg);
995                                 if (n >= 0)
996                                         tx_rs_thresh = (int16_t)n;
997                                 else
998                                         rte_exit(EXIT_FAILURE, "txrst must be >= 0\n");
999                         }
1000                         if (!strcmp(lgopts[opt_idx].name, "txqflags")) {
1001                                 char *end = NULL;
1002                                 n = strtoul(optarg, &end, 16);
1003                                 if (n >= 0)
1004                                         txq_flags = (int32_t)n;
1005                                 else
1006                                         rte_exit(EXIT_FAILURE,
1007                                                  "txqflags must be >= 0\n");
1008                         }
1009                         if (!strcmp(lgopts[opt_idx].name, "rxd")) {
1010                                 n = atoi(optarg);
1011                                 if (n > 0) {
1012                                         if (rx_free_thresh >= n)
1013                                                 rte_exit(EXIT_FAILURE,
1014                                                          "rxd must be > "
1015                                                          "rx_free_thresh(%d)\n",
1016                                                          (int)rx_free_thresh);
1017                                         else
1018                                                 nb_rxd = (uint16_t) n;
1019                                 } else
1020                                         rte_exit(EXIT_FAILURE,
1021                                                  "rxd(%d) invalid - must be > 0\n",
1022                                                  n);
1023                         }
1024                         if (!strcmp(lgopts[opt_idx].name, "txd")) {
1025                                 n = atoi(optarg);
1026                                 if (n > 0)
1027                                         nb_txd = (uint16_t) n;
1028                                 else
1029                                         rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
1030                         }
1031                         if (!strcmp(lgopts[opt_idx].name, "txpt")) {
1032                                 n = atoi(optarg);
1033                                 if (n >= 0)
1034                                         tx_pthresh = (int8_t)n;
1035                                 else
1036                                         rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
1037                         }
1038                         if (!strcmp(lgopts[opt_idx].name, "txht")) {
1039                                 n = atoi(optarg);
1040                                 if (n >= 0)
1041                                         tx_hthresh = (int8_t)n;
1042                                 else
1043                                         rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
1044                         }
1045                         if (!strcmp(lgopts[opt_idx].name, "txwt")) {
1046                                 n = atoi(optarg);
1047                                 if (n >= 0)
1048                                         tx_wthresh = (int8_t)n;
1049                                 else
1050                                         rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
1051                         }
1052                         if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
1053                                 n = atoi(optarg);
1054                                 if (n >= 0)
1055                                         rx_pthresh = (int8_t)n;
1056                                 else
1057                                         rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
1058                         }
1059                         if (!strcmp(lgopts[opt_idx].name, "rxht")) {
1060                                 n = atoi(optarg);
1061                                 if (n >= 0)
1062                                         rx_hthresh = (int8_t)n;
1063                                 else
1064                                         rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
1065                         }
1066                         if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
1067                                 n = atoi(optarg);
1068                                 if (n >= 0)
1069                                         rx_wthresh = (int8_t)n;
1070                                 else
1071                                         rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
1072                         }
1073                         if (!strcmp(lgopts[opt_idx].name, "rxfreet")) {
1074                                 n = atoi(optarg);
1075                                 if (n >= 0)
1076                                         rx_free_thresh = (int16_t)n;
1077                                 else
1078                                         rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n");
1079                         }
1080                         if (!strcmp(lgopts[opt_idx].name, "tx-queue-stats-mapping")) {
1081                                 if (parse_queue_stats_mapping_config(optarg, TX)) {
1082                                         rte_exit(EXIT_FAILURE,
1083                                                  "invalid TX queue statistics mapping config entered\n");
1084                                 }
1085                         }
1086                         if (!strcmp(lgopts[opt_idx].name, "rx-queue-stats-mapping")) {
1087                                 if (parse_queue_stats_mapping_config(optarg, RX)) {
1088                                         rte_exit(EXIT_FAILURE,
1089                                                  "invalid RX queue statistics mapping config entered\n");
1090                                 }
1091                         }
1092                         if (!strcmp(lgopts[opt_idx].name, "txpkts")) {
1093                                 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1094                                 unsigned int nb_segs;
1095
1096                                 nb_segs = parse_item_list(optarg, "txpkt segments",
1097                                                 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1098                                 if (nb_segs > 0)
1099                                         set_tx_pkt_segments(seg_lengths, nb_segs);
1100                                 else
1101                                         rte_exit(EXIT_FAILURE, "bad txpkts\n");
1102                         }
1103                         if (!strcmp(lgopts[opt_idx].name, "no-flush-rx"))
1104                                 no_flush_rx = 1;
1105                         if (!strcmp(lgopts[opt_idx].name, "disable-link-check"))
1106                                 no_link_check = 1;
1107                         if (!strcmp(lgopts[opt_idx].name, "no-lsc-interrupt"))
1108                                 lsc_interrupt = 0;
1109                         if (!strcmp(lgopts[opt_idx].name, "no-rmv-interrupt"))
1110                                 rmv_interrupt = 0;
1111                         if (!strcmp(lgopts[opt_idx].name, "flow-isolate-all"))
1112                                 flow_isolate_all = 1;
1113                         if (!strcmp(lgopts[opt_idx].name, "print-event"))
1114                                 if (parse_event_printing_config(optarg, 1)) {
1115                                         rte_exit(EXIT_FAILURE,
1116                                                  "invalid print-event argument\n");
1117                                 }
1118                         if (!strcmp(lgopts[opt_idx].name, "mask-event"))
1119                                 if (parse_event_printing_config(optarg, 0)) {
1120                                         rte_exit(EXIT_FAILURE,
1121                                                  "invalid mask-event argument\n");
1122                                 }
1123
1124                         break;
1125                 case 'h':
1126                         usage(argv[0]);
1127                         rte_exit(EXIT_SUCCESS, "Displayed help\n");
1128                         break;
1129                 default:
1130                         usage(argv[0]);
1131                         rte_exit(EXIT_FAILURE,
1132                                  "Command line is incomplete or incorrect\n");
1133                         break;
1134                 }
1135         }
1136 }