Skip to content

Commit 3de88c9

Browse files
Luigi RizzoAlexei Starovoitov
authored andcommitted
net-af_xdp: Use correct number of channels from ethtool
Drivers use different fields to report the number of channels, so take the maximum of all data channels (rx, tx, combined) when determining the size of the xsk map. The current code used only 'combined' which was set to 0 in some drivers e.g. mlx4. Tested: compiled and run xdpsock -q 3 -r -S on mlx4 Signed-off-by: Luigi Rizzo <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Acked-by: Magnus Karlsson <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 0424c5a commit 3de88c9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tools/lib/bpf/xsk.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,18 @@ static int xsk_get_max_queues(struct xsk_socket *xsk)
431431
goto out;
432432
}
433433

434-
if (err || channels.max_combined == 0)
434+
if (err) {
435435
/* If the device says it has no channels, then all traffic
436436
* is sent to a single stream, so max queues = 1.
437437
*/
438438
ret = 1;
439-
else
440-
ret = channels.max_combined;
439+
} else {
440+
/* Take the max of rx, tx, combined. Drivers return
441+
* the number of channels in different ways.
442+
*/
443+
ret = max(channels.max_rx, channels.max_tx);
444+
ret = max(ret, (int)channels.max_combined);
445+
}
441446

442447
out:
443448
close(fd);

0 commit comments

Comments
 (0)