From 43a9691d59c222eb37c7bbcb21a8a219bdcf1616 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 20 Mar 2015 21:44:48 +0100 Subject: [PATCH] dma: add dma op for adding an rx buffer Signed-off-by: Felix Fietkau --- dma.c | 16 +++++++++++----- mt76.h | 3 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/dma.c b/dma.c index 95e130d1..5dace478 100644 --- a/dma.c +++ b/dma.c @@ -144,6 +144,15 @@ mt76_queue_add_buf(struct mt76_dev *dev, struct mt76_queue *q, return idx; } +static int +mt76_dma_add_rx_buf(struct mt76_dev *dev, struct mt76_queue *q, + dma_addr_t addr, int len) +{ + int offset = mt76_rx_buf_offset(dev); + + return mt76_queue_add_buf(dev, q, addr + offset, len - offset, 0, 0, 0); +} + static int mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q) { @@ -156,8 +165,6 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q) spin_lock_bh(&q->lock); while (q->queued < q->ndesc - 1) { - int offset = mt76_rx_buf_offset(dev); - buf = kzalloc(len, GFP_ATOMIC); if (!buf) break; @@ -168,9 +175,7 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q) break; } - idx = mt76_queue_add_buf(dev, q, addr + offset, len - offset, - 0, 0, 0); - + idx = dev->dma_ops->add_rx_buf(dev, q, addr, len); q->entry[idx].buf = buf; frames++; } @@ -540,6 +545,7 @@ static const struct mt76_dma_ops dma_ops = { .queue_skb = mt76_dma_tx_queue_skb, .queue_mcu = mt76_dma_tx_queue_mcu, .cleanup_idx = mt76_dma_tx_cleanup_idx, + .add_rx_buf = mt76_dma_add_rx_buf, }; int mt76_dma_init(struct mt76_dev *dev) diff --git a/mt76.h b/mt76.h index 49ecf338..fa9540d0 100644 --- a/mt76.h +++ b/mt76.h @@ -150,6 +150,9 @@ struct mt76_dma_ops { void (*cleanup_idx)(struct mt76_dev *dev, struct mt76_queue *q, int idx, bool flush, bool *schedule); + + int (*add_rx_buf)(struct mt76_dev *dev, struct mt76_queue *q, + dma_addr_t addr, int len); }; struct mt76_dev {