[dpdk-dev] i40e: fix i40e_validate_mac_addr to permit multicast addresses

Message ID 20170822222146.36912-1-dharton@cisco.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 success Compilation OK

Commit Message

David Harton Aug. 22, 2017, 10:21 p.m. UTC
  The i40e maintains a single MAC filter table for both
unicast and multicast addresses.  The i40e_validate_mac_addr
function was preventing multicast addresses from being added
to the table via i40evf_add_mac_addr.  Fixed the issue by
removing the multicast address check in i40e_validate_mac_addr.

Signed-off-by: David Harton <dharton@cisco.com>
---
 drivers/net/i40e/base/i40e_common.c | 12 +++++-------
 drivers/net/i40e/i40e_ethdev.c      |  3 ++-
 2 files changed, 7 insertions(+), 8 deletions(-)
  

Comments

Ferruh Yigit Aug. 31, 2017, 3:53 p.m. UTC | #1
On 8/22/2017 11:21 PM, David Harton wrote:
> The i40e maintains a single MAC filter table for both
> unicast and multicast addresses.  The i40e_validate_mac_addr
> function was preventing multicast addresses from being added
> to the table via i40evf_add_mac_addr.  Fixed the issue by
> removing the multicast address check in i40e_validate_mac_addr.
> 
> Signed-off-by: David Harton <dharton@cisco.com>
> ---
>  drivers/net/i40e/base/i40e_common.c | 12 +++++-------
>  drivers/net/i40e/i40e_ethdev.c      |  3 ++-
>  2 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/i40e/base/i40e_common.c b/drivers/net/i40e/base/i40e_common.c
> index 900d379..9779854 100644
> --- a/drivers/net/i40e/base/i40e_common.c
> +++ b/drivers/net/i40e/base/i40e_common.c
> @@ -969,10 +969,10 @@ struct i40e_rx_ptype_decoded i40e_ptype_lookup[] = {
>  
>  
>  /**
> - * i40e_validate_mac_addr - Validate unicast MAC address
> + * i40e_validate_mac_addr - Validate MAC address
>   * @mac_addr: pointer to MAC address
>   *
> - * Tests a MAC address to ensure it is a valid Individual Address
> + * Tests a MAC address to ensure it is a valid Address
>   **/
>  enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr)
>  {
> @@ -980,13 +980,11 @@ enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr)
>  
>  	DEBUGFUNC("i40e_validate_mac_addr");
>  
> -	/* Broadcast addresses ARE multicast addresses
> -	 * Make sure it is not a multicast address
> +	/*
>  	 * Reject the zero address
>  	 */
> -	if (I40E_IS_MULTICAST(mac_addr) ||
> -	    (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
> -	      mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0))
> +	if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
> +	    mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)
>  		status = I40E_ERR_INVALID_MAC_ADDR;
>  
>  	return status;
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 5f26e24..00b6082 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -1199,7 +1199,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
>  
>  	/* Get and check the mac address */
>  	i40e_get_mac_addr(hw, hw->mac.addr);
> -	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS) {
> +	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS ||
> +	    I40E_IS_MULTICAST(hw->mac.addr)) {

As far as I can see this is to set PF permanent mac address during
init(), i40e_macaddr_add() can be used to set multicast address filters.
Why do you want to set multicast address as mac permanent address?

Any chance that you want to update i40evf_add_mac_addr() to let
multicast addresses?

>  		PMD_INIT_LOG(ERR, "mac address is not valid");
>  		ret = -EIO;
>  		goto err_get_mac_addr;
>
  
David Harton Aug. 31, 2017, 4:04 p.m. UTC | #2
> -----Original Message-----

> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]

> Sent: Thursday, August 31, 2017 11:54 AM

> To: David Harton (dharton) <dharton@cisco.com>; jingjing.wu@intel.com;

> beilei.xing@intel.com

> Cc: dev@dpdk.org

> Subject: Re: [dpdk-dev] [PATCH] i40e: fix i40e_validate_mac_addr to permit

> multicast addresses

> 

> On 8/22/2017 11:21 PM, David Harton wrote:

> > The i40e maintains a single MAC filter table for both unicast and

> > multicast addresses.  The i40e_validate_mac_addr function was

> > preventing multicast addresses from being added to the table via

> > i40evf_add_mac_addr.  Fixed the issue by removing the multicast

> > address check in i40e_validate_mac_addr.

> >

> > Signed-off-by: David Harton <dharton@cisco.com>

> > ---

> >  drivers/net/i40e/base/i40e_common.c | 12 +++++-------

> >  drivers/net/i40e/i40e_ethdev.c      |  3 ++-

> >  2 files changed, 7 insertions(+), 8 deletions(-)

> >

> > diff --git a/drivers/net/i40e/base/i40e_common.c

> > b/drivers/net/i40e/base/i40e_common.c

> > index 900d379..9779854 100644

> > --- a/drivers/net/i40e/base/i40e_common.c

> > +++ b/drivers/net/i40e/base/i40e_common.c

> > @@ -969,10 +969,10 @@ struct i40e_rx_ptype_decoded i40e_ptype_lookup[]

> > = {

> >

> >

> >  /**

> > - * i40e_validate_mac_addr - Validate unicast MAC address

> > + * i40e_validate_mac_addr - Validate MAC address

> >   * @mac_addr: pointer to MAC address

> >   *

> > - * Tests a MAC address to ensure it is a valid Individual Address

> > + * Tests a MAC address to ensure it is a valid Address

> >   **/

> >  enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr)  { @@

> > -980,13 +980,11 @@ enum i40e_status_code i40e_validate_mac_addr(u8

> > *mac_addr)

> >

> >  	DEBUGFUNC("i40e_validate_mac_addr");

> >

> > -	/* Broadcast addresses ARE multicast addresses

> > -	 * Make sure it is not a multicast address

> > +	/*

> >  	 * Reject the zero address

> >  	 */

> > -	if (I40E_IS_MULTICAST(mac_addr) ||

> > -	    (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&

> > -	      mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0))

> > +	if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&

> > +	    mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)

> >  		status = I40E_ERR_INVALID_MAC_ADDR;

> >

> >  	return status;

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

> > b/drivers/net/i40e/i40e_ethdev.c index 5f26e24..00b6082 100644

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

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

> > @@ -1199,7 +1199,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)

> >

> >  	/* Get and check the mac address */

> >  	i40e_get_mac_addr(hw, hw->mac.addr);

> > -	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS) {

> > +	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS ||

> > +	    I40E_IS_MULTICAST(hw->mac.addr)) {

> 

> As far as I can see this is to set PF permanent mac address during init(),

> i40e_macaddr_add() can be used to set multicast address filters.

> Why do you want to set multicast address as mac permanent address?

> 

> Any chance that you want to update i40evf_add_mac_addr() to let multicast

> addresses?


No.  I'm preserving the existing behavior here.  The previous call used to ensure that the permanent mac address here was both non-null and not a multi-cast address.

Since I removed the multi cast check from i40e_validate_mac_addr() I added the multicast check here.  If "not valid" or a multicast address fail.

Regards,
Dave

> 

> >  		PMD_INIT_LOG(ERR, "mac address is not valid");

> >  		ret = -EIO;

> >  		goto err_get_mac_addr;

> >
  
David Harton Sept. 8, 2017, 12:51 p.m. UTC | #3
Hi Jingjing/Beilei,

A kind reminder to review the patch and the discussion between 
Ferruh and myself.

Thanks,
Dave

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

> From: David Harton (dharton)

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

> > From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]

> >

> > On 8/22/2017 11:21 PM, David Harton wrote:

> > > The i40e maintains a single MAC filter table for both unicast and

> > > multicast addresses.  The i40e_validate_mac_addr function was

> > > preventing multicast addresses from being added to the table via

> > > i40evf_add_mac_addr.  Fixed the issue by removing the multicast

> > > address check in i40e_validate_mac_addr.

> > >

> > > Signed-off-by: David Harton <dharton@cisco.com>

> > > ---

> > >  drivers/net/i40e/base/i40e_common.c | 12 +++++-------

> > >  drivers/net/i40e/i40e_ethdev.c      |  3 ++-

> > >  2 files changed, 7 insertions(+), 8 deletions(-)

> > >

> > > diff --git a/drivers/net/i40e/base/i40e_common.c

> > > b/drivers/net/i40e/base/i40e_common.c

> > > index 900d379..9779854 100644

> > > --- a/drivers/net/i40e/base/i40e_common.c

> > > +++ b/drivers/net/i40e/base/i40e_common.c

> > > @@ -969,10 +969,10 @@ struct i40e_rx_ptype_decoded

> > > i40e_ptype_lookup[] = {

> > >

> > >

> > >  /**

> > > - * i40e_validate_mac_addr - Validate unicast MAC address

> > > + * i40e_validate_mac_addr - Validate MAC address

> > >   * @mac_addr: pointer to MAC address

> > >   *

> > > - * Tests a MAC address to ensure it is a valid Individual Address

> > > + * Tests a MAC address to ensure it is a valid Address

> > >   **/

> > >  enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr)  { @@

> > > -980,13 +980,11 @@ enum i40e_status_code i40e_validate_mac_addr(u8

> > > *mac_addr)

> > >

> > >  	DEBUGFUNC("i40e_validate_mac_addr");

> > >

> > > -	/* Broadcast addresses ARE multicast addresses

> > > -	 * Make sure it is not a multicast address

> > > +	/*

> > >  	 * Reject the zero address

> > >  	 */

> > > -	if (I40E_IS_MULTICAST(mac_addr) ||

> > > -	    (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&

> > > -	      mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0))

> > > +	if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&

> > > +	    mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)

> > >  		status = I40E_ERR_INVALID_MAC_ADDR;

> > >

> > >  	return status;

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

> > > b/drivers/net/i40e/i40e_ethdev.c index 5f26e24..00b6082 100644

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

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

> > > @@ -1199,7 +1199,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)

> > >

> > >  	/* Get and check the mac address */

> > >  	i40e_get_mac_addr(hw, hw->mac.addr);

> > > -	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS) {

> > > +	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS ||

> > > +	    I40E_IS_MULTICAST(hw->mac.addr)) {

> >

> > As far as I can see this is to set PF permanent mac address during

> > init(),

> > i40e_macaddr_add() can be used to set multicast address filters.

> > Why do you want to set multicast address as mac permanent address?

> >

> > Any chance that you want to update i40evf_add_mac_addr() to let

> > multicast addresses?

> 

> No.  I'm preserving the existing behavior here.  The previous call used to

> ensure that the permanent mac address here was both non-null and not a

> multi-cast address.

> 

> Since I removed the multi cast check from i40e_validate_mac_addr() I added

> the multicast check here.  If "not valid" or a multicast address fail.

> 

> Regards,

> Dave

> 

> >

> > >  		PMD_INIT_LOG(ERR, "mac address is not valid");

> > >  		ret = -EIO;

> > >  		goto err_get_mac_addr;

> > >
  
Ferruh Yigit Sept. 8, 2017, 12:56 p.m. UTC | #4
On 9/8/2017 1:51 PM, David Harton (dharton) wrote:
> Hi Jingjing/Beilei,
> 
> A kind reminder to review the patch and the discussion between 
> Ferruh and myself.

Hi David,

To clarify, your reply answered my concern, so I am OK, still I believe
this should be reviewed by driver maintainer.

Thanks,
ferruh

> 
> Thanks,
> Dave
> 
>> -----Original Message-----
>> From: David Harton (dharton)
>>> -----Original Message-----
>>> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
>>>
>>> On 8/22/2017 11:21 PM, David Harton wrote:
>>>> The i40e maintains a single MAC filter table for both unicast and
>>>> multicast addresses.  The i40e_validate_mac_addr function was
>>>> preventing multicast addresses from being added to the table via
>>>> i40evf_add_mac_addr.  Fixed the issue by removing the multicast
>>>> address check in i40e_validate_mac_addr.
>>>>
>>>> Signed-off-by: David Harton <dharton@cisco.com>
>>>> ---
>>>>  drivers/net/i40e/base/i40e_common.c | 12 +++++-------
>>>>  drivers/net/i40e/i40e_ethdev.c      |  3 ++-
>>>>  2 files changed, 7 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/drivers/net/i40e/base/i40e_common.c
>>>> b/drivers/net/i40e/base/i40e_common.c
>>>> index 900d379..9779854 100644
>>>> --- a/drivers/net/i40e/base/i40e_common.c
>>>> +++ b/drivers/net/i40e/base/i40e_common.c
>>>> @@ -969,10 +969,10 @@ struct i40e_rx_ptype_decoded
>>>> i40e_ptype_lookup[] = {
>>>>
>>>>
>>>>  /**
>>>> - * i40e_validate_mac_addr - Validate unicast MAC address
>>>> + * i40e_validate_mac_addr - Validate MAC address
>>>>   * @mac_addr: pointer to MAC address
>>>>   *
>>>> - * Tests a MAC address to ensure it is a valid Individual Address
>>>> + * Tests a MAC address to ensure it is a valid Address
>>>>   **/
>>>>  enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr)  { @@
>>>> -980,13 +980,11 @@ enum i40e_status_code i40e_validate_mac_addr(u8
>>>> *mac_addr)
>>>>
>>>>  	DEBUGFUNC("i40e_validate_mac_addr");
>>>>
>>>> -	/* Broadcast addresses ARE multicast addresses
>>>> -	 * Make sure it is not a multicast address
>>>> +	/*
>>>>  	 * Reject the zero address
>>>>  	 */
>>>> -	if (I40E_IS_MULTICAST(mac_addr) ||
>>>> -	    (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
>>>> -	      mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0))
>>>> +	if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
>>>> +	    mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)
>>>>  		status = I40E_ERR_INVALID_MAC_ADDR;
>>>>
>>>>  	return status;
>>>> diff --git a/drivers/net/i40e/i40e_ethdev.c
>>>> b/drivers/net/i40e/i40e_ethdev.c index 5f26e24..00b6082 100644
>>>> --- a/drivers/net/i40e/i40e_ethdev.c
>>>> +++ b/drivers/net/i40e/i40e_ethdev.c
>>>> @@ -1199,7 +1199,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
>>>>
>>>>  	/* Get and check the mac address */
>>>>  	i40e_get_mac_addr(hw, hw->mac.addr);
>>>> -	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS) {
>>>> +	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS ||
>>>> +	    I40E_IS_MULTICAST(hw->mac.addr)) {
>>>
>>> As far as I can see this is to set PF permanent mac address during
>>> init(),
>>> i40e_macaddr_add() can be used to set multicast address filters.
>>> Why do you want to set multicast address as mac permanent address?
>>>
>>> Any chance that you want to update i40evf_add_mac_addr() to let
>>> multicast addresses?
>>
>> No.  I'm preserving the existing behavior here.  The previous call used to
>> ensure that the permanent mac address here was both non-null and not a
>> multi-cast address.
>>
>> Since I removed the multi cast check from i40e_validate_mac_addr() I added
>> the multicast check here.  If "not valid" or a multicast address fail.
>>
>> Regards,
>> Dave
>>
>>>
>>>>  		PMD_INIT_LOG(ERR, "mac address is not valid");
>>>>  		ret = -EIO;
>>>>  		goto err_get_mac_addr;
>>>>
>
  
Xing, Beilei Sept. 11, 2017, 5:41 a.m. UTC | #5
Hi,

> -----Original Message-----
> From: David Harton [mailto:dharton@cisco.com]
> Sent: Wednesday, August 23, 2017 6:22 AM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org; David Harton <dharton@cisco.com>
> Subject: [PATCH] i40e: fix i40e_validate_mac_addr to permit multicast
> addresses
> 
> The i40e maintains a single MAC filter table for both unicast and multicast
> addresses.  The i40e_validate_mac_addr function was preventing multicast
> addresses from being added to the table via i40evf_add_mac_addr.  Fixed
> the issue by removing the multicast address check in
> i40e_validate_mac_addr.
> 

Maybe fix line is needed here.

> Signed-off-by: David Harton <dharton@cisco.com>
> ---
>  drivers/net/i40e/base/i40e_common.c | 12 +++++-------
>  drivers/net/i40e/i40e_ethdev.c      |  3 ++-
>  2 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/i40e/base/i40e_common.c
> b/drivers/net/i40e/base/i40e_common.c
> index 900d379..9779854 100644
> --- a/drivers/net/i40e/base/i40e_common.c
> +++ b/drivers/net/i40e/base/i40e_common.c
> @@ -969,10 +969,10 @@ struct i40e_rx_ptype_decoded
> i40e_ptype_lookup[] = {
> 
> 
>  /**
> - * i40e_validate_mac_addr - Validate unicast MAC address
> + * i40e_validate_mac_addr - Validate MAC address
>   * @mac_addr: pointer to MAC address
>   *
> - * Tests a MAC address to ensure it is a valid Individual Address
> + * Tests a MAC address to ensure it is a valid Address
>   **/
>  enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr)  { @@ -
> 980,13 +980,11 @@ enum i40e_status_code i40e_validate_mac_addr(u8
> *mac_addr)
> 
>  	DEBUGFUNC("i40e_validate_mac_addr");
> 
> -	/* Broadcast addresses ARE multicast addresses
> -	 * Make sure it is not a multicast address
> +	/*
>  	 * Reject the zero address
>  	 */
> -	if (I40E_IS_MULTICAST(mac_addr) ||
> -	    (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
> -	      mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0))
> +	if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
> +	    mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)
>  		status = I40E_ERR_INVALID_MAC_ADDR;
> 

We'd better not to change the base code which is from kernel driver. How about changing the i40evf_add_mac_addr function as following:
-	if (i40e_validate_mac_addr(addr->addr_bytes) != I40E_SUCCESS) {
+	if (is_zero_ether_addr (addr->addr_bytes) != I40E_SUCCESS) {

Then following modification in eth_i40e_dev_init function can be removed. But we should also pay attention to other functions which call
i40evf_add_mac_addr.

Beilei

>  	return status;
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 5f26e24..00b6082 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -1199,7 +1199,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
> 
>  	/* Get and check the mac address */
>  	i40e_get_mac_addr(hw, hw->mac.addr);
> -	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS) {
> +	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS ||
> +	    I40E_IS_MULTICAST(hw->mac.addr)) {
>  		PMD_INIT_LOG(ERR, "mac address is not valid");
>  		ret = -EIO;
>  		goto err_get_mac_addr;
> --
> 2.10.3.dirty
  
David Harton Sept. 11, 2017, 5:22 p.m. UTC | #6
Hi Beilei,

> -----Original Message-----
> From: Xing, Beilei [mailto:beilei.xing@intel.com]
> 
> Hi,
> 
> > -----Original Message-----
> > From: David Harton [mailto:dharton@cisco.com]
> >
> > The i40e maintains a single MAC filter table for both unicast and
> > multicast addresses.  The i40e_validate_mac_addr function was
> > preventing multicast addresses from being added to the table via
> > i40evf_add_mac_addr.  Fixed the issue by removing the multicast
> > address check in i40e_validate_mac_addr.
> >
> 
> Maybe fix line is needed here.

Please elaborate.  If feel this is a regression and you want 
me to add a fixline can you offer the offending commit?

> 
> > Signed-off-by: David Harton <dharton@cisco.com>
> > ---
> >  drivers/net/i40e/base/i40e_common.c | 12 +++++-------
> >  drivers/net/i40e/i40e_ethdev.c      |  3 ++-
> >  2 files changed, 7 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/i40e/base/i40e_common.c
> > b/drivers/net/i40e/base/i40e_common.c
> > index 900d379..9779854 100644
> > --- a/drivers/net/i40e/base/i40e_common.c
> > +++ b/drivers/net/i40e/base/i40e_common.c
> > @@ -969,10 +969,10 @@ struct i40e_rx_ptype_decoded i40e_ptype_lookup[]
> > = {
> >
> >
> >  /**
> > - * i40e_validate_mac_addr - Validate unicast MAC address
> > + * i40e_validate_mac_addr - Validate MAC address
> >   * @mac_addr: pointer to MAC address
> >   *
> > - * Tests a MAC address to ensure it is a valid Individual Address
> > + * Tests a MAC address to ensure it is a valid Address
> >   **/
> >  enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr)  { @@ -
> > 980,13 +980,11 @@ enum i40e_status_code i40e_validate_mac_addr(u8
> > *mac_addr)
> >
> >  	DEBUGFUNC("i40e_validate_mac_addr");
> >
> > -	/* Broadcast addresses ARE multicast addresses
> > -	 * Make sure it is not a multicast address
> > +	/*
> >  	 * Reject the zero address
> >  	 */
> > -	if (I40E_IS_MULTICAST(mac_addr) ||
> > -	    (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
> > -	      mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0))
> > +	if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
> > +	    mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)
> >  		status = I40E_ERR_INVALID_MAC_ADDR;
> >
> 
> We'd better not to change the base code which is from kernel driver. How
> about changing the i40evf_add_mac_addr function as following:
> -	if (i40e_validate_mac_addr(addr->addr_bytes) != I40E_SUCCESS) {
> +	if (is_zero_ether_addr (addr->addr_bytes) != I40E_SUCCESS) {
> 
> Then following modification in eth_i40e_dev_init function can be removed.
> But we should also pay attention to other functions which call
> i40evf_add_mac_addr.

Sure.  I'll post a new patch as suggested once the fixline question is answered.  

I was trying to fix the issue the way I did in case i40e passthru 
wanted to benefit.  Your suggestion will work for the VF as the only 
other caller for i40evf_add_mac_addr() performs its own macaddr validation.

Thanks,
Dave

> 
> Beilei
> 
> >  	return status;
> > diff --git a/drivers/net/i40e/i40e_ethdev.c
> > b/drivers/net/i40e/i40e_ethdev.c index 5f26e24..00b6082 100644
> > --- a/drivers/net/i40e/i40e_ethdev.c
> > +++ b/drivers/net/i40e/i40e_ethdev.c
> > @@ -1199,7 +1199,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
> >
> >  	/* Get and check the mac address */
> >  	i40e_get_mac_addr(hw, hw->mac.addr);
> > -	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS) {
> > +	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS ||
> > +	    I40E_IS_MULTICAST(hw->mac.addr)) {
> >  		PMD_INIT_LOG(ERR, "mac address is not valid");
> >  		ret = -EIO;
> >  		goto err_get_mac_addr;
> > --
> > 2.10.3.dirty
  
Xing, Beilei Sept. 12, 2017, 3 a.m. UTC | #7
> -----Original Message-----
> From: David Harton (dharton) [mailto:dharton@cisco.com]
> Sent: Tuesday, September 12, 2017 1:23 AM
> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH] i40e: fix i40e_validate_mac_addr to permit multicast
> addresses
> 
> Hi Beilei,
> 
> > -----Original Message-----
> > From: Xing, Beilei [mailto:beilei.xing@intel.com]
> >
> > Hi,
> >
> > > -----Original Message-----
> > > From: David Harton [mailto:dharton@cisco.com]
> > >
> > > The i40e maintains a single MAC filter table for both unicast and
> > > multicast addresses.  The i40e_validate_mac_addr function was
> > > preventing multicast addresses from being added to the table via
> > > i40evf_add_mac_addr.  Fixed the issue by removing the multicast
> > > address check in i40e_validate_mac_addr.
> > >
> >
> > Maybe fix line is needed here.
> 
> Please elaborate.  If feel this is a regression and you want me to add a fixline
> can you offer the offending commit?

I think these two commit are related:
commit 4861cde4611601ccc9d467675f9d7a10c3095b54
commit 97ac72aa71a93d5c9bc5dc3ef1d1a324f38e61c8

> 
> >
> > > Signed-off-by: David Harton <dharton@cisco.com>
> > > ---
> > >  drivers/net/i40e/base/i40e_common.c | 12 +++++-------
> > >  drivers/net/i40e/i40e_ethdev.c      |  3 ++-
> > >  2 files changed, 7 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/net/i40e/base/i40e_common.c
> > > b/drivers/net/i40e/base/i40e_common.c
> > > index 900d379..9779854 100644
> > > --- a/drivers/net/i40e/base/i40e_common.c
> > > +++ b/drivers/net/i40e/base/i40e_common.c
> > > @@ -969,10 +969,10 @@ struct i40e_rx_ptype_decoded
> > > i40e_ptype_lookup[] = {
> > >
> > >
> > >  /**
> > > - * i40e_validate_mac_addr - Validate unicast MAC address
> > > + * i40e_validate_mac_addr - Validate MAC address
> > >   * @mac_addr: pointer to MAC address
> > >   *
> > > - * Tests a MAC address to ensure it is a valid Individual Address
> > > + * Tests a MAC address to ensure it is a valid Address
> > >   **/
> > >  enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr)  { @@ -
> > > 980,13 +980,11 @@ enum i40e_status_code i40e_validate_mac_addr(u8
> > > *mac_addr)
> > >
> > >  	DEBUGFUNC("i40e_validate_mac_addr");
> > >
> > > -	/* Broadcast addresses ARE multicast addresses
> > > -	 * Make sure it is not a multicast address
> > > +	/*
> > >  	 * Reject the zero address
> > >  	 */
> > > -	if (I40E_IS_MULTICAST(mac_addr) ||
> > > -	    (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
> > > -	      mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0))
> > > +	if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
> > > +	    mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)
> > >  		status = I40E_ERR_INVALID_MAC_ADDR;
> > >
> >
> > We'd better not to change the base code which is from kernel driver.
> > How about changing the i40evf_add_mac_addr function as following:
> > -	if (i40e_validate_mac_addr(addr->addr_bytes) != I40E_SUCCESS) {
> > +	if (is_zero_ether_addr (addr->addr_bytes) != I40E_SUCCESS) {
> >
> > Then following modification in eth_i40e_dev_init function can be removed.
> > But we should also pay attention to other functions which call
> > i40evf_add_mac_addr.
> 
> Sure.  I'll post a new patch as suggested once the fixline question is answered.
> 
> I was trying to fix the issue the way I did in case i40e passthru wanted to
> benefit.  Your suggestion will work for the VF as the only other caller for
> i40evf_add_mac_addr() performs its own macaddr validation.
> 
> Thanks,
> Dave
> 
> >
> > Beilei
> >
> > >  	return status;
> > > diff --git a/drivers/net/i40e/i40e_ethdev.c
> > > b/drivers/net/i40e/i40e_ethdev.c index 5f26e24..00b6082 100644
> > > --- a/drivers/net/i40e/i40e_ethdev.c
> > > +++ b/drivers/net/i40e/i40e_ethdev.c
> > > @@ -1199,7 +1199,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
> > >
> > >  	/* Get and check the mac address */
> > >  	i40e_get_mac_addr(hw, hw->mac.addr);
> > > -	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS) {
> > > +	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS ||
> > > +	    I40E_IS_MULTICAST(hw->mac.addr)) {
> > >  		PMD_INIT_LOG(ERR, "mac address is not valid");
> > >  		ret = -EIO;
> > >  		goto err_get_mac_addr;
> > > --
> > > 2.10.3.dirty
  

Patch

diff --git a/drivers/net/i40e/base/i40e_common.c b/drivers/net/i40e/base/i40e_common.c
index 900d379..9779854 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -969,10 +969,10 @@  struct i40e_rx_ptype_decoded i40e_ptype_lookup[] = {
 
 
 /**
- * i40e_validate_mac_addr - Validate unicast MAC address
+ * i40e_validate_mac_addr - Validate MAC address
  * @mac_addr: pointer to MAC address
  *
- * Tests a MAC address to ensure it is a valid Individual Address
+ * Tests a MAC address to ensure it is a valid Address
  **/
 enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr)
 {
@@ -980,13 +980,11 @@  enum i40e_status_code i40e_validate_mac_addr(u8 *mac_addr)
 
 	DEBUGFUNC("i40e_validate_mac_addr");
 
-	/* Broadcast addresses ARE multicast addresses
-	 * Make sure it is not a multicast address
+	/*
 	 * Reject the zero address
 	 */
-	if (I40E_IS_MULTICAST(mac_addr) ||
-	    (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
-	      mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0))
+	if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&
+	    mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)
 		status = I40E_ERR_INVALID_MAC_ADDR;
 
 	return status;
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 5f26e24..00b6082 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1199,7 +1199,8 @@  eth_i40e_dev_init(struct rte_eth_dev *dev)
 
 	/* Get and check the mac address */
 	i40e_get_mac_addr(hw, hw->mac.addr);
-	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS) {
+	if (i40e_validate_mac_addr(hw->mac.addr) != I40E_SUCCESS ||
+	    I40E_IS_MULTICAST(hw->mac.addr)) {
 		PMD_INIT_LOG(ERR, "mac address is not valid");
 		ret = -EIO;
 		goto err_get_mac_addr;