2023-09-11 21:49:21

by Felix Fietkau

[permalink] [raw]
Subject: [PATCH] wifi: mt76: mt7915: fix monitor mode issues

Enable receiving other-unicast packets
Disable RX header translation in order to proprerly receive data packets.
Fixes warnings and missed packets when rx decap offload is enabled

Signed-off-by: Felix Fietkau <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7915/main.c | 24 ++++++++++++++-----
.../wireless/mediatek/mt76/mt7915/mt7915.h | 2 ++
.../net/wireless/mediatek/mt76/mt7915/regs.h | 1 +
3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
index 55809d9f7a7b..240483154faa 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
@@ -483,16 +483,22 @@ static int mt7915_config(struct ieee80211_hw *hw, u32 changed)
if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
bool band = phy->mt76->band_idx;
+ u32 rxfilter = phy->rxfilter;

- if (!enabled)
- phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;
- else
- phy->rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC;
+ if (!enabled) {
+ rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;
+ dev->monitor_mask &= ~BIT(band);
+ } else {
+ rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC;
+ dev->monitor_mask |= BIT(band);
+ }

mt76_rmw_field(dev, MT_DMA_DCR0(band), MT_DMA_DCR0_RXD_G5_EN,
enabled);
+ mt76_rmw_field(dev, MT_DMA_DCR0(band), MT_MDP_DCR0_RX_HDR_TRANS_EN,
+ !dev->monitor_mask);
mt76_testmode_reset(phy->mt76, true);
- mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter);
+ mt76_wr(dev, MT_WF_RFCR(band), rxfilter);
}

mutex_unlock(&dev->mt76.mutex);
@@ -527,6 +533,7 @@ static void mt7915_configure_filter(struct ieee80211_hw *hw,
MT_WF_RFCR1_DROP_BA |
MT_WF_RFCR1_DROP_CFEND |
MT_WF_RFCR1_DROP_CFACK;
+ u32 rxfilter;
u32 flags = 0;

#define MT76_FILTER(_flag, _hw) do { \
@@ -561,7 +568,12 @@ static void mt7915_configure_filter(struct ieee80211_hw *hw,
MT_WF_RFCR_DROP_NDPA);

*total_flags = flags;
- mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter);
+ rxfilter = phy->rxfilter;
+ if (hw->conf.flags & IEEE80211_CONF_MONITOR)
+ rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC;
+ else
+ rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;
+ mt76_wr(dev, MT_WF_RFCR(band), rxfilter);

if (*total_flags & FIF_CONTROL)
mt76_clear(dev, MT_WF_RFCR1(band), ctl_flags);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
index 0456e56f6348..795c3e6f80ca 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
@@ -295,6 +295,8 @@ struct mt7915_dev {
bool muru_debug;
bool ibf;

+ u8 monitor_mask;
+
struct dentry *debugfs_dir;
struct rchan *relay_fwlog;

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
index 588cd87e24e9..89ac8e6707b8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
@@ -172,6 +172,7 @@ enum offs_rev {

#define MT_MDP_DCR0 MT_MDP(0x000)
#define MT_MDP_DCR0_DAMSDU_EN BIT(15)
+#define MT_MDP_DCR0_RX_HDR_TRANS_EN BIT(19)

#define MT_MDP_DCR1 MT_MDP(0x004)
#define MT_MDP_DCR1_MAX_RX_LEN GENMASK(15, 3)
--
2.41.0