From: Jasvinder Singh <jasvinder.singh@intel.com>
To: dev@dpdk.org
Cc: cristian.dumitrescu@intel.com
Subject: [dpdk-dev] [PATCH] ip_pipeline: configuration file parser cleanup
Date: Mon, 2 May 2016 12:53:55 +0100 [thread overview]
Message-ID: <1462190035-63125-1-git-send-email-jasvinder.singh@intel.com> (raw)
This patch updates the parsing routines of packet queues (pktq_in/out
fields in the PIPELINE section) and message queues (msgq_in/out fields
of in the MSGQ Section) specified in ip_pipeline configuration file.
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
examples/ip_pipeline/config_parse.c | 221 ++++++++----------------------------
1 file changed, 45 insertions(+), 176 deletions(-)
diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c
index ab79cd5..72e3d61 100644
--- a/examples/ip_pipeline/config_parse.c
+++ b/examples/ip_pipeline/config_parse.c
@@ -1128,61 +1128,29 @@ parse_pipeline_pcap_sink(struct app_params *app,
static int
parse_pipeline_pktq_in(struct app_params *app,
struct app_pipeline_params *p,
- const char *value)
+ char *value)
{
- const char *next = value;
- char *end;
- char name[APP_PARAM_NAME_SIZE];
- size_t name_len;
- while (*next != '\0') {
+ while (1) {
enum app_pktq_in_type type;
int id;
- char *end_space;
- char *end_tab;
+ char *token = strtok_r(value, PARSE_DELIMITER, &value);
- next = skip_white_spaces(next);
- if (!next)
+ if (token == NULL)
break;
- end_space = strchr(next, ' ');
- end_tab = strchr(next, ' ');
-
- if (end_space && (!end_tab))
- end = end_space;
- else if ((!end_space) && end_tab)
- end = end_tab;
- else if (end_space && end_tab)
- end = RTE_MIN(end_space, end_tab);
- else
- end = NULL;
-
- if (!end)
- name_len = strlen(next);
- else
- name_len = end - next;
-
- if (name_len == 0 || name_len == sizeof(name))
- return -EINVAL;
-
- strncpy(name, next, name_len);
- name[name_len] = '\0';
- next += name_len;
- if (*next != '\0')
- next++;
-
- if (validate_name(name, "RXQ", 2) == 0) {
+ if (validate_name(token, "RXQ", 2) == 0) {
type = APP_PKTQ_IN_HWQ;
- id = APP_PARAM_ADD(app->hwq_in_params, name);
- } else if (validate_name(name, "SWQ", 1) == 0) {
+ id = APP_PARAM_ADD(app->hwq_in_params, token);
+ } else if (validate_name(token, "SWQ", 1) == 0) {
type = APP_PKTQ_IN_SWQ;
- id = APP_PARAM_ADD(app->swq_params, name);
- } else if (validate_name(name, "TM", 1) == 0) {
+ id = APP_PARAM_ADD(app->swq_params, token);
+ } else if (validate_name(token, "TM", 1) == 0) {
type = APP_PKTQ_IN_TM;
- id = APP_PARAM_ADD(app->tm_params, name);
- } else if (validate_name(name, "SOURCE", 1) == 0) {
+ id = APP_PARAM_ADD(app->tm_params, token);
+ } else if (validate_name(token, "SOURCE", 1) == 0) {
type = APP_PKTQ_IN_SOURCE;
- id = APP_PARAM_ADD(app->source_params, name);
+ id = APP_PARAM_ADD(app->source_params, token);
} else
return -EINVAL;
@@ -1200,60 +1168,28 @@ parse_pipeline_pktq_in(struct app_params *app,
static int
parse_pipeline_pktq_out(struct app_params *app,
struct app_pipeline_params *p,
- const char *value)
+ char *value)
{
- const char *next = value;
- char *end;
- char name[APP_PARAM_NAME_SIZE];
- size_t name_len;
-
- while (*next != '\0') {
- enum app_pktq_out_type type;
+ while (1) {
+ enum app_pktq_in_type type;
int id;
- char *end_space;
- char *end_tab;
+ char *token = strtok_r(value, PARSE_DELIMITER, &value);
- next = skip_white_spaces(next);
- if (!next)
+ if (token == NULL)
break;
- end_space = strchr(next, ' ');
- end_tab = strchr(next, ' ');
-
- if (end_space && (!end_tab))
- end = end_space;
- else if ((!end_space) && end_tab)
- end = end_tab;
- else if (end_space && end_tab)
- end = RTE_MIN(end_space, end_tab);
- else
- end = NULL;
-
- if (!end)
- name_len = strlen(next);
- else
- name_len = end - next;
-
- if (name_len == 0 || name_len == sizeof(name))
- return -EINVAL;
-
- strncpy(name, next, name_len);
- name[name_len] = '\0';
- next += name_len;
- if (*next != '\0')
- next++;
- if (validate_name(name, "TXQ", 2) == 0) {
+ if (validate_name(token, "TXQ", 2) == 0) {
type = APP_PKTQ_OUT_HWQ;
- id = APP_PARAM_ADD(app->hwq_out_params, name);
- } else if (validate_name(name, "SWQ", 1) == 0) {
+ id = APP_PARAM_ADD(app->hwq_out_params, token);
+ } else if (validate_name(token, "SWQ", 1) == 0) {
type = APP_PKTQ_OUT_SWQ;
- id = APP_PARAM_ADD(app->swq_params, name);
- } else if (validate_name(name, "TM", 1) == 0) {
+ id = APP_PARAM_ADD(app->swq_params, token);
+ } else if (validate_name(token, "TM", 1) == 0) {
type = APP_PKTQ_OUT_TM;
- id = APP_PARAM_ADD(app->tm_params, name);
- } else if (validate_name(name, "SINK", 1) == 0) {
+ id = APP_PARAM_ADD(app->tm_params, token);
+ } else if (validate_name(token, "SINK", 1) == 0) {
type = APP_PKTQ_OUT_SINK;
- id = APP_PARAM_ADD(app->sink_params, name);
+ id = APP_PARAM_ADD(app->sink_params, token);
} else
return -EINVAL;
@@ -1271,56 +1207,23 @@ parse_pipeline_pktq_out(struct app_params *app,
static int
parse_pipeline_msgq_in(struct app_params *app,
struct app_pipeline_params *p,
- const char *value)
+ char *value)
{
- const char *next = value;
- char *end;
- char name[APP_PARAM_NAME_SIZE];
- size_t name_len;
- ssize_t idx;
-
- while (*next != '\0') {
- char *end_space;
- char *end_tab;
+ while (1) {
+ int id;
+ char *token = strtok_r(value, PARSE_DELIMITER, &value);
- next = skip_white_spaces(next);
- if (!next)
+ if (token == NULL)
break;
- end_space = strchr(next, ' ');
- end_tab = strchr(next, ' ');
-
- if (end_space && (!end_tab))
- end = end_space;
- else if ((!end_space) && end_tab)
- end = end_tab;
- else if (end_space && end_tab)
- end = RTE_MIN(end_space, end_tab);
- else
- end = NULL;
-
- if (!end)
- name_len = strlen(next);
- else
- name_len = end - next;
-
- if (name_len == 0 || name_len == sizeof(name))
- return -EINVAL;
-
- strncpy(name, next, name_len);
- name[name_len] = '\0';
- next += name_len;
- if (*next != '\0')
- next++;
-
- if (validate_name(name, "MSGQ", 1) != 0)
+ if (validate_name(token, "MSGQ", 1) != 0)
return -EINVAL;
- idx = APP_PARAM_ADD(app->msgq_params, name);
- if (idx < 0)
- return idx;
+ id = APP_PARAM_ADD(app->msgq_params, token);
+ if (id < 0)
+ return id;
- p->msgq_in[p->n_msgq_in] = idx;
+ p->msgq_in[p->n_msgq_in] = id;
p->n_msgq_in++;
}
@@ -1330,56 +1233,22 @@ parse_pipeline_msgq_in(struct app_params *app,
static int
parse_pipeline_msgq_out(struct app_params *app,
struct app_pipeline_params *p,
- const char *value)
+ char *value)
{
- const char *next = value;
- char *end;
- char name[APP_PARAM_NAME_SIZE];
- size_t name_len;
- ssize_t idx;
-
- while (*next != '\0') {
- char *end_space;
- char *end_tab;
+ while (1) {
+ int id;
+ char *token = strtok_r(value, PARSE_DELIMITER, &value);
- next = skip_white_spaces(next);
- if (!next)
+ if (token == NULL)
break;
-
- end_space = strchr(next, ' ');
- end_tab = strchr(next, ' ');
-
- if (end_space && (!end_tab))
- end = end_space;
- else if ((!end_space) && end_tab)
- end = end_tab;
- else if (end_space && end_tab)
- end = RTE_MIN(end_space, end_tab);
- else
- end = NULL;
-
- if (!end)
- name_len = strlen(next);
- else
- name_len = end - next;
-
- if (name_len == 0 || name_len == sizeof(name))
- return -EINVAL;
-
- strncpy(name, next, name_len);
- name[name_len] = '\0';
- next += name_len;
- if (*next != '\0')
- next++;
-
- if (validate_name(name, "MSGQ", 1) != 0)
+ if (validate_name(token, "MSGQ", 1) != 0)
return -EINVAL;
- idx = APP_PARAM_ADD(app->msgq_params, name);
- if (idx < 0)
- return idx;
+ id = APP_PARAM_ADD(app->msgq_params, token);
+ if (id < 0)
+ return id;
- p->msgq_out[p->n_msgq_out] = idx;
+ p->msgq_out[p->n_msgq_out] = id;
p->n_msgq_out++;
}
--
2.5.5
next reply other threads:[~2016-05-02 11:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-02 11:53 Jasvinder Singh [this message]
2016-05-03 9:43 ` Bruce Richardson
2016-05-03 13:58 ` [dpdk-dev] [PATCH v2] " Jasvinder Singh
2016-05-11 16:36 ` [dpdk-dev] [PATCH v3] " Jasvinder Singh
2016-05-30 14:33 ` [dpdk-dev] [PATCH v4] " Jasvinder Singh
2016-06-08 14:48 ` Thomas Monjalon
2016-06-08 16:24 ` Singh, Jasvinder
2016-06-08 16:30 ` [dpdk-dev] [PATCH v5] " Jasvinder Singh
2016-06-08 18:05 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462190035-63125-1-git-send-email-jasvinder.singh@intel.com \
--to=jasvinder.singh@intel.com \
--cc=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).