xdp-project / xdp-tools

Utilities and example programs for use with XDP
Other
644 stars 139 forks source link

xdp-loader will not perform hardware offload mode #170

Closed davehouser1 closed 1 year ago

davehouser1 commented 2 years ago

When trying to perform xdp-loader load -m hw ens224 ./xdp_prog_kern.o I keep getting the following error:

Couldn't attach XDP program on iface 'ens224': Invalid argument(-22)

My xdp program works fine with generic and native modes.

Here is info on the interface:

# ethtool -i ens224
driver: i40e
version: 5.11.0-49-generic
firmware-version: 7.10 0x800075e1 19.5.12
expansion-rom-version:
bus-info: 0000:5e:00.2
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: yes
# ip link show dev ens224
6: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether f8:f2:1e:bd:12:b2 brd ff:ff:ff:ff:ff:ff
# uname -r
5.11.0-49-generic

How can I troubleshoot this? Its not clear to me what Invalid argument(-22) means.

tohojo commented 2 years ago

What hardware are you trying this on?

davehouser1 commented 2 years ago

@tohojo here is the lshw -c network info

  *-network:2
       description: Ethernet interface
       product: Ethernet Controller X710 for 10GbE SFP+
       vendor: Intel Corporation
       physical id: 0.2
       bus info: pci@0000:86:00.2
       logical name: ens224
       version: 02
       serial: f8:f2:1e:bd:11:82
       capacity: 10Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi msix pciexpress vpd bus_master cap_list rom ethernet physical 10000bt-fd autonegotiation
       configuration: autonegotiation=off broadcast=yes driver=i40e driverversion=5.11.0-49-generic firmware=7.10 0x800075e1 19.5.12 latency=0 link=no multicast=yes
       resources: irq:277 memory:d5000000-d5ffffff memory:d8008000-d800ffff memory:d3900000-d397ffff
tohojo commented 2 years ago

Oh, sorry, missed you already included the driver info. Intel cards don't support hardware offloaded BPF, so the error is expected...

davehouser1 commented 2 years ago

Ok, how do you know that? Is there somewhere I can go to look up this information? or a way to check from the Linux Kernel?

tohojo commented 2 years ago

davehouser1 @.***> writes:

Ok, how do you know that? Is there somewhere I can go to look up this information? or a way to check from the Linux Kernel?

Sadly no way to check it at runtime. There's a list of drivers and their support in the Cilium docs, but sadly it hasn't been updated since kernel 4.17: https://docs.cilium.io/en/latest/bpf/ (but for hw offload it's still accurate).

Otherwise, all you can do is try it out, or grep the kernel sources for XDP_SETUP_PROG_HW

Being able to query for support has been on our wishlist for a while, but nothing has materialised so far...

davehouser1 commented 2 years ago

@tohojo Thanks for the info. Sounds like I just need to look up if my card can do hardware offload or reach out to the manufacture to check if it can. I will close the case, however I would recommend someone update the documentation here before I do. It was not clear to me that only specific NICs support HW offload even if your driver carries support. The section under the -m, --mode <mode> section to state not all NICs support hardware offload and research with the NIC manufacture is needed to determine if there is support for the feature.

tohojo commented 2 years ago

Sounds like I just need to look up if my card can do hardware offload or reach out to the manufacture to check if it can.

In principle, yes, but in this instance I can tell you with confidence that it can't :)

You're quite right that the documentation could certainly mention this. I don't suppose you'd be interested in contributing some text to fix this?