Commit cbaa0a40 authored by Sean Wang's avatar Sean Wang Committed by Felix Fietkau

mt76: mt7921: fix up the monitor mode

Properly set up the monitor mode the firmware can support to fix up
RTS/CTS and beacon frames cannot be captured and forwarded to the host.
Tested-by: default avatarDeren Wu <deren.wu@mediatek.com>
Tested-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 4dd4ad44
...@@ -993,6 +993,7 @@ enum { ...@@ -993,6 +993,7 @@ enum {
MCU_UNI_CMD_SUSPEND = 0x05, MCU_UNI_CMD_SUSPEND = 0x05,
MCU_UNI_CMD_OFFLOAD = 0x06, MCU_UNI_CMD_OFFLOAD = 0x06,
MCU_UNI_CMD_HIF_CTRL = 0x07, MCU_UNI_CMD_HIF_CTRL = 0x07,
MCU_UNI_CMD_SNIFFER = 0x24,
}; };
enum { enum {
......
...@@ -479,6 +479,16 @@ mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) ...@@ -479,6 +479,16 @@ mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
mt7921_mcu_set_beacon_filter(dev, vif, dev->pm.enable); mt7921_mcu_set_beacon_filter(dev, vif, dev->pm.enable);
} }
static void
mt7921_sniffer_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
{
struct mt7921_dev *dev = priv;
struct ieee80211_hw *hw = mt76_hw(dev);
bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
mt7921_mcu_set_sniffer(dev, vif, enabled);
}
void mt7921_set_runtime_pm(struct mt7921_dev *dev) void mt7921_set_runtime_pm(struct mt7921_dev *dev)
{ {
struct ieee80211_hw *hw = dev->mphy.hw; struct ieee80211_hw *hw = dev->mphy.hw;
...@@ -516,16 +526,10 @@ static int mt7921_config(struct ieee80211_hw *hw, u32 changed) ...@@ -516,16 +526,10 @@ static int mt7921_config(struct ieee80211_hw *hw, u32 changed)
} }
if (changed & IEEE80211_CONF_CHANGE_MONITOR) { if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); ieee80211_iterate_active_interfaces(hw,
IEEE80211_IFACE_ITER_RESUME_ALL,
if (!enabled) mt7921_sniffer_interface_iter, dev);
phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC; dev->mt76.rxfilter = mt76_rr(dev, MT_WF_RFCR(0));
else
phy->rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC;
mt76_rmw_field(dev, MT_DMA_DCR0(0), MT_DMA_DCR0_RXD_G5_EN,
enabled);
mt76_wr(dev, MT_WF_RFCR(0), phy->rxfilter);
mt7921_set_runtime_pm(dev); mt7921_set_runtime_pm(dev);
} }
......
...@@ -1135,3 +1135,33 @@ int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txpwr) ...@@ -1135,3 +1135,33 @@ int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txpwr)
return 0; return 0;
} }
int mt7921_mcu_set_sniffer(struct mt7921_dev *dev, struct ieee80211_vif *vif,
bool enable)
{
struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
struct {
struct {
u8 band_idx;
u8 pad[3];
} __packed hdr;
struct sniffer_enable_tlv {
__le16 tag;
__le16 len;
u8 enable;
u8 pad[3];
} __packed enable;
} req = {
.hdr = {
.band_idx = mvif->band_idx,
},
.enable = {
.tag = cpu_to_le16(0),
.len = cpu_to_le16(sizeof(struct sniffer_enable_tlv)),
.enable = enable,
},
};
return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(SNIFFER), &req, sizeof(req),
true);
}
...@@ -452,4 +452,6 @@ void mt7921s_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e); ...@@ -452,4 +452,6 @@ void mt7921s_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e);
bool mt7921s_tx_status_data(struct mt76_dev *mdev, u8 *update); bool mt7921s_tx_status_data(struct mt76_dev *mdev, u8 *update);
void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data); void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data);
void mt7921_set_runtime_pm(struct mt7921_dev *dev); void mt7921_set_runtime_pm(struct mt7921_dev *dev);
int mt7921_mcu_set_sniffer(struct mt7921_dev *dev, struct ieee80211_vif *vif,
bool enable);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment