public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Ryder Lee <ryder.lee@mediatek.com>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: Felix Fietkau <nbd@nbd.name>,
	Lorenzo Bianconi <lorenzo.bianconi@redhat.com>,
	Shayne Chen <shayne.chen@mediatek.com>,
	"Roy Luo" <royluo@google.com>, Sean Wang <sean.wang@mediatek.com>,
	<linux-wireless@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH 1/7] mt76: mt7615: simplify mcu_set_bmc flow
Date: Wed, 22 Jan 2020 00:00:39 +0800	[thread overview]
Message-ID: <1579622439.4993.17.camel@mtkswgap22> (raw)
In-Reply-To: <20200121151105.GA2396@localhost.localdomain>

On Tue, 2020-01-21 at 16:11 +0100, Lorenzo Bianconi wrote:
> > Move mcu_wtbl_bmc into mcu_set_sta_rec_bmc to simplify flow.
> > 
> > Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
> > ---
> >  .../net/wireless/mediatek/mt76/mt7615/main.c  |  3 +-
> >  .../net/wireless/mediatek/mt76/mt7615/mcu.c   | 97 ++++++++-----------
> >  .../wireless/mediatek/mt76/mt7615/mt7615.h    |  6 +-
> >  3 files changed, 45 insertions(+), 61 deletions(-)
> > 
> 
> [...]
> 
> > -int mt7615_mcu_set_sta_rec_bmc(struct mt7615_dev *dev,
> > -			       struct ieee80211_vif *vif, bool en)
> > +int mt7615_mcu_set_bmc(struct mt7615_dev *dev,
> > +		       struct ieee80211_vif *vif, bool en)
> >  {
> >  	struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
> >  	struct {
> >  		struct sta_req_hdr hdr;
> >  		struct sta_rec_basic basic;
> > -	} req = {
> > +		u8 buf[MT7615_WTBL_UPDATE_MAX_SIZE];
> > +	} __packed req = {
> >  		.hdr = {
> >  			.bss_idx = mvif->idx,
> >  			.wlan_idx = mvif->sta.wcid.idx,
> > @@ -1109,8 +1059,18 @@ int mt7615_mcu_set_sta_rec_bmc(struct mt7615_dev *dev,
> >  			.conn_type = cpu_to_le32(CONNECTION_INFRA_BC),
> >  		},
> >  	};
> > +	struct wtbl_req_hdr *wtbl_hdr;
> > +	struct wtbl_generic *wtbl_g;
> > +	struct wtbl_rx *wtbl_rx;
> > +	u8 *buf = req.buf;
> > +
> >  	eth_broadcast_addr(req.basic.peer_addr);
> >  
> > +	wtbl_hdr = (struct wtbl_req_hdr *)buf;
> > +	buf += sizeof(*wtbl_hdr);
> > +	wtbl_hdr->wlan_idx = mvif->sta.wcid.idx;
> > +	wtbl_hdr->operation = WTBL_RESET_AND_SET;
> > +
> >  	if (en) {
> >  		req.basic.conn_state = CONN_STATE_PORT_SECURE;
> >  		req.basic.extra_info = cpu_to_le16(EXTRA_INFO_VER |
> > @@ -1118,10 +1078,37 @@ int mt7615_mcu_set_sta_rec_bmc(struct mt7615_dev *dev,
> >  	} else {
> >  		req.basic.conn_state = CONN_STATE_DISCONNECT;
> >  		req.basic.extra_info = cpu_to_le16(EXTRA_INFO_VER);
> > +
> > +		__mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE,
> > +				    &req, (u8 *)wtbl_hdr - (u8 *)&req, true);
> 
> we need to check the return value from __mt76_mcu_send_msg here.

Okay, but it seems we lack of some error handling for mcu in main.c.

> Moreover, here (u8 *)wtbl_hdr - (u8 *)&req is
> sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_basic), right?
> I guess it would be easier to understand if we explicit the length, what do you think?

I'd love to explicit the length, but the length of these variable tlv
rely on sta's ht/vht_cap. Especially we have to take backward
compatibility (firmware v1) into account, and this actually makes code a
bit messy. 

> > +
> > +		return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
> > +					   (u8 *)wtbl_hdr, buf - (u8 *)wtbl_hdr,
> > +					   true);
> >  	}
> >  
> > +	wtbl_g = (struct wtbl_generic *)buf;
> > +	buf += sizeof(*wtbl_g);
> > +	wtbl_g->tag = cpu_to_le16(WTBL_GENERIC);
> > +	wtbl_g->len = cpu_to_le16(sizeof(*wtbl_g));
> > +	wtbl_g->muar_idx = 0xe;
> > +	eth_broadcast_addr(wtbl_g->peer_addr);
> > +
> > +	wtbl_rx = (struct wtbl_rx *)buf;
> > +	buf += sizeof(*wtbl_rx);
> > +	wtbl_rx->tag = cpu_to_le16(WTBL_RX);
> > +	wtbl_rx->len = cpu_to_le16(sizeof(*wtbl_rx));
> > +	wtbl_rx->rv = 1;
> > +	wtbl_rx->rca1 = 1;
> > +	wtbl_rx->rca2 = 1;
> > +
> > +	wtbl_hdr->tlv_num = cpu_to_le16(2);
> > +
> > +	__mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
> > +			    (u8 *)wtbl_hdr, buf - (u8 *)wtbl_hdr, true);
> 
> we need to check the return value from __mt76_mcu_send_msg here
> > +
> >  	return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE,
> > -				   &req, sizeof(req), true);
> > +				   &req, (u8 *)wtbl_hdr - (u8 *)&req, true);
> 
> same here about the length.
> 
> Regards,
> Lorenzo
> 
Ryder



      reply	other threads:[~2020-01-21 16:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-21 14:13 [PATCH 1/7] mt76: mt7615: simplify mcu_set_bmc flow Ryder Lee
2020-01-21 14:13 ` [PATCH 2/7] mt76: mt7615: simplify mcu_set_sta flow Ryder Lee
2020-01-21 14:13 ` [PATCH 3/7] mt76: mt7615: add a helper to encapsulate sta_rec operation Ryder Lee
2020-01-21 14:13 ` [PATCH 4/7] mt76: mt7615: adjust command flow for firmware v2 Ryder Lee
2020-01-21 14:13 ` [PATCH 5/7] mt76: mt7615: add a tag sta_rec_wtbl for v2 firmware Ryder Lee
2020-01-21 14:13 ` [PATCH 6/7] mt76: mt7615: switch mt7615_mcu_set_tx_ba to new MCU format Ryder Lee
2020-01-21 14:13 ` [PATCH 7/7] mt76: mt7615: switch mt7615_mcu_set_rx_ba " Ryder Lee
2020-01-21 15:11 ` [PATCH 1/7] mt76: mt7615: simplify mcu_set_bmc flow Lorenzo Bianconi
2020-01-21 16:00   ` Ryder Lee [this message]

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=1579622439.4993.17.camel@mtkswgap22 \
    --to=ryder.lee@mediatek.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=nbd@nbd.name \
    --cc=royluo@google.com \
    --cc=sean.wang@mediatek.com \
    --cc=shayne.chen@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