[dpdk-dev] net/i40e: fix eth pattern parsing

Message ID 1491236049-6747-1-git-send-email-bernard.iremonger@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

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

Commit Message

Iremonger, Bernard April 3, 2017, 4:14 p.m. UTC
  Handle the following eth patterns:
eth dst spec aa:bb:cc:dd:ee:ff
eth dst mask ff:ff:ff:ff:ff:ff
eth src spec aa:bb:cc:dd:ee:ff
eth src mask ff:ff:ff:ff:ff:ff

Fixes: d46e85af6b5c ("net/i40e: parse QinQ pattern")

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Ferruh Yigit April 4, 2017, 12:39 p.m. UTC | #1
On 4/3/2017 5:14 PM, Bernard Iremonger wrote:
> Handle the following eth patterns:
> eth dst spec aa:bb:cc:dd:ee:ff
> eth dst mask ff:ff:ff:ff:ff:ff
> eth src spec aa:bb:cc:dd:ee:ff
> eth src mask ff:ff:ff:ff:ff:ff
> 
> Fixes: d46e85af6b5c ("net/i40e: parse QinQ pattern")
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  drivers/net/i40e/i40e_flow.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
> index 9f541eaff..3fcd31036 100644
> --- a/drivers/net/i40e/i40e_flow.c
> +++ b/drivers/net/i40e/i40e_flow.c
> @@ -1772,7 +1772,8 @@ i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev,
>  		case RTE_FLOW_ITEM_TYPE_ETH:
>  			eth_spec = (const struct rte_flow_item_eth *)item->spec;
>  			eth_mask = (const struct rte_flow_item_eth *)item->mask;
> -			if (eth_spec && eth_mask) {
> +			if ((eth_spec && eth_mask) ||
> +			    (eth_spec || eth_mask)) {

Is this check requires both spec and mask to be all zeros? If this is
the real intention, can you please add a comment above check to clarify it.

Also other i40e_flow_parse_xxx_pattern() functions has function comment
to describe expected/valid pattern for the flow rule.
i40e_flow_parse_qinq_pattern() is missing that function comment. Would
you mind adding it, which helps to validate implementation against
intention.

Thanks,
ferruh

>  				rte_flow_error_set(error, EINVAL,
>  						   RTE_FLOW_ERROR_TYPE_ITEM,
>  						   item,
>
  
Iremonger, Bernard April 4, 2017, 12:52 p.m. UTC | #2
Hi Ferruh,

> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Tuesday, April 4, 2017 1:40 PM
> To: Iremonger, Bernard <bernard.iremonger@intel.com>; dev@dpdk.org;
> Xing, Beilei <beilei.xing@intel.com>
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix eth pattern parsing
> 
> On 4/3/2017 5:14 PM, Bernard Iremonger wrote:
> > Handle the following eth patterns:
> > eth dst spec aa:bb:cc:dd:ee:ff
> > eth dst mask ff:ff:ff:ff:ff:ff
> > eth src spec aa:bb:cc:dd:ee:ff
> > eth src mask ff:ff:ff:ff:ff:ff
> >
> > Fixes: d46e85af6b5c ("net/i40e: parse QinQ pattern")
> >
> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > ---
> >  drivers/net/i40e/i40e_flow.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/i40e/i40e_flow.c
> > b/drivers/net/i40e/i40e_flow.c index 9f541eaff..3fcd31036 100644
> > --- a/drivers/net/i40e/i40e_flow.c
> > +++ b/drivers/net/i40e/i40e_flow.c
> > @@ -1772,7 +1772,8 @@ i40e_flow_parse_qinq_pattern(__rte_unused
> struct rte_eth_dev *dev,
> >  		case RTE_FLOW_ITEM_TYPE_ETH:
> >  			eth_spec = (const struct rte_flow_item_eth *)item-
> >spec;
> >  			eth_mask = (const struct rte_flow_item_eth *)item-
> >mask;
> > -			if (eth_spec && eth_mask) {
> > +			if ((eth_spec && eth_mask) ||
> > +			    (eth_spec || eth_mask)) {
> 
> Is this check requires both spec and mask to be all zeros? If this is the real
> intention, can you please add a comment above check to clarify it.

Yes , the intention is to only except the "eth" key word, I will send a v2.

> 
> Also other i40e_flow_parse_xxx_pattern() functions has function comment
> to describe expected/valid pattern for the flow rule.
> i40e_flow_parse_qinq_pattern() is missing that function comment. Would
> you mind adding it, which helps to validate implementation against intention.

Yes , I will describe valid patterns for the flow rule in a separate patch. 
 
> Thanks,
> ferruh
> 
> >  				rte_flow_error_set(error, EINVAL,
> >
> RTE_FLOW_ERROR_TYPE_ITEM,
> >  						   item,
> >
Regards,

Bernard.
  
Xing, Beilei April 5, 2017, 2:03 a.m. UTC | #3
> -----Original Message-----
> From: Iremonger, Bernard
> Sent: Tuesday, April 4, 2017 8:52 PM
> To: Yigit, Ferruh <ferruh.yigit@intel.com>; dev@dpdk.org; Xing, Beilei
> <beilei.xing@intel.com>
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix eth pattern parsing
> 
> Hi Ferruh,
> 
> > -----Original Message-----
> > From: Yigit, Ferruh
> > Sent: Tuesday, April 4, 2017 1:40 PM
> > To: Iremonger, Bernard <bernard.iremonger@intel.com>; dev@dpdk.org;
> > Xing, Beilei <beilei.xing@intel.com>
> > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> > Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix eth pattern parsing
> >
> > On 4/3/2017 5:14 PM, Bernard Iremonger wrote:
> > > Handle the following eth patterns:
> > > eth dst spec aa:bb:cc:dd:ee:ff
> > > eth dst mask ff:ff:ff:ff:ff:ff
> > > eth src spec aa:bb:cc:dd:ee:ff
> > > eth src mask ff:ff:ff:ff:ff:ff
> > >
> > > Fixes: d46e85af6b5c ("net/i40e: parse QinQ pattern")
> > >
> > > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > > ---
> > >  drivers/net/i40e/i40e_flow.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/net/i40e/i40e_flow.c
> > > b/drivers/net/i40e/i40e_flow.c index 9f541eaff..3fcd31036 100644
> > > --- a/drivers/net/i40e/i40e_flow.c
> > > +++ b/drivers/net/i40e/i40e_flow.c
> > > @@ -1772,7 +1772,8 @@ i40e_flow_parse_qinq_pattern(__rte_unused
> > struct rte_eth_dev *dev,
> > >  		case RTE_FLOW_ITEM_TYPE_ETH:
> > >  			eth_spec = (const struct rte_flow_item_eth *)item-
> spec;
> > >  			eth_mask = (const struct rte_flow_item_eth *)item-
> mask;
> > > -			if (eth_spec && eth_mask) {
> > > +			if ((eth_spec && eth_mask) ||
> > > +			    (eth_spec || eth_mask)) {
> >
> > Is this check requires both spec and mask to be all zeros? If this is
> > the real intention, can you please add a comment above check to clarify it.
> 
> Yes , the intention is to only except the "eth" key word, I will send a v2.

Seem " if (eth_spec || eth_mask) " is enough, what do you think?

Beilei

> 
> >
> > Also other i40e_flow_parse_xxx_pattern() functions has function
> > comment to describe expected/valid pattern for the flow rule.
> > i40e_flow_parse_qinq_pattern() is missing that function comment. Would
> > you mind adding it, which helps to validate implementation against
> intention.
> 
> Yes , I will describe valid patterns for the flow rule in a separate patch.
> 
> > Thanks,
> > ferruh
> >
> > >  				rte_flow_error_set(error, EINVAL,
> > >
> > RTE_FLOW_ERROR_TYPE_ITEM,
> > >  						   item,
> > >
> Regards,
> 
> Bernard.
  
Iremonger, Bernard April 5, 2017, 8 a.m. UTC | #4
Hi Beilei,

> -----Original Message-----
> From: Xing, Beilei
> Sent: Wednesday, April 5, 2017 3:03 AM
> To: Iremonger, Bernard <bernard.iremonger@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix eth pattern parsing
> 
> 
> > -----Original Message-----
> > From: Iremonger, Bernard
> > Sent: Tuesday, April 4, 2017 8:52 PM
> > To: Yigit, Ferruh <ferruh.yigit@intel.com>; dev@dpdk.org; Xing, Beilei
> > <beilei.xing@intel.com>
> > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> > Subject: RE: [dpdk-dev] [PATCH] net/i40e: fix eth pattern parsing
> >
> > Hi Ferruh,
> >
> > > -----Original Message-----
> > > From: Yigit, Ferruh
> > > Sent: Tuesday, April 4, 2017 1:40 PM
> > > To: Iremonger, Bernard <bernard.iremonger@intel.com>;
> dev@dpdk.org;
> > > Xing, Beilei <beilei.xing@intel.com>
> > > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> > > Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix eth pattern parsing
> > >
> > > On 4/3/2017 5:14 PM, Bernard Iremonger wrote:
> > > > Handle the following eth patterns:
> > > > eth dst spec aa:bb:cc:dd:ee:ff
> > > > eth dst mask ff:ff:ff:ff:ff:ff
> > > > eth src spec aa:bb:cc:dd:ee:ff
> > > > eth src mask ff:ff:ff:ff:ff:ff
> > > >
> > > > Fixes: d46e85af6b5c ("net/i40e: parse QinQ pattern")
> > > >
> > > > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > > > ---
> > > >  drivers/net/i40e/i40e_flow.c | 3 ++-
> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/net/i40e/i40e_flow.c
> > > > b/drivers/net/i40e/i40e_flow.c index 9f541eaff..3fcd31036 100644
> > > > --- a/drivers/net/i40e/i40e_flow.c
> > > > +++ b/drivers/net/i40e/i40e_flow.c
> > > > @@ -1772,7 +1772,8 @@
> i40e_flow_parse_qinq_pattern(__rte_unused
> > > struct rte_eth_dev *dev,
> > > >  		case RTE_FLOW_ITEM_TYPE_ETH:
> > > >  			eth_spec = (const struct rte_flow_item_eth *)item-
> > spec;
> > > >  			eth_mask = (const struct rte_flow_item_eth *)item-
> > mask;
> > > > -			if (eth_spec && eth_mask) {
> > > > +			if ((eth_spec && eth_mask) ||
> > > > +			    (eth_spec || eth_mask)) {
> > >
> > > Is this check requires both spec and mask to be all zeros? If this
> > > is the real intention, can you please add a comment above check to clarify
> it.
> >
> > Yes , the intention is to only except the "eth" key word, I will send a v2.
> 
> Seem " if (eth_spec || eth_mask) " is enough, what do you think?
> 
> Beilei

Yes, I think you are right.
I will change to how it is done for MPLS and send a v2.
> 
> >
> > >
> > > Also other i40e_flow_parse_xxx_pattern() functions has function
> > > comment to describe expected/valid pattern for the flow rule.
> > > i40e_flow_parse_qinq_pattern() is missing that function comment.
> > > Would you mind adding it, which helps to validate implementation
> > > against
> > intention.
> >
> > Yes , I will describe valid patterns for the flow rule in a separate patch.
> >
> > > Thanks,
> > > ferruh
> > >
> > > >  				rte_flow_error_set(error, EINVAL,
> > > >
> > > RTE_FLOW_ERROR_TYPE_ITEM,
> > > >  						   item,
> > > >
> > Regards,
> >
> > Bernard.

Regards,

Bernard.
  

Patch

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 9f541eaff..3fcd31036 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1772,7 +1772,8 @@  i40e_flow_parse_qinq_pattern(__rte_unused struct rte_eth_dev *dev,
 		case RTE_FLOW_ITEM_TYPE_ETH:
 			eth_spec = (const struct rte_flow_item_eth *)item->spec;
 			eth_mask = (const struct rte_flow_item_eth *)item->mask;
-			if (eth_spec && eth_mask) {
+			if ((eth_spec && eth_mask) ||
+			    (eth_spec || eth_mask)) {
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
 						   item,