All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC v2 0/8] xdp: Generalize XDP
@ 2017-02-08 23:41 Tom Herbert
  2017-02-08 23:41 ` [PATCH RFC v2 1/8] xdp: Infrastructure to generalize XDP Tom Herbert
                   ` (7 more replies)
  0 siblings, 8 replies; 32+ messages in thread
From: Tom Herbert @ 2017-02-08 23:41 UTC (permalink / raw)
  To: netdev; +Cc: kernel-team

This patch set generalizes XDP by making the hooks in drivers to be
generic. 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 an xdp_hook structure that
contains callback functions and private data structure that can be
populated by the user of XDP. The XDP hooks are registered either on a
netdev or a napi (both maintain a list of XDP hooks). Allowing per
netdev hooks makes management of XDP a lot simpler when the intent is
for the hook to apply to the whole device (as is the case with XDP_BPF
so far).  Multiple xdp hooks may be registered on a device or napi
instance, the order of execution is indicated in the priority field of
the xdp_hook structure. Execution of the list contains to the end or
until a program returns something other than XDP_PASS. If both
napi XDP hooks and device hooks are enabled, the NAPI hooks are run
first.

The xdp_hook structure contains a "hookfn" field that is the function
executes a hook. The "priv" structure is private data that is provided
as an argument to hookfn-- in the case of a BPF hook this is simply
the bpf_prog.

Hooks may be registered by xdp_register_dev_hook or
xdp_register_napi_hook, and subsequently they can be unregistered
but xdp_unregister_dev_hook and xdp_unregister_napi_hook. The
identifier for a hook is the pointer to the template hook that was
used to register the hook. xdp_find_dev_hook and
xdp_find_napi_hook will return whether a hook has been registered
and optionally return the contents of the hook. xdp_bpf_check_prog
is called for BPF programs to check if the driver is okay with
running the program (uses the XDP_CHECK_BPF_PROG ndo command
described below).

Driver interface:

Drivers no longer deal with BPF programs for the most part, instead
they call into the XDP interface.

There are two functions of interest for use in the receive data path:
  - xdp_hook_run_needed_check: returns true if there is an XDP
    program registered on the napi instance or its device
  - xdp_hook_run, xdp_hook_run_ret_last: runs the XDP programs for
    the hooks registered for the given napi instance or its device.
    The latter variant returns a pointer to the last XDP hook that
    was run (useful for reporting).

The ndo_xdp defines a new set of commands for this interface. A driver
should implement these commands:
  - XDP_MODE_ON: Initialize device to use XDP. Called when first XDP
		 program is registered on a device (including on a NAPI
		 instance).
  - XDP_MODE_OFF: XDP is finished on the device. Called after the last
		  XDP hook has been unregistered for a device.
  - XDP_CHECK_BPF_PROG: Check if a BPF program is acceptable to a device
		  to run.
  - XDP_OFFLOAD_BPF: Offload the associated BPF program (e.g. Netronome).

A new net feature is added NETIF_F_XDP so that a driver indicates
that is supports XDP.

This patch set:
  - Adds the infrastructure described above include xdp.c and xdp.h files.
  - Modifies mlx4, mlx5, qede, nfp, and virt_net drivers to use the new
    interface. That is mostly removed the management of BPF programs and
    changing to call the new interface.

v2:
  - Eliminate use of nfhooks like lists. Just use use simple array for
    the hooks
  - Modify more drivers that now support XDP

Tested: TBD


Tom Herbert (8):
  xdp: Infrastructure to generalize XDP
  mlx4: Changes to use generic XDP infrastructure
  nfp: Changes to use generic XDP infrastructure
  qede: Changes to use generic XDP infrastructure
  virt_net: Changes to use generic XDP infrastructure
  mlx5: Changes to use generic XDP infrastructure
  bnxt: Changes to use generic XDP infrastructure
  xdp: Cleanup after API changes

 drivers/net/ethernet/broadcom/bnxt/bnxt.c          |  14 -
 drivers/net/ethernet/broadcom/bnxt/bnxt.h          |   2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c      |  46 +--
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c     |  92 ++----
 drivers/net/ethernet/mellanox/mlx4/en_rx.c         |  27 +-
 drivers/net/ethernet/mellanox/mlx4/en_tx.c         |   1 +
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h       |   1 -
 drivers/net/ethernet/mellanox/mlx5/core/en.h       |   3 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  | 105 ++-----
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c    |  12 +-
 drivers/net/ethernet/netronome/nfp/nfp_bpf_jit.c   |   1 +
 drivers/net/ethernet/netronome/nfp/nfp_net.h       |   5 +-
 .../net/ethernet/netronome/nfp/nfp_net_common.c    | 170 ++++++-----
 .../net/ethernet/netronome/nfp/nfp_net_ethtool.c   |  12 +-
 drivers/net/ethernet/qlogic/qede/qede.h            |   3 +-
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c    |   2 +-
 drivers/net/ethernet/qlogic/qede/qede_filter.c     |  39 ++-
 drivers/net/ethernet/qlogic/qede/qede_fp.c         |  36 ++-
 drivers/net/ethernet/qlogic/qede/qede_main.c       |  23 +-
 drivers/net/virtio_net.c                           |  98 +++----
 include/linux/filter.h                             |  11 +-
 include/linux/netdev_features.h                    |   3 +-
 include/linux/netdevice.h                          |  27 +-
 include/net/xdp.h                                  | 310 +++++++++++++++++++++
 include/trace/events/xdp.h                         |  16 +-
 net/core/Makefile                                  |   2 +-
 net/core/dev.c                                     |  53 ++--
 net/core/filter.c                                  |   7 +-
 net/core/rtnetlink.c                               |  14 +-
 net/core/xdp.c                                     | 304 ++++++++++++++++++++
 30 files changed, 942 insertions(+), 497 deletions(-)
 create mode 100644 include/net/xdp.h
 create mode 100644 net/core/xdp.c

-- 
2.9.3

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

end of thread, other threads:[~2017-02-14 22:29 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-08 23:41 [PATCH RFC v2 0/8] xdp: Generalize XDP Tom Herbert
2017-02-08 23:41 ` [PATCH RFC v2 1/8] xdp: Infrastructure to generalize XDP Tom Herbert
2017-02-09  7:49   ` Jiri Pirko
2017-02-09 14:22   ` Mintz, Yuval
2017-02-09 22:17   ` David Miller
2017-02-09 22:26     ` Tom Herbert
2017-02-09 22:34       ` David Miller
2017-02-09 22:45         ` Tom Herbert
2017-02-10  1:42           ` David Miller
2017-02-10  2:29             ` Tom Herbert
2017-02-10  3:33               ` David Miller
2017-02-10  4:55                 ` Tom Herbert
2017-02-10 15:12                   ` David Miller
2017-02-09 23:08         ` Tom Herbert
2017-02-10  1:48           ` David Miller
2017-02-10  2:30             ` Tom Herbert
2017-02-10  5:42               ` Jason Wang
2017-02-13  2:41   ` [lkp-robot] [xdp] 543d41bf78: INFO:suspicious_RCU_usage kernel test robot
2017-02-13  2:41     ` kernel test robot
2017-02-14 20:31   ` [PATCH RFC v2 1/8] xdp: Infrastructure to generalize XDP Jesper Dangaard Brouer
2017-02-14 20:47     ` Tom Herbert
2017-02-14 21:07       ` Tom Herbert
2017-02-14 22:08         ` Edward Cree
2017-02-14 22:28           ` Tom Herbert
2017-02-14 22:29           ` Jesper Dangaard Brouer
2017-02-08 23:41 ` [PATCH RFC v2 2/8] mlx4: Changes to use generic XDP infrastructure Tom Herbert
2017-02-08 23:41 ` [PATCH RFC v2 3/8] nfp: " Tom Herbert
2017-02-08 23:41 ` [PATCH RFC v2 4/8] qede: " Tom Herbert
2017-02-08 23:41 ` [PATCH RFC v2 5/8] virt_net: " Tom Herbert
2017-02-08 23:41 ` [PATCH RFC v2 6/8] mlx5: " Tom Herbert
2017-02-08 23:41 ` [PATCH RFC v2 7/8] bnxt: " Tom Herbert
2017-02-08 23:41 ` [PATCH RFC v2 8/8] xdp: Cleanup after API changes Tom Herbert

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.