mt76: move mt76_dma_tx_queue_skb_raw in mt76-core module
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Thu, 7 Feb 2019 10:10:57 +0000 (11:10 +0100)
committerFelix Fietkau <nbd@nbd.name>
Mon, 18 Feb 2019 18:54:33 +0000 (19:54 +0100)
Move mt76_dma_tx_queue_skb_raw routine in dma.c and add the
corresponding entry in mt76_queue_ops data structure.
mt76_dma_tx_queue_skb_raw  will be reused adding support for
mt7603 driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/dma.c
drivers/net/wireless/mediatek/mt76/mt76.h
drivers/net/wireless/mediatek/mt76/mt76x02_mcu.c

index e769c8a555dd4b1778c454c6df4a5048eae9f7d7..ac1da2ee01a60afc6cfd7179949b6ef526d8fc5a 100644 (file)
@@ -242,6 +242,30 @@ mt76_dma_kick_queue(struct mt76_dev *dev, struct mt76_queue *q)
        iowrite32(q->head, &q->regs->cpu_idx);
 }
 
+static int
+mt76_dma_tx_queue_skb_raw(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;
+}
+
 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)
@@ -523,6 +547,7 @@ static const struct mt76_queue_ops mt76_dma_ops = {
        .init = mt76_dma_init,
        .alloc = mt76_dma_alloc_queue,
        .add_buf = mt76_dma_add_buf,
+       .tx_queue_skb_raw = mt76_dma_tx_queue_skb_raw,
        .tx_queue_skb = mt76_dma_tx_queue_skb,
        .tx_cleanup = mt76_dma_tx_cleanup,
        .rx_reset = mt76_dma_rx_reset,
index a6cc9a2ff97e828c1fb303941bf00895e079eba0..1d761b45a172c0f4a3b777c36090069aa1d72f6f 100644 (file)
@@ -157,6 +157,9 @@ struct mt76_queue_ops {
                            struct sk_buff *skb, struct mt76_wcid *wcid,
                            struct ieee80211_sta *sta);
 
+       int (*tx_queue_skb_raw)(struct mt76_dev *dev, enum mt76_txq_id qid,
+                               struct sk_buff *skb, u32 tx_info);
+
        void *(*dequeue)(struct mt76_dev *dev, struct mt76_queue *q, bool flush,
                         int *len, u32 *info, bool *more);
 
@@ -563,6 +566,7 @@ static inline u16 mt76_rev(struct mt76_dev *dev)
 #define mt76_init_queues(dev)          (dev)->mt76.queue_ops->init(&((dev)->mt76))
 #define mt76_queue_alloc(dev, ...)     (dev)->mt76.queue_ops->alloc(&((dev)->mt76), __VA_ARGS__)
 #define mt76_queue_add_buf(dev, ...)   (dev)->mt76.queue_ops->add_buf(&((dev)->mt76), __VA_ARGS__)
+#define mt76_tx_queue_skb_raw(dev, ...)        (dev)->mt76.queue_ops->tx_queue_skb_raw(&((dev)->mt76), __VA_ARGS__)
 #define mt76_queue_rx_reset(dev, ...)  (dev)->mt76.queue_ops->rx_reset(&((dev)->mt76), __VA_ARGS__)
 #define mt76_queue_tx_cleanup(dev, ...)        (dev)->mt76.queue_ops->tx_cleanup(&((dev)->mt76), __VA_ARGS__)
 #define mt76_queue_kick(dev, ...)      (dev)->mt76.queue_ops->kick(&((dev)->mt76), __VA_ARGS__)
index b44d128f6f9397dd1c5e100475f674417569856b..4752c104abf336ca0f6ccf1cb1704fa1de671bf6 100644 (file)
 
 #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_skb_raw(dev, MT_TXQ_MCU, skb, tx_info);
        if (ret)
                goto out;