[dpdk-dev] net/i40e: add flow RSS queue index check

Message ID 1522811927-46772-1-git-send-email-wei.zhao1@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Helin Zhang
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Zhao1, Wei April 4, 2018, 3:18 a.m. UTC
  There need a queue index check for RSS queue region
in order to aviod error from configuration.

Fixes: ecad87d22383 ("net/i40e: move RSS to flow API")
Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
Tested-by: Peng Yuan <yuan.peng@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
  

Comments

Qi Zhang April 4, 2018, 3:59 a.m. UTC | #1
> -----Original Message-----
> From: Zhao1, Wei
> Sent: Wednesday, April 4, 2018 11:19 AM
> To: dev@dpdk.org; stable@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhao1, Wei <wei.zhao1@intel.com>
> Subject: [PATCH] net/i40e: add flow RSS queue index check
> 
> There need a queue index check for RSS queue region in order to aviod error
> from configuration.
> 
> Fixes: ecad87d22383 ("net/i40e: move RSS to flow API")
> Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> Tested-by: Peng Yuan <yuan.peng@intel.com>

Please add Cc: stable@dpdk.org here.

> ---
>  drivers/net/i40e/i40e_flow.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index
> f3e8c5f..4e86ecb 100644
> --- a/drivers/net/i40e/i40e_flow.c
> +++ b/drivers/net/i40e/i40e_flow.c
> @@ -4249,6 +4249,20 @@ i40e_flow_parse_rss_action(struct rte_eth_dev
> *dev,
>  				return -rte_errno;
>  			}
> 
> +			for (i = 0; i < rss->num; i++) {
> +				for (j = 0; j < rss_info->num; j++) {
> +					if (rss->queue[i] == rss_info->queue[j])
> +						break;
> +				}
> +				if (j == rss_info->num) {
> +					rte_flow_error_set(error, EINVAL,
> +						RTE_FLOW_ERROR_TYPE_ACTION,
> +						act,
> +						"no valid queues");
> +					return -rte_errno;
> +				}
> +			}

Is it necessary to add this check inside the big loop ?

Btw, the function of i40e_flow_parse_rss_action looks too big and without enough comment

It's better to use sub-function or add some comment before each code block 
to make it more readable.

Regards
Qi

 
> +
>  			for (i = 0; i < info->queue_region_number; i++) {
>  				if (info->region[i].queue_num == rss->num &&
>  					info->region[i].queue_start_index ==
> --
> 2.7.5
  
Zhao1, Wei April 4, 2018, 4:02 a.m. UTC | #2
Ok,I will add more comment in other  independent patch

> -----Original Message-----

> From: Zhang, Qi Z

> Sent: Wednesday, April 4, 2018 11:59 AM

> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org; stable@dpdk.org

> Subject: RE: [PATCH] net/i40e: add flow RSS queue index check

> 

> 

> 

> > -----Original Message-----

> > From: Zhao1, Wei

> > Sent: Wednesday, April 4, 2018 11:19 AM

> > To: dev@dpdk.org; stable@dpdk.org

> > Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhao1, Wei

> > <wei.zhao1@intel.com>

> > Subject: [PATCH] net/i40e: add flow RSS queue index check

> >

> > There need a queue index check for RSS queue region in order to aviod

> > error from configuration.

> >

> > Fixes: ecad87d22383 ("net/i40e: move RSS to flow API")

> > Signed-off-by: Wei Zhao <wei.zhao1@intel.com>

> > Tested-by: Peng Yuan <yuan.peng@intel.com>

> 

> Please add Cc: stable@dpdk.org here.

> 

> > ---

> >  drivers/net/i40e/i40e_flow.c | 14 ++++++++++++++

> >  1 file changed, 14 insertions(+)

> >

> > diff --git a/drivers/net/i40e/i40e_flow.c

> > b/drivers/net/i40e/i40e_flow.c index f3e8c5f..4e86ecb 100644

> > --- a/drivers/net/i40e/i40e_flow.c

> > +++ b/drivers/net/i40e/i40e_flow.c

> > @@ -4249,6 +4249,20 @@ i40e_flow_parse_rss_action(struct rte_eth_dev

> > *dev,

> >  				return -rte_errno;

> >  			}

> >

> > +			for (i = 0; i < rss->num; i++) {

> > +				for (j = 0; j < rss_info->num; j++) {

> > +					if (rss->queue[i] == rss_info-

> >queue[j])

> > +						break;

> > +				}

> > +				if (j == rss_info->num) {

> > +					rte_flow_error_set(error, EINVAL,

> > +

> 	RTE_FLOW_ERROR_TYPE_ACTION,

> > +						act,

> > +						"no valid queues");

> > +					return -rte_errno;

> > +				}

> > +			}

> 

> Is it necessary to add this check inside the big loop ?

> 

> Btw, the function of i40e_flow_parse_rss_action looks too big and without

> enough comment

> 

> It's better to use sub-function or add some comment before each code block

> to make it more readable.

> 

> Regards

> Qi

> 

> 

> > +

> >  			for (i = 0; i < info->queue_region_number; i++) {

> >  				if (info->region[i].queue_num == rss->num

> &&

> >  					info->region[i].queue_start_index ==

> > --

> > 2.7.5
  
Zhao1, Wei April 4, 2018, 5:12 a.m. UTC | #3
> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Wednesday, April 4, 2018 11:59 AM
> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org; stable@dpdk.org
> Subject: RE: [PATCH] net/i40e: add flow RSS queue index check
> 
> 
> 
> > -----Original Message-----
> > From: Zhao1, Wei
> > Sent: Wednesday, April 4, 2018 11:19 AM
> > To: dev@dpdk.org; stable@dpdk.org
> > Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhao1, Wei
> > <wei.zhao1@intel.com>
> > Subject: [PATCH] net/i40e: add flow RSS queue index check
> >
> > There need a queue index check for RSS queue region in order to aviod
> > error from configuration.
> >
> > Fixes: ecad87d22383 ("net/i40e: move RSS to flow API")
> > Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> > Tested-by: Peng Yuan <yuan.peng@intel.com>
> 
> Please add Cc: stable@dpdk.org here.
> 
> > ---
> >  drivers/net/i40e/i40e_flow.c | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> >
> > diff --git a/drivers/net/i40e/i40e_flow.c
> > b/drivers/net/i40e/i40e_flow.c index f3e8c5f..4e86ecb 100644
> > --- a/drivers/net/i40e/i40e_flow.c
> > +++ b/drivers/net/i40e/i40e_flow.c
> > @@ -4249,6 +4249,20 @@ i40e_flow_parse_rss_action(struct rte_eth_dev
> > *dev,
> >  				return -rte_errno;
> >  			}
> >
> > +			for (i = 0; i < rss->num; i++) {
> > +				for (j = 0; j < rss_info->num; j++) {
> > +					if (rss->queue[i] == rss_info-
> >queue[j])
> > +						break;
> > +				}
> > +				if (j == rss_info->num) {
> > +					rte_flow_error_set(error, EINVAL,
> > +
> 	RTE_FLOW_ERROR_TYPE_ACTION,
> > +						act,
> > +						"no valid queues");
> > +					return -rte_errno;
> > +				}
> > +			}
> 
> Is it necessary to add this check inside the big loop ?

Ok, I will commit v2 later.

> 
> Btw, the function of i40e_flow_parse_rss_action looks too big and without
> enough comment
> 
> It's better to use sub-function or add some comment before each code block
> to make it more readable.
> 
> Regards
> Qi
> 
> 
> > +
> >  			for (i = 0; i < info->queue_region_number; i++) {
> >  				if (info->region[i].queue_num == rss->num
> &&
> >  					info->region[i].queue_start_index ==
> > --
> > 2.7.5
  

Patch

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index f3e8c5f..4e86ecb 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -4249,6 +4249,20 @@  i40e_flow_parse_rss_action(struct rte_eth_dev *dev,
 				return -rte_errno;
 			}
 
+			for (i = 0; i < rss->num; i++) {
+				for (j = 0; j < rss_info->num; j++) {
+					if (rss->queue[i] == rss_info->queue[j])
+						break;
+				}
+				if (j == rss_info->num) {
+					rte_flow_error_set(error, EINVAL,
+						RTE_FLOW_ERROR_TYPE_ACTION,
+						act,
+						"no valid queues");
+					return -rte_errno;
+				}
+			}
+
 			for (i = 0; i < info->queue_region_number; i++) {
 				if (info->region[i].queue_num == rss->num &&
 					info->region[i].queue_start_index ==