remove version in all files
[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 }
159
160 static int
161 init_peer_eth_addrs(char *config_filename)
162 {
163         FILE *config_file;
164         portid_t i;
165         char buf[50];
166
167         config_file = fopen(config_filename, "r");
168         if (config_file == NULL) {
169                 perror("open log file failed\n");
170                 return -1;
171         }
172
173         for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
174
175                 if (fgets(buf, sizeof(buf), config_file) == NULL)
176                         break;
177
178                 if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i]) < 0 ){
179                         printf("bad format of mac address on line %d\n", i);
180                         fclose(config_file);
181                         return -1;
182                 }
183         }
184         fclose(config_file);
185         nb_peer_eth_addrs = (portid_t) i;
186         return 0;
187 }
188
189 /*
190  * Parse the coremask given as argument (hexadecimal string) and set
191  * the global configuration of forwarding cores.
192  */
193 static void
194 parse_fwd_coremask(const char *coremask)
195 {
196         char *end;
197         unsigned long long int cm;
198
199         /* parse hexadecimal string */
200         end = NULL;
201         cm = strtoull(coremask, &end, 16);
202         if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0'))
203                 rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n");
204         else
205                 set_fwd_lcores_mask((uint64_t) cm);
206 }
207
208 /*
209  * Parse the coremask given as argument (hexadecimal string) and set
210  * the global configuration of forwarding cores.
211  */
212 static void
213 parse_fwd_portmask(const char *portmask)
214 {
215         char *end;
216         unsigned long long int pm;
217
218         /* parse hexadecimal string */
219         end = NULL;
220         pm = strtoull(portmask, &end, 16);
221         if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
222                 rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n");
223         else
224                 set_fwd_ports_mask((uint64_t) pm);
225 }
226
227 void
228 launch_args_parse(int argc, char** argv)
229 {
230         int n, opt;
231         char **argvopt;
232         int opt_idx;
233         static struct option lgopts[] = {
234                 { "help",                       0, 0, 0 },
235                 { "interactive",                0, 0, 0 },
236                 { "eth-peers-configfile",       1, 0, 0 },
237                 { "eth-peer",                   1, 0, 0 },
238                 { "ports",                      1, 0, 0 },
239                 { "nb-cores",                   1, 0, 0 },
240                 { "nb-ports",                   1, 0, 0 },
241                 { "coremask",                   1, 0, 0 },
242                 { "portmask",                   1, 0, 0 },
243                 { "numa",                       0, 0, 0 },
244                 { "mbuf-size",                  1, 0, 0 },
245                 { "max-pkt-len",                1, 0, 0 },
246                 { "pkt-filter-mode",            1, 0, 0 },
247                 { "pkt-filter-report-hash",     1, 0, 0 },
248                 { "pkt-filter-size",            1, 0, 0 },
249                 { "pkt-filter-flexbytes-offset",1, 0, 0 },
250                 { "pkt-filter-drop-queue",      1, 0, 0 },
251                 { "crc-strip",                  0, 0, 0 },
252                 { "disable-hw-vlan",            0, 0, 0 },
253                 { "disable-rss",                0, 0, 0 },
254                 { "port-topology",              1, 0, 0 },
255                 { "rss-ip",                     0, 0, 0 },
256                 { "rss-udp",                    0, 0, 0 },
257                 { "rxq",                        1, 0, 0 },
258                 { "txq",                        1, 0, 0 },
259                 { "rxd",                        1, 0, 0 },
260                 { "txd",                        1, 0, 0 },
261                 { "burst",                      1, 0, 0 },
262                 { "mbcache",                    1, 0, 0 },
263                 { "txpt",                       1, 0, 0 },
264                 { "txht",                       1, 0, 0 },
265                 { "txwt",                       1, 0, 0 },
266                 { "txfreet",                    1, 0, 0 },
267                 { "txrst",                      1, 0, 0 },
268                 { "rxpt",                       1, 0, 0 },
269                 { "rxht",                       1, 0, 0 },
270                 { "rxwt",                       1, 0, 0 },
271                 { "rxfreet",                    1, 0, 0 },
272                 { 0, 0, 0, 0 },
273         };
274
275         argvopt = argv;
276
277         while ((opt = getopt_long(argc, argvopt, "ih",
278                                  lgopts, &opt_idx)) != EOF) {
279                 switch (opt) {
280                 case 'i':
281                         printf("Interactive-mode selected\n");
282                         interactive = 1;
283                         break;
284                 case 0: /*long options */
285                         if (!strcmp(lgopts[opt_idx].name, "help")) {
286                                 usage(argv[0]);
287                                 rte_exit(EXIT_SUCCESS, "Displayed help\n");
288                         }
289                         if (!strcmp(lgopts[opt_idx].name, "interactive")) {
290                                 printf("Interactive-mode selected\n");
291                                 interactive = 1;
292                         }
293                         if (!strcmp(lgopts[opt_idx].name,
294                                     "eth-peers-configfile")) {
295                                 if (init_peer_eth_addrs(optarg) != 0)
296                                         rte_exit(EXIT_FAILURE,
297                                                  "Cannot open logfile\n");
298                         }
299                         if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
300                                 char *port_end;
301                                 uint8_t c, peer_addr[6];
302
303                                 errno = 0;
304                                 n = strtoul(optarg, &port_end, 10);
305                                 if (errno != 0 || port_end == optarg || *port_end++ != ',')
306                                         rte_exit(EXIT_FAILURE,
307                                                  "Invalid eth-peer: %s", optarg);
308                                 if (n >= RTE_MAX_ETHPORTS)
309                                         rte_exit(EXIT_FAILURE,
310                                                  "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n",
311                                                  n, RTE_MAX_ETHPORTS);
312
313                                 if (cmdline_parse_etheraddr(NULL, port_end, &peer_addr) < 0 )
314                                         rte_exit(EXIT_FAILURE,
315                                                  "Invalid ethernet address: %s\n",
316                                                  port_end);
317                                 for (c = 0; c < 6; c++)
318                                         peer_eth_addrs[n].addr_bytes[c] =
319                                                 peer_addr[c];
320                                 nb_peer_eth_addrs++;
321                         }
322                         if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
323                                 n = atoi(optarg);
324                                 if (n > 0 && n <= nb_ports)
325                                         nb_fwd_ports = (uint8_t) n;
326                                 else
327                                         rte_exit(EXIT_FAILURE,
328                                                  "nb-ports should be > 0 and <= %d\n",
329                                                  nb_ports);
330                         }
331                         if (!strcmp(lgopts[opt_idx].name, "nb-cores")) {
332                                 n = atoi(optarg);
333                                 if (n > 0 && n <= nb_lcores)
334                                         nb_fwd_lcores = (uint8_t) n;
335                                 else
336                                         rte_exit(EXIT_FAILURE,
337                                                  "nb-cores should be > 0 and <= %d\n",
338                                                  nb_lcores);
339                         }
340                         if (!strcmp(lgopts[opt_idx].name, "coremask"))
341                                 parse_fwd_coremask(optarg);
342                         if (!strcmp(lgopts[opt_idx].name, "portmask"))
343                                 parse_fwd_portmask(optarg);
344                         if (!strcmp(lgopts[opt_idx].name, "numa"))
345                                 numa_support = 1;
346                         if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
347                                 n = atoi(optarg);
348                                 if (n > 0 && n <= 0xFFFF)
349                                         mbuf_data_size = (uint16_t) n;
350                                 else
351                                         rte_exit(EXIT_FAILURE,
352                                                  "mbuf-size should be > 0 and < 65536\n");
353                         }
354                         if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
355                                 n = atoi(optarg);
356                                 if (n >= ETHER_MIN_LEN) {
357                                         rx_mode.max_rx_pkt_len = (uint32_t) n;
358                                         if (n > ETHER_MAX_LEN)
359                                             rx_mode.jumbo_frame = 1;
360                                 } else
361                                         rte_exit(EXIT_FAILURE,
362                                                  "Invalid max-pkt-len=%d - should be > %d\n",
363                                                  n, ETHER_MIN_LEN);
364                         }
365                         if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) {
366                                 if (!strcmp(optarg, "signature"))
367                                         fdir_conf.mode =
368                                                 RTE_FDIR_MODE_SIGNATURE;
369                                 else if (!strcmp(optarg, "perfect"))
370                                         fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
371                                 else if (!strcmp(optarg, "none"))
372                                         fdir_conf.mode = RTE_FDIR_MODE_NONE;
373                                 else
374                                         rte_exit(EXIT_FAILURE,
375                                                  "pkt-mode-invalid %s invalid - must be: "
376                                                  "none, signature or perfect\n",
377                                                  optarg);
378                         }
379                         if (!strcmp(lgopts[opt_idx].name,
380                                     "pkt-filter-report-hash")) {
381                                 if (!strcmp(optarg, "none"))
382                                         fdir_conf.status =
383                                                 RTE_FDIR_NO_REPORT_STATUS;
384                                 else if (!strcmp(optarg, "match"))
385                                         fdir_conf.status =
386                                                 RTE_FDIR_REPORT_STATUS;
387                                 else if (!strcmp(optarg, "always"))
388                                         fdir_conf.status =
389                                                 RTE_FDIR_REPORT_STATUS_ALWAYS;
390                                 else
391                                         rte_exit(EXIT_FAILURE,
392                                                  "pkt-filter-report-hash %s invalid "
393                                                  "- must be: none or match or always\n",
394                                                  optarg);
395                         }
396                         if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) {
397                                 if (!strcmp(optarg, "64K"))
398                                         fdir_conf.pballoc =
399                                                 RTE_FDIR_PBALLOC_64K;
400                                 else if (!strcmp(optarg, "128K"))
401                                         fdir_conf.pballoc =
402                                                 RTE_FDIR_PBALLOC_128K;
403                                 else if (!strcmp(optarg, "256K"))
404                                         fdir_conf.pballoc =
405                                                 RTE_FDIR_PBALLOC_256K;
406                                 else
407                                         rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -"
408                                                  " must be: 64K or 128K or 256K\n",
409                                                  optarg);
410                         }
411                         if (!strcmp(lgopts[opt_idx].name,
412                                     "pkt-filter-flexbytes-offset")) {
413                                 n = atoi(optarg);
414                                 if ( n >= 0 && n <= (int) 32)
415                                         fdir_conf.flexbytes_offset =
416                                                 (uint8_t) n;
417                                 else
418                                         rte_exit(EXIT_FAILURE,
419                                                  "flexbytes %d invalid - must"
420                                                  "be  >= 0 && <= 32\n", n);
421                         }
422                         if (!strcmp(lgopts[opt_idx].name,
423                                     "pkt-filter-drop-queue")) {
424                                 n = atoi(optarg);
425                                 if (n >= 0)
426                                         fdir_conf.drop_queue = (uint8_t) n;
427                                 else
428                                         rte_exit(EXIT_FAILURE,
429                                                  "drop queue %d invalid - must"
430                                                  "be >= 0 \n", n);
431                         }
432                         if (!strcmp(lgopts[opt_idx].name, "crc-strip"))
433                                 rx_mode.hw_strip_crc = 1;
434                         if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
435                                 rx_mode.hw_ip_checksum = 1;
436                         if (!strcmp(lgopts[opt_idx].name, "disable-hw-vlan"))
437                                 rx_mode.hw_vlan_filter = 0;
438                         if (!strcmp(lgopts[opt_idx].name, "disable-rss"))
439                                 rss_hf = 0;
440                         if (!strcmp(lgopts[opt_idx].name, "port-topology")) {
441                                 if (!strcmp(optarg, "paired"))
442                                         port_topology = PORT_TOPOLOGY_PAIRED;
443                                 else if (!strcmp(optarg, "chained"))
444                                         port_topology = PORT_TOPOLOGY_CHAINED;
445                                 else
446                                         rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
447                                                  " must be: paired or chained \n",
448                                                  optarg);
449                         }
450                         if (!strcmp(lgopts[opt_idx].name, "rss-ip"))
451                                 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
452                         if (!strcmp(lgopts[opt_idx].name, "rss-udp"))
453                                 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 |
454                                         ETH_RSS_IPV4_UDP;
455                         if (!strcmp(lgopts[opt_idx].name, "rxq")) {
456                                 n = atoi(optarg);
457                                 if (n >= 1 && n <= (int) MAX_QUEUE_ID)
458                                         nb_rxq = (queueid_t) n;
459                                 else
460                                         rte_exit(EXIT_FAILURE, "rxq %d invalid - must be"
461                                                   " >= 1 && <= %d\n", n,
462                                                   (int) MAX_QUEUE_ID);
463                         }
464                         if (!strcmp(lgopts[opt_idx].name, "txq")) {
465                                 n = atoi(optarg);
466                                 if (n >= 1 && n <= (int) MAX_QUEUE_ID)
467                                         nb_txq = (queueid_t) n;
468                                 else
469                                         rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
470                                                   " >= 1 && <= %d\n", n,
471                                                   (int) MAX_QUEUE_ID);
472                         }
473                         if (!strcmp(lgopts[opt_idx].name, "rxd")) {
474                                 n = atoi(optarg);
475                                 if (n > 0)
476                                         nb_rxd = (uint16_t) n;
477                                 else
478                                         rte_exit(EXIT_FAILURE, "rxd must be > 0\n");
479                         }
480                         if (!strcmp(lgopts[opt_idx].name, "txd")) {
481                                 n = atoi(optarg);
482                                 if (n > 0)
483                                         nb_txd = (uint16_t) n;
484                                 else
485                                         rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
486                         }
487                         if (!strcmp(lgopts[opt_idx].name, "burst")) {
488                                 n = atoi(optarg);
489                                 if ((n >= 1) && (n <= MAX_PKT_BURST))
490                                         nb_pkt_per_burst = (uint16_t) n;
491                                 else
492                                         rte_exit(EXIT_FAILURE,
493                                                  "burst must >= 1 and <= %d]",
494                                                  MAX_PKT_BURST);
495                         }
496                         if (!strcmp(lgopts[opt_idx].name, "mbcache")) {
497                                 n = atoi(optarg);
498                                 if ((n >= 0) &&
499                                     (n <= RTE_MEMPOOL_CACHE_MAX_SIZE))
500                                         mb_mempool_cache = (uint16_t) n;
501                                 else
502                                         rte_exit(EXIT_FAILURE,
503                                                  "mbcache must be >= 0 and <= %d\n",
504                                                  RTE_MEMPOOL_CACHE_MAX_SIZE);
505                         }
506                         if (!strcmp(lgopts[opt_idx].name, "txpt")) {
507                                 n = atoi(optarg);
508                                 if (n >= 0)
509                                         tx_thresh.pthresh = (uint8_t)n;
510                                 else
511                                         rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
512                         }
513                         if (!strcmp(lgopts[opt_idx].name, "txht")) {
514                                 n = atoi(optarg);
515                                 if (n >= 0)
516                                         tx_thresh.hthresh = (uint8_t)n;
517                                 else
518                                         rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
519                         }
520                         if (!strcmp(lgopts[opt_idx].name, "txwt")) {
521                                 n = atoi(optarg);
522                                 if (n >= 0)
523                                         tx_thresh.wthresh = (uint8_t)n;
524                                 else
525                                         rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
526                         }
527                         if (!strcmp(lgopts[opt_idx].name, "txfreet")) {
528                                 n = atoi(optarg);
529                                 if (n >= 0)
530                                         tx_free_thresh = (uint16_t)n;
531                                 else
532                                         rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n");
533                         }
534                         if (!strcmp(lgopts[opt_idx].name, "txrst")) {
535                                 n = atoi(optarg);
536                                 if (n >= 0)
537                                         tx_rs_thresh = (uint16_t)n;
538                                 else
539                                         rte_exit(EXIT_FAILURE, "txrst must be >= 0\n");
540                         }
541                         if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
542                                 n = atoi(optarg);
543                                 if (n >= 0)
544                                         rx_thresh.pthresh = (uint8_t)n;
545                                 else
546                                         rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
547                         }
548                         if (!strcmp(lgopts[opt_idx].name, "rxht")) {
549                                 n = atoi(optarg);
550                                 if (n >= 0)
551                                         rx_thresh.hthresh = (uint8_t)n;
552                                 else
553                                         rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
554                         }
555                         if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
556                                 n = atoi(optarg);
557                                 if (n >= 0)
558                                         rx_thresh.wthresh = (uint8_t)n;
559                                 else
560                                         rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
561                         }
562                         if (!strcmp(lgopts[opt_idx].name, "rxd")) {
563                                 n = atoi(optarg);
564                                 if (n > 0) {
565                                         if (rx_free_thresh >= n)
566                                                 rte_exit(EXIT_FAILURE,
567                                                          "rxd must be > "
568                                                          "rx_free_thresh(%d)\n",
569                                                          (int)rx_free_thresh);
570                                         else
571                                                 nb_rxd = (uint16_t) n;
572                                 } else
573                                         rte_exit(EXIT_FAILURE,
574                                                  "rxd(%d) invalid - must be > 0\n",
575                                                  n);
576                         }
577                         if (!strcmp(lgopts[opt_idx].name, "txd")) {
578                                 n = atoi(optarg);
579                                 if (n > 0)
580                                         nb_txd = (uint16_t) n;
581                                 else
582                                         rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
583                         }
584                         if (!strcmp(lgopts[opt_idx].name, "txpt")) {
585                                 n = atoi(optarg);
586                                 if (n >= 0)
587                                         tx_thresh.pthresh = (uint8_t)n;
588                                 else
589                                         rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
590                         }
591                         if (!strcmp(lgopts[opt_idx].name, "txht")) {
592                                 n = atoi(optarg);
593                                 if (n >= 0)
594                                         tx_thresh.hthresh = (uint8_t)n;
595                                 else
596                                         rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
597                         }
598                         if (!strcmp(lgopts[opt_idx].name, "txwt")) {
599                                 n = atoi(optarg);
600                                 if (n >= 0)
601                                         tx_thresh.wthresh = (uint8_t)n;
602                                 else
603                                         rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
604                         }
605                         if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
606                                 n = atoi(optarg);
607                                 if (n >= 0)
608                                         rx_thresh.pthresh = (uint8_t)n;
609                                 else
610                                         rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
611                         }
612                         if (!strcmp(lgopts[opt_idx].name, "rxht")) {
613                                 n = atoi(optarg);
614                                 if (n >= 0)
615                                         rx_thresh.hthresh = (uint8_t)n;
616                                 else
617                                         rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
618                         }
619                         if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
620                                 n = atoi(optarg);
621                                 if (n >= 0)
622                                         rx_thresh.wthresh = (uint8_t)n;
623                                 else
624                                         rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
625                         }
626                         if (!strcmp(lgopts[opt_idx].name, "rxfreet")) {
627                                 n = atoi(optarg);
628                                 if (n >= 0)
629                                         rx_free_thresh = (uint16_t)n;
630                                 else
631                                         rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n");
632                         }
633                         break;
634                 case 'h':
635                         usage(argv[0]);
636                         rte_exit(EXIT_SUCCESS, "Displayed help\n");
637                         break;
638                 default:
639                         usage(argv[0]);
640                         rte_exit(EXIT_FAILURE,
641                                  "Command line is incomplete or incorrect\n");
642                         break;
643                 }
644         }
645 }