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