ethdev: increase port id range
[dpdk.git] / app / test-pmd / parameters.c
index a0300eb..31287d7 100644 (file)
@@ -41,7 +41,6 @@
 #include <time.h>
 #include <fcntl.h>
 #include <sys/types.h>
-#include <errno.h>
 
 #include <sys/queue.h>
 #include <sys/stat.h>
@@ -86,8 +85,10 @@ usage(char* progname)
        printf("usage: %s "
 #ifdef RTE_LIBRTE_CMDLINE
               "[--interactive|-i] "
+              "[--cmdline-file=FILENAME] "
 #endif
               "[--help|-h] | [--auto-start|-a] | ["
+              "--tx-first | --stats-period=PERIOD | "
               "--coremask=COREMASK --portmask=PORTMASK --numa "
               "--mbuf-size= | --total-num-mbufs= | "
               "--nb-cores= | --nb-ports= | "
@@ -103,10 +104,15 @@ usage(char* progname)
               progname);
 #ifdef RTE_LIBRTE_CMDLINE
        printf("  --interactive: run in interactive mode.\n");
+       printf("  --cmdline-file: execute cli commands before startup.\n");
 #endif
        printf("  --auto-start: start forwarding on init "
               "[always when non-interactive].\n");
        printf("  --help: display this message and quit.\n");
+       printf("  --tx-first: start forwarding sending a burst first "
+              "(only if interactive is disabled).\n");
+       printf("  --stats-period=PERIOD: statistics will be shown "
+              "every PERIOD seconds (only if interactive is disabled).\n");
        printf("  --nb-cores=N: set the number of forwarding cores "
               "(1 <= N <= %d).\n", nb_lcores);
        printf("  --nb-ports=N: set the number of forwarding ports "
@@ -204,6 +210,12 @@ usage(char* progname)
        printf("  --no-rmv-interrupt: disable device removal interrupt.\n");
        printf("  --bitrate-stats=N: set the logical core N to perform "
                "bit-rate calculation.\n");
+       printf("  --print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>: "
+              "enable print of designated event or all of them.\n");
+       printf("  --mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>: "
+              "disable print of designated event or all of them.\n");
+       printf("  --flow-isolate-all: "
+              "requests flow API isolated mode on all ports at initialization time.\n");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -363,6 +375,18 @@ parse_queue_stats_mapping_config(const char *q_arg, int is_rx)
        return 0;
 }
 
+static void
+print_invalid_socket_id_error(void)
+{
+       unsigned int i = 0;
+
+       printf("Invalid socket id, options are: ");
+       for (i = 0; i < num_sockets; i++) {
+               printf("%u%s", socket_ids[i],
+                     (i == num_sockets - 1) ? "\n" : ",");
+       }
+}
+
 static int
 parse_portnuma_config(const char *q_arg)
 {
@@ -408,9 +432,8 @@ parse_portnuma_config(const char *q_arg)
                        return -1;
                }
                socket_id = (uint8_t)int_fld[FLD_SOCKET];
-               if(socket_id >= max_socket) {
-                       printf("Invalid socket id, range is [0, %d]\n",
-                                max_socket - 1);
+               if (new_socket_id(socket_id)) {
+                       print_invalid_socket_id_error();
                        return -1;
                }
                port_numa[port_id] = socket_id;
@@ -468,9 +491,8 @@ parse_ringnuma_config(const char *q_arg)
                        return -1;
                }
                socket_id = (uint8_t)int_fld[FLD_SOCKET];
-               if (socket_id >= max_socket) {
-                       printf("Invalid socket id, range is [0, %d]\n",
-                               max_socket - 1);
+               if (new_socket_id(socket_id)) {
+                       print_invalid_socket_id_error();
                        return -1;
                }
                ring_flag = (uint8_t)int_fld[FLD_FLAG];
@@ -501,6 +523,38 @@ parse_ringnuma_config(const char *q_arg)
        return 0;
 }
 
+static int
+parse_event_printing_config(const char *optarg, int enable)
+{
+       uint32_t mask = 0;
+
+       if (!strcmp(optarg, "unknown"))
+               mask = UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN;
+       else if (!strcmp(optarg, "intr_lsc"))
+               mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_LSC;
+       else if (!strcmp(optarg, "queue_state"))
+               mask = UINT32_C(1) << RTE_ETH_EVENT_QUEUE_STATE;
+       else if (!strcmp(optarg, "intr_reset"))
+               mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET;
+       else if (!strcmp(optarg, "vf_mbox"))
+               mask = UINT32_C(1) << RTE_ETH_EVENT_VF_MBOX;
+       else if (!strcmp(optarg, "macsec"))
+               mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
+       else if (!strcmp(optarg, "intr_rmv"))
+               mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
+       else if (!strcmp(optarg, "all"))
+               mask = ~UINT32_C(0);
+       else {
+               fprintf(stderr, "Invalid event: %s\n", optarg);
+               return -1;
+       }
+       if (enable)
+               event_print_mask |= mask;
+       else
+               event_print_mask &= ~mask;
+       return 0;
+}
+
 void
 launch_args_parse(int argc, char** argv)
 {
@@ -513,10 +567,13 @@ launch_args_parse(int argc, char** argv)
                { "help",                       0, 0, 0 },
 #ifdef RTE_LIBRTE_CMDLINE
                { "interactive",                0, 0, 0 },
+               { "cmdline-file",               1, 0, 0 },
                { "auto-start",                 0, 0, 0 },
                { "eth-peers-configfile",       1, 0, 0 },
                { "eth-peer",                   1, 0, 0 },
 #endif
+               { "tx-first",                   0, 0, 0 },
+               { "stats-period",               1, 0, 0 },
                { "ports",                      1, 0, 0 },
                { "nb-cores",                   1, 0, 0 },
                { "nb-ports",                   1, 0, 0 },
@@ -574,10 +631,13 @@ launch_args_parse(int argc, char** argv)
                { "tx-queue-stats-mapping",     1, 0, 0 },
                { "rx-queue-stats-mapping",     1, 0, 0 },
                { "no-flush-rx",        0, 0, 0 },
+               { "flow-isolate-all",           0, 0, 0 },
                { "txpkts",                     1, 0, 0 },
                { "disable-link-check",         0, 0, 0 },
                { "no-lsc-interrupt",           0, 0, 0 },
                { "no-rmv-interrupt",           0, 0, 0 },
+               { "print-event",                1, 0, 0 },
+               { "mask-event",                 1, 0, 0 },
                { 0, 0, 0, 0 },
        };
 
@@ -612,10 +672,34 @@ launch_args_parse(int argc, char** argv)
                                printf("Interactive-mode selected\n");
                                interactive = 1;
                        }
+                       if (!strcmp(lgopts[opt_idx].name, "cmdline-file")) {
+                               printf("CLI commands to be read from %s\n",
+                                      optarg);
+                               snprintf(cmdline_filename,
+                                        sizeof(cmdline_filename), "%s",
+                                        optarg);
+                       }
                        if (!strcmp(lgopts[opt_idx].name, "auto-start")) {
                                printf("Auto-start selected\n");
                                auto_start = 1;
                        }
+                       if (!strcmp(lgopts[opt_idx].name, "tx-first")) {
+                               printf("Ports to start sending a burst of "
+                                               "packets first\n");
+                               tx_first = 1;
+                       }
+                       if (!strcmp(lgopts[opt_idx].name, "stats-period")) {
+                               char *end = NULL;
+                               unsigned int n;
+
+                               n = strtoul(optarg, &end, 10);
+                               if ((optarg[0] == '\0') || (end == NULL) ||
+                                               (*end != '\0'))
+                                       break;
+
+                               stats_period = n;
+                               break;
+                       }
                        if (!strcmp(lgopts[opt_idx].name,
                                    "eth-peers-configfile")) {
                                if (init_peer_eth_addrs(optarg) != 0)
@@ -650,7 +734,7 @@ launch_args_parse(int argc, char** argv)
                        if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
                                n = atoi(optarg);
                                if (n > 0 && n <= nb_ports)
-                                       nb_fwd_ports = (uint8_t) n;
+                                       nb_fwd_ports = n;
                                else
                                        rte_exit(EXIT_FAILURE,
                                                 "Invalid port %d\n", n);
@@ -670,12 +754,8 @@ launch_args_parse(int argc, char** argv)
                                parse_fwd_portmask(optarg);
                        if (!strcmp(lgopts[opt_idx].name, "no-numa"))
                                numa_support = 0;
-                       if (!strcmp(lgopts[opt_idx].name, "numa")) {
+                       if (!strcmp(lgopts[opt_idx].name, "numa"))
                                numa_support = 1;
-                               memset(port_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS);
-                               memset(rxring_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS);
-                               memset(txring_numa,NUMA_NO_CONFIG,RTE_MAX_ETHPORTS);
-                       }
                        if (!strcmp(lgopts[opt_idx].name, "mp-anon")) {
                                mp_anon = 1;
                        }
@@ -690,12 +770,13 @@ launch_args_parse(int argc, char** argv)
                                           "invalid ring-numa configuration\n");
                        if (!strcmp(lgopts[opt_idx].name, "socket-num")) {
                                n = atoi(optarg);
-                               if((uint8_t)n < max_socket)
+                               if (!new_socket_id((uint8_t)n)) {
                                        socket_num = (uint8_t)n;
-                               else
+                               } else {
+                                       print_invalid_socket_id_error();
                                        rte_exit(EXIT_FAILURE,
-                                               "The socket number should be < %d\n",
-                                               max_socket);
+                                               "Invalid socket id");
+                               }
                        }
                        if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
                                n = atoi(optarg);
@@ -1026,6 +1107,18 @@ launch_args_parse(int argc, char** argv)
                                lsc_interrupt = 0;
                        if (!strcmp(lgopts[opt_idx].name, "no-rmv-interrupt"))
                                rmv_interrupt = 0;
+                       if (!strcmp(lgopts[opt_idx].name, "flow-isolate-all"))
+                               flow_isolate_all = 1;
+                       if (!strcmp(lgopts[opt_idx].name, "print-event"))
+                               if (parse_event_printing_config(optarg, 1)) {
+                                       rte_exit(EXIT_FAILURE,
+                                                "invalid print-event argument\n");
+                               }
+                       if (!strcmp(lgopts[opt_idx].name, "mask-event"))
+                               if (parse_event_printing_config(optarg, 0)) {
+                                       rte_exit(EXIT_FAILURE,
+                                                "invalid mask-event argument\n");
+                               }
 
                        break;
                case 'h':