Linux-mediatek Archive on lore.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,
	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,
	Stella.Chang@mediatek.com, Tom.Chou@mediatek.com,
	steve.lee@mediatek.com, jsiuda@google.com, frankgor@google.com,
	kuabhs@google.com, druth@google.com, abhishekpandit@google.com,
	shawnku@google.com, linux-wireless@vger.kernel.org,
	linux-mediatek@lists.infradead.org,
	Quan Zhou <quan.zhou@mediatek.com>,
	Kaikai Hu <kaikai.hu@mediatek.com>
Subject: Re: [PATCH 5/9] wifi: mt76: mt7921: add unified ROC cmd/event support
Date: Wed, 17 Aug 2022 09:15:43 +0200	[thread overview]
Message-ID: <YvyVn439t0z/Yzfy@lore-desk> (raw)
In-Reply-To: <31abc0972859270b619b098bdcd02d4b8d5fdaa0.1660606893.git.objelf@gmail.com>

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

On Aug 16, Sean Wang wrote:
> From: Quan Zhou <quan.zhou@mediatek.com>
> 
> Add unified ROC cmd/event which is only supported by the newer fw.
> 
> Co-developed-by: Sean Wang <sean.wang@mediatek.com>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> Co-developed-by: Deren Wu <deren.wu@mediatek.com>
> Signed-off-by: Deren Wu <deren.wu@mediatek.com>
> Co-developed-by: Kaikai Hu <kaikai.hu@mediatek.com>
> Signed-off-by: Kaikai Hu <kaikai.hu@mediatek.com>
> Signed-off-by: Quan Zhou <quan.zhou@mediatek.com>
> ---
>  .../wireless/mediatek/mt76/mt76_connac_mcu.h  |  10 +-
>  .../net/wireless/mediatek/mt76/mt7921/mcu.c   | 119 ++++++++++++++++++
>  .../wireless/mediatek/mt76/mt7921/mt7921.h    |  19 +++
>  3 files changed, 147 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> index 1fcc3e8c5380..f3c1e1dc574a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
> @@ -114,11 +114,15 @@ struct mt76_connac2_mcu_rxd {
>  
>  	u8 eid;
>  	u8 seq;
> -	u8 rsv[2];
> +	u8 option;
> +	u8 __rsv;
> +

nit: remove new line here and use 'u8 rsv' to be consistent with the rest of
the code.

>  
>  	u8 ext_eid;
>  	u8 rsv1[2];
>  	u8 s2d_index;
> +
> +	u8 tlv[0];
>  };
>  
>  struct mt76_connac2_patch_hdr {
> @@ -938,6 +942,9 @@ enum {
>  	DEV_INFO_MAX_NUM
>  };
>  
> +#define MCU_UNI_CMD_EVENT                       BIT(1)
> +#define MCU_UNI_CMD_UNSOLICITED_EVENT           BIT(2)
> +
>  /* event table */
>  enum {
>  	MCU_EVENT_TARGET_ADDRESS_LEN = 0x01,
> @@ -1144,6 +1151,7 @@ enum {
>  	MCU_UNI_CMD_OFFLOAD = 0x06,
>  	MCU_UNI_CMD_HIF_CTRL = 0x07,
>  	MCU_UNI_CMD_SNIFFER = 0x24,
> +	MCU_UNI_CMD_ROC = 0x27,
>  };
>  
>  enum {
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> index da12d0ae0835..76c8afc00c24 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
> @@ -275,6 +275,23 @@ mt7921_mcu_rx_unsolicited_event(struct mt7921_dev *dev, struct sk_buff *skb)
>  	dev_kfree_skb(skb);
>  }
>  
> +static void
> +mt7921_mcu_uni_rx_unsolicited_event(struct mt7921_dev *dev,
> +				    struct sk_buff *skb)
> +{
> +	struct mt76_connac2_mcu_rxd *rxd;
> +
> +	rxd = (struct mt76_connac2_mcu_rxd *)skb->data;
> +
> +	switch (rxd->eid) {
> +	case MCU_UNI_EVENT_ROC:
> +		break;
> +	default:
> +		break;
> +	}
> +	dev_kfree_skb(skb);
> +}
> +
>  void mt7921_mcu_rx_event(struct mt7921_dev *dev, struct sk_buff *skb)
>  {
>  	struct mt76_connac2_mcu_rxd *rxd;
> @@ -284,6 +301,11 @@ void mt7921_mcu_rx_event(struct mt7921_dev *dev, struct sk_buff *skb)
>  
>  	rxd = (struct mt76_connac2_mcu_rxd *)skb->data;
>  
> +	if (rxd->option & MCU_UNI_CMD_UNSOLICITED_EVENT) {
> +		mt7921_mcu_uni_rx_unsolicited_event(dev, skb);
> +		return;
> +	}
> +
>  	if (rxd->eid == 0x6) {
>  		mt76_mcu_rx_event(&dev->mt76, skb);
>  		return;
> @@ -521,6 +543,103 @@ int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif)
>  				 &req_mu, sizeof(req_mu), false);
>  }
>  
> +int mt7921_mcu_set_roc(struct mt7921_phy *phy, struct mt7921_vif *vif,
> +		       struct ieee80211_channel *chan, int duration,
> +		       enum mt7921_roc_req type, u8 token_id)
> +{
> +	int center_ch = ieee80211_frequency_to_channel(chan->center_freq);
> +	struct mt7921_dev *dev = phy->dev;
> +	struct {
> +		struct {
> +			u8 rsv[4];
> +		} __packed hdr;
> +		struct roc_acquire_tlv {
> +			__le16 tag;
> +			__le16 len;
> +			u8 bss_idx;
> +			u8 tokenid;
> +			u8 control_channel;
> +			u8 sco;
> +			u8 band;
> +			u8 bw;
> +			u8 center_chan;
> +			u8 center_chan2;
> +			u8 bw_from_ap;
> +			u8 center_chan_from_ap;
> +			u8 center_chan2_from_ap;
> +			u8 reqtype;
> +			__le32 maxinterval;
> +			u8 dbdcband;
> +			u8 rsv[3];
> +		} __packed roc;
> +	} __packed req = {
> +		.roc = {
> +			.tag = cpu_to_le16(UNI_ROC_ACQUIRE),
> +			.len = cpu_to_le16(sizeof(struct roc_acquire_tlv)),
> +			.tokenid = token_id,
> +			.reqtype = type,
> +			.maxinterval = cpu_to_le32(duration),
> +			.bss_idx = vif->mt76.idx,
> +			.control_channel = chan->hw_value,
> +			.bw = CMD_CBW_20MHZ,
> +			.bw_from_ap = CMD_CBW_20MHZ,
> +			.center_chan = center_ch,
> +			.center_chan_from_ap = center_ch,
> +			.dbdcband = 0xff, /* auto */
> +		},
> +	};
> +
> +	if (chan->hw_value < center_ch)
> +		req.roc.sco = 1; /* SCA */
> +	else if (chan->hw_value > center_ch)
> +		req.roc.sco = 3; /* SCB */
> +
> +	switch (chan->band) {
> +	case NL80211_BAND_6GHZ:
> +		req.roc.band = 3;
> +		break;
> +	case NL80211_BAND_5GHZ:
> +		req.roc.band = 2;
> +		break;
> +	default:
> +		req.roc.band = 1;
> +		break;
> +	}
> +
> +	return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(ROC),
> +				 &req, sizeof(req), false);
> +}
> +
> +int mt7921_mcu_abort_roc(struct mt7921_phy *phy, struct mt7921_vif *vif,
> +			 u8 token_id)
> +{
> +	struct mt7921_dev *dev = phy->dev;
> +	struct {
> +		struct {
> +			u8 rsv[4];
> +		} __packed hdr;
> +		struct roc_abort_tlv {
> +			__le16 tag;
> +			__le16 len;
> +			u8 bss_idx;
> +			u8 tokenid;
> +			u8 dbdcband;
> +			u8 rsv[5];
> +		} __packed abort;
> +	} __packed req = {
> +		.abort = {
> +			.tag = cpu_to_le16(UNI_ROC_ABORT),
> +			.len = cpu_to_le16(sizeof(struct roc_abort_tlv)),
> +			.tokenid = token_id,
> +			.bss_idx = vif->mt76.idx,
> +			.dbdcband = 0xff, /* auto*/
> +		},
> +	};
> +
> +	return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(ROC),
> +				 &req, sizeof(req), false);
> +}
> +
>  int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd)
>  {
>  	struct mt7921_dev *dev = phy->dev;
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> index c161031ac62a..c9044d546e94 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
> @@ -51,6 +51,20 @@
>  #define MT7921_SDIO_HDR_TX_BYTES	GENMASK(15, 0)
>  #define MT7921_SDIO_HDR_PKT_TYPE	GENMASK(17, 16)
>  
> +#define MCU_UNI_EVENT_ROC  0x27
> +
> +enum {
> +	UNI_ROC_ACQUIRE,
> +	UNI_ROC_ABORT,
> +	UNI_ROC_NUM
> +};
> +
> +enum mt7921_roc_req {
> +	MT7921_ROC_REQ_JOIN,
> +	MT7921_ROC_REQ_ROC,
> +	MT7921_ROC_REQ_NUM
> +};
> +
>  enum mt7921_sdio_pkt_type {
>  	MT7921_SDIO_TXD,
>  	MT7921_SDIO_DATA,
> @@ -479,4 +493,9 @@ mt7921_init_acpi_sar_power(struct mt7921_phy *phy, bool set_default)
>  #endif
>  int mt7921_set_tx_sar_pwr(struct ieee80211_hw *hw,
>  			  const struct cfg80211_sar_specs *sar);
> +int mt7921_mcu_set_roc(struct mt7921_phy *phy, struct mt7921_vif *vif,
> +		       struct ieee80211_channel *chan, int duration,
> +		       enum mt7921_roc_req type, u8 token_id);
> +int mt7921_mcu_abort_roc(struct mt7921_phy *phy, struct mt7921_vif *vif,
> +			 u8 token_id);
>  #endif
> -- 
> 2.25.1
> 

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

  reply	other threads:[~2022-08-17  7:16 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16  0:03 [PATCH 0/9] wifi: mt76: mt7921: introduce chanctx support sean.wang
2022-08-16  0:03 ` [PATCH 1/9] wifi: mac80211: allow enabling chanctx until hw registration sean.wang
2022-08-16  8:03   ` Johannes Berg
2022-08-17  8:28     ` Sean Wang
2022-08-17  8:30       ` Johannes Berg
2022-08-18  0:11         ` Sean Wang
2022-08-18 10:49           ` Johannes Berg
2022-08-18 23:40             ` Sean Wang
2022-08-19 17:16               ` Johannes Berg
2022-08-19 17:36                 ` Johannes Berg
2022-08-16  0:03 ` [PATCH 2/9] wifi: mt76: connac: add mt76_connac_mcu_uni_set_chctx sean.wang
2022-08-17  7:13   ` Lorenzo Bianconi
2022-08-16  0:03 ` [PATCH 3/9] wifi: mt76: connac: rely on mt76_connac_mcu_uni_set_chctx sean.wang
2022-08-17  7:13   ` Lorenzo Bianconi
2022-08-16  0:03 ` [PATCH 4/9] wifi: mt76: mt7921: add chanctx parameter to mt76_connac_mcu_uni_add_bss signature sean.wang
2022-08-16  0:03 ` [PATCH 5/9] wifi: mt76: mt7921: add unified ROC cmd/event support sean.wang
2022-08-17  7:15   ` Lorenzo Bianconi [this message]
2022-08-16  0:03 ` [PATCH 6/9] wifi: mt76: mt7921: drop ieee80211_[start, stop]_queues in driver sean.wang
2022-08-17  7:16   ` Lorenzo Bianconi
2022-08-18  0:44     ` Sean Wang
2022-08-16  0:03 ` [PATCH 7/9] wifi: mt76: connac: accept hw scan request at a time sean.wang
2022-08-16  0:03 ` [PATCH 8/9] wifi: mt76: mt7921: introduce remain_on_channel support sean.wang
2022-08-17  7:12   ` Lorenzo Bianconi
2022-08-18  1:03     ` Sean Wang
2022-08-18  7:39       ` Lorenzo Bianconi
2022-08-25  0:10         ` Sean Wang
2022-08-30  5:18           ` Kalle Valo
2022-08-16  0:03 ` [PATCH 9/9] wifi: mt76: mt7921: introduce chanctx support sean.wang
2022-08-17  7:24   ` Lorenzo Bianconi
2022-08-18  0:37     ` Sean Wang
2022-08-18  7:43       ` Lorenzo Bianconi

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=YvyVn439t0z/Yzfy@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=Deren.Wu@mediatek.com \
    --cc=Eddie.Chen@mediatek.com \
    --cc=Eric-SY.Chang@mediatek.com \
    --cc=Leon.Yen@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=druth@google.com \
    --cc=frankgor@google.com \
    --cc=jenhao.yang@mediatek.com \
    --cc=jsiuda@google.com \
    --cc=kaikai.hu@mediatek.com \
    --cc=km.lin@mediatek.com \
    --cc=kuabhs@google.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=quan.zhou@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