Skip to content

Commit d97eaf6

Browse files
Ming Yen Hsiehopsiff
authored andcommitted
wifi: mt76: mt7925: adjust rm BSS flow to prevent next connection failure
mainline inclusion from mainline-v6.15-rc1 category: bugfix Removing BSS without removing STAREC first will cause firmware abnormal and next connection fail. Fixes: 8161610 ("wifi: mt76: mt7925: Cleanup MLO settings post-disconnection") Cc: stable@vger.kernel.org Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Tested-by: Caleb Jorden <cjorden@gmail.com> Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com> Link: https://patch.msgid.link/20250305000851.493671-4-sean.wang@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name> (cherry picked from commit 0ebb60d) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 3e2e6b1 commit d97eaf6

3 files changed

Lines changed: 91 additions & 33 deletions

File tree

drivers/net/wireless/mediatek/mt76/mt7925/main.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,12 @@ static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev,
11321132
struct mt792x_bss_conf *mconf;
11331133

11341134
mconf = mt792x_link_conf_to_mconf(link_conf);
1135-
mt792x_mac_link_bss_remove(dev, mconf, mlink);
1135+
1136+
if (ieee80211_vif_is_mld(vif))
1137+
mt792x_mac_link_bss_remove(dev, mconf, mlink);
1138+
else
1139+
mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, link_conf,
1140+
link_sta, false);
11361141
}
11371142

11381143
spin_lock_bh(&mdev->sta_poll_lock);
@@ -1152,6 +1157,31 @@ mt7925_mac_sta_remove_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
11521157
struct mt76_wcid *wcid;
11531158
unsigned int link_id;
11541159

1160+
/* clean up bss before starec */
1161+
for_each_set_bit(link_id, &old_links, IEEE80211_MLD_MAX_NUM_LINKS) {
1162+
struct ieee80211_link_sta *link_sta;
1163+
struct ieee80211_bss_conf *link_conf;
1164+
struct mt792x_bss_conf *mconf;
1165+
struct mt792x_link_sta *mlink;
1166+
1167+
link_sta = mt792x_sta_to_link_sta(vif, sta, link_id);
1168+
if (!link_sta)
1169+
continue;
1170+
1171+
mlink = mt792x_sta_to_link(msta, link_id);
1172+
if (!mlink)
1173+
continue;
1174+
1175+
link_conf = mt792x_vif_to_bss_conf(vif, link_id);
1176+
if (!link_conf)
1177+
continue;
1178+
1179+
mconf = mt792x_link_conf_to_mconf(link_conf);
1180+
1181+
mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, link_conf,
1182+
link_sta, false);
1183+
}
1184+
11551185
for_each_set_bit(link_id, &old_links, IEEE80211_MLD_MAX_NUM_LINKS) {
11561186
struct ieee80211_link_sta *link_sta;
11571187
struct mt792x_link_sta *mlink;
@@ -1190,44 +1220,14 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
11901220
{
11911221
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
11921222
struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv;
1193-
struct {
1194-
struct {
1195-
u8 omac_idx;
1196-
u8 band_idx;
1197-
__le16 pad;
1198-
} __packed hdr;
1199-
struct req_tlv {
1200-
__le16 tag;
1201-
__le16 len;
1202-
u8 active;
1203-
u8 link_idx; /* hw link idx */
1204-
u8 omac_addr[ETH_ALEN];
1205-
} __packed tlv;
1206-
} dev_req = {
1207-
.hdr = {
1208-
.omac_idx = 0,
1209-
.band_idx = 0,
1210-
},
1211-
.tlv = {
1212-
.tag = cpu_to_le16(DEV_INFO_ACTIVE),
1213-
.len = cpu_to_le16(sizeof(struct req_tlv)),
1214-
.active = true,
1215-
},
1216-
};
12171223
unsigned long rem;
12181224

12191225
rem = ieee80211_vif_is_mld(vif) ? msta->valid_links : BIT(0);
12201226

12211227
mt7925_mac_sta_remove_links(dev, vif, sta, rem);
12221228

1223-
if (ieee80211_vif_is_mld(vif)) {
1224-
mt7925_mcu_set_dbdc(&dev->mphy, false);
1225-
1226-
/* recovery omac address for the legacy interface */
1227-
memcpy(dev_req.tlv.omac_addr, vif->addr, ETH_ALEN);
1228-
mt76_mcu_send_msg(mdev, MCU_UNI_CMD(DEV_INFO_UPDATE),
1229-
&dev_req, sizeof(dev_req), true);
1230-
}
1229+
if (ieee80211_vif_is_mld(vif))
1230+
mt7925_mcu_del_dev(mdev, vif);
12311231

12321232
if (vif->type == NL80211_IFTYPE_STATION) {
12331233
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;

drivers/net/wireless/mediatek/mt76/mt7925/mcu.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,6 +2568,62 @@ int mt7925_mcu_set_timing(struct mt792x_phy *phy,
25682568
MCU_UNI_CMD(BSS_INFO_UPDATE), true);
25692569
}
25702570

2571+
void mt7925_mcu_del_dev(struct mt76_dev *mdev,
2572+
struct ieee80211_vif *vif)
2573+
{
2574+
struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv;
2575+
struct {
2576+
struct {
2577+
u8 omac_idx;
2578+
u8 band_idx;
2579+
__le16 pad;
2580+
} __packed hdr;
2581+
struct req_tlv {
2582+
__le16 tag;
2583+
__le16 len;
2584+
u8 active;
2585+
u8 link_idx; /* hw link idx */
2586+
u8 omac_addr[ETH_ALEN];
2587+
} __packed tlv;
2588+
} dev_req = {
2589+
.tlv = {
2590+
.tag = cpu_to_le16(DEV_INFO_ACTIVE),
2591+
.len = cpu_to_le16(sizeof(struct req_tlv)),
2592+
.active = true,
2593+
},
2594+
};
2595+
struct {
2596+
struct {
2597+
u8 bss_idx;
2598+
u8 pad[3];
2599+
} __packed hdr;
2600+
struct mt76_connac_bss_basic_tlv basic;
2601+
} basic_req = {
2602+
.basic = {
2603+
.tag = cpu_to_le16(UNI_BSS_INFO_BASIC),
2604+
.len = cpu_to_le16(sizeof(struct mt76_connac_bss_basic_tlv)),
2605+
.active = true,
2606+
.conn_state = 1,
2607+
},
2608+
};
2609+
2610+
dev_req.hdr.omac_idx = mvif->omac_idx;
2611+
dev_req.hdr.band_idx = mvif->band_idx;
2612+
2613+
basic_req.hdr.bss_idx = mvif->idx;
2614+
basic_req.basic.omac_idx = mvif->omac_idx;
2615+
basic_req.basic.band_idx = mvif->band_idx;
2616+
basic_req.basic.link_idx = mvif->link_idx;
2617+
2618+
mt76_mcu_send_msg(mdev, MCU_UNI_CMD(BSS_INFO_UPDATE),
2619+
&basic_req, sizeof(basic_req), true);
2620+
2621+
/* recovery omac address for the legacy interface */
2622+
memcpy(dev_req.tlv.omac_addr, vif->addr, ETH_ALEN);
2623+
mt76_mcu_send_msg(mdev, MCU_UNI_CMD(DEV_INFO_UPDATE),
2624+
&dev_req, sizeof(dev_req), true);
2625+
}
2626+
25712627
int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
25722628
struct ieee80211_chanctx_conf *ctx,
25732629
struct ieee80211_bss_conf *link_conf,

drivers/net/wireless/mediatek/mt76/mt7925/mcu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ int mt7925_mcu_sched_scan_req(struct mt76_phy *phy,
627627
int mt7925_mcu_sched_scan_enable(struct mt76_phy *phy,
628628
struct ieee80211_vif *vif,
629629
bool enable);
630+
void mt7925_mcu_del_dev(struct mt76_dev *mdev,
631+
struct ieee80211_vif *vif);
630632
int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
631633
struct ieee80211_chanctx_conf *ctx,
632634
struct ieee80211_bss_conf *link_conf,

0 commit comments

Comments
 (0)