Skip to content

Commit

Permalink
dma: add dma_ops function for queueing mcu command messages
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
Felix Fietkau committed Jul 17, 2015
1 parent 158ad06 commit a2015fb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
13 changes: 11 additions & 2 deletions dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,31 @@
#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,
MT_QSEL_EDCA,
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;
Expand Down
8 changes: 1 addition & 7 deletions mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
18 changes: 0 additions & 18 deletions mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions mt76.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a2015fb

Please sign in to comment.