linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: nbd@nbd.name
Cc: lorenzo.bianconi@redhat.com, sean.wang@mediatek.com,
	ryder.lee@mediatek.com, linux-wireless@vger.kernel.org,
	linux-mediatek@lists.infradead.org
Subject: [PATCH v4 20/25] mt76: mt7615: introduce uni cmd command types
Date: Tue, 17 Mar 2020 17:41:27 +0100	[thread overview]
Message-ID: <99d40d768390f9cddbf8b52135680fd3193c4abf.1584463004.git.lorenzo@kernel.org> (raw)
In-Reply-To: <cover.1584463004.git.lorenzo@kernel.org>

Introduce mcu uni command type. Uni commands rely on a stripped verions
of mt7615_mcu_txd data strutture. Split mt7615_mcu_txd_common and
mt7615_mcu_txd. Uni commands will be use by mt7663e driver

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 .../net/wireless/mediatek/mt76/mt7615/mcu.c   | 27 ++++++---
 .../net/wireless/mediatek/mt76/mt7615/mcu.h   | 60 ++++++++++++++++++-
 2 files changed, 79 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index e73cd3cb014a..372ffc6322c9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -52,7 +52,8 @@ struct mt7615_fw_trailer {
 void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,
 			 int cmd, int *wait_seq)
 {
-	int mcu_cmd = cmd & MCU_CMD_MASK;
+	int txd_len, mcu_cmd = cmd & MCU_CMD_MASK;
+	struct mt7615_uni_txd *uni_txd;
 	struct mt7615_mcu_txd *mcu_txd;
 	u8 seq, q_idx, pkt_fmt;
 	__le32 *txd;
@@ -61,8 +62,11 @@ void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,
 	seq = ++dev->mt76.mcu.msg_seq & 0xf;
 	if (!seq)
 		seq = ++dev->mt76.mcu.msg_seq & 0xf;
+	if (wait_seq)
+		*wait_seq = seq;
 
-	mcu_txd = (struct mt7615_mcu_txd *)skb_push(skb, sizeof(*mcu_txd));
+	txd_len = cmd & MCU_UNI_PREFIX ? sizeof(*uni_txd) : sizeof(*mcu_txd);
+	txd = (__le32 *)skb_push(skb, txd_len);
 
 	if (cmd != MCU_CMD_FW_SCATTER) {
 		q_idx = MT_TX_MCU_PORT_RX_Q0;
@@ -71,7 +75,6 @@ void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,
 		q_idx = MT_TX_MCU_PORT_RX_FWDL;
 		pkt_fmt = MT_TX_TYPE_FW;
 	}
-	txd = mcu_txd->txd;
 
 	val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len) |
 	      FIELD_PREP(MT_TXD0_P_IDX, MT_TX_PORT_IDX_MCU) |
@@ -83,8 +86,22 @@ void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,
 	      FIELD_PREP(MT_TXD1_PKT_FMT, pkt_fmt);
 	txd[1] = cpu_to_le32(val);
 
+	if (cmd & MCU_UNI_PREFIX) {
+		uni_txd = (struct mt7615_uni_txd *)txd;
+		uni_txd->len = cpu_to_le16(skb->len - sizeof(uni_txd->txd));
+		uni_txd->option = MCU_CMD_UNI_EXT_ACK;
+		uni_txd->s2d_index = MCU_S2D_H2N;
+		uni_txd->pkt_type = MCU_PKT_ID;
+		uni_txd->cid = mcu_cmd;
+		uni_txd->seq = seq;
+
+		return;
+	}
+
+	mcu_txd = (struct mt7615_mcu_txd *)txd;
 	mcu_txd->len = cpu_to_le16(skb->len - sizeof(mcu_txd->txd));
 	mcu_txd->pq_id = cpu_to_le16(MCU_PQ_ID(MT_TX_PORT_IDX_MCU, q_idx));
+	mcu_txd->s2d_index = MCU_S2D_H2N;
 	mcu_txd->pkt_type = MCU_PKT_ID;
 	mcu_txd->seq = seq;
 
@@ -97,10 +114,6 @@ void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,
 		mcu_txd->ext_cid = cmd;
 		mcu_txd->ext_cid_ack = 1;
 	}
-	mcu_txd->s2d_index = MCU_S2D_H2N;
-
-	if (wait_seq)
-		*wait_seq = seq;
 }
 
 static int __mt7615_mcu_msg_send(struct mt7615_dev *dev, struct sk_buff *skb,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
index 8ae08a2bf10d..3aad460e0809 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
@@ -23,6 +23,57 @@ struct mt7615_mcu_txd {
 	u32 reserved[5];
 } __packed __aligned(4);
 
+/**
+ * struct mt7615_uni_txd - mcu command descriptor for firmware v3
+ * @txd: hardware descriptor
+ * @len: total length not including txd
+ * @cid: command identifier
+ * @pkt_type: must be 0xa0 (cmd packet by long format)
+ * @frag_n: fragment number
+ * @seq: sequence number
+ * @checksum: 0 mean there is no checksum
+ * @s2d_index: index for command source and destination
+ *  Definition              | value | note
+ *  CMD_S2D_IDX_H2N         | 0x00  | command from HOST to WM
+ *  CMD_S2D_IDX_C2N         | 0x01  | command from WA to WM
+ *  CMD_S2D_IDX_H2C         | 0x02  | command from HOST to WA
+ *  CMD_S2D_IDX_H2N_AND_H2C | 0x03  | command from HOST to WA and WM
+ *
+ * @option: command option
+ *  BIT[0]: UNI_CMD_OPT_BIT_ACK
+ *          set to 1 to request a fw reply
+ *          if UNI_CMD_OPT_BIT_0_ACK is set and UNI_CMD_OPT_BIT_2_SET_QUERY
+ *          is set, mcu firmware will send response event EID = 0x01
+ *          (UNI_EVENT_ID_CMD_RESULT) to the host.
+ *  BIT[1]: UNI_CMD_OPT_BIT_UNI_CMD
+ *          0: original command
+ *          1: unified command
+ *  BIT[2]: UNI_CMD_OPT_BIT_SET_QUERY
+ *          0: QUERY command
+ *          1: SET command
+ */
+struct mt7615_uni_txd {
+	__le32 txd[8];
+
+	/* DW1 */
+	__le16 len;
+	__le16 cid;
+
+	/* DW2 */
+	u8 reserved;
+	u8 pkt_type;
+	u8 frag_n;
+	u8 seq;
+
+	/* DW3 */
+	__le16 checksum;
+	u8 s2d_index;
+	u8 option;
+
+	/* DW4 */
+	u8 reserved2[4];
+} __packed __aligned(4);
+
 /* event table */
 enum {
 	MCU_EVENT_TARGET_ADDRESS_LEN = 0x01,
@@ -180,7 +231,8 @@ enum {
 };
 
 #define MCU_FW_PREFIX		BIT(31)
-#define MCU_CMD_MASK		~MCU_FW_PREFIX
+#define MCU_UNI_PREFIX		BIT(30)
+#define MCU_CMD_MASK		~(MCU_FW_PREFIX | MCU_UNI_PREFIX)
 
 enum {
 	MCU_CMD_TARGET_ADDRESS_LEN_REQ = MCU_FW_PREFIX | 0x01,
@@ -217,6 +269,12 @@ enum {
 	MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d,
 };
 
+#define MCU_CMD_ACK		BIT(0)
+#define MCU_CMD_UNI		BIT(1)
+#define MCU_CMD_QUERY		BIT(2)
+
+#define MCU_CMD_UNI_EXT_ACK	(MCU_CMD_ACK | MCU_CMD_UNI | MCU_CMD_QUERY)
+
 enum {
 	PATCH_SEM_RELEASE = 0x0,
 	PATCH_SEM_GET	  = 0x1
-- 
2.25.1


  parent reply	other threads:[~2020-03-17 16:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-17 16:41 [PATCH v4 00/25] Introduce mt7663e support to mt7615 driver Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 01/25] mt76: mt7615: introduce mt7615_mcu_fill_msg Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 02/25] mt76: mt7615: introduce mt7615_mcu_wait_response Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 03/25] mt76: mt7615: cleanup fw queue just for mmio devices Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 04/25] mt76: mt7615: introduce mt7615_init_device routine Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 05/25] mt76: always init to 0 mcu messages Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 06/25] mt76: mt7615: introduce mt7615_mcu_send_message routine Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 07/25] mt76: mt7615: add mt7615_mcu_ops data structure Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 08/25] mt76: mt7615: move mt7615_mcu_set_bmc to mt7615_mcu_ops Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 09/25] mt76: mt7615: move mt7615_mcu_set_sta in mt7615_mcu_ops Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 10/25] mt76: mt7615: rely on skb API for mt7615_mcu_set_eeprom Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 11/25] mt76: mt7615: rework mt7615_mcu_set_bss_info using skb APIs Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 12/25] mt76: mt7615: move more mcu commands in mt7615_mcu_ops data structure Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 13/25] mt76: mt7615: introduce MCU_FW_PREFIX for fw mcu commands Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 14/25] mt76: mt7615: introduce mt7615_register_map Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 15/25] mt76: mt7615: add mt7663e support to mt7615_reg_map Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 16/25] mt76: mt7615: add mt7663e support to mt7615_{driver,firmware}_own Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 17/25] mt76: mt7615: add mt7663e support to mt7615_mcu_set_eeprom Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 18/25] mt76: mt7615: introduce mt7615_eeprom_parse_hw_band_cap routine Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 19/25] mt76: mt7615: introduce mt7615_init_mac_chain routine Lorenzo Bianconi
2020-03-17 16:41 ` Lorenzo Bianconi [this message]
2020-03-17 16:41 ` [PATCH v4 21/25] mt76: mt7615: introduce set_bmc and st_sta for uni commands Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 22/25] mt76: mt7615: add more uni mcu commands Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 23/25] mt76: mt7615: introduce set_ba uni command Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 24/25] mt76: mt7615: get rid of sta_rec_wtbl data structure Lorenzo Bianconi
2020-03-17 16:41 ` [PATCH v4 25/25] mt76: mt7615: introduce mt7663e support 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=99d40d768390f9cddbf8b52135680fd3193c4abf.1584463004.git.lorenzo@kernel.org \
    --to=lorenzo@kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    --cc=ryder.lee@mediatek.com \
    --cc=sean.wang@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).