app/testpmd: fix help info for interactive commands
[dpdk.git] / app / test-pmd / parameters.c
index 565bea7..41eb3ff 100644 (file)
@@ -19,6 +19,7 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <arpa/inet.h>
 
 #include <rte_common.h>
 #include <rte_byteorder.h>
@@ -65,6 +66,7 @@ usage(char* progname)
 #ifdef RTE_LIBRTE_CMDLINE
               "--eth-peers-configfile= | "
               "--eth-peer=X,M:M:M:M:M:M | "
+              "--tx-ip=SRC,DST | --tx-udp=PORT | "
 #endif
               "--pkt-filter-mode= |"
               "--rss-ip | --rss-udp | "
@@ -173,6 +175,7 @@ usage(char* progname)
               " Used mainly with PCAP drivers.\n");
        printf("  --txpkts=X[,Y]*: set TX segment sizes"
                " or total packet length.\n");
+       printf("  --txonly-multi-flow: generate multiple flows in txonly mode\n");
        printf("  --disable-link-check: disable check on link status when "
               "starting/stopping ports.\n");
        printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
@@ -195,6 +198,14 @@ usage(char* progname)
               "    anon: use regular DPDK memory to create and anonymous memory to populate mempool\n"
               "    xmem: use anonymous memory to create and populate mempool\n"
               "    xmemhuge: use anonymous hugepage memory to create and populate mempool\n");
+       printf("  --noisy-tx-sw-buffer-size=N: size of FIFO buffer\n");
+       printf("  --noisy-tx-sw-buffer-flushtime=N: flush FIFO after N ms\n");
+       printf("  --noisy-lkup-memory=N: allocate N MB of VNF memory\n");
+       printf("  --noisy-lkup-num-writes=N: do N random writes per packet\n");
+       printf("  --noisy-lkup-num-reads=N: do N random reads per packet\n");
+       printf("  --noisy-lkup-num-writes=N: do N random reads and writes per packet\n");
+       printf("  --no-iova-contig: mempool memory can be IOVA non contiguous. "
+              "valid only with --mp-alloc=anon\n");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -410,8 +421,11 @@ parse_portnuma_config(const char *q_arg)
                }
                socket_id = (uint8_t)int_fld[FLD_SOCKET];
                if (new_socket_id(socket_id)) {
-                       print_invalid_socket_id_error();
-                       return -1;
+                       if (num_sockets >= RTE_MAX_NUMA_NODES) {
+                               print_invalid_socket_id_error();
+                               return -1;
+                       }
+                       socket_ids[num_sockets++] = socket_id;
                }
                port_numa[port_id] = socket_id;
        }
@@ -467,8 +481,11 @@ parse_ringnuma_config(const char *q_arg)
                }
                socket_id = (uint8_t)int_fld[FLD_SOCKET];
                if (new_socket_id(socket_id)) {
-                       print_invalid_socket_id_error();
-                       return -1;
+                       if (num_sockets >= RTE_MAX_NUMA_NODES) {
+                               print_invalid_socket_id_error();
+                               return -1;
+                       }
+                       socket_ids[num_sockets++] = socket_id;
                }
                ring_flag = (uint8_t)int_fld[FLD_FLAG];
                if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) {
@@ -620,6 +637,7 @@ launch_args_parse(int argc, char** argv)
                { "no-flush-rx",        0, 0, 0 },
                { "flow-isolate-all",           0, 0, 0 },
                { "txpkts",                     1, 0, 0 },
+               { "txonly-multi-flow",          0, 0, 0 },
                { "disable-link-check",         0, 0, 0 },
                { "no-lsc-interrupt",           0, 0, 0 },
                { "no-rmv-interrupt",           0, 0, 0 },
@@ -631,6 +649,15 @@ launch_args_parse(int argc, char** argv)
                { "mlockall",                   0, 0, 0 },
                { "no-mlockall",                0, 0, 0 },
                { "mp-alloc",                   1, 0, 0 },
+               { "tx-ip",                      1, 0, 0 },
+               { "tx-udp",                     1, 0, 0 },
+               { "noisy-tx-sw-buffer-size",    1, 0, 0 },
+               { "noisy-tx-sw-buffer-flushtime", 1, 0, 0 },
+               { "noisy-lkup-memory",          1, 0, 0 },
+               { "noisy-lkup-num-writes",      1, 0, 0 },
+               { "noisy-lkup-num-reads",       1, 0, 0 },
+               { "noisy-lkup-num-reads-writes", 1, 0, 0 },
+               { "no-iova-contig",             0, 0, 0 },
                { 0, 0, 0, 0 },
        };
 
@@ -723,6 +750,55 @@ launch_args_parse(int argc, char** argv)
                                nb_peer_eth_addrs++;
                        }
 #endif
+                       if (!strcmp(lgopts[opt_idx].name, "tx-ip")) {
+                               struct in_addr in;
+                               char *end;
+
+                               end = strchr(optarg, ',');
+                               if (end == optarg || !end)
+                                       rte_exit(EXIT_FAILURE,
+                                                "Invalid tx-ip: %s", optarg);
+
+                               *end++ = 0;
+                               if (inet_aton(optarg, &in) == 0)
+                                       rte_exit(EXIT_FAILURE,
+                                                "Invalid source IP address: %s\n",
+                                                optarg);
+                               tx_ip_src_addr = rte_be_to_cpu_32(in.s_addr);
+
+                               if (inet_aton(end, &in) == 0)
+                                       rte_exit(EXIT_FAILURE,
+                                                "Invalid destination IP address: %s\n",
+                                                optarg);
+                               tx_ip_dst_addr = rte_be_to_cpu_32(in.s_addr);
+                       }
+                       if (!strcmp(lgopts[opt_idx].name, "tx-udp")) {
+                               char *end = NULL;
+
+                               errno = 0;
+                               n = strtoul(optarg, &end, 10);
+                               if (errno != 0 || end == optarg ||
+                                   n > UINT16_MAX ||
+                                   !(*end == '\0' || *end == ','))
+                                       rte_exit(EXIT_FAILURE,
+                                                "Invalid UDP port: %s\n",
+                                                optarg);
+                               tx_udp_src_port = n;
+                               if (*end == ',') {
+                                       char *dst = end + 1;
+
+                                       n = strtoul(dst, &end, 10);
+                                       if (errno != 0 || end == dst ||
+                                           n > UINT16_MAX || *end)
+                                               rte_exit(EXIT_FAILURE,
+                                                        "Invalid destination UDP port: %s\n",
+                                                        dst);
+                                       tx_udp_dst_port = n;
+                               } else {
+                                       tx_udp_dst_port = n;
+                               }
+
+                       }
                        if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
                                n = atoi(optarg);
                                if (n > 0 && n <= nb_ports)
@@ -1123,6 +1199,8 @@ launch_args_parse(int argc, char** argv)
                                else
                                        rte_exit(EXIT_FAILURE, "bad txpkts\n");
                        }
+                       if (!strcmp(lgopts[opt_idx].name, "txonly-multi-flow"))
+                               txonly_multi_flow = 1;
                        if (!strcmp(lgopts[opt_idx].name, "no-flush-rx"))
                                no_flush_rx = 1;
                        if (!strcmp(lgopts[opt_idx].name, "disable-link-check"))
@@ -1166,6 +1244,62 @@ launch_args_parse(int argc, char** argv)
                                do_mlockall = 1;
                        if (!strcmp(lgopts[opt_idx].name, "no-mlockall"))
                                do_mlockall = 0;
+                       if (!strcmp(lgopts[opt_idx].name,
+                                   "noisy-tx-sw-buffer-size")) {
+                               n = atoi(optarg);
+                               if (n >= 0)
+                                       noisy_tx_sw_bufsz = n;
+                               else
+                                       rte_exit(EXIT_FAILURE,
+                                               "noisy-tx-sw-buffer-size must be >= 0\n");
+                       }
+                       if (!strcmp(lgopts[opt_idx].name,
+                                   "noisy-tx-sw-buffer-flushtime")) {
+                               n = atoi(optarg);
+                               if (n >= 0)
+                                       noisy_tx_sw_buf_flush_time = n;
+                               else
+                                       rte_exit(EXIT_FAILURE,
+                                                "noisy-tx-sw-buffer-flushtime must be >= 0\n");
+                       }
+                       if (!strcmp(lgopts[opt_idx].name,
+                                   "noisy-lkup-memory")) {
+                               n = atoi(optarg);
+                               if (n >= 0)
+                                       noisy_lkup_mem_sz = n;
+                               else
+                                       rte_exit(EXIT_FAILURE,
+                                                "noisy-lkup-memory must be >= 0\n");
+                       }
+                       if (!strcmp(lgopts[opt_idx].name,
+                                   "noisy-lkup-num-writes")) {
+                               n = atoi(optarg);
+                               if (n >= 0)
+                                       noisy_lkup_num_writes = n;
+                               else
+                                       rte_exit(EXIT_FAILURE,
+                                                "noisy-lkup-num-writes must be >= 0\n");
+                       }
+                       if (!strcmp(lgopts[opt_idx].name,
+                                   "noisy-lkup-num-reads")) {
+                               n = atoi(optarg);
+                               if (n >= 0)
+                                       noisy_lkup_num_reads = n;
+                               else
+                                       rte_exit(EXIT_FAILURE,
+                                                "noisy-lkup-num-reads must be >= 0\n");
+                       }
+                       if (!strcmp(lgopts[opt_idx].name,
+                                   "noisy-lkup-num-reads-writes")) {
+                               n = atoi(optarg);
+                               if (n >= 0)
+                                       noisy_lkup_num_reads_writes = n;
+                               else
+                                       rte_exit(EXIT_FAILURE,
+                                                "noisy-lkup-num-reads-writes must be >= 0\n");
+                       }
+                       if (!strcmp(lgopts[opt_idx].name, "no-iova-contig"))
+                               mempool_flags = MEMPOOL_F_NO_IOVA_CONTIG;
                        break;
                case 'h':
                        usage(argv[0]);
@@ -1182,4 +1316,12 @@ launch_args_parse(int argc, char** argv)
        /* Set offload configuration from command line parameters. */
        rx_mode.offloads = rx_offloads;
        tx_mode.offloads = tx_offloads;
+
+       if (mempool_flags & MEMPOOL_F_NO_IOVA_CONTIG &&
+           mp_alloc_type != MP_ALLOC_ANON) {
+               TESTPMD_LOG(WARNING, "cannot use no-iova-contig without "
+                                 "mp-alloc=anon. mempool no-iova-contig is "
+                                 "ignored\n");
+               mempool_flags = 0;
+       }
 }