developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 1 | From 2985f8ada71e49f6894f47b05e4c71de00c1ac7b Mon Sep 17 00:00:00 2001 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Fri, 24 Nov 2023 11:31:55 +0800 |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 078/193] mtk: mt76: mt7996: switch to per-link data structure |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 5 | of vif |
| 6 | |
| 7 | Introduce struct mt7996_bss_conf, data structure for per-link BSS. |
| 8 | Note that mt7996_vif now represents a legacy or MLD device. |
| 9 | This is a preliminary patch to add MLO support for mt7996 chipsets. |
| 10 | |
| 11 | Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com> |
| 12 | Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com> |
| 13 | Signed-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 | |
| 24 | diff --git a/mt7996/debugfs.c b/mt7996/debugfs.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 25 | index 7e8e91c..792ace0 100644 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 26 | --- a/mt7996/debugfs.c |
| 27 | +++ b/mt7996/debugfs.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 28 | @@ -726,7 +726,7 @@ static void |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 37 | @@ -746,7 +746,7 @@ mt7996_sta_hw_queue_read(void *data, struct ieee80211_sta *sta) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 46 | @@ -1010,7 +1010,7 @@ mt7996_atf_enable_set(void *data, u64 val) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 55 | @@ -1042,7 +1042,7 @@ mt7996_airtime_read(struct seq_file *s, void *data) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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" |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 64 | @@ -1217,7 +1217,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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; |
| 73 | diff --git a/mt7996/init.c b/mt7996/init.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 74 | index c6ca865..1a3b867 100644 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 75 | --- a/mt7996/init.c |
| 76 | +++ b/mt7996/init.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 77 | @@ -627,11 +627,11 @@ static int mt7996_vow_init(struct mt7996_phy *phy) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 | |
| 91 | diff --git a/mt7996/mac.c b/mt7996/mac.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 92 | index 7cfc25b..8f74312 100644 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 93 | --- a/mt7996/mac.c |
| 94 | +++ b/mt7996/mac.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 95 | @@ -912,8 +912,9 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 106 | @@ -1527,12 +1528,15 @@ static void |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 123 | @@ -2249,6 +2253,8 @@ void mt7996_mac_sta_rc_work(struct work_struct *work) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 132 | @@ -2265,14 +2271,16 @@ void mt7996_mac_sta_rc_work(struct work_struct *work) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 151 | @@ -2655,7 +2663,7 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 160 | @@ -2664,7 +2672,8 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 170 | @@ -2686,6 +2695,7 @@ void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 178 | @@ -2696,8 +2706,7 @@ void mt7996_mac_twt_teardown_flow(struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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); |
| 188 | diff --git a/mt7996/main.c b/mt7996/main.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 189 | index ed14bbb..f81df91 100644 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 254 | - mvif->mt76.wmm_idx = vif->type == NL80211_IFTYPE_AP ? 0 : 3; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 261 | + mconf->mt76.wmm_idx = vif->type == NL80211_IFTYPE_AP ? 0 : 3; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 364 | @@ -439,6 +446,8 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 373 | @@ -480,9 +489,11 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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) { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 388 | @@ -496,9 +507,9 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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: |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 400 | @@ -545,7 +556,9 @@ mt7996_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 410 | @@ -553,10 +566,15 @@ mt7996_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 | |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 427 | @@ -616,22 +634,20 @@ static void mt7996_configure_filter(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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; |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 454 | @@ -639,16 +655,15 @@ mt7996_update_bss_color(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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; |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 475 | @@ -669,23 +684,22 @@ mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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]); |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 505 | @@ -697,20 +711,22 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 | |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 531 | @@ -722,42 +738,42 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 | } |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 587 | @@ -768,9 +784,14 @@ mt7996_channel_switch_beacon(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 | |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 603 | @@ -780,7 +801,8 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 613 | @@ -800,7 +822,7 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 622 | @@ -827,7 +849,10 @@ int mt7996_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 623 | struct ieee80211_sta *sta, enum mt76_sta_event ev) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 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 | |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 633 | @@ -835,8 +860,10 @@ int mt7996_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 634 | mt7996_mac_wtbl_update(dev, msta->wcid.idx, |
| 635 | MT_WTBL_UPDATE_ADM_COUNT_CLEAR); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 636 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 637 | - mt7996_mcu_add_sta(dev, vif, sta, true, true); |
| 638 | - mt7996_mcu_add_rate_ctrl(dev, vif, sta, false); |
| 639 | + conf = link_conf_dereference_protected(vif, 0); |
| 640 | + mconf = mconf_dereference_protected(mvif, 0); |
| 641 | + mt7996_mcu_add_sta(dev, conf, mconf, sta, true, true); |
| 642 | + mt7996_mcu_add_rate_ctrl(dev, conf, mconf, sta, false); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 643 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 644 | ewma_avg_signal_init(&msta->avg_ack_signal); |
| 645 | } |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 646 | @@ -848,10 +875,15 @@ void mt7996_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 647 | struct ieee80211_sta *sta) |
| 648 | { |
| 649 | struct mt7996_dev *dev = container_of(mdev, struct mt7996_dev, mt76); |
| 650 | + struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 651 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 652 | + struct mt7996_bss_conf *mconf; |
| 653 | + struct ieee80211_bss_conf *conf; |
| 654 | int i; |
| 655 | |
| 656 | - mt7996_mcu_add_sta(dev, vif, sta, false, false); |
| 657 | + conf = link_conf_dereference_protected(vif, 0); |
| 658 | + mconf = mconf_dereference_protected(mvif, 0); |
| 659 | + mt7996_mcu_add_sta(dev, conf, mconf, sta, false, false); |
| 660 | |
| 661 | mt7996_mac_wtbl_update(dev, msta->wcid.idx, |
| 662 | MT_WTBL_UPDATE_ADM_COUNT_CLEAR); |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 663 | @@ -983,7 +1015,7 @@ mt7996_get_stats(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 664 | return 0; |
| 665 | } |
| 666 | |
| 667 | -u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif *mvif) |
| 668 | +u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_bss_conf *mconf) |
| 669 | { |
| 670 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 671 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 672 | @@ -995,8 +1027,8 @@ u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif *mvif) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 673 | |
| 674 | lockdep_assert_held(&dev->mt76.mutex); |
| 675 | |
| 676 | - n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 |
| 677 | - : mvif->mt76.omac_idx; |
| 678 | + n = mconf->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 |
| 679 | + : mconf->mt76.omac_idx; |
| 680 | /* TSF software read */ |
| 681 | mt76_rmw(dev, MT_LPON_TCR(phy->mt76->band_idx, n), MT_LPON_TCR_SW_MODE, |
| 682 | MT_LPON_TCR_SW_READ); |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 683 | @@ -1011,10 +1043,12 @@ mt7996_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 684 | { |
| 685 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 686 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 687 | + struct mt7996_bss_conf *mconf; |
| 688 | u64 ret; |
| 689 | |
| 690 | mutex_lock(&dev->mt76.mutex); |
| 691 | - ret = __mt7996_get_tsf(hw, mvif); |
| 692 | + mconf = mconf_dereference_protected(mvif, 0); |
| 693 | + ret = __mt7996_get_tsf(hw, mconf); |
| 694 | mutex_unlock(&dev->mt76.mutex); |
| 695 | |
| 696 | return ret; |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 697 | @@ -1027,6 +1061,7 @@ mt7996_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 698 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 699 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 700 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 701 | + struct mt7996_bss_conf *mconf; |
| 702 | union { |
| 703 | u64 t64; |
| 704 | u32 t32[2]; |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 705 | @@ -1035,8 +1070,9 @@ mt7996_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 706 | |
| 707 | mutex_lock(&dev->mt76.mutex); |
| 708 | |
| 709 | - n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 |
| 710 | - : mvif->mt76.omac_idx; |
| 711 | + mconf = mconf_dereference_protected(mvif, 0); |
| 712 | + n = mconf->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 |
| 713 | + : mconf->mt76.omac_idx; |
| 714 | mt76_wr(dev, MT_LPON_UTTR0(phy->mt76->band_idx), tsf.t32[0]); |
| 715 | mt76_wr(dev, MT_LPON_UTTR1(phy->mt76->band_idx), tsf.t32[1]); |
| 716 | /* TSF software overwrite */ |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 717 | @@ -1053,6 +1089,7 @@ mt7996_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 718 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 719 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 720 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 721 | + struct mt7996_bss_conf *mconf; |
| 722 | union { |
| 723 | u64 t64; |
| 724 | u32 t32[2]; |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 725 | @@ -1061,8 +1098,9 @@ mt7996_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 726 | |
| 727 | mutex_lock(&dev->mt76.mutex); |
| 728 | |
| 729 | - n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 |
| 730 | - : mvif->mt76.omac_idx; |
| 731 | + mconf = mconf_dereference_protected(mvif, 0); |
| 732 | + n = mconf->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 |
| 733 | + : mconf->mt76.omac_idx; |
| 734 | mt76_wr(dev, MT_LPON_UTTR0(phy->mt76->band_idx), tsf.t32[0]); |
| 735 | mt76_wr(dev, MT_LPON_UTTR1(phy->mt76->band_idx), tsf.t32[1]); |
| 736 | /* TSF software adjust*/ |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 737 | @@ -1178,7 +1216,7 @@ static void mt7996_sta_statistics(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 738 | static void mt7996_sta_rc_work(void *data, struct ieee80211_sta *sta) |
| 739 | { |
| 740 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 741 | - struct mt7996_dev *dev = msta->vif->phy->dev; |
| 742 | + struct mt7996_dev *dev = msta->vif->dev; |
| 743 | u32 *changed = data; |
| 744 | |
| 745 | spin_lock_bh(&dev->mt76.sta_poll_lock); |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 746 | @@ -1214,9 +1252,13 @@ mt7996_set_bitrate_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 747 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 748 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 749 | struct mt7996_dev *dev = phy->dev; |
| 750 | + struct mt7996_bss_conf *mconf; |
| 751 | u32 changed = IEEE80211_RC_SUPP_RATES_CHANGED; |
| 752 | |
| 753 | - mvif->bitrate_mask = *mask; |
| 754 | + mutex_lock(&dev->mt76.mutex); |
| 755 | + mconf = mconf_dereference_protected(mvif, 0); |
| 756 | + mconf->bitrate_mask = *mask; |
| 757 | + mutex_unlock(&dev->mt76.mutex); |
| 758 | |
| 759 | /* if multiple rates across different preambles are given we can |
| 760 | * reconfigure this info with all peers using sta_rec command with |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 761 | @@ -1238,14 +1280,20 @@ static void mt7996_sta_set_4addr(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 762 | bool enabled) |
| 763 | { |
| 764 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 765 | + struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 766 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 767 | + struct mt7996_bss_conf *mconf; |
| 768 | + |
| 769 | + mutex_lock(&dev->mt76.mutex); |
| 770 | + mconf = mconf_dereference_protected(mvif, 0); |
| 771 | |
| 772 | if (enabled) |
| 773 | set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); |
| 774 | else |
| 775 | clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); |
| 776 | |
| 777 | - mt7996_mcu_wtbl_update_hdr_trans(dev, vif, sta); |
| 778 | + mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, sta); |
| 779 | + mutex_unlock(&dev->mt76.mutex); |
| 780 | } |
| 781 | |
| 782 | static void mt7996_sta_set_decap_offload(struct ieee80211_hw *hw, |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 783 | @@ -1254,14 +1302,20 @@ static void mt7996_sta_set_decap_offload(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 784 | bool enabled) |
| 785 | { |
| 786 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 787 | + struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 788 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 789 | + struct mt7996_bss_conf *mconf; |
| 790 | + |
| 791 | + mutex_lock(&dev->mt76.mutex); |
| 792 | + mconf = mconf_dereference_protected(mvif, 0); |
| 793 | |
| 794 | if (enabled) |
| 795 | set_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags); |
| 796 | else |
| 797 | clear_bit(MT_WCID_FLAG_HDR_TRANS, &msta->wcid.flags); |
| 798 | |
| 799 | - mt7996_mcu_wtbl_update_hdr_trans(dev, vif, sta); |
| 800 | + mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, sta); |
| 801 | + mutex_unlock(&dev->mt76.mutex); |
| 802 | } |
| 803 | |
| 804 | static const char mt7996_gstrings_stats[][ETH_GSTRING_LEN] = { |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 805 | @@ -1394,7 +1448,7 @@ static void mt7996_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 806 | struct mt76_ethtool_worker_info *wi = wi_data; |
| 807 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 808 | |
| 809 | - if (msta->vif->mt76.idx != wi->idx) |
| 810 | + if (msta->vif->deflink.mt76.idx != wi->idx) |
| 811 | return; |
| 812 | |
| 813 | mt76_ethtool_worker(wi, &msta->wcid.stats, true); |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 814 | @@ -1408,15 +1462,17 @@ void mt7996_get_et_stats(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 815 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 816 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 817 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 818 | + struct mt7996_bss_conf *mconf; |
| 819 | struct mt76_mib_stats *mib = &phy->mib; |
| 820 | struct mt76_ethtool_worker_info wi = { |
| 821 | .data = data, |
| 822 | - .idx = mvif->mt76.idx, |
| 823 | }; |
| 824 | /* See mt7996_ampdu_stat_read_phy, etc */ |
| 825 | int i, ei = 0; |
| 826 | |
| 827 | mutex_lock(&dev->mt76.mutex); |
| 828 | + mconf = mconf_dereference_protected(mvif, 0); |
| 829 | + wi.idx = mconf->mt76.idx, |
| 830 | |
| 831 | mt7996_mac_update_stats(phy); |
| 832 | |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 833 | @@ -1622,6 +1678,7 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 834 | struct net_device_path *path) |
| 835 | { |
| 836 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 837 | + struct mt7996_bss_conf *mconf = &mvif->deflink; |
| 838 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 839 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 840 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 841 | @@ -1651,7 +1708,7 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 842 | path->type = DEV_PATH_MTK_WDMA; |
| 843 | path->dev = ctx->dev; |
| 844 | path->mtk_wdma.wdma_idx = wed->wdma_idx; |
| 845 | - path->mtk_wdma.bss = mvif->mt76.idx; |
| 846 | + path->mtk_wdma.bss = mconf->mt76.idx; |
| 847 | path->mtk_wdma.queue = 0; |
| 848 | path->mtk_wdma.wcid = msta->wcid.idx; |
| 849 | |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 850 | @@ -1783,6 +1840,7 @@ mt7996_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 851 | struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf); |
| 852 | struct mt7996_phy *phy = ctx->phy; |
| 853 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 854 | + struct mt7996_bss_conf *mconf; |
| 855 | |
| 856 | wiphy_info(hw->wiphy, "Assign VIF (addr: %pM, type: %d, link_id: %d) to channel context: %d MHz\n", |
| 857 | vif->addr, vif->type, link_conf->link_id, |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 858 | @@ -1790,7 +1848,8 @@ mt7996_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 859 | |
| 860 | mutex_lock(&phy->dev->mt76.mutex); |
| 861 | |
| 862 | - mvif->chanctx = ctx; |
| 863 | + mconf = mconf_dereference_protected(mvif, 0); |
| 864 | + mconf->chanctx = ctx; |
| 865 | ctx->nbss_assigned++; |
| 866 | |
| 867 | mutex_unlock(&phy->dev->mt76.mutex); |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 868 | @@ -1806,6 +1865,7 @@ mt7996_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 869 | struct mt7996_chanctx *ctx = mt7996_chanctx_get(conf); |
| 870 | struct mt7996_phy *phy = ctx->phy; |
| 871 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 872 | + struct mt7996_bss_conf *mconf; |
| 873 | |
| 874 | wiphy_info(hw->wiphy, "Remove VIF (addr: %pM, type: %d, link_id: %d) from channel context: %d MHz\n", |
| 875 | vif->addr, vif->type, link_conf->link_id, |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 876 | @@ -1817,7 +1877,8 @@ mt7996_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 877 | if (test_bit(MT76_SCANNING, &phy->mt76->state)) |
| 878 | mt7996_scan_complete(phy, true); |
| 879 | |
| 880 | - mvif->chanctx = NULL; |
| 881 | + mconf = mconf_dereference_protected(mvif, 0); |
| 882 | + mconf->chanctx = NULL; |
| 883 | ctx->nbss_assigned--; |
| 884 | |
| 885 | mutex_unlock(&phy->dev->mt76.mutex); |
| 886 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 887 | index b8bfcbf..cdc019f 100644 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 888 | --- a/mt7996/mcu.c |
| 889 | +++ b/mt7996/mcu.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 890 | @@ -122,12 +122,12 @@ mt7996_mcu_get_sta_nss(u16 mcs_map) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 891 | } |
| 892 | |
| 893 | static void |
| 894 | -mt7996_mcu_set_sta_he_mcs(struct ieee80211_sta *sta, __le16 *he_mcs, |
| 895 | - u16 mcs_map) |
| 896 | +mt7996_mcu_set_sta_he_mcs(struct ieee80211_sta *sta, |
| 897 | + struct mt7996_bss_conf *mconf, |
| 898 | + __le16 *he_mcs, u16 mcs_map) |
| 899 | { |
| 900 | - struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 901 | - enum nl80211_band band = msta->vif->phy->mt76->chandef.chan->band; |
| 902 | - const u16 *mask = msta->vif->bitrate_mask.control[band].he_mcs; |
| 903 | + enum nl80211_band band = mconf->phy->mt76->chandef.chan->band; |
| 904 | + const u16 *mask = mconf->bitrate_mask.control[band].he_mcs; |
| 905 | int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss; |
| 906 | |
| 907 | for (nss = 0; nss < max_nss; nss++) { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 908 | @@ -927,8 +927,7 @@ mt7996_mcu_add_uni_tlv(struct sk_buff *skb, u16 tag, u16 len) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | static void |
| 912 | -mt7996_mcu_bss_rfch_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
| 913 | - struct mt7996_phy *phy) |
| 914 | +mt7996_mcu_bss_rfch_tlv(struct sk_buff *skb, struct mt7996_phy *phy) |
| 915 | { |
| 916 | static const u8 rlm_ch_band[] = { |
| 917 | [NL80211_BAND_2GHZ] = 1, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 918 | @@ -958,8 +957,7 @@ mt7996_mcu_bss_rfch_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | static void |
| 922 | -mt7996_mcu_bss_ra_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
| 923 | - struct mt7996_phy *phy) |
| 924 | +mt7996_mcu_bss_ra_tlv(struct sk_buff *skb) |
| 925 | { |
| 926 | struct bss_ra_tlv *ra; |
| 927 | struct tlv *tlv; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 928 | @@ -971,7 +969,7 @@ mt7996_mcu_bss_ra_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | static void |
| 932 | -mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
| 933 | +mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf, |
| 934 | struct mt7996_phy *phy) |
| 935 | { |
| 936 | #define DEFAULT_HE_PE_DURATION 4 |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 937 | @@ -980,16 +978,16 @@ mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 938 | struct bss_info_uni_he *he; |
| 939 | struct tlv *tlv; |
| 940 | |
| 941 | - cap = mt76_connac_get_he_phy_cap(phy->mt76, vif); |
| 942 | + cap = mt76_connac_get_he_phy_cap(phy->mt76, conf->vif); |
| 943 | |
| 944 | tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_HE_BASIC, sizeof(*he)); |
| 945 | |
| 946 | he = (struct bss_info_uni_he *)tlv; |
| 947 | - he->he_pe_duration = vif->bss_conf.htc_trig_based_pkt_ext; |
| 948 | + he->he_pe_duration = conf->htc_trig_based_pkt_ext; |
| 949 | if (!he->he_pe_duration) |
| 950 | he->he_pe_duration = DEFAULT_HE_PE_DURATION; |
| 951 | |
| 952 | - he->he_rts_thres = cpu_to_le16(vif->bss_conf.frame_time_rts_th); |
| 953 | + he->he_rts_thres = cpu_to_le16(conf->frame_time_rts_th); |
| 954 | if (!he->he_rts_thres) |
| 955 | he->he_rts_thres = cpu_to_le16(DEFAULT_HE_DURATION_RTS_THRES); |
| 956 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 957 | @@ -999,13 +997,13 @@ mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 958 | } |
| 959 | |
| 960 | static void |
| 961 | -mt7996_mcu_bss_mbssid_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
| 962 | +mt7996_mcu_bss_mbssid_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf, |
| 963 | struct mt7996_phy *phy, int enable) |
| 964 | { |
| 965 | struct bss_info_uni_mbssid *mbssid; |
| 966 | struct tlv *tlv; |
| 967 | |
| 968 | - if (!vif->bss_conf.bssid_indicator && enable) |
| 969 | + if (!conf->bssid_indicator && enable) |
| 970 | return; |
| 971 | |
| 972 | tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_11V_MBSSID, sizeof(*mbssid)); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 973 | @@ -1013,23 +1011,21 @@ mt7996_mcu_bss_mbssid_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 974 | mbssid = (struct bss_info_uni_mbssid *)tlv; |
| 975 | |
| 976 | if (enable) { |
| 977 | - mbssid->max_indicator = vif->bss_conf.bssid_indicator; |
| 978 | - mbssid->mbss_idx = vif->bss_conf.bssid_index; |
| 979 | + mbssid->max_indicator = conf->bssid_indicator; |
| 980 | + mbssid->mbss_idx = conf->bssid_index; |
| 981 | mbssid->tx_bss_omac_idx = 0; |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | static void |
| 986 | -mt7996_mcu_bss_bmc_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
| 987 | +mt7996_mcu_bss_bmc_tlv(struct sk_buff *skb, struct mt7996_bss_conf *mconf, |
| 988 | struct mt7996_phy *phy) |
| 989 | { |
| 990 | - struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; |
| 991 | struct bss_rate_tlv *bmc; |
| 992 | struct cfg80211_chan_def *chandef = &phy->mt76->chandef; |
| 993 | enum nl80211_band band = chandef->chan->band; |
| 994 | struct tlv *tlv; |
| 995 | - u8 idx = mvif->mcast_rates_idx ? |
| 996 | - mvif->mcast_rates_idx : mvif->basic_rates_idx; |
| 997 | + u8 idx = mconf->mt76.mcast_rates_idx ?: mconf->mt76.basic_rates_idx; |
| 998 | |
| 999 | tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_RATE, sizeof(*bmc)); |
| 1000 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1001 | @@ -1053,9 +1049,9 @@ mt7996_mcu_bss_txcmd_tlv(struct sk_buff *skb, bool en) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1002 | } |
| 1003 | |
| 1004 | static void |
| 1005 | -mt7996_mcu_bss_mld_tlv(struct sk_buff *skb, struct ieee80211_vif *vif) |
| 1006 | +mt7996_mcu_bss_mld_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
| 1007 | + struct mt7996_bss_conf *mconf) |
| 1008 | { |
| 1009 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1010 | struct bss_mld_tlv *mld; |
| 1011 | struct tlv *tlv; |
| 1012 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1013 | @@ -1063,33 +1059,30 @@ mt7996_mcu_bss_mld_tlv(struct sk_buff *skb, struct ieee80211_vif *vif) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1014 | |
| 1015 | mld = (struct bss_mld_tlv *)tlv; |
| 1016 | mld->group_mld_id = 0xff; |
| 1017 | - mld->own_mld_id = mvif->mt76.idx; |
| 1018 | + mld->own_mld_id = mconf->mt76.idx; |
| 1019 | mld->remap_idx = 0xff; |
| 1020 | } |
| 1021 | |
| 1022 | static void |
| 1023 | -mt7996_mcu_bss_sec_tlv(struct sk_buff *skb, struct ieee80211_vif *vif) |
| 1024 | +mt7996_mcu_bss_sec_tlv(struct sk_buff *skb, struct mt7996_bss_conf *mconf) |
| 1025 | { |
| 1026 | - struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; |
| 1027 | struct bss_sec_tlv *sec; |
| 1028 | struct tlv *tlv; |
| 1029 | |
| 1030 | tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_SEC, sizeof(*sec)); |
| 1031 | |
| 1032 | sec = (struct bss_sec_tlv *)tlv; |
| 1033 | - sec->cipher = mvif->cipher; |
| 1034 | + sec->cipher = mconf->mt76.cipher; |
| 1035 | } |
| 1036 | |
| 1037 | static int |
| 1038 | -mt7996_mcu_muar_config(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
| 1039 | - bool bssid, bool enable) |
| 1040 | +mt7996_mcu_muar_config(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf, |
| 1041 | + struct mt7996_bss_conf *mconf, bool bssid, bool enable) |
| 1042 | { |
| 1043 | #define UNI_MUAR_ENTRY 2 |
| 1044 | struct mt7996_dev *dev = phy->dev; |
| 1045 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1046 | - u32 idx = mvif->mt76.omac_idx - REPEATER_BSSID_START; |
| 1047 | - const u8 *addr = vif->addr; |
| 1048 | - |
| 1049 | + u32 idx = mconf->mt76.omac_idx - REPEATER_BSSID_START; |
| 1050 | + const u8 *addr = bssid ? conf->bssid : conf->vif->addr; |
| 1051 | struct { |
| 1052 | struct { |
| 1053 | u8 band; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1054 | @@ -1114,9 +1107,6 @@ mt7996_mcu_muar_config(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1055 | .entry_add = true, |
| 1056 | }; |
| 1057 | |
| 1058 | - if (bssid) |
| 1059 | - addr = vif->bss_conf.bssid; |
| 1060 | - |
| 1061 | if (enable) |
| 1062 | memcpy(req.addr, addr, ETH_ALEN); |
| 1063 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1064 | @@ -1125,10 +1115,8 @@ mt7996_mcu_muar_config(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1065 | } |
| 1066 | |
| 1067 | static void |
| 1068 | -mt7996_mcu_bss_ifs_timing_tlv(struct sk_buff *skb, struct ieee80211_vif *vif) |
| 1069 | +mt7996_mcu_bss_ifs_timing_tlv(struct sk_buff *skb, struct mt7996_phy *phy) |
| 1070 | { |
| 1071 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1072 | - struct mt7996_phy *phy = mvif->phy; |
| 1073 | struct bss_ifs_time_tlv *ifs_time; |
| 1074 | struct tlv *tlv; |
| 1075 | bool is_2ghz = phy->mt76->chandef.chan->band == NL80211_BAND_2GHZ; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1076 | @@ -1154,12 +1142,13 @@ mt7996_mcu_bss_ifs_timing_tlv(struct sk_buff *skb, struct ieee80211_vif *vif) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1077 | |
| 1078 | static int |
| 1079 | mt7996_mcu_bss_basic_tlv(struct sk_buff *skb, |
| 1080 | - struct ieee80211_vif *vif, |
| 1081 | + struct ieee80211_bss_conf *conf, |
| 1082 | + struct mt7996_bss_conf *mconf, |
| 1083 | struct ieee80211_sta *sta, |
| 1084 | struct mt76_phy *phy, u16 wlan_idx, |
| 1085 | bool enable) |
| 1086 | { |
| 1087 | - struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; |
| 1088 | + struct ieee80211_vif *vif = conf->vif; |
| 1089 | struct cfg80211_chan_def *chandef = &phy->chandef; |
| 1090 | struct mt76_connac_bss_basic_tlv *bss; |
| 1091 | u32 type = CONNECTION_INFRA_AP; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1092 | @@ -1176,8 +1165,7 @@ mt7996_mcu_bss_basic_tlv(struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1093 | if (enable) { |
| 1094 | rcu_read_lock(); |
| 1095 | if (!sta) |
| 1096 | - sta = ieee80211_find_sta(vif, |
| 1097 | - vif->bss_conf.bssid); |
| 1098 | + sta = ieee80211_find_sta(vif, conf->bssid); |
| 1099 | /* TODO: enable BSS_INFO_UAPSD & BSS_INFO_PM */ |
| 1100 | if (sta) { |
| 1101 | struct mt76_wcid *wcid; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1102 | @@ -1200,18 +1188,17 @@ mt7996_mcu_bss_basic_tlv(struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1103 | tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_BASIC, sizeof(*bss)); |
| 1104 | |
| 1105 | bss = (struct mt76_connac_bss_basic_tlv *)tlv; |
| 1106 | - bss->bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int); |
| 1107 | - bss->dtim_period = vif->bss_conf.dtim_period; |
| 1108 | bss->bmc_tx_wlan_idx = cpu_to_le16(wlan_idx); |
| 1109 | bss->sta_idx = cpu_to_le16(sta_wlan_idx); |
| 1110 | bss->conn_type = cpu_to_le32(type); |
| 1111 | - bss->omac_idx = mvif->omac_idx; |
| 1112 | - bss->band_idx = mvif->band_idx; |
| 1113 | - bss->wmm_idx = mvif->wmm_idx; |
| 1114 | + bss->omac_idx = mconf->mt76.omac_idx; |
| 1115 | + bss->band_idx = mconf->mt76.band_idx; |
| 1116 | + bss->wmm_idx = mconf->mt76.wmm_idx; |
| 1117 | bss->conn_state = !enable; |
| 1118 | bss->active = enable; |
| 1119 | |
| 1120 | - idx = mvif->omac_idx > EXT_BSSID_START ? HW_BSSID_0 : mvif->omac_idx; |
| 1121 | + idx = mconf->mt76.omac_idx > EXT_BSSID_START ? HW_BSSID_0 : |
| 1122 | + mconf->mt76.omac_idx; |
| 1123 | bss->hw_bss_idx = idx; |
| 1124 | |
| 1125 | if (vif->type == NL80211_IFTYPE_MONITOR) { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1126 | @@ -1224,9 +1211,9 @@ mt7996_mcu_bss_basic_tlv(struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1127 | return 0; |
| 1128 | } |
| 1129 | |
| 1130 | - memcpy(bss->bssid, vif->bss_conf.bssid, ETH_ALEN); |
| 1131 | - bss->bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int); |
| 1132 | - bss->dtim_period = vif->bss_conf.dtim_period; |
| 1133 | + memcpy(bss->bssid, conf->bssid, ETH_ALEN); |
| 1134 | + bss->bcn_interval = cpu_to_le16(conf->beacon_int); |
| 1135 | + bss->dtim_period = conf->dtim_period; |
| 1136 | bss->phymode = mt76_connac_get_phy_mode(phy, vif, |
| 1137 | chandef->chan->band, NULL); |
| 1138 | bss->phymode_ext = mt76_connac_get_phy_mode_ext(phy, vif, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1139 | @@ -1253,63 +1240,64 @@ __mt7996_mcu_alloc_bss_req(struct mt76_dev *dev, struct mt76_vif *mvif, int len) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1140 | } |
| 1141 | |
| 1142 | int mt7996_mcu_add_bss_info(struct mt7996_phy *phy, |
| 1143 | - struct ieee80211_vif *vif, int enable) |
| 1144 | + struct ieee80211_bss_conf *conf, |
| 1145 | + struct mt7996_bss_conf *mconf, int enable) |
| 1146 | { |
| 1147 | + struct ieee80211_vif *vif = conf->vif; |
| 1148 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1149 | struct mt7996_dev *dev = phy->dev; |
| 1150 | struct sk_buff *skb; |
| 1151 | |
| 1152 | - if (mvif->mt76.omac_idx >= REPEATER_BSSID_START) { |
| 1153 | - mt7996_mcu_muar_config(phy, vif, false, enable); |
| 1154 | - mt7996_mcu_muar_config(phy, vif, true, enable); |
| 1155 | + if (mconf->mt76.omac_idx >= REPEATER_BSSID_START) { |
| 1156 | + mt7996_mcu_muar_config(phy, conf, mconf, false, enable); |
| 1157 | + mt7996_mcu_muar_config(phy, conf, mconf, true, enable); |
| 1158 | } |
| 1159 | |
| 1160 | - skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, |
| 1161 | + skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76, |
| 1162 | MT7996_BSS_UPDATE_MAX_SIZE); |
| 1163 | if (IS_ERR(skb)) |
| 1164 | return PTR_ERR(skb); |
| 1165 | |
| 1166 | /* bss_basic must be first */ |
| 1167 | - mt7996_mcu_bss_basic_tlv(skb, vif, NULL, phy->mt76, |
| 1168 | + mt7996_mcu_bss_basic_tlv(skb, conf, mconf, NULL, phy->mt76, |
| 1169 | mvif->sta.wcid.idx, enable); |
| 1170 | - mt7996_mcu_bss_sec_tlv(skb, vif); |
| 1171 | + mt7996_mcu_bss_sec_tlv(skb, mconf); |
| 1172 | |
| 1173 | if (vif->type == NL80211_IFTYPE_MONITOR) |
| 1174 | goto out; |
| 1175 | |
| 1176 | if (enable) { |
| 1177 | - mt7996_mcu_bss_rfch_tlv(skb, vif, phy); |
| 1178 | - mt7996_mcu_bss_bmc_tlv(skb, vif, phy); |
| 1179 | - mt7996_mcu_bss_ra_tlv(skb, vif, phy); |
| 1180 | + mt7996_mcu_bss_rfch_tlv(skb, phy); |
| 1181 | + mt7996_mcu_bss_bmc_tlv(skb, mconf, phy); |
| 1182 | + mt7996_mcu_bss_ra_tlv(skb); |
| 1183 | mt7996_mcu_bss_txcmd_tlv(skb, true); |
| 1184 | - mt7996_mcu_bss_ifs_timing_tlv(skb, vif); |
| 1185 | + mt7996_mcu_bss_ifs_timing_tlv(skb, phy); |
| 1186 | |
| 1187 | - if (vif->bss_conf.he_support) |
| 1188 | - mt7996_mcu_bss_he_tlv(skb, vif, phy); |
| 1189 | + if (conf->he_support) |
| 1190 | + mt7996_mcu_bss_he_tlv(skb, conf, phy); |
| 1191 | |
| 1192 | /* this tag is necessary no matter if the vif is MLD */ |
| 1193 | - mt7996_mcu_bss_mld_tlv(skb, vif); |
| 1194 | + mt7996_mcu_bss_mld_tlv(skb, vif, mconf); |
| 1195 | } |
| 1196 | |
| 1197 | - mt7996_mcu_bss_mbssid_tlv(skb, vif, phy, enable); |
| 1198 | + mt7996_mcu_bss_mbssid_tlv(skb, conf, phy, enable); |
| 1199 | |
| 1200 | out: |
| 1201 | return mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| 1202 | MCU_WMWA_UNI_CMD(BSS_INFO_UPDATE), true); |
| 1203 | } |
| 1204 | |
| 1205 | -int mt7996_mcu_set_timing(struct mt7996_phy *phy, struct ieee80211_vif *vif) |
| 1206 | +int mt7996_mcu_set_timing(struct mt7996_phy *phy, struct mt7996_bss_conf *mconf) |
| 1207 | { |
| 1208 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1209 | struct mt7996_dev *dev = phy->dev; |
| 1210 | struct sk_buff *skb; |
| 1211 | |
| 1212 | - skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, |
| 1213 | + skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76, |
| 1214 | MT7996_BSS_UPDATE_MAX_SIZE); |
| 1215 | if (IS_ERR(skb)) |
| 1216 | return PTR_ERR(skb); |
| 1217 | |
| 1218 | - mt7996_mcu_bss_ifs_timing_tlv(skb, vif); |
| 1219 | + mt7996_mcu_bss_ifs_timing_tlv(skb, phy); |
| 1220 | |
| 1221 | return mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| 1222 | MCU_WMWA_UNI_CMD(BSS_INFO_UPDATE), true); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1223 | @@ -1351,12 +1339,12 @@ int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1224 | bool enable) |
| 1225 | { |
| 1226 | struct mt7996_sta *msta = (struct mt7996_sta *)params->sta->drv_priv; |
| 1227 | - struct mt7996_vif *mvif = msta->vif; |
| 1228 | + struct mt7996_bss_conf *mconf = mconf_dereference_protected(msta->vif, 0); |
| 1229 | |
| 1230 | if (enable && !params->amsdu) |
| 1231 | msta->wcid.amsdu = false; |
| 1232 | |
| 1233 | - return mt7996_mcu_sta_ba(dev, &mvif->mt76, params, enable, true); |
| 1234 | + return mt7996_mcu_sta_ba(dev, &mconf->mt76, params, enable, true); |
| 1235 | } |
| 1236 | |
| 1237 | int mt7996_mcu_add_rx_ba(struct mt7996_dev *dev, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1238 | @@ -1364,13 +1352,14 @@ int mt7996_mcu_add_rx_ba(struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1239 | bool enable) |
| 1240 | { |
| 1241 | struct mt7996_sta *msta = (struct mt7996_sta *)params->sta->drv_priv; |
| 1242 | - struct mt7996_vif *mvif = msta->vif; |
| 1243 | + struct mt7996_bss_conf *mconf = mconf_dereference_protected(msta->vif, 0); |
| 1244 | |
| 1245 | - return mt7996_mcu_sta_ba(dev, &mvif->mt76, params, enable, false); |
| 1246 | + return mt7996_mcu_sta_ba(dev, &mconf->mt76, params, enable, false); |
| 1247 | } |
| 1248 | |
| 1249 | static void |
| 1250 | -mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
| 1251 | +mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *conf, |
| 1252 | + struct mt7996_bss_conf *mconf, |
| 1253 | struct ieee80211_sta *sta) |
| 1254 | { |
| 1255 | struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1256 | @@ -1391,9 +1380,9 @@ mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1257 | he->he_phy_cap[i] = elem->phy_cap_info[i]; |
| 1258 | } |
| 1259 | |
| 1260 | - if (vif->type == NL80211_IFTYPE_AP && |
| 1261 | + if (conf->vif->type == NL80211_IFTYPE_AP && |
| 1262 | (elem->phy_cap_info[1] & IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD)) |
| 1263 | - u8p_replace_bits(&he->he_phy_cap[1], vif->bss_conf.he_ldpc, |
| 1264 | + u8p_replace_bits(&he->he_phy_cap[1], conf->he_ldpc, |
| 1265 | IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD); |
| 1266 | |
| 1267 | mcs_map = sta->deflink.he_cap.he_mcs_nss_supp; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1268 | @@ -1401,16 +1390,16 @@ mt7996_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1269 | case IEEE80211_STA_RX_BW_160: |
| 1270 | if (elem->phy_cap_info[0] & |
| 1271 | IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G) |
| 1272 | - mt7996_mcu_set_sta_he_mcs(sta, |
| 1273 | + mt7996_mcu_set_sta_he_mcs(sta, mconf, |
| 1274 | &he->max_nss_mcs[CMD_HE_MCS_BW8080], |
| 1275 | le16_to_cpu(mcs_map.rx_mcs_80p80)); |
| 1276 | |
| 1277 | - mt7996_mcu_set_sta_he_mcs(sta, |
| 1278 | + mt7996_mcu_set_sta_he_mcs(sta, mconf, |
| 1279 | &he->max_nss_mcs[CMD_HE_MCS_BW160], |
| 1280 | le16_to_cpu(mcs_map.rx_mcs_160)); |
| 1281 | fallthrough; |
| 1282 | default: |
| 1283 | - mt7996_mcu_set_sta_he_mcs(sta, |
| 1284 | + mt7996_mcu_set_sta_he_mcs(sta, mconf, |
| 1285 | &he->max_nss_mcs[CMD_HE_MCS_BW80], |
| 1286 | le16_to_cpu(mcs_map.rx_mcs_80)); |
| 1287 | break; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1288 | @@ -1501,7 +1490,7 @@ mt7996_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1289 | struct tlv *tlv; |
| 1290 | #ifdef CONFIG_MTK_VENDOR |
| 1291 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 1292 | - struct mt7996_phy *phy = (struct mt7996_phy *)msta->vif->phy; |
| 1293 | + struct mt7996_phy *phy = (struct mt7996_phy *)msta->vif->deflink.phy; |
| 1294 | #endif |
| 1295 | |
| 1296 | /* For 6G band, this tlv is necessary to let hw work normally */ |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1297 | @@ -1558,25 +1547,26 @@ mt7996_mcu_sta_amsdu_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1298 | |
| 1299 | static void |
| 1300 | mt7996_mcu_sta_muru_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
| 1301 | - struct ieee80211_vif *vif, struct ieee80211_sta *sta) |
| 1302 | + struct ieee80211_bss_conf *conf, |
| 1303 | + struct mt7996_bss_conf *mconf, |
| 1304 | + struct ieee80211_sta *sta) |
| 1305 | { |
| 1306 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1307 | - struct mt7996_phy *phy = mvif->phy; |
| 1308 | + struct mt7996_phy *phy = mconf->phy; |
| 1309 | struct ieee80211_he_cap_elem *elem = &sta->deflink.he_cap.he_cap_elem; |
| 1310 | struct sta_rec_muru *muru; |
| 1311 | struct tlv *tlv; |
| 1312 | |
| 1313 | - if (vif->type != NL80211_IFTYPE_STATION && |
| 1314 | - vif->type != NL80211_IFTYPE_AP) |
| 1315 | + if (conf->vif->type != NL80211_IFTYPE_STATION && |
| 1316 | + conf->vif->type != NL80211_IFTYPE_AP) |
| 1317 | return; |
| 1318 | |
| 1319 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_MURU, sizeof(*muru)); |
| 1320 | |
| 1321 | muru = (struct sta_rec_muru *)tlv; |
| 1322 | - muru->cfg.mimo_dl_en = (vif->bss_conf.eht_mu_beamformer || |
| 1323 | - vif->bss_conf.he_mu_beamformer || |
| 1324 | - vif->bss_conf.vht_mu_beamformer || |
| 1325 | - vif->bss_conf.vht_mu_beamformee) && |
| 1326 | + muru->cfg.mimo_dl_en = (conf->eht_mu_beamformer || |
| 1327 | + conf->he_mu_beamformer || |
| 1328 | + conf->vht_mu_beamformer || |
| 1329 | + conf->vht_mu_beamformee) && |
| 1330 | !!(phy->muru_onoff & MUMIMO_DL); |
| 1331 | muru->cfg.mimo_ul_en = !!(phy->muru_onoff & MUMIMO_UL); |
| 1332 | muru->cfg.ofdma_dl_en = !!(phy->muru_onoff & OFDMA_DL); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1333 | @@ -1617,13 +1607,14 @@ mt7996_mcu_sta_muru_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1334 | } |
| 1335 | |
| 1336 | static inline bool |
| 1337 | -mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
| 1338 | +mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf, |
| 1339 | + struct mt7996_bss_conf *mconf, |
| 1340 | struct ieee80211_sta *sta, bool bfee) |
| 1341 | { |
| 1342 | int sts = hweight16(phy->mt76->chainmask); |
| 1343 | |
| 1344 | - if (vif->type != NL80211_IFTYPE_STATION && |
| 1345 | - vif->type != NL80211_IFTYPE_AP) |
| 1346 | + if (conf->vif->type != NL80211_IFTYPE_STATION && |
| 1347 | + conf->vif->type != NL80211_IFTYPE_AP) |
| 1348 | return false; |
| 1349 | |
| 1350 | if (!bfee && sts < 2) |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1351 | @@ -1634,10 +1625,10 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1352 | struct ieee80211_eht_cap_elem_fixed *pe = &pc->eht_cap_elem; |
| 1353 | |
| 1354 | if (bfee) |
| 1355 | - return vif->bss_conf.eht_su_beamformee && |
| 1356 | + return conf->eht_su_beamformee && |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1357 | EHT_PHY(CAP0_SU_BEAMFORMER, pe->phy_cap_info[0]); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1358 | else |
| 1359 | - return vif->bss_conf.eht_su_beamformer && |
| 1360 | + return conf->eht_su_beamformer && |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1361 | EHT_PHY(CAP0_SU_BEAMFORMEE, pe->phy_cap_info[0]); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1362 | } |
| 1363 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1364 | @@ -1645,10 +1636,10 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1365 | struct ieee80211_he_cap_elem *pe = &sta->deflink.he_cap.he_cap_elem; |
| 1366 | |
| 1367 | if (bfee) |
| 1368 | - return vif->bss_conf.he_su_beamformee && |
| 1369 | + return conf->he_su_beamformee && |
| 1370 | HE_PHY(CAP3_SU_BEAMFORMER, pe->phy_cap_info[3]); |
| 1371 | else |
| 1372 | - return vif->bss_conf.he_su_beamformer && |
| 1373 | + return conf->he_su_beamformer && |
| 1374 | HE_PHY(CAP4_SU_BEAMFORMEE, pe->phy_cap_info[4]); |
| 1375 | } |
| 1376 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1377 | @@ -1656,10 +1647,10 @@ mt7996_is_ebf_supported(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1378 | u32 cap = sta->deflink.vht_cap.cap; |
| 1379 | |
| 1380 | if (bfee) |
| 1381 | - return vif->bss_conf.vht_su_beamformee && |
| 1382 | + return conf->vht_su_beamformee && |
| 1383 | (cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE); |
| 1384 | else |
| 1385 | - return vif->bss_conf.vht_su_beamformer && |
| 1386 | + return conf->vht_su_beamformer && |
| 1387 | (cap & IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE); |
| 1388 | } |
| 1389 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1390 | @@ -1855,10 +1846,10 @@ mt7996_mcu_sta_bfer_eht(struct ieee80211_sta *sta, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1391 | |
| 1392 | static void |
| 1393 | mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
| 1394 | - struct ieee80211_vif *vif, struct ieee80211_sta *sta) |
| 1395 | + struct ieee80211_bss_conf *conf, struct mt7996_bss_conf *mconf, |
| 1396 | + struct ieee80211_sta *sta) |
| 1397 | { |
| 1398 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1399 | - struct mt7996_phy *phy = mvif->phy; |
| 1400 | + struct mt7996_phy *phy = mconf->phy; |
| 1401 | int tx_ant = hweight16(phy->mt76->chainmask) - 1; |
| 1402 | struct sta_rec_bf *bf; |
| 1403 | struct tlv *tlv; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1404 | @@ -1873,7 +1864,7 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1405 | if (!(sta->deflink.ht_cap.ht_supported || sta->deflink.he_cap.has_he)) |
| 1406 | return; |
| 1407 | |
| 1408 | - ebf = mt7996_is_ebf_supported(phy, vif, sta, false); |
| 1409 | + ebf = mt7996_is_ebf_supported(phy, conf, mconf, sta, false); |
| 1410 | if (!ebf && !dev->ibf) |
| 1411 | return; |
| 1412 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1413 | @@ -1885,9 +1876,9 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1414 | * ht: iBF only, since mac80211 lacks of eBF support |
| 1415 | */ |
| 1416 | if (sta->deflink.eht_cap.has_eht && ebf) |
| 1417 | - mt7996_mcu_sta_bfer_eht(sta, vif, phy, bf); |
| 1418 | + mt7996_mcu_sta_bfer_eht(sta, conf->vif, phy, bf); |
| 1419 | else if (sta->deflink.he_cap.has_he && ebf) |
| 1420 | - mt7996_mcu_sta_bfer_he(sta, vif, phy, bf); |
| 1421 | + mt7996_mcu_sta_bfer_he(sta, conf->vif, phy, bf); |
| 1422 | else if (sta->deflink.vht_cap.vht_supported) |
| 1423 | mt7996_mcu_sta_bfer_vht(sta, phy, bf, ebf); |
| 1424 | else if (sta->deflink.ht_cap.ht_supported) |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1425 | @@ -1926,10 +1917,10 @@ mt7996_mcu_sta_bfer_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1426 | |
| 1427 | static void |
| 1428 | mt7996_mcu_sta_bfee_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
| 1429 | - struct ieee80211_vif *vif, struct ieee80211_sta *sta) |
| 1430 | + struct ieee80211_bss_conf *conf, |
| 1431 | + struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta) |
| 1432 | { |
| 1433 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1434 | - struct mt7996_phy *phy = mvif->phy; |
| 1435 | + struct mt7996_phy *phy = mconf->phy; |
| 1436 | int tx_ant = hweight8(phy->mt76->antenna_mask) - 1; |
| 1437 | struct sta_rec_bfee *bfee; |
| 1438 | struct tlv *tlv; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1439 | @@ -1938,7 +1929,7 @@ mt7996_mcu_sta_bfee_tlv(struct mt7996_dev *dev, struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1440 | if (!(sta->deflink.vht_cap.vht_supported || sta->deflink.he_cap.has_he)) |
| 1441 | return; |
| 1442 | |
| 1443 | - if (!mt7996_is_ebf_supported(phy, vif, sta, true)) |
| 1444 | + if (!mt7996_is_ebf_supported(phy, conf, mconf, sta, true)) |
| 1445 | return; |
| 1446 | |
| 1447 | tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_BFEE, sizeof(*bfee)); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1448 | @@ -2060,17 +2051,17 @@ int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1449 | MCU_WM_UNI_CMD(RA), true); |
| 1450 | } |
| 1451 | |
| 1452 | -int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 1453 | +int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev, |
| 1454 | + struct mt7996_bss_conf *mconf, |
| 1455 | struct ieee80211_sta *sta, void *data, u32 field) |
| 1456 | { |
| 1457 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1458 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 1459 | struct sta_phy_uni *phy = data; |
| 1460 | struct sta_rec_ra_fixed_uni *ra; |
| 1461 | struct sk_buff *skb; |
| 1462 | struct tlv *tlv; |
| 1463 | |
| 1464 | - skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, |
| 1465 | + skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, |
| 1466 | &msta->wcid, |
| 1467 | MT7996_STA_UPDATE_MAX_SIZE); |
| 1468 | if (IS_ERR(skb)) |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1469 | @@ -2102,12 +2093,13 @@ int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev, struct ieee80211_vif *vif |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1470 | } |
| 1471 | |
| 1472 | static int |
| 1473 | -mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 1474 | +mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, |
| 1475 | + struct ieee80211_bss_conf *conf, |
| 1476 | + struct mt7996_bss_conf *mconf, |
| 1477 | struct ieee80211_sta *sta) |
| 1478 | { |
| 1479 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1480 | - struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef; |
| 1481 | - struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask; |
| 1482 | + struct cfg80211_chan_def *chandef = &mconf->phy->mt76->chandef; |
| 1483 | + struct cfg80211_bitrate_mask *mask = &mconf->bitrate_mask; |
| 1484 | enum nl80211_band band = chandef->chan->band; |
| 1485 | struct sta_phy_uni phy = {}; |
| 1486 | int ret, nrates = 0; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1487 | @@ -2149,7 +2141,7 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, struct ieee80211_vif *vif |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1488 | |
| 1489 | /* fixed single rate */ |
| 1490 | if (nrates == 1) { |
| 1491 | - ret = mt7996_mcu_set_fixed_field(dev, vif, sta, &phy, |
| 1492 | + ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy, |
| 1493 | RATE_PARAM_FIXED_MCS); |
| 1494 | if (ret) |
| 1495 | return ret; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1496 | @@ -2171,7 +2163,7 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, struct ieee80211_vif *vif |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1497 | else |
| 1498 | mt76_rmw_field(dev, addr, GENMASK(15, 12), phy.sgi); |
| 1499 | |
| 1500 | - ret = mt7996_mcu_set_fixed_field(dev, vif, sta, &phy, |
| 1501 | + ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy, |
| 1502 | RATE_PARAM_FIXED_GI); |
| 1503 | if (ret) |
| 1504 | return ret; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1505 | @@ -2179,7 +2171,7 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, struct ieee80211_vif *vif |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1506 | |
| 1507 | /* fixed HE_LTF */ |
| 1508 | if (mask->control[band].he_ltf != GENMASK(7, 0)) { |
| 1509 | - ret = mt7996_mcu_set_fixed_field(dev, vif, sta, &phy, |
| 1510 | + ret = mt7996_mcu_set_fixed_field(dev, mconf, sta, &phy, |
| 1511 | RATE_PARAM_FIXED_HE_LTF); |
| 1512 | if (ret) |
| 1513 | return ret; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1514 | @@ -2190,13 +2182,14 @@ mt7996_mcu_add_rate_ctrl_fixed(struct mt7996_dev *dev, struct ieee80211_vif *vif |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1515 | |
| 1516 | static void |
| 1517 | mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev, |
| 1518 | - struct ieee80211_vif *vif, struct ieee80211_sta *sta) |
| 1519 | + struct ieee80211_bss_conf *conf, |
| 1520 | + struct mt7996_bss_conf *mconf, |
| 1521 | + struct ieee80211_sta *sta) |
| 1522 | { |
| 1523 | #define INIT_RCPI 180 |
| 1524 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1525 | - struct mt76_phy *mphy = mvif->phy->mt76; |
| 1526 | + struct mt76_phy *mphy = mconf->phy->mt76; |
| 1527 | struct cfg80211_chan_def *chandef = &mphy->chandef; |
| 1528 | - struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask; |
| 1529 | + struct cfg80211_bitrate_mask *mask = &mconf->bitrate_mask; |
| 1530 | enum nl80211_band band = chandef->chan->band; |
| 1531 | struct sta_rec_ra_uni *ra; |
| 1532 | struct tlv *tlv; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1533 | @@ -2208,7 +2201,7 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1534 | |
| 1535 | ra->valid = true; |
| 1536 | ra->auto_rate = true; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1537 | - ra->phy_mode = mt76_connac_get_phy_mode(mphy, vif, band, &sta->deflink); |
| 1538 | + ra->phy_mode = mt76_connac_get_phy_mode(mphy, conf->vif, band, &sta->deflink); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1539 | ra->channel = chandef->chan->hw_value; |
| 1540 | ra->bw = (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_320) ? |
| 1541 | CMD_CBW_320MHZ : sta->deflink.bandwidth; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1542 | @@ -2247,7 +2240,7 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1543 | cap |= STA_CAP_TX_STBC; |
| 1544 | if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_RX_STBC) |
| 1545 | cap |= STA_CAP_RX_STBC; |
| 1546 | - if (vif->bss_conf.ht_ldpc && |
| 1547 | + if (conf->ht_ldpc && |
| 1548 | (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING)) |
| 1549 | cap |= STA_CAP_LDPC; |
| 1550 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1551 | @@ -2273,7 +2266,7 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1552 | cap |= STA_CAP_VHT_TX_STBC; |
| 1553 | if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXSTBC_1) |
| 1554 | cap |= STA_CAP_VHT_RX_STBC; |
| 1555 | - if (vif->bss_conf.vht_ldpc && |
| 1556 | + if (conf->vht_ldpc && |
| 1557 | (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC)) |
| 1558 | cap |= STA_CAP_VHT_LDPC; |
| 1559 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1560 | @@ -2294,15 +2287,16 @@ mt7996_mcu_sta_rate_ctrl_tlv(struct sk_buff *skb, struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1561 | memset(ra->rx_rcpi, INIT_RCPI, sizeof(ra->rx_rcpi)); |
| 1562 | } |
| 1563 | |
| 1564 | -int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 1565 | +int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, |
| 1566 | + struct ieee80211_bss_conf *conf, |
| 1567 | + struct mt7996_bss_conf *mconf, |
| 1568 | struct ieee80211_sta *sta, bool changed) |
| 1569 | { |
| 1570 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1571 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 1572 | struct sk_buff *skb; |
| 1573 | int ret; |
| 1574 | |
| 1575 | - skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, |
| 1576 | + skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, |
| 1577 | &msta->wcid, |
| 1578 | MT7996_STA_UPDATE_MAX_SIZE); |
| 1579 | if (IS_ERR(skb)) |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1580 | @@ -2313,26 +2307,27 @@ int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1581 | * update sta_rec_he here. |
| 1582 | */ |
| 1583 | if (changed) |
| 1584 | - mt7996_mcu_sta_he_tlv(skb, vif, sta); |
| 1585 | + mt7996_mcu_sta_he_tlv(skb, conf, mconf, sta); |
| 1586 | |
| 1587 | /* sta_rec_ra accommodates BW, NSS and only MCS range format |
| 1588 | * i.e 0-{7,8,9} for VHT. |
| 1589 | */ |
| 1590 | - mt7996_mcu_sta_rate_ctrl_tlv(skb, dev, vif, sta); |
| 1591 | + mt7996_mcu_sta_rate_ctrl_tlv(skb, dev, conf, mconf, sta); |
| 1592 | |
| 1593 | ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, |
| 1594 | MCU_WMWA_UNI_CMD(STA_REC_UPDATE), true); |
| 1595 | if (ret) |
| 1596 | return ret; |
| 1597 | |
| 1598 | - return mt7996_mcu_add_rate_ctrl_fixed(dev, vif, sta); |
| 1599 | + return mt7996_mcu_add_rate_ctrl_fixed(dev, conf, mconf, sta); |
| 1600 | } |
| 1601 | |
| 1602 | static int |
| 1603 | -mt7996_mcu_sta_init_vow(struct mt7996_phy *phy, struct mt7996_sta *msta) |
| 1604 | +mt7996_mcu_sta_init_vow(struct mt7996_bss_conf *mconf, struct mt7996_sta *msta) |
| 1605 | { |
| 1606 | + struct mt7996_phy *phy = mconf->phy; |
| 1607 | struct mt7996_vow_sta_ctrl *vow = &msta->vow; |
| 1608 | - u8 omac_idx = msta->vif->mt76.omac_idx; |
| 1609 | + u8 omac_idx = mconf->mt76.omac_idx; |
| 1610 | int ret; |
| 1611 | |
| 1612 | /* Assignment of STA BSS group index aligns FW. |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1613 | @@ -2349,20 +2344,22 @@ mt7996_mcu_sta_init_vow(struct mt7996_phy *phy, struct mt7996_sta *msta) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1614 | vow->drr_quantum[IEEE80211_AC_BE] = VOW_DRR_QUANTUM_IDX2; |
| 1615 | vow->drr_quantum[IEEE80211_AC_BK] = VOW_DRR_QUANTUM_IDX2; |
| 1616 | |
| 1617 | - ret = mt7996_mcu_set_vow_drr_ctrl(phy, msta, VOW_DRR_CTRL_STA_BSS_GROUP); |
| 1618 | + ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_BSS_GROUP); |
| 1619 | if (ret) |
| 1620 | return ret; |
| 1621 | |
| 1622 | - ret = mt7996_mcu_set_vow_drr_ctrl(phy, msta, VOW_DRR_CTRL_STA_PAUSE); |
| 1623 | + ret = mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_PAUSE); |
| 1624 | if (ret) |
| 1625 | return ret; |
| 1626 | |
| 1627 | - return mt7996_mcu_set_vow_drr_ctrl(phy, msta, VOW_DRR_CTRL_STA_ALL); |
| 1628 | + return mt7996_mcu_set_vow_drr_ctrl(phy, mconf, msta, VOW_DRR_CTRL_STA_ALL); |
| 1629 | } |
| 1630 | |
| 1631 | -int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 1632 | - struct ieee80211_sta *sta, bool enable, bool newly) |
| 1633 | +int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf, |
| 1634 | + struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta, |
| 1635 | + bool enable, bool newly) |
| 1636 | { |
| 1637 | + struct ieee80211_vif *vif = conf->vif; |
| 1638 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1639 | struct ieee80211_link_sta *link_sta; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1640 | struct mt7996_sta *msta; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1641 | @@ -2373,7 +2370,7 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1642 | msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->sta; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1643 | link_sta = sta ? &sta->deflink : NULL; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1644 | |
| 1645 | - skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, |
| 1646 | + skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, |
| 1647 | &msta->wcid, |
| 1648 | MT7996_STA_UPDATE_MAX_SIZE); |
| 1649 | if (IS_ERR(skb)) |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1650 | @@ -2397,7 +2394,7 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1651 | /* starec hdrt mode */ |
| 1652 | mt7996_mcu_sta_hdrt_tlv(dev, skb); |
| 1653 | /* starec bfer */ |
| 1654 | - mt7996_mcu_sta_bfer_tlv(dev, skb, vif, sta); |
| 1655 | + mt7996_mcu_sta_bfer_tlv(dev, skb, conf, mconf, sta); |
| 1656 | /* starec ht */ |
| 1657 | mt7996_mcu_sta_ht_tlv(skb, sta); |
| 1658 | /* starec vht */ |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1659 | @@ -2407,18 +2404,18 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1660 | /* starec amsdu */ |
| 1661 | mt7996_mcu_sta_amsdu_tlv(dev, skb, vif, sta); |
| 1662 | /* starec he */ |
| 1663 | - mt7996_mcu_sta_he_tlv(skb, vif, sta); |
| 1664 | + mt7996_mcu_sta_he_tlv(skb, conf, mconf, sta); |
| 1665 | /* starec he 6g*/ |
| 1666 | mt7996_mcu_sta_he_6g_tlv(skb, sta); |
| 1667 | /* starec eht */ |
| 1668 | mt7996_mcu_sta_eht_tlv(skb, sta); |
| 1669 | /* starec muru */ |
| 1670 | - mt7996_mcu_sta_muru_tlv(dev, skb, vif, sta); |
| 1671 | + mt7996_mcu_sta_muru_tlv(dev, skb, conf, mconf, sta); |
| 1672 | /* starec bfee */ |
| 1673 | - mt7996_mcu_sta_bfee_tlv(dev, skb, vif, sta); |
| 1674 | + mt7996_mcu_sta_bfee_tlv(dev, skb, conf, mconf, sta); |
| 1675 | } |
| 1676 | |
| 1677 | - ret = mt7996_mcu_sta_init_vow(mvif->phy, msta); |
| 1678 | + ret = mt7996_mcu_sta_init_vow(mconf, msta); |
| 1679 | if (ret) { |
| 1680 | dev_kfree_skb(skb); |
| 1681 | return ret; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1682 | @@ -2473,16 +2470,15 @@ mt7996_mcu_sta_key_tlv(struct mt76_wcid *wcid, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1683 | return 0; |
| 1684 | } |
| 1685 | |
| 1686 | -int mt7996_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 1687 | +int mt7996_mcu_add_key(struct mt76_dev *dev, struct mt7996_bss_conf *mconf, |
| 1688 | struct ieee80211_key_conf *key, int mcu_cmd, |
| 1689 | struct mt76_wcid *wcid, enum set_key_cmd cmd) |
| 1690 | { |
| 1691 | - struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; |
| 1692 | struct sk_buff *skb; |
| 1693 | int ret; |
| 1694 | |
| 1695 | - skb = __mt76_connac_mcu_alloc_sta_req(dev, mvif, wcid, |
| 1696 | - MT7996_STA_UPDATE_MAX_SIZE); |
| 1697 | + skb = __mt76_connac_mcu_alloc_sta_req(dev, (struct mt76_vif *)mconf, |
| 1698 | + wcid, MT7996_STA_UPDATE_MAX_SIZE); |
| 1699 | if (IS_ERR(skb)) |
| 1700 | return PTR_ERR(skb); |
| 1701 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1702 | @@ -2493,17 +2489,18 @@ int mt7996_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1703 | return mt76_mcu_skb_send_msg(dev, skb, mcu_cmd, true); |
| 1704 | } |
| 1705 | |
| 1706 | -static int mt7996_mcu_get_pn(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 1707 | - u8 *pn) |
| 1708 | +static int mt7996_mcu_get_pn(struct mt7996_dev *dev, |
| 1709 | + struct ieee80211_bss_conf *conf, |
| 1710 | + struct mt7996_bss_conf *mconf, u8 *pn) |
| 1711 | { |
| 1712 | #define TSC_TYPE_BIGTK_PN 2 |
| 1713 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1714 | + struct mt7996_vif *mvif = (struct mt7996_vif *)conf->vif->drv_priv; |
| 1715 | struct sta_rec_pn_info *pn_info; |
| 1716 | struct sk_buff *skb, *rskb; |
| 1717 | struct tlv *tlv; |
| 1718 | int ret; |
| 1719 | |
| 1720 | - skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, &mvif->sta.wcid); |
| 1721 | + skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, &mvif->sta.wcid); |
| 1722 | if (IS_ERR(skb)) |
| 1723 | return PTR_ERR(skb); |
| 1724 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1725 | @@ -2527,10 +2524,11 @@ static int mt7996_mcu_get_pn(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1726 | return 0; |
| 1727 | } |
| 1728 | |
| 1729 | -int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 1730 | +int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, |
| 1731 | + struct ieee80211_bss_conf *conf, |
| 1732 | + struct mt7996_bss_conf *mconf, |
| 1733 | struct ieee80211_key_conf *key) |
| 1734 | { |
| 1735 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1736 | struct mt7996_mcu_bcn_prot_tlv *bcn_prot; |
| 1737 | struct sk_buff *skb; |
| 1738 | struct tlv *tlv; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1739 | @@ -2539,7 +2537,7 @@ int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, struct ieee80211_vif *vif |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1740 | sizeof(struct mt7996_mcu_bcn_prot_tlv); |
| 1741 | int ret; |
| 1742 | |
| 1743 | - skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, len); |
| 1744 | + skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76, len); |
| 1745 | if (IS_ERR(skb)) |
| 1746 | return PTR_ERR(skb); |
| 1747 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1748 | @@ -2547,7 +2545,7 @@ int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, struct ieee80211_vif *vif |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1749 | |
| 1750 | bcn_prot = (struct mt7996_mcu_bcn_prot_tlv *)tlv; |
| 1751 | |
| 1752 | - ret = mt7996_mcu_get_pn(dev, vif, pn); |
| 1753 | + ret = mt7996_mcu_get_pn(dev, conf, mconf, pn); |
| 1754 | if (ret) { |
| 1755 | dev_kfree_skb(skb); |
| 1756 | return ret; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1757 | @@ -2580,10 +2578,10 @@ int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, struct ieee80211_vif *vif |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1758 | MCU_WMWA_UNI_CMD(BSS_INFO_UPDATE), true); |
| 1759 | } |
| 1760 | int mt7996_mcu_add_dev_info(struct mt7996_phy *phy, |
| 1761 | - struct ieee80211_vif *vif, bool enable) |
| 1762 | + struct ieee80211_bss_conf *conf, |
| 1763 | + struct mt7996_bss_conf *mconf, bool enable) |
| 1764 | { |
| 1765 | struct mt7996_dev *dev = phy->dev; |
| 1766 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1767 | struct { |
| 1768 | struct req_hdr { |
| 1769 | u8 omac_idx; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1770 | @@ -2599,8 +2597,8 @@ int mt7996_mcu_add_dev_info(struct mt7996_phy *phy, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1771 | } __packed tlv; |
| 1772 | } data = { |
| 1773 | .hdr = { |
| 1774 | - .omac_idx = mvif->mt76.omac_idx, |
| 1775 | - .band_idx = mvif->mt76.band_idx, |
| 1776 | + .omac_idx = mconf->mt76.omac_idx, |
| 1777 | + .band_idx = mconf->mt76.band_idx, |
| 1778 | }, |
| 1779 | .tlv = { |
| 1780 | .tag = cpu_to_le16(DEV_INFO_ACTIVE), |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1781 | @@ -2609,16 +2607,16 @@ int mt7996_mcu_add_dev_info(struct mt7996_phy *phy, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1782 | }, |
| 1783 | }; |
| 1784 | |
| 1785 | - if (mvif->mt76.omac_idx >= REPEATER_BSSID_START) |
| 1786 | - return mt7996_mcu_muar_config(phy, vif, false, enable); |
| 1787 | + if (mconf->mt76.omac_idx >= REPEATER_BSSID_START) |
| 1788 | + return mt7996_mcu_muar_config(phy, conf, mconf, false, enable); |
| 1789 | |
| 1790 | - memcpy(data.tlv.omac_addr, vif->addr, ETH_ALEN); |
| 1791 | + memcpy(data.tlv.omac_addr, conf->addr, ETH_ALEN); |
| 1792 | return mt76_mcu_send_msg(&dev->mt76, MCU_WMWA_UNI_CMD(DEV_INFO_UPDATE), |
| 1793 | &data, sizeof(data), true); |
| 1794 | } |
| 1795 | |
| 1796 | static void |
| 1797 | -mt7996_mcu_beacon_cntdwn(struct ieee80211_vif *vif, struct sk_buff *rskb, |
| 1798 | +mt7996_mcu_beacon_cntdwn(struct ieee80211_bss_conf *conf, struct sk_buff *rskb, |
| 1799 | struct sk_buff *skb, |
| 1800 | struct ieee80211_mutable_offsets *offs) |
| 1801 | { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1802 | @@ -2629,7 +2627,7 @@ mt7996_mcu_beacon_cntdwn(struct ieee80211_vif *vif, struct sk_buff *rskb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1803 | if (!offs->cntdwn_counter_offs[0]) |
| 1804 | return; |
| 1805 | |
| 1806 | - tag = vif->bss_conf.csa_active ? UNI_BSS_INFO_BCN_CSA : UNI_BSS_INFO_BCN_BCC; |
| 1807 | + tag = conf->csa_active ? UNI_BSS_INFO_BCN_CSA : UNI_BSS_INFO_BCN_BCC; |
| 1808 | |
| 1809 | tlv = mt7996_mcu_add_uni_tlv(rskb, tag, sizeof(*info)); |
| 1810 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1811 | @@ -2639,14 +2637,15 @@ mt7996_mcu_beacon_cntdwn(struct ieee80211_vif *vif, struct sk_buff *rskb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1812 | |
| 1813 | static void |
| 1814 | mt7996_mcu_beacon_mbss(struct sk_buff *rskb, struct sk_buff *skb, |
| 1815 | - struct ieee80211_vif *vif, struct bss_bcn_content_tlv *bcn, |
| 1816 | + struct ieee80211_bss_conf *conf, |
| 1817 | + struct bss_bcn_content_tlv *bcn, |
| 1818 | struct ieee80211_mutable_offsets *offs) |
| 1819 | { |
| 1820 | struct bss_bcn_mbss_tlv *mbss; |
| 1821 | const struct element *elem; |
| 1822 | struct tlv *tlv; |
| 1823 | |
| 1824 | - if (!vif->bss_conf.bssid_indicator) |
| 1825 | + if (!conf->bssid_indicator) |
| 1826 | return; |
| 1827 | |
| 1828 | tlv = mt7996_mcu_add_uni_tlv(rskb, UNI_BSS_INFO_BCN_MBSSID, sizeof(*mbss)); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1829 | @@ -2691,7 +2690,7 @@ mt7996_mcu_beacon_mbss(struct sk_buff *rskb, struct sk_buff *skb, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1830 | } |
| 1831 | |
| 1832 | static void |
| 1833 | -mt7996_mcu_beacon_cont(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 1834 | +mt7996_mcu_beacon_cont(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf, |
| 1835 | struct sk_buff *rskb, struct sk_buff *skb, |
| 1836 | struct bss_bcn_content_tlv *bcn, |
| 1837 | struct ieee80211_mutable_offsets *offs) |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1838 | @@ -2705,9 +2704,9 @@ mt7996_mcu_beacon_cont(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1839 | if (offs->cntdwn_counter_offs[0]) { |
| 1840 | u16 offset = offs->cntdwn_counter_offs[0]; |
| 1841 | |
| 1842 | - if (vif->bss_conf.csa_active) |
| 1843 | + if (conf->csa_active) |
| 1844 | bcn->csa_ie_pos = cpu_to_le16(offset - 4); |
| 1845 | - if (vif->bss_conf.color_change_active) |
| 1846 | + if (conf->color_change_active) |
| 1847 | bcn->bcc_ie_pos = cpu_to_le16(offset - 3); |
| 1848 | } |
| 1849 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1850 | @@ -2719,11 +2718,11 @@ mt7996_mcu_beacon_cont(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1851 | } |
| 1852 | |
| 1853 | int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, |
| 1854 | - struct ieee80211_vif *vif, int en) |
| 1855 | + struct ieee80211_bss_conf *conf, |
| 1856 | + struct mt7996_bss_conf *mconf, int en) |
| 1857 | { |
| 1858 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 1859 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 1860 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1861 | struct ieee80211_mutable_offsets offs; |
| 1862 | struct ieee80211_tx_info *info; |
| 1863 | struct sk_buff *skb, *rskb; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1864 | @@ -2731,15 +2730,15 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1865 | struct bss_bcn_content_tlv *bcn; |
| 1866 | int len; |
| 1867 | |
| 1868 | - if (vif->bss_conf.nontransmitted) |
| 1869 | + if (conf->nontransmitted) |
| 1870 | return 0; |
| 1871 | |
| 1872 | - rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, |
| 1873 | + rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76, |
| 1874 | MT7996_MAX_BSS_OFFLOAD_SIZE); |
| 1875 | if (IS_ERR(rskb)) |
| 1876 | return PTR_ERR(rskb); |
| 1877 | |
| 1878 | - skb = ieee80211_beacon_get_template(hw, vif, &offs, 0); |
| 1879 | + skb = ieee80211_beacon_get_template(hw, conf->vif, &offs, 0); |
| 1880 | if (!skb) { |
| 1881 | dev_kfree_skb(rskb); |
| 1882 | return -EINVAL; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1883 | @@ -2762,9 +2761,9 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1884 | if (!en) |
| 1885 | goto out; |
| 1886 | |
| 1887 | - mt7996_mcu_beacon_cont(dev, vif, rskb, skb, bcn, &offs); |
| 1888 | - mt7996_mcu_beacon_mbss(rskb, skb, vif, bcn, &offs); |
| 1889 | - mt7996_mcu_beacon_cntdwn(vif, rskb, skb, &offs); |
| 1890 | + mt7996_mcu_beacon_cont(dev, conf, rskb, skb, bcn, &offs); |
| 1891 | + mt7996_mcu_beacon_mbss(rskb, skb, conf, bcn, &offs); |
| 1892 | + mt7996_mcu_beacon_cntdwn(conf, rskb, skb, &offs); |
| 1893 | out: |
| 1894 | dev_kfree_skb(skb); |
| 1895 | return mt76_mcu_skb_send_msg(&phy->dev->mt76, rskb, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1896 | @@ -2772,14 +2771,15 @@ out: |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1897 | } |
| 1898 | |
| 1899 | int mt7996_mcu_beacon_inband_discov(struct mt7996_dev *dev, |
| 1900 | - struct ieee80211_vif *vif, u32 changed) |
| 1901 | + struct ieee80211_bss_conf *conf, |
| 1902 | + struct mt7996_bss_conf *mconf, u32 changed) |
| 1903 | { |
| 1904 | #define OFFLOAD_TX_MODE_SU BIT(0) |
| 1905 | #define OFFLOAD_TX_MODE_MU BIT(1) |
| 1906 | struct ieee80211_hw *hw = mt76_hw(dev); |
| 1907 | + struct ieee80211_vif *vif = conf->vif; |
| 1908 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 1909 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1910 | - struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef; |
| 1911 | + struct cfg80211_chan_def *chandef = &mconf->phy->mt76->chandef; |
| 1912 | enum nl80211_band band = chandef->chan->band; |
| 1913 | struct mt76_wcid *wcid = &dev->mt76.global_wcid; |
| 1914 | struct bss_inband_discovery_tlv *discov; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1915 | @@ -2789,20 +2789,20 @@ int mt7996_mcu_beacon_inband_discov(struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1916 | u8 *buf, interval; |
| 1917 | int len; |
| 1918 | |
| 1919 | - if (vif->bss_conf.nontransmitted) |
| 1920 | + if (conf->nontransmitted) |
| 1921 | return 0; |
| 1922 | |
| 1923 | - rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, |
| 1924 | + rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76, |
| 1925 | MT7996_MAX_BSS_OFFLOAD_SIZE); |
| 1926 | if (IS_ERR(rskb)) |
| 1927 | return PTR_ERR(rskb); |
| 1928 | |
| 1929 | if (changed & BSS_CHANGED_FILS_DISCOVERY) { |
| 1930 | - interval = vif->bss_conf.fils_discovery.max_interval; |
| 1931 | + interval = conf->fils_discovery.max_interval; |
| 1932 | skb = ieee80211_get_fils_discovery_tmpl(hw, vif); |
| 1933 | } else if (changed & BSS_CHANGED_UNSOL_BCAST_PROBE_RESP && |
| 1934 | - vif->bss_conf.unsol_bcast_probe_resp_interval) { |
| 1935 | - interval = vif->bss_conf.unsol_bcast_probe_resp_interval; |
| 1936 | + conf->unsol_bcast_probe_resp_interval) { |
| 1937 | + interval = conf->unsol_bcast_probe_resp_interval; |
| 1938 | skb = ieee80211_get_unsol_bcast_probe_resp_tmpl(hw, vif); |
| 1939 | } |
| 1940 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1941 | @@ -3467,7 +3467,7 @@ int mt7996_mcu_set_hdr_trans(struct mt7996_dev *dev, bool hdr_trans) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1942 | MCU_WM_UNI_CMD(RX_HDR_TRANS), true); |
| 1943 | } |
| 1944 | |
| 1945 | -int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct ieee80211_vif *vif) |
| 1946 | +int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct mt7996_bss_conf *mconf) |
| 1947 | { |
| 1948 | #define MCU_EDCA_AC_PARAM 0 |
| 1949 | #define WMM_AIFS_SET BIT(0) |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1950 | @@ -3476,12 +3476,11 @@ int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct ieee80211_vif *vif) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1951 | #define WMM_TXOP_SET BIT(3) |
| 1952 | #define WMM_PARAM_SET (WMM_AIFS_SET | WMM_CW_MIN_SET | \ |
| 1953 | WMM_CW_MAX_SET | WMM_TXOP_SET) |
| 1954 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1955 | struct { |
| 1956 | u8 bss_idx; |
| 1957 | u8 __rsv[3]; |
| 1958 | } __packed hdr = { |
| 1959 | - .bss_idx = mvif->mt76.idx, |
| 1960 | + .bss_idx = mconf->mt76.idx, |
| 1961 | }; |
| 1962 | struct sk_buff *skb; |
| 1963 | int len = sizeof(hdr) + IEEE80211_NUM_ACS * sizeof(struct edca); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1964 | @@ -3494,7 +3493,7 @@ int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct ieee80211_vif *vif) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1965 | skb_put_data(skb, &hdr, sizeof(hdr)); |
| 1966 | |
| 1967 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { |
| 1968 | - struct ieee80211_tx_queue_params *q = &mvif->queue_params[ac]; |
| 1969 | + struct ieee80211_tx_queue_params *q = &mconf->queue_params[ac]; |
| 1970 | struct edca *e; |
| 1971 | struct tlv *tlv; |
| 1972 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1973 | @@ -4525,12 +4524,12 @@ mt7996_mcu_set_obss_spr_pd(struct mt7996_phy *phy, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1974 | } |
| 1975 | |
| 1976 | static int |
| 1977 | -mt7996_mcu_set_obss_spr_siga(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
| 1978 | +mt7996_mcu_set_obss_spr_siga(struct mt7996_phy *phy, |
| 1979 | + struct mt7996_bss_conf *mconf, |
| 1980 | struct ieee80211_he_obss_pd *he_obss_pd) |
| 1981 | { |
| 1982 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 1983 | struct mt7996_dev *dev = phy->dev; |
| 1984 | - u8 omac = mvif->mt76.omac_idx; |
| 1985 | + u8 omac = mconf->mt76.omac_idx; |
| 1986 | struct { |
| 1987 | u8 band_idx; |
| 1988 | u8 __rsv[3]; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1989 | @@ -4602,7 +4601,8 @@ mt7996_mcu_set_obss_spr_bitmap(struct mt7996_phy *phy, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1990 | sizeof(req), true); |
| 1991 | } |
| 1992 | |
| 1993 | -int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
| 1994 | +int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy, |
| 1995 | + struct mt7996_bss_conf *mconf, |
| 1996 | struct ieee80211_he_obss_pd *he_obss_pd) |
| 1997 | { |
| 1998 | int ret; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 1999 | @@ -4636,7 +4636,7 @@ int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2000 | return ret; |
| 2001 | |
| 2002 | /* Set SR prohibit */ |
| 2003 | - ret = mt7996_mcu_set_obss_spr_siga(phy, vif, he_obss_pd); |
| 2004 | + ret = mt7996_mcu_set_obss_spr_siga(phy, mconf, he_obss_pd); |
| 2005 | if (ret) |
| 2006 | return ret; |
| 2007 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2008 | @@ -4644,16 +4644,16 @@ int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2009 | return mt7996_mcu_set_obss_spr_bitmap(phy, he_obss_pd); |
| 2010 | } |
| 2011 | |
| 2012 | -int mt7996_mcu_update_bss_color(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 2013 | +int mt7996_mcu_update_bss_color(struct mt7996_dev *dev, |
| 2014 | + struct mt7996_bss_conf *mconf, |
| 2015 | struct cfg80211_he_bss_color *he_bss_color) |
| 2016 | { |
| 2017 | int len = sizeof(struct bss_req_hdr) + sizeof(struct bss_color_tlv); |
| 2018 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 2019 | struct bss_color_tlv *bss_color; |
| 2020 | struct sk_buff *skb; |
| 2021 | struct tlv *tlv; |
| 2022 | |
| 2023 | - skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, len); |
| 2024 | + skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mconf->mt76, len); |
| 2025 | if (IS_ERR(skb)) |
| 2026 | return PTR_ERR(skb); |
| 2027 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2028 | @@ -4672,7 +4672,7 @@ int mt7996_mcu_update_bss_color(struct mt7996_dev *dev, struct ieee80211_vif *vi |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2029 | #define TWT_AGRT_PROTECT BIT(2) |
| 2030 | |
| 2031 | int mt7996_mcu_twt_agrt_update(struct mt7996_dev *dev, |
| 2032 | - struct mt7996_vif *mvif, |
| 2033 | + struct mt7996_bss_conf *mconf, |
| 2034 | struct mt7996_twt_flow *flow, |
| 2035 | int cmd) |
| 2036 | { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2037 | @@ -4703,12 +4703,12 @@ int mt7996_mcu_twt_agrt_update(struct mt7996_dev *dev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2038 | .len = cpu_to_le16(sizeof(req) - 4), |
| 2039 | .tbl_idx = flow->table_id, |
| 2040 | .cmd = cmd, |
| 2041 | - .own_mac_idx = mvif->mt76.omac_idx, |
| 2042 | + .own_mac_idx = mconf->mt76.omac_idx, |
| 2043 | .flowid = flow->id, |
| 2044 | .peer_id = cpu_to_le16(flow->wcid), |
| 2045 | .duration = flow->duration, |
| 2046 | - .bss = mvif->mt76.idx, |
| 2047 | - .bss_idx = mvif->mt76.idx, |
| 2048 | + .bss = mconf->mt76.idx, |
| 2049 | + .bss_idx = mconf->mt76.idx, |
| 2050 | .start_tsf = cpu_to_le64(flow->tsf), |
| 2051 | .mantissa = flow->mantissa, |
| 2052 | .exponent = flow->exp, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2053 | @@ -4839,15 +4839,15 @@ int mt7996_mcu_rdd_background_disable_timer(struct mt7996_dev *dev, bool disable |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2054 | |
| 2055 | int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev, |
| 2056 | struct ieee80211_vif *vif, |
| 2057 | + struct mt7996_bss_conf *mconf, |
| 2058 | struct ieee80211_sta *sta) |
| 2059 | { |
| 2060 | - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 2061 | struct mt7996_sta *msta; |
| 2062 | struct sk_buff *skb; |
| 2063 | |
| 2064 | - msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->sta; |
| 2065 | + msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mconf->vif->sta; |
| 2066 | |
| 2067 | - skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, |
| 2068 | + skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mconf->mt76, |
| 2069 | &msta->wcid, |
| 2070 | MT7996_STA_UPDATE_MAX_SIZE); |
| 2071 | if (IS_ERR(skb)) |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2072 | @@ -5475,8 +5475,9 @@ int mt7996_mcu_set_scs(struct mt7996_phy *phy, u8 enable) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2073 | &req, sizeof(req), false); |
| 2074 | } |
| 2075 | |
| 2076 | -int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy, struct mt7996_sta *msta, |
| 2077 | - enum vow_drr_ctrl_id id) |
| 2078 | +int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy, |
| 2079 | + struct mt7996_bss_conf *mconf, |
| 2080 | + struct mt7996_sta *msta, enum vow_drr_ctrl_id id) |
| 2081 | { |
| 2082 | struct mt7996_vow_sta_ctrl *vow = msta ? &msta->vow : NULL; |
| 2083 | u32 val = 0; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2084 | @@ -5502,9 +5503,9 @@ int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy, struct mt7996_sta *msta, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2085 | .len = cpu_to_le16(sizeof(req) - 4), |
| 2086 | .wlan_idx = cpu_to_le16(msta ? msta->wcid.idx : 0), |
| 2087 | .band_idx = phy->mt76->band_idx, |
| 2088 | - .wmm_idx = msta ? msta->vif->mt76.wmm_idx : 0, |
| 2089 | + .wmm_idx = msta ? mconf->mt76.wmm_idx : 0, |
| 2090 | .ctrl_id = cpu_to_le32(id), |
| 2091 | - .omac_idx = msta ? msta->vif->mt76.omac_idx : 0 |
| 2092 | + .omac_idx = msta ? mconf->mt76.omac_idx : 0 |
| 2093 | }; |
| 2094 | |
| 2095 | switch (id) { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2096 | @@ -5692,7 +5693,7 @@ void mt7996_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2097 | { |
| 2098 | u8 mode, val; |
| 2099 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 2100 | - struct mt7996_phy *phy = mvif->phy; |
| 2101 | + struct mt7996_phy *phy = mvif->deflink.phy; |
| 2102 | |
| 2103 | mode = FIELD_GET(RATE_CFG_MODE, *((u32 *)data)); |
| 2104 | val = FIELD_GET(RATE_CFG_VAL, *((u32 *)data)); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2105 | @@ -5723,11 +5724,11 @@ void mt7996_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2106 | void mt7996_set_beacon_vif(void *data, u8 *mac, struct ieee80211_vif *vif) |
| 2107 | { |
| 2108 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 2109 | - struct ieee80211_hw *hw = mvif->phy->mt76->hw; |
| 2110 | + struct ieee80211_hw *hw = mvif->deflink.phy->mt76->hw; |
| 2111 | u8 val = *((u8 *)data); |
| 2112 | |
| 2113 | vif->bss_conf.enable_beacon = val; |
| 2114 | |
| 2115 | - mt7996_mcu_add_beacon(hw, vif, val); |
| 2116 | + mt7996_mcu_add_beacon(hw, &vif->bss_conf, &mvif->deflink, val); |
| 2117 | } |
| 2118 | #endif |
| 2119 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 2120 | index 7d416f3..be966c1 100644 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2121 | --- a/mt7996/mt7996.h |
| 2122 | +++ b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2123 | @@ -326,18 +326,25 @@ struct mt7996_sta { |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2124 | struct mt7996_vow_sta_ctrl vow; |
| 2125 | }; |
| 2126 | |
| 2127 | -struct mt7996_vif { |
| 2128 | +struct mt7996_bss_conf { |
| 2129 | struct mt76_vif mt76; /* must be first */ |
| 2130 | |
| 2131 | - struct mt7996_sta sta; |
| 2132 | + struct mt7996_vif *vif; |
| 2133 | struct mt7996_phy *phy; |
| 2134 | - |
| 2135 | struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS]; |
| 2136 | struct cfg80211_bitrate_mask bitrate_mask; |
| 2137 | |
| 2138 | struct mt7996_chanctx *chanctx; |
| 2139 | }; |
| 2140 | |
| 2141 | +struct mt7996_vif { |
| 2142 | + struct mt7996_bss_conf deflink; |
| 2143 | + struct mt7996_bss_conf __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS]; |
| 2144 | + |
| 2145 | + struct mt7996_sta sta; |
| 2146 | + struct mt7996_dev *dev; |
| 2147 | +}; |
| 2148 | + |
| 2149 | /* crash-dump */ |
| 2150 | struct mt7996_crash_data { |
| 2151 | guid_t guid; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2152 | @@ -774,6 +781,13 @@ mt7996_chanctx_get(struct ieee80211_chanctx_conf *ctx) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2153 | return (struct mt7996_chanctx *)&ctx->drv_priv; |
| 2154 | } |
| 2155 | |
| 2156 | +static inline struct mt7996_bss_conf * |
| 2157 | +mconf_dereference_protected(struct mt7996_vif *mvif, u8 link_id) |
| 2158 | +{ |
| 2159 | + return rcu_dereference_protected(mvif->link[link_id], |
| 2160 | + lockdep_is_held(&mvif->dev->mt76.mutex)); |
| 2161 | +} |
| 2162 | + |
| 2163 | extern const struct ieee80211_ops mt7996_ops; |
| 2164 | extern struct pci_driver mt7996_pci_driver; |
| 2165 | extern struct pci_driver mt7996_hif_driver; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2166 | @@ -784,7 +798,7 @@ struct mt7996_dev *mt7996_mmio_probe(struct device *pdev, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2167 | void mt7996_wfsys_reset(struct mt7996_dev *dev); |
| 2168 | void mt7996_rro_hw_init(struct mt7996_dev *dev); |
| 2169 | irqreturn_t mt7996_irq_handler(int irq, void *dev_instance); |
| 2170 | -u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif *mvif); |
| 2171 | +u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_bss_conf *mconf); |
| 2172 | int mt7996_register_device(struct mt7996_dev *dev); |
| 2173 | void mt7996_unregister_device(struct mt7996_dev *dev); |
| 2174 | const char *mt7996_eeprom_name(struct mt7996_dev *dev); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2175 | @@ -810,37 +824,47 @@ int mt7996_run(struct ieee80211_hw *hw); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2176 | int mt7996_mcu_init(struct mt7996_dev *dev); |
| 2177 | int mt7996_mcu_init_firmware(struct mt7996_dev *dev); |
| 2178 | int mt7996_mcu_twt_agrt_update(struct mt7996_dev *dev, |
| 2179 | - struct mt7996_vif *mvif, |
| 2180 | + struct mt7996_bss_conf *mconf, |
| 2181 | struct mt7996_twt_flow *flow, |
| 2182 | int cmd); |
| 2183 | int mt7996_mcu_add_dev_info(struct mt7996_phy *phy, |
| 2184 | - struct ieee80211_vif *vif, bool enable); |
| 2185 | + struct ieee80211_bss_conf *conf, |
| 2186 | + struct mt7996_bss_conf *mconf, bool enable); |
| 2187 | int mt7996_mcu_add_bss_info(struct mt7996_phy *phy, |
| 2188 | - struct ieee80211_vif *vif, int enable); |
| 2189 | -int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 2190 | - struct ieee80211_sta *sta, bool enable, bool newly); |
| 2191 | + struct ieee80211_bss_conf *conf, |
| 2192 | + struct mt7996_bss_conf *mconf, int enable); |
| 2193 | +int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_bss_conf *conf, |
| 2194 | + struct mt7996_bss_conf *mconf, struct ieee80211_sta *sta, |
| 2195 | + bool enable, bool newly); |
| 2196 | int mt7996_mcu_add_tx_ba(struct mt7996_dev *dev, |
| 2197 | struct ieee80211_ampdu_params *params, |
| 2198 | bool add); |
| 2199 | int mt7996_mcu_add_rx_ba(struct mt7996_dev *dev, |
| 2200 | struct ieee80211_ampdu_params *params, |
| 2201 | bool add); |
| 2202 | -int mt7996_mcu_update_bss_color(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 2203 | +int mt7996_mcu_update_bss_color(struct mt7996_dev *dev, |
| 2204 | + struct mt7996_bss_conf *mconf, |
| 2205 | struct cfg80211_he_bss_color *he_bss_color); |
| 2206 | -int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 2207 | - int enable); |
| 2208 | +int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, |
| 2209 | + struct ieee80211_bss_conf *conf, |
| 2210 | + struct mt7996_bss_conf *mconf, int en); |
| 2211 | int mt7996_mcu_beacon_inband_discov(struct mt7996_dev *dev, |
| 2212 | - struct ieee80211_vif *vif, u32 changed); |
| 2213 | -int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy, struct ieee80211_vif *vif, |
| 2214 | + struct ieee80211_bss_conf *conf, |
| 2215 | + struct mt7996_bss_conf *mconf, u32 changed); |
| 2216 | +int mt7996_mcu_add_obss_spr(struct mt7996_phy *phy, |
| 2217 | + struct mt7996_bss_conf *mconf, |
| 2218 | struct ieee80211_he_obss_pd *he_obss_pd); |
| 2219 | -int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 2220 | +int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, |
| 2221 | + struct ieee80211_bss_conf *conf, |
| 2222 | + struct mt7996_bss_conf *mconf, |
| 2223 | struct ieee80211_sta *sta, bool changed); |
| 2224 | int mt7996_set_channel(struct mt7996_phy *phy, struct cfg80211_chan_def *chandef); |
| 2225 | int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag); |
| 2226 | -int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct ieee80211_vif *vif); |
| 2227 | +int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct mt7996_bss_conf *mconf); |
| 2228 | int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev, |
| 2229 | void *data, u16 version); |
| 2230 | -int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 2231 | +int mt7996_mcu_set_fixed_field(struct mt7996_dev *dev, |
| 2232 | + struct mt7996_bss_conf *mconf, |
| 2233 | struct ieee80211_sta *sta, void *data, u32 field); |
| 2234 | int mt7996_mcu_set_eeprom(struct mt7996_dev *dev); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2235 | int mt7996_mcu_get_eeprom(struct mt7996_dev *dev, u32 offset, u8 *buf, u32 buf_len); |
| 2236 | @@ -855,7 +879,7 @@ int mt7996_mcu_set_radar_th(struct mt7996_dev *dev, int index, |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2237 | const struct mt7996_dfs_pattern *pattern); |
| 2238 | int mt7996_mcu_set_radio_en(struct mt7996_phy *phy, bool enable); |
| 2239 | int mt7996_mcu_set_rts_thresh(struct mt7996_phy *phy, u32 val); |
| 2240 | -int mt7996_mcu_set_timing(struct mt7996_phy *phy, struct ieee80211_vif *vif); |
| 2241 | +int mt7996_mcu_set_timing(struct mt7996_phy *phy, struct mt7996_bss_conf *mconf); |
| 2242 | int mt7996_mcu_get_chan_mib_info(struct mt7996_phy *phy, bool chan_switch); |
| 2243 | int mt7996_mcu_get_temperature(struct mt7996_phy *phy); |
| 2244 | int mt7996_mcu_set_thermal_throttling(struct mt7996_phy *phy, u8 state); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2245 | @@ -895,8 +919,9 @@ void mt7996_tm_rf_test_event(struct mt7996_dev *dev, struct sk_buff *skb); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2246 | int mt7996_mcu_set_scs(struct mt7996_phy *phy, u8 enable); |
| 2247 | void mt7996_mcu_scs_sta_poll(struct work_struct *work); |
| 2248 | int mt7996_mcu_set_band_confg(struct mt7996_phy *phy, u16 option, bool enable); |
| 2249 | -int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy, struct mt7996_sta *msta, |
| 2250 | - enum vow_drr_ctrl_id id); |
| 2251 | +int mt7996_mcu_set_vow_drr_ctrl(struct mt7996_phy *phy, |
| 2252 | + struct mt7996_bss_conf *mconf, |
| 2253 | + struct mt7996_sta *msta, enum vow_drr_ctrl_id id); |
| 2254 | int mt7996_mcu_set_vow_feature_ctrl(struct mt7996_phy *phy); |
| 2255 | void mt7996_mcu_wmm_pbc_work(struct work_struct *work); |
| 2256 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2257 | @@ -1005,13 +1030,16 @@ void mt7996_update_channel(struct mt76_phy *mphy); |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2258 | int mt7996_init_debugfs(struct mt7996_phy *phy); |
| 2259 | void mt7996_debugfs_rx_fw_monitor(struct mt7996_dev *dev, const void *data, int len); |
| 2260 | bool mt7996_debugfs_rx_log(struct mt7996_dev *dev, const void *data, int len); |
| 2261 | -int mt7996_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 2262 | +int mt7996_mcu_add_key(struct mt76_dev *dev, struct mt7996_bss_conf *mconf, |
| 2263 | struct ieee80211_key_conf *key, int mcu_cmd, |
| 2264 | struct mt76_wcid *wcid, enum set_key_cmd cmd); |
| 2265 | -int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 2266 | +int mt7996_mcu_bcn_prot_enable(struct mt7996_dev *dev, |
| 2267 | + struct ieee80211_bss_conf *conf, |
| 2268 | + struct mt7996_bss_conf *mconf, |
| 2269 | struct ieee80211_key_conf *key); |
| 2270 | int mt7996_mcu_wtbl_update_hdr_trans(struct mt7996_dev *dev, |
| 2271 | struct ieee80211_vif *vif, |
| 2272 | + struct mt7996_bss_conf *mconf, |
| 2273 | struct ieee80211_sta *sta); |
| 2274 | int mt7996_mcu_cp_support(struct mt7996_dev *dev, u8 mode); |
| 2275 | int mt7996_mcu_set_pp_en(struct mt7996_phy *phy, u8 mode, u16 bitmap); |
| 2276 | diff --git a/mt7996/testmode.c b/mt7996/testmode.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 2277 | index 5a8b6d0..042da4e 100644 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2278 | --- a/mt7996/testmode.c |
| 2279 | +++ b/mt7996/testmode.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2280 | @@ -229,6 +229,7 @@ static void |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2281 | mt7996_tm_init(struct mt7996_phy *phy, bool en) |
| 2282 | { |
| 2283 | struct mt7996_dev *dev = phy->dev; |
| 2284 | + struct mt7996_vif *mvif = (struct mt7996_vif *)phy->monitor_vif->drv_priv; |
| 2285 | u8 rf_test_mode = en ? RF_OPER_RF_TEST : RF_OPER_NORMAL; |
| 2286 | |
| 2287 | if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state)) |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2288 | @@ -240,8 +241,8 @@ mt7996_tm_init(struct mt7996_phy *phy, bool en) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2289 | |
| 2290 | mt7996_tm_rf_switch_mode(dev, rf_test_mode); |
| 2291 | |
| 2292 | - mt7996_mcu_add_bss_info(phy, phy->monitor_vif, en); |
| 2293 | - mt7996_mcu_add_sta(dev, phy->monitor_vif, NULL, en, false); |
| 2294 | + mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, en); |
| 2295 | + mt7996_mcu_add_sta(dev, &phy->monitor_vif->bss_conf, &mvif->deflink, NULL, en, false); |
| 2296 | |
| 2297 | mt7996_tm_set(dev, SET_ID(BAND_IDX), phy->mt76->band_idx); |
| 2298 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2299 | @@ -1185,13 +1186,13 @@ mt7996_tm_txbf_init(struct mt7996_phy *phy, u16 *val) |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2300 | mt7996_tm_set_mac_addr(dev, td->addr[2], SET_ID(BSSID)); |
| 2301 | |
| 2302 | /* bss idx & omac idx should be set to band idx for ibf cal */ |
| 2303 | - mvif->mt76.idx = band_idx; |
| 2304 | - dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx); |
| 2305 | - mvif->mt76.omac_idx = band_idx; |
| 2306 | - phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx); |
| 2307 | + mvif->deflink.mt76.idx = band_idx; |
| 2308 | + dev->mt76.vif_mask |= BIT_ULL(mvif->deflink.mt76.idx); |
| 2309 | + mvif->deflink.mt76.omac_idx = band_idx; |
| 2310 | + phy->omac_mask |= BIT_ULL(mvif->deflink.mt76.omac_idx); |
| 2311 | |
| 2312 | - mt7996_mcu_add_dev_info(phy, phy->monitor_vif, true); |
| 2313 | - mt7996_mcu_add_bss_info(phy, phy->monitor_vif, true); |
| 2314 | + mt7996_mcu_add_dev_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, true); |
| 2315 | + mt7996_mcu_add_bss_info(phy, &phy->monitor_vif->bss_conf, &mvif->deflink, true); |
| 2316 | |
| 2317 | if (td->ibf) { |
| 2318 | if (td->is_txbf_dut) { |
| 2319 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 2320 | 2.45.2 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 2321 | |