All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] i40e: fix setting of default MAC address
@ 2016-11-24 12:34 Igor Ryzhov
  2016-12-01  9:52 ` Igor Ryzhov
  2016-12-02  3:10 ` Wu, Jingjing
  0 siblings, 2 replies; 3+ messages in thread
From: Igor Ryzhov @ 2016-11-24 12:34 UTC (permalink / raw)
  To: dev; +Cc: helin.zhang, jingjing.wu

While testing X710 cards in our lab I found that setting of default MAC address
doesn't work correctly for i40e driver. I compared DPDK driver implementation
with Linux driver implementation and found that a lot of code is lost in DPDK.
I tried to make DPDK implementation similar to Linux implementation and it
worked for me – now everything is working. But I'm not sure that my changes are
correct so, please, maintainers, check the patch very careful.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
---
 drivers/net/i40e/i40e_ethdev.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 67778ba..b73f9c8 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -9694,6 +9694,7 @@ static int i40e_get_eeprom(struct rte_eth_dev *dev,
 static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
 				      struct ether_addr *mac_addr)
 {
+	struct i40e_vsi *vsi = I40E_DEV_PRIVATE_TO_MAIN_VSI(dev->data->dev_private);
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	if (!is_valid_assigned_ether_addr(mac_addr)) {
@@ -9701,8 +9702,33 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
 		return;
 	}
 
-	/* Flags: 0x3 updates port address */
-	i40e_aq_mac_address_write(hw, 0x3, mac_addr->addr_bytes, NULL);
+	i40e_aq_mac_address_write(hw, I40E_AQC_WRITE_TYPE_LAA_WOL, mac_addr->addr_bytes, NULL);
+
+	if (!memcmp(&dev->data->mac_addrs[0].addr_bytes, hw->mac.addr, ETH_ADDR_LEN)) {
+		struct i40e_aqc_remove_macvlan_element_data element;
+
+		memset(&element, 0, sizeof(element));
+		memcpy(element.mac_addr, &dev->data->mac_addrs[0].addr_bytes, ETH_ADDR_LEN);
+		element.flags = I40E_AQC_MACVLAN_DEL_PERFECT_MATCH;
+		i40e_aq_remove_macvlan(hw, vsi->seid, &element, 1, NULL);
+	} else {
+		i40e_vsi_delete_mac(vsi, &dev->data->mac_addrs[0]);
+	}
+
+	if (!memcmp(mac_addr->addr_bytes, hw->mac.addr, ETH_ADDR_LEN)) {
+		struct i40e_aqc_add_macvlan_element_data element;
+
+		memset(&element, 0, sizeof(element));
+		memcpy(element.mac_addr, hw->mac.addr, ETH_ADDR_LEN);
+		element.flags = CPU_TO_LE16(I40E_AQC_MACVLAN_ADD_PERFECT_MATCH);
+		i40e_aq_add_macvlan(hw, vsi->seid, &element, 1, NULL);
+	} else {
+		struct i40e_mac_filter_info filter;
+
+		memcpy(&filter.mac_addr, mac_addr, ETH_ADDR_LEN);
+		filter.filter_type = RTE_MAC_PERFECT_MATCH;
+		i40e_vsi_add_mac(vsi, &filter);
+	}
 }
 
 static int
-- 
2.6.4

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

* Re: [RFC PATCH] i40e: fix setting of default MAC address
  2016-11-24 12:34 [RFC PATCH] i40e: fix setting of default MAC address Igor Ryzhov
@ 2016-12-01  9:52 ` Igor Ryzhov
  2016-12-02  3:10 ` Wu, Jingjing
  1 sibling, 0 replies; 3+ messages in thread
From: Igor Ryzhov @ 2016-12-01  9:52 UTC (permalink / raw)
  To: dev; +Cc: Helin Zhang, jingjing.wu

Ping.

On Thu, Nov 24, 2016 at 3:34 PM, Igor Ryzhov <iryzhov@nfware.com> wrote:

> While testing X710 cards in our lab I found that setting of default MAC
> address
> doesn't work correctly for i40e driver. I compared DPDK driver
> implementation
> with Linux driver implementation and found that a lot of code is lost in
> DPDK.
> I tried to make DPDK implementation similar to Linux implementation and it
> worked for me – now everything is working. But I'm not sure that my
> changes are
> correct so, please, maintainers, check the patch very careful.
>
> Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c | 30 ++++++++++++++++++++++++++++--
>  1 file changed, 28 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_
> ethdev.c
> index 67778ba..b73f9c8 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -9694,6 +9694,7 @@ static int i40e_get_eeprom(struct rte_eth_dev *dev,
>  static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
>                                       struct ether_addr *mac_addr)
>  {
> +       struct i40e_vsi *vsi = I40E_DEV_PRIVATE_TO_MAIN_VSI(
> dev->data->dev_private);
>         struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->
> data->dev_private);
>
>         if (!is_valid_assigned_ether_addr(mac_addr)) {
> @@ -9701,8 +9702,33 @@ static void i40e_set_default_mac_addr(struct
> rte_eth_dev *dev,
>                 return;
>         }
>
> -       /* Flags: 0x3 updates port address */
> -       i40e_aq_mac_address_write(hw, 0x3, mac_addr->addr_bytes, NULL);
> +       i40e_aq_mac_address_write(hw, I40E_AQC_WRITE_TYPE_LAA_WOL,
> mac_addr->addr_bytes, NULL);
> +
> +       if (!memcmp(&dev->data->mac_addrs[0].addr_bytes, hw->mac.addr,
> ETH_ADDR_LEN)) {
> +               struct i40e_aqc_remove_macvlan_element_data element;
> +
> +               memset(&element, 0, sizeof(element));
> +               memcpy(element.mac_addr, &dev->data->mac_addrs[0].addr_bytes,
> ETH_ADDR_LEN);
> +               element.flags = I40E_AQC_MACVLAN_DEL_PERFECT_MATCH;
> +               i40e_aq_remove_macvlan(hw, vsi->seid, &element, 1, NULL);
> +       } else {
> +               i40e_vsi_delete_mac(vsi, &dev->data->mac_addrs[0]);
> +       }
> +
> +       if (!memcmp(mac_addr->addr_bytes, hw->mac.addr, ETH_ADDR_LEN)) {
> +               struct i40e_aqc_add_macvlan_element_data element;
> +
> +               memset(&element, 0, sizeof(element));
> +               memcpy(element.mac_addr, hw->mac.addr, ETH_ADDR_LEN);
> +               element.flags = CPU_TO_LE16(I40E_AQC_MACVLAN_
> ADD_PERFECT_MATCH);
> +               i40e_aq_add_macvlan(hw, vsi->seid, &element, 1, NULL);
> +       } else {
> +               struct i40e_mac_filter_info filter;
> +
> +               memcpy(&filter.mac_addr, mac_addr, ETH_ADDR_LEN);
> +               filter.filter_type = RTE_MAC_PERFECT_MATCH;
> +               i40e_vsi_add_mac(vsi, &filter);
> +       }
>  }
>
>  static int
> --
> 2.6.4
>
>

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

* Re: [RFC PATCH] i40e: fix setting of default MAC address
  2016-11-24 12:34 [RFC PATCH] i40e: fix setting of default MAC address Igor Ryzhov
  2016-12-01  9:52 ` Igor Ryzhov
@ 2016-12-02  3:10 ` Wu, Jingjing
  1 sibling, 0 replies; 3+ messages in thread
From: Wu, Jingjing @ 2016-12-02  3:10 UTC (permalink / raw)
  To: Igor Ryzhov, dev; +Cc: Zhang, Helin

Hi, Igor

Thanks for your contribute, my comments are in below, thanks.

> -----Original Message-----
> From: Igor Ryzhov [mailto:iryzhov@nfware.com]
> Sent: Thursday, November 24, 2016 8:35 PM
> To: dev@dpdk.org
> Cc: Zhang, Helin <helin.zhang@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Subject: [RFC PATCH] i40e: fix setting of default MAC address
> 
> While testing X710 cards in our lab I found that setting of default MAC
> address doesn't work correctly for i40e driver. I compared DPDK driver
> implementation with Linux driver implementation and found that a lot of
> code is lost in DPDK.
> I tried to make DPDK implementation similar to Linux implementation and it
> worked for me – now everything is working. But I'm not sure that my
> changes are correct so, please, maintainers, check the patch very careful.
> 
> Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c | 30 ++++++++++++++++++++++++++++--
>  1 file changed, 28 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 67778ba..b73f9c8 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -9694,6 +9694,7 @@ static int i40e_get_eeprom(struct rte_eth_dev
> *dev,  static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
>  				      struct ether_addr *mac_addr)
>  {
> +	struct i40e_vsi *vsi =
> +I40E_DEV_PRIVATE_TO_MAIN_VSI(dev->data->dev_private);
>  	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
> 
>  	if (!is_valid_assigned_ether_addr(mac_addr)) { @@ -9701,8 +9702,33
> @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
>  		return;
>  	}
> 
> -	/* Flags: 0x3 updates port address */
> -	i40e_aq_mac_address_write(hw, 0x3, mac_addr->addr_bytes,
> NULL);
> +	i40e_aq_mac_address_write(hw, I40E_AQC_WRITE_TYPE_LAA_WOL,
> +mac_addr->addr_bytes, NULL);
> +
> +	if (!memcmp(&dev->data->mac_addrs[0].addr_bytes, hw-
> >mac.addr, ETH_ADDR_LEN)) {
> +		struct i40e_aqc_remove_macvlan_element_data element;
> +
> +		memset(&element, 0, sizeof(element));
> +		memcpy(element.mac_addr, &dev->data-
> >mac_addrs[0].addr_bytes, ETH_ADDR_LEN);
> +		element.flags = I40E_AQC_MACVLAN_DEL_PERFECT_MATCH;
> +		i40e_aq_remove_macvlan(hw, vsi->seid, &element, 1, NULL);
> +	} else {
> +		i40e_vsi_delete_mac(vsi, &dev->data->mac_addrs[0]);
> +	}
> +
> +	if (!memcmp(mac_addr->addr_bytes, hw->mac.addr,
> ETH_ADDR_LEN)) {

In rte_eth_dev_default_mac_addr_set, before call dev_ops->mac_addr_set,
The dev->data->mac_addrs[0] is already set to the input addr.

So the if loop is the same as above if, why not merge them? 


If you look the code in eth_i40e_dev_init, you will found the dev->data->mac_addrs[0]
Is just the hw->mac.addr. And I think we need to make them same all the time.
So hw->mac.addr may also need to be updated.


Thanks for figure it out!

/Jingjing

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

end of thread, other threads:[~2016-12-02  3:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-24 12:34 [RFC PATCH] i40e: fix setting of default MAC address Igor Ryzhov
2016-12-01  9:52 ` Igor Ryzhov
2016-12-02  3:10 ` Wu, Jingjing

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.