blob: f035710e0c01e7e2dc2b7d7eb0a7c5e940df40ee [file] [log] [blame]
developer9237f442024-06-14 17:13:04 +08001From a8c22741f0614f90922e3dcac3a94666e29e4682 Mon Sep 17 00:00:00 2001
2From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Fri, 24 Nov 2023 11:31:55 +0800
4Subject: [PATCH 085/116] wifi: mt76: mt7996: switch to per-link data structure
5 of vif
6
7Introduce struct mt7996_bss_conf, data structure for per-link BSS.
8Note that mt7996_vif now represents a legacy or MLD device.
9This is a preliminary patch to add MLO support for mt7996 chipsets.
10
11Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com>
12Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
13Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
14---
15 mt7996/debugfs.c | 10 +-
16 mt7996/init.c | 4 +-
17 mt7996/mac.c | 25 ++-
18 mt7996/main.c | 269 ++++++++++++++++++-----------
19 mt7996/mcu.c | 429 +++++++++++++++++++++++-----------------------
20 mt7996/mt7996.h | 72 +++++---
21 mt7996/testmode.c | 17 +-
22 7 files changed, 463 insertions(+), 363 deletions(-)
23
24diff --git a/mt7996/debugfs.c b/mt7996/debugfs.c
25index 8377586..06015d6 100644
26--- a/mt7996/debugfs.c
27+++ b/mt7996/debugfs.c
28@@ -739,7 +739,7 @@ static void
29 mt7996_sta_hw_queue_read(void *data, struct ieee80211_sta *sta)
30 {
31 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
32- struct mt7996_dev *dev = msta->vif->phy->dev;
33+ struct mt7996_dev *dev = msta->vif->deflink.phy->dev;
34 struct seq_file *s = data;
35 u8 ac;
36
37@@ -759,7 +759,7 @@ mt7996_sta_hw_queue_read(void *data, struct ieee80211_sta *sta)
38 GENMASK(11, 0));
39 seq_printf(s, "\tSTA %pM wcid %d: AC%d%d queued:%d\n",
40 sta->addr, msta->wcid.idx,
41- msta->vif->mt76.wmm_idx, ac, qlen);
42+ msta->vif->deflink.mt76.wmm_idx, ac, qlen);
43 }
44 }
45
46@@ -1023,7 +1023,7 @@ mt7996_atf_enable_set(void *data, u64 val)
47 int ret;
48
49 vow->max_deficit = val ? 64 : 1;
50- ret = mt7996_mcu_set_vow_drr_ctrl(phy, NULL, VOW_DRR_CTRL_AIRTIME_DEFICIT_BOUND);
51+ ret = mt7996_mcu_set_vow_drr_ctrl(phy, NULL, NULL, VOW_DRR_CTRL_AIRTIME_DEFICIT_BOUND);
52 if (ret)
53 return ret;
54
55@@ -1055,7 +1055,7 @@ mt7996_airtime_read(struct seq_file *s, void *data)
56
57 msta = container_of(wcid, struct mt7996_sta, wcid);
58 sta = container_of((void *)msta, struct ieee80211_sta, drv_priv);
59- vif = &msta->vif->mt76;
60+ vif = &msta->vif->deflink.mt76;
61 stats = &wcid->stats;
62
63 seq_printf(s, "%pM WCID: %hu BandIdx: %hhu OmacIdx: 0x%hhx\t"
64@@ -1230,7 +1230,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
65 #define LONG_PREAMBLE 1
66 struct ieee80211_sta *sta = file->private_data;
67 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
68- struct mt7996_dev *dev = msta->vif->phy->dev;
69+ struct mt7996_dev *dev = msta->vif->deflink.phy->dev;
70 struct ra_rate phy = {};
71 char buf[100];
72 int ret;
73diff --git a/mt7996/init.c b/mt7996/init.c
74index 6eeec3b..381e129 100644
75--- a/mt7996/init.c
76+++ b/mt7996/init.c
77@@ -628,11 +628,11 @@ static int mt7996_vow_init(struct mt7996_phy *phy)
78 vow->drr_quantum[6] = VOW_DRR_QUANTUM_L6;
79 vow->drr_quantum[7] = VOW_DRR_QUANTUM_L7;
80
81- ret = mt7996_mcu_set_vow_drr_ctrl(phy, NULL, VOW_DRR_CTRL_AIRTIME_DEFICIT_BOUND);
82+ ret = mt7996_mcu_set_vow_drr_ctrl(phy, NULL, NULL, VOW_DRR_CTRL_AIRTIME_DEFICIT_BOUND);
83 if (ret)
84 return ret;
85
86- ret = mt7996_mcu_set_vow_drr_ctrl(phy, NULL, VOW_DRR_CTRL_AIRTIME_QUANTUM_ALL);
87+ ret = mt7996_mcu_set_vow_drr_ctrl(phy, NULL, NULL, VOW_DRR_CTRL_AIRTIME_QUANTUM_ALL);
88 if (ret)
89 return ret;
90
91diff --git a/mt7996/mac.c b/mt7996/mac.c
92index 0879c77..63b16f9 100644
93--- a/mt7996/mac.c
94+++ b/mt7996/mac.c
95@@ -897,8 +897,9 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
96
97 if (vif) {
98 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
99+ struct mt7996_bss_conf *mconf = &mvif->deflink;
100
101- txp->fw.bss_idx = mvif->mt76.idx;
102+ txp->fw.bss_idx = mconf->mt76.idx;
103 }
104
105 txp->fw.token = cpu_to_le16(id);
106@@ -1518,12 +1519,15 @@ static void
107 mt7996_update_vif_beacon(void *priv, u8 *mac, struct ieee80211_vif *vif)
108 {
109 struct ieee80211_hw *hw = priv;
110+ struct ieee80211_bss_conf *conf = &vif->bss_conf;
111+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
112+ struct mt7996_bss_conf *mconf = &mvif->deflink;
113
114 switch (vif->type) {
115 case NL80211_IFTYPE_MESH_POINT:
116 case NL80211_IFTYPE_ADHOC:
117 case NL80211_IFTYPE_AP:
118- mt7996_mcu_add_beacon(hw, vif, vif->bss_conf.enable_beacon);
119+ mt7996_mcu_add_beacon(hw, conf, mconf, conf->enable_beacon);
120 break;
121 default:
122 break;
123@@ -2237,6 +2241,8 @@ void mt7996_mac_sta_rc_work(struct work_struct *work)
124 struct mt7996_dev *dev = container_of(work, struct mt7996_dev, rc_work);
125 struct ieee80211_sta *sta;
126 struct ieee80211_vif *vif;
127+ struct ieee80211_bss_conf *conf;
128+ struct mt7996_bss_conf *mconf;
129 struct mt7996_sta *msta;
130 u32 changed;
131 LIST_HEAD(list);
132@@ -2253,14 +2259,16 @@ void mt7996_mac_sta_rc_work(struct work_struct *work)
133
134 sta = container_of((void *)msta, struct ieee80211_sta, drv_priv);
135 vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv);
136+ conf = &vif->bss_conf;
137+ mconf = &msta->vif->deflink;
138
139 if (changed & (IEEE80211_RC_SUPP_RATES_CHANGED |
140 IEEE80211_RC_NSS_CHANGED |
141 IEEE80211_RC_BW_CHANGED))
142- mt7996_mcu_add_rate_ctrl(dev, vif, sta, true);
143+ mt7996_mcu_add_rate_ctrl(dev, conf, mconf, sta, true);
144
145 if (changed & IEEE80211_RC_SMPS_CHANGED)
146- mt7996_mcu_set_fixed_field(dev, vif, sta, NULL,
147+ mt7996_mcu_set_fixed_field(dev, mconf, sta, NULL,
148 RATE_PARAM_MMPS_UPDATE);
149
150 spin_lock_bh(&dev->mt76.sta_poll_lock);
151@@ -2643,7 +2651,7 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
152
153 flow->sched = true;
154 flow->start_tsf = mt7996_mac_twt_sched_list_add(dev, flow);
155- curr_tsf = __mt7996_get_tsf(hw, msta->vif);
156+ curr_tsf = __mt7996_get_tsf(hw, &msta->vif->deflink);
157 div_u64_rem(curr_tsf - flow->start_tsf, interval, &rem);
158 flow_tsf = curr_tsf + interval - rem;
159 twt_agrt->twt = cpu_to_le64(flow_tsf);
160@@ -2652,7 +2660,8 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
161 }
162 flow->tsf = le64_to_cpu(twt_agrt->twt);
163
164- if (mt7996_mcu_twt_agrt_update(dev, msta->vif, flow, MCU_TWT_AGRT_ADD))
165+ if (mt7996_mcu_twt_agrt_update(dev, &msta->vif->deflink, flow,
166+ MCU_TWT_AGRT_ADD))
167 goto unlock;
168
169 setup_cmd = TWT_SETUP_CMD_ACCEPT;
170@@ -2674,6 +2683,7 @@ void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev,
171 u8 flowid)
172 {
173 struct mt7996_twt_flow *flow;
174+ struct mt7996_bss_conf *mconf = mconf_dereference_protected(msta->vif, 0);
175
176 lockdep_assert_held(&dev->mt76.mutex);
177
178@@ -2684,8 +2694,7 @@ void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev,
179 return;
180
181 flow = &msta->twt.flow[flowid];
182- if (mt7996_mcu_twt_agrt_update(dev, msta->vif, flow,
183- MCU_TWT_AGRT_DELETE))
184+ if (mt7996_mcu_twt_agrt_update(dev, mconf, flow, MCU_TWT_AGRT_DELETE))
185 return;
186
187 list_del_init(&flow->list);
188diff --git a/mt7996/main.c b/mt7996/main.c
189index 9eb4c5b..bc4863d 100644
190--- a/mt7996/main.c
191+++ b/mt7996/main.c
192@@ -205,29 +205,30 @@ static int get_omac_idx(enum nl80211_iftype type, u64 mask)
193 return -1;
194 }
195
196-static void mt7996_init_bitrate_mask(struct ieee80211_vif *vif)
197+static void mt7996_init_bitrate_mask(struct mt7996_bss_conf *mconf)
198 {
199- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
200 int i;
201
202- for (i = 0; i < ARRAY_SIZE(mvif->bitrate_mask.control); i++) {
203- mvif->bitrate_mask.control[i].gi = NL80211_TXRATE_DEFAULT_GI;
204- mvif->bitrate_mask.control[i].he_gi = 0xff;
205- mvif->bitrate_mask.control[i].he_ltf = 0xff;
206- mvif->bitrate_mask.control[i].legacy = GENMASK(31, 0);
207- memset(mvif->bitrate_mask.control[i].ht_mcs, 0xff,
208- sizeof(mvif->bitrate_mask.control[i].ht_mcs));
209- memset(mvif->bitrate_mask.control[i].vht_mcs, 0xff,
210- sizeof(mvif->bitrate_mask.control[i].vht_mcs));
211- memset(mvif->bitrate_mask.control[i].he_mcs, 0xff,
212- sizeof(mvif->bitrate_mask.control[i].he_mcs));
213+ for (i = 0; i < ARRAY_SIZE(mconf->bitrate_mask.control); i++) {
214+ mconf->bitrate_mask.control[i].gi = NL80211_TXRATE_DEFAULT_GI;
215+ mconf->bitrate_mask.control[i].he_gi = 0xff;
216+ mconf->bitrate_mask.control[i].he_ltf = 0xff;
217+ mconf->bitrate_mask.control[i].legacy = GENMASK(31, 0);
218+ memset(mconf->bitrate_mask.control[i].ht_mcs, 0xff,
219+ sizeof(mconf->bitrate_mask.control[i].ht_mcs));
220+ memset(mconf->bitrate_mask.control[i].vht_mcs, 0xff,
221+ sizeof(mconf->bitrate_mask.control[i].vht_mcs));
222+ memset(mconf->bitrate_mask.control[i].he_mcs, 0xff,
223+ sizeof(mconf->bitrate_mask.control[i].he_mcs));
224 }
225 }
226
227 static int mt7996_add_interface(struct ieee80211_hw *hw,
228 struct ieee80211_vif *vif)
229 {
230+ struct ieee80211_bss_conf *conf = &vif->bss_conf;
231 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
232+ struct mt7996_bss_conf *mconf = &mvif->deflink;
233 struct mt7996_dev *dev = mt7996_hw_dev(hw);
234 struct mt7996_phy *phy = mt7996_hw_phy(hw);
235 struct mt76_txq *mtxq;
236@@ -240,8 +241,8 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
237 is_zero_ether_addr(vif->addr))
238 phy->monitor_vif = vif;
239
240- mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
241- if (mvif->mt76.idx >= mt7996_max_interface_num(dev)) {
242+ mconf->mt76.idx = __ffs64(~dev->mt76.vif_mask);
243+ if (mconf->mt76.idx >= mt7996_max_interface_num(dev)) {
244 ret = -ENOSPC;
245 goto out;
246 }
247@@ -251,19 +252,21 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
248 ret = -ENOSPC;
249 goto out;
250 }
251- mvif->mt76.omac_idx = idx;
252- mvif->phy = phy;
253- mvif->mt76.band_idx = band_idx;
254- mvif->mt76.wmm_idx = vif->type != NL80211_IFTYPE_AP;
255-
256- ret = mt7996_mcu_add_dev_info(phy, vif, true);
257+ mconf->mt76.omac_idx = idx;
258+ mconf->vif = mvif;
259+ mconf->phy = phy;
260+ mconf->mt76.band_idx = band_idx;
261+ mconf->mt76.wmm_idx = vif->type != NL80211_IFTYPE_AP;
262+ mvif->dev = dev;
263+
264+ ret = mt7996_mcu_add_dev_info(phy, conf, mconf, true);
265 if (ret)
266 goto out;
267
268- dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx);
269- phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
270+ dev->mt76.vif_mask |= BIT_ULL(mconf->mt76.idx);
271+ phy->omac_mask |= BIT_ULL(mconf->mt76.omac_idx);
272
273- idx = MT7996_WTBL_RESERVED - mvif->mt76.idx;
274+ idx = MT7996_WTBL_RESERVED - mconf->mt76.idx;
275
276 INIT_LIST_HEAD(&mvif->sta.rc_list);
277 INIT_LIST_HEAD(&mvif->sta.wcid.poll_list);
278@@ -283,24 +286,25 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
279 }
280
281 if (vif->type != NL80211_IFTYPE_AP &&
282- (!mvif->mt76.omac_idx || mvif->mt76.omac_idx > 3))
283+ (!mconf->mt76.omac_idx || mconf->mt76.omac_idx > 3))
284 vif->offload_flags = 0;
285 vif->offload_flags |= IEEE80211_OFFLOAD_ENCAP_4ADDR;
286
287 if (phy->mt76->chandef.chan->band != NL80211_BAND_2GHZ)
288- mvif->mt76.basic_rates_idx = MT7996_BASIC_RATES_TBL + 4;
289+ mconf->mt76.basic_rates_idx = MT7996_BASIC_RATES_TBL + 4;
290 else
291- mvif->mt76.basic_rates_idx = MT7996_BASIC_RATES_TBL;
292+ mconf->mt76.basic_rates_idx = MT7996_BASIC_RATES_TBL;
293
294- mt7996_init_bitrate_mask(vif);
295+ mt7996_init_bitrate_mask(mconf);
296
297- mt7996_mcu_add_bss_info(phy, vif, true);
298+ mt7996_mcu_add_bss_info(phy, conf, mconf, true);
299 /* defer the first STA_REC of BMC entry to BSS_CHANGED_BSSID for STA
300 * interface, since firmware only records BSSID when the entry is new
301 */
302 if (vif->type != NL80211_IFTYPE_STATION)
303- mt7996_mcu_add_sta(dev, vif, NULL, true, true);
304+ mt7996_mcu_add_sta(dev, conf, mconf, NULL, true, true);
305 rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid);
306+ rcu_assign_pointer(mvif->link[0], mconf);
307
308 out:
309 mutex_unlock(&dev->mt76.mutex);
310@@ -311,7 +315,9 @@ out:
311 static void mt7996_remove_interface(struct ieee80211_hw *hw,
312 struct ieee80211_vif *vif)
313 {
314+ struct ieee80211_bss_conf *conf;
315 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
316+ struct mt7996_bss_conf *mconf;
317 struct mt7996_sta *msta = &mvif->sta;
318 struct mt7996_dev *dev = mt7996_hw_dev(hw);
319 struct mt7996_phy *phy = mt7996_hw_phy(hw);
320@@ -319,24 +325,22 @@ static void mt7996_remove_interface(struct ieee80211_hw *hw,
321
322 cancel_delayed_work_sync(&phy->scan_work);
323
324- mt7996_mcu_add_sta(dev, vif, NULL, false, false);
325- mt7996_mcu_add_bss_info(phy, vif, false);
326+ mutex_lock(&dev->mt76.mutex);
327+
328+ conf = link_conf_dereference_protected(vif, 0);
329+ mconf = mconf_dereference_protected(mvif, 0);
330+ mt7996_mcu_add_sta(dev, conf, mconf, NULL, false, false);
331+ mt7996_mcu_add_bss_info(phy, conf, mconf, false);
332
333 if (vif == phy->monitor_vif)
334 phy->monitor_vif = NULL;
335
336- mt7996_mcu_add_dev_info(phy, vif, false);
337+ mt7996_mcu_add_dev_info(phy, conf, mconf, false);
338
339 rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
340
341- mutex_lock(&dev->mt76.mutex);
342-
343- if (test_bit(MT76_SCANNING, &phy->mt76->state))
344- mt7996_scan_complete(phy, true);
345-
346- dev->mt76.vif_mask &= ~BIT_ULL(mvif->mt76.idx);
347- phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
348- mutex_unlock(&dev->mt76.mutex);
349+ dev->mt76.vif_mask &= ~BIT_ULL(mconf->mt76.idx);
350+ phy->omac_mask &= ~BIT_ULL(mconf->mt76.omac_idx);
351
352 spin_lock_bh(&dev->mt76.sta_poll_lock);
353 if (!list_empty(&msta->wcid.poll_list))
354@@ -344,6 +348,9 @@ static void mt7996_remove_interface(struct ieee80211_hw *hw,
355 spin_unlock_bh(&dev->mt76.sta_poll_lock);
356
357 mt76_wcid_cleanup(&dev->mt76, &msta->wcid);
358+ rcu_assign_pointer(mvif->link[0], NULL);
359+
360+ mutex_unlock(&dev->mt76.mutex);
361 }
362
363 static void ___mt7996_set_channel(struct mt7996_phy *phy,
364@@ -441,6 +448,8 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
365 struct mt7996_sta *msta = sta ? (struct mt7996_sta *)sta->drv_priv :
366 &mvif->sta;
367 struct mt76_wcid *wcid = &msta->wcid;
368+ struct mt7996_bss_conf *mconf;
369+ struct ieee80211_bss_conf *conf;
370 u8 *wcid_keyidx = &wcid->hw_key_idx;
371 int idx = key->keyidx;
372 int err = 0;
373@@ -482,9 +491,11 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
374
375 mutex_lock(&dev->mt76.mutex);
376
377- if (cmd == SET_KEY && !sta && !mvif->mt76.cipher) {
378- mvif->mt76.cipher = mt76_connac_mcu_get_cipher(key->cipher);
379- mt7996_mcu_add_bss_info(phy, vif, true);
380+ conf = link_conf_dereference_protected(vif, 0);
381+ mconf = mconf_dereference_protected(mvif, 0);
382+ if (cmd == SET_KEY && !sta && !mconf->mt76.cipher) {
383+ mconf->mt76.cipher = mt76_connac_mcu_get_cipher(key->cipher);
384+ mt7996_mcu_add_bss_info(phy, conf, mconf, true);
385 }
386
387 if (cmd == SET_KEY) {
388@@ -498,9 +509,9 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
389 mt76_wcid_key_setup(&dev->mt76, wcid, key);
390
391 if (key->keyidx == 6 || key->keyidx == 7)
392- err = mt7996_mcu_bcn_prot_enable(dev, vif, key);
393+ err = mt7996_mcu_bcn_prot_enable(dev, conf, mconf, key);
394 else
395- err = mt7996_mcu_add_key(&dev->mt76, vif, key,
396+ err = mt7996_mcu_add_key(&dev->mt76, mconf, key,
397 MCU_WMWA_UNI_CMD(STA_REC_UPDATE),
398 &msta->wcid, cmd);
399 out:
400@@ -547,7 +558,9 @@ mt7996_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
401 unsigned int link_id, u16 queue,
402 const struct ieee80211_tx_queue_params *params)
403 {
404+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
405 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
406+ struct mt7996_bss_conf *mconf;
407 static const u8 mq_to_aci[] = {
408 [IEEE80211_AC_VO] = 3,
409 [IEEE80211_AC_VI] = 2,
410@@ -555,10 +568,15 @@ mt7996_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
411 [IEEE80211_AC_BK] = 1,
412 };
413
414+ mutex_lock(&dev->mt76.mutex);
415+ mconf = mconf_dereference_protected(mvif, 0);
416+
417 /* firmware uses access class index */
418- mvif->queue_params[mq_to_aci[queue]] = *params;
419+ mconf->queue_params[mq_to_aci[queue]] = *params;
420 /* no need to update right away, we'll get BSS_CHANGED_QOS */
421
422+ mutex_unlock(&dev->mt76.mutex);
423+
424 return 0;
425 }
426
427@@ -619,22 +637,20 @@ static void mt7996_configure_filter(struct ieee80211_hw *hw,
428 }
429
430 static void
431-mt7996_update_bss_color(struct ieee80211_hw *hw,
432- struct ieee80211_vif *vif,
433+mt7996_update_bss_color(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
434+ struct mt7996_bss_conf *mconf,
435 struct cfg80211_he_bss_color *bss_color)
436 {
437 struct mt7996_dev *dev = mt7996_hw_dev(hw);
438
439 switch (vif->type) {
440 case NL80211_IFTYPE_AP: {
441- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
442-
443- if (mvif->mt76.omac_idx > HW_BSSID_MAX)
444+ if (mconf->mt76.omac_idx > HW_BSSID_MAX)
445 return;
446 fallthrough;
447 }
448 case NL80211_IFTYPE_STATION:
449- mt7996_mcu_update_bss_color(dev, vif, bss_color);
450+ mt7996_mcu_update_bss_color(dev, mconf, bss_color);
451 break;
452 default:
453 break;
454@@ -642,16 +658,15 @@ mt7996_update_bss_color(struct ieee80211_hw *hw,
455 }
456
457 static u8
458-mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
459- bool beacon, bool mcast)
460+mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_bss_conf *conf,
461+ struct mt7996_bss_conf *mconf, bool beacon, bool mcast)
462 {
463- struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
464 struct mt7996_dev *dev = mt7996_hw_dev(hw);
465- struct mt76_phy *mphy = hw->priv;
466+ struct mt76_phy *mphy = mconf->phy->mt76;
467 u16 rate;
468 u8 i, idx;
469
470- rate = mt76_connac2_mac_tx_rate_val(mphy, vif, beacon, mcast);
471+ rate = mt76_connac2_mac_tx_rate_val(mphy, conf->vif, beacon, mcast);
472
473 if (beacon) {
474 struct mt7996_phy *phy = mphy->priv;
475@@ -672,23 +687,22 @@ mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
476 if ((mt76_rates[i].hw_value & GENMASK(7, 0)) == idx)
477 return MT7996_BASIC_RATES_TBL + 2 * i;
478
479- return mvif->basic_rates_idx;
480+ return mconf->mt76.basic_rates_idx;
481 }
482
483 static void
484-mt7996_update_mu_group(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
485- struct ieee80211_bss_conf *info)
486+mt7996_update_mu_group(struct ieee80211_hw *hw, struct ieee80211_bss_conf *conf,
487+ struct mt7996_bss_conf *mconf)
488 {
489- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
490 struct mt7996_dev *dev = mt7996_hw_dev(hw);
491- u8 band = mvif->mt76.band_idx;
492+ u8 band = mconf->mt76.band_idx;
493 u32 *mu;
494
495- mu = (u32 *)info->mu_group.membership;
496+ mu = (u32 *)conf->mu_group.membership;
497 mt76_wr(dev, MT_WF_PHYRX_BAND_GID_TAB_VLD0(band), mu[0]);
498 mt76_wr(dev, MT_WF_PHYRX_BAND_GID_TAB_VLD1(band), mu[1]);
499
500- mu = (u32 *)info->mu_group.position;
501+ mu = (u32 *)conf->mu_group.position;
502 mt76_wr(dev, MT_WF_PHYRX_BAND_GID_TAB_POS0(band), mu[0]);
503 mt76_wr(dev, MT_WF_PHYRX_BAND_GID_TAB_POS1(band), mu[1]);
504 mt76_wr(dev, MT_WF_PHYRX_BAND_GID_TAB_POS2(band), mu[2]);
505@@ -700,20 +714,22 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
506 struct ieee80211_bss_conf *info,
507 u64 changed)
508 {
509- struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
510+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
511+ struct mt7996_bss_conf *mconf;
512 struct mt7996_phy *phy = mt7996_hw_phy(hw);
513 struct mt7996_dev *dev = mt7996_hw_dev(hw);
514
515 mutex_lock(&dev->mt76.mutex);
516
517+ mconf = mconf_dereference_protected(mvif, 0);
518 /* station mode uses BSSID to map the wlan entry to a peer,
519 * and then peer references bss_info_rfch to set bandwidth cap.
520 */
521 if ((changed & BSS_CHANGED_BSSID && !is_zero_ether_addr(info->bssid)) ||
522 (changed & BSS_CHANGED_ASSOC && vif->cfg.assoc) ||
523 (changed & BSS_CHANGED_BEACON_ENABLED && info->enable_beacon)) {
524- mt7996_mcu_add_bss_info(phy, vif, true);
525- mt7996_mcu_add_sta(dev, vif, NULL, true,
526+ mt7996_mcu_add_bss_info(phy, info, mconf, true);
527+ mt7996_mcu_add_sta(dev, info, mconf, NULL, true,
528 !!(changed & BSS_CHANGED_BSSID));
529 }
530
531@@ -725,42 +741,42 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
532
533 if (slottime != phy->slottime) {
534 phy->slottime = slottime;
535- mt7996_mcu_set_timing(phy, vif);
536+ mt7996_mcu_set_timing(phy, mconf);
537 }
538 }
539
540 if (changed & BSS_CHANGED_MCAST_RATE)
541- mvif->mcast_rates_idx =
542- mt7996_get_rates_table(hw, vif, false, true);
543+ mconf->mt76.mcast_rates_idx =
544+ mt7996_get_rates_table(hw, info, mconf, false, true);
545
546 if (changed & BSS_CHANGED_BASIC_RATES)
547- mvif->basic_rates_idx =
548- mt7996_get_rates_table(hw, vif, false, false);
549+ mconf->mt76.basic_rates_idx =
550+ mt7996_get_rates_table(hw, info, mconf, false, false);
551
552 /* ensure that enable txcmd_mode after bss_info */
553 if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED))
554- mt7996_mcu_set_tx(dev, vif);
555+ mt7996_mcu_set_tx(dev, mconf);
556
557 if (changed & BSS_CHANGED_HE_OBSS_PD)
558- mt7996_mcu_add_obss_spr(phy, vif, &info->he_obss_pd);
559+ mt7996_mcu_add_obss_spr(phy, mconf, &info->he_obss_pd);
560
561 if (changed & BSS_CHANGED_HE_BSS_COLOR)
562- mt7996_update_bss_color(hw, vif, &info->he_bss_color);
563+ mt7996_update_bss_color(hw, vif, mconf, &info->he_bss_color);
564
565 if (changed & (BSS_CHANGED_BEACON |
566 BSS_CHANGED_BEACON_ENABLED)) {
567- mvif->beacon_rates_idx =
568- mt7996_get_rates_table(hw, vif, true, false);
569+ mconf->mt76.beacon_rates_idx =
570+ mt7996_get_rates_table(hw, info, mconf, true, false);
571
572- mt7996_mcu_add_beacon(hw, vif, info->enable_beacon);
573+ mt7996_mcu_add_beacon(hw, info, mconf, info->enable_beacon);
574 }
575
576 if (changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
577 BSS_CHANGED_FILS_DISCOVERY))
578- mt7996_mcu_beacon_inband_discov(dev, vif, changed);
579+ mt7996_mcu_beacon_inband_discov(dev, info, mconf, changed);
580
581 if (changed & BSS_CHANGED_MU_GROUPS)
582- mt7996_update_mu_group(hw, vif, info);
583+ mt7996_update_mu_group(hw, info, mconf);
584
585 mutex_unlock(&dev->mt76.mutex);
586 }
587@@ -771,9 +787,14 @@ mt7996_channel_switch_beacon(struct ieee80211_hw *hw,
588 struct cfg80211_chan_def *chandef)
589 {
590 struct mt7996_dev *dev = mt7996_hw_dev(hw);
591+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
592+ struct mt7996_bss_conf *mconf;
593+ struct ieee80211_bss_conf *conf;
594
595 mutex_lock(&dev->mt76.mutex);
596- mt7996_mcu_add_beacon(hw, vif, true);
597+ mconf = mconf_dereference_protected(mvif, 0);
598+ conf = link_conf_dereference_protected(vif, 0);
599+ mt7996_mcu_add_beacon(hw, conf, mconf, true);
600 mutex_unlock(&dev->mt76.mutex);
601 }
602
603@@ -783,7 +804,8 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
604 struct mt7996_dev *dev = container_of(mdev, struct mt7996_dev, mt76);
605 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
606 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
607- u8 band_idx = mvif->phy->mt76->band_idx;
608+ struct mt7996_bss_conf *mconf = mconf_dereference_protected(mvif, 0);
609+ u8 band_idx = mconf->phy->mt76->band_idx;
610 int idx;
611
612 #ifdef CONFIG_MTK_VENDOR
613@@ -803,7 +825,7 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
614 msta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
615
616 #ifdef CONFIG_MTK_VENDOR
617- mt7996_vendor_amnt_sta_remove(mvif->phy, sta);
618+ mt7996_vendor_amnt_sta_remove(mconf->phy, sta);
619 #endif
620
621 #ifdef CONFIG_MTK_VENDOR
622@@ -830,15 +852,20 @@ void mt7996_mac_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
623 struct ieee80211_sta *sta)
624 {
625 struct mt7996_dev *dev = container_of(mdev, struct mt7996_dev, mt76);
626+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
627 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
628+ struct mt7996_bss_conf *mconf;
629+ struct ieee80211_bss_conf *conf;
630
631 mutex_lock(&dev->mt76.mutex);
632
633 mt7996_mac_wtbl_update(dev, msta->wcid.idx,
634 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
635
636- mt7996_mcu_add_sta(dev, vif, sta, true, true);
637- mt7996_mcu_add_rate_ctrl(dev, vif, sta, false);
638+ conf = link_conf_dereference_protected(vif, 0);
639+ mconf = mconf_dereference_protected(mvif, 0);
640+ mt7996_mcu_add_sta(dev, conf, mconf, sta, true, true);
641+ mt7996_mcu_add_rate_ctrl(dev, conf, mconf, sta, false);
642
643 ewma_avg_signal_init(&msta->avg_ack_signal);
644
645@@ -849,10 +876,15 @@ void mt7996_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
646 struct ieee80211_sta *sta)
647 {
648 struct mt7996_dev *dev = container_of(mdev, struct mt7996_dev, mt76);
649+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
650 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
651+ struct mt7996_bss_conf *mconf;
652+ struct ieee80211_bss_conf *conf;
653 int i;
654
655- mt7996_mcu_add_sta(dev, vif, sta, false, false);
656+ conf = link_conf_dereference_protected(vif, 0);
657+ mconf = mconf_dereference_protected(mvif, 0);
658+ mt7996_mcu_add_sta(dev, conf, mconf, sta, false, false);
659
660 mt7996_mac_wtbl_update(dev, msta->wcid.idx,
661 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
662@@ -984,7 +1016,7 @@ mt7996_get_stats(struct ieee80211_hw *hw,
663 return 0;
664 }
665
666-u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif *mvif)
667+u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_bss_conf *mconf)
668 {
669 struct mt7996_dev *dev = mt7996_hw_dev(hw);
670 struct mt7996_phy *phy = mt7996_hw_phy(hw);
671@@ -996,8 +1028,8 @@ u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif *mvif)
672
673 lockdep_assert_held(&dev->mt76.mutex);
674
675- n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
676- : mvif->mt76.omac_idx;
677+ n = mconf->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
678+ : mconf->mt76.omac_idx;
679 /* TSF software read */
680 mt76_rmw(dev, MT_LPON_TCR(phy->mt76->band_idx, n), MT_LPON_TCR_SW_MODE,
681 MT_LPON_TCR_SW_READ);
682@@ -1012,10 +1044,12 @@ mt7996_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
683 {
684 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
685 struct mt7996_dev *dev = mt7996_hw_dev(hw);
686+ struct mt7996_bss_conf *mconf;
687 u64 ret;
688
689 mutex_lock(&dev->mt76.mutex);
690- ret = __mt7996_get_tsf(hw, mvif);
691+ mconf = mconf_dereference_protected(mvif, 0);
692+ ret = __mt7996_get_tsf(hw, mconf);
693 mutex_unlock(&dev->mt76.mutex);
694
695 return ret;
696@@ -1028,6 +1062,7 @@ mt7996_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
697 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
698 struct mt7996_dev *dev = mt7996_hw_dev(hw);
699 struct mt7996_phy *phy = mt7996_hw_phy(hw);
700+ struct mt7996_bss_conf *mconf;
701 union {
702 u64 t64;
703 u32 t32[2];
704@@ -1036,8 +1071,9 @@ mt7996_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
705
706 mutex_lock(&dev->mt76.mutex);
707
708- n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
709- : mvif->mt76.omac_idx;
710+ mconf = mconf_dereference_protected(mvif, 0);
711+ n = mconf->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
712+ : mconf->mt76.omac_idx;
713 mt76_wr(dev, MT_LPON_UTTR0(phy->mt76->band_idx), tsf.t32[0]);
714 mt76_wr(dev, MT_LPON_UTTR1(phy->mt76->band_idx), tsf.t32[1]);
715 /* TSF software overwrite */
716@@ -1054,6 +1090,7 @@ mt7996_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
717 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
718 struct mt7996_dev *dev = mt7996_hw_dev(hw);
719 struct mt7996_phy *phy = mt7996_hw_phy(hw);
720+ struct mt7996_bss_conf *mconf;
721 union {
722 u64 t64;
723 u32 t32[2];
724@@ -1062,8 +1099,9 @@ mt7996_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
725
726 mutex_lock(&dev->mt76.mutex);
727
728- n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
729- : mvif->mt76.omac_idx;
730+ mconf = mconf_dereference_protected(mvif, 0);
731+ n = mconf->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
732+ : mconf->mt76.omac_idx;
733 mt76_wr(dev, MT_LPON_UTTR0(phy->mt76->band_idx), tsf.t32[0]);
734 mt76_wr(dev, MT_LPON_UTTR1(phy->mt76->band_idx), tsf.t32[1]);
735 /* TSF software adjust*/
736@@ -1179,7 +1217,7 @@ static void mt7996_sta_statistics(struct ieee80211_hw *hw,
737 static void mt7996_sta_rc_work(void *data, struct ieee80211_sta *sta)
738 {
739 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
740- struct mt7996_dev *dev = msta->vif->phy->dev;
741+ struct mt7996_dev *dev = msta->vif->dev;
742 u32 *changed = data;
743
744 spin_lock_bh(&dev->mt76.sta_poll_lock);
745@@ -1215,9 +1253,13 @@ mt7996_set_bitrate_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
746 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
747 struct mt7996_phy *phy = mt7996_hw_phy(hw);
748 struct mt7996_dev *dev = phy->dev;
749+ struct mt7996_bss_conf *mconf;
750 u32 changed = IEEE80211_RC_SUPP_RATES_CHANGED;
751
752- mvif->bitrate_mask = *mask;
753+ mutex_lock(&dev->mt76.mutex);
754+ mconf = mconf_dereference_protected(mvif, 0);
755+ mconf->bitrate_mask = *mask;
756+ mutex_unlock(&dev->mt76.mutex);
757
758 /* if multiple rates across different preambles are given we can
759 * reconfigure this info with all peers using sta_rec command with
760@@ -1239,14 +1281,20 @@ static void mt7996_sta_set_4addr(struct ieee80211_hw *hw,
761 bool enabled)
762 {
763 struct mt7996_dev *dev = mt7996_hw_dev(hw);
764+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
765 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
766+ struct mt7996_bss_conf *mconf;
767+
768+ mutex_lock(&dev->mt76.mutex);
769+ mconf = mconf_dereference_protected(mvif, 0);
770
771 if (enabled)
772 set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
773 else
774 clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
775
776- mt7996_mcu_wtbl_update_hdr_trans(dev, vif, sta);
777+ mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, sta);
778+ mutex_unlock(&dev->mt76.mutex);
779 }
780
781 static void mt7996_sta_set_decap_offload(struct ieee80211_hw *hw,
782@@ -1255,14 +1303,20 @@ static void mt7996_sta_set_decap_offload(struct ieee80211_hw *hw,
783 bool enabled)
784 {
785 struct mt7996_dev *dev = mt7996_hw_dev(hw);
786+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
787 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
788+ struct mt7996_bss_conf *mconf;
789+
790+ mutex_lock(&dev->mt76.mutex);
791+ mconf = mconf_dereference_protected(mvif, 0);
792
793 if (enabled)
794 set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
795 else
796 clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags);
797
798- mt7996_mcu_wtbl_update_hdr_trans(dev, vif, sta);
799+ mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, sta);
800+ mutex_unlock(&dev->mt76.mutex);
801 }
802
803 static const char mt7996_gstrings_stats[][ETH_GSTRING_LEN] = {
804@@ -1395,7 +1449,7 @@ static void mt7996_ethtool_worker(void *wi_data, struct ieee80211_sta *sta)
805 struct mt76_ethtool_worker_info *wi = wi_data;
806 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
807
808- if (msta->vif->mt76.idx != wi->idx)
809+ if (msta->vif->deflink.mt76.idx != wi->idx)
810 return;
811
812 mt76_ethtool_worker(wi, &msta->wcid.stats, true);
813@@ -1409,15 +1463,17 @@ void mt7996_get_et_stats(struct ieee80211_hw *hw,
814 struct mt7996_dev *dev = mt7996_hw_dev(hw);
815 struct mt7996_phy *phy = mt7996_hw_phy(hw);
816 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
817+ struct mt7996_bss_conf *mconf;
818 struct mt76_mib_stats *mib = &phy->mib;
819 struct mt76_ethtool_worker_info wi = {
820 .data = data,
821- .idx = mvif->mt76.idx,
822 };
823 /* See mt7996_ampdu_stat_read_phy, etc */
824 int i, ei = 0;
825
826 mutex_lock(&dev->mt76.mutex);
827+ mconf = mconf_dereference_protected(mvif, 0);
828+ wi.idx = mconf->mt76.idx,
829
830 mt7996_mac_update_stats(phy);
831
832@@ -1623,6 +1679,7 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw,
833 struct net_device_path *path)
834 {
835 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
836+ struct mt7996_bss_conf *mconf = &mvif->deflink;
837 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
838 struct mt7996_dev *dev = mt7996_hw_dev(hw);
839 struct mt7996_phy *phy = mt7996_hw_phy(hw);
840@@ -1652,7 +1709,7 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw,
841 path->type = DEV_PATH_MTK_WDMA;
842 path->dev = ctx->dev;
843 path->mtk_wdma.wdma_idx = wed->wdma_idx;
844- path->mtk_wdma.bss = mvif->mt76.idx;
845+ path->mtk_wdma.bss = mconf->mt76.idx;
846 path->mtk_wdma.queue = 0;
847 path->mtk_wdma.wcid = msta->wcid.idx;
848
849@@ -1784,6 +1841,7 @@ mt7996_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
850 struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf);
851 struct mt7996_phy *phy = ctx->phy;
852 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
853+ struct mt7996_bss_conf *mconf;
854
855 wiphy_info(hw->wiphy, "Assign VIF (addr: %pM, type: %d, link_id: %d) to channel context: %d MHz\n",
856 vif->addr, vif->type, link_conf->link_id,
857@@ -1791,7 +1849,8 @@ mt7996_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
858
859 mutex_lock(&phy->dev->mt76.mutex);
860
861- mvif->chanctx = ctx;
862+ mconf = mconf_dereference_protected(mvif, 0);
863+ mconf->chanctx = ctx;
864 ctx->nbss_assigned++;
865
866 mutex_unlock(&phy->dev->mt76.mutex);
867@@ -1807,6 +1866,7 @@ mt7996_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
868 struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf);
869 struct mt7996_phy *phy = ctx->phy;
870 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
871+ struct mt7996_bss_conf *mconf;
872
873 wiphy_info(hw->wiphy, "Remove VIF (addr: %pM, type: %d, link_id: %d) from channel context: %d MHz\n",
874 vif->addr, vif->type, link_conf->link_id,
875@@ -1818,7 +1878,8 @@ mt7996_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
876 if (test_bit(MT76_SCANNING, &phy->mt76->state))
877 mt7996_scan_complete(phy, true);
878
879- mvif->chanctx = NULL;
880+ mconf = mconf_dereference_protected(mvif, 0);
881+ mconf->chanctx = NULL;
882 ctx->nbss_assigned--;
883
884 mutex_unlock(&phy->dev->mt76.mutex);
885diff --git a/mt7996/mcu.c b/mt7996/mcu.c
886index 5319cc3..ebd3192 100644
887--- a/mt7996/mcu.c
888+++ b/mt7996/mcu.c
889@@ -117,12 +117,12 @@ mt7996_mcu_get_sta_nss(u16 mcs_map)
890 }
891
892 static void
893-mt7996_mcu_set_sta_he_mcs(struct ieee80211_sta *sta, __le16 *he_mcs,
894- u16 mcs_map)
895+mt7996_mcu_set_sta_he_mcs(struct ieee80211_sta *sta,
896+ struct mt7996_bss_conf *mconf,
897+ __le16 *he_mcs, u16 mcs_map)
898 {
899- struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
900- enum nl80211_band band = msta->vif->phy->mt76->chandef.chan->band;
901- const u16 *mask = msta->vif->bitrate_mask.control[band].he_mcs;
902+ enum nl80211_band band = mconf->phy->mt76->chandef.chan->band;
903+ const u16 *mask = mconf->bitrate_mask.control[band].he_mcs;
904 int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss;
905
906 for (nss = 0; nss < max_nss; nss++) {
907@@ -922,8 +922,7 @@ mt7996_mcu_add_uni_tlv(struct sk_buff *skb, u16 tag, u16 len)
908 }
909
910 static void
911-mt7996_mcu_bss_rfch_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
912- struct mt7996_phy *phy)
913+mt7996_mcu_bss_rfch_tlv(struct sk_buff *skb, struct mt7996_phy *phy)
914 {
915 static const u8 rlm_ch_band[] = {
916 [NL80211_BAND_2GHZ] = 1,
917@@ -953,8 +952,7 @@ mt7996_mcu_bss_rfch_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
918 }
919
920 static void
921-mt7996_mcu_bss_ra_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
922- struct mt7996_phy *phy)
923+mt7996_mcu_bss_ra_tlv(struct sk_buff *skb)
924 {
925 struct bss_ra_tlv *ra;
926 struct tlv *tlv;
927@@ -966,7 +964,7 @@ mt7996_mcu_bss_ra_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
928 }
929
930 static void
931-mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
932+mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf,
933 struct mt7996_phy *phy)
934 {
935 #define DEFAULT_HE_PE_DURATION 4
936@@ -975,16 +973,16 @@ mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
937 struct bss_info_uni_he *he;
938 struct tlv *tlv;
939
940- cap = mt76_connac_get_he_phy_cap(phy->mt76, vif);
941+ cap = mt76_connac_get_he_phy_cap(phy->mt76, conf->vif);
942
943 tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_HE_BASIC, sizeof(*he));
944
945 he = (struct bss_info_uni_he *)tlv;
946- he->he_pe_duration = vif->bss_conf.htc_trig_based_pkt_ext;
947+ he->he_pe_duration = conf->htc_trig_based_pkt_ext;
948 if (!he->he_pe_duration)
949 he->he_pe_duration = DEFAULT_HE_PE_DURATION;
950
951- he->he_rts_thres = cpu_to_le16(vif->bss_conf.frame_time_rts_th);
952+ he->he_rts_thres = cpu_to_le16(conf->frame_time_rts_th);
953 if (!he->he_rts_thres)
954 he->he_rts_thres = cpu_to_le16(DEFAULT_HE_DURATION_RTS_THRES);
955
956@@ -994,13 +992,13 @@ mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
957 }
958
959 static void
960-mt7996_mcu_bss_mbssid_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
961+mt7996_mcu_bss_mbssid_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf,
962 struct mt7996_phy *phy, int enable)
963 {
964 struct bss_info_uni_mbssid *mbssid;
965 struct tlv *tlv;
966
967- if (!vif->bss_conf.bssid_indicator && enable)
968+ if (!conf->bssid_indicator && enable)
969 return;
970
971 tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_11V_MBSSID, sizeof(*mbssid));
972@@ -1008,23 +1006,21 @@ mt7996_mcu_bss_mbssid_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
973 mbssid = (struct bss_info_uni_mbssid *)tlv;
974
975 if (enable) {
976- mbssid->max_indicator = vif->bss_conf.bssid_indicator;
977- mbssid->mbss_idx = vif->bss_conf.bssid_index;
978+ mbssid->max_indicator = conf->bssid_indicator;
979+ mbssid->mbss_idx = conf->bssid_index;
980 mbssid->tx_bss_omac_idx = 0;
981 }
982 }
983
984 static void
985-mt7996_mcu_bss_bmc_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
986+mt7996_mcu_bss_bmc_tlv(struct sk_buff *skb, struct mt7996_bss_conf *mconf,
987 struct mt7996_phy *phy)
988 {
989- struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
990 struct bss_rate_tlv *bmc;
991 struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
992 enum nl80211_band band = chandef->chan->band;
993 struct tlv *tlv;
994- u8 idx = mvif->mcast_rates_idx ?
995- mvif->mcast_rates_idx : mvif->basic_rates_idx;
996+ u8 idx = mconf->mt76.mcast_rates_idx ?: mconf->mt76.basic_rates_idx;
997
998 tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_RATE, sizeof(*bmc));
999
1000@@ -1048,9 +1044,9 @@ mt7996_mcu_bss_txcmd_tlv(struct sk_buff *skb, bool en)
1001 }
1002
1003 static void
1004-mt7996_mcu_bss_mld_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
1005+mt7996_mcu_bss_mld_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
1006+ struct mt7996_bss_conf *mconf)
1007 {
1008- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1009 struct bss_mld_tlv *mld;
1010 struct tlv *tlv;
1011
1012@@ -1058,33 +1054,30 @@ mt7996_mcu_bss_mld_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
1013
1014 mld = (struct bss_mld_tlv *)tlv;
1015 mld->group_mld_id = 0xff;
1016- mld->own_mld_id = mvif->mt76.idx;
1017+ mld->own_mld_id = mconf->mt76.idx;
1018 mld->remap_idx = 0xff;
1019 }
1020
1021 static void
1022-mt7996_mcu_bss_sec_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
1023+mt7996_mcu_bss_sec_tlv(struct sk_buff *skb, struct mt7996_bss_conf *mconf)
1024 {
1025- struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
1026 struct bss_sec_tlv *sec;
1027 struct tlv *tlv;
1028
1029 tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_SEC, sizeof(*sec));
1030
1031 sec = (struct bss_sec_tlv *)tlv;
1032- sec->cipher = mvif->cipher;
1033+ sec->cipher = mconf->mt76.cipher;
1034 }
1035
1036 static int
1037-mt7996_mcu_muar_config(struct mt7996_phy *phy, struct ieee80211_vif *vif,
1038- bool bssid, bool enable)
1039+mt7996_mcu_muar_config(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
1040+ struct mt7996_bss_conf *mconf, bool bssid, bool enable)
1041 {
1042 #define UNI_MUAR_ENTRY 2
1043 struct mt7996_dev *dev = phy->dev;
1044- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1045- u32 idx = mvif->mt76.omac_idx - REPEATER_BSSID_START;
1046- const u8 *addr = vif->addr;
1047-
1048+ u32 idx = mconf->mt76.omac_idx - REPEATER_BSSID_START;
1049+ const u8 *addr = bssid ? conf->bssid : conf->vif->addr;
1050 struct {
1051 struct {
1052 u8 band;
1053@@ -1109,9 +1102,6 @@ mt7996_mcu_muar_config(struct mt7996_phy *phy, struct ieee80211_vif *vif,
1054 .entry_add = true,
1055 };
1056
1057- if (bssid)
1058- addr = vif->bss_conf.bssid;
1059-
1060 if (enable)
1061 memcpy(req.addr, addr, ETH_ALEN);
1062
1063@@ -1120,10 +1110,8 @@ mt7996_mcu_muar_config(struct mt7996_phy *phy, struct ieee80211_vif *vif,
1064 }
1065
1066 static void
1067-mt7996_mcu_bss_ifs_timing_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
1068+mt7996_mcu_bss_ifs_timing_tlv(struct sk_buff *skb, struct mt7996_phy *phy)
1069 {
1070- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1071- struct mt7996_phy *phy = mvif->phy;
1072 struct bss_ifs_time_tlv *ifs_time;
1073 struct tlv *tlv;
1074 bool is_2ghz = phy->mt76->chandef.chan->band == NL80211_BAND_2GHZ;
1075@@ -1149,12 +1137,13 @@ mt7996_mcu_bss_ifs_timing_tlv(struct sk_buff *skb, struct ieee80211_vif *vif)
1076
1077 static int
1078 mt7996_mcu_bss_basic_tlv(struct sk_buff *skb,
1079- struct ieee80211_vif *vif,
1080+ struct ieee80211_bss_conf *conf,
1081+ struct mt7996_bss_conf *mconf,
1082 struct ieee80211_sta *sta,
1083 struct mt76_phy *phy, u16 wlan_idx,
1084 bool enable)
1085 {
1086- struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
1087+ struct ieee80211_vif *vif = conf->vif;
1088 struct cfg80211_chan_def *chandef = &phy->chandef;
1089 struct mt76_connac_bss_basic_tlv *bss;
1090 u32 type = CONNECTION_INFRA_AP;
1091@@ -1171,8 +1160,7 @@ mt7996_mcu_bss_basic_tlv(struct sk_buff *skb,
1092 if (enable) {
1093 rcu_read_lock();
1094 if (!sta)
1095- sta = ieee80211_find_sta(vif,
1096- vif->bss_conf.bssid);
1097+ sta = ieee80211_find_sta(vif, conf->bssid);
1098 /* TODO: enable BSS_INFO_UAPSD & BSS_INFO_PM */
1099 if (sta) {
1100 struct mt76_wcid *wcid;
1101@@ -1195,18 +1183,17 @@ mt7996_mcu_bss_basic_tlv(struct sk_buff *skb,
1102 tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_BASIC, sizeof(*bss));
1103
1104 bss = (struct mt76_connac_bss_basic_tlv *)tlv;
1105- bss->bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int);
1106- bss->dtim_period = vif->bss_conf.dtim_period;
1107 bss->bmc_tx_wlan_idx = cpu_to_le16(wlan_idx);
1108 bss->sta_idx = cpu_to_le16(sta_wlan_idx);
1109 bss->conn_type = cpu_to_le32(type);
1110- bss->omac_idx = mvif->omac_idx;
1111- bss->band_idx = mvif->band_idx;
1112- bss->wmm_idx = mvif->wmm_idx;
1113+ bss->omac_idx = mconf->mt76.omac_idx;
1114+ bss->band_idx = mconf->mt76.band_idx;
1115+ bss->wmm_idx = mconf->mt76.wmm_idx;
1116 bss->conn_state = !enable;
1117 bss->active = enable;
1118
1119- idx = mvif->omac_idx > EXT_BSSID_START ? HW_BSSID_0 : mvif->omac_idx;
1120+ idx = mconf->mt76.omac_idx > EXT_BSSID_START ? HW_BSSID_0 :
1121+ mconf->mt76.omac_idx;
1122 bss->hw_bss_idx = idx;
1123
1124 if (vif->type == NL80211_IFTYPE_MONITOR) {
1125@@ -1219,9 +1206,9 @@ mt7996_mcu_bss_basic_tlv(struct sk_buff *skb,
1126 return 0;
1127 }
1128
1129- memcpy(bss->bssid, vif->bss_conf.bssid, ETH_ALEN);
1130- bss->bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int);
1131- bss->dtim_period = vif->bss_conf.dtim_period;
1132+ memcpy(bss->bssid, conf->bssid, ETH_ALEN);
1133+ bss->bcn_interval = cpu_to_le16(conf->beacon_int);
1134+ bss->dtim_period = conf->dtim_period;
1135 bss->phymode = mt76_connac_get_phy_mode(phy, vif,
1136 chandef->chan->band, NULL);
1137 bss->phymode_ext = mt76_connac_get_phy_mode_ext(phy, vif,
1138@@ -1248,63 +1235,64 @@ __mt7996_mcu_alloc_bss_req(struct mt76_dev *dev, struct mt76_vif *mvif, int len)
1139 }
1140
1141 int mt7996_mcu_add_bss_info(struct mt7996_phy *phy,
1142- struct ieee80211_vif *vif, int enable)
1143+ struct ieee80211_bss_conf *conf,
1144+ struct mt7996_bss_conf *mconf, int enable)
1145 {
1146+ struct ieee80211_vif *vif = conf->vif;
1147 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1148 struct mt7996_dev *dev = phy->dev;
1149 struct sk_buff *skb;
1150
1151- if (mvif->mt76.omac_idx >= REPEATER_BSSID_START) {
1152- mt7996_mcu_muar_config(phy, vif, false, enable);
1153- mt7996_mcu_muar_config(phy, vif, true, enable);
1154+ if (mconf->mt76.omac_idx >= REPEATER_BSSID_START) {
1155+ mt7996_mcu_muar_config(phy, conf, mconf, false, enable);
1156+ mt7996_mcu_muar_config(phy, conf, mconf, true, enable);
1157 }
1158
1159- skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76,
1160+ skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76,
1161 MT7996_BSS_UPDATE_MAX_SIZE);
1162 if (IS_ERR(skb))
1163 return PTR_ERR(skb);
1164
1165 /* bss_basic must be first */
1166- mt7996_mcu_bss_basic_tlv(skb, vif, NULL, phy->mt76,
1167+ mt7996_mcu_bss_basic_tlv(skb, conf, mconf, NULL, phy->mt76,
1168 mvif->sta.wcid.idx, enable);
1169- mt7996_mcu_bss_sec_tlv(skb, vif);
1170+ mt7996_mcu_bss_sec_tlv(skb, mconf);
1171
1172 if (vif->type == NL80211_IFTYPE_MONITOR)
1173 goto out;
1174
1175 if (enable) {
1176- mt7996_mcu_bss_rfch_tlv(skb, vif, phy);
1177- mt7996_mcu_bss_bmc_tlv(skb, vif, phy);
1178- mt7996_mcu_bss_ra_tlv(skb, vif, phy);
1179+ mt7996_mcu_bss_rfch_tlv(skb, phy);
1180+ mt7996_mcu_bss_bmc_tlv(skb, mconf, phy);
1181+ mt7996_mcu_bss_ra_tlv(skb);
1182 mt7996_mcu_bss_txcmd_tlv(skb, true);
1183- mt7996_mcu_bss_ifs_timing_tlv(skb, vif);
1184+ mt7996_mcu_bss_ifs_timing_tlv(skb, phy);
1185
1186- if (vif->bss_conf.he_support)
1187- mt7996_mcu_bss_he_tlv(skb, vif, phy);
1188+ if (conf->he_support)
1189+ mt7996_mcu_bss_he_tlv(skb, conf, phy);
1190
1191 /* this tag is necessary no matter if the vif is MLD */
1192- mt7996_mcu_bss_mld_tlv(skb, vif);
1193+ mt7996_mcu_bss_mld_tlv(skb, vif, mconf);
1194 }
1195
1196- mt7996_mcu_bss_mbssid_tlv(skb, vif, phy, enable);
1197+ mt7996_mcu_bss_mbssid_tlv(skb, conf, phy, enable);
1198
1199 out:
1200 return mt76_mcu_skb_send_msg(&dev->mt76, skb,
1201 MCU_WMWA_UNI_CMD(BSS_INFO_UPDATE), true);
1202 }
1203
1204-int mt7996_mcu_set_timing(struct mt7996_phy *phy, struct ieee80211_vif *vif)
1205+int mt7996_mcu_set_timing(struct mt7996_phy *phy, struct mt7996_bss_conf *mconf)
1206 {
1207- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1208 struct mt7996_dev *dev = phy->dev;
1209 struct sk_buff *skb;
1210
1211- skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76,
1212+ skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76,
1213 MT7996_BSS_UPDATE_MAX_SIZE);
1214 if (IS_ERR(skb))
1215 return PTR_ERR(skb);
1216
1217- mt7996_mcu_bss_ifs_timing_tlv(skb, vif);
1218+ mt7996_mcu_bss_ifs_timing_tlv(skb, phy);
1219
1220 return mt76_mcu_skb_send_msg(&dev->mt76, skb,
1221 MCU_WMWA_UNI_CMD(BSS_INFO_UPDATE), true);
1222@@ -1346,12 +1334,12 @@ int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev,
1223 bool enable)
1224 {
1225 struct mt7996_sta *msta = (struct mt7996_sta *)params->sta->drv_priv;
1226- struct mt7996_vif *mvif = msta->vif;
1227+ struct mt7996_bss_conf *mconf = mconf_dereference_protected(msta->vif, 0);
1228
1229 if (enable && !params->amsdu)
1230 msta->wcid.amsdu = false;
1231
1232- return mt7996_mcu_sta_ba(dev, &mvif->mt76, params, enable, true);
1233+ return mt7996_mcu_sta_ba(dev, &mconf->mt76, params, enable, true);
1234 }
1235
1236 int mt7996_mcu_add_rx_ba(struct mt7996_dev *dev,
1237@@ -1359,13 +1347,14 @@ int mt7996_mcu_add_rx_ba(struct mt7996_dev *dev,
1238 bool enable)
1239 {
1240 struct mt7996_sta *msta = (struct mt7996_sta *)params->sta->drv_priv;
1241- struct mt7996_vif *mvif = msta->vif;
1242+ struct mt7996_bss_conf *mconf = mconf_dereference_protected(msta->vif, 0);
1243
1244- return mt7996_mcu_sta_ba(dev, &mvif->mt76, params, enable, false);
1245+ return mt7996_mcu_sta_ba(dev, &mconf->mt76, params, enable, false);
1246 }
1247
1248 static void
1249-mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
1250+mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf,
1251+ struct mt7996_bss_conf *mconf,
1252 struct ieee80211_sta *sta)
1253 {
1254 struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem;
1255@@ -1386,9 +1375,9 @@ mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
1256 he->he_phy_cap[i] = elem->phy_cap_info[i];
1257 }
1258
1259- if (vif->type == NL80211_IFTYPE_AP &&
1260+ if (conf->vif->type == NL80211_IFTYPE_AP &&
1261 (elem->phy_cap_info[1] & IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD))
1262- u8p_replace_bits(&he->he_phy_cap[1], vif->bss_conf.he_ldpc,
1263+ u8p_replace_bits(&he->he_phy_cap[1], conf->he_ldpc,
1264 IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD);
1265
1266 mcs_map = sta->deflink.he_cap.he_mcs_nss_supp;
1267@@ -1396,16 +1385,16 @@ mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
1268 case IEEE80211_STA_RX_BW_160:
1269 if (elem->phy_cap_info[0] &
1270 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G)
1271- mt7996_mcu_set_sta_he_mcs(sta,
1272+ mt7996_mcu_set_sta_he_mcs(sta, mconf,
1273 &he->max_nss_mcs[CMD_HE_MCS_BW8080],
1274 le16_to_cpu(mcs_map.rx_mcs_80p80));
1275
1276- mt7996_mcu_set_sta_he_mcs(sta,
1277+ mt7996_mcu_set_sta_he_mcs(sta, mconf,
1278 &he->max_nss_mcs[CMD_HE_MCS_BW160],
1279 le16_to_cpu(mcs_map.rx_mcs_160));
1280 fallthrough;
1281 default:
1282- mt7996_mcu_set_sta_he_mcs(sta,
1283+ mt7996_mcu_set_sta_he_mcs(sta, mconf,
1284 &he->max_nss_mcs[CMD_HE_MCS_BW80],
1285 le16_to_cpu(mcs_map.rx_mcs_80));
1286 break;
1287@@ -1496,7 +1485,7 @@ mt7996_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
1288 struct tlv *tlv;
1289 #ifdef CONFIG_MTK_VENDOR
1290 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
1291- struct mt7996_phy *phy = (struct mt7996_phy *)msta->vif->phy;
1292+ struct mt7996_phy *phy = (struct mt7996_phy *)msta->vif->deflink.phy;
1293 #endif
1294
1295 /* For 6G band, this tlv is necessary to let hw work normally */
1296@@ -1553,25 +1542,26 @@ mt7996_mcu_sta_amsdu_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1297
1298 static void
1299 mt7996_mcu_sta_muru_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1300- struct ieee80211_vif *vif, struct ieee80211_sta *sta)
1301+ struct ieee80211_bss_conf *conf,
1302+ struct mt7996_bss_conf *mconf,
1303+ struct ieee80211_sta *sta)
1304 {
1305- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1306- struct mt7996_phy *phy = mvif->phy;
1307+ struct mt7996_phy *phy = mconf->phy;
1308 struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem;
1309 struct sta_rec_muru *muru;
1310 struct tlv *tlv;
1311
1312- if (vif->type != NL80211_IFTYPE_STATION &&
1313- vif->type != NL80211_IFTYPE_AP)
1314+ if (conf->vif->type != NL80211_IFTYPE_STATION &&
1315+ conf->vif->type != NL80211_IFTYPE_AP)
1316 return;
1317
1318 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_MURU, sizeof(*muru));
1319
1320 muru = (struct sta_rec_muru *)tlv;
1321- muru->cfg.mimo_dl_en = (vif->bss_conf.eht_mu_beamformer ||
1322- vif->bss_conf.he_mu_beamformer ||
1323- vif->bss_conf.vht_mu_beamformer ||
1324- vif->bss_conf.vht_mu_beamformee) &&
1325+ muru->cfg.mimo_dl_en = (conf->eht_mu_beamformer ||
1326+ conf->he_mu_beamformer ||
1327+ conf->vht_mu_beamformer ||
1328+ conf->vht_mu_beamformee) &&
1329 !!(phy->muru_onoff & MUMIMO_DL);
1330 muru->cfg.mimo_ul_en = !!(phy->muru_onoff & MUMIMO_UL);
1331 muru->cfg.ofdma_dl_en = !!(phy->muru_onoff & OFDMA_DL);
1332@@ -1612,13 +1602,14 @@ mt7996_mcu_sta_muru_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1333 }
1334
1335 static inline bool
1336-mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_vif *vif,
1337+mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
1338+ struct mt7996_bss_conf *mconf,
1339 struct ieee80211_sta *sta, bool bfee)
1340 {
1341 int sts = hweight16(phy->mt76->chainmask);
1342
1343- if (vif->type != NL80211_IFTYPE_STATION &&
1344- vif->type != NL80211_IFTYPE_AP)
1345+ if (conf->vif->type != NL80211_IFTYPE_STATION &&
1346+ conf->vif->type != NL80211_IFTYPE_AP)
1347 return false;
1348
1349 if (!bfee && sts < 2)
1350@@ -1629,10 +1620,10 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_vif *vif,
1351 struct ieee80211_eht_cap_elem_fixed *pe = &pc->eht_cap_elem;
1352
1353 if (bfee)
1354- return vif->bss_conf.eht_su_beamformee &&
1355+ return conf->eht_su_beamformee &&
1356 EHT_PHY(CAP0_SU_BEAMFORMEE, pe->phy_cap_info[0]);
1357 else
1358- return vif->bss_conf.eht_su_beamformer &&
1359+ return conf->eht_su_beamformer &&
1360 EHT_PHY(CAP0_SU_BEAMFORMER, pe->phy_cap_info[0]);
1361 }
1362
1363@@ -1640,10 +1631,10 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_vif *vif,
1364 struct ieee80211_he_cap_elem *pe = &sta->deflink.he_cap.he_cap_elem;
1365
1366 if (bfee)
1367- return vif->bss_conf.he_su_beamformee &&
1368+ return conf->he_su_beamformee &&
1369 HE_PHY(CAP3_SU_BEAMFORMER, pe->phy_cap_info[3]);
1370 else
1371- return vif->bss_conf.he_su_beamformer &&
1372+ return conf->he_su_beamformer &&
1373 HE_PHY(CAP4_SU_BEAMFORMEE, pe->phy_cap_info[4]);
1374 }
1375
1376@@ -1651,10 +1642,10 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_vif *vif,
1377 u32 cap = sta->deflink.vht_cap.cap;
1378
1379 if (bfee)
1380- return vif->bss_conf.vht_su_beamformee &&
1381+ return conf->vht_su_beamformee &&
1382 (cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE);
1383 else
1384- return vif->bss_conf.vht_su_beamformer &&
1385+ return conf->vht_su_beamformer &&
1386 (cap & IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE);
1387 }
1388
1389@@ -1850,10 +1841,10 @@ mt7996_mcu_sta_bfer_eht(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
1390
1391 static void
1392 mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1393- struct ieee80211_vif *vif, struct ieee80211_sta *sta)
1394+ struct ieee80211_bss_conf *conf, struct mt7996_bss_conf *mconf,
1395+ struct ieee80211_sta *sta)
1396 {
1397- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1398- struct mt7996_phy *phy = mvif->phy;
1399+ struct mt7996_phy *phy = mconf->phy;
1400 int tx_ant = hweight16(phy->mt76->chainmask) - 1;
1401 struct sta_rec_bf *bf;
1402 struct tlv *tlv;
1403@@ -1868,7 +1859,7 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1404 if (!(sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he))
1405 return;
1406
1407- ebf = mt7996_is_ebf_supported(phy, vif, sta, false);
1408+ ebf = mt7996_is_ebf_supported(phy, conf, mconf, sta, false);
1409 if (!ebf && !dev->ibf)
1410 return;
1411
1412@@ -1880,9 +1871,9 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1413 * ht: iBF only, since mac80211 lacks of eBF support
1414 */
1415 if (sta->deflink.eht_cap.has_eht && ebf)
1416- mt7996_mcu_sta_bfer_eht(sta, vif, phy, bf);
1417+ mt7996_mcu_sta_bfer_eht(sta, conf->vif, phy, bf);
1418 else if (sta->deflink.he_cap.has_he && ebf)
1419- mt7996_mcu_sta_bfer_he(sta, vif, phy, bf);
1420+ mt7996_mcu_sta_bfer_he(sta, conf->vif, phy, bf);
1421 else if (sta->deflink.vht_cap.vht_supported)
1422 mt7996_mcu_sta_bfer_vht(sta, phy, bf, ebf);
1423 else if (sta->deflink.ht_cap.ht_supported)
1424@@ -1921,10 +1912,10 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1425
1426 static void
1427 mt7996_mcu_sta_bfee_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1428- struct ieee80211_vif *vif, struct ieee80211_sta *sta)
1429+ struct ieee80211_bss_conf *conf,
1430+ struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta)
1431 {
1432- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1433- struct mt7996_phy *phy = mvif->phy;
1434+ struct mt7996_phy *phy = mconf->phy;
1435 int tx_ant = hweight8(phy->mt76->antenna_mask) - 1;
1436 struct sta_rec_bfee *bfee;
1437 struct tlv *tlv;
1438@@ -1933,7 +1924,7 @@ mt7996_mcu_sta_bfee_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
1439 if (!(sta->deflink.vht_cap.vht_supported || sta->deflink.he_cap.has_he))
1440 return;
1441
1442- if (!mt7996_is_ebf_supported(phy, vif, sta, true))
1443+ if (!mt7996_is_ebf_supported(phy, conf, mconf, sta, true))
1444 return;
1445
1446 tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_BFEE, sizeof(*bfee));
1447@@ -2055,17 +2046,17 @@ int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev,
1448 MCU_WM_UNI_CMD(RA), true);
1449 }
1450
1451-int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1452+int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev,
1453+ struct mt7996_bss_conf *mconf,
1454 struct ieee80211_sta *sta, void *data, u32 field)
1455 {
1456- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1457 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
1458 struct sta_phy_uni *phy = data;
1459 struct sta_rec_ra_fixed_uni *ra;
1460 struct sk_buff *skb;
1461 struct tlv *tlv;
1462
1463- skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
1464+ skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76,
1465 &msta->wcid,
1466 MT7996_STA_UPDATE_MAX_SIZE);
1467 if (IS_ERR(skb))
1468@@ -2097,12 +2088,13 @@ int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev, struct ieee80211_vif *vif
1469 }
1470
1471 static int
1472-mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1473+mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev,
1474+ struct ieee80211_bss_conf *conf,
1475+ struct mt7996_bss_conf *mconf,
1476 struct ieee80211_sta *sta)
1477 {
1478- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1479- struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef;
1480- struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask;
1481+ struct cfg80211_chan_def *chandef = &mconf->phy->mt76->chandef;
1482+ struct cfg80211_bitrate_mask *mask = &mconf->bitrate_mask;
1483 enum nl80211_band band = chandef->chan->band;
1484 struct sta_phy_uni phy = {};
1485 int ret, nrates = 0;
1486@@ -2144,7 +2136,7 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, struct ieee80211_vif *vif
1487
1488 /* fixed single rate */
1489 if (nrates == 1) {
1490- ret = mt7996_mcu_set_fixed_field(dev, vif, sta, &phy,
1491+ ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy,
1492 RATE_PARAM_FIXED_MCS);
1493 if (ret)
1494 return ret;
1495@@ -2166,7 +2158,7 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, struct ieee80211_vif *vif
1496 else
1497 mt76_rmw_field(dev, addr, GENMASK(15, 12), phy.sgi);
1498
1499- ret = mt7996_mcu_set_fixed_field(dev, vif, sta, &phy,
1500+ ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy,
1501 RATE_PARAM_FIXED_GI);
1502 if (ret)
1503 return ret;
1504@@ -2174,7 +2166,7 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, struct ieee80211_vif *vif
1505
1506 /* fixed HE_LTF */
1507 if (mask->control[band].he_ltf != GENMASK(7, 0)) {
1508- ret = mt7996_mcu_set_fixed_field(dev, vif, sta, &phy,
1509+ ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy,
1510 RATE_PARAM_FIXED_HE_LTF);
1511 if (ret)
1512 return ret;
1513@@ -2185,13 +2177,14 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, struct ieee80211_vif *vif
1514
1515 static void
1516 mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev,
1517- struct ieee80211_vif *vif, struct ieee80211_sta *sta)
1518+ struct ieee80211_bss_conf *conf,
1519+ struct mt7996_bss_conf *mconf,
1520+ struct ieee80211_sta *sta)
1521 {
1522 #define INIT_RCPI 180
1523- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1524- struct mt76_phy *mphy = mvif->phy->mt76;
1525+ struct mt76_phy *mphy = mconf->phy->mt76;
1526 struct cfg80211_chan_def *chandef = &mphy->chandef;
1527- struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask;
1528+ struct cfg80211_bitrate_mask *mask = &mconf->bitrate_mask;
1529 enum nl80211_band band = chandef->chan->band;
1530 struct sta_rec_ra_uni *ra;
1531 struct tlv *tlv;
1532@@ -2203,7 +2196,7 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev,
1533
1534 ra->valid = true;
1535 ra->auto_rate = true;
1536- ra->phy_mode = mt76_connac_get_phy_mode(mphy, vif, band, sta);
1537+ ra->phy_mode = mt76_connac_get_phy_mode(mphy, conf->vif, band, sta);
1538 ra->channel = chandef->chan->hw_value;
1539 ra->bw = (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_320) ?
1540 CMD_CBW_320MHZ : sta->deflink.bandwidth;
1541@@ -2242,7 +2235,7 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev,
1542 cap |= STA_CAP_TX_STBC;
1543 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_RX_STBC)
1544 cap |= STA_CAP_RX_STBC;
1545- if (vif->bss_conf.ht_ldpc &&
1546+ if (conf->ht_ldpc &&
1547 (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING))
1548 cap |= STA_CAP_LDPC;
1549
1550@@ -2268,7 +2261,7 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev,
1551 cap |= STA_CAP_VHT_TX_STBC;
1552 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXSTBC_1)
1553 cap |= STA_CAP_VHT_RX_STBC;
1554- if (vif->bss_conf.vht_ldpc &&
1555+ if (conf->vht_ldpc &&
1556 (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC))
1557 cap |= STA_CAP_VHT_LDPC;
1558
1559@@ -2289,15 +2282,16 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev,
1560 memset(ra->rx_rcpi, INIT_RCPI, sizeof(ra->rx_rcpi));
1561 }
1562
1563-int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1564+int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev,
1565+ struct ieee80211_bss_conf *conf,
1566+ struct mt7996_bss_conf *mconf,
1567 struct ieee80211_sta *sta, bool changed)
1568 {
1569- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1570 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
1571 struct sk_buff *skb;
1572 int ret;
1573
1574- skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
1575+ skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76,
1576 &msta->wcid,
1577 MT7996_STA_UPDATE_MAX_SIZE);
1578 if (IS_ERR(skb))
1579@@ -2308,26 +2302,27 @@ int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1580 * update sta_rec_he here.
1581 */
1582 if (changed)
1583- mt7996_mcu_sta_he_tlv(skb, vif, sta);
1584+ mt7996_mcu_sta_he_tlv(skb, conf, mconf, sta);
1585
1586 /* sta_rec_ra accommodates BW, NSS and only MCS range format
1587 * i.e 0-{7,8,9} for VHT.
1588 */
1589- mt7996_mcu_sta_rate_ctrl_tlv(skb, dev, vif, sta);
1590+ mt7996_mcu_sta_rate_ctrl_tlv(skb, dev, conf, mconf, sta);
1591
1592 ret = mt76_mcu_skb_send_msg(&dev->mt76, skb,
1593 MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true);
1594 if (ret)
1595 return ret;
1596
1597- return mt7996_mcu_add_rate_ctrl_fixed(dev, vif, sta);
1598+ return mt7996_mcu_add_rate_ctrl_fixed(dev, conf, mconf, sta);
1599 }
1600
1601 static int
1602-mt7996_mcu_sta_init_vow(struct mt7996_phy *phy, struct mt7996_sta *msta)
1603+mt7996_mcu_sta_init_vow(struct mt7996_bss_conf *mconf, struct mt7996_sta *msta)
1604 {
1605+ struct mt7996_phy *phy = mconf->phy;
1606 struct mt7996_vow_sta_ctrl *vow = &msta->vow;
1607- u8 omac_idx = msta->vif->mt76.omac_idx;
1608+ u8 omac_idx = mconf->mt76.omac_idx;
1609 int ret;
1610
1611 /* Assignment of STA BSS group index aligns FW.
1612@@ -2344,20 +2339,22 @@ mt7996_mcu_sta_init_vow(struct mt7996_phy *phy, struct mt7996_sta *msta)
1613 vow->drr_quantum[IEEE80211_AC_BE] = VOW_DRR_QUANTUM_IDX2;
1614 vow->drr_quantum[IEEE80211_AC_BK] = VOW_DRR_QUANTUM_IDX2;
1615
1616- ret = mt7996_mcu_set_vow_drr_ctrl(phy, msta, VOW_DRR_CTRL_STA_BSS_GROUP);
1617+ ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_BSS_GROUP);
1618 if (ret)
1619 return ret;
1620
1621- ret = mt7996_mcu_set_vow_drr_ctrl(phy, msta, VOW_DRR_CTRL_STA_PAUSE);
1622+ ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_PAUSE);
1623 if (ret)
1624 return ret;
1625
1626- return mt7996_mcu_set_vow_drr_ctrl(phy, msta, VOW_DRR_CTRL_STA_ALL);
1627+ return mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_ALL);
1628 }
1629
1630-int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1631- struct ieee80211_sta *sta, bool enable, bool newly)
1632+int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
1633+ struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta,
1634+ bool enable, bool newly)
1635 {
1636+ struct ieee80211_vif *vif = conf->vif;
1637 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1638 struct mt7996_sta *msta;
1639 struct sk_buff *skb;
1640@@ -2365,7 +2362,7 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1641
1642 msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->sta;
1643
1644- skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
1645+ skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76,
1646 &msta->wcid,
1647 MT7996_STA_UPDATE_MAX_SIZE);
1648 if (IS_ERR(skb))
1649@@ -2387,7 +2384,7 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1650 /* starec hdrt mode */
1651 mt7996_mcu_sta_hdrt_tlv(dev, skb);
1652 /* starec bfer */
1653- mt7996_mcu_sta_bfer_tlv(dev, skb, vif, sta);
1654+ mt7996_mcu_sta_bfer_tlv(dev, skb, conf, mconf, sta);
1655 /* starec ht */
1656 mt7996_mcu_sta_ht_tlv(skb, sta);
1657 /* starec vht */
1658@@ -2397,18 +2394,18 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1659 /* starec amsdu */
1660 mt7996_mcu_sta_amsdu_tlv(dev, skb, vif, sta);
1661 /* starec he */
1662- mt7996_mcu_sta_he_tlv(skb, vif, sta);
1663+ mt7996_mcu_sta_he_tlv(skb, conf, mconf, sta);
1664 /* starec he 6g*/
1665 mt7996_mcu_sta_he_6g_tlv(skb, sta);
1666 /* starec eht */
1667 mt7996_mcu_sta_eht_tlv(skb, sta);
1668 /* starec muru */
1669- mt7996_mcu_sta_muru_tlv(dev, skb, vif, sta);
1670+ mt7996_mcu_sta_muru_tlv(dev, skb, conf, mconf, sta);
1671 /* starec bfee */
1672- mt7996_mcu_sta_bfee_tlv(dev, skb, vif, sta);
1673+ mt7996_mcu_sta_bfee_tlv(dev, skb, conf, mconf, sta);
1674 }
1675
1676- ret = mt7996_mcu_sta_init_vow(mvif->phy, msta);
1677+ ret = mt7996_mcu_sta_init_vow(mconf, msta);
1678 if (ret) {
1679 dev_kfree_skb(skb);
1680 return ret;
1681@@ -2463,16 +2460,15 @@ mt7996_mcu_sta_key_tlv(struct mt76_wcid *wcid,
1682 return 0;
1683 }
1684
1685-int mt7996_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif,
1686+int mt7996_mcu_add_key(struct mt76_dev *dev, struct mt7996_bss_conf *mconf,
1687 struct ieee80211_key_conf *key, int mcu_cmd,
1688 struct mt76_wcid *wcid, enum set_key_cmd cmd)
1689 {
1690- struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
1691 struct sk_buff *skb;
1692 int ret;
1693
1694- skb = __mt76_connac_mcu_alloc_sta_req(dev, mvif, wcid,
1695- MT7996_STA_UPDATE_MAX_SIZE);
1696+ skb = __mt76_connac_mcu_alloc_sta_req(dev, (struct mt76_vif *)mconf,
1697+ wcid, MT7996_STA_UPDATE_MAX_SIZE);
1698 if (IS_ERR(skb))
1699 return PTR_ERR(skb);
1700
1701@@ -2483,17 +2479,18 @@ int mt7996_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif,
1702 return mt76_mcu_skb_send_msg(dev, skb, mcu_cmd, true);
1703 }
1704
1705-static int mt7996_mcu_get_pn(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1706- u8 *pn)
1707+static int mt7996_mcu_get_pn(struct mt7996_dev *dev,
1708+ struct ieee80211_bss_conf *conf,
1709+ struct mt7996_bss_conf *mconf, u8 *pn)
1710 {
1711 #define TSC_TYPE_BIGTK_PN 2
1712- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1713+ struct mt7996_vif *mvif = (struct mt7996_vif *)conf->vif->drv_priv;
1714 struct sta_rec_pn_info *pn_info;
1715 struct sk_buff *skb, *rskb;
1716 struct tlv *tlv;
1717 int ret;
1718
1719- skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, &mvif->sta.wcid);
1720+ skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, &mvif->sta.wcid);
1721 if (IS_ERR(skb))
1722 return PTR_ERR(skb);
1723
1724@@ -2517,10 +2514,11 @@ static int mt7996_mcu_get_pn(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1725 return 0;
1726 }
1727
1728-int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1729+int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev,
1730+ struct ieee80211_bss_conf *conf,
1731+ struct mt7996_bss_conf *mconf,
1732 struct ieee80211_key_conf *key)
1733 {
1734- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1735 struct mt7996_mcu_bcn_prot_tlv *bcn_prot;
1736 struct sk_buff *skb;
1737 struct tlv *tlv;
1738@@ -2529,7 +2527,7 @@ int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, struct ieee80211_vif *vif
1739 sizeof(struct mt7996_mcu_bcn_prot_tlv);
1740 int ret;
1741
1742- skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, len);
1743+ skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76, len);
1744 if (IS_ERR(skb))
1745 return PTR_ERR(skb);
1746
1747@@ -2537,7 +2535,7 @@ int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, struct ieee80211_vif *vif
1748
1749 bcn_prot = (struct mt7996_mcu_bcn_prot_tlv *)tlv;
1750
1751- ret = mt7996_mcu_get_pn(dev, vif, pn);
1752+ ret = mt7996_mcu_get_pn(dev, conf, mconf, pn);
1753 if (ret) {
1754 dev_kfree_skb(skb);
1755 return ret;
1756@@ -2570,10 +2568,10 @@ int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, struct ieee80211_vif *vif
1757 MCU_WMWA_UNI_CMD(BSS_INFO_UPDATE), true);
1758 }
1759 int mt7996_mcu_add_dev_info(struct mt7996_phy *phy,
1760- struct ieee80211_vif *vif, bool enable)
1761+ struct ieee80211_bss_conf *conf,
1762+ struct mt7996_bss_conf *mconf, bool enable)
1763 {
1764 struct mt7996_dev *dev = phy->dev;
1765- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1766 struct {
1767 struct req_hdr {
1768 u8 omac_idx;
1769@@ -2589,8 +2587,8 @@ int mt7996_mcu_add_dev_info(struct mt7996_phy *phy,
1770 } __packed tlv;
1771 } data = {
1772 .hdr = {
1773- .omac_idx = mvif->mt76.omac_idx,
1774- .band_idx = mvif->mt76.band_idx,
1775+ .omac_idx = mconf->mt76.omac_idx,
1776+ .band_idx = mconf->mt76.band_idx,
1777 },
1778 .tlv = {
1779 .tag = cpu_to_le16(DEV_INFO_ACTIVE),
1780@@ -2599,16 +2597,16 @@ int mt7996_mcu_add_dev_info(struct mt7996_phy *phy,
1781 },
1782 };
1783
1784- if (mvif->mt76.omac_idx >= REPEATER_BSSID_START)
1785- return mt7996_mcu_muar_config(phy, vif, false, enable);
1786+ if (mconf->mt76.omac_idx >= REPEATER_BSSID_START)
1787+ return mt7996_mcu_muar_config(phy, conf, mconf, false, enable);
1788
1789- memcpy(data.tlv.omac_addr, vif->addr, ETH_ALEN);
1790+ memcpy(data.tlv.omac_addr, conf->addr, ETH_ALEN);
1791 return mt76_mcu_send_msg(&dev->mt76, MCU_WMWA_UNI_CMD(DEV_INFO_UPDATE),
1792 &data, sizeof(data), true);
1793 }
1794
1795 static void
1796-mt7996_mcu_beacon_cntdwn(struct ieee80211_vif *vif, struct sk_buff *rskb,
1797+mt7996_mcu_beacon_cntdwn(struct ieee80211_bss_conf *conf, struct sk_buff *rskb,
1798 struct sk_buff *skb,
1799 struct ieee80211_mutable_offsets *offs)
1800 {
1801@@ -2619,7 +2617,7 @@ mt7996_mcu_beacon_cntdwn(struct ieee80211_vif *vif, struct sk_buff *rskb,
1802 if (!offs->cntdwn_counter_offs[0])
1803 return;
1804
1805- tag = vif->bss_conf.csa_active ? UNI_BSS_INFO_BCN_CSA : UNI_BSS_INFO_BCN_BCC;
1806+ tag = conf->csa_active ? UNI_BSS_INFO_BCN_CSA : UNI_BSS_INFO_BCN_BCC;
1807
1808 tlv = mt7996_mcu_add_uni_tlv(rskb, tag, sizeof(*info));
1809
1810@@ -2629,14 +2627,15 @@ mt7996_mcu_beacon_cntdwn(struct ieee80211_vif *vif, struct sk_buff *rskb,
1811
1812 static void
1813 mt7996_mcu_beacon_mbss(struct sk_buff *rskb, struct sk_buff *skb,
1814- struct ieee80211_vif *vif, struct bss_bcn_content_tlv *bcn,
1815+ struct ieee80211_bss_conf *conf,
1816+ struct bss_bcn_content_tlv *bcn,
1817 struct ieee80211_mutable_offsets *offs)
1818 {
1819 struct bss_bcn_mbss_tlv *mbss;
1820 const struct element *elem;
1821 struct tlv *tlv;
1822
1823- if (!vif->bss_conf.bssid_indicator)
1824+ if (!conf->bssid_indicator)
1825 return;
1826
1827 tlv = mt7996_mcu_add_uni_tlv(rskb, UNI_BSS_INFO_BCN_MBSSID, sizeof(*mbss));
1828@@ -2681,7 +2680,7 @@ mt7996_mcu_beacon_mbss(struct sk_buff *rskb, struct sk_buff *skb,
1829 }
1830
1831 static void
1832-mt7996_mcu_beacon_cont(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1833+mt7996_mcu_beacon_cont(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
1834 struct sk_buff *rskb, struct sk_buff *skb,
1835 struct bss_bcn_content_tlv *bcn,
1836 struct ieee80211_mutable_offsets *offs)
1837@@ -2695,9 +2694,9 @@ mt7996_mcu_beacon_cont(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1838 if (offs->cntdwn_counter_offs[0]) {
1839 u16 offset = offs->cntdwn_counter_offs[0];
1840
1841- if (vif->bss_conf.csa_active)
1842+ if (conf->csa_active)
1843 bcn->csa_ie_pos = cpu_to_le16(offset - 4);
1844- if (vif->bss_conf.color_change_active)
1845+ if (conf->color_change_active)
1846 bcn->bcc_ie_pos = cpu_to_le16(offset - 3);
1847 }
1848
1849@@ -2709,11 +2708,11 @@ mt7996_mcu_beacon_cont(struct mt7996_dev *dev, struct ieee80211_vif *vif,
1850 }
1851
1852 int mt7996_mcu_add_beacon(struct ieee80211_hw *hw,
1853- struct ieee80211_vif *vif, int en)
1854+ struct ieee80211_bss_conf *conf,
1855+ struct mt7996_bss_conf *mconf, int en)
1856 {
1857 struct mt7996_dev *dev = mt7996_hw_dev(hw);
1858 struct mt7996_phy *phy = mt7996_hw_phy(hw);
1859- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1860 struct ieee80211_mutable_offsets offs;
1861 struct ieee80211_tx_info *info;
1862 struct sk_buff *skb, *rskb;
1863@@ -2721,15 +2720,15 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw,
1864 struct bss_bcn_content_tlv *bcn;
1865 int len;
1866
1867- if (vif->bss_conf.nontransmitted)
1868+ if (conf->nontransmitted)
1869 return 0;
1870
1871- rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76,
1872+ rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76,
1873 MT7996_MAX_BSS_OFFLOAD_SIZE);
1874 if (IS_ERR(rskb))
1875 return PTR_ERR(rskb);
1876
1877- skb = ieee80211_beacon_get_template(hw, vif, &offs, 0);
1878+ skb = ieee80211_beacon_get_template(hw, conf->vif, &offs, 0);
1879 if (!skb) {
1880 dev_kfree_skb(rskb);
1881 return -EINVAL;
1882@@ -2752,9 +2751,9 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw,
1883 if (!en)
1884 goto out;
1885
1886- mt7996_mcu_beacon_cont(dev, vif, rskb, skb, bcn, &offs);
1887- mt7996_mcu_beacon_mbss(rskb, skb, vif, bcn, &offs);
1888- mt7996_mcu_beacon_cntdwn(vif, rskb, skb, &offs);
1889+ mt7996_mcu_beacon_cont(dev, conf, rskb, skb, bcn, &offs);
1890+ mt7996_mcu_beacon_mbss(rskb, skb, conf, bcn, &offs);
1891+ mt7996_mcu_beacon_cntdwn(conf, rskb, skb, &offs);
1892 out:
1893 dev_kfree_skb(skb);
1894 return mt76_mcu_skb_send_msg(&phy->dev->mt76, rskb,
1895@@ -2762,14 +2761,15 @@ out:
1896 }
1897
1898 int mt7996_mcu_beacon_inband_discov(struct mt7996_dev *dev,
1899- struct ieee80211_vif *vif, u32 changed)
1900+ struct ieee80211_bss_conf *conf,
1901+ struct mt7996_bss_conf *mconf, u32 changed)
1902 {
1903 #define OFFLOAD_TX_MODE_SU BIT(0)
1904 #define OFFLOAD_TX_MODE_MU BIT(1)
1905 struct ieee80211_hw *hw = mt76_hw(dev);
1906+ struct ieee80211_vif *vif = conf->vif;
1907 struct mt7996_phy *phy = mt7996_hw_phy(hw);
1908- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1909- struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef;
1910+ struct cfg80211_chan_def *chandef = &mconf->phy->mt76->chandef;
1911 enum nl80211_band band = chandef->chan->band;
1912 struct mt76_wcid *wcid = &dev->mt76.global_wcid;
1913 struct bss_inband_discovery_tlv *discov;
1914@@ -2779,20 +2779,20 @@ int mt7996_mcu_beacon_inband_discov(struct mt7996_dev *dev,
1915 u8 *buf, interval;
1916 int len;
1917
1918- if (vif->bss_conf.nontransmitted)
1919+ if (conf->nontransmitted)
1920 return 0;
1921
1922- rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76,
1923+ rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76,
1924 MT7996_MAX_BSS_OFFLOAD_SIZE);
1925 if (IS_ERR(rskb))
1926 return PTR_ERR(rskb);
1927
1928 if (changed & BSS_CHANGED_FILS_DISCOVERY) {
1929- interval = vif->bss_conf.fils_discovery.max_interval;
1930+ interval = conf->fils_discovery.max_interval;
1931 skb = ieee80211_get_fils_discovery_tmpl(hw, vif);
1932 } else if (changed & BSS_CHANGED_UNSOL_BCAST_PROBE_RESP &&
1933- vif->bss_conf.unsol_bcast_probe_resp_interval) {
1934- interval = vif->bss_conf.unsol_bcast_probe_resp_interval;
1935+ conf->unsol_bcast_probe_resp_interval) {
1936+ interval = conf->unsol_bcast_probe_resp_interval;
1937 skb = ieee80211_get_unsol_bcast_probe_resp_tmpl(hw, vif);
1938 }
1939
1940@@ -3456,7 +3456,7 @@ int mt7996_mcu_set_hdr_trans(struct mt7996_dev *dev, bool hdr_trans)
1941 MCU_WM_UNI_CMD(RX_HDR_TRANS), true);
1942 }
1943
1944-int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct ieee80211_vif *vif)
1945+int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct mt7996_bss_conf *mconf)
1946 {
1947 #define MCU_EDCA_AC_PARAM 0
1948 #define WMM_AIFS_SET BIT(0)
1949@@ -3465,12 +3465,11 @@ int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct ieee80211_vif *vif)
1950 #define WMM_TXOP_SET BIT(3)
1951 #define WMM_PARAM_SET (WMM_AIFS_SET | WMM_CW_MIN_SET | \
1952 WMM_CW_MAX_SET | WMM_TXOP_SET)
1953- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1954 struct {
1955 u8 bss_idx;
1956 u8 __rsv[3];
1957 } __packed hdr = {
1958- .bss_idx = mvif->mt76.idx,
1959+ .bss_idx = mconf->mt76.idx,
1960 };
1961 struct sk_buff *skb;
1962 int len = sizeof(hdr) + IEEE80211_NUM_ACS * sizeof(struct edca);
1963@@ -3483,7 +3482,7 @@ int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct ieee80211_vif *vif)
1964 skb_put_data(skb, &hdr, sizeof(hdr));
1965
1966 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
1967- struct ieee80211_tx_queue_params *q = &mvif->queue_params[ac];
1968+ struct ieee80211_tx_queue_params *q = &mconf->queue_params[ac];
1969 struct edca *e;
1970 struct tlv *tlv;
1971
1972@@ -4496,12 +4495,12 @@ mt7996_mcu_set_obss_spr_pd(struct mt7996_phy *phy,
1973 }
1974
1975 static int
1976-mt7996_mcu_set_obss_spr_siga(struct mt7996_phy *phy, struct ieee80211_vif *vif,
1977+mt7996_mcu_set_obss_spr_siga(struct mt7996_phy *phy,
1978+ struct mt7996_bss_conf *mconf,
1979 struct ieee80211_he_obss_pd *he_obss_pd)
1980 {
1981- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
1982 struct mt7996_dev *dev = phy->dev;
1983- u8 omac = mvif->mt76.omac_idx;
1984+ u8 omac = mconf->mt76.omac_idx;
1985 struct {
1986 u8 band_idx;
1987 u8 __rsv[3];
1988@@ -4573,7 +4572,8 @@ mt7996_mcu_set_obss_spr_bitmap(struct mt7996_phy *phy,
1989 sizeof(req), true);
1990 }
1991
1992-int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy, struct ieee80211_vif *vif,
1993+int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy,
1994+ struct mt7996_bss_conf *mconf,
1995 struct ieee80211_he_obss_pd *he_obss_pd)
1996 {
1997 int ret;
1998@@ -4607,7 +4607,7 @@ int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy, struct ieee80211_vif *vif,
1999 return ret;
2000
2001 /* Set SR prohibit */
2002- ret = mt7996_mcu_set_obss_spr_siga(phy, vif, he_obss_pd);
2003+ ret = mt7996_mcu_set_obss_spr_siga(phy, mconf, he_obss_pd);
2004 if (ret)
2005 return ret;
2006
2007@@ -4615,16 +4615,16 @@ int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy, struct ieee80211_vif *vif,
2008 return mt7996_mcu_set_obss_spr_bitmap(phy, he_obss_pd);
2009 }
2010
2011-int mt7996_mcu_update_bss_color(struct mt7996_dev *dev, struct ieee80211_vif *vif,
2012+int mt7996_mcu_update_bss_color(struct mt7996_dev *dev,
2013+ struct mt7996_bss_conf *mconf,
2014 struct cfg80211_he_bss_color *he_bss_color)
2015 {
2016 int len = sizeof(struct bss_req_hdr) + sizeof(struct bss_color_tlv);
2017- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
2018 struct bss_color_tlv *bss_color;
2019 struct sk_buff *skb;
2020 struct tlv *tlv;
2021
2022- skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, len);
2023+ skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76, len);
2024 if (IS_ERR(skb))
2025 return PTR_ERR(skb);
2026
2027@@ -4643,7 +4643,7 @@ int mt7996_mcu_update_bss_color(struct mt7996_dev *dev, struct ieee80211_vif *vi
2028 #define TWT_AGRT_PROTECT BIT(2)
2029
2030 int mt7996_mcu_twt_agrt_update(struct mt7996_dev *dev,
2031- struct mt7996_vif *mvif,
2032+ struct mt7996_bss_conf *mconf,
2033 struct mt7996_twt_flow *flow,
2034 int cmd)
2035 {
2036@@ -4674,12 +4674,12 @@ int mt7996_mcu_twt_agrt_update(struct mt7996_dev *dev,
2037 .len = cpu_to_le16(sizeof(req) - 4),
2038 .tbl_idx = flow->table_id,
2039 .cmd = cmd,
2040- .own_mac_idx = mvif->mt76.omac_idx,
2041+ .own_mac_idx = mconf->mt76.omac_idx,
2042 .flowid = flow->id,
2043 .peer_id = cpu_to_le16(flow->wcid),
2044 .duration = flow->duration,
2045- .bss = mvif->mt76.idx,
2046- .bss_idx = mvif->mt76.idx,
2047+ .bss = mconf->mt76.idx,
2048+ .bss_idx = mconf->mt76.idx,
2049 .start_tsf = cpu_to_le64(flow->tsf),
2050 .mantissa = flow->mantissa,
2051 .exponent = flow->exp,
2052@@ -4810,15 +4810,15 @@ int mt7996_mcu_rdd_background_disable_timer(struct mt7996_dev *dev, bool disable
2053
2054 int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev,
2055 struct ieee80211_vif *vif,
2056+ struct mt7996_bss_conf *mconf,
2057 struct ieee80211_sta *sta)
2058 {
2059- struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
2060 struct mt7996_sta *msta;
2061 struct sk_buff *skb;
2062
2063- msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->sta;
2064+ msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mconf->vif->sta;
2065
2066- skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
2067+ skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76,
2068 &msta->wcid,
2069 MT7996_STA_UPDATE_MAX_SIZE);
2070 if (IS_ERR(skb))
2071@@ -5462,8 +5462,9 @@ int mt7996_mcu_set_scs(struct mt7996_phy *phy, u8 enable)
2072 &req, sizeof(req), false);
2073 }
2074
2075-int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy, struct mt7996_sta *msta,
2076- enum vow_drr_ctrl_id id)
2077+int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy,
2078+ struct mt7996_bss_conf *mconf,
2079+ struct mt7996_sta *msta, enum vow_drr_ctrl_id id)
2080 {
2081 struct mt7996_vow_sta_ctrl *vow = msta ? &msta->vow : NULL;
2082 u32 val = 0;
2083@@ -5489,9 +5490,9 @@ int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy, struct mt7996_sta *msta,
2084 .len = cpu_to_le16(sizeof(req) - 4),
2085 .wlan_idx = cpu_to_le16(msta ? msta->wcid.idx : 0),
2086 .band_idx = phy->mt76->band_idx,
2087- .wmm_idx = msta ? msta->vif->mt76.wmm_idx : 0,
2088+ .wmm_idx = msta ? mconf->mt76.wmm_idx : 0,
2089 .ctrl_id = cpu_to_le32(id),
2090- .omac_idx = msta ? msta->vif->mt76.omac_idx : 0
2091+ .omac_idx = msta ? mconf->mt76.omac_idx : 0
2092 };
2093
2094 switch (id) {
2095@@ -5679,7 +5680,7 @@ void mt7996_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
2096 {
2097 u8 mode, val;
2098 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
2099- struct mt7996_phy *phy = mvif->phy;
2100+ struct mt7996_phy *phy = mvif->deflink.phy;
2101
2102 mode = FIELD_GET(RATE_CFG_MODE, *((u32 *)data));
2103 val = FIELD_GET(RATE_CFG_VAL, *((u32 *)data));
2104@@ -5710,11 +5711,11 @@ void mt7996_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
2105 void mt7996_set_beacon_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
2106 {
2107 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
2108- struct ieee80211_hw *hw = mvif->phy->mt76->hw;
2109+ struct ieee80211_hw *hw = mvif->deflink.phy->mt76->hw;
2110 u8 val = *((u8 *)data);
2111
2112 vif->bss_conf.enable_beacon = val;
2113
2114- mt7996_mcu_add_beacon(hw, vif, val);
2115+ mt7996_mcu_add_beacon(hw, &vif->bss_conf, &mvif->deflink, val);
2116 }
2117 #endif
2118diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
2119index 2b266d1..6b03ee1 100644
2120--- a/mt7996/mt7996.h
2121+++ b/mt7996/mt7996.h
2122@@ -324,18 +324,25 @@ struct mt7996_sta {
2123 struct mt7996_vow_sta_ctrl vow;
2124 };
2125
2126-struct mt7996_vif {
2127+struct mt7996_bss_conf {
2128 struct mt76_vif mt76; /* must be first */
2129
2130- struct mt7996_sta sta;
2131+ struct mt7996_vif *vif;
2132 struct mt7996_phy *phy;
2133-
2134 struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
2135 struct cfg80211_bitrate_mask bitrate_mask;
2136
2137 struct mt7996_chanctx *chanctx;
2138 };
2139
2140+struct mt7996_vif {
2141+ struct mt7996_bss_conf deflink;
2142+ struct mt7996_bss_conf __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS];
2143+
2144+ struct mt7996_sta sta;
2145+ struct mt7996_dev *dev;
2146+};
2147+
2148 /* crash-dump */
2149 struct mt7996_crash_data {
2150 guid_t guid;
2151@@ -769,6 +776,13 @@ mt7996_chanctx_get(struct ieee80211_chanctx_conf *ctx)
2152 return (struct mt7996_chanctx *)&ctx->drv_priv;
2153 }
2154
2155+static inline struct mt7996_bss_conf *
2156+mconf_dereference_protected(struct mt7996_vif *mvif, u8 link_id)
2157+{
2158+ return rcu_dereference_protected(mvif->link[link_id],
2159+ lockdep_is_held(&mvif->dev->mt76.mutex));
2160+}
2161+
2162 extern const struct ieee80211_ops mt7996_ops;
2163 extern struct pci_driver mt7996_pci_driver;
2164 extern struct pci_driver mt7996_hif_driver;
2165@@ -779,7 +793,7 @@ struct mt7996_dev *mt7996_mmio_probe(struct device *pdev,
2166 void mt7996_wfsys_reset(struct mt7996_dev *dev);
2167 void mt7996_rro_hw_init(struct mt7996_dev *dev);
2168 irqreturn_t mt7996_irq_handler(int irq, void *dev_instance);
2169-u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif *mvif);
2170+u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_bss_conf *mconf);
2171 int mt7996_register_device(struct mt7996_dev *dev);
2172 void mt7996_unregister_device(struct mt7996_dev *dev);
2173 const char *mt7996_eeprom_name(struct mt7996_dev *dev);
2174@@ -805,37 +819,47 @@ int mt7996_run(struct ieee80211_hw *hw);
2175 int mt7996_mcu_init(struct mt7996_dev *dev);
2176 int mt7996_mcu_init_firmware(struct mt7996_dev *dev);
2177 int mt7996_mcu_twt_agrt_update(struct mt7996_dev *dev,
2178- struct mt7996_vif *mvif,
2179+ struct mt7996_bss_conf *mconf,
2180 struct mt7996_twt_flow *flow,
2181 int cmd);
2182 int mt7996_mcu_add_dev_info(struct mt7996_phy *phy,
2183- struct ieee80211_vif *vif, bool enable);
2184+ struct ieee80211_bss_conf *conf,
2185+ struct mt7996_bss_conf *mconf, bool enable);
2186 int mt7996_mcu_add_bss_info(struct mt7996_phy *phy,
2187- struct ieee80211_vif *vif, int enable);
2188-int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
2189- struct ieee80211_sta *sta, bool enable, bool newly);
2190+ struct ieee80211_bss_conf *conf,
2191+ struct mt7996_bss_conf *mconf, int enable);
2192+int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf,
2193+ struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta,
2194+ bool enable, bool newly);
2195 int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev,
2196 struct ieee80211_ampdu_params *params,
2197 bool add);
2198 int mt7996_mcu_add_rx_ba(struct mt7996_dev *dev,
2199 struct ieee80211_ampdu_params *params,
2200 bool add);
2201-int mt7996_mcu_update_bss_color(struct mt7996_dev *dev, struct ieee80211_vif *vif,
2202+int mt7996_mcu_update_bss_color(struct mt7996_dev *dev,
2203+ struct mt7996_bss_conf *mconf,
2204 struct cfg80211_he_bss_color *he_bss_color);
2205-int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2206- int enable);
2207+int mt7996_mcu_add_beacon(struct ieee80211_hw *hw,
2208+ struct ieee80211_bss_conf *conf,
2209+ struct mt7996_bss_conf *mconf, int en);
2210 int mt7996_mcu_beacon_inband_discov(struct mt7996_dev *dev,
2211- struct ieee80211_vif *vif, u32 changed);
2212-int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy, struct ieee80211_vif *vif,
2213+ struct ieee80211_bss_conf *conf,
2214+ struct mt7996_bss_conf *mconf, u32 changed);
2215+int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy,
2216+ struct mt7996_bss_conf *mconf,
2217 struct ieee80211_he_obss_pd *he_obss_pd);
2218-int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, struct ieee80211_vif *vif,
2219+int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev,
2220+ struct ieee80211_bss_conf *conf,
2221+ struct mt7996_bss_conf *mconf,
2222 struct ieee80211_sta *sta, bool changed);
2223 int mt7996_set_channel(struct mt7996_phy *phy, struct cfg80211_chan_def *chandef);
2224 int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag);
2225-int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct ieee80211_vif *vif);
2226+int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct mt7996_bss_conf *mconf);
2227 int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev,
2228 void *data, u16 version);
2229-int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev, struct ieee80211_vif *vif,
2230+int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev,
2231+ struct mt7996_bss_conf *mconf,
2232 struct ieee80211_sta *sta, void *data, u32 field);
2233 int mt7996_mcu_set_eeprom(struct mt7996_dev *dev);
2234 int mt7996_mcu_get_eeprom(struct mt7996_dev *dev, u32 offset, u8 *read_buf);
2235@@ -850,7 +874,7 @@ int mt7996_mcu_set_radar_th(struct mt7996_dev *dev, int index,
2236 const struct mt7996_dfs_pattern *pattern);
2237 int mt7996_mcu_set_radio_en(struct mt7996_phy *phy, bool enable);
2238 int mt7996_mcu_set_rts_thresh(struct mt7996_phy *phy, u32 val);
2239-int mt7996_mcu_set_timing(struct mt7996_phy *phy, struct ieee80211_vif *vif);
2240+int mt7996_mcu_set_timing(struct mt7996_phy *phy, struct mt7996_bss_conf *mconf);
2241 int mt7996_mcu_get_chan_mib_info(struct mt7996_phy *phy, bool chan_switch);
2242 int mt7996_mcu_get_temperature(struct mt7996_phy *phy);
2243 int mt7996_mcu_set_thermal_throttling(struct mt7996_phy *phy, u8 state);
2244@@ -890,8 +914,9 @@ void mt7996_tm_rf_test_event(struct mt7996_dev *dev, struct sk_buff *skb);
2245 int mt7996_mcu_set_scs(struct mt7996_phy *phy, u8 enable);
2246 void mt7996_mcu_scs_sta_poll(struct work_struct *work);
2247 int mt7996_mcu_set_band_confg(struct mt7996_phy *phy, u16 option, bool enable);
2248-int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy, struct mt7996_sta *msta,
2249- enum vow_drr_ctrl_id id);
2250+int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy,
2251+ struct mt7996_bss_conf *mconf,
2252+ struct mt7996_sta *msta, enum vow_drr_ctrl_id id);
2253 int mt7996_mcu_set_vow_feature_ctrl(struct mt7996_phy *phy);
2254 void mt7996_mcu_wmm_pbc_work(struct work_struct *work);
2255
2256@@ -1000,13 +1025,16 @@ void mt7996_update_channel(struct mt76_phy *mphy);
2257 int mt7996_init_debugfs(struct mt7996_phy *phy);
2258 void mt7996_debugfs_rx_fw_monitor(struct mt7996_dev *dev, const void *data, int len);
2259 bool mt7996_debugfs_rx_log(struct mt7996_dev *dev, const void *data, int len);
2260-int mt7996_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif,
2261+int mt7996_mcu_add_key(struct mt76_dev *dev, struct mt7996_bss_conf *mconf,
2262 struct ieee80211_key_conf *key, int mcu_cmd,
2263 struct mt76_wcid *wcid, enum set_key_cmd cmd);
2264-int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, struct ieee80211_vif *vif,
2265+int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev,
2266+ struct ieee80211_bss_conf *conf,
2267+ struct mt7996_bss_conf *mconf,
2268 struct ieee80211_key_conf *key);
2269 int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev,
2270 struct ieee80211_vif *vif,
2271+ struct mt7996_bss_conf *mconf,
2272 struct ieee80211_sta *sta);
2273 int mt7996_mcu_cp_support(struct mt7996_dev *dev, u8 mode);
2274 int mt7996_mcu_set_pp_en(struct mt7996_phy *phy, u8 mode, u16 bitmap);
2275diff --git a/mt7996/testmode.c b/mt7996/testmode.c
2276index 784a8be..bf55b43 100644
2277--- a/mt7996/testmode.c
2278+++ b/mt7996/testmode.c
2279@@ -223,6 +223,7 @@ static void
2280 mt7996_tm_init(struct mt7996_phy *phy, bool en)
2281 {
2282 struct mt7996_dev *dev = phy->dev;
2283+ struct mt7996_vif *mvif = (struct mt7996_vif *)phy->monitor_vif->drv_priv;
2284 u8 rf_test_mode = en ? RF_OPER_RF_TEST : RF_OPER_NORMAL;
2285
2286 if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state))
2287@@ -234,8 +235,8 @@ mt7996_tm_init(struct mt7996_phy *phy, bool en)
2288
2289 mt7996_tm_rf_switch_mode(dev, rf_test_mode);
2290
2291- mt7996_mcu_add_bss_info(phy, phy->monitor_vif, en);
2292- mt7996_mcu_add_sta(dev, phy->monitor_vif, NULL, en, false);
2293+ mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, en);
2294+ mt7996_mcu_add_sta(dev, &phy->monitor_vif->bss_conf, &mvif->deflink, NULL, en, false);
2295
2296 mt7996_tm_set(dev, SET_ID(BAND_IDX), phy->mt76->band_idx);
2297
2298@@ -1179,13 +1180,13 @@ mt7996_tm_txbf_init(struct mt7996_phy *phy, u16 *val)
2299 mt7996_tm_set_mac_addr(dev, td->addr[2], SET_ID(BSSID));
2300
2301 /* bss idx & omac idx should be set to band idx for ibf cal */
2302- mvif->mt76.idx = band_idx;
2303- dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx);
2304- mvif->mt76.omac_idx = band_idx;
2305- phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
2306+ mvif->deflink.mt76.idx = band_idx;
2307+ dev->mt76.vif_mask |= BIT_ULL(mvif->deflink.mt76.idx);
2308+ mvif->deflink.mt76.omac_idx = band_idx;
2309+ phy->omac_mask |= BIT_ULL(mvif->deflink.mt76.omac_idx);
2310
2311- mt7996_mcu_add_dev_info(phy, phy->monitor_vif, true);
2312- mt7996_mcu_add_bss_info(phy, phy->monitor_vif, true);
2313+ mt7996_mcu_add_dev_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, true);
2314+ mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, true);
2315
2316 if (td->ibf) {
2317 if (td->is_txbf_dut) {
2318--
23192.18.0
2320