From: Ryder Lee <ryder.lee@mediatek.com>
To: Felix Fietkau <nbd@nbd.name>,
Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Cc: Ryder Lee <ryder.lee@mediatek.com>,
Josh Boyer <jwboyer@kernel.org>,
Sean Wang <sean.wang@mediatek.com>,
linux-wireless@vger.kernel.org,
linux-mediatek@lists.infradead.org, Roy Luo <royluo@google.com>,
Shayne Chen <shayne.chen@mediatek.com>
Subject: [PATCH v2 3/7] mt76: mt7615: add a helper to encapsulate sta_rec operation
Date: Sat, 1 Feb 2020 23:33:48 +0800 [thread overview]
Message-ID: <0be0e4d66e8a775c7e0f0b9d9289cb149df97678.1580565624.git.ryder.lee@mediatek.com> (raw)
In-Reply-To: <cover.1580565624.git.ryder.lee@mediatek.com>
Operating command is simpler and just as clear
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Tested-by: Sean Wang <sean.wang@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7615/mcu.c | 122 ++++++++++--------
1 file changed, 65 insertions(+), 57 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index 30ff08bc9afc..baafa8fafaf1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -988,6 +988,33 @@ int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev)
&req, sizeof(req), true);
}
+static int
+mt7615_mcu_send_sta_rec(struct mt7615_dev *dev, u8 *req, u8 *wreq,
+ u8 wlen, bool enable)
+{
+ u32 slen = wreq - req;
+ int ret;
+
+ if (!enable) {
+ ret = __mt76_mcu_send_msg(&dev->mt76,
+ MCU_EXT_CMD_STA_REC_UPDATE,
+ req, slen, true);
+ if (ret)
+ return ret;
+
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
+ wreq, wlen, true);
+ }
+
+ ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE, wreq,
+ wlen, true);
+ if (ret)
+ return ret;
+
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE,
+ req, slen, true);
+}
+
int mt7615_mcu_set_bmc(struct mt7615_dev *dev,
struct ieee80211_vif *vif, bool en)
{
@@ -1029,13 +1056,7 @@ int mt7615_mcu_set_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);
-
- return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
- (u8 *)wtbl_hdr, buf - (u8 *)wtbl_hdr,
- true);
+ goto out;
}
wtbl_g = (struct wtbl_generic *)buf;
@@ -1055,11 +1076,9 @@ int mt7615_mcu_set_bmc(struct mt7615_dev *dev,
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);
-
- return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE,
- &req, (u8 *)wtbl_hdr - (u8 *)&req, true);
+out:
+ return mt7615_mcu_send_sta_rec(dev, (u8 *)&req, (u8 *)wtbl_hdr,
+ buf - (u8 *)wtbl_hdr, en);
}
int mt7615_mcu_set_sta(struct mt7615_dev *dev, struct ieee80211_vif *vif,
@@ -1076,7 +1095,6 @@ int mt7615_mcu_set_sta(struct mt7615_dev *dev, struct ieee80211_vif *vif,
.hdr = {
.bss_idx = mvif->idx,
.wlan_idx = msta->wcid.idx,
- .tlv_num = cpu_to_le16(1),
.is_tlv_append = 1,
.muar_idx = mvif->omac_idx,
},
@@ -1115,49 +1133,38 @@ int mt7615_mcu_set_sta(struct mt7615_dev *dev, struct ieee80211_vif *vif,
req.basic.conn_state = CONN_STATE_PORT_SECURE;
req.basic.extra_info = cpu_to_le16(EXTRA_INFO_VER |
EXTRA_INFO_NEW);
- } else {
- req.basic.conn_state = CONN_STATE_DISCONNECT;
- req.basic.extra_info = cpu_to_le16(EXTRA_INFO_VER);
-
- /* wtbl reset */
- wtbl_hdr = (struct wtbl_req_hdr *)buf;
- buf += sizeof(*wtbl_hdr);
- wtbl_hdr->wlan_idx = msta->wcid.idx;
- wtbl_hdr->operation = WTBL_RESET_AND_SET;
-
- __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE,
- &req, req.buf - (u8 *)&req, true);
-
- return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
- req.buf, buf - req.buf, true);
- }
-
- /* sta_rec ht */
- if (sta->ht_cap.ht_supported) {
- struct sta_rec_ht *sta_ht;
- sta_ht = (struct sta_rec_ht *)buf;
- buf += sizeof(*sta_ht);
- sta_ht->tag = cpu_to_le16(STA_REC_HT);
- sta_ht->len = cpu_to_le16(sizeof(*sta_ht));
- sta_ht->ht_cap = cpu_to_le16(sta->ht_cap.cap);
- stlv++;
+ /* sta_rec ht */
+ if (sta->ht_cap.ht_supported) {
+ struct sta_rec_ht *sta_ht;
- /* sta_rec vht */
- if (sta->vht_cap.vht_supported) {
- struct sta_rec_vht *sta_vht;
-
- sta_vht = (struct sta_rec_vht *)buf;
- buf += sizeof(*sta_vht);
- sta_vht->tag = cpu_to_le16(STA_REC_VHT);
- sta_vht->len = cpu_to_le16(sizeof(*sta_vht));
- sta_vht->vht_cap = cpu_to_le32(sta->vht_cap.cap);
- sta_vht->vht_rx_mcs_map =
- sta->vht_cap.vht_mcs.rx_mcs_map;
- sta_vht->vht_tx_mcs_map =
- sta->vht_cap.vht_mcs.tx_mcs_map;
+ sta_ht = (struct sta_rec_ht *)buf;
+ buf += sizeof(*sta_ht);
+ sta_ht->tag = cpu_to_le16(STA_REC_HT);
+ sta_ht->len = cpu_to_le16(sizeof(*sta_ht));
+ sta_ht->ht_cap = cpu_to_le16(sta->ht_cap.cap);
stlv++;
+
+ /* sta_rec vht */
+ if (sta->vht_cap.vht_supported) {
+ struct sta_rec_vht *sta_vht;
+
+ sta_vht = (struct sta_rec_vht *)buf;
+ buf += sizeof(*sta_vht);
+ sta_vht->tag = cpu_to_le16(STA_REC_VHT);
+ sta_vht->len = cpu_to_le16(sizeof(*sta_vht));
+ sta_vht->vht_cap =
+ cpu_to_le32(sta->vht_cap.cap);
+ sta_vht->vht_rx_mcs_map =
+ sta->vht_cap.vht_mcs.rx_mcs_map;
+ sta_vht->vht_tx_mcs_map =
+ sta->vht_cap.vht_mcs.tx_mcs_map;
+ stlv++;
+ }
}
+ } else {
+ req.basic.conn_state = CONN_STATE_DISCONNECT;
+ req.basic.extra_info = cpu_to_le16(EXTRA_INFO_VER);
}
/* wtbl */
@@ -1166,6 +1173,9 @@ int mt7615_mcu_set_sta(struct mt7615_dev *dev, struct ieee80211_vif *vif,
wtbl_hdr->wlan_idx = msta->wcid.idx;
wtbl_hdr->operation = WTBL_RESET_AND_SET;
+ if (!en)
+ goto out;
+
wtbl_g = (struct wtbl_generic *)buf;
buf += sizeof(*wtbl_g);
wtbl_g->tag = cpu_to_le16(WTBL_GENERIC);
@@ -1252,14 +1262,12 @@ int mt7615_mcu_set_sta(struct mt7615_dev *dev, struct ieee80211_vif *vif,
wtlv++;
}
+out:
wtbl_hdr->tlv_num = cpu_to_le16(wtlv);
req.hdr.tlv_num = cpu_to_le16(stlv);
- __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE, (u8 *)wtbl_hdr,
- buf - (u8 *)wtbl_hdr, true);
-
- return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE,
- &req, (u8 *)wtbl_hdr - (u8 *)&req, true);
+ return mt7615_mcu_send_sta_rec(dev, (u8 *)&req, (u8 *)wtbl_hdr,
+ buf - (u8 *)wtbl_hdr, en);
}
int mt7615_mcu_set_bcn(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2020-02-01 15:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-01 15:33 [PATCH v2 0/7] switch mt7615 MCU command format from v1 to v2 Ryder Lee
2020-02-01 15:33 ` [PATCH v2 1/7] mt76: mt7615: simplify mcu_set_bmc flow Ryder Lee
2020-02-01 15:33 ` [PATCH v2 2/7] mt76: mt7615: simplify mcu_set_sta flow Ryder Lee
2020-02-01 15:33 ` Ryder Lee [this message]
2020-02-01 15:33 ` [PATCH v2 4/7] mt76: mt7615: add starec operating flow for firmware v2 Ryder Lee
2020-02-01 15:33 ` [PATCH v2 5/7] mt76: mt7615: use new tag sta_rec_wtbl Ryder Lee
2020-02-01 15:33 ` [PATCH v2 6/7] mt76: mt7615: switch mt7615_mcu_set_tx_ba to v2 format Ryder Lee
2020-02-01 15:33 ` [PATCH v2 7/7] mt76: mt7615: switch mt7615_mcu_set_rx_ba " Ryder Lee
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=0be0e4d66e8a775c7e0f0b9d9289cb149df97678.1580565624.git.ryder.lee@mediatek.com \
--to=ryder.lee@mediatek.com \
--cc=jwboyer@kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).