xref: /dpdk/app/test-pmd/parameters.c (revision 35b2d13fd6fdcbd191f2a30d74648faeb1186c65)
1174a1631SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2174a1631SBruce Richardson  * Copyright(c) 2010-2017 Intel Corporation
3af75078fSIntel  */
4af75078fSIntel 
5af75078fSIntel #include <errno.h>
6af75078fSIntel #include <getopt.h>
7af75078fSIntel #include <stdarg.h>
8af75078fSIntel #include <stdio.h>
9af75078fSIntel #include <stdlib.h>
10af75078fSIntel #include <signal.h>
11af75078fSIntel #include <string.h>
12af75078fSIntel #include <time.h>
13af75078fSIntel #include <fcntl.h>
14af75078fSIntel #include <sys/types.h>
15af75078fSIntel 
16af75078fSIntel #include <sys/queue.h>
17af75078fSIntel #include <sys/stat.h>
18af75078fSIntel 
19af75078fSIntel #include <stdint.h>
20af75078fSIntel #include <unistd.h>
21af75078fSIntel #include <inttypes.h>
22bf5b2126SStephen Hemminger #include <arpa/inet.h>
23af75078fSIntel 
24af75078fSIntel #include <rte_common.h>
25af75078fSIntel #include <rte_byteorder.h>
26af75078fSIntel #include <rte_log.h>
27af75078fSIntel #include <rte_debug.h>
28af75078fSIntel #include <rte_cycles.h>
29af75078fSIntel #include <rte_memory.h>
30af75078fSIntel #include <rte_launch.h>
31af75078fSIntel #include <rte_eal.h>
32af75078fSIntel #include <rte_per_lcore.h>
33af75078fSIntel #include <rte_lcore.h>
34af75078fSIntel #include <rte_atomic.h>
35af75078fSIntel #include <rte_branch_prediction.h>
36af75078fSIntel #include <rte_mempool.h>
37af75078fSIntel #include <rte_interrupts.h>
38af75078fSIntel #include <rte_pci.h>
39af75078fSIntel #include <rte_ether.h>
40af75078fSIntel #include <rte_ethdev.h>
41af75078fSIntel #include <rte_string_fns.h>
420d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
43af75078fSIntel #include <cmdline_parse.h>
44af75078fSIntel #include <cmdline_parse_etheraddr.h>
450d56cb81SThomas Monjalon #endif
462950a769SDeclan Doherty #ifdef RTE_LIBRTE_PMD_BOND
472950a769SDeclan Doherty #include <rte_eth_bond.h>
482950a769SDeclan Doherty #endif
49938a184aSAdrien Mazarguil #include <rte_flow.h>
50af75078fSIntel 
51af75078fSIntel #include "testpmd.h"
52af75078fSIntel 
53af75078fSIntel static void
54af75078fSIntel usage(char* progname)
55af75078fSIntel {
560d56cb81SThomas Monjalon 	printf("usage: %s "
570d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
580d56cb81SThomas Monjalon 	       "[--interactive|-i] "
5981ef862bSAllain Legacy 	       "[--cmdline-file=FILENAME] "
600d56cb81SThomas Monjalon #endif
61ca7feb22SCyril Chemparathy 	       "[--help|-h] | [--auto-start|-a] | ["
62cfea1f30SPablo de Lara 	       "--tx-first | --stats-period=PERIOD | "
63af75078fSIntel 	       "--coremask=COREMASK --portmask=PORTMASK --numa "
64c8798818SIntel 	       "--mbuf-size= | --total-num-mbufs= | "
653be52ffcSIntel 	       "--nb-cores= | --nb-ports= | "
660d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
67af75078fSIntel 	       "--eth-peers-configfile= | "
683be52ffcSIntel 	       "--eth-peer=X,M:M:M:M:M:M | "
69bf5b2126SStephen Hemminger 	       "--tx-ip=SRC,DST | --tx-udp=PORT | "
700d56cb81SThomas Monjalon #endif
71af75078fSIntel 	       "--pkt-filter-mode= |"
72af75078fSIntel 	       "--rss-ip | --rss-udp | "
73af75078fSIntel 	       "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
74af75078fSIntel 	       "--txpt= | --txht= | --txwt= | --txfreet= | "
7539e5e20fSXueming Li 	       "--txrst= | --tx-offloads= | --vxlan-gpe-port= ]\n",
76af75078fSIntel 	       progname);
770d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
783be52ffcSIntel 	printf("  --interactive: run in interactive mode.\n");
7981ef862bSAllain Legacy 	printf("  --cmdline-file: execute cli commands before startup.\n");
800d56cb81SThomas Monjalon #endif
81ca7feb22SCyril Chemparathy 	printf("  --auto-start: start forwarding on init "
82ca7feb22SCyril Chemparathy 	       "[always when non-interactive].\n");
833be52ffcSIntel 	printf("  --help: display this message and quit.\n");
8499cabef0SPablo de Lara 	printf("  --tx-first: start forwarding sending a burst first "
8599cabef0SPablo de Lara 	       "(only if interactive is disabled).\n");
86cfea1f30SPablo de Lara 	printf("  --stats-period=PERIOD: statistics will be shown "
87cfea1f30SPablo de Lara 	       "every PERIOD seconds (only if interactive is disabled).\n");
883be52ffcSIntel 	printf("  --nb-cores=N: set the number of forwarding cores "
893be52ffcSIntel 	       "(1 <= N <= %d).\n", nb_lcores);
903be52ffcSIntel 	printf("  --nb-ports=N: set the number of forwarding ports "
913be52ffcSIntel 	       "(1 <= N <= %d).\n", nb_ports);
92af75078fSIntel 	printf("  --coremask=COREMASK: hexadecimal bitmask of cores running "
93013af9b6SIntel 	       "the packet forwarding test. The master lcore is reserved for "
943be52ffcSIntel 	       "command line parsing only, and cannot be masked on for "
953be52ffcSIntel 	       "packet forwarding.\n");
96af75078fSIntel 	printf("  --portmask=PORTMASK: hexadecimal bitmask of ports used "
973be52ffcSIntel 	       "by the packet forwarding test.\n");
98af75078fSIntel 	printf("  --numa: enable NUMA-aware allocation of RX/TX rings and of "
993be52ffcSIntel 	       "RX memory buffers (mbufs).\n");
100b6ea6408SIntel 	printf("  --port-numa-config=(port,socket)[,(port,socket)]: "
101b6ea6408SIntel 	       "specify the socket on which the memory pool "
102b6ea6408SIntel 	       "used by the port will be allocated.\n");
103b6ea6408SIntel 	printf("  --ring-numa-config=(port,flag,socket)[,(port,flag,socket)]: "
104b6ea6408SIntel 	       "specify the socket on which the TX/RX rings for "
105b6ea6408SIntel 	       "the port will be allocated "
106b6ea6408SIntel 	       "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
107b6ea6408SIntel 	printf("  --socket-num=N: set socket from which all memory is allocated "
108b6ea6408SIntel 	       "in NUMA mode.\n");
1093be52ffcSIntel 	printf("  --mbuf-size=N: set the data size of mbuf to N bytes.\n");
1103be52ffcSIntel 	printf("  --total-num-mbufs=N: set the number of mbufs to be allocated "
1113be52ffcSIntel 	       "in mbuf pools.\n");
1123be52ffcSIntel 	printf("  --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
1130d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
1143be52ffcSIntel 	printf("  --eth-peers-configfile=name: config file with ethernet addresses "
1153be52ffcSIntel 	       "of peer ports.\n");
1163be52ffcSIntel 	printf("  --eth-peer=X,M:M:M:M:M:M: set the MAC address of the X peer "
1173be52ffcSIntel 	       "port (0 <= X < %d).\n", RTE_MAX_ETHPORTS);
1180d56cb81SThomas Monjalon #endif
1193be52ffcSIntel 	printf("  --pkt-filter-mode=N: set Flow Director mode "
1203be52ffcSIntel 	       "(N: none (default mode) or signature or perfect).\n");
1213be52ffcSIntel 	printf("  --pkt-filter-report-hash=N: set Flow Director report mode "
1223be52ffcSIntel 	       "(N: none  or match (default) or always).\n");
1233be52ffcSIntel 	printf("  --pkt-filter-size=N: set Flow Director mode "
1243be52ffcSIntel 	       "(N: 64K (default mode) or 128K or 256K).\n");
125af75078fSIntel 	printf("  --pkt-filter-drop-queue=N: set drop-queue. "
1263be52ffcSIntel 	       "In perfect mode, when you add a rule with queue = -1 "
127af75078fSIntel 	       "the packet will be enqueued into the rx drop-queue. "
128af75078fSIntel 	       "If the drop-queue doesn't exist, the packet is dropped. "
1293be52ffcSIntel 	       "By default drop-queue=127.\n");
13062d3216dSReshma Pattan #ifdef RTE_LIBRTE_LATENCY_STATS
13162d3216dSReshma Pattan 	printf("  --latencystats=N: enable latency and jitter statistcs "
13262d3216dSReshma Pattan 	       "monitoring on forwarding lcore id N.\n");
13362d3216dSReshma Pattan #endif
13479dd163fSJeff Guo 	printf("  --disable-crc-strip: disable CRC stripping by hardware.\n");
1354c3ea508SOlivier Matz 	printf("  --enable-lro: enable large receive offload.\n");
1363be52ffcSIntel 	printf("  --enable-rx-cksum: enable rx hardware checksum offload.\n");
137912267a3SRaslan Darawsheh 	printf("  --enable-rx-timestamp: enable rx hardware timestamp offload.\n");
1388b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan: enable hardware vlan.\n");
1398b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan-filter: enable hardware vlan filter.\n");
1408b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan-strip: enable hardware vlan strip.\n");
1418b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan-extend: enable hardware vlan extend.\n");
1423be52ffcSIntel 	printf("  --enable-drop-en: enable per queue packet drop.\n");
1433be52ffcSIntel 	printf("  --disable-rss: disable rss.\n");
144af75078fSIntel 	printf("  --port-topology=N: set port topology (N: paired (default) or "
1453be52ffcSIntel 	       "chained).\n");
146769ce6b1SThomas Monjalon 	printf("  --forward-mode=N: set forwarding mode (N: %s).\n",
147769ce6b1SThomas Monjalon 	       list_pkt_forwarding_modes());
1483be52ffcSIntel 	printf("  --rss-ip: set RSS functions to IPv4/IPv6 only .\n");
1493be52ffcSIntel 	printf("  --rss-udp: set RSS functions to IPv4/IPv6 + UDP.\n");
1503be52ffcSIntel 	printf("  --rxq=N: set the number of RX queues per port to N.\n");
1513be52ffcSIntel 	printf("  --rxd=N: set the number of descriptors in RX rings to N.\n");
1523be52ffcSIntel 	printf("  --txq=N: set the number of TX queues per port to N.\n");
1533be52ffcSIntel 	printf("  --txd=N: set the number of descriptors in TX rings to N.\n");
1543be52ffcSIntel 	printf("  --burst=N: set the number of packets per burst to N.\n");
1553be52ffcSIntel 	printf("  --mbcache=N: set the cache of mbuf memory pool to N.\n");
15657af3415SPablo de Lara 	printf("  --rxpt=N: set prefetch threshold register of RX rings to N.\n");
15757af3415SPablo de Lara 	printf("  --rxht=N: set the host threshold register of RX rings to N.\n");
1583be52ffcSIntel 	printf("  --rxfreet=N: set the free threshold of RX descriptors to N "
1593be52ffcSIntel 	       "(0 <= N < value of rxd).\n");
16057af3415SPablo de Lara 	printf("  --rxwt=N: set the write-back threshold register of RX rings to N.\n");
16157af3415SPablo de Lara 	printf("  --txpt=N: set the prefetch threshold register of TX rings to N.\n");
16257af3415SPablo de Lara 	printf("  --txht=N: set the nhost threshold register of TX rings to N.\n");
16357af3415SPablo de Lara 	printf("  --txwt=N: set the write-back threshold register of TX rings to N.\n");
1643be52ffcSIntel 	printf("  --txfreet=N: set the transmit free threshold of TX rings to N "
1653be52ffcSIntel 	       "(0 <= N <= value of txd).\n");
1663be52ffcSIntel 	printf("  --txrst=N: set the transmit RS bit threshold of TX rings to N "
1673be52ffcSIntel 	       "(0 <= N <= value of txd).\n");
1683be52ffcSIntel 	printf("  --tx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: "
169ed30d9b6SIntel 	       "tx queues statistics counters mapping "
1703be52ffcSIntel 	       "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
1713be52ffcSIntel 	printf("  --rx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: "
172ed30d9b6SIntel 	       "rx queues statistics counters mapping "
1733be52ffcSIntel 	       "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
1745e2ee196SIntel 	printf("  --no-flush-rx: Don't flush RX streams before forwarding."
1755e2ee196SIntel 	       " Used mainly with PCAP drivers.\n");
1762ebacaa7SMaciej Czekaj 	printf("  --txpkts=X[,Y]*: set TX segment sizes"
1772ebacaa7SMaciej Czekaj 		" or total packet length.\n");
17882010ef5SYongseok Koh 	printf("  --txonly-multi-flow: generate multiple flows in txonly mode\n");
179bc202406SDavid Marchand 	printf("  --disable-link-check: disable check on link status when "
180bc202406SDavid Marchand 	       "starting/stopping ports.\n");
1818ea656f8SGaetan Rivet 	printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
182e25e6c70SRemy Horton 	printf("  --no-rmv-interrupt: disable device removal interrupt.\n");
183e25e6c70SRemy Horton 	printf("  --bitrate-stats=N: set the logical core N to perform "
184e25e6c70SRemy Horton 		"bit-rate calculation.\n");
185b6b63dfdSGaetan Rivet 	printf("  --print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>: "
186776ecd42SWenzhuo Lu 	       "enable print of designated event or all of them.\n");
187b6b63dfdSGaetan Rivet 	printf("  --mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>: "
188776ecd42SWenzhuo Lu 	       "disable print of designated event or all of them.\n");
1897ee3e944SVasily Philipov 	printf("  --flow-isolate-all: "
190776ecd42SWenzhuo Lu 	       "requests flow API isolated mode on all ports at initialization time.\n");
191fd8c20aaSShahaf Shuler 	printf("  --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
192fb73e096SJeff Guo 	printf("  --hot-plug: enable hot plug for device.\n");
19339e5e20fSXueming Li 	printf("  --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\n");
194e505d84cSAnatoly Burakov 	printf("  --mlockall: lock all memory\n");
195e505d84cSAnatoly Burakov 	printf("  --no-mlockall: do not lock all memory\n");
196c7f5dba7SAnatoly Burakov 	printf("  --mp-alloc <native|anon|xmem|xmemhuge>: mempool allocation method.\n"
197c7f5dba7SAnatoly Burakov 	       "    native: use regular DPDK memory to create and populate mempool\n"
198c7f5dba7SAnatoly Burakov 	       "    anon: use regular DPDK memory to create and anonymous memory to populate mempool\n"
199c7f5dba7SAnatoly Burakov 	       "    xmem: use anonymous memory to create and populate mempool\n"
200c7f5dba7SAnatoly Burakov 	       "    xmemhuge: use anonymous hugepage memory to create and populate mempool\n");
2013c156061SJens Freimann 	printf("  --noisy-tx-sw-buffer-size=N: size of FIFO buffer\n");
2023c156061SJens Freimann 	printf("  --noisy-tx-sw-buffer-flushtime=N: flush FIFO after N ms\n");
2033c156061SJens Freimann 	printf("  --noisy-lkup-memory=N: allocate N MB of VNF memory\n");
2043c156061SJens Freimann 	printf("  --noisy-lkup-num-writes=N: do N random writes per packet\n");
2053c156061SJens Freimann 	printf("  --noisy-lkup-num-reads=N: do N random reads per packet\n");
2063c156061SJens Freimann 	printf("  --noisy-lkup-num-writes=N: do N random reads and writes per packet\n");
20759fcf854SShahaf Shuler 	printf("  --no-iova-contig: mempool memory can be IOVA non contiguous. "
20859fcf854SShahaf Shuler 	       "valid only with --mp-alloc=anon\n");
209af75078fSIntel }
210af75078fSIntel 
2110d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
212af75078fSIntel static int
213af75078fSIntel init_peer_eth_addrs(char *config_filename)
214af75078fSIntel {
215af75078fSIntel 	FILE *config_file;
216af75078fSIntel 	portid_t i;
217af75078fSIntel 	char buf[50];
218af75078fSIntel 
219af75078fSIntel 	config_file = fopen(config_filename, "r");
220af75078fSIntel 	if (config_file == NULL) {
2213be52ffcSIntel 		perror("Failed to open eth config file\n");
222af75078fSIntel 		return -1;
223af75078fSIntel 	}
224af75078fSIntel 
225af75078fSIntel 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
226af75078fSIntel 
227af75078fSIntel 		if (fgets(buf, sizeof(buf), config_file) == NULL)
228af75078fSIntel 			break;
229af75078fSIntel 
230aaa662e7SAlan Carew 		if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i],
231aaa662e7SAlan Carew 				sizeof(peer_eth_addrs[i])) < 0) {
2323be52ffcSIntel 			printf("Bad MAC address format on line %d\n", i+1);
233af75078fSIntel 			fclose(config_file);
234af75078fSIntel 			return -1;
235af75078fSIntel 		}
236af75078fSIntel 	}
237af75078fSIntel 	fclose(config_file);
238af75078fSIntel 	nb_peer_eth_addrs = (portid_t) i;
239af75078fSIntel 	return 0;
240af75078fSIntel }
2410d56cb81SThomas Monjalon #endif
242af75078fSIntel 
243af75078fSIntel /*
244af75078fSIntel  * Parse the coremask given as argument (hexadecimal string) and set
245af75078fSIntel  * the global configuration of forwarding cores.
246af75078fSIntel  */
247af75078fSIntel static void
248af75078fSIntel parse_fwd_coremask(const char *coremask)
249af75078fSIntel {
250af75078fSIntel 	char *end;
251af75078fSIntel 	unsigned long long int cm;
252af75078fSIntel 
253af75078fSIntel 	/* parse hexadecimal string */
254af75078fSIntel 	end = NULL;
255af75078fSIntel 	cm = strtoull(coremask, &end, 16);
256af75078fSIntel 	if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0'))
257af75078fSIntel 		rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n");
258013af9b6SIntel 	else if (set_fwd_lcores_mask((uint64_t) cm) < 0)
259013af9b6SIntel 		rte_exit(EXIT_FAILURE, "coremask is not valid\n");
260af75078fSIntel }
261af75078fSIntel 
262af75078fSIntel /*
263af75078fSIntel  * Parse the coremask given as argument (hexadecimal string) and set
264af75078fSIntel  * the global configuration of forwarding cores.
265af75078fSIntel  */
266af75078fSIntel static void
267af75078fSIntel parse_fwd_portmask(const char *portmask)
268af75078fSIntel {
269af75078fSIntel 	char *end;
270af75078fSIntel 	unsigned long long int pm;
271af75078fSIntel 
272af75078fSIntel 	/* parse hexadecimal string */
273af75078fSIntel 	end = NULL;
274af75078fSIntel 	pm = strtoull(portmask, &end, 16);
275af75078fSIntel 	if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
276af75078fSIntel 		rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n");
277af75078fSIntel 	else
278af75078fSIntel 		set_fwd_ports_mask((uint64_t) pm);
279af75078fSIntel }
280af75078fSIntel 
281ed30d9b6SIntel 
282ed30d9b6SIntel static int
283ed30d9b6SIntel parse_queue_stats_mapping_config(const char *q_arg, int is_rx)
284ed30d9b6SIntel {
285ed30d9b6SIntel 	char s[256];
286ed30d9b6SIntel 	const char *p, *p0 = q_arg;
287ed30d9b6SIntel 	char *end;
288ed30d9b6SIntel 	enum fieldnames {
289ed30d9b6SIntel 		FLD_PORT = 0,
290ed30d9b6SIntel 		FLD_QUEUE,
291ed30d9b6SIntel 		FLD_STATS_COUNTER,
292ed30d9b6SIntel 		_NUM_FLD
293ed30d9b6SIntel 	};
294ed30d9b6SIntel 	unsigned long int_fld[_NUM_FLD];
295ed30d9b6SIntel 	char *str_fld[_NUM_FLD];
296ed30d9b6SIntel 	int i;
297ed30d9b6SIntel 	unsigned size;
298ed30d9b6SIntel 
299ed30d9b6SIntel 	/* reset from value set at definition */
300ed30d9b6SIntel 	is_rx ? (nb_rx_queue_stats_mappings = 0) : (nb_tx_queue_stats_mappings = 0);
301ed30d9b6SIntel 
302ed30d9b6SIntel 	while ((p = strchr(p0,'(')) != NULL) {
303ed30d9b6SIntel 		++p;
304ed30d9b6SIntel 		if((p0 = strchr(p,')')) == NULL)
305ed30d9b6SIntel 			return -1;
306ed30d9b6SIntel 
307ed30d9b6SIntel 		size = p0 - p;
308ed30d9b6SIntel 		if(size >= sizeof(s))
309ed30d9b6SIntel 			return -1;
310ed30d9b6SIntel 
3116f41fe75SStephen Hemminger 		snprintf(s, sizeof(s), "%.*s", size, p);
312ed30d9b6SIntel 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
313ed30d9b6SIntel 			return -1;
314ed30d9b6SIntel 		for (i = 0; i < _NUM_FLD; i++){
315ed30d9b6SIntel 			errno = 0;
316ed30d9b6SIntel 			int_fld[i] = strtoul(str_fld[i], &end, 0);
317ed30d9b6SIntel 			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
318ed30d9b6SIntel 				return -1;
319ed30d9b6SIntel 		}
320ed30d9b6SIntel 		/* Check mapping field is in correct range (0..RTE_ETHDEV_QUEUE_STAT_CNTRS-1) */
321ed30d9b6SIntel 		if (int_fld[FLD_STATS_COUNTER] >= RTE_ETHDEV_QUEUE_STAT_CNTRS) {
322ed30d9b6SIntel 			printf("Stats counter not in the correct range 0..%d\n",
323ed30d9b6SIntel 					RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
324ed30d9b6SIntel 			return -1;
325ed30d9b6SIntel 		}
326ed30d9b6SIntel 
3274dccdc78SBruce Richardson 		if (!is_rx) {
3284dccdc78SBruce Richardson 			if ((nb_tx_queue_stats_mappings >=
3294dccdc78SBruce Richardson 						MAX_TX_QUEUE_STATS_MAPPINGS)) {
3304dccdc78SBruce Richardson 				printf("exceeded max number of TX queue "
3314dccdc78SBruce Richardson 						"statistics mappings: %hu\n",
3324dccdc78SBruce Richardson 						nb_tx_queue_stats_mappings);
333ed30d9b6SIntel 				return -1;
334ed30d9b6SIntel 			}
335ed30d9b6SIntel 			tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id =
336ed30d9b6SIntel 				(uint8_t)int_fld[FLD_PORT];
337ed30d9b6SIntel 			tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id =
338ed30d9b6SIntel 				(uint8_t)int_fld[FLD_QUEUE];
339ed30d9b6SIntel 			tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].stats_counter_id =
340ed30d9b6SIntel 				(uint8_t)int_fld[FLD_STATS_COUNTER];
341ed30d9b6SIntel 			++nb_tx_queue_stats_mappings;
342ed30d9b6SIntel 		}
343ed30d9b6SIntel 		else {
3444dccdc78SBruce Richardson 			if ((nb_rx_queue_stats_mappings >=
3454dccdc78SBruce Richardson 						MAX_RX_QUEUE_STATS_MAPPINGS)) {
3464dccdc78SBruce Richardson 				printf("exceeded max number of RX queue "
3474dccdc78SBruce Richardson 						"statistics mappings: %hu\n",
3484dccdc78SBruce Richardson 						nb_rx_queue_stats_mappings);
3494dccdc78SBruce Richardson 				return -1;
3504dccdc78SBruce Richardson 			}
351ed30d9b6SIntel 			rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id =
352ed30d9b6SIntel 				(uint8_t)int_fld[FLD_PORT];
353ed30d9b6SIntel 			rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id =
354ed30d9b6SIntel 				(uint8_t)int_fld[FLD_QUEUE];
355ed30d9b6SIntel 			rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].stats_counter_id =
356ed30d9b6SIntel 				(uint8_t)int_fld[FLD_STATS_COUNTER];
357ed30d9b6SIntel 			++nb_rx_queue_stats_mappings;
358ed30d9b6SIntel 		}
359ed30d9b6SIntel 
360ed30d9b6SIntel 	}
361ed30d9b6SIntel /* Reassign the rx/tx_queue_stats_mappings pointer to point to this newly populated array rather */
362ed30d9b6SIntel /* than to the default array (that was set at its definition) */
363ed30d9b6SIntel 	is_rx ? (rx_queue_stats_mappings = rx_queue_stats_mappings_array) :
364ed30d9b6SIntel 		(tx_queue_stats_mappings = tx_queue_stats_mappings_array);
365ed30d9b6SIntel 	return 0;
366ed30d9b6SIntel }
367ed30d9b6SIntel 
368c9cafcc8SShahaf Shuler static void
369c9cafcc8SShahaf Shuler print_invalid_socket_id_error(void)
370c9cafcc8SShahaf Shuler {
371c9cafcc8SShahaf Shuler 	unsigned int i = 0;
372c9cafcc8SShahaf Shuler 
373c9cafcc8SShahaf Shuler 	printf("Invalid socket id, options are: ");
374c9cafcc8SShahaf Shuler 	for (i = 0; i < num_sockets; i++) {
375c9cafcc8SShahaf Shuler 		printf("%u%s", socket_ids[i],
376c9cafcc8SShahaf Shuler 		      (i == num_sockets - 1) ? "\n" : ",");
377c9cafcc8SShahaf Shuler 	}
378c9cafcc8SShahaf Shuler }
379c9cafcc8SShahaf Shuler 
380b6ea6408SIntel static int
381b6ea6408SIntel parse_portnuma_config(const char *q_arg)
382b6ea6408SIntel {
383b6ea6408SIntel 	char s[256];
384b6ea6408SIntel 	const char *p, *p0 = q_arg;
385b6ea6408SIntel 	char *end;
386d1f1a0fdSLi Han 	uint8_t i, socket_id;
387d1f1a0fdSLi Han 	portid_t port_id;
388b6ea6408SIntel 	unsigned size;
389b6ea6408SIntel 	enum fieldnames {
390b6ea6408SIntel 		FLD_PORT = 0,
391b6ea6408SIntel 		FLD_SOCKET,
392b6ea6408SIntel 		_NUM_FLD
393b6ea6408SIntel 	};
394b6ea6408SIntel 	unsigned long int_fld[_NUM_FLD];
395b6ea6408SIntel 	char *str_fld[_NUM_FLD];
396b6ea6408SIntel 
397b6ea6408SIntel 	/* reset from value set at definition */
398b6ea6408SIntel 	while ((p = strchr(p0,'(')) != NULL) {
399b6ea6408SIntel 		++p;
400b6ea6408SIntel 		if((p0 = strchr(p,')')) == NULL)
401b6ea6408SIntel 			return -1;
402b6ea6408SIntel 
403b6ea6408SIntel 		size = p0 - p;
404b6ea6408SIntel 		if(size >= sizeof(s))
405b6ea6408SIntel 			return -1;
406b6ea6408SIntel 
4076f41fe75SStephen Hemminger 		snprintf(s, sizeof(s), "%.*s", size, p);
408b6ea6408SIntel 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
409b6ea6408SIntel 			return -1;
410b6ea6408SIntel 		for (i = 0; i < _NUM_FLD; i++) {
411b6ea6408SIntel 			errno = 0;
412b6ea6408SIntel 			int_fld[i] = strtoul(str_fld[i], &end, 0);
413b6ea6408SIntel 			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
414b6ea6408SIntel 				return -1;
415b6ea6408SIntel 		}
416d1f1a0fdSLi Han 		port_id = (portid_t)int_fld[FLD_PORT];
417d1f1a0fdSLi Han 		if (port_id_is_invalid(port_id, ENABLED_WARN) ||
418d1f1a0fdSLi Han 			port_id == (portid_t)RTE_PORT_ALL) {
4198f3c4176SMatan Azrad 			print_valid_ports();
420b6ea6408SIntel 			return -1;
421b6ea6408SIntel 		}
422b6ea6408SIntel 		socket_id = (uint8_t)int_fld[FLD_SOCKET];
423c9cafcc8SShahaf Shuler 		if (new_socket_id(socket_id)) {
424a569af24SPhil Yang 			if (num_sockets >= RTE_MAX_NUMA_NODES) {
425c9cafcc8SShahaf Shuler 				print_invalid_socket_id_error();
426b6ea6408SIntel 				return -1;
427b6ea6408SIntel 			}
428a569af24SPhil Yang 			socket_ids[num_sockets++] = socket_id;
429a569af24SPhil Yang 		}
430b6ea6408SIntel 		port_numa[port_id] = socket_id;
431b6ea6408SIntel 	}
432b6ea6408SIntel 
433b6ea6408SIntel 	return 0;
434b6ea6408SIntel }
435b6ea6408SIntel 
436b6ea6408SIntel static int
437b6ea6408SIntel parse_ringnuma_config(const char *q_arg)
438b6ea6408SIntel {
439b6ea6408SIntel 	char s[256];
440b6ea6408SIntel 	const char *p, *p0 = q_arg;
441b6ea6408SIntel 	char *end;
442d1f1a0fdSLi Han 	uint8_t i, ring_flag, socket_id;
443d1f1a0fdSLi Han 	portid_t port_id;
444b6ea6408SIntel 	unsigned size;
445b6ea6408SIntel 	enum fieldnames {
446b6ea6408SIntel 		FLD_PORT = 0,
447b6ea6408SIntel 		FLD_FLAG,
448b6ea6408SIntel 		FLD_SOCKET,
449b6ea6408SIntel 		_NUM_FLD
450b6ea6408SIntel 	};
451b6ea6408SIntel 	unsigned long int_fld[_NUM_FLD];
452b6ea6408SIntel 	char *str_fld[_NUM_FLD];
453b6ea6408SIntel 	#define RX_RING_ONLY 0x1
454b6ea6408SIntel 	#define TX_RING_ONLY 0x2
455b6ea6408SIntel 	#define RXTX_RING    0x3
456b6ea6408SIntel 
457b6ea6408SIntel 	/* reset from value set at definition */
458b6ea6408SIntel 	while ((p = strchr(p0,'(')) != NULL) {
459b6ea6408SIntel 		++p;
460b6ea6408SIntel 		if((p0 = strchr(p,')')) == NULL)
461b6ea6408SIntel 			return -1;
462b6ea6408SIntel 
463b6ea6408SIntel 		size = p0 - p;
464b6ea6408SIntel 		if(size >= sizeof(s))
465b6ea6408SIntel 			return -1;
466b6ea6408SIntel 
4676f41fe75SStephen Hemminger 		snprintf(s, sizeof(s), "%.*s", size, p);
468b6ea6408SIntel 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
469b6ea6408SIntel 			return -1;
470b6ea6408SIntel 		for (i = 0; i < _NUM_FLD; i++) {
471b6ea6408SIntel 			errno = 0;
472b6ea6408SIntel 			int_fld[i] = strtoul(str_fld[i], &end, 0);
473b6ea6408SIntel 			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
474b6ea6408SIntel 				return -1;
475b6ea6408SIntel 		}
476d1f1a0fdSLi Han 		port_id = (portid_t)int_fld[FLD_PORT];
477d1f1a0fdSLi Han 		if (port_id_is_invalid(port_id, ENABLED_WARN) ||
478d1f1a0fdSLi Han 			port_id == (portid_t)RTE_PORT_ALL) {
4798f3c4176SMatan Azrad 			print_valid_ports();
480b6ea6408SIntel 			return -1;
481b6ea6408SIntel 		}
482b6ea6408SIntel 		socket_id = (uint8_t)int_fld[FLD_SOCKET];
483c9cafcc8SShahaf Shuler 		if (new_socket_id(socket_id)) {
484a569af24SPhil Yang 			if (num_sockets >= RTE_MAX_NUMA_NODES) {
485c9cafcc8SShahaf Shuler 				print_invalid_socket_id_error();
486b6ea6408SIntel 				return -1;
487b6ea6408SIntel 			}
488a569af24SPhil Yang 			socket_ids[num_sockets++] = socket_id;
489a569af24SPhil Yang 		}
490b6ea6408SIntel 		ring_flag = (uint8_t)int_fld[FLD_FLAG];
491b6ea6408SIntel 		if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) {
492b6ea6408SIntel 			printf("Invalid ring-flag=%d config for port =%d\n",
493b6ea6408SIntel 				ring_flag,port_id);
494b6ea6408SIntel 			return -1;
495b6ea6408SIntel 		}
496b6ea6408SIntel 
497b6ea6408SIntel 		switch (ring_flag & RXTX_RING) {
498b6ea6408SIntel 		case RX_RING_ONLY:
499b6ea6408SIntel 			rxring_numa[port_id] = socket_id;
500b6ea6408SIntel 			break;
501b6ea6408SIntel 		case TX_RING_ONLY:
502b6ea6408SIntel 			txring_numa[port_id] = socket_id;
503b6ea6408SIntel 			break;
504b6ea6408SIntel 		case RXTX_RING:
505b6ea6408SIntel 			rxring_numa[port_id] = socket_id;
506b6ea6408SIntel 			txring_numa[port_id] = socket_id;
507b6ea6408SIntel 			break;
508b6ea6408SIntel 		default:
509b6ea6408SIntel 			printf("Invalid ring-flag=%d config for port=%d\n",
510b6ea6408SIntel 				ring_flag,port_id);
511b6ea6408SIntel 			break;
512b6ea6408SIntel 		}
513b6ea6408SIntel 	}
514b6ea6408SIntel 
515b6ea6408SIntel 	return 0;
516b6ea6408SIntel }
517ed30d9b6SIntel 
5183af72783SGaetan Rivet static int
5193af72783SGaetan Rivet parse_event_printing_config(const char *optarg, int enable)
5203af72783SGaetan Rivet {
5213af72783SGaetan Rivet 	uint32_t mask = 0;
5223af72783SGaetan Rivet 
5233af72783SGaetan Rivet 	if (!strcmp(optarg, "unknown"))
5243af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN;
5253af72783SGaetan Rivet 	else if (!strcmp(optarg, "intr_lsc"))
5263af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_LSC;
5273af72783SGaetan Rivet 	else if (!strcmp(optarg, "queue_state"))
5283af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_QUEUE_STATE;
5293af72783SGaetan Rivet 	else if (!strcmp(optarg, "intr_reset"))
5303af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET;
5313af72783SGaetan Rivet 	else if (!strcmp(optarg, "vf_mbox"))
5323af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_VF_MBOX;
533badb87c1SAnoob Joseph 	else if (!strcmp(optarg, "ipsec"))
534badb87c1SAnoob Joseph 		mask = UINT32_C(1) << RTE_ETH_EVENT_IPSEC;
5353af72783SGaetan Rivet 	else if (!strcmp(optarg, "macsec"))
5363af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
5373af72783SGaetan Rivet 	else if (!strcmp(optarg, "intr_rmv"))
5383af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
5394fb82244SMatan Azrad 	else if (!strcmp(optarg, "dev_probed"))
5404fb82244SMatan Azrad 		mask = UINT32_C(1) << RTE_ETH_EVENT_NEW;
5414fb82244SMatan Azrad 	else if (!strcmp(optarg, "dev_released"))
5424fb82244SMatan Azrad 		mask = UINT32_C(1) << RTE_ETH_EVENT_DESTROY;
543b6b63dfdSGaetan Rivet 	else if (!strcmp(optarg, "all"))
544b6b63dfdSGaetan Rivet 		mask = ~UINT32_C(0);
5453af72783SGaetan Rivet 	else {
5463af72783SGaetan Rivet 		fprintf(stderr, "Invalid event: %s\n", optarg);
5473af72783SGaetan Rivet 		return -1;
5483af72783SGaetan Rivet 	}
5493af72783SGaetan Rivet 	if (enable)
5503af72783SGaetan Rivet 		event_print_mask |= mask;
5513af72783SGaetan Rivet 	else
5523af72783SGaetan Rivet 		event_print_mask &= ~mask;
5533af72783SGaetan Rivet 	return 0;
5543af72783SGaetan Rivet }
5553af72783SGaetan Rivet 
556af75078fSIntel void
557af75078fSIntel launch_args_parse(int argc, char** argv)
558af75078fSIntel {
559af75078fSIntel 	int n, opt;
560af75078fSIntel 	char **argvopt;
561af75078fSIntel 	int opt_idx;
5623f7311baSWei Dai 	portid_t pid;
563013af9b6SIntel 	enum { TX, RX };
564fd8c20aaSShahaf Shuler 	/* Default offloads for all ports. */
5650074d02fSShahaf Shuler 	uint64_t rx_offloads = rx_mode.offloads;
566fd8c20aaSShahaf Shuler 	uint64_t tx_offloads = tx_mode.offloads;
5678599ed31SRemy Horton 	struct rte_eth_dev_info dev_info;
5688599ed31SRemy Horton 	uint16_t rec_nb_pkts;
569013af9b6SIntel 
570af75078fSIntel 	static struct option lgopts[] = {
571af75078fSIntel 		{ "help",			0, 0, 0 },
5720d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
573af75078fSIntel 		{ "interactive",		0, 0, 0 },
57481ef862bSAllain Legacy 		{ "cmdline-file",		1, 0, 0 },
575ca7feb22SCyril Chemparathy 		{ "auto-start",			0, 0, 0 },
576af75078fSIntel 		{ "eth-peers-configfile",	1, 0, 0 },
577af75078fSIntel 		{ "eth-peer",			1, 0, 0 },
5780d56cb81SThomas Monjalon #endif
57999cabef0SPablo de Lara 		{ "tx-first",			0, 0, 0 },
580cfea1f30SPablo de Lara 		{ "stats-period",		1, 0, 0 },
581af75078fSIntel 		{ "ports",			1, 0, 0 },
582af75078fSIntel 		{ "nb-cores",			1, 0, 0 },
583af75078fSIntel 		{ "nb-ports",			1, 0, 0 },
584af75078fSIntel 		{ "coremask",			1, 0, 0 },
585af75078fSIntel 		{ "portmask",			1, 0, 0 },
586af75078fSIntel 		{ "numa",			0, 0, 0 },
587999b2ee0SBruce Richardson 		{ "no-numa",			0, 0, 0 },
588148f963fSBruce Richardson 		{ "mp-anon",			0, 0, 0 },
589b6ea6408SIntel 		{ "port-numa-config",           1, 0, 0 },
590b6ea6408SIntel 		{ "ring-numa-config",           1, 0, 0 },
591b6ea6408SIntel 		{ "socket-num",			1, 0, 0 },
592af75078fSIntel 		{ "mbuf-size",			1, 0, 0 },
593c8798818SIntel 		{ "total-num-mbufs",		1, 0, 0 },
594af75078fSIntel 		{ "max-pkt-len",		1, 0, 0 },
595af75078fSIntel 		{ "pkt-filter-mode",            1, 0, 0 },
596af75078fSIntel 		{ "pkt-filter-report-hash",     1, 0, 0 },
597af75078fSIntel 		{ "pkt-filter-size",            1, 0, 0 },
598af75078fSIntel 		{ "pkt-filter-drop-queue",      1, 0, 0 },
59962d3216dSReshma Pattan #ifdef RTE_LIBRTE_LATENCY_STATS
60062d3216dSReshma Pattan 		{ "latencystats",               1, 0, 0 },
60162d3216dSReshma Pattan #endif
602e25e6c70SRemy Horton #ifdef RTE_LIBRTE_BITRATE
603e25e6c70SRemy Horton 		{ "bitrate-stats",              1, 0, 0 },
604e25e6c70SRemy Horton #endif
60579dd163fSJeff Guo 		{ "disable-crc-strip",          0, 0, 0 },
6064c3ea508SOlivier Matz 		{ "enable-lro",                 0, 0, 0 },
607013af9b6SIntel 		{ "enable-rx-cksum",            0, 0, 0 },
608912267a3SRaslan Darawsheh 		{ "enable-rx-timestamp",        0, 0, 0 },
60904997938SMaciej Czekaj 		{ "enable-scatter",             0, 0, 0 },
6108b9bd0efSMoti Haimovsky 		{ "enable-hw-vlan",             0, 0, 0 },
6118b9bd0efSMoti Haimovsky 		{ "enable-hw-vlan-filter",      0, 0, 0 },
6128b9bd0efSMoti Haimovsky 		{ "enable-hw-vlan-strip",       0, 0, 0 },
6138b9bd0efSMoti Haimovsky 		{ "enable-hw-vlan-extend",      0, 0, 0 },
614013af9b6SIntel 		{ "enable-drop-en",            0, 0, 0 },
615af75078fSIntel 		{ "disable-rss",                0, 0, 0 },
616af75078fSIntel 		{ "port-topology",              1, 0, 0 },
617ce9b9fb0SCyril Chemparathy 		{ "forward-mode",               1, 0, 0 },
618af75078fSIntel 		{ "rss-ip",			0, 0, 0 },
619af75078fSIntel 		{ "rss-udp",			0, 0, 0 },
620af75078fSIntel 		{ "rxq",			1, 0, 0 },
621af75078fSIntel 		{ "txq",			1, 0, 0 },
622af75078fSIntel 		{ "rxd",			1, 0, 0 },
623af75078fSIntel 		{ "txd",			1, 0, 0 },
624af75078fSIntel 		{ "burst",			1, 0, 0 },
625af75078fSIntel 		{ "mbcache",			1, 0, 0 },
626af75078fSIntel 		{ "txpt",			1, 0, 0 },
627af75078fSIntel 		{ "txht",			1, 0, 0 },
628af75078fSIntel 		{ "txwt",			1, 0, 0 },
629af75078fSIntel 		{ "txfreet",			1, 0, 0 },
630af75078fSIntel 		{ "txrst",			1, 0, 0 },
631af75078fSIntel 		{ "rxpt",			1, 0, 0 },
632af75078fSIntel 		{ "rxht",			1, 0, 0 },
633af75078fSIntel 		{ "rxwt",			1, 0, 0 },
634af75078fSIntel 		{ "rxfreet",                    1, 0, 0 },
635ed30d9b6SIntel 		{ "tx-queue-stats-mapping",	1, 0, 0 },
636ed30d9b6SIntel 		{ "rx-queue-stats-mapping",	1, 0, 0 },
6377741e4cfSIntel 		{ "no-flush-rx",	0, 0, 0 },
6387ee3e944SVasily Philipov 		{ "flow-isolate-all",	        0, 0, 0 },
639a7e7bb4eSCyril Chemparathy 		{ "txpkts",			1, 0, 0 },
64082010ef5SYongseok Koh 		{ "txonly-multi-flow",		0, 0, 0 },
641bc202406SDavid Marchand 		{ "disable-link-check",		0, 0, 0 },
6428ea656f8SGaetan Rivet 		{ "no-lsc-interrupt",		0, 0, 0 },
643284c908cSGaetan Rivet 		{ "no-rmv-interrupt",		0, 0, 0 },
6443af72783SGaetan Rivet 		{ "print-event",		1, 0, 0 },
6453af72783SGaetan Rivet 		{ "mask-event",			1, 0, 0 },
646fd8c20aaSShahaf Shuler 		{ "tx-offloads",		1, 0, 0 },
647fb73e096SJeff Guo 		{ "hot-plug",			0, 0, 0 },
64839e5e20fSXueming Li 		{ "vxlan-gpe-port",		1, 0, 0 },
649e505d84cSAnatoly Burakov 		{ "mlockall",			0, 0, 0 },
650e505d84cSAnatoly Burakov 		{ "no-mlockall",		0, 0, 0 },
651c7f5dba7SAnatoly Burakov 		{ "mp-alloc",			1, 0, 0 },
652bf5b2126SStephen Hemminger 		{ "tx-ip",			1, 0, 0 },
653bf5b2126SStephen Hemminger 		{ "tx-udp",			1, 0, 0 },
6543c156061SJens Freimann 		{ "noisy-tx-sw-buffer-size",	1, 0, 0 },
6553c156061SJens Freimann 		{ "noisy-tx-sw-buffer-flushtime", 1, 0, 0 },
6563c156061SJens Freimann 		{ "noisy-lkup-memory",		1, 0, 0 },
6573c156061SJens Freimann 		{ "noisy-lkup-num-writes",	1, 0, 0 },
6583c156061SJens Freimann 		{ "noisy-lkup-num-reads",	1, 0, 0 },
6593c156061SJens Freimann 		{ "noisy-lkup-num-reads-writes", 1, 0, 0 },
66059fcf854SShahaf Shuler 		{ "no-iova-contig",             0, 0, 0 },
661af75078fSIntel 		{ 0, 0, 0, 0 },
662af75078fSIntel 	};
663af75078fSIntel 
664af75078fSIntel 	argvopt = argv;
665af75078fSIntel 
6660d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
667ca7feb22SCyril Chemparathy #define SHORTOPTS "i"
6680d56cb81SThomas Monjalon #else
669ca7feb22SCyril Chemparathy #define SHORTOPTS ""
6700d56cb81SThomas Monjalon #endif
671ca7feb22SCyril Chemparathy 	while ((opt = getopt_long(argc, argvopt, SHORTOPTS "ah",
672af75078fSIntel 				 lgopts, &opt_idx)) != EOF) {
673af75078fSIntel 		switch (opt) {
6740d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
675af75078fSIntel 		case 'i':
676af75078fSIntel 			printf("Interactive-mode selected\n");
677af75078fSIntel 			interactive = 1;
678af75078fSIntel 			break;
6790d56cb81SThomas Monjalon #endif
680ca7feb22SCyril Chemparathy 		case 'a':
681ca7feb22SCyril Chemparathy 			printf("Auto-start selected\n");
682ca7feb22SCyril Chemparathy 			auto_start = 1;
683ca7feb22SCyril Chemparathy 			break;
684ca7feb22SCyril Chemparathy 
685af75078fSIntel 		case 0: /*long options */
686af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "help")) {
687af75078fSIntel 				usage(argv[0]);
688af75078fSIntel 				rte_exit(EXIT_SUCCESS, "Displayed help\n");
689af75078fSIntel 			}
6900d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
691af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "interactive")) {
692af75078fSIntel 				printf("Interactive-mode selected\n");
693af75078fSIntel 				interactive = 1;
694af75078fSIntel 			}
69581ef862bSAllain Legacy 			if (!strcmp(lgopts[opt_idx].name, "cmdline-file")) {
69681ef862bSAllain Legacy 				printf("CLI commands to be read from %s\n",
69781ef862bSAllain Legacy 				       optarg);
698c022cb40SBruce Richardson 				strlcpy(cmdline_filename, optarg,
699c022cb40SBruce Richardson 					sizeof(cmdline_filename));
70081ef862bSAllain Legacy 			}
701ca7feb22SCyril Chemparathy 			if (!strcmp(lgopts[opt_idx].name, "auto-start")) {
702ca7feb22SCyril Chemparathy 				printf("Auto-start selected\n");
703ca7feb22SCyril Chemparathy 				auto_start = 1;
704ca7feb22SCyril Chemparathy 			}
70599cabef0SPablo de Lara 			if (!strcmp(lgopts[opt_idx].name, "tx-first")) {
70699cabef0SPablo de Lara 				printf("Ports to start sending a burst of "
70799cabef0SPablo de Lara 						"packets first\n");
70899cabef0SPablo de Lara 				tx_first = 1;
70999cabef0SPablo de Lara 			}
710cfea1f30SPablo de Lara 			if (!strcmp(lgopts[opt_idx].name, "stats-period")) {
711cfea1f30SPablo de Lara 				char *end = NULL;
712cfea1f30SPablo de Lara 				unsigned int n;
713cfea1f30SPablo de Lara 
714cfea1f30SPablo de Lara 				n = strtoul(optarg, &end, 10);
715cfea1f30SPablo de Lara 				if ((optarg[0] == '\0') || (end == NULL) ||
716cfea1f30SPablo de Lara 						(*end != '\0'))
717cfea1f30SPablo de Lara 					break;
718cfea1f30SPablo de Lara 
719cfea1f30SPablo de Lara 				stats_period = n;
720cfea1f30SPablo de Lara 				break;
721cfea1f30SPablo de Lara 			}
722af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name,
723af75078fSIntel 				    "eth-peers-configfile")) {
724af75078fSIntel 				if (init_peer_eth_addrs(optarg) != 0)
725af75078fSIntel 					rte_exit(EXIT_FAILURE,
726af75078fSIntel 						 "Cannot open logfile\n");
727af75078fSIntel 			}
728af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
729af75078fSIntel 				char *port_end;
730af75078fSIntel 				uint8_t c, peer_addr[6];
731af75078fSIntel 
732af75078fSIntel 				errno = 0;
733af75078fSIntel 				n = strtoul(optarg, &port_end, 10);
734af75078fSIntel 				if (errno != 0 || port_end == optarg || *port_end++ != ',')
735af75078fSIntel 					rte_exit(EXIT_FAILURE,
736af75078fSIntel 						 "Invalid eth-peer: %s", optarg);
737af75078fSIntel 				if (n >= RTE_MAX_ETHPORTS)
738af75078fSIntel 					rte_exit(EXIT_FAILURE,
739af75078fSIntel 						 "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n",
740af75078fSIntel 						 n, RTE_MAX_ETHPORTS);
741af75078fSIntel 
742aaa662e7SAlan Carew 				if (cmdline_parse_etheraddr(NULL, port_end,
743aaa662e7SAlan Carew 						&peer_addr, sizeof(peer_addr)) < 0)
744af75078fSIntel 					rte_exit(EXIT_FAILURE,
745af75078fSIntel 						 "Invalid ethernet address: %s\n",
746af75078fSIntel 						 port_end);
747af75078fSIntel 				for (c = 0; c < 6; c++)
748af75078fSIntel 					peer_eth_addrs[n].addr_bytes[c] =
749af75078fSIntel 						peer_addr[c];
750af75078fSIntel 				nb_peer_eth_addrs++;
751af75078fSIntel 			}
7520d56cb81SThomas Monjalon #endif
753bf5b2126SStephen Hemminger 			if (!strcmp(lgopts[opt_idx].name, "tx-ip")) {
754bf5b2126SStephen Hemminger 				struct in_addr in;
755bf5b2126SStephen Hemminger 				char *end;
756bf5b2126SStephen Hemminger 
757bf5b2126SStephen Hemminger 				end = strchr(optarg, ',');
758bf5b2126SStephen Hemminger 				if (end == optarg || !end)
759bf5b2126SStephen Hemminger 					rte_exit(EXIT_FAILURE,
760bf5b2126SStephen Hemminger 						 "Invalid tx-ip: %s", optarg);
761bf5b2126SStephen Hemminger 
762bf5b2126SStephen Hemminger 				*end++ = 0;
763bf5b2126SStephen Hemminger 				if (inet_aton(optarg, &in) == 0)
764bf5b2126SStephen Hemminger 					rte_exit(EXIT_FAILURE,
765bf5b2126SStephen Hemminger 						 "Invalid source IP address: %s\n",
766bf5b2126SStephen Hemminger 						 optarg);
767bf5b2126SStephen Hemminger 				tx_ip_src_addr = rte_be_to_cpu_32(in.s_addr);
768bf5b2126SStephen Hemminger 
769bf5b2126SStephen Hemminger 				if (inet_aton(end, &in) == 0)
770bf5b2126SStephen Hemminger 					rte_exit(EXIT_FAILURE,
771bf5b2126SStephen Hemminger 						 "Invalid destination IP address: %s\n",
772bf5b2126SStephen Hemminger 						 optarg);
773bf5b2126SStephen Hemminger 				tx_ip_dst_addr = rte_be_to_cpu_32(in.s_addr);
774bf5b2126SStephen Hemminger 			}
775bf5b2126SStephen Hemminger 			if (!strcmp(lgopts[opt_idx].name, "tx-udp")) {
776bf5b2126SStephen Hemminger 				char *end = NULL;
777bf5b2126SStephen Hemminger 
778bf5b2126SStephen Hemminger 				errno = 0;
779bf5b2126SStephen Hemminger 				n = strtoul(optarg, &end, 10);
780bf5b2126SStephen Hemminger 				if (errno != 0 || end == optarg ||
781bf5b2126SStephen Hemminger 				    n > UINT16_MAX ||
782bf5b2126SStephen Hemminger 				    !(*end == '\0' || *end == ','))
783bf5b2126SStephen Hemminger 					rte_exit(EXIT_FAILURE,
784bf5b2126SStephen Hemminger 						 "Invalid UDP port: %s\n",
785bf5b2126SStephen Hemminger 						 optarg);
786bf5b2126SStephen Hemminger 				tx_udp_src_port = n;
787bf5b2126SStephen Hemminger 				if (*end == ',') {
788bf5b2126SStephen Hemminger 					char *dst = end + 1;
789bf5b2126SStephen Hemminger 
790bf5b2126SStephen Hemminger 					n = strtoul(dst, &end, 10);
791bf5b2126SStephen Hemminger 					if (errno != 0 || end == dst ||
792bf5b2126SStephen Hemminger 					    n > UINT16_MAX || *end)
793bf5b2126SStephen Hemminger 						rte_exit(EXIT_FAILURE,
794bf5b2126SStephen Hemminger 							 "Invalid destination UDP port: %s\n",
795bf5b2126SStephen Hemminger 							 dst);
796bf5b2126SStephen Hemminger 					tx_udp_dst_port = n;
797bf5b2126SStephen Hemminger 				} else {
798bf5b2126SStephen Hemminger 					tx_udp_dst_port = n;
799bf5b2126SStephen Hemminger 				}
800bf5b2126SStephen Hemminger 
801bf5b2126SStephen Hemminger 			}
802af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
803af75078fSIntel 				n = atoi(optarg);
8040a530f0dSYong Liu 				if (n > 0 && n <= nb_ports)
805f8244c63SZhiyong Yang 					nb_fwd_ports = n;
806af75078fSIntel 				else
807af75078fSIntel 					rte_exit(EXIT_FAILURE,
808edab33b1STetsuya Mukawa 						 "Invalid port %d\n", n);
809af75078fSIntel 			}
810af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "nb-cores")) {
811af75078fSIntel 				n = atoi(optarg);
812af75078fSIntel 				if (n > 0 && n <= nb_lcores)
813af75078fSIntel 					nb_fwd_lcores = (uint8_t) n;
814af75078fSIntel 				else
815af75078fSIntel 					rte_exit(EXIT_FAILURE,
816af75078fSIntel 						 "nb-cores should be > 0 and <= %d\n",
817af75078fSIntel 						 nb_lcores);
818af75078fSIntel 			}
819af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "coremask"))
820af75078fSIntel 				parse_fwd_coremask(optarg);
821af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "portmask"))
822af75078fSIntel 				parse_fwd_portmask(optarg);
823999b2ee0SBruce Richardson 			if (!strcmp(lgopts[opt_idx].name, "no-numa"))
824999b2ee0SBruce Richardson 				numa_support = 0;
825487f9a59SYulong Pei 			if (!strcmp(lgopts[opt_idx].name, "numa"))
826af75078fSIntel 				numa_support = 1;
827148f963fSBruce Richardson 			if (!strcmp(lgopts[opt_idx].name, "mp-anon")) {
828c7f5dba7SAnatoly Burakov 				mp_alloc_type = MP_ALLOC_ANON;
829c7f5dba7SAnatoly Burakov 			}
830c7f5dba7SAnatoly Burakov 			if (!strcmp(lgopts[opt_idx].name, "mp-alloc")) {
831c7f5dba7SAnatoly Burakov 				if (!strcmp(optarg, "native"))
832c7f5dba7SAnatoly Burakov 					mp_alloc_type = MP_ALLOC_NATIVE;
833c7f5dba7SAnatoly Burakov 				else if (!strcmp(optarg, "anon"))
834c7f5dba7SAnatoly Burakov 					mp_alloc_type = MP_ALLOC_ANON;
835c7f5dba7SAnatoly Burakov 				else if (!strcmp(optarg, "xmem"))
836c7f5dba7SAnatoly Burakov 					mp_alloc_type = MP_ALLOC_XMEM;
837c7f5dba7SAnatoly Burakov 				else if (!strcmp(optarg, "xmemhuge"))
838c7f5dba7SAnatoly Burakov 					mp_alloc_type = MP_ALLOC_XMEM_HUGE;
839c7f5dba7SAnatoly Burakov 				else
840c7f5dba7SAnatoly Burakov 					rte_exit(EXIT_FAILURE,
841c7f5dba7SAnatoly Burakov 						"mp-alloc %s invalid - must be: "
842c7f5dba7SAnatoly Burakov 						"native, anon, xmem or xmemhuge\n",
843c7f5dba7SAnatoly Burakov 						 optarg);
844148f963fSBruce Richardson 			}
845b6ea6408SIntel 			if (!strcmp(lgopts[opt_idx].name, "port-numa-config")) {
846b6ea6408SIntel 				if (parse_portnuma_config(optarg))
847b6ea6408SIntel 					rte_exit(EXIT_FAILURE,
848b6ea6408SIntel 					   "invalid port-numa configuration\n");
849b6ea6408SIntel 			}
850b6ea6408SIntel 			if (!strcmp(lgopts[opt_idx].name, "ring-numa-config"))
851b6ea6408SIntel 				if (parse_ringnuma_config(optarg))
852b6ea6408SIntel 					rte_exit(EXIT_FAILURE,
853b6ea6408SIntel 					   "invalid ring-numa configuration\n");
854b6ea6408SIntel 			if (!strcmp(lgopts[opt_idx].name, "socket-num")) {
855b6ea6408SIntel 				n = atoi(optarg);
856c9cafcc8SShahaf Shuler 				if (!new_socket_id((uint8_t)n)) {
857b6ea6408SIntel 					socket_num = (uint8_t)n;
858c9cafcc8SShahaf Shuler 				} else {
859c9cafcc8SShahaf Shuler 					print_invalid_socket_id_error();
860b6ea6408SIntel 					rte_exit(EXIT_FAILURE,
861c9cafcc8SShahaf Shuler 						"Invalid socket id");
862c9cafcc8SShahaf Shuler 				}
863b6ea6408SIntel 			}
864af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
865af75078fSIntel 				n = atoi(optarg);
866af75078fSIntel 				if (n > 0 && n <= 0xFFFF)
867af75078fSIntel 					mbuf_data_size = (uint16_t) n;
868af75078fSIntel 				else
869af75078fSIntel 					rte_exit(EXIT_FAILURE,
870af75078fSIntel 						 "mbuf-size should be > 0 and < 65536\n");
871af75078fSIntel 			}
872c8798818SIntel 			if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
873c8798818SIntel 				n = atoi(optarg);
874c8798818SIntel 				if (n > 1024)
875c8798818SIntel 					param_total_num_mbufs = (unsigned)n;
876c8798818SIntel 				else
877c8798818SIntel 					rte_exit(EXIT_FAILURE,
878c8798818SIntel 						 "total-num-mbufs should be > 1024\n");
879c8798818SIntel 			}
880af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
881af75078fSIntel 				n = atoi(optarg);
882*35b2d13fSOlivier Matz 				if (n >= RTE_ETHER_MIN_LEN) {
883af75078fSIntel 					rx_mode.max_rx_pkt_len = (uint32_t) n;
884*35b2d13fSOlivier Matz 					if (n > RTE_ETHER_MAX_LEN)
8850074d02fSShahaf Shuler 						rx_offloads |=
8860074d02fSShahaf Shuler 							DEV_RX_OFFLOAD_JUMBO_FRAME;
887af75078fSIntel 				} else
888af75078fSIntel 					rte_exit(EXIT_FAILURE,
889af75078fSIntel 						 "Invalid max-pkt-len=%d - should be > %d\n",
890*35b2d13fSOlivier Matz 						 n, RTE_ETHER_MIN_LEN);
891af75078fSIntel 			}
892af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) {
893af75078fSIntel 				if (!strcmp(optarg, "signature"))
894af75078fSIntel 					fdir_conf.mode =
895af75078fSIntel 						RTE_FDIR_MODE_SIGNATURE;
896af75078fSIntel 				else if (!strcmp(optarg, "perfect"))
897af75078fSIntel 					fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
8989276b982SWenzhuo Lu 				else if (!strcmp(optarg, "perfect-mac-vlan"))
8999276b982SWenzhuo Lu 					fdir_conf.mode = RTE_FDIR_MODE_PERFECT_MAC_VLAN;
9009276b982SWenzhuo Lu 				else if (!strcmp(optarg, "perfect-tunnel"))
9019276b982SWenzhuo Lu 					fdir_conf.mode = RTE_FDIR_MODE_PERFECT_TUNNEL;
902af75078fSIntel 				else if (!strcmp(optarg, "none"))
903af75078fSIntel 					fdir_conf.mode = RTE_FDIR_MODE_NONE;
904af75078fSIntel 				else
905af75078fSIntel 					rte_exit(EXIT_FAILURE,
906af75078fSIntel 						 "pkt-mode-invalid %s invalid - must be: "
9079276b982SWenzhuo Lu 						 "none, signature, perfect, perfect-mac-vlan"
9089276b982SWenzhuo Lu 						 " or perfect-tunnel\n",
909af75078fSIntel 						 optarg);
910af75078fSIntel 			}
911af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name,
912af75078fSIntel 				    "pkt-filter-report-hash")) {
913af75078fSIntel 				if (!strcmp(optarg, "none"))
914af75078fSIntel 					fdir_conf.status =
915af75078fSIntel 						RTE_FDIR_NO_REPORT_STATUS;
916af75078fSIntel 				else if (!strcmp(optarg, "match"))
917af75078fSIntel 					fdir_conf.status =
918af75078fSIntel 						RTE_FDIR_REPORT_STATUS;
919af75078fSIntel 				else if (!strcmp(optarg, "always"))
920af75078fSIntel 					fdir_conf.status =
921af75078fSIntel 						RTE_FDIR_REPORT_STATUS_ALWAYS;
922af75078fSIntel 				else
923af75078fSIntel 					rte_exit(EXIT_FAILURE,
924af75078fSIntel 						 "pkt-filter-report-hash %s invalid "
925af75078fSIntel 						 "- must be: none or match or always\n",
926af75078fSIntel 						 optarg);
927af75078fSIntel 			}
928af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) {
929af75078fSIntel 				if (!strcmp(optarg, "64K"))
930af75078fSIntel 					fdir_conf.pballoc =
931af75078fSIntel 						RTE_FDIR_PBALLOC_64K;
932af75078fSIntel 				else if (!strcmp(optarg, "128K"))
933af75078fSIntel 					fdir_conf.pballoc =
934af75078fSIntel 						RTE_FDIR_PBALLOC_128K;
935af75078fSIntel 				else if (!strcmp(optarg, "256K"))
936af75078fSIntel 					fdir_conf.pballoc =
937af75078fSIntel 						RTE_FDIR_PBALLOC_256K;
938af75078fSIntel 				else
939af75078fSIntel 					rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -"
940af75078fSIntel 						 " must be: 64K or 128K or 256K\n",
941af75078fSIntel 						 optarg);
942af75078fSIntel 			}
943af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name,
944af75078fSIntel 				    "pkt-filter-drop-queue")) {
945af75078fSIntel 				n = atoi(optarg);
946af75078fSIntel 				if (n >= 0)
947af75078fSIntel 					fdir_conf.drop_queue = (uint8_t) n;
948af75078fSIntel 				else
949af75078fSIntel 					rte_exit(EXIT_FAILURE,
950af75078fSIntel 						 "drop queue %d invalid - must"
951af75078fSIntel 						 "be >= 0 \n", n);
952af75078fSIntel 			}
95362d3216dSReshma Pattan #ifdef RTE_LIBRTE_LATENCY_STATS
95462d3216dSReshma Pattan 			if (!strcmp(lgopts[opt_idx].name,
95562d3216dSReshma Pattan 				    "latencystats")) {
95662d3216dSReshma Pattan 				n = atoi(optarg);
95762d3216dSReshma Pattan 				if (n >= 0) {
95862d3216dSReshma Pattan 					latencystats_lcore_id = (lcoreid_t) n;
95962d3216dSReshma Pattan 					latencystats_enabled = 1;
96062d3216dSReshma Pattan 				} else
96162d3216dSReshma Pattan 					rte_exit(EXIT_FAILURE,
96262d3216dSReshma Pattan 						 "invalid lcore id %d for latencystats"
96362d3216dSReshma Pattan 						 " must be >= 0\n", n);
96462d3216dSReshma Pattan 			}
96562d3216dSReshma Pattan #endif
966e25e6c70SRemy Horton #ifdef RTE_LIBRTE_BITRATE
967e25e6c70SRemy Horton 			if (!strcmp(lgopts[opt_idx].name, "bitrate-stats")) {
968e25e6c70SRemy Horton 				n = atoi(optarg);
969e25e6c70SRemy Horton 				if (n >= 0) {
970e25e6c70SRemy Horton 					bitrate_lcore_id = (lcoreid_t) n;
971e25e6c70SRemy Horton 					bitrate_enabled = 1;
972e25e6c70SRemy Horton 				} else
973e25e6c70SRemy Horton 					rte_exit(EXIT_FAILURE,
974e25e6c70SRemy Horton 						 "invalid lcore id %d for bitrate stats"
975e25e6c70SRemy Horton 						 " must be >= 0\n", n);
976e25e6c70SRemy Horton 			}
977e25e6c70SRemy Horton #endif
978323e7b66SFerruh Yigit 			if (!strcmp(lgopts[opt_idx].name, "disable-crc-strip"))
979e557ebc0SFerruh Yigit 				rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
9804c3ea508SOlivier Matz 			if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
9810074d02fSShahaf Shuler 				rx_offloads |= DEV_RX_OFFLOAD_TCP_LRO;
98204997938SMaciej Czekaj 			if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
9830074d02fSShahaf Shuler 				rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
984af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
9850074d02fSShahaf Shuler 				rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
986912267a3SRaslan Darawsheh 			if (!strcmp(lgopts[opt_idx].name,
987912267a3SRaslan Darawsheh 					"enable-rx-timestamp"))
9880074d02fSShahaf Shuler 				rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
9898b9bd0efSMoti Haimovsky 			if (!strcmp(lgopts[opt_idx].name, "enable-hw-vlan"))
9908b9bd0efSMoti Haimovsky 				rx_offloads |= DEV_RX_OFFLOAD_VLAN;
991a47aa8b9SIntel 
992c9dd4aadSOuyang Changchun 			if (!strcmp(lgopts[opt_idx].name,
9938b9bd0efSMoti Haimovsky 					"enable-hw-vlan-filter"))
9948b9bd0efSMoti Haimovsky 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
995c9dd4aadSOuyang Changchun 
996c9dd4aadSOuyang Changchun 			if (!strcmp(lgopts[opt_idx].name,
9978b9bd0efSMoti Haimovsky 					"enable-hw-vlan-strip"))
9988b9bd0efSMoti Haimovsky 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
999c9dd4aadSOuyang Changchun 
1000c9dd4aadSOuyang Changchun 			if (!strcmp(lgopts[opt_idx].name,
10018b9bd0efSMoti Haimovsky 					"enable-hw-vlan-extend"))
10028b9bd0efSMoti Haimovsky 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1003c9dd4aadSOuyang Changchun 
1004ce8d5614SIntel 			if (!strcmp(lgopts[opt_idx].name, "enable-drop-en"))
1005ce8d5614SIntel 				rx_drop_en = 1;
1006ce8d5614SIntel 
1007af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "disable-rss"))
1008af75078fSIntel 				rss_hf = 0;
1009af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "port-topology")) {
1010af75078fSIntel 				if (!strcmp(optarg, "paired"))
1011af75078fSIntel 					port_topology = PORT_TOPOLOGY_PAIRED;
1012af75078fSIntel 				else if (!strcmp(optarg, "chained"))
1013af75078fSIntel 					port_topology = PORT_TOPOLOGY_CHAINED;
10143e2006d6SCyril Chemparathy 				else if (!strcmp(optarg, "loop"))
10153e2006d6SCyril Chemparathy 					port_topology = PORT_TOPOLOGY_LOOP;
1016af75078fSIntel 				else
1017af75078fSIntel 					rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
101875358833SPablo de Lara 						 " must be: paired, chained or loop\n",
1019af75078fSIntel 						 optarg);
1020af75078fSIntel 			}
1021ce9b9fb0SCyril Chemparathy 			if (!strcmp(lgopts[opt_idx].name, "forward-mode"))
1022ce9b9fb0SCyril Chemparathy 				set_pkt_forwarding_mode(optarg);
1023af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rss-ip"))
10248a387fa8SHelin Zhang 				rss_hf = ETH_RSS_IP;
1025af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rss-udp"))
10268a387fa8SHelin Zhang 				rss_hf = ETH_RSS_UDP;
1027af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxq")) {
1028af75078fSIntel 				n = atoi(optarg);
10293f7311baSWei Dai 				if (n >= 0 && check_nb_rxq((queueid_t)n) == 0)
1030af75078fSIntel 					nb_rxq = (queueid_t) n;
1031af75078fSIntel 				else
1032af75078fSIntel 					rte_exit(EXIT_FAILURE, "rxq %d invalid - must be"
10333f7311baSWei Dai 						  " >= 0 && <= %u\n", n,
10343f7311baSWei Dai 						  get_allowed_max_nb_rxq(&pid));
1035af75078fSIntel 			}
1036af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txq")) {
1037af75078fSIntel 				n = atoi(optarg);
103836db4f6cSWei Dai 				if (n >= 0 && check_nb_txq((queueid_t)n) == 0)
1039af75078fSIntel 					nb_txq = (queueid_t) n;
1040af75078fSIntel 				else
1041af75078fSIntel 					rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
104236db4f6cSWei Dai 						  " >= 0 && <= %u\n", n,
104336db4f6cSWei Dai 						  get_allowed_max_nb_txq(&pid));
1044af75078fSIntel 			}
10455a8fb55cSReshma Pattan 			if (!nb_rxq && !nb_txq) {
10465a8fb55cSReshma Pattan 				rte_exit(EXIT_FAILURE, "Either rx or tx queues should "
10475a8fb55cSReshma Pattan 						"be non-zero\n");
10485a8fb55cSReshma Pattan 			}
1049af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "burst")) {
1050af75078fSIntel 				n = atoi(optarg);
10518599ed31SRemy Horton 				if (n == 0) {
10528599ed31SRemy Horton 					/* A burst size of zero means that the
10538599ed31SRemy Horton 					 * PMD should be queried for
10548599ed31SRemy Horton 					 * recommended Rx burst size. Since
10558599ed31SRemy Horton 					 * testpmd uses a single size for all
10568599ed31SRemy Horton 					 * ports, port 0 is queried for the
10578599ed31SRemy Horton 					 * value, on the assumption that all
10588599ed31SRemy Horton 					 * ports are of the same NIC model.
10598599ed31SRemy Horton 					 */
10608599ed31SRemy Horton 					rte_eth_dev_info_get(0, &dev_info);
10618599ed31SRemy Horton 					rec_nb_pkts = dev_info
10628599ed31SRemy Horton 						.default_rxportconf.burst_size;
10638599ed31SRemy Horton 
10648599ed31SRemy Horton 					if (rec_nb_pkts == 0)
1065af75078fSIntel 						rte_exit(EXIT_FAILURE,
10668599ed31SRemy Horton 							"PMD does not recommend a burst size. "
10678599ed31SRemy Horton 							"Provided value must be between "
10688599ed31SRemy Horton 							"1 and %d\n", MAX_PKT_BURST);
10698599ed31SRemy Horton 					else if (rec_nb_pkts > MAX_PKT_BURST)
10708599ed31SRemy Horton 						rte_exit(EXIT_FAILURE,
10718599ed31SRemy Horton 							"PMD recommended burst size of %d"
10728599ed31SRemy Horton 							" exceeds maximum value of %d\n",
10738599ed31SRemy Horton 							rec_nb_pkts, MAX_PKT_BURST);
10748599ed31SRemy Horton 					printf("Using PMD-provided burst value of %d\n",
10758599ed31SRemy Horton 						rec_nb_pkts);
10768599ed31SRemy Horton 					nb_pkt_per_burst = rec_nb_pkts;
10778599ed31SRemy Horton 				} else if (n > MAX_PKT_BURST)
10788599ed31SRemy Horton 					rte_exit(EXIT_FAILURE,
10798599ed31SRemy Horton 						"burst must be between1 and %d\n",
1080af75078fSIntel 						MAX_PKT_BURST);
10818599ed31SRemy Horton 				else
10828599ed31SRemy Horton 					nb_pkt_per_burst = (uint16_t) n;
1083af75078fSIntel 			}
1084af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "mbcache")) {
1085af75078fSIntel 				n = atoi(optarg);
1086af75078fSIntel 				if ((n >= 0) &&
1087af75078fSIntel 				    (n <= RTE_MEMPOOL_CACHE_MAX_SIZE))
1088af75078fSIntel 					mb_mempool_cache = (uint16_t) n;
1089af75078fSIntel 				else
1090af75078fSIntel 					rte_exit(EXIT_FAILURE,
1091af75078fSIntel 						 "mbcache must be >= 0 and <= %d\n",
1092af75078fSIntel 						 RTE_MEMPOOL_CACHE_MAX_SIZE);
1093af75078fSIntel 			}
1094af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txfreet")) {
1095af75078fSIntel 				n = atoi(optarg);
1096af75078fSIntel 				if (n >= 0)
1097f2c5125aSPablo de Lara 					tx_free_thresh = (int16_t)n;
1098af75078fSIntel 				else
1099af75078fSIntel 					rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n");
1100af75078fSIntel 			}
1101af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txrst")) {
1102af75078fSIntel 				n = atoi(optarg);
1103af75078fSIntel 				if (n >= 0)
1104f2c5125aSPablo de Lara 					tx_rs_thresh = (int16_t)n;
1105af75078fSIntel 				else
1106af75078fSIntel 					rte_exit(EXIT_FAILURE, "txrst must be >= 0\n");
1107af75078fSIntel 			}
1108af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxd")) {
1109af75078fSIntel 				n = atoi(optarg);
1110af75078fSIntel 				if (n > 0) {
1111af75078fSIntel 					if (rx_free_thresh >= n)
1112af75078fSIntel 						rte_exit(EXIT_FAILURE,
1113af75078fSIntel 							 "rxd must be > "
1114af75078fSIntel 							 "rx_free_thresh(%d)\n",
1115af75078fSIntel 							 (int)rx_free_thresh);
1116af75078fSIntel 					else
1117af75078fSIntel 						nb_rxd = (uint16_t) n;
1118af75078fSIntel 				} else
1119af75078fSIntel 					rte_exit(EXIT_FAILURE,
1120af75078fSIntel 						 "rxd(%d) invalid - must be > 0\n",
1121af75078fSIntel 						 n);
1122af75078fSIntel 			}
1123af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txd")) {
1124af75078fSIntel 				n = atoi(optarg);
1125af75078fSIntel 				if (n > 0)
1126af75078fSIntel 					nb_txd = (uint16_t) n;
1127af75078fSIntel 				else
1128af75078fSIntel 					rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
1129af75078fSIntel 			}
1130af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txpt")) {
1131af75078fSIntel 				n = atoi(optarg);
1132af75078fSIntel 				if (n >= 0)
1133f2c5125aSPablo de Lara 					tx_pthresh = (int8_t)n;
1134af75078fSIntel 				else
1135af75078fSIntel 					rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
1136af75078fSIntel 			}
1137af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txht")) {
1138af75078fSIntel 				n = atoi(optarg);
1139af75078fSIntel 				if (n >= 0)
1140f2c5125aSPablo de Lara 					tx_hthresh = (int8_t)n;
1141af75078fSIntel 				else
1142af75078fSIntel 					rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
1143af75078fSIntel 			}
1144af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txwt")) {
1145af75078fSIntel 				n = atoi(optarg);
1146af75078fSIntel 				if (n >= 0)
1147f2c5125aSPablo de Lara 					tx_wthresh = (int8_t)n;
1148af75078fSIntel 				else
1149af75078fSIntel 					rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
1150af75078fSIntel 			}
1151af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
1152af75078fSIntel 				n = atoi(optarg);
1153af75078fSIntel 				if (n >= 0)
1154f2c5125aSPablo de Lara 					rx_pthresh = (int8_t)n;
1155af75078fSIntel 				else
1156af75078fSIntel 					rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
1157af75078fSIntel 			}
1158af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxht")) {
1159af75078fSIntel 				n = atoi(optarg);
1160af75078fSIntel 				if (n >= 0)
1161f2c5125aSPablo de Lara 					rx_hthresh = (int8_t)n;
1162af75078fSIntel 				else
1163af75078fSIntel 					rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
1164af75078fSIntel 			}
1165af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
1166af75078fSIntel 				n = atoi(optarg);
1167af75078fSIntel 				if (n >= 0)
1168f2c5125aSPablo de Lara 					rx_wthresh = (int8_t)n;
1169af75078fSIntel 				else
1170af75078fSIntel 					rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
1171af75078fSIntel 			}
1172af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxfreet")) {
1173af75078fSIntel 				n = atoi(optarg);
1174af75078fSIntel 				if (n >= 0)
1175f2c5125aSPablo de Lara 					rx_free_thresh = (int16_t)n;
1176af75078fSIntel 				else
1177af75078fSIntel 					rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n");
1178af75078fSIntel 			}
1179ed30d9b6SIntel 			if (!strcmp(lgopts[opt_idx].name, "tx-queue-stats-mapping")) {
1180ed30d9b6SIntel 				if (parse_queue_stats_mapping_config(optarg, TX)) {
1181ed30d9b6SIntel 					rte_exit(EXIT_FAILURE,
1182ed30d9b6SIntel 						 "invalid TX queue statistics mapping config entered\n");
1183ed30d9b6SIntel 				}
1184ed30d9b6SIntel 			}
1185ed30d9b6SIntel 			if (!strcmp(lgopts[opt_idx].name, "rx-queue-stats-mapping")) {
1186ed30d9b6SIntel 				if (parse_queue_stats_mapping_config(optarg, RX)) {
1187ed30d9b6SIntel 					rte_exit(EXIT_FAILURE,
1188ed30d9b6SIntel 						 "invalid RX queue statistics mapping config entered\n");
1189ed30d9b6SIntel 				}
1190ed30d9b6SIntel 			}
1191a7e7bb4eSCyril Chemparathy 			if (!strcmp(lgopts[opt_idx].name, "txpkts")) {
1192a7e7bb4eSCyril Chemparathy 				unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1193a7e7bb4eSCyril Chemparathy 				unsigned int nb_segs;
1194a7e7bb4eSCyril Chemparathy 
1195950d1516SBruce Richardson 				nb_segs = parse_item_list(optarg, "txpkt segments",
1196950d1516SBruce Richardson 						RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1197a7e7bb4eSCyril Chemparathy 				if (nb_segs > 0)
1198a7e7bb4eSCyril Chemparathy 					set_tx_pkt_segments(seg_lengths, nb_segs);
1199a7e7bb4eSCyril Chemparathy 				else
1200a7e7bb4eSCyril Chemparathy 					rte_exit(EXIT_FAILURE, "bad txpkts\n");
1201a7e7bb4eSCyril Chemparathy 			}
120282010ef5SYongseok Koh 			if (!strcmp(lgopts[opt_idx].name, "txonly-multi-flow"))
120382010ef5SYongseok Koh 				txonly_multi_flow = 1;
12047741e4cfSIntel 			if (!strcmp(lgopts[opt_idx].name, "no-flush-rx"))
12057741e4cfSIntel 				no_flush_rx = 1;
1206bc202406SDavid Marchand 			if (!strcmp(lgopts[opt_idx].name, "disable-link-check"))
1207bc202406SDavid Marchand 				no_link_check = 1;
12088ea656f8SGaetan Rivet 			if (!strcmp(lgopts[opt_idx].name, "no-lsc-interrupt"))
12098ea656f8SGaetan Rivet 				lsc_interrupt = 0;
1210284c908cSGaetan Rivet 			if (!strcmp(lgopts[opt_idx].name, "no-rmv-interrupt"))
1211284c908cSGaetan Rivet 				rmv_interrupt = 0;
12127ee3e944SVasily Philipov 			if (!strcmp(lgopts[opt_idx].name, "flow-isolate-all"))
12137ee3e944SVasily Philipov 				flow_isolate_all = 1;
1214fd8c20aaSShahaf Shuler 			if (!strcmp(lgopts[opt_idx].name, "tx-offloads")) {
1215fd8c20aaSShahaf Shuler 				char *end = NULL;
1216fd8c20aaSShahaf Shuler 				n = strtoull(optarg, &end, 16);
1217fd8c20aaSShahaf Shuler 				if (n >= 0)
1218fd8c20aaSShahaf Shuler 					tx_offloads = (uint64_t)n;
1219fd8c20aaSShahaf Shuler 				else
1220fd8c20aaSShahaf Shuler 					rte_exit(EXIT_FAILURE,
1221fd8c20aaSShahaf Shuler 						 "tx-offloads must be >= 0\n");
1222fd8c20aaSShahaf Shuler 			}
122339e5e20fSXueming Li 			if (!strcmp(lgopts[opt_idx].name, "vxlan-gpe-port")) {
122439e5e20fSXueming Li 				n = atoi(optarg);
122539e5e20fSXueming Li 				if (n >= 0)
122639e5e20fSXueming Li 					vxlan_gpe_udp_port = (uint16_t)n;
122739e5e20fSXueming Li 				else
122839e5e20fSXueming Li 					rte_exit(EXIT_FAILURE,
122939e5e20fSXueming Li 						 "vxlan-gpe-port must be >= 0\n");
123039e5e20fSXueming Li 			}
12313af72783SGaetan Rivet 			if (!strcmp(lgopts[opt_idx].name, "print-event"))
12323af72783SGaetan Rivet 				if (parse_event_printing_config(optarg, 1)) {
12333af72783SGaetan Rivet 					rte_exit(EXIT_FAILURE,
12343af72783SGaetan Rivet 						 "invalid print-event argument\n");
12353af72783SGaetan Rivet 				}
12363af72783SGaetan Rivet 			if (!strcmp(lgopts[opt_idx].name, "mask-event"))
12373af72783SGaetan Rivet 				if (parse_event_printing_config(optarg, 0)) {
12383af72783SGaetan Rivet 					rte_exit(EXIT_FAILURE,
12393af72783SGaetan Rivet 						 "invalid mask-event argument\n");
12403af72783SGaetan Rivet 				}
1241fb73e096SJeff Guo 			if (!strcmp(lgopts[opt_idx].name, "hot-plug"))
1242fb73e096SJeff Guo 				hot_plug = 1;
1243e505d84cSAnatoly Burakov 			if (!strcmp(lgopts[opt_idx].name, "mlockall"))
1244e505d84cSAnatoly Burakov 				do_mlockall = 1;
1245e505d84cSAnatoly Burakov 			if (!strcmp(lgopts[opt_idx].name, "no-mlockall"))
1246e505d84cSAnatoly Burakov 				do_mlockall = 0;
12473c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
12483c156061SJens Freimann 				    "noisy-tx-sw-buffer-size")) {
12493c156061SJens Freimann 				n = atoi(optarg);
12503c156061SJens Freimann 				if (n >= 0)
12513c156061SJens Freimann 					noisy_tx_sw_bufsz = n;
12523c156061SJens Freimann 				else
12533c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
12543c156061SJens Freimann 						"noisy-tx-sw-buffer-size must be >= 0\n");
12553c156061SJens Freimann 			}
12563c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
12573c156061SJens Freimann 				    "noisy-tx-sw-buffer-flushtime")) {
12583c156061SJens Freimann 				n = atoi(optarg);
12593c156061SJens Freimann 				if (n >= 0)
12603c156061SJens Freimann 					noisy_tx_sw_buf_flush_time = n;
12613c156061SJens Freimann 				else
12623c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
12633c156061SJens Freimann 						 "noisy-tx-sw-buffer-flushtime must be >= 0\n");
12643c156061SJens Freimann 			}
12653c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
12663c156061SJens Freimann 				    "noisy-lkup-memory")) {
12673c156061SJens Freimann 				n = atoi(optarg);
12683c156061SJens Freimann 				if (n >= 0)
12693c156061SJens Freimann 					noisy_lkup_mem_sz = n;
12703c156061SJens Freimann 				else
12713c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
12723c156061SJens Freimann 						 "noisy-lkup-memory must be >= 0\n");
12733c156061SJens Freimann 			}
12743c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
12753c156061SJens Freimann 				    "noisy-lkup-num-writes")) {
12763c156061SJens Freimann 				n = atoi(optarg);
12773c156061SJens Freimann 				if (n >= 0)
12783c156061SJens Freimann 					noisy_lkup_num_writes = n;
12793c156061SJens Freimann 				else
12803c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
12813c156061SJens Freimann 						 "noisy-lkup-num-writes must be >= 0\n");
12823c156061SJens Freimann 			}
12833c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
12843c156061SJens Freimann 				    "noisy-lkup-num-reads")) {
12853c156061SJens Freimann 				n = atoi(optarg);
12863c156061SJens Freimann 				if (n >= 0)
12873c156061SJens Freimann 					noisy_lkup_num_reads = n;
12883c156061SJens Freimann 				else
12893c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
12903c156061SJens Freimann 						 "noisy-lkup-num-reads must be >= 0\n");
12913c156061SJens Freimann 			}
12923c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
12933c156061SJens Freimann 				    "noisy-lkup-num-reads-writes")) {
12943c156061SJens Freimann 				n = atoi(optarg);
12953c156061SJens Freimann 				if (n >= 0)
12963c156061SJens Freimann 					noisy_lkup_num_reads_writes = n;
12973c156061SJens Freimann 				else
12983c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
12993c156061SJens Freimann 						 "noisy-lkup-num-reads-writes must be >= 0\n");
13003c156061SJens Freimann 			}
130159fcf854SShahaf Shuler 			if (!strcmp(lgopts[opt_idx].name, "no-iova-contig"))
130259fcf854SShahaf Shuler 				mempool_flags = MEMPOOL_F_NO_IOVA_CONTIG;
1303af75078fSIntel 			break;
1304af75078fSIntel 		case 'h':
1305af75078fSIntel 			usage(argv[0]);
1306af75078fSIntel 			rte_exit(EXIT_SUCCESS, "Displayed help\n");
1307af75078fSIntel 			break;
1308af75078fSIntel 		default:
1309af75078fSIntel 			usage(argv[0]);
1310af75078fSIntel 			rte_exit(EXIT_FAILURE,
1311af75078fSIntel 				 "Command line is incomplete or incorrect\n");
1312af75078fSIntel 			break;
1313af75078fSIntel 		}
1314af75078fSIntel 	}
13150074d02fSShahaf Shuler 
13160074d02fSShahaf Shuler 	/* Set offload configuration from command line parameters. */
13170074d02fSShahaf Shuler 	rx_mode.offloads = rx_offloads;
1318fd8c20aaSShahaf Shuler 	tx_mode.offloads = tx_offloads;
131959fcf854SShahaf Shuler 
132059fcf854SShahaf Shuler 	if (mempool_flags & MEMPOOL_F_NO_IOVA_CONTIG &&
132159fcf854SShahaf Shuler 	    mp_alloc_type != MP_ALLOC_ANON) {
132259fcf854SShahaf Shuler 		TESTPMD_LOG(WARNING, "cannot use no-iova-contig without "
132359fcf854SShahaf Shuler 				  "mp-alloc=anon. mempool no-iova-contig is "
132459fcf854SShahaf Shuler 				  "ignored\n");
132559fcf854SShahaf Shuler 		mempool_flags = 0;
132659fcf854SShahaf Shuler 	}
1327af75078fSIntel }
1328