dma: add dma op for adding an rx buffer

Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Felix Fietkau
2015-07-17 19:30:27 +02:00
parent 8ed2c99dc7
commit 43a9691d59
2 changed files with 14 additions and 5 deletions
+11 -5
View File
@@ -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)
+3
View File
@@ -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 {