From b4de6c49e569c7ca91bf0d4c25cdb6eeca9c9529 Mon Sep 17 00:00:00 2001 From: Mark Starovoytov Date: Sat, 9 May 2020 09:47:00 +0300 Subject: net: atlantic: unify MAC generation This patch unifies invalid MAC address handling with other drivers. Basically we've switched to using standard APIs (is_valid_ether_addr / eth_hw_addr_random) where possible. It's worth noting that some of engineering Aquantia NICs might be provisioned with a partially zeroed out MAC, which is still invalid, but not caught by is_valid_ether_addr(), so we've added a special handling for this case. Also adding a warning in case of fallback to random MAC, because this shouldn't be needed on production NICs, they should all be provisioned with unique MAC. NB! Default systemd/udevd configuration is 'MACAddressPolicy=persistent'. This causes MAC address to be persisted across driver reloads and reboots. We had to change it to 'none' for verification purposes. Signed-off-by: Mark Starovoytov Signed-off-by: Igor Russkikh Signed-off-by: Jakub Kicinski --- .../aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'drivers/net/ethernet/aquantia/atlantic/hw_atl') diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c index 017364486703..eeedd8c90067 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c @@ -283,8 +283,6 @@ static int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac) u32 efuse_addr = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_EFUSE_ADDR); u32 mac_addr[2] = { 0 }; int err = 0; - u32 h = 0U; - u32 l = 0U; if (efuse_addr != 0) { err = hw_atl_utils_fw_downld_dwords(self, @@ -299,26 +297,6 @@ static int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac) ether_addr_copy(mac, (u8 *)mac_addr); - if ((mac[0] & 0x01U) || ((mac[0] | mac[1] | mac[2]) == 0x00U)) { - unsigned int rnd = 0; - - get_random_bytes(&rnd, sizeof(unsigned int)); - - l = 0xE3000000U | (0xFFFFU & rnd) | (0x00 << 16); - h = 0x8001300EU; - - mac[5] = (u8)(0xFFU & l); - l >>= 8; - mac[4] = (u8)(0xFFU & l); - l >>= 8; - mac[3] = (u8)(0xFFU & l); - l >>= 8; - mac[2] = (u8)(0xFFU & l); - mac[1] = (u8)(0xFFU & h); - h >>= 8; - mac[0] = (u8)(0xFFU & h); - } - return err; } -- cgit v1.2.3-59-g8ed1b