Skip to content

Commit

Permalink
wifi: mt76: set page_pool napi pointer for mmio devices
Browse files Browse the repository at this point in the history
In order to recycle skbs in the page_pool "hot" cache in
napi_pp_put_page routine, set napi pointer for MMIO devices in
mt76_create_page_pool().

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Feb 22, 2024
1 parent 8a7386e commit 3c37da5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/net/wireless/mediatek/mt76/mac80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,18 @@ EXPORT_SYMBOL_GPL(mt76_unregister_phy);

int mt76_create_page_pool(struct mt76_dev *dev, struct mt76_queue *q)
{
bool is_qrx = mt76_queue_is_rx(dev, q);
struct page_pool_params pp_params = {
.order = 0,
.flags = 0,
.nid = NUMA_NO_NODE,
.dev = dev->dma_dev,
};
int idx = q - dev->q_rx;
int idx = is_qrx ? q - dev->q_rx : -1;

/* Allocate page_pools just for rx/wed_tx_free queues */
if (!is_qrx && !mt76_queue_is_wed_tx_free(q))
return 0;

switch (idx) {
case MT_RXQ_MAIN:
Expand All @@ -604,6 +609,9 @@ int mt76_create_page_pool(struct mt76_dev *dev, struct mt76_queue *q)
pp_params.dma_dir = DMA_FROM_DEVICE;
pp_params.max_len = PAGE_SIZE;
pp_params.offset = 0;
/* NAPI is available just for rx queues */
if (idx >= 0 && idx < ARRAY_SIZE(dev->napi))
pp_params.napi = &dev->napi[idx];
}

q->page_pool = page_pool_create(&pp_params);
Expand Down
12 changes: 12 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt76.h
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,18 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy,
struct mt76_power_limits *dest,
s8 target_power);

static inline bool mt76_queue_is_rx(struct mt76_dev *dev, struct mt76_queue *q)
{
int i;

for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) {
if (q == &dev->q_rx[i])
return true;
}

return false;
}

static inline bool mt76_queue_is_wed_tx_free(struct mt76_queue *q)
{
return (q->flags & MT_QFLAG_WED) &&
Expand Down

0 comments on commit 3c37da5

Please sign in to comment.