Re: AF_XDP metadata/hints

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alexander Lobakin wrote:
> From: John Fastabend <john.fastabend@xxxxxxxxx>
> Date: Wed, 26 May 2021 08:35:49 -0700
> 
> Hi all,
> 
> >Toke Høiland-Jørgensen wrote:
> >> Jesper Dangaard Brouer <brouer@xxxxxxxxxx> writes:
> >> 
> >> > On Tue, 25 May 2021 21:51:22 -0700
> >> > John Fastabend <john.fastabend@xxxxxxxxx> wrote:
> >> >
> >> >> Separate the config of hardware from the BPF infrastructure these
> >> >> are two separate things.
> >> >
> >> > I fully agree.
> 
> It was not about hardware feature reprogramming like csumming and
> stuff, only about composing the medatada according to the prog's
> request.
> 
> >> +1. Another reason why is the case of multiple XDP programs on a single
> >> interface: When attaching these (using freplace as libxdp does it), the
> >> kernel can just check the dest interface when verifying the freplace
> >> program and any rewriting of the bytecode from the BTF format can happen
> >> at that point. Whereas if the BPF attach needs to have side effects,
> >> suddenly we have to copy over all the features to the dispatcher program
> >> and do some kind of set union operation; and what happens if an freplace
> >> program is attached after the fact (same thing with tail calls)?
> >> 
> >> So in my mind there's no doubt this needs to be:
> >> 
> >> driver is config'ed -> it changes its exposed BTF metadata -> program is
> >> attached -> verifier rewrites program to access metadata correctly
> >
> >Well likely libbpf would do the rewrite I think.
> 
> So your proposal is to not compose metadata according to the prog's
> request, but rather reprogram the prog itself to access metadata
> accordingly? Sounds very nice.

Correct, otherwise you end up trying to parse programs and infer what
its trying to access and I don't want that logic in the driver. Or you
have to go into the BPF core and try to get it to pass the driver metadata.
And I don't want to add complexity to the BPF core bits.

> 
> If follow this path, is it something like this?
> 
> 1. Driver exposes the fields layout (e.g. Rx/Tx descriptor fields)
> via BTF to the BPF layer.

Not to the kernel BPF layer but to userspace so we can do CO-RE in
userspace before loading the program. While we learn how to use
this I expect we can just pass around a BTF file its not needed
to have the driver interface expose it as a first step.

Presumably you can generate the BTF when you configure the hardware.
I assume hardware config is close to a firmware update.

> 2. When an XDP prog is attached, BPF reprograms it to look for the
> required fields at the right offset.

User space can rewrite the fields using the existing infrastructure.
Dumb snippit,

  struct my_metadata m = (struct my_metadata *) data->metadata

  my_foo = m->foo;

Then CO-RE layer will know how to rewrite that m->foo to the right
offset into the metadata if we give it the normal CO-RE annotations.

> 
> >> 
> >> > How should we handle existing config interfaces?
> >> >
> >> > Let me give some concrete examples. Today there are multiple existing
> >> > interfaces to enable/disable NIC hardware features that change what is
> >> > available to put in our BTF-layout.
> >> >
> >> > E.g. changing if VLAN is in descriptor:
> >> >  # ethtool -K ixgbe1 rx-vlan-offload off
> >> >  # ethtool -k ixgbe1 | grep vlan-offload
> >> >  rx-vlan-offload: off
> >> >  tx-vlan-offload: on
> >> >
> >> > The timestamping features can be listed by ethtool -T (see below
> >> > signature), but it is a socket option that enable[1] these
> >> > (see SO_TIMESTAMPNS or SOF_TIMESTAMPING_RX_HARDWARE).
> >> >
> >> > Or tuning RSS hash fields:
> >> >  [2] https://github.com/stackpath/rxtxcpu/blob/master/Documentation/case-studies/observing-rss-on-ixgbe-advanced-rss-configuration-rss-hash-fields.md
> >> >
> >> > I assume we need to stay compatible and respect the existing config
> >> > interfaces, right?
> 
> Again, XDP Hints won't change any netdev features and stuff, only
> compose provide the hardware provided fields that are currently
> inaccessible by the XDP prog and say cpumap code, but that are
> highly needed (cpumap builds skbs without csums -> GRO layer
> consumes CPU time to calculate it manually, without RSS hash ->
> Flow Dissector consumes CPU time to calculate it manually +
> possible NAPI bucket misses etc.).

Thats a specific cpumap problem correct? In general checksums work
as expected?

> 
> So, neither Ethtool (that doesn't belong to XDP at all) nor anything
> else that changes hardware behaviour is involved.

Good.

> 
> >I'm not convinced its a strict requirement, rather its a nice to
> >have. These are low level ethtool hooks into the hardware its
> >fine IMO if the hardware just reports off and uses a more robust
> >configuration channel. In general we should try to get away from
> >this model where kernel devs are acting as the gate keepers for
> >all hardware offloads and we explicit add checkboxs that driver
> >writers can use. The result is the current state of things where
> >we have very flexible hardware that are not usable from Linux.
> >
> >> >
> >> > Should we simple leverage existing interfaces?
> >> 
> >> Now that ethtool has moved to netlink it should be quite
> >> straight-forward to add a separate subset of commands for configuring
> >> metadata fields; and internally the kernel can map those to the existing
> >> config knobs, no?
> >
> >Its unclear to me how you simple expose knobs to reconfigure hardware.
> >It looks to me that you need to push a blob down to the hardware to
> >reconfigure it for new parsers, new actions, etc. But, maybe the
> >folks working on current hardware can speak up.
> >
> >> 
> >> E.g., if you tell the kernel you'd like to have the VLAN field as a
> >> metadata field that kinda implies that rx-vlan-offload should be turned
> >> on; etc. Any reason this would break down?
> >> 
> >> -Toke
> >> 
> 
> That's right. If you want to have a VLAN tag in the medatdata, make
> sure Rx offloading is enabled. Same with csums and the rest. No
> explicit switches on prog insertion/removing.
> 
> >Agree driver should be able to map these back onto 'legacy' feature
> >sets.
> >
> >I'll still have a basic question though. I've never invested much time
> >into the hints because its still not clear to me what the use case is?
> >What would we put in the hints and do we have any data to show it would be
> >a performance win.
> 
> As I said, currently both XDP Rx and XDP Tx paths suffer from that
> they lack some essential info like Rx csums and hashes and e.g.
> Tx csum status. XDP Hints are about to place these fields into
> the metadata area that is located right before the frame, so either
> BPF prog or mentioned cpumap could access it.

I'm not convinced hashes and csum are so interesting but show me some
data. Also my admittedly rough understanding of cpumap is that it helps
the case where hardware RSS is not sufficient. Seeing your coming from
the Intel hardware side why not fix the RSS root problem instead
of using cpumap at all? I think your hardware is flexible enough.

I would really prefer to see example use cases that are more generic
than the cpumap case.

> 
> >If its a simple hash of the headers then how would we use it? The
> >map_lookup/updates use IP addrs for keys in Cilium. So I think the
> >suggestion is to offload the jhash operation? But that requires some
> >program changes to work. Could someone convince me?
> >
> >Maybe packet timestamp?
> >
> >Thanks,
> >John
> 
> Thanks,
> Al






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux