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