blob: f88fbcf46c5632037123bffbae593ce779bc2a0e [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From ca4c360d853ec0678da7b08c9b524334b931eeda 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
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 079/223] 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
developerd0c89452024-10-11 16:53:27 +080011Change-Id: I3929a2e3d1bd092581175f60fb900690f22b57d6
developer66e89bc2024-04-23 14:50:01 +080012Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com>
13Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
14Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
15---
developer9237f442024-06-14 17:13:04 +080016 mt7996/debugfs.c | 20 ++-
17 mt7996/mac.c | 109 ++++++------
developerd0c89452024-10-11 16:53:27 +080018 mt7996/main.c | 220 +++++++++++++++---------
developer9237f442024-06-14 17:13:04 +080019 mt7996/mcu.c | 430 ++++++++++++++++++++++++----------------------
20 mt7996/mt7996.h | 44 +++--
21 mt7996/testmode.c | 6 +-
developerd0c89452024-10-11 16:53:27 +080022 6 files changed, 461 insertions(+), 368 deletions(-)
developer66e89bc2024-04-23 14:50:01 +080023
24diff --git a/mt7996/debugfs.c b/mt7996/debugfs.c
developerd0c89452024-10-11 16:53:27 +080025index 792ace03..786bdc38 100644
developer66e89bc2024-04-23 14:50:01 +080026--- a/mt7996/debugfs.c
27+++ b/mt7996/debugfs.c
developer05f3b2b2024-08-19 19:17:34 +080028@@ -726,14 +726,15 @@ static void
developer66e89bc2024-04-23 14:50:01 +080029 mt7996_sta_hw_queue_read(void *data, struct ieee80211_sta *sta)
30 {
31 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer9237f442024-06-14 17:13:04 +080032+ struct mt7996_link_sta *mlink = &msta->deflink;
33 struct mt7996_dev *dev = msta->vif->deflink.phy->dev;
developer66e89bc2024-04-23 14:50:01 +080034 struct seq_file *s = data;
35 u8 ac;
36
developer9237f442024-06-14 17:13:04 +080037 for (ac = 0; ac < 4; ac++) {
38 u32 qlen, ctrl, val;
39- u32 idx = msta->wcid.idx >> 5;
40- u8 offs = msta->wcid.idx & GENMASK(4, 0);
41+ u32 idx = mlink->wcid.idx >> 5;
42+ u8 offs = mlink->wcid.idx & GENMASK(4, 0);
43
44 ctrl = BIT(31) | BIT(11) | (ac << 24);
45 val = mt76_rr(dev, MT_PLE_AC_QEMPTY(ac, idx));
developer05f3b2b2024-08-19 19:17:34 +080046@@ -741,11 +742,11 @@ mt7996_sta_hw_queue_read(void *data, struct ieee80211_sta *sta)
developer9237f442024-06-14 17:13:04 +080047 if (val & BIT(offs))
48 continue;
49
50- mt76_wr(dev, MT_FL_Q0_CTRL, ctrl | msta->wcid.idx);
51+ mt76_wr(dev, MT_FL_Q0_CTRL, ctrl | mlink->wcid.idx);
52 qlen = mt76_get_field(dev, MT_FL_Q3_CTRL,
developer66e89bc2024-04-23 14:50:01 +080053 GENMASK(11, 0));
54 seq_printf(s, "\tSTA %pM wcid %d: AC%d%d queued:%d\n",
developer9237f442024-06-14 17:13:04 +080055- sta->addr, msta->wcid.idx,
56+ sta->addr, mlink->wcid.idx,
57 msta->vif->deflink.mt76.wmm_idx, ac, qlen);
developer66e89bc2024-04-23 14:50:01 +080058 }
59 }
developer05f3b2b2024-08-19 19:17:34 +080060@@ -1028,7 +1029,7 @@ mt7996_airtime_read(struct seq_file *s, void *data)
developer9237f442024-06-14 17:13:04 +080061 struct mt76_dev *mdev = &dev->mt76;
62 struct mt76_sta_stats *stats;
63 struct ieee80211_sta *sta;
64- struct mt7996_sta *msta;
65+ struct mt7996_link_sta *mlink;
66 struct mt76_wcid *wcid;
67 struct mt76_vif *vif;
68 u16 i;
developer05f3b2b2024-08-19 19:17:34 +080069@@ -1040,9 +1041,9 @@ mt7996_airtime_read(struct seq_file *s, void *data)
developer9237f442024-06-14 17:13:04 +080070 if (!wcid || !wcid->sta)
71 continue;
developer66e89bc2024-04-23 14:50:01 +080072
developer9237f442024-06-14 17:13:04 +080073- msta = container_of(wcid, struct mt7996_sta, wcid);
74- sta = container_of((void *)msta, struct ieee80211_sta, drv_priv);
75- vif = &msta->vif->deflink.mt76;
76+ mlink = container_of(wcid, struct mt7996_link_sta, wcid);
77+ sta = container_of((void *)mlink->sta, struct ieee80211_sta, drv_priv);
78+ vif = &mlink->sta->vif->deflink.mt76;
developer66e89bc2024-04-23 14:50:01 +080079 stats = &wcid->stats;
80
81 seq_printf(s, "%pM WCID: %hu BandIdx: %hhu OmacIdx: 0x%hhx\t"
developer05f3b2b2024-08-19 19:17:34 +080082@@ -1217,6 +1218,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
developer66e89bc2024-04-23 14:50:01 +080083 #define LONG_PREAMBLE 1
84 struct ieee80211_sta *sta = file->private_data;
85 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
developer9237f442024-06-14 17:13:04 +080086+ struct mt7996_link_sta *mlink = &msta->deflink;
87 struct mt7996_dev *dev = msta->vif->deflink.phy->dev;
developer66e89bc2024-04-23 14:50:01 +080088 struct ra_rate phy = {};
89 char buf[100];
developer05f3b2b2024-08-19 19:17:34 +080090@@ -1252,7 +1254,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
developer9237f442024-06-14 17:13:04 +080091 goto out;
92 }
developer66e89bc2024-04-23 14:50:01 +080093
developer9237f442024-06-14 17:13:04 +080094- phy.wlan_idx = cpu_to_le16(msta->wcid.idx);
95+ phy.wlan_idx = cpu_to_le16(mlink->wcid.idx);
96 phy.gi = cpu_to_le16(gi);
97 phy.ltf = cpu_to_le16(ltf);
98 phy.ldpc = phy.ldpc ? 7 : 0;
developer66e89bc2024-04-23 14:50:01 +080099diff --git a/mt7996/mac.c b/mt7996/mac.c
developerd0c89452024-10-11 16:53:27 +0800100index 8f743125..8b682842 100644
developer66e89bc2024-04-23 14:50:01 +0800101--- a/mt7996/mac.c
102+++ b/mt7996/mac.c
developer9237f442024-06-14 17:13:04 +0800103@@ -54,7 +54,7 @@ static const struct mt7996_dfs_radar_spec jp_radar_specs = {
104 static struct mt76_wcid *mt7996_rx_get_wcid(struct mt7996_dev *dev,
105 u16 idx, bool unicast)
106 {
107- struct mt7996_sta *sta;
108+ struct mt7996_link_sta *mlink;
109 struct mt76_wcid *wcid;
110
111 if (idx >= ARRAY_SIZE(dev->mt76.wcid))
112@@ -67,11 +67,11 @@ static struct mt76_wcid *mt7996_rx_get_wcid(struct mt7996_dev *dev,
113 if (!wcid->sta)
114 return NULL;
115
116- sta = container_of(wcid, struct mt7996_sta, wcid);
117- if (!sta->vif)
118+ mlink = container_of(wcid, struct mt7996_link_sta, wcid);
119+ if (!mlink->sta->vif)
120 return NULL;
developer66e89bc2024-04-23 14:50:01 +0800121
developer9237f442024-06-14 17:13:04 +0800122- return &sta->vif->sta.wcid;
123+ return &mlink->wcid;
124 }
125
126 bool mt7996_mac_wtbl_update(struct mt7996_dev *dev, int idx, u32 mask)
127@@ -92,12 +92,11 @@ u32 mt7996_mac_wtbl_lmac_addr(struct mt7996_dev *dev, u16 wcid, u8 dw)
128 }
129
130 void mt7996_mac_enable_rtscts(struct mt7996_dev *dev,
131- struct ieee80211_vif *vif, bool enable)
132+ struct mt7996_link_sta *mlink, bool enable)
133 {
134- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
135 u32 addr;
136
137- addr = mt7996_mac_wtbl_lmac_addr(dev, mvif->sta.wcid.idx, 5);
138+ addr = mt7996_mac_wtbl_lmac_addr(dev, mlink->wcid.idx, 5);
139 if (enable)
140 mt76_set(dev, addr, BIT(5));
141 else
142@@ -349,7 +348,7 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
143 __le16 fc = 0;
144 int idx;
145 u8 hw_aggr = false;
146- struct mt7996_sta *msta = NULL;
147+ struct mt7996_link_sta *mlink = NULL;
developer66e89bc2024-04-23 14:50:01 +0800148
developer9237f442024-06-14 17:13:04 +0800149 hw_aggr = status->aggr;
150 memset(status, 0, sizeof(*status));
developer05f3b2b2024-08-19 19:17:34 +0800151@@ -378,10 +377,10 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
developer9237f442024-06-14 17:13:04 +0800152 status->wcid = mt7996_rx_get_wcid(dev, idx, unicast);
153
154 if (status->wcid) {
155- msta = container_of(status->wcid, struct mt7996_sta, wcid);
156+ mlink = container_of(status->wcid, struct mt7996_link_sta, wcid);
157 spin_lock_bh(&dev->mt76.sta_poll_lock);
158- if (list_empty(&msta->wcid.poll_list))
159- list_add_tail(&msta->wcid.poll_list,
160+ if (list_empty(&mlink->wcid.poll_list))
161+ list_add_tail(&mlink->wcid.poll_list,
162 &dev->mt76.sta_poll_list);
163 spin_unlock_bh(&dev->mt76.sta_poll_lock);
developer66e89bc2024-04-23 14:50:01 +0800164 }
developerd0c89452024-10-11 16:53:27 +0800165@@ -588,7 +587,7 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
developer9237f442024-06-14 17:13:04 +0800166 #endif
167 } else {
168 status->flag |= RX_FLAG_8023;
169- mt7996_wed_check_ppe(dev, &dev->mt76.q_rx[q], msta, skb,
170+ mt7996_wed_check_ppe(dev, &dev->mt76.q_rx[q], mlink ? mlink->sta : NULL, skb,
171 *info);
172 }
173
developerd0c89452024-10-11 16:53:27 +0800174@@ -957,6 +956,7 @@ static void
developer9237f442024-06-14 17:13:04 +0800175 mt7996_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb)
176 {
177 struct mt7996_sta *msta;
178+ struct mt7996_link_sta *mlink;
179 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
180 bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP;
181 u16 fc, tid;
developerd0c89452024-10-11 16:53:27 +0800182@@ -985,7 +985,8 @@ mt7996_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb)
developer9237f442024-06-14 17:13:04 +0800183 return;
184
185 msta = (struct mt7996_sta *)sta->drv_priv;
186- if (!test_and_set_bit(tid, &msta->wcid.ampdu_state))
187+ mlink = rcu_dereference(msta->link[0]);
188+ if (!test_and_set_bit(tid, &mlink->wcid.ampdu_state))
189 ieee80211_start_tx_ba_session(sta, tid, 0);
190 }
191
developerd0c89452024-10-11 16:53:27 +0800192@@ -1063,7 +1064,7 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len)
developer9237f442024-06-14 17:13:04 +0800193 */
194 info = le32_to_cpu(*cur_info);
195 if (info & MT_TXFREE_INFO_PAIR) {
196- struct mt7996_sta *msta;
197+ struct mt7996_link_sta *mlink;
198 u16 idx;
199
200 idx = FIELD_GET(MT_TXFREE_INFO_WLAN_ID, info);
developerd0c89452024-10-11 16:53:27 +0800201@@ -1072,10 +1073,10 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len)
developer9237f442024-06-14 17:13:04 +0800202 if (!sta)
203 continue;
204
205- msta = container_of(wcid, struct mt7996_sta, wcid);
206+ mlink = container_of(wcid, struct mt7996_link_sta, wcid);
207 spin_lock_bh(&mdev->sta_poll_lock);
208- if (list_empty(&msta->wcid.poll_list))
209- list_add_tail(&msta->wcid.poll_list,
210+ if (list_empty(&mlink->wcid.poll_list))
211+ list_add_tail(&mlink->wcid.poll_list,
212 &mdev->sta_poll_list);
213 spin_unlock_bh(&mdev->sta_poll_lock);
214 continue;
developerd0c89452024-10-11 16:53:27 +0800215@@ -1280,7 +1281,7 @@ out:
developer66e89bc2024-04-23 14:50:01 +0800216
developer9237f442024-06-14 17:13:04 +0800217 static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data)
developer66e89bc2024-04-23 14:50:01 +0800218 {
developer9237f442024-06-14 17:13:04 +0800219- struct mt7996_sta *msta = NULL;
220+ struct mt7996_link_sta *mlink;
221 struct mt76_wcid *wcid;
222 __le32 *txs_data = data;
223 u16 wcidx;
developerd0c89452024-10-11 16:53:27 +0800224@@ -1301,16 +1302,15 @@ static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data)
developer9237f442024-06-14 17:13:04 +0800225 if (!wcid)
226 goto out;
developer66e89bc2024-04-23 14:50:01 +0800227
developer9237f442024-06-14 17:13:04 +0800228- msta = container_of(wcid, struct mt7996_sta, wcid);
229-
230 mt7996_mac_add_txs_skb(dev, wcid, pid, txs_data);
231
232 if (!wcid->sta)
233 goto out;
234
235+ mlink = container_of(wcid, struct mt7996_link_sta, wcid);
236 spin_lock_bh(&dev->mt76.sta_poll_lock);
237- if (list_empty(&msta->wcid.poll_list))
238- list_add_tail(&msta->wcid.poll_list, &dev->mt76.sta_poll_list);
239+ if (list_empty(&mlink->wcid.poll_list))
240+ list_add_tail(&mlink->wcid.poll_list, &dev->mt76.sta_poll_list);
241 spin_unlock_bh(&dev->mt76.sta_poll_lock);
242
243 out:
developerd0c89452024-10-11 16:53:27 +0800244@@ -2254,8 +2254,9 @@ void mt7996_mac_sta_rc_work(struct work_struct *work)
developer66e89bc2024-04-23 14:50:01 +0800245 struct ieee80211_sta *sta;
246 struct ieee80211_vif *vif;
developer9237f442024-06-14 17:13:04 +0800247 struct ieee80211_bss_conf *conf;
248+ struct ieee80211_link_sta *link_sta;
249 struct mt7996_bss_conf *mconf;
250- struct mt7996_sta *msta;
251+ struct mt7996_link_sta *mlink;
developer66e89bc2024-04-23 14:50:01 +0800252 u32 changed;
253 LIST_HEAD(list);
developer9237f442024-06-14 17:13:04 +0800254
developerd0c89452024-10-11 16:53:27 +0800255@@ -2263,24 +2264,25 @@ void mt7996_mac_sta_rc_work(struct work_struct *work)
developer9237f442024-06-14 17:13:04 +0800256 list_splice_init(&dev->sta_rc_list, &list);
developer66e89bc2024-04-23 14:50:01 +0800257
developer9237f442024-06-14 17:13:04 +0800258 while (!list_empty(&list)) {
259- msta = list_first_entry(&list, struct mt7996_sta, rc_list);
260- list_del_init(&msta->rc_list);
261- changed = msta->changed;
262- msta->changed = 0;
263+ mlink = list_first_entry(&list, struct mt7996_link_sta, rc_list);
264+ list_del_init(&mlink->rc_list);
265+ changed = mlink->changed;
266+ mlink->changed = 0;
267 spin_unlock_bh(&dev->mt76.sta_poll_lock);
268
269- sta = container_of((void *)msta, struct ieee80211_sta, drv_priv);
270- vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv);
271+ sta = container_of((void *)mlink->sta, struct ieee80211_sta, drv_priv);
272+ link_sta = &sta->deflink;
273+ vif = container_of((void *)mlink->sta->vif, struct ieee80211_vif, drv_priv);
274 conf = &vif->bss_conf;
275- mconf = &msta->vif->deflink;
276+ mconf = &mlink->sta->vif->deflink;
developer66e89bc2024-04-23 14:50:01 +0800277
278 if (changed & (IEEE80211_RC_SUPP_RATES_CHANGED |
279 IEEE80211_RC_NSS_CHANGED |
280 IEEE80211_RC_BW_CHANGED))
developer9237f442024-06-14 17:13:04 +0800281- mt7996_mcu_add_rate_ctrl(dev, conf, mconf, sta, true);
282+ mt7996_mcu_add_rate_ctrl(dev, conf, mconf, link_sta, mlink, true);
developer66e89bc2024-04-23 14:50:01 +0800283
284 if (changed & IEEE80211_RC_SMPS_CHANGED)
developer9237f442024-06-14 17:13:04 +0800285- mt7996_mcu_set_fixed_field(dev, mconf, sta, NULL,
286+ mt7996_mcu_set_fixed_field(dev, mconf, link_sta, mlink, NULL,
developer66e89bc2024-04-23 14:50:01 +0800287 RATE_PARAM_MMPS_UPDATE);
288
289 spin_lock_bh(&dev->mt76.sta_poll_lock);
developerd0c89452024-10-11 16:53:27 +0800290@@ -2573,7 +2575,7 @@ static int mt7996_mac_check_twt_req(struct ieee80211_twt_setup *twt)
developer9237f442024-06-14 17:13:04 +0800291 }
292
293 static bool
294-mt7996_mac_twt_param_equal(struct mt7996_sta *msta,
295+mt7996_mac_twt_param_equal(struct mt7996_link_sta *mlink,
296 struct ieee80211_twt_params *twt_agrt)
297 {
298 u16 type = le16_to_cpu(twt_agrt->req_type);
developerd0c89452024-10-11 16:53:27 +0800299@@ -2584,10 +2586,10 @@ mt7996_mac_twt_param_equal(struct mt7996_sta *msta,
developer9237f442024-06-14 17:13:04 +0800300 for (i = 0; i < MT7996_MAX_STA_TWT_AGRT; i++) {
301 struct mt7996_twt_flow *f;
302
303- if (!(msta->twt.flowid_mask & BIT(i)))
304+ if (!(mlink->twt.flowid_mask & BIT(i)))
305 continue;
306
307- f = &msta->twt.flow[i];
308+ f = &mlink->twt.flow[i];
309 if (f->duration == twt_agrt->min_twt_dur &&
310 f->mantissa == twt_agrt->mantissa &&
311 f->exp == exp &&
developerd0c89452024-10-11 16:53:27 +0800312@@ -2606,6 +2608,7 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
developer9237f442024-06-14 17:13:04 +0800313 {
314 enum ieee80211_twt_setup_cmd setup_cmd = TWT_SETUP_CMD_REJECT;
315 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
316+ struct mt7996_link_sta *mlink;
317 struct ieee80211_twt_params *twt_agrt = (void *)twt->params;
318 u16 req_type = le16_to_cpu(twt_agrt->req_type);
319 enum ieee80211_twt_setup_cmd sta_setup_cmd;
developerd0c89452024-10-11 16:53:27 +0800320@@ -2617,11 +2620,12 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
developer9237f442024-06-14 17:13:04 +0800321 goto out;
322
323 mutex_lock(&dev->mt76.mutex);
324+ mlink = mlink_dereference_protected(msta, 0);
325
326 if (dev->twt.n_agrt == MT7996_MAX_TWT_AGRT)
327 goto unlock;
328
329- if (hweight8(msta->twt.flowid_mask) == ARRAY_SIZE(msta->twt.flow))
330+ if (hweight8(mlink->twt.flowid_mask) == ARRAY_SIZE(mlink->twt.flow))
331 goto unlock;
332
333 if (twt_agrt->min_twt_dur < MT7996_MIN_TWT_DUR) {
developerd0c89452024-10-11 16:53:27 +0800334@@ -2630,10 +2634,10 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
developer9237f442024-06-14 17:13:04 +0800335 goto unlock;
336 }
337
338- if (mt7996_mac_twt_param_equal(msta, twt_agrt))
339+ if (mt7996_mac_twt_param_equal(mlink, twt_agrt))
340 goto unlock;
341
342- flowid = ffs(~msta->twt.flowid_mask) - 1;
343+ flowid = ffs(~mlink->twt.flowid_mask) - 1;
344 twt_agrt->req_type &= ~cpu_to_le16(IEEE80211_TWT_REQTYPE_FLOWID);
345 twt_agrt->req_type |= le16_encode_bits(flowid,
346 IEEE80211_TWT_REQTYPE_FLOWID);
developerd0c89452024-10-11 16:53:27 +0800347@@ -2642,10 +2646,10 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
developer9237f442024-06-14 17:13:04 +0800348 exp = FIELD_GET(IEEE80211_TWT_REQTYPE_WAKE_INT_EXP, req_type);
349 sta_setup_cmd = FIELD_GET(IEEE80211_TWT_REQTYPE_SETUP_CMD, req_type);
350
351- flow = &msta->twt.flow[flowid];
352+ flow = &mlink->twt.flow[flowid];
353 memset(flow, 0, sizeof(*flow));
354 INIT_LIST_HEAD(&flow->list);
355- flow->wcid = msta->wcid.idx;
356+ flow->wcid = mlink->wcid.idx;
357 flow->table_id = table_id;
358 flow->id = flowid;
359 flow->duration = twt_agrt->min_twt_dur;
developerd0c89452024-10-11 16:53:27 +0800360@@ -2663,7 +2667,7 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800361
362 flow->sched = true;
363 flow->start_tsf = mt7996_mac_twt_sched_list_add(dev, flow);
developer9237f442024-06-14 17:13:04 +0800364- curr_tsf = __mt7996_get_tsf(hw, &msta->vif->deflink);
365+ curr_tsf = __mt7996_get_tsf(hw, &mlink->sta->vif->deflink);
developer66e89bc2024-04-23 14:50:01 +0800366 div_u64_rem(curr_tsf - flow->start_tsf, interval, &rem);
367 flow_tsf = curr_tsf + interval - rem;
368 twt_agrt->twt = cpu_to_le64(flow_tsf);
developerd0c89452024-10-11 16:53:27 +0800369@@ -2672,13 +2676,13 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800370 }
371 flow->tsf = le64_to_cpu(twt_agrt->twt);
372
developer9237f442024-06-14 17:13:04 +0800373- if (mt7996_mcu_twt_agrt_update(dev, &msta->vif->deflink, flow,
374+ if (mt7996_mcu_twt_agrt_update(dev, &mlink->sta->vif->deflink, flow,
375 MCU_TWT_AGRT_ADD))
developer66e89bc2024-04-23 14:50:01 +0800376 goto unlock;
377
378 setup_cmd = TWT_SETUP_CMD_ACCEPT;
developer9237f442024-06-14 17:13:04 +0800379 dev->twt.table_mask |= BIT(table_id);
380- msta->twt.flowid_mask |= BIT(flowid);
381+ mlink->twt.flowid_mask |= BIT(flowid);
382 dev->twt.n_agrt++;
383
384 unlock:
developerd0c89452024-10-11 16:53:27 +0800385@@ -2691,26 +2695,25 @@ out:
developer9237f442024-06-14 17:13:04 +0800386 }
387
388 void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev,
389- struct mt7996_sta *msta,
390- u8 flowid)
391+ struct mt7996_link_sta *mlink, u8 flowid)
developer66e89bc2024-04-23 14:50:01 +0800392 {
393 struct mt7996_twt_flow *flow;
developer9237f442024-06-14 17:13:04 +0800394- struct mt7996_bss_conf *mconf = mconf_dereference_protected(msta->vif, 0);
395+ struct mt7996_bss_conf *mconf = mconf_dereference_protected(mlink->sta->vif, 0);
developer66e89bc2024-04-23 14:50:01 +0800396
397 lockdep_assert_held(&dev->mt76.mutex);
398
developer9237f442024-06-14 17:13:04 +0800399- if (flowid >= ARRAY_SIZE(msta->twt.flow))
400+ if (flowid >= ARRAY_SIZE(mlink->twt.flow))
401 return;
402
403- if (!(msta->twt.flowid_mask & BIT(flowid)))
404+ if (!(mlink->twt.flowid_mask & BIT(flowid)))
developer66e89bc2024-04-23 14:50:01 +0800405 return;
406
developer9237f442024-06-14 17:13:04 +0800407- flow = &msta->twt.flow[flowid];
408+ flow = &mlink->twt.flow[flowid];
409 if (mt7996_mcu_twt_agrt_update(dev, mconf, flow, MCU_TWT_AGRT_DELETE))
developer66e89bc2024-04-23 14:50:01 +0800410 return;
411
412 list_del_init(&flow->list);
developer9237f442024-06-14 17:13:04 +0800413- msta->twt.flowid_mask &= ~BIT(flowid);
414+ mlink->twt.flowid_mask &= ~BIT(flowid);
415 dev->twt.table_mask &= ~BIT(flow->table_id);
416 dev->twt.n_agrt--;
developer66e89bc2024-04-23 14:50:01 +0800417 }
developerd0c89452024-10-11 16:53:27 +0800418@@ -2723,7 +2726,7 @@ mt7996_scan_send_probe(struct mt7996_phy *phy, struct cfg80211_ssid *ssid,
developer9237f442024-06-14 17:13:04 +0800419 struct cfg80211_scan_request *req = phy->scan_req;
420 struct ieee80211_vif *vif = phy->scan_vif;
421 struct mt7996_vif *mvif;
422- struct mt76_wcid *wcid;
423+ struct mt7996_link_sta *mlink;
424 struct ieee80211_tx_info *info;
425 struct sk_buff *skb;
developer66e89bc2024-04-23 14:50:01 +0800426
developerd0c89452024-10-11 16:53:27 +0800427@@ -2731,7 +2734,6 @@ mt7996_scan_send_probe(struct mt7996_phy *phy, struct cfg80211_ssid *ssid,
developer9237f442024-06-14 17:13:04 +0800428 return;
developer66e89bc2024-04-23 14:50:01 +0800429
developer9237f442024-06-14 17:13:04 +0800430 mvif = (struct mt7996_vif *)vif->drv_priv;
431- wcid = &mvif->sta.wcid;
432
433 skb = ieee80211_probereq_get(hw, vif->addr,
434 ssid->ssid, ssid->ssid_len, req->ie_len);
developerd0c89452024-10-11 16:53:27 +0800435@@ -2764,7 +2766,8 @@ mt7996_scan_send_probe(struct mt7996_phy *phy, struct cfg80211_ssid *ssid,
developer66e89bc2024-04-23 14:50:01 +0800436 }
developer66e89bc2024-04-23 14:50:01 +0800437
developer9237f442024-06-14 17:13:04 +0800438 local_bh_disable();
439- mt76_tx(phy->mt76, NULL, wcid, skb);
440+ mlink = rcu_dereference(mvif->sta.link[0]);
441+ mt76_tx(phy->mt76, NULL, &mlink->wcid, skb);
442 local_bh_enable();
443
444 rcu_read_unlock();
445diff --git a/mt7996/main.c b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +0800446index 8d919dd0..98afb057 100644
developer9237f442024-06-14 17:13:04 +0800447--- a/mt7996/main.c
448+++ b/mt7996/main.c
449@@ -229,6 +229,7 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
450 struct ieee80211_bss_conf *conf = &vif->bss_conf;
developer66e89bc2024-04-23 14:50:01 +0800451 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
developer9237f442024-06-14 17:13:04 +0800452 struct mt7996_bss_conf *mconf = &mvif->deflink;
453+ struct mt7996_link_sta *mlink = &mvif->sta.deflink;
developer66e89bc2024-04-23 14:50:01 +0800454 struct mt7996_dev *dev = mt7996_hw_dev(hw);
455 struct mt7996_phy *phy = mt7996_hw_phy(hw);
456 struct mt76_txq *mtxq;
developer9237f442024-06-14 17:13:04 +0800457@@ -268,14 +269,15 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800458
developer9237f442024-06-14 17:13:04 +0800459 idx = MT7996_WTBL_RESERVED - mconf->mt76.idx;
developer66e89bc2024-04-23 14:50:01 +0800460
developer9237f442024-06-14 17:13:04 +0800461- INIT_LIST_HEAD(&mvif->sta.rc_list);
462- INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
463- mvif->sta.wcid.idx = idx;
464- mvif->sta.wcid.phy_idx = band_idx;
465- mvif->sta.wcid.hw_key_idx = -1;
466- mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
467- mvif->sta.vif = mvif;
468- mt76_wcid_init(&mvif->sta.wcid);
469+ INIT_LIST_HEAD(&mlink->rc_list);
470+ INIT_LIST_HEAD(&mlink->wcid.poll_list);
471+ mlink->wcid.idx = idx;
472+ mlink->wcid.phy_idx = band_idx;
473+ mlink->wcid.hw_key_idx = -1;
474+ mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
475+ mlink->sta = &mvif->sta;
476+ mlink->sta->vif = mvif;
477+ mt76_wcid_init(&mlink->wcid);
developer66e89bc2024-04-23 14:50:01 +0800478
developer9237f442024-06-14 17:13:04 +0800479 mt7996_mac_wtbl_update(dev, idx,
480 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
481@@ -297,14 +299,15 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800482
developer9237f442024-06-14 17:13:04 +0800483 mt7996_init_bitrate_mask(mconf);
developer66e89bc2024-04-23 14:50:01 +0800484
developer9237f442024-06-14 17:13:04 +0800485- mt7996_mcu_add_bss_info(phy, conf, mconf, true);
486+ mt7996_mcu_add_bss_info(phy, conf, mconf, mlink, true);
developer66e89bc2024-04-23 14:50:01 +0800487 /* defer the first STA_REC of BMC entry to BSS_CHANGED_BSSID for STA
488 * interface, since firmware only records BSSID when the entry is new
489 */
490 if (vif->type != NL80211_IFTYPE_STATION)
developer9237f442024-06-14 17:13:04 +0800491- mt7996_mcu_add_sta(dev, conf, mconf, NULL, true, true);
492- rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid);
493+ mt7996_mcu_add_sta(dev, conf, mconf, NULL, mlink, true, true);
494+ rcu_assign_pointer(dev->mt76.wcid[idx], &mlink->wcid);
495 rcu_assign_pointer(mvif->link[0], mconf);
496+ rcu_assign_pointer(mvif->sta.link[0], mlink);
developer66e89bc2024-04-23 14:50:01 +0800497
498 out:
499 mutex_unlock(&dev->mt76.mutex);
developer9237f442024-06-14 17:13:04 +0800500@@ -318,10 +321,10 @@ static void mt7996_remove_interface(struct ieee80211_hw *hw,
501 struct ieee80211_bss_conf *conf;
developer66e89bc2024-04-23 14:50:01 +0800502 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
developer9237f442024-06-14 17:13:04 +0800503 struct mt7996_bss_conf *mconf;
504- struct mt7996_sta *msta = &mvif->sta;
505+ struct mt7996_link_sta *mlink = &mvif->sta.deflink;
developer66e89bc2024-04-23 14:50:01 +0800506 struct mt7996_dev *dev = mt7996_hw_dev(hw);
507 struct mt7996_phy *phy = mt7996_hw_phy(hw);
developer9237f442024-06-14 17:13:04 +0800508- int idx = msta->wcid.idx;
509+ int idx = mlink->wcid.idx;
developer66e89bc2024-04-23 14:50:01 +0800510
511 cancel_delayed_work_sync(&phy->scan_work);
512
developer9237f442024-06-14 17:13:04 +0800513@@ -329,8 +332,8 @@ static void mt7996_remove_interface(struct ieee80211_hw *hw,
514
515 conf = link_conf_dereference_protected(vif, 0);
516 mconf = mconf_dereference_protected(mvif, 0);
517- mt7996_mcu_add_sta(dev, conf, mconf, NULL, false, false);
518- mt7996_mcu_add_bss_info(phy, conf, mconf, false);
519+ mt7996_mcu_add_sta(dev, conf, mconf, NULL, mlink, false, false);
520+ mt7996_mcu_add_bss_info(phy, conf, mconf, mlink, false);
developer66e89bc2024-04-23 14:50:01 +0800521
522 if (vif == phy->monitor_vif)
523 phy->monitor_vif = NULL;
developer9237f442024-06-14 17:13:04 +0800524@@ -343,12 +346,13 @@ static void mt7996_remove_interface(struct ieee80211_hw *hw,
525 phy->omac_mask &= ~BIT_ULL(mconf->mt76.omac_idx);
developer66e89bc2024-04-23 14:50:01 +0800526
527 spin_lock_bh(&dev->mt76.sta_poll_lock);
developer9237f442024-06-14 17:13:04 +0800528- if (!list_empty(&msta->wcid.poll_list))
529- list_del_init(&msta->wcid.poll_list);
530+ if (!list_empty(&mlink->wcid.poll_list))
531+ list_del_init(&mlink->wcid.poll_list);
developer66e89bc2024-04-23 14:50:01 +0800532 spin_unlock_bh(&dev->mt76.sta_poll_lock);
533
developer9237f442024-06-14 17:13:04 +0800534- mt76_wcid_cleanup(&dev->mt76, &msta->wcid);
535+ mt76_wcid_cleanup(&dev->mt76, &mlink->wcid);
536 rcu_assign_pointer(mvif->link[0], NULL);
537+ rcu_assign_pointer(mvif->sta.link[0], NULL);
developer66e89bc2024-04-23 14:50:01 +0800538
developer9237f442024-06-14 17:13:04 +0800539 mutex_unlock(&dev->mt76.mutex);
540 }
developerd0c89452024-10-11 16:53:27 +0800541@@ -445,10 +449,10 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
developer9237f442024-06-14 17:13:04 +0800542 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
developer66e89bc2024-04-23 14:50:01 +0800543 struct mt7996_sta *msta = sta ? (struct mt7996_sta *)sta->drv_priv :
544 &mvif->sta;
developer9237f442024-06-14 17:13:04 +0800545- struct mt76_wcid *wcid = &msta->wcid;
546 struct mt7996_bss_conf *mconf;
547+ struct mt7996_link_sta *mlink;
548 struct ieee80211_bss_conf *conf;
549- u8 *wcid_keyidx = &wcid->hw_key_idx;
550+ u8 *wcid_keyidx;
developer66e89bc2024-04-23 14:50:01 +0800551 int idx = key->keyidx;
552 int err = 0;
developer66e89bc2024-04-23 14:50:01 +0800553
developerd0c89452024-10-11 16:53:27 +0800554@@ -462,6 +466,12 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
developer9237f442024-06-14 17:13:04 +0800555 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
556 return -EOPNOTSUPP;
developer66e89bc2024-04-23 14:50:01 +0800557
developer9237f442024-06-14 17:13:04 +0800558+ mutex_lock(&dev->mt76.mutex);
developer66e89bc2024-04-23 14:50:01 +0800559+ conf = link_conf_dereference_protected(vif, 0);
560+ mconf = mconf_dereference_protected(mvif, 0);
developer9237f442024-06-14 17:13:04 +0800561+ mlink = mlink_dereference_protected(msta, 0);
562+ wcid_keyidx = &mlink->wcid.hw_key_idx;
563+
564 /* fall back to sw encryption for unsupported ciphers */
565 switch (key->cipher) {
566 case WLAN_CIPHER_SUITE_TKIP:
developerd0c89452024-10-11 16:53:27 +0800567@@ -484,16 +494,13 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
developer9237f442024-06-14 17:13:04 +0800568 case WLAN_CIPHER_SUITE_WEP40:
569 case WLAN_CIPHER_SUITE_WEP104:
570 default:
571+ mutex_unlock(&dev->mt76.mutex);
572 return -EOPNOTSUPP;
573 }
574
575- mutex_lock(&dev->mt76.mutex);
576-
577- conf = link_conf_dereference_protected(vif, 0);
578- mconf = mconf_dereference_protected(mvif, 0);
579 if (cmd == SET_KEY && !sta && !mconf->mt76.cipher) {
580 mconf->mt76.cipher = mt76_connac_mcu_get_cipher(key->cipher);
581- mt7996_mcu_add_bss_info(phy, conf, mconf, true);
582+ mt7996_mcu_add_bss_info(phy, conf, mconf, mlink, true);
developer66e89bc2024-04-23 14:50:01 +0800583 }
584
585 if (cmd == SET_KEY) {
developerd0c89452024-10-11 16:53:27 +0800586@@ -504,14 +511,14 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
developer9237f442024-06-14 17:13:04 +0800587 goto out;
588 }
589
590- mt76_wcid_key_setup(&dev->mt76, wcid, key);
591+ mt76_wcid_key_setup(&dev->mt76, &mlink->wcid, key);
developer66e89bc2024-04-23 14:50:01 +0800592
593 if (key->keyidx == 6 || key->keyidx == 7)
developer9237f442024-06-14 17:13:04 +0800594- err = mt7996_mcu_bcn_prot_enable(dev, conf, mconf, key);
595+ err = mt7996_mcu_bcn_prot_enable(dev, conf, mconf, mlink, key);
developer66e89bc2024-04-23 14:50:01 +0800596 else
developer9237f442024-06-14 17:13:04 +0800597 err = mt7996_mcu_add_key(&dev->mt76, mconf, key,
developer66e89bc2024-04-23 14:50:01 +0800598 MCU_WMWA_UNI_CMD(STA_REC_UPDATE),
developer9237f442024-06-14 17:13:04 +0800599- &msta->wcid, cmd);
600+ &mlink->wcid, cmd);
developer66e89bc2024-04-23 14:50:01 +0800601 out:
developer9237f442024-06-14 17:13:04 +0800602 mutex_unlock(&dev->mt76.mutex);
developer66e89bc2024-04-23 14:50:01 +0800603
developerd0c89452024-10-11 16:53:27 +0800604@@ -714,25 +721,27 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800605 {
developer9237f442024-06-14 17:13:04 +0800606 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
607 struct mt7996_bss_conf *mconf;
608+ struct mt7996_link_sta *mlink;
developer66e89bc2024-04-23 14:50:01 +0800609 struct mt7996_phy *phy = mt7996_hw_phy(hw);
610 struct mt7996_dev *dev = mt7996_hw_dev(hw);
611
612 mutex_lock(&dev->mt76.mutex);
613
developer9237f442024-06-14 17:13:04 +0800614 mconf = mconf_dereference_protected(mvif, 0);
615+ mlink = mlink_dereference_protected(&mvif->sta, 0);
developer66e89bc2024-04-23 14:50:01 +0800616 /* station mode uses BSSID to map the wlan entry to a peer,
617 * and then peer references bss_info_rfch to set bandwidth cap.
618 */
619 if ((changed & BSS_CHANGED_BSSID && !is_zero_ether_addr(info->bssid)) ||
620 (changed & BSS_CHANGED_ASSOC && vif->cfg.assoc) ||
621 (changed & BSS_CHANGED_BEACON_ENABLED && info->enable_beacon)) {
developer9237f442024-06-14 17:13:04 +0800622- mt7996_mcu_add_bss_info(phy, info, mconf, true);
623- mt7996_mcu_add_sta(dev, info, mconf, NULL, true,
624+ mt7996_mcu_add_bss_info(phy, info, mconf, mlink, true);
625+ mt7996_mcu_add_sta(dev, info, mconf, NULL, mlink, true,
developer66e89bc2024-04-23 14:50:01 +0800626 !!(changed & BSS_CHANGED_BSSID));
627 }
628
developer9237f442024-06-14 17:13:04 +0800629 if (changed & BSS_CHANGED_ERP_CTS_PROT)
630- mt7996_mac_enable_rtscts(dev, vif, info->use_cts_prot);
631+ mt7996_mac_enable_rtscts(dev, mlink, info->use_cts_prot);
developer66e89bc2024-04-23 14:50:01 +0800632
developer9237f442024-06-14 17:13:04 +0800633 if (changed & BSS_CHANGED_ERP_SLOT) {
634 int slottime = info->use_short_slot ? 9 : 20;
developerd0c89452024-10-11 16:53:27 +0800635@@ -803,6 +812,7 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +0800636 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
637 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
638 struct mt7996_bss_conf *mconf = mconf_dereference_protected(mvif, 0);
639+ struct mt7996_link_sta *mlink = &msta->deflink;
640 u8 band_idx = mconf->phy->mt76->band_idx;
641 int idx;
developer66e89bc2024-04-23 14:50:01 +0800642
developerd0c89452024-10-11 16:53:27 +0800643@@ -814,13 +824,16 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +0800644 if (idx < 0)
645 return -ENOSPC;
developer66e89bc2024-04-23 14:50:01 +0800646
developer9237f442024-06-14 17:13:04 +0800647- INIT_LIST_HEAD(&msta->rc_list);
648- INIT_LIST_HEAD(&msta->wcid.poll_list);
649+ INIT_LIST_HEAD(&mlink->rc_list);
650+ INIT_LIST_HEAD(&mlink->wcid.poll_list);
651 msta->vif = mvif;
652- msta->wcid.sta = 1;
653- msta->wcid.idx = idx;
654- msta->wcid.phy_idx = band_idx;
655- msta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
656+ mlink->wcid.sta = 1;
657+ mlink->wcid.idx = idx;
658+ mlink->wcid.phy_idx = band_idx;
659+ mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
660+ mlink->sta = msta;
661+
662+ rcu_assign_pointer(msta->link[0], mlink);
developer66e89bc2024-04-23 14:50:01 +0800663
developer9237f442024-06-14 17:13:04 +0800664 #ifdef CONFIG_MTK_VENDOR
665 mt7996_vendor_amnt_sta_remove(mconf->phy, sta);
developerd0c89452024-10-11 16:53:27 +0800666@@ -853,7 +866,9 @@ int mt7996_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +0800667 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
668 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
669 struct mt7996_bss_conf *mconf;
670+ struct mt7996_link_sta *mlink;
671 struct ieee80211_bss_conf *conf;
672+ struct ieee80211_link_sta *link_sta;
developer66e89bc2024-04-23 14:50:01 +0800673
developer9237f442024-06-14 17:13:04 +0800674 mutex_lock(&dev->mt76.mutex);
developer66e89bc2024-04-23 14:50:01 +0800675
developerd0c89452024-10-11 16:53:27 +0800676@@ -863,10 +878,17 @@ int mt7996_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developer66e89bc2024-04-23 14:50:01 +0800677
developerd0c89452024-10-11 16:53:27 +0800678 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);
developer9237f442024-06-14 17:13:04 +0800684+
developerd0c89452024-10-11 16:53:27 +0800685+ mt7996_mac_wtbl_update(dev, mlink->wcid.idx,
686+ MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
687
688- ewma_avg_signal_init(&msta->avg_ack_signal);
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;
developer9237f442024-06-14 17:13:04 +0800692+
developerd0c89452024-10-11 16:53:27 +0800693+ ewma_avg_signal_init(&mlink->avg_ack_signal);
694 }
developer66e89bc2024-04-23 14:50:01 +0800695
developer9237f442024-06-14 17:13:04 +0800696 mutex_unlock(&dev->mt76.mutex);
developerd0c89452024-10-11 16:53:27 +0800697@@ -879,25 +901,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,
developerd0c89452024-10-11 16:53:27 +0800737@@ -909,19 +937,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);
developerd0c89452024-10-11 16:53:27 +0800764@@ -948,6 +979,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;
developerd0c89452024-10-11 16:53:27 +0800772@@ -959,14 +991,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:
developerd0c89452024-10-11 16:53:27 +0800790@@ -977,16 +1010,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;
developerd0c89452024-10-11 16:53:27 +0800810@@ -1165,10 +1198,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;
developerd0c89452024-10-11 16:53:27 +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;
developerd0c89452024-10-11 16:53:27 +0800826
developer9237f442024-06-14 17:13:04 +0800827+ txrate = &mlink->wcid.rate;
828 if (txrate->legacy || txrate->flags) {
829 if (txrate->legacy) {
830 sinfo->txrate.legacy = txrate->legacy;
developerd0c89452024-10-11 16:53:27 +0800831@@ -1187,44 +1229,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,
developerd0c89452024-10-11 16:53:27 +0800895@@ -1238,7 +1288,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
developerd0c89452024-10-11 16:53:27 +0800904@@ -1284,16 +1334,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
developerd0c89452024-10-11 16:53:27 +0800926@@ -1306,16 +1358,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
developerd0c89452024-10-11 16:53:27 +0800948@@ -1448,11 +1502,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
developerd0c89452024-10-11 16:53:27 +0800962@@ -1555,10 +1610,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
developerd0c89452024-10-11 16:53:27 +0800976@@ -1681,6 +1738,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;
developerd0c89452024-10-11 16:53:27 +0800984@@ -1703,7 +1761,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;
developerd0c89452024-10-11 16:53:27 +0800993@@ -1711,11 +1769,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
developerd0c89452024-10-11 16:53:27 +08001008index b2eed253..ced769b4 100644
developer66e89bc2024-04-23 14:50:01 +08001009--- a/mt7996/mcu.c
1010+++ b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +08001011@@ -122,13 +122,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;
developerd0c89452024-10-11 16:53:27 +08001027@@ -171,11 +171,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) {
developerd0c89452024-10-11 16:53:27 +08001043@@ -197,13 +197,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
developerd0c89452024-10-11 16:53:27 +08001060@@ -536,14 +536,14 @@ static inline void __mt7996_stat_to_netdev(struct mt76_phy *mphy,
developer9237f442024-06-14 17:13:04 +08001061 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
developerd0c89452024-10-11 16:53:27 +08001078@@ -1241,10 +1241,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
developerd0c89452024-10-11 16:53:27 +08001091@@ -1260,7 +1260,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)
developerd0c89452024-10-11 16:53:27 +08001100@@ -1340,9 +1340,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 }
developerd0c89452024-10-11 16:53:27 +08001112@@ -1360,15 +1361,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));
developerd0c89452024-10-11 16:53:27 +08001131@@ -1385,21 +1386,21 @@ mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf,
developer9237f442024-06-14 17:13:04 +08001132 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;
developerd0c89452024-10-11 16:53:27 +08001158@@ -1409,24 +1410,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;
developerd0c89452024-10-11 16:53:27 +08001189@@ -1434,11 +1436,11 @@ mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
developer9237f442024-06-14 17:13:04 +08001190 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
developerd0c89452024-10-11 16:53:27 +08001204@@ -1449,7 +1451,7 @@ mt7996_mcu_sta_eht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
developer9237f442024-06-14 17:13:04 +08001205 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 |
developerd0c89452024-10-11 16:53:27 +08001213@@ -1465,44 +1467,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
developerd0c89452024-10-11 16:53:27 +08001269@@ -1510,9 +1512,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
developerd0c89452024-10-11 16:53:27 +08001282@@ -1521,16 +1524,16 @@ mt7996_mcu_sta_amsdu_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
developer9237f442024-06-14 17:13:04 +08001283 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;
developerd0c89452024-10-11 16:53:27 +08001302@@ -1549,10 +1552,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
developerd0c89452024-10-11 16:53:27 +08001315@@ -1572,11 +1575,11 @@ mt7996_mcu_sta_muru_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
developer9237f442024-06-14 17:13:04 +08001316 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 =
developerd0c89452024-10-11 16:53:27 +08001330@@ -1609,7 +1612,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
developerd0c89452024-10-11 16:53:27 +08001339@@ -1620,8 +1623,8 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
developer9237f442024-06-14 17:13:04 +08001340 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)
developerd0c89452024-10-11 16:53:27 +08001350@@ -1632,8 +1635,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 &&
developerd0c89452024-10-11 16:53:27 +08001361@@ -1643,8 +1646,8 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
developer9237f442024-06-14 17:13:04 +08001362 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 &&
developerd0c89452024-10-11 16:53:27 +08001372@@ -1667,10 +1670,10 @@ mt7996_mcu_sta_sounding_rate(struct sta_rec_bf *bf)
developer9237f442024-06-14 17:13:04 +08001373 }
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;
developerd0c89452024-10-11 16:53:27 +08001386@@ -1692,10 +1695,11 @@ mt7996_mcu_sta_bfer_ht(struct ieee80211_sta *sta, struct mt7996_phy *phy,
developer9237f442024-06-14 17:13:04 +08001387 }
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);
developerd0c89452024-10-11 16:53:27 +08001401@@ -1716,23 +1720,24 @@ mt7996_mcu_sta_bfer_vht(struct ieee80211_sta *sta, struct mt7996_phy *phy,
developer9237f442024-06-14 17:13:04 +08001402 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);
developerd0c89452024-10-11 16:53:27 +08001431@@ -1757,7 +1762,7 @@ mt7996_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +08001432 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 */
developerd0c89452024-10-11 16:53:27 +08001440@@ -1789,10 +1794,11 @@ mt7996_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +08001441 }
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 =
developerd0c89452024-10-11 16:53:27 +08001455@@ -1815,10 +1821,10 @@ mt7996_mcu_sta_bfer_eht(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +08001456 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]);
developerd0c89452024-10-11 16:53:27 +08001468@@ -1847,7 +1853,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;
developerd0c89452024-10-11 16:53:27 +08001477@@ -1861,10 +1867,10 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
developer9237f442024-06-14 17:13:04 +08001478 };
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
developerd0c89452024-10-11 16:53:27 +08001490@@ -1875,23 +1881,23 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
developer9237f442024-06-14 17:13:04 +08001491 * 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;
developerd0c89452024-10-11 16:53:27 +08001525@@ -1901,7 +1907,7 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
developer9237f442024-06-14 17:13:04 +08001526 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;
developerd0c89452024-10-11 16:53:27 +08001534@@ -1918,7 +1924,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;
developerd0c89452024-10-11 16:53:27 +08001544@@ -1926,22 +1933,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);
developerd0c89452024-10-11 16:53:27 +08001573@@ -1978,25 +1985,24 @@ mt7996_mcu_sta_hdrt_tlv(struct mt7996_dev *dev, struct sk_buff *skb)
developer9237f442024-06-14 17:13:04 +08001574 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;
developerd0c89452024-10-11 16:53:27 +08001604@@ -2053,16 +2059,17 @@ int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev,
developer9237f442024-06-14 17:13:04 +08001605
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);
developerd0c89452024-10-11 16:53:27 +08001625@@ -2081,7 +2088,7 @@ int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev,
developer9237f442024-06-14 17:13:04 +08001626 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;
developerd0c89452024-10-11 16:53:27 +08001634@@ -2096,7 +2103,8 @@ static int
developer9237f442024-06-14 17:13:04 +08001635 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;
developerd0c89452024-10-11 16:53:27 +08001644@@ -2120,11 +2128,11 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev,
developer9237f442024-06-14 17:13:04 +08001645 } \
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);
developerd0c89452024-10-11 16:53:27 +08001659@@ -2141,8 +2149,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 }
developerd0c89452024-10-11 16:53:27 +08001670@@ -2150,29 +2158,28 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev,
developer9237f442024-06-14 17:13:04 +08001671 /* 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 }
developerd0c89452024-10-11 16:53:27 +08001706@@ -2184,7 +2191,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;
developerd0c89452024-10-11 16:53:27 +08001715@@ -2193,20 +2200,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;
developerd0c89452024-10-11 16:53:27 +08001742@@ -2226,60 +2233,60 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev,
developer9237f442024-06-14 17:13:04 +08001743 }
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);
developerd0c89452024-10-11 16:53:27 +08001823@@ -2290,14 +2297,14 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev,
developer9237f442024-06-14 17:13:04 +08001824 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);
developerd0c89452024-10-11 16:53:27 +08001841@@ -2307,26 +2314,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
developerd0c89452024-10-11 16:53:27 +08001874@@ -2344,34 +2352,29 @@ 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;
developerd0c89452024-10-11 16:53:27 +08001904 int conn_state;
developer9237f442024-06-14 17:13:04 +08001905 int ret;
developer66e89bc2024-04-23 14:50:01 +08001906
developer9237f442024-06-14 17:13:04 +08001907- msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->sta;
developer05f3b2b2024-08-19 19:17:34 +08001908- link_sta = sta ? &sta->deflink : NULL;
developer9237f442024-06-14 17:13:04 +08001909-
1910 skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76,
1911- &msta->wcid,
1912+ &mlink->wcid,
developer66e89bc2024-04-23 14:50:01 +08001913 MT7996_STA_UPDATE_MAX_SIZE);
1914 if (IS_ERR(skb))
developer9237f442024-06-14 17:13:04 +08001915 return PTR_ERR(skb);
developerd0c89452024-10-11 16:53:27 +08001916@@ -2385,37 +2388,37 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
developer9237f442024-06-14 17:13:04 +08001917 goto out;
1918
1919 /* starec hdr trans */
1920- mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, sta);
1921+ mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, mlink);
1922 /* starec tx proc */
1923 mt7996_mcu_sta_tx_proc_tlv(skb);
1924
1925 /* tag order is in accordance with firmware dependency. */
1926- if (sta) {
1927+ if (link_sta) {
developer66e89bc2024-04-23 14:50:01 +08001928 /* starec hdrt mode */
1929 mt7996_mcu_sta_hdrt_tlv(dev, skb);
1930 /* starec bfer */
developer9237f442024-06-14 17:13:04 +08001931- mt7996_mcu_sta_bfer_tlv(dev, skb, conf, mconf, sta);
1932+ mt7996_mcu_sta_bfer_tlv(dev, skb, conf, mconf, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001933 /* starec ht */
developer9237f442024-06-14 17:13:04 +08001934- mt7996_mcu_sta_ht_tlv(skb, sta);
1935+ mt7996_mcu_sta_ht_tlv(skb, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001936 /* starec vht */
developer9237f442024-06-14 17:13:04 +08001937- mt7996_mcu_sta_vht_tlv(skb, sta);
1938+ mt7996_mcu_sta_vht_tlv(skb, link_sta);
1939 /* starec uapsd */
1940- mt76_connac_mcu_sta_uapsd(skb, vif, sta);
1941+ mt76_connac_mcu_sta_uapsd(skb, vif, link_sta->sta);
developer66e89bc2024-04-23 14:50:01 +08001942 /* starec amsdu */
developer9237f442024-06-14 17:13:04 +08001943- mt7996_mcu_sta_amsdu_tlv(dev, skb, vif, sta);
1944+ mt7996_mcu_sta_amsdu_tlv(dev, skb, vif, link_sta, mlink);
developer66e89bc2024-04-23 14:50:01 +08001945 /* starec he */
developer9237f442024-06-14 17:13:04 +08001946- mt7996_mcu_sta_he_tlv(skb, conf, mconf, sta);
1947+ mt7996_mcu_sta_he_tlv(skb, conf, mconf, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001948 /* starec he 6g*/
developer9237f442024-06-14 17:13:04 +08001949- mt7996_mcu_sta_he_6g_tlv(skb, sta);
1950+ mt7996_mcu_sta_he_6g_tlv(skb, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001951 /* starec eht */
developer9237f442024-06-14 17:13:04 +08001952- mt7996_mcu_sta_eht_tlv(skb, sta);
1953+ mt7996_mcu_sta_eht_tlv(skb, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001954 /* starec muru */
developer9237f442024-06-14 17:13:04 +08001955- mt7996_mcu_sta_muru_tlv(dev, skb, conf, mconf, sta);
1956+ mt7996_mcu_sta_muru_tlv(dev, skb, conf, mconf, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001957 /* starec bfee */
developer9237f442024-06-14 17:13:04 +08001958- mt7996_mcu_sta_bfee_tlv(dev, skb, conf, mconf, sta);
1959+ mt7996_mcu_sta_bfee_tlv(dev, skb, conf, mconf, link_sta);
developer66e89bc2024-04-23 14:50:01 +08001960 }
1961
developer9237f442024-06-14 17:13:04 +08001962- ret = mt7996_mcu_sta_init_vow(mconf, msta);
1963+ ret = mt7996_mcu_sta_init_vow(mconf, mlink);
developer66e89bc2024-04-23 14:50:01 +08001964 if (ret) {
1965 dev_kfree_skb(skb);
1966 return ret;
developerd0c89452024-10-11 16:53:27 +08001967@@ -2491,16 +2494,16 @@ int mt7996_mcu_add_key(struct mt76_dev *dev, struct mt7996_bss_conf *mconf,
developer66e89bc2024-04-23 14:50:01 +08001968
developer9237f442024-06-14 17:13:04 +08001969 static int mt7996_mcu_get_pn(struct mt7996_dev *dev,
1970 struct ieee80211_bss_conf *conf,
1971- struct mt7996_bss_conf *mconf, u8 *pn)
1972+ struct mt7996_bss_conf *mconf,
1973+ struct mt7996_link_sta *mlink, u8 *pn)
developer66e89bc2024-04-23 14:50:01 +08001974 {
1975 #define TSC_TYPE_BIGTK_PN 2
developer9237f442024-06-14 17:13:04 +08001976- struct mt7996_vif *mvif = (struct mt7996_vif *)conf->vif->drv_priv;
developer66e89bc2024-04-23 14:50:01 +08001977 struct sta_rec_pn_info *pn_info;
1978 struct sk_buff *skb, *rskb;
1979 struct tlv *tlv;
1980 int ret;
1981
developer9237f442024-06-14 17:13:04 +08001982- skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, &mvif->sta.wcid);
1983+ skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, &mlink->wcid);
developer66e89bc2024-04-23 14:50:01 +08001984 if (IS_ERR(skb))
1985 return PTR_ERR(skb);
1986
developerd0c89452024-10-11 16:53:27 +08001987@@ -2527,6 +2530,7 @@ static int mt7996_mcu_get_pn(struct mt7996_dev *dev,
developer9237f442024-06-14 17:13:04 +08001988 int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev,
1989 struct ieee80211_bss_conf *conf,
1990 struct mt7996_bss_conf *mconf,
1991+ struct mt7996_link_sta *mlink,
developer66e89bc2024-04-23 14:50:01 +08001992 struct ieee80211_key_conf *key)
1993 {
developer66e89bc2024-04-23 14:50:01 +08001994 struct mt7996_mcu_bcn_prot_tlv *bcn_prot;
developerd0c89452024-10-11 16:53:27 +08001995@@ -2545,7 +2549,7 @@ int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev,
developer66e89bc2024-04-23 14:50:01 +08001996
1997 bcn_prot = (struct mt7996_mcu_bcn_prot_tlv *)tlv;
1998
developer9237f442024-06-14 17:13:04 +08001999- ret = mt7996_mcu_get_pn(dev, conf, mconf, pn);
2000+ ret = mt7996_mcu_get_pn(dev, conf, mconf, mlink, pn);
developer66e89bc2024-04-23 14:50:01 +08002001 if (ret) {
2002 dev_kfree_skb(skb);
2003 return ret;
developerd0c89452024-10-11 16:53:27 +08002004@@ -4840,21 +4844,18 @@ int mt7996_mcu_rdd_background_disable_timer(struct mt7996_dev *dev, bool disable
developer9237f442024-06-14 17:13:04 +08002005 int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev,
2006 struct ieee80211_vif *vif,
2007 struct mt7996_bss_conf *mconf,
2008- struct ieee80211_sta *sta)
2009+ struct mt7996_link_sta *mlink)
developer66e89bc2024-04-23 14:50:01 +08002010 {
developer9237f442024-06-14 17:13:04 +08002011- struct mt7996_sta *msta;
developer66e89bc2024-04-23 14:50:01 +08002012 struct sk_buff *skb;
developer66e89bc2024-04-23 14:50:01 +08002013
developer9237f442024-06-14 17:13:04 +08002014- msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mconf->vif->sta;
2015-
2016 skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76,
2017- &msta->wcid,
2018+ &mlink->wcid,
2019 MT7996_STA_UPDATE_MAX_SIZE);
2020 if (IS_ERR(skb))
2021 return PTR_ERR(skb);
developer66e89bc2024-04-23 14:50:01 +08002022
developer9237f442024-06-14 17:13:04 +08002023 /* starec hdr trans */
2024- mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, sta);
2025+ mt7996_mcu_sta_hdr_trans_tlv(dev, skb, vif, mlink);
2026 return mt76_mcu_skb_send_msg(&dev->mt76, skb,
2027 MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
developer66e89bc2024-04-23 14:50:01 +08002028 }
developerd0c89452024-10-11 16:53:27 +08002029@@ -5043,7 +5044,7 @@ int mt7996_mcu_get_per_sta_info(struct mt76_dev *dev, u16 tag,
developer9237f442024-06-14 17:13:04 +08002030 switch (tag) {
2031 case UNI_PER_STA_RSSI:
2032 for (i = 0; i < sta_num; ++i) {
2033- struct mt7996_sta *msta;
2034+ struct mt7996_link_sta *mlink;
2035 struct mt76_phy *phy;
2036 s8 rssi[4];
2037 u8 *rcpi;
developerd0c89452024-10-11 16:53:27 +08002038@@ -5057,10 +5058,10 @@ int mt7996_mcu_get_per_sta_info(struct mt76_dev *dev, u16 tag,
developer9237f442024-06-14 17:13:04 +08002039 rssi[2] = to_rssi(MT_PRXV_RCPI0, rcpi[2]);
2040 rssi[3] = to_rssi(MT_PRXV_RCPI0, rcpi[3]);
developer66e89bc2024-04-23 14:50:01 +08002041
developer9237f442024-06-14 17:13:04 +08002042- msta = container_of(wcid, struct mt7996_sta, wcid);
2043- phy = msta->vif->phy->mt76;
2044- msta->ack_signal = mt76_rx_signal(phy->antenna_mask, rssi);
2045- ewma_avg_signal_add(&msta->avg_ack_signal, -msta->ack_signal);
2046+ mlink = container_of(wcid, struct mt7996_link_sta, wcid);
2047+ phy = mlink->sta->vif->deflink.phy->mt76;
2048+ mlink->ack_signal = mt76_rx_signal(phy->antenna_mask, rssi);
2049+ ewma_avg_signal_add(&mlink->avg_ack_signal, -mlink->ack_signal);
2050 } else {
2051 ret = -EINVAL;
2052 dev_err(dev->dev, "Failed to update RSSI for "
developerd0c89452024-10-11 16:53:27 +08002053@@ -5082,7 +5083,7 @@ int mt7996_mcu_get_rssi(struct mt76_dev *dev)
developer66e89bc2024-04-23 14:50:01 +08002054 {
developer9237f442024-06-14 17:13:04 +08002055 u16 sta_list[PER_STA_INFO_MAX_NUM];
2056 LIST_HEAD(sta_poll_list);
2057- struct mt7996_sta *msta;
2058+ struct mt7996_link_sta *mlink;
2059 int i, ret;
2060 bool empty = false;
developer66e89bc2024-04-23 14:50:01 +08002061
developerd0c89452024-10-11 16:53:27 +08002062@@ -5102,13 +5103,13 @@ int mt7996_mcu_get_rssi(struct mt76_dev *dev)
developer9237f442024-06-14 17:13:04 +08002063 empty = true;
2064 break;
2065 }
2066- msta = list_first_entry(&sta_poll_list,
2067- struct mt7996_sta,
2068+ mlink = list_first_entry(&sta_poll_list,
2069+ struct mt7996_link_sta,
2070 wcid.poll_list);
2071- list_del_init(&msta->wcid.poll_list);
2072+ list_del_init(&mlink->wcid.poll_list);
2073 spin_unlock_bh(&dev->sta_poll_lock);
developer66e89bc2024-04-23 14:50:01 +08002074
developer9237f442024-06-14 17:13:04 +08002075- sta_list[i] = msta->wcid.idx;
2076+ sta_list[i] = mlink->wcid.idx;
2077 }
developer66e89bc2024-04-23 14:50:01 +08002078
developer9237f442024-06-14 17:13:04 +08002079 ret = mt7996_mcu_get_per_sta_info(dev, UNI_PER_STA_RSSI,
developerd0c89452024-10-11 16:53:27 +08002080@@ -5398,10 +5399,18 @@ int mt7996_mcu_set_scs_stats(struct mt7996_phy *phy)
developer9237f442024-06-14 17:13:04 +08002081 void mt7996_sta_rssi_work(void *data, struct ieee80211_sta *sta)
developer66e89bc2024-04-23 14:50:01 +08002082 {
developer9237f442024-06-14 17:13:04 +08002083 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
2084+ struct mt7996_link_sta *mlink;
2085 struct mt7996_phy *poll_phy = (struct mt7996_phy *) data;
developer66e89bc2024-04-23 14:50:01 +08002086
developer9237f442024-06-14 17:13:04 +08002087- if (poll_phy->scs_ctrl.sta_min_rssi > msta->ack_signal)
2088- poll_phy->scs_ctrl.sta_min_rssi = msta->ack_signal;
2089+ mutex_lock(&poll_phy->dev->mt76.mutex);
2090+ mlink = mlink_dereference_protected(msta, 0);
2091+ if (!mlink)
2092+ goto out;
2093+
2094+ if (poll_phy->scs_ctrl.sta_min_rssi > mlink->ack_signal)
2095+ poll_phy->scs_ctrl.sta_min_rssi = mlink->ack_signal;
2096+out:
2097+ mutex_unlock(&poll_phy->dev->mt76.mutex);
developer66e89bc2024-04-23 14:50:01 +08002098 }
2099
developer9237f442024-06-14 17:13:04 +08002100 void mt7996_mcu_scs_sta_poll(struct work_struct *work)
developerd0c89452024-10-11 16:53:27 +08002101@@ -5477,9 +5486,10 @@ int mt7996_mcu_set_scs(struct mt7996_phy *phy, u8 enable)
developer9237f442024-06-14 17:13:04 +08002102
2103 int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy,
2104 struct mt7996_bss_conf *mconf,
2105- struct mt7996_sta *msta, enum vow_drr_ctrl_id id)
2106+ struct mt7996_link_sta *mlink,
2107+ enum vow_drr_ctrl_id id)
developer66e89bc2024-04-23 14:50:01 +08002108 {
developer9237f442024-06-14 17:13:04 +08002109- struct mt7996_vow_sta_ctrl *vow = msta ? &msta->vow : NULL;
2110+ struct mt7996_vow_sta_ctrl *vow = mlink ? &mlink->vow : NULL;
developer66e89bc2024-04-23 14:50:01 +08002111 u32 val = 0;
developer9237f442024-06-14 17:13:04 +08002112 struct {
2113 u8 __rsv1[4];
developerd0c89452024-10-11 16:53:27 +08002114@@ -5501,11 +5511,11 @@ int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy,
developer9237f442024-06-14 17:13:04 +08002115 } __packed req = {
2116 .tag = cpu_to_le16(UNI_VOW_DRR_CTRL),
developer66e89bc2024-04-23 14:50:01 +08002117 .len = cpu_to_le16(sizeof(req) - 4),
developer9237f442024-06-14 17:13:04 +08002118- .wlan_idx = cpu_to_le16(msta ? msta->wcid.idx : 0),
2119+ .wlan_idx = cpu_to_le16(mlink ? mlink->wcid.idx : 0),
developer66e89bc2024-04-23 14:50:01 +08002120 .band_idx = phy->mt76->band_idx,
developer9237f442024-06-14 17:13:04 +08002121- .wmm_idx = msta ? mconf->mt76.wmm_idx : 0,
2122+ .wmm_idx = mlink ? mconf->mt76.wmm_idx : 0,
developer66e89bc2024-04-23 14:50:01 +08002123 .ctrl_id = cpu_to_le32(id),
developer9237f442024-06-14 17:13:04 +08002124- .omac_idx = msta ? mconf->mt76.omac_idx : 0
2125+ .omac_idx = mlink ? mconf->mt76.omac_idx : 0
developer66e89bc2024-04-23 14:50:01 +08002126 };
2127
2128 switch (id) {
developer66e89bc2024-04-23 14:50:01 +08002129diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +08002130index be966c18..d86e24e3 100644
developer66e89bc2024-04-23 14:50:01 +08002131--- a/mt7996/mt7996.h
2132+++ b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +08002133@@ -304,10 +304,10 @@ struct mt7996_vow_sta_ctrl {
developer9237f442024-06-14 17:13:04 +08002134 u8 drr_quantum[IEEE80211_NUM_ACS];
developer66e89bc2024-04-23 14:50:01 +08002135 };
2136
developer9237f442024-06-14 17:13:04 +08002137-struct mt7996_sta {
2138+struct mt7996_link_sta {
2139 struct mt76_wcid wcid; /* must be first */
developer66e89bc2024-04-23 14:50:01 +08002140
developer9237f442024-06-14 17:13:04 +08002141- struct mt7996_vif *vif;
2142+ struct mt7996_sta *sta;
developer66e89bc2024-04-23 14:50:01 +08002143
developer9237f442024-06-14 17:13:04 +08002144 struct list_head rc_list;
2145
developerd0c89452024-10-11 16:53:27 +08002146@@ -326,6 +326,13 @@ struct mt7996_sta {
developer9237f442024-06-14 17:13:04 +08002147 struct mt7996_vow_sta_ctrl vow;
developer66e89bc2024-04-23 14:50:01 +08002148 };
2149
developer9237f442024-06-14 17:13:04 +08002150+struct mt7996_sta {
2151+ struct mt7996_link_sta deflink;
2152+ struct mt7996_link_sta __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS];
developer66e89bc2024-04-23 14:50:01 +08002153+
developer9237f442024-06-14 17:13:04 +08002154+ struct mt7996_vif *vif;
developer66e89bc2024-04-23 14:50:01 +08002155+};
2156+
developer9237f442024-06-14 17:13:04 +08002157 struct mt7996_bss_conf {
2158 struct mt76_vif mt76; /* must be first */
2159
developerd0c89452024-10-11 16:53:27 +08002160@@ -788,6 +795,13 @@ mconf_dereference_protected(struct mt7996_vif *mvif, u8 link_id)
developer9237f442024-06-14 17:13:04 +08002161 lockdep_is_held(&mvif->dev->mt76.mutex));
developer66e89bc2024-04-23 14:50:01 +08002162 }
2163
developer9237f442024-06-14 17:13:04 +08002164+static inline struct mt7996_link_sta *
2165+mlink_dereference_protected(struct mt7996_sta *msta, u8 link_id)
developer66e89bc2024-04-23 14:50:01 +08002166+{
developer9237f442024-06-14 17:13:04 +08002167+ return rcu_dereference_protected(msta->link[link_id],
2168+ lockdep_is_held(&msta->vif->dev->mt76.mutex));
developer66e89bc2024-04-23 14:50:01 +08002169+}
2170+
2171 extern const struct ieee80211_ops mt7996_ops;
2172 extern struct pci_driver mt7996_pci_driver;
2173 extern struct pci_driver mt7996_hif_driver;
developerd0c89452024-10-11 16:53:27 +08002174@@ -832,10 +846,12 @@ int mt7996_mcu_add_dev_info(struct mt7996_phy *phy,
developer9237f442024-06-14 17:13:04 +08002175 struct mt7996_bss_conf *mconf, bool enable);
developer66e89bc2024-04-23 14:50:01 +08002176 int mt7996_mcu_add_bss_info(struct mt7996_phy *phy,
developer9237f442024-06-14 17:13:04 +08002177 struct ieee80211_bss_conf *conf,
2178- struct mt7996_bss_conf *mconf, int enable);
2179+ struct mt7996_bss_conf *mconf,
2180+ struct mt7996_link_sta *mlink, int enable);
2181 int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
2182- struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta,
2183- bool enable, bool newly);
2184+ struct mt7996_bss_conf *mconf,
2185+ struct ieee80211_link_sta *link_sta,
2186+ struct mt7996_link_sta *mlink, bool enable, bool newly);
developer66e89bc2024-04-23 14:50:01 +08002187 int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev,
2188 struct ieee80211_ampdu_params *params,
2189 bool add);
developerd0c89452024-10-11 16:53:27 +08002190@@ -857,7 +873,8 @@ int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy,
developer9237f442024-06-14 17:13:04 +08002191 int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev,
2192 struct ieee80211_bss_conf *conf,
2193 struct mt7996_bss_conf *mconf,
2194- struct ieee80211_sta *sta, bool changed);
2195+ struct ieee80211_link_sta *link_sta,
2196+ struct mt7996_link_sta *mlink, bool changed);
developer66e89bc2024-04-23 14:50:01 +08002197 int mt7996_set_channel(struct mt7996_phy *phy, struct cfg80211_chan_def *chandef);
2198 int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag);
developer9237f442024-06-14 17:13:04 +08002199 int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct mt7996_bss_conf *mconf);
developerd0c89452024-10-11 16:53:27 +08002200@@ -865,7 +882,9 @@ int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev,
developer66e89bc2024-04-23 14:50:01 +08002201 void *data, u16 version);
developer9237f442024-06-14 17:13:04 +08002202 int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev,
2203 struct mt7996_bss_conf *mconf,
2204- struct ieee80211_sta *sta, void *data, u32 field);
2205+ struct ieee80211_link_sta *link_sta,
2206+ struct mt7996_link_sta *mlink, void *data,
2207+ u32 field);
developer66e89bc2024-04-23 14:50:01 +08002208 int mt7996_mcu_set_eeprom(struct mt7996_dev *dev);
developerd0c89452024-10-11 16:53:27 +08002209 int mt7996_mcu_get_eeprom(struct mt7996_dev *dev, u32 offset, u8 *buf, u32 buf_len);
developer9237f442024-06-14 17:13:04 +08002210 int mt7996_mcu_get_eeprom_free_block(struct mt7996_dev *dev, u8 *block_num);
developerd0c89452024-10-11 16:53:27 +08002211@@ -921,7 +940,8 @@ void mt7996_mcu_scs_sta_poll(struct work_struct *work);
developer66e89bc2024-04-23 14:50:01 +08002212 int mt7996_mcu_set_band_confg(struct mt7996_phy *phy, u16 option, bool enable);
developer9237f442024-06-14 17:13:04 +08002213 int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy,
2214 struct mt7996_bss_conf *mconf,
2215- struct mt7996_sta *msta, enum vow_drr_ctrl_id id);
2216+ struct mt7996_link_sta *mlink,
2217+ enum vow_drr_ctrl_id id);
developer66e89bc2024-04-23 14:50:01 +08002218 int mt7996_mcu_set_vow_feature_ctrl(struct mt7996_phy *phy);
2219 void mt7996_mcu_wmm_pbc_work(struct work_struct *work);
2220
developerd0c89452024-10-11 16:53:27 +08002221@@ -988,7 +1008,7 @@ void mt7996_mac_reset_counters(struct mt7996_phy *phy);
developer9237f442024-06-14 17:13:04 +08002222 void mt7996_mac_cca_stats_reset(struct mt7996_phy *phy);
2223 void mt7996_mac_enable_nf(struct mt7996_dev *dev, u8 band);
2224 void mt7996_mac_enable_rtscts(struct mt7996_dev *dev,
2225- struct ieee80211_vif *vif, bool enable);
2226+ struct mt7996_link_sta *mlink, bool enable);
2227 void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
2228 struct sk_buff *skb, struct mt76_wcid *wcid,
2229 struct ieee80211_key_conf *key, int pid,
developerd0c89452024-10-11 16:53:27 +08002230@@ -1006,8 +1026,7 @@ void mt7996_mac_dump_work(struct work_struct *work);
developer9237f442024-06-14 17:13:04 +08002231 void mt7996_mac_sta_rc_work(struct work_struct *work);
2232 void mt7996_mac_update_stats(struct mt7996_phy *phy);
2233 void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev,
2234- struct mt7996_sta *msta,
2235- u8 flowid);
2236+ struct mt7996_link_sta *mlink, u8 flowid);
2237 void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
2238 struct ieee80211_sta *sta,
2239 struct ieee80211_twt_setup *twt);
developerd0c89452024-10-11 16:53:27 +08002240@@ -1036,11 +1055,12 @@ int mt7996_mcu_add_key(struct mt76_dev *dev, struct mt7996_bss_conf *mconf,
developer9237f442024-06-14 17:13:04 +08002241 int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev,
2242 struct ieee80211_bss_conf *conf,
2243 struct mt7996_bss_conf *mconf,
2244+ struct mt7996_link_sta *mlink,
developer66e89bc2024-04-23 14:50:01 +08002245 struct ieee80211_key_conf *key);
2246 int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev,
2247 struct ieee80211_vif *vif,
developer9237f442024-06-14 17:13:04 +08002248 struct mt7996_bss_conf *mconf,
2249- struct ieee80211_sta *sta);
2250+ struct mt7996_link_sta *mlink);
developer66e89bc2024-04-23 14:50:01 +08002251 int mt7996_mcu_cp_support(struct mt7996_dev *dev, u8 mode);
2252 int mt7996_mcu_set_pp_en(struct mt7996_phy *phy, u8 mode, u16 bitmap);
developer9237f442024-06-14 17:13:04 +08002253 #ifdef CONFIG_MAC80211_DEBUGFS
developer66e89bc2024-04-23 14:50:01 +08002254diff --git a/mt7996/testmode.c b/mt7996/testmode.c
developerd0c89452024-10-11 16:53:27 +08002255index 042da4e4..be224373 100644
developer66e89bc2024-04-23 14:50:01 +08002256--- a/mt7996/testmode.c
2257+++ b/mt7996/testmode.c
developerd0c89452024-10-11 16:53:27 +08002258@@ -241,8 +241,8 @@ mt7996_tm_init(struct mt7996_phy *phy, bool en)
developer66e89bc2024-04-23 14:50:01 +08002259
2260 mt7996_tm_rf_switch_mode(dev, rf_test_mode);
2261
developer9237f442024-06-14 17:13:04 +08002262- mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, en);
2263- mt7996_mcu_add_sta(dev, &phy->monitor_vif->bss_conf, &mvif->deflink, NULL, en, false);
2264+ mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, &mvif->sta.deflink, en);
2265+ mt7996_mcu_add_sta(dev, &phy->monitor_vif->bss_conf, &mvif->deflink, NULL, &mvif->sta.deflink, en, false);
developer66e89bc2024-04-23 14:50:01 +08002266
2267 mt7996_tm_set(dev, SET_ID(BAND_IDX), phy->mt76->band_idx);
2268
developerd0c89452024-10-11 16:53:27 +08002269@@ -1192,7 +1192,7 @@ mt7996_tm_txbf_init(struct mt7996_phy *phy, u16 *val)
developer9237f442024-06-14 17:13:04 +08002270 phy->omac_mask |= BIT_ULL(mvif->deflink.mt76.omac_idx);
developer66e89bc2024-04-23 14:50:01 +08002271
developer9237f442024-06-14 17:13:04 +08002272 mt7996_mcu_add_dev_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, true);
2273- mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, true);
2274+ mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, &mvif->sta.deflink, true);
developer66e89bc2024-04-23 14:50:01 +08002275
2276 if (td->ibf) {
2277 if (td->is_txbf_dut) {
2278--
developerd0c89452024-10-11 16:53:27 +080022792.45.2
developer66e89bc2024-04-23 14:50:01 +08002280