wifi: rtw88: Use random MAC when efuse MAC invalid
authorChris Morgan <macromorgan@hotmail.com>
Fri, 8 Dec 2023 15:07:39 +0000 (09:07 -0600)
committerKalle Valo <kvalo@kernel.org>
Tue, 12 Dec 2023 15:34:41 +0000 (17:34 +0200)
When the MAC address read from the efuse data is invalid, warn the
user and use a random MAC address instead.

On a device I am currently using (Anbernic RG-ARC) with a rtw8821cs
the efuse appears to be incompletely/improperly programmed. The MAC
address reads as ff:ff:ff:ff:ff:ff. When networkmanager attempts to
initiate a connection (and I haven't hard-coded a MAC address or
set it to random) it fails to establish a connection.

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231208150739.129753-1-macroalpha82@gmail.com
drivers/net/wireless/realtek/rtw88/main.c

index 4a33d2e47f33ff59751fe4ff95de3e1179dd8300..6d22628129d0d5d0abf2e4259be1087fac26e320 100644 (file)
@@ -2008,6 +2008,11 @@ static int rtw_chip_efuse_info_setup(struct rtw_dev *rtwdev)
        efuse->ext_pa_5g = efuse->pa_type_5g & BIT(0) ? 1 : 0;
        efuse->ext_lna_2g = efuse->lna_type_5g & BIT(3) ? 1 : 0;
 
+       if (!is_valid_ether_addr(efuse->addr)) {
+               eth_random_addr(efuse->addr);
+               dev_warn(rtwdev->dev, "efuse MAC invalid, using random\n");
+       }
+
 out_disable:
        rtw_chip_efuse_disable(rtwdev);