From: Wenzhuo Lu Date: Fri, 27 Nov 2015 06:07:35 +0000 (+0800) Subject: igbvf: fix MAC address if none assigned by PF X-Git-Tag: spdx-start~7927 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2a3cf07108b468467ea15bbe49e3569eb73b85df;p=dpdk.git igbvf: fix MAC address if none assigned by PF If use DPDK PF + DPDK VF on igb NICs, we find the MAC address of VF port is always 0. Because we forget to give it a value if this MAC address is not assigned by PF. This patch'll assign a random MAC address to igb VF port as ixgbe does. Signed-off-by: Wenzhuo Lu --- diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst index 0c6aa0476c..511d7a0b40 100644 --- a/doc/guides/rel_notes/release_2_2.rst +++ b/doc/guides/rel_notes/release_2_2.rst @@ -151,6 +151,10 @@ Drivers VF needs the PF interrupt support initialized even if not started. +* **igb: Fixed VF MAC address when using with DPDK PF.** + + Assign a random MAC address in VF when not assigned by PF. + * **ixgbe: Fixed issue with X550 DCB.** Fixed a DCB issue with x550 where for 8 TCs (Traffic Classes), if a packet diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 31452ae970..6c2aa8c688 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -846,6 +846,7 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev) struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); int diag; + struct ether_addr *perm_addr = (struct ether_addr *)hw->mac.perm_addr; PMD_INIT_FUNC_TRACE(); @@ -898,6 +899,26 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev) return -ENOMEM; } + /* Generate a random MAC address, if none was assigned by PF. */ + if (is_zero_ether_addr(perm_addr)) { + eth_random_addr(perm_addr->addr_bytes); + diag = e1000_rar_set(hw, perm_addr->addr_bytes, 0); + if (diag) { + rte_free(eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs = NULL; + return diag; + } + PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF"); + PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address " + "%02x:%02x:%02x:%02x:%02x:%02x", + perm_addr->addr_bytes[0], + perm_addr->addr_bytes[1], + perm_addr->addr_bytes[2], + perm_addr->addr_bytes[3], + perm_addr->addr_bytes[4], + perm_addr->addr_bytes[5]); + } + /* Copy the permanent MAC address */ ether_addr_copy((struct ether_addr *) hw->mac.perm_addr, ð_dev->data->mac_addrs[0]);