1af75078fSIntel /*- 2af75078fSIntel * BSD LICENSE 3af75078fSIntel * 4af75078fSIntel * Copyright(c) 2010-2012 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 35af75078fSIntel #include <errno.h> 36af75078fSIntel #include <getopt.h> 37af75078fSIntel #include <stdarg.h> 38af75078fSIntel #include <stdio.h> 39af75078fSIntel #include <stdlib.h> 40af75078fSIntel #include <signal.h> 41af75078fSIntel #include <string.h> 42af75078fSIntel #include <time.h> 43af75078fSIntel #include <fcntl.h> 44af75078fSIntel #include <sys/types.h> 45af75078fSIntel #include <errno.h> 46af75078fSIntel 47af75078fSIntel #include <sys/queue.h> 48af75078fSIntel #include <sys/stat.h> 49af75078fSIntel 50af75078fSIntel #include <stdint.h> 51af75078fSIntel #include <unistd.h> 52af75078fSIntel #include <inttypes.h> 53af75078fSIntel 54af75078fSIntel #include <rte_common.h> 55af75078fSIntel #include <rte_byteorder.h> 56af75078fSIntel #include <rte_log.h> 57af75078fSIntel #include <rte_debug.h> 58af75078fSIntel #include <rte_cycles.h> 59af75078fSIntel #include <rte_memory.h> 60af75078fSIntel #include <rte_memzone.h> 61af75078fSIntel #include <rte_launch.h> 62af75078fSIntel #include <rte_tailq.h> 63af75078fSIntel #include <rte_eal.h> 64af75078fSIntel #include <rte_per_lcore.h> 65af75078fSIntel #include <rte_lcore.h> 66af75078fSIntel #include <rte_atomic.h> 67af75078fSIntel #include <rte_branch_prediction.h> 68af75078fSIntel #include <rte_ring.h> 69af75078fSIntel #include <rte_mempool.h> 70af75078fSIntel #include <rte_interrupts.h> 71af75078fSIntel #include <rte_pci.h> 72af75078fSIntel #include <rte_ether.h> 73af75078fSIntel #include <rte_ethdev.h> 74af75078fSIntel #include <rte_string_fns.h> 75af75078fSIntel #include <cmdline_parse.h> 76af75078fSIntel #include <cmdline_parse_etheraddr.h> 77af75078fSIntel 78af75078fSIntel #include "testpmd.h" 79af75078fSIntel 80af75078fSIntel static void 81af75078fSIntel usage(char* progname) 82af75078fSIntel { 83af75078fSIntel printf("usage: %s [--interactive|-i] [--help|-h] | [" 84af75078fSIntel "--coremask=COREMASK --portmask=PORTMASK --numa " 85af75078fSIntel "--eth-peers-configfile= | " 86af75078fSIntel "--eth-peer=X,M:M:M:M:M:M | --nb-cores= | --nb-ports= | " 87af75078fSIntel "--pkt-filter-mode= |" 88af75078fSIntel "--rss-ip | --rss-udp | " 89af75078fSIntel "--rxpt= | --rxht= | --rxwt= | --rxfreet= | " 90af75078fSIntel "--txpt= | --txht= | --txwt= | --txfreet= | " 91af75078fSIntel "--txrst= ]\n", 92af75078fSIntel progname); 93af75078fSIntel printf(" --interactive: run in interactive mode\n"); 94af75078fSIntel printf(" --help: display this message and quit\n"); 95af75078fSIntel printf(" --eth-peers-configfile=name of file with ethernet addresses " 96af75078fSIntel "of peer ports\n"); 97af75078fSIntel printf(" --eth-peer=X,M:M:M:M:M:M set the mac address of the X peer " 98af75078fSIntel "port (0 <= X < %d)\n", RTE_MAX_ETHPORTS); 99af75078fSIntel printf(" --nb-cores=N set the number of forwarding cores" 100af75078fSIntel " (1 <= N <= %d)\n", nb_lcores); 101af75078fSIntel printf(" --nb-ports=N set the number of forwarding ports" 102af75078fSIntel " (1 <= N <= %d)\n", nb_ports); 103af75078fSIntel printf(" --coremask=COREMASK: hexadecimal bitmask of cores running " 104af75078fSIntel "the packet forwarding test\n"); 105af75078fSIntel printf(" --portmask=PORTMASK: hexadecimal bitmask of ports used " 106af75078fSIntel "by the packet forwarding test\n"); 107af75078fSIntel printf(" --numa: enable NUMA-aware allocation of RX/TX rings and of " 108af75078fSIntel " RX memory buffers (mbufs)\n"); 109af75078fSIntel printf(" --mbuf-size=N set the data size of mbuf to N bytes\n"); 110af75078fSIntel printf(" --max-pkt-len=N set the maximum size of packet to N bytes\n"); 111af75078fSIntel printf(" --pkt-filter-mode=N: set Flow director mode " 112af75078fSIntel "( N: none (default mode) or signature or perfect)\n"); 113af75078fSIntel printf(" --pkt-filter-report-hash=N: set Flow director report mode " 114af75078fSIntel "( N: none or match (default) or always)\n"); 115af75078fSIntel printf(" --pkt-filter-size=N: set Flow director mode " 116af75078fSIntel "( N: 64K (default mode) or 128K or 256K)\n"); 117af75078fSIntel printf(" --pkt-filter-flexbytes-offset=N: set flexbytes-offset." 118af75078fSIntel " The offset is defined in word units counted from the" 119af75078fSIntel " first byte of the destination Ethernet MAC address." 120af75078fSIntel " 0 <= N <= 32\n"); 121af75078fSIntel printf(" --pkt-filter-drop-queue=N: set drop-queue." 122af75078fSIntel " In perfect mode, when you add a rule with queue -1" 123af75078fSIntel " the packet will be enqueued into the rx drop-queue." 124af75078fSIntel " If the drop-queue doesn't exist, the packet is dropped." 125af75078fSIntel " By default drop-queue=127\n"); 126af75078fSIntel printf(" --crc-strip: enable CRC stripping by hardware\n"); 127af75078fSIntel printf(" --enable-rx-cksum: enable rx hardware checksum offload\n"); 128af75078fSIntel printf(" --disable-hw-vlan: disable hardware vlan\n"); 129af75078fSIntel printf(" --disable-rss: disable rss\n"); 130af75078fSIntel printf(" --port-topology=N: set port topology (N: paired (default) or " 131af75078fSIntel "chained)\n"); 132af75078fSIntel printf(" --rss-ip: set RSS functions to IPv4/IPv6 only \n"); 133af75078fSIntel printf(" --rss-udp: set RSS functions to IPv4/IPv6 + UDP\n"); 134af75078fSIntel printf(" --rxq=N set the number of RX queues per port to N\n"); 135af75078fSIntel printf(" --rxd=N set the number of descriptors in RX rings to N\n"); 136af75078fSIntel printf(" --txq=N set the number of TX queues per port to N\n"); 137af75078fSIntel printf(" --txd=N set the number of descriptors in TX rings to N\n"); 138af75078fSIntel printf(" --burst=N set the number of packets per burst to N\n"); 139af75078fSIntel printf(" --mbcache=N set the cache of mbuf memory pool to N\n"); 140af75078fSIntel printf(" --rxpt=N set prefetch threshold register of RX rings to N" 141af75078fSIntel " (0 <= N <= 16)\n"); 142af75078fSIntel printf(" --rxht=N set the host threshold register of RX rings to N" 143af75078fSIntel " (0 <= N <= 16)\n"); 144af75078fSIntel printf(" --rxfreet=N set the free threshold of RX descriptors to N" 145af75078fSIntel " (0 <= N < value of rxd)\n"); 146af75078fSIntel printf(" --rxwt=N set the write-back threshold register of RX rings" 147af75078fSIntel " to N (0 <= N <= 16)\n"); 148af75078fSIntel printf(" --txpt=N set the prefetch threshold register of TX rings" 149af75078fSIntel " to N (0 <= N <= 16)\n"); 150af75078fSIntel printf(" --txht=N set the nhost threshold register of TX rings to N" 151af75078fSIntel " (0 <= N <= 16)\n"); 152af75078fSIntel printf(" --txwt=N set the write-back threshold register of TX rings" 153af75078fSIntel " to N (0 <= N <= 16)\n"); 154af75078fSIntel printf(" --txfreet=N set the transmit free threshold of TX rings to N" 155af75078fSIntel " (0 <= N <= value of txd)\n"); 156af75078fSIntel printf(" --txrst=N set the transmit RS bit threshold of TX rings to N" 157af75078fSIntel " (0 <= N <= value of txd)\n"); 158*ed30d9b6SIntel printf(" --tx-queue-stats-mapping (port,queue,mapping)[,(port,queue,mapping]:" 159*ed30d9b6SIntel " tx queues statistics counters mapping" 160*ed30d9b6SIntel " (0 <= mapping <= %d)\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); 161*ed30d9b6SIntel printf(" --rx-queue-stats-mapping (port,queue,mapping)[,(port,queue,mapping]:" 162*ed30d9b6SIntel " rx queues statistics counters mapping" 163*ed30d9b6SIntel " (0 <= mapping <= %d)\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); 164af75078fSIntel } 165af75078fSIntel 166af75078fSIntel static int 167af75078fSIntel init_peer_eth_addrs(char *config_filename) 168af75078fSIntel { 169af75078fSIntel FILE *config_file; 170af75078fSIntel portid_t i; 171af75078fSIntel char buf[50]; 172af75078fSIntel 173af75078fSIntel config_file = fopen(config_filename, "r"); 174af75078fSIntel if (config_file == NULL) { 175af75078fSIntel perror("open log file failed\n"); 176af75078fSIntel return -1; 177af75078fSIntel } 178af75078fSIntel 179af75078fSIntel for (i = 0; i < RTE_MAX_ETHPORTS; i++) { 180af75078fSIntel 181af75078fSIntel if (fgets(buf, sizeof(buf), config_file) == NULL) 182af75078fSIntel break; 183af75078fSIntel 184af75078fSIntel if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i]) < 0 ){ 185af75078fSIntel printf("bad format of mac address on line %d\n", i); 186af75078fSIntel fclose(config_file); 187af75078fSIntel return -1; 188af75078fSIntel } 189af75078fSIntel } 190af75078fSIntel fclose(config_file); 191af75078fSIntel nb_peer_eth_addrs = (portid_t) i; 192af75078fSIntel return 0; 193af75078fSIntel } 194af75078fSIntel 195af75078fSIntel /* 196af75078fSIntel * Parse the coremask given as argument (hexadecimal string) and set 197af75078fSIntel * the global configuration of forwarding cores. 198af75078fSIntel */ 199af75078fSIntel static void 200af75078fSIntel parse_fwd_coremask(const char *coremask) 201af75078fSIntel { 202af75078fSIntel char *end; 203af75078fSIntel unsigned long long int cm; 204af75078fSIntel 205af75078fSIntel /* parse hexadecimal string */ 206af75078fSIntel end = NULL; 207af75078fSIntel cm = strtoull(coremask, &end, 16); 208af75078fSIntel if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0')) 209af75078fSIntel rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n"); 210af75078fSIntel else 211af75078fSIntel set_fwd_lcores_mask((uint64_t) cm); 212af75078fSIntel } 213af75078fSIntel 214af75078fSIntel /* 215af75078fSIntel * Parse the coremask given as argument (hexadecimal string) and set 216af75078fSIntel * the global configuration of forwarding cores. 217af75078fSIntel */ 218af75078fSIntel static void 219af75078fSIntel parse_fwd_portmask(const char *portmask) 220af75078fSIntel { 221af75078fSIntel char *end; 222af75078fSIntel unsigned long long int pm; 223af75078fSIntel 224af75078fSIntel /* parse hexadecimal string */ 225af75078fSIntel end = NULL; 226af75078fSIntel pm = strtoull(portmask, &end, 16); 227af75078fSIntel if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) 228af75078fSIntel rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n"); 229af75078fSIntel else 230af75078fSIntel set_fwd_ports_mask((uint64_t) pm); 231af75078fSIntel } 232af75078fSIntel 233*ed30d9b6SIntel 234*ed30d9b6SIntel static int 235*ed30d9b6SIntel parse_queue_stats_mapping_config(const char *q_arg, int is_rx) 236*ed30d9b6SIntel { 237*ed30d9b6SIntel char s[256]; 238*ed30d9b6SIntel const char *p, *p0 = q_arg; 239*ed30d9b6SIntel char *end; 240*ed30d9b6SIntel enum fieldnames { 241*ed30d9b6SIntel FLD_PORT = 0, 242*ed30d9b6SIntel FLD_QUEUE, 243*ed30d9b6SIntel FLD_STATS_COUNTER, 244*ed30d9b6SIntel _NUM_FLD 245*ed30d9b6SIntel }; 246*ed30d9b6SIntel unsigned long int_fld[_NUM_FLD]; 247*ed30d9b6SIntel char *str_fld[_NUM_FLD]; 248*ed30d9b6SIntel int i; 249*ed30d9b6SIntel unsigned size; 250*ed30d9b6SIntel 251*ed30d9b6SIntel /* reset from value set at definition */ 252*ed30d9b6SIntel is_rx ? (nb_rx_queue_stats_mappings = 0) : (nb_tx_queue_stats_mappings = 0); 253*ed30d9b6SIntel 254*ed30d9b6SIntel while ((p = strchr(p0,'(')) != NULL) { 255*ed30d9b6SIntel ++p; 256*ed30d9b6SIntel if((p0 = strchr(p,')')) == NULL) 257*ed30d9b6SIntel return -1; 258*ed30d9b6SIntel 259*ed30d9b6SIntel size = p0 - p; 260*ed30d9b6SIntel if(size >= sizeof(s)) 261*ed30d9b6SIntel return -1; 262*ed30d9b6SIntel 263*ed30d9b6SIntel rte_snprintf(s, sizeof(s), "%.*s", size, p); 264*ed30d9b6SIntel if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 265*ed30d9b6SIntel return -1; 266*ed30d9b6SIntel for (i = 0; i < _NUM_FLD; i++){ 267*ed30d9b6SIntel errno = 0; 268*ed30d9b6SIntel int_fld[i] = strtoul(str_fld[i], &end, 0); 269*ed30d9b6SIntel if (errno != 0 || end == str_fld[i] || int_fld[i] > 255) 270*ed30d9b6SIntel return -1; 271*ed30d9b6SIntel } 272*ed30d9b6SIntel /* Check mapping field is in correct range (0..RTE_ETHDEV_QUEUE_STAT_CNTRS-1) */ 273*ed30d9b6SIntel if (int_fld[FLD_STATS_COUNTER] >= RTE_ETHDEV_QUEUE_STAT_CNTRS) { 274*ed30d9b6SIntel printf("Stats counter not in the correct range 0..%d\n", 275*ed30d9b6SIntel RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); 276*ed30d9b6SIntel return -1; 277*ed30d9b6SIntel } 278*ed30d9b6SIntel 279*ed30d9b6SIntel if (is_rx ? (nb_rx_queue_stats_mappings >= MAX_RX_QUEUE_STATS_MAPPINGS) : 280*ed30d9b6SIntel (nb_tx_queue_stats_mappings >= MAX_TX_QUEUE_STATS_MAPPINGS)) { 281*ed30d9b6SIntel printf("exceeded max number of %s queue statistics mappings: %hu\n", 282*ed30d9b6SIntel is_rx ? "RX" : "TX", 283*ed30d9b6SIntel is_rx ? nb_rx_queue_stats_mappings : nb_tx_queue_stats_mappings); 284*ed30d9b6SIntel return -1; 285*ed30d9b6SIntel } 286*ed30d9b6SIntel if (!is_rx) { 287*ed30d9b6SIntel tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id = 288*ed30d9b6SIntel (uint8_t)int_fld[FLD_PORT]; 289*ed30d9b6SIntel tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id = 290*ed30d9b6SIntel (uint8_t)int_fld[FLD_QUEUE]; 291*ed30d9b6SIntel tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].stats_counter_id = 292*ed30d9b6SIntel (uint8_t)int_fld[FLD_STATS_COUNTER]; 293*ed30d9b6SIntel ++nb_tx_queue_stats_mappings; 294*ed30d9b6SIntel } 295*ed30d9b6SIntel else { 296*ed30d9b6SIntel rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id = 297*ed30d9b6SIntel (uint8_t)int_fld[FLD_PORT]; 298*ed30d9b6SIntel rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id = 299*ed30d9b6SIntel (uint8_t)int_fld[FLD_QUEUE]; 300*ed30d9b6SIntel rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].stats_counter_id = 301*ed30d9b6SIntel (uint8_t)int_fld[FLD_STATS_COUNTER]; 302*ed30d9b6SIntel ++nb_rx_queue_stats_mappings; 303*ed30d9b6SIntel } 304*ed30d9b6SIntel 305*ed30d9b6SIntel } 306*ed30d9b6SIntel /* Reassign the rx/tx_queue_stats_mappings pointer to point to this newly populated array rather */ 307*ed30d9b6SIntel /* than to the default array (that was set at its definition) */ 308*ed30d9b6SIntel is_rx ? (rx_queue_stats_mappings = rx_queue_stats_mappings_array) : 309*ed30d9b6SIntel (tx_queue_stats_mappings = tx_queue_stats_mappings_array); 310*ed30d9b6SIntel return 0; 311*ed30d9b6SIntel } 312*ed30d9b6SIntel 313*ed30d9b6SIntel 314af75078fSIntel void 315af75078fSIntel launch_args_parse(int argc, char** argv) 316af75078fSIntel { 317af75078fSIntel int n, opt; 318af75078fSIntel char **argvopt; 319af75078fSIntel int opt_idx; 320af75078fSIntel static struct option lgopts[] = { 321af75078fSIntel { "help", 0, 0, 0 }, 322af75078fSIntel { "interactive", 0, 0, 0 }, 323af75078fSIntel { "eth-peers-configfile", 1, 0, 0 }, 324af75078fSIntel { "eth-peer", 1, 0, 0 }, 325af75078fSIntel { "ports", 1, 0, 0 }, 326af75078fSIntel { "nb-cores", 1, 0, 0 }, 327af75078fSIntel { "nb-ports", 1, 0, 0 }, 328af75078fSIntel { "coremask", 1, 0, 0 }, 329af75078fSIntel { "portmask", 1, 0, 0 }, 330af75078fSIntel { "numa", 0, 0, 0 }, 331af75078fSIntel { "mbuf-size", 1, 0, 0 }, 332af75078fSIntel { "max-pkt-len", 1, 0, 0 }, 333af75078fSIntel { "pkt-filter-mode", 1, 0, 0 }, 334af75078fSIntel { "pkt-filter-report-hash", 1, 0, 0 }, 335af75078fSIntel { "pkt-filter-size", 1, 0, 0 }, 336af75078fSIntel { "pkt-filter-flexbytes-offset",1, 0, 0 }, 337af75078fSIntel { "pkt-filter-drop-queue", 1, 0, 0 }, 338af75078fSIntel { "crc-strip", 0, 0, 0 }, 339af75078fSIntel { "disable-hw-vlan", 0, 0, 0 }, 340af75078fSIntel { "disable-rss", 0, 0, 0 }, 341af75078fSIntel { "port-topology", 1, 0, 0 }, 342af75078fSIntel { "rss-ip", 0, 0, 0 }, 343af75078fSIntel { "rss-udp", 0, 0, 0 }, 344af75078fSIntel { "rxq", 1, 0, 0 }, 345af75078fSIntel { "txq", 1, 0, 0 }, 346af75078fSIntel { "rxd", 1, 0, 0 }, 347af75078fSIntel { "txd", 1, 0, 0 }, 348af75078fSIntel { "burst", 1, 0, 0 }, 349af75078fSIntel { "mbcache", 1, 0, 0 }, 350af75078fSIntel { "txpt", 1, 0, 0 }, 351af75078fSIntel { "txht", 1, 0, 0 }, 352af75078fSIntel { "txwt", 1, 0, 0 }, 353af75078fSIntel { "txfreet", 1, 0, 0 }, 354af75078fSIntel { "txrst", 1, 0, 0 }, 355af75078fSIntel { "rxpt", 1, 0, 0 }, 356af75078fSIntel { "rxht", 1, 0, 0 }, 357af75078fSIntel { "rxwt", 1, 0, 0 }, 358af75078fSIntel { "rxfreet", 1, 0, 0 }, 359*ed30d9b6SIntel { "tx-queue-stats-mapping", 1, 0, 0 }, 360*ed30d9b6SIntel { "rx-queue-stats-mapping", 1, 0, 0 }, 361af75078fSIntel { 0, 0, 0, 0 }, 362af75078fSIntel }; 363af75078fSIntel 364af75078fSIntel argvopt = argv; 365af75078fSIntel 366af75078fSIntel while ((opt = getopt_long(argc, argvopt, "ih", 367af75078fSIntel lgopts, &opt_idx)) != EOF) { 368af75078fSIntel switch (opt) { 369af75078fSIntel case 'i': 370af75078fSIntel printf("Interactive-mode selected\n"); 371af75078fSIntel interactive = 1; 372af75078fSIntel break; 373af75078fSIntel case 0: /*long options */ 374af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "help")) { 375af75078fSIntel usage(argv[0]); 376af75078fSIntel rte_exit(EXIT_SUCCESS, "Displayed help\n"); 377af75078fSIntel } 378af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "interactive")) { 379af75078fSIntel printf("Interactive-mode selected\n"); 380af75078fSIntel interactive = 1; 381af75078fSIntel } 382af75078fSIntel if (!strcmp(lgopts[opt_idx].name, 383af75078fSIntel "eth-peers-configfile")) { 384af75078fSIntel if (init_peer_eth_addrs(optarg) != 0) 385af75078fSIntel rte_exit(EXIT_FAILURE, 386af75078fSIntel "Cannot open logfile\n"); 387af75078fSIntel } 388af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "eth-peer")) { 389af75078fSIntel char *port_end; 390af75078fSIntel uint8_t c, peer_addr[6]; 391af75078fSIntel 392af75078fSIntel errno = 0; 393af75078fSIntel n = strtoul(optarg, &port_end, 10); 394af75078fSIntel if (errno != 0 || port_end == optarg || *port_end++ != ',') 395af75078fSIntel rte_exit(EXIT_FAILURE, 396af75078fSIntel "Invalid eth-peer: %s", optarg); 397af75078fSIntel if (n >= RTE_MAX_ETHPORTS) 398af75078fSIntel rte_exit(EXIT_FAILURE, 399af75078fSIntel "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n", 400af75078fSIntel n, RTE_MAX_ETHPORTS); 401af75078fSIntel 402af75078fSIntel if (cmdline_parse_etheraddr(NULL, port_end, &peer_addr) < 0 ) 403af75078fSIntel rte_exit(EXIT_FAILURE, 404af75078fSIntel "Invalid ethernet address: %s\n", 405af75078fSIntel port_end); 406af75078fSIntel for (c = 0; c < 6; c++) 407af75078fSIntel peer_eth_addrs[n].addr_bytes[c] = 408af75078fSIntel peer_addr[c]; 409af75078fSIntel nb_peer_eth_addrs++; 410af75078fSIntel } 411af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "nb-ports")) { 412af75078fSIntel n = atoi(optarg); 413af75078fSIntel if (n > 0 && n <= nb_ports) 414af75078fSIntel nb_fwd_ports = (uint8_t) n; 415af75078fSIntel else 416af75078fSIntel rte_exit(EXIT_FAILURE, 417af75078fSIntel "nb-ports should be > 0 and <= %d\n", 418af75078fSIntel nb_ports); 419af75078fSIntel } 420af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "nb-cores")) { 421af75078fSIntel n = atoi(optarg); 422af75078fSIntel if (n > 0 && n <= nb_lcores) 423af75078fSIntel nb_fwd_lcores = (uint8_t) n; 424af75078fSIntel else 425af75078fSIntel rte_exit(EXIT_FAILURE, 426af75078fSIntel "nb-cores should be > 0 and <= %d\n", 427af75078fSIntel nb_lcores); 428af75078fSIntel } 429af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "coremask")) 430af75078fSIntel parse_fwd_coremask(optarg); 431af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "portmask")) 432af75078fSIntel parse_fwd_portmask(optarg); 433af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "numa")) 434af75078fSIntel numa_support = 1; 435af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) { 436af75078fSIntel n = atoi(optarg); 437af75078fSIntel if (n > 0 && n <= 0xFFFF) 438af75078fSIntel mbuf_data_size = (uint16_t) n; 439af75078fSIntel else 440af75078fSIntel rte_exit(EXIT_FAILURE, 441af75078fSIntel "mbuf-size should be > 0 and < 65536\n"); 442af75078fSIntel } 443af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) { 444af75078fSIntel n = atoi(optarg); 445af75078fSIntel if (n >= ETHER_MIN_LEN) { 446af75078fSIntel rx_mode.max_rx_pkt_len = (uint32_t) n; 447af75078fSIntel if (n > ETHER_MAX_LEN) 448af75078fSIntel rx_mode.jumbo_frame = 1; 449af75078fSIntel } else 450af75078fSIntel rte_exit(EXIT_FAILURE, 451af75078fSIntel "Invalid max-pkt-len=%d - should be > %d\n", 452af75078fSIntel n, ETHER_MIN_LEN); 453af75078fSIntel } 454af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "pkt-filter-mode")) { 455af75078fSIntel if (!strcmp(optarg, "signature")) 456af75078fSIntel fdir_conf.mode = 457af75078fSIntel RTE_FDIR_MODE_SIGNATURE; 458af75078fSIntel else if (!strcmp(optarg, "perfect")) 459af75078fSIntel fdir_conf.mode = RTE_FDIR_MODE_PERFECT; 460af75078fSIntel else if (!strcmp(optarg, "none")) 461af75078fSIntel fdir_conf.mode = RTE_FDIR_MODE_NONE; 462af75078fSIntel else 463af75078fSIntel rte_exit(EXIT_FAILURE, 464af75078fSIntel "pkt-mode-invalid %s invalid - must be: " 465af75078fSIntel "none, signature or perfect\n", 466af75078fSIntel optarg); 467af75078fSIntel } 468af75078fSIntel if (!strcmp(lgopts[opt_idx].name, 469af75078fSIntel "pkt-filter-report-hash")) { 470af75078fSIntel if (!strcmp(optarg, "none")) 471af75078fSIntel fdir_conf.status = 472af75078fSIntel RTE_FDIR_NO_REPORT_STATUS; 473af75078fSIntel else if (!strcmp(optarg, "match")) 474af75078fSIntel fdir_conf.status = 475af75078fSIntel RTE_FDIR_REPORT_STATUS; 476af75078fSIntel else if (!strcmp(optarg, "always")) 477af75078fSIntel fdir_conf.status = 478af75078fSIntel RTE_FDIR_REPORT_STATUS_ALWAYS; 479af75078fSIntel else 480af75078fSIntel rte_exit(EXIT_FAILURE, 481af75078fSIntel "pkt-filter-report-hash %s invalid " 482af75078fSIntel "- must be: none or match or always\n", 483af75078fSIntel optarg); 484af75078fSIntel } 485af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "pkt-filter-size")) { 486af75078fSIntel if (!strcmp(optarg, "64K")) 487af75078fSIntel fdir_conf.pballoc = 488af75078fSIntel RTE_FDIR_PBALLOC_64K; 489af75078fSIntel else if (!strcmp(optarg, "128K")) 490af75078fSIntel fdir_conf.pballoc = 491af75078fSIntel RTE_FDIR_PBALLOC_128K; 492af75078fSIntel else if (!strcmp(optarg, "256K")) 493af75078fSIntel fdir_conf.pballoc = 494af75078fSIntel RTE_FDIR_PBALLOC_256K; 495af75078fSIntel else 496af75078fSIntel rte_exit(EXIT_FAILURE, "pkt-filter-size %s invalid -" 497af75078fSIntel " must be: 64K or 128K or 256K\n", 498af75078fSIntel optarg); 499af75078fSIntel } 500af75078fSIntel if (!strcmp(lgopts[opt_idx].name, 501af75078fSIntel "pkt-filter-flexbytes-offset")) { 502af75078fSIntel n = atoi(optarg); 503af75078fSIntel if ( n >= 0 && n <= (int) 32) 504af75078fSIntel fdir_conf.flexbytes_offset = 505af75078fSIntel (uint8_t) n; 506af75078fSIntel else 507af75078fSIntel rte_exit(EXIT_FAILURE, 508af75078fSIntel "flexbytes %d invalid - must" 509af75078fSIntel "be >= 0 && <= 32\n", n); 510af75078fSIntel } 511af75078fSIntel if (!strcmp(lgopts[opt_idx].name, 512af75078fSIntel "pkt-filter-drop-queue")) { 513af75078fSIntel n = atoi(optarg); 514af75078fSIntel if (n >= 0) 515af75078fSIntel fdir_conf.drop_queue = (uint8_t) n; 516af75078fSIntel else 517af75078fSIntel rte_exit(EXIT_FAILURE, 518af75078fSIntel "drop queue %d invalid - must" 519af75078fSIntel "be >= 0 \n", n); 520af75078fSIntel } 521af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "crc-strip")) 522af75078fSIntel rx_mode.hw_strip_crc = 1; 523af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum")) 524af75078fSIntel rx_mode.hw_ip_checksum = 1; 525af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "disable-hw-vlan")) 526af75078fSIntel rx_mode.hw_vlan_filter = 0; 527af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "disable-rss")) 528af75078fSIntel rss_hf = 0; 529af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "port-topology")) { 530af75078fSIntel if (!strcmp(optarg, "paired")) 531af75078fSIntel port_topology = PORT_TOPOLOGY_PAIRED; 532af75078fSIntel else if (!strcmp(optarg, "chained")) 533af75078fSIntel port_topology = PORT_TOPOLOGY_CHAINED; 534af75078fSIntel else 535af75078fSIntel rte_exit(EXIT_FAILURE, "port-topology %s invalid -" 536af75078fSIntel " must be: paired or chained \n", 537af75078fSIntel optarg); 538af75078fSIntel } 539af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rss-ip")) 540af75078fSIntel rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6; 541af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rss-udp")) 542af75078fSIntel rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | 543af75078fSIntel ETH_RSS_IPV4_UDP; 544af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxq")) { 545af75078fSIntel n = atoi(optarg); 546af75078fSIntel if (n >= 1 && n <= (int) MAX_QUEUE_ID) 547af75078fSIntel nb_rxq = (queueid_t) n; 548af75078fSIntel else 549af75078fSIntel rte_exit(EXIT_FAILURE, "rxq %d invalid - must be" 550af75078fSIntel " >= 1 && <= %d\n", n, 551af75078fSIntel (int) MAX_QUEUE_ID); 552af75078fSIntel } 553af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txq")) { 554af75078fSIntel n = atoi(optarg); 555af75078fSIntel if (n >= 1 && n <= (int) MAX_QUEUE_ID) 556af75078fSIntel nb_txq = (queueid_t) n; 557af75078fSIntel else 558af75078fSIntel rte_exit(EXIT_FAILURE, "txq %d invalid - must be" 559af75078fSIntel " >= 1 && <= %d\n", n, 560af75078fSIntel (int) MAX_QUEUE_ID); 561af75078fSIntel } 562af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxd")) { 563af75078fSIntel n = atoi(optarg); 564af75078fSIntel if (n > 0) 565af75078fSIntel nb_rxd = (uint16_t) n; 566af75078fSIntel else 567af75078fSIntel rte_exit(EXIT_FAILURE, "rxd must be > 0\n"); 568af75078fSIntel } 569af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txd")) { 570af75078fSIntel n = atoi(optarg); 571af75078fSIntel if (n > 0) 572af75078fSIntel nb_txd = (uint16_t) n; 573af75078fSIntel else 574af75078fSIntel rte_exit(EXIT_FAILURE, "txd must be in > 0\n"); 575af75078fSIntel } 576af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "burst")) { 577af75078fSIntel n = atoi(optarg); 578af75078fSIntel if ((n >= 1) && (n <= MAX_PKT_BURST)) 579af75078fSIntel nb_pkt_per_burst = (uint16_t) n; 580af75078fSIntel else 581af75078fSIntel rte_exit(EXIT_FAILURE, 582af75078fSIntel "burst must >= 1 and <= %d]", 583af75078fSIntel MAX_PKT_BURST); 584af75078fSIntel } 585af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "mbcache")) { 586af75078fSIntel n = atoi(optarg); 587af75078fSIntel if ((n >= 0) && 588af75078fSIntel (n <= RTE_MEMPOOL_CACHE_MAX_SIZE)) 589af75078fSIntel mb_mempool_cache = (uint16_t) n; 590af75078fSIntel else 591af75078fSIntel rte_exit(EXIT_FAILURE, 592af75078fSIntel "mbcache must be >= 0 and <= %d\n", 593af75078fSIntel RTE_MEMPOOL_CACHE_MAX_SIZE); 594af75078fSIntel } 595af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txpt")) { 596af75078fSIntel n = atoi(optarg); 597af75078fSIntel if (n >= 0) 598af75078fSIntel tx_thresh.pthresh = (uint8_t)n; 599af75078fSIntel else 600af75078fSIntel rte_exit(EXIT_FAILURE, "txpt must be >= 0\n"); 601af75078fSIntel } 602af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txht")) { 603af75078fSIntel n = atoi(optarg); 604af75078fSIntel if (n >= 0) 605af75078fSIntel tx_thresh.hthresh = (uint8_t)n; 606af75078fSIntel else 607af75078fSIntel rte_exit(EXIT_FAILURE, "txht must be >= 0\n"); 608af75078fSIntel } 609af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txwt")) { 610af75078fSIntel n = atoi(optarg); 611af75078fSIntel if (n >= 0) 612af75078fSIntel tx_thresh.wthresh = (uint8_t)n; 613af75078fSIntel else 614af75078fSIntel rte_exit(EXIT_FAILURE, "txwt must be >= 0\n"); 615af75078fSIntel } 616af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txfreet")) { 617af75078fSIntel n = atoi(optarg); 618af75078fSIntel if (n >= 0) 619af75078fSIntel tx_free_thresh = (uint16_t)n; 620af75078fSIntel else 621af75078fSIntel rte_exit(EXIT_FAILURE, "txfreet must be >= 0\n"); 622af75078fSIntel } 623af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txrst")) { 624af75078fSIntel n = atoi(optarg); 625af75078fSIntel if (n >= 0) 626af75078fSIntel tx_rs_thresh = (uint16_t)n; 627af75078fSIntel else 628af75078fSIntel rte_exit(EXIT_FAILURE, "txrst must be >= 0\n"); 629af75078fSIntel } 630af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxpt")) { 631af75078fSIntel n = atoi(optarg); 632af75078fSIntel if (n >= 0) 633af75078fSIntel rx_thresh.pthresh = (uint8_t)n; 634af75078fSIntel else 635af75078fSIntel rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n"); 636af75078fSIntel } 637af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxht")) { 638af75078fSIntel n = atoi(optarg); 639af75078fSIntel if (n >= 0) 640af75078fSIntel rx_thresh.hthresh = (uint8_t)n; 641af75078fSIntel else 642af75078fSIntel rte_exit(EXIT_FAILURE, "rxht must be >= 0\n"); 643af75078fSIntel } 644af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxwt")) { 645af75078fSIntel n = atoi(optarg); 646af75078fSIntel if (n >= 0) 647af75078fSIntel rx_thresh.wthresh = (uint8_t)n; 648af75078fSIntel else 649af75078fSIntel rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n"); 650af75078fSIntel } 651af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxd")) { 652af75078fSIntel n = atoi(optarg); 653af75078fSIntel if (n > 0) { 654af75078fSIntel if (rx_free_thresh >= n) 655af75078fSIntel rte_exit(EXIT_FAILURE, 656af75078fSIntel "rxd must be > " 657af75078fSIntel "rx_free_thresh(%d)\n", 658af75078fSIntel (int)rx_free_thresh); 659af75078fSIntel else 660af75078fSIntel nb_rxd = (uint16_t) n; 661af75078fSIntel } else 662af75078fSIntel rte_exit(EXIT_FAILURE, 663af75078fSIntel "rxd(%d) invalid - must be > 0\n", 664af75078fSIntel n); 665af75078fSIntel } 666af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txd")) { 667af75078fSIntel n = atoi(optarg); 668af75078fSIntel if (n > 0) 669af75078fSIntel nb_txd = (uint16_t) n; 670af75078fSIntel else 671af75078fSIntel rte_exit(EXIT_FAILURE, "txd must be in > 0\n"); 672af75078fSIntel } 673af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txpt")) { 674af75078fSIntel n = atoi(optarg); 675af75078fSIntel if (n >= 0) 676af75078fSIntel tx_thresh.pthresh = (uint8_t)n; 677af75078fSIntel else 678af75078fSIntel rte_exit(EXIT_FAILURE, "txpt must be >= 0\n"); 679af75078fSIntel } 680af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txht")) { 681af75078fSIntel n = atoi(optarg); 682af75078fSIntel if (n >= 0) 683af75078fSIntel tx_thresh.hthresh = (uint8_t)n; 684af75078fSIntel else 685af75078fSIntel rte_exit(EXIT_FAILURE, "txht must be >= 0\n"); 686af75078fSIntel } 687af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "txwt")) { 688af75078fSIntel n = atoi(optarg); 689af75078fSIntel if (n >= 0) 690af75078fSIntel tx_thresh.wthresh = (uint8_t)n; 691af75078fSIntel else 692af75078fSIntel rte_exit(EXIT_FAILURE, "txwt must be >= 0\n"); 693af75078fSIntel } 694af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxpt")) { 695af75078fSIntel n = atoi(optarg); 696af75078fSIntel if (n >= 0) 697af75078fSIntel rx_thresh.pthresh = (uint8_t)n; 698af75078fSIntel else 699af75078fSIntel rte_exit(EXIT_FAILURE, "rxpt must be >= 0\n"); 700af75078fSIntel } 701af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxht")) { 702af75078fSIntel n = atoi(optarg); 703af75078fSIntel if (n >= 0) 704af75078fSIntel rx_thresh.hthresh = (uint8_t)n; 705af75078fSIntel else 706af75078fSIntel rte_exit(EXIT_FAILURE, "rxht must be >= 0\n"); 707af75078fSIntel } 708af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxwt")) { 709af75078fSIntel n = atoi(optarg); 710af75078fSIntel if (n >= 0) 711af75078fSIntel rx_thresh.wthresh = (uint8_t)n; 712af75078fSIntel else 713af75078fSIntel rte_exit(EXIT_FAILURE, "rxwt must be >= 0\n"); 714af75078fSIntel } 715af75078fSIntel if (!strcmp(lgopts[opt_idx].name, "rxfreet")) { 716af75078fSIntel n = atoi(optarg); 717af75078fSIntel if (n >= 0) 718af75078fSIntel rx_free_thresh = (uint16_t)n; 719af75078fSIntel else 720af75078fSIntel rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n"); 721af75078fSIntel } 722*ed30d9b6SIntel if (!strcmp(lgopts[opt_idx].name, "tx-queue-stats-mapping")) { 723*ed30d9b6SIntel if (parse_queue_stats_mapping_config(optarg, TX)) { 724*ed30d9b6SIntel rte_exit(EXIT_FAILURE, 725*ed30d9b6SIntel "invalid TX queue statistics mapping config entered\n"); 726*ed30d9b6SIntel } 727*ed30d9b6SIntel } 728*ed30d9b6SIntel if (!strcmp(lgopts[opt_idx].name, "rx-queue-stats-mapping")) { 729*ed30d9b6SIntel if (parse_queue_stats_mapping_config(optarg, RX)) { 730*ed30d9b6SIntel rte_exit(EXIT_FAILURE, 731*ed30d9b6SIntel "invalid RX queue statistics mapping config entered\n"); 732*ed30d9b6SIntel } 733*ed30d9b6SIntel } 734af75078fSIntel break; 735af75078fSIntel case 'h': 736af75078fSIntel usage(argv[0]); 737af75078fSIntel rte_exit(EXIT_SUCCESS, "Displayed help\n"); 738af75078fSIntel break; 739af75078fSIntel default: 740af75078fSIntel usage(argv[0]); 741af75078fSIntel rte_exit(EXIT_FAILURE, 742af75078fSIntel "Command line is incomplete or incorrect\n"); 743af75078fSIntel break; 744af75078fSIntel } 745af75078fSIntel } 746af75078fSIntel } 747