From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id F12312BD0 for ; Fri, 1 Apr 2016 11:55:32 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 01 Apr 2016 02:55:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,427,1455004800"; d="scan'208";a="77197567" Received: from sie-lab-212-033.ir.intel.com (HELO silpixa00383881.ir.intel.com) ([10.237.212.33]) by fmsmga004.fm.intel.com with ESMTP; 01 Apr 2016 02:55:32 -0700 From: Fan Zhang To: dev@dpdk.org Date: Fri, 1 Apr 2016 10:55:30 +0100 Message-Id: <1459504530-6158-1-git-send-email-roy.fan.zhang@intel.com> X-Mailer: git-send-email 2.5.0 Subject: [dpdk-dev] [PATCH] examples/ip_pipeline: fix pcap file parsing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2016 09:55:33 -0000 Fixes: fe5d046 ("examples/ip_pipeline: add pcap file dump") This patch fixes the pcap file parsing in ip_pipeline. Originally, the parser recognizes the pcap related entries regardless of the RTE_PORT_PCAP macro definition status. Signed-off-by: Fan Zhang Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/config_parse.c | 90 ++++++++++++++++++++++++++++++------- 1 file changed, 74 insertions(+), 16 deletions(-) diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c index 152889d..e83f1d6 100644 --- a/examples/ip_pipeline/config_parse.c +++ b/examples/ip_pipeline/config_parse.c @@ -989,11 +989,6 @@ parse_pipeline_pcap_source(struct app_params *app, if (p->n_pktq_in == 0) return -EINVAL; - for (i = 0; i < p->n_pktq_in; i++) { - if (p->pktq_in[i].type != APP_PKTQ_IN_SOURCE) - return -EINVAL; - } - i = 0; while (*next != '\0') { uint32_t id; @@ -1068,11 +1063,6 @@ parse_pipeline_pcap_sink(struct app_params *app, if (p->n_pktq_out == 0) return -EINVAL; - for (i = 0; i < p->n_pktq_out; i++) { - if (p->pktq_out[i].type != APP_PKTQ_OUT_SINK) - return -EINVAL; - } - i = 0; while (*next != '\0') { uint32_t id; @@ -1478,7 +1468,13 @@ parse_pipeline(struct app_params *app, } if (strcmp(ent->name, "pcap_file_rd") == 0) { - int status = parse_pipeline_pcap_source(app, + int status; + +#ifndef RTE_PORT_PCAP + PARSE_ERROR_INVALID(0, section_name, ent->name); +#endif + + status = parse_pipeline_pcap_source(app, param, ent->value, NULL); PARSE_ERROR((status == 0), section_name, @@ -1487,7 +1483,13 @@ parse_pipeline(struct app_params *app, } if (strcmp(ent->name, "pcap_bytes_rd_per_pkt") == 0) { - int status = parse_pipeline_pcap_source(app, + int status; + +#ifndef RTE_PORT_PCAP + PARSE_ERROR_INVALID(0, section_name, ent->name); +#endif + + status = parse_pipeline_pcap_source(app, param, NULL, ent->value); PARSE_ERROR((status == 0), section_name, @@ -1496,7 +1498,13 @@ parse_pipeline(struct app_params *app, } if (strcmp(ent->name, "pcap_file_wr") == 0) { - int status = parse_pipeline_pcap_sink(app, param, + int status; + +#ifndef RTE_PORT_PCAP + PARSE_ERROR_INVALID(0, section_name, ent->name); +#endif + + status = parse_pipeline_pcap_sink(app, param, ent->value, NULL); PARSE_ERROR((status == 0), section_name, @@ -1505,7 +1513,13 @@ parse_pipeline(struct app_params *app, } if (strcmp(ent->name, "pcap_n_pkt_wr") == 0) { - int status = parse_pipeline_pcap_sink(app, param, + int status; + +#ifndef RTE_PORT_PCAP + PARSE_ERROR_INVALID(0, section_name, ent->name); +#endif + + status = parse_pipeline_pcap_sink(app, param, NULL, ent->value); PARSE_ERROR((status == 0), section_name, @@ -2163,6 +2177,8 @@ parse_source(struct app_params *app, struct rte_cfgfile_entry *entries; int n_entries, i; ssize_t param_idx; + uint32_t pcap_file_present = 0; + uint32_t pcap_size_present = 0; n_entries = rte_cfgfile_section_num_entries(cfg, section_name); PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name); @@ -2205,18 +2221,31 @@ parse_source(struct app_params *app, } if (strcmp(ent->name, "pcap_file_rd")) { + PARSE_ERROR_DUPLICATE((pcap_file_present == 0), + section_name, ent->name); + param->file_name = strdup(ent->value); PARSE_ERROR_MALLOC(param->file_name != NULL); + pcap_file_present = 1; + continue; } if (strcmp(ent->name, "pcap_bytes_rd_per_pkt") == 0) { - int status = parser_read_uint32( + int status; + + PARSE_ERROR_DUPLICATE((pcap_size_present == 0), + section_name, ent->name); + + status = parser_read_uint32( ¶m->n_bytes_per_pkt, ent->value); PARSE_ERROR((status == 0), section_name, ent->name); + pcap_size_present = 1; + + continue; } /* unrecognized */ @@ -2237,6 +2266,8 @@ parse_sink(struct app_params *app, struct rte_cfgfile_entry *entries; int n_entries, i; ssize_t param_idx; + uint32_t pcap_file_present = 0; + uint32_t pcap_n_pkt_present = 0; n_entries = rte_cfgfile_section_num_entries(cfg, section_name); PARSE_ERROR_SECTION_NO_ENTRIES((n_entries > 0), section_name); @@ -2255,18 +2286,28 @@ parse_sink(struct app_params *app, struct rte_cfgfile_entry *ent = &entries[i]; if (strcmp(ent->name, "pcap_file_wr")) { + PARSE_ERROR_DUPLICATE((pcap_file_present == 0), + section_name, ent->name); + param->file_name = strdup(ent->value); PARSE_ERROR_MALLOC((param->file_name != NULL)); + continue; } if (strcmp(ent->name, "pcap_n_pkt_wr")) { - int status = parser_read_uint32( + int status; + + PARSE_ERROR_DUPLICATE((pcap_n_pkt_present == 0), + section_name, ent->name); + + status = parser_read_uint32( ¶m->n_pkts_to_dump, ent->value); PARSE_ERROR((status == 0), section_name, ent->name); + continue; } @@ -2580,6 +2621,23 @@ app_config_parse(struct app_params *app, const char *file_name) APP_PARAM_COUNT(app->msgq_params, app->n_msgq); APP_PARAM_COUNT(app->pipeline_params, app->n_pipelines); +#ifdef RTE_PORT_PCAP + for (i = 0; i < (int)app->n_pktq_source; i++) { + struct app_pktq_source_params *p = &app->source_params[i]; + + APP_CHECK((p->file_name), "Parse error: missing " + "mandatory field \"pcap_file_rd\" for \"%s\"", + p->name); + } +#else + for (i = 0; i < (int)app->n_pktq_source; i++) { + struct app_pktq_source_params *p = &app->source_params[i]; + + APP_CHECK((!p->file_name), "Parse error: invalid field " + "\"pcap_file_rd\" for \"%s\"", p->name); + } +#endif + if (app->port_mask == 0) assign_link_pmd_id_from_pci_bdf(app); -- 2.5.0