]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: Use netif_threaded_enable instead of netif_set_threaded in drivers
authorSamiullah Khawaja <skhawaja@google.com>
Wed, 23 Jul 2025 01:30:30 +0000 (01:30 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 25 Jul 2025 01:34:55 +0000 (18:34 -0700)
Prepare for adding an enum type for NAPI threaded states by adding
netif_threaded_enable API. De-export the existing netif_set_threaded API
and only use it internally. Update existing drivers to use
netif_threaded_enable instead of the de-exported netif_set_threaded.

Note that dev_set_threaded used by mt76 debugfs file is unchanged.

Signed-off-by: Samiullah Khawaja <skhawaja@google.com>
Link: https://patch.msgid.link/20250723013031.2911384-3-skhawaja@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/atheros/atl1c/atl1c_main.c
drivers/net/ethernet/mellanox/mlxsw/pci.c
drivers/net/ethernet/renesas/ravb_main.c
drivers/net/wireguard/device.c
drivers/net/wireless/ath/ath10k/snoc.c
include/linux/netdevice.h
net/core/dev.c
net/core/dev.h

index 3a9ad4a9c1cbeb8e91531c6f27c398f0282517a8..7efa3fc257b39518a81373a1849b930eaf7cb777 100644 (file)
@@ -2688,7 +2688,7 @@ static int atl1c_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        adapter->mii.mdio_write = atl1c_mdio_write;
        adapter->mii.phy_id_mask = 0x1f;
        adapter->mii.reg_num_mask = MDIO_CTRL_REG_MASK;
-       netif_set_threaded(netdev, true);
+       netif_threaded_enable(netdev);
        for (i = 0; i < adapter->rx_queue_count; ++i)
                netif_napi_add(netdev, &adapter->rrd_ring[i].napi,
                               atl1c_clean_rx);
index a2e97b712a3d7295825f9bcefaa5f72f4d54fe5c..8769cba2c7460f67ee45d544b777292318a62fe1 100644 (file)
@@ -156,7 +156,7 @@ static int mlxsw_pci_napi_devs_init(struct mlxsw_pci *mlxsw_pci)
        }
        strscpy(mlxsw_pci->napi_dev_rx->name, "mlxsw_rx",
                sizeof(mlxsw_pci->napi_dev_rx->name));
-       netif_set_threaded(mlxsw_pci->napi_dev_rx, true);
+       netif_threaded_enable(mlxsw_pci->napi_dev_rx);
 
        return 0;
 
index 4e79bf88688a9f43cd3769b98718bb07bf367a4c..94b6fb94f8f17de31cdfb3e9f875c8980e6042f1 100644 (file)
@@ -3075,7 +3075,7 @@ static int ravb_probe(struct platform_device *pdev)
        if (info->coalesce_irqs) {
                netdev_sw_irq_coalesce_default_on(ndev);
                if (num_present_cpus() == 1)
-                       netif_set_threaded(ndev, true);
+                       netif_threaded_enable(ndev);
        }
 
        /* Network device register */
index 5afec5a865f475773f0da136160b6224a691cd0a..813bd10d3dc7858b84088e81712c6e2f0ed5cf53 100644 (file)
@@ -366,7 +366,7 @@ static int wg_newlink(struct net_device *dev,
        if (ret < 0)
                goto err_free_handshake_queue;
 
-       netif_set_threaded(dev, true);
+       netif_threaded_enable(dev);
        ret = register_netdevice(dev);
        if (ret < 0)
                goto err_uninit_ratelimiter;
index 0ee68d3dad1296ccfface2ab4acb053dbbe7d0f2..f0713bd3617314d24e40b72d8e6da48df8a5bbcd 100644 (file)
@@ -936,7 +936,7 @@ static int ath10k_snoc_hif_start(struct ath10k *ar)
 
        bitmap_clear(ar_snoc->pending_ce_irqs, 0, CE_COUNT_MAX);
 
-       netif_set_threaded(ar->napi_dev, true);
+       netif_threaded_enable(ar->napi_dev);
        ath10k_core_napi_enable(ar);
        /* IRQs are left enabled when we restart due to a firmware crash */
        if (!test_bit(ATH10K_SNOC_FLAG_RECOVERY, &ar_snoc->flags))
index 5aee8d3895f4c95adf1ab8a60d0564f17def2734..a97c9a337d6bb4a1f64c1f0d57047a8afd022f4e 100644 (file)
@@ -589,7 +589,7 @@ static inline bool napi_complete(struct napi_struct *n)
        return napi_complete_done(n, 0);
 }
 
-int netif_set_threaded(struct net_device *dev, bool threaded);
+void netif_threaded_enable(struct net_device *dev);
 int dev_set_threaded(struct net_device *dev, bool threaded);
 
 void napi_disable(struct napi_struct *n);
index 76384b8a7871cc74fa1f0d665181fb82578243c4..f28661d6f5eab440edcb90f518afc3995b8fb027 100644 (file)
@@ -7029,7 +7029,23 @@ int netif_set_threaded(struct net_device *dev, bool threaded)
 
        return err;
 }
-EXPORT_SYMBOL(netif_set_threaded);
+
+/**
+ * netif_threaded_enable() - enable threaded NAPIs
+ * @dev: net_device instance
+ *
+ * Enable threaded mode for the NAPI instances of the device. This may be useful
+ * for devices where multiple NAPI instances get scheduled by a single
+ * interrupt. Threaded NAPI allows moving the NAPI processing to cores other
+ * than the core where IRQ is mapped.
+ *
+ * This function should be called before @dev is registered.
+ */
+void netif_threaded_enable(struct net_device *dev)
+{
+       WARN_ON_ONCE(netif_set_threaded(dev, true));
+}
+EXPORT_SYMBOL(netif_threaded_enable);
 
 /**
  * netif_queue_set_napi - Associate queue with the napi
index a603387fb566829d7d083cb2eb819332014e7b80..f5b5673109087ae938c45976bd1884598c2c3505 100644 (file)
@@ -322,6 +322,8 @@ static inline bool napi_get_threaded(struct napi_struct *n)
 
 int napi_set_threaded(struct napi_struct *n, bool threaded);
 
+int netif_set_threaded(struct net_device *dev, bool threaded);
+
 int rps_cpumask_housekeeping(struct cpumask *mask);
 
 #if defined(CONFIG_DEBUG_NET) && defined(CONFIG_BPF_SYSCALL)