From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Shayne Chen <shayne.chen@mediatek.com>
Cc: Felix Fietkau <nbd@nbd.name>,
linux-wireless <linux-wireless@vger.kernel.org>,
Ryder Lee <ryder.lee@mediatek.com>,
Evelyn Tsai <evelyn.tsai@mediatek.com>,
linux-mediatek <linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH mt76 09/12] wifi: mt76: mt7996: fix MLD group index assignment
Date: Wed, 5 Nov 2025 11:42:55 +0100 [thread overview]
Message-ID: <aQsqLyDjGonv2aip@lore-desk> (raw)
In-Reply-To: <20251105093100.541408-9-shayne.chen@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 3850 bytes --]
> Fix extender mode and MBSS issues caused by incorrect assignment of the
> MLD group and remap indices.
>
> Fixes: ed01c310eca9 ("wifi: mt76: mt7996: Fix mt7996_mcu_bss_mld_tlv routine")
> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> .../net/wireless/mediatek/mt76/mt7996/main.c | 58 +++++++++++++------
> 1 file changed, 40 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
> index 3958688d622b..346d650107d4 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
> @@ -90,9 +90,11 @@ static void mt7996_stop(struct ieee80211_hw *hw, bool suspend)
> {
> }
>
> -static inline int get_free_idx(u32 mask, u8 start, u8 end)
> +static inline int get_free_idx(u64 mask, u8 start, u8 end)
> {
> - return ffs(~mask & GENMASK(end, start));
> + if (~mask & GENMASK_ULL(end, start))
> + return __ffs64(~mask & GENMASK_ULL(end, start)) + 1;
> + return 0;
> }
>
> static int get_omac_idx(enum nl80211_iftype type, u64 mask)
> @@ -308,12 +310,6 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
> if (idx < 0)
> return -ENOSPC;
>
> - if (!dev->mld_idx_mask) { /* first link in the group */
> - mvif->mld_group_idx = get_own_mld_idx(dev->mld_idx_mask, true);
> - mvif->mld_remap_idx = get_free_idx(dev->mld_remap_idx_mask,
> - 0, 15);
> - }
> -
> mld_idx = get_own_mld_idx(dev->mld_idx_mask, false);
> if (mld_idx < 0)
> return -ENOSPC;
> @@ -331,10 +327,6 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
> return ret;
>
> dev->mt76.vif_mask |= BIT_ULL(mlink->idx);
> - if (!dev->mld_idx_mask) {
> - dev->mld_idx_mask |= BIT_ULL(mvif->mld_group_idx);
> - dev->mld_remap_idx_mask |= BIT_ULL(mvif->mld_remap_idx);
> - }
> dev->mld_idx_mask |= BIT_ULL(link->mld_idx);
> phy->omac_mask |= BIT_ULL(mlink->omac_idx);
>
> @@ -424,11 +416,6 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif,
> dev->mt76.vif_mask &= ~BIT_ULL(mlink->idx);
> dev->mld_idx_mask &= ~BIT_ULL(link->mld_idx);
> phy->omac_mask &= ~BIT_ULL(mlink->omac_idx);
> - if (!(dev->mld_idx_mask & ~BIT_ULL(mvif->mld_group_idx))) {
> - /* last link */
> - dev->mld_idx_mask &= ~BIT_ULL(mvif->mld_group_idx);
> - dev->mld_remap_idx_mask &= ~BIT_ULL(mvif->mld_remap_idx);
> - }
>
> spin_lock_bh(&dev->mt76.sta_poll_lock);
> if (!list_empty(&msta_link->wcid.poll_list))
> @@ -2225,7 +2212,42 @@ mt7996_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> u16 old_links, u16 new_links,
> struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS])
> {
> - return 0;
> + struct mt7996_dev *dev = mt7996_hw_dev(hw);
> + struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
> + int ret = 0;
> +
> + mutex_lock(&dev->mt76.mutex);
> +
> + if (!old_links) {
> + int idx;
> +
> + idx = get_own_mld_idx(dev->mld_idx_mask, true);
> + if (idx < 0) {
> + ret = -ENOSPC;
> + goto out;
> + }
> + mvif->mld_group_idx = idx;
> + dev->mld_idx_mask |= BIT_ULL(mvif->mld_group_idx);
> +
> + idx = get_free_idx(dev->mld_remap_idx_mask, 0, 15) - 1;
> + if (idx < 0) {
> + ret = -ENOSPC;
> + goto out;
> + }
> + mvif->mld_remap_idx = idx;
> + dev->mld_remap_idx_mask |= BIT_ULL(mvif->mld_remap_idx);
> + }
> +
> + if (new_links)
> + goto out;
> +
> + dev->mld_idx_mask &= ~BIT_ULL(mvif->mld_group_idx);
> + dev->mld_remap_idx_mask &= ~BIT_ULL(mvif->mld_remap_idx);
> +
> +out:
> + mutex_unlock(&dev->mt76.mutex);
> +
> + return ret;
> }
>
> static void
> --
> 2.51.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-11-05 10:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-05 9:30 [PATCH mt76 01/12] wifi: mt76: mt7996: fix max nss value when getting rx chainmask Shayne Chen
2025-11-05 9:30 ` [PATCH mt76 02/12] wifi: mt76: mt7996: no need to wait ACK event for SDO command Shayne Chen
2025-11-05 9:30 ` [PATCH mt76 03/12] wifi: mt76: mt7996: fix implicit beamforming support for mt7992 Shayne Chen
2025-11-05 9:30 ` [PATCH mt76 04/12] wifi: mt76: mt7996: support fixed rate for link station Shayne Chen
2025-11-05 9:30 ` [PATCH mt76 05/12] wifi: mt76: mt7996: fix several fields in mt7996_mcu_bss_basic_tlv() Shayne Chen
2025-11-05 10:04 ` Lorenzo Bianconi
2025-11-05 9:30 ` [PATCH mt76 06/12] wifi: mt76: mt7996: fix teardown command for an MLD peer Shayne Chen
2025-11-05 10:09 ` Lorenzo Bianconi
2025-11-05 9:30 ` [PATCH mt76 07/12] wifi: mt76: mt7996: set link_valid field when initializing wcid Shayne Chen
2025-11-05 10:15 ` Lorenzo Bianconi
2025-11-05 9:30 ` [PATCH mt76 08/12] wifi: mt76: mt7996: use correct link_id when filling TXD and TXP Shayne Chen
2025-11-05 10:34 ` Lorenzo Bianconi
2025-11-05 9:30 ` [PATCH mt76 09/12] wifi: mt76: mt7996: fix MLD group index assignment Shayne Chen
2025-11-05 10:42 ` Lorenzo Bianconi [this message]
2025-11-05 9:30 ` [PATCH mt76 10/12] wifi: mt76: mt7996: fix MLO set key and group key issues Shayne Chen
2025-11-05 9:30 ` [PATCH mt76 11/12] wifi: mt76: mt7996: fix using wrong phy to start in mt7996_mac_restart() Shayne Chen
2025-11-05 10:45 ` Lorenzo Bianconi
2025-11-05 9:31 ` [PATCH mt76 12/12] wifi: mt76: mt7996: fix EMI rings for RRO Shayne Chen
2025-11-05 10:57 ` Lorenzo Bianconi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aQsqLyDjGonv2aip@lore-desk \
--to=lorenzo@kernel.org \
--cc=evelyn.tsai@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=nbd@nbd.name \
--cc=ryder.lee@mediatek.com \
--cc=shayne.chen@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).