@@ -297,6 +297,25 @@ app_parse_burst_conf(const char *conf_str)
return 0;
}
+enum {
+#define CMD_LINE_OPT_PFC "pfc"
+ CMD_LINE_OPT_PFC_NUM = 256,
+#define CMD_LINE_OPT_MNC "mnc"
+ CMD_LINE_OPT_MNC_NUM,
+#define CMD_LINE_OPT_RSZ "rsz"
+ CMD_LINE_OPT_RSZ_NUM,
+#define CMD_LINE_OPT_BSZ "bsz"
+ CMD_LINE_OPT_BSZ_NUM,
+#define CMD_LINE_OPT_MSZ "msz"
+ CMD_LINE_OPT_MSZ_NUM,
+#define CMD_LINE_OPT_RTH "rth"
+ CMD_LINE_OPT_RTH_NUM,
+#define CMD_LINE_OPT_TTH "tth"
+ CMD_LINE_OPT_TTH_NUM,
+#define CMD_LINE_OPT_CFG "cfg"
+ CMD_LINE_OPT_CFG_NUM,
+};
+
/*
* Parses the argument given in the command line of the application,
* calculates mask for used cores and initializes EAL with calculated core mask
@@ -306,19 +325,26 @@ app_parse_args(int argc, char **argv)
{
int opt, ret;
int option_index;
- const char *optname;
char *prgname = argv[0];
uint32_t i, nb_lcores;
static struct option lgopts[] = {
- { "pfc", 1, 0, 0 },
- { "mnc", 1, 0, 0 },
- { "rsz", 1, 0, 0 },
- { "bsz", 1, 0, 0 },
- { "msz", 1, 0, 0 },
- { "rth", 1, 0, 0 },
- { "tth", 1, 0, 0 },
- { "cfg", 1, 0, 0 },
+ { CMD_LINE_OPT_PFC, 1,
+ NULL, CMD_LINE_OPT_PFC_NUM },
+ { CMD_LINE_OPT_MNC, 1,
+ NULL, CMD_LINE_OPT_MNC_NUM},
+ { CMD_LINE_OPT_RSZ, 1,
+ NULL, CMD_LINE_OPT_RSZ_NUM},
+ { CMD_LINE_OPT_BSZ, 1,
+ NULL, CMD_LINE_OPT_BSZ_NUM},
+ { CMD_LINE_OPT_MSZ, 1,
+ NULL, CMD_LINE_OPT_MSZ_NUM},
+ { CMD_LINE_OPT_RTH, 1,
+ NULL, CMD_LINE_OPT_RTH_NUM},
+ { CMD_LINE_OPT_TTH, 1,
+ NULL, CMD_LINE_OPT_TTH_NUM},
+ { CMD_LINE_OPT_CFG, 1,
+ NULL, CMD_LINE_OPT_CFG_NUM},
{ NULL, 0, 0, 0 }
};
@@ -342,66 +368,77 @@ app_parse_args(int argc, char **argv)
interactive = 1;
break;
/* long options */
- case 0:
- optname = lgopts[option_index].name;
- if (str_is(optname, "pfc")) {
- ret = app_parse_flow_conf(optarg);
- if (ret) {
- RTE_LOG(ERR, APP, "Invalid pipe configuration %s\n", optarg);
- return -1;
- }
- break;
- }
- if (str_is(optname, "mnc")) {
- app_main_core = (uint32_t)atoi(optarg);
- break;
- }
- if (str_is(optname, "rsz")) {
- ret = app_parse_ring_conf(optarg);
- if (ret) {
- RTE_LOG(ERR, APP, "Invalid ring configuration %s\n", optarg);
- return -1;
- }
- break;
+
+ case CMD_LINE_OPT_PFC_NUM:
+ {
+ ret = app_parse_flow_conf(optarg);
+ if (ret) {
+ RTE_LOG(ERR, APP, "Invalid pipe configuration %s\n",
+ optarg);
+ return -1;
}
- if (str_is(optname, "bsz")) {
- ret = app_parse_burst_conf(optarg);
- if (ret) {
- RTE_LOG(ERR, APP, "Invalid burst configuration %s\n", optarg);
- return -1;
- }
- break;
+ break;
+ }
+ case CMD_LINE_OPT_MNC_NUM:
+ {
+ app_main_core = (uint32_t)atoi(optarg);
+ break;
+ }
+ case CMD_LINE_OPT_RSZ_NUM:
+ {
+ ret = app_parse_ring_conf(optarg);
+ if (ret) {
+ RTE_LOG(ERR, APP, "Invalid ring configuration %s\n",
+ optarg);
+ return -1;
}
- if (str_is(optname, "msz")) {
- mp_size = atoi(optarg);
- if (mp_size <= 0) {
- RTE_LOG(ERR, APP, "Invalid mempool size %s\n", optarg);
- return -1;
- }
- break;
+ break;
+ }
+ case CMD_LINE_OPT_BSZ_NUM:
+ {
+ ret = app_parse_burst_conf(optarg);
+ if (ret) {
+ RTE_LOG(ERR, APP, "Invalid burst configuration %s\n",
+ optarg);
+ return -1;
}
- if (str_is(optname, "rth")) {
- ret = app_parse_rth_conf(optarg);
- if (ret) {
- RTE_LOG(ERR, APP, "Invalid RX threshold configuration %s\n", optarg);
- return -1;
- }
- break;
+ break;
+ }
+ case CMD_LINE_OPT_MSZ_NUM:
+ {
+ mp_size = atoi(optarg);
+ if (mp_size <= 0) {
+ RTE_LOG(ERR, APP, "Invalid mempool size %s\n",
+ optarg);
+ return -1;
}
- if (str_is(optname, "tth")) {
- ret = app_parse_tth_conf(optarg);
- if (ret) {
- RTE_LOG(ERR, APP, "Invalid TX threshold configuration %s\n", optarg);
- return -1;
- }
- break;
+ break;
+ }
+ case CMD_LINE_OPT_RTH_NUM:
+ {
+ ret = app_parse_rth_conf(optarg);
+ if (ret) {
+ RTE_LOG(ERR, APP, "Invalid RX threshold configuration %s\n",
+ optarg);
+ return -1;
}
- if (str_is(optname, "cfg")) {
- cfg_profile = optarg;
- break;
+ break;
+ }
+ case CMD_LINE_OPT_TTH_NUM:
+ {
+ ret = app_parse_tth_conf(optarg);
+ if (ret) {
+ RTE_LOG(ERR, APP, "Invalid TX threshold configuration %s\n",
+ optarg);
+ return -1;
}
break;
-
+ }
+ case CMD_LINE_OPT_CFG_NUM:
+ {
+ cfg_profile = optarg;
+ break;
+ }
default:
app_usage(prgname);
return -1;