From a2015fbffc81716f2796154335c2b926d52f5c17 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 20 Mar 2015 20:28:02 +0100 Subject: [PATCH] dma: add dma_ops function for queueing mcu command messages Signed-off-by: Felix Fietkau --- dma.c | 13 +++++++++++-- dma.h | 18 ++++++++++++++++++ mcu.c | 8 +------- mcu.h | 18 ------------------ mt76.h | 6 +++--- 5 files changed, 33 insertions(+), 30 deletions(-) diff --git a/dma.c b/dma.c index 8e73d0dc..9ca6e308 100644 --- a/dma.c +++ b/dma.c @@ -183,13 +183,21 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q) return frames; } -int __mt76_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid, - struct sk_buff *skb, u32 tx_info) +static int +mt76_dma_tx_queue_mcu(struct mt76_dev *dev, enum mt76_txq_id qid, + struct sk_buff *skb, int cmd, int seq) { struct mt76_queue *q = &dev->q_tx[qid]; dma_addr_t addr; + u32 tx_info; int idx; + tx_info = MT_MCU_MSG_TYPE_CMD | + MT76_SET(MT_MCU_MSG_CMD_TYPE, cmd) | + MT76_SET(MT_MCU_MSG_CMD_SEQ, seq) | + MT76_SET(MT_MCU_MSG_PORT, CPU_TX_PORT) | + MT76_SET(MT_MCU_MSG_LEN, skb->len); + addr = dma_map_single(dev->dev, skb->data, skb->len, DMA_TO_DEVICE); if (dma_mapping_error(dev->dev, addr)) return -ENOMEM; @@ -520,6 +528,7 @@ mt76_rx_tasklet(unsigned long data) static const struct mt76_dma_ops dma_ops = { .queue_skb = mt76_dma_tx_queue_skb, + .queue_mcu = mt76_dma_tx_queue_mcu, }; int mt76_dma_init(struct mt76_dev *dev) diff --git a/dma.h b/dma.h index 5f07773a..74f868c1 100644 --- a/dma.h +++ b/dma.h @@ -42,6 +42,14 @@ #define MT_RX_FCE_INFO_D_PORT GENMASK(29, 27) #define MT_RX_FCE_INFO_TYPE GENMASK(31, 30) +/* MCU request message header */ +#define MT_MCU_MSG_LEN GENMASK(15, 0) +#define MT_MCU_MSG_CMD_SEQ GENMASK(19, 16) +#define MT_MCU_MSG_CMD_TYPE GENMASK(26, 20) +#define MT_MCU_MSG_PORT GENMASK(29, 27) +#define MT_MCU_MSG_TYPE GENMASK(31, 30) +#define MT_MCU_MSG_TYPE_CMD BIT(30) + enum mt76_qsel { MT_QSEL_MGMT, MT_QSEL_HCCA, @@ -49,6 +57,16 @@ enum mt76_qsel { MT_QSEL_EDCA_2, }; +enum dma_msg_port { + WLAN_PORT, + CPU_RX_PORT, + CPU_TX_PORT, + HOST_PORT, + VIRTUAL_CPU_RX_PORT, + VIRTUAL_CPU_TX_PORT, + DISCARD, +}; + struct mt76_desc { __le32 buf0; __le32 ctrl; diff --git a/mcu.c b/mcu.c index a2df0c2b..27d7142b 100644 --- a/mcu.c +++ b/mcu.c @@ -79,13 +79,7 @@ mt76_mcu_msg_send(struct mt76_dev *dev, struct sk_buff *skb, enum mcu_cmd cmd) if (!seq) seq = ++dev->mcu.msg_seq & 0xf; - info = MT_MCU_MSG_TYPE_CMD | - MT76_SET(MT_MCU_MSG_CMD_TYPE, cmd) | - MT76_SET(MT_MCU_MSG_CMD_SEQ, seq) | - MT76_SET(MT_MCU_MSG_PORT, CPU_TX_PORT) | - MT76_SET(MT_MCU_MSG_LEN, skb->len); - - ret = __mt76_tx_queue_skb(dev, MT_TXQ_MCU, skb, info); + ret = mt76_tx_queue_mcu(dev, MT_TXQ_MCU, skb, cmd, seq); if (ret) goto out; diff --git a/mcu.h b/mcu.h index 21d643e3..c32c807e 100644 --- a/mcu.h +++ b/mcu.h @@ -47,14 +47,6 @@ #define MT_MCU_DLM_ADDR 0x90000 #define MT_MCU_DLM_ADDR_E3 0x90800 -/* MCU request message header */ -#define MT_MCU_MSG_LEN GENMASK(15, 0) -#define MT_MCU_MSG_CMD_SEQ GENMASK(19, 16) -#define MT_MCU_MSG_CMD_TYPE GENMASK(26, 20) -#define MT_MCU_MSG_PORT GENMASK(29, 27) -#define MT_MCU_MSG_TYPE GENMASK(31, 30) -#define MT_MCU_MSG_TYPE_CMD BIT(30) - enum mcu_cmd { CMD_FUN_SET_OP = 1, CMD_LOAD_CR = 2, @@ -88,16 +80,6 @@ enum mcu_function { GET_FW_VERSION = 5, }; -enum mcu_msg_port { - WLAN_PORT, - CPU_RX_PORT, - CPU_TX_PORT, - HOST_PORT, - VIRTUAL_CPU_RX_PORT, - VIRTUAL_CPU_TX_PORT, - DISCARD, -}; - enum mcu_power_mode { RADIO_OFF = 0x30, RADIO_ON = 0x31, diff --git a/mt76.h b/mt76.h index a6afafd6..0aa98efe 100644 --- a/mt76.h +++ b/mt76.h @@ -145,6 +145,8 @@ struct mt76_dma_ops { int (*queue_skb)(struct mt76_dev *dev, struct mt76_queue *q, struct sk_buff *skb, struct mt76_wcid *wcid, struct ieee80211_sta *sta); + int (*queue_mcu)(struct mt76_dev *dev, enum mt76_txq_id qid, + struct sk_buff *skb, int cmd, int seq); }; struct mt76_dev { @@ -330,10 +332,8 @@ void mt76_dma_cleanup(struct mt76_dev *dev); void mt76_cleanup(struct mt76_dev *dev); void mt76_rx(struct mt76_dev *dev, struct sk_buff *skb); -int __mt76_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid, - struct sk_buff *skb, u32 tx_info); - #define mt76_tx_queue_skb(dev, ...) dev->dma_ops->queue_skb(dev, __VA_ARGS__) +#define mt76_tx_queue_mcu(dev, ...) dev->dma_ops->queue_mcu(dev, __VA_ARGS__) void mt76_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, struct sk_buff *skb);