app/testpmd: support multi-process
[dpdk.git] / app / test-pmd / parameters.c
index 5e69d2a..3f94a82 100644 (file)
@@ -143,6 +143,7 @@ usage(char* progname)
               "N.\n");
        printf("  --burst=N: set the number of packets per burst to N.\n");
        printf("  --flowgen-clones=N: set the number of single packet clones to send in flowgen mode. Should be less than burst value.\n");
+       printf("  --flowgen-flows=N: set the number of flows in flowgen mode to N (1 <= N <= INT32_MAX).\n");
        printf("  --mbcache=N: set the cache of mbuf memory pool to N.\n");
        printf("  --rxpt=N: set prefetch threshold register of RX rings to N.\n");
        printf("  --rxht=N: set the host threshold register of RX rings to N.\n");
@@ -230,7 +231,8 @@ init_peer_eth_addrs(const char *config_filename)
                        break;
 
                if (rte_ether_unformat_addr(buf, &peer_eth_addrs[i]) < 0) {
-                       printf("Bad MAC address format on line %d\n", i+1);
+                       fprintf(stderr, "Bad MAC address format on line %d\n",
+                               i + 1);
                        fclose(config_file);
                        return -1;
                }
@@ -284,10 +286,10 @@ print_invalid_socket_id_error(void)
 {
        unsigned int i = 0;
 
-       printf("Invalid socket id, options are: ");
+       fprintf(stderr, "Invalid socket id, options are: ");
        for (i = 0; i < num_sockets; i++) {
-               printf("%u%s", socket_ids[i],
-                     (i == num_sockets - 1) ? "\n" : ",");
+               fprintf(stderr, "%u%s", socket_ids[i],
+                       (i == num_sockets - 1) ? "\n" : ",");
        }
 }
 
@@ -403,7 +405,8 @@ parse_ringnuma_config(const char *q_arg)
                }
                ring_flag = (uint8_t)int_fld[FLD_FLAG];
                if ((ring_flag < RX_RING_ONLY) || (ring_flag > RXTX_RING)) {
-                       printf("Invalid ring-flag=%d config for port =%d\n",
+                       fprintf(stderr,
+                               "Invalid ring-flag=%d config for port =%d\n",
                                ring_flag,port_id);
                        return -1;
                }
@@ -420,7 +423,8 @@ parse_ringnuma_config(const char *q_arg)
                        txring_numa[port_id] = socket_id;
                        break;
                default:
-                       printf("Invalid ring-flag=%d config for port=%d\n",
+                       fprintf(stderr,
+                               "Invalid ring-flag=%d config for port=%d\n",
                                ring_flag,port_id);
                        break;
                }
@@ -499,7 +503,7 @@ parse_link_speed(int n)
        case 100:
        case 10:
        default:
-               printf("Unsupported fixed speed\n");
+               fprintf(stderr, "Unsupported fixed speed\n");
                return 0;
        }
 
@@ -509,6 +513,9 @@ parse_link_speed(int n)
 void
 launch_args_parse(int argc, char** argv)
 {
+#define PARAM_PROC_ID "proc-id"
+#define PARAM_NUM_PROCS "num-procs"
+
        int n, opt;
        char **argvopt;
        int opt_idx;
@@ -583,6 +590,7 @@ launch_args_parse(int argc, char** argv)
                { "hairpin-mode",               1, 0, 0 },
                { "burst",                      1, 0, 0 },
                { "flowgen-clones",             1, 0, 0 },
+               { "flowgen-flows",              1, 0, 0 },
                { "mbcache",                    1, 0, 0 },
                { "txpt",                       1, 0, 0 },
                { "txht",                       1, 0, 0 },
@@ -628,6 +636,8 @@ launch_args_parse(int argc, char** argv)
                { "rx-mq-mode",                 1, 0, 0 },
                { "record-core-cycles",         0, 0, 0 },
                { "record-burst-stats",         0, 0, 0 },
+               { PARAM_NUM_PROCS,              1, 0, 0 },
+               { PARAM_PROC_ID,                1, 0, 0 },
                { 0, 0, 0, 0 },
        };
 
@@ -1119,6 +1129,14 @@ launch_args_parse(int argc, char** argv)
                                        rte_exit(EXIT_FAILURE,
                                                 "clones must be >= 0 and <= current burst\n");
                        }
+                       if (!strcmp(lgopts[opt_idx].name, "flowgen-flows")) {
+                               n = atoi(optarg);
+                               if (n > 0)
+                                       nb_flows_flowgen = (int) n;
+                               else
+                                       rte_exit(EXIT_FAILURE,
+                                                "flows must be >= 1\n");
+                       }
                        if (!strcmp(lgopts[opt_idx].name, "mbcache")) {
                                n = atoi(optarg);
                                if ((n >= 0) &&
@@ -1394,6 +1412,10 @@ launch_args_parse(int argc, char** argv)
                                record_core_cycles = 1;
                        if (!strcmp(lgopts[opt_idx].name, "record-burst-stats"))
                                record_burst_stats = 1;
+                       if (!strcmp(lgopts[opt_idx].name, PARAM_NUM_PROCS))
+                               num_procs = atoi(optarg);
+                       if (!strcmp(lgopts[opt_idx].name, PARAM_PROC_ID))
+                               proc_id = atoi(optarg);
                        break;
                case 'h':
                        usage(argv[0]);
@@ -1401,7 +1423,7 @@ launch_args_parse(int argc, char** argv)
                        break;
                default:
                        usage(argv[0]);
-                       printf("Invalid option: %s\n", argv[optind]);
+                       fprintf(stderr, "Invalid option: %s\n", argv[optind]);
                        rte_exit(EXIT_FAILURE,
                                 "Command line is incomplete or incorrect\n");
                        break;
@@ -1410,7 +1432,7 @@ launch_args_parse(int argc, char** argv)
 
        if (optind != argc) {
                usage(argv[0]);
-               printf("Invalid parameter: %s\n", argv[optind]);
+               fprintf(stderr, "Invalid parameter: %s\n", argv[optind]);
                rte_exit(EXIT_FAILURE, "Command line is incorrect\n");
        }