Skip to content

Commit 3874d6a

Browse files
Jeffrey Huangdavem330
authored andcommitted
bnxt_en: Improve bnxt_vf_update_mac().
Allow the VF to setup its own MAC address if the PF has not administratively set it for the VF. To do that, we should always store the MAC address from the firmware. There are 2 cases: 1. The MAC address is valid. This MAC address is assigned by the PF and it needs to override the current VF MAC address. 2. The MAC address is zero. The VF will use a random MAC address by default. By storing this 0 MAC address in the VF structure, it will allow the VF user to change the MAC address later using ndo_set_mac_address() when it sees that the stored MAC address is 0. v2: Expanded descriptions and added more comments. Signed-off-by: Jeffrey Huang <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0c92c94 commit 3874d6a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -809,13 +809,19 @@ void bnxt_update_vf_mac(struct bnxt *bp)
809809
if (_hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT))
810810
goto update_vf_mac_exit;
811811

812-
if (!is_valid_ether_addr(resp->perm_mac_address))
813-
goto update_vf_mac_exit;
814-
812+
/* Store MAC address from the firmware. There are 2 cases:
813+
* 1. MAC address is valid. It is assigned from the PF and we
814+
* need to override the current VF MAC address with it.
815+
* 2. MAC address is zero. The VF will use a random MAC address by
816+
* default but the stored zero MAC will allow the VF user to change
817+
* the random MAC address using ndo_set_mac_address() if he wants.
818+
*/
815819
if (!ether_addr_equal(resp->perm_mac_address, bp->vf.mac_addr))
816820
memcpy(bp->vf.mac_addr, resp->perm_mac_address, ETH_ALEN);
817-
/* overwrite netdev dev_adr with admin VF MAC */
818-
memcpy(bp->dev->dev_addr, bp->vf.mac_addr, ETH_ALEN);
821+
822+
/* overwrite netdev dev_addr with admin VF MAC */
823+
if (is_valid_ether_addr(bp->vf.mac_addr))
824+
memcpy(bp->dev->dev_addr, bp->vf.mac_addr, ETH_ALEN);
819825
update_vf_mac_exit:
820826
mutex_unlock(&bp->hwrm_cmd_lock);
821827
}

0 commit comments

Comments
 (0)