diff options
author | Jakub Kicinski <jakub.kicinski@netronome.com> | 2017-06-22 04:25:08 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-23 20:42:20 +0300 |
commit | cafa92ac255337517ca2466ab05ca9f24c0ca9de (patch) | |
tree | 6f1f17c742343527b93fc40f10e5baed8d070cdc /drivers/net/ethernet/netronome | |
parent | 6a8ef5428c9fb5b589c2c912889d157abb50dd61 (diff) | |
download | linux-cafa92ac255337517ca2466ab05ca9f24c0ca9de.tar.xz |
nfp: bpf: add support for XDP_FLAGS_HW_MODE
Respect the XDP_FLAGS_HW_MODE. When it's set install the program
on the NIC and skip enabling XDP in the driver.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/netronome')
-rw-r--r-- | drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 35b4530a7e02..c9fc1df1823e 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -3302,19 +3302,25 @@ static int nfp_net_xdp_setup(struct nfp_net *nn, struct bpf_prog *prog, u32 flags, struct netlink_ext_ack *extack) { - struct bpf_prog *offload_prog; + struct bpf_prog *drv_prog, *offload_prog; int err; if (nn->xdp_prog && (flags ^ nn->xdp_flags) & XDP_FLAGS_MODES) return -EBUSY; + /* Load both when no flags set to allow easy activation of driver path + * when program is replaced by one which can't be offloaded. + */ + drv_prog = flags & XDP_FLAGS_HW_MODE ? NULL : prog; offload_prog = flags & XDP_FLAGS_DRV_MODE ? NULL : prog; - err = nfp_net_xdp_setup_drv(nn, prog, extack); + err = nfp_net_xdp_setup_drv(nn, drv_prog, extack); if (err) return err; - nfp_app_xdp_offload(nn->app, nn, offload_prog); + err = nfp_app_xdp_offload(nn->app, nn, offload_prog); + if (err && flags & XDP_FLAGS_HW_MODE) + return err; if (nn->xdp_prog) bpf_prog_put(nn->xdp_prog); @@ -3330,6 +3336,7 @@ static int nfp_net_xdp(struct net_device *netdev, struct netdev_xdp *xdp) switch (xdp->command) { case XDP_SETUP_PROG: + case XDP_SETUP_PROG_HW: return nfp_net_xdp_setup(nn, xdp->prog, xdp->flags, xdp->extack); case XDP_QUERY_PROG: |