diff mbox series

wifi: rtw88: Use random MAC when efuse MAC invalid

Message ID 20231208150739.129753-1-macroalpha82@gmail.com (mailing list archive)
State Accepted
Commit 0a999d82b782b55626e370ae2006dd51b48923ee
Delegated to: Kalle Valo
Headers show
Series wifi: rtw88: Use random MAC when efuse MAC invalid | expand

Commit Message

Chris Morgan Dec. 8, 2023, 3:07 p.m. UTC
From: Chris Morgan <macromorgan@hotmail.com>

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>
---
 drivers/net/wireless/realtek/rtw88/main.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Larry Finger Dec. 8, 2023, 4:17 p.m. UTC | #1
On 12/8/23 09:07, Chris Morgan wrote:
> From: Chris Morgan <macromorgan@hotmail.com>
> 
> 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>
> ---
>   drivers/net/wireless/realtek/rtw88/main.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
> index 4a33d2e47f33..6d22628129d0 100644
> --- a/drivers/net/wireless/realtek/rtw88/main.c
> +++ b/drivers/net/wireless/realtek/rtw88/main.c
> @@ -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);
>   

Reviewed by Larry Finger <Larry.Finger@lwfinger.net>

Thanks for this patch.

There are a number of SDIO devices known to me with improperly coded EFUSE 
values. It seems that RTW8723DS chips perform poorly even when given a valid MAC 
address. Is this also true for RTW8821CS chips?

Larry
Chris Morgan Dec. 8, 2023, 8:34 p.m. UTC | #2
On Fri, Dec 08, 2023 at 10:17:00AM -0600, Larry Finger wrote:
> On 12/8/23 09:07, Chris Morgan wrote:
> > From: Chris Morgan <macromorgan@hotmail.com>
> > 
> > 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>
> > ---
> >   drivers/net/wireless/realtek/rtw88/main.c | 5 +++++
> >   1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
> > index 4a33d2e47f33..6d22628129d0 100644
> > --- a/drivers/net/wireless/realtek/rtw88/main.c
> > +++ b/drivers/net/wireless/realtek/rtw88/main.c
> > @@ -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);
> 
> Reviewed by Larry Finger <Larry.Finger@lwfinger.net>
> 
> Thanks for this patch.
> 
> There are a number of SDIO devices known to me with improperly coded EFUSE
> values. It seems that RTW8723DS chips perform poorly even when given a valid
> MAC address. Is this also true for RTW8821CS chips?

The RTW8821CS I have in this specific case doesn't perform all that
well, but it also has sub-optimal antennas. I'm not noticing any major
performance difference between the devices with a valid MAC address
and the device I have without one. They're both pulling about 8MB/s
over scp on a 5GHz 802.11ac(ax wifi gateway) network.

Thank you,
Chris

> 
> Larry
>
Ping-Ke Shih Dec. 11, 2023, 12:53 a.m. UTC | #3
> -----Original Message-----
> From: Chris Morgan <macromorgan@hotmail.com>
> Sent: Saturday, December 9, 2023 4:34 AM
> To: Larry Finger <Larry.Finger@lwfinger.net>
> Cc: Chris Morgan <macroalpha82@gmail.com>; linux-wireless@vger.kernel.org; kvalo@kernel.org; Ping-Ke Shih
> <pkshih@realtek.com>
> Subject: Re: [PATCH] wifi: rtw88: Use random MAC when efuse MAC invalid
> 
> 
> On Fri, Dec 08, 2023 at 10:17:00AM -0600, Larry Finger wrote:
> > On 12/8/23 09:07, Chris Morgan wrote:
> > > From: Chris Morgan <macromorgan@hotmail.com>
> > >
> > > 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>
> > > ---
> > >   drivers/net/wireless/realtek/rtw88/main.c | 5 +++++
> > >   1 file changed, 5 insertions(+)
> > >
> > > diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
> > > index 4a33d2e47f33..6d22628129d0 100644
> > > --- a/drivers/net/wireless/realtek/rtw88/main.c
> > > +++ b/drivers/net/wireless/realtek/rtw88/main.c
> > > @@ -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);
> >
> > Reviewed by Larry Finger <Larry.Finger@lwfinger.net>

Acked-by: Ping-Ke Shih <pkshih@realtek.com>

Patch looks good to me. At least, it can have a valid MAC address. 


> >
> > Thanks for this patch.
> >
> > There are a number of SDIO devices known to me with improperly coded EFUSE
> > values. It seems that RTW8723DS chips perform poorly even when given a valid
> > MAC address. Is this also true for RTW8821CS chips?
> 
> The RTW8821CS I have in this specific case doesn't perform all that
> well, but it also has sub-optimal antennas. I'm not noticing any major
> performance difference between the devices with a valid MAC address
> and the device I have without one. They're both pulling about 8MB/s
> over scp on a 5GHz 802.11ac(ax wifi gateway) network.
> 

It seems like we still need to have a set of _default_ efuse values.
Kalle Valo Dec. 12, 2023, 3:34 p.m. UTC | #4
Chris Morgan <macroalpha82@gmail.com> wrote:

> From: Chris Morgan <macromorgan@hotmail.com>
> 
> 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>

Patch applied to wireless-next.git, thanks.

0a999d82b782 wifi: rtw88: Use random MAC when efuse MAC invalid
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index 4a33d2e47f33..6d22628129d0 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -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);