app/testpmd: configure event display
[dpdk.git] / app / test-pmd / parameters.c
index 3f4d3a2..23f2fa3 100644 (file)
@@ -86,6 +86,7 @@ usage(char* progname)
        printf("usage: %s "
 #ifdef RTE_LIBRTE_CMDLINE
               "[--interactive|-i] "
+              "[--cmdline-file=FILENAME] "
 #endif
               "[--help|-h] | [--auto-start|-a] | ["
               "--coremask=COREMASK --portmask=PORTMASK --numa "
@@ -103,6 +104,7 @@ 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");
@@ -201,7 +203,13 @@ usage(char* progname)
        printf("  --disable-link-check: disable check on link status when "
               "starting/stopping ports.\n");
        printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
-       printf("  --no-rmv-interrupt: disable device removal interrupt.");
+       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>: "
+              "enable print of designated event");
+       printf("  --mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv>: "
+              "disable print of designated event");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -499,6 +507,36 @@ 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 {
+               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)
 {
@@ -511,6 +549,7 @@ 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 },
@@ -535,6 +574,9 @@ launch_args_parse(int argc, char** argv)
                { "pkt-filter-drop-queue",      1, 0, 0 },
 #ifdef RTE_LIBRTE_LATENCY_STATS
                { "latencystats",               1, 0, 0 },
+#endif
+#ifdef RTE_LIBRTE_BITRATE
+               { "bitrate-stats",              1, 0, 0 },
 #endif
                { "disable-crc-strip",          0, 0, 0 },
                { "enable-lro",                 0, 0, 0 },
@@ -573,6 +615,8 @@ launch_args_parse(int argc, char** argv)
                { "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 },
        };
 
@@ -607,6 +651,13 @@ 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;
@@ -665,12 +716,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;
                        }
@@ -792,6 +839,18 @@ launch_args_parse(int argc, char** argv)
                                                 "invalid lcore id %d for latencystats"
                                                 " must be >= 0\n", n);
                        }
+#endif
+#ifdef RTE_LIBRTE_BITRATE
+                       if (!strcmp(lgopts[opt_idx].name, "bitrate-stats")) {
+                               n = atoi(optarg);
+                               if (n >= 0) {
+                                       bitrate_lcore_id = (lcoreid_t) n;
+                                       bitrate_enabled = 1;
+                               } else
+                                       rte_exit(EXIT_FAILURE,
+                                                "invalid lcore id %d for bitrate stats"
+                                                " must be >= 0\n", n);
+                       }
 #endif
                        if (!strcmp(lgopts[opt_idx].name, "disable-crc-strip"))
                                rx_mode.hw_strip_crc = 0;
@@ -1009,6 +1068,16 @@ 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, "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':