Skip to content

Commit 78afdad

Browse files
samikhawajakuba-moo
authored andcommitted
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>
1 parent 71c5241 commit 78afdad

File tree

8 files changed

+25
-7
lines changed

8 files changed

+25
-7
lines changed

drivers/net/ethernet/atheros/atl1c/atl1c_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2688,7 +2688,7 @@ static int atl1c_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
26882688
adapter->mii.mdio_write = atl1c_mdio_write;
26892689
adapter->mii.phy_id_mask = 0x1f;
26902690
adapter->mii.reg_num_mask = MDIO_CTRL_REG_MASK;
2691-
netif_set_threaded(netdev, true);
2691+
netif_threaded_enable(netdev);
26922692
for (i = 0; i < adapter->rx_queue_count; ++i)
26932693
netif_napi_add(netdev, &adapter->rrd_ring[i].napi,
26942694
atl1c_clean_rx);

drivers/net/ethernet/mellanox/mlxsw/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static int mlxsw_pci_napi_devs_init(struct mlxsw_pci *mlxsw_pci)
156156
}
157157
strscpy(mlxsw_pci->napi_dev_rx->name, "mlxsw_rx",
158158
sizeof(mlxsw_pci->napi_dev_rx->name));
159-
netif_set_threaded(mlxsw_pci->napi_dev_rx, true);
159+
netif_threaded_enable(mlxsw_pci->napi_dev_rx);
160160

161161
return 0;
162162

drivers/net/ethernet/renesas/ravb_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3075,7 +3075,7 @@ static int ravb_probe(struct platform_device *pdev)
30753075
if (info->coalesce_irqs) {
30763076
netdev_sw_irq_coalesce_default_on(ndev);
30773077
if (num_present_cpus() == 1)
3078-
netif_set_threaded(ndev, true);
3078+
netif_threaded_enable(ndev);
30793079
}
30803080

30813081
/* Network device register */

drivers/net/wireguard/device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ static int wg_newlink(struct net_device *dev,
366366
if (ret < 0)
367367
goto err_free_handshake_queue;
368368

369-
netif_set_threaded(dev, true);
369+
netif_threaded_enable(dev);
370370
ret = register_netdevice(dev);
371371
if (ret < 0)
372372
goto err_uninit_ratelimiter;

drivers/net/wireless/ath/ath10k/snoc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ static int ath10k_snoc_hif_start(struct ath10k *ar)
936936

937937
bitmap_clear(ar_snoc->pending_ce_irqs, 0, CE_COUNT_MAX);
938938

939-
netif_set_threaded(ar->napi_dev, true);
939+
netif_threaded_enable(ar->napi_dev);
940940
ath10k_core_napi_enable(ar);
941941
/* IRQs are left enabled when we restart due to a firmware crash */
942942
if (!test_bit(ATH10K_SNOC_FLAG_RECOVERY, &ar_snoc->flags))

include/linux/netdevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ static inline bool napi_complete(struct napi_struct *n)
589589
return napi_complete_done(n, 0);
590590
}
591591

592-
int netif_set_threaded(struct net_device *dev, bool threaded);
592+
void netif_threaded_enable(struct net_device *dev);
593593
int dev_set_threaded(struct net_device *dev, bool threaded);
594594

595595
void napi_disable(struct napi_struct *n);

net/core/dev.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7029,7 +7029,23 @@ int netif_set_threaded(struct net_device *dev, bool threaded)
70297029

70307030
return err;
70317031
}
7032-
EXPORT_SYMBOL(netif_set_threaded);
7032+
7033+
/**
7034+
* netif_threaded_enable() - enable threaded NAPIs
7035+
* @dev: net_device instance
7036+
*
7037+
* Enable threaded mode for the NAPI instances of the device. This may be useful
7038+
* for devices where multiple NAPI instances get scheduled by a single
7039+
* interrupt. Threaded NAPI allows moving the NAPI processing to cores other
7040+
* than the core where IRQ is mapped.
7041+
*
7042+
* This function should be called before @dev is registered.
7043+
*/
7044+
void netif_threaded_enable(struct net_device *dev)
7045+
{
7046+
WARN_ON_ONCE(netif_set_threaded(dev, true));
7047+
}
7048+
EXPORT_SYMBOL(netif_threaded_enable);
70337049

70347050
/**
70357051
* netif_queue_set_napi - Associate queue with the napi

net/core/dev.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ static inline bool napi_get_threaded(struct napi_struct *n)
322322

323323
int napi_set_threaded(struct napi_struct *n, bool threaded);
324324

325+
int netif_set_threaded(struct net_device *dev, bool threaded);
326+
325327
int rps_cpumask_housekeeping(struct cpumask *mask);
326328

327329
#if defined(CONFIG_DEBUG_NET) && defined(CONFIG_BPF_SYSCALL)

0 commit comments

Comments
 (0)