LCOV - code coverage report
Current view: top level - app/test-pmd - parameters.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 649 0.0 %
Date: 2024-01-22 16:13:49 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.14