Skip to content

Commit 89628a0

Browse files
committed
Merge branch 'use-enum-to-represent-the-napi-threaded-state'
Samiullah Khawaja says: ==================== Use enum to represent the NAPI threaded state Instead of using 0/1 to represent the NAPI threaded states use enum (disabled/enabled) to represent the NAPI threaded states. This patch series is a subset of patches from the following patch series: https://lore.kernel.org/20250718232052.1266188-1-skhawaja@google.com The first 3 patches are being sent separately as per the feedback to replace the usage of 0/1 as NAPI threaded states with enum. See: https://lore.kernel.org/20250721164856.1d2208e4@kernel.org ==================== Link: https://patch.msgid.link/20250723013031.2911384-1-skhawaja@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents d2002cc + 8e7583a commit 89628a0

File tree

18 files changed

+95
-54
lines changed

18 files changed

+95
-54
lines changed

Documentation/netlink/specs/netdev.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ definitions:
8585
name: qstats-scope
8686
type: flags
8787
entries: [queue]
88+
-
89+
name: napi-threaded
90+
type: enum
91+
entries: [disabled, enabled]
8892

8993
attribute-sets:
9094
-
@@ -286,11 +290,10 @@ attribute-sets:
286290
-
287291
name: threaded
288292
doc: Whether the NAPI is configured to operate in threaded polling
289-
mode. If this is set to 1 then the NAPI context operates in
290-
threaded polling mode.
291-
type: uint
292-
checks:
293-
max: 1
293+
mode. If this is set to enabled then the NAPI context operates
294+
in threaded polling mode.
295+
type: u32
296+
enum: napi-threaded
294297
-
295298
name: xsk-info
296299
attributes: []

Documentation/networking/net_cachelines/net_device.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ unsigned_char addr_assign_type
6868
unsigned_char addr_len
6969
unsigned_char upper_level
7070
unsigned_char lower_level
71+
u8 threaded napi_poll(napi_enable,netif_set_threaded)
7172
unsigned_short neigh_priv_len
7273
unsigned_short padded
7374
unsigned_short dev_id
@@ -165,7 +166,6 @@ struct sfp_bus* sfp_bus
165166
struct lock_class_key* qdisc_tx_busylock
166167
bool proto_down
167168
unsigned:1 wol_enabled
168-
unsigned:1 threaded napi_poll(napi_enable,netif_set_threaded)
169169
unsigned_long:1 see_all_hwtstamp_requests
170170
unsigned_long:1 change_proto_down
171171
unsigned_long:1 netns_immutable

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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ struct napi_config {
369369
u64 irq_suspend_timeout;
370370
u32 defer_hard_irqs;
371371
cpumask_t affinity_mask;
372-
bool threaded;
372+
u8 threaded;
373373
unsigned int napi_id;
374374
};
375375

@@ -589,8 +589,9 @@ 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);
593-
int dev_set_threaded(struct net_device *dev, bool threaded);
592+
void netif_threaded_enable(struct net_device *dev);
593+
int dev_set_threaded(struct net_device *dev,
594+
enum netdev_napi_threaded threaded);
594595

595596
void napi_disable(struct napi_struct *n);
596597
void napi_disable_locked(struct napi_struct *n);
@@ -1872,6 +1873,7 @@ enum netdev_reg_state {
18721873
* @addr_len: Hardware address length
18731874
* @upper_level: Maximum depth level of upper devices.
18741875
* @lower_level: Maximum depth level of lower devices.
1876+
* @threaded: napi threaded state.
18751877
* @neigh_priv_len: Used in neigh_alloc()
18761878
* @dev_id: Used to differentiate devices that share
18771879
* the same link layer address
@@ -2011,8 +2013,6 @@ enum netdev_reg_state {
20112013
* switch driver and used to set the phys state of the
20122014
* switch port.
20132015
*
2014-
* @threaded: napi threaded mode is enabled
2015-
*
20162016
* @irq_affinity_auto: driver wants the core to store and re-assign the IRQ
20172017
* affinity. Set by netif_enable_irq_affinity(), then
20182018
* the driver must create a persistent napi by
@@ -2248,6 +2248,7 @@ struct net_device {
22482248
unsigned char addr_len;
22492249
unsigned char upper_level;
22502250
unsigned char lower_level;
2251+
u8 threaded;
22512252

22522253
unsigned short neigh_priv_len;
22532254
unsigned short dev_id;
@@ -2429,7 +2430,6 @@ struct net_device {
24292430
struct sfp_bus *sfp_bus;
24302431
struct lock_class_key *qdisc_tx_busylock;
24312432
bool proto_down;
2432-
bool threaded;
24332433
bool irq_affinity_auto;
24342434
bool rx_cpu_rmap_auto;
24352435

include/net/gro.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,12 @@ static inline void gro_normal_list(struct gro_node *gro)
534534
gro->rx_count = 0;
535535
}
536536

537+
static inline void gro_flush_normal(struct gro_node *gro, bool flush_old)
538+
{
539+
gro_flush(gro, flush_old);
540+
gro_normal_list(gro);
541+
}
542+
537543
/* Queue one GRO_NORMAL SKB up for list processing. If batch size exceeded,
538544
* pass the whole batch up to the stack.
539545
*/

include/uapi/linux/netdev.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ enum netdev_qstats_scope {
7777
NETDEV_QSTATS_SCOPE_QUEUE = 1,
7878
};
7979

80+
enum netdev_napi_threaded {
81+
NETDEV_NAPI_THREADED_DISABLED,
82+
NETDEV_NAPI_THREADED_ENABLED,
83+
};
84+
8085
enum {
8186
NETDEV_A_DEV_IFINDEX = 1,
8287
NETDEV_A_DEV_PAD,

0 commit comments

Comments
 (0)