mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-08-15 09:33:17 +00:00
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:
parent
2de3379701
commit
1468381415
@ -615,11 +615,13 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
|
|||||||
invarg("Invalid \"mtu\" value\n", *argv);
|
invarg("Invalid \"mtu\" value\n", *argv);
|
||||||
addattr_l(&req->n, sizeof(*req), IFLA_MTU, &mtu, 4);
|
addattr_l(&req->n, sizeof(*req), IFLA_MTU, &mtu, 4);
|
||||||
} else if (strcmp(*argv, "xdpgeneric") == 0 ||
|
} else if (strcmp(*argv, "xdpgeneric") == 0 ||
|
||||||
|
strcmp(*argv, "xdpdrv") == 0 ||
|
||||||
strcmp(*argv, "xdp") == 0) {
|
strcmp(*argv, "xdp") == 0) {
|
||||||
bool generic = strcmp(*argv, "xdpgeneric") == 0;
|
bool generic = strcmp(*argv, "xdpgeneric") == 0;
|
||||||
|
bool drv = strcmp(*argv, "xdpdrv") == 0;
|
||||||
|
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (xdp_parse(&argc, &argv, req, generic))
|
if (xdp_parse(&argc, &argv, req, generic, drv))
|
||||||
exit(-1);
|
exit(-1);
|
||||||
} else if (strcmp(*argv, "netns") == 0) {
|
} else if (strcmp(*argv, "netns") == 0) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
@ -47,7 +47,8 @@ static int xdp_delete(struct xdp_req *xdp)
|
|||||||
return 0;
|
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 = {
|
struct bpf_cfg_in cfg = {
|
||||||
.argc = *argc,
|
.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;
|
xdp.flags |= XDP_FLAGS_UPDATE_IF_NOEXIST;
|
||||||
if (generic)
|
if (generic)
|
||||||
xdp.flags |= XDP_FLAGS_SKB_MODE;
|
xdp.flags |= XDP_FLAGS_SKB_MODE;
|
||||||
|
if (drv)
|
||||||
|
xdp.flags |= XDP_FLAGS_DRV_MODE;
|
||||||
|
|
||||||
if (*argc == 1) {
|
if (*argc == 1) {
|
||||||
if (strcmp(**argv, "none") == 0 ||
|
if (strcmp(**argv, "none") == 0 ||
|
||||||
|
3
ip/xdp.h
3
ip/xdp.h
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#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);
|
void xdp_dump(FILE *fp, struct rtattr *tb);
|
||||||
|
|
||||||
#endif /* __XDP__ */
|
#endif /* __XDP__ */
|
||||||
|
@ -126,7 +126,7 @@ ip-link \- network device configuration
|
|||||||
.RB "[ " port_guid " eui64 ] ]"
|
.RB "[ " port_guid " eui64 ] ]"
|
||||||
.br
|
.br
|
||||||
.in -9
|
.in -9
|
||||||
.RB "[ { " xdp " | " xdpgeneric " } { " off " | "
|
.RB "[ { " xdp " | " xdpgeneric " | " xdpdrv " } { " off " | "
|
||||||
.br
|
.br
|
||||||
.in +8
|
.in +8
|
||||||
.BR object
|
.BR object
|
||||||
@ -1589,6 +1589,12 @@ only. If the driver does have native XDP support, but the program is
|
|||||||
loaded under
|
loaded under
|
||||||
.B xdpgeneric object "|" pinned
|
.B xdpgeneric object "|" pinned
|
||||||
then the kernel will use the generic XDP variant instead of the native one.
|
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
|
.B off
|
||||||
(or
|
(or
|
||||||
|
Loading…
Reference in New Issue
Block a user