From: Yan Zhai <yan@cloudflare.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
linux-kernel@vger.kernel.org, yan@cloudflare.com
Subject: [RFC net-next 0/9] xdp: allow disable GRO per packet by XDP
Date: Thu, 20 Jun 2024 15:19:07 -0700 [thread overview]
Message-ID: <cover.1718919473.git.yan@cloudflare.com> (raw)
Software GRO is currently controlled by a single switch, i.e.
ethtool -K dev gro on|off
However, this is not always desired. When GRO is enabled, even if the
kernel cannot GRO certain traffic, it has to run through the GRO receive
handlers with no benefit.
There are also scenarios that turning off GRO is a requirement. For
example, our production environment has a scenario that a TC egress hook
may add multiple encapsulation headers to forwarded skbs for load
balancing and isolation purpose. The encapsulation is implemented via
BPF. But the problem arises then: there is no way to properly offload a
double-encapsulated packet, since skb only has network_header and
inner_network_header to track one layer of encapsulation, but not two.
On the other hand, not all the traffic through this device needs double
encapsulation. But we have to turn off GRO completely for any ingress
device as a result.
A natural approach to make this more flexible is to use XDP to control
GRO behavior. But current semantic gap between XDP buffer/frame and socket
buffer requires some new primitives.
This change set proposes a control bit gro_disabled on skbs to determine
if GRO should work on an skb or not. To manipulate this bit, we
introduce a new XDP kfunc bpf_xdp_disable_gro as well as generic helpers
xdp_frame/buff_fixup_skb_offloading.
The expected working flow is that:
* XDP program examines packets and can call bpf_xdp_disable_gro to
disable GRO on a packet
* Device drivers need to call xdp_buff_fixup_skb_offloading (or
equivalent version for xdp_frame), to check if skb->gro_disabled
needs to be set.
* The kernel will elide GRO later if this bit is used.
Initially we only modified a few drivers for demonstration purpose. The
driver side changes is optional and also incremental depending on
vendors' agenda. Any suggestions are welcome!
Jesper Dangaard Brouer (1):
mlx5: move xdp_buff scope one level up
Yan Zhai (8):
skb: introduce gro_disabled bit
xdp: add XDP_FLAGS_GRO_DISABLED flag
xdp: implement bpf_xdp_disable_gro kfunc
bnxt: apply XDP offloading fixup when building skb
ice: apply XDP offloading fixup when building skb
veth: apply XDP offloading fixup when building skb
mlx5: apply XDP offloading fixup when building skb
bpf: selftests: test disabling GRO by XDP
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 +
drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +
drivers/net/ethernet/intel/ice/ice_xsk.c | 6 +-
drivers/net/ethernet/mellanox/mlx5/core/en.h | 6 +-
.../ethernet/mellanox/mlx5/core/en/xsk/rx.c | 10 +-
.../ethernet/mellanox/mlx5/core/en/xsk/rx.h | 6 +-
.../net/ethernet/mellanox/mlx5/core/en_rx.c | 117 ++++++++++-------
drivers/net/veth.c | 4 +
include/linux/netdevice.h | 9 +-
include/linux/skbuff.h | 10 ++
include/net/xdp.h | 38 +++++-
include/net/xdp_sock_drv.h | 2 +-
net/Kconfig | 10 ++
net/core/gro.c | 2 +-
net/core/gro_cells.c | 2 +-
net/core/skbuff.c | 4 +
net/core/xdp.c | 27 +++-
tools/testing/selftests/bpf/config | 1 +
.../selftests/bpf/prog_tests/xdp_offloading.c | 122 ++++++++++++++++++
.../selftests/bpf/progs/xdp_offloading.c | 50 +++++++
20 files changed, 369 insertions(+), 63 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/xdp_offloading.c
create mode 100644 tools/testing/selftests/bpf/progs/xdp_offloading.c
--
2.30.2
next reply other threads:[~2024-06-20 22:19 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-20 22:19 Yan Zhai [this message]
2024-06-20 22:19 ` [RFC net-next 1/9] skb: introduce gro_disabled bit Yan Zhai
2024-06-21 9:11 ` Alexander Lobakin
2024-06-21 15:40 ` Yan Zhai
2024-06-21 9:49 ` Paolo Abeni
2024-06-21 14:29 ` Yan Zhai
2024-06-21 9:57 ` Paolo Abeni
2024-06-21 15:17 ` Yan Zhai
2024-06-21 12:15 ` Willem de Bruijn
2024-06-21 12:47 ` Daniel Borkmann
2024-06-21 16:00 ` Yan Zhai
2024-06-21 16:15 ` Daniel Borkmann
2024-06-21 17:20 ` Yan Zhai
2024-06-23 8:23 ` Willem de Bruijn
2024-06-24 13:30 ` Daniel Borkmann
2024-06-24 17:49 ` Yan Zhai
2024-06-21 15:34 ` Yan Zhai
2024-06-23 8:27 ` Willem de Bruijn
2024-06-24 18:17 ` Yan Zhai
2024-06-30 13:40 ` Willem de Bruijn
2024-07-03 18:46 ` Yan Zhai
2024-06-20 22:19 ` [RFC net-next 2/9] xdp: add XDP_FLAGS_GRO_DISABLED flag Yan Zhai
2024-06-21 9:15 ` Alexander Lobakin
2024-06-21 16:12 ` Yan Zhai
2024-06-20 22:19 ` [RFC net-next 3/9] xdp: implement bpf_xdp_disable_gro kfunc Yan Zhai
2024-06-20 22:19 ` [RFC net-next 4/9] bnxt: apply XDP offloading fixup when building skb Yan Zhai
2024-06-20 22:19 ` [RFC net-next 5/9] ice: " Yan Zhai
2024-06-21 9:20 ` Alexander Lobakin
2024-06-21 16:05 ` Yan Zhai
2024-06-20 22:19 ` [RFC net-next 6/9] veth: " Yan Zhai
2024-06-20 22:19 ` [RFC net-next 7/9] mlx5: move xdp_buff scope one level up Jesper Dangaard Brouer
2024-06-20 22:19 ` [RFC net-next 8/9] mlx5: apply XDP offloading fixup when building skb Yan Zhai
2024-06-20 22:19 ` [RFC net-next 9/9] bpf: selftests: test disabling GRO by XDP Yan Zhai
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=cover.1718919473.git.yan@cloudflare.com \
--to=yan@cloudflare.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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).