Skip to content

Commit 4348254

Browse files
csyuancnbd168
authored andcommitted
wifi: mt76: mt7996: add helpers for wtbl and interface limit
Add helpers to get the maximum wtbl size and interface num based on hw caps. Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
1 parent 5d33053 commit 4348254

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

drivers/net/wireless/mediatek/mt76/mt7996/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static void mt7996_mac_init(struct mt7996_dev *dev)
256256

257257
mt76_clear(dev, MT_MDP_DCR2, MT_MDP_DCR2_RX_TRANS_SHORT);
258258

259-
for (i = 0; i < MT7996_WTBL_SIZE; i++)
259+
for (i = 0; i < mt7996_wtbl_size(dev); i++)
260260
mt7996_mac_wtbl_update(dev, i,
261261
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
262262

drivers/net/wireless/mediatek/mt76/mt7996/mac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data)
14301430
if (pid < MT_PACKET_ID_FIRST)
14311431
return;
14321432

1433-
if (wcidx >= MT7996_WTBL_SIZE)
1433+
if (wcidx >= mt7996_wtbl_size(dev))
14341434
return;
14351435

14361436
rcu_read_lock();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
170170
phy->monitor_vif = vif;
171171

172172
mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
173-
if (mvif->mt76.idx >= (MT7996_MAX_INTERFACES << dev->dbdc_support)) {
173+
if (mvif->mt76.idx >= mt7996_max_interface_num(dev)) {
174174
ret = -ENOSPC;
175175
goto out;
176176
}

drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
#include "../mt76_connac.h"
1212
#include "regs.h"
1313

14-
#define MT7996_MAX_INTERFACES 19
14+
#define MT7996_MAX_INTERFACES 19 /* per-band */
1515
#define MT7996_MAX_WMM_SETS 4
16-
#define MT7996_WTBL_SIZE 544
17-
#define MT7996_WTBL_RESERVED (MT7996_WTBL_SIZE - 1)
16+
#define MT7996_WTBL_RESERVED (mt7996_wtbl_size(dev) - 1)
1817
#define MT7996_WTBL_STA (MT7996_WTBL_RESERVED - \
19-
MT7996_MAX_INTERFACES)
18+
mt7996_max_interface_num(dev))
2019

2120
#define MT7996_WATCHDOG_TIME (HZ / 10)
2221
#define MT7996_RESET_TIMEOUT (30 * HZ)
@@ -447,6 +446,16 @@ int mt7996_mcu_fw_dbg_ctrl(struct mt7996_dev *dev, u32 module, u8 level);
447446
void mt7996_mcu_rx_event(struct mt7996_dev *dev, struct sk_buff *skb);
448447
void mt7996_mcu_exit(struct mt7996_dev *dev);
449448

449+
static inline u8 mt7996_max_interface_num(struct mt7996_dev *dev)
450+
{
451+
return MT7996_MAX_INTERFACES * (1 + dev->dbdc_support + dev->tbtc_support);
452+
}
453+
454+
static inline u16 mt7996_wtbl_size(struct mt7996_dev *dev)
455+
{
456+
return (dev->wtbl_size_group << 8) + 64;
457+
}
458+
450459
void mt7996_dual_hif_set_irq_mask(struct mt7996_dev *dev, bool write_reg,
451460
u32 clear, u32 set);
452461

0 commit comments

Comments
 (0)