1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
12 #include <rte_memory.h>
13 #include <rte_ethdev.h>
14 #include <rte_string_fns.h>
20 /* global var for number of clients - extern in header */
23 static const char *progname;
26 * Prints out usage information to stdout
32 "%s [EAL options] -- -p PORTMASK -n NUM_CLIENTS [-s NUM_SOCKETS]\n"
33 " -p PORTMASK: hexadecimal bitmask of ports to use\n"
34 " -n NUM_CLIENTS: number of client processes to use\n"
39 * The ports to be used by the application are passed in
40 * the form of a bitmask. This function parses the bitmask
41 * and places the port numbers to be used into the port[]
45 parse_portmask(const char *portmask)
48 unsigned long long pm;
51 if (portmask == NULL || *portmask == '\0')
54 /* convert parameter to a number and verify */
56 pm = strtoull(portmask, &end, 16);
57 if (errno != 0 || end == NULL || *end != '\0')
60 RTE_ETH_FOREACH_DEV(id) {
61 unsigned long msk = 1u << id;
67 ports->id[ports->num_ports++] = id;
71 printf("WARNING: leftover ports in mask %#llx - ignoring\n",
79 * Take the number of clients parameter passed to the app
80 * and convert to a number to store in the num_clients variable
83 parse_num_clients(const char *clients)
88 if (clients == NULL || *clients == '\0')
91 temp = strtoul(clients, &end, 10);
92 if (end == NULL || *end != '\0' || temp == 0)
95 num_clients = (uint8_t)temp;
100 * The application specific arguments follow the DPDK-specific
101 * arguments which are stripped by the DPDK init. This function
102 * processes these application arguments, printing usage info
106 parse_app_args(int argc, char *argv[])
108 int option_index, opt;
109 char **argvopt = argv;
110 static struct option lgopts[] = { /* no long options */
115 while ((opt = getopt_long(argc, argvopt, "n:p:", lgopts,
116 &option_index)) != EOF){
119 if (parse_portmask(optarg) != 0) {
125 if (parse_num_clients(optarg) != 0){
131 printf("ERROR: Unknown option '%c'\n", opt);
137 if (ports->num_ports == 0 || num_clients == 0){
142 if (ports->num_ports % 2 != 0){
143 printf("ERROR: application requires an even number of ports to use\n");