mt76: move mt76_tx_queue_mcu in mt76-core module
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 mt76: move mt76_tx_queue_mcu in mt76-core module
Move mt76_tx_queue_mcu routine in dma.c and remove duplicated code. mt76_tx_queue_mcu will be reused adding support for mt7603 driver
--- drivers/net/wireless/mediatek/mt76/dma.c | 24 +++++++++++ drivers/net/wireless/mediatek/mt76/mt76.h | 2 + .../net/wireless/mediatek/mt76/mt76x02_mcu.c | 40 ++++--------------- 3 files changed, 34 insertions(+), 32 deletions(-)
drivers/net/wireless/mediatek/mt76/dma.c +24 -0
@@ -242,6 +242,30 @@ mt76_dma_kick_queue(struct mt76_dev *dev, struct mt76_queue *q)iowrite32 (q->head, &q->regs->cpu_idx); } +int mt76_tx_queue_mcu (struct mt76_dev *dev,enum mt76_txq_id qid, +struct sk_buff *skb,u32 tx_info) +{ +struct mt76_queue *q = &dev->q_tx[qid]; +struct mt76_queue_buf buf; +dma_addr_t addr; + + addr =dma_map_single (dev->dev, skb->data, skb->len, +DMA_TO_DEVICE ); +if (dma_mapping_error (dev->dev, addr)) +return -ENOMEM ; + + buf.addr = addr; + buf.len = skb->len; + +spin_lock_bh (&q->lock); +mt76_dma_add_buf (dev, q, &buf,1 , tx_info, skb,NULL ); +mt76_dma_kick_queue (dev, q); +spin_unlock_bh (&q->lock); + +return 0 ; +} +EXPORT_SYMBOL_GPL (mt76_tx_queue_mcu); +int mt76_dma_tx_queue_skb (struct mt76_dev *dev,struct mt76_queue *q,struct sk_buff *skb,struct mt76_wcid *wcid,struct ieee80211_sta *sta)
drivers/net/wireless/mediatek/mt76/mt76.h +2 -0
@@ -761,6 +761,8 @@ mt76_mcu_msg_alloc(const void *data, int head_len,void mt76_mcu_rx_event (struct mt76_dev *dev,struct sk_buff *skb);struct sk_buff *mt76_mcu_get_response (struct mt76_dev *dev,unsigned long expires); +int mt76_tx_queue_mcu (struct mt76_dev *dev,enum mt76_txq_id qid, +struct sk_buff *skb,u32 tx_info);void mt76u_mcu_complete_urb (struct urb *urb);int mt76u_mcu_init_rx (struct mt76_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c +8 -32
@@ -21,43 +21,13 @@#include "mt76x02_mcu.h" -static int -mt76x02_tx_queue_mcu (struct mt76x02_dev *dev,enum mt76_txq_id qid, -struct sk_buff *skb,int cmd,int seq) -{ -struct mt76_queue *q = &dev->mt76.q_tx[qid]; -struct mt76_queue_buf buf; -dma_addr_t addr; -u32 tx_info; - - tx_info =MT_MCU_MSG_TYPE_CMD | -FIELD_PREP (MT_MCU_MSG_CMD_TYPE , cmd) | -FIELD_PREP (MT_MCU_MSG_CMD_SEQ , seq) | -FIELD_PREP (MT_MCU_MSG_PORT ,CPU_TX_PORT ) | -FIELD_PREP (MT_MCU_MSG_LEN , skb->len); - - addr =dma_map_single (dev->mt76.dev, skb->data, skb->len, -DMA_TO_DEVICE ); -if (dma_mapping_error (dev->mt76.dev, addr)) -return -ENOMEM ; - - buf.addr = addr; - buf.len = skb->len; - -spin_lock_bh (&q->lock); -mt76_queue_add_buf (dev, q, &buf,1 , tx_info, skb,NULL ); -mt76_queue_kick (dev, q); -spin_unlock_bh (&q->lock); - -return 0 ; -} -int mt76x02_mcu_msg_send (struct mt76_dev *mdev,int cmd,const void *data,int len,bool wait_resp) { struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);unsigned long expires = jiffies +HZ ;struct sk_buff *skb; +u32 tx_info;int ret;u8 seq;
@@ -71,7 +41,13 @@ int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,if (!seq) seq = ++mdev->mmio.mcu.msg_seq &0xf ; - ret =mt76x02_tx_queue_mcu (dev,MT_TXQ_MCU , skb, cmd, seq); + tx_info =MT_MCU_MSG_TYPE_CMD | +FIELD_PREP (MT_MCU_MSG_CMD_TYPE , cmd) | +FIELD_PREP (MT_MCU_MSG_CMD_SEQ , seq) | +FIELD_PREP (MT_MCU_MSG_PORT ,CPU_TX_PORT ) | +FIELD_PREP (MT_MCU_MSG_LEN , skb->len); + + ret =mt76_tx_queue_mcu (&dev->mt76,MT_TXQ_MCU , skb, tx_info);if (ret) goto out;
Signature · 1 line
2.20.1
Felix Fietkau
maintainerQuoted 4 lines · Lorenzo Bianconi
Move
mt76_tx_queue_mcuroutine indma.cand remove duplicated code.mt76_tx_queue_mcuwill be reused adding support for mt7603 driverSigned-off-by Lorenzo Bianconi <[email protected]>
I think we should rename this function, since it's going to be used for more than just MCU commands.
Maybe mt76_dma_tx_queue_skb_raw (and add corresponding queue_op instead of direct calls)?
While you're at it, maybe you could also remove mt76_queue_add_buf and the corresponding queue op.
- Felix
Quoted 11 lines · Lorenzo Bianconi
Quoted 4 lines
Move
mt76_tx_queue_mcuroutine indma.cand remove duplicated code.mt76_tx_queue_mcuwill be reused adding support for mt7603 driverSigned-off-by Lorenzo Bianconi <[email protected]>I think we should rename this function, since it's going to be used for more than just MCU commands.
Maybemt76_dma_tx_queue_skb_raw(and add correspondingqueue_opinstead of direct calls)?
While you're at it, maybe you could also removemt76_queue_add_bufand the corresponding queue op.
ack, will fix it in v2
Regards,
Lorenzo
Quoted 2 lines
- Felix