diff mbox series

wifi: wilc1000: Set MAC after operation mode

Message ID 20240926195308.2823595-1-marex@denx.de (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series wifi: wilc1000: Set MAC after operation mode | expand

Commit Message

Marek Vasut Sept. 26, 2024, 7:52 p.m. UTC
It seems it is necessary to set WILC MAC address after operation mode,
otherwise the MAC address of the WILC MAC is reset back to what is in
nvmem. This causes a failure to associate with AP after the WILC MAC
address was overridden by userspace.

Test case:
"
ap$ cat << EOF > hostap.conf
interface=wlan0
ssid=ssid
hw_mode=g
channel=6
wpa=2
wpa_passphrase=pass
wpa_key_mgmt=WPA-PSK
EOF
ap$ hostapd -d hostap.conf
ap$ ifconfig wlan0 10.0.0.1
"

"
sta$ ifconfig wlan0 hw ether 00:11:22:33:44:55
sta$ wpa_supplicant -i wlan0 -c <(wpa_passphrase ssid pass)
sta$ ifconfig wlan0 10.0.0.2
sta$ ping 10.0.0.1 # fails without this patch
"

AP still indicates SA with original MAC address from nvmem without this patch:
"
nl80211: RX frame da=ff:ff:ff:ff:ff:ff sa=60:01:23:45:67:89 bssid=ff:ff:ff:ff:ff:ff ...
                                          ^^^^^^^^^^^^^^^^^
"

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Ajay Singh <ajay.kathat@microchip.com>
Cc: Alexis Lothoré <alexis.lothore@bootlin.com>
Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Cc: Kalle Valo <kvalo@kernel.org>
Cc: Marek Vasut <marex@denx.de>
Cc: linux-wireless@vger.kernel.org
---
 drivers/net/wireless/microchip/wilc1000/netdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Alexis Lothoré Oct. 3, 2024, 12:32 p.m. UTC | #1
Hello Marek,

On 9/26/24 21:52, Marek Vasut wrote:
> It seems it is necessary to set WILC MAC address after operation mode,
> otherwise the MAC address of the WILC MAC is reset back to what is in
> nvmem. This causes a failure to associate with AP after the WILC MAC
> address was overridden by userspace.
> 
> Test case:
> "
> ap$ cat << EOF > hostap.conf
> interface=wlan0
> ssid=ssid
> hw_mode=g
> channel=6
> wpa=2
> wpa_passphrase=pass
> wpa_key_mgmt=WPA-PSK
> EOF
> ap$ hostapd -d hostap.conf
> ap$ ifconfig wlan0 10.0.0.1
> "
> 
> "
> sta$ ifconfig wlan0 hw ether 00:11:22:33:44:55
> sta$ wpa_supplicant -i wlan0 -c <(wpa_passphrase ssid pass)
> sta$ ifconfig wlan0 10.0.0.2
> sta$ ping 10.0.0.1 # fails without this patch
> "
> 
> AP still indicates SA with original MAC address from nvmem without this patch:
> "
> nl80211: RX frame da=ff:ff:ff:ff:ff:ff sa=60:01:23:45:67:89 bssid=ff:ff:ff:ff:ff:ff ...
>                                           ^^^^^^^^^^^^^^^^^
> "

Good catch, thanks for the fix. I tracked a bit the issue history and it seems
to have been introduced by my recent change about reading the mac address early
from the chip nvmem (to set correctly mac address reported to userspace once net
device has been registered). I indeed reproduce the issue, and reverting the
commit below makes it disappear, so the following can be added:

Fixes: 83d9b54ee5d4 ("wifi: wilc1000: read MAC address from fuse at probe")

> Signed-off-by: Marek Vasut <marex@denx.de>

Tested-by: Alexis Lothoré <alexis.lothore@bootlin.com>

Thanks,

Alexis
Marek Vasut Oct. 3, 2024, 1:25 p.m. UTC | #2
On 10/3/24 2:32 PM, Alexis Lothoré wrote:
> Hello Marek,

Hi,

> On 9/26/24 21:52, Marek Vasut wrote:
>> It seems it is necessary to set WILC MAC address after operation mode,
>> otherwise the MAC address of the WILC MAC is reset back to what is in
>> nvmem. This causes a failure to associate with AP after the WILC MAC
>> address was overridden by userspace.
>>
>> Test case:
>> "
>> ap$ cat << EOF > hostap.conf
>> interface=wlan0
>> ssid=ssid
>> hw_mode=g
>> channel=6
>> wpa=2
>> wpa_passphrase=pass
>> wpa_key_mgmt=WPA-PSK
>> EOF
>> ap$ hostapd -d hostap.conf
>> ap$ ifconfig wlan0 10.0.0.1
>> "
>>
>> "
>> sta$ ifconfig wlan0 hw ether 00:11:22:33:44:55
>> sta$ wpa_supplicant -i wlan0 -c <(wpa_passphrase ssid pass)
>> sta$ ifconfig wlan0 10.0.0.2
>> sta$ ping 10.0.0.1 # fails without this patch
>> "
>>
>> AP still indicates SA with original MAC address from nvmem without this patch:
>> "
>> nl80211: RX frame da=ff:ff:ff:ff:ff:ff sa=60:01:23:45:67:89 bssid=ff:ff:ff:ff:ff:ff ...
>>                                            ^^^^^^^^^^^^^^^^^
>> "
> 
> Good catch, thanks for the fix. I tracked a bit the issue history and it seems
> to have been introduced by my recent change about reading the mac address early
> from the chip nvmem (to set correctly mac address reported to userspace once net
> device has been registered). I indeed reproduce the issue, and reverting the
> commit below makes it disappear, so the following can be added:
> 
> Fixes: 83d9b54ee5d4 ("wifi: wilc1000: read MAC address from fuse at probe")
> 
>> Signed-off-by: Marek Vasut <marex@denx.de>
> 
> Tested-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Nice, thanks !
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c
index 9ecf3fb29b558..8bc127c5a538c 100644
--- a/drivers/net/wireless/microchip/wilc1000/netdev.c
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
@@ -608,6 +608,9 @@  static int wilc_mac_open(struct net_device *ndev)
 		return ret;
 	}
 
+	wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), vif->iftype,
+				vif->idx);
+
 	netdev_dbg(ndev, "Mac address: %pM\n", ndev->dev_addr);
 	ret = wilc_set_mac_address(vif, ndev->dev_addr);
 	if (ret) {
@@ -618,9 +621,6 @@  static int wilc_mac_open(struct net_device *ndev)
 		return ret;
 	}
 
-	wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), vif->iftype,
-				vif->idx);
-
 	mgmt_regs.interface_stypes = vif->mgmt_reg_stypes;
 	/* so we detect a change */
 	vif->mgmt_reg_stypes = 0;