Skip to content

Commit 1cbddbd

Browse files
jdamato-fslykuba-moo
authored andcommitted
selftests: drv-net: Check if combined-count exists
Some drivers, like tg3, do not set combined-count: $ ethtool -l enp4s0f1 Channel parameters for enp4s0f1: Pre-set maximums: RX: 4 TX: 4 Other: n/a Combined: n/a Current hardware settings: RX: 4 TX: 1 Other: n/a Combined: n/a In the case where combined-count is not set, the ethtool netlink code in the kernel elides the value and the code in the test: netnl.channels_get(...) With a tg3 device, the returned dictionary looks like: {'header': {'dev-index': 3, 'dev-name': 'enp4s0f1'}, 'rx-max': 4, 'rx-count': 4, 'tx-max': 4, 'tx-count': 1} Note that the key 'combined-count' is missing. As a result of this missing key the test raises an exception: # Exception| if channels['combined-count'] == 0: # Exception| ~~~~~~~~^^^^^^^^^^^^^^^^^^ # Exception| KeyError: 'combined-count' Change the test to check if 'combined-count' is a key in the dictionary first and if not assume that this means the driver has separate RX and TX queues. With this change, the test now passes successfully on tg3 and mlx5 (which does have a 'combined-count'). Fixes: 1cf2704 ("net: selftest: add test for netdev netlink queue-get API") Signed-off-by: Joe Damato <jdamato@fastly.com> Reviewed-by: David Wei <dw@davidwei.uk> Link: https://patch.msgid.link/20250226181957.212189-1-jdamato@fastly.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent c907db8 commit 1cbddbd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ def addremove_queues(cfg, nl) -> None:
4545

4646
netnl = EthtoolFamily()
4747
channels = netnl.channels_get({'header': {'dev-index': cfg.ifindex}})
48-
if channels['combined-count'] == 0:
49-
rx_type = 'rx'
50-
else:
51-
rx_type = 'combined'
48+
rx_type = 'rx'
49+
if channels.get('combined-count', 0) > 0:
50+
rx_type = 'combined'
5251

5352
expected = curr_queues - 1
5453
cmd(f"ethtool -L {cfg.dev['ifname']} {rx_type} {expected}", timeout=10)

0 commit comments

Comments
 (0)