f473fad1182652071faa416d3c028b206782d398
[openwrt/staging/ansuel.git] /
1 From 7f444692cde83c1455682c2d0d2c9a666422b867 Mon Sep 17 00:00:00 2001
2 From: Martin Kaistra <martin.kaistra@linutronix.de>
3 Date: Fri, 22 Dec 2023 11:14:24 +0100
4 Subject: [PATCH 03/21] wifi: rtl8xxxu: support setting linktype for both
5 interfaces
6
7 To prepare for concurrent mode, enhance the set_linktype function to be
8 able to set the linktype in the MSR register for both hardware ports.
9
10 Until the users of set_linktype can handle multiple interfaces, use
11 port_num = 0.
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-4-martin.kaistra@linutronix.de
17 ---
18 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 37 +++++++++++--------
19 1 file changed, 22 insertions(+), 15 deletions(-)
20
21 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
22 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
23 @@ -1633,33 +1633,41 @@ rtl8xxxu_gen1_set_tx_power(struct rtl8xx
24 }
25
26 static void rtl8xxxu_set_linktype(struct rtl8xxxu_priv *priv,
27 - enum nl80211_iftype linktype)
28 + enum nl80211_iftype linktype, int port_num)
29 {
30 - u8 val8;
31 -
32 - val8 = rtl8xxxu_read8(priv, REG_MSR);
33 - val8 &= ~MSR_LINKTYPE_MASK;
34 + u8 val8, type;
35
36 switch (linktype) {
37 case NL80211_IFTYPE_UNSPECIFIED:
38 - val8 |= MSR_LINKTYPE_NONE;
39 + type = MSR_LINKTYPE_NONE;
40 break;
41 case NL80211_IFTYPE_ADHOC:
42 - val8 |= MSR_LINKTYPE_ADHOC;
43 + type = MSR_LINKTYPE_ADHOC;
44 break;
45 case NL80211_IFTYPE_STATION:
46 - val8 |= MSR_LINKTYPE_STATION;
47 + type = MSR_LINKTYPE_STATION;
48 break;
49 case NL80211_IFTYPE_AP:
50 - val8 |= MSR_LINKTYPE_AP;
51 + type = MSR_LINKTYPE_AP;
52 break;
53 default:
54 - goto out;
55 + return;
56 + }
57 +
58 + switch (port_num) {
59 + case 0:
60 + val8 = rtl8xxxu_read8(priv, REG_MSR) & 0x0c;
61 + val8 |= type;
62 + break;
63 + case 1:
64 + val8 = rtl8xxxu_read8(priv, REG_MSR) & 0x03;
65 + val8 |= type << 2;
66 + break;
67 + default:
68 + return;
69 }
70
71 rtl8xxxu_write8(priv, REG_MSR, val8);
72 -out:
73 - return;
74 }
75
76 static void
77 @@ -4236,7 +4244,6 @@ static int rtl8xxxu_init_device(struct i
78 }
79
80 rtl8xxxu_set_mac(priv);
81 - rtl8xxxu_set_linktype(priv, NL80211_IFTYPE_STATION);
82
83 /*
84 * Configure initial WMAC settings
85 @@ -4964,7 +4971,7 @@ rtl8xxxu_bss_info_changed(struct ieee802
86 if (changed & BSS_CHANGED_ASSOC) {
87 dev_dbg(dev, "Changed ASSOC: %i!\n", vif->cfg.assoc);
88
89 - rtl8xxxu_set_linktype(priv, vif->type);
90 + rtl8xxxu_set_linktype(priv, vif->type, 0);
91
92 if (vif->cfg.assoc) {
93 u32 ramask;
94 @@ -6610,7 +6617,7 @@ static int rtl8xxxu_add_interface(struct
95 ret = -EOPNOTSUPP;
96 }
97
98 - rtl8xxxu_set_linktype(priv, vif->type);
99 + rtl8xxxu_set_linktype(priv, vif->type, 0);
100 ether_addr_copy(priv->mac_addr, vif->addr);
101 rtl8xxxu_set_mac(priv);
102