diff options
author | Lorenzo Bianconi <lorenzo@kernel.org> | 2022-06-20 15:59:18 +0300 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2022-07-11 14:40:02 +0300 |
commit | d2f5c8ed9fc436b53a59fdb8bdeb5f19f3a1b12c (patch) | |
tree | dbffdadfc62872c9deab4d55896a74c091722cbf /drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | |
parent | fc6ee71a2a8f2d183724e3f97762e93c5102425c (diff) |
mt76: move mt76_connac2_mcu_fill_message in mt76_connac module
Move mt76_connac2_mcu_fill_message routine in shared module in order to
reuse it for mt7921 and mt7915e drivers. This is a preliminary patch to
add mt7990 driver support.
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/mt7921/mcu.c')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index 6eab03890e02..1b62135bdc8f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -84,83 +84,6 @@ int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd, } EXPORT_SYMBOL_GPL(mt7921_mcu_parse_response); -int mt7921_mcu_fill_message(struct mt76_dev *mdev, struct sk_buff *skb, - int cmd, int *wait_seq) -{ - struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); - int txd_len, mcu_cmd = FIELD_GET(__MCU_CMD_FIELD_ID, cmd); - struct mt76_connac2_mcu_uni_txd *uni_txd; - struct mt76_connac2_mcu_txd *mcu_txd; - __le32 *txd; - u32 val; - u8 seq; - - if (cmd == MCU_UNI_CMD(HIF_CTRL) || - cmd == MCU_UNI_CMD(SUSPEND) || - cmd == MCU_UNI_CMD(OFFLOAD)) - mdev->mcu.timeout = HZ; - else - mdev->mcu.timeout = 3 * HZ; - - seq = ++dev->mt76.mcu.msg_seq & 0xf; - if (!seq) - seq = ++dev->mt76.mcu.msg_seq & 0xf; - - if (cmd == MCU_CMD(FW_SCATTER)) - goto exit; - - txd_len = cmd & __MCU_CMD_FIELD_UNI ? sizeof(*uni_txd) : sizeof(*mcu_txd); - txd = (__le32 *)skb_push(skb, txd_len); - - val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len) | - FIELD_PREP(MT_TXD0_PKT_FMT, MT_TX_TYPE_CMD) | - FIELD_PREP(MT_TXD0_Q_IDX, MT_TX_MCU_PORT_RX_Q0); - txd[0] = cpu_to_le32(val); - - val = MT_TXD1_LONG_FORMAT | - FIELD_PREP(MT_TXD1_HDR_FORMAT, MT_HDR_FORMAT_CMD); - txd[1] = cpu_to_le32(val); - - if (cmd & __MCU_CMD_FIELD_UNI) { - uni_txd = (struct mt76_connac2_mcu_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->cid = cpu_to_le16(mcu_cmd); - uni_txd->s2d_index = MCU_S2D_H2N; - uni_txd->pkt_type = MCU_PKT_ID; - uni_txd->seq = seq; - - goto exit; - } - - mcu_txd = (struct mt76_connac2_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, - MT_TX_MCU_PORT_RX_Q0)); - mcu_txd->pkt_type = MCU_PKT_ID; - mcu_txd->seq = seq; - mcu_txd->cid = mcu_cmd; - mcu_txd->s2d_index = MCU_S2D_H2N; - mcu_txd->ext_cid = FIELD_GET(__MCU_CMD_FIELD_EXT_ID, cmd); - - if (mcu_txd->ext_cid || (cmd & __MCU_CMD_FIELD_CE)) { - if (cmd & __MCU_CMD_FIELD_QUERY) - mcu_txd->set_query = MCU_Q_QUERY; - else - mcu_txd->set_query = MCU_Q_SET; - mcu_txd->ext_cid_ack = !!mcu_txd->ext_cid; - } else { - mcu_txd->set_query = MCU_Q_NA; - } - -exit: - if (wait_seq) - *wait_seq = seq; - - return 0; -} -EXPORT_SYMBOL_GPL(mt7921_mcu_fill_message); - #ifdef CONFIG_PM static int |