xref: /dpdk/app/test-pmd/parameters.c (revision 0dff3f26d6faad4e51f75e5245f0387ee9bb0c6d)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2017 Intel Corporation
3  */
4 
5 #include <errno.h>
6 #include <getopt.h>
7 #include <stdarg.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <signal.h>
11 #include <string.h>
12 #include <time.h>
13 #include <fcntl.h>
14 #include <sys/types.h>
15 
16 #include <sys/queue.h>
17 #include <sys/stat.h>
18 
19 #include <stdint.h>
20 #include <unistd.h>
21 #include <inttypes.h>
22 
23 #include <rte_common.h>
24 #include <rte_byteorder.h>
25 #include <rte_log.h>
26 #include <rte_debug.h>
27 #include <rte_cycles.h>
28 #include <rte_memory.h>
29 #include <rte_launch.h>
30 #include <rte_eal.h>
31 #include <rte_per_lcore.h>
32 #include <rte_lcore.h>
33 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
36 #include <rte_pci.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_flow.h>
41 
42 #include "testpmd.h"
43 
44 static void
45 usage(char* progname)
46 {
47 	printf("\nUsage: %s [EAL options] -- [testpmd options]\n\n",
48 	       progname);
49 #ifdef RTE_LIB_CMDLINE
50 	printf("  --interactive: run in interactive mode.\n");
51 	printf("  --cmdline-file: execute cli commands before startup.\n");
52 #endif
53 	printf("  --auto-start: start forwarding on init "
54 	       "[always when non-interactive].\n");
55 	printf("  --help: display this message and quit.\n");
56 	printf("  --tx-first: start forwarding sending a burst first "
57 	       "(only if interactive is disabled).\n");
58 	printf("  --stats-period=PERIOD: statistics will be shown "
59 	       "every PERIOD seconds (only if interactive is disabled).\n");
60 	printf("  --display-xstats xstat_name1[,...]: comma-separated list of "
61 	       "extended statistics to show. Used with --stats-period "
62 	       "specified or interactive commands that show Rx/Tx statistics "
63 	       "(i.e. 'show port stats').\n");
64 	printf("  --nb-cores=N: set the number of forwarding cores "
65 	       "(1 <= N <= %d).\n", nb_lcores);
66 	printf("  --nb-ports=N: set the number of forwarding ports "
67 	       "(1 <= N <= %d).\n", nb_ports);
68 	printf("  --coremask=COREMASK: hexadecimal bitmask of cores running "
69 	       "the packet forwarding test. The main lcore is reserved for "
70 	       "command line parsing only, and cannot be masked on for "
71 	       "packet forwarding.\n");
72 	printf("  --portmask=PORTMASK: hexadecimal bitmask of ports used "
73 	       "by the packet forwarding test.\n");
74 	printf("  --portlist=PORTLIST: list of forwarding ports\n");
75 	printf("  --numa: enable NUMA-aware allocation of RX/TX rings and of "
76 	       "RX memory buffers (mbufs).\n");
77 	printf("  --no-numa: disable NUMA-aware allocation.\n");
78 	printf("  --port-numa-config=(port,socket)[,(port,socket)]: "
79 	       "specify the socket on which the memory pool "
80 	       "used by the port will be allocated.\n");
81 	printf("  --ring-numa-config=(port,flag,socket)[,(port,flag,socket)]: "
82 	       "specify the socket on which the TX/RX rings for "
83 	       "the port will be allocated "
84 	       "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
85 	printf("  --socket-num=N: set socket from which all memory is allocated "
86 	       "in NUMA mode.\n");
87 	printf("  --mbuf-size=N,[N1[,..Nn]: set the data size of mbuf to "
88 	       "N bytes. If multiple numbers are specified the extra pools "
89 	       "will be created to receive with packet split features\n");
90 	printf("  --total-num-mbufs=N: set the number of mbufs to be allocated "
91 	       "in mbuf pools.\n");
92 	printf("  --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
93 	printf("  --max-lro-pkt-size=N: set the maximum LRO aggregated packet "
94 	       "size to N bytes.\n");
95 #ifdef RTE_LIB_CMDLINE
96 	printf("  --eth-peers-configfile=name: config 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 #endif
101 	printf("  --pkt-filter-mode=N: set Flow Director mode "
102 	       "(N: none (default mode) or signature or perfect).\n");
103 	printf("  --pkt-filter-report-hash=N: set Flow Director report mode "
104 	       "(N: none  or match (default) or always).\n");
105 	printf("  --pkt-filter-size=N: set Flow Director mode "
106 	       "(N: 64K (default mode) or 128K or 256K).\n");
107 	printf("  --pkt-filter-drop-queue=N: set drop-queue. "
108 	       "In perfect mode, when you add a rule with queue = -1 "
109 	       "the packet will be enqueued into the rx drop-queue. "
110 	       "If the drop-queue doesn't exist, the packet is dropped. "
111 	       "By default drop-queue=127.\n");
112 #ifdef RTE_LIB_LATENCYSTATS
113 	printf("  --latencystats=N: enable latency and jitter statistics "
114 	       "monitoring on forwarding lcore id N.\n");
115 #endif
116 	printf("  --disable-crc-strip: disable CRC stripping by hardware.\n");
117 	printf("  --enable-scatter: enable scattered Rx.\n");
118 	printf("  --enable-lro: enable large receive offload.\n");
119 	printf("  --enable-rx-cksum: enable rx hardware checksum offload.\n");
120 	printf("  --enable-rx-timestamp: enable rx hardware timestamp offload.\n");
121 	printf("  --enable-hw-vlan: enable hardware vlan.\n");
122 	printf("  --enable-hw-vlan-filter: enable hardware vlan filter.\n");
123 	printf("  --enable-hw-vlan-strip: enable hardware vlan strip.\n");
124 	printf("  --enable-hw-vlan-extend: enable hardware vlan extend.\n");
125 	printf("  --enable-hw-qinq-strip: enable hardware qinq strip.\n");
126 	printf("  --enable-drop-en: enable per queue packet drop.\n");
127 	printf("  --disable-rss: disable rss.\n");
128 	printf("  --port-topology=<paired|chained|loop>: set port topology (paired "
129 	       "is default).\n");
130 	printf("  --forward-mode=N: set forwarding mode (N: %s).\n",
131 	       list_pkt_forwarding_modes());
132 	printf("  --forward-mode=5tswap: set forwarding mode to "
133 			"swap L2,L3,L4 for MAC, IPv4/IPv6 and TCP/UDP only.\n");
134 	printf("  --rss-ip: set RSS functions to IPv4/IPv6 only .\n");
135 	printf("  --rss-udp: set RSS functions to IPv4/IPv6 + UDP.\n");
136 	printf("  --rss-level-inner: set RSS hash level to innermost\n");
137 	printf("  --rss-level-outer: set RSS hash level to outermost\n");
138 	printf("  --rxq=N: set the number of RX queues per port to N.\n");
139 	printf("  --rxd=N: set the number of descriptors in RX rings to N.\n");
140 	printf("  --txq=N: set the number of TX queues per port to N.\n");
141 	printf("  --txd=N: set the number of descriptors in TX rings to N.\n");
142 	printf("  --hairpinq=N: set the number of hairpin queues per port to "
143 	       "N.\n");
144 	printf("  --burst=N: set the number of packets per burst to N.\n");
145 	printf("  --flowgen-clones=N: set the number of single packet clones to send in flowgen mode. Should be less than burst value.\n");
146 	printf("  --flowgen-flows=N: set the number of flows in flowgen mode to N (1 <= N <= INT32_MAX).\n");
147 	printf("  --mbcache=N: set the cache of mbuf memory pool to N.\n");
148 	printf("  --rxpt=N: set prefetch threshold register of RX rings to N.\n");
149 	printf("  --rxht=N: set the host threshold register of RX rings to N.\n");
150 	printf("  --rxfreet=N: set the free threshold of RX descriptors to N "
151 	       "(0 <= N < value of rxd).\n");
152 	printf("  --rxwt=N: set the write-back threshold register of RX rings to N.\n");
153 	printf("  --txpt=N: set the prefetch threshold register of TX rings to N.\n");
154 	printf("  --txht=N: set the nhost threshold register of TX rings to N.\n");
155 	printf("  --txwt=N: set the write-back threshold register of TX rings to N.\n");
156 	printf("  --txfreet=N: set the transmit free threshold of TX rings to N "
157 	       "(0 <= N <= value of txd).\n");
158 	printf("  --txrst=N: set the transmit RS bit threshold of TX rings to N "
159 	       "(0 <= N <= value of txd).\n");
160 	printf("  --no-flush-rx: Don't flush RX streams before forwarding."
161 	       " Used mainly with PCAP drivers.\n");
162 	printf("  --rxoffs=X[,Y]*: set RX segment offsets for split.\n");
163 	printf("  --rxpkts=X[,Y]*: set RX segment sizes to split.\n");
164 	printf("  --txpkts=X[,Y]*: set TX segment sizes"
165 		" or total packet length.\n");
166 	printf("  --txonly-multi-flow: generate multiple flows in txonly mode\n");
167 	printf("  --tx-ip=src,dst: IP addresses in Tx-only mode\n");
168 	printf("  --tx-udp=src[,dst]: UDP ports in Tx-only mode\n");
169 	printf("  --eth-link-speed: force link speed.\n");
170 	printf("  --rxq-share=X: number of ports per shared Rx queue groups, defaults to UINT32_MAX (1 group)\n");
171 	printf("  --disable-link-check: disable check on link status when "
172 	       "starting/stopping ports.\n");
173 	printf("  --disable-device-start: do not automatically start port\n");
174 	printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
175 	printf("  --no-rmv-interrupt: disable device removal interrupt.\n");
176 	printf("  --bitrate-stats=N: set the logical core N to perform "
177 		"bit-rate calculation.\n");
178 	printf("  --print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|flow_aged|all>: "
179 	       "enable print of designated event or all of them.\n");
180 	printf("  --mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|flow_aged|all>: "
181 	       "disable print of designated event or all of them.\n");
182 	printf("  --flow-isolate-all: "
183 	       "requests flow API isolated mode on all ports at initialization time.\n");
184 	printf("  --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
185 	printf("  --rx-offloads=0xXXXXXXXX: hexadecimal bitmask of RX queue offloads\n");
186 	printf("  --hot-plug: enable hot plug for device.\n");
187 	printf("  --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\n");
188 	printf("  --geneve-parsed-port=N: UPD port to parse GENEVE tunnel protocol\n");
189 #ifndef RTE_EXEC_ENV_WINDOWS
190 	printf("  --mlockall: lock all memory\n");
191 	printf("  --no-mlockall: do not lock all memory\n");
192 #endif
193 	printf("  --mp-alloc <native|anon|xmem|xmemhuge>: mempool allocation method.\n"
194 	       "    native: use regular DPDK memory to create and populate mempool\n"
195 	       "    anon: use regular DPDK memory to create and anonymous memory to populate mempool\n"
196 	       "    xmem: use anonymous memory to create and populate mempool\n"
197 	       "    xmemhuge: use anonymous hugepage memory to create and populate mempool\n");
198 	printf("  --noisy-tx-sw-buffer-size=N: size of FIFO buffer\n");
199 	printf("  --noisy-tx-sw-buffer-flushtime=N: flush FIFO after N ms\n");
200 	printf("  --noisy-lkup-memory=N: allocate N MB of VNF memory\n");
201 	printf("  --noisy-lkup-num-writes=N: do N random writes per packet\n");
202 	printf("  --noisy-lkup-num-reads=N: do N random reads per packet\n");
203 	printf("  --noisy-lkup-num-reads-writes=N: do N random reads and writes per packet\n");
204 	printf("  --no-iova-contig: mempool memory can be IOVA non contiguous. "
205 	       "valid only with --mp-alloc=anon\n");
206 	printf("  --rx-mq-mode=0xX: hexadecimal bitmask of RX mq mode can be "
207 	       "enabled\n");
208 	printf("  --record-core-cycles: enable measurement of CPU cycles.\n");
209 	printf("  --record-burst-stats: enable display of RX and TX bursts.\n");
210 	printf("  --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n"
211 	       "    0x10 - explicit Tx rule, 0x02 - hairpin ports paired\n"
212 	       "    0x01 - hairpin ports loop, 0x00 - hairpin port self\n");
213 }
214 
215 #ifdef RTE_LIB_CMDLINE
216 static int
217 init_peer_eth_addrs(const char *config_filename)
218 {
219 	FILE *config_file;
220 	portid_t i;
221 	char buf[50];
222 
223 	config_file = fopen(config_filename, "r");
224 	if (config_file == NULL) {
225 		perror("Failed to open eth config file\n");
226 		return -1;
227 	}
228 
229 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
230 
231 		if (fgets(buf, sizeof(buf), config_file) == NULL)
232 			break;
233 
234 		if (rte_ether_unformat_addr(buf, &peer_eth_addrs[i]) < 0) {
235 			fprintf(stderr, "Bad MAC address format on line %d\n",
236 				i + 1);
237 			fclose(config_file);
238 			return -1;
239 		}
240 	}
241 	fclose(config_file);
242 	nb_peer_eth_addrs = (portid_t) i;
243 	return 0;
244 }
245 #endif
246 
247 /*
248  * Parse the coremask given as argument (hexadecimal string) and set
249  * the global configuration of forwarding cores.
250  */
251 static void
252 parse_fwd_coremask(const char *coremask)
253 {
254 	char *end;
255 	unsigned long long int cm;
256 
257 	/* parse hexadecimal string */
258 	end = NULL;
259 	cm = strtoull(coremask, &end, 16);
260 	if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0'))
261 		rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n");
262 	else if (set_fwd_lcores_mask((uint64_t) cm) < 0)
263 		rte_exit(EXIT_FAILURE, "coremask is not valid\n");
264 }
265 
266 /*
267  * Parse the coremask given as argument (hexadecimal string) and set
268  * the global configuration of forwarding cores.
269  */
270 static void
271 parse_fwd_portmask(const char *portmask)
272 {
273 	char *end;
274 	unsigned long long int pm;
275 
276 	/* parse hexadecimal string */
277 	end = NULL;
278 	pm = strtoull(portmask, &end, 16);
279 	if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
280 		rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n");
281 	else
282 		set_fwd_ports_mask((uint64_t) pm);
283 }
284 
285 static void
286 print_invalid_socket_id_error(void)
287 {
288 	unsigned int i = 0;
289 
290 	fprintf(stderr, "Invalid socket id, options are: ");
291 	for (i = 0; i < num_sockets; i++) {
292 		fprintf(stderr, "%u%s", socket_ids[i],
293 			(i == num_sockets - 1) ? "\n" : ",");
294 	}
295 }
296 
297 static int
298 parse_portnuma_config(const char *q_arg)
299 {
300 	char s[256];
301 	const char *p, *p0 = q_arg;
302 	char *end;
303 	uint8_t i, socket_id;
304 	portid_t port_id;
305 	unsigned size;
306 	enum fieldnames {
307 		FLD_PORT = 0,
308 		FLD_SOCKET,
309 		_NUM_FLD
310 	};
311 	unsigned long int_fld[_NUM_FLD];
312 	char *str_fld[_NUM_FLD];
313 
314 	/* reset from value set at definition */
315 	while ((p = strchr(p0,'(')) != NULL) {
316 		++p;
317 		if((p0 = strchr(p,')')) == NULL)
318 			return -1;
319 
320 		size = p0 - p;
321 		if(size >= sizeof(s))
322 			return -1;
323 
324 		snprintf(s, sizeof(s), "%.*s", size, p);
325 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
326 			return -1;
327 		for (i = 0; i < _NUM_FLD; i++) {
328 			errno = 0;
329 			int_fld[i] = strtoul(str_fld[i], &end, 0);
330 			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
331 				return -1;
332 		}
333 		port_id = (portid_t)int_fld[FLD_PORT];
334 		if (port_id_is_invalid(port_id, ENABLED_WARN) ||
335 			port_id == (portid_t)RTE_PORT_ALL) {
336 			print_valid_ports();
337 			return -1;
338 		}
339 		socket_id = (uint8_t)int_fld[FLD_SOCKET];
340 		if (new_socket_id(socket_id)) {
341 			if (num_sockets >= RTE_MAX_NUMA_NODES) {
342 				print_invalid_socket_id_error();
343 				return -1;
344 			}
345 			socket_ids[num_sockets++] = socket_id;
346 		}
347 		port_numa[port_id] = socket_id;
348 	}
349 
350 	return 0;
351 }
352 
353 static int
354 parse_ringnuma_config(const char *q_arg)
355 {
356 	char s[256];
357 	const char *p, *p0 = q_arg;
358 	char *end;
359 	uint8_t i, ring_flag, socket_id;
360 	portid_t port_id;
361 	unsigned size;
362 	enum fieldnames {
363 		FLD_PORT = 0,
364 		FLD_FLAG,
365 		FLD_SOCKET,
366 		_NUM_FLD
367 	};
368 	unsigned long int_fld[_NUM_FLD];
369 	char *str_fld[_NUM_FLD];
370 	#define RX_RING_ONLY 0x1
371 	#define TX_RING_ONLY 0x2
372 	#define RXTX_RING    0x3
373 
374 	/* reset from value set at definition */
375 	while ((p = strchr(p0,'(')) != NULL) {
376 		++p;
377 		if((p0 = strchr(p,')')) == NULL)
378 			return -1;
379 
380 		size = p0 - p;
381 		if(size >= sizeof(s))
382 			return -1;
383 
384 		snprintf(s, sizeof(s), "%.*s", size, p);
385 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
386 			return -1;
387 		for (i = 0; i < _NUM_FLD; i++) {
388 			errno = 0;
389 			int_fld[i] = strtoul(str_fld[i], &end, 0);
390 			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
391 				return -1;
392 		}
393 		port_id = (portid_t)int_fld[FLD_PORT];
394 		if (port_id_is_invalid(port_id, ENABLED_WARN) ||
395 			port_id == (portid_t)RTE_PORT_ALL) {
396 			print_valid_ports();
397 			return -1;
398 		}
399 		socket_id = (uint8_t)int_fld[FLD_SOCKET];
400 		if (new_socket_id(socket_id)) {
401 			if (num_sockets >= RTE_MAX_NUMA_NODES) {
402 				print_invalid_socket_id_error();
403 				return -1;
404 			}
405 			socket_ids[num_sockets++] = socket_id;
406 		}
407 		ring_flag = (uint8_t)int_fld[FLD_FLAG];
408 		if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) {
409 			fprintf(stderr,
410 				"Invalid ring-flag=%d config for port =%d\n",
411 				ring_flag,port_id);
412 			return -1;
413 		}
414 
415 		switch (ring_flag & RXTX_RING) {
416 		case RX_RING_ONLY:
417 			rxring_numa[port_id] = socket_id;
418 			break;
419 		case TX_RING_ONLY:
420 			txring_numa[port_id] = socket_id;
421 			break;
422 		case RXTX_RING:
423 			rxring_numa[port_id] = socket_id;
424 			txring_numa[port_id] = socket_id;
425 			break;
426 		default:
427 			fprintf(stderr,
428 				"Invalid ring-flag=%d config for port=%d\n",
429 				ring_flag,port_id);
430 			break;
431 		}
432 	}
433 
434 	return 0;
435 }
436 
437 static int
438 parse_event_printing_config(const char *optarg, int enable)
439 {
440 	uint32_t mask = 0;
441 
442 	if (!strcmp(optarg, "unknown"))
443 		mask = UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN;
444 	else if (!strcmp(optarg, "intr_lsc"))
445 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_LSC;
446 	else if (!strcmp(optarg, "queue_state"))
447 		mask = UINT32_C(1) << RTE_ETH_EVENT_QUEUE_STATE;
448 	else if (!strcmp(optarg, "intr_reset"))
449 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET;
450 	else if (!strcmp(optarg, "vf_mbox"))
451 		mask = UINT32_C(1) << RTE_ETH_EVENT_VF_MBOX;
452 	else if (!strcmp(optarg, "ipsec"))
453 		mask = UINT32_C(1) << RTE_ETH_EVENT_IPSEC;
454 	else if (!strcmp(optarg, "macsec"))
455 		mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
456 	else if (!strcmp(optarg, "intr_rmv"))
457 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
458 	else if (!strcmp(optarg, "dev_probed"))
459 		mask = UINT32_C(1) << RTE_ETH_EVENT_NEW;
460 	else if (!strcmp(optarg, "dev_released"))
461 		mask = UINT32_C(1) << RTE_ETH_EVENT_DESTROY;
462 	else if (!strcmp(optarg, "flow_aged"))
463 		mask = UINT32_C(1) << RTE_ETH_EVENT_FLOW_AGED;
464 	else if (!strcmp(optarg, "all"))
465 		mask = ~UINT32_C(0);
466 	else {
467 		fprintf(stderr, "Invalid event: %s\n", optarg);
468 		return -1;
469 	}
470 	if (enable)
471 		event_print_mask |= mask;
472 	else
473 		event_print_mask &= ~mask;
474 	return 0;
475 }
476 
477 static int
478 parse_xstats_list(const char *in_str, struct rte_eth_xstat_name **xstats,
479 		  unsigned int *xstats_num)
480 {
481 	int max_names_nb, names_nb, nonempty_names_nb;
482 	int name, nonempty_name;
483 	int stringlen;
484 	char **names;
485 	char *str;
486 	int ret;
487 	int i;
488 
489 	names = NULL;
490 	str = strdup(in_str);
491 	if (str == NULL) {
492 		ret = -ENOMEM;
493 		goto out;
494 	}
495 	stringlen = strlen(str);
496 
497 	for (i = 0, max_names_nb = 1; str[i] != '\0'; i++) {
498 		if (str[i] == ',')
499 			max_names_nb++;
500 	}
501 
502 	names = calloc(max_names_nb, sizeof(*names));
503 	if (names == NULL) {
504 		ret = -ENOMEM;
505 		goto out;
506 	}
507 
508 	names_nb = rte_strsplit(str, stringlen, names, max_names_nb, ',');
509 	if (names_nb < 0) {
510 		ret = -EINVAL;
511 		goto out;
512 	}
513 
514 	nonempty_names_nb = 0;
515 	for (i = 0; i < names_nb; i++) {
516 		if (names[i][0] == '\0')
517 			continue;
518 		nonempty_names_nb++;
519 	}
520 	*xstats = calloc(nonempty_names_nb, sizeof(**xstats));
521 	if (*xstats == NULL) {
522 		ret = -ENOMEM;
523 		goto out;
524 	}
525 
526 	for (name = nonempty_name = 0; name < names_nb; name++) {
527 		if (names[name][0] == '\0')
528 			continue;
529 		rte_strscpy((*xstats)[nonempty_name].name, names[name],
530 			    sizeof((*xstats)[nonempty_name].name));
531 		nonempty_name++;
532 	}
533 
534 	*xstats_num = nonempty_names_nb;
535 	ret = 0;
536 
537 out:
538 	free(names);
539 	free(str);
540 	return ret;
541 }
542 
543 static int
544 parse_link_speed(int n)
545 {
546 	uint32_t speed = RTE_ETH_LINK_SPEED_FIXED;
547 
548 	switch (n) {
549 	case 1000:
550 		speed |= RTE_ETH_LINK_SPEED_1G;
551 		break;
552 	case 10000:
553 		speed |= RTE_ETH_LINK_SPEED_10G;
554 		break;
555 	case 25000:
556 		speed |= RTE_ETH_LINK_SPEED_25G;
557 		break;
558 	case 40000:
559 		speed |= RTE_ETH_LINK_SPEED_40G;
560 		break;
561 	case 50000:
562 		speed |= RTE_ETH_LINK_SPEED_50G;
563 		break;
564 	case 100000:
565 		speed |= RTE_ETH_LINK_SPEED_100G;
566 		break;
567 	case 200000:
568 		speed |= RTE_ETH_LINK_SPEED_200G;
569 		break;
570 	case 100:
571 	case 10:
572 	default:
573 		fprintf(stderr, "Unsupported fixed speed\n");
574 		return 0;
575 	}
576 
577 	return speed;
578 }
579 
580 void
581 launch_args_parse(int argc, char** argv)
582 {
583 #define PARAM_PROC_ID "proc-id"
584 #define PARAM_NUM_PROCS "num-procs"
585 
586 	int n, opt;
587 	char **argvopt;
588 	int opt_idx;
589 	portid_t pid;
590 	enum { TX, RX };
591 	/* Default offloads for all ports. */
592 	uint64_t rx_offloads = rx_mode.offloads;
593 	uint64_t tx_offloads = tx_mode.offloads;
594 	struct rte_eth_dev_info dev_info;
595 	uint16_t rec_nb_pkts;
596 	int ret;
597 
598 	static struct option lgopts[] = {
599 		{ "help",			0, 0, 0 },
600 #ifdef RTE_LIB_CMDLINE
601 		{ "interactive",		0, 0, 0 },
602 		{ "cmdline-file",		1, 0, 0 },
603 		{ "auto-start",			0, 0, 0 },
604 		{ "eth-peers-configfile",	1, 0, 0 },
605 		{ "eth-peer",			1, 0, 0 },
606 #endif
607 		{ "tx-first",			0, 0, 0 },
608 		{ "stats-period",		1, 0, 0 },
609 		{ "display-xstats",		1, 0, 0 },
610 		{ "nb-cores",			1, 0, 0 },
611 		{ "nb-ports",			1, 0, 0 },
612 		{ "coremask",			1, 0, 0 },
613 		{ "portmask",			1, 0, 0 },
614 		{ "portlist",			1, 0, 0 },
615 		{ "numa",			0, 0, 0 },
616 		{ "no-numa",			0, 0, 0 },
617 		{ "mp-anon",			0, 0, 0 }, /* deprecated */
618 		{ "port-numa-config",           1, 0, 0 },
619 		{ "ring-numa-config",           1, 0, 0 },
620 		{ "socket-num",			1, 0, 0 },
621 		{ "mbuf-size",			1, 0, 0 },
622 		{ "total-num-mbufs",		1, 0, 0 },
623 		{ "max-pkt-len",		1, 0, 0 },
624 		{ "max-lro-pkt-size",		1, 0, 0 },
625 		{ "pkt-filter-mode",            1, 0, 0 },
626 		{ "pkt-filter-report-hash",     1, 0, 0 },
627 		{ "pkt-filter-size",            1, 0, 0 },
628 		{ "pkt-filter-drop-queue",      1, 0, 0 },
629 #ifdef RTE_LIB_LATENCYSTATS
630 		{ "latencystats",               1, 0, 0 },
631 #endif
632 #ifdef RTE_LIB_BITRATESTATS
633 		{ "bitrate-stats",              1, 0, 0 },
634 #endif
635 		{ "disable-crc-strip",          0, 0, 0 },
636 		{ "enable-lro",                 0, 0, 0 },
637 		{ "enable-rx-cksum",            0, 0, 0 },
638 		{ "enable-rx-timestamp",        0, 0, 0 },
639 		{ "enable-scatter",             0, 0, 0 },
640 		{ "enable-hw-vlan",             0, 0, 0 },
641 		{ "enable-hw-vlan-filter",      0, 0, 0 },
642 		{ "enable-hw-vlan-strip",       0, 0, 0 },
643 		{ "enable-hw-vlan-extend",      0, 0, 0 },
644 		{ "enable-hw-qinq-strip",       0, 0, 0 },
645 		{ "enable-drop-en",            0, 0, 0 },
646 		{ "disable-rss",                0, 0, 0 },
647 		{ "port-topology",              1, 0, 0 },
648 		{ "forward-mode",               1, 0, 0 },
649 		{ "rss-ip",			0, 0, 0 },
650 		{ "rss-udp",			0, 0, 0 },
651 		{ "rss-level-outer",		0, 0, 0 },
652 		{ "rss-level-inner",		0, 0, 0 },
653 		{ "rxq",			1, 0, 0 },
654 		{ "txq",			1, 0, 0 },
655 		{ "rxd",			1, 0, 0 },
656 		{ "txd",			1, 0, 0 },
657 		{ "hairpinq",			1, 0, 0 },
658 		{ "hairpin-mode",		1, 0, 0 },
659 		{ "burst",			1, 0, 0 },
660 		{ "flowgen-clones",		1, 0, 0 },
661 		{ "flowgen-flows",		1, 0, 0 },
662 		{ "mbcache",			1, 0, 0 },
663 		{ "txpt",			1, 0, 0 },
664 		{ "txht",			1, 0, 0 },
665 		{ "txwt",			1, 0, 0 },
666 		{ "txfreet",			1, 0, 0 },
667 		{ "txrst",			1, 0, 0 },
668 		{ "rxpt",			1, 0, 0 },
669 		{ "rxht",			1, 0, 0 },
670 		{ "rxwt",			1, 0, 0 },
671 		{ "rxfreet",                    1, 0, 0 },
672 		{ "no-flush-rx",	0, 0, 0 },
673 		{ "flow-isolate-all",	        0, 0, 0 },
674 		{ "rxoffs",			1, 0, 0 },
675 		{ "rxpkts",			1, 0, 0 },
676 		{ "txpkts",			1, 0, 0 },
677 		{ "txonly-multi-flow",		0, 0, 0 },
678 		{ "rxq-share",			2, 0, 0 },
679 		{ "eth-link-speed",		1, 0, 0 },
680 		{ "disable-link-check",		0, 0, 0 },
681 		{ "disable-device-start",	0, 0, 0 },
682 		{ "no-lsc-interrupt",		0, 0, 0 },
683 		{ "no-rmv-interrupt",		0, 0, 0 },
684 		{ "print-event",		1, 0, 0 },
685 		{ "mask-event",			1, 0, 0 },
686 		{ "tx-offloads",		1, 0, 0 },
687 		{ "rx-offloads",		1, 0, 0 },
688 		{ "hot-plug",			0, 0, 0 },
689 		{ "vxlan-gpe-port",		1, 0, 0 },
690 		{ "geneve-parsed-port",		1, 0, 0 },
691 #ifndef RTE_EXEC_ENV_WINDOWS
692 		{ "mlockall",			0, 0, 0 },
693 		{ "no-mlockall",		0, 0, 0 },
694 #endif
695 		{ "mp-alloc",			1, 0, 0 },
696 		{ "tx-ip",			1, 0, 0 },
697 		{ "tx-udp",			1, 0, 0 },
698 		{ "noisy-tx-sw-buffer-size",	1, 0, 0 },
699 		{ "noisy-tx-sw-buffer-flushtime", 1, 0, 0 },
700 		{ "noisy-lkup-memory",		1, 0, 0 },
701 		{ "noisy-lkup-num-writes",	1, 0, 0 },
702 		{ "noisy-lkup-num-reads",	1, 0, 0 },
703 		{ "noisy-lkup-num-reads-writes", 1, 0, 0 },
704 		{ "no-iova-contig",             0, 0, 0 },
705 		{ "rx-mq-mode",                 1, 0, 0 },
706 		{ "record-core-cycles",         0, 0, 0 },
707 		{ "record-burst-stats",         0, 0, 0 },
708 		{ PARAM_NUM_PROCS,              1, 0, 0 },
709 		{ PARAM_PROC_ID,                1, 0, 0 },
710 		{ 0, 0, 0, 0 },
711 	};
712 
713 	argvopt = argv;
714 
715 #ifdef RTE_LIB_CMDLINE
716 #define SHORTOPTS "i"
717 #else
718 #define SHORTOPTS ""
719 #endif
720 	while ((opt = getopt_long(argc, argvopt, SHORTOPTS "ah",
721 				 lgopts, &opt_idx)) != EOF) {
722 		switch (opt) {
723 #ifdef RTE_LIB_CMDLINE
724 		case 'i':
725 			printf("Interactive-mode selected\n");
726 			interactive = 1;
727 			break;
728 #endif
729 		case 'a':
730 			printf("Auto-start selected\n");
731 			auto_start = 1;
732 			break;
733 
734 		case 0: /*long options */
735 			if (!strcmp(lgopts[opt_idx].name, "help")) {
736 				usage(argv[0]);
737 				exit(EXIT_SUCCESS);
738 			}
739 #ifdef RTE_LIB_CMDLINE
740 			if (!strcmp(lgopts[opt_idx].name, "interactive")) {
741 				printf("Interactive-mode selected\n");
742 				interactive = 1;
743 			}
744 			if (!strcmp(lgopts[opt_idx].name, "cmdline-file")) {
745 				printf("CLI commands to be read from %s\n",
746 				       optarg);
747 				strlcpy(cmdline_filename, optarg,
748 					sizeof(cmdline_filename));
749 			}
750 			if (!strcmp(lgopts[opt_idx].name, "auto-start")) {
751 				printf("Auto-start selected\n");
752 				auto_start = 1;
753 			}
754 			if (!strcmp(lgopts[opt_idx].name, "tx-first")) {
755 				printf("Ports to start sending a burst of "
756 						"packets first\n");
757 				tx_first = 1;
758 			}
759 			if (!strcmp(lgopts[opt_idx].name, "stats-period")) {
760 				char *end = NULL;
761 				unsigned int n;
762 
763 				n = strtoul(optarg, &end, 10);
764 				if ((optarg[0] == '\0') || (end == NULL) ||
765 						(*end != '\0'))
766 					break;
767 
768 				stats_period = n;
769 				break;
770 			}
771 			if (!strcmp(lgopts[opt_idx].name, "display-xstats")) {
772 				char rc;
773 
774 				rc = parse_xstats_list(optarg, &xstats_display,
775 						       &xstats_display_num);
776 				if (rc != 0)
777 					rte_exit(EXIT_FAILURE,
778 						 "Failed to parse display-xstats argument: %d\n",
779 						 rc);
780 			}
781 			if (!strcmp(lgopts[opt_idx].name,
782 				    "eth-peers-configfile")) {
783 				if (init_peer_eth_addrs(optarg) != 0)
784 					rte_exit(EXIT_FAILURE,
785 						 "Cannot open logfile\n");
786 			}
787 			if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
788 				char *port_end;
789 
790 				errno = 0;
791 				n = strtoul(optarg, &port_end, 10);
792 				if (errno != 0 || port_end == optarg || *port_end++ != ',')
793 					rte_exit(EXIT_FAILURE,
794 						 "Invalid eth-peer: %s", optarg);
795 				if (n >= RTE_MAX_ETHPORTS)
796 					rte_exit(EXIT_FAILURE,
797 						 "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n",
798 						 n, RTE_MAX_ETHPORTS);
799 
800 				if (rte_ether_unformat_addr(port_end,
801 						&peer_eth_addrs[n]) < 0)
802 					rte_exit(EXIT_FAILURE,
803 						 "Invalid ethernet address: %s\n",
804 						 port_end);
805 				nb_peer_eth_addrs++;
806 			}
807 #endif
808 			if (!strcmp(lgopts[opt_idx].name, "tx-ip")) {
809 				struct in_addr in;
810 				char *end;
811 
812 				end = strchr(optarg, ',');
813 				if (end == optarg || !end)
814 					rte_exit(EXIT_FAILURE,
815 						 "Invalid tx-ip: %s", optarg);
816 
817 				*end++ = 0;
818 				if (inet_pton(AF_INET, optarg, &in) == 0)
819 					rte_exit(EXIT_FAILURE,
820 						 "Invalid source IP address: %s\n",
821 						 optarg);
822 				tx_ip_src_addr = rte_be_to_cpu_32(in.s_addr);
823 
824 				if (inet_pton(AF_INET, end, &in) == 0)
825 					rte_exit(EXIT_FAILURE,
826 						 "Invalid destination IP address: %s\n",
827 						 optarg);
828 				tx_ip_dst_addr = rte_be_to_cpu_32(in.s_addr);
829 			}
830 			if (!strcmp(lgopts[opt_idx].name, "tx-udp")) {
831 				char *end = NULL;
832 
833 				errno = 0;
834 				n = strtoul(optarg, &end, 10);
835 				if (errno != 0 || end == optarg ||
836 				    n > UINT16_MAX ||
837 				    !(*end == '\0' || *end == ','))
838 					rte_exit(EXIT_FAILURE,
839 						 "Invalid UDP port: %s\n",
840 						 optarg);
841 				tx_udp_src_port = n;
842 				if (*end == ',') {
843 					char *dst = end + 1;
844 
845 					n = strtoul(dst, &end, 10);
846 					if (errno != 0 || end == dst ||
847 					    n > UINT16_MAX || *end)
848 						rte_exit(EXIT_FAILURE,
849 							 "Invalid destination UDP port: %s\n",
850 							 dst);
851 					tx_udp_dst_port = n;
852 				} else {
853 					tx_udp_dst_port = n;
854 				}
855 
856 			}
857 			if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
858 				n = atoi(optarg);
859 				if (n > 0 && n <= nb_ports)
860 					nb_fwd_ports = n;
861 				else
862 					rte_exit(EXIT_FAILURE,
863 						 "Invalid port %d\n", n);
864 			}
865 			if (!strcmp(lgopts[opt_idx].name, "nb-cores")) {
866 				n = atoi(optarg);
867 				if (n > 0 && n <= nb_lcores)
868 					nb_fwd_lcores = (uint8_t) n;
869 				else
870 					rte_exit(EXIT_FAILURE,
871 						 "nb-cores should be > 0 and <= %d\n",
872 						 nb_lcores);
873 			}
874 			if (!strcmp(lgopts[opt_idx].name, "coremask"))
875 				parse_fwd_coremask(optarg);
876 			if (!strcmp(lgopts[opt_idx].name, "portmask"))
877 				parse_fwd_portmask(optarg);
878 			if (!strcmp(lgopts[opt_idx].name, "portlist"))
879 				parse_fwd_portlist(optarg);
880 			if (!strcmp(lgopts[opt_idx].name, "no-numa"))
881 				numa_support = 0;
882 			if (!strcmp(lgopts[opt_idx].name, "numa"))
883 				numa_support = 1;
884 			if (!strcmp(lgopts[opt_idx].name, "mp-anon")) {
885 				mp_alloc_type = MP_ALLOC_ANON;
886 			}
887 			if (!strcmp(lgopts[opt_idx].name, "mp-alloc")) {
888 				if (!strcmp(optarg, "native"))
889 					mp_alloc_type = MP_ALLOC_NATIVE;
890 				else if (!strcmp(optarg, "anon"))
891 					mp_alloc_type = MP_ALLOC_ANON;
892 				else if (!strcmp(optarg, "xmem"))
893 					mp_alloc_type = MP_ALLOC_XMEM;
894 				else if (!strcmp(optarg, "xmemhuge"))
895 					mp_alloc_type = MP_ALLOC_XMEM_HUGE;
896 				else if (!strcmp(optarg, "xbuf"))
897 					mp_alloc_type = MP_ALLOC_XBUF;
898 				else
899 					rte_exit(EXIT_FAILURE,
900 						"mp-alloc %s invalid - must be: "
901 						"native, anon, xmem or xmemhuge\n",
902 						 optarg);
903 			}
904 			if (!strcmp(lgopts[opt_idx].name, "port-numa-config")) {
905 				if (parse_portnuma_config(optarg))
906 					rte_exit(EXIT_FAILURE,
907 					   "invalid port-numa configuration\n");
908 			}
909 			if (!strcmp(lgopts[opt_idx].name, "ring-numa-config"))
910 				if (parse_ringnuma_config(optarg))
911 					rte_exit(EXIT_FAILURE,
912 					   "invalid ring-numa configuration\n");
913 			if (!strcmp(lgopts[opt_idx].name, "socket-num")) {
914 				n = atoi(optarg);
915 				if (!new_socket_id((uint8_t)n)) {
916 					socket_num = (uint8_t)n;
917 				} else {
918 					print_invalid_socket_id_error();
919 					rte_exit(EXIT_FAILURE,
920 						"Invalid socket id");
921 				}
922 			}
923 			if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
924 				unsigned int mb_sz[MAX_SEGS_BUFFER_SPLIT];
925 				unsigned int nb_segs, i;
926 
927 				nb_segs = parse_item_list(optarg, "mbuf-size",
928 					MAX_SEGS_BUFFER_SPLIT, mb_sz, 0);
929 				if (nb_segs <= 0)
930 					rte_exit(EXIT_FAILURE,
931 						 "bad mbuf-size\n");
932 				for (i = 0; i < nb_segs; i++) {
933 					if (mb_sz[i] <= 0 || mb_sz[i] > 0xFFFF)
934 						rte_exit(EXIT_FAILURE,
935 							 "mbuf-size should be "
936 							 "> 0 and < 65536\n");
937 					mbuf_data_size[i] = (uint16_t) mb_sz[i];
938 				}
939 				mbuf_data_size_n = nb_segs;
940 			}
941 			if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
942 				n = atoi(optarg);
943 				if (n > 1024)
944 					param_total_num_mbufs = (unsigned)n;
945 				else
946 					rte_exit(EXIT_FAILURE,
947 						 "total-num-mbufs should be > 1024\n");
948 			}
949 			if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
950 				n = atoi(optarg);
951 				if (n >= RTE_ETHER_MIN_LEN)
952 					max_rx_pkt_len = n;
953 				else
954 					rte_exit(EXIT_FAILURE,
955 						 "Invalid max-pkt-len=%d - should be > %d\n",
956 						 n, RTE_ETHER_MIN_LEN);
957 			}
958 			if (!strcmp(lgopts[opt_idx].name, "max-lro-pkt-size")) {
959 				n = atoi(optarg);
960 				rx_mode.max_lro_pkt_size = (uint32_t) n;
961 			}
962 			if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) {
963 				if (!strcmp(optarg, "signature"))
964 					fdir_conf.mode =
965 						RTE_FDIR_MODE_SIGNATURE;
966 				else if (!strcmp(optarg, "perfect"))
967 					fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
968 				else if (!strcmp(optarg, "perfect-mac-vlan"))
969 					fdir_conf.mode = RTE_FDIR_MODE_PERFECT_MAC_VLAN;
970 				else if (!strcmp(optarg, "perfect-tunnel"))
971 					fdir_conf.mode = RTE_FDIR_MODE_PERFECT_TUNNEL;
972 				else if (!strcmp(optarg, "none"))
973 					fdir_conf.mode = RTE_FDIR_MODE_NONE;
974 				else
975 					rte_exit(EXIT_FAILURE,
976 						 "pkt-mode-invalid %s invalid - must be: "
977 						 "none, signature, perfect, perfect-mac-vlan"
978 						 " or perfect-tunnel\n",
979 						 optarg);
980 			}
981 			if (!strcmp(lgopts[opt_idx].name,
982 				    "pkt-filter-report-hash")) {
983 				if (!strcmp(optarg, "none"))
984 					fdir_conf.status =
985 						RTE_FDIR_NO_REPORT_STATUS;
986 				else if (!strcmp(optarg, "match"))
987 					fdir_conf.status =
988 						RTE_FDIR_REPORT_STATUS;
989 				else if (!strcmp(optarg, "always"))
990 					fdir_conf.status =
991 						RTE_FDIR_REPORT_STATUS_ALWAYS;
992 				else
993 					rte_exit(EXIT_FAILURE,
994 						 "pkt-filter-report-hash %s invalid "
995 						 "- must be: none or match or always\n",
996 						 optarg);
997 			}
998 			if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) {
999 				if (!strcmp(optarg, "64K"))
1000 					fdir_conf.pballoc =
1001 						RTE_ETH_FDIR_PBALLOC_64K;
1002 				else if (!strcmp(optarg, "128K"))
1003 					fdir_conf.pballoc =
1004 						RTE_ETH_FDIR_PBALLOC_128K;
1005 				else if (!strcmp(optarg, "256K"))
1006 					fdir_conf.pballoc =
1007 						RTE_ETH_FDIR_PBALLOC_256K;
1008 				else
1009 					rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -"
1010 						 " must be: 64K or 128K or 256K\n",
1011 						 optarg);
1012 			}
1013 			if (!strcmp(lgopts[opt_idx].name,
1014 				    "pkt-filter-drop-queue")) {
1015 				n = atoi(optarg);
1016 				if (n >= 0)
1017 					fdir_conf.drop_queue = (uint8_t) n;
1018 				else
1019 					rte_exit(EXIT_FAILURE,
1020 						 "drop queue %d invalid - must"
1021 						 "be >= 0 \n", n);
1022 			}
1023 #ifdef RTE_LIB_LATENCYSTATS
1024 			if (!strcmp(lgopts[opt_idx].name,
1025 				    "latencystats")) {
1026 				n = atoi(optarg);
1027 				if (n >= 0) {
1028 					latencystats_lcore_id = (lcoreid_t) n;
1029 					latencystats_enabled = 1;
1030 				} else
1031 					rte_exit(EXIT_FAILURE,
1032 						 "invalid lcore id %d for latencystats"
1033 						 " must be >= 0\n", n);
1034 			}
1035 #endif
1036 #ifdef RTE_LIB_BITRATESTATS
1037 			if (!strcmp(lgopts[opt_idx].name, "bitrate-stats")) {
1038 				n = atoi(optarg);
1039 				if (n >= 0) {
1040 					bitrate_lcore_id = (lcoreid_t) n;
1041 					bitrate_enabled = 1;
1042 				} else
1043 					rte_exit(EXIT_FAILURE,
1044 						 "invalid lcore id %d for bitrate stats"
1045 						 " must be >= 0\n", n);
1046 			}
1047 #endif
1048 			if (!strcmp(lgopts[opt_idx].name, "disable-crc-strip"))
1049 				rx_offloads |= RTE_ETH_RX_OFFLOAD_KEEP_CRC;
1050 			if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
1051 				rx_offloads |= RTE_ETH_RX_OFFLOAD_TCP_LRO;
1052 			if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
1053 				rx_offloads |= RTE_ETH_RX_OFFLOAD_SCATTER;
1054 			if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
1055 				rx_offloads |= RTE_ETH_RX_OFFLOAD_CHECKSUM;
1056 			if (!strcmp(lgopts[opt_idx].name,
1057 					"enable-rx-timestamp"))
1058 				rx_offloads |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
1059 			if (!strcmp(lgopts[opt_idx].name, "enable-hw-vlan"))
1060 				rx_offloads |= RTE_ETH_RX_OFFLOAD_VLAN;
1061 
1062 			if (!strcmp(lgopts[opt_idx].name,
1063 					"enable-hw-vlan-filter"))
1064 				rx_offloads |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
1065 
1066 			if (!strcmp(lgopts[opt_idx].name,
1067 					"enable-hw-vlan-strip"))
1068 				rx_offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
1069 
1070 			if (!strcmp(lgopts[opt_idx].name,
1071 					"enable-hw-vlan-extend"))
1072 				rx_offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
1073 
1074 			if (!strcmp(lgopts[opt_idx].name,
1075 					"enable-hw-qinq-strip"))
1076 				rx_offloads |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
1077 
1078 			if (!strcmp(lgopts[opt_idx].name, "enable-drop-en"))
1079 				rx_drop_en = 1;
1080 
1081 			if (!strcmp(lgopts[opt_idx].name, "disable-rss"))
1082 				rss_hf = 0;
1083 			if (!strcmp(lgopts[opt_idx].name, "port-topology")) {
1084 				if (!strcmp(optarg, "paired"))
1085 					port_topology = PORT_TOPOLOGY_PAIRED;
1086 				else if (!strcmp(optarg, "chained"))
1087 					port_topology = PORT_TOPOLOGY_CHAINED;
1088 				else if (!strcmp(optarg, "loop"))
1089 					port_topology = PORT_TOPOLOGY_LOOP;
1090 				else
1091 					rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
1092 						 " must be: paired, chained or loop\n",
1093 						 optarg);
1094 			}
1095 			if (!strcmp(lgopts[opt_idx].name, "forward-mode"))
1096 				set_pkt_forwarding_mode(optarg);
1097 			if (!strcmp(lgopts[opt_idx].name, "rss-ip"))
1098 				rss_hf = RTE_ETH_RSS_IP;
1099 			if (!strcmp(lgopts[opt_idx].name, "rss-udp"))
1100 				rss_hf = RTE_ETH_RSS_UDP;
1101 			if (!strcmp(lgopts[opt_idx].name, "rss-level-inner"))
1102 				rss_hf |= RTE_ETH_RSS_LEVEL_INNERMOST;
1103 			if (!strcmp(lgopts[opt_idx].name, "rss-level-outer"))
1104 				rss_hf |= RTE_ETH_RSS_LEVEL_OUTERMOST;
1105 			if (!strcmp(lgopts[opt_idx].name, "rxq")) {
1106 				n = atoi(optarg);
1107 				if (n >= 0 && check_nb_rxq((queueid_t)n) == 0)
1108 					nb_rxq = (queueid_t) n;
1109 				else
1110 					rte_exit(EXIT_FAILURE, "rxq %d invalid - must be"
1111 						  " >= 0 && <= %u\n", n,
1112 						  get_allowed_max_nb_rxq(&pid));
1113 			}
1114 			if (!strcmp(lgopts[opt_idx].name, "txq")) {
1115 				n = atoi(optarg);
1116 				if (n >= 0 && check_nb_txq((queueid_t)n) == 0)
1117 					nb_txq = (queueid_t) n;
1118 				else
1119 					rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
1120 						  " >= 0 && <= %u\n", n,
1121 						  get_allowed_max_nb_txq(&pid));
1122 			}
1123 			if (!strcmp(lgopts[opt_idx].name, "hairpinq")) {
1124 				n = atoi(optarg);
1125 				if (n >= 0 &&
1126 				    check_nb_hairpinq((queueid_t)n) == 0)
1127 					nb_hairpinq = (queueid_t) n;
1128 				else
1129 					rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
1130 						  " >= 0 && <= %u\n", n,
1131 						  get_allowed_max_nb_hairpinq
1132 						  (&pid));
1133 				if ((n + nb_txq) < 0 ||
1134 				    check_nb_txq((queueid_t)(n + nb_txq)) != 0)
1135 					rte_exit(EXIT_FAILURE, "txq + hairpinq "
1136 						 "%d invalid - must be"
1137 						  " >= 0 && <= %u\n",
1138 						  n + nb_txq,
1139 						  get_allowed_max_nb_txq(&pid));
1140 				if ((n + nb_rxq) < 0 ||
1141 				    check_nb_rxq((queueid_t)(n + nb_rxq)) != 0)
1142 					rte_exit(EXIT_FAILURE, "rxq + hairpinq "
1143 						 "%d invalid - must be"
1144 						  " >= 0 && <= %u\n",
1145 						  n + nb_rxq,
1146 						  get_allowed_max_nb_rxq(&pid));
1147 			}
1148 			if (!nb_rxq && !nb_txq) {
1149 				rte_exit(EXIT_FAILURE, "Either rx or tx queues should "
1150 						"be non-zero\n");
1151 			}
1152 			if (!strcmp(lgopts[opt_idx].name, "hairpin-mode")) {
1153 				char *end = NULL;
1154 				unsigned int n;
1155 
1156 				errno = 0;
1157 				n = strtoul(optarg, &end, 0);
1158 				if (errno != 0 || end == optarg)
1159 					rte_exit(EXIT_FAILURE, "hairpin mode invalid\n");
1160 				else
1161 					hairpin_mode = (uint16_t)n;
1162 			}
1163 			if (!strcmp(lgopts[opt_idx].name, "burst")) {
1164 				n = atoi(optarg);
1165 				if (n == 0) {
1166 					/* A burst size of zero means that the
1167 					 * PMD should be queried for
1168 					 * recommended Rx burst size. Since
1169 					 * testpmd uses a single size for all
1170 					 * ports, port 0 is queried for the
1171 					 * value, on the assumption that all
1172 					 * ports are of the same NIC model.
1173 					 */
1174 					ret = eth_dev_info_get_print_err(
1175 								0,
1176 								&dev_info);
1177 					if (ret != 0)
1178 						return;
1179 
1180 					rec_nb_pkts = dev_info
1181 						.default_rxportconf.burst_size;
1182 
1183 					if (rec_nb_pkts == 0)
1184 						rte_exit(EXIT_FAILURE,
1185 							"PMD does not recommend a burst size. "
1186 							"Provided value must be between "
1187 							"1 and %d\n", MAX_PKT_BURST);
1188 					else if (rec_nb_pkts > MAX_PKT_BURST)
1189 						rte_exit(EXIT_FAILURE,
1190 							"PMD recommended burst size of %d"
1191 							" exceeds maximum value of %d\n",
1192 							rec_nb_pkts, MAX_PKT_BURST);
1193 					printf("Using PMD-provided burst value of %d\n",
1194 						rec_nb_pkts);
1195 					nb_pkt_per_burst = rec_nb_pkts;
1196 				} else if (n > MAX_PKT_BURST)
1197 					rte_exit(EXIT_FAILURE,
1198 						"burst must be between1 and %d\n",
1199 						MAX_PKT_BURST);
1200 				else
1201 					nb_pkt_per_burst = (uint16_t) n;
1202 			}
1203 			if (!strcmp(lgopts[opt_idx].name, "flowgen-clones")) {
1204 				n = atoi(optarg);
1205 				if (n >= 0)
1206 					nb_pkt_flowgen_clones = (uint16_t) n;
1207 				else
1208 					rte_exit(EXIT_FAILURE,
1209 						 "clones must be >= 0 and <= current burst\n");
1210 			}
1211 			if (!strcmp(lgopts[opt_idx].name, "flowgen-flows")) {
1212 				n = atoi(optarg);
1213 				if (n > 0)
1214 					nb_flows_flowgen = (int) n;
1215 				else
1216 					rte_exit(EXIT_FAILURE,
1217 						 "flows must be >= 1\n");
1218 			}
1219 			if (!strcmp(lgopts[opt_idx].name, "mbcache")) {
1220 				n = atoi(optarg);
1221 				if ((n >= 0) &&
1222 				    (n <= RTE_MEMPOOL_CACHE_MAX_SIZE))
1223 					mb_mempool_cache = (uint16_t) n;
1224 				else
1225 					rte_exit(EXIT_FAILURE,
1226 						 "mbcache must be >= 0 and <= %d\n",
1227 						 RTE_MEMPOOL_CACHE_MAX_SIZE);
1228 			}
1229 			if (!strcmp(lgopts[opt_idx].name, "txfreet")) {
1230 				n = atoi(optarg);
1231 				if (n >= 0)
1232 					tx_free_thresh = (int16_t)n;
1233 				else
1234 					rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n");
1235 			}
1236 			if (!strcmp(lgopts[opt_idx].name, "txrst")) {
1237 				n = atoi(optarg);
1238 				if (n >= 0)
1239 					tx_rs_thresh = (int16_t)n;
1240 				else
1241 					rte_exit(EXIT_FAILURE, "txrst must be >= 0\n");
1242 			}
1243 			if (!strcmp(lgopts[opt_idx].name, "rxd")) {
1244 				n = atoi(optarg);
1245 				if (n > 0) {
1246 					if (rx_free_thresh >= n)
1247 						rte_exit(EXIT_FAILURE,
1248 							 "rxd must be > "
1249 							 "rx_free_thresh(%d)\n",
1250 							 (int)rx_free_thresh);
1251 					else
1252 						nb_rxd = (uint16_t) n;
1253 				} else
1254 					rte_exit(EXIT_FAILURE,
1255 						 "rxd(%d) invalid - must be > 0\n",
1256 						 n);
1257 			}
1258 			if (!strcmp(lgopts[opt_idx].name, "txd")) {
1259 				n = atoi(optarg);
1260 				if (n > 0)
1261 					nb_txd = (uint16_t) n;
1262 				else
1263 					rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
1264 			}
1265 			if (!strcmp(lgopts[opt_idx].name, "txpt")) {
1266 				n = atoi(optarg);
1267 				if (n >= 0)
1268 					tx_pthresh = (int8_t)n;
1269 				else
1270 					rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
1271 			}
1272 			if (!strcmp(lgopts[opt_idx].name, "txht")) {
1273 				n = atoi(optarg);
1274 				if (n >= 0)
1275 					tx_hthresh = (int8_t)n;
1276 				else
1277 					rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
1278 			}
1279 			if (!strcmp(lgopts[opt_idx].name, "txwt")) {
1280 				n = atoi(optarg);
1281 				if (n >= 0)
1282 					tx_wthresh = (int8_t)n;
1283 				else
1284 					rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
1285 			}
1286 			if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
1287 				n = atoi(optarg);
1288 				if (n >= 0)
1289 					rx_pthresh = (int8_t)n;
1290 				else
1291 					rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
1292 			}
1293 			if (!strcmp(lgopts[opt_idx].name, "rxht")) {
1294 				n = atoi(optarg);
1295 				if (n >= 0)
1296 					rx_hthresh = (int8_t)n;
1297 				else
1298 					rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
1299 			}
1300 			if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
1301 				n = atoi(optarg);
1302 				if (n >= 0)
1303 					rx_wthresh = (int8_t)n;
1304 				else
1305 					rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
1306 			}
1307 			if (!strcmp(lgopts[opt_idx].name, "rxfreet")) {
1308 				n = atoi(optarg);
1309 				if (n >= 0)
1310 					rx_free_thresh = (int16_t)n;
1311 				else
1312 					rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n");
1313 			}
1314 			if (!strcmp(lgopts[opt_idx].name, "rxoffs")) {
1315 				unsigned int seg_off[MAX_SEGS_BUFFER_SPLIT];
1316 				unsigned int nb_offs;
1317 
1318 				nb_offs = parse_item_list
1319 						(optarg, "rxpkt offsets",
1320 						 MAX_SEGS_BUFFER_SPLIT,
1321 						 seg_off, 0);
1322 				if (nb_offs > 0)
1323 					set_rx_pkt_offsets(seg_off, nb_offs);
1324 				else
1325 					rte_exit(EXIT_FAILURE, "bad rxoffs\n");
1326 			}
1327 			if (!strcmp(lgopts[opt_idx].name, "rxpkts")) {
1328 				unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT];
1329 				unsigned int nb_segs;
1330 
1331 				nb_segs = parse_item_list
1332 						(optarg, "rxpkt segments",
1333 						 MAX_SEGS_BUFFER_SPLIT,
1334 						 seg_len, 0);
1335 				if (nb_segs > 0)
1336 					set_rx_pkt_segments(seg_len, nb_segs);
1337 				else
1338 					rte_exit(EXIT_FAILURE, "bad rxpkts\n");
1339 			}
1340 			if (!strcmp(lgopts[opt_idx].name, "txpkts")) {
1341 				unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1342 				unsigned int nb_segs;
1343 
1344 				nb_segs = parse_item_list(optarg, "txpkt segments",
1345 						RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1346 				if (nb_segs > 0)
1347 					set_tx_pkt_segments(seg_lengths, nb_segs);
1348 				else
1349 					rte_exit(EXIT_FAILURE, "bad txpkts\n");
1350 			}
1351 			if (!strcmp(lgopts[opt_idx].name, "txonly-multi-flow"))
1352 				txonly_multi_flow = 1;
1353 			if (!strcmp(lgopts[opt_idx].name, "rxq-share")) {
1354 				if (optarg == NULL) {
1355 					rxq_share = UINT32_MAX;
1356 				} else {
1357 					n = atoi(optarg);
1358 					if (n >= 0)
1359 						rxq_share = (uint32_t)n;
1360 					else
1361 						rte_exit(EXIT_FAILURE, "rxq-share must be >= 0\n");
1362 				}
1363 			}
1364 			if (!strcmp(lgopts[opt_idx].name, "no-flush-rx"))
1365 				no_flush_rx = 1;
1366 			if (!strcmp(lgopts[opt_idx].name, "eth-link-speed")) {
1367 				n = atoi(optarg);
1368 				if (n >= 0 && parse_link_speed(n) > 0)
1369 					eth_link_speed = parse_link_speed(n);
1370 			}
1371 			if (!strcmp(lgopts[opt_idx].name, "disable-link-check"))
1372 				no_link_check = 1;
1373 			if (!strcmp(lgopts[opt_idx].name, "disable-device-start"))
1374 				no_device_start = 1;
1375 			if (!strcmp(lgopts[opt_idx].name, "no-lsc-interrupt"))
1376 				lsc_interrupt = 0;
1377 			if (!strcmp(lgopts[opt_idx].name, "no-rmv-interrupt"))
1378 				rmv_interrupt = 0;
1379 			if (!strcmp(lgopts[opt_idx].name, "flow-isolate-all"))
1380 				flow_isolate_all = 1;
1381 			if (!strcmp(lgopts[opt_idx].name, "tx-offloads")) {
1382 				char *end = NULL;
1383 				n = strtoull(optarg, &end, 16);
1384 				if (n >= 0)
1385 					tx_offloads = (uint64_t)n;
1386 				else
1387 					rte_exit(EXIT_FAILURE,
1388 						 "tx-offloads must be >= 0\n");
1389 			}
1390 
1391 			if (!strcmp(lgopts[opt_idx].name, "rx-offloads")) {
1392 				char *end = NULL;
1393 				n = strtoull(optarg, &end, 16);
1394 				if (n >= 0)
1395 					rx_offloads = (uint64_t)n;
1396 				else
1397 					rte_exit(EXIT_FAILURE,
1398 						 "rx-offloads must be >= 0\n");
1399 			}
1400 
1401 			if (!strcmp(lgopts[opt_idx].name, "vxlan-gpe-port")) {
1402 				n = atoi(optarg);
1403 				if (n >= 0)
1404 					vxlan_gpe_udp_port = (uint16_t)n;
1405 				else
1406 					rte_exit(EXIT_FAILURE,
1407 						 "vxlan-gpe-port must be >= 0\n");
1408 			}
1409 			if (!strcmp(lgopts[opt_idx].name,
1410 				    "geneve-parsed-port")) {
1411 				n = atoi(optarg);
1412 				if (n >= 0)
1413 					geneve_udp_port = (uint16_t)n;
1414 				else
1415 					rte_exit(EXIT_FAILURE,
1416 						 "geneve-parsed-port must be >= 0\n");
1417 			}
1418 			if (!strcmp(lgopts[opt_idx].name, "print-event"))
1419 				if (parse_event_printing_config(optarg, 1)) {
1420 					rte_exit(EXIT_FAILURE,
1421 						 "invalid print-event argument\n");
1422 				}
1423 			if (!strcmp(lgopts[opt_idx].name, "mask-event"))
1424 				if (parse_event_printing_config(optarg, 0)) {
1425 					rte_exit(EXIT_FAILURE,
1426 						 "invalid mask-event argument\n");
1427 				}
1428 			if (!strcmp(lgopts[opt_idx].name, "hot-plug"))
1429 				hot_plug = 1;
1430 			if (!strcmp(lgopts[opt_idx].name, "mlockall"))
1431 				do_mlockall = 1;
1432 			if (!strcmp(lgopts[opt_idx].name, "no-mlockall"))
1433 				do_mlockall = 0;
1434 			if (!strcmp(lgopts[opt_idx].name,
1435 				    "noisy-tx-sw-buffer-size")) {
1436 				n = atoi(optarg);
1437 				if (n >= 0)
1438 					noisy_tx_sw_bufsz = n;
1439 				else
1440 					rte_exit(EXIT_FAILURE,
1441 						"noisy-tx-sw-buffer-size must be >= 0\n");
1442 			}
1443 			if (!strcmp(lgopts[opt_idx].name,
1444 				    "noisy-tx-sw-buffer-flushtime")) {
1445 				n = atoi(optarg);
1446 				if (n >= 0)
1447 					noisy_tx_sw_buf_flush_time = n;
1448 				else
1449 					rte_exit(EXIT_FAILURE,
1450 						 "noisy-tx-sw-buffer-flushtime must be >= 0\n");
1451 			}
1452 			if (!strcmp(lgopts[opt_idx].name,
1453 				    "noisy-lkup-memory")) {
1454 				n = atoi(optarg);
1455 				if (n >= 0)
1456 					noisy_lkup_mem_sz = n;
1457 				else
1458 					rte_exit(EXIT_FAILURE,
1459 						 "noisy-lkup-memory must be >= 0\n");
1460 			}
1461 			if (!strcmp(lgopts[opt_idx].name,
1462 				    "noisy-lkup-num-writes")) {
1463 				n = atoi(optarg);
1464 				if (n >= 0)
1465 					noisy_lkup_num_writes = n;
1466 				else
1467 					rte_exit(EXIT_FAILURE,
1468 						 "noisy-lkup-num-writes must be >= 0\n");
1469 			}
1470 			if (!strcmp(lgopts[opt_idx].name,
1471 				    "noisy-lkup-num-reads")) {
1472 				n = atoi(optarg);
1473 				if (n >= 0)
1474 					noisy_lkup_num_reads = n;
1475 				else
1476 					rte_exit(EXIT_FAILURE,
1477 						 "noisy-lkup-num-reads must be >= 0\n");
1478 			}
1479 			if (!strcmp(lgopts[opt_idx].name,
1480 				    "noisy-lkup-num-reads-writes")) {
1481 				n = atoi(optarg);
1482 				if (n >= 0)
1483 					noisy_lkup_num_reads_writes = n;
1484 				else
1485 					rte_exit(EXIT_FAILURE,
1486 						 "noisy-lkup-num-reads-writes must be >= 0\n");
1487 			}
1488 			if (!strcmp(lgopts[opt_idx].name, "no-iova-contig"))
1489 				mempool_flags = RTE_MEMPOOL_F_NO_IOVA_CONTIG;
1490 
1491 			if (!strcmp(lgopts[opt_idx].name, "rx-mq-mode")) {
1492 				char *end = NULL;
1493 				n = strtoul(optarg, &end, 16);
1494 				if (n >= 0 && n <= RTE_ETH_MQ_RX_VMDQ_DCB_RSS)
1495 					rx_mq_mode = (enum rte_eth_rx_mq_mode)n;
1496 				else
1497 					rte_exit(EXIT_FAILURE,
1498 						 "rx-mq-mode must be >= 0 and <= %d\n",
1499 						 RTE_ETH_MQ_RX_VMDQ_DCB_RSS);
1500 			}
1501 			if (!strcmp(lgopts[opt_idx].name, "record-core-cycles"))
1502 				record_core_cycles = 1;
1503 			if (!strcmp(lgopts[opt_idx].name, "record-burst-stats"))
1504 				record_burst_stats = 1;
1505 			if (!strcmp(lgopts[opt_idx].name, PARAM_NUM_PROCS))
1506 				num_procs = atoi(optarg);
1507 			if (!strcmp(lgopts[opt_idx].name, PARAM_PROC_ID))
1508 				proc_id = atoi(optarg);
1509 			break;
1510 		case 'h':
1511 			usage(argv[0]);
1512 			exit(EXIT_SUCCESS);
1513 			break;
1514 		default:
1515 			usage(argv[0]);
1516 			fprintf(stderr, "Invalid option: %s\n", argv[optind]);
1517 			rte_exit(EXIT_FAILURE,
1518 				 "Command line is incomplete or incorrect\n");
1519 			break;
1520 		}
1521 	}
1522 
1523 	if (optind != argc) {
1524 		usage(argv[0]);
1525 		fprintf(stderr, "Invalid parameter: %s\n", argv[optind]);
1526 		rte_exit(EXIT_FAILURE, "Command line is incorrect\n");
1527 	}
1528 
1529 	if (proc_id >= (int)num_procs)
1530 		rte_exit(EXIT_FAILURE,
1531 			 "The multi-process option '%s(%d)' should be less than '%s(%u)'\n",
1532 			 PARAM_PROC_ID, proc_id,
1533 			 PARAM_NUM_PROCS, num_procs);
1534 
1535 	/* Set offload configuration from command line parameters. */
1536 	rx_mode.offloads = rx_offloads;
1537 	tx_mode.offloads = tx_offloads;
1538 
1539 	if (mempool_flags & RTE_MEMPOOL_F_NO_IOVA_CONTIG &&
1540 	    mp_alloc_type != MP_ALLOC_ANON) {
1541 		TESTPMD_LOG(WARNING, "cannot use no-iova-contig without "
1542 				  "mp-alloc=anon. mempool no-iova-contig is "
1543 				  "ignored\n");
1544 		mempool_flags = 0;
1545 	}
1546 }
1547