bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net-af_xdp: use correct number of channels from ethtool
@ 2019-11-19  0:19 Luigi Rizzo
  2019-11-19  8:42 ` Magnus Karlsson
  2019-11-19 22:03 ` Jakub Kicinski
  0 siblings, 2 replies; 4+ messages in thread
From: Luigi Rizzo @ 2019-11-19  0:19 UTC (permalink / raw)
  To: magnus.karlsson, bjorn.topel, jonathan.lemon, netdev
  Cc: bpf, rizzo, 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 <lrizzo@google.com>
---
 tools/lib/bpf/xsk.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
index 74d84f36a5b24..37921375f4d45 100644
--- a/tools/lib/bpf/xsk.c
+++ b/tools/lib/bpf/xsk.c
@@ -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);
-- 
2.24.0.432.g9d3f5f5b63-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] net-af_xdp: use correct number of channels from ethtool
  2019-11-19  0:19 [PATCH v2] net-af_xdp: use correct number of channels from ethtool Luigi Rizzo
@ 2019-11-19  8:42 ` Magnus Karlsson
  2019-11-19 22:03 ` Jakub Kicinski
  1 sibling, 0 replies; 4+ messages in thread
From: Magnus Karlsson @ 2019-11-19  8:42 UTC (permalink / raw)
  To: Luigi Rizzo
  Cc: Karlsson, Magnus, Björn Töpel, Jonathan Lemon,
	Network Development, bpf, rizzo

On Tue, Nov 19, 2019 at 1:20 AM Luigi Rizzo <lrizzo@google.com> wrote:
>
> 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 <lrizzo@google.com>
> ---
>  tools/lib/bpf/xsk.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
> index 74d84f36a5b24..37921375f4d45 100644
> --- a/tools/lib/bpf/xsk.c
> +++ b/tools/lib/bpf/xsk.c
> @@ -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);
> --
> 2.24.0.432.g9d3f5f5b63-goog
>

Thanks Luigi.

Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] net-af_xdp: use correct number of channels from ethtool
  2019-11-19  0:19 [PATCH v2] net-af_xdp: use correct number of channels from ethtool Luigi Rizzo
  2019-11-19  8:42 ` Magnus Karlsson
@ 2019-11-19 22:03 ` Jakub Kicinski
  2019-11-19 22:07   ` Alexei Starovoitov
  1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2019-11-19 22:03 UTC (permalink / raw)
  To: Luigi Rizzo
  Cc: magnus.karlsson, bjorn.topel, jonathan.lemon, netdev, bpf, rizzo

On Mon, 18 Nov 2019 16:19:51 -0800, Luigi Rizzo wrote:
> 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 <lrizzo@google.com>

Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] net-af_xdp: use correct number of channels from ethtool
  2019-11-19 22:03 ` Jakub Kicinski
@ 2019-11-19 22:07   ` Alexei Starovoitov
  0 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2019-11-19 22:07 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Luigi Rizzo, Karlsson, Magnus, Björn Töpel,
	Jonathan Lemon, Network Development, bpf, rizzo

On Tue, Nov 19, 2019 at 2:04 PM Jakub Kicinski
<jakub.kicinski@netronome.com> wrote:
>
> On Mon, 18 Nov 2019 16:19:51 -0800, Luigi Rizzo wrote:
> > 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 <lrizzo@google.com>
>
> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Applied. Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-19 22:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-19  0:19 [PATCH v2] net-af_xdp: use correct number of channels from ethtool Luigi Rizzo
2019-11-19  8:42 ` Magnus Karlsson
2019-11-19 22:03 ` Jakub Kicinski
2019-11-19 22:07   ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).