mac80211: rtl8xxxu: sync with linux-next 20240229
[openwrt/staging/mans0n.git] / package / kernel / mac80211 / patches / rtl / 001-09-v6.9-wifi-rtl8xxxu-support-setting-bssid-register-for-mul.patch
1 From 3ff7a05996f901a7a10068b42e9dc8435f908a4c Mon Sep 17 00:00:00 2001
2 From: Martin Kaistra <martin.kaistra@linutronix.de>
3 Date: Fri, 22 Dec 2023 11:14:30 +0100
4 Subject: [PATCH 09/21] wifi: rtl8xxxu: support setting bssid register for
5 multiple interfaces
6
7 To prepare for concurrent mode, enhance rtl8xxxu_set_bssid() to write the
8 BSSID of the respective interface to REG_BSSID or REG_BSSID1.
9
10 Like done with rtl8xxxu_set_mac(), call rtl8xxxu_set_bssid() with
11 port_num = 0, until the callers also support multiple interfaces.
12
13 Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
14 Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
15 Signed-off-by: Kalle Valo <kvalo@kernel.org>
16 Link: https://msgid.link/20231222101442.626837-10-martin.kaistra@linutronix.de
17 ---
18 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 18 ++++++++++++++----
19 1 file changed, 14 insertions(+), 4 deletions(-)
20
21 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
22 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
23 @@ -3603,14 +3603,24 @@ static int rtl8xxxu_set_mac(struct rtl8x
24 return 0;
25 }
26
27 -static int rtl8xxxu_set_bssid(struct rtl8xxxu_priv *priv, const u8 *bssid)
28 +static int rtl8xxxu_set_bssid(struct rtl8xxxu_priv *priv, const u8 *bssid, int port_num)
29 {
30 int i;
31 u16 reg;
32
33 dev_dbg(&priv->udev->dev, "%s: (%pM)\n", __func__, bssid);
34
35 - reg = REG_BSSID;
36 + switch (port_num) {
37 + case 0:
38 + reg = REG_BSSID;
39 + break;
40 + case 1:
41 + reg = REG_BSSID1;
42 + break;
43 + default:
44 + WARN_ONCE("%s: invalid port_num\n", __func__);
45 + return -EINVAL;
46 + }
47
48 for (i = 0; i < ETH_ALEN; i++)
49 rtl8xxxu_write8(priv, reg + i, bssid[i]);
50 @@ -5068,7 +5078,7 @@ rtl8xxxu_bss_info_changed(struct ieee802
51
52 if (changed & BSS_CHANGED_BSSID) {
53 dev_dbg(dev, "Changed BSSID!\n");
54 - rtl8xxxu_set_bssid(priv, bss_conf->bssid);
55 + rtl8xxxu_set_bssid(priv, bss_conf->bssid, 0);
56 }
57
58 if (changed & BSS_CHANGED_BASIC_RATES) {
59 @@ -5097,7 +5107,7 @@ static int rtl8xxxu_start_ap(struct ieee
60 struct device *dev = &priv->udev->dev;
61
62 dev_dbg(dev, "Start AP mode\n");
63 - rtl8xxxu_set_bssid(priv, vif->bss_conf.bssid);
64 + rtl8xxxu_set_bssid(priv, vif->bss_conf.bssid, 0);
65 rtl8xxxu_write16(priv, REG_BCN_INTERVAL, vif->bss_conf.beacon_int);
66 priv->fops->report_connect(priv, RTL8XXXU_BC_MC_MACID, 0, true);
67