All of lore.kernel.org
 help / color / mirror / Atom feed
* XDP-hints: Howto support multiple BTF types per packet basis?
@ 2021-05-26 10:58 Jesper Dangaard Brouer
  2021-05-26 19:12 ` Andrii Nakryiko
  2021-07-28  9:54 ` XDP-hints: how to inform driver about hints Michal Swiatkowski
  0 siblings, 2 replies; 43+ messages in thread
From: Jesper Dangaard Brouer @ 2021-05-26 10:58 UTC (permalink / raw)
  To: BPF-dev-list, Alexander Lobakin, Andrii Nakryiko
  Cc: brouer, Karlsson, Magnus, Magnus Karlsson, David Ahern,
	Björn Töpel, Saeed Mahameed, kurt, Raczynski, Piotr,
	Zhang, Jessica, Maloor, Kishen, Gomes, Vinicius, Brandeburg,
	Jesse, Swiatkowski, Michal, Plantykow, Marta A, Desouza, Ederson,
	Song, Yoong Siang, Czapnik, Lukasz, John Fastabend, Joseph,
	Jithu, William Tu, Ong Boon Leong

Hi All,

I see a need for a driver to use different XDP metadata layout on a per
packet basis. E.g. PTP packets contains a hardware timestamp. E.g. VLAN
offloading and associated metadata as only relevant for packets using
VLANs. (Reserving room for every possible HW-hint is against the idea
of BTF).

The question is how to support multiple BTF types on per packet basis?
(I need input from BTF experts, to tell me if I'm going in the wrong
direction with below ideas).

Let me describe a possible/proposed packet flow (feel free to disagree):

 When driver RX e.g. a PTP packet it knows HW is configured for PTP-TS and
 when it sees a TS is available, then it chooses a code path that use the
 BTF layout that contains RX-TS. To communicate what BTF-type the
 XDP-metadata contains, it simply store the BTF-ID in xdp_buff->btf_id.

 When redirecting the xdp_buff is converted to xdp_frame, and also contains
 the btf_id member. When converting xdp_frame to SKB, then netcore-code
 checks if this BTF-ID have been registered, if so there is a (callback or
 BPF-hook) registered to handle this BTF-type that transfer the fields from
 XDP-metadata area into SKB fields.

 The XDP-prog also have access to this ctx->btf_id and can multiplex on
 this in the BPF-code itself. Or use other methods like parsing PTP packet
 and extract TS as expected BTF offset in XDP metadata (perhaps add a
 sanity check if metadata-size match).


I talked to AF_XDP people (Magnus, Bjørn and William) about this idea,
and they pointed out that AF_XDP also need to know what BTF-layout is
used. As Magnus wrote in other thread; there is only 32-bit left in
AF_XDP descriptor option. We could store the BTF-ID in this field, but
it would block for other use-cases. Bjørn came up with the idea of
storing the BTF-ID in the BTF-layout itself, but as the last-member (to
have fixed offset to check in userspace AF_XDP program). Then we only
need to use a single bit in AF_XDP descriptor option to say
XDP-metadata is BTF described.

In the AF_XDP userspace program, the programmers can have a similar
callback system per known BTF-ID. This way they can compile efficient
code per ID via requesting the BTF layout from the kernel. (Hint:
`bpftool btf dump id 42 format c`).

Please let me know if this it the right or wrong direction?

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


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

end of thread, other threads:[~2021-09-10 11:16 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 10:58 XDP-hints: Howto support multiple BTF types per packet basis? Jesper Dangaard Brouer
2021-05-26 19:12 ` Andrii Nakryiko
2021-05-26 20:20   ` Jesper Dangaard Brouer
2021-05-26 20:37     ` John Fastabend
2021-05-26 22:39     ` Andrii Nakryiko
2021-05-28 11:16       ` Jesper Dangaard Brouer
2021-05-30  3:24         ` Andrii Nakryiko
2021-05-26 20:31   ` John Fastabend
2021-05-26 22:54     ` Andrii Nakryiko
2021-05-27  0:44       ` John Fastabend
2021-05-27 17:44         ` Andrii Nakryiko
2021-05-28  5:48           ` John Fastabend
2021-05-28  9:16             ` Toke Høiland-Jørgensen
2021-05-28 10:38               ` Alexander Lobakin
2021-05-28 14:35               ` John Fastabend
2021-05-28 15:33                 ` Toke Høiland-Jørgensen
2021-05-28 16:02                 ` Jesper Dangaard Brouer
2021-05-28 17:29                   ` John Fastabend
2021-05-30  3:27                     ` Andrii Nakryiko
2021-05-31 11:03                     ` Toke Høiland-Jørgensen
2021-05-31 13:17                       ` Jesper Dangaard Brouer
2021-06-02  0:22                       ` John Fastabend
2021-06-02 16:18                         ` Jakub Kicinski
2021-06-22  7:44                           ` Michal Swiatkowski
2021-06-22 11:53                             ` Toke Høiland-Jørgensen
2021-06-23  8:32                               ` Michal Swiatkowski
2021-06-24 12:23                                 ` Toke Høiland-Jørgensen
2021-06-24 13:07                                   ` Magnus Karlsson
2021-06-24 14:58                                     ` Alexei Starovoitov
2021-06-24 15:11                                   ` Zvi Effron
2021-06-24 16:04                                     ` Toke Høiland-Jørgensen
2021-06-24 16:32                                       ` Zvi Effron
2021-06-24 16:45                                       ` Jesper Dangaard Brouer
2021-07-08  8:32                                   ` Michal Swiatkowski
2021-07-09 10:57                                     ` Toke Høiland-Jørgensen
2021-09-02  2:49                                       ` Michal Swiatkowski
2021-09-02  9:17                                         ` Jesper Dangaard Brouer
2021-09-07  6:27                                           ` Michal Swiatkowski
2021-09-08 13:28                                             ` Jesper Dangaard Brouer
2021-09-09 18:19                                               ` Andrii Nakryiko
2021-09-10 11:16                                                 ` Jesper Dangaard Brouer
2021-07-28  9:54 ` XDP-hints: how to inform driver about hints Michal Swiatkowski
2021-07-28 18:40   ` John Fastabend

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.