public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: sean.wang@mediatek.com
Cc: nbd@nbd.name, lorenzo.bianconi@redhat.com,
	Soul.Huang@mediatek.com, YN.Chen@mediatek.com,
	Leon.Yen@mediatek.com, Eric-SY.Chang@mediatek.com,
	Mark-YW.Chen@mediatek.com, Deren.Wu@mediatek.com,
	km.lin@mediatek.com, jenhao.yang@mediatek.com,
	robin.chiu@mediatek.com, Eddie.Chen@mediatek.com,
	ch.yeh@mediatek.com, posh.sun@mediatek.com,
	ted.huang@mediatek.com, Eric.Liang@mediatek.com,
	Stella.Chang@mediatek.com, Tom.Chou@mediatek.com,
	steve.lee@mediatek.com, jsiuda@google.com, frankgor@google.com,
	jemele@google.com, abhishekpandit@google.com, shawnku@google.com,
	linux-wireless@vger.kernel.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH v2 1/2] mt76: mt7921: fix up the monitor mode
Date: Sat, 26 Feb 2022 10:41:23 +0100	[thread overview]
Message-ID: <Yhn1w5YF3d0NW7qE@lore-desk> (raw)
In-Reply-To: <c61deba952e23bcfa98e28778bc11af524ad2f1e.1645832790.git.objelf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 5002 bytes --]

> From: Sean Wang <sean.wang@mediatek.com>
> 
> 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: Deren Wu <deren.wu@mediatek.com>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
> v2: 1. add Tested-by tag
>     2. make mt76_connac_mcu_set_sniffer mt7921 specific
>     3. align the structure declartion
> ---
>  .../wireless/mediatek/mt76/mt76_connac_mcu.h  |  1 +
>  .../net/wireless/mediatek/mt76/mt7921/main.c  | 23 +++++++-------
>  .../net/wireless/mediatek/mt76/mt7921/mcu.c   | 30 +++++++++++++++++++
>  .../wireless/mediatek/mt76/mt7921/mt7921.h    |  2 ++
>  4 files changed, 46 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> index 384c3eab1c8a..e5857d2cf78c 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> @@ -993,6 +993,7 @@ enum {
>  	MCU_UNI_CMD_SUSPEND = 0x05,
>  	MCU_UNI_CMD_OFFLOAD = 0x06,
>  	MCU_UNI_CMD_HIF_CTRL = 0x07,
> +	MCU_UNI_CMD_SNIFFER = 0x24,
>  };
>  
>  enum {
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index b6e836a4fad7..0f3c56530e66 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -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);
>  }
>  
> +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)
>  {
>  	struct ieee80211_hw *hw = dev->mphy.hw;
> @@ -516,16 +526,9 @@ static int mt7921_config(struct ieee80211_hw *hw, u32 changed)
>  	}
>  
>  	if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
> -		bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
> -
> -		if (!enabled)
> -			phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;
> -		else
> -			phy->rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC;

Hi Sean,

phy->rxfilter is used even in other codepath (e.g. mt7921_tm_set() or
mt7921_configure_filter()). I guess we should keep it updated here doing
something like:

		if (hw->conf.flags & IEEE80211_CONF_MONITOR)
			phy->rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC;
		else
			phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;

Agree?

Regards,
Lorenzo

> -
> -		mt76_rmw_field(dev, MT_DMA_DCR0(0), MT_DMA_DCR0_RXD_G5_EN,
> -			       enabled);
> -		mt76_wr(dev, MT_WF_RFCR(0), phy->rxfilter);
> +		ieee80211_iterate_active_interfaces(hw,
> +						    IEEE80211_IFACE_ITER_RESUME_ALL,
> +						    mt7921_sniffer_interface_iter, dev);
>  		mt7921_set_runtime_pm(dev);
>  	}
>  
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> index 33a836825cca..ab790e5df863 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> @@ -1133,3 +1133,33 @@ int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txpwr)
>  
>  	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);
> +}
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> index 9edc83f06139..9575d571b425 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> @@ -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);
>  void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data);
>  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
> -- 
> 2.25.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  parent reply	other threads:[~2022-02-26  9:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-26  0:26 [PATCH v2 1/2] mt76: mt7921: fix up the monitor mode sean.wang
2022-02-26  0:26 ` [PATCH v2 2/2] mt76: mt7921: use mt76_hw instead of open coding it sean.wang
2022-02-26  9:41 ` Lorenzo Bianconi [this message]
2022-02-26 16:52 ` [PATCH v2 1/2] mt76: mt7921: fix up the monitor mode Sven Eckelmann

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=Yhn1w5YF3d0NW7qE@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=Deren.Wu@mediatek.com \
    --cc=Eddie.Chen@mediatek.com \
    --cc=Eric-SY.Chang@mediatek.com \
    --cc=Eric.Liang@mediatek.com \
    --cc=Leon.Yen@mediatek.com \
    --cc=Mark-YW.Chen@mediatek.com \
    --cc=Soul.Huang@mediatek.com \
    --cc=Stella.Chang@mediatek.com \
    --cc=Tom.Chou@mediatek.com \
    --cc=YN.Chen@mediatek.com \
    --cc=abhishekpandit@google.com \
    --cc=ch.yeh@mediatek.com \
    --cc=frankgor@google.com \
    --cc=jemele@google.com \
    --cc=jenhao.yang@mediatek.com \
    --cc=jsiuda@google.com \
    --cc=km.lin@mediatek.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    --cc=posh.sun@mediatek.com \
    --cc=robin.chiu@mediatek.com \
    --cc=sean.wang@mediatek.com \
    --cc=shawnku@google.com \
    --cc=steve.lee@mediatek.com \
    --cc=ted.huang@mediatek.com \
    /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