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