bpf: add xdpdrv for requesting XDP driver mode

Allow user to select XDP DRV_MODE flag by using xdpdrv keyword
instead of xdp or xdpgeneric.

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:52 -07:00 committed by Stephen Hemminger
parent 2de3379701
commit 1468381415
4 changed files with 16 additions and 4 deletions

View File

@ -615,11 +615,13 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
invarg("Invalid \"mtu\" value\n", *argv);
addattr_l(&req->n, sizeof(*req), IFLA_MTU, &mtu, 4);
} else if (strcmp(*argv, "xdpgeneric") == 0 ||
strcmp(*argv, "xdpdrv") == 0 ||
strcmp(*argv, "xdp") == 0) {
bool generic = strcmp(*argv, "xdpgeneric") == 0;
bool drv = strcmp(*argv, "xdpdrv") == 0;
NEXT_ARG();
if (xdp_parse(&argc, &argv, req, generic))
if (xdp_parse(&argc, &argv, req, generic, drv))
exit(-1);
} else if (strcmp(*argv, "netns") == 0) {
NEXT_ARG();

View File

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

View File

@ -3,7 +3,8 @@
#include "utils.h"
int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic);
int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic,
bool drv);
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 " } { " off " | "
.RB "[ { " xdp " | " xdpgeneric " | " xdpdrv " } { " off " | "
.br
.in +8
.BR object
@ -1589,6 +1589,12 @@ only. If the driver does have native XDP support, but the program is
loaded under
.B xdpgeneric object "|" pinned
then the kernel will use the generic XDP variant instead of the native one.
.B xdpdrv
has the opposite effect of requestsing that the automatic fallback to the
generic XDP variant be disabled and in case driver is not XDP-capable error
should be returned.
.B xdpdrv
also disables hardware offloads.
.B off
(or