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