bpf: allow requesting XDP HW offload

Let XDP link set command request that the program be offloaded.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
Jakub Kicinski 2017-06-26 17:23:53 -07:00 committed by Stephen Hemminger
parent 1468381415
commit 1b5e809466
4 changed files with 14 additions and 4 deletions

View File

@ -616,12 +616,15 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
addattr_l(&req->n, sizeof(*req), IFLA_MTU, &mtu, 4);
} else if (strcmp(*argv, "xdpgeneric") == 0 ||
strcmp(*argv, "xdpdrv") == 0 ||
strcmp(*argv, "xdpoffload") == 0 ||
strcmp(*argv, "xdp") == 0) {
bool generic = strcmp(*argv, "xdpgeneric") == 0;
bool drv = strcmp(*argv, "xdpdrv") == 0;
bool offload = strcmp(*argv, "xdpoffload") == 0;
NEXT_ARG();
if (xdp_parse(&argc, &argv, req, generic, drv))
if (xdp_parse(&argc, &argv, req, generic, drv,
offload))
exit(-1);
} else if (strcmp(*argv, "netns") == 0) {
NEXT_ARG();

View File

@ -48,7 +48,7 @@ static int xdp_delete(struct xdp_req *xdp)
}
int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic,
bool drv)
bool drv, bool offload)
{
struct bpf_cfg_in cfg = {
.argc = *argc,
@ -64,6 +64,8 @@ int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic,
xdp.flags |= XDP_FLAGS_SKB_MODE;
if (drv)
xdp.flags |= XDP_FLAGS_DRV_MODE;
if (offload)
xdp.flags |= XDP_FLAGS_HW_MODE;
if (*argc == 1) {
if (strcmp(**argv, "none") == 0 ||

View File

@ -4,7 +4,7 @@
#include "utils.h"
int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic,
bool drv);
bool drv, bool offload);
void xdp_dump(FILE *fp, struct rtattr *tb);
#endif /* __XDP__ */

View File

@ -126,7 +126,7 @@ ip-link \- network device configuration
.RB "[ " port_guid " eui64 ] ]"
.br
.in -9
.RB "[ { " xdp " | " xdpgeneric " | " xdpdrv " } { " off " | "
.RB "[ { " xdp " | " xdpgeneric " | " xdpdrv " | " xdpoffload " } { " off " | "
.br
.in +8
.BR object
@ -1595,6 +1595,11 @@ generic XDP variant be disabled and in case driver is not XDP-capable error
should be returned.
.B xdpdrv
also disables hardware offloads.
.B xdpoffload
in ip link output indicates that the program has been offloaded to hardware
and can also be used to request the "offload" mode, much like
.B xdpgeneric
it forces program to be installed specifically in HW/FW of the apater.
.B off
(or