net: Use netif_threaded_enable instead of netif_set_threaded in drivers

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>
This commit is contained in:
Samiullah Khawaja 2025-07-23 01:30:30 +00:00 committed by Jakub Kicinski
parent 71c52411c5
commit 78afdadafe
8 changed files with 25 additions and 7 deletions

View 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);

View 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;

View 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 */

View 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;

View 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))

View 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);

View 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

View 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)