1af75078fSIntel /*- 2af75078fSIntel * BSD LICENSE 3af75078fSIntel * 45a8fb55cSReshma Pattan * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. 5af75078fSIntel * All rights reserved. 6af75078fSIntel * 7af75078fSIntel * Redistribution and use in source and binary forms, with or without 8af75078fSIntel * modification, are permitted provided that the following conditions 9af75078fSIntel * are met: 10af75078fSIntel * 11af75078fSIntel * * Redistributions of source code must retain the above copyright 12af75078fSIntel * notice, this list of conditions and the following disclaimer. 13af75078fSIntel * * Redistributions in binary form must reproduce the above copyright 14af75078fSIntel * notice, this list of conditions and the following disclaimer in 15af75078fSIntel * the documentation and/or other materials provided with the 16af75078fSIntel * distribution. 17af75078fSIntel * * Neither the name of Intel Corporation nor the names of its 18af75078fSIntel * contributors may be used to endorse or promote products derived 19af75078fSIntel * from this software without specific prior written permission. 20af75078fSIntel * 21af75078fSIntel * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22af75078fSIntel * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23af75078fSIntel * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24af75078fSIntel * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25af75078fSIntel * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26af75078fSIntel * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27af75078fSIntel * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28af75078fSIntel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29af75078fSIntel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30af75078fSIntel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31af75078fSIntel * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32af75078fSIntel */ 33af75078fSIntel 34af75078fSIntel #include <errno.h> 35af75078fSIntel #include <getopt.h> 36af75078fSIntel #include <stdarg.h> 37af75078fSIntel #include <stdio.h> 38af75078fSIntel #include <stdlib.h> 39af75078fSIntel #include <signal.h> 40af75078fSIntel #include <string.h> 41af75078fSIntel #include <time.h> 42af75078fSIntel #include <fcntl.h> 43af75078fSIntel #include <sys/types.h> 44af75078fSIntel #include <errno.h> 45af75078fSIntel 46af75078fSIntel #include <sys/queue.h> 47af75078fSIntel #include <sys/stat.h> 48af75078fSIntel 49af75078fSIntel #include <stdint.h> 50af75078fSIntel #include <unistd.h> 51af75078fSIntel #include <inttypes.h> 52af75078fSIntel 53af75078fSIntel #include <rte_common.h> 54af75078fSIntel #include <rte_byteorder.h> 55af75078fSIntel #include <rte_log.h> 56af75078fSIntel #include <rte_debug.h> 57af75078fSIntel #include <rte_cycles.h> 58af75078fSIntel #include <rte_memory.h> 59af75078fSIntel #include <rte_memzone.h> 60af75078fSIntel #include <rte_launch.h> 61af75078fSIntel #include <rte_eal.h> 62af75078fSIntel #include <rte_per_lcore.h> 63af75078fSIntel #include <rte_lcore.h> 64af75078fSIntel #include <rte_atomic.h> 65af75078fSIntel #include <rte_branch_prediction.h> 66af75078fSIntel #include <rte_ring.h> 67af75078fSIntel #include <rte_mempool.h> 68af75078fSIntel #include <rte_interrupts.h> 69af75078fSIntel #include <rte_pci.h> 70af75078fSIntel #include <rte_ether.h> 71af75078fSIntel #include <rte_ethdev.h> 72af75078fSIntel #include <rte_string_fns.h> 730d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE 74af75078fSIntel #include <cmdline_parse.h> 75af75078fSIntel #include <cmdline_parse_etheraddr.h> 760d56cb81SThomas Monjalon #endif 772950a769SDeclan Doherty #ifdef RTE_LIBRTE_PMD_BOND 782950a769SDeclan Doherty #include <rte_eth_bond.h> 792950a769SDeclan Doherty #endif 80af75078fSIntel 81af75078fSIntel #include "testpmd.h" 82af75078fSIntel 83af75078fSIntel static void 84af75078fSIntel usage(char* progname) 85af75078fSIntel { 860d56cb81SThomas Monjalon printf("usage: %s " 870d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE 880d56cb81SThomas Monjalon "[--interactive|-i] " 890d56cb81SThomas Monjalon #endif 90ca7feb22SCyril Chemparathy "[--help|-h] | [--auto-start|-a] | [" 91af75078fSIntel "--coremask=COREMASK --portmask=PORTMASK --numa " 92c8798818SIntel "--mbuf-size= | --total-num-mbufs= | " 933be52ffcSIntel "--nb-cores= | --nb-ports= | " 940d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE 95af75078fSIntel "--eth-peers-configfile= | " 963be52ffcSIntel "--eth-peer=X,M:M:M:M:M:M | " 970d56cb81SThomas Monjalon #endif 98af75078fSIntel "--pkt-filter-mode= |" 99af75078fSIntel "--rss-ip | --rss-udp | " 100af75078fSIntel "--rxpt= | --rxht= | --rxwt= | --rxfreet= | " 101af75078fSIntel "--txpt= | --txht= | --txwt= | --txfreet= | " 102ce8d5614SIntel "--txrst= | --txqflags= ]\n", 103af75078fSIntel progname); 1040d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE 1053be52ffcSIntel printf(" --interactive: run in interactive mode.\n"); 1060d56cb81SThomas Monjalon #endif 107ca7feb22SCyril Chemparathy printf(" --auto-start: start forwarding on init " 108ca7feb22SCyril Chemparathy "[always when non-interactive].\n"); 1093be52ffcSIntel printf(" --help: display this message and quit.\n"); 1103be52ffcSIntel printf(" --nb-cores=N: set the number of forwarding cores " 1113be52ffcSIntel "(1 <= N <= %d).\n", nb_lcores); 1123be52ffcSIntel printf(" --nb-ports=N: set the number of forwarding ports " 1133be52ffcSIntel "(1 <= N <= %d).\n", nb_ports); 114af75078fSIntel printf(" --coremask=COREMASK: hexadecimal bitmask of cores running " 115013af9b6SIntel "the packet forwarding test. The master lcore is reserved for " 1163be52ffcSIntel "command line parsing only, and cannot be masked on for " 1173be52ffcSIntel "packet forwarding.\n"); 118af75078fSIntel printf(" --portmask=PORTMASK: hexadecimal bitmask of ports used " 1193be52ffcSIntel "by the packet forwarding test.\n"); 120af75078fSIntel printf(" --numa: enable NUMA-aware allocation of RX/TX rings and of " 1213be52ffcSIntel "RX memory buffers (mbufs).\n"); 122b6ea6408SIntel printf(" --port-numa-config=(port,socket)[,(port,socket)]: " 123b6ea6408SIntel "specify the socket on which the memory pool " 124b6ea6408SIntel "used by the port will be allocated.\n"); 125b6ea6408SIntel printf(" --ring-numa-config=(port,flag,socket)[,(port,flag,socket)]: " 126b6ea6408SIntel "specify the socket on which the TX/RX rings for " 127b6ea6408SIntel "the port will be allocated " 128b6ea6408SIntel "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n"); 129b6ea6408SIntel printf(" --socket-num=N: set socket from which all memory is allocated " 130b6ea6408SIntel "in NUMA mode.\n"); 1313be52ffcSIntel printf(" --mbuf-size=N: set the data size of mbuf to N bytes.\n"); 1323be52ffcSIntel printf(" --total-num-mbufs=N: set the number of mbufs to be allocated " 1333be52ffcSIntel "in mbuf pools.\n"); 1343be52ffcSIntel printf(" --max-pkt-len=N: set the maximum size of packet to N bytes.\n"); 1350d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE 1363be52ffcSIntel printf(" --eth-peers-configfile=name: config file with ethernet addresses " 1373be52ffcSIntel "of peer ports.\n"); 1383be52ffcSIntel printf(" --eth-peer=X,M:M:M:M:M:M: set the MAC address of the X peer " 1393be52ffcSIntel "port (0 <= X < %d).\n", RTE_MAX_ETHPORTS); 1400d56cb81SThomas Monjalon #endif 1413be52ffcSIntel printf(" --pkt-filter-mode=N: set Flow Director mode " 1423be52ffcSIntel "(N: none (default mode) or signature or perfect).\n"); 1433be52ffcSIntel printf(" --pkt-filter-report-hash=N: set Flow Director report mode " 1443be52ffcSIntel "(N: none or match (default) or always).\n"); 1453be52ffcSIntel printf(" --pkt-filter-size=N: set Flow Director mode " 1463be52ffcSIntel "(N: 64K (default mode) or 128K or 256K).\n"); 147af75078fSIntel printf(" --pkt-filter-drop-queue=N: set drop-queue. " 1483be52ffcSIntel "In perfect mode, when you add a rule with queue = -1 " 149af75078fSIntel "the packet will be enqueued into the rx drop-queue. " 150af75078fSIntel "If the drop-queue doesn't exist, the packet is dropped. " 1513be52ffcSIntel "By default drop-queue=127.\n"); 1523be52ffcSIntel printf(" --crc-strip: enable CRC stripping by hardware.\n"); 1533be52ffcSIntel printf(" --enable-rx-cksum: enable rx hardware checksum offload.\n"); 1543be52ffcSIntel printf(" --disable-hw-vlan: disable hardware vlan.\n"); 155c9dd4aadSOuyang Changchun printf(" --disable-hw-vlan-filter: disable hardware vlan filter.\n"); 156c9dd4aadSOuyang Changchun printf(" --disable-hw-vlan-strip: disable hardware vlan strip.\n"); 157c9dd4aadSOuyang Changchun printf(" --disable-hw-vlan-extend: disable hardware vlan extend.\n"); 1583be52ffcSIntel printf(" --enable-drop-en: enable per queue packet drop.\n"); 1593be52ffcSIntel printf(" --disable-rss: disable rss.\n"); 160af75078fSIntel printf(" --port-topology=N: set port topology (N: paired (default) or " 1613be52ffcSIntel "chained).\n"); 162769ce6b1SThomas Monjalon printf(" --forward-mode=N: set forwarding mode (N: %s).\n", 163769ce6b1SThomas Monjalon list_pkt_forwarding_modes()); 1643be52ffcSIntel printf(" --rss-ip: set RSS functions to IPv4/IPv6 only .\n"); 1653be52ffcSIntel printf(" --rss-udp: set RSS functions to IPv4/IPv6 + UDP.\n"); 1663be52ffcSIntel printf(" --rxq=N: set the number of RX queues per port to N.\n"); 1673be52ffcSIntel printf(" --rxd=N: set the number of descriptors in RX rings to N.\n"); 1683be52ffcSIntel printf(" --txq=N: set the number of TX queues per port to N.\n"); 1693be52ffcSIntel printf(" --txd=N: set the number of descriptors in TX rings to N.\n"); 1703be52ffcSIntel printf(" --burst=N: set the number of packets per burst to N.\n"); 1713be52ffcSIntel printf(" --mbcache=N: set the cache of mbuf memory pool to N.\n"); 17257af3415SPablo de Lara printf(" --rxpt=N: set prefetch threshold register of RX rings to N.\n"); 17357af3415SPablo de Lara printf(" --rxht=N: set the host threshold register of RX rings to N.\n"); 1743be52ffcSIntel printf(" --rxfreet=N: set the free threshold of RX descriptors to N " 1753be52ffcSIntel "(0 <= N < value of rxd).\n"); 17657af3415SPablo de Lara printf(" --rxwt=N: set the write-back threshold register of RX rings to N.\n"); 17757af3415SPablo de Lara printf(" --txpt=N: set the prefetch threshold register of TX rings to N.\n"); 17857af3415SPablo de Lara printf(" --txht=N: set the nhost threshold register of TX rings to N.\n"); 17957af3415SPablo de Lara printf(" --txwt=N: set the write-back threshold register of TX rings to N.\n"); 1803be52ffcSIntel printf(" --txfreet=N: set the transmit free threshold of TX rings to N " 1813be52ffcSIntel "(0 <= N <= value of txd).\n"); 1823be52ffcSIntel printf(" --txrst=N: set the transmit RS bit threshold of TX rings to N " 1833be52ffcSIntel "(0 <= N <= value of txd).\n"); 1843be52ffcSIntel printf(" --txqflags=0xXXXXXXXX: hexadecimal bitmask of TX queue flags " 1853be52ffcSIntel "(0 <= N <= 0x7FFFFFFF).\n"); 1863be52ffcSIntel printf(" --tx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: " 187ed30d9b6SIntel "tx queues statistics counters mapping " 1883be52ffcSIntel "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); 1893be52ffcSIntel printf(" --rx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: " 190ed30d9b6SIntel "rx queues statistics counters mapping " 1913be52ffcSIntel "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); 1925e2ee196SIntel printf(" --no-flush-rx: Don't flush RX streams before forwarding." 1935e2ee196SIntel " Used mainly with PCAP drivers.\n"); 194a7e7bb4eSCyril Chemparathy printf(" --txpkts=X[,Y]*: set TX segment sizes.\n"); 195bc202406SDavid Marchand printf(" --disable-link-check: disable check on link status when " 196bc202406SDavid Marchand "starting/stopping ports.\n"); 197af75078fSIntel } 198af75078fSIntel 1990d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE 200af75078fSIntel static int 201af75078fSIntel init_peer_eth_addrs(char *config_filename) 202af75078fSIntel { 203af75078fSIntel FILE *config_file; 204af75078fSIntel portid_t i; 205af75078fSIntel char buf[50]; 206af75078fSIntel 207af75078fSIntel config_file = fopen(config_filename, "r"); 208af75078fSIntel if (config_file == NULL) { 2093be52ffcSIntel perror("Failed to open eth config file\n"); 210af75078fSIntel return -1; 211af75078fSIntel } 212af75078fSIntel 213af75078fSIntel for (i = 0; i < RTE_MAX_ETHPORTS; i++) { 214af75078fSIntel 215af75078fSIntel if (fgets(buf, sizeof(buf), config_file) == NULL) 216af75078fSIntel break; 217af75078fSIntel 218aaa662e7SAlan Carew if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i], 219aaa662e7SAlan Carew sizeof(peer_eth_addrs[i])) < 0) { 2203be52ffcSIntel printf("Bad MAC address format on line %d\n", i+1); 221af75078fSIntel fclose(config_file); 222af75078fSIntel return -1; 223af75078fSIntel } 224af75078fSIntel } 225af75078fSIntel fclose(config_file); 226af75078fSIntel nb_peer_eth_addrs = (portid_t) i; 227af75078fSIntel return 0; 228af75078fSIntel } 2290d56cb81SThomas Monjalon #endif 230af75078fSIntel 231af75078fSIntel /* 232af75078fSIntel * Parse the coremask given as argument (hexadecimal string) and set 233af75078fSIntel * the global configuration of forwarding cores. 234af75078fSIntel */ 235af75078fSIntel static void 236af75078fSIntel parse_fwd_coremask(const char *coremask) 237af75078fSIntel { 238af75078fSIntel char *end; 239af75078fSIntel unsigned long long int cm; 240af75078fSIntel 241af75078fSIntel /* parse hexadecimal string */ 242af75078fSIntel end = NULL; 243af75078fSIntel cm = strtoull(coremask, &end, 16); 244af75078fSIntel if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0')) 245af75078fSIntel rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n"); 246013af9b6SIntel else if (set_fwd_lcores_mask((uint64_t) cm) < 0) 247013af9b6SIntel rte_exit(EXIT_FAILURE, "coremask is not valid\n"); 248af75078fSIntel } 249af75078fSIntel 250af75078fSIntel /* 251af75078fSIntel * Parse the coremask given as argument (hexadecimal string) and set 252af75078fSIntel * the global configuration of forwarding cores. 253af75078fSIntel */ 254af75078fSIntel static void 255af75078fSIntel parse_fwd_portmask(const char *portmask) 256af75078fSIntel { 257af75078fSIntel char *end; 258af75078fSIntel unsigned long long int pm; 259af75078fSIntel 260af75078fSIntel /* parse hexadecimal string */ 261af75078fSIntel end = NULL; 262af75078fSIntel pm = strtoull(portmask, &end, 16); 263af75078fSIntel if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) 264af75078fSIntel rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n"); 265af75078fSIntel else 266af75078fSIntel set_fwd_ports_mask((uint64_t) pm); 267af75078fSIntel } 268af75078fSIntel 269ed30d9b6SIntel 270ed30d9b6SIntel static int 271ed30d9b6SIntel parse_queue_stats_mapping_config(const char *q_arg, int is_rx) 272ed30d9b6SIntel { 273ed30d9b6SIntel char s[256]; 274ed30d9b6SIntel const char *p, *p0 = q_arg; 275ed30d9b6SIntel char *end; 276ed30d9b6SIntel enum fieldnames { 277ed30d9b6SIntel FLD_PORT = 0, 278ed30d9b6SIntel FLD_QUEUE, 279ed30d9b6SIntel FLD_STATS_COUNTER, 280ed30d9b6SIntel _NUM_FLD 281ed30d9b6SIntel }; 282ed30d9b6SIntel unsigned long int_fld[_NUM_FLD]; 283ed30d9b6SIntel char *str_fld[_NUM_FLD]; 284ed30d9b6SIntel int i; 285ed30d9b6SIntel unsigned size; 286ed30d9b6SIntel 287ed30d9b6SIntel /* reset from value set at definition */ 288ed30d9b6SIntel is_rx ? (nb_rx_queue_stats_mappings = 0) : (nb_tx_queue_stats_mappings = 0); 289ed30d9b6SIntel 290ed30d9b6SIntel while ((p = strchr(p0,'(')) != NULL) { 291ed30d9b6SIntel ++p; 292ed30d9b6SIntel if((p0 = strchr(p,')')) == NULL) 293ed30d9b6SIntel return -1; 294ed30d9b6SIntel 295ed30d9b6SIntel size = p0 - p; 296ed30d9b6SIntel if(size >= sizeof(s)) 297ed30d9b6SIntel return -1; 298ed30d9b6SIntel 2996f41fe75SStephen Hemminger snprintf(s, sizeof(s), "%.*s", size, p); 300ed30d9b6SIntel if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 301ed30d9b6SIntel return -1; 302ed30d9b6SIntel for (i = 0; i < _NUM_FLD; i++){ 303ed30d9b6SIntel errno = 0; 304ed30d9b6SIntel int_fld[i] = strtoul(str_fld[i], &end, 0); 305ed30d9b6SIntel if (errno != 0 || end == str_fld[i] || int_fld[i] > 255) 306ed30d9b6SIntel return -1; 307ed30d9b6SIntel } 308ed30d9b6SIntel /* Check mapping field is in correct range (0..RTE_ETHDEV_QUEUE_STAT_CNTRS-1) */ 309ed30d9b6SIntel if (int_fld[FLD_STATS_COUNTER] >= RTE_ETHDEV_QUEUE_STAT_CNTRS) { 310ed30d9b6SIntel printf("Stats counter not in the correct range 0..%d\n", 311ed30d9b6SIntel RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); 312ed30d9b6SIntel return -1; 313ed30d9b6SIntel } 314ed30d9b6SIntel 3154dccdc78SBruce Richardson if (!is_rx) { 3164dccdc78SBruce Richardson if ((nb_tx_queue_stats_mappings >= 3174dccdc78SBruce Richardson MAX_TX_QUEUE_STATS_MAPPINGS)) { 3184dccdc78SBruce Richardson printf("exceeded max number of TX queue " 3194dccdc78SBruce Richardson "statistics mappings: %hu\n", 3204dccdc78SBruce Richardson nb_tx_queue_stats_mappings); 321ed30d9b6SIntel return -1; 322ed30d9b6SIntel } 323ed30d9b6SIntel tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id = 324ed30d9b6SIntel (uint8_t)int_fld[FLD_PORT]; 325ed30d9b6SIntel tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id = 326ed30d9b6SIntel (uint8_t)int_fld[FLD_QUEUE]; 327ed30d9b6SIntel tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].stats_counter_id = 328ed30d9b6SIntel (uint8_t)int_fld[FLD_STATS_COUNTER]; 329ed30d9b6SIntel ++nb_tx_queue_stats_mappings; 330ed30d9b6SIntel } 331ed30d9b6SIntel else { 3324dccdc78SBruce Richardson if ((nb_rx_queue_stats_mappings >= 3334dccdc78SBruce Richardson MAX_RX_QUEUE_STATS_MAPPINGS)) { 3344dccdc78SBruce Richardson printf("exceeded max number of RX queue " 3354dccdc78SBruce Richardson "statistics mappings: %hu\n", 3364dccdc78SBruce Richardson nb_rx_queue_stats_mappings); 3374dccdc78SBruce Richardson return -1; 3384dccdc78SBruce Richardson } 339ed30d9b6SIntel rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id = 340ed30d9b6SIntel (uint8_t)int_fld[FLD_PORT]; 341ed30d9b6SIntel rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id = 342ed30d9b6SIntel (uint8_t)int_fld[FLD_QUEUE]; 343ed30d9b6SIntel rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].stats_counter_id = 344ed30d9b6SIntel (uint8_t)int_fld[FLD_STATS_COUNTER]; 345ed30d9b6SIntel ++nb_rx_queue_stats_mappings; 346ed30d9b6SIntel } 347ed30d9b6SIntel 348ed30d9b6SIntel } 349ed30d9b6SIntel /* Reassign the rx/tx_queue_stats_mappings pointer to point to this newly populated array rather */ 350ed30d9b6SIntel /* than to the default array (that was set at its definition) */ 351ed30d9b6SIntel is_rx ? (rx_queue_stats_mappings = rx_queue_stats_mappings_array) : 352ed30d9b6SIntel (tx_queue_stats_mappings = tx_queue_stats_mappings_array); 353ed30d9b6SIntel return 0; 354ed30d9b6SIntel } 355ed30d9b6SIntel 356b6ea6408SIntel static int 357b6ea6408SIntel parse_portnuma_config(const char *q_arg) 358b6ea6408SIntel { 359b6ea6408SIntel char s[256]; 360b6ea6408SIntel const char *p, *p0 = q_arg; 361b6ea6408SIntel char *end; 362b6ea6408SIntel uint8_t i,port_id,socket_id; 363b6ea6408SIntel unsigned size; 364b6ea6408SIntel enum fieldnames { 365b6ea6408SIntel FLD_PORT = 0, 366b6ea6408SIntel FLD_SOCKET, 367b6ea6408SIntel _NUM_FLD 368b6ea6408SIntel }; 369b6ea6408SIntel unsigned long int_fld[_NUM_FLD]; 370b6ea6408SIntel char *str_fld[_NUM_FLD]; 371edab33b1STetsuya Mukawa portid_t pid; 372b6ea6408SIntel 373b6ea6408SIntel /* reset from value set at definition */ 374b6ea6408SIntel while ((p = strchr(p0,'(')) != NULL) { 375b6ea6408SIntel ++p; 376b6ea6408SIntel if((p0 = strchr(p,')')) == NULL) 377b6ea6408SIntel return -1; 378b6ea6408SIntel 379b6ea6408SIntel size = p0 - p; 380b6ea6408SIntel if(size >= sizeof(s)) 381b6ea6408SIntel return -1; 382b6ea6408SIntel 3836f41fe75SStephen Hemminger snprintf(s, sizeof(s), "%.*s", size, p); 384b6ea6408SIntel if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 385b6ea6408SIntel return -1; 386b6ea6408SIntel for (i = 0; i < _NUM_FLD; i++) { 387b6ea6408SIntel errno = 0; 388b6ea6408SIntel int_fld[i] = strtoul(str_fld[i], &end, 0); 389b6ea6408SIntel if (errno != 0 || end == str_fld[i] || int_fld[i] > 255) 390b6ea6408SIntel return -1; 391b6ea6408SIntel } 392b6ea6408SIntel port_id = (uint8_t)int_fld[FLD_PORT]; 393edab33b1STetsuya Mukawa if (port_id_is_invalid(port_id, ENABLED_WARN)) { 394edab33b1STetsuya Mukawa printf("Valid port range is [0"); 395edab33b1STetsuya Mukawa FOREACH_PORT(pid, ports) 396edab33b1STetsuya Mukawa printf(", %d", pid); 397edab33b1STetsuya Mukawa printf("]\n"); 398b6ea6408SIntel return -1; 399b6ea6408SIntel } 400b6ea6408SIntel socket_id = (uint8_t)int_fld[FLD_SOCKET]; 4017acf894dSStephen Hurd if(socket_id >= max_socket) { 402b6ea6408SIntel printf("Invalid socket id, range is [0, %d]\n", 4037acf894dSStephen Hurd max_socket - 1); 404b6ea6408SIntel return -1; 405b6ea6408SIntel } 406b6ea6408SIntel port_numa[port_id] = socket_id; 407b6ea6408SIntel } 408b6ea6408SIntel 409b6ea6408SIntel return 0; 410b6ea6408SIntel } 411b6ea6408SIntel 412b6ea6408SIntel static int 413b6ea6408SIntel parse_ringnuma_config(const char *q_arg) 414b6ea6408SIntel { 415b6ea6408SIntel char s[256]; 416b6ea6408SIntel const char *p, *p0 = q_arg; 417b6ea6408SIntel char *end; 418b6ea6408SIntel uint8_t i,port_id,ring_flag,socket_id; 419b6ea6408SIntel unsigned size; 420b6ea6408SIntel enum fieldnames { 421b6ea6408SIntel FLD_PORT = 0, 422b6ea6408SIntel FLD_FLAG, 423b6ea6408SIntel FLD_SOCKET, 424b6ea6408SIntel _NUM_FLD 425b6ea6408SIntel }; 426b6ea6408SIntel unsigned long int_fld[_NUM_FLD]; 427b6ea6408SIntel char *str_fld[_NUM_FLD]; 428edab33b1STetsuya Mukawa portid_t pid; 429b6ea6408SIntel #define RX_RING_ONLY 0x1 430b6ea6408SIntel #define TX_RING_ONLY 0x2 431b6ea6408SIntel #define RXTX_RING 0x3 432b6ea6408SIntel 433b6ea6408SIntel /* reset from value set at definition */ 434b6ea6408SIntel while ((p = strchr(p0,'(')) != NULL) { 435b6ea6408SIntel ++p; 436b6ea6408SIntel if((p0 = strchr(p,')')) == NULL) 437b6ea6408SIntel return -1; 438b6ea6408SIntel 439b6ea6408SIntel size = p0 - p; 440b6ea6408SIntel if(size >= sizeof(s)) 441b6ea6408SIntel return -1; 442b6ea6408SIntel 4436f41fe75SStephen Hemminger snprintf(s, sizeof(s), "%.*s", size, p); 444b6ea6408SIntel if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 445b6ea6408SIntel return -1; 446b6ea6408SIntel for (i = 0; i < _NUM_FLD; i++) { 447b6ea6408SIntel errno = 0; 448b6ea6408SIntel int_fld[i] = strtoul(str_fld[i], &end, 0); 449b6ea6408SIntel if (errno != 0 || end == str_fld[i] || int_fld[i] > 255) 450b6ea6408SIntel return -1; 451b6ea6408SIntel } 452b6ea6408SIntel port_id = (uint8_t)int_fld[FLD_PORT]; 453edab33b1STetsuya Mukawa if (port_id_is_invalid(port_id, ENABLED_WARN)) { 454edab33b1STetsuya Mukawa printf("Valid port range is [0"); 455edab33b1STetsuya Mukawa FOREACH_PORT(pid, ports) 456edab33b1STetsuya Mukawa printf(", %d", pid); 457edab33b1STetsuya Mukawa printf("]\n"); 458b6ea6408SIntel return -1; 459b6ea6408SIntel } 460b6ea6408SIntel socket_id = (uint8_t)int_fld[FLD_SOCKET]; 4617acf894dSStephen Hurd if (socket_id >= max_socket) { 462b6ea6408SIntel printf("Invalid socket id, range is [0, %d]\n", 4637acf894dSStephen Hurd max_socket - 1); 464b6ea6408SIntel return -1; 465b6ea6408SIntel } 466b6ea6408SIntel ring_flag = (uint8_t)int_fld[FLD_FLAG]; 467b6ea6408SIntel if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) { 468b6ea6408SIntel printf("Invalid ring-flag=%d config for port =%d\n", 469b6ea6408SIntel ring_flag,port_id); 470b6ea6408SIntel return -1; 471b6ea6408SIntel } 472b6ea6408SIntel 473b6ea6408SIntel switch (ring_flag & RXTX_RING) { 474b6ea6408SIntel case RX_RING_ONLY: 475b6ea6408SIntel rxring_numa[port_id] = socket_id; 476b6ea6408SIntel break; 477b6ea6408SIntel case TX_RING_ONLY: 478b6ea6408SIntel txring_numa[port_id] = socket_id; 479b6ea6408SIntel break; 480b6ea6408SIntel case RXTX_RING: 481b6ea6408SIntel rxring_numa[port_id] = socket_id; 482b6ea6408SIntel txring_numa[port_id] = socket_id; 483b6ea6408SIntel break; 484b6ea6408SIntel default: 485b6ea6408SIntel printf("Invalid ring-flag=%d config for port=%d\n", 486b6ea6408SIntel ring_flag,port_id); 487b6ea6408SIntel break; 488b6ea6408SIntel } 489b6ea6408SIntel } 490b6ea6408SIntel 491b6ea6408SIntel return 0; 492b6ea6408SIntel } 493ed30d9b6SIntel 494af75078fSIntel void 495af75078fSIntel launch_args_parse(int argc, char** argv) 496af75078fSIntel { 497af75078fSIntel int n, opt; 498af75078fSIntel char **argvopt; 499af75078fSIntel int opt_idx; 500013af9b6SIntel enum { TX, RX }; 501013af9b6SIntel 502af75078fSIntel static struct option lgopts[] = { 503af75078fSIntel { "help", 0, 0, 0 }, 5040d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE 505af75078fSIntel { "interactive", 0, 0, 0 }, 506ca7feb22SCyril Chemparathy { "auto-start", 0, 0, 0 }, 507af75078fSIntel { "eth-peers-configfile", 1, 0, 0 }, 508af75078fSIntel { "eth-peer", 1, 0, 0 }, 5090d56cb81SThomas Monjalon #endif 510af75078fSIntel { "ports", 1, 0, 0 }, 511af75078fSIntel { "nb-cores", 1, 0, 0 }, 512af75078fSIntel { "nb-ports", 1, 0, 0 }, 513af75078fSIntel { "coremask", 1, 0, 0 }, 514af75078fSIntel { "portmask", 1, 0, 0 }, 515af75078fSIntel { "numa", 0, 0, 0 }, 516148f963fSBruce Richardson { "mp-anon", 0, 0, 0 }, 517b6ea6408SIntel { "port-numa-config", 1, 0, 0 }, 518b6ea6408SIntel { "ring-numa-config", 1, 0, 0 }, 519b6ea6408SIntel { "socket-num", 1, 0, 0 }, 520af75078fSIntel { "mbuf-size", 1, 0, 0 }, 521c8798818SIntel { "total-num-mbufs", 1, 0, 0 }, 522af75078fSIntel { "max-pkt-len", 1, 0, 0 }, 523af75078fSIntel { "pkt-filter-mode", 1, 0, 0 }, 524af75078fSIntel { "pkt-filter-report-hash", 1, 0, 0 }, 525af75078fSIntel { "pkt-filter-size", 1, 0, 0 }, 526af75078fSIntel { "pkt-filter-drop-queue", 1, 0, 0 }, 527af75078fSIntel { "crc-strip", 0, 0, 0 }, 528013af9b6SIntel { "enable-rx-cksum", 0, 0, 0 }, 529*04997938SMaciej Czekaj { "enable-scatter", 0, 0, 0 }, 530af75078fSIntel { "disable-hw-vlan", 0, 0, 0 }, 531c9dd4aadSOuyang Changchun { "disable-hw-vlan-filter", 0, 0, 0 }, 532c9dd4aadSOuyang Changchun { "disable-hw-vlan-strip", 0, 0, 0 }, 533c9dd4aadSOuyang Changchun { "disable-hw-vlan-extend", 0, 0, 0 }, 534013af9b6SIntel { "enable-drop-en", 0, 0, 0 }, 535af75078fSIntel { "disable-rss", 0, 0, 0 }, 536af75078fSIntel { "port-topology", 1, 0, 0 }, 537ce9b9fb0SCyril Chemparathy { "forward-mode", 1, 0, 0 }, 538af75078fSIntel { "rss-ip", 0, 0, 0 }, 539af75078fSIntel { "rss-udp", 0, 0, 0 }, 540af75078fSIntel { "rxq", 1, 0, 0 }, 541af75078fSIntel { "txq", 1, 0, 0 }, 542af75078fSIntel { "rxd", 1, 0, 0 }, 543af75078fSIntel { "txd", 1, 0, 0 }, 544af75078fSIntel { "burst", 1, 0, 0 }, 545af75078fSIntel { "mbcache", 1, 0, 0 }, 546af75078fSIntel { "txpt", 1, 0, 0 }, 547af75078fSIntel { "txht", 1, 0, 0 }, 548af75078fSIntel { "txwt", 1, 0, 0 }, 549af75078fSIntel { "txfreet", 1, 0, 0 }, 550af75078fSIntel { "txrst", 1, 0, 0 }, 551ce8d5614SIntel { "txqflags", 1, 0, 0 }, 552af75078fSIntel { "rxpt", 1, 0, 0 }, 553af75078fSIntel { "rxht", 1, 0, 0 }, 554af75078fSIntel { "rxwt", 1, 0, 0 }, 555af75078fSIntel { "rxfreet", 1, 0, 0 }, 556ed30d9b6SIntel { "tx-queue-stats-mapping", 1, 0, 0 }, 557ed30d9b6SIntel { "rx-queue-stats-mapping", 1, 0, 0 }, 5587741e4cfSIntel { "no-flush-rx", 0, 0, 0 }, 559a7e7bb4eSCyril Chemparathy { "txpkts", 1, 0, 0 }, 560bc202406SDavid Marchand { "disable-link-check", 0, 0, 0 }, 561af75078fSIntel { 0, 0, 0, 0 }, 562af75078fSIntel }; 563af75078fSIntel 564af75078fSIntel argvopt = argv; 565af75078fSIntel 5660d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE 567ca7feb22SCyril Chemparathy #define SHORTOPTS "i" 5680d56cb81SThomas Monjalon #else 569ca7feb22SCyril Chemparathy #define SHORTOPTS "" 5700d56cb81SThomas Monjalon #endif 571ca7feb22SCyril Chemparathy while ((opt = getopt_long(argc, argvopt, SHORTOPTS "ah", 572af75078fSIntel lgopts, &opt_idx)) != EOF) { 573af75078fSIntel switch (opt) { 5740d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE 575af75078fSIntel case 'i': 576af75078fSIntel printf("Interactive-mode selected\n"); 577af75078fSIntel interactive = 1; 578af75078fSIntel break; 5790d56cb81SThomas Monjalon #endif 580ca7feb22SCyril Chemparathy case 'a': 581ca7feb22SCyril Chemparathy printf("Auto-start selected\n"); 582ca7feb22SCyril Chemparathy auto_start = 1; 583ca7feb22SCyril Chemparathy break; 584ca7feb22SCyril Chemparathy 585af75078fSIntel case 0: /*long options */ 586af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "help")) { 587af75078fSIntel usage(argv[0]); 588af75078fSIntel rte_exit(EXIT_SUCCESS, "Displayed help\n"); 589af75078fSIntel } 5900d56cb81SThomas Monjalon #ifdef RTE_LIBRTE_CMDLINE 591af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "interactive")) { 592af75078fSIntel printf("Interactive-mode selected\n"); 593af75078fSIntel interactive = 1; 594af75078fSIntel } 595ca7feb22SCyril Chemparathy if (!strcmp(lgopts[opt_idx].name, "auto-start")) { 596ca7feb22SCyril Chemparathy printf("Auto-start selected\n"); 597ca7feb22SCyril Chemparathy auto_start = 1; 598ca7feb22SCyril Chemparathy } 599af75078fSIntel if (!strcmp(lgopts[opt_idx].name, 600af75078fSIntel "eth-peers-configfile")) { 601af75078fSIntel if (init_peer_eth_addrs(optarg) != 0) 602af75078fSIntel rte_exit(EXIT_FAILURE, 603af75078fSIntel "Cannot open logfile\n"); 604af75078fSIntel } 605af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "eth-peer")) { 606af75078fSIntel char *port_end; 607af75078fSIntel uint8_t c, peer_addr[6]; 608af75078fSIntel 609af75078fSIntel errno = 0; 610af75078fSIntel n = strtoul(optarg, &port_end, 10); 611af75078fSIntel if (errno != 0 || port_end == optarg || *port_end++ != ',') 612af75078fSIntel rte_exit(EXIT_FAILURE, 613af75078fSIntel "Invalid eth-peer: %s", optarg); 614af75078fSIntel if (n >= RTE_MAX_ETHPORTS) 615af75078fSIntel rte_exit(EXIT_FAILURE, 616af75078fSIntel "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n", 617af75078fSIntel n, RTE_MAX_ETHPORTS); 618af75078fSIntel 619aaa662e7SAlan Carew if (cmdline_parse_etheraddr(NULL, port_end, 620aaa662e7SAlan Carew &peer_addr, sizeof(peer_addr)) < 0) 621af75078fSIntel rte_exit(EXIT_FAILURE, 622af75078fSIntel "Invalid ethernet address: %s\n", 623af75078fSIntel port_end); 624af75078fSIntel for (c = 0; c < 6; c++) 625af75078fSIntel peer_eth_addrs[n].addr_bytes[c] = 626af75078fSIntel peer_addr[c]; 627af75078fSIntel nb_peer_eth_addrs++; 628af75078fSIntel } 6290d56cb81SThomas Monjalon #endif 630af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "nb-ports")) { 631af75078fSIntel n = atoi(optarg); 6320a530f0dSYong Liu if (n > 0 && n <= nb_ports) 633af75078fSIntel nb_fwd_ports = (uint8_t) n; 634af75078fSIntel else 635af75078fSIntel rte_exit(EXIT_FAILURE, 636edab33b1STetsuya Mukawa "Invalid port %d\n", n); 637af75078fSIntel } 638af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "nb-cores")) { 639af75078fSIntel n = atoi(optarg); 640af75078fSIntel if (n > 0 && n <= nb_lcores) 641af75078fSIntel nb_fwd_lcores = (uint8_t) n; 642af75078fSIntel else 643af75078fSIntel rte_exit(EXIT_FAILURE, 644af75078fSIntel "nb-cores should be > 0 and <= %d\n", 645af75078fSIntel nb_lcores); 646af75078fSIntel } 647af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "coremask")) 648af75078fSIntel parse_fwd_coremask(optarg); 649af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "portmask")) 650af75078fSIntel parse_fwd_portmask(optarg); 651b6ea6408SIntel if (!strcmp(lgopts[opt_idx].name, "numa")) { 652af75078fSIntel numa_support = 1; 653b6ea6408SIntel memset(port_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS); 654b6ea6408SIntel memset(rxring_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS); 655b6ea6408SIntel memset(txring_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS); 656b6ea6408SIntel } 657148f963fSBruce Richardson if (!strcmp(lgopts[opt_idx].name, "mp-anon")) { 658148f963fSBruce Richardson mp_anon = 1; 659148f963fSBruce Richardson } 660b6ea6408SIntel if (!strcmp(lgopts[opt_idx].name, "port-numa-config")) { 661b6ea6408SIntel if (parse_portnuma_config(optarg)) 662b6ea6408SIntel rte_exit(EXIT_FAILURE, 663b6ea6408SIntel "invalid port-numa configuration\n"); 664b6ea6408SIntel } 665b6ea6408SIntel if (!strcmp(lgopts[opt_idx].name, "ring-numa-config")) 666b6ea6408SIntel if (parse_ringnuma_config(optarg)) 667b6ea6408SIntel rte_exit(EXIT_FAILURE, 668b6ea6408SIntel "invalid ring-numa configuration\n"); 669b6ea6408SIntel if (!strcmp(lgopts[opt_idx].name, "socket-num")) { 670b6ea6408SIntel n = atoi(optarg); 6717acf894dSStephen Hurd if((uint8_t)n < max_socket) 672b6ea6408SIntel socket_num = (uint8_t)n; 673b6ea6408SIntel else 674b6ea6408SIntel rte_exit(EXIT_FAILURE, 675b6ea6408SIntel "The socket number should be < %d\n", 6767acf894dSStephen Hurd max_socket); 677b6ea6408SIntel } 678af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) { 679af75078fSIntel n = atoi(optarg); 680af75078fSIntel if (n > 0 && n <= 0xFFFF) 681af75078fSIntel mbuf_data_size = (uint16_t) n; 682af75078fSIntel else 683af75078fSIntel rte_exit(EXIT_FAILURE, 684af75078fSIntel "mbuf-size should be > 0 and < 65536\n"); 685af75078fSIntel } 686c8798818SIntel if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) { 687c8798818SIntel n = atoi(optarg); 688c8798818SIntel if (n > 1024) 689c8798818SIntel param_total_num_mbufs = (unsigned)n; 690c8798818SIntel else 691c8798818SIntel rte_exit(EXIT_FAILURE, 692c8798818SIntel "total-num-mbufs should be > 1024\n"); 693c8798818SIntel } 694af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) { 695af75078fSIntel n = atoi(optarg); 696af75078fSIntel if (n >= ETHER_MIN_LEN) { 697af75078fSIntel rx_mode.max_rx_pkt_len = (uint32_t) n; 698af75078fSIntel if (n > ETHER_MAX_LEN) 699af75078fSIntel rx_mode.jumbo_frame = 1; 700af75078fSIntel } else 701af75078fSIntel rte_exit(EXIT_FAILURE, 702af75078fSIntel "Invalid max-pkt-len=%d - should be > %d\n", 703af75078fSIntel n, ETHER_MIN_LEN); 704af75078fSIntel } 705af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) { 706af75078fSIntel if (!strcmp(optarg, "signature")) 707af75078fSIntel fdir_conf.mode = 708af75078fSIntel RTE_FDIR_MODE_SIGNATURE; 709af75078fSIntel else if (!strcmp(optarg, "perfect")) 710af75078fSIntel fdir_conf.mode = RTE_FDIR_MODE_PERFECT; 7119276b982SWenzhuo Lu else if (!strcmp(optarg, "perfect-mac-vlan")) 7129276b982SWenzhuo Lu fdir_conf.mode = RTE_FDIR_MODE_PERFECT_MAC_VLAN; 7139276b982SWenzhuo Lu else if (!strcmp(optarg, "perfect-tunnel")) 7149276b982SWenzhuo Lu fdir_conf.mode = RTE_FDIR_MODE_PERFECT_TUNNEL; 715af75078fSIntel else if (!strcmp(optarg, "none")) 716af75078fSIntel fdir_conf.mode = RTE_FDIR_MODE_NONE; 717af75078fSIntel else 718af75078fSIntel rte_exit(EXIT_FAILURE, 719af75078fSIntel "pkt-mode-invalid %s invalid - must be: " 7209276b982SWenzhuo Lu "none, signature, perfect, perfect-mac-vlan" 7219276b982SWenzhuo Lu " or perfect-tunnel\n", 722af75078fSIntel optarg); 723af75078fSIntel } 724af75078fSIntel if (!strcmp(lgopts[opt_idx].name, 725af75078fSIntel "pkt-filter-report-hash")) { 726af75078fSIntel if (!strcmp(optarg, "none")) 727af75078fSIntel fdir_conf.status = 728af75078fSIntel RTE_FDIR_NO_REPORT_STATUS; 729af75078fSIntel else if (!strcmp(optarg, "match")) 730af75078fSIntel fdir_conf.status = 731af75078fSIntel RTE_FDIR_REPORT_STATUS; 732af75078fSIntel else if (!strcmp(optarg, "always")) 733af75078fSIntel fdir_conf.status = 734af75078fSIntel RTE_FDIR_REPORT_STATUS_ALWAYS; 735af75078fSIntel else 736af75078fSIntel rte_exit(EXIT_FAILURE, 737af75078fSIntel "pkt-filter-report-hash %s invalid " 738af75078fSIntel "- must be: none or match or always\n", 739af75078fSIntel optarg); 740af75078fSIntel } 741af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) { 742af75078fSIntel if (!strcmp(optarg, "64K")) 743af75078fSIntel fdir_conf.pballoc = 744af75078fSIntel RTE_FDIR_PBALLOC_64K; 745af75078fSIntel else if (!strcmp(optarg, "128K")) 746af75078fSIntel fdir_conf.pballoc = 747af75078fSIntel RTE_FDIR_PBALLOC_128K; 748af75078fSIntel else if (!strcmp(optarg, "256K")) 749af75078fSIntel fdir_conf.pballoc = 750af75078fSIntel RTE_FDIR_PBALLOC_256K; 751af75078fSIntel else 752af75078fSIntel rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -" 753af75078fSIntel " must be: 64K or 128K or 256K\n", 754af75078fSIntel optarg); 755af75078fSIntel } 756af75078fSIntel if (!strcmp(lgopts[opt_idx].name, 757af75078fSIntel "pkt-filter-drop-queue")) { 758af75078fSIntel n = atoi(optarg); 759af75078fSIntel if (n >= 0) 760af75078fSIntel fdir_conf.drop_queue = (uint8_t) n; 761af75078fSIntel else 762af75078fSIntel rte_exit(EXIT_FAILURE, 763af75078fSIntel "drop queue %d invalid - must" 764af75078fSIntel "be >= 0 \n", n); 765af75078fSIntel } 766af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "crc-strip")) 767af75078fSIntel rx_mode.hw_strip_crc = 1; 768*04997938SMaciej Czekaj if (!strcmp(lgopts[opt_idx].name, "enable-scatter")) 769*04997938SMaciej Czekaj rx_mode.enable_scatter = 1; 770af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum")) 771af75078fSIntel rx_mode.hw_ip_checksum = 1; 772a47aa8b9SIntel 773a47aa8b9SIntel if (!strcmp(lgopts[opt_idx].name, "disable-hw-vlan")) { 774af75078fSIntel rx_mode.hw_vlan_filter = 0; 775a47aa8b9SIntel rx_mode.hw_vlan_strip = 0; 776a47aa8b9SIntel rx_mode.hw_vlan_extend = 0; 777a47aa8b9SIntel } 778a47aa8b9SIntel 779c9dd4aadSOuyang Changchun if (!strcmp(lgopts[opt_idx].name, 780c9dd4aadSOuyang Changchun "disable-hw-vlan-filter")) 781c9dd4aadSOuyang Changchun rx_mode.hw_vlan_filter = 0; 782c9dd4aadSOuyang Changchun 783c9dd4aadSOuyang Changchun if (!strcmp(lgopts[opt_idx].name, 784c9dd4aadSOuyang Changchun "disable-hw-vlan-strip")) 785c9dd4aadSOuyang Changchun rx_mode.hw_vlan_strip = 0; 786c9dd4aadSOuyang Changchun 787c9dd4aadSOuyang Changchun if (!strcmp(lgopts[opt_idx].name, 788c9dd4aadSOuyang Changchun "disable-hw-vlan-extend")) 789c9dd4aadSOuyang Changchun rx_mode.hw_vlan_extend = 0; 790c9dd4aadSOuyang Changchun 791ce8d5614SIntel if (!strcmp(lgopts[opt_idx].name, "enable-drop-en")) 792ce8d5614SIntel rx_drop_en = 1; 793ce8d5614SIntel 794af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "disable-rss")) 795af75078fSIntel rss_hf = 0; 796af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "port-topology")) { 797af75078fSIntel if (!strcmp(optarg, "paired")) 798af75078fSIntel port_topology = PORT_TOPOLOGY_PAIRED; 799af75078fSIntel else if (!strcmp(optarg, "chained")) 800af75078fSIntel port_topology = PORT_TOPOLOGY_CHAINED; 8013e2006d6SCyril Chemparathy else if (!strcmp(optarg, "loop")) 8023e2006d6SCyril Chemparathy port_topology = PORT_TOPOLOGY_LOOP; 803af75078fSIntel else 804af75078fSIntel rte_exit(EXIT_FAILURE, "port-topology %s invalid -" 805af75078fSIntel " must be: paired or chained \n", 806af75078fSIntel optarg); 807af75078fSIntel } 808ce9b9fb0SCyril Chemparathy if (!strcmp(lgopts[opt_idx].name, "forward-mode")) 809ce9b9fb0SCyril Chemparathy set_pkt_forwarding_mode(optarg); 810af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rss-ip")) 8118a387fa8SHelin Zhang rss_hf = ETH_RSS_IP; 812af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rss-udp")) 8138a387fa8SHelin Zhang rss_hf = ETH_RSS_UDP; 814af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxq")) { 815af75078fSIntel n = atoi(optarg); 8165a8fb55cSReshma Pattan if (n >= 0 && n <= (int) MAX_QUEUE_ID) 817af75078fSIntel nb_rxq = (queueid_t) n; 818af75078fSIntel else 819af75078fSIntel rte_exit(EXIT_FAILURE, "rxq %d invalid - must be" 8205a8fb55cSReshma Pattan " >= 0 && <= %d\n", n, 821af75078fSIntel (int) MAX_QUEUE_ID); 822af75078fSIntel } 823af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txq")) { 824af75078fSIntel n = atoi(optarg); 8255a8fb55cSReshma Pattan if (n >= 0 && n <= (int) MAX_QUEUE_ID) 826af75078fSIntel nb_txq = (queueid_t) n; 827af75078fSIntel else 828af75078fSIntel rte_exit(EXIT_FAILURE, "txq %d invalid - must be" 8295a8fb55cSReshma Pattan " >= 0 && <= %d\n", n, 830af75078fSIntel (int) MAX_QUEUE_ID); 831af75078fSIntel } 8325a8fb55cSReshma Pattan if (!nb_rxq && !nb_txq) { 8335a8fb55cSReshma Pattan rte_exit(EXIT_FAILURE, "Either rx or tx queues should " 8345a8fb55cSReshma Pattan "be non-zero\n"); 8355a8fb55cSReshma Pattan } 836af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "burst")) { 837af75078fSIntel n = atoi(optarg); 838af75078fSIntel if ((n >= 1) && (n <= MAX_PKT_BURST)) 839af75078fSIntel nb_pkt_per_burst = (uint16_t) n; 840af75078fSIntel else 841af75078fSIntel rte_exit(EXIT_FAILURE, 842af75078fSIntel "burst must >= 1 and <= %d]", 843af75078fSIntel MAX_PKT_BURST); 844af75078fSIntel } 845af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "mbcache")) { 846af75078fSIntel n = atoi(optarg); 847af75078fSIntel if ((n >= 0) && 848af75078fSIntel (n <= RTE_MEMPOOL_CACHE_MAX_SIZE)) 849af75078fSIntel mb_mempool_cache = (uint16_t) n; 850af75078fSIntel else 851af75078fSIntel rte_exit(EXIT_FAILURE, 852af75078fSIntel "mbcache must be >= 0 and <= %d\n", 853af75078fSIntel RTE_MEMPOOL_CACHE_MAX_SIZE); 854af75078fSIntel } 855af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txfreet")) { 856af75078fSIntel n = atoi(optarg); 857af75078fSIntel if (n >= 0) 858f2c5125aSPablo de Lara tx_free_thresh = (int16_t)n; 859af75078fSIntel else 860af75078fSIntel rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n"); 861af75078fSIntel } 862af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txrst")) { 863af75078fSIntel n = atoi(optarg); 864af75078fSIntel if (n >= 0) 865f2c5125aSPablo de Lara tx_rs_thresh = (int16_t)n; 866af75078fSIntel else 867af75078fSIntel rte_exit(EXIT_FAILURE, "txrst must be >= 0\n"); 868af75078fSIntel } 869ce8d5614SIntel if (!strcmp(lgopts[opt_idx].name, "txqflags")) { 870ce8d5614SIntel char *end = NULL; 871ce8d5614SIntel n = strtoul(optarg, &end, 16); 872ce8d5614SIntel if (n >= 0) 873f2c5125aSPablo de Lara txq_flags = (int32_t)n; 874ce8d5614SIntel else 875ce8d5614SIntel rte_exit(EXIT_FAILURE, 876ce8d5614SIntel "txqflags must be >= 0\n"); 877ce8d5614SIntel } 878af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxd")) { 879af75078fSIntel n = atoi(optarg); 880af75078fSIntel if (n > 0) { 881af75078fSIntel if (rx_free_thresh >= n) 882af75078fSIntel rte_exit(EXIT_FAILURE, 883af75078fSIntel "rxd must be > " 884af75078fSIntel "rx_free_thresh(%d)\n", 885af75078fSIntel (int)rx_free_thresh); 886af75078fSIntel else 887af75078fSIntel nb_rxd = (uint16_t) n; 888af75078fSIntel } else 889af75078fSIntel rte_exit(EXIT_FAILURE, 890af75078fSIntel "rxd(%d) invalid - must be > 0\n", 891af75078fSIntel n); 892af75078fSIntel } 893af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txd")) { 894af75078fSIntel n = atoi(optarg); 895af75078fSIntel if (n > 0) 896af75078fSIntel nb_txd = (uint16_t) n; 897af75078fSIntel else 898af75078fSIntel rte_exit(EXIT_FAILURE, "txd must be in > 0\n"); 899af75078fSIntel } 900af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txpt")) { 901af75078fSIntel n = atoi(optarg); 902af75078fSIntel if (n >= 0) 903f2c5125aSPablo de Lara tx_pthresh = (int8_t)n; 904af75078fSIntel else 905af75078fSIntel rte_exit(EXIT_FAILURE, "txpt must be >= 0\n"); 906af75078fSIntel } 907af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txht")) { 908af75078fSIntel n = atoi(optarg); 909af75078fSIntel if (n >= 0) 910f2c5125aSPablo de Lara tx_hthresh = (int8_t)n; 911af75078fSIntel else 912af75078fSIntel rte_exit(EXIT_FAILURE, "txht must be >= 0\n"); 913af75078fSIntel } 914af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txwt")) { 915af75078fSIntel n = atoi(optarg); 916af75078fSIntel if (n >= 0) 917f2c5125aSPablo de Lara tx_wthresh = (int8_t)n; 918af75078fSIntel else 919af75078fSIntel rte_exit(EXIT_FAILURE, "txwt must be >= 0\n"); 920af75078fSIntel } 921af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxpt")) { 922af75078fSIntel n = atoi(optarg); 923af75078fSIntel if (n >= 0) 924f2c5125aSPablo de Lara rx_pthresh = (int8_t)n; 925af75078fSIntel else 926af75078fSIntel rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n"); 927af75078fSIntel } 928af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxht")) { 929af75078fSIntel n = atoi(optarg); 930af75078fSIntel if (n >= 0) 931f2c5125aSPablo de Lara rx_hthresh = (int8_t)n; 932af75078fSIntel else 933af75078fSIntel rte_exit(EXIT_FAILURE, "rxht must be >= 0\n"); 934af75078fSIntel } 935af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxwt")) { 936af75078fSIntel n = atoi(optarg); 937af75078fSIntel if (n >= 0) 938f2c5125aSPablo de Lara rx_wthresh = (int8_t)n; 939af75078fSIntel else 940af75078fSIntel rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n"); 941af75078fSIntel } 942af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxfreet")) { 943af75078fSIntel n = atoi(optarg); 944af75078fSIntel if (n >= 0) 945f2c5125aSPablo de Lara rx_free_thresh = (int16_t)n; 946af75078fSIntel else 947af75078fSIntel rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n"); 948af75078fSIntel } 949ed30d9b6SIntel if (!strcmp(lgopts[opt_idx].name, "tx-queue-stats-mapping")) { 950ed30d9b6SIntel if (parse_queue_stats_mapping_config(optarg, TX)) { 951ed30d9b6SIntel rte_exit(EXIT_FAILURE, 952ed30d9b6SIntel "invalid TX queue statistics mapping config entered\n"); 953ed30d9b6SIntel } 954ed30d9b6SIntel } 955ed30d9b6SIntel if (!strcmp(lgopts[opt_idx].name, "rx-queue-stats-mapping")) { 956ed30d9b6SIntel if (parse_queue_stats_mapping_config(optarg, RX)) { 957ed30d9b6SIntel rte_exit(EXIT_FAILURE, 958ed30d9b6SIntel "invalid RX queue statistics mapping config entered\n"); 959ed30d9b6SIntel } 960ed30d9b6SIntel } 961a7e7bb4eSCyril Chemparathy if (!strcmp(lgopts[opt_idx].name, "txpkts")) { 962a7e7bb4eSCyril Chemparathy unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 963a7e7bb4eSCyril Chemparathy unsigned int nb_segs; 964a7e7bb4eSCyril Chemparathy 965950d1516SBruce Richardson nb_segs = parse_item_list(optarg, "txpkt segments", 966950d1516SBruce Richardson RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 967a7e7bb4eSCyril Chemparathy if (nb_segs > 0) 968a7e7bb4eSCyril Chemparathy set_tx_pkt_segments(seg_lengths, nb_segs); 969a7e7bb4eSCyril Chemparathy else 970a7e7bb4eSCyril Chemparathy rte_exit(EXIT_FAILURE, "bad txpkts\n"); 971a7e7bb4eSCyril Chemparathy } 9727741e4cfSIntel if (!strcmp(lgopts[opt_idx].name, "no-flush-rx")) 9737741e4cfSIntel no_flush_rx = 1; 974bc202406SDavid Marchand if (!strcmp(lgopts[opt_idx].name, "disable-link-check")) 975bc202406SDavid Marchand no_link_check = 1; 9767741e4cfSIntel 977af75078fSIntel break; 978af75078fSIntel case 'h': 979af75078fSIntel usage(argv[0]); 980af75078fSIntel rte_exit(EXIT_SUCCESS, "Displayed help\n"); 981af75078fSIntel break; 982af75078fSIntel default: 983af75078fSIntel usage(argv[0]); 984af75078fSIntel rte_exit(EXIT_FAILURE, 985af75078fSIntel "Command line is incomplete or incorrect\n"); 986af75078fSIntel break; 987af75078fSIntel } 988af75078fSIntel } 989af75078fSIntel } 990