From: Tom Herbert <tom@herbertland.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: <kernel-team@fb.com>, <tariqt@mellanox.com>,
<bblanco@plumgrid.com>, <alexei.starovoitov@gmail.com>,
<eric.dumazet@gmail.com>, <brouer@redhat.com>
Subject: [PATCH RFC 0/3] xdp: Generalize XDP
Date: Tue, 20 Sep 2016 15:00:21 -0700 [thread overview]
Message-ID: <1474408824-418864-1-git-send-email-tom@herbertland.com> (raw)
This patch set generalizes XDP by make the hooks in drivers to be
generic in the same manner of nfhooks. This has a number of
advantages:
- Allows alternative users of the XDP hooks other than the original
BPF
- Allows a means to pipeline XDP programs together
- Reduces the amount of code and complexity needed in drivers to
manage XDP
- Provides a more structured environment that is extensible to new
features while being mostly transparent to the drivers
The generic XDP infrastructure is based on how nfhooks works. The new
xdp_hook_ops structure contains callback functions and private data
structure that can be populated by the user of XDP. The hook ops are
registered either on a netdev or a napi (both maintain a list of XDP
hook ops). Allow per netdev ops makes management of XDP a lot simpler
when the intent is for the hook to apply to the whole driver (as is the
case with XDP_BPF so far). The downside is that we may need per napi
data (such as counters of returned actions).
The xdp_hook_ops contains three fields of interest. The "hook" field is
the function that is run for the hook. This takes a private data field
and the xdp_buff as arguments. "priv" is private data and "put_priv"
is a function called when XDP is done with the private data. In XDP_BPF
terminology the hook field is bpf_prog_run_xdp, "priv" is the xdp_prog,
and "put_priv" is bpf_prog_put.
The meaning of ndo_xdp is also changed. There are two commands for this
nod: XDP_DEV_INIT and XDP_DEV_FINISH. XDP_DEV_INIT is called the first
time an XDP hook is set on a device, this is primarily intended to
allow the device to initialize XDP (allocated the XDP TX queues for
instance). XDP_DEV_FINISH is called when the last XDP hook is
removed from a driver so that the driver can cleanup when XDP is done.
A new net feature is added NETIF_F_XDP so that a driver indicates
that is supports XDP.
The primary modification to a driver to support XDP is that it call
xdp_hook_run in the receive path (equivalent to bpf_prog_run in
previous XDP-BPF). The driver must deal with the four XDP return
actions XDP_PASS, XDP_DROP, XDP_TX, and XDP_ABORT.
xdp.h contains the interface to register and manage XDP hooks.
Tested:
Created a simple hook that does XDP_PASS and saw it works. A lot more
testing is needed for this.
Tom Herbert (3):
xdp: Infrastructure to generalize XDP
mlx4: Change XDP/BPF to use generic XDP infrastructure
netdevice: Remove obsolete xdp_netdev_command
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 64 ++------
drivers/net/ethernet/mellanox/mlx4/en_rx.c | 25 ++-
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 -
include/linux/filter.h | 19 +--
include/linux/netdev_features.h | 3 +-
include/linux/netdevice.h | 24 ++-
include/net/xdp.h | 218 +++++++++++++++++++++++++
include/uapi/linux/bpf.h | 20 ---
include/uapi/linux/xdp.h | 24 +++
net/core/Makefile | 2 +-
net/core/dev.c | 44 ++++-
net/core/filter.c | 7 +-
net/core/rtnetlink.c | 16 +-
net/core/xdp.c | 211 ++++++++++++++++++++++++
14 files changed, 534 insertions(+), 144 deletions(-)
create mode 100644 include/net/xdp.h
create mode 100644 include/uapi/linux/xdp.h
create mode 100644 net/core/xdp.c
--
2.8.0.rc2
next reply other threads:[~2016-09-20 22:00 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-20 22:00 Tom Herbert [this message]
2016-09-20 22:00 ` [PATCH RFC 1/3] xdp: Infrastructure to generalize XDP Tom Herbert
2016-09-20 22:37 ` Eric Dumazet
2016-09-20 22:40 ` Tom Herbert
2016-09-20 22:44 ` Thomas Graf
2016-09-20 22:49 ` Tom Herbert
2016-09-20 23:09 ` Thomas Graf
2016-09-20 23:18 ` Tom Herbert
2016-09-20 23:43 ` Thomas Graf
2016-09-20 23:59 ` Tom Herbert
2016-09-21 0:13 ` Alexei Starovoitov
2016-09-21 11:55 ` Thomas Graf
2016-09-21 14:19 ` Tom Herbert
2016-09-21 14:48 ` Thomas Graf
2016-09-21 15:08 ` Tom Herbert
2016-09-21 19:56 ` Jesper Dangaard Brouer
2016-09-22 13:14 ` Jesper Dangaard Brouer
2016-09-22 14:46 ` Eric Dumazet
2016-09-21 15:39 ` Alexei Starovoitov
2016-09-21 17:26 ` Jakub Kicinski
2016-09-20 23:22 ` Daniel Borkmann
2016-09-21 0:01 ` Alexei Starovoitov
2016-09-21 6:39 ` Jesper Dangaard Brouer
2016-09-21 8:42 ` Daniel Borkmann
2016-09-21 15:44 ` Alexei Starovoitov
2016-09-21 17:26 ` Jakub Kicinski
2016-09-21 17:39 ` Tom Herbert
2016-09-21 18:45 ` Jakub Kicinski
2016-09-21 18:50 ` Tom Herbert
2016-09-21 18:54 ` Jakub Kicinski
2016-09-21 18:58 ` Thomas Graf
2016-09-23 11:13 ` Jamal Hadi Salim
2016-09-23 13:00 ` Jesper Dangaard Brouer
2016-09-23 14:26 ` Alexei Starovoitov
2016-09-25 11:32 ` Jamal Hadi Salim
2016-09-23 14:14 ` Tom Herbert
2016-09-25 12:29 ` Jamal Hadi Salim
2016-09-20 22:00 ` [PATCH RFC 2/3] mlx4: Change XDP/BPF to use generic XDP infrastructure Tom Herbert
2016-09-20 22:00 ` [PATCH RFC 3/3] netdevice: Remove obsolete xdp_netdev_command Tom Herbert
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=1474408824-418864-1-git-send-email-tom@herbertland.com \
--to=tom@herbertland.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bblanco@plumgrid.com \
--cc=brouer@redhat.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=tariqt@mellanox.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).