From: Jesper Dangaard Brouer <brouer@redhat.com>
To: brouer@redhat.com, "Július Milan" <Julius.Milan@pantheon.tech>,
"Marek Závodský" <marek.zavodsky@pantheon.tech>
Cc: "xdp-newbies@vger.kernel.org" <xdp-newbies@vger.kernel.org>,
"Karlsson, Magnus" <magnus.karlsson@intel.com>,
"Björn Töpel" <bjorn.topel@intel.com>,
"Eelco Chaudron" <echaudro@redhat.com>,
"Thomas F Herbert" <therbert@redhat.com>,
"William Tu" <u9012063@gmail.com>
Subject: AF_XDP integration with FDio VPP? (Was: Questions about XDP)
Date: Fri, 23 Aug 2019 10:22:24 +0200 [thread overview]
Message-ID: <20190823102224.16141c87@carbon> (raw)
In-Reply-To: <CA+_TK733RPSU=sEqSFpk-La6RNuJJM4m7xsDgOZ-EnaRAwKwKA@mail.gmail.com>
Bringing these questions to the xdp-newbies list, where they belong.
Answers inlined below.
On Tue, 20 Aug 2019 21:17:57 +0200 Július Milan <Julius.Milan@pantheon.tech>
>
> I am writing AF_XDP driver for FDio VPP. I have 2 questions.
>
That sounds excellent. I was hoping someone would do this for FDio VPP.
Do notice that DPDK now also got AF_XDP support. IHMO it makes a lot
of sense to implement AF_XDP for FDio, and avoid the DPDK dependency.
(AFAIK FDio already got other back-ends than DPDK).
> 1 - I created a simple driver according to sample in kernel. I load my XDP
> program and pin the maps.
>
> Then in user application I create a socket, mmap the memory and
> push it to xskmap in program. All fine yet.
>
> Then I start another instance of user application and do the
> same, create socket, mmap the memory and trying to
>
> push it somewhere else into the map. But I got errno: 16
> "Device or resource busy" when trying to bind.
>
> I guess the memory can’t be mmaped 2 times, but should be
> shared, is that correct?
I'm cc'ing the AF_XDP experts, as I'm not sure myself. I mostly deal
with the in-kernel XDP path. (AF_XDP is essentially kernel bypass :-O)
> If so, I am wondering how to solve this nicely.
>
> Can I store the value of first socket (that created the mmaped
> memory) in some special map in my XDP program to avoid complicated
> inter-process communication?
>
> And what happens if this first socket is closed while any other
> sockets are still alive (using its shared mmaped memory)?
>
> What would you recommend? Maybe you have some sample.
We just added a sample (by Eelco Cc'ed) into XDP-tutorial:
https://github.com/xdp-project/xdp-tutorial/tree/master/advanced03-AF_XDP
At-least read the README.org file... to get over the common gotchas.
AFAIK the sample doesn't cover your use-case. I guess, we/someone
should extend the sample, to illustrate how how multiple interfaces can
share the same UMEM.
The official documentation is:
https://www.kernel.org/doc/html/latest/networking/af_xdp.html
> Can I do also atomic operations? (I want it just for such rare
> cases as initialization of next socket, to check if there already is
> one, that mmaped the memory)
>
>
>
> 2 – We want to do also some decap/encap on XDP layer, before
> redirecting it to the socket.
>
Decap on XDP layer is an excellent use-case, that demonstrate
cooperation between XDP and AF_XDP kernel-bypass facility.
> On RX way it is easy, I do what I want and redirect it to the
> socket, but can I achieve the same also on TX?
>
(Yes, RX case is easy)
We don't have an XDP TX hook yet... but so many people have requested
this, that we should add this.
> Can I catch the packet while TX in XDP and do something with it
> (encapsulate it) before sending it out?
Usually, we recommend people use the TC egress BPF hook to do the encap
in TX. For the AF_XDP use-case, the TC hook isn't there... so that is
not an option. Again an argument for an XDP-TX hook. You, could
of-cause add the encap header in your AF_XDP userspace program, but I
do understand it would make architectural sense that in-kernel XDP
would act as a decap/encap layer.
> If so what about performance?
>
For AF_XDP RX-side is really really fast, even in copy-mode.
For AF_XDP TX-side in copy-mode, it is rather slow, as it allocates
SKBs etc. We could optimize this further but we have not. When
enabling AF_XDP zero-copy mode, the TX-side is also super fast.
Another hint, for AF_XDP TX-side, remember to "produce" several packets
before doing the sendmsg system call. Thus, effectively doing bulking
on the TX-ring.
>
> By the way, great job with XDP ;)
Thanks!
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next parent reply other threads:[~2019-08-23 8:22 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <889477ed79c44e6a9395cf961f782209@pantheon.tech>
[not found] ` <CA+_TK733RPSU=sEqSFpk-La6RNuJJM4m7xsDgOZ-EnaRAwKwKA@mail.gmail.com>
2019-08-23 8:22 ` Jesper Dangaard Brouer [this message]
2019-08-23 12:23 ` AF_XDP integration with FDio VPP? (Was: Questions about XDP) Marek Zavodsky
2019-08-23 14:12 ` Marek Zavodsky
[not found] ` <87d6d1ccab164292bb050c55f2cd81f8@pantheon.tech>
2019-08-23 13:07 ` William Tu
2019-08-23 13:42 ` Björn Töpel
2019-08-23 14:56 ` Július Milan
2019-08-23 15:22 ` William Tu
2019-08-24 7:36 ` Pavel Popa
2019-08-31 8:41 ` Björn Töpel
2019-08-30 16:37 ` Július Milan
2019-08-31 9:13 ` Björn Töpel
2019-09-06 22:51 ` William Tu
2019-09-18 18:13 ` Július Milan
2019-09-19 7:22 ` Magnus Karlsson
2019-09-23 9:00 ` Július Milan
2019-09-23 13:01 ` Eelco Chaudron
2019-09-24 15:13 ` William Tu
2019-09-25 6:46 ` Július Milan
2019-09-25 7:48 ` Eelco Chaudron
2019-09-25 23:33 ` William Tu
2019-09-27 7:02 ` Magnus Karlsson
2019-09-27 18:08 ` William Tu
2019-09-30 6:51 ` Magnus Karlsson
2019-09-30 9:28 ` Eelco Chaudron
2019-09-30 11:02 ` Magnus Karlsson
2019-09-30 12:17 ` Eelco Chaudron
2019-09-30 22:49 ` William Tu
2019-10-10 9:30 ` Július Milan
2019-10-11 8:55 ` Magnus Karlsson
2019-08-23 13:15 ` William Tu
2019-08-23 13:36 ` 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=20190823102224.16141c87@carbon \
--to=brouer@redhat.com \
--cc=Julius.Milan@pantheon.tech \
--cc=bjorn.topel@intel.com \
--cc=echaudro@redhat.com \
--cc=magnus.karlsson@intel.com \
--cc=marek.zavodsky@pantheon.tech \
--cc=therbert@redhat.com \
--cc=u9012063@gmail.com \
--cc=xdp-newbies@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.