Skip to content

Commit

Permalink
mt76: dma: add the capability to define a custom rx napi poll routine
Browse files Browse the repository at this point in the history
Add the capability to define a custom rx napi callback for each driver.
This is a preliminary patch to properly support runtime-pm on rx side

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Apr 21, 2021
1 parent 36f664e commit 51b3d1a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
10 changes: 5 additions & 5 deletions dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
return done;
}

static int
mt76_dma_rx_poll(struct napi_struct *napi, int budget)
int mt76_dma_rx_poll(struct napi_struct *napi, int budget)
{
struct mt76_dev *dev;
int qid, done = 0, cur;
Expand All @@ -626,9 +625,11 @@ mt76_dma_rx_poll(struct napi_struct *napi, int budget)

return done;
}
EXPORT_SYMBOL_GPL(mt76_dma_rx_poll);

static int
mt76_dma_init(struct mt76_dev *dev)
mt76_dma_init(struct mt76_dev *dev,
int (*poll)(struct napi_struct *napi, int budget))
{
int i;

Expand All @@ -639,8 +640,7 @@ mt76_dma_init(struct mt76_dev *dev)
dev->napi_dev.threaded = 1;

mt76_for_each_q_rx(dev, i) {
netif_napi_add(&dev->napi_dev, &dev->napi[i], mt76_dma_rx_poll,
64);
netif_napi_add(&dev->napi_dev, &dev->napi[i], poll, 64);
mt76_dma_rx_fill(dev, &dev->q_rx[i]);
napi_enable(&dev->napi[i]);
}
Expand Down
1 change: 1 addition & 0 deletions dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum mt76_mcu_evt_type {
EVT_EVENT_DFS_DETECT_RSP,
};

int mt76_dma_rx_poll(struct napi_struct *napi, int budget);
void mt76_dma_attach(struct mt76_dev *dev);
void mt76_dma_cleanup(struct mt76_dev *dev);

Expand Down
5 changes: 3 additions & 2 deletions mt76.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ struct mt76_mcu_ops {
};

struct mt76_queue_ops {
int (*init)(struct mt76_dev *dev);
int (*init)(struct mt76_dev *dev,
int (*poll)(struct napi_struct *napi, int budget));

int (*alloc)(struct mt76_dev *dev, struct mt76_queue *q,
int idx, int n_desc, int bufsize,
Expand Down Expand Up @@ -802,7 +803,7 @@ static inline u16 mt76_rev(struct mt76_dev *dev)
#define mt76xx_chip(dev) mt76_chip(&((dev)->mt76))
#define mt76xx_rev(dev) mt76_rev(&((dev)->mt76))

#define mt76_init_queues(dev) (dev)->mt76.queue_ops->init(&((dev)->mt76))
#define mt76_init_queues(dev, ...) (dev)->mt76.queue_ops->init(&((dev)->mt76), __VA_ARGS__)
#define mt76_queue_alloc(dev, ...) (dev)->mt76.queue_ops->alloc(&((dev)->mt76), __VA_ARGS__)
#define mt76_tx_queue_skb_raw(dev, ...) (dev)->mt76.queue_ops->tx_queue_skb_raw(&((dev)->mt76), __VA_ARGS__)
#define mt76_tx_queue_skb(dev, ...) (dev)->mt76.queue_ops->tx_queue_skb(&((dev)->mt76), __VA_ARGS__)
Expand Down
2 changes: 1 addition & 1 deletion mt7603/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ int mt7603_dma_init(struct mt7603_dev *dev)
return ret;

mt76_wr(dev, MT_DELAY_INT_CFG, 0);
ret = mt76_init_queues(dev);
ret = mt76_init_queues(dev, mt76_dma_rx_poll);
if (ret)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion mt7615/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ int mt7615_dma_init(struct mt7615_dev *dev)

mt76_wr(dev, MT_DELAY_INT_CFG, 0);

ret = mt76_init_queues(dev);
ret = mt76_init_queues(dev, mt76_dma_rx_poll);
if (ret < 0)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion mt76x02_mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ int mt76x02_dma_init(struct mt76x02_dev *dev)
if (ret)
return ret;

ret = mt76_init_queues(dev);
ret = mt76_init_queues(dev, mt76_dma_rx_poll);
if (ret)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion mt7915/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ int mt7915_dma_init(struct mt7915_dev *dev)
return ret;
}

ret = mt76_init_queues(dev);
ret = mt76_init_queues(dev, mt76_dma_rx_poll);
if (ret < 0)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion mt7921/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ int mt7921_dma_init(struct mt7921_dev *dev)
if (ret)
return ret;

ret = mt76_init_queues(dev);
ret = mt76_init_queues(dev, mt76_dma_rx_poll);
if (ret < 0)
return ret;

Expand Down

0 comments on commit 51b3d1a

Please sign in to comment.