diff mbox

[dpdk-dev,3/3,v2] ixgbe: fix setting of VF MAC address

Message ID 1456498163-26619-4-git-send-email-bernard.iremonger@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Bruce Richardson
Headers show

Commit Message

Iremonger, Bernard Feb. 26, 2016, 2:49 p.m. UTC
Fix setting of VF MAC address to allow a zero address.
Reprogram the RAR[0] with a zero MAC address, to ensure
ensure that the VF traffic goes to the PF after stop,
close and detach of the VF.

Fixes: af75078fece3 ("first public release")
Fixes: 00e30184daa0 ("ixgbe: add PF support")

ixgbe: don't overwrite perm addr
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 10 +++++++++-
 drivers/net/ixgbe/ixgbe_pf.c     |  7 ++++---
 2 files changed, 13 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 759177a..5608f67 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -3902,6 +3902,7 @@  static void
 ixgbevf_dev_close(struct rte_eth_dev *dev)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ether_addr *addr = (struct ether_addr *)hw->mac.addr;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -3911,7 +3912,14 @@  ixgbevf_dev_close(struct rte_eth_dev *dev)
 
 	ixgbe_dev_free_queues(dev);
 
-	/* reprogram the RAR[0] in case user changed it. */
+	memset(addr->addr_bytes, 0, ETHER_ADDR_LEN);
+
+	/**
+	 * reprogram the RAR[0] with a zero mac address.
+	 * to ensure that the VF traffic goes to the PF
+	 * after stop, close and detach of the VF
+	 **/
+
 	ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
 }
 
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index 2ffbd1f..e5cfd05 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -1,7 +1,7 @@ 
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -445,8 +445,9 @@  ixgbe_vf_set_mac_addr(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 	int rar_entry = hw->mac.num_rar_entries - (vf + 1);
 	uint8_t *new_mac = (uint8_t *)(&msgbuf[1]);
 
-	if (is_valid_assigned_ether_addr((struct ether_addr*)new_mac)) {
-		rte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac, 6);
+	if (is_unicast_ether_addr((struct ether_addr *)new_mac)) {
+		if (!is_zero_ether_addr((struct ether_addr *)new_mac))
+			rte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac, 6);
 		return hw->mac.ops.set_rar(hw, rar_entry, new_mac, vf, IXGBE_RAH_AV);
 	}
 	return -1;