blob: 8dcbc38724ac074ece3997f0364abbb1e4ec325c [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From bb417654387169098f02664031be303d1f1a7f16 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: Shayne Chen <shayne.chen@mediatek.com>
developer9237f442024-06-14 17:13:04 +08003Date: Mon, 27 Nov 2023 10:43:34 +0800
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 091/199] mtk: mt76: mt7996: switch to per-link data structure
developer9237f442024-06-14 17:13:04 +08005 of sta
developer66e89bc2024-04-23 14:50:01 +08006
developer9237f442024-06-14 17:13:04 +08007Introduce struct mt7996_link_sta, data structure for per-link STA.
8Note that mt7996_sta now represents a peer legacy or MLD device.
developer66e89bc2024-04-23 14:50:01 +08009This is a preliminary patch to add MLO support for mt7996 chipsets.
10
11Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com>
12Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
13Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
14---
developer9237f442024-06-14 17:13:04 +080015 mt7996/debugfs.c | 20 ++-
16 mt7996/mac.c | 109 ++++++------
17 mt7996/main.c | 223 +++++++++++++++---------
18 mt7996/mcu.c | 430 ++++++++++++++++++++++++----------------------
19 mt7996/mt7996.h | 44 +++--
20 mt7996/testmode.c | 6 +-
developer05f3b2b2024-08-19 19:17:34 +080021 6 files changed, 461 insertions(+), 371 deletions(-)
developer66e89bc2024-04-23 14:50:01 +080022
23diff --git a/mt7996/debugfs.c b/mt7996/debugfs.c
developer05f3b2b2024-08-19 19:17:34 +080024index 5d4d69ea..62658dbc 100644
developer66e89bc2024-04-23 14:50:01 +080025--- a/mt7996/debugfs.c
26+++ b/mt7996/debugfs.c
developer05f3b2b2024-08-19 19:17:34 +080027@@ -726,14 +726,15 @@ static void
developer66e89bc2024-04-23 14:50:01 +080028 mt7996_sta_hw_queue_read(void *data, struct ieee80211_sta *sta)
29 {
30 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer9237f442024-06-14 17:13:04 +080031+ struct mt7996_link_sta *mlink = &msta->deflink;
32 struct mt7996_dev *dev = msta->vif->deflink.phy->dev;
developer66e89bc2024-04-23 14:50:01 +080033 struct seq_file *s = data;
34 u8 ac;
35
developer9237f442024-06-14 17:13:04 +080036 for (ac = 0; ac < 4; ac++) {
37 u32 qlen, ctrl, val;
38- u32 idx = msta->wcid.idx >> 5;
39- u8 offs = msta->wcid.idx & GENMASK(4, 0);
40+ u32 idx = mlink->wcid.idx >> 5;
41+ u8 offs = mlink->wcid.idx & GENMASK(4, 0);
42
43 ctrl = BIT(31) | BIT(11) | (ac << 24);
44 val = mt76_rr(dev, MT_PLE_AC_QEMPTY(ac, idx));
developer05f3b2b2024-08-19 19:17:34 +080045@@ -741,11 +742,11 @@ mt7996_sta_hw_queue_read(void *data, struct ieee80211_sta *sta)
developer9237f442024-06-14 17:13:04 +080046 if (val & BIT(offs))
47 continue;
48
49- mt76_wr(dev, MT_FL_Q0_CTRL, ctrl | msta->wcid.idx);
50+ mt76_wr(dev, MT_FL_Q0_CTRL, ctrl | mlink->wcid.idx);
51 qlen = mt76_get_field(dev, MT_FL_Q3_CTRL,
developer66e89bc2024-04-23 14:50:01 +080052 GENMASK(11, 0));
53 seq_printf(s, "\tSTA %pM wcid %d: AC%d%d queued:%d\n",
developer9237f442024-06-14 17:13:04 +080054- sta->addr, msta->wcid.idx,
55+ sta->addr, mlink->wcid.idx,
56 msta->vif->deflink.mt76.wmm_idx, ac, qlen);
developer66e89bc2024-04-23 14:50:01 +080057 }
58 }
developer05f3b2b2024-08-19 19:17:34 +080059@@ -1028,7 +1029,7 @@ mt7996_airtime_read(struct seq_file *s, void *data)
developer9237f442024-06-14 17:13:04 +080060 struct mt76_dev *mdev = &dev->mt76;
61 struct mt76_sta_stats *stats;
62 struct ieee80211_sta *sta;
63- struct mt7996_sta *msta;
64+ struct mt7996_link_sta *mlink;
65 struct mt76_wcid *wcid;
66 struct mt76_vif *vif;
67 u16 i;
developer05f3b2b2024-08-19 19:17:34 +080068@@ -1040,9 +1041,9 @@ mt7996_airtime_read(struct seq_file *s, void *data)
developer9237f442024-06-14 17:13:04 +080069 if (!wcid || !wcid->sta)
70 continue;
developer66e89bc2024-04-23 14:50:01 +080071
developer9237f442024-06-14 17:13:04 +080072- msta = container_of(wcid, struct mt7996_sta, wcid);
73- sta = container_of((void *)msta, struct ieee80211_sta, drv_priv);
74- vif = &msta->vif->deflink.mt76;
75+ mlink = container_of(wcid, struct mt7996_link_sta, wcid);
76+ sta = container_of((void *)mlink->sta, struct ieee80211_sta, drv_priv);
77+ vif = &mlink->sta->vif->deflink.mt76;
developer66e89bc2024-04-23 14:50:01 +080078 stats = &wcid->stats;
79
80 seq_printf(s, "%pM WCID: %hu BandIdx: %hhu OmacIdx: 0x%hhx\t"
developer05f3b2b2024-08-19 19:17:34 +080081@@ -1217,6 +1218,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
developer66e89bc2024-04-23 14:50:01 +080082 #define LONG_PREAMBLE 1
83 struct ieee80211_sta *sta = file->private_data;
84 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer9237f442024-06-14 17:13:04 +080085+ struct mt7996_link_sta *mlink = &msta->deflink;
86 struct mt7996_dev *dev = msta->vif->deflink.phy->dev;
developer66e89bc2024-04-23 14:50:01 +080087 struct ra_rate phy = {};
88 char buf[100];
developer05f3b2b2024-08-19 19:17:34 +080089@@ -1252,7 +1254,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
developer9237f442024-06-14 17:13:04 +080090 goto out;
91 }
developer66e89bc2024-04-23 14:50:01 +080092
developer9237f442024-06-14 17:13:04 +080093- phy.wlan_idx = cpu_to_le16(msta->wcid.idx);
94+ phy.wlan_idx = cpu_to_le16(mlink->wcid.idx);
95 phy.gi = cpu_to_le16(gi);
96 phy.ltf = cpu_to_le16(ltf);
97 phy.ldpc = phy.ldpc ? 7 : 0;
developer66e89bc2024-04-23 14:50:01 +080098diff --git a/mt7996/mac.c b/mt7996/mac.c
developer05f3b2b2024-08-19 19:17:34 +080099index 5fbcfc74..fbe6c0bd 100644
developer66e89bc2024-04-23 14:50:01 +0800100--- a/mt7996/mac.c
101+++ b/mt7996/mac.c
developer9237f442024-06-14 17:13:04 +0800102@@ -54,7 +54,7 @@ static const struct mt7996_dfs_radar_spec jp_radar_specs = {
103 static struct mt76_wcid *mt7996_rx_get_wcid(struct mt7996_dev *dev,
104 u16 idx, bool unicast)
105 {
106- struct mt7996_sta *sta;
107+ struct mt7996_link_sta *mlink;
108 struct mt76_wcid *wcid;
109
110 if (idx >= ARRAY_SIZE(dev->mt76.wcid))
111@@ -67,11 +67,11 @@ static struct mt76_wcid *mt7996_rx_get_wcid(struct mt7996_dev *dev,
112 if (!wcid->sta)
113 return NULL;
114
115- sta = container_of(wcid, struct mt7996_sta, wcid);
116- if (!sta->vif)
117+ mlink = container_of(wcid, struct mt7996_link_sta, wcid);
118+ if (!mlink->sta->vif)
119 return NULL;
developer66e89bc2024-04-23 14:50:01 +0800120
developer9237f442024-06-14 17:13:04 +0800121- return &sta->vif->sta.wcid;
122+ return &mlink->wcid;
123 }
124
125 bool mt7996_mac_wtbl_update(struct mt7996_dev *dev, int idx, u32 mask)
126@@ -92,12 +92,11 @@ u32 mt7996_mac_wtbl_lmac_addr(struct mt7996_dev *dev, u16 wcid, u8 dw)
127 }
128
129 void mt7996_mac_enable_rtscts(struct mt7996_dev *dev,
130- struct ieee80211_vif *vif, bool enable)
131+ struct mt7996_link_sta *mlink, bool enable)
132 {
133- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
134 u32 addr;
135
136- addr = mt7996_mac_wtbl_lmac_addr(dev, mvif->sta.wcid.idx, 5);
137+ addr = mt7996_mac_wtbl_lmac_addr(dev, mlink->wcid.idx, 5);
138 if (enable)
139 mt76_set(dev, addr, BIT(5));
140 else
141@@ -349,7 +348,7 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
142 __le16 fc = 0;
143 int idx;
144 u8 hw_aggr = false;
145- struct mt7996_sta *msta = NULL;
146+ struct mt7996_link_sta *mlink = NULL;
developer66e89bc2024-04-23 14:50:01 +0800147
developer9237f442024-06-14 17:13:04 +0800148 hw_aggr = status->aggr;
149 memset(status, 0, sizeof(*status));
developer05f3b2b2024-08-19 19:17:34 +0800150@@ -378,10 +377,10 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
developer9237f442024-06-14 17:13:04 +0800151 status->wcid = mt7996_rx_get_wcid(dev, idx, unicast);
152
153 if (status->wcid) {
154- msta = container_of(status->wcid, struct mt7996_sta, wcid);
155+ mlink = container_of(status->wcid, struct mt7996_link_sta, wcid);
156 spin_lock_bh(&dev->mt76.sta_poll_lock);
157- if (list_empty(&msta->wcid.poll_list))
158- list_add_tail(&msta->wcid.poll_list,
159+ if (list_empty(&mlink->wcid.poll_list))
160+ list_add_tail(&mlink->wcid.poll_list,
161 &dev->mt76.sta_poll_list);
162 spin_unlock_bh(&dev->mt76.sta_poll_lock);
developer66e89bc2024-04-23 14:50:01 +0800163 }
developer05f3b2b2024-08-19 19:17:34 +0800164@@ -586,7 +585,7 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
developer9237f442024-06-14 17:13:04 +0800165 #endif
166 } else {
167 status->flag |= RX_FLAG_8023;
168- mt7996_wed_check_ppe(dev, &dev->mt76.q_rx[q], msta, skb,
169+ mt7996_wed_check_ppe(dev, &dev->mt76.q_rx[q], mlink ? mlink->sta : NULL, skb,
170 *info);
171 }
172
developer05f3b2b2024-08-19 19:17:34 +0800173@@ -945,6 +944,7 @@ static void
developer9237f442024-06-14 17:13:04 +0800174 mt7996_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb)
175 {
176 struct mt7996_sta *msta;
177+ struct mt7996_link_sta *mlink;
178 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
179 bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP;
180 u16 fc, tid;
developer05f3b2b2024-08-19 19:17:34 +0800181@@ -973,7 +973,8 @@ mt7996_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb)
developer9237f442024-06-14 17:13:04 +0800182 return;
183
184 msta = (struct mt7996_sta *)sta->drv_priv;
185- if (!test_and_set_bit(tid, &msta->wcid.ampdu_state))
186+ mlink = rcu_dereference(msta->link[0]);
187+ if (!test_and_set_bit(tid, &mlink->wcid.ampdu_state))
188 ieee80211_start_tx_ba_session(sta, tid, 0);
189 }
190
developer05f3b2b2024-08-19 19:17:34 +0800191@@ -1051,7 +1052,7 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len)
developer9237f442024-06-14 17:13:04 +0800192 */
193 info = le32_to_cpu(*cur_info);
194 if (info & MT_TXFREE_INFO_PAIR) {
195- struct mt7996_sta *msta;
196+ struct mt7996_link_sta *mlink;
197 u16 idx;
198
199 idx = FIELD_GET(MT_TXFREE_INFO_WLAN_ID, info);
developer05f3b2b2024-08-19 19:17:34 +0800200@@ -1060,10 +1061,10 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len)
developer9237f442024-06-14 17:13:04 +0800201 if (!sta)
202 continue;
203
204- msta = container_of(wcid, struct mt7996_sta, wcid);
205+ mlink = container_of(wcid, struct mt7996_link_sta, wcid);
206 spin_lock_bh(&mdev->sta_poll_lock);
207- if (list_empty(&msta->wcid.poll_list))
208- list_add_tail(&msta->wcid.poll_list,
209+ if (list_empty(&mlink->wcid.poll_list))
210+ list_add_tail(&mlink->wcid.poll_list,
211 &mdev->sta_poll_list);
212 spin_unlock_bh(&mdev->sta_poll_lock);
213 continue;
developer05f3b2b2024-08-19 19:17:34 +0800214@@ -1268,7 +1269,7 @@ out:
developer66e89bc2024-04-23 14:50:01 +0800215
developer9237f442024-06-14 17:13:04 +0800216 static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data)
developer66e89bc2024-04-23 14:50:01 +0800217 {
developer9237f442024-06-14 17:13:04 +0800218- struct mt7996_sta *msta = NULL;
219+ struct mt7996_link_sta *mlink;
220 struct mt76_wcid *wcid;
221 __le32 *txs_data = data;
222 u16 wcidx;
developer05f3b2b2024-08-19 19:17:34 +0800223@@ -1289,16 +1290,15 @@ static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data)
developer9237f442024-06-14 17:13:04 +0800224 if (!wcid)
225 goto out;
developer66e89bc2024-04-23 14:50:01 +0800226
developer9237f442024-06-14 17:13:04 +0800227- msta = container_of(wcid, struct mt7996_sta, wcid);
228-
229 mt7996_mac_add_txs_skb(dev, wcid, pid, txs_data);
230
231 if (!wcid->sta)
232 goto out;
233
234+ mlink = container_of(wcid, struct mt7996_link_sta, wcid);
235 spin_lock_bh(&dev->mt76.sta_poll_lock);
236- if (list_empty(&msta->wcid.poll_list))
237- list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list);
238+ if (list_empty(&mlink->wcid.poll_list))
239+ list_add_tail(&mlink->wcid.poll_list, &dev->mt76.sta_poll_list);
240 spin_unlock_bh(&dev->mt76.sta_poll_lock);
241
242 out:
243@@ -2242,8 +2242,9 @@ void mt7996_mac_sta_rc_work(struct work_struct *work)
developer66e89bc2024-04-23 14:50:01 +0800244 struct ieee80211_sta *sta;
245 struct ieee80211_vif *vif;
developer9237f442024-06-14 17:13:04 +0800246 struct ieee80211_bss_conf *conf;
247+ struct ieee80211_link_sta *link_sta;
248 struct mt7996_bss_conf *mconf;
249- struct mt7996_sta *msta;
250+ struct mt7996_link_sta *mlink;
developer66e89bc2024-04-23 14:50:01 +0800251 u32 changed;
252 LIST_HEAD(list);
developer9237f442024-06-14 17:13:04 +0800253
254@@ -2251,24 +2252,25 @@ void mt7996_mac_sta_rc_work(struct work_struct *work)
255 list_splice_init(&dev->sta_rc_list, &list);
developer66e89bc2024-04-23 14:50:01 +0800256
developer9237f442024-06-14 17:13:04 +0800257 while (!list_empty(&list)) {
258- msta = list_first_entry(&list, struct mt7996_sta, rc_list);
259- list_del_init(&msta->rc_list);
260- changed = msta->changed;
261- msta->changed = 0;
262+ mlink = list_first_entry(&list, struct mt7996_link_sta, rc_list);
263+ list_del_init(&mlink->rc_list);
264+ changed = mlink->changed;
265+ mlink->changed = 0;
266 spin_unlock_bh(&dev->mt76.sta_poll_lock);
267
268- sta = container_of((void *)msta, struct ieee80211_sta, drv_priv);
269- vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv);
270+ sta = container_of((void *)mlink->sta, struct ieee80211_sta, drv_priv);
271+ link_sta = &sta->deflink;
272+ vif = container_of((void *)mlink->sta->vif, struct ieee80211_vif, drv_priv);
273 conf = &vif->bss_conf;
274- mconf = &msta->vif->deflink;
275+ mconf = &mlink->sta->vif->deflink;
developer66e89bc2024-04-23 14:50:01 +0800276
277 if (changed & (IEEE80211_RC_SUPP_RATES_CHANGED |
278 IEEE80211_RC_NSS_CHANGED |
279 IEEE80211_RC_BW_CHANGED))
developer9237f442024-06-14 17:13:04 +0800280- mt7996_mcu_add_rate_ctrl(dev, conf, mconf, sta, true);
281+ mt7996_mcu_add_rate_ctrl(dev, conf, mconf, link_sta, mlink, true);
developer66e89bc2024-04-23 14:50:01 +0800282
283 if (changed & IEEE80211_RC_SMPS_CHANGED)
developer9237f442024-06-14 17:13:04 +0800284- mt7996_mcu_set_fixed_field(dev, mconf, sta, NULL,
285+ mt7996_mcu_set_fixed_field(dev, mconf, link_sta, mlink, NULL,
developer66e89bc2024-04-23 14:50:01 +0800286 RATE_PARAM_MMPS_UPDATE);
287
288 spin_lock_bh(&dev->mt76.sta_poll_lock);
developer9237f442024-06-14 17:13:04 +0800289@@ -2561,7 +2563,7 @@ static int mt7996_mac_check_twt_req(struct ieee80211_twt_setup *twt)
290 }
291
292 static bool
293-mt7996_mac_twt_param_equal(struct mt7996_sta *msta,
294+mt7996_mac_twt_param_equal(struct mt7996_link_sta *mlink,
295 struct ieee80211_twt_params *twt_agrt)
296 {
297 u16 type = le16_to_cpu(twt_agrt->req_type);
298@@ -2572,10 +2574,10 @@ mt7996_mac_twt_param_equal(struct mt7996_sta *msta,
299 for (i = 0; i < MT7996_MAX_STA_TWT_AGRT; i++) {
300 struct mt7996_twt_flow *f;
301
302- if (!(msta->twt.flowid_mask & BIT(i)))
303+ if (!(mlink->twt.flowid_mask & BIT(i)))
304 continue;
305
306- f = &msta->twt.flow[i];
307+ f = &mlink->twt.flow[i];
308 if (f->duration == twt_agrt->min_twt_dur &&
309 f->mantissa == twt_agrt->mantissa &&
310 f->exp == exp &&
311@@ -2594,6 +2596,7 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
312 {
313 enum ieee80211_twt_setup_cmd setup_cmd = TWT_SETUP_CMD_REJECT;
314 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
315+ struct mt7996_link_sta *mlink;
316 struct ieee80211_twt_params *twt_agrt = (void *)twt->params;
317 u16 req_type = le16_to_cpu(twt_agrt->req_type);
318 enum ieee80211_twt_setup_cmd sta_setup_cmd;
319@@ -2605,11 +2608,12 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
320 goto out;
321
322 mutex_lock(&dev->mt76.mutex);
323+ mlink = mlink_dereference_protected(msta, 0);
324
325 if (dev->twt.n_agrt == MT7996_MAX_TWT_AGRT)
326 goto unlock;
327
328- if (hweight8(msta->twt.flowid_mask) == ARRAY_SIZE(msta->twt.flow))
329+ if (hweight8(mlink->twt.flowid_mask) == ARRAY_SIZE(mlink->twt.flow))
330 goto unlock;
331
332 if (twt_agrt->min_twt_dur < MT7996_MIN_TWT_DUR) {
333@@ -2618,10 +2622,10 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
334 goto unlock;
335 }
336
337- if (mt7996_mac_twt_param_equal(msta, twt_agrt))
338+ if (mt7996_mac_twt_param_equal(mlink, twt_agrt))
339 goto unlock;
340
341- flowid = ffs(~msta->twt.flowid_mask) - 1;
342+ flowid = ffs(~mlink->twt.flowid_mask) - 1;
343 twt_agrt->req_type &= ~cpu_to_le16(IEEE80211_TWT_REQTYPE_FLOWID);
344 twt_agrt->req_type |= le16_encode_bits(flowid,
345 IEEE80211_TWT_REQTYPE_FLOWID);
346@@ -2630,10 +2634,10 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
347 exp = FIELD_GET(IEEE80211_TWT_REQTYPE_WAKE_INT_EXP, req_type);
348 sta_setup_cmd = FIELD_GET(IEEE80211_TWT_REQTYPE_SETUP_CMD, req_type);
349
350- flow = &msta->twt.flow[flowid];
351+ flow = &mlink->twt.flow[flowid];
352 memset(flow, 0, sizeof(*flow));
353 INIT_LIST_HEAD(&flow->list);
354- flow->wcid = msta->wcid.idx;
355+ flow->wcid = mlink->wcid.idx;
356 flow->table_id = table_id;
357 flow->id = flowid;
358 flow->duration = twt_agrt->min_twt_dur;
359@@ -2651,7 +2655,7 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800360
361 flow->sched = true;
362 flow->start_tsf = mt7996_mac_twt_sched_list_add(dev, flow);
developer9237f442024-06-14 17:13:04 +0800363- curr_tsf = __mt7996_get_tsf(hw, &msta->vif->deflink);
364+ curr_tsf = __mt7996_get_tsf(hw, &mlink->sta->vif->deflink);
developer66e89bc2024-04-23 14:50:01 +0800365 div_u64_rem(curr_tsf - flow->start_tsf, interval, &rem);
366 flow_tsf = curr_tsf + interval - rem;
367 twt_agrt->twt = cpu_to_le64(flow_tsf);
developer9237f442024-06-14 17:13:04 +0800368@@ -2660,13 +2664,13 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800369 }
370 flow->tsf = le64_to_cpu(twt_agrt->twt);
371
developer9237f442024-06-14 17:13:04 +0800372- if (mt7996_mcu_twt_agrt_update(dev, &msta->vif->deflink, flow,
373+ if (mt7996_mcu_twt_agrt_update(dev, &mlink->sta->vif->deflink, flow,
374 MCU_TWT_AGRT_ADD))
developer66e89bc2024-04-23 14:50:01 +0800375 goto unlock;
376
377 setup_cmd = TWT_SETUP_CMD_ACCEPT;
developer9237f442024-06-14 17:13:04 +0800378 dev->twt.table_mask |= BIT(table_id);
379- msta->twt.flowid_mask |= BIT(flowid);
380+ mlink->twt.flowid_mask |= BIT(flowid);
381 dev->twt.n_agrt++;
382
383 unlock:
384@@ -2679,26 +2683,25 @@ out:
385 }
386
387 void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev,
388- struct mt7996_sta *msta,
389- u8 flowid)
390+ struct mt7996_link_sta *mlink, u8 flowid)
developer66e89bc2024-04-23 14:50:01 +0800391 {
392 struct mt7996_twt_flow *flow;
developer9237f442024-06-14 17:13:04 +0800393- struct mt7996_bss_conf *mconf = mconf_dereference_protected(msta->vif, 0);
394+ struct mt7996_bss_conf *mconf = mconf_dereference_protected(mlink->sta->vif, 0);
developer66e89bc2024-04-23 14:50:01 +0800395
396 lockdep_assert_held(&dev->mt76.mutex);
397
developer9237f442024-06-14 17:13:04 +0800398- if (flowid >= ARRAY_SIZE(msta->twt.flow))
399+ if (flowid >= ARRAY_SIZE(mlink->twt.flow))
400 return;
401
402- if (!(msta->twt.flowid_mask & BIT(flowid)))
403+ if (!(mlink->twt.flowid_mask & BIT(flowid)))
developer66e89bc2024-04-23 14:50:01 +0800404 return;
405
developer9237f442024-06-14 17:13:04 +0800406- flow = &msta->twt.flow[flowid];
407+ flow = &mlink->twt.flow[flowid];
408 if (mt7996_mcu_twt_agrt_update(dev, mconf, flow, MCU_TWT_AGRT_DELETE))
developer66e89bc2024-04-23 14:50:01 +0800409 return;
410
411 list_del_init(&flow->list);
developer9237f442024-06-14 17:13:04 +0800412- msta->twt.flowid_mask &= ~BIT(flowid);
413+ mlink->twt.flowid_mask &= ~BIT(flowid);
414 dev->twt.table_mask &= ~BIT(flow->table_id);
415 dev->twt.n_agrt--;
developer66e89bc2024-04-23 14:50:01 +0800416 }
developer9237f442024-06-14 17:13:04 +0800417@@ -2711,7 +2714,7 @@ mt7996_scan_send_probe(struct mt7996_phy *phy, struct cfg80211_ssid *ssid,
418 struct cfg80211_scan_request *req = phy->scan_req;
419 struct ieee80211_vif *vif = phy->scan_vif;
420 struct mt7996_vif *mvif;
421- struct mt76_wcid *wcid;
422+ struct mt7996_link_sta *mlink;
423 struct ieee80211_tx_info *info;
424 struct sk_buff *skb;
developer66e89bc2024-04-23 14:50:01 +0800425
developer9237f442024-06-14 17:13:04 +0800426@@ -2719,7 +2722,6 @@ mt7996_scan_send_probe(struct mt7996_phy *phy, struct cfg80211_ssid *ssid,
427 return;
developer66e89bc2024-04-23 14:50:01 +0800428
developer9237f442024-06-14 17:13:04 +0800429 mvif = (struct mt7996_vif *)vif->drv_priv;
430- wcid = &mvif->sta.wcid;
431
432 skb = ieee80211_probereq_get(hw, vif->addr,
433 ssid->ssid, ssid->ssid_len, req->ie_len);
434@@ -2752,7 +2754,8 @@ mt7996_scan_send_probe(struct mt7996_phy *phy, struct cfg80211_ssid *ssid,
developer66e89bc2024-04-23 14:50:01 +0800435 }
developer66e89bc2024-04-23 14:50:01 +0800436
developer9237f442024-06-14 17:13:04 +0800437 local_bh_disable();
438- mt76_tx(phy->mt76, NULL, wcid, skb);
439+ mlink = rcu_dereference(mvif->sta.link[0]);
440+ mt76_tx(phy->mt76, NULL, &mlink->wcid, skb);
441 local_bh_enable();
442
443 rcu_read_unlock();
444diff --git a/mt7996/main.c b/mt7996/main.c
developer05f3b2b2024-08-19 19:17:34 +0800445index 8a32ec69..e071c5fa 100644
developer9237f442024-06-14 17:13:04 +0800446--- a/mt7996/main.c
447+++ b/mt7996/main.c
448@@ -229,6 +229,7 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
449 struct ieee80211_bss_conf *conf = &vif->bss_conf;
developer66e89bc2024-04-23 14:50:01 +0800450 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
developer9237f442024-06-14 17:13:04 +0800451 struct mt7996_bss_conf *mconf = &mvif->deflink;
452+ struct mt7996_link_sta *mlink = &mvif->sta.deflink;
developer66e89bc2024-04-23 14:50:01 +0800453 struct mt7996_dev *dev = mt7996_hw_dev(hw);
454 struct mt7996_phy *phy = mt7996_hw_phy(hw);
455 struct mt76_txq *mtxq;
developer9237f442024-06-14 17:13:04 +0800456@@ -268,14 +269,15 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800457
developer9237f442024-06-14 17:13:04 +0800458 idx = MT7996_WTBL_RESERVED - mconf->mt76.idx;
developer66e89bc2024-04-23 14:50:01 +0800459
developer9237f442024-06-14 17:13:04 +0800460- INIT_LIST_HEAD(&mvif->sta.rc_list);
461- INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
462- mvif->sta.wcid.idx = idx;
463- mvif->sta.wcid.phy_idx = band_idx;
464- mvif->sta.wcid.hw_key_idx = -1;
465- mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
466- mvif->sta.vif = mvif;
467- mt76_wcid_init(&mvif->sta.wcid);
468+ INIT_LIST_HEAD(&mlink->rc_list);
469+ INIT_LIST_HEAD(&mlink->wcid.poll_list);
470+ mlink->wcid.idx = idx;
471+ mlink->wcid.phy_idx = band_idx;
472+ mlink->wcid.hw_key_idx = -1;
473+ mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
474+ mlink->sta = &mvif->sta;
475+ mlink->sta->vif = mvif;
476+ mt76_wcid_init(&mlink->wcid);
developer66e89bc2024-04-23 14:50:01 +0800477
developer9237f442024-06-14 17:13:04 +0800478 mt7996_mac_wtbl_update(dev, idx,
479 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
480@@ -297,14 +299,15 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800481
developer9237f442024-06-14 17:13:04 +0800482 mt7996_init_bitrate_mask(mconf);
developer66e89bc2024-04-23 14:50:01 +0800483
developer9237f442024-06-14 17:13:04 +0800484- mt7996_mcu_add_bss_info(phy, conf, mconf, true);
485+ mt7996_mcu_add_bss_info(phy, conf, mconf, mlink, true);
developer66e89bc2024-04-23 14:50:01 +0800486 /* defer the first STA_REC of BMC entry to BSS_CHANGED_BSSID for STA
487 * interface, since firmware only records BSSID when the entry is new
488 */
489 if (vif->type != NL80211_IFTYPE_STATION)
developer9237f442024-06-14 17:13:04 +0800490- mt7996_mcu_add_sta(dev, conf, mconf, NULL, true, true);
491- rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid);
492+ mt7996_mcu_add_sta(dev, conf, mconf, NULL, mlink, true, true);
493+ rcu_assign_pointer(dev->mt76.wcid[idx], &mlink->wcid);
494 rcu_assign_pointer(mvif->link[0], mconf);
495+ rcu_assign_pointer(mvif->sta.link[0], mlink);
developer66e89bc2024-04-23 14:50:01 +0800496
497 out:
498 mutex_unlock(&dev->mt76.mutex);
developer9237f442024-06-14 17:13:04 +0800499@@ -318,10 +321,10 @@ static void mt7996_remove_interface(struct ieee80211_hw *hw,
500 struct ieee80211_bss_conf *conf;
developer66e89bc2024-04-23 14:50:01 +0800501 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
developer9237f442024-06-14 17:13:04 +0800502 struct mt7996_bss_conf *mconf;
503- struct mt7996_sta *msta = &mvif->sta;
504+ struct mt7996_link_sta *mlink = &mvif->sta.deflink;
developer66e89bc2024-04-23 14:50:01 +0800505 struct mt7996_dev *dev = mt7996_hw_dev(hw);
506 struct mt7996_phy *phy = mt7996_hw_phy(hw);
developer9237f442024-06-14 17:13:04 +0800507- int idx = msta->wcid.idx;
508+ int idx = mlink->wcid.idx;
developer66e89bc2024-04-23 14:50:01 +0800509
510 cancel_delayed_work_sync(&phy->scan_work);
511
developer9237f442024-06-14 17:13:04 +0800512@@ -329,8 +332,8 @@ static void mt7996_remove_interface(struct ieee80211_hw *hw,
513
514 conf = link_conf_dereference_protected(vif, 0);
515 mconf = mconf_dereference_protected(mvif, 0);
516- mt7996_mcu_add_sta(dev, conf, mconf, NULL, false, false);
517- mt7996_mcu_add_bss_info(phy, conf, mconf, false);
518+ mt7996_mcu_add_sta(dev, conf, mconf, NULL, mlink, false, false);
519+ mt7996_mcu_add_bss_info(phy, conf, mconf, mlink, false);
developer66e89bc2024-04-23 14:50:01 +0800520
521 if (vif == phy->monitor_vif)
522 phy->monitor_vif = NULL;
developer9237f442024-06-14 17:13:04 +0800523@@ -343,12 +346,13 @@ static void mt7996_remove_interface(struct ieee80211_hw *hw,
524 phy->omac_mask &= ~BIT_ULL(mconf->mt76.omac_idx);
developer66e89bc2024-04-23 14:50:01 +0800525
526 spin_lock_bh(&dev->mt76.sta_poll_lock);
developer9237f442024-06-14 17:13:04 +0800527- if (!list_empty(&msta->wcid.poll_list))
528- list_del_init(&msta->wcid.poll_list);
529+ if (!list_empty(&mlink->wcid.poll_list))
530+ list_del_init(&mlink->wcid.poll_list);
developer66e89bc2024-04-23 14:50:01 +0800531 spin_unlock_bh(&dev->mt76.sta_poll_lock);
532
developer9237f442024-06-14 17:13:04 +0800533- mt76_wcid_cleanup(&dev->mt76, &msta->wcid);
534+ mt76_wcid_cleanup(&dev->mt76, &mlink->wcid);
535 rcu_assign_pointer(mvif->link[0], NULL);
536+ rcu_assign_pointer(mvif->sta.link[0], NULL);
developer66e89bc2024-04-23 14:50:01 +0800537
developer9237f442024-06-14 17:13:04 +0800538 mutex_unlock(&dev->mt76.mutex);
539 }
developer05f3b2b2024-08-19 19:17:34 +0800540@@ -451,10 +455,10 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
developer9237f442024-06-14 17:13:04 +0800541 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
developer66e89bc2024-04-23 14:50:01 +0800542 struct mt7996_sta *msta = sta ? (struct mt7996_sta *)sta->drv_priv :
543 &mvif->sta;
developer9237f442024-06-14 17:13:04 +0800544- struct mt76_wcid *wcid = &msta->wcid;
545 struct mt7996_bss_conf *mconf;
546+ struct mt7996_link_sta *mlink;
547 struct ieee80211_bss_conf *conf;
548- u8 *wcid_keyidx = &wcid->hw_key_idx;
549+ u8 *wcid_keyidx;
developer66e89bc2024-04-23 14:50:01 +0800550 int idx = key->keyidx;
551 int err = 0;
developer66e89bc2024-04-23 14:50:01 +0800552
developer05f3b2b2024-08-19 19:17:34 +0800553@@ -468,6 +472,12 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
developer9237f442024-06-14 17:13:04 +0800554 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
555 return -EOPNOTSUPP;
developer66e89bc2024-04-23 14:50:01 +0800556
developer9237f442024-06-14 17:13:04 +0800557+ mutex_lock(&dev->mt76.mutex);
developer66e89bc2024-04-23 14:50:01 +0800558+ conf = link_conf_dereference_protected(vif, 0);
559+ mconf = mconf_dereference_protected(mvif, 0);
developer9237f442024-06-14 17:13:04 +0800560+ mlink = mlink_dereference_protected(msta, 0);
561+ wcid_keyidx = &mlink->wcid.hw_key_idx;
562+
563 /* fall back to sw encryption for unsupported ciphers */
564 switch (key->cipher) {
565 case WLAN_CIPHER_SUITE_TKIP:
developer05f3b2b2024-08-19 19:17:34 +0800566@@ -490,16 +500,13 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
developer9237f442024-06-14 17:13:04 +0800567 case WLAN_CIPHER_SUITE_WEP40:
568 case WLAN_CIPHER_SUITE_WEP104:
569 default:
570+ mutex_unlock(&dev->mt76.mutex);
571 return -EOPNOTSUPP;
572 }
573
574- mutex_lock(&dev->mt76.mutex);
575-
576- conf = link_conf_dereference_protected(vif, 0);
577- mconf = mconf_dereference_protected(mvif, 0);
578 if (cmd == SET_KEY && !sta && !mconf->mt76.cipher) {
579 mconf->mt76.cipher = mt76_connac_mcu_get_cipher(key->cipher);
580- mt7996_mcu_add_bss_info(phy, conf, mconf, true);
581+ mt7996_mcu_add_bss_info(phy, conf, mconf, mlink, true);
developer66e89bc2024-04-23 14:50:01 +0800582 }
583
584 if (cmd == SET_KEY) {
developer05f3b2b2024-08-19 19:17:34 +0800585@@ -510,14 +517,14 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
developer9237f442024-06-14 17:13:04 +0800586 goto out;
587 }
588
589- mt76_wcid_key_setup(&dev->mt76, wcid, key);
590+ mt76_wcid_key_setup(&dev->mt76, &mlink->wcid, key);
developer66e89bc2024-04-23 14:50:01 +0800591
592 if (key->keyidx == 6 || key->keyidx == 7)
developer9237f442024-06-14 17:13:04 +0800593- err = mt7996_mcu_bcn_prot_enable(dev, conf, mconf, key);
594+ err = mt7996_mcu_bcn_prot_enable(dev, conf, mconf, mlink, key);
developer66e89bc2024-04-23 14:50:01 +0800595 else
developer9237f442024-06-14 17:13:04 +0800596 err = mt7996_mcu_add_key(&dev->mt76, mconf, key,
developer66e89bc2024-04-23 14:50:01 +0800597 MCU_WMWA_UNI_CMD(STA_REC_UPDATE),
developer9237f442024-06-14 17:13:04 +0800598- &msta->wcid, cmd);
599+ &mlink->wcid, cmd);
developer66e89bc2024-04-23 14:50:01 +0800600 out:
developer9237f442024-06-14 17:13:04 +0800601 mutex_unlock(&dev->mt76.mutex);
developer66e89bc2024-04-23 14:50:01 +0800602
developer05f3b2b2024-08-19 19:17:34 +0800603@@ -720,25 +727,27 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800604 {
developer9237f442024-06-14 17:13:04 +0800605 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
606 struct mt7996_bss_conf *mconf;
607+ struct mt7996_link_sta *mlink;
developer66e89bc2024-04-23 14:50:01 +0800608 struct mt7996_phy *phy = mt7996_hw_phy(hw);
609 struct mt7996_dev *dev = mt7996_hw_dev(hw);
610
611 mutex_lock(&dev->mt76.mutex);
612
developer9237f442024-06-14 17:13:04 +0800613 mconf = mconf_dereference_protected(mvif, 0);
614+ mlink = mlink_dereference_protected(&mvif->sta, 0);
developer66e89bc2024-04-23 14:50:01 +0800615 /* station mode uses BSSID to map the wlan entry to a peer,
616 * and then peer references bss_info_rfch to set bandwidth cap.
617 */
618 if ((changed & BSS_CHANGED_BSSID && !is_zero_ether_addr(info->bssid)) ||
619 (changed & BSS_CHANGED_ASSOC && vif->cfg.assoc) ||
620 (changed & BSS_CHANGED_BEACON_ENABLED && info->enable_beacon)) {
developer9237f442024-06-14 17:13:04 +0800621- mt7996_mcu_add_bss_info(phy, info, mconf, true);
622- mt7996_mcu_add_sta(dev, info, mconf, NULL, true,
623+ mt7996_mcu_add_bss_info(phy, info, mconf, mlink, true);
624+ mt7996_mcu_add_sta(dev, info, mconf, NULL, mlink, true,
developer66e89bc2024-04-23 14:50:01 +0800625 !!(changed & BSS_CHANGED_BSSID));
626 }
627
developer9237f442024-06-14 17:13:04 +0800628 if (changed & BSS_CHANGED_ERP_CTS_PROT)
629- mt7996_mac_enable_rtscts(dev, vif, info->use_cts_prot);
630+ mt7996_mac_enable_rtscts(dev, mlink, info->use_cts_prot);
developer66e89bc2024-04-23 14:50:01 +0800631
developer9237f442024-06-14 17:13:04 +0800632 if (changed & BSS_CHANGED_ERP_SLOT) {
633 int slottime = info->use_short_slot ? 9 : 20;
developer05f3b2b2024-08-19 19:17:34 +0800634@@ -809,6 +818,7 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +0800635 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
636 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
637 struct mt7996_bss_conf *mconf = mconf_dereference_protected(mvif, 0);
638+ struct mt7996_link_sta *mlink = &msta->deflink;
639 u8 band_idx = mconf->phy->mt76->band_idx;
640 int idx;
developer66e89bc2024-04-23 14:50:01 +0800641
developer05f3b2b2024-08-19 19:17:34 +0800642@@ -820,13 +830,16 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +0800643 if (idx < 0)
644 return -ENOSPC;
developer66e89bc2024-04-23 14:50:01 +0800645
developer9237f442024-06-14 17:13:04 +0800646- INIT_LIST_HEAD(&msta->rc_list);
647- INIT_LIST_HEAD(&msta->wcid.poll_list);
648+ INIT_LIST_HEAD(&mlink->rc_list);
649+ INIT_LIST_HEAD(&mlink->wcid.poll_list);
650 msta->vif = mvif;
651- msta->wcid.sta = 1;
652- msta->wcid.idx = idx;
653- msta->wcid.phy_idx = band_idx;
654- msta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
655+ mlink->wcid.sta = 1;
656+ mlink->wcid.idx = idx;
657+ mlink->wcid.phy_idx = band_idx;
658+ mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
659+ mlink->sta = msta;
660+
661+ rcu_assign_pointer(msta->link[0], mlink);
developer66e89bc2024-04-23 14:50:01 +0800662
developer9237f442024-06-14 17:13:04 +0800663 #ifdef CONFIG_MTK_VENDOR
664 mt7996_vendor_amnt_sta_remove(mconf->phy, sta);
developer05f3b2b2024-08-19 19:17:34 +0800665@@ -859,19 +872,25 @@ void mt7996_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +0800666 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
667 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
668 struct mt7996_bss_conf *mconf;
669+ struct mt7996_link_sta *mlink;
670 struct ieee80211_bss_conf *conf;
671+ struct ieee80211_link_sta *link_sta;
developer66e89bc2024-04-23 14:50:01 +0800672
developer9237f442024-06-14 17:13:04 +0800673 mutex_lock(&dev->mt76.mutex);
developer66e89bc2024-04-23 14:50:01 +0800674
developer9237f442024-06-14 17:13:04 +0800675- mt7996_mac_wtbl_update(dev, msta->wcid.idx,
676- MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
677-
678 conf = link_conf_dereference_protected(vif, 0);
679 mconf = mconf_dereference_protected(mvif, 0);
680- mt7996_mcu_add_sta(dev, conf, mconf, sta, true, true);
681- mt7996_mcu_add_rate_ctrl(dev, conf, mconf, sta, false);
682+ link_sta = link_sta_dereference_protected(sta, 0);
683+ mlink = mlink_dereference_protected(msta, 0);
developer66e89bc2024-04-23 14:50:01 +0800684
developer9237f442024-06-14 17:13:04 +0800685- ewma_avg_signal_init(&msta->avg_ack_signal);
686+ mt7996_mac_wtbl_update(dev, mlink->wcid.idx,
687+ MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
688+
689+ mt7996_mcu_add_sta(dev, conf, mconf, link_sta, mlink, true, true);
690+ mt7996_mcu_add_rate_ctrl(dev, conf, mconf, link_sta, mlink, false);
691+ mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
692+
693+ ewma_avg_signal_init(&mlink->avg_ack_signal);
developer66e89bc2024-04-23 14:50:01 +0800694
developer9237f442024-06-14 17:13:04 +0800695 mutex_unlock(&dev->mt76.mutex);
696 }
developer05f3b2b2024-08-19 19:17:34 +0800697@@ -883,25 +902,31 @@ void mt7996_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +0800698 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
699 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
700 struct mt7996_bss_conf *mconf;
701+ struct mt7996_link_sta *mlink;
702 struct ieee80211_bss_conf *conf;
703+ struct ieee80211_link_sta *link_sta;
704 int i;
developer66e89bc2024-04-23 14:50:01 +0800705
developer9237f442024-06-14 17:13:04 +0800706 conf = link_conf_dereference_protected(vif, 0);
707 mconf = mconf_dereference_protected(mvif, 0);
708- mt7996_mcu_add_sta(dev, conf, mconf, sta, false, false);
709+ link_sta = link_sta_dereference_protected(sta, 0);
710+ mlink = mlink_dereference_protected(msta, 0);
711+ mt7996_mcu_add_sta(dev, conf, mconf, link_sta, mlink, false, false);
developer66e89bc2024-04-23 14:50:01 +0800712
developer9237f442024-06-14 17:13:04 +0800713- mt7996_mac_wtbl_update(dev, msta->wcid.idx,
714+ mt7996_mac_wtbl_update(dev, mlink->wcid.idx,
715 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
developer66e89bc2024-04-23 14:50:01 +0800716
developer9237f442024-06-14 17:13:04 +0800717- for (i = 0; i < ARRAY_SIZE(msta->twt.flow); i++)
718- mt7996_mac_twt_teardown_flow(dev, msta, i);
719+ for (i = 0; i < ARRAY_SIZE(mlink->twt.flow); i++)
720+ mt7996_mac_twt_teardown_flow(dev, mlink, i);
developer66e89bc2024-04-23 14:50:01 +0800721
developer9237f442024-06-14 17:13:04 +0800722 spin_lock_bh(&mdev->sta_poll_lock);
723- if (!list_empty(&msta->wcid.poll_list))
724- list_del_init(&msta->wcid.poll_list);
725- if (!list_empty(&msta->rc_list))
726- list_del_init(&msta->rc_list);
727+ if (!list_empty(&mlink->wcid.poll_list))
728+ list_del_init(&mlink->wcid.poll_list);
729+ if (!list_empty(&mlink->rc_list))
730+ list_del_init(&mlink->rc_list);
731 spin_unlock_bh(&mdev->sta_poll_lock);
732+
733+ rcu_assign_pointer(msta->link[0], NULL);
developer66e89bc2024-04-23 14:50:01 +0800734 }
735
developer9237f442024-06-14 17:13:04 +0800736 static void mt7996_tx(struct ieee80211_hw *hw,
developer05f3b2b2024-08-19 19:17:34 +0800737@@ -913,19 +938,22 @@ static void mt7996_tx(struct ieee80211_hw *hw,
developer9237f442024-06-14 17:13:04 +0800738 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
739 struct ieee80211_vif *vif = info->control.vif;
740 struct mt76_wcid *wcid = &dev->mt76.global_wcid;
741+ struct mt7996_link_sta *mlink;
developer66e89bc2024-04-23 14:50:01 +0800742
developer9237f442024-06-14 17:13:04 +0800743 if (control->sta) {
744- struct mt7996_sta *sta;
745+ struct mt7996_sta *msta;
developer66e89bc2024-04-23 14:50:01 +0800746
developer9237f442024-06-14 17:13:04 +0800747- sta = (struct mt7996_sta *)control->sta->drv_priv;
748- wcid = &sta->wcid;
749+ msta = (struct mt7996_sta *)control->sta->drv_priv;
750+ mlink = rcu_dereference(msta->link[0]);
751+ wcid = &mlink->wcid;
752 }
developer66e89bc2024-04-23 14:50:01 +0800753
developer9237f442024-06-14 17:13:04 +0800754 if (vif && !control->sta) {
755 struct mt7996_vif *mvif;
developer66e89bc2024-04-23 14:50:01 +0800756
developer9237f442024-06-14 17:13:04 +0800757 mvif = (struct mt7996_vif *)vif->drv_priv;
758- wcid = &mvif->sta.wcid;
759+ mlink = rcu_dereference(mvif->sta.link[0]);
760+ wcid = &mlink->wcid;
761 }
developer66e89bc2024-04-23 14:50:01 +0800762
developer9237f442024-06-14 17:13:04 +0800763 mt76_tx(mphy, control->sta, wcid, skb);
developer05f3b2b2024-08-19 19:17:34 +0800764@@ -952,6 +980,7 @@ mt7996_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +0800765 struct ieee80211_sta *sta = params->sta;
766 struct ieee80211_txq *txq = sta->txq[params->tid];
767 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
768+ struct mt7996_link_sta *mlink;
769 u16 tid = params->tid;
770 u16 ssn = params->ssn;
771 struct mt76_txq *mtxq;
developer05f3b2b2024-08-19 19:17:34 +0800772@@ -963,14 +992,15 @@ mt7996_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +0800773 mtxq = (struct mt76_txq *)txq->drv_priv;
developer66e89bc2024-04-23 14:50:01 +0800774
developer9237f442024-06-14 17:13:04 +0800775 mutex_lock(&dev->mt76.mutex);
776+ mlink = mlink_dereference_protected(msta, 0);
777 switch (action) {
778 case IEEE80211_AMPDU_RX_START:
779- mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn,
780+ mt76_rx_aggr_start(&dev->mt76, &mlink->wcid, tid, ssn,
781 params->buf_size);
782 ret = mt7996_mcu_add_rx_ba(dev, params, true);
783 break;
784 case IEEE80211_AMPDU_RX_STOP:
785- mt76_rx_aggr_stop(&dev->mt76, &msta->wcid, tid);
786+ mt76_rx_aggr_stop(&dev->mt76, &mlink->wcid, tid);
787 ret = mt7996_mcu_add_rx_ba(dev, params, false);
788 break;
789 case IEEE80211_AMPDU_TX_OPERATIONAL:
developer05f3b2b2024-08-19 19:17:34 +0800790@@ -981,16 +1011,16 @@ mt7996_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +0800791 case IEEE80211_AMPDU_TX_STOP_FLUSH:
792 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
793 mtxq->aggr = false;
794- clear_bit(tid, &msta->wcid.ampdu_state);
795+ clear_bit(tid, &mlink->wcid.ampdu_state);
796 ret = mt7996_mcu_add_tx_ba(dev, params, false);
797 break;
798 case IEEE80211_AMPDU_TX_START:
799- set_bit(tid, &msta->wcid.ampdu_state);
800+ set_bit(tid, &mlink->wcid.ampdu_state);
801 ret = IEEE80211_AMPDU_TX_START_IMMEDIATE;
802 break;
803 case IEEE80211_AMPDU_TX_STOP_CONT:
804 mtxq->aggr = false;
805- clear_bit(tid, &msta->wcid.ampdu_state);
806+ clear_bit(tid, &mlink->wcid.ampdu_state);
807 ret = mt7996_mcu_add_tx_ba(dev, params, false);
808 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
809 break;
developer05f3b2b2024-08-19 19:17:34 +0800810@@ -1169,10 +1199,19 @@ static void mt7996_sta_statistics(struct ieee80211_hw *hw,
developer9237f442024-06-14 17:13:04 +0800811 struct ieee80211_sta *sta,
812 struct station_info *sinfo)
developer66e89bc2024-04-23 14:50:01 +0800813 {
developer9237f442024-06-14 17:13:04 +0800814+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
815 struct mt7996_phy *phy = mt7996_hw_phy(hw);
developer66e89bc2024-04-23 14:50:01 +0800816 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer9237f442024-06-14 17:13:04 +0800817- struct rate_info *txrate = &msta->wcid.rate;
818+ struct mt7996_link_sta *mlink;
819+ struct rate_info *txrate;
developer66e89bc2024-04-23 14:50:01 +0800820
developer9237f442024-06-14 17:13:04 +0800821+ /* TODO: support per-link rate report */
822+ mutex_lock(&dev->mt76.mutex);
823+ mlink = mlink_dereference_protected(msta, 0);
824+ if (!mlink)
825+ goto out;
826+
827+ txrate = &mlink->wcid.rate;
828 if (txrate->legacy || txrate->flags) {
829 if (txrate->legacy) {
830 sinfo->txrate.legacy = txrate->legacy;
developer05f3b2b2024-08-19 19:17:34 +0800831@@ -1191,44 +1230,52 @@ static void mt7996_sta_statistics(struct ieee80211_hw *hw,
developer9237f442024-06-14 17:13:04 +0800832 sinfo->txrate.flags = txrate->flags;
833 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
developer66e89bc2024-04-23 14:50:01 +0800834
developer9237f442024-06-14 17:13:04 +0800835- sinfo->tx_failed = msta->wcid.stats.tx_failed;
836+ sinfo->tx_failed = mlink->wcid.stats.tx_failed;
837 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
developer66e89bc2024-04-23 14:50:01 +0800838
developer9237f442024-06-14 17:13:04 +0800839- sinfo->tx_retries = msta->wcid.stats.tx_retries;
840+ sinfo->tx_retries = mlink->wcid.stats.tx_retries;
841 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
developer66e89bc2024-04-23 14:50:01 +0800842
developer9237f442024-06-14 17:13:04 +0800843- sinfo->ack_signal = (s8)msta->ack_signal;
844+ sinfo->ack_signal = (s8)mlink->ack_signal;
845 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL);
developer66e89bc2024-04-23 14:50:01 +0800846
developer9237f442024-06-14 17:13:04 +0800847- sinfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&msta->avg_ack_signal);
848+ sinfo->avg_ack_signal = -(s8)ewma_avg_signal_read(&mlink->avg_ack_signal);
849 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG);
developer66e89bc2024-04-23 14:50:01 +0800850
developer9237f442024-06-14 17:13:04 +0800851 if (mtk_wed_device_active(&phy->dev->mt76.mmio.wed)) {
852- sinfo->tx_bytes = msta->wcid.stats.tx_bytes;
853+ sinfo->tx_bytes = mlink->wcid.stats.tx_bytes;
854 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64);
developer66e89bc2024-04-23 14:50:01 +0800855
developer9237f442024-06-14 17:13:04 +0800856- sinfo->rx_bytes = msta->wcid.stats.rx_bytes;
857+ sinfo->rx_bytes = mlink->wcid.stats.rx_bytes;
858 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64);
developer66e89bc2024-04-23 14:50:01 +0800859
developer9237f442024-06-14 17:13:04 +0800860- sinfo->tx_packets = msta->wcid.stats.tx_packets;
861+ sinfo->tx_packets = mlink->wcid.stats.tx_packets;
862 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS);
developer66e89bc2024-04-23 14:50:01 +0800863
developer9237f442024-06-14 17:13:04 +0800864- sinfo->rx_packets = msta->wcid.stats.rx_packets;
865+ sinfo->rx_packets = mlink->wcid.stats.rx_packets;
866 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS);
867 }
868+out:
869+ mutex_unlock(&dev->mt76.mutex);
870 }
developer66e89bc2024-04-23 14:50:01 +0800871
developer66e89bc2024-04-23 14:50:01 +0800872 static void mt7996_sta_rc_work(void *data, struct ieee80211_sta *sta)
873 {
874 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer9237f442024-06-14 17:13:04 +0800875+ struct mt7996_link_sta *mlink;
876 struct mt7996_dev *dev = msta->vif->dev;
developer66e89bc2024-04-23 14:50:01 +0800877 u32 *changed = data;
878
developer9237f442024-06-14 17:13:04 +0800879+ rcu_read_lock();
880+ mlink = rcu_dereference(msta->link[0]);
881+
developer66e89bc2024-04-23 14:50:01 +0800882 spin_lock_bh(&dev->mt76.sta_poll_lock);
developer9237f442024-06-14 17:13:04 +0800883- msta->changed |= *changed;
884- if (list_empty(&msta->rc_list))
885- list_add_tail(&msta->rc_list, &dev->sta_rc_list);
886+ mlink->changed |= *changed;
887+ if (list_empty(&mlink->rc_list))
888+ list_add_tail(&mlink->rc_list, &dev->sta_rc_list);
889 spin_unlock_bh(&dev->mt76.sta_poll_lock);
890+
891+ rcu_read_unlock();
892 }
developer66e89bc2024-04-23 14:50:01 +0800893
developer9237f442024-06-14 17:13:04 +0800894 static void mt7996_sta_rc_update(struct ieee80211_hw *hw,
developer05f3b2b2024-08-19 19:17:34 +0800895@@ -1242,7 +1289,7 @@ static void mt7996_sta_rc_update(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800896
developer9237f442024-06-14 17:13:04 +0800897 if (!msta->vif) {
898 dev_warn(dev->mt76.dev, "Un-initialized STA %pM wcid %d in rc_work\n",
899- sta->addr, msta->wcid.idx);
900+ sta->addr, msta->deflink.wcid.idx);
901 return;
902 }
903
developer05f3b2b2024-08-19 19:17:34 +0800904@@ -1288,16 +1335,18 @@ static void mt7996_sta_set_4addr(struct ieee80211_hw *hw,
developer9237f442024-06-14 17:13:04 +0800905 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
developer66e89bc2024-04-23 14:50:01 +0800906 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer9237f442024-06-14 17:13:04 +0800907 struct mt7996_bss_conf *mconf;
908+ struct mt7996_link_sta *mlink;
909
910 mutex_lock(&dev->mt76.mutex);
911 mconf = mconf_dereference_protected(mvif, 0);
912+ mlink = mlink_dereference_protected(msta, 0);
developer66e89bc2024-04-23 14:50:01 +0800913
914 if (enabled)
developer9237f442024-06-14 17:13:04 +0800915- set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
916+ set_bit(MT_WCID_FLAG_4ADDR, &mlink->wcid.flags);
developer66e89bc2024-04-23 14:50:01 +0800917 else
developer9237f442024-06-14 17:13:04 +0800918- clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
919+ clear_bit(MT_WCID_FLAG_4ADDR, &mlink->wcid.flags);
developer66e89bc2024-04-23 14:50:01 +0800920
developer9237f442024-06-14 17:13:04 +0800921- mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, sta);
922+ mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, mlink);
923 mutex_unlock(&dev->mt76.mutex);
developer66e89bc2024-04-23 14:50:01 +0800924 }
925
developer05f3b2b2024-08-19 19:17:34 +0800926@@ -1310,16 +1359,18 @@ static void mt7996_sta_set_decap_offload(struct ieee80211_hw *hw,
developer9237f442024-06-14 17:13:04 +0800927 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
developer66e89bc2024-04-23 14:50:01 +0800928 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer9237f442024-06-14 17:13:04 +0800929 struct mt7996_bss_conf *mconf;
930+ struct mt7996_link_sta *mlink;
931
932 mutex_lock(&dev->mt76.mutex);
933 mconf = mconf_dereference_protected(mvif, 0);
934+ mlink = mlink_dereference_protected(msta, 0);
developer66e89bc2024-04-23 14:50:01 +0800935
936 if (enabled)
developer9237f442024-06-14 17:13:04 +0800937- set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
938+ set_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags);
developer66e89bc2024-04-23 14:50:01 +0800939 else
developer9237f442024-06-14 17:13:04 +0800940- clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
941+ clear_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags);
developer66e89bc2024-04-23 14:50:01 +0800942
developer9237f442024-06-14 17:13:04 +0800943- mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, sta);
944+ mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, mlink);
945 mutex_unlock(&dev->mt76.mutex);
developer66e89bc2024-04-23 14:50:01 +0800946 }
947
developer05f3b2b2024-08-19 19:17:34 +0800948@@ -1452,11 +1503,12 @@ static void mt7996_ethtool_worker(void *wi_data, struct ieee80211_sta *sta)
developer9237f442024-06-14 17:13:04 +0800949 {
developer66e89bc2024-04-23 14:50:01 +0800950 struct mt76_ethtool_worker_info *wi = wi_data;
951 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer9237f442024-06-14 17:13:04 +0800952+ struct mt7996_link_sta *mlink = &msta->deflink;
developer66e89bc2024-04-23 14:50:01 +0800953
developer9237f442024-06-14 17:13:04 +0800954 if (msta->vif->deflink.mt76.idx != wi->idx)
developer66e89bc2024-04-23 14:50:01 +0800955 return;
956
developer9237f442024-06-14 17:13:04 +0800957- mt76_ethtool_worker(wi, &msta->wcid.stats, true);
958+ mt76_ethtool_worker(wi, &mlink->wcid.stats, true);
959 }
960
961 static
developer05f3b2b2024-08-19 19:17:34 +0800962@@ -1559,10 +1611,12 @@ mt7996_twt_teardown_request(struct ieee80211_hw *hw,
developer9237f442024-06-14 17:13:04 +0800963 u8 flowid)
964 {
965 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
966+ struct mt7996_link_sta *mlink;
developer66e89bc2024-04-23 14:50:01 +0800967 struct mt7996_dev *dev = mt7996_hw_dev(hw);
developer66e89bc2024-04-23 14:50:01 +0800968
969 mutex_lock(&dev->mt76.mutex);
developer9237f442024-06-14 17:13:04 +0800970- mt7996_mac_twt_teardown_flow(dev, msta, flowid);
971+ mlink = mlink_dereference_protected(msta, 0);
972+ mt7996_mac_twt_teardown_flow(dev, mlink, flowid);
973 mutex_unlock(&dev->mt76.mutex);
974 }
developer66e89bc2024-04-23 14:50:01 +0800975
developer05f3b2b2024-08-19 19:17:34 +0800976@@ -1685,6 +1739,7 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800977 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
developer9237f442024-06-14 17:13:04 +0800978 struct mt7996_bss_conf *mconf = &mvif->deflink;
developer66e89bc2024-04-23 14:50:01 +0800979 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer9237f442024-06-14 17:13:04 +0800980+ struct mt7996_link_sta *mlink = &msta->deflink;
developer66e89bc2024-04-23 14:50:01 +0800981 struct mt7996_dev *dev = mt7996_hw_dev(hw);
982 struct mt7996_phy *phy = mt7996_hw_phy(hw);
developer9237f442024-06-14 17:13:04 +0800983 struct mtk_wed_device *wed = &dev->mt76.mmio.wed;
developer05f3b2b2024-08-19 19:17:34 +0800984@@ -1707,7 +1762,7 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw,
developer9237f442024-06-14 17:13:04 +0800985 if (!mtk_wed_device_active(wed))
986 return -ENODEV;
987
988- if (msta->wcid.idx > MT7996_WTBL_STA)
989+ if (mlink->wcid.idx > MT7996_WTBL_STA)
990 return -EIO;
991
developer66e89bc2024-04-23 14:50:01 +0800992 path->type = DEV_PATH_MTK_WDMA;
developer05f3b2b2024-08-19 19:17:34 +0800993@@ -1715,11 +1770,11 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800994 path->mtk_wdma.wdma_idx = wed->wdma_idx;
developer9237f442024-06-14 17:13:04 +0800995 path->mtk_wdma.bss = mconf->mt76.idx;
developer66e89bc2024-04-23 14:50:01 +0800996 path->mtk_wdma.queue = 0;
developer9237f442024-06-14 17:13:04 +0800997- path->mtk_wdma.wcid = msta->wcid.idx;
998+ path->mtk_wdma.wcid = mlink->wcid.idx;
developer66e89bc2024-04-23 14:50:01 +0800999
developer9237f442024-06-14 17:13:04 +08001000 if (ieee80211_hw_check(hw, SUPPORTS_AMSDU_IN_AMPDU) &&
1001 mtk_wed_is_amsdu_supported(wed))
1002- path->mtk_wdma.amsdu = msta->wcid.amsdu;
1003+ path->mtk_wdma.amsdu = mlink->wcid.amsdu;
1004 else
1005 path->mtk_wdma.amsdu = 0;
developer66e89bc2024-04-23 14:50:01 +08001006
developer66e89bc2024-04-23 14:50:01 +08001007diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developer05f3b2b2024-08-19 19:17:34 +08001008index 1e0fca2d..20b84c93 100644
developer66e89bc2024-04-23 14:50:01 +08001009--- a/mt7996/mcu.c
1010+++ b/mt7996/mcu.c
developer9237f442024-06-14 17:13:04 +08001011@@ -117,13 +117,13 @@ mt7996_mcu_get_sta_nss(u16 mcs_map)
developer66e89bc2024-04-23 14:50:01 +08001012 }
1013
1014 static void
developer9237f442024-06-14 17:13:04 +08001015-mt7996_mcu_set_sta_he_mcs(struct ieee80211_sta *sta,
1016+mt7996_mcu_set_sta_he_mcs(struct ieee80211_link_sta *link_sta,
1017 struct mt7996_bss_conf *mconf,
1018 __le16 *he_mcs, u16 mcs_map)
developer66e89bc2024-04-23 14:50:01 +08001019 {
developer9237f442024-06-14 17:13:04 +08001020 enum nl80211_band band = mconf->phy->mt76->chandef.chan->band;
1021 const u16 *mask = mconf->bitrate_mask.control[band].he_mcs;
1022- int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss;
1023+ int nss, max_nss = link_sta->rx_nss > 3 ? 4 : link_sta->rx_nss;
developer66e89bc2024-04-23 14:50:01 +08001024
1025 for (nss = 0; nss < max_nss; nss++) {
developer9237f442024-06-14 17:13:04 +08001026 int mcs;
1027@@ -166,11 +166,11 @@ mt7996_mcu_set_sta_he_mcs(struct ieee80211_sta *sta,
developer66e89bc2024-04-23 14:50:01 +08001028 }
1029
1030 static void
developer9237f442024-06-14 17:13:04 +08001031-mt7996_mcu_set_sta_vht_mcs(struct ieee80211_sta *sta, __le16 *vht_mcs,
1032- const u16 *mask)
1033+mt7996_mcu_set_sta_vht_mcs(struct ieee80211_link_sta *link_sta,
1034+ __le16 *vht_mcs, const u16 *mask)
developer66e89bc2024-04-23 14:50:01 +08001035 {
developer9237f442024-06-14 17:13:04 +08001036- u16 mcs, mcs_map = le16_to_cpu(sta->deflink.vht_cap.vht_mcs.rx_mcs_map);
1037- int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss;
1038+ u16 mcs, mcs_map = le16_to_cpu(link_sta->vht_cap.vht_mcs.rx_mcs_map);
1039+ int nss, max_nss = link_sta->rx_nss > 3 ? 4 : link_sta->rx_nss;
1040
1041 for (nss = 0; nss < max_nss; nss++, mcs_map >>= 2) {
1042 switch (mcs_map & 0x3) {
1043@@ -192,13 +192,13 @@ mt7996_mcu_set_sta_vht_mcs(struct ieee80211_sta *sta, __le16 *vht_mcs,
developer66e89bc2024-04-23 14:50:01 +08001044 }
1045
1046 static void
developer9237f442024-06-14 17:13:04 +08001047-mt7996_mcu_set_sta_ht_mcs(struct ieee80211_sta *sta, u8 *ht_mcs,
1048+mt7996_mcu_set_sta_ht_mcs(struct ieee80211_link_sta *link_sta, u8 *ht_mcs,
1049 const u8 *mask)
developer66e89bc2024-04-23 14:50:01 +08001050 {
developer9237f442024-06-14 17:13:04 +08001051- int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss;
1052+ int nss, max_nss = link_sta->rx_nss > 3 ? 4 : link_sta->rx_nss;
1053
1054 for (nss = 0; nss < max_nss; nss++)
1055- ht_mcs[nss] = sta->deflink.ht_cap.mcs.rx_mask[nss] & mask[nss];
1056+ ht_mcs[nss] = link_sta->ht_cap.mcs.rx_mask[nss] & mask[nss];
developer66e89bc2024-04-23 14:50:01 +08001057 }
1058
developer9237f442024-06-14 17:13:04 +08001059 static int
1060@@ -531,14 +531,14 @@ static inline void __mt7996_stat_to_netdev(struct mt76_phy *mphy,
1061 u32 tx_bytes, u32 rx_bytes,
1062 u32 tx_packets, u32 rx_packets)
developer66e89bc2024-04-23 14:50:01 +08001063 {
developer9237f442024-06-14 17:13:04 +08001064- struct mt7996_sta *msta;
1065+ struct mt7996_link_sta *mlink;
1066 struct ieee80211_vif *vif;
1067 struct wireless_dev *wdev;
developer66e89bc2024-04-23 14:50:01 +08001068
developer9237f442024-06-14 17:13:04 +08001069 if (wiphy_ext_feature_isset(mphy->hw->wiphy,
1070 NL80211_EXT_FEATURE_STAS_COUNT)) {
1071- msta = container_of(wcid, struct mt7996_sta, wcid);
1072- vif = container_of((void *)msta->vif, struct ieee80211_vif,
1073+ mlink = container_of(wcid, struct mt7996_link_sta, wcid);
1074+ vif = container_of((void *)mlink->sta->vif, struct ieee80211_vif,
1075 drv_priv);
1076 wdev = ieee80211_vif_to_wdev(vif);
developer66e89bc2024-04-23 14:50:01 +08001077
developer9237f442024-06-14 17:13:04 +08001078@@ -1236,10 +1236,10 @@ __mt7996_mcu_alloc_bss_req(struct mt76_dev *dev, struct mt76_vif *mvif, int len)
developer66e89bc2024-04-23 14:50:01 +08001079
developer9237f442024-06-14 17:13:04 +08001080 int mt7996_mcu_add_bss_info(struct mt7996_phy *phy,
1081 struct ieee80211_bss_conf *conf,
1082- struct mt7996_bss_conf *mconf, int enable)
1083+ struct mt7996_bss_conf *mconf,
1084+ struct mt7996_link_sta *mlink, int enable)
1085 {
1086 struct ieee80211_vif *vif = conf->vif;
1087- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1088 struct mt7996_dev *dev = phy->dev;
1089 struct sk_buff *skb;
developer66e89bc2024-04-23 14:50:01 +08001090
developer9237f442024-06-14 17:13:04 +08001091@@ -1255,7 +1255,7 @@ int mt7996_mcu_add_bss_info(struct mt7996_phy *phy,
developer66e89bc2024-04-23 14:50:01 +08001092
developer9237f442024-06-14 17:13:04 +08001093 /* bss_basic must be first */
1094 mt7996_mcu_bss_basic_tlv(skb, conf, mconf, NULL, phy->mt76,
1095- mvif->sta.wcid.idx, enable);
1096+ mlink->wcid.idx, enable);
1097 mt7996_mcu_bss_sec_tlv(skb, mconf);
developer66e89bc2024-04-23 14:50:01 +08001098
developer9237f442024-06-14 17:13:04 +08001099 if (vif->type == NL80211_IFTYPE_MONITOR)
1100@@ -1335,9 +1335,10 @@ int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev,
developer66e89bc2024-04-23 14:50:01 +08001101 {
developer9237f442024-06-14 17:13:04 +08001102 struct mt7996_sta *msta = (struct mt7996_sta *)params->sta->drv_priv;
1103 struct mt7996_bss_conf *mconf = mconf_dereference_protected(msta->vif, 0);
1104+ struct mt7996_link_sta *mlink = mlink_dereference_protected(msta, 0);
developer66e89bc2024-04-23 14:50:01 +08001105
developer9237f442024-06-14 17:13:04 +08001106 if (enable && !params->amsdu)
1107- msta->wcid.amsdu = false;
1108+ mlink->wcid.amsdu = false;
developer66e89bc2024-04-23 14:50:01 +08001109
developer9237f442024-06-14 17:13:04 +08001110 return mt7996_mcu_sta_ba(dev, &mconf->mt76, params, enable, true);
developer66e89bc2024-04-23 14:50:01 +08001111 }
developer9237f442024-06-14 17:13:04 +08001112@@ -1355,15 +1356,15 @@ int mt7996_mcu_add_rx_ba(struct mt7996_dev *dev,
developer66e89bc2024-04-23 14:50:01 +08001113 static void
developer9237f442024-06-14 17:13:04 +08001114 mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf,
1115 struct mt7996_bss_conf *mconf,
1116- struct ieee80211_sta *sta)
1117+ struct ieee80211_link_sta *link_sta)
developer66e89bc2024-04-23 14:50:01 +08001118 {
developer9237f442024-06-14 17:13:04 +08001119- struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem;
1120+ struct ieee80211_he_cap_elem *elem = &link_sta->he_cap.he_cap_elem;
1121 struct ieee80211_he_mcs_nss_supp mcs_map;
1122 struct sta_rec_he_v2 *he;
developer66e89bc2024-04-23 14:50:01 +08001123 struct tlv *tlv;
developer9237f442024-06-14 17:13:04 +08001124 int i = 0;
developer66e89bc2024-04-23 14:50:01 +08001125
developer9237f442024-06-14 17:13:04 +08001126- if (!sta->deflink.he_cap.has_he)
1127+ if (!link_sta->he_cap.has_he)
1128 return;
developer66e89bc2024-04-23 14:50:01 +08001129
developer9237f442024-06-14 17:13:04 +08001130 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HE_V2, sizeof(*he));
1131@@ -1380,21 +1381,21 @@ mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf,
1132 u8p_replace_bits(&he->he_phy_cap[1], conf->he_ldpc,
1133 IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD);
developer66e89bc2024-04-23 14:50:01 +08001134
developer9237f442024-06-14 17:13:04 +08001135- mcs_map = sta->deflink.he_cap.he_mcs_nss_supp;
1136- switch (sta->deflink.bandwidth) {
1137+ mcs_map = link_sta->he_cap.he_mcs_nss_supp;
1138+ switch (link_sta->bandwidth) {
1139 case IEEE80211_STA_RX_BW_160:
1140 if (elem->phy_cap_info[0] &
1141 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G)
1142- mt7996_mcu_set_sta_he_mcs(sta, mconf,
1143+ mt7996_mcu_set_sta_he_mcs(link_sta, mconf,
1144 &he->max_nss_mcs[CMD_HE_MCS_BW8080],
1145 le16_to_cpu(mcs_map.rx_mcs_80p80));
developer66e89bc2024-04-23 14:50:01 +08001146
developer9237f442024-06-14 17:13:04 +08001147- mt7996_mcu_set_sta_he_mcs(sta, mconf,
1148+ mt7996_mcu_set_sta_he_mcs(link_sta, mconf,
1149 &he->max_nss_mcs[CMD_HE_MCS_BW160],
1150 le16_to_cpu(mcs_map.rx_mcs_160));
1151 fallthrough;
1152 default:
1153- mt7996_mcu_set_sta_he_mcs(sta, mconf,
1154+ mt7996_mcu_set_sta_he_mcs(link_sta, mconf,
1155 &he->max_nss_mcs[CMD_HE_MCS_BW80],
1156 le16_to_cpu(mcs_map.rx_mcs_80));
1157 break;
1158@@ -1404,24 +1405,25 @@ mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf,
developer66e89bc2024-04-23 14:50:01 +08001159 }
1160
1161 static void
developer9237f442024-06-14 17:13:04 +08001162-mt7996_mcu_sta_he_6g_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
1163+mt7996_mcu_sta_he_6g_tlv(struct sk_buff *skb,
1164+ struct ieee80211_link_sta *link_sta)
developer66e89bc2024-04-23 14:50:01 +08001165 {
developer9237f442024-06-14 17:13:04 +08001166 struct sta_rec_he_6g_capa *he_6g;
developer66e89bc2024-04-23 14:50:01 +08001167 struct tlv *tlv;
1168
developer9237f442024-06-14 17:13:04 +08001169- if (!sta->deflink.he_6ghz_capa.capa)
1170+ if (!link_sta->he_6ghz_capa.capa)
1171 return;
developer66e89bc2024-04-23 14:50:01 +08001172
developer9237f442024-06-14 17:13:04 +08001173 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HE_6G, sizeof(*he_6g));
developer66e89bc2024-04-23 14:50:01 +08001174
developer9237f442024-06-14 17:13:04 +08001175 he_6g = (struct sta_rec_he_6g_capa *)tlv;
1176- he_6g->capa = sta->deflink.he_6ghz_capa.capa;
1177+ he_6g->capa = link_sta->he_6ghz_capa.capa;
developer66e89bc2024-04-23 14:50:01 +08001178 }
1179
1180 static void
developer9237f442024-06-14 17:13:04 +08001181-mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
1182+mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta)
developer66e89bc2024-04-23 14:50:01 +08001183 {
developer9237f442024-06-14 17:13:04 +08001184- struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
1185+ struct mt7996_sta *msta = (struct mt7996_sta *)link_sta->sta->drv_priv;
1186 struct ieee80211_vif *vif = container_of((void *)msta->vif,
1187 struct ieee80211_vif, drv_priv);
1188 struct ieee80211_eht_mcs_nss_supp *mcs_map;
1189@@ -1429,11 +1431,11 @@ mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
1190 struct sta_rec_eht *eht;
developer66e89bc2024-04-23 14:50:01 +08001191 struct tlv *tlv;
developer66e89bc2024-04-23 14:50:01 +08001192
developer9237f442024-06-14 17:13:04 +08001193- if (!sta->deflink.eht_cap.has_eht)
1194+ if (!link_sta->eht_cap.has_eht)
1195 return;
developer66e89bc2024-04-23 14:50:01 +08001196
developer9237f442024-06-14 17:13:04 +08001197- mcs_map = &sta->deflink.eht_cap.eht_mcs_nss_supp;
1198- elem = &sta->deflink.eht_cap.eht_cap_elem;
1199+ mcs_map = &link_sta->eht_cap.eht_mcs_nss_supp;
1200+ elem = &link_sta->eht_cap.eht_cap_elem;
developer66e89bc2024-04-23 14:50:01 +08001201
developer9237f442024-06-14 17:13:04 +08001202 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_EHT, sizeof(*eht));
developer66e89bc2024-04-23 14:50:01 +08001203
developer9237f442024-06-14 17:13:04 +08001204@@ -1444,7 +1446,7 @@ mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
1205 eht->phy_cap_ext = cpu_to_le64(elem->phy_cap_info[8]);
developer66e89bc2024-04-23 14:50:01 +08001206
developer9237f442024-06-14 17:13:04 +08001207 if (vif->type != NL80211_IFTYPE_STATION &&
1208- (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] &
1209+ (link_sta->he_cap.he_cap_elem.phy_cap_info[0] &
1210 (IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G |
1211 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G |
1212 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G |
1213@@ -1460,44 +1462,44 @@ mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
developer66e89bc2024-04-23 14:50:01 +08001214 }
1215
developer9237f442024-06-14 17:13:04 +08001216 static void
1217-mt7996_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
1218+mt7996_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta)
developer66e89bc2024-04-23 14:50:01 +08001219 {
developer9237f442024-06-14 17:13:04 +08001220 struct sta_rec_ht_uni *ht;
1221 struct tlv *tlv;
developer66e89bc2024-04-23 14:50:01 +08001222
developer9237f442024-06-14 17:13:04 +08001223- if (!sta->deflink.ht_cap.ht_supported)
1224+ if (!link_sta->ht_cap.ht_supported)
1225 return;
developer66e89bc2024-04-23 14:50:01 +08001226
developer9237f442024-06-14 17:13:04 +08001227 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HT, sizeof(*ht));
developer66e89bc2024-04-23 14:50:01 +08001228
developer9237f442024-06-14 17:13:04 +08001229 ht = (struct sta_rec_ht_uni *)tlv;
1230- ht->ht_cap = cpu_to_le16(sta->deflink.ht_cap.cap);
1231- ht->ampdu_param = u8_encode_bits(sta->deflink.ht_cap.ampdu_factor,
1232+ ht->ht_cap = cpu_to_le16(link_sta->ht_cap.cap);
1233+ ht->ampdu_param = u8_encode_bits(link_sta->ht_cap.ampdu_factor,
1234 IEEE80211_HT_AMPDU_PARM_FACTOR) |
1235- u8_encode_bits(sta->deflink.ht_cap.ampdu_density,
1236+ u8_encode_bits(link_sta->ht_cap.ampdu_density,
1237 IEEE80211_HT_AMPDU_PARM_DENSITY);
developer66e89bc2024-04-23 14:50:01 +08001238 }
1239
developer9237f442024-06-14 17:13:04 +08001240 static void
1241-mt7996_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
1242+mt7996_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta)
developer66e89bc2024-04-23 14:50:01 +08001243 {
developer9237f442024-06-14 17:13:04 +08001244 struct sta_rec_vht *vht;
1245 struct tlv *tlv;
1246 #ifdef CONFIG_MTK_VENDOR
1247- struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
1248+ struct mt7996_sta *msta = (struct mt7996_sta *)link_sta->sta->drv_priv;
1249 struct mt7996_phy *phy = (struct mt7996_phy *)msta->vif->deflink.phy;
1250 #endif
developer66e89bc2024-04-23 14:50:01 +08001251
developer9237f442024-06-14 17:13:04 +08001252 /* For 6G band, this tlv is necessary to let hw work normally */
1253- if (!sta->deflink.he_6ghz_capa.capa && !sta->deflink.vht_cap.vht_supported)
1254+ if (!link_sta->he_6ghz_capa.capa && !link_sta->vht_cap.vht_supported)
1255 return;
developer66e89bc2024-04-23 14:50:01 +08001256
developer9237f442024-06-14 17:13:04 +08001257 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_VHT, sizeof(*vht));
developer66e89bc2024-04-23 14:50:01 +08001258
developer9237f442024-06-14 17:13:04 +08001259 vht = (struct sta_rec_vht *)tlv;
1260- vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap);
1261- vht->vht_rx_mcs_map = sta->deflink.vht_cap.vht_mcs.rx_mcs_map;
1262- vht->vht_tx_mcs_map = sta->deflink.vht_cap.vht_mcs.tx_mcs_map;
1263+ vht->vht_cap = cpu_to_le32(link_sta->vht_cap.cap);
1264+ vht->vht_rx_mcs_map = link_sta->vht_cap.vht_mcs.rx_mcs_map;
1265+ vht->vht_tx_mcs_map = link_sta->vht_cap.vht_mcs.tx_mcs_map;
1266 #ifdef CONFIG_MTK_VENDOR
1267 vht->rts_bw_sig = phy->rts_bw_sig;
1268 #endif
1269@@ -1505,9 +1507,10 @@ mt7996_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
developer66e89bc2024-04-23 14:50:01 +08001270
1271 static void
developer9237f442024-06-14 17:13:04 +08001272 mt7996_mcu_sta_amsdu_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1273- struct ieee80211_vif *vif, struct ieee80211_sta *sta)
1274+ struct ieee80211_vif *vif,
1275+ struct ieee80211_link_sta *link_sta,
1276+ struct mt7996_link_sta *mlink)
developer66e89bc2024-04-23 14:50:01 +08001277 {
developer9237f442024-06-14 17:13:04 +08001278- struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
1279 struct sta_rec_amsdu *amsdu;
1280 struct tlv *tlv;
developer66e89bc2024-04-23 14:50:01 +08001281
developer9237f442024-06-14 17:13:04 +08001282@@ -1516,16 +1519,16 @@ mt7996_mcu_sta_amsdu_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1283 vif->type != NL80211_IFTYPE_AP)
1284 return;
developer66e89bc2024-04-23 14:50:01 +08001285
developer9237f442024-06-14 17:13:04 +08001286- if (!sta->deflink.agg.max_amsdu_len)
1287+ if (!link_sta->agg.max_amsdu_len)
1288 return;
developer66e89bc2024-04-23 14:50:01 +08001289
developer9237f442024-06-14 17:13:04 +08001290 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HW_AMSDU, sizeof(*amsdu));
1291 amsdu = (struct sta_rec_amsdu *)tlv;
1292 amsdu->max_amsdu_num = 8;
1293 amsdu->amsdu_en = true;
1294- msta->wcid.amsdu = true;
1295+ mlink->wcid.amsdu = true;
developer66e89bc2024-04-23 14:50:01 +08001296
developer9237f442024-06-14 17:13:04 +08001297- switch (sta->deflink.agg.max_amsdu_len) {
1298+ switch (link_sta->agg.max_amsdu_len) {
1299 case IEEE80211_MAX_MPDU_LEN_VHT_11454:
1300 amsdu->max_mpdu_size =
1301 IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454;
1302@@ -1544,10 +1547,10 @@ static void
developer66e89bc2024-04-23 14:50:01 +08001303 mt7996_mcu_sta_muru_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
developer9237f442024-06-14 17:13:04 +08001304 struct ieee80211_bss_conf *conf,
1305 struct mt7996_bss_conf *mconf,
1306- struct ieee80211_sta *sta)
1307+ struct ieee80211_link_sta *link_sta)
developer66e89bc2024-04-23 14:50:01 +08001308 {
developer9237f442024-06-14 17:13:04 +08001309 struct mt7996_phy *phy = mconf->phy;
1310- struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem;
1311+ struct ieee80211_he_cap_elem *elem = &link_sta->he_cap.he_cap_elem;
developer66e89bc2024-04-23 14:50:01 +08001312 struct sta_rec_muru *muru;
1313 struct tlv *tlv;
1314
developer9237f442024-06-14 17:13:04 +08001315@@ -1567,11 +1570,11 @@ mt7996_mcu_sta_muru_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1316 muru->cfg.ofdma_dl_en = !!(phy->muru_onoff & OFDMA_DL);
1317 muru->cfg.ofdma_ul_en = !!(phy->muru_onoff & OFDMA_UL);
developer66e89bc2024-04-23 14:50:01 +08001318
developer9237f442024-06-14 17:13:04 +08001319- if (sta->deflink.vht_cap.vht_supported)
1320+ if (link_sta->vht_cap.vht_supported)
1321 muru->mimo_dl.vht_mu_bfee =
1322- !!(sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE);
1323+ !!(link_sta->vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE);
developer66e89bc2024-04-23 14:50:01 +08001324
developer9237f442024-06-14 17:13:04 +08001325- if (!sta->deflink.he_cap.has_he)
1326+ if (!link_sta->he_cap.has_he)
1327 return;
developer66e89bc2024-04-23 14:50:01 +08001328
developer9237f442024-06-14 17:13:04 +08001329 muru->mimo_dl.partial_bw_dl_mimo =
1330@@ -1604,7 +1607,7 @@ mt7996_mcu_sta_muru_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
developer66e89bc2024-04-23 14:50:01 +08001331 static inline bool
developer9237f442024-06-14 17:13:04 +08001332 mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
1333 struct mt7996_bss_conf *mconf,
1334- struct ieee80211_sta *sta, bool bfee)
1335+ struct ieee80211_link_sta *link_sta, bool bfee)
developer66e89bc2024-04-23 14:50:01 +08001336 {
1337 int sts = hweight16(phy->mt76->chainmask);
1338
developer9237f442024-06-14 17:13:04 +08001339@@ -1615,8 +1618,8 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
1340 if (!bfee && sts < 2)
developer66e89bc2024-04-23 14:50:01 +08001341 return false;
1342
developer9237f442024-06-14 17:13:04 +08001343- if (sta->deflink.eht_cap.has_eht) {
1344- struct ieee80211_sta_eht_cap *pc = &sta->deflink.eht_cap;
1345+ if (link_sta->eht_cap.has_eht) {
1346+ struct ieee80211_sta_eht_cap *pc = &link_sta->eht_cap;
developer66e89bc2024-04-23 14:50:01 +08001347 struct ieee80211_eht_cap_elem_fixed *pe = &pc->eht_cap_elem;
1348
1349 if (bfee)
developer9237f442024-06-14 17:13:04 +08001350@@ -1627,8 +1630,8 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
developer05f3b2b2024-08-19 19:17:34 +08001351 EHT_PHY(CAP0_SU_BEAMFORMEE, pe->phy_cap_info[0]);
developer66e89bc2024-04-23 14:50:01 +08001352 }
1353
developer9237f442024-06-14 17:13:04 +08001354- if (sta->deflink.he_cap.has_he) {
1355- struct ieee80211_he_cap_elem *pe = &sta->deflink.he_cap.he_cap_elem;
1356+ if (link_sta->he_cap.has_he) {
1357+ struct ieee80211_he_cap_elem *pe = &link_sta->he_cap.he_cap_elem;
1358
1359 if (bfee)
1360 return conf->he_su_beamformee &&
1361@@ -1638,8 +1641,8 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
1362 HE_PHY(CAP4_SU_BEAMFORMEE, pe->phy_cap_info[4]);
1363 }
1364
1365- if (sta->deflink.vht_cap.vht_supported) {
1366- u32 cap = sta->deflink.vht_cap.cap;
1367+ if (link_sta->vht_cap.vht_supported) {
1368+ u32 cap = link_sta->vht_cap.cap;
1369
1370 if (bfee)
1371 return conf->vht_su_beamformee &&
1372@@ -1662,10 +1665,10 @@ mt7996_mcu_sta_sounding_rate(struct sta_rec_bf *bf)
1373 }
1374
1375 static void
1376-mt7996_mcu_sta_bfer_ht(struct ieee80211_sta *sta, struct mt7996_phy *phy,
1377- struct sta_rec_bf *bf)
1378+mt7996_mcu_sta_bfer_ht(struct ieee80211_link_sta *link_sta,
1379+ struct mt7996_phy *phy, struct sta_rec_bf *bf)
1380 {
1381- struct ieee80211_mcs_info *mcs = &sta->deflink.ht_cap.mcs;
1382+ struct ieee80211_mcs_info *mcs = &link_sta->ht_cap.mcs;
1383 u8 n = 0;
1384
1385 bf->tx_mode = MT_PHY_TYPE_HT;
1386@@ -1687,10 +1690,11 @@ mt7996_mcu_sta_bfer_ht(struct ieee80211_sta *sta, struct mt7996_phy *phy,
1387 }
1388
1389 static void
1390-mt7996_mcu_sta_bfer_vht(struct ieee80211_sta *sta, struct mt7996_phy *phy,
1391- struct sta_rec_bf *bf, bool explicit)
1392+mt7996_mcu_sta_bfer_vht(struct ieee80211_link_sta *link_sta,
1393+ struct mt7996_phy *phy, struct sta_rec_bf *bf,
1394+ bool explicit)
1395 {
1396- struct ieee80211_sta_vht_cap *pc = &sta->deflink.vht_cap;
1397+ struct ieee80211_sta_vht_cap *pc = &link_sta->vht_cap;
1398 struct ieee80211_sta_vht_cap *vc = &phy->mt76->sband_5g.sband.vht_cap;
1399 u16 mcs_map = le16_to_cpu(pc->vht_mcs.rx_mcs_map);
1400 u8 nss_mcs = mt7996_mcu_get_sta_nss(mcs_map);
1401@@ -1711,23 +1715,24 @@ mt7996_mcu_sta_bfer_vht(struct ieee80211_sta *sta, struct mt7996_phy *phy,
1402 bf->ncol = min_t(u8, nss_mcs, bf->nrow);
1403 bf->ibf_ncol = bf->ncol;
1404
1405- if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160)
1406+ if (link_sta->bandwidth == IEEE80211_STA_RX_BW_160)
1407 bf->nrow = 1;
1408 } else {
1409 bf->nrow = tx_ant;
1410 bf->ncol = min_t(u8, nss_mcs, bf->nrow);
1411 bf->ibf_ncol = nss_mcs;
developer66e89bc2024-04-23 14:50:01 +08001412
developer9237f442024-06-14 17:13:04 +08001413- if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160)
1414+ if (link_sta->bandwidth == IEEE80211_STA_RX_BW_160)
1415 bf->ibf_nrow = 1;
developer66e89bc2024-04-23 14:50:01 +08001416 }
developer9237f442024-06-14 17:13:04 +08001417 }
developer66e89bc2024-04-23 14:50:01 +08001418
developer9237f442024-06-14 17:13:04 +08001419 static void
1420-mt7996_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
1421- struct mt7996_phy *phy, struct sta_rec_bf *bf)
1422+mt7996_mcu_sta_bfer_he(struct ieee80211_link_sta *link_sta,
1423+ struct ieee80211_vif *vif, struct mt7996_phy *phy,
1424+ struct sta_rec_bf *bf)
1425 {
1426- struct ieee80211_sta_he_cap *pc = &sta->deflink.he_cap;
1427+ struct ieee80211_sta_he_cap *pc = &link_sta->he_cap;
1428 struct ieee80211_he_cap_elem *pe = &pc->he_cap_elem;
1429 const struct ieee80211_sta_he_cap *vc =
1430 mt76_connac_get_he_phy_cap(phy->mt76, vif);
1431@@ -1752,7 +1757,7 @@ mt7996_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
1432 bf->ncol = min_t(u8, nss_mcs, bf->nrow);
1433 bf->ibf_ncol = bf->ncol;
developer66e89bc2024-04-23 14:50:01 +08001434
developer9237f442024-06-14 17:13:04 +08001435- if (sta->deflink.bandwidth != IEEE80211_STA_RX_BW_160)
1436+ if (link_sta->bandwidth != IEEE80211_STA_RX_BW_160)
1437 return;
1438
1439 /* go over for 160MHz and 80p80 */
1440@@ -1784,10 +1789,11 @@ mt7996_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
1441 }
1442
1443 static void
1444-mt7996_mcu_sta_bfer_eht(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
1445- struct mt7996_phy *phy, struct sta_rec_bf *bf)
1446+mt7996_mcu_sta_bfer_eht(struct ieee80211_link_sta *link_sta,
1447+ struct ieee80211_vif *vif, struct mt7996_phy *phy,
1448+ struct sta_rec_bf *bf)
1449 {
1450- struct ieee80211_sta_eht_cap *pc = &sta->deflink.eht_cap;
1451+ struct ieee80211_sta_eht_cap *pc = &link_sta->eht_cap;
1452 struct ieee80211_eht_cap_elem_fixed *pe = &pc->eht_cap_elem;
1453 struct ieee80211_eht_mcs_nss_supp *eht_nss = &pc->eht_mcs_nss_supp;
1454 const struct ieee80211_sta_eht_cap *vc =
1455@@ -1810,10 +1816,10 @@ mt7996_mcu_sta_bfer_eht(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
1456 bf->ncol = min_t(u8, nss_mcs, bf->nrow);
1457 bf->ibf_ncol = bf->ncol;
developer66e89bc2024-04-23 14:50:01 +08001458
developer9237f442024-06-14 17:13:04 +08001459- if (sta->deflink.bandwidth < IEEE80211_STA_RX_BW_160)
1460+ if (link_sta->bandwidth < IEEE80211_STA_RX_BW_160)
1461 return;
developer66e89bc2024-04-23 14:50:01 +08001462
developer9237f442024-06-14 17:13:04 +08001463- switch (sta->deflink.bandwidth) {
1464+ switch (link_sta->bandwidth) {
1465 case IEEE80211_STA_RX_BW_160:
1466 snd_dim = EHT_PHY(CAP2_SOUNDING_DIM_160MHZ_MASK, ve->phy_cap_info[2]);
1467 sts = EHT_PHY(CAP1_BEAMFORMEE_SS_160MHZ_MASK, pe->phy_cap_info[1]);
1468@@ -1842,7 +1848,7 @@ mt7996_mcu_sta_bfer_eht(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
developer66e89bc2024-04-23 14:50:01 +08001469 static void
1470 mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
developer9237f442024-06-14 17:13:04 +08001471 struct ieee80211_bss_conf *conf, struct mt7996_bss_conf *mconf,
1472- struct ieee80211_sta *sta)
1473+ struct ieee80211_link_sta *link_sta)
developer66e89bc2024-04-23 14:50:01 +08001474 {
developer9237f442024-06-14 17:13:04 +08001475 struct mt7996_phy *phy = mconf->phy;
developer66e89bc2024-04-23 14:50:01 +08001476 int tx_ant = hweight16(phy->mt76->chainmask) - 1;
developer9237f442024-06-14 17:13:04 +08001477@@ -1856,10 +1862,10 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1478 };
1479 bool ebf;
1480
1481- if (!(sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he))
1482+ if (!(link_sta->ht_cap.ht_supported || link_sta->he_cap.has_he))
developer66e89bc2024-04-23 14:50:01 +08001483 return;
1484
developer9237f442024-06-14 17:13:04 +08001485- ebf = mt7996_is_ebf_supported(phy, conf, mconf, sta, false);
1486+ ebf = mt7996_is_ebf_supported(phy, conf, mconf, link_sta, false);
developer66e89bc2024-04-23 14:50:01 +08001487 if (!ebf && !dev->ibf)
1488 return;
1489
developer9237f442024-06-14 17:13:04 +08001490@@ -1870,23 +1876,23 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1491 * vht: support eBF and iBF
developer66e89bc2024-04-23 14:50:01 +08001492 * ht: iBF only, since mac80211 lacks of eBF support
1493 */
developer9237f442024-06-14 17:13:04 +08001494- if (sta->deflink.eht_cap.has_eht && ebf)
1495- mt7996_mcu_sta_bfer_eht(sta, conf->vif, phy, bf);
1496- else if (sta->deflink.he_cap.has_he && ebf)
1497- mt7996_mcu_sta_bfer_he(sta, conf->vif, phy, bf);
1498- else if (sta->deflink.vht_cap.vht_supported)
1499- mt7996_mcu_sta_bfer_vht(sta, phy, bf, ebf);
1500- else if (sta->deflink.ht_cap.ht_supported)
1501- mt7996_mcu_sta_bfer_ht(sta, phy, bf);
1502+ if (link_sta->eht_cap.has_eht && ebf)
1503+ mt7996_mcu_sta_bfer_eht(link_sta, conf->vif, phy, bf);
1504+ else if (link_sta->he_cap.has_he && ebf)
1505+ mt7996_mcu_sta_bfer_he(link_sta, conf->vif, phy, bf);
1506+ else if (link_sta->vht_cap.vht_supported)
1507+ mt7996_mcu_sta_bfer_vht(link_sta, phy, bf, ebf);
1508+ else if (link_sta->ht_cap.ht_supported)
1509+ mt7996_mcu_sta_bfer_ht(link_sta, phy, bf);
1510 else
1511 return;
developer66e89bc2024-04-23 14:50:01 +08001512
developer9237f442024-06-14 17:13:04 +08001513 bf->bf_cap = ebf ? ebf : dev->ibf << 1;
1514- bf->bw = sta->deflink.bandwidth;
1515- bf->ibf_dbw = sta->deflink.bandwidth;
1516+ bf->bw = link_sta->bandwidth;
1517+ bf->ibf_dbw = link_sta->bandwidth;
1518 bf->ibf_nrow = tx_ant;
1519
1520- if (!ebf && sta->deflink.bandwidth <= IEEE80211_STA_RX_BW_40 && !bf->ncol)
1521+ if (!ebf && link_sta->bandwidth <= IEEE80211_STA_RX_BW_40 && !bf->ncol)
1522 bf->ibf_timeout = 0x48;
1523 else
1524 bf->ibf_timeout = 0x18;
1525@@ -1896,7 +1902,7 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1526 else
1527 bf->mem_20m = matrix[bf->nrow][bf->ncol];
1528
1529- switch (sta->deflink.bandwidth) {
1530+ switch (link_sta->bandwidth) {
1531 case IEEE80211_STA_RX_BW_160:
1532 case IEEE80211_STA_RX_BW_80:
1533 bf->mem_total = bf->mem_20m * 2;
1534@@ -1913,7 +1919,8 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
developer66e89bc2024-04-23 14:50:01 +08001535 static void
1536 mt7996_mcu_sta_bfee_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
developer9237f442024-06-14 17:13:04 +08001537 struct ieee80211_bss_conf *conf,
1538- struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta)
1539+ struct mt7996_bss_conf *mconf,
1540+ struct ieee80211_link_sta *link_sta)
developer66e89bc2024-04-23 14:50:01 +08001541 {
developer9237f442024-06-14 17:13:04 +08001542 struct mt7996_phy *phy = mconf->phy;
developer66e89bc2024-04-23 14:50:01 +08001543 int tx_ant = hweight8(phy->mt76->antenna_mask) - 1;
developer9237f442024-06-14 17:13:04 +08001544@@ -1921,22 +1928,22 @@ mt7996_mcu_sta_bfee_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
developer66e89bc2024-04-23 14:50:01 +08001545 struct tlv *tlv;
developer9237f442024-06-14 17:13:04 +08001546 u8 nrow = 0;
1547
1548- if (!(sta->deflink.vht_cap.vht_supported || sta->deflink.he_cap.has_he))
1549+ if (!(link_sta->vht_cap.vht_supported || link_sta->he_cap.has_he))
developer66e89bc2024-04-23 14:50:01 +08001550 return;
1551
developer9237f442024-06-14 17:13:04 +08001552- if (!mt7996_is_ebf_supported(phy, conf, mconf, sta, true))
1553+ if (!mt7996_is_ebf_supported(phy, conf, mconf, link_sta, true))
developer66e89bc2024-04-23 14:50:01 +08001554 return;
1555
1556 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_BFEE, sizeof(*bfee));
developer9237f442024-06-14 17:13:04 +08001557 bfee = (struct sta_rec_bfee *)tlv;
1558
1559- if (sta->deflink.he_cap.has_he) {
1560- struct ieee80211_he_cap_elem *pe = &sta->deflink.he_cap.he_cap_elem;
1561+ if (link_sta->he_cap.has_he) {
1562+ struct ieee80211_he_cap_elem *pe = &link_sta->he_cap.he_cap_elem;
developer66e89bc2024-04-23 14:50:01 +08001563
developer9237f442024-06-14 17:13:04 +08001564 nrow = HE_PHY(CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK,
1565 pe->phy_cap_info[5]);
1566- } else if (sta->deflink.vht_cap.vht_supported) {
1567- struct ieee80211_sta_vht_cap *pc = &sta->deflink.vht_cap;
1568+ } else if (link_sta->vht_cap.vht_supported) {
1569+ struct ieee80211_sta_vht_cap *pc = &link_sta->vht_cap;
1570
1571 nrow = FIELD_GET(IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK,
1572 pc->cap);
1573@@ -1973,25 +1980,24 @@ mt7996_mcu_sta_hdrt_tlv(struct mt7996_dev *dev, struct sk_buff *skb)
1574 static void
1575 mt7996_mcu_sta_hdr_trans_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1576 struct ieee80211_vif *vif,
1577- struct ieee80211_sta *sta)
1578+ struct mt7996_link_sta *mlink)
developer66e89bc2024-04-23 14:50:01 +08001579 {
developer9237f442024-06-14 17:13:04 +08001580 struct sta_rec_hdr_trans *hdr_trans;
1581- struct mt76_wcid *wcid;
1582+ struct mt76_wcid *wcid = &mlink->wcid;
1583 struct tlv *tlv;
1584
1585 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HDR_TRANS, sizeof(*hdr_trans));
1586 hdr_trans = (struct sta_rec_hdr_trans *)tlv;
1587 hdr_trans->dis_rx_hdr_tran = true;
1588
1589+ if (!wcid->sta)
1590+ return;
1591+
1592 if (vif->type == NL80211_IFTYPE_STATION)
1593 hdr_trans->to_ds = true;
1594 else
1595 hdr_trans->from_ds = true;
1596
1597- if (!sta)
1598- return;
1599-
1600- wcid = (struct mt76_wcid *)sta->drv_priv;
1601 hdr_trans->dis_rx_hdr_tran = !test_bit(MT_WCID_FLAG_HDR_TRANS, &wcid->flags);
1602 if (test_bit(MT_WCID_FLAG_4ADDR, &wcid->flags)) {
1603 hdr_trans->to_ds = true;
1604@@ -2048,16 +2054,17 @@ int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev,
1605
1606 int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev,
1607 struct mt7996_bss_conf *mconf,
1608- struct ieee80211_sta *sta, void *data, u32 field)
1609+ struct ieee80211_link_sta *link_sta,
1610+ struct mt7996_link_sta *mlink, void *data,
1611+ u32 field)
1612 {
1613- struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer66e89bc2024-04-23 14:50:01 +08001614 struct sta_phy_uni *phy = data;
1615 struct sta_rec_ra_fixed_uni *ra;
1616 struct sk_buff *skb;
1617 struct tlv *tlv;
1618
developer9237f442024-06-14 17:13:04 +08001619 skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76,
1620- &msta->wcid,
1621+ &mlink->wcid,
developer66e89bc2024-04-23 14:50:01 +08001622 MT7996_STA_UPDATE_MAX_SIZE);
1623 if (IS_ERR(skb))
developer9237f442024-06-14 17:13:04 +08001624 return PTR_ERR(skb);
1625@@ -2076,7 +2083,7 @@ int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev,
1626 ra->phy = *phy;
1627 break;
1628 case RATE_PARAM_MMPS_UPDATE:
1629- ra->mmps_mode = mt7996_mcu_get_mmps_mode(sta->deflink.smps_mode);
1630+ ra->mmps_mode = mt7996_mcu_get_mmps_mode(link_sta->smps_mode);
1631 break;
1632 default:
1633 break;
1634@@ -2091,7 +2098,8 @@ static int
1635 mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev,
1636 struct ieee80211_bss_conf *conf,
1637 struct mt7996_bss_conf *mconf,
1638- struct ieee80211_sta *sta)
1639+ struct ieee80211_link_sta *link_sta,
1640+ struct mt7996_link_sta *mlink)
developer66e89bc2024-04-23 14:50:01 +08001641 {
developer9237f442024-06-14 17:13:04 +08001642 struct cfg80211_chan_def *chandef = &mconf->phy->mt76->chandef;
1643 struct cfg80211_bitrate_mask *mask = &mconf->bitrate_mask;
1644@@ -2115,11 +2123,11 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev,
1645 } \
1646 } while (0)
1647
1648- if (sta->deflink.he_cap.has_he) {
1649+ if (link_sta->he_cap.has_he) {
1650 __sta_phy_bitrate_mask_check(he_mcs, he_gi, 0, 1);
1651- } else if (sta->deflink.vht_cap.vht_supported) {
1652+ } else if (link_sta->vht_cap.vht_supported) {
1653 __sta_phy_bitrate_mask_check(vht_mcs, gi, 0, 0);
1654- } else if (sta->deflink.ht_cap.ht_supported) {
1655+ } else if (link_sta->ht_cap.ht_supported) {
1656 __sta_phy_bitrate_mask_check(ht_mcs, gi, 1, 0);
1657 } else {
1658 nrates = hweight32(mask->control[band].legacy);
1659@@ -2136,8 +2144,8 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev,
developer66e89bc2024-04-23 14:50:01 +08001660
1661 /* fixed single rate */
1662 if (nrates == 1) {
developer9237f442024-06-14 17:13:04 +08001663- ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy,
1664- RATE_PARAM_FIXED_MCS);
1665+ ret = mt7996_mcu_set_fixed_field(dev, mconf, link_sta, mlink,
1666+ &phy, RATE_PARAM_FIXED_MCS);
developer66e89bc2024-04-23 14:50:01 +08001667 if (ret)
1668 return ret;
developer9237f442024-06-14 17:13:04 +08001669 }
1670@@ -2145,29 +2153,28 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev,
1671 /* fixed GI */
1672 if (mask->control[band].gi != NL80211_TXRATE_DEFAULT_GI ||
1673 mask->control[band].he_gi != GENMASK(7, 0)) {
1674- struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
1675 u32 addr;
1676
1677 /* firmware updates only TXCMD but doesn't take WTBL into
1678 * account, so driver should update here to reflect the
1679 * actual txrate hardware sends out.
1680 */
1681- addr = mt7996_mac_wtbl_lmac_addr(dev, msta->wcid.idx, 7);
1682- if (sta->deflink.he_cap.has_he)
1683+ addr = mt7996_mac_wtbl_lmac_addr(dev, mlink->wcid.idx, 7);
1684+ if (link_sta->he_cap.has_he)
1685 mt76_rmw_field(dev, addr, GENMASK(31, 24), phy.sgi);
developer66e89bc2024-04-23 14:50:01 +08001686 else
1687 mt76_rmw_field(dev, addr, GENMASK(15, 12), phy.sgi);
1688
developer9237f442024-06-14 17:13:04 +08001689- ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy,
1690- RATE_PARAM_FIXED_GI);
1691+ ret = mt7996_mcu_set_fixed_field(dev, mconf, link_sta, mlink,
1692+ &phy, RATE_PARAM_FIXED_GI);
developer66e89bc2024-04-23 14:50:01 +08001693 if (ret)
1694 return ret;
developer9237f442024-06-14 17:13:04 +08001695 }
developer66e89bc2024-04-23 14:50:01 +08001696
1697 /* fixed HE_LTF */
1698 if (mask->control[band].he_ltf != GENMASK(7, 0)) {
developer9237f442024-06-14 17:13:04 +08001699- ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy,
1700- RATE_PARAM_FIXED_HE_LTF);
1701+ ret = mt7996_mcu_set_fixed_field(dev, mconf, link_sta, mlink,
1702+ &phy, RATE_PARAM_FIXED_HE_LTF);
developer66e89bc2024-04-23 14:50:01 +08001703 if (ret)
1704 return ret;
developer9237f442024-06-14 17:13:04 +08001705 }
1706@@ -2179,7 +2186,7 @@ static void
developer66e89bc2024-04-23 14:50:01 +08001707 mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev,
developer9237f442024-06-14 17:13:04 +08001708 struct ieee80211_bss_conf *conf,
1709 struct mt7996_bss_conf *mconf,
1710- struct ieee80211_sta *sta)
1711+ struct ieee80211_link_sta *link_sta)
developer66e89bc2024-04-23 14:50:01 +08001712 {
1713 #define INIT_RCPI 180
developer9237f442024-06-14 17:13:04 +08001714 struct mt76_phy *mphy = mconf->phy->mt76;
1715@@ -2188,20 +2195,20 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev,
developer66e89bc2024-04-23 14:50:01 +08001716 enum nl80211_band band = chandef->chan->band;
1717 struct sta_rec_ra_uni *ra;
1718 struct tlv *tlv;
developer9237f442024-06-14 17:13:04 +08001719- u32 supp_rate = sta->deflink.supp_rates[band];
1720- u32 cap = sta->wme ? STA_CAP_WMM : 0;
1721+ u32 supp_rate = link_sta->supp_rates[band];
1722+ u32 cap = link_sta->sta->wme ? STA_CAP_WMM : 0;
1723
1724 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra));
1725 ra = (struct sta_rec_ra_uni *)tlv;
developer66e89bc2024-04-23 14:50:01 +08001726
1727 ra->valid = true;
1728 ra->auto_rate = true;
developer05f3b2b2024-08-19 19:17:34 +08001729- ra->phy_mode = mt76_connac_get_phy_mode(mphy, conf->vif, band, &sta->deflink);
developer9237f442024-06-14 17:13:04 +08001730+ ra->phy_mode = mt76_connac_get_phy_mode(mphy, conf->vif, band, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001731 ra->channel = chandef->chan->hw_value;
developer9237f442024-06-14 17:13:04 +08001732- ra->bw = (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_320) ?
1733- CMD_CBW_320MHZ : sta->deflink.bandwidth;
1734+ ra->bw = (link_sta->bandwidth == IEEE80211_STA_RX_BW_320) ?
1735+ CMD_CBW_320MHZ : link_sta->bandwidth;
1736 ra->phy.bw = ra->bw;
1737- ra->mmps_mode = mt7996_mcu_get_mmps_mode(sta->deflink.smps_mode);
1738+ ra->mmps_mode = mt7996_mcu_get_mmps_mode(link_sta->smps_mode);
1739
1740 if (supp_rate) {
1741 supp_rate &= mask->control[band].legacy;
1742@@ -2221,60 +2228,60 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev,
1743 }
1744 }
1745
1746- if (sta->deflink.ht_cap.ht_supported) {
1747+ if (link_sta->ht_cap.ht_supported) {
1748 ra->supp_mode |= MODE_HT;
1749- ra->af = sta->deflink.ht_cap.ampdu_factor;
1750- ra->ht_gf = !!(sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD);
1751+ ra->af = link_sta->ht_cap.ampdu_factor;
1752+ ra->ht_gf = !!(link_sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD);
1753
1754 cap |= STA_CAP_HT;
1755- if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_20)
1756+ if (link_sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20)
1757 cap |= STA_CAP_SGI_20;
1758- if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_40)
1759+ if (link_sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40)
1760 cap |= STA_CAP_SGI_40;
1761- if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_TX_STBC)
1762+ if (link_sta->ht_cap.cap & IEEE80211_HT_CAP_TX_STBC)
developer66e89bc2024-04-23 14:50:01 +08001763 cap |= STA_CAP_TX_STBC;
developer9237f442024-06-14 17:13:04 +08001764- if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_RX_STBC)
1765+ if (link_sta->ht_cap.cap & IEEE80211_HT_CAP_RX_STBC)
developer66e89bc2024-04-23 14:50:01 +08001766 cap |= STA_CAP_RX_STBC;
developer9237f442024-06-14 17:13:04 +08001767 if (conf->ht_ldpc &&
1768- (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING))
1769+ (link_sta->ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING))
developer66e89bc2024-04-23 14:50:01 +08001770 cap |= STA_CAP_LDPC;
1771
developer9237f442024-06-14 17:13:04 +08001772- mt7996_mcu_set_sta_ht_mcs(sta, ra->ht_mcs,
1773+ mt7996_mcu_set_sta_ht_mcs(link_sta, ra->ht_mcs,
1774 mask->control[band].ht_mcs);
1775 ra->supp_ht_mcs = *(__le32 *)ra->ht_mcs;
1776 }
1777
1778- if (sta->deflink.vht_cap.vht_supported) {
1779+ if (link_sta->vht_cap.vht_supported) {
1780 u8 af;
1781
1782 ra->supp_mode |= MODE_VHT;
1783 af = FIELD_GET(IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK,
1784- sta->deflink.vht_cap.cap);
1785+ link_sta->vht_cap.cap);
1786 ra->af = max_t(u8, ra->af, af);
1787
1788 cap |= STA_CAP_VHT;
1789- if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80)
1790+ if (link_sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80)
1791 cap |= STA_CAP_VHT_SGI_80;
1792- if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_160)
1793+ if (link_sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_160)
1794 cap |= STA_CAP_VHT_SGI_160;
1795- if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_TXSTBC)
1796+ if (link_sta->vht_cap.cap & IEEE80211_VHT_CAP_TXSTBC)
developer66e89bc2024-04-23 14:50:01 +08001797 cap |= STA_CAP_VHT_TX_STBC;
developer9237f442024-06-14 17:13:04 +08001798- if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXSTBC_1)
1799+ if (link_sta->vht_cap.cap & IEEE80211_VHT_CAP_RXSTBC_1)
developer66e89bc2024-04-23 14:50:01 +08001800 cap |= STA_CAP_VHT_RX_STBC;
developer9237f442024-06-14 17:13:04 +08001801 if (conf->vht_ldpc &&
1802- (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC))
1803+ (link_sta->vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC))
developer66e89bc2024-04-23 14:50:01 +08001804 cap |= STA_CAP_VHT_LDPC;
1805
developer9237f442024-06-14 17:13:04 +08001806- mt7996_mcu_set_sta_vht_mcs(sta, ra->supp_vht_mcs,
1807+ mt7996_mcu_set_sta_vht_mcs(link_sta, ra->supp_vht_mcs,
1808 mask->control[band].vht_mcs);
1809 }
developer66e89bc2024-04-23 14:50:01 +08001810
developer9237f442024-06-14 17:13:04 +08001811- if (sta->deflink.he_cap.has_he) {
1812+ if (link_sta->he_cap.has_he) {
1813 ra->supp_mode |= MODE_HE;
1814 cap |= STA_CAP_HE;
1815
1816- if (sta->deflink.he_6ghz_capa.capa)
1817- ra->af = le16_get_bits(sta->deflink.he_6ghz_capa.capa,
1818+ if (link_sta->he_6ghz_capa.capa)
1819+ ra->af = le16_get_bits(link_sta->he_6ghz_capa.capa,
1820 IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP);
1821 }
1822 ra->sta_cap = cpu_to_le32(cap);
1823@@ -2285,14 +2292,14 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev,
1824 int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev,
1825 struct ieee80211_bss_conf *conf,
1826 struct mt7996_bss_conf *mconf,
1827- struct ieee80211_sta *sta, bool changed)
1828+ struct ieee80211_link_sta *link_sta,
1829+ struct mt7996_link_sta *mlink, bool changed)
developer66e89bc2024-04-23 14:50:01 +08001830 {
developer9237f442024-06-14 17:13:04 +08001831- struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer66e89bc2024-04-23 14:50:01 +08001832 struct sk_buff *skb;
1833 int ret;
1834
developer9237f442024-06-14 17:13:04 +08001835 skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76,
1836- &msta->wcid,
1837+ &mlink->wcid,
developer66e89bc2024-04-23 14:50:01 +08001838 MT7996_STA_UPDATE_MAX_SIZE);
1839 if (IS_ERR(skb))
developer9237f442024-06-14 17:13:04 +08001840 return PTR_ERR(skb);
1841@@ -2302,26 +2309,27 @@ int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev,
developer66e89bc2024-04-23 14:50:01 +08001842 * update sta_rec_he here.
1843 */
1844 if (changed)
developer9237f442024-06-14 17:13:04 +08001845- mt7996_mcu_sta_he_tlv(skb, conf, mconf, sta);
1846+ mt7996_mcu_sta_he_tlv(skb, conf, mconf, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001847
1848 /* sta_rec_ra accommodates BW, NSS and only MCS range format
1849 * i.e 0-{7,8,9} for VHT.
1850 */
developer9237f442024-06-14 17:13:04 +08001851- mt7996_mcu_sta_rate_ctrl_tlv(skb, dev, conf, mconf, sta);
1852+ mt7996_mcu_sta_rate_ctrl_tlv(skb, dev, conf, mconf, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001853
1854 ret = mt76_mcu_skb_send_msg(&dev->mt76, skb,
1855 MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
1856 if (ret)
1857 return ret;
1858
developer9237f442024-06-14 17:13:04 +08001859- return mt7996_mcu_add_rate_ctrl_fixed(dev, conf, mconf, sta);
1860+ return mt7996_mcu_add_rate_ctrl_fixed(dev, conf, mconf, link_sta, mlink);
developer66e89bc2024-04-23 14:50:01 +08001861 }
1862
1863 static int
developer9237f442024-06-14 17:13:04 +08001864-mt7996_mcu_sta_init_vow(struct mt7996_bss_conf *mconf, struct mt7996_sta *msta)
1865+mt7996_mcu_sta_init_vow(struct mt7996_bss_conf *mconf,
1866+ struct mt7996_link_sta *mlink)
developer66e89bc2024-04-23 14:50:01 +08001867 {
developer9237f442024-06-14 17:13:04 +08001868 struct mt7996_phy *phy = mconf->phy;
1869- struct mt7996_vow_sta_ctrl *vow = &msta->vow;
1870+ struct mt7996_vow_sta_ctrl *vow = &mlink->vow;
1871 u8 omac_idx = mconf->mt76.omac_idx;
developer66e89bc2024-04-23 14:50:01 +08001872 int ret;
1873
developer05f3b2b2024-08-19 19:17:34 +08001874@@ -2339,33 +2347,28 @@ mt7996_mcu_sta_init_vow(struct mt7996_bss_conf *mconf, struct mt7996_sta *msta)
developer66e89bc2024-04-23 14:50:01 +08001875 vow->drr_quantum[IEEE80211_AC_BE] = VOW_DRR_QUANTUM_IDX2;
1876 vow->drr_quantum[IEEE80211_AC_BK] = VOW_DRR_QUANTUM_IDX2;
1877
developer9237f442024-06-14 17:13:04 +08001878- ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_BSS_GROUP);
1879+ ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, mlink, VOW_DRR_CTRL_STA_BSS_GROUP);
developer66e89bc2024-04-23 14:50:01 +08001880 if (ret)
1881 return ret;
1882
developer9237f442024-06-14 17:13:04 +08001883- ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_PAUSE);
1884+ ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, mlink, VOW_DRR_CTRL_STA_PAUSE);
developer66e89bc2024-04-23 14:50:01 +08001885 if (ret)
1886 return ret;
1887
developer9237f442024-06-14 17:13:04 +08001888- return mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_ALL);
1889+ return mt7996_mcu_set_vow_drr_ctrl(phy, mconf, mlink, VOW_DRR_CTRL_STA_ALL);
developer66e89bc2024-04-23 14:50:01 +08001890 }
1891
developer9237f442024-06-14 17:13:04 +08001892 int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
1893- struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta,
1894- bool enable, bool newly)
1895+ struct mt7996_bss_conf *mconf,
1896+ struct ieee80211_link_sta *link_sta,
1897+ struct mt7996_link_sta *mlink, bool enable, bool newly)
developer66e89bc2024-04-23 14:50:01 +08001898 {
developer9237f442024-06-14 17:13:04 +08001899 struct ieee80211_vif *vif = conf->vif;
1900- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
developer05f3b2b2024-08-19 19:17:34 +08001901- struct ieee80211_link_sta *link_sta;
developer9237f442024-06-14 17:13:04 +08001902- struct mt7996_sta *msta;
developer66e89bc2024-04-23 14:50:01 +08001903 struct sk_buff *skb;
developer9237f442024-06-14 17:13:04 +08001904 int ret;
developer66e89bc2024-04-23 14:50:01 +08001905
developer9237f442024-06-14 17:13:04 +08001906- msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->sta;
developer05f3b2b2024-08-19 19:17:34 +08001907- link_sta = sta ? &sta->deflink : NULL;
developer9237f442024-06-14 17:13:04 +08001908-
1909 skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76,
1910- &msta->wcid,
1911+ &mlink->wcid,
developer66e89bc2024-04-23 14:50:01 +08001912 MT7996_STA_UPDATE_MAX_SIZE);
1913 if (IS_ERR(skb))
developer9237f442024-06-14 17:13:04 +08001914 return PTR_ERR(skb);
developer05f3b2b2024-08-19 19:17:34 +08001915@@ -2378,37 +2381,37 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
developer9237f442024-06-14 17:13:04 +08001916 goto out;
1917
1918 /* starec hdr trans */
1919- mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, sta);
1920+ mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, mlink);
1921 /* starec tx proc */
1922 mt7996_mcu_sta_tx_proc_tlv(skb);
1923
1924 /* tag order is in accordance with firmware dependency. */
1925- if (sta) {
1926+ if (link_sta) {
developer66e89bc2024-04-23 14:50:01 +08001927 /* starec hdrt mode */
1928 mt7996_mcu_sta_hdrt_tlv(dev, skb);
1929 /* starec bfer */
developer9237f442024-06-14 17:13:04 +08001930- mt7996_mcu_sta_bfer_tlv(dev, skb, conf, mconf, sta);
1931+ mt7996_mcu_sta_bfer_tlv(dev, skb, conf, mconf, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001932 /* starec ht */
developer9237f442024-06-14 17:13:04 +08001933- mt7996_mcu_sta_ht_tlv(skb, sta);
1934+ mt7996_mcu_sta_ht_tlv(skb, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001935 /* starec vht */
developer9237f442024-06-14 17:13:04 +08001936- mt7996_mcu_sta_vht_tlv(skb, sta);
1937+ mt7996_mcu_sta_vht_tlv(skb, link_sta);
1938 /* starec uapsd */
1939- mt76_connac_mcu_sta_uapsd(skb, vif, sta);
1940+ mt76_connac_mcu_sta_uapsd(skb, vif, link_sta->sta);
developer66e89bc2024-04-23 14:50:01 +08001941 /* starec amsdu */
developer9237f442024-06-14 17:13:04 +08001942- mt7996_mcu_sta_amsdu_tlv(dev, skb, vif, sta);
1943+ mt7996_mcu_sta_amsdu_tlv(dev, skb, vif, link_sta, mlink);
developer66e89bc2024-04-23 14:50:01 +08001944 /* starec he */
developer9237f442024-06-14 17:13:04 +08001945- mt7996_mcu_sta_he_tlv(skb, conf, mconf, sta);
1946+ mt7996_mcu_sta_he_tlv(skb, conf, mconf, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001947 /* starec he 6g*/
developer9237f442024-06-14 17:13:04 +08001948- mt7996_mcu_sta_he_6g_tlv(skb, sta);
1949+ mt7996_mcu_sta_he_6g_tlv(skb, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001950 /* starec eht */
developer9237f442024-06-14 17:13:04 +08001951- mt7996_mcu_sta_eht_tlv(skb, sta);
1952+ mt7996_mcu_sta_eht_tlv(skb, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001953 /* starec muru */
developer9237f442024-06-14 17:13:04 +08001954- mt7996_mcu_sta_muru_tlv(dev, skb, conf, mconf, sta);
1955+ mt7996_mcu_sta_muru_tlv(dev, skb, conf, mconf, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001956 /* starec bfee */
developer9237f442024-06-14 17:13:04 +08001957- mt7996_mcu_sta_bfee_tlv(dev, skb, conf, mconf, sta);
1958+ mt7996_mcu_sta_bfee_tlv(dev, skb, conf, mconf, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001959 }
1960
developer9237f442024-06-14 17:13:04 +08001961- ret = mt7996_mcu_sta_init_vow(mconf, msta);
1962+ ret = mt7996_mcu_sta_init_vow(mconf, mlink);
developer66e89bc2024-04-23 14:50:01 +08001963 if (ret) {
1964 dev_kfree_skb(skb);
1965 return ret;
developer05f3b2b2024-08-19 19:17:34 +08001966@@ -2484,16 +2487,16 @@ int mt7996_mcu_add_key(struct mt76_dev *dev, struct mt7996_bss_conf *mconf,
developer66e89bc2024-04-23 14:50:01 +08001967
developer9237f442024-06-14 17:13:04 +08001968 static int mt7996_mcu_get_pn(struct mt7996_dev *dev,
1969 struct ieee80211_bss_conf *conf,
1970- struct mt7996_bss_conf *mconf, u8 *pn)
1971+ struct mt7996_bss_conf *mconf,
1972+ struct mt7996_link_sta *mlink, u8 *pn)
developer66e89bc2024-04-23 14:50:01 +08001973 {
1974 #define TSC_TYPE_BIGTK_PN 2
developer9237f442024-06-14 17:13:04 +08001975- struct mt7996_vif *mvif = (struct mt7996_vif *)conf->vif->drv_priv;
developer66e89bc2024-04-23 14:50:01 +08001976 struct sta_rec_pn_info *pn_info;
1977 struct sk_buff *skb, *rskb;
1978 struct tlv *tlv;
1979 int ret;
1980
developer9237f442024-06-14 17:13:04 +08001981- skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, &mvif->sta.wcid);
1982+ skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, &mlink->wcid);
developer66e89bc2024-04-23 14:50:01 +08001983 if (IS_ERR(skb))
1984 return PTR_ERR(skb);
1985
developer05f3b2b2024-08-19 19:17:34 +08001986@@ -2520,6 +2523,7 @@ static int mt7996_mcu_get_pn(struct mt7996_dev *dev,
developer9237f442024-06-14 17:13:04 +08001987 int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev,
1988 struct ieee80211_bss_conf *conf,
1989 struct mt7996_bss_conf *mconf,
1990+ struct mt7996_link_sta *mlink,
developer66e89bc2024-04-23 14:50:01 +08001991 struct ieee80211_key_conf *key)
1992 {
developer66e89bc2024-04-23 14:50:01 +08001993 struct mt7996_mcu_bcn_prot_tlv *bcn_prot;
developer05f3b2b2024-08-19 19:17:34 +08001994@@ -2538,7 +2542,7 @@ int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev,
developer66e89bc2024-04-23 14:50:01 +08001995
1996 bcn_prot = (struct mt7996_mcu_bcn_prot_tlv *)tlv;
1997
developer9237f442024-06-14 17:13:04 +08001998- ret = mt7996_mcu_get_pn(dev, conf, mconf, pn);
1999+ ret = mt7996_mcu_get_pn(dev, conf, mconf, mlink, pn);
developer66e89bc2024-04-23 14:50:01 +08002000 if (ret) {
2001 dev_kfree_skb(skb);
2002 return ret;
developer05f3b2b2024-08-19 19:17:34 +08002003@@ -4814,21 +4818,18 @@ int mt7996_mcu_rdd_background_disable_timer(struct mt7996_dev *dev, bool disable
developer9237f442024-06-14 17:13:04 +08002004 int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev,
2005 struct ieee80211_vif *vif,
2006 struct mt7996_bss_conf *mconf,
2007- struct ieee80211_sta *sta)
2008+ struct mt7996_link_sta *mlink)
developer66e89bc2024-04-23 14:50:01 +08002009 {
developer9237f442024-06-14 17:13:04 +08002010- struct mt7996_sta *msta;
developer66e89bc2024-04-23 14:50:01 +08002011 struct sk_buff *skb;
developer66e89bc2024-04-23 14:50:01 +08002012
developer9237f442024-06-14 17:13:04 +08002013- msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mconf->vif->sta;
2014-
2015 skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76,
2016- &msta->wcid,
2017+ &mlink->wcid,
2018 MT7996_STA_UPDATE_MAX_SIZE);
2019 if (IS_ERR(skb))
2020 return PTR_ERR(skb);
developer66e89bc2024-04-23 14:50:01 +08002021
developer9237f442024-06-14 17:13:04 +08002022 /* starec hdr trans */
2023- mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, sta);
2024+ mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, mlink);
2025 return mt76_mcu_skb_send_msg(&dev->mt76, skb,
2026 MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
developer66e89bc2024-04-23 14:50:01 +08002027 }
developer05f3b2b2024-08-19 19:17:34 +08002028@@ -5017,7 +5018,7 @@ int mt7996_mcu_get_per_sta_info(struct mt76_dev *dev, u16 tag,
developer9237f442024-06-14 17:13:04 +08002029 switch (tag) {
2030 case UNI_PER_STA_RSSI:
2031 for (i = 0; i < sta_num; ++i) {
2032- struct mt7996_sta *msta;
2033+ struct mt7996_link_sta *mlink;
2034 struct mt76_phy *phy;
2035 s8 rssi[4];
2036 u8 *rcpi;
developer05f3b2b2024-08-19 19:17:34 +08002037@@ -5031,10 +5032,10 @@ int mt7996_mcu_get_per_sta_info(struct mt76_dev *dev, u16 tag,
developer9237f442024-06-14 17:13:04 +08002038 rssi[2] = to_rssi(MT_PRXV_RCPI0, rcpi[2]);
2039 rssi[3] = to_rssi(MT_PRXV_RCPI0, rcpi[3]);
developer66e89bc2024-04-23 14:50:01 +08002040
developer9237f442024-06-14 17:13:04 +08002041- msta = container_of(wcid, struct mt7996_sta, wcid);
2042- phy = msta->vif->phy->mt76;
2043- msta->ack_signal = mt76_rx_signal(phy->antenna_mask, rssi);
2044- ewma_avg_signal_add(&msta->avg_ack_signal, -msta->ack_signal);
2045+ mlink = container_of(wcid, struct mt7996_link_sta, wcid);
2046+ phy = mlink->sta->vif->deflink.phy->mt76;
2047+ mlink->ack_signal = mt76_rx_signal(phy->antenna_mask, rssi);
2048+ ewma_avg_signal_add(&mlink->avg_ack_signal, -mlink->ack_signal);
2049 } else {
2050 ret = -EINVAL;
2051 dev_err(dev->dev, "Failed to update RSSI for "
developer05f3b2b2024-08-19 19:17:34 +08002052@@ -5056,7 +5057,7 @@ int mt7996_mcu_get_rssi(struct mt76_dev *dev)
developer66e89bc2024-04-23 14:50:01 +08002053 {
developer9237f442024-06-14 17:13:04 +08002054 u16 sta_list[PER_STA_INFO_MAX_NUM];
2055 LIST_HEAD(sta_poll_list);
2056- struct mt7996_sta *msta;
2057+ struct mt7996_link_sta *mlink;
2058 int i, ret;
2059 bool empty = false;
developer66e89bc2024-04-23 14:50:01 +08002060
developer05f3b2b2024-08-19 19:17:34 +08002061@@ -5076,13 +5077,13 @@ int mt7996_mcu_get_rssi(struct mt76_dev *dev)
developer9237f442024-06-14 17:13:04 +08002062 empty = true;
2063 break;
2064 }
2065- msta = list_first_entry(&sta_poll_list,
2066- struct mt7996_sta,
2067+ mlink = list_first_entry(&sta_poll_list,
2068+ struct mt7996_link_sta,
2069 wcid.poll_list);
2070- list_del_init(&msta->wcid.poll_list);
2071+ list_del_init(&mlink->wcid.poll_list);
2072 spin_unlock_bh(&dev->sta_poll_lock);
developer66e89bc2024-04-23 14:50:01 +08002073
developer9237f442024-06-14 17:13:04 +08002074- sta_list[i] = msta->wcid.idx;
2075+ sta_list[i] = mlink->wcid.idx;
2076 }
developer66e89bc2024-04-23 14:50:01 +08002077
developer9237f442024-06-14 17:13:04 +08002078 ret = mt7996_mcu_get_per_sta_info(dev, UNI_PER_STA_RSSI,
developer05f3b2b2024-08-19 19:17:34 +08002079@@ -5372,10 +5373,18 @@ int mt7996_mcu_set_scs_stats(struct mt7996_phy *phy)
developer9237f442024-06-14 17:13:04 +08002080 void mt7996_sta_rssi_work(void *data, struct ieee80211_sta *sta)
developer66e89bc2024-04-23 14:50:01 +08002081 {
developer9237f442024-06-14 17:13:04 +08002082 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
2083+ struct mt7996_link_sta *mlink;
2084 struct mt7996_phy *poll_phy = (struct mt7996_phy *) data;
developer66e89bc2024-04-23 14:50:01 +08002085
developer9237f442024-06-14 17:13:04 +08002086- if (poll_phy->scs_ctrl.sta_min_rssi > msta->ack_signal)
2087- poll_phy->scs_ctrl.sta_min_rssi = msta->ack_signal;
2088+ mutex_lock(&poll_phy->dev->mt76.mutex);
2089+ mlink = mlink_dereference_protected(msta, 0);
2090+ if (!mlink)
2091+ goto out;
2092+
2093+ if (poll_phy->scs_ctrl.sta_min_rssi > mlink->ack_signal)
2094+ poll_phy->scs_ctrl.sta_min_rssi = mlink->ack_signal;
2095+out:
2096+ mutex_unlock(&poll_phy->dev->mt76.mutex);
developer66e89bc2024-04-23 14:50:01 +08002097 }
2098
developer9237f442024-06-14 17:13:04 +08002099 void mt7996_mcu_scs_sta_poll(struct work_struct *work)
developer05f3b2b2024-08-19 19:17:34 +08002100@@ -5451,9 +5460,10 @@ int mt7996_mcu_set_scs(struct mt7996_phy *phy, u8 enable)
developer9237f442024-06-14 17:13:04 +08002101
2102 int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy,
2103 struct mt7996_bss_conf *mconf,
2104- struct mt7996_sta *msta, enum vow_drr_ctrl_id id)
2105+ struct mt7996_link_sta *mlink,
2106+ enum vow_drr_ctrl_id id)
developer66e89bc2024-04-23 14:50:01 +08002107 {
developer9237f442024-06-14 17:13:04 +08002108- struct mt7996_vow_sta_ctrl *vow = msta ? &msta->vow : NULL;
2109+ struct mt7996_vow_sta_ctrl *vow = mlink ? &mlink->vow : NULL;
developer66e89bc2024-04-23 14:50:01 +08002110 u32 val = 0;
developer9237f442024-06-14 17:13:04 +08002111 struct {
2112 u8 __rsv1[4];
developer05f3b2b2024-08-19 19:17:34 +08002113@@ -5475,11 +5485,11 @@ int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy,
developer9237f442024-06-14 17:13:04 +08002114 } __packed req = {
2115 .tag = cpu_to_le16(UNI_VOW_DRR_CTRL),
developer66e89bc2024-04-23 14:50:01 +08002116 .len = cpu_to_le16(sizeof(req) - 4),
developer9237f442024-06-14 17:13:04 +08002117- .wlan_idx = cpu_to_le16(msta ? msta->wcid.idx : 0),
2118+ .wlan_idx = cpu_to_le16(mlink ? mlink->wcid.idx : 0),
developer66e89bc2024-04-23 14:50:01 +08002119 .band_idx = phy->mt76->band_idx,
developer9237f442024-06-14 17:13:04 +08002120- .wmm_idx = msta ? mconf->mt76.wmm_idx : 0,
2121+ .wmm_idx = mlink ? mconf->mt76.wmm_idx : 0,
developer66e89bc2024-04-23 14:50:01 +08002122 .ctrl_id = cpu_to_le32(id),
developer9237f442024-06-14 17:13:04 +08002123- .omac_idx = msta ? mconf->mt76.omac_idx : 0
2124+ .omac_idx = mlink ? mconf->mt76.omac_idx : 0
developer66e89bc2024-04-23 14:50:01 +08002125 };
2126
2127 switch (id) {
developer66e89bc2024-04-23 14:50:01 +08002128diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developer05f3b2b2024-08-19 19:17:34 +08002129index 46964079..1732ff36 100644
developer66e89bc2024-04-23 14:50:01 +08002130--- a/mt7996/mt7996.h
2131+++ b/mt7996/mt7996.h
developer05f3b2b2024-08-19 19:17:34 +08002132@@ -303,10 +303,10 @@ struct mt7996_vow_sta_ctrl {
developer9237f442024-06-14 17:13:04 +08002133 u8 drr_quantum[IEEE80211_NUM_ACS];
developer66e89bc2024-04-23 14:50:01 +08002134 };
2135
developer9237f442024-06-14 17:13:04 +08002136-struct mt7996_sta {
2137+struct mt7996_link_sta {
2138 struct mt76_wcid wcid; /* must be first */
developer66e89bc2024-04-23 14:50:01 +08002139
developer9237f442024-06-14 17:13:04 +08002140- struct mt7996_vif *vif;
2141+ struct mt7996_sta *sta;
developer66e89bc2024-04-23 14:50:01 +08002142
developer9237f442024-06-14 17:13:04 +08002143 struct list_head rc_list;
2144
developer05f3b2b2024-08-19 19:17:34 +08002145@@ -325,6 +325,13 @@ struct mt7996_sta {
developer9237f442024-06-14 17:13:04 +08002146 struct mt7996_vow_sta_ctrl vow;
developer66e89bc2024-04-23 14:50:01 +08002147 };
2148
developer9237f442024-06-14 17:13:04 +08002149+struct mt7996_sta {
2150+ struct mt7996_link_sta deflink;
2151+ struct mt7996_link_sta __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS];
developer66e89bc2024-04-23 14:50:01 +08002152+
developer9237f442024-06-14 17:13:04 +08002153+ struct mt7996_vif *vif;
developer66e89bc2024-04-23 14:50:01 +08002154+};
2155+
developer9237f442024-06-14 17:13:04 +08002156 struct mt7996_bss_conf {
2157 struct mt76_vif mt76; /* must be first */
2158
developer05f3b2b2024-08-19 19:17:34 +08002159@@ -784,6 +791,13 @@ mconf_dereference_protected(struct mt7996_vif *mvif, u8 link_id)
developer9237f442024-06-14 17:13:04 +08002160 lockdep_is_held(&mvif->dev->mt76.mutex));
developer66e89bc2024-04-23 14:50:01 +08002161 }
2162
developer9237f442024-06-14 17:13:04 +08002163+static inline struct mt7996_link_sta *
2164+mlink_dereference_protected(struct mt7996_sta *msta, u8 link_id)
developer66e89bc2024-04-23 14:50:01 +08002165+{
developer9237f442024-06-14 17:13:04 +08002166+ return rcu_dereference_protected(msta->link[link_id],
2167+ lockdep_is_held(&msta->vif->dev->mt76.mutex));
developer66e89bc2024-04-23 14:50:01 +08002168+}
2169+
2170 extern const struct ieee80211_ops mt7996_ops;
2171 extern struct pci_driver mt7996_pci_driver;
2172 extern struct pci_driver mt7996_hif_driver;
developer05f3b2b2024-08-19 19:17:34 +08002173@@ -828,10 +842,12 @@ int mt7996_mcu_add_dev_info(struct mt7996_phy *phy,
developer9237f442024-06-14 17:13:04 +08002174 struct mt7996_bss_conf *mconf, bool enable);
developer66e89bc2024-04-23 14:50:01 +08002175 int mt7996_mcu_add_bss_info(struct mt7996_phy *phy,
developer9237f442024-06-14 17:13:04 +08002176 struct ieee80211_bss_conf *conf,
2177- struct mt7996_bss_conf *mconf, int enable);
2178+ struct mt7996_bss_conf *mconf,
2179+ struct mt7996_link_sta *mlink, int enable);
2180 int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
2181- struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta,
2182- bool enable, bool newly);
2183+ struct mt7996_bss_conf *mconf,
2184+ struct ieee80211_link_sta *link_sta,
2185+ struct mt7996_link_sta *mlink, bool enable, bool newly);
developer66e89bc2024-04-23 14:50:01 +08002186 int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev,
2187 struct ieee80211_ampdu_params *params,
2188 bool add);
developer05f3b2b2024-08-19 19:17:34 +08002189@@ -853,7 +869,8 @@ int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy,
developer9237f442024-06-14 17:13:04 +08002190 int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev,
2191 struct ieee80211_bss_conf *conf,
2192 struct mt7996_bss_conf *mconf,
2193- struct ieee80211_sta *sta, bool changed);
2194+ struct ieee80211_link_sta *link_sta,
2195+ struct mt7996_link_sta *mlink, bool changed);
developer66e89bc2024-04-23 14:50:01 +08002196 int mt7996_set_channel(struct mt7996_phy *phy, struct cfg80211_chan_def *chandef);
2197 int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag);
developer9237f442024-06-14 17:13:04 +08002198 int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct mt7996_bss_conf *mconf);
developer05f3b2b2024-08-19 19:17:34 +08002199@@ -861,7 +878,9 @@ int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev,
developer66e89bc2024-04-23 14:50:01 +08002200 void *data, u16 version);
developer9237f442024-06-14 17:13:04 +08002201 int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev,
2202 struct mt7996_bss_conf *mconf,
2203- struct ieee80211_sta *sta, void *data, u32 field);
2204+ struct ieee80211_link_sta *link_sta,
2205+ struct mt7996_link_sta *mlink, void *data,
2206+ u32 field);
developer66e89bc2024-04-23 14:50:01 +08002207 int mt7996_mcu_set_eeprom(struct mt7996_dev *dev);
2208 int mt7996_mcu_get_eeprom(struct mt7996_dev *dev, u32 offset, u8 *read_buf);
developer9237f442024-06-14 17:13:04 +08002209 int mt7996_mcu_get_eeprom_free_block(struct mt7996_dev *dev, u8 *block_num);
developer05f3b2b2024-08-19 19:17:34 +08002210@@ -917,7 +936,8 @@ void mt7996_mcu_scs_sta_poll(struct work_struct *work);
developer66e89bc2024-04-23 14:50:01 +08002211 int mt7996_mcu_set_band_confg(struct mt7996_phy *phy, u16 option, bool enable);
developer9237f442024-06-14 17:13:04 +08002212 int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy,
2213 struct mt7996_bss_conf *mconf,
2214- struct mt7996_sta *msta, enum vow_drr_ctrl_id id);
2215+ struct mt7996_link_sta *mlink,
2216+ enum vow_drr_ctrl_id id);
developer66e89bc2024-04-23 14:50:01 +08002217 int mt7996_mcu_set_vow_feature_ctrl(struct mt7996_phy *phy);
2218 void mt7996_mcu_wmm_pbc_work(struct work_struct *work);
2219
developer05f3b2b2024-08-19 19:17:34 +08002220@@ -984,7 +1004,7 @@ void mt7996_mac_reset_counters(struct mt7996_phy *phy);
developer9237f442024-06-14 17:13:04 +08002221 void mt7996_mac_cca_stats_reset(struct mt7996_phy *phy);
2222 void mt7996_mac_enable_nf(struct mt7996_dev *dev, u8 band);
2223 void mt7996_mac_enable_rtscts(struct mt7996_dev *dev,
2224- struct ieee80211_vif *vif, bool enable);
2225+ struct mt7996_link_sta *mlink, bool enable);
2226 void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
2227 struct sk_buff *skb, struct mt76_wcid *wcid,
2228 struct ieee80211_key_conf *key, int pid,
developer05f3b2b2024-08-19 19:17:34 +08002229@@ -1002,8 +1022,7 @@ void mt7996_mac_dump_work(struct work_struct *work);
developer9237f442024-06-14 17:13:04 +08002230 void mt7996_mac_sta_rc_work(struct work_struct *work);
2231 void mt7996_mac_update_stats(struct mt7996_phy *phy);
2232 void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev,
2233- struct mt7996_sta *msta,
2234- u8 flowid);
2235+ struct mt7996_link_sta *mlink, u8 flowid);
2236 void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
2237 struct ieee80211_sta *sta,
2238 struct ieee80211_twt_setup *twt);
developer05f3b2b2024-08-19 19:17:34 +08002239@@ -1032,11 +1051,12 @@ int mt7996_mcu_add_key(struct mt76_dev *dev, struct mt7996_bss_conf *mconf,
developer9237f442024-06-14 17:13:04 +08002240 int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev,
2241 struct ieee80211_bss_conf *conf,
2242 struct mt7996_bss_conf *mconf,
2243+ struct mt7996_link_sta *mlink,
developer66e89bc2024-04-23 14:50:01 +08002244 struct ieee80211_key_conf *key);
2245 int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev,
2246 struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +08002247 struct mt7996_bss_conf *mconf,
2248- struct ieee80211_sta *sta);
2249+ struct mt7996_link_sta *mlink);
developer66e89bc2024-04-23 14:50:01 +08002250 int mt7996_mcu_cp_support(struct mt7996_dev *dev, u8 mode);
2251 int mt7996_mcu_set_pp_en(struct mt7996_phy *phy, u8 mode, u16 bitmap);
developer9237f442024-06-14 17:13:04 +08002252 #ifdef CONFIG_MAC80211_DEBUGFS
developer66e89bc2024-04-23 14:50:01 +08002253diff --git a/mt7996/testmode.c b/mt7996/testmode.c
developer05f3b2b2024-08-19 19:17:34 +08002254index bf55b430..ba17f947 100644
developer66e89bc2024-04-23 14:50:01 +08002255--- a/mt7996/testmode.c
2256+++ b/mt7996/testmode.c
developer9237f442024-06-14 17:13:04 +08002257@@ -235,8 +235,8 @@ mt7996_tm_init(struct mt7996_phy *phy, bool en)
developer66e89bc2024-04-23 14:50:01 +08002258
2259 mt7996_tm_rf_switch_mode(dev, rf_test_mode);
2260
developer9237f442024-06-14 17:13:04 +08002261- mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, en);
2262- mt7996_mcu_add_sta(dev, &phy->monitor_vif->bss_conf, &mvif->deflink, NULL, en, false);
2263+ mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, &mvif->sta.deflink, en);
2264+ mt7996_mcu_add_sta(dev, &phy->monitor_vif->bss_conf, &mvif->deflink, NULL, &mvif->sta.deflink, en, false);
developer66e89bc2024-04-23 14:50:01 +08002265
2266 mt7996_tm_set(dev, SET_ID(BAND_IDX), phy->mt76->band_idx);
2267
developer9237f442024-06-14 17:13:04 +08002268@@ -1186,7 +1186,7 @@ mt7996_tm_txbf_init(struct mt7996_phy *phy, u16 *val)
2269 phy->omac_mask |= BIT_ULL(mvif->deflink.mt76.omac_idx);
developer66e89bc2024-04-23 14:50:01 +08002270
developer9237f442024-06-14 17:13:04 +08002271 mt7996_mcu_add_dev_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, true);
2272- mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, true);
2273+ mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, &mvif->sta.deflink, true);
developer66e89bc2024-04-23 14:50:01 +08002274
2275 if (td->ibf) {
2276 if (td->is_txbf_dut) {
2277--
developer9237f442024-06-14 17:13:04 +080022782.18.0
developer66e89bc2024-04-23 14:50:01 +08002279