From: Maciej Fijalkowski <maciejromanfijalkowski@gmail.com>
To: "Björn Töpel" <bjorn.topel@intel.com>
Cc: magnus.karlsson@intel.com, netdev@vger.kernel.org,
ast@kernel.org, daniel@iogearbox.net,
jakub.kicinski@netronome.com, jonathan.lemon@gmail.com,
songliubraving@fb.com, bpf <bpf@vger.kernel.org>
Subject: Re: [RFC PATCH bpf-next 2/4] libbpf: check for channels.max_{t,r}x in xsk_get_max_queues
Date: Tue, 4 Jun 2019 17:05:45 +0200 [thread overview]
Message-ID: <20190604170545.00003ee7@gmail.com> (raw)
In-Reply-To: <87505132-2f1b-dc4d-5c1f-d52fc8dca647@intel.com>
On Tue, 4 Jun 2019 10:06:57 +0200
Björn Töpel <bjorn.topel@intel.com> wrote:
> On 2019-06-03 15:19, Maciej Fijalkowski wrote:
> > When it comes down to ethtool's get channels API, various drivers are
> > reporting the queue count in two ways - they are setting max_combined or
> > max_tx/max_rx fields. When creating the eBPF maps for xsk socket, this
> > API is used so that we have an entries in maps per each queue.
> > In case where driver (mlx4, ice) reports queues in max_tx/max_rx, we end
> > up with eBPF maps with single entries, so it's not possible to attach an
> > AF_XDP socket onto queue other than 0 - xsk_set_bpf_maps() would try to
> > call bpf_map_update_elem() with key set to xsk->queue_id.
> >
> > To fix this, let's look for channels.max_{t,r}x as well in
> > xsk_get_max_queues.
> >
> > Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> > ---
> > tools/lib/bpf/xsk.c | 18 ++++++++++--------
> > 1 file changed, 10 insertions(+), 8 deletions(-)
> >
> > diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
> > index 57dda1389870..514ab3fb06f4 100644
> > --- a/tools/lib/bpf/xsk.c
> > +++ b/tools/lib/bpf/xsk.c
> > @@ -339,21 +339,23 @@ static int xsk_get_max_queues(struct xsk_socket *xsk)
> > ifr.ifr_data = (void *)&channels;
> > strncpy(ifr.ifr_name, xsk->ifname, IFNAMSIZ);
> > err = ioctl(fd, SIOCETHTOOL, &ifr);
> > - if (err && errno != EOPNOTSUPP) {
> > - ret = -errno;
> > - goto out;
> > - }
> > + close(fd);
> > +
> > + if (err && errno != EOPNOTSUPP)
> > + return -errno;
> >
> > - if (channels.max_combined == 0 || errno == EOPNOTSUPP)
> > + if (channels.max_combined)
> > + ret = channels.max_combined;
> > + else if (channels.max_rx && channels.max_tx)
> > + ret = min(channels.max_rx, channels.max_tx);
>
> Hmm, do we really need to look at max_tx? For each Rx, there's (usually)
> an XDP ring.
Probably we would be good to go with only max_rx, but in drivers during the
umem setup we also are comparing the queue id provided by user against the num
tx queues...so in theory, we could allocate the max_rx entries, but if the
current txq count is lower than reported max_rx, a bunch of map entries would
never be used, no?
>
> OTOH, when AF_XDP ZC is not implemented, it uses the skb path...
>
> > + else if (channels.max_combined == 0 || errno == EOPNOTSUPP)
> > /* 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;
> > + ret = -1;
> >
> > -out:
> > - close(fd);
> > return ret;
> > }
> >
> >
next prev parent reply other threads:[~2019-06-04 15:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190603131907.13395-1-maciej.fijalkowski@intel.com>
[not found] ` <20190603131907.13395-2-maciej.fijalkowski@intel.com>
2019-06-04 8:06 ` [RFC PATCH bpf-next 1/4] libbpf: fill the AF_XDP fill queue before bind() call Björn Töpel
2019-06-04 15:04 ` Maciej Fijalkowski
2019-06-04 15:54 ` Jonathan Lemon
2019-06-05 9:00 ` Björn Töpel
[not found] ` <20190603131907.13395-3-maciej.fijalkowski@intel.com>
2019-06-04 8:06 ` [RFC PATCH bpf-next 2/4] libbpf: check for channels.max_{t,r}x in xsk_get_max_queues Björn Töpel
2019-06-04 15:05 ` Maciej Fijalkowski [this message]
[not found] ` <20190603131907.13395-4-maciej.fijalkowski@intel.com>
2019-06-04 8:07 ` [RFC PATCH bpf-next 3/4] libbpf: move xdp program removal to libbpf Björn Töpel
2019-06-04 15:06 ` Maciej Fijalkowski
2019-06-05 9:03 ` Björn Töpel
[not found] ` <20190603131907.13395-5-maciej.fijalkowski@intel.com>
2019-06-04 8:08 ` [RFC PATCH bpf-next 4/4] libbpf: don't remove eBPF resources when other xsks are present Björn Töpel
2019-06-04 15:07 ` Maciej Fijalkowski
2019-06-05 9:26 ` Björn Töpel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190604170545.00003ee7@gmail.com \
--to=maciejromanfijalkowski@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jakub.kicinski@netronome.com \
--cc=jonathan.lemon@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).