From 8ed2c99dc72ef23490815962a64c73b9d801a441 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 20 Mar 2015 21:30:26 +0100 Subject: [PATCH] add dma op for cleaning up a tx dma entry Signed-off-by: Felix Fietkau --- dma.c | 37 ++++++++++++++++++++++++------------- mt76.h | 3 +++ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/dma.c b/dma.c index 9ca6e308..95e130d1 100644 --- a/dma.c +++ b/dma.c @@ -287,14 +287,15 @@ mt76_dma_dequeue(struct mt76_dev *dev, struct mt76_queue *q, bool flush) } static void -mt76_tx_cleanup_entry(struct mt76_dev *dev, struct mt76_queue *q, int idx, - bool flush) +mt76_dma_tx_cleanup_idx(struct mt76_dev *dev, struct mt76_queue *q, int idx, + bool flush, bool *schedule) { struct mt76_queue_entry *e = &q->entry[idx]; struct sk_buff *skb = e->skb; struct mt76_txwi_cache *txwi = e->txwi; dma_addr_t skb_addr; - bool schedule = e->schedule; + + *schedule = e->schedule; if (txwi) skb_addr = ACCESS_ONCE(q->desc[idx].buf1); @@ -306,17 +307,26 @@ mt76_tx_cleanup_entry(struct mt76_dev *dev, struct mt76_queue *q, int idx, e->txwi = NULL; e->schedule = false; - if (txwi) { - mt76_mac_queue_txdone(dev, skb, &txwi->txwi); - mt76_put_txwi(dev, txwi); - - if (schedule) { - q->swq_queued--; - if (!flush) - mt76_txq_schedule(dev, q); - } - } else { + if (!txwi) { dev_kfree_skb_any(skb); + return; + } + + mt76_mac_queue_txdone(dev, skb, &txwi->txwi); + mt76_put_txwi(dev, txwi); +} + +static void +mt76_tx_cleanup_entry(struct mt76_dev *dev, struct mt76_queue *q, int idx, + bool flush) +{ + bool schedule; + + dev->dma_ops->cleanup_idx(dev, q, idx, flush, &schedule); + if (schedule) { + q->swq_queued--; + if (!flush) + mt76_txq_schedule(dev, q); } } @@ -529,6 +539,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, + .cleanup_idx = mt76_dma_tx_cleanup_idx, }; int mt76_dma_init(struct mt76_dev *dev) diff --git a/mt76.h b/mt76.h index 0aa98efe..49ecf338 100644 --- a/mt76.h +++ b/mt76.h @@ -147,6 +147,9 @@ struct mt76_dma_ops { struct ieee80211_sta *sta); int (*queue_mcu)(struct mt76_dev *dev, enum mt76_txq_id qid, struct sk_buff *skb, int cmd, int seq); + + void (*cleanup_idx)(struct mt76_dev *dev, struct mt76_queue *q, int idx, + bool flush, bool *schedule); }; struct mt76_dev {