wifi: mt76: set page_pool napi pointer for mmio devices
authorLorenzo Bianconi <lorenzo@kernel.org>
Tue, 12 Dec 2023 09:15:19 +0000 (10:15 +0100)
committerFelix Fietkau <nbd@nbd.name>
Thu, 22 Feb 2024 08:55:18 +0000 (09:55 +0100)
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>
drivers/net/wireless/mediatek/mt76/mac80211.c
drivers/net/wireless/mediatek/mt76/mt76.h

index e3ebadcd149946d874cc680f8b03b15277cdf97b..068206e48aec64dd2d402036c83ce2efbf788c0d 100644 (file)
@@ -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:
@@ -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);
index ac969a88438b927b5d6b89c8a31f249d554cf50a..a91f6ddacbd95fd3dd9d94dee4946be22ed823a4 100644 (file)
@@ -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) &&