[dpdk-dev,1/1] ip_pipeline: fixed parsing cpu cores

Message ID 1437489540-20758-1-git-send-email-maciejx.t.gajdzica@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Maciej Gajdzica July 21, 2015, 2:39 p.m. UTC
  This patch fixes parsing value of core variable in pipeline config.
Before not every combination of cores (c), sockets (s) and
hyperthreading (h) was parsed correctly.

Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
---
 examples/ip_pipeline/config_parse.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
  

Comments

Cristian Dumitrescu July 21, 2015, 3:35 p.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Maciej Gajdzica
> Sent: Tuesday, July 21, 2015 3:39 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 1/1] ip_pipeline: fixed parsing cpu cores
> 
> This patch fixes parsing value of core variable in pipeline config.
> Before not every combination of cores (c), sockets (s) and
> hyperthreading (h) was parsed correctly.
> 
> Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
> ---
>  examples/ip_pipeline/config_parse.c |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/examples/ip_pipeline/config_parse.c
> b/examples/ip_pipeline/config_parse.c
> index 361bf8a..c9b78f9 100644
> --- a/examples/ip_pipeline/config_parse.c
> +++ b/examples/ip_pipeline/config_parse.c
> @@ -386,14 +386,14 @@ parse_pipeline_core(uint32_t *socket,
>  		switch (type) {
>  		case 's':
>  		case 'S':
> -			if (s_parsed)
> +			if (s_parsed || c_parsed || h_parsed)
>  				return -EINVAL;
>  			s_parsed = 1;
>  			next++;
>  			break;
>  		case 'c':
>  		case 'C':
> -			if (c_parsed)
> +			if (c_parsed || h_parsed)
>  				return -EINVAL;
>  			c_parsed = 1;
>  			next++;
> @@ -423,7 +423,10 @@ parse_pipeline_core(uint32_t *socket,
>  			num[num_len] = *next;
>  		}
> 
> -		if (num_len == 0 && type != 'h')
> +		if (num_len == 0 && type != 'h' && type != 'H')
> +			return -EINVAL;
> +
> +		if (num_len != 0 && (type == 'h' || type == 'H'))
>  			return -EINVAL;
> 
>  		num[num_len] = '\0';
> @@ -438,9 +441,6 @@ parse_pipeline_core(uint32_t *socket,
>  		case 'c':
>  		case 'C':
>  			c = val;
> -			if (type == 'C' && *next != '\0')
> -				return -EINVAL;
> -
>  			break;
>  		case 'h':
>  		case 'H':
> --
> 1.7.9.5

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
  
Thomas Monjalon July 27, 2015, 1:50 p.m. UTC | #2
> > This patch fixes parsing value of core variable in pipeline config.
> > Before not every combination of cores (c), sockets (s) and
> > hyperthreading (h) was parsed correctly.
> > 
> > Signed-off-by: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
> 
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks
  

Patch

diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c
index 361bf8a..c9b78f9 100644
--- a/examples/ip_pipeline/config_parse.c
+++ b/examples/ip_pipeline/config_parse.c
@@ -386,14 +386,14 @@  parse_pipeline_core(uint32_t *socket,
 		switch (type) {
 		case 's':
 		case 'S':
-			if (s_parsed)
+			if (s_parsed || c_parsed || h_parsed)
 				return -EINVAL;
 			s_parsed = 1;
 			next++;
 			break;
 		case 'c':
 		case 'C':
-			if (c_parsed)
+			if (c_parsed || h_parsed)
 				return -EINVAL;
 			c_parsed = 1;
 			next++;
@@ -423,7 +423,10 @@  parse_pipeline_core(uint32_t *socket,
 			num[num_len] = *next;
 		}
 
-		if (num_len == 0 && type != 'h')
+		if (num_len == 0 && type != 'h' && type != 'H')
+			return -EINVAL;
+
+		if (num_len != 0 && (type == 'h' || type == 'H'))
 			return -EINVAL;
 
 		num[num_len] = '\0';
@@ -438,9 +441,6 @@  parse_pipeline_core(uint32_t *socket,
 		case 'c':
 		case 'C':
 			c = val;
-			if (type == 'C' && *next != '\0')
-				return -EINVAL;
-
 			break;
 		case 'h':
 		case 'H':