net-af_xdp: use correct number of channels from ethtool
Subsystems (4)
PATCH v2 1/1 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
--- tools/lib/bpf/xsk.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/lib/bpf/xsk.c +8 -3
@@ -431,13 +431,18 @@ static int xsk_get_max_queues(struct xsk_socket *xsk) goto out; } -if (err || channels.max_combined ==0 ) +if (err) {/* If the device says it has no channels, then all traffic * is sent to a single stream, so max queues = 1. */ ret =1 ; -else - ret = channels.max_combined; + }else { +/* Take the max of rx, tx, combined. Drivers return +* the number of channels in different ways. +*/ + ret =max (channels.max_rx, channels.max_tx); + ret =max (ret, (int )channels.max_combined); + } out:close (fd);
Signature · 1 line
2.24.0.432.g9d3f5f5b63-goog
Quoted 39 lines · Luigi Rizzo
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]>--- tools/lib/bpf/xsk.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)tools/lib/bpf/xsk.c +8
-4@@ -431,13 +431,18 @@ static int xsk_get_max_queues(struct xsk_socket *xsk) goto out; } -if (err || channels.max_combined ==0 ) +if (err) {/* If the device says it has no channels, then all traffic * is sent to a single stream, so max queues = 1. */ ret =1 ; -else - ret = channels.max_combined; + }else { +/* Take the max of rx, tx, combined. Drivers return +* the number of channels in different ways. +*/ + ret =max (channels.max_rx, channels.max_tx); + ret =max (ret, (int )channels.max_combined); + } out:close (fd); --
Quoted 2 lines
2.24.0.432.g9d3f5f5b63-goog
Thanks Luigi.
Quoted 7 lines · Luigi Rizzo
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]>
Alexei Starovoitov
AppliedQuoted 11 lines · Jakub Kicinski
Quoted 7 lines · Luigi Rizzo
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]>Reviewed-by Jakub Kicinski <[email protected]>
Applied. Thanks