xref: /dpdk/app/test-pmd/parameters.c (revision 82010ef55e7cb4948b4bf4ff229716a3a142e95c)
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>
22af75078fSIntel 
23af75078fSIntel #include <rte_common.h>
24af75078fSIntel #include <rte_byteorder.h>
25af75078fSIntel #include <rte_log.h>
26af75078fSIntel #include <rte_debug.h>
27af75078fSIntel #include <rte_cycles.h>
28af75078fSIntel #include <rte_memory.h>
29af75078fSIntel #include <rte_launch.h>
30af75078fSIntel #include <rte_eal.h>
31af75078fSIntel #include <rte_per_lcore.h>
32af75078fSIntel #include <rte_lcore.h>
33af75078fSIntel #include <rte_atomic.h>
34af75078fSIntel #include <rte_branch_prediction.h>
35af75078fSIntel #include <rte_mempool.h>
36af75078fSIntel #include <rte_interrupts.h>
37af75078fSIntel #include <rte_pci.h>
38af75078fSIntel #include <rte_ether.h>
39af75078fSIntel #include <rte_ethdev.h>
40af75078fSIntel #include <rte_string_fns.h>
410d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
42af75078fSIntel #include <cmdline_parse.h>
43af75078fSIntel #include <cmdline_parse_etheraddr.h>
440d56cb81SThomas Monjalon #endif
452950a769SDeclan Doherty #ifdef RTE_LIBRTE_PMD_BOND
462950a769SDeclan Doherty #include <rte_eth_bond.h>
472950a769SDeclan Doherty #endif
48938a184aSAdrien Mazarguil #include <rte_flow.h>
49af75078fSIntel 
50af75078fSIntel #include "testpmd.h"
51af75078fSIntel 
52af75078fSIntel static void
53af75078fSIntel usage(char* progname)
54af75078fSIntel {
550d56cb81SThomas Monjalon 	printf("usage: %s "
560d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
570d56cb81SThomas Monjalon 	       "[--interactive|-i] "
5881ef862bSAllain Legacy 	       "[--cmdline-file=FILENAME] "
590d56cb81SThomas Monjalon #endif
60ca7feb22SCyril Chemparathy 	       "[--help|-h] | [--auto-start|-a] | ["
61cfea1f30SPablo de Lara 	       "--tx-first | --stats-period=PERIOD | "
62af75078fSIntel 	       "--coremask=COREMASK --portmask=PORTMASK --numa "
63c8798818SIntel 	       "--mbuf-size= | --total-num-mbufs= | "
643be52ffcSIntel 	       "--nb-cores= | --nb-ports= | "
650d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
66af75078fSIntel 	       "--eth-peers-configfile= | "
673be52ffcSIntel 	       "--eth-peer=X,M:M:M:M:M:M | "
680d56cb81SThomas Monjalon #endif
69af75078fSIntel 	       "--pkt-filter-mode= |"
70af75078fSIntel 	       "--rss-ip | --rss-udp | "
71af75078fSIntel 	       "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
72af75078fSIntel 	       "--txpt= | --txht= | --txwt= | --txfreet= | "
7339e5e20fSXueming Li 	       "--txrst= | --tx-offloads= | --vxlan-gpe-port= ]\n",
74af75078fSIntel 	       progname);
750d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
763be52ffcSIntel 	printf("  --interactive: run in interactive mode.\n");
7781ef862bSAllain Legacy 	printf("  --cmdline-file: execute cli commands before startup.\n");
780d56cb81SThomas Monjalon #endif
79ca7feb22SCyril Chemparathy 	printf("  --auto-start: start forwarding on init "
80ca7feb22SCyril Chemparathy 	       "[always when non-interactive].\n");
813be52ffcSIntel 	printf("  --help: display this message and quit.\n");
8299cabef0SPablo de Lara 	printf("  --tx-first: start forwarding sending a burst first "
8399cabef0SPablo de Lara 	       "(only if interactive is disabled).\n");
84cfea1f30SPablo de Lara 	printf("  --stats-period=PERIOD: statistics will be shown "
85cfea1f30SPablo de Lara 	       "every PERIOD seconds (only if interactive is disabled).\n");
863be52ffcSIntel 	printf("  --nb-cores=N: set the number of forwarding cores "
873be52ffcSIntel 	       "(1 <= N <= %d).\n", nb_lcores);
883be52ffcSIntel 	printf("  --nb-ports=N: set the number of forwarding ports "
893be52ffcSIntel 	       "(1 <= N <= %d).\n", nb_ports);
90af75078fSIntel 	printf("  --coremask=COREMASK: hexadecimal bitmask of cores running "
91013af9b6SIntel 	       "the packet forwarding test. The master lcore is reserved for "
923be52ffcSIntel 	       "command line parsing only, and cannot be masked on for "
933be52ffcSIntel 	       "packet forwarding.\n");
94af75078fSIntel 	printf("  --portmask=PORTMASK: hexadecimal bitmask of ports used "
953be52ffcSIntel 	       "by the packet forwarding test.\n");
96af75078fSIntel 	printf("  --numa: enable NUMA-aware allocation of RX/TX rings and of "
973be52ffcSIntel 	       "RX memory buffers (mbufs).\n");
98b6ea6408SIntel 	printf("  --port-numa-config=(port,socket)[,(port,socket)]: "
99b6ea6408SIntel 	       "specify the socket on which the memory pool "
100b6ea6408SIntel 	       "used by the port will be allocated.\n");
101b6ea6408SIntel 	printf("  --ring-numa-config=(port,flag,socket)[,(port,flag,socket)]: "
102b6ea6408SIntel 	       "specify the socket on which the TX/RX rings for "
103b6ea6408SIntel 	       "the port will be allocated "
104b6ea6408SIntel 	       "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
105b6ea6408SIntel 	printf("  --socket-num=N: set socket from which all memory is allocated "
106b6ea6408SIntel 	       "in NUMA mode.\n");
1073be52ffcSIntel 	printf("  --mbuf-size=N: set the data size of mbuf to N bytes.\n");
1083be52ffcSIntel 	printf("  --total-num-mbufs=N: set the number of mbufs to be allocated "
1093be52ffcSIntel 	       "in mbuf pools.\n");
1103be52ffcSIntel 	printf("  --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
1110d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
1123be52ffcSIntel 	printf("  --eth-peers-configfile=name: config file with ethernet addresses "
1133be52ffcSIntel 	       "of peer ports.\n");
1143be52ffcSIntel 	printf("  --eth-peer=X,M:M:M:M:M:M: set the MAC address of the X peer "
1153be52ffcSIntel 	       "port (0 <= X < %d).\n", RTE_MAX_ETHPORTS);
1160d56cb81SThomas Monjalon #endif
1173be52ffcSIntel 	printf("  --pkt-filter-mode=N: set Flow Director mode "
1183be52ffcSIntel 	       "(N: none (default mode) or signature or perfect).\n");
1193be52ffcSIntel 	printf("  --pkt-filter-report-hash=N: set Flow Director report mode "
1203be52ffcSIntel 	       "(N: none  or match (default) or always).\n");
1213be52ffcSIntel 	printf("  --pkt-filter-size=N: set Flow Director mode "
1223be52ffcSIntel 	       "(N: 64K (default mode) or 128K or 256K).\n");
123af75078fSIntel 	printf("  --pkt-filter-drop-queue=N: set drop-queue. "
1243be52ffcSIntel 	       "In perfect mode, when you add a rule with queue = -1 "
125af75078fSIntel 	       "the packet will be enqueued into the rx drop-queue. "
126af75078fSIntel 	       "If the drop-queue doesn't exist, the packet is dropped. "
1273be52ffcSIntel 	       "By default drop-queue=127.\n");
12862d3216dSReshma Pattan #ifdef RTE_LIBRTE_LATENCY_STATS
12962d3216dSReshma Pattan 	printf("  --latencystats=N: enable latency and jitter statistcs "
13062d3216dSReshma Pattan 	       "monitoring on forwarding lcore id N.\n");
13162d3216dSReshma Pattan #endif
13279dd163fSJeff Guo 	printf("  --disable-crc-strip: disable CRC stripping by hardware.\n");
1334c3ea508SOlivier Matz 	printf("  --enable-lro: enable large receive offload.\n");
1343be52ffcSIntel 	printf("  --enable-rx-cksum: enable rx hardware checksum offload.\n");
135912267a3SRaslan Darawsheh 	printf("  --enable-rx-timestamp: enable rx hardware timestamp offload.\n");
1368b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan: enable hardware vlan.\n");
1378b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan-filter: enable hardware vlan filter.\n");
1388b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan-strip: enable hardware vlan strip.\n");
1398b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan-extend: enable hardware vlan extend.\n");
1403be52ffcSIntel 	printf("  --enable-drop-en: enable per queue packet drop.\n");
1413be52ffcSIntel 	printf("  --disable-rss: disable rss.\n");
142af75078fSIntel 	printf("  --port-topology=N: set port topology (N: paired (default) or "
1433be52ffcSIntel 	       "chained).\n");
144769ce6b1SThomas Monjalon 	printf("  --forward-mode=N: set forwarding mode (N: %s).\n",
145769ce6b1SThomas Monjalon 	       list_pkt_forwarding_modes());
1463be52ffcSIntel 	printf("  --rss-ip: set RSS functions to IPv4/IPv6 only .\n");
1473be52ffcSIntel 	printf("  --rss-udp: set RSS functions to IPv4/IPv6 + UDP.\n");
1483be52ffcSIntel 	printf("  --rxq=N: set the number of RX queues per port to N.\n");
1493be52ffcSIntel 	printf("  --rxd=N: set the number of descriptors in RX rings to N.\n");
1503be52ffcSIntel 	printf("  --txq=N: set the number of TX queues per port to N.\n");
1513be52ffcSIntel 	printf("  --txd=N: set the number of descriptors in TX rings to N.\n");
1523be52ffcSIntel 	printf("  --burst=N: set the number of packets per burst to N.\n");
1533be52ffcSIntel 	printf("  --mbcache=N: set the cache of mbuf memory pool to N.\n");
15457af3415SPablo de Lara 	printf("  --rxpt=N: set prefetch threshold register of RX rings to N.\n");
15557af3415SPablo de Lara 	printf("  --rxht=N: set the host threshold register of RX rings to N.\n");
1563be52ffcSIntel 	printf("  --rxfreet=N: set the free threshold of RX descriptors to N "
1573be52ffcSIntel 	       "(0 <= N < value of rxd).\n");
15857af3415SPablo de Lara 	printf("  --rxwt=N: set the write-back threshold register of RX rings to N.\n");
15957af3415SPablo de Lara 	printf("  --txpt=N: set the prefetch threshold register of TX rings to N.\n");
16057af3415SPablo de Lara 	printf("  --txht=N: set the nhost threshold register of TX rings to N.\n");
16157af3415SPablo de Lara 	printf("  --txwt=N: set the write-back threshold register of TX rings to N.\n");
1623be52ffcSIntel 	printf("  --txfreet=N: set the transmit free threshold of TX rings to N "
1633be52ffcSIntel 	       "(0 <= N <= value of txd).\n");
1643be52ffcSIntel 	printf("  --txrst=N: set the transmit RS bit threshold of TX rings to N "
1653be52ffcSIntel 	       "(0 <= N <= value of txd).\n");
1663be52ffcSIntel 	printf("  --tx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: "
167ed30d9b6SIntel 	       "tx queues statistics counters mapping "
1683be52ffcSIntel 	       "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
1693be52ffcSIntel 	printf("  --rx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: "
170ed30d9b6SIntel 	       "rx queues statistics counters mapping "
1713be52ffcSIntel 	       "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
1725e2ee196SIntel 	printf("  --no-flush-rx: Don't flush RX streams before forwarding."
1735e2ee196SIntel 	       " Used mainly with PCAP drivers.\n");
1742ebacaa7SMaciej Czekaj 	printf("  --txpkts=X[,Y]*: set TX segment sizes"
1752ebacaa7SMaciej Czekaj 		" or total packet length.\n");
176*82010ef5SYongseok Koh 	printf("  --txonly-multi-flow: generate multiple flows in txonly mode\n");
177bc202406SDavid Marchand 	printf("  --disable-link-check: disable check on link status when "
178bc202406SDavid Marchand 	       "starting/stopping ports.\n");
1798ea656f8SGaetan Rivet 	printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
180e25e6c70SRemy Horton 	printf("  --no-rmv-interrupt: disable device removal interrupt.\n");
181e25e6c70SRemy Horton 	printf("  --bitrate-stats=N: set the logical core N to perform "
182e25e6c70SRemy Horton 		"bit-rate calculation.\n");
183b6b63dfdSGaetan Rivet 	printf("  --print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>: "
184776ecd42SWenzhuo Lu 	       "enable print of designated event or all of them.\n");
185b6b63dfdSGaetan Rivet 	printf("  --mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>: "
186776ecd42SWenzhuo Lu 	       "disable print of designated event or all of them.\n");
1877ee3e944SVasily Philipov 	printf("  --flow-isolate-all: "
188776ecd42SWenzhuo Lu 	       "requests flow API isolated mode on all ports at initialization time.\n");
189fd8c20aaSShahaf Shuler 	printf("  --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
190fb73e096SJeff Guo 	printf("  --hot-plug: enable hot plug for device.\n");
19139e5e20fSXueming Li 	printf("  --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\n");
192e505d84cSAnatoly Burakov 	printf("  --mlockall: lock all memory\n");
193e505d84cSAnatoly Burakov 	printf("  --no-mlockall: do not lock all memory\n");
194c7f5dba7SAnatoly Burakov 	printf("  --mp-alloc <native|anon|xmem|xmemhuge>: mempool allocation method.\n"
195c7f5dba7SAnatoly Burakov 	       "    native: use regular DPDK memory to create and populate mempool\n"
196c7f5dba7SAnatoly Burakov 	       "    anon: use regular DPDK memory to create and anonymous memory to populate mempool\n"
197c7f5dba7SAnatoly Burakov 	       "    xmem: use anonymous memory to create and populate mempool\n"
198c7f5dba7SAnatoly Burakov 	       "    xmemhuge: use anonymous hugepage memory to create and populate mempool\n");
1993c156061SJens Freimann 	printf("  --noisy-tx-sw-buffer-size=N: size of FIFO buffer\n");
2003c156061SJens Freimann 	printf("  --noisy-tx-sw-buffer-flushtime=N: flush FIFO after N ms\n");
2013c156061SJens Freimann 	printf("  --noisy-lkup-memory=N: allocate N MB of VNF memory\n");
2023c156061SJens Freimann 	printf("  --noisy-lkup-num-writes=N: do N random writes per packet\n");
2033c156061SJens Freimann 	printf("  --noisy-lkup-num-reads=N: do N random reads per packet\n");
2043c156061SJens Freimann 	printf("  --noisy-lkup-num-writes=N: do N random reads and writes per packet\n");
205af75078fSIntel }
206af75078fSIntel 
2070d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
208af75078fSIntel static int
209af75078fSIntel init_peer_eth_addrs(char *config_filename)
210af75078fSIntel {
211af75078fSIntel 	FILE *config_file;
212af75078fSIntel 	portid_t i;
213af75078fSIntel 	char buf[50];
214af75078fSIntel 
215af75078fSIntel 	config_file = fopen(config_filename, "r");
216af75078fSIntel 	if (config_file == NULL) {
2173be52ffcSIntel 		perror("Failed to open eth config file\n");
218af75078fSIntel 		return -1;
219af75078fSIntel 	}
220af75078fSIntel 
221af75078fSIntel 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
222af75078fSIntel 
223af75078fSIntel 		if (fgets(buf, sizeof(buf), config_file) == NULL)
224af75078fSIntel 			break;
225af75078fSIntel 
226aaa662e7SAlan Carew 		if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i],
227aaa662e7SAlan Carew 				sizeof(peer_eth_addrs[i])) < 0) {
2283be52ffcSIntel 			printf("Bad MAC address format on line %d\n", i+1);
229af75078fSIntel 			fclose(config_file);
230af75078fSIntel 			return -1;
231af75078fSIntel 		}
232af75078fSIntel 	}
233af75078fSIntel 	fclose(config_file);
234af75078fSIntel 	nb_peer_eth_addrs = (portid_t) i;
235af75078fSIntel 	return 0;
236af75078fSIntel }
2370d56cb81SThomas Monjalon #endif
238af75078fSIntel 
239af75078fSIntel /*
240af75078fSIntel  * Parse the coremask given as argument (hexadecimal string) and set
241af75078fSIntel  * the global configuration of forwarding cores.
242af75078fSIntel  */
243af75078fSIntel static void
244af75078fSIntel parse_fwd_coremask(const char *coremask)
245af75078fSIntel {
246af75078fSIntel 	char *end;
247af75078fSIntel 	unsigned long long int cm;
248af75078fSIntel 
249af75078fSIntel 	/* parse hexadecimal string */
250af75078fSIntel 	end = NULL;
251af75078fSIntel 	cm = strtoull(coremask, &end, 16);
252af75078fSIntel 	if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0'))
253af75078fSIntel 		rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n");
254013af9b6SIntel 	else if (set_fwd_lcores_mask((uint64_t) cm) < 0)
255013af9b6SIntel 		rte_exit(EXIT_FAILURE, "coremask is not valid\n");
256af75078fSIntel }
257af75078fSIntel 
258af75078fSIntel /*
259af75078fSIntel  * Parse the coremask given as argument (hexadecimal string) and set
260af75078fSIntel  * the global configuration of forwarding cores.
261af75078fSIntel  */
262af75078fSIntel static void
263af75078fSIntel parse_fwd_portmask(const char *portmask)
264af75078fSIntel {
265af75078fSIntel 	char *end;
266af75078fSIntel 	unsigned long long int pm;
267af75078fSIntel 
268af75078fSIntel 	/* parse hexadecimal string */
269af75078fSIntel 	end = NULL;
270af75078fSIntel 	pm = strtoull(portmask, &end, 16);
271af75078fSIntel 	if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
272af75078fSIntel 		rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n");
273af75078fSIntel 	else
274af75078fSIntel 		set_fwd_ports_mask((uint64_t) pm);
275af75078fSIntel }
276af75078fSIntel 
277ed30d9b6SIntel 
278ed30d9b6SIntel static int
279ed30d9b6SIntel parse_queue_stats_mapping_config(const char *q_arg, int is_rx)
280ed30d9b6SIntel {
281ed30d9b6SIntel 	char s[256];
282ed30d9b6SIntel 	const char *p, *p0 = q_arg;
283ed30d9b6SIntel 	char *end;
284ed30d9b6SIntel 	enum fieldnames {
285ed30d9b6SIntel 		FLD_PORT = 0,
286ed30d9b6SIntel 		FLD_QUEUE,
287ed30d9b6SIntel 		FLD_STATS_COUNTER,
288ed30d9b6SIntel 		_NUM_FLD
289ed30d9b6SIntel 	};
290ed30d9b6SIntel 	unsigned long int_fld[_NUM_FLD];
291ed30d9b6SIntel 	char *str_fld[_NUM_FLD];
292ed30d9b6SIntel 	int i;
293ed30d9b6SIntel 	unsigned size;
294ed30d9b6SIntel 
295ed30d9b6SIntel 	/* reset from value set at definition */
296ed30d9b6SIntel 	is_rx ? (nb_rx_queue_stats_mappings = 0) : (nb_tx_queue_stats_mappings = 0);
297ed30d9b6SIntel 
298ed30d9b6SIntel 	while ((p = strchr(p0,'(')) != NULL) {
299ed30d9b6SIntel 		++p;
300ed30d9b6SIntel 		if((p0 = strchr(p,')')) == NULL)
301ed30d9b6SIntel 			return -1;
302ed30d9b6SIntel 
303ed30d9b6SIntel 		size = p0 - p;
304ed30d9b6SIntel 		if(size >= sizeof(s))
305ed30d9b6SIntel 			return -1;
306ed30d9b6SIntel 
3076f41fe75SStephen Hemminger 		snprintf(s, sizeof(s), "%.*s", size, p);
308ed30d9b6SIntel 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
309ed30d9b6SIntel 			return -1;
310ed30d9b6SIntel 		for (i = 0; i < _NUM_FLD; i++){
311ed30d9b6SIntel 			errno = 0;
312ed30d9b6SIntel 			int_fld[i] = strtoul(str_fld[i], &end, 0);
313ed30d9b6SIntel 			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
314ed30d9b6SIntel 				return -1;
315ed30d9b6SIntel 		}
316ed30d9b6SIntel 		/* Check mapping field is in correct range (0..RTE_ETHDEV_QUEUE_STAT_CNTRS-1) */
317ed30d9b6SIntel 		if (int_fld[FLD_STATS_COUNTER] >= RTE_ETHDEV_QUEUE_STAT_CNTRS) {
318ed30d9b6SIntel 			printf("Stats counter not in the correct range 0..%d\n",
319ed30d9b6SIntel 					RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
320ed30d9b6SIntel 			return -1;
321ed30d9b6SIntel 		}
322ed30d9b6SIntel 
3234dccdc78SBruce Richardson 		if (!is_rx) {
3244dccdc78SBruce Richardson 			if ((nb_tx_queue_stats_mappings >=
3254dccdc78SBruce Richardson 						MAX_TX_QUEUE_STATS_MAPPINGS)) {
3264dccdc78SBruce Richardson 				printf("exceeded max number of TX queue "
3274dccdc78SBruce Richardson 						"statistics mappings: %hu\n",
3284dccdc78SBruce Richardson 						nb_tx_queue_stats_mappings);
329ed30d9b6SIntel 				return -1;
330ed30d9b6SIntel 			}
331ed30d9b6SIntel 			tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id =
332ed30d9b6SIntel 				(uint8_t)int_fld[FLD_PORT];
333ed30d9b6SIntel 			tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id =
334ed30d9b6SIntel 				(uint8_t)int_fld[FLD_QUEUE];
335ed30d9b6SIntel 			tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].stats_counter_id =
336ed30d9b6SIntel 				(uint8_t)int_fld[FLD_STATS_COUNTER];
337ed30d9b6SIntel 			++nb_tx_queue_stats_mappings;
338ed30d9b6SIntel 		}
339ed30d9b6SIntel 		else {
3404dccdc78SBruce Richardson 			if ((nb_rx_queue_stats_mappings >=
3414dccdc78SBruce Richardson 						MAX_RX_QUEUE_STATS_MAPPINGS)) {
3424dccdc78SBruce Richardson 				printf("exceeded max number of RX queue "
3434dccdc78SBruce Richardson 						"statistics mappings: %hu\n",
3444dccdc78SBruce Richardson 						nb_rx_queue_stats_mappings);
3454dccdc78SBruce Richardson 				return -1;
3464dccdc78SBruce Richardson 			}
347ed30d9b6SIntel 			rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id =
348ed30d9b6SIntel 				(uint8_t)int_fld[FLD_PORT];
349ed30d9b6SIntel 			rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id =
350ed30d9b6SIntel 				(uint8_t)int_fld[FLD_QUEUE];
351ed30d9b6SIntel 			rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].stats_counter_id =
352ed30d9b6SIntel 				(uint8_t)int_fld[FLD_STATS_COUNTER];
353ed30d9b6SIntel 			++nb_rx_queue_stats_mappings;
354ed30d9b6SIntel 		}
355ed30d9b6SIntel 
356ed30d9b6SIntel 	}
357ed30d9b6SIntel /* Reassign the rx/tx_queue_stats_mappings pointer to point to this newly populated array rather */
358ed30d9b6SIntel /* than to the default array (that was set at its definition) */
359ed30d9b6SIntel 	is_rx ? (rx_queue_stats_mappings = rx_queue_stats_mappings_array) :
360ed30d9b6SIntel 		(tx_queue_stats_mappings = tx_queue_stats_mappings_array);
361ed30d9b6SIntel 	return 0;
362ed30d9b6SIntel }
363ed30d9b6SIntel 
364c9cafcc8SShahaf Shuler static void
365c9cafcc8SShahaf Shuler print_invalid_socket_id_error(void)
366c9cafcc8SShahaf Shuler {
367c9cafcc8SShahaf Shuler 	unsigned int i = 0;
368c9cafcc8SShahaf Shuler 
369c9cafcc8SShahaf Shuler 	printf("Invalid socket id, options are: ");
370c9cafcc8SShahaf Shuler 	for (i = 0; i < num_sockets; i++) {
371c9cafcc8SShahaf Shuler 		printf("%u%s", socket_ids[i],
372c9cafcc8SShahaf Shuler 		      (i == num_sockets - 1) ? "\n" : ",");
373c9cafcc8SShahaf Shuler 	}
374c9cafcc8SShahaf Shuler }
375c9cafcc8SShahaf Shuler 
376b6ea6408SIntel static int
377b6ea6408SIntel parse_portnuma_config(const char *q_arg)
378b6ea6408SIntel {
379b6ea6408SIntel 	char s[256];
380b6ea6408SIntel 	const char *p, *p0 = q_arg;
381b6ea6408SIntel 	char *end;
382d1f1a0fdSLi Han 	uint8_t i, socket_id;
383d1f1a0fdSLi Han 	portid_t port_id;
384b6ea6408SIntel 	unsigned size;
385b6ea6408SIntel 	enum fieldnames {
386b6ea6408SIntel 		FLD_PORT = 0,
387b6ea6408SIntel 		FLD_SOCKET,
388b6ea6408SIntel 		_NUM_FLD
389b6ea6408SIntel 	};
390b6ea6408SIntel 	unsigned long int_fld[_NUM_FLD];
391b6ea6408SIntel 	char *str_fld[_NUM_FLD];
392b6ea6408SIntel 
393b6ea6408SIntel 	/* reset from value set at definition */
394b6ea6408SIntel 	while ((p = strchr(p0,'(')) != NULL) {
395b6ea6408SIntel 		++p;
396b6ea6408SIntel 		if((p0 = strchr(p,')')) == NULL)
397b6ea6408SIntel 			return -1;
398b6ea6408SIntel 
399b6ea6408SIntel 		size = p0 - p;
400b6ea6408SIntel 		if(size >= sizeof(s))
401b6ea6408SIntel 			return -1;
402b6ea6408SIntel 
4036f41fe75SStephen Hemminger 		snprintf(s, sizeof(s), "%.*s", size, p);
404b6ea6408SIntel 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
405b6ea6408SIntel 			return -1;
406b6ea6408SIntel 		for (i = 0; i < _NUM_FLD; i++) {
407b6ea6408SIntel 			errno = 0;
408b6ea6408SIntel 			int_fld[i] = strtoul(str_fld[i], &end, 0);
409b6ea6408SIntel 			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
410b6ea6408SIntel 				return -1;
411b6ea6408SIntel 		}
412d1f1a0fdSLi Han 		port_id = (portid_t)int_fld[FLD_PORT];
413d1f1a0fdSLi Han 		if (port_id_is_invalid(port_id, ENABLED_WARN) ||
414d1f1a0fdSLi Han 			port_id == (portid_t)RTE_PORT_ALL) {
4158f3c4176SMatan Azrad 			print_valid_ports();
416b6ea6408SIntel 			return -1;
417b6ea6408SIntel 		}
418b6ea6408SIntel 		socket_id = (uint8_t)int_fld[FLD_SOCKET];
419c9cafcc8SShahaf Shuler 		if (new_socket_id(socket_id)) {
420a569af24SPhil Yang 			if (num_sockets >= RTE_MAX_NUMA_NODES) {
421c9cafcc8SShahaf Shuler 				print_invalid_socket_id_error();
422b6ea6408SIntel 				return -1;
423b6ea6408SIntel 			}
424a569af24SPhil Yang 			socket_ids[num_sockets++] = socket_id;
425a569af24SPhil Yang 		}
426b6ea6408SIntel 		port_numa[port_id] = socket_id;
427b6ea6408SIntel 	}
428b6ea6408SIntel 
429b6ea6408SIntel 	return 0;
430b6ea6408SIntel }
431b6ea6408SIntel 
432b6ea6408SIntel static int
433b6ea6408SIntel parse_ringnuma_config(const char *q_arg)
434b6ea6408SIntel {
435b6ea6408SIntel 	char s[256];
436b6ea6408SIntel 	const char *p, *p0 = q_arg;
437b6ea6408SIntel 	char *end;
438d1f1a0fdSLi Han 	uint8_t i, ring_flag, socket_id;
439d1f1a0fdSLi Han 	portid_t port_id;
440b6ea6408SIntel 	unsigned size;
441b6ea6408SIntel 	enum fieldnames {
442b6ea6408SIntel 		FLD_PORT = 0,
443b6ea6408SIntel 		FLD_FLAG,
444b6ea6408SIntel 		FLD_SOCKET,
445b6ea6408SIntel 		_NUM_FLD
446b6ea6408SIntel 	};
447b6ea6408SIntel 	unsigned long int_fld[_NUM_FLD];
448b6ea6408SIntel 	char *str_fld[_NUM_FLD];
449b6ea6408SIntel 	#define RX_RING_ONLY 0x1
450b6ea6408SIntel 	#define TX_RING_ONLY 0x2
451b6ea6408SIntel 	#define RXTX_RING    0x3
452b6ea6408SIntel 
453b6ea6408SIntel 	/* reset from value set at definition */
454b6ea6408SIntel 	while ((p = strchr(p0,'(')) != NULL) {
455b6ea6408SIntel 		++p;
456b6ea6408SIntel 		if((p0 = strchr(p,')')) == NULL)
457b6ea6408SIntel 			return -1;
458b6ea6408SIntel 
459b6ea6408SIntel 		size = p0 - p;
460b6ea6408SIntel 		if(size >= sizeof(s))
461b6ea6408SIntel 			return -1;
462b6ea6408SIntel 
4636f41fe75SStephen Hemminger 		snprintf(s, sizeof(s), "%.*s", size, p);
464b6ea6408SIntel 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
465b6ea6408SIntel 			return -1;
466b6ea6408SIntel 		for (i = 0; i < _NUM_FLD; i++) {
467b6ea6408SIntel 			errno = 0;
468b6ea6408SIntel 			int_fld[i] = strtoul(str_fld[i], &end, 0);
469b6ea6408SIntel 			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
470b6ea6408SIntel 				return -1;
471b6ea6408SIntel 		}
472d1f1a0fdSLi Han 		port_id = (portid_t)int_fld[FLD_PORT];
473d1f1a0fdSLi Han 		if (port_id_is_invalid(port_id, ENABLED_WARN) ||
474d1f1a0fdSLi Han 			port_id == (portid_t)RTE_PORT_ALL) {
4758f3c4176SMatan Azrad 			print_valid_ports();
476b6ea6408SIntel 			return -1;
477b6ea6408SIntel 		}
478b6ea6408SIntel 		socket_id = (uint8_t)int_fld[FLD_SOCKET];
479c9cafcc8SShahaf Shuler 		if (new_socket_id(socket_id)) {
480a569af24SPhil Yang 			if (num_sockets >= RTE_MAX_NUMA_NODES) {
481c9cafcc8SShahaf Shuler 				print_invalid_socket_id_error();
482b6ea6408SIntel 				return -1;
483b6ea6408SIntel 			}
484a569af24SPhil Yang 			socket_ids[num_sockets++] = socket_id;
485a569af24SPhil Yang 		}
486b6ea6408SIntel 		ring_flag = (uint8_t)int_fld[FLD_FLAG];
487b6ea6408SIntel 		if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) {
488b6ea6408SIntel 			printf("Invalid ring-flag=%d config for port =%d\n",
489b6ea6408SIntel 				ring_flag,port_id);
490b6ea6408SIntel 			return -1;
491b6ea6408SIntel 		}
492b6ea6408SIntel 
493b6ea6408SIntel 		switch (ring_flag & RXTX_RING) {
494b6ea6408SIntel 		case RX_RING_ONLY:
495b6ea6408SIntel 			rxring_numa[port_id] = socket_id;
496b6ea6408SIntel 			break;
497b6ea6408SIntel 		case TX_RING_ONLY:
498b6ea6408SIntel 			txring_numa[port_id] = socket_id;
499b6ea6408SIntel 			break;
500b6ea6408SIntel 		case RXTX_RING:
501b6ea6408SIntel 			rxring_numa[port_id] = socket_id;
502b6ea6408SIntel 			txring_numa[port_id] = socket_id;
503b6ea6408SIntel 			break;
504b6ea6408SIntel 		default:
505b6ea6408SIntel 			printf("Invalid ring-flag=%d config for port=%d\n",
506b6ea6408SIntel 				ring_flag,port_id);
507b6ea6408SIntel 			break;
508b6ea6408SIntel 		}
509b6ea6408SIntel 	}
510b6ea6408SIntel 
511b6ea6408SIntel 	return 0;
512b6ea6408SIntel }
513ed30d9b6SIntel 
5143af72783SGaetan Rivet static int
5153af72783SGaetan Rivet parse_event_printing_config(const char *optarg, int enable)
5163af72783SGaetan Rivet {
5173af72783SGaetan Rivet 	uint32_t mask = 0;
5183af72783SGaetan Rivet 
5193af72783SGaetan Rivet 	if (!strcmp(optarg, "unknown"))
5203af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN;
5213af72783SGaetan Rivet 	else if (!strcmp(optarg, "intr_lsc"))
5223af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_LSC;
5233af72783SGaetan Rivet 	else if (!strcmp(optarg, "queue_state"))
5243af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_QUEUE_STATE;
5253af72783SGaetan Rivet 	else if (!strcmp(optarg, "intr_reset"))
5263af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET;
5273af72783SGaetan Rivet 	else if (!strcmp(optarg, "vf_mbox"))
5283af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_VF_MBOX;
529badb87c1SAnoob Joseph 	else if (!strcmp(optarg, "ipsec"))
530badb87c1SAnoob Joseph 		mask = UINT32_C(1) << RTE_ETH_EVENT_IPSEC;
5313af72783SGaetan Rivet 	else if (!strcmp(optarg, "macsec"))
5323af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
5333af72783SGaetan Rivet 	else if (!strcmp(optarg, "intr_rmv"))
5343af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
5354fb82244SMatan Azrad 	else if (!strcmp(optarg, "dev_probed"))
5364fb82244SMatan Azrad 		mask = UINT32_C(1) << RTE_ETH_EVENT_NEW;
5374fb82244SMatan Azrad 	else if (!strcmp(optarg, "dev_released"))
5384fb82244SMatan Azrad 		mask = UINT32_C(1) << RTE_ETH_EVENT_DESTROY;
539b6b63dfdSGaetan Rivet 	else if (!strcmp(optarg, "all"))
540b6b63dfdSGaetan Rivet 		mask = ~UINT32_C(0);
5413af72783SGaetan Rivet 	else {
5423af72783SGaetan Rivet 		fprintf(stderr, "Invalid event: %s\n", optarg);
5433af72783SGaetan Rivet 		return -1;
5443af72783SGaetan Rivet 	}
5453af72783SGaetan Rivet 	if (enable)
5463af72783SGaetan Rivet 		event_print_mask |= mask;
5473af72783SGaetan Rivet 	else
5483af72783SGaetan Rivet 		event_print_mask &= ~mask;
5493af72783SGaetan Rivet 	return 0;
5503af72783SGaetan Rivet }
5513af72783SGaetan Rivet 
552af75078fSIntel void
553af75078fSIntel launch_args_parse(int argc, char** argv)
554af75078fSIntel {
555af75078fSIntel 	int n, opt;
556af75078fSIntel 	char **argvopt;
557af75078fSIntel 	int opt_idx;
5583f7311baSWei Dai 	portid_t pid;
559013af9b6SIntel 	enum { TX, RX };
560fd8c20aaSShahaf Shuler 	/* Default offloads for all ports. */
5610074d02fSShahaf Shuler 	uint64_t rx_offloads = rx_mode.offloads;
562fd8c20aaSShahaf Shuler 	uint64_t tx_offloads = tx_mode.offloads;
5638599ed31SRemy Horton 	struct rte_eth_dev_info dev_info;
5648599ed31SRemy Horton 	uint16_t rec_nb_pkts;
565013af9b6SIntel 
566af75078fSIntel 	static struct option lgopts[] = {
567af75078fSIntel 		{ "help",			0, 0, 0 },
5680d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
569af75078fSIntel 		{ "interactive",		0, 0, 0 },
57081ef862bSAllain Legacy 		{ "cmdline-file",		1, 0, 0 },
571ca7feb22SCyril Chemparathy 		{ "auto-start",			0, 0, 0 },
572af75078fSIntel 		{ "eth-peers-configfile",	1, 0, 0 },
573af75078fSIntel 		{ "eth-peer",			1, 0, 0 },
5740d56cb81SThomas Monjalon #endif
57599cabef0SPablo de Lara 		{ "tx-first",			0, 0, 0 },
576cfea1f30SPablo de Lara 		{ "stats-period",		1, 0, 0 },
577af75078fSIntel 		{ "ports",			1, 0, 0 },
578af75078fSIntel 		{ "nb-cores",			1, 0, 0 },
579af75078fSIntel 		{ "nb-ports",			1, 0, 0 },
580af75078fSIntel 		{ "coremask",			1, 0, 0 },
581af75078fSIntel 		{ "portmask",			1, 0, 0 },
582af75078fSIntel 		{ "numa",			0, 0, 0 },
583999b2ee0SBruce Richardson 		{ "no-numa",			0, 0, 0 },
584148f963fSBruce Richardson 		{ "mp-anon",			0, 0, 0 },
585b6ea6408SIntel 		{ "port-numa-config",           1, 0, 0 },
586b6ea6408SIntel 		{ "ring-numa-config",           1, 0, 0 },
587b6ea6408SIntel 		{ "socket-num",			1, 0, 0 },
588af75078fSIntel 		{ "mbuf-size",			1, 0, 0 },
589c8798818SIntel 		{ "total-num-mbufs",		1, 0, 0 },
590af75078fSIntel 		{ "max-pkt-len",		1, 0, 0 },
591af75078fSIntel 		{ "pkt-filter-mode",            1, 0, 0 },
592af75078fSIntel 		{ "pkt-filter-report-hash",     1, 0, 0 },
593af75078fSIntel 		{ "pkt-filter-size",            1, 0, 0 },
594af75078fSIntel 		{ "pkt-filter-drop-queue",      1, 0, 0 },
59562d3216dSReshma Pattan #ifdef RTE_LIBRTE_LATENCY_STATS
59662d3216dSReshma Pattan 		{ "latencystats",               1, 0, 0 },
59762d3216dSReshma Pattan #endif
598e25e6c70SRemy Horton #ifdef RTE_LIBRTE_BITRATE
599e25e6c70SRemy Horton 		{ "bitrate-stats",              1, 0, 0 },
600e25e6c70SRemy Horton #endif
60179dd163fSJeff Guo 		{ "disable-crc-strip",          0, 0, 0 },
6024c3ea508SOlivier Matz 		{ "enable-lro",                 0, 0, 0 },
603013af9b6SIntel 		{ "enable-rx-cksum",            0, 0, 0 },
604912267a3SRaslan Darawsheh 		{ "enable-rx-timestamp",        0, 0, 0 },
60504997938SMaciej Czekaj 		{ "enable-scatter",             0, 0, 0 },
6068b9bd0efSMoti Haimovsky 		{ "enable-hw-vlan",             0, 0, 0 },
6078b9bd0efSMoti Haimovsky 		{ "enable-hw-vlan-filter",      0, 0, 0 },
6088b9bd0efSMoti Haimovsky 		{ "enable-hw-vlan-strip",       0, 0, 0 },
6098b9bd0efSMoti Haimovsky 		{ "enable-hw-vlan-extend",      0, 0, 0 },
610013af9b6SIntel 		{ "enable-drop-en",            0, 0, 0 },
611af75078fSIntel 		{ "disable-rss",                0, 0, 0 },
612af75078fSIntel 		{ "port-topology",              1, 0, 0 },
613ce9b9fb0SCyril Chemparathy 		{ "forward-mode",               1, 0, 0 },
614af75078fSIntel 		{ "rss-ip",			0, 0, 0 },
615af75078fSIntel 		{ "rss-udp",			0, 0, 0 },
616af75078fSIntel 		{ "rxq",			1, 0, 0 },
617af75078fSIntel 		{ "txq",			1, 0, 0 },
618af75078fSIntel 		{ "rxd",			1, 0, 0 },
619af75078fSIntel 		{ "txd",			1, 0, 0 },
620af75078fSIntel 		{ "burst",			1, 0, 0 },
621af75078fSIntel 		{ "mbcache",			1, 0, 0 },
622af75078fSIntel 		{ "txpt",			1, 0, 0 },
623af75078fSIntel 		{ "txht",			1, 0, 0 },
624af75078fSIntel 		{ "txwt",			1, 0, 0 },
625af75078fSIntel 		{ "txfreet",			1, 0, 0 },
626af75078fSIntel 		{ "txrst",			1, 0, 0 },
627af75078fSIntel 		{ "rxpt",			1, 0, 0 },
628af75078fSIntel 		{ "rxht",			1, 0, 0 },
629af75078fSIntel 		{ "rxwt",			1, 0, 0 },
630af75078fSIntel 		{ "rxfreet",                    1, 0, 0 },
631ed30d9b6SIntel 		{ "tx-queue-stats-mapping",	1, 0, 0 },
632ed30d9b6SIntel 		{ "rx-queue-stats-mapping",	1, 0, 0 },
6337741e4cfSIntel 		{ "no-flush-rx",	0, 0, 0 },
6347ee3e944SVasily Philipov 		{ "flow-isolate-all",	        0, 0, 0 },
635a7e7bb4eSCyril Chemparathy 		{ "txpkts",			1, 0, 0 },
636*82010ef5SYongseok Koh 		{ "txonly-multi-flow",		0, 0, 0 },
637bc202406SDavid Marchand 		{ "disable-link-check",		0, 0, 0 },
6388ea656f8SGaetan Rivet 		{ "no-lsc-interrupt",		0, 0, 0 },
639284c908cSGaetan Rivet 		{ "no-rmv-interrupt",		0, 0, 0 },
6403af72783SGaetan Rivet 		{ "print-event",		1, 0, 0 },
6413af72783SGaetan Rivet 		{ "mask-event",			1, 0, 0 },
642fd8c20aaSShahaf Shuler 		{ "tx-offloads",		1, 0, 0 },
643fb73e096SJeff Guo 		{ "hot-plug",			0, 0, 0 },
64439e5e20fSXueming Li 		{ "vxlan-gpe-port",		1, 0, 0 },
645e505d84cSAnatoly Burakov 		{ "mlockall",			0, 0, 0 },
646e505d84cSAnatoly Burakov 		{ "no-mlockall",		0, 0, 0 },
647c7f5dba7SAnatoly Burakov 		{ "mp-alloc",			1, 0, 0 },
6483c156061SJens Freimann 		{ "noisy-tx-sw-buffer-size",	1, 0, 0 },
6493c156061SJens Freimann 		{ "noisy-tx-sw-buffer-flushtime", 1, 0, 0 },
6503c156061SJens Freimann 		{ "noisy-lkup-memory",		1, 0, 0 },
6513c156061SJens Freimann 		{ "noisy-lkup-num-writes",	1, 0, 0 },
6523c156061SJens Freimann 		{ "noisy-lkup-num-reads",	1, 0, 0 },
6533c156061SJens Freimann 		{ "noisy-lkup-num-reads-writes", 1, 0, 0 },
654af75078fSIntel 		{ 0, 0, 0, 0 },
655af75078fSIntel 	};
656af75078fSIntel 
657af75078fSIntel 	argvopt = argv;
658af75078fSIntel 
6590d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
660ca7feb22SCyril Chemparathy #define SHORTOPTS "i"
6610d56cb81SThomas Monjalon #else
662ca7feb22SCyril Chemparathy #define SHORTOPTS ""
6630d56cb81SThomas Monjalon #endif
664ca7feb22SCyril Chemparathy 	while ((opt = getopt_long(argc, argvopt, SHORTOPTS "ah",
665af75078fSIntel 				 lgopts, &opt_idx)) != EOF) {
666af75078fSIntel 		switch (opt) {
6670d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
668af75078fSIntel 		case 'i':
669af75078fSIntel 			printf("Interactive-mode selected\n");
670af75078fSIntel 			interactive = 1;
671af75078fSIntel 			break;
6720d56cb81SThomas Monjalon #endif
673ca7feb22SCyril Chemparathy 		case 'a':
674ca7feb22SCyril Chemparathy 			printf("Auto-start selected\n");
675ca7feb22SCyril Chemparathy 			auto_start = 1;
676ca7feb22SCyril Chemparathy 			break;
677ca7feb22SCyril Chemparathy 
678af75078fSIntel 		case 0: /*long options */
679af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "help")) {
680af75078fSIntel 				usage(argv[0]);
681af75078fSIntel 				rte_exit(EXIT_SUCCESS, "Displayed help\n");
682af75078fSIntel 			}
6830d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE
684af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "interactive")) {
685af75078fSIntel 				printf("Interactive-mode selected\n");
686af75078fSIntel 				interactive = 1;
687af75078fSIntel 			}
68881ef862bSAllain Legacy 			if (!strcmp(lgopts[opt_idx].name, "cmdline-file")) {
68981ef862bSAllain Legacy 				printf("CLI commands to be read from %s\n",
69081ef862bSAllain Legacy 				       optarg);
691c022cb40SBruce Richardson 				strlcpy(cmdline_filename, optarg,
692c022cb40SBruce Richardson 					sizeof(cmdline_filename));
69381ef862bSAllain Legacy 			}
694ca7feb22SCyril Chemparathy 			if (!strcmp(lgopts[opt_idx].name, "auto-start")) {
695ca7feb22SCyril Chemparathy 				printf("Auto-start selected\n");
696ca7feb22SCyril Chemparathy 				auto_start = 1;
697ca7feb22SCyril Chemparathy 			}
69899cabef0SPablo de Lara 			if (!strcmp(lgopts[opt_idx].name, "tx-first")) {
69999cabef0SPablo de Lara 				printf("Ports to start sending a burst of "
70099cabef0SPablo de Lara 						"packets first\n");
70199cabef0SPablo de Lara 				tx_first = 1;
70299cabef0SPablo de Lara 			}
703cfea1f30SPablo de Lara 			if (!strcmp(lgopts[opt_idx].name, "stats-period")) {
704cfea1f30SPablo de Lara 				char *end = NULL;
705cfea1f30SPablo de Lara 				unsigned int n;
706cfea1f30SPablo de Lara 
707cfea1f30SPablo de Lara 				n = strtoul(optarg, &end, 10);
708cfea1f30SPablo de Lara 				if ((optarg[0] == '\0') || (end == NULL) ||
709cfea1f30SPablo de Lara 						(*end != '\0'))
710cfea1f30SPablo de Lara 					break;
711cfea1f30SPablo de Lara 
712cfea1f30SPablo de Lara 				stats_period = n;
713cfea1f30SPablo de Lara 				break;
714cfea1f30SPablo de Lara 			}
715af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name,
716af75078fSIntel 				    "eth-peers-configfile")) {
717af75078fSIntel 				if (init_peer_eth_addrs(optarg) != 0)
718af75078fSIntel 					rte_exit(EXIT_FAILURE,
719af75078fSIntel 						 "Cannot open logfile\n");
720af75078fSIntel 			}
721af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
722af75078fSIntel 				char *port_end;
723af75078fSIntel 				uint8_t c, peer_addr[6];
724af75078fSIntel 
725af75078fSIntel 				errno = 0;
726af75078fSIntel 				n = strtoul(optarg, &port_end, 10);
727af75078fSIntel 				if (errno != 0 || port_end == optarg || *port_end++ != ',')
728af75078fSIntel 					rte_exit(EXIT_FAILURE,
729af75078fSIntel 						 "Invalid eth-peer: %s", optarg);
730af75078fSIntel 				if (n >= RTE_MAX_ETHPORTS)
731af75078fSIntel 					rte_exit(EXIT_FAILURE,
732af75078fSIntel 						 "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n",
733af75078fSIntel 						 n, RTE_MAX_ETHPORTS);
734af75078fSIntel 
735aaa662e7SAlan Carew 				if (cmdline_parse_etheraddr(NULL, port_end,
736aaa662e7SAlan Carew 						&peer_addr, sizeof(peer_addr)) < 0)
737af75078fSIntel 					rte_exit(EXIT_FAILURE,
738af75078fSIntel 						 "Invalid ethernet address: %s\n",
739af75078fSIntel 						 port_end);
740af75078fSIntel 				for (c = 0; c < 6; c++)
741af75078fSIntel 					peer_eth_addrs[n].addr_bytes[c] =
742af75078fSIntel 						peer_addr[c];
743af75078fSIntel 				nb_peer_eth_addrs++;
744af75078fSIntel 			}
7450d56cb81SThomas Monjalon #endif
746af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
747af75078fSIntel 				n = atoi(optarg);
7480a530f0dSYong Liu 				if (n > 0 && n <= nb_ports)
749f8244c63SZhiyong Yang 					nb_fwd_ports = n;
750af75078fSIntel 				else
751af75078fSIntel 					rte_exit(EXIT_FAILURE,
752edab33b1STetsuya Mukawa 						 "Invalid port %d\n", n);
753af75078fSIntel 			}
754af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "nb-cores")) {
755af75078fSIntel 				n = atoi(optarg);
756af75078fSIntel 				if (n > 0 && n <= nb_lcores)
757af75078fSIntel 					nb_fwd_lcores = (uint8_t) n;
758af75078fSIntel 				else
759af75078fSIntel 					rte_exit(EXIT_FAILURE,
760af75078fSIntel 						 "nb-cores should be > 0 and <= %d\n",
761af75078fSIntel 						 nb_lcores);
762af75078fSIntel 			}
763af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "coremask"))
764af75078fSIntel 				parse_fwd_coremask(optarg);
765af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "portmask"))
766af75078fSIntel 				parse_fwd_portmask(optarg);
767999b2ee0SBruce Richardson 			if (!strcmp(lgopts[opt_idx].name, "no-numa"))
768999b2ee0SBruce Richardson 				numa_support = 0;
769487f9a59SYulong Pei 			if (!strcmp(lgopts[opt_idx].name, "numa"))
770af75078fSIntel 				numa_support = 1;
771148f963fSBruce Richardson 			if (!strcmp(lgopts[opt_idx].name, "mp-anon")) {
772c7f5dba7SAnatoly Burakov 				mp_alloc_type = MP_ALLOC_ANON;
773c7f5dba7SAnatoly Burakov 			}
774c7f5dba7SAnatoly Burakov 			if (!strcmp(lgopts[opt_idx].name, "mp-alloc")) {
775c7f5dba7SAnatoly Burakov 				if (!strcmp(optarg, "native"))
776c7f5dba7SAnatoly Burakov 					mp_alloc_type = MP_ALLOC_NATIVE;
777c7f5dba7SAnatoly Burakov 				else if (!strcmp(optarg, "anon"))
778c7f5dba7SAnatoly Burakov 					mp_alloc_type = MP_ALLOC_ANON;
779c7f5dba7SAnatoly Burakov 				else if (!strcmp(optarg, "xmem"))
780c7f5dba7SAnatoly Burakov 					mp_alloc_type = MP_ALLOC_XMEM;
781c7f5dba7SAnatoly Burakov 				else if (!strcmp(optarg, "xmemhuge"))
782c7f5dba7SAnatoly Burakov 					mp_alloc_type = MP_ALLOC_XMEM_HUGE;
783c7f5dba7SAnatoly Burakov 				else
784c7f5dba7SAnatoly Burakov 					rte_exit(EXIT_FAILURE,
785c7f5dba7SAnatoly Burakov 						"mp-alloc %s invalid - must be: "
786c7f5dba7SAnatoly Burakov 						"native, anon, xmem or xmemhuge\n",
787c7f5dba7SAnatoly Burakov 						 optarg);
788148f963fSBruce Richardson 			}
789b6ea6408SIntel 			if (!strcmp(lgopts[opt_idx].name, "port-numa-config")) {
790b6ea6408SIntel 				if (parse_portnuma_config(optarg))
791b6ea6408SIntel 					rte_exit(EXIT_FAILURE,
792b6ea6408SIntel 					   "invalid port-numa configuration\n");
793b6ea6408SIntel 			}
794b6ea6408SIntel 			if (!strcmp(lgopts[opt_idx].name, "ring-numa-config"))
795b6ea6408SIntel 				if (parse_ringnuma_config(optarg))
796b6ea6408SIntel 					rte_exit(EXIT_FAILURE,
797b6ea6408SIntel 					   "invalid ring-numa configuration\n");
798b6ea6408SIntel 			if (!strcmp(lgopts[opt_idx].name, "socket-num")) {
799b6ea6408SIntel 				n = atoi(optarg);
800c9cafcc8SShahaf Shuler 				if (!new_socket_id((uint8_t)n)) {
801b6ea6408SIntel 					socket_num = (uint8_t)n;
802c9cafcc8SShahaf Shuler 				} else {
803c9cafcc8SShahaf Shuler 					print_invalid_socket_id_error();
804b6ea6408SIntel 					rte_exit(EXIT_FAILURE,
805c9cafcc8SShahaf Shuler 						"Invalid socket id");
806c9cafcc8SShahaf Shuler 				}
807b6ea6408SIntel 			}
808af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
809af75078fSIntel 				n = atoi(optarg);
810af75078fSIntel 				if (n > 0 && n <= 0xFFFF)
811af75078fSIntel 					mbuf_data_size = (uint16_t) n;
812af75078fSIntel 				else
813af75078fSIntel 					rte_exit(EXIT_FAILURE,
814af75078fSIntel 						 "mbuf-size should be > 0 and < 65536\n");
815af75078fSIntel 			}
816c8798818SIntel 			if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
817c8798818SIntel 				n = atoi(optarg);
818c8798818SIntel 				if (n > 1024)
819c8798818SIntel 					param_total_num_mbufs = (unsigned)n;
820c8798818SIntel 				else
821c8798818SIntel 					rte_exit(EXIT_FAILURE,
822c8798818SIntel 						 "total-num-mbufs should be > 1024\n");
823c8798818SIntel 			}
824af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
825af75078fSIntel 				n = atoi(optarg);
826af75078fSIntel 				if (n >= ETHER_MIN_LEN) {
827af75078fSIntel 					rx_mode.max_rx_pkt_len = (uint32_t) n;
828af75078fSIntel 					if (n > ETHER_MAX_LEN)
8290074d02fSShahaf Shuler 						rx_offloads |=
8300074d02fSShahaf Shuler 							DEV_RX_OFFLOAD_JUMBO_FRAME;
831af75078fSIntel 				} else
832af75078fSIntel 					rte_exit(EXIT_FAILURE,
833af75078fSIntel 						 "Invalid max-pkt-len=%d - should be > %d\n",
834af75078fSIntel 						 n, ETHER_MIN_LEN);
835af75078fSIntel 			}
836af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) {
837af75078fSIntel 				if (!strcmp(optarg, "signature"))
838af75078fSIntel 					fdir_conf.mode =
839af75078fSIntel 						RTE_FDIR_MODE_SIGNATURE;
840af75078fSIntel 				else if (!strcmp(optarg, "perfect"))
841af75078fSIntel 					fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
8429276b982SWenzhuo Lu 				else if (!strcmp(optarg, "perfect-mac-vlan"))
8439276b982SWenzhuo Lu 					fdir_conf.mode = RTE_FDIR_MODE_PERFECT_MAC_VLAN;
8449276b982SWenzhuo Lu 				else if (!strcmp(optarg, "perfect-tunnel"))
8459276b982SWenzhuo Lu 					fdir_conf.mode = RTE_FDIR_MODE_PERFECT_TUNNEL;
846af75078fSIntel 				else if (!strcmp(optarg, "none"))
847af75078fSIntel 					fdir_conf.mode = RTE_FDIR_MODE_NONE;
848af75078fSIntel 				else
849af75078fSIntel 					rte_exit(EXIT_FAILURE,
850af75078fSIntel 						 "pkt-mode-invalid %s invalid - must be: "
8519276b982SWenzhuo Lu 						 "none, signature, perfect, perfect-mac-vlan"
8529276b982SWenzhuo Lu 						 " or perfect-tunnel\n",
853af75078fSIntel 						 optarg);
854af75078fSIntel 			}
855af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name,
856af75078fSIntel 				    "pkt-filter-report-hash")) {
857af75078fSIntel 				if (!strcmp(optarg, "none"))
858af75078fSIntel 					fdir_conf.status =
859af75078fSIntel 						RTE_FDIR_NO_REPORT_STATUS;
860af75078fSIntel 				else if (!strcmp(optarg, "match"))
861af75078fSIntel 					fdir_conf.status =
862af75078fSIntel 						RTE_FDIR_REPORT_STATUS;
863af75078fSIntel 				else if (!strcmp(optarg, "always"))
864af75078fSIntel 					fdir_conf.status =
865af75078fSIntel 						RTE_FDIR_REPORT_STATUS_ALWAYS;
866af75078fSIntel 				else
867af75078fSIntel 					rte_exit(EXIT_FAILURE,
868af75078fSIntel 						 "pkt-filter-report-hash %s invalid "
869af75078fSIntel 						 "- must be: none or match or always\n",
870af75078fSIntel 						 optarg);
871af75078fSIntel 			}
872af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) {
873af75078fSIntel 				if (!strcmp(optarg, "64K"))
874af75078fSIntel 					fdir_conf.pballoc =
875af75078fSIntel 						RTE_FDIR_PBALLOC_64K;
876af75078fSIntel 				else if (!strcmp(optarg, "128K"))
877af75078fSIntel 					fdir_conf.pballoc =
878af75078fSIntel 						RTE_FDIR_PBALLOC_128K;
879af75078fSIntel 				else if (!strcmp(optarg, "256K"))
880af75078fSIntel 					fdir_conf.pballoc =
881af75078fSIntel 						RTE_FDIR_PBALLOC_256K;
882af75078fSIntel 				else
883af75078fSIntel 					rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -"
884af75078fSIntel 						 " must be: 64K or 128K or 256K\n",
885af75078fSIntel 						 optarg);
886af75078fSIntel 			}
887af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name,
888af75078fSIntel 				    "pkt-filter-drop-queue")) {
889af75078fSIntel 				n = atoi(optarg);
890af75078fSIntel 				if (n >= 0)
891af75078fSIntel 					fdir_conf.drop_queue = (uint8_t) n;
892af75078fSIntel 				else
893af75078fSIntel 					rte_exit(EXIT_FAILURE,
894af75078fSIntel 						 "drop queue %d invalid - must"
895af75078fSIntel 						 "be >= 0 \n", n);
896af75078fSIntel 			}
89762d3216dSReshma Pattan #ifdef RTE_LIBRTE_LATENCY_STATS
89862d3216dSReshma Pattan 			if (!strcmp(lgopts[opt_idx].name,
89962d3216dSReshma Pattan 				    "latencystats")) {
90062d3216dSReshma Pattan 				n = atoi(optarg);
90162d3216dSReshma Pattan 				if (n >= 0) {
90262d3216dSReshma Pattan 					latencystats_lcore_id = (lcoreid_t) n;
90362d3216dSReshma Pattan 					latencystats_enabled = 1;
90462d3216dSReshma Pattan 				} else
90562d3216dSReshma Pattan 					rte_exit(EXIT_FAILURE,
90662d3216dSReshma Pattan 						 "invalid lcore id %d for latencystats"
90762d3216dSReshma Pattan 						 " must be >= 0\n", n);
90862d3216dSReshma Pattan 			}
90962d3216dSReshma Pattan #endif
910e25e6c70SRemy Horton #ifdef RTE_LIBRTE_BITRATE
911e25e6c70SRemy Horton 			if (!strcmp(lgopts[opt_idx].name, "bitrate-stats")) {
912e25e6c70SRemy Horton 				n = atoi(optarg);
913e25e6c70SRemy Horton 				if (n >= 0) {
914e25e6c70SRemy Horton 					bitrate_lcore_id = (lcoreid_t) n;
915e25e6c70SRemy Horton 					bitrate_enabled = 1;
916e25e6c70SRemy Horton 				} else
917e25e6c70SRemy Horton 					rte_exit(EXIT_FAILURE,
918e25e6c70SRemy Horton 						 "invalid lcore id %d for bitrate stats"
919e25e6c70SRemy Horton 						 " must be >= 0\n", n);
920e25e6c70SRemy Horton 			}
921e25e6c70SRemy Horton #endif
922323e7b66SFerruh Yigit 			if (!strcmp(lgopts[opt_idx].name, "disable-crc-strip"))
923e557ebc0SFerruh Yigit 				rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
9244c3ea508SOlivier Matz 			if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
9250074d02fSShahaf Shuler 				rx_offloads |= DEV_RX_OFFLOAD_TCP_LRO;
92604997938SMaciej Czekaj 			if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
9270074d02fSShahaf Shuler 				rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
928af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
9290074d02fSShahaf Shuler 				rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
930912267a3SRaslan Darawsheh 			if (!strcmp(lgopts[opt_idx].name,
931912267a3SRaslan Darawsheh 					"enable-rx-timestamp"))
9320074d02fSShahaf Shuler 				rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
9338b9bd0efSMoti Haimovsky 			if (!strcmp(lgopts[opt_idx].name, "enable-hw-vlan"))
9348b9bd0efSMoti Haimovsky 				rx_offloads |= DEV_RX_OFFLOAD_VLAN;
935a47aa8b9SIntel 
936c9dd4aadSOuyang Changchun 			if (!strcmp(lgopts[opt_idx].name,
9378b9bd0efSMoti Haimovsky 					"enable-hw-vlan-filter"))
9388b9bd0efSMoti Haimovsky 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
939c9dd4aadSOuyang Changchun 
940c9dd4aadSOuyang Changchun 			if (!strcmp(lgopts[opt_idx].name,
9418b9bd0efSMoti Haimovsky 					"enable-hw-vlan-strip"))
9428b9bd0efSMoti Haimovsky 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
943c9dd4aadSOuyang Changchun 
944c9dd4aadSOuyang Changchun 			if (!strcmp(lgopts[opt_idx].name,
9458b9bd0efSMoti Haimovsky 					"enable-hw-vlan-extend"))
9468b9bd0efSMoti Haimovsky 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
947c9dd4aadSOuyang Changchun 
948ce8d5614SIntel 			if (!strcmp(lgopts[opt_idx].name, "enable-drop-en"))
949ce8d5614SIntel 				rx_drop_en = 1;
950ce8d5614SIntel 
951af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "disable-rss"))
952af75078fSIntel 				rss_hf = 0;
953af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "port-topology")) {
954af75078fSIntel 				if (!strcmp(optarg, "paired"))
955af75078fSIntel 					port_topology = PORT_TOPOLOGY_PAIRED;
956af75078fSIntel 				else if (!strcmp(optarg, "chained"))
957af75078fSIntel 					port_topology = PORT_TOPOLOGY_CHAINED;
9583e2006d6SCyril Chemparathy 				else if (!strcmp(optarg, "loop"))
9593e2006d6SCyril Chemparathy 					port_topology = PORT_TOPOLOGY_LOOP;
960af75078fSIntel 				else
961af75078fSIntel 					rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
96275358833SPablo de Lara 						 " must be: paired, chained or loop\n",
963af75078fSIntel 						 optarg);
964af75078fSIntel 			}
965ce9b9fb0SCyril Chemparathy 			if (!strcmp(lgopts[opt_idx].name, "forward-mode"))
966ce9b9fb0SCyril Chemparathy 				set_pkt_forwarding_mode(optarg);
967af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rss-ip"))
9688a387fa8SHelin Zhang 				rss_hf = ETH_RSS_IP;
969af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rss-udp"))
9708a387fa8SHelin Zhang 				rss_hf = ETH_RSS_UDP;
971af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxq")) {
972af75078fSIntel 				n = atoi(optarg);
9733f7311baSWei Dai 				if (n >= 0 && check_nb_rxq((queueid_t)n) == 0)
974af75078fSIntel 					nb_rxq = (queueid_t) n;
975af75078fSIntel 				else
976af75078fSIntel 					rte_exit(EXIT_FAILURE, "rxq %d invalid - must be"
9773f7311baSWei Dai 						  " >= 0 && <= %u\n", n,
9783f7311baSWei Dai 						  get_allowed_max_nb_rxq(&pid));
979af75078fSIntel 			}
980af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txq")) {
981af75078fSIntel 				n = atoi(optarg);
98236db4f6cSWei Dai 				if (n >= 0 && check_nb_txq((queueid_t)n) == 0)
983af75078fSIntel 					nb_txq = (queueid_t) n;
984af75078fSIntel 				else
985af75078fSIntel 					rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
98636db4f6cSWei Dai 						  " >= 0 && <= %u\n", n,
98736db4f6cSWei Dai 						  get_allowed_max_nb_txq(&pid));
988af75078fSIntel 			}
9895a8fb55cSReshma Pattan 			if (!nb_rxq && !nb_txq) {
9905a8fb55cSReshma Pattan 				rte_exit(EXIT_FAILURE, "Either rx or tx queues should "
9915a8fb55cSReshma Pattan 						"be non-zero\n");
9925a8fb55cSReshma Pattan 			}
993af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "burst")) {
994af75078fSIntel 				n = atoi(optarg);
9958599ed31SRemy Horton 				if (n == 0) {
9968599ed31SRemy Horton 					/* A burst size of zero means that the
9978599ed31SRemy Horton 					 * PMD should be queried for
9988599ed31SRemy Horton 					 * recommended Rx burst size. Since
9998599ed31SRemy Horton 					 * testpmd uses a single size for all
10008599ed31SRemy Horton 					 * ports, port 0 is queried for the
10018599ed31SRemy Horton 					 * value, on the assumption that all
10028599ed31SRemy Horton 					 * ports are of the same NIC model.
10038599ed31SRemy Horton 					 */
10048599ed31SRemy Horton 					rte_eth_dev_info_get(0, &dev_info);
10058599ed31SRemy Horton 					rec_nb_pkts = dev_info
10068599ed31SRemy Horton 						.default_rxportconf.burst_size;
10078599ed31SRemy Horton 
10088599ed31SRemy Horton 					if (rec_nb_pkts == 0)
1009af75078fSIntel 						rte_exit(EXIT_FAILURE,
10108599ed31SRemy Horton 							"PMD does not recommend a burst size. "
10118599ed31SRemy Horton 							"Provided value must be between "
10128599ed31SRemy Horton 							"1 and %d\n", MAX_PKT_BURST);
10138599ed31SRemy Horton 					else if (rec_nb_pkts > MAX_PKT_BURST)
10148599ed31SRemy Horton 						rte_exit(EXIT_FAILURE,
10158599ed31SRemy Horton 							"PMD recommended burst size of %d"
10168599ed31SRemy Horton 							" exceeds maximum value of %d\n",
10178599ed31SRemy Horton 							rec_nb_pkts, MAX_PKT_BURST);
10188599ed31SRemy Horton 					printf("Using PMD-provided burst value of %d\n",
10198599ed31SRemy Horton 						rec_nb_pkts);
10208599ed31SRemy Horton 					nb_pkt_per_burst = rec_nb_pkts;
10218599ed31SRemy Horton 				} else if (n > MAX_PKT_BURST)
10228599ed31SRemy Horton 					rte_exit(EXIT_FAILURE,
10238599ed31SRemy Horton 						"burst must be between1 and %d\n",
1024af75078fSIntel 						MAX_PKT_BURST);
10258599ed31SRemy Horton 				else
10268599ed31SRemy Horton 					nb_pkt_per_burst = (uint16_t) n;
1027af75078fSIntel 			}
1028af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "mbcache")) {
1029af75078fSIntel 				n = atoi(optarg);
1030af75078fSIntel 				if ((n >= 0) &&
1031af75078fSIntel 				    (n <= RTE_MEMPOOL_CACHE_MAX_SIZE))
1032af75078fSIntel 					mb_mempool_cache = (uint16_t) n;
1033af75078fSIntel 				else
1034af75078fSIntel 					rte_exit(EXIT_FAILURE,
1035af75078fSIntel 						 "mbcache must be >= 0 and <= %d\n",
1036af75078fSIntel 						 RTE_MEMPOOL_CACHE_MAX_SIZE);
1037af75078fSIntel 			}
1038af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txfreet")) {
1039af75078fSIntel 				n = atoi(optarg);
1040af75078fSIntel 				if (n >= 0)
1041f2c5125aSPablo de Lara 					tx_free_thresh = (int16_t)n;
1042af75078fSIntel 				else
1043af75078fSIntel 					rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n");
1044af75078fSIntel 			}
1045af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txrst")) {
1046af75078fSIntel 				n = atoi(optarg);
1047af75078fSIntel 				if (n >= 0)
1048f2c5125aSPablo de Lara 					tx_rs_thresh = (int16_t)n;
1049af75078fSIntel 				else
1050af75078fSIntel 					rte_exit(EXIT_FAILURE, "txrst must be >= 0\n");
1051af75078fSIntel 			}
1052af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxd")) {
1053af75078fSIntel 				n = atoi(optarg);
1054af75078fSIntel 				if (n > 0) {
1055af75078fSIntel 					if (rx_free_thresh >= n)
1056af75078fSIntel 						rte_exit(EXIT_FAILURE,
1057af75078fSIntel 							 "rxd must be > "
1058af75078fSIntel 							 "rx_free_thresh(%d)\n",
1059af75078fSIntel 							 (int)rx_free_thresh);
1060af75078fSIntel 					else
1061af75078fSIntel 						nb_rxd = (uint16_t) n;
1062af75078fSIntel 				} else
1063af75078fSIntel 					rte_exit(EXIT_FAILURE,
1064af75078fSIntel 						 "rxd(%d) invalid - must be > 0\n",
1065af75078fSIntel 						 n);
1066af75078fSIntel 			}
1067af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txd")) {
1068af75078fSIntel 				n = atoi(optarg);
1069af75078fSIntel 				if (n > 0)
1070af75078fSIntel 					nb_txd = (uint16_t) n;
1071af75078fSIntel 				else
1072af75078fSIntel 					rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
1073af75078fSIntel 			}
1074af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txpt")) {
1075af75078fSIntel 				n = atoi(optarg);
1076af75078fSIntel 				if (n >= 0)
1077f2c5125aSPablo de Lara 					tx_pthresh = (int8_t)n;
1078af75078fSIntel 				else
1079af75078fSIntel 					rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
1080af75078fSIntel 			}
1081af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txht")) {
1082af75078fSIntel 				n = atoi(optarg);
1083af75078fSIntel 				if (n >= 0)
1084f2c5125aSPablo de Lara 					tx_hthresh = (int8_t)n;
1085af75078fSIntel 				else
1086af75078fSIntel 					rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
1087af75078fSIntel 			}
1088af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "txwt")) {
1089af75078fSIntel 				n = atoi(optarg);
1090af75078fSIntel 				if (n >= 0)
1091f2c5125aSPablo de Lara 					tx_wthresh = (int8_t)n;
1092af75078fSIntel 				else
1093af75078fSIntel 					rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
1094af75078fSIntel 			}
1095af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxpt")) {
1096af75078fSIntel 				n = atoi(optarg);
1097af75078fSIntel 				if (n >= 0)
1098f2c5125aSPablo de Lara 					rx_pthresh = (int8_t)n;
1099af75078fSIntel 				else
1100af75078fSIntel 					rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
1101af75078fSIntel 			}
1102af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxht")) {
1103af75078fSIntel 				n = atoi(optarg);
1104af75078fSIntel 				if (n >= 0)
1105f2c5125aSPablo de Lara 					rx_hthresh = (int8_t)n;
1106af75078fSIntel 				else
1107af75078fSIntel 					rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
1108af75078fSIntel 			}
1109af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxwt")) {
1110af75078fSIntel 				n = atoi(optarg);
1111af75078fSIntel 				if (n >= 0)
1112f2c5125aSPablo de Lara 					rx_wthresh = (int8_t)n;
1113af75078fSIntel 				else
1114af75078fSIntel 					rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
1115af75078fSIntel 			}
1116af75078fSIntel 			if (!strcmp(lgopts[opt_idx].name, "rxfreet")) {
1117af75078fSIntel 				n = atoi(optarg);
1118af75078fSIntel 				if (n >= 0)
1119f2c5125aSPablo de Lara 					rx_free_thresh = (int16_t)n;
1120af75078fSIntel 				else
1121af75078fSIntel 					rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n");
1122af75078fSIntel 			}
1123ed30d9b6SIntel 			if (!strcmp(lgopts[opt_idx].name, "tx-queue-stats-mapping")) {
1124ed30d9b6SIntel 				if (parse_queue_stats_mapping_config(optarg, TX)) {
1125ed30d9b6SIntel 					rte_exit(EXIT_FAILURE,
1126ed30d9b6SIntel 						 "invalid TX queue statistics mapping config entered\n");
1127ed30d9b6SIntel 				}
1128ed30d9b6SIntel 			}
1129ed30d9b6SIntel 			if (!strcmp(lgopts[opt_idx].name, "rx-queue-stats-mapping")) {
1130ed30d9b6SIntel 				if (parse_queue_stats_mapping_config(optarg, RX)) {
1131ed30d9b6SIntel 					rte_exit(EXIT_FAILURE,
1132ed30d9b6SIntel 						 "invalid RX queue statistics mapping config entered\n");
1133ed30d9b6SIntel 				}
1134ed30d9b6SIntel 			}
1135a7e7bb4eSCyril Chemparathy 			if (!strcmp(lgopts[opt_idx].name, "txpkts")) {
1136a7e7bb4eSCyril Chemparathy 				unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1137a7e7bb4eSCyril Chemparathy 				unsigned int nb_segs;
1138a7e7bb4eSCyril Chemparathy 
1139950d1516SBruce Richardson 				nb_segs = parse_item_list(optarg, "txpkt segments",
1140950d1516SBruce Richardson 						RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1141a7e7bb4eSCyril Chemparathy 				if (nb_segs > 0)
1142a7e7bb4eSCyril Chemparathy 					set_tx_pkt_segments(seg_lengths, nb_segs);
1143a7e7bb4eSCyril Chemparathy 				else
1144a7e7bb4eSCyril Chemparathy 					rte_exit(EXIT_FAILURE, "bad txpkts\n");
1145a7e7bb4eSCyril Chemparathy 			}
1146*82010ef5SYongseok Koh 			if (!strcmp(lgopts[opt_idx].name, "txonly-multi-flow"))
1147*82010ef5SYongseok Koh 				txonly_multi_flow = 1;
11487741e4cfSIntel 			if (!strcmp(lgopts[opt_idx].name, "no-flush-rx"))
11497741e4cfSIntel 				no_flush_rx = 1;
1150bc202406SDavid Marchand 			if (!strcmp(lgopts[opt_idx].name, "disable-link-check"))
1151bc202406SDavid Marchand 				no_link_check = 1;
11528ea656f8SGaetan Rivet 			if (!strcmp(lgopts[opt_idx].name, "no-lsc-interrupt"))
11538ea656f8SGaetan Rivet 				lsc_interrupt = 0;
1154284c908cSGaetan Rivet 			if (!strcmp(lgopts[opt_idx].name, "no-rmv-interrupt"))
1155284c908cSGaetan Rivet 				rmv_interrupt = 0;
11567ee3e944SVasily Philipov 			if (!strcmp(lgopts[opt_idx].name, "flow-isolate-all"))
11577ee3e944SVasily Philipov 				flow_isolate_all = 1;
1158fd8c20aaSShahaf Shuler 			if (!strcmp(lgopts[opt_idx].name, "tx-offloads")) {
1159fd8c20aaSShahaf Shuler 				char *end = NULL;
1160fd8c20aaSShahaf Shuler 				n = strtoull(optarg, &end, 16);
1161fd8c20aaSShahaf Shuler 				if (n >= 0)
1162fd8c20aaSShahaf Shuler 					tx_offloads = (uint64_t)n;
1163fd8c20aaSShahaf Shuler 				else
1164fd8c20aaSShahaf Shuler 					rte_exit(EXIT_FAILURE,
1165fd8c20aaSShahaf Shuler 						 "tx-offloads must be >= 0\n");
1166fd8c20aaSShahaf Shuler 			}
116739e5e20fSXueming Li 			if (!strcmp(lgopts[opt_idx].name, "vxlan-gpe-port")) {
116839e5e20fSXueming Li 				n = atoi(optarg);
116939e5e20fSXueming Li 				if (n >= 0)
117039e5e20fSXueming Li 					vxlan_gpe_udp_port = (uint16_t)n;
117139e5e20fSXueming Li 				else
117239e5e20fSXueming Li 					rte_exit(EXIT_FAILURE,
117339e5e20fSXueming Li 						 "vxlan-gpe-port must be >= 0\n");
117439e5e20fSXueming Li 			}
11753af72783SGaetan Rivet 			if (!strcmp(lgopts[opt_idx].name, "print-event"))
11763af72783SGaetan Rivet 				if (parse_event_printing_config(optarg, 1)) {
11773af72783SGaetan Rivet 					rte_exit(EXIT_FAILURE,
11783af72783SGaetan Rivet 						 "invalid print-event argument\n");
11793af72783SGaetan Rivet 				}
11803af72783SGaetan Rivet 			if (!strcmp(lgopts[opt_idx].name, "mask-event"))
11813af72783SGaetan Rivet 				if (parse_event_printing_config(optarg, 0)) {
11823af72783SGaetan Rivet 					rte_exit(EXIT_FAILURE,
11833af72783SGaetan Rivet 						 "invalid mask-event argument\n");
11843af72783SGaetan Rivet 				}
1185fb73e096SJeff Guo 			if (!strcmp(lgopts[opt_idx].name, "hot-plug"))
1186fb73e096SJeff Guo 				hot_plug = 1;
1187e505d84cSAnatoly Burakov 			if (!strcmp(lgopts[opt_idx].name, "mlockall"))
1188e505d84cSAnatoly Burakov 				do_mlockall = 1;
1189e505d84cSAnatoly Burakov 			if (!strcmp(lgopts[opt_idx].name, "no-mlockall"))
1190e505d84cSAnatoly Burakov 				do_mlockall = 0;
11913c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
11923c156061SJens Freimann 				    "noisy-tx-sw-buffer-size")) {
11933c156061SJens Freimann 				n = atoi(optarg);
11943c156061SJens Freimann 				if (n >= 0)
11953c156061SJens Freimann 					noisy_tx_sw_bufsz = n;
11963c156061SJens Freimann 				else
11973c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
11983c156061SJens Freimann 						"noisy-tx-sw-buffer-size must be >= 0\n");
11993c156061SJens Freimann 			}
12003c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
12013c156061SJens Freimann 				    "noisy-tx-sw-buffer-flushtime")) {
12023c156061SJens Freimann 				n = atoi(optarg);
12033c156061SJens Freimann 				if (n >= 0)
12043c156061SJens Freimann 					noisy_tx_sw_buf_flush_time = n;
12053c156061SJens Freimann 				else
12063c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
12073c156061SJens Freimann 						 "noisy-tx-sw-buffer-flushtime must be >= 0\n");
12083c156061SJens Freimann 			}
12093c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
12103c156061SJens Freimann 				    "noisy-lkup-memory")) {
12113c156061SJens Freimann 				n = atoi(optarg);
12123c156061SJens Freimann 				if (n >= 0)
12133c156061SJens Freimann 					noisy_lkup_mem_sz = n;
12143c156061SJens Freimann 				else
12153c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
12163c156061SJens Freimann 						 "noisy-lkup-memory must be >= 0\n");
12173c156061SJens Freimann 			}
12183c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
12193c156061SJens Freimann 				    "noisy-lkup-num-writes")) {
12203c156061SJens Freimann 				n = atoi(optarg);
12213c156061SJens Freimann 				if (n >= 0)
12223c156061SJens Freimann 					noisy_lkup_num_writes = n;
12233c156061SJens Freimann 				else
12243c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
12253c156061SJens Freimann 						 "noisy-lkup-num-writes must be >= 0\n");
12263c156061SJens Freimann 			}
12273c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
12283c156061SJens Freimann 				    "noisy-lkup-num-reads")) {
12293c156061SJens Freimann 				n = atoi(optarg);
12303c156061SJens Freimann 				if (n >= 0)
12313c156061SJens Freimann 					noisy_lkup_num_reads = n;
12323c156061SJens Freimann 				else
12333c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
12343c156061SJens Freimann 						 "noisy-lkup-num-reads must be >= 0\n");
12353c156061SJens Freimann 			}
12363c156061SJens Freimann 			if (!strcmp(lgopts[opt_idx].name,
12373c156061SJens Freimann 				    "noisy-lkup-num-reads-writes")) {
12383c156061SJens Freimann 				n = atoi(optarg);
12393c156061SJens Freimann 				if (n >= 0)
12403c156061SJens Freimann 					noisy_lkup_num_reads_writes = n;
12413c156061SJens Freimann 				else
12423c156061SJens Freimann 					rte_exit(EXIT_FAILURE,
12433c156061SJens Freimann 						 "noisy-lkup-num-reads-writes must be >= 0\n");
12443c156061SJens Freimann 			}
1245af75078fSIntel 			break;
1246af75078fSIntel 		case 'h':
1247af75078fSIntel 			usage(argv[0]);
1248af75078fSIntel 			rte_exit(EXIT_SUCCESS, "Displayed help\n");
1249af75078fSIntel 			break;
1250af75078fSIntel 		default:
1251af75078fSIntel 			usage(argv[0]);
1252af75078fSIntel 			rte_exit(EXIT_FAILURE,
1253af75078fSIntel 				 "Command line is incomplete or incorrect\n");
1254af75078fSIntel 			break;
1255af75078fSIntel 		}
1256af75078fSIntel 	}
12570074d02fSShahaf Shuler 
12580074d02fSShahaf Shuler 	/* Set offload configuration from command line parameters. */
12590074d02fSShahaf Shuler 	rx_mode.offloads = rx_offloads;
1260fd8c20aaSShahaf Shuler 	tx_mode.offloads = tx_offloads;
1261af75078fSIntel }
1262