From 158ad06239880c0cc64173730ef35906292bbafd Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 20 Mar 2015 20:14:38 +0100 Subject: [PATCH] dma: add a mt76_dma_ops abstraction struct to prepare for more chipset support Signed-off-by: Felix Fietkau --- dma.c | 9 ++++++++- mt76.h | 12 +++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dma.c b/dma.c index 41b3c983..8e73d0dc 100644 --- a/dma.c +++ b/dma.c @@ -203,7 +203,8 @@ int __mt76_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid, return 0; } -int mt76_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q, +static 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) { @@ -517,6 +518,10 @@ mt76_rx_tasklet(unsigned long data) mt76_irq_enable(dev, MT_INT_RX_DONE(1)); } +static const struct mt76_dma_ops dma_ops = { + .queue_skb = mt76_dma_tx_queue_skb, +}; + int mt76_dma_init(struct mt76_dev *dev) { static const u8 wmm_queue_map[] = { @@ -528,6 +533,8 @@ int mt76_dma_init(struct mt76_dev *dev) int ret; int i; + dev->dma_ops = &dma_ops; + init_waitqueue_head(&dev->mcu.wait); skb_queue_head_init(&dev->mcu.res_q); diff --git a/mt76.h b/mt76.h index b8c2ad13..a6afafd6 100644 --- a/mt76.h +++ b/mt76.h @@ -141,6 +141,12 @@ struct mt76_hw_cap { bool has_5ghz; }; +struct mt76_dma_ops { + int (*queue_skb)(struct mt76_dev *dev, struct mt76_queue *q, + struct sk_buff *skb, struct mt76_wcid *wcid, + struct ieee80211_sta *sta); +}; + struct mt76_dev { struct ieee80211_hw *hw; struct device *dev; @@ -151,6 +157,8 @@ struct mt76_dev { struct mutex mutex; + const struct mt76_dma_ops *dma_ops; + const u16 *beacon_offsets; unsigned long wcid_mask[256 / BITS_PER_LONG]; @@ -325,9 +333,7 @@ void mt76_rx(struct mt76_dev *dev, struct sk_buff *skb); int __mt76_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid, struct sk_buff *skb, u32 tx_info); -int mt76_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q, - struct sk_buff *skb, struct mt76_wcid *wcid, - struct ieee80211_sta *sta); +#define mt76_tx_queue_skb(dev, ...) dev->dma_ops->queue_skb(dev, __VA_ARGS__) void mt76_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, struct sk_buff *skb);