From a08c4a3cd426426502cea0bc57b0cd0128ba7b61 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 16 Dec 2015 18:38:39 +0100 Subject: [PATCH] add a driver ops struct to allow mt76 to call into driver specific code, will be used for queueing tx packets (incl. mac header processing) Signed-off-by: Felix Fietkau --- mt76.h | 9 +++++++++ mt76x2.h | 2 +- mt76x2_dma.c | 3 ++- mt76x2_init.c | 4 ++++ mt76x2_tx.c | 10 +++++----- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/mt76.h b/mt76.h index f3ec5976..f43a5c2d 100644 --- a/mt76.h +++ b/mt76.h @@ -130,10 +130,17 @@ struct mt76_hw_cap { bool has_5ghz; }; +struct mt76_driver_ops { + int (*tx_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; const struct mt76_bus_ops *bus; + const struct mt76_driver_ops *drv; void __iomem *regs; struct device *dev; @@ -200,6 +207,8 @@ static inline u16 mt76_rev(struct mt76_dev *dev) #define mt76_queue_cleanup(dev, ...) (dev)->mt76.queue_ops->cleanup(&((dev)->mt76), __VA_ARGS__) #define mt76_queue_kick(dev, ...) (dev)->mt76.queue_ops->kick(&((dev)->mt76), __VA_ARGS__) +#define mt76_tx_queue_skb(dev, ...) (dev)->drv->tx_queue_skb(dev, __VA_ARGS__) + int mt76_register_device(struct mt76_dev *dev, bool vht, struct ieee80211_rate *rates, int n_rates); diff --git a/mt76x2.h b/mt76x2.h index 219e2808..dbe80472 100644 --- a/mt76x2.h +++ b/mt76x2.h @@ -226,7 +226,7 @@ void mt76x2_dma_cleanup(struct mt76x2_dev *dev); void mt76x2_cleanup(struct mt76x2_dev *dev); void mt76x2_rx(struct mt76x2_dev *dev, struct sk_buff *skb); -int mt76x2_tx_queue_skb(struct mt76x2_dev *dev, struct mt76_queue *q, +int mt76x2_tx_queue_skb(struct mt76_dev *dev, struct mt76_queue *q, struct sk_buff *skb, struct mt76_wcid *wcid, struct ieee80211_sta *sta); int mt76x2_tx_queue_mcu(struct mt76x2_dev *dev, enum mt76_txq_id qid, diff --git a/mt76x2_dma.c b/mt76x2_dma.c index 7c2b3d5a..07681618 100644 --- a/mt76x2_dma.c +++ b/mt76x2_dma.c @@ -157,10 +157,11 @@ mt76x2_tx_queue_mcu(struct mt76x2_dev *dev, enum mt76_txq_id qid, } int -mt76x2_tx_queue_skb(struct mt76x2_dev *dev, struct mt76_queue *q, +mt76x2_tx_queue_skb(struct mt76_dev *cdev, struct mt76_queue *q, struct sk_buff *skb, struct mt76_wcid *wcid, struct ieee80211_sta *sta) { + struct mt76x2_dev *dev = container_of(cdev, struct mt76x2_dev, mt76); struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct mt76_txwi_cache *t; dma_addr_t addr; diff --git a/mt76x2_init.c b/mt76x2_init.c index 80dad438..8f3d331d 100644 --- a/mt76x2_init.c +++ b/mt76x2_init.c @@ -560,6 +560,9 @@ void mt76x2_cleanup(struct mt76x2_dev *dev) struct mt76x2_dev *mt76x2_alloc_device(struct device *pdev) { + static const struct mt76_driver_ops drv_ops = { + .tx_queue_skb = mt76x2_tx_queue_skb + }; struct ieee80211_hw *hw; struct mt76x2_dev *dev; @@ -570,6 +573,7 @@ struct mt76x2_dev *mt76x2_alloc_device(struct device *pdev) dev = hw->priv; dev->mt76.dev = pdev; dev->mt76.hw = hw; + dev->mt76.drv = &drv_ops; mutex_init(&dev->mutex); spin_lock_init(&dev->lock); spin_lock_init(&dev->irq_lock); diff --git a/mt76x2_tx.c b/mt76x2_tx.c index d22f8687..56804dfd 100644 --- a/mt76x2_tx.c +++ b/mt76x2_tx.c @@ -48,7 +48,7 @@ void mt76x2_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, q = &dev->mt76.q_tx[qid]; spin_lock_bh(&q->lock); - mt76x2_tx_queue_skb(dev, q, skb, wcid, control->sta); + mt76_tx_queue_skb(&dev->mt76, q, skb, wcid, control->sta); mt76_queue_kick(dev, q); if (q->queued > q->ndesc - 8) @@ -169,7 +169,7 @@ void mt76x2_pre_tbtt_tasklet(unsigned long arg) struct ieee80211_vif *vif = info->control.vif; struct mt76x2_vif *mvif = (struct mt76x2_vif *) vif->drv_priv; - mt76x2_tx_queue_skb(dev, q, skb, &mvif->group_wcid, NULL); + mt76_tx_queue_skb(&dev->mt76, q, skb, &mvif->group_wcid, NULL); } spin_unlock_bh(&q->lock); } @@ -231,7 +231,7 @@ mt76x2_queue_ps_skb(struct mt76x2_dev *dev, struct ieee80211_sta *sta, info->flags |= IEEE80211_TX_STATUS_EOSP; mt76x2_skb_set_moredata(skb, !last); - mt76x2_tx_queue_skb(dev, hwq, skb, wcid, sta); + mt76_tx_queue_skb(&dev->mt76, hwq, skb, wcid, sta); } void @@ -309,7 +309,7 @@ mt76x2_txq_send_burst(struct mt76x2_dev *dev, struct mt76_queue *hwq, if (ampdu) mt76x2_check_agg_ssn(mtxq, skb); - idx = mt76x2_tx_queue_skb(dev, hwq, skb, wcid, txq->sta); + idx = mt76_tx_queue_skb(&dev->mt76, hwq, skb, wcid, txq->sta); if (idx < 0) return idx; @@ -340,7 +340,7 @@ mt76x2_txq_send_burst(struct mt76x2_dev *dev, struct mt76_queue *hwq, if (cur_ampdu) mt76x2_check_agg_ssn(mtxq, skb); - idx = mt76x2_tx_queue_skb(dev, hwq, skb, wcid, txq->sta); + idx = mt76_tx_queue_skb(&dev->mt76, hwq, skb, wcid, txq->sta); if (idx < 0) return idx;