Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wifi: mt76: mt7996: split link specific data from struct mt7996_vif

Preparation for MLO support.

Link: https://patch.msgid.link/20250102163508.52945-5-nbd@nbd.name
Signed-off-by: Felix Fietkau <nbd@nbd.name>

+185 -132
+3 -3
drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c
··· 601 601 mt7996_sta_hw_queue_read(void *data, struct ieee80211_sta *sta) 602 602 { 603 603 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; 604 - struct mt7996_dev *dev = msta->vif->phy->dev; 604 + struct mt7996_dev *dev = msta->vif->deflink.phy->dev; 605 605 struct seq_file *s = data; 606 606 u8 ac; 607 607 ··· 621 621 GENMASK(11, 0)); 622 622 seq_printf(s, "\tSTA %pM wcid %d: AC%d%d queued:%d\n", 623 623 sta->addr, msta->wcid.idx, 624 - msta->vif->mt76.wmm_idx, ac, qlen); 624 + msta->vif->deflink.mt76.wmm_idx, ac, qlen); 625 625 } 626 626 } 627 627 ··· 899 899 #define LONG_PREAMBLE 1 900 900 struct ieee80211_sta *sta = file->private_data; 901 901 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; 902 - struct mt7996_dev *dev = msta->vif->phy->dev; 902 + struct mt7996_dev *dev = msta->vif->deflink.phy->dev; 903 903 struct ra_rate phy = {}; 904 904 char buf[100]; 905 905 int ret;
+4 -4
drivers/net/wireless/mediatek/mt76/mt7996/mac.c
··· 72 72 if (!sta->vif) 73 73 return NULL; 74 74 75 - return &sta->vif->sta.wcid; 75 + return &sta->vif->deflink.sta.wcid; 76 76 } 77 77 78 78 bool mt7996_mac_wtbl_update(struct mt7996_dev *dev, int idx, u32 mask) ··· 182 182 rssi[3] = to_rssi(GENMASK(31, 14), val); 183 183 184 184 msta->ack_signal = 185 - mt76_rx_signal(msta->vif->phy->mt76->antenna_mask, rssi); 185 + mt76_rx_signal(msta->vif->deflink.phy->mt76->antenna_mask, rssi); 186 186 187 187 ewma_avg_signal_add(&msta->avg_ack_signal, -msta->ack_signal); 188 188 } ··· 196 196 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 197 197 u32 addr; 198 198 199 - addr = mt7996_mac_wtbl_lmac_addr(dev, mvif->sta.wcid.idx, 5); 199 + addr = mt7996_mac_wtbl_lmac_addr(dev, mvif->deflink.sta.wcid.idx, 5); 200 200 if (enable) 201 201 mt76_set(dev, addr, BIT(5)); 202 202 else ··· 984 984 if (vif) { 985 985 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 986 986 987 - txp->fw.bss_idx = mvif->mt76.idx; 987 + txp->fw.bss_idx = mvif->deflink.mt76.idx; 988 988 } 989 989 990 990 txp->fw.token = cpu_to_le16(id);
+118 -84
drivers/net/wireless/mediatek/mt76/mt7996/main.c
··· 157 157 return -1; 158 158 } 159 159 160 - static void mt7996_init_bitrate_mask(struct ieee80211_vif *vif) 160 + static void 161 + mt7996_init_bitrate_mask(struct ieee80211_vif *vif, struct mt7996_vif_link *mlink) 161 162 { 162 - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 163 163 int i; 164 164 165 - for (i = 0; i < ARRAY_SIZE(mvif->bitrate_mask.control); i++) { 166 - mvif->bitrate_mask.control[i].gi = NL80211_TXRATE_DEFAULT_GI; 167 - mvif->bitrate_mask.control[i].he_gi = 0xff; 168 - mvif->bitrate_mask.control[i].he_ltf = 0xff; 169 - mvif->bitrate_mask.control[i].legacy = GENMASK(31, 0); 170 - memset(mvif->bitrate_mask.control[i].ht_mcs, 0xff, 171 - sizeof(mvif->bitrate_mask.control[i].ht_mcs)); 172 - memset(mvif->bitrate_mask.control[i].vht_mcs, 0xff, 173 - sizeof(mvif->bitrate_mask.control[i].vht_mcs)); 174 - memset(mvif->bitrate_mask.control[i].he_mcs, 0xff, 175 - sizeof(mvif->bitrate_mask.control[i].he_mcs)); 165 + for (i = 0; i < ARRAY_SIZE(mlink->bitrate_mask.control); i++) { 166 + mlink->bitrate_mask.control[i].gi = NL80211_TXRATE_DEFAULT_GI; 167 + mlink->bitrate_mask.control[i].he_gi = 0xff; 168 + mlink->bitrate_mask.control[i].he_ltf = 0xff; 169 + mlink->bitrate_mask.control[i].legacy = GENMASK(31, 0); 170 + memset(mlink->bitrate_mask.control[i].ht_mcs, 0xff, 171 + sizeof(mlink->bitrate_mask.control[i].ht_mcs)); 172 + memset(mlink->bitrate_mask.control[i].vht_mcs, 0xff, 173 + sizeof(mlink->bitrate_mask.control[i].vht_mcs)); 174 + memset(mlink->bitrate_mask.control[i].he_mcs, 0xff, 175 + sizeof(mlink->bitrate_mask.control[i].he_mcs)); 176 176 } 177 177 } 178 178 179 - static int mt7996_add_interface(struct ieee80211_hw *hw, 180 - struct ieee80211_vif *vif) 179 + static int 180 + mt7996_vif_link_add(struct mt7996_phy *phy, struct ieee80211_vif *vif, 181 + struct ieee80211_bss_conf *link_conf) 181 182 { 182 - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 183 - struct mt7996_dev *dev = mt7996_hw_dev(hw); 184 - struct mt7996_phy *phy = mt7996_hw_phy(hw); 185 - struct mt76_txq *mtxq; 183 + struct mt7996_dev *dev = phy->dev; 186 184 u8 band_idx = phy->mt76->band_idx; 187 - int idx, ret = 0; 185 + struct mt7996_vif_link *mlink; 186 + struct mt76_txq *mtxq; 187 + int idx, ret; 188 188 189 - mutex_lock(&dev->mt76.mutex); 189 + mlink = mt7996_vif_conf_link(dev, vif, link_conf); 190 + if (!mlink) 191 + return -EINVAL; 190 192 191 - mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask); 192 - if (mvif->mt76.idx >= mt7996_max_interface_num(dev)) { 193 - ret = -ENOSPC; 194 - goto out; 195 - } 193 + mlink->mt76.idx = __ffs64(~dev->mt76.vif_mask); 194 + if (mlink->mt76.idx >= mt7996_max_interface_num(dev)) 195 + return -ENOSPC; 196 196 197 197 idx = get_omac_idx(vif->type, phy->omac_mask); 198 - if (idx < 0) { 199 - ret = -ENOSPC; 200 - goto out; 201 - } 202 - mvif->mt76.omac_idx = idx; 203 - mvif->phy = phy; 204 - mvif->mt76.band_idx = band_idx; 205 - mvif->mt76.wmm_idx = vif->type == NL80211_IFTYPE_AP ? 0 : 3; 206 - mvif->mt76.wcid = &mvif->sta.wcid; 198 + if (idx < 0) 199 + return -ENOSPC; 200 + 201 + mlink->mt76.omac_idx = idx; 202 + mlink->phy = phy; 203 + mlink->mt76.band_idx = band_idx; 204 + mlink->mt76.wmm_idx = vif->type == NL80211_IFTYPE_AP ? 0 : 3; 205 + mlink->mt76.wcid = &mlink->sta.wcid; 207 206 208 207 ret = mt7996_mcu_add_dev_info(phy, vif, true); 209 208 if (ret) 210 - goto out; 209 + return ret; 211 210 212 - dev->mt76.vif_mask |= BIT_ULL(mvif->mt76.idx); 213 - phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx); 211 + dev->mt76.vif_mask |= BIT_ULL(mlink->mt76.idx); 212 + phy->omac_mask |= BIT_ULL(mlink->mt76.omac_idx); 214 213 215 - idx = MT7996_WTBL_RESERVED - mvif->mt76.idx; 214 + idx = MT7996_WTBL_RESERVED - mlink->mt76.idx; 216 215 217 - INIT_LIST_HEAD(&mvif->sta.rc_list); 218 - INIT_LIST_HEAD(&mvif->sta.wcid.poll_list); 219 - mvif->sta.wcid.idx = idx; 220 - mvif->sta.wcid.phy_idx = band_idx; 221 - mvif->sta.wcid.hw_key_idx = -1; 222 - mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET; 223 - mt76_wcid_init(&mvif->sta.wcid); 216 + INIT_LIST_HEAD(&mlink->sta.rc_list); 217 + INIT_LIST_HEAD(&mlink->sta.wcid.poll_list); 218 + mlink->sta.wcid.idx = idx; 219 + mlink->sta.wcid.phy_idx = band_idx; 220 + mlink->sta.wcid.hw_key_idx = -1; 221 + mlink->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET; 222 + mt76_wcid_init(&mlink->sta.wcid); 224 223 225 224 mt7996_mac_wtbl_update(dev, idx, 226 225 MT_WTBL_UPDATE_ADM_COUNT_CLEAR); ··· 230 231 } 231 232 232 233 if (vif->type != NL80211_IFTYPE_AP && 233 - (!mvif->mt76.omac_idx || mvif->mt76.omac_idx > 3)) 234 + (!mlink->mt76.omac_idx || mlink->mt76.omac_idx > 3)) 234 235 vif->offload_flags = 0; 235 - vif->offload_flags |= IEEE80211_OFFLOAD_ENCAP_4ADDR; 236 236 237 237 if (phy->mt76->chandef.chan->band != NL80211_BAND_2GHZ) 238 - mvif->mt76.basic_rates_idx = MT7996_BASIC_RATES_TBL + 4; 238 + mlink->mt76.basic_rates_idx = MT7996_BASIC_RATES_TBL + 4; 239 239 else 240 - mvif->mt76.basic_rates_idx = MT7996_BASIC_RATES_TBL; 240 + mlink->mt76.basic_rates_idx = MT7996_BASIC_RATES_TBL; 241 241 242 - mt7996_init_bitrate_mask(vif); 242 + mt7996_init_bitrate_mask(vif, mlink); 243 243 244 244 mt7996_mcu_add_bss_info(phy, vif, true); 245 245 /* defer the first STA_REC of BMC entry to BSS_CHANGED_BSSID for STA ··· 246 248 */ 247 249 if (vif->type != NL80211_IFTYPE_STATION) 248 250 mt7996_mcu_add_sta(dev, vif, NULL, CONN_STATE_PORT_SECURE, true); 249 - rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid); 251 + rcu_assign_pointer(dev->mt76.wcid[idx], &mlink->sta.wcid); 250 252 251 - out: 252 - mutex_unlock(&dev->mt76.mutex); 253 - 254 - return ret; 253 + return 0; 255 254 } 256 255 257 - static void mt7996_remove_interface(struct ieee80211_hw *hw, 258 - struct ieee80211_vif *vif) 256 + static void 257 + mt7996_vif_link_remove(struct mt7996_phy *phy, struct ieee80211_vif *vif, 258 + struct ieee80211_bss_conf *link_conf) 259 259 { 260 - struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 261 - struct mt7996_sta *msta = &mvif->sta; 262 - struct mt7996_dev *dev = mt7996_hw_dev(hw); 263 - struct mt7996_phy *phy = mt7996_hw_phy(hw); 264 - int idx = msta->wcid.idx; 260 + struct mt7996_dev *dev = phy->dev; 261 + struct mt7996_vif_link *mlink; 262 + struct mt7996_sta *msta; 263 + int idx; 265 264 265 + mlink = mt7996_vif_conf_link(dev, vif, link_conf); 266 + if (!mlink) 267 + return; 268 + 269 + mlink->phy = NULL; 270 + msta = &mlink->sta; 271 + idx = msta->wcid.idx; 266 272 mt7996_mcu_add_sta(dev, vif, NULL, CONN_STATE_DISCONNECT, false); 267 273 mt7996_mcu_add_bss_info(phy, vif, false); 274 + 268 275 mt7996_mcu_add_dev_info(phy, vif, false); 269 276 270 277 rcu_assign_pointer(dev->mt76.wcid[idx], NULL); 271 278 272 279 mutex_lock(&dev->mt76.mutex); 273 - dev->mt76.vif_mask &= ~BIT_ULL(mvif->mt76.idx); 274 - phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx); 280 + dev->mt76.vif_mask &= ~BIT_ULL(mlink->mt76.idx); 281 + phy->omac_mask &= ~BIT_ULL(mlink->mt76.omac_idx); 275 282 mutex_unlock(&dev->mt76.mutex); 276 283 277 284 spin_lock_bh(&dev->mt76.sta_poll_lock); ··· 285 282 spin_unlock_bh(&dev->mt76.sta_poll_lock); 286 283 287 284 mt76_wcid_cleanup(&dev->mt76, &msta->wcid); 285 + } 286 + 287 + static int mt7996_add_interface(struct ieee80211_hw *hw, 288 + struct ieee80211_vif *vif) 289 + { 290 + struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 291 + struct mt7996_dev *dev = mt7996_hw_dev(hw); 292 + struct mt7996_phy *phy = mt7996_hw_phy(hw); 293 + int ret = 0; 294 + 295 + mutex_lock(&dev->mt76.mutex); 296 + 297 + mt76_vif_init(vif, &mvif->mt76); 298 + 299 + vif->offload_flags |= IEEE80211_OFFLOAD_ENCAP_4ADDR; 300 + ret = mt7996_vif_link_add(phy, vif, &vif->bss_conf); 301 + 302 + mutex_unlock(&dev->mt76.mutex); 303 + 304 + return ret; 305 + } 306 + 307 + static void mt7996_remove_interface(struct ieee80211_hw *hw, 308 + struct ieee80211_vif *vif) 309 + { 310 + struct mt7996_phy *phy = mt7996_hw_phy(hw); 311 + struct mt7996_dev *dev = mt7996_hw_dev(hw); 312 + 313 + mt7996_vif_link_remove(phy, vif, &vif->bss_conf); 314 + mt76_vif_cleanup(&dev->mt76, vif); 288 315 } 289 316 290 317 int mt7996_set_channel(struct mt76_phy *mphy) ··· 350 317 struct mt7996_dev *dev = mt7996_hw_dev(hw); 351 318 struct mt7996_phy *phy = mt7996_hw_phy(hw); 352 319 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 320 + struct mt7996_vif_link *mlink = &mvif->deflink; 353 321 struct mt7996_sta *msta = sta ? (struct mt7996_sta *)sta->drv_priv : 354 - &mvif->sta; 322 + &mlink->sta; 355 323 struct mt76_wcid *wcid = &msta->wcid; 356 324 u8 *wcid_keyidx = &wcid->hw_key_idx; 357 325 int idx = key->keyidx; ··· 398 364 399 365 mutex_lock(&dev->mt76.mutex); 400 366 401 - if (cmd == SET_KEY && !sta && !mvif->mt76.cipher) { 402 - mvif->mt76.cipher = mt76_connac_mcu_get_cipher(key->cipher); 367 + if (cmd == SET_KEY && !sta && !mlink->mt76.cipher) { 368 + mlink->mt76.cipher = mt76_connac_mcu_get_cipher(key->cipher); 403 369 mt7996_mcu_add_bss_info(phy, vif, true); 404 370 } 405 371 ··· 478 444 }; 479 445 480 446 /* firmware uses access class index */ 481 - mvif->queue_params[mq_to_aci[queue]] = *params; 447 + mvif->deflink.queue_params[mq_to_aci[queue]] = *params; 482 448 /* no need to update right away, we'll get BSS_CHANGED_QOS */ 483 449 484 450 return 0; ··· 550 516 case NL80211_IFTYPE_AP: { 551 517 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 552 518 553 - if (mvif->mt76.omac_idx > HW_BSSID_MAX) 519 + if (mvif->deflink.mt76.omac_idx > HW_BSSID_MAX) 554 520 return; 555 521 fallthrough; 556 522 } ··· 598 564 { 599 565 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 600 566 struct mt7996_dev *dev = mt7996_hw_dev(hw); 601 - u8 band = mvif->mt76.band_idx; 567 + u8 band = mvif->deflink.mt76.band_idx; 602 568 u32 *mu; 603 569 604 570 mu = (u32 *)info->mu_group.membership; ··· 700 666 struct mt7996_dev *dev = container_of(mdev, struct mt7996_dev, mt76); 701 667 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; 702 668 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 703 - u8 band_idx = mvif->phy->mt76->band_idx; 669 + u8 band_idx = mvif->deflink.phy->mt76->band_idx; 704 670 int idx; 705 671 706 672 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA); ··· 800 766 struct mt7996_vif *mvif; 801 767 802 768 mvif = (struct mt7996_vif *)vif->drv_priv; 803 - wcid = &mvif->sta.wcid; 769 + wcid = &mvif->deflink.sta.wcid; 804 770 } 805 771 806 772 mt76_tx(mphy, control->sta, wcid, skb); ··· 907 873 908 874 lockdep_assert_held(&dev->mt76.mutex); 909 875 910 - n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 911 - : mvif->mt76.omac_idx; 876 + n = mvif->deflink.mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 877 + : mvif->deflink.mt76.omac_idx; 912 878 /* TSF software read */ 913 879 mt76_rmw(dev, MT_LPON_TCR(phy->mt76->band_idx, n), MT_LPON_TCR_SW_MODE, 914 880 MT_LPON_TCR_SW_READ); ··· 947 913 948 914 mutex_lock(&dev->mt76.mutex); 949 915 950 - n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 951 - : mvif->mt76.omac_idx; 916 + n = mvif->deflink.mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 917 + : mvif->deflink.mt76.omac_idx; 952 918 mt76_wr(dev, MT_LPON_UTTR0(phy->mt76->band_idx), tsf.t32[0]); 953 919 mt76_wr(dev, MT_LPON_UTTR1(phy->mt76->band_idx), tsf.t32[1]); 954 920 /* TSF software overwrite */ ··· 973 939 974 940 mutex_lock(&dev->mt76.mutex); 975 941 976 - n = mvif->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 977 - : mvif->mt76.omac_idx; 942 + n = mvif->deflink.mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0 943 + : mvif->deflink.mt76.omac_idx; 978 944 mt76_wr(dev, MT_LPON_UTTR0(phy->mt76->band_idx), tsf.t32[0]); 979 945 mt76_wr(dev, MT_LPON_UTTR1(phy->mt76->band_idx), tsf.t32[1]); 980 946 /* TSF software adjust*/ ··· 1090 1056 static void mt7996_sta_rc_work(void *data, struct ieee80211_sta *sta) 1091 1057 { 1092 1058 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; 1093 - struct mt7996_dev *dev = msta->vif->phy->dev; 1059 + struct mt7996_dev *dev = msta->vif->deflink.phy->dev; 1094 1060 u32 *changed = data; 1095 1061 1096 1062 spin_lock_bh(&dev->mt76.sta_poll_lock); ··· 1122 1088 struct mt7996_dev *dev = phy->dev; 1123 1089 u32 changed = IEEE80211_RC_SUPP_RATES_CHANGED; 1124 1090 1125 - mvif->bitrate_mask = *mask; 1091 + mvif->deflink.bitrate_mask = *mask; 1126 1092 1127 1093 /* if multiple rates across different preambles are given we can 1128 1094 * reconfigure this info with all peers using sta_rec command with ··· 1306 1272 struct mt76_ethtool_worker_info *wi = wi_data; 1307 1273 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; 1308 1274 1309 - if (msta->vif->mt76.idx != wi->idx) 1275 + if (msta->vif->deflink.mt76.idx != wi->idx) 1310 1276 return; 1311 1277 1312 1278 mt76_ethtool_worker(wi, &msta->wcid.stats, true); ··· 1323 1289 struct mt76_mib_stats *mib = &phy->mib; 1324 1290 struct mt76_ethtool_worker_info wi = { 1325 1291 .data = data, 1326 - .idx = mvif->mt76.idx, 1292 + .idx = mvif->deflink.mt76.idx, 1327 1293 }; 1328 1294 /* See mt7996_ampdu_stat_read_phy, etc */ 1329 1295 int i, ei = 0; ··· 1492 1458 path->type = DEV_PATH_MTK_WDMA; 1493 1459 path->dev = ctx->dev; 1494 1460 path->mtk_wdma.wdma_idx = wed->wdma_idx; 1495 - path->mtk_wdma.bss = mvif->mt76.idx; 1461 + path->mtk_wdma.bss = mvif->deflink.mt76.idx; 1496 1462 path->mtk_wdma.queue = 0; 1497 1463 path->mtk_wdma.wcid = msta->wcid.idx; 1498 1464
+40 -40
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
··· 122 122 u16 mcs_map) 123 123 { 124 124 struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv; 125 - enum nl80211_band band = msta->vif->phy->mt76->chandef.chan->band; 126 - const u16 *mask = msta->vif->bitrate_mask.control[band].he_mcs; 125 + enum nl80211_band band = msta->vif->deflink.phy->mt76->chandef.chan->band; 126 + const u16 *mask = msta->vif->deflink.bitrate_mask.control[band].he_mcs; 127 127 int nss, max_nss = sta->deflink.rx_nss > 3 ? 4 : sta->deflink.rx_nss; 128 128 129 129 for (nss = 0; nss < max_nss; nss++) { ··· 892 892 893 893 mld = (struct bss_mld_tlv *)tlv; 894 894 mld->group_mld_id = 0xff; 895 - mld->own_mld_id = mvif->mt76.idx; 895 + mld->own_mld_id = mvif->deflink.mt76.idx; 896 896 mld->remap_idx = 0xff; 897 897 } 898 898 ··· 916 916 #define UNI_MUAR_ENTRY 2 917 917 struct mt7996_dev *dev = phy->dev; 918 918 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 919 - u32 idx = mvif->mt76.omac_idx - REPEATER_BSSID_START; 919 + u32 idx = mvif->deflink.mt76.omac_idx - REPEATER_BSSID_START; 920 920 const u8 *addr = vif->addr; 921 921 922 922 struct { ··· 957 957 mt7996_mcu_bss_ifs_timing_tlv(struct sk_buff *skb, struct ieee80211_vif *vif) 958 958 { 959 959 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 960 - struct mt7996_phy *phy = mvif->phy; 960 + struct mt7996_phy *phy = mvif->deflink.phy; 961 961 struct bss_ifs_time_tlv *ifs_time; 962 962 struct tlv *tlv; 963 963 bool is_2ghz = phy->mt76->chandef.chan->band == NL80211_BAND_2GHZ; ··· 1083 1083 struct mt7996_dev *dev = phy->dev; 1084 1084 struct sk_buff *skb; 1085 1085 1086 - if (mvif->mt76.omac_idx >= REPEATER_BSSID_START) { 1086 + if (mvif->deflink.mt76.omac_idx >= REPEATER_BSSID_START) { 1087 1087 mt7996_mcu_muar_config(phy, vif, false, enable); 1088 1088 mt7996_mcu_muar_config(phy, vif, true, enable); 1089 1089 } 1090 1090 1091 - skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, 1091 + skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->deflink.mt76, 1092 1092 MT7996_BSS_UPDATE_MAX_SIZE); 1093 1093 if (IS_ERR(skb)) 1094 1094 return PTR_ERR(skb); 1095 1095 1096 1096 /* bss_basic must be first */ 1097 1097 mt7996_mcu_bss_basic_tlv(skb, vif, NULL, phy->mt76, 1098 - mvif->sta.wcid.idx, enable); 1098 + mvif->deflink.sta.wcid.idx, enable); 1099 1099 mt7996_mcu_bss_sec_tlv(skb, vif); 1100 1100 1101 1101 if (vif->type == NL80211_IFTYPE_MONITOR) ··· 1128 1128 struct mt7996_dev *dev = phy->dev; 1129 1129 struct sk_buff *skb; 1130 1130 1131 - skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, 1131 + skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->deflink.mt76, 1132 1132 MT7996_BSS_UPDATE_MAX_SIZE); 1133 1133 if (IS_ERR(skb)) 1134 1134 return PTR_ERR(skb); ··· 1180 1180 if (enable && !params->amsdu) 1181 1181 msta->wcid.amsdu = false; 1182 1182 1183 - return mt7996_mcu_sta_ba(dev, &mvif->mt76, params, enable, true); 1183 + return mt7996_mcu_sta_ba(dev, &mvif->deflink.mt76, params, enable, true); 1184 1184 } 1185 1185 1186 1186 int mt7996_mcu_add_rx_ba(struct mt7996_dev *dev, ··· 1190 1190 struct mt7996_sta *msta = (struct mt7996_sta *)params->sta->drv_priv; 1191 1191 struct mt7996_vif *mvif = msta->vif; 1192 1192 1193 - return mt7996_mcu_sta_ba(dev, &mvif->mt76, params, enable, false); 1193 + return mt7996_mcu_sta_ba(dev, &mvif->deflink.mt76, params, enable, false); 1194 1194 } 1195 1195 1196 1196 static void ··· 1667 1667 struct ieee80211_vif *vif, struct ieee80211_sta *sta) 1668 1668 { 1669 1669 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 1670 - struct mt7996_phy *phy = mvif->phy; 1670 + struct mt7996_phy *phy = mvif->deflink.phy; 1671 1671 int tx_ant = hweight16(phy->mt76->chainmask) - 1; 1672 1672 struct sta_rec_bf *bf; 1673 1673 struct tlv *tlv; ··· 1738 1738 struct ieee80211_vif *vif, struct ieee80211_sta *sta) 1739 1739 { 1740 1740 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 1741 - struct mt7996_phy *phy = mvif->phy; 1741 + struct mt7996_phy *phy = mvif->deflink.phy; 1742 1742 int tx_ant = hweight8(phy->mt76->antenna_mask) - 1; 1743 1743 struct sta_rec_bfee *bfee; 1744 1744 struct tlv *tlv; ··· 1879 1879 struct sk_buff *skb; 1880 1880 struct tlv *tlv; 1881 1881 1882 - skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, 1882 + skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->deflink.mt76, 1883 1883 &msta->wcid, 1884 1884 MT7996_STA_UPDATE_MAX_SIZE); 1885 1885 if (IS_ERR(skb)) ··· 1915 1915 struct ieee80211_sta *sta) 1916 1916 { 1917 1917 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 1918 - struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef; 1919 - struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask; 1918 + struct cfg80211_chan_def *chandef = &mvif->deflink.phy->mt76->chandef; 1919 + struct cfg80211_bitrate_mask *mask = &mvif->deflink.bitrate_mask; 1920 1920 enum nl80211_band band = chandef->chan->band; 1921 1921 struct sta_phy_uni phy = {}; 1922 1922 int ret, nrates = 0; ··· 2003 2003 { 2004 2004 #define INIT_RCPI 180 2005 2005 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 2006 - struct mt76_phy *mphy = mvif->phy->mt76; 2006 + struct mt76_phy *mphy = mvif->deflink.phy->mt76; 2007 2007 struct cfg80211_chan_def *chandef = &mphy->chandef; 2008 - struct cfg80211_bitrate_mask *mask = &mvif->bitrate_mask; 2008 + struct cfg80211_bitrate_mask *mask = &mvif->deflink.bitrate_mask; 2009 2009 enum nl80211_band band = chandef->chan->band; 2010 2010 struct sta_rec_ra_uni *ra; 2011 2011 struct tlv *tlv; ··· 2111 2111 struct sk_buff *skb; 2112 2112 int ret; 2113 2113 2114 - skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, 2114 + skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->deflink.mt76, 2115 2115 &msta->wcid, 2116 2116 MT7996_STA_UPDATE_MAX_SIZE); 2117 2117 if (IS_ERR(skb)) ··· 2158 2158 .tag = cpu_to_le16(UNI_VOW_DRR_CTRL), 2159 2159 .len = cpu_to_le16(sizeof(req) - 4), 2160 2160 .action = cpu_to_le32(MT_STA_BSS_GROUP), 2161 - .val = cpu_to_le32(mvif->mt76.idx % 16), 2161 + .val = cpu_to_le32(mvif->deflink.mt76.idx % 16), 2162 2162 }; 2163 2163 2164 - msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->sta; 2164 + msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->deflink.sta; 2165 2165 req.wlan_idx = cpu_to_le16(msta->wcid.idx); 2166 2166 2167 2167 return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(VOW), &req, ··· 2177 2177 struct sk_buff *skb; 2178 2178 int ret; 2179 2179 2180 - msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->sta; 2180 + msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->deflink.sta; 2181 2181 link_sta = sta ? &sta->deflink : NULL; 2182 2182 2183 - skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, 2183 + skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->deflink.mt76, 2184 2184 &msta->wcid, 2185 2185 MT7996_STA_UPDATE_MAX_SIZE); 2186 2186 if (IS_ERR(skb)) ··· 2309 2309 struct tlv *tlv; 2310 2310 int ret; 2311 2311 2312 - skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, &mvif->sta.wcid); 2312 + skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->deflink.mt76, &mvif->deflink.sta.wcid); 2313 2313 if (IS_ERR(skb)) 2314 2314 return PTR_ERR(skb); 2315 2315 ··· 2345 2345 sizeof(struct mt7996_mcu_bcn_prot_tlv); 2346 2346 int ret; 2347 2347 2348 - skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, len); 2348 + skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->deflink.mt76, len); 2349 2349 if (IS_ERR(skb)) 2350 2350 return PTR_ERR(skb); 2351 2351 ··· 2405 2405 } __packed tlv; 2406 2406 } data = { 2407 2407 .hdr = { 2408 - .omac_idx = mvif->mt76.omac_idx, 2409 - .band_idx = mvif->mt76.band_idx, 2408 + .omac_idx = mvif->deflink.mt76.omac_idx, 2409 + .band_idx = mvif->deflink.mt76.band_idx, 2410 2410 }, 2411 2411 .tlv = { 2412 2412 .tag = cpu_to_le16(DEV_INFO_ACTIVE), ··· 2415 2415 }, 2416 2416 }; 2417 2417 2418 - if (mvif->mt76.omac_idx >= REPEATER_BSSID_START) 2418 + if (mvif->deflink.mt76.omac_idx >= REPEATER_BSSID_START) 2419 2419 return mt7996_mcu_muar_config(phy, vif, false, enable); 2420 2420 2421 2421 memcpy(data.tlv.omac_addr, vif->addr, ETH_ALEN); ··· 2540 2540 if (vif->bss_conf.nontransmitted) 2541 2541 return 0; 2542 2542 2543 - rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, 2543 + rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->deflink.mt76, 2544 2544 MT7996_MAX_BSS_OFFLOAD_SIZE); 2545 2545 if (IS_ERR(rskb)) 2546 2546 return PTR_ERR(rskb); ··· 2585 2585 struct ieee80211_hw *hw = mt76_hw(dev); 2586 2586 struct mt7996_phy *phy = mt7996_hw_phy(hw); 2587 2587 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 2588 - struct cfg80211_chan_def *chandef = &mvif->phy->mt76->chandef; 2588 + struct cfg80211_chan_def *chandef = &mvif->deflink.phy->mt76->chandef; 2589 2589 enum nl80211_band band = chandef->chan->band; 2590 2590 struct mt76_wcid *wcid = &dev->mt76.global_wcid; 2591 2591 struct bss_inband_discovery_tlv *discov; ··· 2598 2598 if (vif->bss_conf.nontransmitted) 2599 2599 return 0; 2600 2600 2601 - rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, 2601 + rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->deflink.mt76, 2602 2602 MT7996_MAX_BSS_OFFLOAD_SIZE); 2603 2603 if (IS_ERR(rskb)) 2604 2604 return PTR_ERR(rskb); ··· 3171 3171 u8 bss_idx; 3172 3172 u8 __rsv[3]; 3173 3173 } __packed hdr = { 3174 - .bss_idx = mvif->mt76.idx, 3174 + .bss_idx = mvif->deflink.mt76.idx, 3175 3175 }; 3176 3176 struct sk_buff *skb; 3177 3177 int len = sizeof(hdr) + IEEE80211_NUM_ACS * sizeof(struct edca); ··· 3184 3184 skb_put_data(skb, &hdr, sizeof(hdr)); 3185 3185 3186 3186 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 3187 - struct ieee80211_tx_queue_params *q = &mvif->queue_params[ac]; 3187 + struct ieee80211_tx_queue_params *q = &mvif->deflink.queue_params[ac]; 3188 3188 struct edca *e; 3189 3189 struct tlv *tlv; 3190 3190 ··· 4039 4039 { 4040 4040 struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; 4041 4041 struct mt7996_dev *dev = phy->dev; 4042 - u8 omac = mvif->mt76.omac_idx; 4042 + u8 omac = mvif->deflink.mt76.omac_idx; 4043 4043 struct { 4044 4044 u8 band_idx; 4045 4045 u8 __rsv[3]; ··· 4162 4162 struct sk_buff *skb; 4163 4163 struct tlv *tlv; 4164 4164 4165 - skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->mt76, len); 4165 + skb = __mt7996_mcu_alloc_bss_req(&dev->mt76, &mvif->deflink.mt76, len); 4166 4166 if (IS_ERR(skb)) 4167 4167 return PTR_ERR(skb); 4168 4168 ··· 4212 4212 .len = cpu_to_le16(sizeof(req) - 4), 4213 4213 .tbl_idx = flow->table_id, 4214 4214 .cmd = cmd, 4215 - .own_mac_idx = mvif->mt76.omac_idx, 4215 + .own_mac_idx = mvif->deflink.mt76.omac_idx, 4216 4216 .flowid = flow->id, 4217 4217 .peer_id = cpu_to_le16(flow->wcid), 4218 4218 .duration = flow->duration, 4219 - .bss = mvif->mt76.idx, 4220 - .bss_idx = mvif->mt76.idx, 4219 + .bss = mvif->deflink.mt76.idx, 4220 + .bss_idx = mvif->deflink.mt76.idx, 4221 4221 .start_tsf = cpu_to_le64(flow->tsf), 4222 4222 .mantissa = flow->mantissa, 4223 4223 .exponent = flow->exp, ··· 4313 4313 struct mt7996_sta *msta; 4314 4314 struct sk_buff *skb; 4315 4315 4316 - msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->sta; 4316 + msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->deflink.sta; 4317 4317 4318 - skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76, 4318 + skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->deflink.mt76, 4319 4319 &msta->wcid, 4320 4320 MT7996_STA_UPDATE_MAX_SIZE); 4321 4321 if (IS_ERR(skb))
+20 -1
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
··· 199 199 } twt; 200 200 }; 201 201 202 - struct mt7996_vif { 202 + struct mt7996_vif_link { 203 203 struct mt76_vif_link mt76; /* must be first */ 204 204 205 205 struct mt7996_sta sta; ··· 207 207 208 208 struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS]; 209 209 struct cfg80211_bitrate_mask bitrate_mask; 210 + }; 211 + 212 + struct mt7996_vif { 213 + struct mt7996_vif_link deflink; /* must be first */ 214 + struct mt76_vif_data mt76; 210 215 }; 211 216 212 217 /* crash-dump */ ··· 467 462 } 468 463 469 464 return true; 465 + } 466 + 467 + static inline struct mt7996_vif_link * 468 + mt7996_vif_link(struct mt7996_dev *dev, struct ieee80211_vif *vif, int link_id) 469 + { 470 + return (struct mt7996_vif_link *)mt76_vif_link(&dev->mt76, vif, link_id); 471 + } 472 + 473 + static inline struct mt7996_vif_link * 474 + mt7996_vif_conf_link(struct mt7996_dev *dev, struct ieee80211_vif *vif, 475 + struct ieee80211_bss_conf *link_conf) 476 + { 477 + return (struct mt7996_vif_link *)mt76_vif_conf_link(&dev->mt76, vif, 478 + link_conf); 470 479 } 471 480 472 481 extern const struct ieee80211_ops mt7996_ops;