xref: /dpdk/app/test-pmd/parameters.c (revision 5334c3feb137ca4eeb4c0f150aae602016b6a5ea)
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_branch_prediction.h>
34af75078fSIntel #include <rte_mempool.h>
35af75078fSIntel #include <rte_interrupts.h>
36af75078fSIntel #include <rte_ether.h>
37af75078fSIntel #include <rte_ethdev.h>
38af75078fSIntel #include <rte_string_fns.h>
39938a184aSAdrien Mazarguil #include <rte_flow.h>
40af75078fSIntel 
41af75078fSIntel #include "testpmd.h"
42af75078fSIntel 
4390c26386SDavid Marchand enum {
4490c26386SDavid Marchand #define TESTPMD_OPT_AUTO_START "auto-start"
4590c26386SDavid Marchand 	TESTPMD_OPT_AUTO_START_NUM = 'a',
4690c26386SDavid Marchand #define TESTPMD_OPT_HELP "help"
4790c26386SDavid Marchand 	TESTPMD_OPT_HELP_NUM = 'h',
4890c26386SDavid Marchand #define TESTPMD_OPT_INTERACTIVE "interactive"
4990c26386SDavid Marchand 	TESTPMD_OPT_INTERACTIVE_NUM = 'i',
5090c26386SDavid Marchand 
5190c26386SDavid Marchand 	TESTPMD_OPT_LONG_MIN_NUM = 256,
5290c26386SDavid Marchand #define TESTPMD_OPT_CMDLINE_FILE "cmdline-file"
5390c26386SDavid Marchand 	TESTPMD_OPT_CMDLINE_FILE_NUM,
5490c26386SDavid Marchand #define TESTPMD_OPT_ETH_PEERS_CONFIGFILE "eth-peers-configfile"
5590c26386SDavid Marchand 	TESTPMD_OPT_ETH_PEERS_CONFIGFILE_NUM,
5690c26386SDavid Marchand #define TESTPMD_OPT_ETH_PEER "eth-peer"
5790c26386SDavid Marchand 	TESTPMD_OPT_ETH_PEER_NUM,
5890c26386SDavid Marchand #define TESTPMD_OPT_TX_FIRST "tx-first"
5990c26386SDavid Marchand 	TESTPMD_OPT_TX_FIRST_NUM,
6090c26386SDavid Marchand #define TESTPMD_OPT_STATS_PERIOD "stats-period"
6190c26386SDavid Marchand 	TESTPMD_OPT_STATS_PERIOD_NUM,
6290c26386SDavid Marchand #define TESTPMD_OPT_DISPLAY_XSTATS "display-xstats"
6390c26386SDavid Marchand 	TESTPMD_OPT_DISPLAY_XSTATS_NUM,
6490c26386SDavid Marchand #define TESTPMD_OPT_NB_CORES "nb-cores"
6590c26386SDavid Marchand 	TESTPMD_OPT_NB_CORES_NUM,
6690c26386SDavid Marchand #define TESTPMD_OPT_NB_PORTS "nb-ports"
6790c26386SDavid Marchand 	TESTPMD_OPT_NB_PORTS_NUM,
6890c26386SDavid Marchand #define TESTPMD_OPT_COREMASK "coremask"
6990c26386SDavid Marchand 	TESTPMD_OPT_COREMASK_NUM,
7090c26386SDavid Marchand #define TESTPMD_OPT_PORTMASK "portmask"
7190c26386SDavid Marchand 	TESTPMD_OPT_PORTMASK_NUM,
7290c26386SDavid Marchand #define TESTPMD_OPT_PORTLIST "portlist"
7390c26386SDavid Marchand 	TESTPMD_OPT_PORTLIST_NUM,
7490c26386SDavid Marchand #define TESTPMD_OPT_NUMA "numa"
7590c26386SDavid Marchand 	TESTPMD_OPT_NUMA_NUM,
7690c26386SDavid Marchand #define TESTPMD_OPT_NO_NUMA "no-numa"
7790c26386SDavid Marchand 	TESTPMD_OPT_NO_NUMA_NUM,
7890c26386SDavid Marchand #define TESTPMD_OPT_MP_ANON "mp-anon"
7990c26386SDavid Marchand 	TESTPMD_OPT_MP_ANON_NUM,
8090c26386SDavid Marchand #define TESTPMD_OPT_PORT_NUMA_CONFIG "port-numa-config"
8190c26386SDavid Marchand 	TESTPMD_OPT_PORT_NUMA_CONFIG_NUM,
8290c26386SDavid Marchand #define TESTPMD_OPT_RING_NUMA_CONFIG "ring-numa-config"
8390c26386SDavid Marchand 	TESTPMD_OPT_RING_NUMA_CONFIG_NUM,
8490c26386SDavid Marchand #define TESTPMD_OPT_SOCKET_NUM "socket-num"
8590c26386SDavid Marchand 	TESTPMD_OPT_SOCKET_NUM_NUM,
8690c26386SDavid Marchand #define TESTPMD_OPT_MBUF_SIZE "mbuf-size"
8790c26386SDavid Marchand 	TESTPMD_OPT_MBUF_SIZE_NUM,
8890c26386SDavid Marchand #define TESTPMD_OPT_TOTAL_NUM_MBUFS "total-num-mbufs"
8990c26386SDavid Marchand 	TESTPMD_OPT_TOTAL_NUM_MBUFS_NUM,
9090c26386SDavid Marchand #define TESTPMD_OPT_MAX_PKT_LEN "max-pkt-len"
9190c26386SDavid Marchand 	TESTPMD_OPT_MAX_PKT_LEN_NUM,
9290c26386SDavid Marchand #define TESTPMD_OPT_MAX_LRO_PKT_SIZE "max-lro-pkt-size"
9390c26386SDavid Marchand 	TESTPMD_OPT_MAX_LRO_PKT_SIZE_NUM,
9490c26386SDavid Marchand #define TESTPMD_OPT_LATENCYSTATS "latencystats"
9590c26386SDavid Marchand 	TESTPMD_OPT_LATENCYSTATS_NUM,
9690c26386SDavid Marchand #define TESTPMD_OPT_BITRATE_STATS "bitrate-stats"
9790c26386SDavid Marchand 	TESTPMD_OPT_BITRATE_STATS_NUM,
9890c26386SDavid Marchand #define TESTPMD_OPT_DISABLE_CRC_STRIP "disable-crc-strip"
9990c26386SDavid Marchand 	TESTPMD_OPT_DISABLE_CRC_STRIP_NUM,
10090c26386SDavid Marchand #define TESTPMD_OPT_ENABLE_LRO "enable-lro"
10190c26386SDavid Marchand 	TESTPMD_OPT_ENABLE_LRO_NUM,
10290c26386SDavid Marchand #define TESTPMD_OPT_ENABLE_RX_CKSUM "enable-rx-cksum"
10390c26386SDavid Marchand 	TESTPMD_OPT_ENABLE_RX_CKSUM_NUM,
10490c26386SDavid Marchand #define TESTPMD_OPT_ENABLE_RX_TIMESTAMP "enable-rx-timestamp"
10590c26386SDavid Marchand 	TESTPMD_OPT_ENABLE_RX_TIMESTAMP_NUM,
10690c26386SDavid Marchand #define TESTPMD_OPT_ENABLE_SCATTER "enable-scatter"
10790c26386SDavid Marchand 	TESTPMD_OPT_ENABLE_SCATTER_NUM,
10890c26386SDavid Marchand #define TESTPMD_OPT_ENABLE_HW_VLAN "enable-hw-vlan"
10990c26386SDavid Marchand 	TESTPMD_OPT_ENABLE_HW_VLAN_NUM,
11090c26386SDavid Marchand #define TESTPMD_OPT_ENABLE_HW_VLAN_FILTER "enable-hw-vlan-filter"
11190c26386SDavid Marchand 	TESTPMD_OPT_ENABLE_HW_VLAN_FILTER_NUM,
11290c26386SDavid Marchand #define TESTPMD_OPT_ENABLE_HW_VLAN_STRIP "enable-hw-vlan-strip"
11390c26386SDavid Marchand 	TESTPMD_OPT_ENABLE_HW_VLAN_STRIP_NUM,
11490c26386SDavid Marchand #define TESTPMD_OPT_ENABLE_HW_VLAN_EXTEND "enable-hw-vlan-extend"
11590c26386SDavid Marchand 	TESTPMD_OPT_ENABLE_HW_VLAN_EXTEND_NUM,
11690c26386SDavid Marchand #define TESTPMD_OPT_ENABLE_HW_QINQ_STRIP "enable-hw-qinq-strip"
11790c26386SDavid Marchand 	TESTPMD_OPT_ENABLE_HW_QINQ_STRIP_NUM,
11890c26386SDavid Marchand #define TESTPMD_OPT_ENABLE_DROP_EN "enable-drop-en"
11990c26386SDavid Marchand 	TESTPMD_OPT_ENABLE_DROP_EN_NUM,
12090c26386SDavid Marchand #define TESTPMD_OPT_DISABLE_RSS "disable-rss"
12190c26386SDavid Marchand 	TESTPMD_OPT_DISABLE_RSS_NUM,
12290c26386SDavid Marchand #define TESTPMD_OPT_PORT_TOPOLOGY "port-topology"
12390c26386SDavid Marchand 	TESTPMD_OPT_PORT_TOPOLOGY_NUM,
12490c26386SDavid Marchand #define TESTPMD_OPT_FORWARD_MODE "forward-mode"
12590c26386SDavid Marchand 	TESTPMD_OPT_FORWARD_MODE_NUM,
12690c26386SDavid Marchand #define TESTPMD_OPT_RSS_IP "rss-ip"
12790c26386SDavid Marchand 	TESTPMD_OPT_RSS_IP_NUM,
12890c26386SDavid Marchand #define TESTPMD_OPT_RSS_UDP "rss-udp"
12990c26386SDavid Marchand 	TESTPMD_OPT_RSS_UDP_NUM,
13090c26386SDavid Marchand #define TESTPMD_OPT_RSS_LEVEL_OUTER "rss-level-outer"
13190c26386SDavid Marchand 	TESTPMD_OPT_RSS_LEVEL_OUTER_NUM,
13290c26386SDavid Marchand #define TESTPMD_OPT_RSS_LEVEL_INNER "rss-level-inner"
13390c26386SDavid Marchand 	TESTPMD_OPT_RSS_LEVEL_INNER_NUM,
13490c26386SDavid Marchand #define TESTPMD_OPT_RXQ "rxq"
13590c26386SDavid Marchand 	TESTPMD_OPT_RXQ_NUM,
13690c26386SDavid Marchand #define TESTPMD_OPT_TXQ "txq"
13790c26386SDavid Marchand 	TESTPMD_OPT_TXQ_NUM,
13890c26386SDavid Marchand #define TESTPMD_OPT_RXD "rxd"
13990c26386SDavid Marchand 	TESTPMD_OPT_RXD_NUM,
14090c26386SDavid Marchand #define TESTPMD_OPT_TXD "txd"
14190c26386SDavid Marchand 	TESTPMD_OPT_TXD_NUM,
14290c26386SDavid Marchand #define TESTPMD_OPT_HAIRPINQ "hairpinq"
14390c26386SDavid Marchand 	TESTPMD_OPT_HAIRPINQ_NUM,
14490c26386SDavid Marchand #define TESTPMD_OPT_HAIRPIN_MODE "hairpin-mode"
14590c26386SDavid Marchand 	TESTPMD_OPT_HAIRPIN_MODE_NUM,
146*5334c3feSGregory Etelson #define TESTPMD_OPT_HAIRPIN_MAP "hairpin-map"
147*5334c3feSGregory Etelson 	TESTPMD_OPT_HAIRPIN_MAP_NUM,
14890c26386SDavid Marchand #define TESTPMD_OPT_BURST "burst"
14990c26386SDavid Marchand 	TESTPMD_OPT_BURST_NUM,
15090c26386SDavid Marchand #define TESTPMD_OPT_FLOWGEN_CLONES "flowgen-clones"
15190c26386SDavid Marchand 	TESTPMD_OPT_FLOWGEN_CLONES_NUM,
15290c26386SDavid Marchand #define TESTPMD_OPT_FLOWGEN_FLOWS "flowgen-flows"
15390c26386SDavid Marchand 	TESTPMD_OPT_FLOWGEN_FLOWS_NUM,
15490c26386SDavid Marchand #define TESTPMD_OPT_MBCACHE "mbcache"
15590c26386SDavid Marchand 	TESTPMD_OPT_MBCACHE_NUM,
15690c26386SDavid Marchand #define TESTPMD_OPT_TXPT "txpt"
15790c26386SDavid Marchand 	TESTPMD_OPT_TXPT_NUM,
15890c26386SDavid Marchand #define TESTPMD_OPT_TXHT "txht"
15990c26386SDavid Marchand 	TESTPMD_OPT_TXHT_NUM,
16090c26386SDavid Marchand #define TESTPMD_OPT_TXWT "txwt"
16190c26386SDavid Marchand 	TESTPMD_OPT_TXWT_NUM,
16290c26386SDavid Marchand #define TESTPMD_OPT_TXFREET "txfreet"
16390c26386SDavid Marchand 	TESTPMD_OPT_TXFREET_NUM,
16490c26386SDavid Marchand #define TESTPMD_OPT_TXRST "txrst"
16590c26386SDavid Marchand 	TESTPMD_OPT_TXRST_NUM,
16690c26386SDavid Marchand #define TESTPMD_OPT_RXPT "rxpt"
16790c26386SDavid Marchand 	TESTPMD_OPT_RXPT_NUM,
16890c26386SDavid Marchand #define TESTPMD_OPT_RXHT "rxht"
16990c26386SDavid Marchand 	TESTPMD_OPT_RXHT_NUM,
17090c26386SDavid Marchand #define TESTPMD_OPT_RXWT "rxwt"
17190c26386SDavid Marchand 	TESTPMD_OPT_RXWT_NUM,
17290c26386SDavid Marchand #define TESTPMD_OPT_RXFREET "rxfreet"
17390c26386SDavid Marchand 	TESTPMD_OPT_RXFREET_NUM,
17490c26386SDavid Marchand #define TESTPMD_OPT_NO_FLUSH_RX "no-flush-rx"
17590c26386SDavid Marchand 	TESTPMD_OPT_NO_FLUSH_RX_NUM,
17690c26386SDavid Marchand #define TESTPMD_OPT_FLOW_ISOLATE_ALL "flow-isolate-all"
17790c26386SDavid Marchand 	TESTPMD_OPT_FLOW_ISOLATE_ALL_NUM,
17890c26386SDavid Marchand #define TESTPMD_OPT_DISABLE_FLOW_FLUSH "disable-flow-flush"
17990c26386SDavid Marchand 	TESTPMD_OPT_DISABLE_FLOW_FLUSH_NUM,
18090c26386SDavid Marchand #define TESTPMD_OPT_RXOFFS "rxoffs"
18190c26386SDavid Marchand 	TESTPMD_OPT_RXOFFS_NUM,
18290c26386SDavid Marchand #define TESTPMD_OPT_RXPKTS "rxpkts"
18390c26386SDavid Marchand 	TESTPMD_OPT_RXPKTS_NUM,
18490c26386SDavid Marchand #define TESTPMD_OPT_RXHDRS "rxhdrs"
18590c26386SDavid Marchand 	TESTPMD_OPT_RXHDRS_NUM,
18690c26386SDavid Marchand #define TESTPMD_OPT_TXPKTS "txpkts"
18790c26386SDavid Marchand 	TESTPMD_OPT_TXPKTS_NUM,
18890c26386SDavid Marchand #define TESTPMD_OPT_MULTI_RX_MEMPOOL "multi-rx-mempool"
18990c26386SDavid Marchand 	TESTPMD_OPT_MULTI_RX_MEMPOOL_NUM,
19090c26386SDavid Marchand #define TESTPMD_OPT_TXONLY_MULTI_FLOW "txonly-multi-flow"
19190c26386SDavid Marchand 	TESTPMD_OPT_TXONLY_MULTI_FLOW_NUM,
19290c26386SDavid Marchand #define TESTPMD_OPT_RXQ_SHARE "rxq-share"
19390c26386SDavid Marchand 	TESTPMD_OPT_RXQ_SHARE_NUM,
19490c26386SDavid Marchand #define TESTPMD_OPT_ETH_LINK_SPEED "eth-link-speed"
19590c26386SDavid Marchand 	TESTPMD_OPT_ETH_LINK_SPEED_NUM,
19690c26386SDavid Marchand #define TESTPMD_OPT_DISABLE_LINK_CHECK "disable-link-check"
19790c26386SDavid Marchand 	TESTPMD_OPT_DISABLE_LINK_CHECK_NUM,
19890c26386SDavid Marchand #define TESTPMD_OPT_DISABLE_DEVICE_START "disable-device-start"
19990c26386SDavid Marchand 	TESTPMD_OPT_DISABLE_DEVICE_START_NUM,
20090c26386SDavid Marchand #define TESTPMD_OPT_NO_LSC_INTERRUPT "no-lsc-interrupt"
20190c26386SDavid Marchand 	TESTPMD_OPT_NO_LSC_INTERRUPT_NUM,
20290c26386SDavid Marchand #define TESTPMD_OPT_NO_RMV_INTERRUPT "no-rmv-interrupt"
20390c26386SDavid Marchand 	TESTPMD_OPT_NO_RMV_INTERRUPT_NUM,
20490c26386SDavid Marchand #define TESTPMD_OPT_PRINT_EVENT "print-event"
20590c26386SDavid Marchand 	TESTPMD_OPT_PRINT_EVENT_NUM,
20690c26386SDavid Marchand #define TESTPMD_OPT_MASK_EVENT "mask-event"
20790c26386SDavid Marchand 	TESTPMD_OPT_MASK_EVENT_NUM,
20890c26386SDavid Marchand #define TESTPMD_OPT_TX_OFFLOADS "tx-offloads"
20990c26386SDavid Marchand 	TESTPMD_OPT_TX_OFFLOADS_NUM,
21090c26386SDavid Marchand #define TESTPMD_OPT_RX_OFFLOADS "rx-offloads"
21190c26386SDavid Marchand 	TESTPMD_OPT_RX_OFFLOADS_NUM,
21290c26386SDavid Marchand #define TESTPMD_OPT_HOT_PLUG "hot-plug"
21390c26386SDavid Marchand 	TESTPMD_OPT_HOT_PLUG_NUM,
21490c26386SDavid Marchand #define TESTPMD_OPT_VXLAN_GPE_PORT "vxlan-gpe-port"
21590c26386SDavid Marchand 	TESTPMD_OPT_VXLAN_GPE_PORT_NUM,
21690c26386SDavid Marchand #define TESTPMD_OPT_GENEVE_PARSED_PORT "geneve-parsed-port"
21790c26386SDavid Marchand 	TESTPMD_OPT_GENEVE_PARSED_PORT_NUM,
21890c26386SDavid Marchand #define TESTPMD_OPT_MLOCKALL "mlockall"
21990c26386SDavid Marchand 	TESTPMD_OPT_MLOCKALL_NUM,
22090c26386SDavid Marchand #define TESTPMD_OPT_NO_MLOCKALL "no-mlockall"
22190c26386SDavid Marchand 	TESTPMD_OPT_NO_MLOCKALL_NUM,
22290c26386SDavid Marchand #define TESTPMD_OPT_MP_ALLOC "mp-alloc"
22390c26386SDavid Marchand 	TESTPMD_OPT_MP_ALLOC_NUM,
22490c26386SDavid Marchand #define TESTPMD_OPT_TX_IP "tx-ip"
22590c26386SDavid Marchand 	TESTPMD_OPT_TX_IP_NUM,
22690c26386SDavid Marchand #define TESTPMD_OPT_TX_UDP "tx-udp"
22790c26386SDavid Marchand 	TESTPMD_OPT_TX_UDP_NUM,
22890c26386SDavid Marchand #define TESTPMD_OPT_NOISY_TX_SW_BUFFER_SIZE "noisy-tx-sw-buffer-size"
22990c26386SDavid Marchand 	TESTPMD_OPT_NOISY_TX_SW_BUFFER_SIZE_NUM,
23090c26386SDavid Marchand #define TESTPMD_OPT_NOISY_TX_SW_BUFFER_FLUSHTIME "noisy-tx-sw-buffer-flushtime"
23190c26386SDavid Marchand 	TESTPMD_OPT_NOISY_TX_SW_BUFFER_FLUSHTIME_NUM,
23290c26386SDavid Marchand #define TESTPMD_OPT_NOISY_LKUP_MEMORY "noisy-lkup-memory"
23390c26386SDavid Marchand 	TESTPMD_OPT_NOISY_LKUP_MEMORY_NUM,
23490c26386SDavid Marchand #define TESTPMD_OPT_NOISY_LKUP_NUM_WRITES "noisy-lkup-num-writes"
23590c26386SDavid Marchand 	TESTPMD_OPT_NOISY_LKUP_NUM_WRITES_NUM,
23690c26386SDavid Marchand #define TESTPMD_OPT_NOISY_LKUP_NUM_READS "noisy-lkup-num-reads"
23790c26386SDavid Marchand 	TESTPMD_OPT_NOISY_LKUP_NUM_READS_NUM,
23890c26386SDavid Marchand #define TESTPMD_OPT_NOISY_LKUP_NUM_READS_WRITES "noisy-lkup-num-reads-writes"
23990c26386SDavid Marchand 	TESTPMD_OPT_NOISY_LKUP_NUM_READS_WRITES_NUM,
24090c26386SDavid Marchand #define TESTPMD_OPT_NOISY_FORWARD_MODE "noisy-forward-mode"
24190c26386SDavid Marchand 	TESTPMD_OPT_NOISY_FORWARD_MODE_NUM,
24290c26386SDavid Marchand #define TESTPMD_OPT_NO_IOVA_CONTIG "no-iova-contig"
24390c26386SDavid Marchand 	TESTPMD_OPT_NO_IOVA_CONTIG_NUM,
24490c26386SDavid Marchand #define TESTPMD_OPT_RX_MQ_MODE "rx-mq-mode"
24590c26386SDavid Marchand 	TESTPMD_OPT_RX_MQ_MODE_NUM,
24690c26386SDavid Marchand #define TESTPMD_OPT_RECORD_CORE_CYCLES "record-core-cycles"
24790c26386SDavid Marchand 	TESTPMD_OPT_RECORD_CORE_CYCLES_NUM,
24890c26386SDavid Marchand #define TESTPMD_OPT_RECORD_BURST_STATS "record-burst-stats"
24990c26386SDavid Marchand 	TESTPMD_OPT_RECORD_BURST_STATS_NUM,
25090c26386SDavid Marchand #define TESTPMD_OPT_NUM_PROCS "num-procs"
25190c26386SDavid Marchand 	TESTPMD_OPT_NUM_PROCS_NUM,
25290c26386SDavid Marchand #define TESTPMD_OPT_PROC_ID "proc-id"
25390c26386SDavid Marchand 	TESTPMD_OPT_PROC_ID_NUM,
25490c26386SDavid Marchand 
25590c26386SDavid Marchand 	TESTPMD_OPT_LONG_MAX_NUM
25690c26386SDavid Marchand };
25790c26386SDavid Marchand 
25890c26386SDavid Marchand static const char short_options[] = {
25990c26386SDavid Marchand 	"a" /* auto-start */
26090c26386SDavid Marchand 	"h" /* help */
26190c26386SDavid Marchand 	"i" /* interactive */
26290c26386SDavid Marchand };
26390c26386SDavid Marchand 
26490c26386SDavid Marchand #define NO_ARG(opt) { opt, no_argument, NULL, opt ## _NUM }
26590c26386SDavid Marchand #define REQUIRED_ARG(opt) { opt, required_argument, NULL, opt ## _NUM }
26690c26386SDavid Marchand #define OPTIONAL_ARG(opt) { opt, optional_argument, NULL, opt ## _NUM }
26790c26386SDavid Marchand static const struct option long_options[] = {
26890c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_AUTO_START),
26990c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_HELP),
27090c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_INTERACTIVE),
27190c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_CMDLINE_FILE),
27290c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_ETH_PEERS_CONFIGFILE),
27390c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_ETH_PEER),
27490c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_TX_FIRST),
27590c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_STATS_PERIOD),
27690c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_DISPLAY_XSTATS),
27790c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_NB_CORES),
27890c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_NB_PORTS),
27990c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_COREMASK),
28090c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_PORTMASK),
28190c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_PORTLIST),
28290c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_NUMA),
28390c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_NO_NUMA),
28490c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_MP_ANON), /* deprecated */
28590c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_PORT_NUMA_CONFIG),
28690c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RING_NUMA_CONFIG),
28790c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_SOCKET_NUM),
28890c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_MBUF_SIZE),
28990c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TOTAL_NUM_MBUFS),
29090c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_MAX_PKT_LEN),
29190c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_MAX_LRO_PKT_SIZE),
29290c26386SDavid Marchand #ifdef RTE_LIB_LATENCYSTATS
29390c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_LATENCYSTATS),
29490c26386SDavid Marchand #endif
29590c26386SDavid Marchand #ifdef RTE_LIB_BITRATESTATS
29690c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_BITRATE_STATS),
29790c26386SDavid Marchand #endif
29890c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_DISABLE_CRC_STRIP),
29990c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_ENABLE_LRO),
30090c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_ENABLE_RX_CKSUM),
30190c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_ENABLE_RX_TIMESTAMP),
30290c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_ENABLE_SCATTER),
30390c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_ENABLE_HW_VLAN),
30490c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_ENABLE_HW_VLAN_FILTER),
30590c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_ENABLE_HW_VLAN_STRIP),
30690c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_ENABLE_HW_VLAN_EXTEND),
30790c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_ENABLE_HW_QINQ_STRIP),
30890c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_ENABLE_DROP_EN),
30990c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_DISABLE_RSS),
31090c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_PORT_TOPOLOGY),
31190c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_FORWARD_MODE),
31290c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_RSS_IP),
31390c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_RSS_UDP),
31490c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_RSS_LEVEL_OUTER),
31590c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_RSS_LEVEL_INNER),
31690c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RXQ),
31790c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TXQ),
31890c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RXD),
31990c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TXD),
32090c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_HAIRPINQ),
32190c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_HAIRPIN_MODE),
322*5334c3feSGregory Etelson 	REQUIRED_ARG(TESTPMD_OPT_HAIRPIN_MAP),
32390c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_BURST),
32490c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_FLOWGEN_CLONES),
32590c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_FLOWGEN_FLOWS),
32690c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_MBCACHE),
32790c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TXPT),
32890c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TXHT),
32990c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TXWT),
33090c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TXFREET),
33190c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TXRST),
33290c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RXPT),
33390c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RXHT),
33490c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RXWT),
33590c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RXFREET),
33690c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_NO_FLUSH_RX),
33790c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_FLOW_ISOLATE_ALL),
33890c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_DISABLE_FLOW_FLUSH),
33990c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RXOFFS),
34090c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RXPKTS),
34190c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RXHDRS),
34290c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TXPKTS),
34390c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_MULTI_RX_MEMPOOL),
34490c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_TXONLY_MULTI_FLOW),
34590c26386SDavid Marchand 	OPTIONAL_ARG(TESTPMD_OPT_RXQ_SHARE),
34690c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_ETH_LINK_SPEED),
34790c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_DISABLE_LINK_CHECK),
34890c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_DISABLE_DEVICE_START),
34990c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_NO_LSC_INTERRUPT),
35090c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_NO_RMV_INTERRUPT),
35190c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_PRINT_EVENT),
35290c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_MASK_EVENT),
35390c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TX_OFFLOADS),
35490c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RX_OFFLOADS),
35590c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_HOT_PLUG),
35690c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_VXLAN_GPE_PORT),
35790c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_GENEVE_PARSED_PORT),
35890c26386SDavid Marchand #ifndef RTE_EXEC_ENV_WINDOWS
35990c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_MLOCKALL),
36090c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_NO_MLOCKALL),
36190c26386SDavid Marchand #endif
36290c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_MP_ALLOC),
36390c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TX_IP),
36490c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_TX_UDP),
36590c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_NOISY_TX_SW_BUFFER_SIZE),
36690c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_NOISY_TX_SW_BUFFER_FLUSHTIME),
36790c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_NOISY_LKUP_MEMORY),
36890c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_NOISY_LKUP_NUM_WRITES),
36990c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_NOISY_LKUP_NUM_READS),
37090c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_NOISY_LKUP_NUM_READS_WRITES),
37190c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_NOISY_FORWARD_MODE),
37290c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_NO_IOVA_CONTIG),
37390c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_RX_MQ_MODE),
37490c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_RECORD_CORE_CYCLES),
37590c26386SDavid Marchand 	NO_ARG(TESTPMD_OPT_RECORD_BURST_STATS),
37690c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_NUM_PROCS),
37790c26386SDavid Marchand 	REQUIRED_ARG(TESTPMD_OPT_PROC_ID),
37890c26386SDavid Marchand 	{ 0, 0, NULL, 0 }
37990c26386SDavid Marchand };
38090c26386SDavid Marchand #undef NO_ARG
38190c26386SDavid Marchand #undef REQUIRED_ARG
38290c26386SDavid Marchand #undef OPTIONAL_ARG
38390c26386SDavid Marchand 
384af75078fSIntel static void
385af75078fSIntel usage(char* progname)
386af75078fSIntel {
387c6d527a1SThomas Monjalon 	printf("\nUsage: %s [EAL options] -- [testpmd options]\n\n",
388af75078fSIntel 	       progname);
3893be52ffcSIntel 	printf("  --interactive: run in interactive mode.\n");
39081ef862bSAllain Legacy 	printf("  --cmdline-file: execute cli commands before startup.\n");
391ca7feb22SCyril Chemparathy 	printf("  --auto-start: start forwarding on init "
392ca7feb22SCyril Chemparathy 	       "[always when non-interactive].\n");
3933be52ffcSIntel 	printf("  --help: display this message and quit.\n");
39499cabef0SPablo de Lara 	printf("  --tx-first: start forwarding sending a burst first "
39599cabef0SPablo de Lara 	       "(only if interactive is disabled).\n");
396cfea1f30SPablo de Lara 	printf("  --stats-period=PERIOD: statistics will be shown "
397cfea1f30SPablo de Lara 	       "every PERIOD seconds (only if interactive is disabled).\n");
39863b72657SIvan Ilchenko 	printf("  --display-xstats xstat_name1[,...]: comma-separated list of "
39963b72657SIvan Ilchenko 	       "extended statistics to show. Used with --stats-period "
40063b72657SIvan Ilchenko 	       "specified or interactive commands that show Rx/Tx statistics "
40163b72657SIvan Ilchenko 	       "(i.e. 'show port stats').\n");
40248588943SHuisong Li 	printf("  --num-procs=N: set the total number of multi-process instances.\n");
40348588943SHuisong Li 	printf("  --proc-id=id: set the id of the current process from "
40448588943SHuisong Li 	       "multi-process instances (0 <= id < num-procs).\n");
4053be52ffcSIntel 	printf("  --nb-cores=N: set the number of forwarding cores "
4063be52ffcSIntel 	       "(1 <= N <= %d).\n", nb_lcores);
4073be52ffcSIntel 	printf("  --nb-ports=N: set the number of forwarding ports "
4083be52ffcSIntel 	       "(1 <= N <= %d).\n", nb_ports);
409af75078fSIntel 	printf("  --coremask=COREMASK: hexadecimal bitmask of cores running "
410cb056611SStephen Hemminger 	       "the packet forwarding test. The main lcore is reserved for "
4113be52ffcSIntel 	       "command line parsing only, and cannot be masked on for "
4123be52ffcSIntel 	       "packet forwarding.\n");
413af75078fSIntel 	printf("  --portmask=PORTMASK: hexadecimal bitmask of ports used "
4143be52ffcSIntel 	       "by the packet forwarding test.\n");
4152df00d56SHariprasad Govindharajan 	printf("  --portlist=PORTLIST: list of forwarding ports\n");
416af75078fSIntel 	printf("  --numa: enable NUMA-aware allocation of RX/TX rings and of "
4173be52ffcSIntel 	       "RX memory buffers (mbufs).\n");
418c6d527a1SThomas Monjalon 	printf("  --no-numa: disable NUMA-aware allocation.\n");
419b6ea6408SIntel 	printf("  --port-numa-config=(port,socket)[,(port,socket)]: "
420b6ea6408SIntel 	       "specify the socket on which the memory pool "
421b6ea6408SIntel 	       "used by the port will be allocated.\n");
422b6ea6408SIntel 	printf("  --ring-numa-config=(port,flag,socket)[,(port,flag,socket)]: "
423b6ea6408SIntel 	       "specify the socket on which the TX/RX rings for "
424b6ea6408SIntel 	       "the port will be allocated "
425b6ea6408SIntel 	       "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
426b6ea6408SIntel 	printf("  --socket-num=N: set socket from which all memory is allocated "
427b6ea6408SIntel 	       "in NUMA mode.\n");
42826cbb419SViacheslav Ovsiienko 	printf("  --mbuf-size=N,[N1[,..Nn]: set the data size of mbuf to "
42926cbb419SViacheslav Ovsiienko 	       "N bytes. If multiple numbers are specified the extra pools "
430a4bf5421SHanumanth Pothula 	       "will be created to receive packets based on the features "
431a4bf5421SHanumanth Pothula 	       "supported, like packet split, multi-rx-mempool.\n");
4323be52ffcSIntel 	printf("  --total-num-mbufs=N: set the number of mbufs to be allocated "
4333be52ffcSIntel 	       "in mbuf pools.\n");
4343be52ffcSIntel 	printf("  --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
4354a729092SDekel Peled 	printf("  --max-lro-pkt-size=N: set the maximum LRO aggregated packet "
4364a729092SDekel Peled 	       "size to N bytes.\n");
4373be52ffcSIntel 	printf("  --eth-peers-configfile=name: config file with ethernet addresses "
4383be52ffcSIntel 	       "of peer ports.\n");
4393be52ffcSIntel 	printf("  --eth-peer=X,M:M:M:M:M:M: set the MAC address of the X peer "
4403be52ffcSIntel 	       "port (0 <= X < %d).\n", RTE_MAX_ETHPORTS);
44179dd163fSJeff Guo 	printf("  --disable-crc-strip: disable CRC stripping by hardware.\n");
442c6d527a1SThomas Monjalon 	printf("  --enable-scatter: enable scattered Rx.\n");
4434c3ea508SOlivier Matz 	printf("  --enable-lro: enable large receive offload.\n");
4443be52ffcSIntel 	printf("  --enable-rx-cksum: enable rx hardware checksum offload.\n");
445912267a3SRaslan Darawsheh 	printf("  --enable-rx-timestamp: enable rx hardware timestamp offload.\n");
4468b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan: enable hardware vlan.\n");
4478b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan-filter: enable hardware vlan filter.\n");
4488b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan-strip: enable hardware vlan strip.\n");
4498b9bd0efSMoti Haimovsky 	printf("  --enable-hw-vlan-extend: enable hardware vlan extend.\n");
450b8577876SVivek Sharma 	printf("  --enable-hw-qinq-strip: enable hardware qinq strip.\n");
4513be52ffcSIntel 	printf("  --enable-drop-en: enable per queue packet drop.\n");
4523be52ffcSIntel 	printf("  --disable-rss: disable rss.\n");
453e71df49eSCiara Power 	printf("  --port-topology=<paired|chained|loop>: set port topology (paired "
454e71df49eSCiara Power 	       "is default).\n");
455769ce6b1SThomas Monjalon 	printf("  --forward-mode=N: set forwarding mode (N: %s).\n",
456769ce6b1SThomas Monjalon 	       list_pkt_forwarding_modes());
4572564abdaSShiri Kuzin 	printf("  --forward-mode=5tswap: set forwarding mode to "
4582564abdaSShiri Kuzin 			"swap L2,L3,L4 for MAC, IPv4/IPv6 and TCP/UDP only.\n");
4593be52ffcSIntel 	printf("  --rss-ip: set RSS functions to IPv4/IPv6 only .\n");
4603be52ffcSIntel 	printf("  --rss-udp: set RSS functions to IPv4/IPv6 + UDP.\n");
46194198f40SKiran Kumar K 	printf("  --rss-level-inner: set RSS hash level to innermost\n");
46294198f40SKiran Kumar K 	printf("  --rss-level-outer: set RSS hash level to outermost\n");
4633be52ffcSIntel 	printf("  --rxq=N: set the number of RX queues per port to N.\n");
4643be52ffcSIntel 	printf("  --rxd=N: set the number of descriptors in RX rings to N.\n");
4653be52ffcSIntel 	printf("  --txq=N: set the number of TX queues per port to N.\n");
4663be52ffcSIntel 	printf("  --txd=N: set the number of descriptors in TX rings to N.\n");
4671c69df45SOri Kam 	printf("  --hairpinq=N: set the number of hairpin queues per port to "
4681c69df45SOri Kam 	       "N.\n");
4693be52ffcSIntel 	printf("  --burst=N: set the number of packets per burst to N.\n");
4706c02043eSIgor Russkikh 	printf("  --flowgen-clones=N: set the number of single packet clones to send in flowgen mode. Should be less than burst value.\n");
471861e7684SZhihong Wang 	printf("  --flowgen-flows=N: set the number of flows in flowgen mode to N (1 <= N <= INT32_MAX).\n");
4723be52ffcSIntel 	printf("  --mbcache=N: set the cache of mbuf memory pool to N.\n");
47357af3415SPablo de Lara 	printf("  --rxpt=N: set prefetch threshold register of RX rings to N.\n");
47457af3415SPablo de Lara 	printf("  --rxht=N: set the host threshold register of RX rings to N.\n");
4753be52ffcSIntel 	printf("  --rxfreet=N: set the free threshold of RX descriptors to N "
4763be52ffcSIntel 	       "(0 <= N < value of rxd).\n");
47757af3415SPablo de Lara 	printf("  --rxwt=N: set the write-back threshold register of RX rings to N.\n");
47857af3415SPablo de Lara 	printf("  --txpt=N: set the prefetch threshold register of TX rings to N.\n");
47957af3415SPablo de Lara 	printf("  --txht=N: set the nhost threshold register of TX rings to N.\n");
48057af3415SPablo de Lara 	printf("  --txwt=N: set the write-back threshold register of TX rings to N.\n");
4813be52ffcSIntel 	printf("  --txfreet=N: set the transmit free threshold of TX rings to N "
4823be52ffcSIntel 	       "(0 <= N <= value of txd).\n");
4833be52ffcSIntel 	printf("  --txrst=N: set the transmit RS bit threshold of TX rings to N "
4843be52ffcSIntel 	       "(0 <= N <= value of txd).\n");
4855e2ee196SIntel 	printf("  --no-flush-rx: Don't flush RX streams before forwarding."
4865e2ee196SIntel 	       " Used mainly with PCAP drivers.\n");
48791c78e09SViacheslav Ovsiienko 	printf("  --rxoffs=X[,Y]*: set RX segment offsets for split.\n");
4880f2096d7SViacheslav Ovsiienko 	printf("  --rxpkts=X[,Y]*: set RX segment sizes to split.\n");
48952e2e7edSYuan Wang 	printf("  --rxhdrs=eth[,ipv4]*: set RX segment protocol to split.\n");
4902ebacaa7SMaciej Czekaj 	printf("  --txpkts=X[,Y]*: set TX segment sizes"
4912ebacaa7SMaciej Czekaj 		" or total packet length.\n");
492a4bf5421SHanumanth Pothula 	printf("  --multi-rx-mempool: enable multi-rx-mempool support\n");
49382010ef5SYongseok Koh 	printf("  --txonly-multi-flow: generate multiple flows in txonly mode\n");
494c6d527a1SThomas Monjalon 	printf("  --tx-ip=src,dst: IP addresses in Tx-only mode\n");
495c6d527a1SThomas Monjalon 	printf("  --tx-udp=src[,dst]: UDP ports in Tx-only mode\n");
496b7b78a08SAjit Khaparde 	printf("  --eth-link-speed: force link speed.\n");
497f4d178c1SXueming Li 	printf("  --rxq-share=X: number of ports per shared Rx queue groups, defaults to UINT32_MAX (1 group)\n");
498bc202406SDavid Marchand 	printf("  --disable-link-check: disable check on link status when "
499bc202406SDavid Marchand 	       "starting/stopping ports.\n");
5006937d210SStephen Hemminger 	printf("  --disable-device-start: do not automatically start port\n");
5018ea656f8SGaetan Rivet 	printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
502e25e6c70SRemy Horton 	printf("  --no-rmv-interrupt: disable device removal interrupt.\n");
503e96491cbSStephen Hemminger #ifdef RTE_LIB_BITRATESTATS
504e25e6c70SRemy Horton 	printf("  --bitrate-stats=N: set the logical core N to perform "
505e25e6c70SRemy Horton 		"bit-rate calculation.\n");
506e96491cbSStephen Hemminger #endif
507e96491cbSStephen Hemminger #ifdef RTE_LIB_LATENCYSTATS
508e96491cbSStephen Hemminger 	printf("  --latencystats=N: enable latency and jitter statistics "
509e96491cbSStephen Hemminger 	       "monitoring on forwarding lcore id N.\n");
510e96491cbSStephen Hemminger #endif
511eb0d471aSKalesh AP 	printf("  --print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|flow_aged|err_recovering|recovery_success|recovery_failed|all>: "
512776ecd42SWenzhuo Lu 	       "enable print of designated event or all of them.\n");
513eb0d471aSKalesh AP 	printf("  --mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|flow_aged|err_recovering|recovery_success|recovery_failed||all>: "
514776ecd42SWenzhuo Lu 	       "disable print of designated event or all of them.\n");
5157ee3e944SVasily Philipov 	printf("  --flow-isolate-all: "
516776ecd42SWenzhuo Lu 	       "requests flow API isolated mode on all ports at initialization time.\n");
517543df472SChengwen Feng 	printf("  --disable-flow-flush: disable port flow flush when stop port.\n");
518fd8c20aaSShahaf Shuler 	printf("  --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
519fb1a5a0fSVivek Sharma 	printf("  --rx-offloads=0xXXXXXXXX: hexadecimal bitmask of RX queue offloads\n");
520fb73e096SJeff Guo 	printf("  --hot-plug: enable hot plug for device.\n");
52139e5e20fSXueming Li 	printf("  --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\n");
5222f60c649SOphir Munk 	printf("  --geneve-parsed-port=N: UPD port to parse GENEVE tunnel protocol\n");
523761f7ae1SJie Zhou #ifndef RTE_EXEC_ENV_WINDOWS
524e505d84cSAnatoly Burakov 	printf("  --mlockall: lock all memory\n");
525e505d84cSAnatoly Burakov 	printf("  --no-mlockall: do not lock all memory\n");
526761f7ae1SJie Zhou #endif
527c7f5dba7SAnatoly Burakov 	printf("  --mp-alloc <native|anon|xmem|xmemhuge>: mempool allocation method.\n"
528c7f5dba7SAnatoly Burakov 	       "    native: use regular DPDK memory to create and populate mempool\n"
529c7f5dba7SAnatoly Burakov 	       "    anon: use regular DPDK memory to create and anonymous memory to populate mempool\n"
530c7f5dba7SAnatoly Burakov 	       "    xmem: use anonymous memory to create and populate mempool\n"
531c7f5dba7SAnatoly Burakov 	       "    xmemhuge: use anonymous hugepage memory to create and populate mempool\n");
5321d343c19SMike Pattrick 	printf("  --noisy-forward-mode=<io|mac|macswap|5tswap>: set the sub-fwd mode, defaults to io\n");
5333c156061SJens Freimann 	printf("  --noisy-tx-sw-buffer-size=N: size of FIFO buffer\n");
5343c156061SJens Freimann 	printf("  --noisy-tx-sw-buffer-flushtime=N: flush FIFO after N ms\n");
5353c156061SJens Freimann 	printf("  --noisy-lkup-memory=N: allocate N MB of VNF memory\n");
5363c156061SJens Freimann 	printf("  --noisy-lkup-num-writes=N: do N random writes per packet\n");
5373c156061SJens Freimann 	printf("  --noisy-lkup-num-reads=N: do N random reads per packet\n");
538c6d527a1SThomas Monjalon 	printf("  --noisy-lkup-num-reads-writes=N: do N random reads and writes per packet\n");
53959fcf854SShahaf Shuler 	printf("  --no-iova-contig: mempool memory can be IOVA non contiguous. "
54059fcf854SShahaf Shuler 	       "valid only with --mp-alloc=anon\n");
541f9295aa2SXiaoyu Min 	printf("  --rx-mq-mode=0xX: hexadecimal bitmask of RX mq mode can be "
542f9295aa2SXiaoyu Min 	       "enabled\n");
543bc700b67SDharmik Thakkar 	printf("  --record-core-cycles: enable measurement of CPU cycles.\n");
5440e4b1963SDharmik Thakkar 	printf("  --record-burst-stats: enable display of RX and TX bursts.\n");
54501817b10SBing Zhao 	printf("  --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n"
54601817b10SBing Zhao 	       "    0x10 - explicit Tx rule, 0x02 - hairpin ports paired\n"
54701817b10SBing Zhao 	       "    0x01 - hairpin ports loop, 0x00 - hairpin port self\n");
548*5334c3feSGregory Etelson 	hairpin_map_usage();
549af75078fSIntel }
550af75078fSIntel 
551af75078fSIntel static int
552761f7ae1SJie Zhou init_peer_eth_addrs(const char *config_filename)
553af75078fSIntel {
554af75078fSIntel 	FILE *config_file;
555af75078fSIntel 	portid_t i;
556af75078fSIntel 	char buf[50];
557af75078fSIntel 
558af75078fSIntel 	config_file = fopen(config_filename, "r");
559af75078fSIntel 	if (config_file == NULL) {
5603be52ffcSIntel 		perror("Failed to open eth config file\n");
561af75078fSIntel 		return -1;
562af75078fSIntel 	}
563af75078fSIntel 
564af75078fSIntel 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
565af75078fSIntel 
566af75078fSIntel 		if (fgets(buf, sizeof(buf), config_file) == NULL)
567af75078fSIntel 			break;
568af75078fSIntel 
569b5ddce89SStephen Hemminger 		if (rte_ether_unformat_addr(buf, &peer_eth_addrs[i]) < 0) {
57061a3b0e5SAndrew Rybchenko 			fprintf(stderr, "Bad MAC address format on line %d\n",
57161a3b0e5SAndrew Rybchenko 				i + 1);
572af75078fSIntel 			fclose(config_file);
573af75078fSIntel 			return -1;
574af75078fSIntel 		}
575af75078fSIntel 	}
576af75078fSIntel 	fclose(config_file);
577af75078fSIntel 	nb_peer_eth_addrs = (portid_t) i;
578af75078fSIntel 	return 0;
579af75078fSIntel }
580af75078fSIntel 
581af75078fSIntel /*
582af75078fSIntel  * Parse the coremask given as argument (hexadecimal string) and set
583af75078fSIntel  * the global configuration of forwarding cores.
584af75078fSIntel  */
585af75078fSIntel static void
586af75078fSIntel parse_fwd_coremask(const char *coremask)
587af75078fSIntel {
588af75078fSIntel 	char *end;
589af75078fSIntel 	unsigned long long int cm;
590af75078fSIntel 
591af75078fSIntel 	/* parse hexadecimal string */
592af75078fSIntel 	end = NULL;
593af75078fSIntel 	cm = strtoull(coremask, &end, 16);
594af75078fSIntel 	if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0'))
595af75078fSIntel 		rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n");
596013af9b6SIntel 	else if (set_fwd_lcores_mask((uint64_t) cm) < 0)
597013af9b6SIntel 		rte_exit(EXIT_FAILURE, "coremask is not valid\n");
598af75078fSIntel }
599af75078fSIntel 
600af75078fSIntel /*
601af75078fSIntel  * Parse the coremask given as argument (hexadecimal string) and set
602af75078fSIntel  * the global configuration of forwarding cores.
603af75078fSIntel  */
604af75078fSIntel static void
605af75078fSIntel parse_fwd_portmask(const char *portmask)
606af75078fSIntel {
607af75078fSIntel 	char *end;
608af75078fSIntel 	unsigned long long int pm;
609af75078fSIntel 
610af75078fSIntel 	/* parse hexadecimal string */
611af75078fSIntel 	end = NULL;
612af75078fSIntel 	pm = strtoull(portmask, &end, 16);
613af75078fSIntel 	if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
614af75078fSIntel 		rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n");
615af75078fSIntel 	else
616af75078fSIntel 		set_fwd_ports_mask((uint64_t) pm);
617af75078fSIntel }
618af75078fSIntel 
619c9cafcc8SShahaf Shuler static void
620c9cafcc8SShahaf Shuler print_invalid_socket_id_error(void)
621c9cafcc8SShahaf Shuler {
622c9cafcc8SShahaf Shuler 	unsigned int i = 0;
623c9cafcc8SShahaf Shuler 
62461a3b0e5SAndrew Rybchenko 	fprintf(stderr, "Invalid socket id, options are: ");
625c9cafcc8SShahaf Shuler 	for (i = 0; i < num_sockets; i++) {
62661a3b0e5SAndrew Rybchenko 		fprintf(stderr, "%u%s", socket_ids[i],
627c9cafcc8SShahaf Shuler 			(i == num_sockets - 1) ? "\n" : ",");
628c9cafcc8SShahaf Shuler 	}
629c9cafcc8SShahaf Shuler }
630c9cafcc8SShahaf Shuler 
631b6ea6408SIntel static int
632b6ea6408SIntel parse_portnuma_config(const char *q_arg)
633b6ea6408SIntel {
634b6ea6408SIntel 	char s[256];
635b6ea6408SIntel 	const char *p, *p0 = q_arg;
636b6ea6408SIntel 	char *end;
637d1f1a0fdSLi Han 	uint8_t i, socket_id;
638d1f1a0fdSLi Han 	portid_t port_id;
639b6ea6408SIntel 	unsigned size;
640b6ea6408SIntel 	enum fieldnames {
641b6ea6408SIntel 		FLD_PORT = 0,
642b6ea6408SIntel 		FLD_SOCKET,
643b6ea6408SIntel 		_NUM_FLD
644b6ea6408SIntel 	};
645b6ea6408SIntel 	unsigned long int_fld[_NUM_FLD];
646b6ea6408SIntel 	char *str_fld[_NUM_FLD];
647b6ea6408SIntel 
648b6ea6408SIntel 	/* reset from value set at definition */
649b6ea6408SIntel 	while ((p = strchr(p0,'(')) != NULL) {
650b6ea6408SIntel 		++p;
651b6ea6408SIntel 		if((p0 = strchr(p,')')) == NULL)
652b6ea6408SIntel 			return -1;
653b6ea6408SIntel 
654b6ea6408SIntel 		size = p0 - p;
655b6ea6408SIntel 		if(size >= sizeof(s))
656b6ea6408SIntel 			return -1;
657b6ea6408SIntel 
6586f41fe75SStephen Hemminger 		snprintf(s, sizeof(s), "%.*s", size, p);
659b6ea6408SIntel 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
660b6ea6408SIntel 			return -1;
661b6ea6408SIntel 		for (i = 0; i < _NUM_FLD; i++) {
662b6ea6408SIntel 			errno = 0;
663b6ea6408SIntel 			int_fld[i] = strtoul(str_fld[i], &end, 0);
664b6ea6408SIntel 			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
665b6ea6408SIntel 				return -1;
666b6ea6408SIntel 		}
667d1f1a0fdSLi Han 		port_id = (portid_t)int_fld[FLD_PORT];
668d1f1a0fdSLi Han 		if (port_id_is_invalid(port_id, ENABLED_WARN) ||
669d1f1a0fdSLi Han 			port_id == (portid_t)RTE_PORT_ALL) {
6708f3c4176SMatan Azrad 			print_valid_ports();
671b6ea6408SIntel 			return -1;
672b6ea6408SIntel 		}
673b6ea6408SIntel 		socket_id = (uint8_t)int_fld[FLD_SOCKET];
674c9cafcc8SShahaf Shuler 		if (new_socket_id(socket_id)) {
675a569af24SPhil Yang 			if (num_sockets >= RTE_MAX_NUMA_NODES) {
676c9cafcc8SShahaf Shuler 				print_invalid_socket_id_error();
677b6ea6408SIntel 				return -1;
678b6ea6408SIntel 			}
679a569af24SPhil Yang 			socket_ids[num_sockets++] = socket_id;
680a569af24SPhil Yang 		}
681b6ea6408SIntel 		port_numa[port_id] = socket_id;
682b6ea6408SIntel 	}
683b6ea6408SIntel 
684b6ea6408SIntel 	return 0;
685b6ea6408SIntel }
686b6ea6408SIntel 
687b6ea6408SIntel static int
688b6ea6408SIntel parse_ringnuma_config(const char *q_arg)
689b6ea6408SIntel {
690b6ea6408SIntel 	char s[256];
691b6ea6408SIntel 	const char *p, *p0 = q_arg;
692b6ea6408SIntel 	char *end;
693d1f1a0fdSLi Han 	uint8_t i, ring_flag, socket_id;
694d1f1a0fdSLi Han 	portid_t port_id;
695b6ea6408SIntel 	unsigned size;
696b6ea6408SIntel 	enum fieldnames {
697b6ea6408SIntel 		FLD_PORT = 0,
698b6ea6408SIntel 		FLD_FLAG,
699b6ea6408SIntel 		FLD_SOCKET,
700b6ea6408SIntel 		_NUM_FLD
701b6ea6408SIntel 	};
702b6ea6408SIntel 	unsigned long int_fld[_NUM_FLD];
703b6ea6408SIntel 	char *str_fld[_NUM_FLD];
704b6ea6408SIntel 	#define RX_RING_ONLY 0x1
705b6ea6408SIntel 	#define TX_RING_ONLY 0x2
706b6ea6408SIntel 	#define RXTX_RING    0x3
707b6ea6408SIntel 
708b6ea6408SIntel 	/* reset from value set at definition */
709b6ea6408SIntel 	while ((p = strchr(p0,'(')) != NULL) {
710b6ea6408SIntel 		++p;
711b6ea6408SIntel 		if((p0 = strchr(p,')')) == NULL)
712b6ea6408SIntel 			return -1;
713b6ea6408SIntel 
714b6ea6408SIntel 		size = p0 - p;
715b6ea6408SIntel 		if(size >= sizeof(s))
716b6ea6408SIntel 			return -1;
717b6ea6408SIntel 
7186f41fe75SStephen Hemminger 		snprintf(s, sizeof(s), "%.*s", size, p);
719b6ea6408SIntel 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
720b6ea6408SIntel 			return -1;
721b6ea6408SIntel 		for (i = 0; i < _NUM_FLD; i++) {
722b6ea6408SIntel 			errno = 0;
723b6ea6408SIntel 			int_fld[i] = strtoul(str_fld[i], &end, 0);
724b6ea6408SIntel 			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
725b6ea6408SIntel 				return -1;
726b6ea6408SIntel 		}
727d1f1a0fdSLi Han 		port_id = (portid_t)int_fld[FLD_PORT];
728d1f1a0fdSLi Han 		if (port_id_is_invalid(port_id, ENABLED_WARN) ||
729d1f1a0fdSLi Han 			port_id == (portid_t)RTE_PORT_ALL) {
7308f3c4176SMatan Azrad 			print_valid_ports();
731b6ea6408SIntel 			return -1;
732b6ea6408SIntel 		}
733b6ea6408SIntel 		socket_id = (uint8_t)int_fld[FLD_SOCKET];
734c9cafcc8SShahaf Shuler 		if (new_socket_id(socket_id)) {
735a569af24SPhil Yang 			if (num_sockets >= RTE_MAX_NUMA_NODES) {
736c9cafcc8SShahaf Shuler 				print_invalid_socket_id_error();
737b6ea6408SIntel 				return -1;
738b6ea6408SIntel 			}
739a569af24SPhil Yang 			socket_ids[num_sockets++] = socket_id;
740a569af24SPhil Yang 		}
741b6ea6408SIntel 		ring_flag = (uint8_t)int_fld[FLD_FLAG];
742b6ea6408SIntel 		if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) {
74361a3b0e5SAndrew Rybchenko 			fprintf(stderr,
74461a3b0e5SAndrew Rybchenko 				"Invalid ring-flag=%d config for port =%d\n",
745b6ea6408SIntel 				ring_flag,port_id);
746b6ea6408SIntel 			return -1;
747b6ea6408SIntel 		}
748b6ea6408SIntel 
749b6ea6408SIntel 		switch (ring_flag & RXTX_RING) {
750b6ea6408SIntel 		case RX_RING_ONLY:
751b6ea6408SIntel 			rxring_numa[port_id] = socket_id;
752b6ea6408SIntel 			break;
753b6ea6408SIntel 		case TX_RING_ONLY:
754b6ea6408SIntel 			txring_numa[port_id] = socket_id;
755b6ea6408SIntel 			break;
756b6ea6408SIntel 		case RXTX_RING:
757b6ea6408SIntel 			rxring_numa[port_id] = socket_id;
758b6ea6408SIntel 			txring_numa[port_id] = socket_id;
759b6ea6408SIntel 			break;
760b6ea6408SIntel 		default:
76161a3b0e5SAndrew Rybchenko 			fprintf(stderr,
76261a3b0e5SAndrew Rybchenko 				"Invalid ring-flag=%d config for port=%d\n",
763b6ea6408SIntel 				ring_flag,port_id);
764b6ea6408SIntel 			break;
765b6ea6408SIntel 		}
766b6ea6408SIntel 	}
767b6ea6408SIntel 
768b6ea6408SIntel 	return 0;
769b6ea6408SIntel }
770ed30d9b6SIntel 
7713af72783SGaetan Rivet static int
7723af72783SGaetan Rivet parse_event_printing_config(const char *optarg, int enable)
7733af72783SGaetan Rivet {
7743af72783SGaetan Rivet 	uint32_t mask = 0;
7753af72783SGaetan Rivet 
7763af72783SGaetan Rivet 	if (!strcmp(optarg, "unknown"))
7773af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN;
7783af72783SGaetan Rivet 	else if (!strcmp(optarg, "intr_lsc"))
7793af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_LSC;
7803af72783SGaetan Rivet 	else if (!strcmp(optarg, "queue_state"))
7813af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_QUEUE_STATE;
7823af72783SGaetan Rivet 	else if (!strcmp(optarg, "intr_reset"))
7833af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET;
7843af72783SGaetan Rivet 	else if (!strcmp(optarg, "vf_mbox"))
7853af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_VF_MBOX;
786badb87c1SAnoob Joseph 	else if (!strcmp(optarg, "ipsec"))
787badb87c1SAnoob Joseph 		mask = UINT32_C(1) << RTE_ETH_EVENT_IPSEC;
7883af72783SGaetan Rivet 	else if (!strcmp(optarg, "macsec"))
7893af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
7903af72783SGaetan Rivet 	else if (!strcmp(optarg, "intr_rmv"))
7913af72783SGaetan Rivet 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
7924fb82244SMatan Azrad 	else if (!strcmp(optarg, "dev_probed"))
7934fb82244SMatan Azrad 		mask = UINT32_C(1) << RTE_ETH_EVENT_NEW;
7944fb82244SMatan Azrad 	else if (!strcmp(optarg, "dev_released"))
7954fb82244SMatan Azrad 		mask = UINT32_C(1) << RTE_ETH_EVENT_DESTROY;
7960e459ffaSDong Zhou 	else if (!strcmp(optarg, "flow_aged"))
7970e459ffaSDong Zhou 		mask = UINT32_C(1) << RTE_ETH_EVENT_FLOW_AGED;
798eb0d471aSKalesh AP 	else if (!strcmp(optarg, "err_recovering"))
799eb0d471aSKalesh AP 		mask = UINT32_C(1) << RTE_ETH_EVENT_ERR_RECOVERING;
800eb0d471aSKalesh AP 	else if (!strcmp(optarg, "recovery_success"))
801eb0d471aSKalesh AP 		mask = UINT32_C(1) << RTE_ETH_EVENT_RECOVERY_SUCCESS;
802eb0d471aSKalesh AP 	else if (!strcmp(optarg, "recovery_failed"))
803eb0d471aSKalesh AP 		mask = UINT32_C(1) << RTE_ETH_EVENT_RECOVERY_FAILED;
804b6b63dfdSGaetan Rivet 	else if (!strcmp(optarg, "all"))
805b6b63dfdSGaetan Rivet 		mask = ~UINT32_C(0);
8063af72783SGaetan Rivet 	else {
8073af72783SGaetan Rivet 		fprintf(stderr, "Invalid event: %s\n", optarg);
8083af72783SGaetan Rivet 		return -1;
8093af72783SGaetan Rivet 	}
8103af72783SGaetan Rivet 	if (enable)
8113af72783SGaetan Rivet 		event_print_mask |= mask;
8123af72783SGaetan Rivet 	else
8133af72783SGaetan Rivet 		event_print_mask &= ~mask;
8143af72783SGaetan Rivet 	return 0;
8153af72783SGaetan Rivet }
8163af72783SGaetan Rivet 
817b7b78a08SAjit Khaparde static int
81863b72657SIvan Ilchenko parse_xstats_list(const char *in_str, struct rte_eth_xstat_name **xstats,
81963b72657SIvan Ilchenko 		  unsigned int *xstats_num)
82063b72657SIvan Ilchenko {
82163b72657SIvan Ilchenko 	int max_names_nb, names_nb, nonempty_names_nb;
82263b72657SIvan Ilchenko 	int name, nonempty_name;
82363b72657SIvan Ilchenko 	int stringlen;
82463b72657SIvan Ilchenko 	char **names;
82563b72657SIvan Ilchenko 	char *str;
82663b72657SIvan Ilchenko 	int ret;
82763b72657SIvan Ilchenko 	int i;
82863b72657SIvan Ilchenko 
82963b72657SIvan Ilchenko 	names = NULL;
83063b72657SIvan Ilchenko 	str = strdup(in_str);
83163b72657SIvan Ilchenko 	if (str == NULL) {
83263b72657SIvan Ilchenko 		ret = -ENOMEM;
83363b72657SIvan Ilchenko 		goto out;
83463b72657SIvan Ilchenko 	}
83563b72657SIvan Ilchenko 	stringlen = strlen(str);
83663b72657SIvan Ilchenko 
83763b72657SIvan Ilchenko 	for (i = 0, max_names_nb = 1; str[i] != '\0'; i++) {
83863b72657SIvan Ilchenko 		if (str[i] == ',')
83963b72657SIvan Ilchenko 			max_names_nb++;
84063b72657SIvan Ilchenko 	}
84163b72657SIvan Ilchenko 
84263b72657SIvan Ilchenko 	names = calloc(max_names_nb, sizeof(*names));
84363b72657SIvan Ilchenko 	if (names == NULL) {
84463b72657SIvan Ilchenko 		ret = -ENOMEM;
84563b72657SIvan Ilchenko 		goto out;
84663b72657SIvan Ilchenko 	}
84763b72657SIvan Ilchenko 
84863b72657SIvan Ilchenko 	names_nb = rte_strsplit(str, stringlen, names, max_names_nb, ',');
84963b72657SIvan Ilchenko 	if (names_nb < 0) {
85063b72657SIvan Ilchenko 		ret = -EINVAL;
85163b72657SIvan Ilchenko 		goto out;
85263b72657SIvan Ilchenko 	}
85363b72657SIvan Ilchenko 
85463b72657SIvan Ilchenko 	nonempty_names_nb = 0;
85563b72657SIvan Ilchenko 	for (i = 0; i < names_nb; i++) {
85663b72657SIvan Ilchenko 		if (names[i][0] == '\0')
85763b72657SIvan Ilchenko 			continue;
85863b72657SIvan Ilchenko 		nonempty_names_nb++;
85963b72657SIvan Ilchenko 	}
86063b72657SIvan Ilchenko 	*xstats = calloc(nonempty_names_nb, sizeof(**xstats));
86163b72657SIvan Ilchenko 	if (*xstats == NULL) {
86263b72657SIvan Ilchenko 		ret = -ENOMEM;
86363b72657SIvan Ilchenko 		goto out;
86463b72657SIvan Ilchenko 	}
86563b72657SIvan Ilchenko 
86663b72657SIvan Ilchenko 	for (name = nonempty_name = 0; name < names_nb; name++) {
86763b72657SIvan Ilchenko 		if (names[name][0] == '\0')
86863b72657SIvan Ilchenko 			continue;
86963b72657SIvan Ilchenko 		rte_strscpy((*xstats)[nonempty_name].name, names[name],
87063b72657SIvan Ilchenko 			    sizeof((*xstats)[nonempty_name].name));
87163b72657SIvan Ilchenko 		nonempty_name++;
87263b72657SIvan Ilchenko 	}
87363b72657SIvan Ilchenko 
87463b72657SIvan Ilchenko 	*xstats_num = nonempty_names_nb;
87563b72657SIvan Ilchenko 	ret = 0;
87663b72657SIvan Ilchenko 
87763b72657SIvan Ilchenko out:
87863b72657SIvan Ilchenko 	free(names);
87963b72657SIvan Ilchenko 	free(str);
88063b72657SIvan Ilchenko 	return ret;
88163b72657SIvan Ilchenko }
88263b72657SIvan Ilchenko 
88363b72657SIvan Ilchenko static int
884b7b78a08SAjit Khaparde parse_link_speed(int n)
885b7b78a08SAjit Khaparde {
886295968d1SFerruh Yigit 	uint32_t speed = RTE_ETH_LINK_SPEED_FIXED;
887b7b78a08SAjit Khaparde 
888b7b78a08SAjit Khaparde 	switch (n) {
889b7b78a08SAjit Khaparde 	case 1000:
890295968d1SFerruh Yigit 		speed |= RTE_ETH_LINK_SPEED_1G;
891b7b78a08SAjit Khaparde 		break;
892d54c7f15SJulien Aube 	case 2500:
893d54c7f15SJulien Aube 		speed |= RTE_ETH_LINK_SPEED_2_5G;
894d54c7f15SJulien Aube 		break;
895d54c7f15SJulien Aube 	case 5000:
896d54c7f15SJulien Aube 		speed |= RTE_ETH_LINK_SPEED_5G;
897d54c7f15SJulien Aube 		break;
898b7b78a08SAjit Khaparde 	case 10000:
899295968d1SFerruh Yigit 		speed |= RTE_ETH_LINK_SPEED_10G;
900b7b78a08SAjit Khaparde 		break;
901b7b78a08SAjit Khaparde 	case 25000:
902295968d1SFerruh Yigit 		speed |= RTE_ETH_LINK_SPEED_25G;
903b7b78a08SAjit Khaparde 		break;
904b7b78a08SAjit Khaparde 	case 40000:
905295968d1SFerruh Yigit 		speed |= RTE_ETH_LINK_SPEED_40G;
906b7b78a08SAjit Khaparde 		break;
907b7b78a08SAjit Khaparde 	case 50000:
908295968d1SFerruh Yigit 		speed |= RTE_ETH_LINK_SPEED_50G;
909b7b78a08SAjit Khaparde 		break;
910b7b78a08SAjit Khaparde 	case 100000:
911295968d1SFerruh Yigit 		speed |= RTE_ETH_LINK_SPEED_100G;
912b7b78a08SAjit Khaparde 		break;
913b7b78a08SAjit Khaparde 	case 200000:
914295968d1SFerruh Yigit 		speed |= RTE_ETH_LINK_SPEED_200G;
915b7b78a08SAjit Khaparde 		break;
916a131d9ecSThomas Monjalon 	case 400000:
917a131d9ecSThomas Monjalon 		speed |= RTE_ETH_LINK_SPEED_400G;
918a131d9ecSThomas Monjalon 		break;
919b7b78a08SAjit Khaparde 	case 100:
920b7b78a08SAjit Khaparde 	case 10:
921b7b78a08SAjit Khaparde 	default:
92261a3b0e5SAndrew Rybchenko 		fprintf(stderr, "Unsupported fixed speed\n");
923b7b78a08SAjit Khaparde 		return 0;
924b7b78a08SAjit Khaparde 	}
925b7b78a08SAjit Khaparde 
926b7b78a08SAjit Khaparde 	return speed;
927b7b78a08SAjit Khaparde }
928b7b78a08SAjit Khaparde 
929af75078fSIntel void
930af75078fSIntel launch_args_parse(int argc, char** argv)
931af75078fSIntel {
932af75078fSIntel 	int n, opt;
933af75078fSIntel 	int opt_idx;
9343f7311baSWei Dai 	portid_t pid;
935013af9b6SIntel 	enum { TX, RX };
936fd8c20aaSShahaf Shuler 	/* Default offloads for all ports. */
9370074d02fSShahaf Shuler 	uint64_t rx_offloads = rx_mode.offloads;
938fd8c20aaSShahaf Shuler 	uint64_t tx_offloads = tx_mode.offloads;
9398599ed31SRemy Horton 	struct rte_eth_dev_info dev_info;
9408599ed31SRemy Horton 	uint16_t rec_nb_pkts;
9416f51deb9SIvan Ilchenko 	int ret;
942013af9b6SIntel 
94390c26386SDavid Marchand 	while ((opt = getopt_long(argc, argv, short_options, long_options,
94490c26386SDavid Marchand 			&opt_idx)) != EOF) {
945af75078fSIntel 		switch (opt) {
946af75078fSIntel 		case 'i':
947af75078fSIntel 			printf("Interactive-mode selected\n");
948af75078fSIntel 			interactive = 1;
949af75078fSIntel 			break;
950ca7feb22SCyril Chemparathy 		case 'a':
951ca7feb22SCyril Chemparathy 			printf("Auto-start selected\n");
952ca7feb22SCyril Chemparathy 			auto_start = 1;
953ca7feb22SCyril Chemparathy 			break;
95490c26386SDavid Marchand 		case 'h':
955af75078fSIntel 			usage(argv[0]);
956487cfc24SThomas Monjalon 			exit(EXIT_SUCCESS);
95790c26386SDavid Marchand 			break;
95890c26386SDavid Marchand 		case TESTPMD_OPT_CMDLINE_FILE_NUM:
95981ef862bSAllain Legacy 			printf("CLI commands to be read from %s\n",
96081ef862bSAllain Legacy 				optarg);
961c022cb40SBruce Richardson 			strlcpy(cmdline_filename, optarg,
962c022cb40SBruce Richardson 				sizeof(cmdline_filename));
96390c26386SDavid Marchand 			break;
96490c26386SDavid Marchand 		case TESTPMD_OPT_TX_FIRST_NUM:
96599cabef0SPablo de Lara 			printf("Ports to start sending a burst of "
96699cabef0SPablo de Lara 				"packets first\n");
96799cabef0SPablo de Lara 			tx_first = 1;
96890c26386SDavid Marchand 			break;
96990c26386SDavid Marchand 		case TESTPMD_OPT_STATS_PERIOD_NUM: {
970cfea1f30SPablo de Lara 			char *end = NULL;
971cfea1f30SPablo de Lara 			unsigned int n;
972cfea1f30SPablo de Lara 
973cfea1f30SPablo de Lara 			n = strtoul(optarg, &end, 10);
974cfea1f30SPablo de Lara 			if ((optarg[0] == '\0') || (end == NULL) ||
975cfea1f30SPablo de Lara 					(*end != '\0'))
9762ae06c57SDavid Marchand 				rte_exit(EXIT_FAILURE, "Invalid stats-period value\n");
977cfea1f30SPablo de Lara 
978cfea1f30SPablo de Lara 			stats_period = n;
979cfea1f30SPablo de Lara 			break;
980cfea1f30SPablo de Lara 		}
98190c26386SDavid Marchand 		case TESTPMD_OPT_DISPLAY_XSTATS_NUM: {
98263b72657SIvan Ilchenko 			char rc;
98363b72657SIvan Ilchenko 
98463b72657SIvan Ilchenko 			rc = parse_xstats_list(optarg, &xstats_display,
98563b72657SIvan Ilchenko 				&xstats_display_num);
98663b72657SIvan Ilchenko 			if (rc != 0)
98763b72657SIvan Ilchenko 				rte_exit(EXIT_FAILURE,
98863b72657SIvan Ilchenko 					"Failed to parse display-xstats argument: %d\n",
98963b72657SIvan Ilchenko 					rc);
99090c26386SDavid Marchand 			break;
99163b72657SIvan Ilchenko 		}
99290c26386SDavid Marchand 		case TESTPMD_OPT_ETH_PEERS_CONFIGFILE_NUM:
993af75078fSIntel 			if (init_peer_eth_addrs(optarg) != 0)
994af75078fSIntel 				rte_exit(EXIT_FAILURE,
995af75078fSIntel 					"Cannot open logfile\n");
99690c26386SDavid Marchand 			break;
99790c26386SDavid Marchand 		case TESTPMD_OPT_ETH_PEER_NUM: {
998af75078fSIntel 			char *port_end;
999af75078fSIntel 
1000af75078fSIntel 			errno = 0;
1001af75078fSIntel 			n = strtoul(optarg, &port_end, 10);
1002af75078fSIntel 			if (errno != 0 || port_end == optarg || *port_end++ != ',')
1003af75078fSIntel 				rte_exit(EXIT_FAILURE,
1004af75078fSIntel 					"Invalid eth-peer: %s", optarg);
1005af75078fSIntel 			if (n >= RTE_MAX_ETHPORTS)
1006af75078fSIntel 				rte_exit(EXIT_FAILURE,
1007af75078fSIntel 					"eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n",
1008af75078fSIntel 					n, RTE_MAX_ETHPORTS);
1009af75078fSIntel 
1010b5ddce89SStephen Hemminger 			if (rte_ether_unformat_addr(port_end,
1011b5ddce89SStephen Hemminger 					&peer_eth_addrs[n]) < 0)
1012af75078fSIntel 				rte_exit(EXIT_FAILURE,
1013af75078fSIntel 					"Invalid ethernet address: %s\n",
1014af75078fSIntel 					port_end);
1015af75078fSIntel 			nb_peer_eth_addrs++;
101690c26386SDavid Marchand 			break;
1017af75078fSIntel 		}
101890c26386SDavid Marchand 		case TESTPMD_OPT_TX_IP_NUM: {
1019bf5b2126SStephen Hemminger 			struct in_addr in;
1020bf5b2126SStephen Hemminger 			char *end;
1021bf5b2126SStephen Hemminger 
1022bf5b2126SStephen Hemminger 			end = strchr(optarg, ',');
1023bf5b2126SStephen Hemminger 			if (end == optarg || !end)
1024bf5b2126SStephen Hemminger 				rte_exit(EXIT_FAILURE,
1025bf5b2126SStephen Hemminger 					"Invalid tx-ip: %s", optarg);
1026bf5b2126SStephen Hemminger 
1027bf5b2126SStephen Hemminger 			*end++ = 0;
1028761f7ae1SJie Zhou 			if (inet_pton(AF_INET, optarg, &in) == 0)
1029bf5b2126SStephen Hemminger 				rte_exit(EXIT_FAILURE,
1030bf5b2126SStephen Hemminger 					"Invalid source IP address: %s\n",
1031bf5b2126SStephen Hemminger 					optarg);
1032bf5b2126SStephen Hemminger 			tx_ip_src_addr = rte_be_to_cpu_32(in.s_addr);
1033bf5b2126SStephen Hemminger 
1034761f7ae1SJie Zhou 			if (inet_pton(AF_INET, end, &in) == 0)
1035bf5b2126SStephen Hemminger 				rte_exit(EXIT_FAILURE,
1036bf5b2126SStephen Hemminger 					"Invalid destination IP address: %s\n",
1037bf5b2126SStephen Hemminger 					optarg);
1038bf5b2126SStephen Hemminger 			tx_ip_dst_addr = rte_be_to_cpu_32(in.s_addr);
103990c26386SDavid Marchand 			break;
1040bf5b2126SStephen Hemminger 		}
104190c26386SDavid Marchand 		case TESTPMD_OPT_TX_UDP_NUM: {
1042bf5b2126SStephen Hemminger 			char *end = NULL;
1043bf5b2126SStephen Hemminger 
1044bf5b2126SStephen Hemminger 			errno = 0;
1045bf5b2126SStephen Hemminger 			n = strtoul(optarg, &end, 10);
1046bf5b2126SStephen Hemminger 			if (errno != 0 || end == optarg ||
1047bf5b2126SStephen Hemminger 					n > UINT16_MAX ||
1048bf5b2126SStephen Hemminger 					!(*end == '\0' || *end == ','))
1049bf5b2126SStephen Hemminger 				rte_exit(EXIT_FAILURE,
1050bf5b2126SStephen Hemminger 					"Invalid UDP port: %s\n",
1051bf5b2126SStephen Hemminger 					optarg);
1052bf5b2126SStephen Hemminger 			tx_udp_src_port = n;
1053bf5b2126SStephen Hemminger 			if (*end == ',') {
1054bf5b2126SStephen Hemminger 				char *dst = end + 1;
1055bf5b2126SStephen Hemminger 
1056bf5b2126SStephen Hemminger 				n = strtoul(dst, &end, 10);
1057bf5b2126SStephen Hemminger 				if (errno != 0 || end == dst ||
1058bf5b2126SStephen Hemminger 						n > UINT16_MAX || *end)
1059bf5b2126SStephen Hemminger 					rte_exit(EXIT_FAILURE,
1060bf5b2126SStephen Hemminger 						"Invalid destination UDP port: %s\n",
1061bf5b2126SStephen Hemminger 						dst);
1062bf5b2126SStephen Hemminger 				tx_udp_dst_port = n;
1063bf5b2126SStephen Hemminger 			} else {
1064bf5b2126SStephen Hemminger 				tx_udp_dst_port = n;
1065bf5b2126SStephen Hemminger 			}
106690c26386SDavid Marchand 			break;
1067bf5b2126SStephen Hemminger 		}
106890c26386SDavid Marchand 		case TESTPMD_OPT_NB_PORTS_NUM:
1069af75078fSIntel 			n = atoi(optarg);
10700a530f0dSYong Liu 			if (n > 0 && n <= nb_ports)
1071f8244c63SZhiyong Yang 				nb_fwd_ports = n;
1072af75078fSIntel 			else
1073af75078fSIntel 				rte_exit(EXIT_FAILURE,
1074edab33b1STetsuya Mukawa 					"Invalid port %d\n", n);
107590c26386SDavid Marchand 			break;
107690c26386SDavid Marchand 		case TESTPMD_OPT_NB_CORES_NUM:
1077af75078fSIntel 			n = atoi(optarg);
10782bf44dd1SSivaprasad Tummala 			if (n > 0 && (lcoreid_t)n <= nb_lcores)
10792bf44dd1SSivaprasad Tummala 				nb_fwd_lcores = (lcoreid_t) n;
1080af75078fSIntel 			else
1081af75078fSIntel 				rte_exit(EXIT_FAILURE,
1082af75078fSIntel 					"nb-cores should be > 0 and <= %d\n",
1083af75078fSIntel 					nb_lcores);
108490c26386SDavid Marchand 			break;
108590c26386SDavid Marchand 		case TESTPMD_OPT_COREMASK_NUM:
1086af75078fSIntel 			parse_fwd_coremask(optarg);
108790c26386SDavid Marchand 			break;
108890c26386SDavid Marchand 		case TESTPMD_OPT_PORTMASK_NUM:
1089af75078fSIntel 			parse_fwd_portmask(optarg);
109090c26386SDavid Marchand 			break;
109190c26386SDavid Marchand 		case TESTPMD_OPT_PORTLIST_NUM:
10922df00d56SHariprasad Govindharajan 			parse_fwd_portlist(optarg);
109390c26386SDavid Marchand 			break;
109490c26386SDavid Marchand 		case TESTPMD_OPT_NO_NUMA_NUM:
1095999b2ee0SBruce Richardson 			numa_support = 0;
109690c26386SDavid Marchand 			break;
109790c26386SDavid Marchand 		case TESTPMD_OPT_NUMA_NUM:
1098af75078fSIntel 			numa_support = 1;
109990c26386SDavid Marchand 			break;
110090c26386SDavid Marchand 		case TESTPMD_OPT_MP_ANON_NUM:
1101c7f5dba7SAnatoly Burakov 			mp_alloc_type = MP_ALLOC_ANON;
110290c26386SDavid Marchand 			break;
110390c26386SDavid Marchand 		case TESTPMD_OPT_MP_ALLOC_NUM:
1104c7f5dba7SAnatoly Burakov 			if (!strcmp(optarg, "native"))
1105c7f5dba7SAnatoly Burakov 				mp_alloc_type = MP_ALLOC_NATIVE;
1106c7f5dba7SAnatoly Burakov 			else if (!strcmp(optarg, "anon"))
1107c7f5dba7SAnatoly Burakov 				mp_alloc_type = MP_ALLOC_ANON;
1108c7f5dba7SAnatoly Burakov 			else if (!strcmp(optarg, "xmem"))
1109c7f5dba7SAnatoly Burakov 				mp_alloc_type = MP_ALLOC_XMEM;
1110c7f5dba7SAnatoly Burakov 			else if (!strcmp(optarg, "xmemhuge"))
1111c7f5dba7SAnatoly Burakov 				mp_alloc_type = MP_ALLOC_XMEM_HUGE;
111272512e18SViacheslav Ovsiienko 			else if (!strcmp(optarg, "xbuf"))
111372512e18SViacheslav Ovsiienko 				mp_alloc_type = MP_ALLOC_XBUF;
1114c7f5dba7SAnatoly Burakov 			else
1115c7f5dba7SAnatoly Burakov 				rte_exit(EXIT_FAILURE,
1116c7f5dba7SAnatoly Burakov 					"mp-alloc %s invalid - must be: "
1117c7f5dba7SAnatoly Burakov 					"native, anon, xmem or xmemhuge\n",
1118c7f5dba7SAnatoly Burakov 					optarg);
111990c26386SDavid Marchand 			break;
112090c26386SDavid Marchand 		case TESTPMD_OPT_PORT_NUMA_CONFIG_NUM:
1121b6ea6408SIntel 			if (parse_portnuma_config(optarg))
1122b6ea6408SIntel 				rte_exit(EXIT_FAILURE,
1123b6ea6408SIntel 					"invalid port-numa configuration\n");
112490c26386SDavid Marchand 			break;
112590c26386SDavid Marchand 		case TESTPMD_OPT_RING_NUMA_CONFIG_NUM:
1126b6ea6408SIntel 			if (parse_ringnuma_config(optarg))
1127b6ea6408SIntel 				rte_exit(EXIT_FAILURE,
1128b6ea6408SIntel 					"invalid ring-numa configuration\n");
112990c26386SDavid Marchand 			break;
113090c26386SDavid Marchand 		case TESTPMD_OPT_SOCKET_NUM_NUM:
1131b6ea6408SIntel 			n = atoi(optarg);
1132c9cafcc8SShahaf Shuler 			if (!new_socket_id((uint8_t)n)) {
1133b6ea6408SIntel 				socket_num = (uint8_t)n;
1134c9cafcc8SShahaf Shuler 			} else {
1135c9cafcc8SShahaf Shuler 				print_invalid_socket_id_error();
1136b6ea6408SIntel 				rte_exit(EXIT_FAILURE,
1137c9cafcc8SShahaf Shuler 					"Invalid socket id");
1138c9cafcc8SShahaf Shuler 			}
113990c26386SDavid Marchand 			break;
114090c26386SDavid Marchand 		case TESTPMD_OPT_MBUF_SIZE_NUM: {
114126cbb419SViacheslav Ovsiienko 			unsigned int mb_sz[MAX_SEGS_BUFFER_SPLIT];
114226cbb419SViacheslav Ovsiienko 			unsigned int nb_segs, i;
114326cbb419SViacheslav Ovsiienko 
114426cbb419SViacheslav Ovsiienko 			nb_segs = parse_item_list(optarg, "mbuf-size",
114526cbb419SViacheslav Ovsiienko 				MAX_SEGS_BUFFER_SPLIT, mb_sz, 0);
114626cbb419SViacheslav Ovsiienko 			if (nb_segs <= 0)
1147af75078fSIntel 				rte_exit(EXIT_FAILURE,
114826cbb419SViacheslav Ovsiienko 					"bad mbuf-size\n");
114926cbb419SViacheslav Ovsiienko 			for (i = 0; i < nb_segs; i++) {
115026cbb419SViacheslav Ovsiienko 				if (mb_sz[i] <= 0 || mb_sz[i] > 0xFFFF)
115126cbb419SViacheslav Ovsiienko 					rte_exit(EXIT_FAILURE,
115226cbb419SViacheslav Ovsiienko 						"mbuf-size should be "
115326cbb419SViacheslav Ovsiienko 						"> 0 and < 65536\n");
115426cbb419SViacheslav Ovsiienko 				mbuf_data_size[i] = (uint16_t) mb_sz[i];
115526cbb419SViacheslav Ovsiienko 			}
115626cbb419SViacheslav Ovsiienko 			mbuf_data_size_n = nb_segs;
115790c26386SDavid Marchand 			break;
1158af75078fSIntel 		}
115990c26386SDavid Marchand 		case TESTPMD_OPT_TOTAL_NUM_MBUFS_NUM:
1160c8798818SIntel 			n = atoi(optarg);
116157d91f5bSMingxia Liu 			if (n > MIN_TOTAL_NUM_MBUFS)
116290c26386SDavid Marchand 				param_total_num_mbufs = (unsigned int)n;
1163c8798818SIntel 			else
1164c8798818SIntel 				rte_exit(EXIT_FAILURE,
116557d91f5bSMingxia Liu 					"total-num-mbufs should be > %d\n",
116657d91f5bSMingxia Liu 					MIN_TOTAL_NUM_MBUFS);
116790c26386SDavid Marchand 			break;
116890c26386SDavid Marchand 		case TESTPMD_OPT_MAX_PKT_LEN_NUM:
1169af75078fSIntel 			n = atoi(optarg);
1170761c4d66SSteve Yang 			if (n >= RTE_ETHER_MIN_LEN)
11711bb4a528SFerruh Yigit 				max_rx_pkt_len = n;
1172761c4d66SSteve Yang 			else
1173af75078fSIntel 				rte_exit(EXIT_FAILURE,
1174af75078fSIntel 					"Invalid max-pkt-len=%d - should be > %d\n",
117535b2d13fSOlivier Matz 					n, RTE_ETHER_MIN_LEN);
117690c26386SDavid Marchand 			break;
117790c26386SDavid Marchand 		case TESTPMD_OPT_MAX_LRO_PKT_SIZE_NUM:
11784a729092SDekel Peled 			n = atoi(optarg);
11794a729092SDekel Peled 			rx_mode.max_lro_pkt_size = (uint32_t) n;
118090c26386SDavid Marchand 			break;
1181a8d0d473SBruce Richardson #ifdef RTE_LIB_LATENCYSTATS
118290c26386SDavid Marchand 		case TESTPMD_OPT_LATENCYSTATS_NUM:
118362d3216dSReshma Pattan 			n = atoi(optarg);
118462d3216dSReshma Pattan 			if (n >= 0) {
118562d3216dSReshma Pattan 				latencystats_lcore_id = (lcoreid_t) n;
118662d3216dSReshma Pattan 				latencystats_enabled = 1;
118762d3216dSReshma Pattan 			} else
118862d3216dSReshma Pattan 				rte_exit(EXIT_FAILURE,
118962d3216dSReshma Pattan 					"invalid lcore id %d for latencystats"
119062d3216dSReshma Pattan 					" must be >= 0\n", n);
119190c26386SDavid Marchand 
119290c26386SDavid Marchand 			break;
119362d3216dSReshma Pattan #endif
1194a8d0d473SBruce Richardson #ifdef RTE_LIB_BITRATESTATS
119590c26386SDavid Marchand 		case TESTPMD_OPT_BITRATE_STATS_NUM:
1196e25e6c70SRemy Horton 			n = atoi(optarg);
1197e25e6c70SRemy Horton 			if (n >= 0) {
1198e25e6c70SRemy Horton 				bitrate_lcore_id = (lcoreid_t) n;
1199e25e6c70SRemy Horton 				bitrate_enabled = 1;
1200e25e6c70SRemy Horton 			} else
1201e25e6c70SRemy Horton 				rte_exit(EXIT_FAILURE,
1202e25e6c70SRemy Horton 					"invalid lcore id %d for bitrate stats"
1203e25e6c70SRemy Horton 					" must be >= 0\n", n);
120490c26386SDavid Marchand 			break;
1205e25e6c70SRemy Horton #endif
120690c26386SDavid Marchand 		case TESTPMD_OPT_DISABLE_CRC_STRIP_NUM:
1207295968d1SFerruh Yigit 			rx_offloads |= RTE_ETH_RX_OFFLOAD_KEEP_CRC;
120890c26386SDavid Marchand 			break;
120990c26386SDavid Marchand 		case TESTPMD_OPT_ENABLE_LRO_NUM:
1210295968d1SFerruh Yigit 			rx_offloads |= RTE_ETH_RX_OFFLOAD_TCP_LRO;
121190c26386SDavid Marchand 			break;
121290c26386SDavid Marchand 		case TESTPMD_OPT_ENABLE_SCATTER_NUM:
1213295968d1SFerruh Yigit 			rx_offloads |= RTE_ETH_RX_OFFLOAD_SCATTER;
121490c26386SDavid Marchand 			break;
121590c26386SDavid Marchand 		case TESTPMD_OPT_ENABLE_RX_CKSUM_NUM:
1216295968d1SFerruh Yigit 			rx_offloads |= RTE_ETH_RX_OFFLOAD_CHECKSUM;
121790c26386SDavid Marchand 			break;
121890c26386SDavid Marchand 		case TESTPMD_OPT_ENABLE_RX_TIMESTAMP_NUM:
1219295968d1SFerruh Yigit 			rx_offloads |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
122090c26386SDavid Marchand 			break;
122190c26386SDavid Marchand 		case TESTPMD_OPT_ENABLE_HW_VLAN_NUM:
1222295968d1SFerruh Yigit 			rx_offloads |= RTE_ETH_RX_OFFLOAD_VLAN;
122390c26386SDavid Marchand 			break;
122490c26386SDavid Marchand 		case TESTPMD_OPT_ENABLE_HW_VLAN_FILTER_NUM:
1225295968d1SFerruh Yigit 			rx_offloads |= RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
122690c26386SDavid Marchand 			break;
122790c26386SDavid Marchand 		case TESTPMD_OPT_ENABLE_HW_VLAN_STRIP_NUM:
1228295968d1SFerruh Yigit 			rx_offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
122990c26386SDavid Marchand 			break;
123090c26386SDavid Marchand 		case TESTPMD_OPT_ENABLE_HW_VLAN_EXTEND_NUM:
1231295968d1SFerruh Yigit 			rx_offloads |= RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
123290c26386SDavid Marchand 			break;
123390c26386SDavid Marchand 		case TESTPMD_OPT_ENABLE_HW_QINQ_STRIP_NUM:
1234295968d1SFerruh Yigit 			rx_offloads |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
123590c26386SDavid Marchand 			break;
123690c26386SDavid Marchand 		case TESTPMD_OPT_ENABLE_DROP_EN_NUM:
1237ce8d5614SIntel 			rx_drop_en = 1;
123890c26386SDavid Marchand 			break;
123990c26386SDavid Marchand 		case TESTPMD_OPT_DISABLE_RSS_NUM:
1240af75078fSIntel 			rss_hf = 0;
124190c26386SDavid Marchand 			break;
124290c26386SDavid Marchand 		case TESTPMD_OPT_PORT_TOPOLOGY_NUM:
1243af75078fSIntel 			if (!strcmp(optarg, "paired"))
1244af75078fSIntel 				port_topology = PORT_TOPOLOGY_PAIRED;
1245af75078fSIntel 			else if (!strcmp(optarg, "chained"))
1246af75078fSIntel 				port_topology = PORT_TOPOLOGY_CHAINED;
12473e2006d6SCyril Chemparathy 			else if (!strcmp(optarg, "loop"))
12483e2006d6SCyril Chemparathy 				port_topology = PORT_TOPOLOGY_LOOP;
1249af75078fSIntel 			else
1250af75078fSIntel 				rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
125175358833SPablo de Lara 					" must be: paired, chained or loop\n",
1252af75078fSIntel 					optarg);
125390c26386SDavid Marchand 			break;
125490c26386SDavid Marchand 		case TESTPMD_OPT_FORWARD_MODE_NUM:
1255ce9b9fb0SCyril Chemparathy 			set_pkt_forwarding_mode(optarg);
125690c26386SDavid Marchand 			break;
125790c26386SDavid Marchand 		case TESTPMD_OPT_RSS_IP_NUM:
1258295968d1SFerruh Yigit 			rss_hf = RTE_ETH_RSS_IP;
125990c26386SDavid Marchand 			break;
126090c26386SDavid Marchand 		case TESTPMD_OPT_RSS_UDP_NUM:
1261295968d1SFerruh Yigit 			rss_hf = RTE_ETH_RSS_UDP;
126290c26386SDavid Marchand 			break;
126390c26386SDavid Marchand 		case TESTPMD_OPT_RSS_LEVEL_INNER_NUM:
1264295968d1SFerruh Yigit 			rss_hf |= RTE_ETH_RSS_LEVEL_INNERMOST;
126590c26386SDavid Marchand 			break;
126690c26386SDavid Marchand 		case TESTPMD_OPT_RSS_LEVEL_OUTER_NUM:
1267295968d1SFerruh Yigit 			rss_hf |= RTE_ETH_RSS_LEVEL_OUTERMOST;
126890c26386SDavid Marchand 			break;
126990c26386SDavid Marchand 		case TESTPMD_OPT_RXQ_NUM:
1270af75078fSIntel 			n = atoi(optarg);
12713f7311baSWei Dai 			if (n >= 0 && check_nb_rxq((queueid_t)n) == 0)
1272af75078fSIntel 				nb_rxq = (queueid_t) n;
1273af75078fSIntel 			else
1274af75078fSIntel 				rte_exit(EXIT_FAILURE, "rxq %d invalid - must be"
12753f7311baSWei Dai 					" >= 0 && <= %u\n", n,
12763f7311baSWei Dai 					get_allowed_max_nb_rxq(&pid));
127790c26386SDavid Marchand 			break;
127890c26386SDavid Marchand 		case TESTPMD_OPT_TXQ_NUM:
1279af75078fSIntel 			n = atoi(optarg);
128036db4f6cSWei Dai 			if (n >= 0 && check_nb_txq((queueid_t)n) == 0)
1281af75078fSIntel 				nb_txq = (queueid_t) n;
1282af75078fSIntel 			else
1283af75078fSIntel 				rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
128436db4f6cSWei Dai 					" >= 0 && <= %u\n", n,
128536db4f6cSWei Dai 					get_allowed_max_nb_txq(&pid));
128690c26386SDavid Marchand 			break;
128790c26386SDavid Marchand 		case TESTPMD_OPT_HAIRPINQ_NUM:
12881c69df45SOri Kam 			n = atoi(optarg);
12891c69df45SOri Kam 			if (n >= 0 &&
12901c69df45SOri Kam 					check_nb_hairpinq((queueid_t)n) == 0)
12911c69df45SOri Kam 				nb_hairpinq = (queueid_t) n;
12921c69df45SOri Kam 			else
12931c69df45SOri Kam 				rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
12941c69df45SOri Kam 					" >= 0 && <= %u\n", n,
12951c69df45SOri Kam 					get_allowed_max_nb_hairpinq
12961c69df45SOri Kam 					(&pid));
12971c69df45SOri Kam 			if ((n + nb_txq) < 0 ||
12981c69df45SOri Kam 					check_nb_txq((queueid_t)(n + nb_txq)) != 0)
12991c69df45SOri Kam 				rte_exit(EXIT_FAILURE, "txq + hairpinq "
13001c69df45SOri Kam 					"%d invalid - must be"
13011c69df45SOri Kam 					" >= 0 && <= %u\n",
13021c69df45SOri Kam 					n + nb_txq,
13031c69df45SOri Kam 					get_allowed_max_nb_txq(&pid));
13041c69df45SOri Kam 			if ((n + nb_rxq) < 0 ||
13051c69df45SOri Kam 					check_nb_rxq((queueid_t)(n + nb_rxq)) != 0)
13061c69df45SOri Kam 				rte_exit(EXIT_FAILURE, "rxq + hairpinq "
13071c69df45SOri Kam 					"%d invalid - must be"
13081c69df45SOri Kam 					" >= 0 && <= %u\n",
13091c69df45SOri Kam 					n + nb_rxq,
13101c69df45SOri Kam 					get_allowed_max_nb_rxq(&pid));
131190c26386SDavid Marchand 			break;
131290c26386SDavid Marchand 		case TESTPMD_OPT_HAIRPIN_MODE_NUM: {
131301817b10SBing Zhao 			char *end = NULL;
131401817b10SBing Zhao 			unsigned int n;
131501817b10SBing Zhao 
131601817b10SBing Zhao 			errno = 0;
131701817b10SBing Zhao 			n = strtoul(optarg, &end, 0);
131801817b10SBing Zhao 			if (errno != 0 || end == optarg)
131901817b10SBing Zhao 				rte_exit(EXIT_FAILURE, "hairpin mode invalid\n");
132001817b10SBing Zhao 			else
132123095155SDariusz Sosnowski 				hairpin_mode = (uint32_t)n;
132290c26386SDavid Marchand 			break;
132301817b10SBing Zhao 		}
1324*5334c3feSGregory Etelson 		case TESTPMD_OPT_HAIRPIN_MAP_NUM:
1325*5334c3feSGregory Etelson 			hairpin_multiport_mode = true;
1326*5334c3feSGregory Etelson 			ret = parse_hairpin_map(optarg);
1327*5334c3feSGregory Etelson 			if (ret)
1328*5334c3feSGregory Etelson 				rte_exit(EXIT_FAILURE, "invalid hairpin map\n");
1329*5334c3feSGregory Etelson 			break;
133090c26386SDavid Marchand 		case TESTPMD_OPT_BURST_NUM:
1331af75078fSIntel 			n = atoi(optarg);
13328599ed31SRemy Horton 			if (n == 0) {
13338599ed31SRemy Horton 				/* A burst size of zero means that the
13348599ed31SRemy Horton 				 * PMD should be queried for
13358599ed31SRemy Horton 				 * recommended Rx burst size. Since
13368599ed31SRemy Horton 				 * testpmd uses a single size for all
13378599ed31SRemy Horton 				 * ports, port 0 is queried for the
13388599ed31SRemy Horton 				 * value, on the assumption that all
13398599ed31SRemy Horton 				 * ports are of the same NIC model.
13408599ed31SRemy Horton 				 */
13416f51deb9SIvan Ilchenko 				ret = eth_dev_info_get_print_err(
13426f51deb9SIvan Ilchenko 					0,
13436f51deb9SIvan Ilchenko 					&dev_info);
13446f51deb9SIvan Ilchenko 				if (ret != 0)
13456fa896aeSDavid Marchand 					rte_exit(EXIT_FAILURE, "Failed to get driver "
13466fa896aeSDavid Marchand 						"recommended burst size, please provide a "
13476fa896aeSDavid Marchand 						"value between 1 and %d\n", MAX_PKT_BURST);
13486f51deb9SIvan Ilchenko 
13498599ed31SRemy Horton 				rec_nb_pkts = dev_info
13508599ed31SRemy Horton 					.default_rxportconf.burst_size;
13518599ed31SRemy Horton 
13528599ed31SRemy Horton 				if (rec_nb_pkts == 0)
1353af75078fSIntel 					rte_exit(EXIT_FAILURE,
13548599ed31SRemy Horton 						"PMD does not recommend a burst size. "
13558599ed31SRemy Horton 						"Provided value must be between "
13568599ed31SRemy Horton 						"1 and %d\n", MAX_PKT_BURST);
13578599ed31SRemy Horton 				else if (rec_nb_pkts > MAX_PKT_BURST)
13588599ed31SRemy Horton 					rte_exit(EXIT_FAILURE,
13598599ed31SRemy Horton 						"PMD recommended burst size of %d"
13608599ed31SRemy Horton 						" exceeds maximum value of %d\n",
13618599ed31SRemy Horton 						rec_nb_pkts, MAX_PKT_BURST);
13628599ed31SRemy Horton 				printf("Using PMD-provided burst value of %d\n",
13638599ed31SRemy Horton 					rec_nb_pkts);
13648599ed31SRemy Horton 				nb_pkt_per_burst = rec_nb_pkts;
13658599ed31SRemy Horton 			} else if (n > MAX_PKT_BURST)
13668599ed31SRemy Horton 				rte_exit(EXIT_FAILURE,
13678599ed31SRemy Horton 					"burst must be between1 and %d\n",
1368af75078fSIntel 					MAX_PKT_BURST);
13698599ed31SRemy Horton 			else
13708599ed31SRemy Horton 				nb_pkt_per_burst = (uint16_t) n;
137190c26386SDavid Marchand 			break;
137290c26386SDavid Marchand 		case TESTPMD_OPT_FLOWGEN_CLONES_NUM:
13736c02043eSIgor Russkikh 			n = atoi(optarg);
13746c02043eSIgor Russkikh 			if (n >= 0)
13756c02043eSIgor Russkikh 				nb_pkt_flowgen_clones = (uint16_t) n;
13766c02043eSIgor Russkikh 			else
13776c02043eSIgor Russkikh 				rte_exit(EXIT_FAILURE,
13786c02043eSIgor Russkikh 					"clones must be >= 0 and <= current burst\n");
137990c26386SDavid Marchand 			break;
138090c26386SDavid Marchand 		case TESTPMD_OPT_FLOWGEN_FLOWS_NUM:
1381861e7684SZhihong Wang 			n = atoi(optarg);
1382861e7684SZhihong Wang 			if (n > 0)
1383861e7684SZhihong Wang 				nb_flows_flowgen = (int) n;
1384861e7684SZhihong Wang 			else
1385861e7684SZhihong Wang 				rte_exit(EXIT_FAILURE,
1386861e7684SZhihong Wang 					"flows must be >= 1\n");
138790c26386SDavid Marchand 			break;
138890c26386SDavid Marchand 		case TESTPMD_OPT_MBCACHE_NUM:
1389af75078fSIntel 			n = atoi(optarg);
1390af75078fSIntel 			if ((n >= 0) &&
1391af75078fSIntel 					(n <= RTE_MEMPOOL_CACHE_MAX_SIZE))
1392af75078fSIntel 				mb_mempool_cache = (uint16_t) n;
1393af75078fSIntel 			else
1394af75078fSIntel 				rte_exit(EXIT_FAILURE,
1395af75078fSIntel 					"mbcache must be >= 0 and <= %d\n",
1396af75078fSIntel 					RTE_MEMPOOL_CACHE_MAX_SIZE);
139790c26386SDavid Marchand 			break;
139890c26386SDavid Marchand 		case TESTPMD_OPT_TXFREET_NUM:
1399af75078fSIntel 			n = atoi(optarg);
1400af75078fSIntel 			if (n >= 0)
1401f2c5125aSPablo de Lara 				tx_free_thresh = (int16_t)n;
1402af75078fSIntel 			else
1403af75078fSIntel 				rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n");
140490c26386SDavid Marchand 			break;
140590c26386SDavid Marchand 		case TESTPMD_OPT_TXRST_NUM:
1406af75078fSIntel 			n = atoi(optarg);
1407af75078fSIntel 			if (n >= 0)
1408f2c5125aSPablo de Lara 				tx_rs_thresh = (int16_t)n;
1409af75078fSIntel 			else
1410af75078fSIntel 				rte_exit(EXIT_FAILURE, "txrst must be >= 0\n");
141190c26386SDavid Marchand 			break;
141290c26386SDavid Marchand 		case TESTPMD_OPT_RXD_NUM:
1413af75078fSIntel 			n = atoi(optarg);
1414af75078fSIntel 			if (n > 0) {
1415af75078fSIntel 				if (rx_free_thresh >= n)
1416af75078fSIntel 					rte_exit(EXIT_FAILURE,
1417af75078fSIntel 						"rxd must be > "
1418af75078fSIntel 						"rx_free_thresh(%d)\n",
1419af75078fSIntel 						(int)rx_free_thresh);
1420af75078fSIntel 				else
1421af75078fSIntel 					nb_rxd = (uint16_t) n;
1422af75078fSIntel 			} else
1423af75078fSIntel 				rte_exit(EXIT_FAILURE,
1424af75078fSIntel 					"rxd(%d) invalid - must be > 0\n",
1425af75078fSIntel 					n);
142690c26386SDavid Marchand 			break;
142790c26386SDavid Marchand 		case TESTPMD_OPT_TXD_NUM:
1428af75078fSIntel 			n = atoi(optarg);
1429af75078fSIntel 			if (n > 0)
1430af75078fSIntel 				nb_txd = (uint16_t) n;
1431af75078fSIntel 			else
1432af75078fSIntel 				rte_exit(EXIT_FAILURE, "txd must be in > 0\n");
143390c26386SDavid Marchand 			break;
143490c26386SDavid Marchand 		case TESTPMD_OPT_TXPT_NUM:
1435af75078fSIntel 			n = atoi(optarg);
1436af75078fSIntel 			if (n >= 0)
1437f2c5125aSPablo de Lara 				tx_pthresh = (int8_t)n;
1438af75078fSIntel 			else
1439af75078fSIntel 				rte_exit(EXIT_FAILURE, "txpt must be >= 0\n");
144090c26386SDavid Marchand 			break;
144190c26386SDavid Marchand 		case TESTPMD_OPT_TXHT_NUM:
1442af75078fSIntel 			n = atoi(optarg);
1443af75078fSIntel 			if (n >= 0)
1444f2c5125aSPablo de Lara 				tx_hthresh = (int8_t)n;
1445af75078fSIntel 			else
1446af75078fSIntel 				rte_exit(EXIT_FAILURE, "txht must be >= 0\n");
144790c26386SDavid Marchand 			break;
144890c26386SDavid Marchand 		case TESTPMD_OPT_TXWT_NUM:
1449af75078fSIntel 			n = atoi(optarg);
1450af75078fSIntel 			if (n >= 0)
1451f2c5125aSPablo de Lara 				tx_wthresh = (int8_t)n;
1452af75078fSIntel 			else
1453af75078fSIntel 				rte_exit(EXIT_FAILURE, "txwt must be >= 0\n");
145490c26386SDavid Marchand 			break;
145590c26386SDavid Marchand 		case TESTPMD_OPT_RXPT_NUM:
1456af75078fSIntel 			n = atoi(optarg);
1457af75078fSIntel 			if (n >= 0)
1458f2c5125aSPablo de Lara 				rx_pthresh = (int8_t)n;
1459af75078fSIntel 			else
1460af75078fSIntel 				rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n");
146190c26386SDavid Marchand 			break;
146290c26386SDavid Marchand 		case TESTPMD_OPT_RXHT_NUM:
1463af75078fSIntel 			n = atoi(optarg);
1464af75078fSIntel 			if (n >= 0)
1465f2c5125aSPablo de Lara 				rx_hthresh = (int8_t)n;
1466af75078fSIntel 			else
1467af75078fSIntel 				rte_exit(EXIT_FAILURE, "rxht must be >= 0\n");
146890c26386SDavid Marchand 			break;
146990c26386SDavid Marchand 		case TESTPMD_OPT_RXWT_NUM:
1470af75078fSIntel 			n = atoi(optarg);
1471af75078fSIntel 			if (n >= 0)
1472f2c5125aSPablo de Lara 				rx_wthresh = (int8_t)n;
1473af75078fSIntel 			else
1474af75078fSIntel 				rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n");
147590c26386SDavid Marchand 			break;
147690c26386SDavid Marchand 		case TESTPMD_OPT_RXFREET_NUM:
1477af75078fSIntel 			n = atoi(optarg);
1478af75078fSIntel 			if (n >= 0)
1479f2c5125aSPablo de Lara 				rx_free_thresh = (int16_t)n;
1480af75078fSIntel 			else
1481af75078fSIntel 				rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n");
148290c26386SDavid Marchand 			break;
148390c26386SDavid Marchand 		case TESTPMD_OPT_RXOFFS_NUM: {
148491c78e09SViacheslav Ovsiienko 			unsigned int seg_off[MAX_SEGS_BUFFER_SPLIT];
148591c78e09SViacheslav Ovsiienko 			unsigned int nb_offs;
148691c78e09SViacheslav Ovsiienko 
148791c78e09SViacheslav Ovsiienko 			nb_offs = parse_item_list
148891c78e09SViacheslav Ovsiienko 				(optarg, "rxpkt offsets",
148991c78e09SViacheslav Ovsiienko 				MAX_SEGS_BUFFER_SPLIT,
149091c78e09SViacheslav Ovsiienko 				seg_off, 0);
149191c78e09SViacheslav Ovsiienko 			if (nb_offs > 0)
149291c78e09SViacheslav Ovsiienko 				set_rx_pkt_offsets(seg_off, nb_offs);
149391c78e09SViacheslav Ovsiienko 			else
149491c78e09SViacheslav Ovsiienko 				rte_exit(EXIT_FAILURE, "bad rxoffs\n");
149590c26386SDavid Marchand 			break;
149691c78e09SViacheslav Ovsiienko 		}
149790c26386SDavid Marchand 		case TESTPMD_OPT_RXPKTS_NUM: {
14980f2096d7SViacheslav Ovsiienko 			unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT];
14990f2096d7SViacheslav Ovsiienko 			unsigned int nb_segs;
150090c26386SDavid Marchand 
15010f2096d7SViacheslav Ovsiienko 			nb_segs = parse_item_list
15020f2096d7SViacheslav Ovsiienko 				(optarg, "rxpkt segments",
15030f2096d7SViacheslav Ovsiienko 				MAX_SEGS_BUFFER_SPLIT,
15040f2096d7SViacheslav Ovsiienko 				seg_len, 0);
15050f2096d7SViacheslav Ovsiienko 			if (nb_segs > 0)
15060f2096d7SViacheslav Ovsiienko 				set_rx_pkt_segments(seg_len, nb_segs);
15070f2096d7SViacheslav Ovsiienko 			else
15080f2096d7SViacheslav Ovsiienko 				rte_exit(EXIT_FAILURE, "bad rxpkts\n");
150990c26386SDavid Marchand 			break;
15100f2096d7SViacheslav Ovsiienko 		}
151190c26386SDavid Marchand 		case TESTPMD_OPT_RXHDRS_NUM: {
151252e2e7edSYuan Wang 			unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
151352e2e7edSYuan Wang 			unsigned int nb_segs;
151452e2e7edSYuan Wang 
151552e2e7edSYuan Wang 			nb_segs = parse_hdrs_list
151652e2e7edSYuan Wang 				(optarg, "rxpkt segments",
151752e2e7edSYuan Wang 				MAX_SEGS_BUFFER_SPLIT,
151823f2dfd3SYuan Wang 				seg_hdrs);
151952e2e7edSYuan Wang 			if (nb_segs > 0)
152052e2e7edSYuan Wang 				set_rx_pkt_hdrs(seg_hdrs, nb_segs);
152152e2e7edSYuan Wang 			else
152252e2e7edSYuan Wang 				rte_exit(EXIT_FAILURE, "bad rxpkts\n");
152390c26386SDavid Marchand 			break;
152452e2e7edSYuan Wang 		}
152590c26386SDavid Marchand 		case TESTPMD_OPT_TXPKTS_NUM: {
152690c26386SDavid Marchand 			unsigned int seg_lengths[RTE_MAX_SEGS_PER_PKT];
1527a7e7bb4eSCyril Chemparathy 			unsigned int nb_segs;
1528a7e7bb4eSCyril Chemparathy 
1529950d1516SBruce Richardson 			nb_segs = parse_item_list(optarg, "txpkt segments",
1530950d1516SBruce Richardson 				RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1531a7e7bb4eSCyril Chemparathy 			if (nb_segs > 0)
1532a7e7bb4eSCyril Chemparathy 				set_tx_pkt_segments(seg_lengths, nb_segs);
1533a7e7bb4eSCyril Chemparathy 			else
1534a7e7bb4eSCyril Chemparathy 				rte_exit(EXIT_FAILURE, "bad txpkts\n");
153590c26386SDavid Marchand 			break;
1536a7e7bb4eSCyril Chemparathy 		}
153790c26386SDavid Marchand 		case TESTPMD_OPT_MULTI_RX_MEMPOOL_NUM:
1538a4bf5421SHanumanth Pothula 			multi_rx_mempool = 1;
153990c26386SDavid Marchand 			break;
154090c26386SDavid Marchand 		case TESTPMD_OPT_TXONLY_MULTI_FLOW_NUM:
154182010ef5SYongseok Koh 			txonly_multi_flow = 1;
154290c26386SDavid Marchand 			break;
154390c26386SDavid Marchand 		case TESTPMD_OPT_RXQ_SHARE_NUM:
1544f4d178c1SXueming Li 			if (optarg == NULL) {
1545f4d178c1SXueming Li 				rxq_share = UINT32_MAX;
1546f4d178c1SXueming Li 			} else {
1547f4d178c1SXueming Li 				n = atoi(optarg);
1548f4d178c1SXueming Li 				if (n >= 0)
1549f4d178c1SXueming Li 					rxq_share = (uint32_t)n;
1550f4d178c1SXueming Li 				else
1551f4d178c1SXueming Li 					rte_exit(EXIT_FAILURE, "rxq-share must be >= 0\n");
1552f4d178c1SXueming Li 			}
155390c26386SDavid Marchand 			break;
155490c26386SDavid Marchand 		case TESTPMD_OPT_NO_FLUSH_RX_NUM:
15557741e4cfSIntel 			no_flush_rx = 1;
155690c26386SDavid Marchand 			break;
155790c26386SDavid Marchand 		case TESTPMD_OPT_ETH_LINK_SPEED_NUM:
1558b7b78a08SAjit Khaparde 			n = atoi(optarg);
1559b7b78a08SAjit Khaparde 			if (n >= 0 && parse_link_speed(n) > 0)
1560b7b78a08SAjit Khaparde 				eth_link_speed = parse_link_speed(n);
156190c26386SDavid Marchand 			break;
156290c26386SDavid Marchand 		case TESTPMD_OPT_DISABLE_LINK_CHECK_NUM:
1563bc202406SDavid Marchand 			no_link_check = 1;
156490c26386SDavid Marchand 			break;
156590c26386SDavid Marchand 		case TESTPMD_OPT_DISABLE_DEVICE_START_NUM:
15666937d210SStephen Hemminger 			no_device_start = 1;
156790c26386SDavid Marchand 			break;
156890c26386SDavid Marchand 		case TESTPMD_OPT_NO_LSC_INTERRUPT_NUM:
15698ea656f8SGaetan Rivet 			lsc_interrupt = 0;
157090c26386SDavid Marchand 			break;
157190c26386SDavid Marchand 		case TESTPMD_OPT_NO_RMV_INTERRUPT_NUM:
1572284c908cSGaetan Rivet 			rmv_interrupt = 0;
157390c26386SDavid Marchand 			break;
157490c26386SDavid Marchand 		case TESTPMD_OPT_FLOW_ISOLATE_ALL_NUM:
15757ee3e944SVasily Philipov 			flow_isolate_all = 1;
157690c26386SDavid Marchand 			break;
157790c26386SDavid Marchand 		case TESTPMD_OPT_DISABLE_FLOW_FLUSH_NUM:
1578543df472SChengwen Feng 			no_flow_flush = 1;
157990c26386SDavid Marchand 			break;
158090c26386SDavid Marchand 		case TESTPMD_OPT_TX_OFFLOADS_NUM: {
1581fd8c20aaSShahaf Shuler 			char *end = NULL;
158290c26386SDavid Marchand 
1583fd8c20aaSShahaf Shuler 			n = strtoull(optarg, &end, 16);
1584fd8c20aaSShahaf Shuler 			if (n >= 0)
1585fd8c20aaSShahaf Shuler 				tx_offloads = (uint64_t)n;
1586fd8c20aaSShahaf Shuler 			else
1587fd8c20aaSShahaf Shuler 				rte_exit(EXIT_FAILURE,
1588fd8c20aaSShahaf Shuler 					"tx-offloads must be >= 0\n");
158990c26386SDavid Marchand 			break;
1590fd8c20aaSShahaf Shuler 		}
159190c26386SDavid Marchand 		case TESTPMD_OPT_RX_OFFLOADS_NUM: {
1592fb1a5a0fSVivek Sharma 			char *end = NULL;
159390c26386SDavid Marchand 
1594fb1a5a0fSVivek Sharma 			n = strtoull(optarg, &end, 16);
1595fb1a5a0fSVivek Sharma 			if (n >= 0)
1596fb1a5a0fSVivek Sharma 				rx_offloads = (uint64_t)n;
1597fb1a5a0fSVivek Sharma 			else
1598fb1a5a0fSVivek Sharma 				rte_exit(EXIT_FAILURE,
1599fb1a5a0fSVivek Sharma 					"rx-offloads must be >= 0\n");
160090c26386SDavid Marchand 			break;
1601fb1a5a0fSVivek Sharma 		}
160290c26386SDavid Marchand 		case TESTPMD_OPT_VXLAN_GPE_PORT_NUM:
160339e5e20fSXueming Li 			n = atoi(optarg);
160439e5e20fSXueming Li 			if (n >= 0)
160539e5e20fSXueming Li 				vxlan_gpe_udp_port = (uint16_t)n;
160639e5e20fSXueming Li 			else
160739e5e20fSXueming Li 				rte_exit(EXIT_FAILURE,
160839e5e20fSXueming Li 					"vxlan-gpe-port must be >= 0\n");
160990c26386SDavid Marchand 			break;
161090c26386SDavid Marchand 		case TESTPMD_OPT_GENEVE_PARSED_PORT_NUM:
16112f60c649SOphir Munk 			n = atoi(optarg);
16122f60c649SOphir Munk 			if (n >= 0)
16132f60c649SOphir Munk 				geneve_udp_port = (uint16_t)n;
16142f60c649SOphir Munk 			else
16152f60c649SOphir Munk 				rte_exit(EXIT_FAILURE,
16162f60c649SOphir Munk 					"geneve-parsed-port must be >= 0\n");
161790c26386SDavid Marchand 			break;
161890c26386SDavid Marchand 		case TESTPMD_OPT_PRINT_EVENT_NUM:
16193af72783SGaetan Rivet 			if (parse_event_printing_config(optarg, 1)) {
16203af72783SGaetan Rivet 				rte_exit(EXIT_FAILURE,
16213af72783SGaetan Rivet 					"invalid print-event argument\n");
16223af72783SGaetan Rivet 			}
162390c26386SDavid Marchand 			break;
162490c26386SDavid Marchand 		case TESTPMD_OPT_MASK_EVENT_NUM:
16253af72783SGaetan Rivet 			if (parse_event_printing_config(optarg, 0)) {
16263af72783SGaetan Rivet 				rte_exit(EXIT_FAILURE,
16273af72783SGaetan Rivet 					"invalid mask-event argument\n");
16283af72783SGaetan Rivet 			}
162990c26386SDavid Marchand 			break;
163090c26386SDavid Marchand 		case TESTPMD_OPT_HOT_PLUG_NUM:
1631fb73e096SJeff Guo 			hot_plug = 1;
163290c26386SDavid Marchand 			break;
163390c26386SDavid Marchand 		case TESTPMD_OPT_MLOCKALL_NUM:
1634e505d84cSAnatoly Burakov 			do_mlockall = 1;
163590c26386SDavid Marchand 			break;
163690c26386SDavid Marchand 		case TESTPMD_OPT_NO_MLOCKALL_NUM:
1637e505d84cSAnatoly Burakov 			do_mlockall = 0;
163890c26386SDavid Marchand 			break;
163990c26386SDavid Marchand 		case TESTPMD_OPT_NOISY_TX_SW_BUFFER_SIZE_NUM:
16403c156061SJens Freimann 			n = atoi(optarg);
16413c156061SJens Freimann 			if (n >= 0)
16423c156061SJens Freimann 				noisy_tx_sw_bufsz = n;
16433c156061SJens Freimann 			else
16443c156061SJens Freimann 				rte_exit(EXIT_FAILURE,
16453c156061SJens Freimann 					"noisy-tx-sw-buffer-size must be >= 0\n");
164690c26386SDavid Marchand 			break;
164790c26386SDavid Marchand 		case TESTPMD_OPT_NOISY_TX_SW_BUFFER_FLUSHTIME_NUM:
16483c156061SJens Freimann 			n = atoi(optarg);
16493c156061SJens Freimann 			if (n >= 0)
16503c156061SJens Freimann 				noisy_tx_sw_buf_flush_time = n;
16513c156061SJens Freimann 			else
16523c156061SJens Freimann 				rte_exit(EXIT_FAILURE,
16533c156061SJens Freimann 					"noisy-tx-sw-buffer-flushtime must be >= 0\n");
165490c26386SDavid Marchand 			break;
165590c26386SDavid Marchand 		case TESTPMD_OPT_NOISY_LKUP_MEMORY_NUM:
16563c156061SJens Freimann 			n = atoi(optarg);
16573c156061SJens Freimann 			if (n >= 0)
16583c156061SJens Freimann 				noisy_lkup_mem_sz = n;
16593c156061SJens Freimann 			else
16603c156061SJens Freimann 				rte_exit(EXIT_FAILURE,
16613c156061SJens Freimann 					"noisy-lkup-memory must be >= 0\n");
166290c26386SDavid Marchand 			break;
166390c26386SDavid Marchand 		case TESTPMD_OPT_NOISY_LKUP_NUM_WRITES_NUM:
16643c156061SJens Freimann 			n = atoi(optarg);
16653c156061SJens Freimann 			if (n >= 0)
16663c156061SJens Freimann 				noisy_lkup_num_writes = n;
16673c156061SJens Freimann 			else
16683c156061SJens Freimann 				rte_exit(EXIT_FAILURE,
16693c156061SJens Freimann 					"noisy-lkup-num-writes must be >= 0\n");
167090c26386SDavid Marchand 			break;
167190c26386SDavid Marchand 		case TESTPMD_OPT_NOISY_LKUP_NUM_READS_NUM:
16723c156061SJens Freimann 			n = atoi(optarg);
16733c156061SJens Freimann 			if (n >= 0)
16743c156061SJens Freimann 				noisy_lkup_num_reads = n;
16753c156061SJens Freimann 			else
16763c156061SJens Freimann 				rte_exit(EXIT_FAILURE,
16773c156061SJens Freimann 					"noisy-lkup-num-reads must be >= 0\n");
167890c26386SDavid Marchand 			break;
167990c26386SDavid Marchand 		case TESTPMD_OPT_NOISY_LKUP_NUM_READS_WRITES_NUM:
16803c156061SJens Freimann 			n = atoi(optarg);
16813c156061SJens Freimann 			if (n >= 0)
16823c156061SJens Freimann 				noisy_lkup_num_reads_writes = n;
16833c156061SJens Freimann 			else
16843c156061SJens Freimann 				rte_exit(EXIT_FAILURE,
16853c156061SJens Freimann 					"noisy-lkup-num-reads-writes must be >= 0\n");
168690c26386SDavid Marchand 			break;
168790c26386SDavid Marchand 		case TESTPMD_OPT_NOISY_FORWARD_MODE_NUM: {
168890c26386SDavid Marchand 			unsigned int i;
168990c26386SDavid Marchand 
169090c26386SDavid Marchand 			for (i = 0; i < NOISY_FWD_MODE_MAX; i++) {
16911d343c19SMike Pattrick 				if (!strcmp(optarg, noisy_fwd_mode_desc[i])) {
16921d343c19SMike Pattrick 					noisy_fwd_mode = i;
16931d343c19SMike Pattrick 					break;
16941d343c19SMike Pattrick 				}
169590c26386SDavid Marchand 			}
16961d343c19SMike Pattrick 			if (i == NOISY_FWD_MODE_MAX)
16971d343c19SMike Pattrick 				rte_exit(EXIT_FAILURE, "noisy-forward-mode %s invalid,"
16981d343c19SMike Pattrick 					 " must be a valid noisy-forward-mode value\n",
16991d343c19SMike Pattrick 					 optarg);
170090c26386SDavid Marchand 			break;
17011d343c19SMike Pattrick 		}
170290c26386SDavid Marchand 		case TESTPMD_OPT_NO_IOVA_CONTIG_NUM:
1703c47d7b90SAndrew Rybchenko 			mempool_flags = RTE_MEMPOOL_F_NO_IOVA_CONTIG;
170490c26386SDavid Marchand 			break;
170590c26386SDavid Marchand 		case TESTPMD_OPT_RX_MQ_MODE_NUM: {
1706f9295aa2SXiaoyu Min 			char *end = NULL;
170790c26386SDavid Marchand 
1708f9295aa2SXiaoyu Min 			n = strtoul(optarg, &end, 16);
1709295968d1SFerruh Yigit 			if (n >= 0 && n <= RTE_ETH_MQ_RX_VMDQ_DCB_RSS)
1710f9295aa2SXiaoyu Min 				rx_mq_mode = (enum rte_eth_rx_mq_mode)n;
1711f9295aa2SXiaoyu Min 			else
1712f9295aa2SXiaoyu Min 				rte_exit(EXIT_FAILURE,
1713f9295aa2SXiaoyu Min 					"rx-mq-mode must be >= 0 and <= %d\n",
1714295968d1SFerruh Yigit 					RTE_ETH_MQ_RX_VMDQ_DCB_RSS);
1715af75078fSIntel 			break;
171690c26386SDavid Marchand 		}
171790c26386SDavid Marchand 		case TESTPMD_OPT_RECORD_CORE_CYCLES_NUM:
171890c26386SDavid Marchand 			record_core_cycles = 1;
171990c26386SDavid Marchand 			break;
172090c26386SDavid Marchand 		case TESTPMD_OPT_RECORD_BURST_STATS_NUM:
172190c26386SDavid Marchand 			record_burst_stats = 1;
172290c26386SDavid Marchand 			break;
172390c26386SDavid Marchand 		case TESTPMD_OPT_NUM_PROCS_NUM:
172490c26386SDavid Marchand 			num_procs = atoi(optarg);
172590c26386SDavid Marchand 			break;
172690c26386SDavid Marchand 		case TESTPMD_OPT_PROC_ID_NUM:
172790c26386SDavid Marchand 			proc_id = atoi(optarg);
1728af75078fSIntel 			break;
1729af75078fSIntel 		default:
1730af75078fSIntel 			usage(argv[0]);
1731c25382faSDavid Marchand 			fprintf(stderr, "Invalid option: %s\n", argv[optind - 1]);
1732af75078fSIntel 			rte_exit(EXIT_FAILURE,
1733af75078fSIntel 				 "Command line is incomplete or incorrect\n");
1734af75078fSIntel 			break;
1735af75078fSIntel 		}
1736af75078fSIntel 	}
17370074d02fSShahaf Shuler 
17388fad2e5aSDavid Marchand 	if (optind != argc) {
17398fad2e5aSDavid Marchand 		usage(argv[0]);
174061a3b0e5SAndrew Rybchenko 		fprintf(stderr, "Invalid parameter: %s\n", argv[optind]);
17418fad2e5aSDavid Marchand 		rte_exit(EXIT_FAILURE, "Command line is incorrect\n");
17428fad2e5aSDavid Marchand 	}
17438fad2e5aSDavid Marchand 
17445388be6eSHaiyue Wang 	if (proc_id >= (int)num_procs)
17455388be6eSHaiyue Wang 		rte_exit(EXIT_FAILURE,
17465388be6eSHaiyue Wang 			"The multi-process option '%s(%d)' should be less than '%s(%u)'\n",
174790c26386SDavid Marchand 			TESTPMD_OPT_PROC_ID, proc_id,
174890c26386SDavid Marchand 			TESTPMD_OPT_NUM_PROCS, num_procs);
17495388be6eSHaiyue Wang 
17500074d02fSShahaf Shuler 	/* Set offload configuration from command line parameters. */
17510074d02fSShahaf Shuler 	rx_mode.offloads = rx_offloads;
1752fd8c20aaSShahaf Shuler 	tx_mode.offloads = tx_offloads;
175359fcf854SShahaf Shuler 
1754c47d7b90SAndrew Rybchenko 	if (mempool_flags & RTE_MEMPOOL_F_NO_IOVA_CONTIG &&
175559fcf854SShahaf Shuler 	    mp_alloc_type != MP_ALLOC_ANON) {
175659fcf854SShahaf Shuler 		TESTPMD_LOG(WARNING, "cannot use no-iova-contig without "
175759fcf854SShahaf Shuler 				  "mp-alloc=anon. mempool no-iova-contig is "
175859fcf854SShahaf Shuler 				  "ignored\n");
175959fcf854SShahaf Shuler 		mempool_flags = 0;
176059fcf854SShahaf Shuler 	}
1761af75078fSIntel }
1762