From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jasvinder Singh Subject: [PATCH v4] ip_pipeline: configuration file parser cleanup Date: Mon, 30 May 2016 15:33:24 +0100 Message-ID: <1464618804-78135-1-git-send-email-jasvinder.singh@intel.com> References: <1462984560-239866-1-git-send-email-jasvinder.singh@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: cristian.dumitrescu@intel.com To: dev@dpdk.org Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id EE6226CA3 for ; Mon, 30 May 2016 16:27:12 +0200 (CEST) In-Reply-To: <1462984560-239866-1-git-send-email-jasvinder.singh@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This commit adds following changes to configuration file parsing of the ip pipeline application; 1. Parsing routines related to packet queues (pktq_in/out fields in the PIPELINE section) and message queues (msgq_in/out fields of in the MSGQ Section) are updated. In the parsing routines, function "strtok_r()" is used for parsing the string instead of manually checking the string termination, white spaces, tabs etc., between the string tokens. Each call to strtok_r() returns a pointer to a null-terminated string containing the next token. If no more tokens are found, strtok_r() returns NULL. As a result of using strtok_r(), the code size of the parsing routines is reduced significantly. 2. Replace PARSER_PARAM_ADD_CHECK macro by more specific macros such as PARSE_CHECK_DUPLICATE_SECTION, PARSE_CHECK_DUPLICATE_SECTION_EAL to detec= t duplicate entries in the various sections of the configuration file 3. Add new macros PARSER_ERROR_NO_ELEMENTS and PARSE_ERROR_TOO_MANY_ELEME= NTS for detecting no element and more elements than allowed situations respectively, in the section entry. 4. Add new macros APP_PARAM_ADD_LINK_FOR_RXQ, APP_PARAM_ADD_LINK_FOR_TXQ and APP_PARAM_ADD_LINK_FOR_TM which add corresponding nic ports entry to the application param structure while parsing rx/tx queues, TM (Traffic Manager) port sections and pktq_in/out entries of pipeline sections Signed-off-by: Jasvinder Singh Acked-by: Cristian Dumitrescu --- v4 - update the commit message - move APP_PARAM_ADD macro from app.h to config_parse.c as it is only use= d by the routines defined in this file - remove extra newline character from error message display - rebased on top of ip_pipeline CLI patchset (http://dpdk.org/dev/patchwork/patch/12911/) and NULL packet processing fix patch (http://dpdk.org/dev/patchwork/patch/12807/) v3 - add check on the number of pktq_in/out entries - add check on the number of msgq_in/out entries v2 - update the commit message - change the local variable name from "token" to "name" examples/ip_pipeline/app.h | 25 +- examples/ip_pipeline/config_parse.c | 472 +++++++++++++++---------------= ------ 2 files changed, 196 insertions(+), 301 deletions(-) diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h index e775024..05d608b 100644 --- a/examples/ip_pipeline/app.h +++ b/examples/ip_pipeline/app.h @@ -50,6 +50,7 @@ =20 #define APP_PARAM_NAME_SIZE PIPELINE_NAME_SIZE #define APP_LINK_PCI_BDF_SIZE 16 + struct app_mempool_params { char *name; uint32_t parsed; @@ -370,6 +371,8 @@ struct app_eal_params { /* Support running on Xen dom0 without hugetlbfs */ uint32_t xen_dom0_present; int xen_dom0; + + uint32_t parsed; }; =20 #ifndef APP_APPNAME_SIZE @@ -529,28 +532,6 @@ do \ sscanf(obj->name, prefix "%" SCNu32, &id); \ while (0) \ =20 -#define APP_PARAM_ADD(obj_array, obj_name) \ -({ \ - ssize_t obj_idx; \ - const ssize_t obj_count =3D RTE_DIM(obj_array); \ - \ - obj_idx =3D APP_PARAM_FIND(obj_array, obj_name); \ - if (obj_idx < 0) { \ - for (obj_idx =3D 0; obj_idx < obj_count; obj_idx++) { \ - if (!APP_PARAM_VALID(&((obj_array)[obj_idx]))) \ - break; \ - } \ - \ - if (obj_idx < obj_count) { \ - (obj_array)[obj_idx].name =3D strdup(obj_name); \ - if ((obj_array)[obj_idx].name =3D=3D NULL) \ - obj_idx =3D -EINVAL; \ - } else \ - obj_idx =3D -ENOMEM; \ - } \ - obj_idx; \ -}) - #define APP_CHECK(exp, fmt, ...) \ do { \ if (!(exp)) { \ diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/c= onfig_parse.c index 3951e1d..53130a0 100644 --- a/examples/ip_pipeline/config_parse.c +++ b/examples/ip_pipeline/config_parse.c @@ -1,4 +1,4 @@ -/*- +=EF=BB=BF/*- * BSD LICENSE * * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. @@ -230,48 +230,122 @@ app_print_usage(char *prgname) rte_exit(0, app_usage, prgname, app_params_default.config_file); } =20 -#define PARSER_PARAM_ADD_CHECK(result, params_array, section_name) \ +#define APP_PARAM_ADD(set, key) \ +({ \ + ssize_t pos =3D APP_PARAM_FIND(set, key); \ + ssize_t size =3D RTE_DIM(set); \ + \ + if (pos < 0) { \ + for (pos =3D 0; pos < size; pos++) { \ + if (!APP_PARAM_VALID(&((set)[pos]))) \ + break; \ + } \ + \ + APP_CHECK((pos < size), \ + "Parse error: size of %s is limited to %u elements",\ + #set, (uint32_t) size); \ + \ + (set)[pos].name =3D strdup(key); \ + APP_CHECK(((set)[pos].name), \ + "Parse error: no free memory"); \ + } \ + pos; \ +}) + +#define APP_PARAM_ADD_LINK_FOR_RXQ(app, rxq_name) \ +({ \ + char link_name[APP_PARAM_NAME_SIZE]; \ + ssize_t link_param_pos; \ + uint32_t link_id, queue_id; \ + \ + sscanf((rxq_name), "RXQ%" SCNu32 ".%" SCNu32, &link_id, &queue_id);\ + sprintf(link_name, "LINK%" PRIu32, link_id); \ + link_param_pos =3D APP_PARAM_ADD((app)->link_params, link_name); \ + link_param_pos; \ +}) + +#define APP_PARAM_ADD_LINK_FOR_TXQ(app, txq_name) \ +({ \ + char link_name[APP_PARAM_NAME_SIZE]; \ + ssize_t link_param_pos; \ + uint32_t link_id, queue_id; \ + \ + sscanf((txq_name), "TXQ%" SCNu32 ".%" SCNu32, &link_id, &queue_id);\ + sprintf(link_name, "LINK%" PRIu32, link_id); \ + link_param_pos =3D APP_PARAM_ADD((app)->link_params, link_name); \ + link_param_pos; \ +}) + +#define APP_PARAM_ADD_LINK_FOR_TM(app, tm_name) \ +({ \ + char link_name[APP_PARAM_NAME_SIZE]; \ + ssize_t link_param_pos; \ + uint32_t link_id; \ + \ + sscanf((tm_name), "TM%" SCNu32, &link_id); \ + sprintf(link_name, "LINK%" PRIu32, link_id); \ + link_param_pos =3D APP_PARAM_ADD((app)->link_params, link_name); \ + link_param_pos; \ +}) + +#define PARSE_CHECK_DUPLICATE_SECTION(obj) \ do { \ - APP_CHECK((result !=3D -EINVAL), \ - "Parse error: no free memory"); \ - APP_CHECK((result !=3D -ENOMEM), \ - "Parse error: too many \"%s\" sections", section_name); \ - APP_CHECK(((result >=3D 0) && (params_array)[result].parsed =3D=3D 0),\ - "Parse error: duplicate \"%s\" section", section_name); \ - APP_CHECK((result >=3D 0), \ - "Parse error in section \"%s\"", section_name); \ + APP_CHECK(((obj)->parsed =3D=3D 0), \ + "Parse error: duplicate \"%s\" section", (obj)->name); \ + (obj)->parsed++; \ +} while (0) + +#define PARSE_CHECK_DUPLICATE_SECTION_EAL(obj) \ +do { \ + APP_CHECK(((obj)->parsed =3D=3D 0), \ + "Parse error: duplicate \"%s\" section", "EAL"); \ + (obj)->parsed++; \ } while (0) =20 #define PARSE_ERROR(exp, section, entry) \ -APP_CHECK(exp, "Parse error in section \"%s\": entry \"%s\"\n", section,= entry) +APP_CHECK(exp, "Parse error in section \"%s\": entry \"%s\"", section, e= ntry) =20 #define PARSE_ERROR_MESSAGE(exp, section, entry, message) \ -APP_CHECK(exp, "Parse error in section \"%s\", entry \"%s\": %s\n", \ +APP_CHECK(exp, "Parse error in section \"%s\", entry \"%s\": %s", \ section, entry, message) =20 +#define PARSE_ERROR_NO_ELEMENTS(exp, section, entry) \ +APP_CHECK(exp, "Parse error in section \"%s\", entry \"%s\": " \ + "no elements detected", \ + section, entry) + +#define PARSE_ERROR_TOO_MANY_ELEMENTS(exp, section, entry, max) \ +APP_CHECK(exp, "Parse error in section \"%s\", entry \"%s\": " \ + "maximum number of elements allowed is %lu", \ + section, entry, max) + +#define PARSE_ERROR_INVALID_ELEMENT(exp, section, entry, value) \ +APP_CHECK(exp, "Parse error in section \"%s\", entry \"%s\": " \ + "Invalid element value \"%s\"", \ + section, entry, value) =20 #define PARSE_ERROR_MALLOC(exp) \ -APP_CHECK(exp, "Parse error: no free memory\n") +APP_CHECK(exp, "Parse error: no free memory") =20 #define PARSE_ERROR_SECTION(exp, section) \ APP_CHECK(exp, "Parse error in section \"%s\"", section) =20 #define PARSE_ERROR_SECTION_NO_ENTRIES(exp, section) \ -APP_CHECK(exp, "Parse error in section \"%s\": no entries\n", section) +APP_CHECK(exp, "Parse error in section \"%s\": no entries", section) =20 #define PARSE_WARNING_IGNORED(exp, section, entry) \ do \ if (!(exp)) \ fprintf(stderr, "Parse warning in section \"%s\": " \ - "entry \"%s\" is ignored\n", section, entry); \ + "entry \"%s\" is ignored", section, entry); \ while (0) =20 #define PARSE_ERROR_INVALID(exp, section, entry) \ -APP_CHECK(exp, "Parse error in section \"%s\": unrecognized entry \"%s\"= \n",\ +APP_CHECK(exp, "Parse error in section \"%s\": unrecognized entry \"%s\"= ",\ section, entry) =20 #define PARSE_ERROR_DUPLICATE(exp, section, entry) \ -APP_CHECK(exp, "Parse error in section \"%s\": duplicate entry \"%s\"\n"= ,\ +APP_CHECK(exp, "Parse error in section \"%s\": duplicate entry \"%s\"", = \ section, entry) =20 static int @@ -329,6 +403,8 @@ parse_eal(struct app_params *app, =20 rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 + PARSE_CHECK_DUPLICATE_SECTION_EAL(p); + for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *entry =3D &entries[i]; =20 @@ -708,265 +784,154 @@ parse_eal(struct app_params *app, free(entries); } =20 -static int +static void parse_pipeline_pktq_in(struct app_params *app, struct app_pipeline_params *p, - const char *value) + char *value) { - const char *next =3D value; - char *end; - char name[APP_PARAM_NAME_SIZE]; - size_t name_len; + p->n_pktq_in =3D 0; =20 - while (*next !=3D '\0') { + while (1) { enum app_pktq_in_type type; int id; - char *end_space; - char *end_tab; + char *name =3D strtok_r(value, PARSE_DELIMITER, &value); =20 - next =3D skip_white_spaces(next); - if (!next) + if (name =3D=3D NULL) break; =20 - end_space =3D strchr(next, ' '); - end_tab =3D strchr(next, ' '); - - if (end_space && (!end_tab)) - end =3D end_space; - else if ((!end_space) && end_tab) - end =3D end_tab; - else if (end_space && end_tab) - end =3D RTE_MIN(end_space, end_tab); - else - end =3D NULL; - - if (!end) - name_len =3D strlen(next); - else - name_len =3D end - next; - - if (name_len =3D=3D 0 || name_len =3D=3D sizeof(name)) - return -EINVAL; - - strncpy(name, next, name_len); - name[name_len] =3D '\0'; - next +=3D name_len; - if (*next !=3D '\0') - next++; + PARSE_ERROR_TOO_MANY_ELEMENTS( + (p->n_pktq_in < RTE_DIM(p->pktq_in)), + p->name, "pktq_in", RTE_DIM(p->pktq_in)); =20 if (validate_name(name, "RXQ", 2) =3D=3D 0) { type =3D APP_PKTQ_IN_HWQ; id =3D APP_PARAM_ADD(app->hwq_in_params, name); + APP_PARAM_ADD_LINK_FOR_RXQ(app, name); } else if (validate_name(name, "SWQ", 1) =3D=3D 0) { type =3D APP_PKTQ_IN_SWQ; id =3D APP_PARAM_ADD(app->swq_params, name); } else if (validate_name(name, "TM", 1) =3D=3D 0) { type =3D APP_PKTQ_IN_TM; id =3D APP_PARAM_ADD(app->tm_params, name); + APP_PARAM_ADD_LINK_FOR_TM(app, name); } else if (validate_name(name, "SOURCE", 1) =3D=3D 0) { type =3D APP_PKTQ_IN_SOURCE; id =3D APP_PARAM_ADD(app->source_params, name); } else - return -EINVAL; - - if (id < 0) - return id; + PARSE_ERROR_INVALID_ELEMENT(0, + p->name, "pktq_in", name); =20 p->pktq_in[p->n_pktq_in].type =3D type; p->pktq_in[p->n_pktq_in].id =3D (uint32_t) id; p->n_pktq_in++; } =20 - return 0; + PARSE_ERROR_NO_ELEMENTS((p->n_pktq_in > 0), p->name, "pktq_in"); } =20 -static int +static void parse_pipeline_pktq_out(struct app_params *app, struct app_pipeline_params *p, - const char *value) + char *value) { - const char *next =3D value; - char *end; - char name[APP_PARAM_NAME_SIZE]; - size_t name_len; + p->n_pktq_out =3D 0; =20 - while (*next !=3D '\0') { - enum app_pktq_out_type type; + while (1) { + enum app_pktq_in_type type; int id; - char *end_space; - char *end_tab; + char *name =3D strtok_r(value, PARSE_DELIMITER, &value); =20 - next =3D skip_white_spaces(next); - if (!next) + if (name =3D=3D NULL) break; =20 - end_space =3D strchr(next, ' '); - end_tab =3D strchr(next, ' '); - - if (end_space && (!end_tab)) - end =3D end_space; - else if ((!end_space) && end_tab) - end =3D end_tab; - else if (end_space && end_tab) - end =3D RTE_MIN(end_space, end_tab); - else - end =3D NULL; - - if (!end) - name_len =3D strlen(next); - else - name_len =3D end - next; - - if (name_len =3D=3D 0 || name_len =3D=3D sizeof(name)) - return -EINVAL; + PARSE_ERROR_TOO_MANY_ELEMENTS( + (p->n_pktq_out < RTE_DIM(p->pktq_out)), + p->name, "pktq_out", RTE_DIM(p->pktq_out)); =20 - strncpy(name, next, name_len); - name[name_len] =3D '\0'; - next +=3D name_len; - if (*next !=3D '\0') - next++; if (validate_name(name, "TXQ", 2) =3D=3D 0) { type =3D APP_PKTQ_OUT_HWQ; id =3D APP_PARAM_ADD(app->hwq_out_params, name); + APP_PARAM_ADD_LINK_FOR_TXQ(app, name); } else if (validate_name(name, "SWQ", 1) =3D=3D 0) { type =3D APP_PKTQ_OUT_SWQ; id =3D APP_PARAM_ADD(app->swq_params, name); } else if (validate_name(name, "TM", 1) =3D=3D 0) { type =3D APP_PKTQ_OUT_TM; id =3D APP_PARAM_ADD(app->tm_params, name); + APP_PARAM_ADD_LINK_FOR_TM(app, name); } else if (validate_name(name, "SINK", 1) =3D=3D 0) { type =3D APP_PKTQ_OUT_SINK; id =3D APP_PARAM_ADD(app->sink_params, name); } else - return -EINVAL; - - if (id < 0) - return id; + PARSE_ERROR_INVALID_ELEMENT(0, + p->name, "pktq_out", name); =20 p->pktq_out[p->n_pktq_out].type =3D type; p->pktq_out[p->n_pktq_out].id =3D id; p->n_pktq_out++; } =20 - return 0; + PARSE_ERROR_NO_ELEMENTS((p->n_pktq_out > 0), p->name, "pktq_out"); } =20 -static int +static void parse_pipeline_msgq_in(struct app_params *app, struct app_pipeline_params *p, - const char *value) + char *value) { - const char *next =3D value; - char *end; - char name[APP_PARAM_NAME_SIZE]; - size_t name_len; - ssize_t idx; - - while (*next !=3D '\0') { - char *end_space; - char *end_tab; - - next =3D skip_white_spaces(next); - if (!next) - break; + p->n_msgq_in =3D 0; =20 - end_space =3D strchr(next, ' '); - end_tab =3D strchr(next, ' '); + while (1) { + int idx; + char *name =3D strtok_r(value, PARSE_DELIMITER, &value); =20 - if (end_space && (!end_tab)) - end =3D end_space; - else if ((!end_space) && end_tab) - end =3D end_tab; - else if (end_space && end_tab) - end =3D RTE_MIN(end_space, end_tab); - else - end =3D NULL; - - if (!end) - name_len =3D strlen(next); - else - name_len =3D end - next; - - if (name_len =3D=3D 0 || name_len =3D=3D sizeof(name)) - return -EINVAL; + if (name =3D=3D NULL) + break; =20 - strncpy(name, next, name_len); - name[name_len] =3D '\0'; - next +=3D name_len; - if (*next !=3D '\0') - next++; + PARSE_ERROR_TOO_MANY_ELEMENTS( + (p->n_msgq_in < RTE_DIM(p->msgq_in)), + p->name, "msgq_in", RTE_DIM(p->msgq_in)); =20 - if (validate_name(name, "MSGQ", 1) !=3D 0) - return -EINVAL; + PARSE_ERROR_INVALID_ELEMENT( + (validate_name(name, "MSGQ", 1) =3D=3D 0), + p->name, "msgq_in", name); =20 idx =3D APP_PARAM_ADD(app->msgq_params, name); - if (idx < 0) - return idx; - p->msgq_in[p->n_msgq_in] =3D idx; p->n_msgq_in++; } =20 - return 0; + PARSE_ERROR_NO_ELEMENTS((p->n_msgq_in > 0), p->name, "msgq_in"); } =20 -static int +static void parse_pipeline_msgq_out(struct app_params *app, struct app_pipeline_params *p, - const char *value) + char *value) { - const char *next =3D value; - char *end; - char name[APP_PARAM_NAME_SIZE]; - size_t name_len; - ssize_t idx; - - while (*next !=3D '\0') { - char *end_space; - char *end_tab; - - next =3D skip_white_spaces(next); - if (!next) - break; - - end_space =3D strchr(next, ' '); - end_tab =3D strchr(next, ' '); - - if (end_space && (!end_tab)) - end =3D end_space; - else if ((!end_space) && end_tab) - end =3D end_tab; - else if (end_space && end_tab) - end =3D RTE_MIN(end_space, end_tab); - else - end =3D NULL; + p->n_msgq_out =3D 0; =20 - if (!end) - name_len =3D strlen(next); - else - name_len =3D end - next; + while (1) { + int idx; + char *name =3D strtok_r(value, PARSE_DELIMITER, &value); =20 - if (name_len =3D=3D 0 || name_len =3D=3D sizeof(name)) - return -EINVAL; + if (name =3D=3D NULL) + break; =20 - strncpy(name, next, name_len); - name[name_len] =3D '\0'; - next +=3D name_len; - if (*next !=3D '\0') - next++; + PARSE_ERROR_TOO_MANY_ELEMENTS( + (p->n_msgq_out < RTE_DIM(p->msgq_out)), + p->name, "msgq_out", RTE_DIM(p->msgq_out)); =20 - if (validate_name(name, "MSGQ", 1) !=3D 0) - return -EINVAL; + PARSE_ERROR_INVALID_ELEMENT( + (validate_name(name, "MSGQ", 1) =3D=3D 0), + p->name, "msgq_out", name); =20 idx =3D APP_PARAM_ADD(app->msgq_params, name); - if (idx < 0) - return idx; - p->msgq_out[p->n_msgq_out] =3D idx; p->n_msgq_out++; } =20 - return 0; + PARSE_ERROR_NO_ELEMENTS((p->n_msgq_out > 0), p->name, "msgq_out"); } =20 static void @@ -989,9 +954,8 @@ parse_pipeline(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->pipeline_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->pipeline_params, section_name); - param =3D &app->pipeline_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1018,38 +982,26 @@ parse_pipeline(struct app_params *app, } =20 if (strcmp(ent->name, "pktq_in") =3D=3D 0) { - int status =3D parse_pipeline_pktq_in(app, param, - ent->value); + parse_pipeline_pktq_in(app, param, ent->value); =20 - PARSE_ERROR((status =3D=3D 0), section_name, - ent->name); continue; } =20 if (strcmp(ent->name, "pktq_out") =3D=3D 0) { - int status =3D parse_pipeline_pktq_out(app, param, - ent->value); + parse_pipeline_pktq_out(app, param, ent->value); =20 - PARSE_ERROR((status =3D=3D 0), section_name, - ent->name); continue; } =20 if (strcmp(ent->name, "msgq_in") =3D=3D 0) { - int status =3D parse_pipeline_msgq_in(app, param, - ent->value); + parse_pipeline_msgq_in(app, param, ent->value); =20 - PARSE_ERROR((status =3D=3D 0), section_name, - ent->name); continue; } =20 if (strcmp(ent->name, "msgq_out") =3D=3D 0) { - int status =3D parse_pipeline_msgq_out(app, param, - ent->value); + parse_pipeline_msgq_out(app, param, ent->value); =20 - PARSE_ERROR((status =3D=3D 0), section_name, - ent->name); continue; } =20 @@ -1078,17 +1030,13 @@ parse_pipeline(struct app_params *app, param->n_args++; } =20 - param->parsed =3D 1; - snprintf(name, sizeof(name), "MSGQ-REQ-%s", section_name); param_idx =3D APP_PARAM_ADD(app->msgq_params, name); - PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, name); app->msgq_params[param_idx].cpu_socket_id =3D param->socket_id; param->msgq_in[param->n_msgq_in++] =3D param_idx; =20 snprintf(name, sizeof(name), "MSGQ-RSP-%s", section_name); param_idx =3D APP_PARAM_ADD(app->msgq_params, name); - PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, name); app->msgq_params[param_idx].cpu_socket_id =3D param->socket_id; param->msgq_out[param->n_msgq_out++] =3D param_idx; =20 @@ -1097,7 +1045,6 @@ parse_pipeline(struct app_params *app, param->core_id, (param->hyper_th_id) ? "h" : ""); param_idx =3D APP_PARAM_ADD(app->msgq_params, name); - PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, name); app->msgq_params[param_idx].cpu_socket_id =3D param->socket_id; =20 snprintf(name, sizeof(name), "MSGQ-RSP-CORE-s%" PRIu32 "c%" PRIu32 "%s"= , @@ -1105,7 +1052,6 @@ parse_pipeline(struct app_params *app, param->core_id, (param->hyper_th_id) ? "h" : ""); param_idx =3D APP_PARAM_ADD(app->msgq_params, name); - PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, name); app->msgq_params[param_idx].cpu_socket_id =3D param->socket_id; =20 free(entries); @@ -1130,9 +1076,8 @@ parse_mempool(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->mempool_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->mempool_params, section_name); - param =3D &app->mempool_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1177,8 +1122,6 @@ parse_mempool(struct app_params *app, PARSE_ERROR_INVALID(0, section_name, ent->name); } =20 - param->parsed =3D 1; - free(entries); } =20 @@ -1202,9 +1145,8 @@ parse_link(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->link_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->link_params, section_name); - param =3D &app->link_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1297,8 +1239,6 @@ parse_link(struct app_params *app, "this entry is mandatory (port_mask is not " "provided)"); =20 - param->parsed =3D 1; - free(entries); } =20 @@ -1321,9 +1261,10 @@ parse_rxq(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->hwq_in_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->hwq_in_params, section_name); - param =3D &app->hwq_in_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); + + APP_PARAM_ADD_LINK_FOR_RXQ(app, section_name); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1335,10 +1276,8 @@ parse_rxq(struct app_params *app, =20 PARSE_ERROR((status =3D=3D 0), section_name, ent->name); - idx =3D APP_PARAM_ADD(app->mempool_params, - ent->value); - PARSER_PARAM_ADD_CHECK(idx, app->mempool_params, - section_name); + + idx =3D APP_PARAM_ADD(app->mempool_params, ent->value); param->mempool_id =3D idx; continue; } @@ -1365,8 +1304,6 @@ parse_rxq(struct app_params *app, PARSE_ERROR_INVALID(0, section_name, ent->name); } =20 - param->parsed =3D 1; - free(entries); } =20 @@ -1389,9 +1326,10 @@ parse_txq(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->hwq_out_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->hwq_out_params, section_name); - param =3D &app->hwq_out_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); + + APP_PARAM_ADD_LINK_FOR_TXQ(app, section_name); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1428,8 +1366,6 @@ parse_txq(struct app_params *app, PARSE_ERROR_INVALID(0, section_name, ent->name); } =20 - param->parsed =3D 1; - free(entries); } =20 @@ -1457,9 +1393,8 @@ parse_swq(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->swq_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->swq_params, section_name); - param =3D &app->swq_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1587,11 +1522,9 @@ parse_swq(struct app_params *app, PARSE_ERROR((status =3D=3D 0), section_name, ent->name); =20 - idx =3D APP_PARAM_ADD(app->mempool_params, - ent->value); - PARSER_PARAM_ADD_CHECK(idx, app->mempool_params, - section_name); + idx =3D APP_PARAM_ADD(app->mempool_params, ent->value); param->mempool_direct_id =3D idx; + mempool_direct_present =3D 1; continue; } @@ -1603,11 +1536,10 @@ parse_swq(struct app_params *app, =20 PARSE_ERROR((status =3D=3D 0), section_name, ent->name); - idx =3D APP_PARAM_ADD(app->mempool_params, - ent->value); - PARSER_PARAM_ADD_CHECK(idx, app->mempool_params, - section_name); + + idx =3D APP_PARAM_ADD(app->mempool_params, ent->value); param->mempool_indirect_id =3D idx; + mempool_indirect_present =3D 1; continue; } @@ -1616,32 +1548,30 @@ parse_swq(struct app_params *app, PARSE_ERROR_INVALID(0, section_name, ent->name); } =20 - APP_CHECK(((mtu_present) && + APP_CHECK(((mtu_present =3D=3D 0) || ((param->ipv4_frag =3D=3D 1) || (param->ipv6_frag =3D=3D 1))), "Parse error in section \"%s\": IPv4/IPv6 fragmentation " "is off, therefore entry \"mtu\" is not allowed", section_name); =20 - APP_CHECK(((metadata_size_present) && + APP_CHECK(((metadata_size_present =3D=3D 0) || ((param->ipv4_frag =3D=3D 1) || (param->ipv6_frag =3D=3D 1))), "Parse error in section \"%s\": IPv4/IPv6 fragmentation " "is off, therefore entry \"metadata_size\" is " "not allowed", section_name); =20 - APP_CHECK(((mempool_direct_present) && + APP_CHECK(((mempool_direct_present =3D=3D 0) || ((param->ipv4_frag =3D=3D 1) || (param->ipv6_frag =3D=3D 1))), "Parse error in section \"%s\": IPv4/IPv6 fragmentation " "is off, therefore entry \"mempool_direct\" is " "not allowed", section_name); =20 - APP_CHECK(((mempool_indirect_present) && + APP_CHECK(((mempool_indirect_present =3D=3D 0) || ((param->ipv4_frag =3D=3D 1) || (param->ipv6_frag =3D=3D 1))), "Parse error in section \"%s\": IPv4/IPv6 fragmentation " "is off, therefore entry \"mempool_indirect\" is " "not allowed", section_name); =20 - param->parsed =3D 1; - free(entries); } =20 @@ -1664,9 +1594,10 @@ parse_tm(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->tm_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->tm_params, section_name); - param =3D &app->tm_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); + + APP_PARAM_ADD_LINK_FOR_TXQ(app, section_name); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1699,8 +1630,6 @@ parse_tm(struct app_params *app, PARSE_ERROR_INVALID(0, section_name, ent->name); } =20 - param->parsed =3D 1; - free(entries); } =20 @@ -1725,9 +1654,8 @@ parse_source(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->source_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->source_params, section_name); - param =3D &app->source_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1739,10 +1667,8 @@ parse_source(struct app_params *app, =20 PARSE_ERROR((status =3D=3D 0), section_name, ent->name); - idx =3D APP_PARAM_ADD(app->mempool_params, - ent->value); - PARSER_PARAM_ADD_CHECK(idx, app->mempool_params, - section_name); + + idx =3D APP_PARAM_ADD(app->mempool_params, ent->value); param->mempool_id =3D idx; continue; } @@ -1788,8 +1714,6 @@ parse_source(struct app_params *app, PARSE_ERROR_INVALID(0, section_name, ent->name); } =20 - param->parsed =3D 1; - free(entries); } =20 @@ -1814,9 +1738,8 @@ parse_sink(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->sink_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->sink_params, section_name); - param =3D &app->sink_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1851,8 +1774,6 @@ parse_sink(struct app_params *app, PARSE_ERROR_INVALID(0, section_name, ent->name); } =20 - param->parsed =3D 1; - free(entries); } =20 @@ -1875,9 +1796,8 @@ parse_msgq_req_pipeline(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->msgq_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, section_name); - param =3D &app->msgq_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1895,7 +1815,6 @@ parse_msgq_req_pipeline(struct app_params *app, PARSE_ERROR_INVALID(0, section_name, ent->name); } =20 - param->parsed =3D 1; free(entries); } =20 @@ -1918,9 +1837,8 @@ parse_msgq_rsp_pipeline(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->msgq_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, section_name); - param =3D &app->msgq_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1938,8 +1856,6 @@ parse_msgq_rsp_pipeline(struct app_params *app, PARSE_ERROR_INVALID(0, section_name, ent->name); } =20 - param->parsed =3D 1; - free(entries); } =20 @@ -1962,9 +1878,8 @@ parse_msgq(struct app_params *app, rte_cfgfile_section_entries(cfg, section_name, entries, n_entries); =20 param_idx =3D APP_PARAM_ADD(app->msgq_params, section_name); - PARSER_PARAM_ADD_CHECK(param_idx, app->msgq_params, section_name); - param =3D &app->msgq_params[param_idx]; + PARSE_CHECK_DUPLICATE_SECTION(param); =20 for (i =3D 0; i < n_entries; i++) { struct rte_cfgfile_entry *ent =3D &entries[i]; @@ -1991,8 +1906,6 @@ parse_msgq(struct app_params *app, PARSE_ERROR_INVALID(0, section_name, ent->name); } =20 - param->parsed =3D 1; - free(entries); } =20 @@ -2025,10 +1938,7 @@ static const struct config_section cfg_file_scheme= [] =3D { static void create_implicit_mempools(struct app_params *app) { - ssize_t idx; - - idx =3D APP_PARAM_ADD(app->mempool_params, "MEMPOOL0"); - PARSER_PARAM_ADD_CHECK(idx, app->mempool_params, "start-up"); + APP_PARAM_ADD(app->mempool_params, "MEMPOOL0"); } =20 static void @@ -2047,7 +1957,6 @@ create_implicit_links_from_port_mask(struct app_par= ams *app, =20 snprintf(name, sizeof(name), "LINK%" PRIu32, link_id); idx =3D APP_PARAM_ADD(app->link_params, name); - PARSER_PARAM_ADD_CHECK(idx, app->link_params, name); =20 app->link_params[idx].pmd_id =3D pmd_id; link_id++; @@ -2062,6 +1971,11 @@ assign_link_pmd_id_from_pci_bdf(struct app_params = *app) for (i =3D 0; i < app->n_links; i++) { struct app_link_params *link =3D &app->link_params[i]; =20 + APP_CHECK((strlen(link->pci_bdf)), + "Parse error: %s pci_bdf is not configured " + "(port_mask is not provided)", + link->name); + link->pmd_id =3D i; } } --=20 2.5.5