Skip to content

Commit bda053d

Browse files
kuba-mooPaolo Abeni
authored andcommitted
selftests: drv-net: don't assume device has only 2 queues
The test is implicitly assuming the device only has 2 queues. A real device will likely have more. The exact problem is that because NAPIs get added to the list from the head, the netlink dump reports them in reverse order. So the naive napis[0] will actually likely give us the _last_ NAPI, not the first one. Re-enable all the NAPIs instead of hard-coding 2 in the test. This way the NAPIs we operated on will always reappear, doesn't matter where they were in the registration order. Fixes: e6d7626 ("net: Update threaded state in napi config in netif_set_threaded") Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Joe Damato <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent e93f7af commit bda053d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/testing/selftests/drivers/net/napi_threaded.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def _setup_deferred_cleanup(cfg) -> None:
3535
threaded = cmd(f"cat /sys/class/net/{cfg.ifname}/threaded").stdout
3636
defer(_set_threaded_state, cfg, threaded)
3737

38+
return combined
39+
3840

3941
def enable_dev_threaded_disable_napi_threaded(cfg, nl) -> None:
4042
"""
@@ -49,7 +51,7 @@ def enable_dev_threaded_disable_napi_threaded(cfg, nl) -> None:
4951
napi0_id = napis[0]['id']
5052
napi1_id = napis[1]['id']
5153

52-
_setup_deferred_cleanup(cfg)
54+
qcnt = _setup_deferred_cleanup(cfg)
5355

5456
# set threaded
5557
_set_threaded_state(cfg, 1)
@@ -62,7 +64,7 @@ def enable_dev_threaded_disable_napi_threaded(cfg, nl) -> None:
6264
nl.napi_set({'id': napi1_id, 'threaded': 'disabled'})
6365

6466
cmd(f"ethtool -L {cfg.ifname} combined 1")
65-
cmd(f"ethtool -L {cfg.ifname} combined 2")
67+
cmd(f"ethtool -L {cfg.ifname} combined {qcnt}")
6668
_assert_napi_threaded_enabled(nl, napi0_id)
6769
_assert_napi_threaded_disabled(nl, napi1_id)
6870

@@ -80,7 +82,7 @@ def change_num_queues(cfg, nl) -> None:
8082
napi0_id = napis[0]['id']
8183
napi1_id = napis[1]['id']
8284

83-
_setup_deferred_cleanup(cfg)
85+
qcnt = _setup_deferred_cleanup(cfg)
8486

8587
# set threaded
8688
_set_threaded_state(cfg, 1)
@@ -90,7 +92,7 @@ def change_num_queues(cfg, nl) -> None:
9092
_assert_napi_threaded_enabled(nl, napi1_id)
9193

9294
cmd(f"ethtool -L {cfg.ifname} combined 1")
93-
cmd(f"ethtool -L {cfg.ifname} combined 2")
95+
cmd(f"ethtool -L {cfg.ifname} combined {qcnt}")
9496

9597
# check napi threaded is set for both napis
9698
_assert_napi_threaded_enabled(nl, napi0_id)

0 commit comments

Comments
 (0)