1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2017 Intel Corporation
12 #include <rte_memory.h>
13 #include <rte_string_fns.h>
19 /* 1M flows by default */
20 #define DEFAULT_NUM_FLOWS 0x100000
22 /* global var for number of nodes - extern in header */
24 /* global var for number of flows - extern in header */
25 uint32_t num_flows = DEFAULT_NUM_FLOWS;
27 static const char *progname;
30 * Prints out usage information to stdout
35 printf("%s [EAL options] -- -p PORTMASK -n NUM_NODES -f NUM_FLOWS\n"
36 " -p PORTMASK: hexadecimal bitmask of ports to use\n"
37 " -n NUM_NODES: number of node processes to use\n"
38 " -f NUM_FLOWS: number of flows to be added in the EFD table\n",
43 * The ports to be used by the application are passed in
44 * the form of a bitmask. This function parses the bitmask
45 * and places the port numbers to be used into the port[]
49 parse_portmask(uint8_t max_ports, const char *portmask)
55 if (portmask == NULL || *portmask == '\0')
58 /* convert parameter to a number and verify */
59 pm = strtoul(portmask, &end, 16);
60 if (end == NULL || *end != '\0' || pm == 0)
63 /* loop through bits of the mask and mark ports */
65 if (pm & 0x01) { /* bit is set in mask, use port */
66 if (count >= max_ports)
67 printf("WARNING: requested port %u not present"
68 " - ignoring\n", (unsigned int)count);
70 info->id[info->num_ports++] = count;
80 * Take the number of nodes parameter passed to the app
81 * and convert to a number to store in the num_nodes variable
84 parse_num_nodes(const char *nodes)
89 if (nodes == NULL || *nodes == '\0')
92 temp = strtoul(nodes, &end, 10);
93 if (end == NULL || *end != '\0' || temp == 0)
96 num_nodes = (uint8_t)temp;
101 parse_num_flows(const char *flows)
105 /* parse hexadecimal string */
106 num_flows = strtoul(flows, &end, 16);
107 if ((flows[0] == '\0') || (end == NULL) || (*end != '\0'))
117 * The application specific arguments follow the DPDK-specific
118 * arguments which are stripped by the DPDK init. This function
119 * processes these application arguments, printing usage info
123 parse_app_args(uint8_t max_ports, int argc, char *argv[])
125 int option_index, opt;
126 char **argvopt = argv;
127 static struct option lgopts[] = { /* no long options */
132 while ((opt = getopt_long(argc, argvopt, "n:f:p:", lgopts,
133 &option_index)) != EOF) {
136 if (parse_portmask(max_ports, optarg) != 0) {
142 if (parse_num_nodes(optarg) != 0) {
148 if (parse_num_flows(optarg) != 0) {
154 printf("ERROR: Unknown option '%c'\n", opt);
160 if (info->num_ports == 0 || num_nodes == 0) {
165 if (info->num_ports % 2 != 0) {
166 printf("ERROR: application requires an even "
167 "number of ports to use\n");