developer | 6bcdd6c | 2024-03-21 16:26:34 +0800 | [diff] [blame^] | 1 | From e7396c6ce0cf5762179d3cb7c92aa0a958b7459d Mon Sep 17 00:00:00 2001 |
| 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Fri, 1 Dec 2023 17:26:43 +0800 |
| 4 | Subject: [PATCH 108/120] wifi: mt76: mt7996: rework ieee80211_ops callbacks |
| 5 | for link consideration |
| 6 | |
| 7 | Extend ieee80211 callback functions to support multi-link operation. |
| 8 | This is a preliminary patch to add MLO support for mt7996 chipsets. |
| 9 | |
| 10 | Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com> |
| 11 | Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com> |
| 12 | Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| 13 | --- |
| 14 | mt7996/main.c | 309 ++++++++++++++++++++++++++++++++------------------ |
| 15 | 1 file changed, 200 insertions(+), 109 deletions(-) |
| 16 | |
| 17 | diff --git a/mt7996/main.c b/mt7996/main.c |
| 18 | index 49406dba5..f4488fdf7 100644 |
| 19 | --- a/mt7996/main.c |
| 20 | +++ b/mt7996/main.c |
| 21 | @@ -568,7 +568,6 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
| 22 | struct ieee80211_key_conf *key) |
| 23 | { |
| 24 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 25 | - struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 26 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 27 | struct mt7996_sta *msta = sta ? (struct mt7996_sta *)sta->drv_priv : |
| 28 | &mvif->sta; |
| 29 | @@ -578,69 +577,76 @@ static int mt7996_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
| 30 | u8 *wcid_keyidx; |
| 31 | int idx = key->keyidx; |
| 32 | int err = 0; |
| 33 | + unsigned long add; |
| 34 | + unsigned int link_id; |
| 35 | |
| 36 | - /* The hardware does not support per-STA RX GTK, fallback |
| 37 | - * to software mode for these. |
| 38 | - */ |
| 39 | - if ((vif->type == NL80211_IFTYPE_ADHOC || |
| 40 | - vif->type == NL80211_IFTYPE_MESH_POINT) && |
| 41 | - (key->cipher == WLAN_CIPHER_SUITE_TKIP || |
| 42 | - key->cipher == WLAN_CIPHER_SUITE_CCMP) && |
| 43 | - !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) |
| 44 | - return -EOPNOTSUPP; |
| 45 | + if (key->link_id >= 0) { |
| 46 | + add = BIT(key->link_id); |
| 47 | + } else { |
| 48 | + if (sta) |
| 49 | + add = sta->valid_links ?: BIT(0); |
| 50 | + else |
| 51 | + add = vif->valid_links ?: BIT(0); |
| 52 | + } |
| 53 | |
| 54 | mutex_lock(&dev->mt76.mutex); |
| 55 | - conf = link_conf_dereference_protected(vif, 0); |
| 56 | - mconf = mconf_dereference_protected(mvif, 0); |
| 57 | - mlink = mlink_dereference_protected(msta, 0); |
| 58 | - wcid_keyidx = &mlink->wcid.hw_key_idx; |
| 59 | - |
| 60 | - /* fall back to sw encryption for unsupported ciphers */ |
| 61 | - switch (key->cipher) { |
| 62 | - case WLAN_CIPHER_SUITE_TKIP: |
| 63 | - case WLAN_CIPHER_SUITE_CCMP: |
| 64 | - case WLAN_CIPHER_SUITE_CCMP_256: |
| 65 | - case WLAN_CIPHER_SUITE_GCMP: |
| 66 | - case WLAN_CIPHER_SUITE_GCMP_256: |
| 67 | - case WLAN_CIPHER_SUITE_SMS4: |
| 68 | - break; |
| 69 | - case WLAN_CIPHER_SUITE_AES_CMAC: |
| 70 | - key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIE; |
| 71 | - fallthrough; |
| 72 | - case WLAN_CIPHER_SUITE_BIP_CMAC_256: |
| 73 | - case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
| 74 | - case WLAN_CIPHER_SUITE_BIP_GMAC_256: |
| 75 | - if (key->keyidx == 6 || key->keyidx == 7) |
| 76 | + |
| 77 | + for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 78 | + conf = link_conf_dereference_protected(vif, link_id); |
| 79 | + mconf = mconf_dereference_protected(mvif, link_id); |
| 80 | + mlink = mlink_dereference_protected(msta, link_id); |
| 81 | + wcid_keyidx = &mlink->wcid.hw_key_idx; |
| 82 | + |
| 83 | + if (!conf || !mconf || !mlink) |
| 84 | + continue; |
| 85 | + |
| 86 | + /* fall back to sw encryption for unsupported ciphers */ |
| 87 | + switch (key->cipher) { |
| 88 | + case WLAN_CIPHER_SUITE_TKIP: |
| 89 | + case WLAN_CIPHER_SUITE_CCMP: |
| 90 | + case WLAN_CIPHER_SUITE_CCMP_256: |
| 91 | + case WLAN_CIPHER_SUITE_GCMP: |
| 92 | + case WLAN_CIPHER_SUITE_GCMP_256: |
| 93 | + case WLAN_CIPHER_SUITE_SMS4: |
| 94 | break; |
| 95 | - fallthrough; |
| 96 | - case WLAN_CIPHER_SUITE_WEP40: |
| 97 | - case WLAN_CIPHER_SUITE_WEP104: |
| 98 | - default: |
| 99 | - mutex_unlock(&dev->mt76.mutex); |
| 100 | - return -EOPNOTSUPP; |
| 101 | - } |
| 102 | + case WLAN_CIPHER_SUITE_AES_CMAC: |
| 103 | + key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIE; |
| 104 | + fallthrough; |
| 105 | + case WLAN_CIPHER_SUITE_BIP_CMAC_256: |
| 106 | + case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
| 107 | + case WLAN_CIPHER_SUITE_BIP_GMAC_256: |
| 108 | + if (key->keyidx == 6 || key->keyidx == 7) |
| 109 | + break; |
| 110 | + fallthrough; |
| 111 | + case WLAN_CIPHER_SUITE_WEP40: |
| 112 | + case WLAN_CIPHER_SUITE_WEP104: |
| 113 | + default: |
| 114 | + mutex_unlock(&dev->mt76.mutex); |
| 115 | + return -EOPNOTSUPP; |
| 116 | + } |
| 117 | |
| 118 | - if (cmd == SET_KEY && !sta && !mconf->mt76.cipher) { |
| 119 | - mconf->mt76.cipher = mt76_connac_mcu_get_cipher(key->cipher); |
| 120 | - mt7996_mcu_add_bss_info(phy, conf, mconf, mlink, true); |
| 121 | - } |
| 122 | + if (cmd == SET_KEY && !sta && !mconf->mt76.cipher) { |
| 123 | + mconf->mt76.cipher = mt76_connac_mcu_get_cipher(key->cipher); |
| 124 | + mt7996_mcu_add_bss_info(mconf->phy, conf, mconf, mlink, true); |
| 125 | + } |
| 126 | |
| 127 | - if (cmd == SET_KEY) { |
| 128 | - *wcid_keyidx = idx; |
| 129 | - } else { |
| 130 | - if (idx == *wcid_keyidx) |
| 131 | - *wcid_keyidx = -1; |
| 132 | - goto out; |
| 133 | - } |
| 134 | + if (cmd == SET_KEY) { |
| 135 | + *wcid_keyidx = idx; |
| 136 | + } else { |
| 137 | + if (idx == *wcid_keyidx) |
| 138 | + *wcid_keyidx = -1; |
| 139 | + goto out; |
| 140 | + } |
| 141 | |
| 142 | - mt76_wcid_key_setup(&dev->mt76, &mlink->wcid, key); |
| 143 | + mt76_wcid_key_setup(&dev->mt76, &mlink->wcid, key); |
| 144 | |
| 145 | - if (key->keyidx == 6 || key->keyidx == 7) |
| 146 | - err = mt7996_mcu_bcn_prot_enable(dev, conf, mconf, mlink, key); |
| 147 | - else |
| 148 | - err = mt7996_mcu_add_key(&dev->mt76, mconf, key, |
| 149 | - MCU_WMWA_UNI_CMD(STA_REC_UPDATE), |
| 150 | - &mlink->wcid, cmd); |
| 151 | + if (key->keyidx == 6 || key->keyidx == 7) |
| 152 | + err = mt7996_mcu_bcn_prot_enable(dev, conf, mconf, mlink, key); |
| 153 | + else |
| 154 | + err = mt7996_mcu_add_key(&dev->mt76, mconf, key, |
| 155 | + MCU_WMWA_UNI_CMD(STA_REC_UPDATE), |
| 156 | + &mlink->wcid, cmd); |
| 157 | + } |
| 158 | out: |
| 159 | mutex_unlock(&dev->mt76.mutex); |
| 160 | |
| 161 | @@ -696,7 +702,11 @@ mt7996_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 162 | }; |
| 163 | |
| 164 | mutex_lock(&dev->mt76.mutex); |
| 165 | - mconf = mconf_dereference_protected(mvif, 0); |
| 166 | + mconf = mconf_dereference_protected(mvif, link_id); |
| 167 | + if (!mconf) { |
| 168 | + mutex_unlock(&dev->mt76.mutex); |
| 169 | + return -EINVAL; |
| 170 | + } |
| 171 | |
| 172 | /* firmware uses access class index */ |
| 173 | mconf->queue_params[mq_to_aci[queue]] = *params; |
| 174 | @@ -839,19 +849,26 @@ mt7996_update_mu_group(struct ieee80211_hw *hw, struct ieee80211_bss_conf *conf, |
| 175 | static void mt7996_vif_cfg_changed(struct ieee80211_hw *hw, |
| 176 | struct ieee80211_vif *vif, u64 changed) |
| 177 | { |
| 178 | - struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 179 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 180 | |
| 181 | mutex_lock(&dev->mt76.mutex); |
| 182 | |
| 183 | if (changed & BSS_CHANGED_ASSOC && vif->cfg.assoc) { |
| 184 | - struct ieee80211_bss_conf *conf = &vif->bss_conf; |
| 185 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 186 | - struct mt7996_bss_conf *mconf = mconf_dereference_protected(mvif, 0); |
| 187 | - struct mt7996_link_sta *mlink = mlink_dereference_protected(&mvif->sta, 0); |
| 188 | - |
| 189 | - mt7996_mcu_add_bss_info(phy, conf, mconf, mlink, true); |
| 190 | - mt7996_mcu_add_sta(dev, conf, mconf, NULL, mlink, true, false); |
| 191 | + unsigned long valid_links = vif->valid_links ?: BIT(0); |
| 192 | + unsigned int link_id; |
| 193 | + |
| 194 | + for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 195 | + struct ieee80211_bss_conf *conf = |
| 196 | + link_conf_dereference_protected(vif, link_id); |
| 197 | + struct mt7996_bss_conf *mconf = |
| 198 | + mconf_dereference_protected(mvif, link_id); |
| 199 | + struct mt7996_link_sta *mlink = |
| 200 | + mlink_dereference_protected(&mvif->sta, link_id); |
| 201 | + |
| 202 | + mt7996_mcu_add_bss_info(mconf->phy, conf, mconf, mlink, true); |
| 203 | + mt7996_mcu_add_sta(dev, conf, mconf, NULL, mlink, true, false); |
| 204 | + } |
| 205 | } |
| 206 | |
| 207 | mutex_unlock(&dev->mt76.mutex); |
| 208 | @@ -870,8 +887,13 @@ static void mt7996_link_info_changed(struct ieee80211_hw *hw, |
| 209 | |
| 210 | mutex_lock(&dev->mt76.mutex); |
| 211 | |
| 212 | - mconf = mconf_dereference_protected(mvif, 0); |
| 213 | - mlink = mlink_dereference_protected(&mvif->sta, 0); |
| 214 | + mconf = mconf_dereference_protected(mvif, info->link_id); |
| 215 | + mlink = mlink_dereference_protected(&mvif->sta, info->link_id); |
| 216 | + if (!mconf || !mlink) |
| 217 | + goto out; |
| 218 | + |
| 219 | + if (mconf->phy) |
| 220 | + phy = mconf->phy; |
| 221 | /* station mode uses BSSID to map the wlan entry to a peer, |
| 222 | * and then peer references bss_info_rfch to set bandwidth cap. |
| 223 | */ |
| 224 | @@ -927,6 +949,7 @@ static void mt7996_link_info_changed(struct ieee80211_hw *hw, |
| 225 | if (changed & BSS_CHANGED_MU_GROUPS) |
| 226 | mt7996_update_mu_group(hw, info, mconf); |
| 227 | |
| 228 | +out: |
| 229 | mutex_unlock(&dev->mt76.mutex); |
| 230 | } |
| 231 | |
| 232 | @@ -937,13 +960,22 @@ mt7996_channel_switch_beacon(struct ieee80211_hw *hw, |
| 233 | { |
| 234 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 235 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 236 | - struct mt7996_bss_conf *mconf; |
| 237 | - struct ieee80211_bss_conf *conf; |
| 238 | + struct mt7996_phy *phy = mt7996_band_phy(hw, chandef->chan->band); |
| 239 | + unsigned long valid_links = vif->valid_links ?: BIT(0); |
| 240 | + unsigned int link_id; |
| 241 | |
| 242 | mutex_lock(&dev->mt76.mutex); |
| 243 | - mconf = mconf_dereference_protected(mvif, 0); |
| 244 | - conf = link_conf_dereference_protected(vif, 0); |
| 245 | - mt7996_mcu_add_beacon(hw, conf, mconf, true); |
| 246 | + for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 247 | + struct mt7996_bss_conf *mconf = |
| 248 | + mconf_dereference_protected(mvif, link_id); |
| 249 | + struct ieee80211_bss_conf *conf = |
| 250 | + link_conf_dereference_protected(vif, link_id); |
| 251 | + |
| 252 | + if (!mconf || phy != mconf->phy) |
| 253 | + continue; |
| 254 | + |
| 255 | + mt7996_mcu_add_beacon(hw, conf, mconf, true); |
| 256 | + } |
| 257 | mutex_unlock(&dev->mt76.mutex); |
| 258 | } |
| 259 | |
| 260 | @@ -1215,34 +1247,70 @@ void mt7996_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 261 | mt7996_mac_sta_remove_links(dev, vif, sta, rem); |
| 262 | } |
| 263 | |
| 264 | +static void |
| 265 | +mt7996_sta_pre_rcu_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 266 | + struct ieee80211_sta *sta) |
| 267 | +{ |
| 268 | + struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 269 | + struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 270 | + unsigned long rem = sta->valid_links ?: BIT(0); |
| 271 | + unsigned int link_id; |
| 272 | + |
| 273 | + mutex_lock(&dev->mt76.mutex); |
| 274 | + spin_lock_bh(&dev->mt76.status_lock); |
| 275 | + for_each_set_bit(link_id, &rem, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 276 | + struct mt7996_link_sta *mlink = |
| 277 | + mlink_dereference_protected(msta, link_id); |
| 278 | + |
| 279 | + rcu_assign_pointer(dev->mt76.wcid[mlink->wcid.idx], NULL); |
| 280 | + } |
| 281 | + spin_unlock_bh(&dev->mt76.status_lock); |
| 282 | + mutex_unlock(&dev->mt76.mutex); |
| 283 | +} |
| 284 | + |
| 285 | static void mt7996_tx(struct ieee80211_hw *hw, |
| 286 | struct ieee80211_tx_control *control, |
| 287 | struct sk_buff *skb) |
| 288 | { |
| 289 | - struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 290 | - struct mt76_phy *mphy = hw->priv; |
| 291 | + struct mt76_phy *mphy; |
| 292 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
| 293 | struct ieee80211_vif *vif = info->control.vif; |
| 294 | - struct mt76_wcid *wcid = &dev->mt76.global_wcid; |
| 295 | - struct mt7996_link_sta *mlink; |
| 296 | + struct mt76_wcid *wcid; |
| 297 | + struct mt7996_vif *mvif; |
| 298 | + struct mt7996_sta *msta; |
| 299 | |
| 300 | if (control->sta) { |
| 301 | - struct mt7996_sta *msta; |
| 302 | - |
| 303 | msta = (struct mt7996_sta *)control->sta->drv_priv; |
| 304 | - mlink = rcu_dereference(msta->link[0]); |
| 305 | - wcid = &mlink->wcid; |
| 306 | + mvif = msta->vif; |
| 307 | + } else if (vif) { |
| 308 | + mvif = (struct mt7996_vif *)vif->drv_priv; |
| 309 | + msta = &mvif->sta; |
| 310 | } |
| 311 | |
| 312 | - if (vif && !control->sta) { |
| 313 | - struct mt7996_vif *mvif; |
| 314 | + rcu_read_lock(); |
| 315 | + if (mvif && msta) { |
| 316 | + struct mt7996_bss_conf *mconf; |
| 317 | + struct mt7996_link_sta *mlink; |
| 318 | |
| 319 | - mvif = (struct mt7996_vif *)vif->drv_priv; |
| 320 | - mlink = rcu_dereference(mvif->sta.link[0]); |
| 321 | + u8 link_id = u32_get_bits(info->control.flags, |
| 322 | + IEEE80211_TX_CTRL_MLO_LINK); |
| 323 | + |
| 324 | + if (link_id >= IEEE80211_LINK_UNSPECIFIED) |
| 325 | + link_id = mvif->master_link_id; |
| 326 | + |
| 327 | + mconf = rcu_dereference(mvif->link[link_id]); |
| 328 | + mlink = rcu_dereference(msta->link[link_id]); |
| 329 | + mphy = mconf->phy->mt76; |
| 330 | wcid = &mlink->wcid; |
| 331 | + } else { |
| 332 | + struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 333 | + |
| 334 | + mphy = hw->priv; |
| 335 | + wcid = &dev->mt76.global_wcid; |
| 336 | } |
| 337 | |
| 338 | mt76_tx(mphy, control->sta, wcid, skb); |
| 339 | + rcu_read_unlock(); |
| 340 | } |
| 341 | |
| 342 | static int mt7996_set_rts_threshold(struct ieee80211_hw *hw, u32 val) |
| 343 | @@ -1278,7 +1346,7 @@ mt7996_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 344 | mtxq = (struct mt76_txq *)txq->drv_priv; |
| 345 | |
| 346 | mutex_lock(&dev->mt76.mutex); |
| 347 | - mlink = mlink_dereference_protected(msta, 0); |
| 348 | + mlink = mlink_dereference_protected(msta, msta->pri_link); |
| 349 | switch (action) { |
| 350 | case IEEE80211_AMPDU_RX_START: |
| 351 | mt76_rx_aggr_start(&dev->mt76, &mlink->wcid, tid, ssn, |
| 352 | @@ -1493,7 +1561,7 @@ static void mt7996_sta_statistics(struct ieee80211_hw *hw, |
| 353 | |
| 354 | /* TODO: support per-link rate report */ |
| 355 | mutex_lock(&dev->mt76.mutex); |
| 356 | - mlink = mlink_dereference_protected(msta, 0); |
| 357 | + mlink = mlink_dereference_protected(msta, msta->pri_link); |
| 358 | if (!mlink) |
| 359 | goto out; |
| 360 | |
| 361 | @@ -1553,7 +1621,7 @@ static void mt7996_sta_rc_work(void *data, struct ieee80211_sta *sta) |
| 362 | u32 *changed = data; |
| 363 | |
| 364 | rcu_read_lock(); |
| 365 | - mlink = rcu_dereference(msta->link[0]); |
| 366 | + mlink = rcu_dereference(msta->link[msta->pri_link]); |
| 367 | |
| 368 | spin_lock_bh(&dev->mt76.sta_poll_lock); |
| 369 | mlink->changed |= *changed; |
| 370 | @@ -1620,19 +1688,26 @@ static void mt7996_sta_set_4addr(struct ieee80211_hw *hw, |
| 371 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 372 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 373 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 374 | - struct mt7996_bss_conf *mconf; |
| 375 | - struct mt7996_link_sta *mlink; |
| 376 | + unsigned long valid_links = sta->valid_links ?: BIT(0); |
| 377 | + unsigned int link_id; |
| 378 | |
| 379 | mutex_lock(&dev->mt76.mutex); |
| 380 | - mconf = mconf_dereference_protected(mvif, 0); |
| 381 | - mlink = mlink_dereference_protected(msta, 0); |
| 382 | + for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 383 | + struct mt7996_bss_conf *mconf = |
| 384 | + mconf_dereference_protected(mvif, link_id); |
| 385 | + struct mt7996_link_sta *mlink = |
| 386 | + mlink_dereference_protected(msta, link_id); |
| 387 | |
| 388 | - if (enabled) |
| 389 | - set_bit(MT_WCID_FLAG_4ADDR, &mlink->wcid.flags); |
| 390 | - else |
| 391 | - clear_bit(MT_WCID_FLAG_4ADDR, &mlink->wcid.flags); |
| 392 | + if (!mconf || !mlink) |
| 393 | + continue; |
| 394 | |
| 395 | - mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, mlink); |
| 396 | + if (enabled) |
| 397 | + set_bit(MT_WCID_FLAG_4ADDR, &mlink->wcid.flags); |
| 398 | + else |
| 399 | + clear_bit(MT_WCID_FLAG_4ADDR, &mlink->wcid.flags); |
| 400 | + |
| 401 | + mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, mlink); |
| 402 | + } |
| 403 | mutex_unlock(&dev->mt76.mutex); |
| 404 | } |
| 405 | |
| 406 | @@ -1644,19 +1719,26 @@ static void mt7996_sta_set_decap_offload(struct ieee80211_hw *hw, |
| 407 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 408 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 409 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 410 | - struct mt7996_bss_conf *mconf; |
| 411 | - struct mt7996_link_sta *mlink; |
| 412 | + unsigned long valid_links = sta->valid_links ?: BIT(0); |
| 413 | + unsigned int link_id; |
| 414 | |
| 415 | mutex_lock(&dev->mt76.mutex); |
| 416 | - mconf = mconf_dereference_protected(mvif, 0); |
| 417 | - mlink = mlink_dereference_protected(msta, 0); |
| 418 | + for_each_set_bit(link_id, &valid_links, IEEE80211_MLD_MAX_NUM_LINKS) { |
| 419 | + struct mt7996_bss_conf *mconf = |
| 420 | + mconf_dereference_protected(mvif, link_id); |
| 421 | + struct mt7996_link_sta *mlink = |
| 422 | + mlink_dereference_protected(msta, link_id); |
| 423 | |
| 424 | - if (enabled) |
| 425 | - set_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags); |
| 426 | - else |
| 427 | - clear_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags); |
| 428 | + if (!mconf || !mlink) |
| 429 | + continue; |
| 430 | + |
| 431 | + if (enabled) |
| 432 | + set_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags); |
| 433 | + else |
| 434 | + clear_bit(MT_WCID_FLAG_HDR_TRANS, &mlink->wcid.flags); |
| 435 | |
| 436 | - mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, mlink); |
| 437 | + mt7996_mcu_wtbl_update_hdr_trans(dev, vif, mconf, mlink); |
| 438 | + } |
| 439 | mutex_unlock(&dev->mt76.mutex); |
| 440 | } |
| 441 | |
| 442 | @@ -1789,9 +1871,13 @@ static void mt7996_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) |
| 443 | { |
| 444 | struct mt76_ethtool_worker_info *wi = wi_data; |
| 445 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 446 | - struct mt7996_link_sta *mlink = &msta->deflink; |
| 447 | + struct mt7996_link_sta *mlink; |
| 448 | + struct mt7996_bss_conf *mconf; |
| 449 | + |
| 450 | + mlink = mlink_dereference_protected(msta, msta->pri_link); |
| 451 | + mconf = mconf_dereference_protected(msta->vif, msta->pri_link); |
| 452 | |
| 453 | - if (msta->vif->deflink.mt76.idx != wi->idx) |
| 454 | + if (mconf->mt76.idx != wi->idx) |
| 455 | return; |
| 456 | |
| 457 | mt76_ethtool_worker(wi, &mlink->wcid.stats, true); |
| 458 | @@ -2023,12 +2109,13 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw, |
| 459 | struct net_device_path *path) |
| 460 | { |
| 461 | struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; |
| 462 | - struct mt7996_bss_conf *mconf = &mvif->deflink; |
| 463 | struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; |
| 464 | - struct mt7996_link_sta *mlink = &msta->deflink; |
| 465 | struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 466 | struct mt7996_phy *phy = mt7996_hw_phy(hw); |
| 467 | struct mtk_wed_device *wed = &dev->mt76.mmio.wed; |
| 468 | + struct mt7996_bss_conf *mconf; |
| 469 | + struct mt7996_link_sta *mlink; |
| 470 | + u8 link_id; |
| 471 | |
| 472 | if (phy != &dev->phy && dev->hif2) { |
| 473 | switch (dev->option_type) { |
| 474 | @@ -2047,6 +2134,10 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw, |
| 475 | if (!mtk_wed_device_active(wed)) |
| 476 | return -ENODEV; |
| 477 | |
| 478 | + link_id = msta->pri_link; |
| 479 | + mconf = rcu_dereference(mvif->link[link_id]); |
| 480 | + mlink = rcu_dereference(msta->link[link_id]); |
| 481 | + |
| 482 | if (mlink->wcid.idx > MT7996_WTBL_STA) |
| 483 | return -EIO; |
| 484 | |
| 485 | @@ -2368,7 +2459,7 @@ const struct ieee80211_ops mt7996_ops = { |
| 486 | .vif_cfg_changed = mt7996_vif_cfg_changed, |
| 487 | .link_info_changed = mt7996_link_info_changed, |
| 488 | .sta_state = mt76_sta_state, |
| 489 | - .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove, |
| 490 | + .sta_pre_rcu_remove = mt7996_sta_pre_rcu_remove, |
| 491 | .sta_rc_update = mt7996_sta_rc_update, |
| 492 | .set_key = mt7996_set_key, |
| 493 | .ampdu_action = mt7996_ampdu_action, |
| 494 | -- |
| 495 | 2.39.2 |
| 496 | |