DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples/ip_pipeline: fix flow classification pipeline
@ 2016-03-31 11:29 Fan Zhang
  2016-03-31 20:55 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Fan Zhang @ 2016-03-31 11:29 UTC (permalink / raw)
  To: dev

Fixes: examples/ip_pipeline: config parser clean-up

This patch fixes the initialization error in flow classification
pipeline. Originally, when there is no key_mask specified in the
CFG file, all '0' mask is utilized.

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 .../pipeline/pipeline_flow_classification_be.c      | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
index 60e9c39..3da46b0 100644
--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
+++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
@@ -55,6 +55,7 @@ struct pipeline_flow_classification {
 	uint32_t key_offset;
 	uint32_t hash_offset;
 	uint8_t key_mask[PIPELINE_FC_FLOW_KEY_MAX_SIZE];
+	uint32_t key_mask_present;
 	uint32_t flow_id_offset;
 
 } __rte_cache_aligned;
@@ -308,7 +309,7 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 				"\"%s\" is too long", params->name,
 				arg_name);
 
-			snprintf(key_mask_str, mask_str_len, "%s",
+			snprintf(key_mask_str, sizeof(key_mask_str), "%s",
 				arg_value);
 
 			continue;
@@ -370,11 +371,21 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 		uint32_t key_size = p->key_size;
 		int status;
 
+		PIPELINE_ARG_CHECK(((key_size == 8) || (key_size == 16)),
+			"Parse error in section \"%s\": entry key_mask "
+			"only allowed for key_size of 8 or 16 bytes",
+			params->name);
+
 		PIPELINE_ARG_CHECK((strlen(key_mask_str) ==
 			(key_size * 2)), "Parse error in section "
 			"\"%s\": key_mask should have exactly %u hex "
 			"digits", params->name, (key_size * 2));
 
+		PIPELINE_ARG_CHECK((hash_offset_present == 0), "Parse "
+			"error in section \"%s\": entry hash_offset only "
+			"allowed when key_mask is not present",
+			params->name);
+
 		status = parse_hex_string(key_mask_str, p->key_mask,
 			&p->key_size);
 
@@ -383,6 +394,8 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 			"key_mask", key_mask_str);
 	}
 
+	p->key_mask_present = key_mask_present;
+
 	return 0;
 }
 
@@ -486,7 +499,8 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 			.signature_offset = p_fc->hash_offset,
 			.key_offset = p_fc->key_offset,
 			.f_hash = hash_func[(p_fc->key_size / 8) - 1],
-			.key_mask = p_fc->key_mask,
+			.key_mask = (p_fc->key_mask_present) ?
+				p_fc->key_mask : NULL,
 			.seed = 0,
 		};
 
@@ -497,7 +511,8 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 			.signature_offset = p_fc->hash_offset,
 			.key_offset = p_fc->key_offset,
 			.f_hash = hash_func[(p_fc->key_size / 8) - 1],
-			.key_mask = p_fc->key_mask,
+			.key_mask = (p_fc->key_mask_present) ?
+				p_fc->key_mask : NULL,
 			.seed = 0,
 		};
 
-- 
2.5.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] examples/ip_pipeline: fix flow classification pipeline
  2016-03-31 11:29 [dpdk-dev] [PATCH] examples/ip_pipeline: fix flow classification pipeline Fan Zhang
@ 2016-03-31 20:55 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2016-03-31 20:55 UTC (permalink / raw)
  To: Fan Zhang; +Cc: dev

2016-03-31 12:29, Fan Zhang:
> Fixes: examples/ip_pipeline: config parser clean-up

Fixes: 1a33c5ea2f45 ("examples/ip_pipeline: clean config parser")

> This patch fixes the initialization error in flow classification
> pipeline. Originally, when there is no key_mask specified in the
> CFG file, all '0' mask is utilized.
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-31 20:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-31 11:29 [dpdk-dev] [PATCH] examples/ip_pipeline: fix flow classification pipeline Fan Zhang
2016-03-31 20:55 ` Thomas Monjalon

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).