mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
dma: add dma_ops function for queueing mcu command messages
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user