app/testpmd: add stats per queue
[dpdk.git] / app / test-pmd / parameters.c
1 /*-
2  *   BSD LICENSE
3  * 
4  *   Copyright(c) 2010-2012 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
35 #include <errno.h>
36 #include <getopt.h>
37 #include <stdarg.h>
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <signal.h>
41 #include <string.h>
42 #include <time.h>
43 #include <fcntl.h>
44 #include <sys/types.h>
45 #include <errno.h>
46
47 #include <sys/queue.h>
48 #include <sys/stat.h>
49
50 #include <stdint.h>
51 #include <unistd.h>
52 #include <inttypes.h>
53
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
56 #include <rte_log.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_launch.h>
62 #include <rte_tailq.h>
63 #include <rte_eal.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
68 #include <rte_ring.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
71 #include <rte_pci.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
75 #include <cmdline_parse.h>
76 #include <cmdline_parse_etheraddr.h>
77
78 #include "testpmd.h"
79
80 static void
81 usage(char* progname)
82 {
83         printf("usage: %s [--interactive|-i] [--help|-h] | ["
84                "--coremask=COREMASK --portmask=PORTMASK --numa "
85                "--eth-peers-configfile= | "
86                "--eth-peer=X,M:M:M:M:M:M | --nb-cores= | --nb-ports= | "
87                "--pkt-filter-mode= |"
88                "--rss-ip | --rss-udp | "
89                "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
90                "--txpt= | --txht= | --txwt= | --txfreet= | "
91                "--txrst= ]\n",
92                progname);
93         printf("  --interactive: run in interactive mode\n");
94         printf("  --help:   display this message and quit\n");
95         printf("  --eth-peers-configfile=name of file with ethernet addresses "
96                "of peer ports\n");
97         printf("  --eth-peer=X,M:M:M:M:M:M set the mac address of the X peer "
98                "port (0 <= X < %d)\n", RTE_MAX_ETHPORTS);
99         printf("  --nb-cores=N set the number of forwarding cores"
100                " (1 <= N <= %d)\n", nb_lcores);
101         printf("  --nb-ports=N set the number of forwarding ports"
102                " (1 <= N <= %d)\n", nb_ports);
103         printf("  --coremask=COREMASK: hexadecimal bitmask of cores running "
104                "the packet forwarding test\n");
105         printf("  --portmask=PORTMASK: hexadecimal bitmask of ports used "
106                "by the packet forwarding test\n");
107         printf("  --numa: enable NUMA-aware allocation of RX/TX rings and of "
108                " RX memory buffers (mbufs)\n");
109         printf("  --mbuf-size=N set the data size of mbuf to N bytes\n");
110         printf("  --max-pkt-len=N set the maximum size of packet to N bytes\n");
111         printf("  --pkt-filter-mode=N: set Flow director mode "
112                "( N: none (default mode) or signature or perfect)\n");
113         printf("  --pkt-filter-report-hash=N: set Flow director report mode "
114                "( N: none  or match (default) or always)\n");
115         printf("  --pkt-filter-size=N: set Flow director mode "
116                "( N: 64K (default mode) or 128K or 256K)\n");
117         printf("  --pkt-filter-flexbytes-offset=N: set flexbytes-offset."
118                " The offset is defined in word units counted from the"
119                " first byte of the destination Ethernet MAC address."
120                " 0 <= N <= 32\n");
121         printf("  --pkt-filter-drop-queue=N: set drop-queue."
122                " In perfect mode, when you add a rule with queue -1"
123                " the packet will be enqueued into the rx drop-queue."
124                " If the drop-queue doesn't exist, the packet is dropped."
125                " By default drop-queue=127\n");
126         printf("  --crc-strip: enable CRC stripping by hardware\n");
127         printf("  --enable-rx-cksum: enable rx hardware checksum offload\n");
128         printf("  --disable-hw-vlan: disable hardware vlan\n");
129         printf("  --disable-rss: disable rss\n");
130         printf("  --port-topology=N: set port topology (N: paired (default) or "
131                "chained)\n");
132         printf("  --rss-ip:  set RSS functions to IPv4/IPv6 only \n");
133         printf("  --rss-udp: set RSS functions to IPv4/IPv6 + UDP\n");
134         printf("  --rxq=N    set the number of RX queues per port to N\n");
135         printf("  --rxd=N    set the number of descriptors in RX rings to N\n");
136         printf("  --txq=N    set the number of TX queues per port to N\n");
137         printf("  --txd=N    set the number of descriptors in TX rings to N\n");
138         printf("  --burst=N  set the number of packets per burst to N\n");
139         printf("  --mbcache=N  set the cache of mbuf memory pool to N\n");
140         printf("  --rxpt=N   set prefetch threshold register of RX rings to N"
141                " (0 <= N <= 16)\n");
142         printf("  --rxht=N  set the host threshold register of RX rings to N"
143                " (0 <= N <= 16)\n");
144         printf("  --rxfreet=N set the free threshold of RX descriptors to N"
145                " (0 <= N < value of rxd)\n");
146         printf("  --rxwt=N  set the write-back threshold register of RX rings"
147                " to N (0 <= N <= 16)\n");
148         printf("  --txpt=N  set the prefetch threshold register of TX rings"
149                " to N (0 <= N <= 16)\n");
150         printf("  --txht=N  set the nhost threshold register of TX rings to N"
151                " (0 <= N <= 16)\n");
152         printf("  --txwt=N  set the write-back threshold register of TX rings"
153                " to N (0 <= N <= 16)\n");
154         printf("  --txfreet=N set the transmit free threshold of TX rings to N"
155                " (0 <= N <= value of txd)\n");
156         printf("  --txrst=N set the transmit RS bit threshold of TX rings to N"
157                " (0 <= N <= value of txd)\n");
158         printf("  --tx-queue-stats-mapping (port,queue,mapping)[,(port,queue,mapping]:"
159                " tx queues statistics counters mapping"
160                " (0 <= mapping <= %d)\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
161         printf("  --rx-queue-stats-mapping (port,queue,mapping)[,(port,queue,mapping]:"
162                " rx queues statistics counters mapping"
163                " (0 <= mapping <= %d)\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
164 }
165
166 static int
167 init_peer_eth_addrs(char *config_filename)
168 {
169         FILE *config_file;
170         portid_t i;
171         char buf[50];
172
173         config_file = fopen(config_filename, "r");
174         if (config_file == NULL) {
175                 perror("open log file failed\n");
176                 return -1;
177         }
178
179         for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
180
181                 if (fgets(buf, sizeof(buf), config_file) == NULL)
182                         break;
183
184                 if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i]) < 0 ){
185                         printf("bad format of mac address on line %d\n", i);
186                         fclose(config_file);
187                         return -1;
188                 }
189         }
190         fclose(config_file);
191         nb_peer_eth_addrs = (portid_t) i;
192         return 0;
193 }
194
195 /*
196  * Parse the coremask given as argument (hexadecimal string) and set
197  * the global configuration of forwarding cores.
198  */
199 static void
200 parse_fwd_coremask(const char *coremask)
201 {
202         char *end;
203         unsigned long long int cm;
204
205         /* parse hexadecimal string */
206         end = NULL;
207         cm = strtoull(coremask, &end, 16);
208         if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0'))
209                 rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n");
210         else
211                 set_fwd_lcores_mask((uint64_t) cm);
212 }
213
214 /*
215  * Parse the coremask given as argument (hexadecimal string) and set
216  * the global configuration of forwarding cores.
217  */
218 static void
219 parse_fwd_portmask(const char *portmask)
220 {
221         char *end;
222         unsigned long long int pm;
223
224         /* parse hexadecimal string */
225         end = NULL;
226         pm = strtoull(portmask, &end, 16);
227         if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
228                 rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n");
229         else
230                 set_fwd_ports_mask((uint64_t) pm);
231 }
232
233
234 static int
235 parse_queue_stats_mapping_config(const char *q_arg, int is_rx)
236 {
237         char s[256];
238         const char *p, *p0 = q_arg;
239         char *end;
240         enum fieldnames {
241                 FLD_PORT = 0,
242                 FLD_QUEUE,
243                 FLD_STATS_COUNTER,
244                 _NUM_FLD
245         };
246         unsigned long int_fld[_NUM_FLD];
247         char *str_fld[_NUM_FLD];
248         int i;
249         unsigned size;
250
251         /* reset from value set at definition */
252         is_rx ? (nb_rx_queue_stats_mappings = 0) : (nb_tx_queue_stats_mappings = 0);
253
254         while ((p = strchr(p0,'(')) != NULL) {
255                 ++p;
256                 if((p0 = strchr(p,')')) == NULL)
257                         return -1;
258
259                 size = p0 - p;
260                 if(size >= sizeof(s))
261                         return -1;
262
263                 rte_snprintf(s, sizeof(s), "%.*s", size, p);
264                 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
265                         return -1;
266                 for (i = 0; i < _NUM_FLD; i++){
267                         errno = 0;
268                         int_fld[i] = strtoul(str_fld[i], &end, 0);
269                         if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
270                                 return -1;
271                 }
272                 /* Check mapping field is in correct range (0..RTE_ETHDEV_QUEUE_STAT_CNTRS-1) */
273                 if (int_fld[FLD_STATS_COUNTER] >= RTE_ETHDEV_QUEUE_STAT_CNTRS) {
274                         printf("Stats counter not in the correct range 0..%d\n",
275                                         RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
276                         return -1;
277                 }
278
279                 if (is_rx ? (nb_rx_queue_stats_mappings >= MAX_RX_QUEUE_STATS_MAPPINGS) :
280                     (nb_tx_queue_stats_mappings >= MAX_TX_QUEUE_STATS_MAPPINGS)) {
281                         printf("exceeded max number of %s queue statistics mappings: %hu\n",
282                                is_rx ? "RX" : "TX",
283                                is_rx ? nb_rx_queue_stats_mappings : nb_tx_queue_stats_mappings);
284                         return -1;
285                 }
286                 if (!is_rx) {
287                         tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id =
288                                 (uint8_t)int_fld[FLD_PORT];
289                         tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id =
290                                 (uint8_t)int_fld[FLD_QUEUE];
291                         tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].stats_counter_id =
292                                 (uint8_t)int_fld[FLD_STATS_COUNTER];
293                         ++nb_tx_queue_stats_mappings;
294                 }
295                 else {
296                         rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id =
297                                 (uint8_t)int_fld[FLD_PORT];
298                         rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id =
299                                 (uint8_t)int_fld[FLD_QUEUE];
300                         rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].stats_counter_id =
301                                 (uint8_t)int_fld[FLD_STATS_COUNTER];
302                         ++nb_rx_queue_stats_mappings;
303                 }
304
305         }
306 /* Reassign the rx/tx_queue_stats_mappings pointer to point to this newly populated array rather */
307 /* than to the default array (that was set at its definition) */
308         is_rx ? (rx_queue_stats_mappings = rx_queue_stats_mappings_array) :
309                 (tx_queue_stats_mappings = tx_queue_stats_mappings_array);
310         return 0;
311 }
312
313
314 void
315 launch_args_parse(int argc, char** argv)
316 {
317         int n, opt;
318         char **argvopt;
319         int opt_idx;
320         static struct option lgopts[] = {
321                 { "help",                       0, 0, 0 },
322                 { "interactive",                0, 0, 0 },
323                 { "eth-peers-configfile",       1, 0, 0 },
324                 { "eth-peer",                   1, 0, 0 },
325                 { "ports",                      1, 0, 0 },
326                 { "nb-cores",                   1, 0, 0 },
327                 { "nb-ports",                   1, 0, 0 },
328                 { "coremask",                   1, 0, 0 },
329                 { "portmask",                   1, 0, 0 },
330                 { "numa",                       0, 0, 0 },
331                 { "mbuf-size",                  1, 0, 0 },
332                 { "max-pkt-len",                1, 0, 0 },
333                 { "pkt-filter-mode",            1, 0, 0 },
334                 { "pkt-filter-report-hash",     1, 0, 0 },
335                 { "pkt-filter-size",            1, 0, 0 },
336                 { "pkt-filter-flexbytes-offset",1, 0, 0 },
337                 { "pkt-filter-drop-queue",      1, 0, 0 },
338                 { "crc-strip",                  0, 0, 0 },
339                 { "disable-hw-vlan",            0, 0, 0 },
340                 { "disable-rss",                0, 0, 0 },
341                 { "port-topology",              1, 0, 0 },
342                 { "rss-ip",                     0, 0, 0 },
343                 { "rss-udp",                    0, 0, 0 },
344                 { "rxq",                        1, 0, 0 },
345                 { "txq",                        1, 0, 0 },
346                 { "rxd",                        1, 0, 0 },
347                 { "txd",                        1, 0, 0 },
348                 { "burst",                      1, 0, 0 },
349                 { "mbcache",                    1, 0, 0 },
350                 { "txpt",                       1, 0, 0 },
351                 { "txht",                       1, 0, 0 },
352                 { "txwt",                       1, 0, 0 },
353                 { "txfreet",                    1, 0, 0 },
354                 { "txrst",                      1, 0, 0 },
355                 { "rxpt",                       1, 0, 0 },
356                 { "rxht",                       1, 0, 0 },
357                 { "rxwt",                       1, 0, 0 },
358                 { "rxfreet",                    1, 0, 0 },
359                 { "tx-queue-stats-mapping",     1, 0, 0 },
360                 { "rx-queue-stats-mapping",     1, 0, 0 },
361                 { 0, 0, 0, 0 },
362         };
363
364         argvopt = argv;
365
366         while ((opt = getopt_long(argc, argvopt, "ih",
367                                  lgopts, &opt_idx)) != EOF) {
368                 switch (opt) {
369                 case 'i':
370                         printf("Interactive-mode selected\n");
371                         interactive = 1;
372                         break;
373                 case 0: /*long options */
374                         if (!strcmp(lgopts[opt_idx].name, "help")) {
375                                 usage(argv[0]);
376                                 rte_exit(EXIT_SUCCESS, "Displayed help\n");
377                         }
378                         if (!strcmp(lgopts[opt_idx].name, "interactive")) {
379                                 printf("Interactive-mode selected\n");
380                                 interactive = 1;
381                         }
382                         if (!strcmp(lgopts[opt_idx].name,
383                                     "eth-peers-configfile")) {
384                                 if (init_peer_eth_addrs(optarg) != 0)
385                                         rte_exit(EXIT_FAILURE,
386                                                  "Cannot open logfile\n");
387                         }
388                         if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
389                                 char *port_end;
390                                 uint8_t c, peer_addr[6];
391
392                                 errno = 0;
393                                 n = strtoul(optarg, &port_end, 10);
394                                 if (errno != 0 || port_end == optarg || *port_end++ != ',')
395                                         rte_exit(EXIT_FAILURE,
396                                                  "Invalid eth-peer: %s", optarg);
397                                 if (n >= RTE_MAX_ETHPORTS)
398                                         rte_exit(EXIT_FAILURE,
399                                                  "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n",
400                                                  n, RTE_MAX_ETHPORTS);
401
402                                 if (cmdline_parse_etheraddr(NULL, port_end, &peer_addr) < 0 )
403                                         rte_exit(EXIT_FAILURE,
404                                                  "Invalid ethernet address: %s\n",
405                                                  port_end);
406                                 for (c = 0; c < 6; c++)
407                                         peer_eth_addrs[n].addr_bytes[c] =
408                                                 peer_addr[c];
409                                 nb_peer_eth_addrs++;
410                         }
411                         if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
412                                 n = atoi(optarg);
413                                 if (n > 0 && n <= nb_ports)
414                                         nb_fwd_ports = (uint8_t) n;
415                                 else
416                                         rte_exit(EXIT_FAILURE,
417                                                  "nb-ports should be > 0 and <= %d\n",
418                                                  nb_ports);
419                         }
420                         if (!strcmp(lgopts[opt_idx].name, "nb-cores")) {
421                                 n = atoi(optarg);
422                                 if (n > 0 && n <= nb_lcores)
423                                         nb_fwd_lcores = (uint8_t) n;
424                                 else
425                                         rte_exit(EXIT_FAILURE,
426                                                  "nb-cores should be > 0 and <= %d\n",
427                                                  nb_lcores);
428                         }
429                         if (!strcmp(lgopts[opt_idx].name, "coremask"))
430                                 parse_fwd_coremask(optarg);
431                         if (!strcmp(lgopts[opt_idx].name, "portmask"))
432                                 parse_fwd_portmask(optarg);
433                         if (!strcmp(lgopts[opt_idx].name, "numa"))
434                                 numa_support = 1;
435                         if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
436                                 n = atoi(optarg);
437                                 if (n > 0 && n <= 0xFFFF)
438                                         mbuf_data_size = (uint16_t) n;
439                                 else
440                                         rte_exit(EXIT_FAILURE,
441                                                  "mbuf-size should be > 0 and < 65536\n");
442                         }
443                         if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
444                                 n = atoi(optarg);
445                                 if (n >= ETHER_MIN_LEN) {
446                                         rx_mode.max_rx_pkt_len = (uint32_t) n;
447                                         if (n > ETHER_MAX_LEN)
448                                             rx_mode.jumbo_frame = 1;
449                                 } else
450                                         rte_exit(EXIT_FAILURE,
451                                                  "Invalid max-pkt-len=%d - should be > %d\n",
452                                                  n, ETHER_MIN_LEN);
453                         }
454                         if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) {
455                                 if (!strcmp(optarg, "signature"))
456                                         fdir_conf.mode =
457                                                 RTE_FDIR_MODE_SIGNATURE;
458                                 else if (!strcmp(optarg, "perfect"))
459                                         fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
460                                 else if (!strcmp(optarg, "none"))
461                                         fdir_conf.mode = RTE_FDIR_MODE_NONE;
462                                 else
463                                         rte_exit(EXIT_FAILURE,
464                                                  "pkt-mode-invalid %s invalid - must be: "
465                                                  "none, signature or perfect\n",
466                                                  optarg);
467                         }
468                         if (!strcmp(lgopts[opt_idx].name,
469                                     "pkt-filter-report-hash")) {
470                                 if (!strcmp(optarg, "none"))
471                                         fdir_conf.status =
472                                                 RTE_FDIR_NO_REPORT_STATUS;
473                                 else if (!strcmp(optarg, "match"))
474                                         fdir_conf.status =
475                                                 RTE_FDIR_REPORT_STATUS;
476                                 else if (!strcmp(optarg, "always"))
477                                         fdir_conf.status =
478                                                 RTE_FDIR_REPORT_STATUS_ALWAYS;
479                                 else
480                                         rte_exit(EXIT_FAILURE,
481                                                  "pkt-filter-report-hash %s invalid "
482                                                  "- must be: none or match or always\n",
483                                                  optarg);
484                         }
485                         if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) {
486                                 if (!strcmp(optarg, "64K"))
487                                         fdir_conf.pballoc =
488                                                 RTE_FDIR_PBALLOC_64K;
489                                 else if (!strcmp(optarg, "128K"))
490                                         fdir_conf.pballoc =
491                                                 RTE_FDIR_PBALLOC_128K;
492                                 else if (!strcmp(optarg, "256K"))
493                                         fdir_conf.pballoc =
494                                                 RTE_FDIR_PBALLOC_256K;
495                                 else
496                                         rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -"
497                                                  " must be: 64K or 128K or 256K\n",
498                                                  optarg);
499                         }
500                         if (!strcmp(lgopts[opt_idx].name,
501                                     "pkt-filter-flexbytes-offset")) {
502                                 n = atoi(optarg);
503                                 if ( n >= 0 && n <= (int) 32)
504                                         fdir_conf.flexbytes_offset =
505                                                 (uint8_t) n;
506                                 else
507                                         rte_exit(EXIT_FAILURE,
508                                                  "flexbytes %d invalid - must"
509                                                  "be  >= 0 && <= 32\n", n);
510                         }
511                         if (!strcmp(lgopts[opt_idx].name,
512                                     "pkt-filter-drop-queue")) {
513                                 n = atoi(optarg);
514                                 if (n >= 0)
515                                         fdir_conf.drop_queue = (uint8_t) n;
516                                 else
517                                         rte_exit(EXIT_FAILURE,
518                                                  "drop queue %d invalid - must"
519                                                  "be >= 0 \n", n);
520                         }
521                         if (!strcmp(lgopts[opt_idx].name, "crc-strip"))
522                                 rx_mode.hw_strip_crc = 1;
523                         if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
524                                 rx_mode.hw_ip_checksum = 1;
525                         if (!strcmp(lgopts[opt_idx].name, "disable-hw-vlan"))
526                                 rx_mode.hw_vlan_filter = 0;
527                         if (!strcmp(lgopts[opt_idx].name, "disable-rss"))
528                                 rss_hf = 0;
529                         if (!strcmp(lgopts[opt_idx].name, "port-topology")) {
530                                 if (!strcmp(optarg, "paired"))
531                                         port_topology = PORT_TOPOLOGY_PAIRED;
532                                 else if (!strcmp(optarg, "chained"))
533                                         port_topology = PORT_TOPOLOGY_CHAINED;
534                                 else
535                                         rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
536                                                  " must be: paired or chained \n",
537                                                  optarg);
538                         }
539                         if (!strcmp(lgopts[opt_idx].name, "rss-ip"))
540                                 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
541                         if (!strcmp(lgopts[opt_idx].name, "rss-udp"))
542                                 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 |
543                                         ETH_RSS_IPV4_UDP;
544                         if (!strcmp(lgopts[opt_idx].name, "rxq")) {
545                                 n = atoi(optarg);
546                                 if (n >= 1 && n <= (int) MAX_QUEUE_ID)
547                                         nb_rxq = (queueid_t) n;
548                                 else
549                                         rte_exit(EXIT_FAILURE, "rxq %d invalid - must be"
550                                                   " >= 1 && <= %d\n", n,
551                                                   (int) MAX_QUEUE_ID);
552                         }
553                         if (!strcmp(lgopts[opt_idx].name, "txq")) {
554                                 n = atoi(optarg);
555                                 if (n >= 1 && n <= (int) MAX_QUEUE_ID)
556                                         nb_txq = (queueid_t) n;
557                                 else
558                                         rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
559                                                   " >= 1 && <= %d\n", n,
560                                                   (int) MAX_QUEUE_ID);
561                         }
562                         if (!strcmp(lgopts[opt_idx].name, "rxd")) {
563                                 n = atoi(optarg);
564                                 if (n > 0)
565                                         nb_rxd = (uint16_t) n;
566                                 else
567                                         rte_exit(EXIT_FAILURE, "rxd must be > 0\n");
568                         }
569                         if (!strcmp(lgopts[opt_idx].name, "txd")) {
570                                 n = atoi(optarg);
571                                 if (n > 0)
572                                         nb_txd = (uint16_t) n;
573                                 else
574                                         rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
575                         }
576                         if (!strcmp(lgopts[opt_idx].name, "burst")) {
577                                 n = atoi(optarg);
578                                 if ((n >= 1) && (n <= MAX_PKT_BURST))
579                                         nb_pkt_per_burst = (uint16_t) n;
580                                 else
581                                         rte_exit(EXIT_FAILURE,
582                                                  "burst must >= 1 and <= %d]",
583                                                  MAX_PKT_BURST);
584                         }
585                         if (!strcmp(lgopts[opt_idx].name, "mbcache")) {
586                                 n = atoi(optarg);
587                                 if ((n >= 0) &&
588                                     (n <= RTE_MEMPOOL_CACHE_MAX_SIZE))
589                                         mb_mempool_cache = (uint16_t) n;
590                                 else
591                                         rte_exit(EXIT_FAILURE,
592                                                  "mbcache must be >= 0 and <= %d\n",
593                                                  RTE_MEMPOOL_CACHE_MAX_SIZE);
594                         }
595                         if (!strcmp(lgopts[opt_idx].name, "txpt")) {
596                                 n = atoi(optarg);
597                                 if (n >= 0)
598                                         tx_thresh.pthresh = (uint8_t)n;
599                                 else
600                                         rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
601                         }
602                         if (!strcmp(lgopts[opt_idx].name, "txht")) {
603                                 n = atoi(optarg);
604                                 if (n >= 0)
605                                         tx_thresh.hthresh = (uint8_t)n;
606                                 else
607                                         rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
608                         }
609                         if (!strcmp(lgopts[opt_idx].name, "txwt")) {
610                                 n = atoi(optarg);
611                                 if (n >= 0)
612                                         tx_thresh.wthresh = (uint8_t)n;
613                                 else
614                                         rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
615                         }
616                         if (!strcmp(lgopts[opt_idx].name, "txfreet")) {
617                                 n = atoi(optarg);
618                                 if (n >= 0)
619                                         tx_free_thresh = (uint16_t)n;
620                                 else
621                                         rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n");
622                         }
623                         if (!strcmp(lgopts[opt_idx].name, "txrst")) {
624                                 n = atoi(optarg);
625                                 if (n >= 0)
626                                         tx_rs_thresh = (uint16_t)n;
627                                 else
628                                         rte_exit(EXIT_FAILURE, "txrst must be >= 0\n");
629                         }
630                         if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
631                                 n = atoi(optarg);
632                                 if (n >= 0)
633                                         rx_thresh.pthresh = (uint8_t)n;
634                                 else
635                                         rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
636                         }
637                         if (!strcmp(lgopts[opt_idx].name, "rxht")) {
638                                 n = atoi(optarg);
639                                 if (n >= 0)
640                                         rx_thresh.hthresh = (uint8_t)n;
641                                 else
642                                         rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
643                         }
644                         if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
645                                 n = atoi(optarg);
646                                 if (n >= 0)
647                                         rx_thresh.wthresh = (uint8_t)n;
648                                 else
649                                         rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
650                         }
651                         if (!strcmp(lgopts[opt_idx].name, "rxd")) {
652                                 n = atoi(optarg);
653                                 if (n > 0) {
654                                         if (rx_free_thresh >= n)
655                                                 rte_exit(EXIT_FAILURE,
656                                                          "rxd must be > "
657                                                          "rx_free_thresh(%d)\n",
658                                                          (int)rx_free_thresh);
659                                         else
660                                                 nb_rxd = (uint16_t) n;
661                                 } else
662                                         rte_exit(EXIT_FAILURE,
663                                                  "rxd(%d) invalid - must be > 0\n",
664                                                  n);
665                         }
666                         if (!strcmp(lgopts[opt_idx].name, "txd")) {
667                                 n = atoi(optarg);
668                                 if (n > 0)
669                                         nb_txd = (uint16_t) n;
670                                 else
671                                         rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
672                         }
673                         if (!strcmp(lgopts[opt_idx].name, "txpt")) {
674                                 n = atoi(optarg);
675                                 if (n >= 0)
676                                         tx_thresh.pthresh = (uint8_t)n;
677                                 else
678                                         rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
679                         }
680                         if (!strcmp(lgopts[opt_idx].name, "txht")) {
681                                 n = atoi(optarg);
682                                 if (n >= 0)
683                                         tx_thresh.hthresh = (uint8_t)n;
684                                 else
685                                         rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
686                         }
687                         if (!strcmp(lgopts[opt_idx].name, "txwt")) {
688                                 n = atoi(optarg);
689                                 if (n >= 0)
690                                         tx_thresh.wthresh = (uint8_t)n;
691                                 else
692                                         rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
693                         }
694                         if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
695                                 n = atoi(optarg);
696                                 if (n >= 0)
697                                         rx_thresh.pthresh = (uint8_t)n;
698                                 else
699                                         rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
700                         }
701                         if (!strcmp(lgopts[opt_idx].name, "rxht")) {
702                                 n = atoi(optarg);
703                                 if (n >= 0)
704                                         rx_thresh.hthresh = (uint8_t)n;
705                                 else
706                                         rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
707                         }
708                         if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
709                                 n = atoi(optarg);
710                                 if (n >= 0)
711                                         rx_thresh.wthresh = (uint8_t)n;
712                                 else
713                                         rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
714                         }
715                         if (!strcmp(lgopts[opt_idx].name, "rxfreet")) {
716                                 n = atoi(optarg);
717                                 if (n >= 0)
718                                         rx_free_thresh = (uint16_t)n;
719                                 else
720                                         rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n");
721                         }
722                         if (!strcmp(lgopts[opt_idx].name, "tx-queue-stats-mapping")) {
723                                 if (parse_queue_stats_mapping_config(optarg, TX)) {
724                                         rte_exit(EXIT_FAILURE,
725                                                  "invalid TX queue statistics mapping config entered\n");
726                                 }
727                         }
728                         if (!strcmp(lgopts[opt_idx].name, "rx-queue-stats-mapping")) {
729                                 if (parse_queue_stats_mapping_config(optarg, RX)) {
730                                         rte_exit(EXIT_FAILURE,
731                                                  "invalid RX queue statistics mapping config entered\n");
732                                 }
733                         }
734                         break;
735                 case 'h':
736                         usage(argv[0]);
737                         rte_exit(EXIT_SUCCESS, "Displayed help\n");
738                         break;
739                 default:
740                         usage(argv[0]);
741                         rte_exit(EXIT_FAILURE,
742                                  "Command line is incomplete or incorrect\n");
743                         break;
744                 }
745         }
746 }