1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
12 #include <rte_memory.h>
13 #include <rte_string_fns.h>
19 /* global var for number of clients - extern in header */
22 static const char *progname;
25 * Prints out usage information to stdout
31 "%s [EAL options] -- -p PORTMASK -n NUM_CLIENTS [-s NUM_SOCKETS]\n"
32 " -p PORTMASK: hexadecimal bitmask of ports to use\n"
33 " -n NUM_CLIENTS: number of client processes to use\n"
38 * The ports to be used by the application are passed in
39 * the form of a bitmask. This function parses the bitmask
40 * and places the port numbers to be used into the port[]
44 parse_portmask(uint8_t max_ports, const char *portmask)
50 if (portmask == NULL || *portmask == '\0')
53 /* convert parameter to a number and verify */
54 pm = strtoul(portmask, &end, 16);
55 if (end == NULL || *end != '\0' || pm == 0)
58 /* loop through bits of the mask and mark ports */
60 if (pm & 0x01){ /* bit is set in mask, use port */
61 if (count >= max_ports)
62 printf("WARNING: requested port %u not present"
63 " - ignoring\n", (unsigned)count);
65 ports->id[ports->num_ports++] = count;
75 * Take the number of clients parameter passed to the app
76 * and convert to a number to store in the num_clients variable
79 parse_num_clients(const char *clients)
84 if (clients == NULL || *clients == '\0')
87 temp = strtoul(clients, &end, 10);
88 if (end == NULL || *end != '\0' || temp == 0)
91 num_clients = (uint8_t)temp;
96 * The application specific arguments follow the DPDK-specific
97 * arguments which are stripped by the DPDK init. This function
98 * processes these application arguments, printing usage info
102 parse_app_args(uint16_t max_ports, int argc, char *argv[])
104 int option_index, opt;
105 char **argvopt = argv;
106 static struct option lgopts[] = { /* no long options */
111 while ((opt = getopt_long(argc, argvopt, "n:p:", lgopts,
112 &option_index)) != EOF){
115 if (parse_portmask(max_ports, optarg) != 0){
121 if (parse_num_clients(optarg) != 0){
127 printf("ERROR: Unknown option '%c'\n", opt);
133 if (ports->num_ports == 0 || num_clients == 0){
138 if (ports->num_ports % 2 != 0){
139 printf("ERROR: application requires an even number of ports to use\n");