app/testpmd: print statistics periodically
[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 }
219
220 #ifdef RTE_LIBRTE_CMDLINE
221 static int
222 init_peer_eth_addrs(char *config_filename)
223 {
224         FILE *config_file;
225         portid_t i;
226         char buf[50];
227
228         config_file = fopen(config_filename, "r");
229         if (config_file == NULL) {
230                 perror("Failed to open eth config file\n");
231                 return -1;
232         }
233
234         for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
235
236                 if (fgets(buf, sizeof(buf), config_file) == NULL)
237                         break;
238
239                 if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i],
240                                 sizeof(peer_eth_addrs[i])) < 0) {
241                         printf("Bad MAC address format on line %d\n", i+1);
242                         fclose(config_file);
243                         return -1;
244                 }
245         }
246         fclose(config_file);
247         nb_peer_eth_addrs = (portid_t) i;
248         return 0;
249 }
250 #endif
251
252 /*
253  * Parse the coremask given as argument (hexadecimal string) and set
254  * the global configuration of forwarding cores.
255  */
256 static void
257 parse_fwd_coremask(const char *coremask)
258 {
259         char *end;
260         unsigned long long int cm;
261
262         /* parse hexadecimal string */
263         end = NULL;
264         cm = strtoull(coremask, &end, 16);
265         if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0'))
266                 rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n");
267         else if (set_fwd_lcores_mask((uint64_t) cm) < 0)
268                 rte_exit(EXIT_FAILURE, "coremask is not valid\n");
269 }
270
271 /*
272  * Parse the coremask given as argument (hexadecimal string) and set
273  * the global configuration of forwarding cores.
274  */
275 static void
276 parse_fwd_portmask(const char *portmask)
277 {
278         char *end;
279         unsigned long long int pm;
280
281         /* parse hexadecimal string */
282         end = NULL;
283         pm = strtoull(portmask, &end, 16);
284         if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
285                 rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n");
286         else
287                 set_fwd_ports_mask((uint64_t) pm);
288 }
289
290
291 static int
292 parse_queue_stats_mapping_config(const char *q_arg, int is_rx)
293 {
294         char s[256];
295         const char *p, *p0 = q_arg;
296         char *end;
297         enum fieldnames {
298                 FLD_PORT = 0,
299                 FLD_QUEUE,
300                 FLD_STATS_COUNTER,
301                 _NUM_FLD
302         };
303         unsigned long int_fld[_NUM_FLD];
304         char *str_fld[_NUM_FLD];
305         int i;
306         unsigned size;
307
308         /* reset from value set at definition */
309         is_rx ? (nb_rx_queue_stats_mappings = 0) : (nb_tx_queue_stats_mappings = 0);
310
311         while ((p = strchr(p0,'(')) != NULL) {
312                 ++p;
313                 if((p0 = strchr(p,')')) == NULL)
314                         return -1;
315
316                 size = p0 - p;
317                 if(size >= sizeof(s))
318                         return -1;
319
320                 snprintf(s, sizeof(s), "%.*s", size, p);
321                 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
322                         return -1;
323                 for (i = 0; i < _NUM_FLD; i++){
324                         errno = 0;
325                         int_fld[i] = strtoul(str_fld[i], &end, 0);
326                         if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
327                                 return -1;
328                 }
329                 /* Check mapping field is in correct range (0..RTE_ETHDEV_QUEUE_STAT_CNTRS-1) */
330                 if (int_fld[FLD_STATS_COUNTER] >= RTE_ETHDEV_QUEUE_STAT_CNTRS) {
331                         printf("Stats counter not in the correct range 0..%d\n",
332                                         RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
333                         return -1;
334                 }
335
336                 if (!is_rx) {
337                         if ((nb_tx_queue_stats_mappings >=
338                                                 MAX_TX_QUEUE_STATS_MAPPINGS)) {
339                                 printf("exceeded max number of TX queue "
340                                                 "statistics mappings: %hu\n",
341                                                 nb_tx_queue_stats_mappings);
342                                 return -1;
343                         }
344                         tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id =
345                                 (uint8_t)int_fld[FLD_PORT];
346                         tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id =
347                                 (uint8_t)int_fld[FLD_QUEUE];
348                         tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].stats_counter_id =
349                                 (uint8_t)int_fld[FLD_STATS_COUNTER];
350                         ++nb_tx_queue_stats_mappings;
351                 }
352                 else {
353                         if ((nb_rx_queue_stats_mappings >=
354                                                 MAX_RX_QUEUE_STATS_MAPPINGS)) {
355                                 printf("exceeded max number of RX queue "
356                                                 "statistics mappings: %hu\n",
357                                                 nb_rx_queue_stats_mappings);
358                                 return -1;
359                         }
360                         rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id =
361                                 (uint8_t)int_fld[FLD_PORT];
362                         rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id =
363                                 (uint8_t)int_fld[FLD_QUEUE];
364                         rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].stats_counter_id =
365                                 (uint8_t)int_fld[FLD_STATS_COUNTER];
366                         ++nb_rx_queue_stats_mappings;
367                 }
368
369         }
370 /* Reassign the rx/tx_queue_stats_mappings pointer to point to this newly populated array rather */
371 /* than to the default array (that was set at its definition) */
372         is_rx ? (rx_queue_stats_mappings = rx_queue_stats_mappings_array) :
373                 (tx_queue_stats_mappings = tx_queue_stats_mappings_array);
374         return 0;
375 }
376
377 static void
378 print_invalid_socket_id_error(void)
379 {
380         unsigned int i = 0;
381
382         printf("Invalid socket id, options are: ");
383         for (i = 0; i < num_sockets; i++) {
384                 printf("%u%s", socket_ids[i],
385                       (i == num_sockets - 1) ? "\n" : ",");
386         }
387 }
388
389 static int
390 parse_portnuma_config(const char *q_arg)
391 {
392         char s[256];
393         const char *p, *p0 = q_arg;
394         char *end;
395         uint8_t i,port_id,socket_id;
396         unsigned size;
397         enum fieldnames {
398                 FLD_PORT = 0,
399                 FLD_SOCKET,
400                 _NUM_FLD
401         };
402         unsigned long int_fld[_NUM_FLD];
403         char *str_fld[_NUM_FLD];
404         portid_t pid;
405
406         /* reset from value set at definition */
407         while ((p = strchr(p0,'(')) != NULL) {
408                 ++p;
409                 if((p0 = strchr(p,')')) == NULL)
410                         return -1;
411
412                 size = p0 - p;
413                 if(size >= sizeof(s))
414                         return -1;
415
416                 snprintf(s, sizeof(s), "%.*s", size, p);
417                 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
418                         return -1;
419                 for (i = 0; i < _NUM_FLD; i++) {
420                         errno = 0;
421                         int_fld[i] = strtoul(str_fld[i], &end, 0);
422                         if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
423                                 return -1;
424                 }
425                 port_id = (uint8_t)int_fld[FLD_PORT];
426                 if (port_id_is_invalid(port_id, ENABLED_WARN)) {
427                         printf("Valid port range is [0");
428                         RTE_ETH_FOREACH_DEV(pid)
429                                 printf(", %d", pid);
430                         printf("]\n");
431                         return -1;
432                 }
433                 socket_id = (uint8_t)int_fld[FLD_SOCKET];
434                 if (new_socket_id(socket_id)) {
435                         print_invalid_socket_id_error();
436                         return -1;
437                 }
438                 port_numa[port_id] = socket_id;
439         }
440
441         return 0;
442 }
443
444 static int
445 parse_ringnuma_config(const char *q_arg)
446 {
447         char s[256];
448         const char *p, *p0 = q_arg;
449         char *end;
450         uint8_t i,port_id,ring_flag,socket_id;
451         unsigned size;
452         enum fieldnames {
453                 FLD_PORT = 0,
454                 FLD_FLAG,
455                 FLD_SOCKET,
456                 _NUM_FLD
457         };
458         unsigned long int_fld[_NUM_FLD];
459         char *str_fld[_NUM_FLD];
460         portid_t pid;
461         #define RX_RING_ONLY 0x1
462         #define TX_RING_ONLY 0x2
463         #define RXTX_RING    0x3
464
465         /* reset from value set at definition */
466         while ((p = strchr(p0,'(')) != NULL) {
467                 ++p;
468                 if((p0 = strchr(p,')')) == NULL)
469                         return -1;
470
471                 size = p0 - p;
472                 if(size >= sizeof(s))
473                         return -1;
474
475                 snprintf(s, sizeof(s), "%.*s", size, p);
476                 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
477                         return -1;
478                 for (i = 0; i < _NUM_FLD; i++) {
479                         errno = 0;
480                         int_fld[i] = strtoul(str_fld[i], &end, 0);
481                         if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
482                                 return -1;
483                 }
484                 port_id = (uint8_t)int_fld[FLD_PORT];
485                 if (port_id_is_invalid(port_id, ENABLED_WARN)) {
486                         printf("Valid port range is [0");
487                         RTE_ETH_FOREACH_DEV(pid)
488                                 printf(", %d", pid);
489                         printf("]\n");
490                         return -1;
491                 }
492                 socket_id = (uint8_t)int_fld[FLD_SOCKET];
493                 if (new_socket_id(socket_id)) {
494                         print_invalid_socket_id_error();
495                         return -1;
496                 }
497                 ring_flag = (uint8_t)int_fld[FLD_FLAG];
498                 if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) {
499                         printf("Invalid ring-flag=%d config for port =%d\n",
500                                 ring_flag,port_id);
501                         return -1;
502                 }
503
504                 switch (ring_flag & RXTX_RING) {
505                 case RX_RING_ONLY:
506                         rxring_numa[port_id] = socket_id;
507                         break;
508                 case TX_RING_ONLY:
509                         txring_numa[port_id] = socket_id;
510                         break;
511                 case RXTX_RING:
512                         rxring_numa[port_id] = socket_id;
513                         txring_numa[port_id] = socket_id;
514                         break;
515                 default:
516                         printf("Invalid ring-flag=%d config for port=%d\n",
517                                 ring_flag,port_id);
518                         break;
519                 }
520         }
521
522         return 0;
523 }
524
525 static int
526 parse_event_printing_config(const char *optarg, int enable)
527 {
528         uint32_t mask = 0;
529
530         if (!strcmp(optarg, "unknown"))
531                 mask = UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN;
532         else if (!strcmp(optarg, "intr_lsc"))
533                 mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_LSC;
534         else if (!strcmp(optarg, "queue_state"))
535                 mask = UINT32_C(1) << RTE_ETH_EVENT_QUEUE_STATE;
536         else if (!strcmp(optarg, "intr_reset"))
537                 mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET;
538         else if (!strcmp(optarg, "vf_mbox"))
539                 mask = UINT32_C(1) << RTE_ETH_EVENT_VF_MBOX;
540         else if (!strcmp(optarg, "macsec"))
541                 mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
542         else if (!strcmp(optarg, "intr_rmv"))
543                 mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
544         else if (!strcmp(optarg, "all"))
545                 mask = ~UINT32_C(0);
546         else {
547                 fprintf(stderr, "Invalid event: %s\n", optarg);
548                 return -1;
549         }
550         if (enable)
551                 event_print_mask |= mask;
552         else
553                 event_print_mask &= ~mask;
554         return 0;
555 }
556
557 void
558 launch_args_parse(int argc, char** argv)
559 {
560         int n, opt;
561         char **argvopt;
562         int opt_idx;
563         enum { TX, RX };
564
565         static struct option lgopts[] = {
566                 { "help",                       0, 0, 0 },
567 #ifdef RTE_LIBRTE_CMDLINE
568                 { "interactive",                0, 0, 0 },
569                 { "cmdline-file",               1, 0, 0 },
570                 { "auto-start",                 0, 0, 0 },
571                 { "eth-peers-configfile",       1, 0, 0 },
572                 { "eth-peer",                   1, 0, 0 },
573 #endif
574                 { "tx-first",                   0, 0, 0 },
575                 { "stats-period",               1, 0, 0 },
576                 { "ports",                      1, 0, 0 },
577                 { "nb-cores",                   1, 0, 0 },
578                 { "nb-ports",                   1, 0, 0 },
579                 { "coremask",                   1, 0, 0 },
580                 { "portmask",                   1, 0, 0 },
581                 { "numa",                       0, 0, 0 },
582                 { "no-numa",                    0, 0, 0 },
583                 { "mp-anon",                    0, 0, 0 },
584                 { "port-numa-config",           1, 0, 0 },
585                 { "ring-numa-config",           1, 0, 0 },
586                 { "socket-num",                 1, 0, 0 },
587                 { "mbuf-size",                  1, 0, 0 },
588                 { "total-num-mbufs",            1, 0, 0 },
589                 { "max-pkt-len",                1, 0, 0 },
590                 { "pkt-filter-mode",            1, 0, 0 },
591                 { "pkt-filter-report-hash",     1, 0, 0 },
592                 { "pkt-filter-size",            1, 0, 0 },
593                 { "pkt-filter-drop-queue",      1, 0, 0 },
594 #ifdef RTE_LIBRTE_LATENCY_STATS
595                 { "latencystats",               1, 0, 0 },
596 #endif
597 #ifdef RTE_LIBRTE_BITRATE
598                 { "bitrate-stats",              1, 0, 0 },
599 #endif
600                 { "disable-crc-strip",          0, 0, 0 },
601                 { "enable-lro",                 0, 0, 0 },
602                 { "enable-rx-cksum",            0, 0, 0 },
603                 { "enable-scatter",             0, 0, 0 },
604                 { "disable-hw-vlan",            0, 0, 0 },
605                 { "disable-hw-vlan-filter",     0, 0, 0 },
606                 { "disable-hw-vlan-strip",      0, 0, 0 },
607                 { "disable-hw-vlan-extend",     0, 0, 0 },
608                 { "enable-drop-en",            0, 0, 0 },
609                 { "disable-rss",                0, 0, 0 },
610                 { "port-topology",              1, 0, 0 },
611                 { "forward-mode",               1, 0, 0 },
612                 { "rss-ip",                     0, 0, 0 },
613                 { "rss-udp",                    0, 0, 0 },
614                 { "rxq",                        1, 0, 0 },
615                 { "txq",                        1, 0, 0 },
616                 { "rxd",                        1, 0, 0 },
617                 { "txd",                        1, 0, 0 },
618                 { "burst",                      1, 0, 0 },
619                 { "mbcache",                    1, 0, 0 },
620                 { "txpt",                       1, 0, 0 },
621                 { "txht",                       1, 0, 0 },
622                 { "txwt",                       1, 0, 0 },
623                 { "txfreet",                    1, 0, 0 },
624                 { "txrst",                      1, 0, 0 },
625                 { "txqflags",                   1, 0, 0 },
626                 { "rxpt",                       1, 0, 0 },
627                 { "rxht",                       1, 0, 0 },
628                 { "rxwt",                       1, 0, 0 },
629                 { "rxfreet",                    1, 0, 0 },
630                 { "tx-queue-stats-mapping",     1, 0, 0 },
631                 { "rx-queue-stats-mapping",     1, 0, 0 },
632                 { "no-flush-rx",        0, 0, 0 },
633                 { "txpkts",                     1, 0, 0 },
634                 { "disable-link-check",         0, 0, 0 },
635                 { "no-lsc-interrupt",           0, 0, 0 },
636                 { "no-rmv-interrupt",           0, 0, 0 },
637                 { "print-event",                1, 0, 0 },
638                 { "mask-event",                 1, 0, 0 },
639                 { 0, 0, 0, 0 },
640         };
641
642         argvopt = argv;
643
644 #ifdef RTE_LIBRTE_CMDLINE
645 #define SHORTOPTS "i"
646 #else
647 #define SHORTOPTS ""
648 #endif
649         while ((opt = getopt_long(argc, argvopt, SHORTOPTS "ah",
650                                  lgopts, &opt_idx)) != EOF) {
651                 switch (opt) {
652 #ifdef RTE_LIBRTE_CMDLINE
653                 case 'i':
654                         printf("Interactive-mode selected\n");
655                         interactive = 1;
656                         break;
657 #endif
658                 case 'a':
659                         printf("Auto-start selected\n");
660                         auto_start = 1;
661                         break;
662
663                 case 0: /*long options */
664                         if (!strcmp(lgopts[opt_idx].name, "help")) {
665                                 usage(argv[0]);
666                                 rte_exit(EXIT_SUCCESS, "Displayed help\n");
667                         }
668 #ifdef RTE_LIBRTE_CMDLINE
669                         if (!strcmp(lgopts[opt_idx].name, "interactive")) {
670                                 printf("Interactive-mode selected\n");
671                                 interactive = 1;
672                         }
673                         if (!strcmp(lgopts[opt_idx].name, "cmdline-file")) {
674                                 printf("CLI commands to be read from %s\n",
675                                        optarg);
676                                 snprintf(cmdline_filename,
677                                          sizeof(cmdline_filename), "%s",
678                                          optarg);
679                         }
680                         if (!strcmp(lgopts[opt_idx].name, "auto-start")) {
681                                 printf("Auto-start selected\n");
682                                 auto_start = 1;
683                         }
684                         if (!strcmp(lgopts[opt_idx].name, "tx-first")) {
685                                 printf("Ports to start sending a burst of "
686                                                 "packets first\n");
687                                 tx_first = 1;
688                         }
689                         if (!strcmp(lgopts[opt_idx].name, "stats-period")) {
690                                 char *end = NULL;
691                                 unsigned int n;
692
693                                 n = strtoul(optarg, &end, 10);
694                                 if ((optarg[0] == '\0') || (end == NULL) ||
695                                                 (*end != '\0'))
696                                         break;
697
698                                 stats_period = n;
699                                 break;
700                         }
701                         if (!strcmp(lgopts[opt_idx].name,
702                                     "eth-peers-configfile")) {
703                                 if (init_peer_eth_addrs(optarg) != 0)
704                                         rte_exit(EXIT_FAILURE,
705                                                  "Cannot open logfile\n");
706                         }
707                         if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
708                                 char *port_end;
709                                 uint8_t c, peer_addr[6];
710
711                                 errno = 0;
712                                 n = strtoul(optarg, &port_end, 10);
713                                 if (errno != 0 || port_end == optarg || *port_end++ != ',')
714                                         rte_exit(EXIT_FAILURE,
715                                                  "Invalid eth-peer: %s", optarg);
716                                 if (n >= RTE_MAX_ETHPORTS)
717                                         rte_exit(EXIT_FAILURE,
718                                                  "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n",
719                                                  n, RTE_MAX_ETHPORTS);
720
721                                 if (cmdline_parse_etheraddr(NULL, port_end,
722                                                 &peer_addr, sizeof(peer_addr)) < 0)
723                                         rte_exit(EXIT_FAILURE,
724                                                  "Invalid ethernet address: %s\n",
725                                                  port_end);
726                                 for (c = 0; c < 6; c++)
727                                         peer_eth_addrs[n].addr_bytes[c] =
728                                                 peer_addr[c];
729                                 nb_peer_eth_addrs++;
730                         }
731 #endif
732                         if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
733                                 n = atoi(optarg);
734                                 if (n > 0 && n <= nb_ports)
735                                         nb_fwd_ports = (uint8_t) n;
736                                 else
737                                         rte_exit(EXIT_FAILURE,
738                                                  "Invalid port %d\n", n);
739                         }
740                         if (!strcmp(lgopts[opt_idx].name, "nb-cores")) {
741                                 n = atoi(optarg);
742                                 if (n > 0 && n <= nb_lcores)
743                                         nb_fwd_lcores = (uint8_t) n;
744                                 else
745                                         rte_exit(EXIT_FAILURE,
746                                                  "nb-cores should be > 0 and <= %d\n",
747                                                  nb_lcores);
748                         }
749                         if (!strcmp(lgopts[opt_idx].name, "coremask"))
750                                 parse_fwd_coremask(optarg);
751                         if (!strcmp(lgopts[opt_idx].name, "portmask"))
752                                 parse_fwd_portmask(optarg);
753                         if (!strcmp(lgopts[opt_idx].name, "no-numa"))
754                                 numa_support = 0;
755                         if (!strcmp(lgopts[opt_idx].name, "numa"))
756                                 numa_support = 1;
757                         if (!strcmp(lgopts[opt_idx].name, "mp-anon")) {
758                                 mp_anon = 1;
759                         }
760                         if (!strcmp(lgopts[opt_idx].name, "port-numa-config")) {
761                                 if (parse_portnuma_config(optarg))
762                                         rte_exit(EXIT_FAILURE,
763                                            "invalid port-numa configuration\n");
764                         }
765                         if (!strcmp(lgopts[opt_idx].name, "ring-numa-config"))
766                                 if (parse_ringnuma_config(optarg))
767                                         rte_exit(EXIT_FAILURE,
768                                            "invalid ring-numa configuration\n");
769                         if (!strcmp(lgopts[opt_idx].name, "socket-num")) {
770                                 n = atoi(optarg);
771                                 if (!new_socket_id((uint8_t)n)) {
772                                         socket_num = (uint8_t)n;
773                                 } else {
774                                         print_invalid_socket_id_error();
775                                         rte_exit(EXIT_FAILURE,
776                                                 "Invalid socket id");
777                                 }
778                         }
779                         if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
780                                 n = atoi(optarg);
781                                 if (n > 0 && n <= 0xFFFF)
782                                         mbuf_data_size = (uint16_t) n;
783                                 else
784                                         rte_exit(EXIT_FAILURE,
785                                                  "mbuf-size should be > 0 and < 65536\n");
786                         }
787                         if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
788                                 n = atoi(optarg);
789                                 if (n > 1024)
790                                         param_total_num_mbufs = (unsigned)n;
791                                 else
792                                         rte_exit(EXIT_FAILURE,
793                                                  "total-num-mbufs should be > 1024\n");
794                         }
795                         if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
796                                 n = atoi(optarg);
797                                 if (n >= ETHER_MIN_LEN) {
798                                         rx_mode.max_rx_pkt_len = (uint32_t) n;
799                                         if (n > ETHER_MAX_LEN)
800                                             rx_mode.jumbo_frame = 1;
801                                 } else
802                                         rte_exit(EXIT_FAILURE,
803                                                  "Invalid max-pkt-len=%d - should be > %d\n",
804                                                  n, ETHER_MIN_LEN);
805                         }
806                         if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) {
807                                 if (!strcmp(optarg, "signature"))
808                                         fdir_conf.mode =
809                                                 RTE_FDIR_MODE_SIGNATURE;
810                                 else if (!strcmp(optarg, "perfect"))
811                                         fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
812                                 else if (!strcmp(optarg, "perfect-mac-vlan"))
813                                         fdir_conf.mode = RTE_FDIR_MODE_PERFECT_MAC_VLAN;
814                                 else if (!strcmp(optarg, "perfect-tunnel"))
815                                         fdir_conf.mode = RTE_FDIR_MODE_PERFECT_TUNNEL;
816                                 else if (!strcmp(optarg, "none"))
817                                         fdir_conf.mode = RTE_FDIR_MODE_NONE;
818                                 else
819                                         rte_exit(EXIT_FAILURE,
820                                                  "pkt-mode-invalid %s invalid - must be: "
821                                                  "none, signature, perfect, perfect-mac-vlan"
822                                                  " or perfect-tunnel\n",
823                                                  optarg);
824                         }
825                         if (!strcmp(lgopts[opt_idx].name,
826                                     "pkt-filter-report-hash")) {
827                                 if (!strcmp(optarg, "none"))
828                                         fdir_conf.status =
829                                                 RTE_FDIR_NO_REPORT_STATUS;
830                                 else if (!strcmp(optarg, "match"))
831                                         fdir_conf.status =
832                                                 RTE_FDIR_REPORT_STATUS;
833                                 else if (!strcmp(optarg, "always"))
834                                         fdir_conf.status =
835                                                 RTE_FDIR_REPORT_STATUS_ALWAYS;
836                                 else
837                                         rte_exit(EXIT_FAILURE,
838                                                  "pkt-filter-report-hash %s invalid "
839                                                  "- must be: none or match or always\n",
840                                                  optarg);
841                         }
842                         if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) {
843                                 if (!strcmp(optarg, "64K"))
844                                         fdir_conf.pballoc =
845                                                 RTE_FDIR_PBALLOC_64K;
846                                 else if (!strcmp(optarg, "128K"))
847                                         fdir_conf.pballoc =
848                                                 RTE_FDIR_PBALLOC_128K;
849                                 else if (!strcmp(optarg, "256K"))
850                                         fdir_conf.pballoc =
851                                                 RTE_FDIR_PBALLOC_256K;
852                                 else
853                                         rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -"
854                                                  " must be: 64K or 128K or 256K\n",
855                                                  optarg);
856                         }
857                         if (!strcmp(lgopts[opt_idx].name,
858                                     "pkt-filter-drop-queue")) {
859                                 n = atoi(optarg);
860                                 if (n >= 0)
861                                         fdir_conf.drop_queue = (uint8_t) n;
862                                 else
863                                         rte_exit(EXIT_FAILURE,
864                                                  "drop queue %d invalid - must"
865                                                  "be >= 0 \n", n);
866                         }
867 #ifdef RTE_LIBRTE_LATENCY_STATS
868                         if (!strcmp(lgopts[opt_idx].name,
869                                     "latencystats")) {
870                                 n = atoi(optarg);
871                                 if (n >= 0) {
872                                         latencystats_lcore_id = (lcoreid_t) n;
873                                         latencystats_enabled = 1;
874                                 } else
875                                         rte_exit(EXIT_FAILURE,
876                                                  "invalid lcore id %d for latencystats"
877                                                  " must be >= 0\n", n);
878                         }
879 #endif
880 #ifdef RTE_LIBRTE_BITRATE
881                         if (!strcmp(lgopts[opt_idx].name, "bitrate-stats")) {
882                                 n = atoi(optarg);
883                                 if (n >= 0) {
884                                         bitrate_lcore_id = (lcoreid_t) n;
885                                         bitrate_enabled = 1;
886                                 } else
887                                         rte_exit(EXIT_FAILURE,
888                                                  "invalid lcore id %d for bitrate stats"
889                                                  " must be >= 0\n", n);
890                         }
891 #endif
892                         if (!strcmp(lgopts[opt_idx].name, "disable-crc-strip"))
893                                 rx_mode.hw_strip_crc = 0;
894                         if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
895                                 rx_mode.enable_lro = 1;
896                         if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
897                                 rx_mode.enable_scatter = 1;
898                         if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
899                                 rx_mode.hw_ip_checksum = 1;
900
901                         if (!strcmp(lgopts[opt_idx].name, "disable-hw-vlan")) {
902                                 rx_mode.hw_vlan_filter = 0;
903                                 rx_mode.hw_vlan_strip  = 0;
904                                 rx_mode.hw_vlan_extend = 0;
905                         }
906
907                         if (!strcmp(lgopts[opt_idx].name,
908                                         "disable-hw-vlan-filter"))
909                                 rx_mode.hw_vlan_filter = 0;
910
911                         if (!strcmp(lgopts[opt_idx].name,
912                                         "disable-hw-vlan-strip"))
913                                 rx_mode.hw_vlan_strip  = 0;
914
915                         if (!strcmp(lgopts[opt_idx].name,
916                                         "disable-hw-vlan-extend"))
917                                 rx_mode.hw_vlan_extend = 0;
918
919                         if (!strcmp(lgopts[opt_idx].name, "enable-drop-en"))
920                                 rx_drop_en = 1;
921
922                         if (!strcmp(lgopts[opt_idx].name, "disable-rss"))
923                                 rss_hf = 0;
924                         if (!strcmp(lgopts[opt_idx].name, "port-topology")) {
925                                 if (!strcmp(optarg, "paired"))
926                                         port_topology = PORT_TOPOLOGY_PAIRED;
927                                 else if (!strcmp(optarg, "chained"))
928                                         port_topology = PORT_TOPOLOGY_CHAINED;
929                                 else if (!strcmp(optarg, "loop"))
930                                         port_topology = PORT_TOPOLOGY_LOOP;
931                                 else
932                                         rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
933                                                  " must be: paired or chained \n",
934                                                  optarg);
935                         }
936                         if (!strcmp(lgopts[opt_idx].name, "forward-mode"))
937                                 set_pkt_forwarding_mode(optarg);
938                         if (!strcmp(lgopts[opt_idx].name, "rss-ip"))
939                                 rss_hf = ETH_RSS_IP;
940                         if (!strcmp(lgopts[opt_idx].name, "rss-udp"))
941                                 rss_hf = ETH_RSS_UDP;
942                         if (!strcmp(lgopts[opt_idx].name, "rxq")) {
943                                 n = atoi(optarg);
944                                 if (n >= 0 && n <= (int) MAX_QUEUE_ID)
945                                         nb_rxq = (queueid_t) n;
946                                 else
947                                         rte_exit(EXIT_FAILURE, "rxq %d invalid - must be"
948                                                   " >= 0 && <= %d\n", n,
949                                                   (int) MAX_QUEUE_ID);
950                         }
951                         if (!strcmp(lgopts[opt_idx].name, "txq")) {
952                                 n = atoi(optarg);
953                                 if (n >= 0 && n <= (int) MAX_QUEUE_ID)
954                                         nb_txq = (queueid_t) n;
955                                 else
956                                         rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
957                                                   " >= 0 && <= %d\n", n,
958                                                   (int) MAX_QUEUE_ID);
959                         }
960                         if (!nb_rxq && !nb_txq) {
961                                 rte_exit(EXIT_FAILURE, "Either rx or tx queues should "
962                                                 "be non-zero\n");
963                         }
964                         if (!strcmp(lgopts[opt_idx].name, "burst")) {
965                                 n = atoi(optarg);
966                                 if ((n >= 1) && (n <= MAX_PKT_BURST))
967                                         nb_pkt_per_burst = (uint16_t) n;
968                                 else
969                                         rte_exit(EXIT_FAILURE,
970                                                  "burst must >= 1 and <= %d]",
971                                                  MAX_PKT_BURST);
972                         }
973                         if (!strcmp(lgopts[opt_idx].name, "mbcache")) {
974                                 n = atoi(optarg);
975                                 if ((n >= 0) &&
976                                     (n <= RTE_MEMPOOL_CACHE_MAX_SIZE))
977                                         mb_mempool_cache = (uint16_t) n;
978                                 else
979                                         rte_exit(EXIT_FAILURE,
980                                                  "mbcache must be >= 0 and <= %d\n",
981                                                  RTE_MEMPOOL_CACHE_MAX_SIZE);
982                         }
983                         if (!strcmp(lgopts[opt_idx].name, "txfreet")) {
984                                 n = atoi(optarg);
985                                 if (n >= 0)
986                                         tx_free_thresh = (int16_t)n;
987                                 else
988                                         rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n");
989                         }
990                         if (!strcmp(lgopts[opt_idx].name, "txrst")) {
991                                 n = atoi(optarg);
992                                 if (n >= 0)
993                                         tx_rs_thresh = (int16_t)n;
994                                 else
995                                         rte_exit(EXIT_FAILURE, "txrst must be >= 0\n");
996                         }
997                         if (!strcmp(lgopts[opt_idx].name, "txqflags")) {
998                                 char *end = NULL;
999                                 n = strtoul(optarg, &end, 16);
1000                                 if (n >= 0)
1001                                         txq_flags = (int32_t)n;
1002                                 else
1003                                         rte_exit(EXIT_FAILURE,
1004                                                  "txqflags must be >= 0\n");
1005                         }
1006                         if (!strcmp(lgopts[opt_idx].name, "rxd")) {
1007                                 n = atoi(optarg);
1008                                 if (n > 0) {
1009                                         if (rx_free_thresh >= n)
1010                                                 rte_exit(EXIT_FAILURE,
1011                                                          "rxd must be > "
1012                                                          "rx_free_thresh(%d)\n",
1013                                                          (int)rx_free_thresh);
1014                                         else
1015                                                 nb_rxd = (uint16_t) n;
1016                                 } else
1017                                         rte_exit(EXIT_FAILURE,
1018                                                  "rxd(%d) invalid - must be > 0\n",
1019                                                  n);
1020                         }
1021                         if (!strcmp(lgopts[opt_idx].name, "txd")) {
1022                                 n = atoi(optarg);
1023                                 if (n > 0)
1024                                         nb_txd = (uint16_t) n;
1025                                 else
1026                                         rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
1027                         }
1028                         if (!strcmp(lgopts[opt_idx].name, "txpt")) {
1029                                 n = atoi(optarg);
1030                                 if (n >= 0)
1031                                         tx_pthresh = (int8_t)n;
1032                                 else
1033                                         rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
1034                         }
1035                         if (!strcmp(lgopts[opt_idx].name, "txht")) {
1036                                 n = atoi(optarg);
1037                                 if (n >= 0)
1038                                         tx_hthresh = (int8_t)n;
1039                                 else
1040                                         rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
1041                         }
1042                         if (!strcmp(lgopts[opt_idx].name, "txwt")) {
1043                                 n = atoi(optarg);
1044                                 if (n >= 0)
1045                                         tx_wthresh = (int8_t)n;
1046                                 else
1047                                         rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
1048                         }
1049                         if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
1050                                 n = atoi(optarg);
1051                                 if (n >= 0)
1052                                         rx_pthresh = (int8_t)n;
1053                                 else
1054                                         rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
1055                         }
1056                         if (!strcmp(lgopts[opt_idx].name, "rxht")) {
1057                                 n = atoi(optarg);
1058                                 if (n >= 0)
1059                                         rx_hthresh = (int8_t)n;
1060                                 else
1061                                         rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
1062                         }
1063                         if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
1064                                 n = atoi(optarg);
1065                                 if (n >= 0)
1066                                         rx_wthresh = (int8_t)n;
1067                                 else
1068                                         rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
1069                         }
1070                         if (!strcmp(lgopts[opt_idx].name, "rxfreet")) {
1071                                 n = atoi(optarg);
1072                                 if (n >= 0)
1073                                         rx_free_thresh = (int16_t)n;
1074                                 else
1075                                         rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n");
1076                         }
1077                         if (!strcmp(lgopts[opt_idx].name, "tx-queue-stats-mapping")) {
1078                                 if (parse_queue_stats_mapping_config(optarg, TX)) {
1079                                         rte_exit(EXIT_FAILURE,
1080                                                  "invalid TX queue statistics mapping config entered\n");
1081                                 }
1082                         }
1083                         if (!strcmp(lgopts[opt_idx].name, "rx-queue-stats-mapping")) {
1084                                 if (parse_queue_stats_mapping_config(optarg, RX)) {
1085                                         rte_exit(EXIT_FAILURE,
1086                                                  "invalid RX queue statistics mapping config entered\n");
1087                                 }
1088                         }
1089                         if (!strcmp(lgopts[opt_idx].name, "txpkts")) {
1090                                 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1091                                 unsigned int nb_segs;
1092
1093                                 nb_segs = parse_item_list(optarg, "txpkt segments",
1094                                                 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1095                                 if (nb_segs > 0)
1096                                         set_tx_pkt_segments(seg_lengths, nb_segs);
1097                                 else
1098                                         rte_exit(EXIT_FAILURE, "bad txpkts\n");
1099                         }
1100                         if (!strcmp(lgopts[opt_idx].name, "no-flush-rx"))
1101                                 no_flush_rx = 1;
1102                         if (!strcmp(lgopts[opt_idx].name, "disable-link-check"))
1103                                 no_link_check = 1;
1104                         if (!strcmp(lgopts[opt_idx].name, "no-lsc-interrupt"))
1105                                 lsc_interrupt = 0;
1106                         if (!strcmp(lgopts[opt_idx].name, "no-rmv-interrupt"))
1107                                 rmv_interrupt = 0;
1108                         if (!strcmp(lgopts[opt_idx].name, "print-event"))
1109                                 if (parse_event_printing_config(optarg, 1)) {
1110                                         rte_exit(EXIT_FAILURE,
1111                                                  "invalid print-event argument\n");
1112                                 }
1113                         if (!strcmp(lgopts[opt_idx].name, "mask-event"))
1114                                 if (parse_event_printing_config(optarg, 0)) {
1115                                         rte_exit(EXIT_FAILURE,
1116                                                  "invalid mask-event argument\n");
1117                                 }
1118
1119                         break;
1120                 case 'h':
1121                         usage(argv[0]);
1122                         rte_exit(EXIT_SUCCESS, "Displayed help\n");
1123                         break;
1124                 default:
1125                         usage(argv[0]);
1126                         rte_exit(EXIT_FAILURE,
1127                                  "Command line is incomplete or incorrect\n");
1128                         break;
1129                 }
1130         }
1131 }