Commit 43482540 authored by Shayne Chen's avatar Shayne Chen Committed by Felix Fietkau
Browse files

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: default avatarShayne Chen <shayne.chen@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 5d33053b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -256,7 +256,7 @@ static void mt7996_mac_init(struct mt7996_dev *dev)

	mt76_clear(dev, MT_MDP_DCR2, MT_MDP_DCR2_RX_TRANS_SHORT);

	for (i = 0; i < MT7996_WTBL_SIZE; i++)
	for (i = 0; i < mt7996_wtbl_size(dev); i++)
		mt7996_mac_wtbl_update(dev, i,
				       MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

+1 −1
Original line number Diff line number Diff line
@@ -1430,7 +1430,7 @@ static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data)
	if (pid < MT_PACKET_ID_FIRST)
		return;

	if (wcidx >= MT7996_WTBL_SIZE)
	if (wcidx >= mt7996_wtbl_size(dev))
		return;

	rcu_read_lock();
+1 −1
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ static int mt7996_add_interface(struct ieee80211_hw *hw,
		phy->monitor_vif = vif;

	mvif->mt76.idx = __ffs64(~dev->mt76.vif_mask);
	if (mvif->mt76.idx >= (MT7996_MAX_INTERFACES << dev->dbdc_support)) {
	if (mvif->mt76.idx >= mt7996_max_interface_num(dev)) {
		ret = -ENOSPC;
		goto out;
	}
+13 −4
Original line number Diff line number Diff line
@@ -11,12 +11,11 @@
#include "../mt76_connac.h"
#include "regs.h"

#define MT7996_MAX_INTERFACES		19
#define MT7996_MAX_INTERFACES		19	/* per-band */
#define MT7996_MAX_WMM_SETS		4
#define MT7996_WTBL_SIZE		544
#define MT7996_WTBL_RESERVED		(MT7996_WTBL_SIZE - 1)
#define MT7996_WTBL_RESERVED		(mt7996_wtbl_size(dev) - 1)
#define MT7996_WTBL_STA			(MT7996_WTBL_RESERVED - \
					 MT7996_MAX_INTERFACES)
					 mt7996_max_interface_num(dev))

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

static inline u8 mt7996_max_interface_num(struct mt7996_dev *dev)
{
	return MT7996_MAX_INTERFACES * (1 + dev->dbdc_support + dev->tbtc_support);
}

static inline u16 mt7996_wtbl_size(struct mt7996_dev *dev)
{
	return (dev->wtbl_size_group << 8) + 64;
}

void mt7996_dual_hif_set_irq_mask(struct mt7996_dev *dev, bool write_reg,
				  u32 clear, u32 set);