From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH mt76-next 18/18] wifi: mt76: mt7996: keep station wcids out of the duplicate WTBL range
Date: Wed, 25 Nov 2026 18:36:16 +0100 [thread overview]
Message-ID: <20261125173616.3776951-18-nbd@nbd.name> (raw)
In-Reply-To: <20261125173616.3776951-1-nbd@nbd.name>
mt7996_mcu_set_dup_wtbl() places the duplicate WTBL range at the top of
the station range. mt7996_global_wcid_init() and
mt7996_mac_sta_init_link() still allocate wcids up to MT7996_WTBL_STA.
The firmware repeats each WTBL write of a wcid below the range size on
its duplicate entry. A station with an index in the range thus shares
its WTBL entry with the duplicate of another station. On the largest
tables the firmware also moves the range down, so the range it uses is
not the one that the driver sends.
Send the base that the firmware uses, and allocate station wcids below
it. This lowers the station capacity by the size of the range, and on
the largest tables by a few more indexes. mt7990 gets no range, so its
station range does not change.
Fixes: 7f3ec778593f ("wifi: mt76: mt7996: add duplicated WTBL command")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
drivers/net/wireless/mediatek/mt76/mt7996/init.c | 3 ++-
drivers/net/wireless/mediatek/mt76/mt7996/main.c | 5 +++--
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 5 ++---
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h | 14 ++++++++++++++
4 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/init.c b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
index ec20fc8d823b..18eab0eaaaad 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
@@ -1260,7 +1260,8 @@ static int mt7996_variant_fem_init(struct mt7996_dev *dev)
int mt7996_global_wcid_init(struct mt7996_dev *dev)
{
- int idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA);
+ int idx = mt76_wcid_alloc(dev->mt76.wcid_mask,
+ mt7996_wtbl_sta_limit(dev));
if (idx)
return -ENOSPC;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index bcae654a2b47..bcecd6558fda 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -1378,7 +1378,7 @@ mt7996_mac_sta_init_link(struct mt7996_dev *dev,
if (!phy)
return -EINVAL;
- idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA);
+ idx = mt76_wcid_alloc(dev->mt76.wcid_mask, mt7996_wtbl_sta_limit(dev));
if (idx < 0)
return -ENOSPC;
@@ -3110,7 +3110,8 @@ mt7996_net_fill_forward_path(struct ieee80211_hw *hw,
if (!msta_link)
return -EIO;
- if (!msta_link->wcid.sta || msta_link->wcid.idx > MT7996_WTBL_STA)
+ if (!msta_link->wcid.sta ||
+ msta_link->wcid.idx >= mt7996_wtbl_sta_limit(dev))
return -EIO;
if (dev->hif2 &&
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index f7c08bc4a588..e4fd4b672e22 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -6008,7 +6008,6 @@ int mt7996_mcu_cp_support(struct mt7996_dev *dev, u8 mode)
int mt7996_mcu_set_dup_wtbl(struct mt7996_dev *dev)
{
-#define DUP_WTBL_NUM 80
struct {
u8 _rsv[4];
@@ -6020,8 +6019,8 @@ int mt7996_mcu_set_dup_wtbl(struct mt7996_dev *dev)
} __packed req = {
.tag = cpu_to_le16(UNI_CHIP_CONFIG_DUP_WTBL),
.len = cpu_to_le16(sizeof(req) - 4),
- .base = cpu_to_le16(MT7996_WTBL_STA - DUP_WTBL_NUM + 1),
- .num = cpu_to_le16(DUP_WTBL_NUM),
+ .base = cpu_to_le16(mt7996_dup_wtbl_base(dev)),
+ .num = cpu_to_le16(MT7996_DUP_WTBL_NUM),
};
if (is_mt7990(&dev->mt76))
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
index e6bf1151447f..1354bd82808c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
@@ -18,6 +18,7 @@
#define MT7996_WTBL_RESERVED (mt7996_wtbl_size(dev) - 1)
#define MT7996_WTBL_STA (MT7996_WTBL_RESERVED - \
mt7996_max_interface_num(dev))
+#define MT7996_DUP_WTBL_NUM 80
#define MT7996_WATCHDOG_TIME (HZ / 10)
#define MT7996_RESET_TIMEOUT (30 * HZ)
@@ -872,6 +873,19 @@ static inline u16 mt7996_wtbl_size(struct mt7996_dev *dev)
return (dev->wtbl_size_group << 8) + MT7996_WTBL_BMC_SIZE;
}
+static inline u16 mt7996_dup_wtbl_base(struct mt7996_dev *dev)
+{
+ return min_t(u16, MT7996_WTBL_STA + 1, 0x400) - MT7996_DUP_WTBL_NUM;
+}
+
+static inline u16 mt7996_wtbl_sta_limit(struct mt7996_dev *dev)
+{
+ if (is_mt7990(&dev->mt76))
+ return MT7996_WTBL_STA;
+
+ return mt7996_dup_wtbl_base(dev);
+}
+
void mt7996_dual_hif_set_irq_mask(struct mt7996_dev *dev, bool write_reg,
u32 clear, u32 set);
--
2.47.3
prev parent reply other threads:[~2026-11-25 17:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 17:35 [PATCH mt76-next 01/18] wifi: mt76: mt7925: keep the RX PN state of a station across a rekey Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 02/18] wifi: mt76: mt7915: hold the rate update of a station in power save Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 03/18] wifi: mt76: mt7996: take the phy of a fixed rate from the station link Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 04/18] wifi: mt76: mt7915: keep the BF column count within the row count Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 05/18] wifi: mt76: mt7996: report the tx power of the requested link Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 06/18] wifi: mt76: mt7996: refuse an RF register offset above 12 bits Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 07/18] wifi: mt76: mt7996: hold the mutex across the thermal protection store Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 08/18] wifi: mt76: mt7996: wait for the answer of each state command Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 09/18] wifi: mt76: mt7915: wait for the answer of the background chain control Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 10/18] wifi: mt76: mt7996: bound the in-band discovery frame by its buffer Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 11/18] wifi: mt76: mt7915: reset on an MCU timeout only once the hw is registered Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 12/18] wifi: mt76: mt7996: " Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 13/18] wifi: mt76: mt7915: mask the LDPC bits of STA_REC_HT and STA_REC_VHT Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 14/18] wifi: mt76: mt7996: mask the LDPC bits of STA_REC_HT, _VHT and _HE_V2 Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 15/18] wifi: mt76: mt7996: send HE_BASIC for each HE link of an MLD Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 16/18] wifi: mt76: restore the operating channel after a failed ROC start Felix Fietkau
2026-11-25 17:36 ` [PATCH mt76-next 17/18] wifi: mt76: mt7996: set the duplicate WTBL range again after a reset Felix Fietkau
2026-11-25 17:36 ` Felix Fietkau [this message]
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=20261125173616.3776951-18-nbd@nbd.name \
--to=nbd@nbd.name \
--cc=linux-wireless@vger.kernel.org \
/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