netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 0/3] ip-link: XDP flags and offload mode
@ 2017-06-27  0:23 Jakub Kicinski
  2017-06-27  0:23 ` [PATCH iproute2 1/3] bpf: print xdp offloaded mode Jakub Kicinski
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Jakub Kicinski @ 2017-06-27  0:23 UTC (permalink / raw)
  To: netdev; +Cc: daniel, oss-drivers, Jakub Kicinski

Hi!

This series adds support for specifying DRV_MODE and new HW_MODE
flags when binding an XDP program to the driver.  It also teaches
ip link about "xdpoffload" attachment mode.

Examples:
# ip link set dev p4p1 xdpoffload obj prog.o sec '.text'
# ip link show dev p4p1
60: p4p1: <BROADCAST,MULTICAST> mtu 1500 xdpoffload/id:2 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 00:15:4d:12:27:6b brd ff:ff:ff:ff:ff:ff
# ip link set dev p4p1 xdpoffload off

Note: this is based on top of Martin's "bpf: Add support for 
IFLA_XDP_PROG_ID".

Jakub Kicinski (3):
  bpf: print xdp offloaded mode
  bpf: add xdpdrv for requesting XDP driver mode
  bpf: allow requesting XDP HW offload

 include/linux/if_link.h |  2 ++
 ip/iplink.c             |  7 ++++++-
 ip/iplink_xdp.c         |  9 ++++++++-
 ip/xdp.h                |  3 ++-
 man/man8/ip-link.8.in   | 13 ++++++++++++-
 5 files changed, 30 insertions(+), 4 deletions(-)

-- 
2.11.0

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

* [PATCH iproute2 1/3] bpf: print xdp offloaded mode
  2017-06-27  0:23 [PATCH iproute2 0/3] ip-link: XDP flags and offload mode Jakub Kicinski
@ 2017-06-27  0:23 ` Jakub Kicinski
  2017-06-27  0:29   ` Daniel Borkmann
  2017-06-27  0:23 ` [PATCH iproute2 2/3] bpf: add xdpdrv for requesting XDP driver mode Jakub Kicinski
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2017-06-27  0:23 UTC (permalink / raw)
  To: netdev; +Cc: daniel, oss-drivers, Jakub Kicinski

Add interpretation of XDP_ATTACHED_HW mode on dump.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 include/linux/if_link.h | 1 +
 ip/iplink_xdp.c         | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index ea57f3c74c77..8a41b3bafcd4 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -897,6 +897,7 @@ enum {
 	XDP_ATTACHED_NONE = 0,
 	XDP_ATTACHED_DRV,
 	XDP_ATTACHED_SKB,
+	XDP_ATTACHED_HW,
 };
 
 enum {
diff --git a/ip/iplink_xdp.c b/ip/iplink_xdp.c
index 4857f50c80de..1b4ef3b836e8 100644
--- a/ip/iplink_xdp.c
+++ b/ip/iplink_xdp.c
@@ -93,6 +93,8 @@ void xdp_dump(FILE *fp, struct rtattr *xdp)
 		fprintf(fp, "xdp");
 	else if (mode == XDP_ATTACHED_SKB)
 		fprintf(fp, "xdpgeneric");
+	else if (mode == XDP_ATTACHED_HW)
+		fprintf(fp, "xdpoffload");
 	else
 		fprintf(fp, "xdp[%u]", mode);
 
-- 
2.11.0

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

* [PATCH iproute2 2/3] bpf: add xdpdrv for requesting XDP driver mode
  2017-06-27  0:23 [PATCH iproute2 0/3] ip-link: XDP flags and offload mode Jakub Kicinski
  2017-06-27  0:23 ` [PATCH iproute2 1/3] bpf: print xdp offloaded mode Jakub Kicinski
@ 2017-06-27  0:23 ` Jakub Kicinski
  2017-06-27  0:30   ` Daniel Borkmann
  2017-06-27  0:23 ` [PATCH iproute2 3/3] bpf: allow requesting XDP HW offload Jakub Kicinski
  2017-06-27 23:15 ` [PATCH iproute2 0/3] ip-link: XDP flags and offload mode Stephen Hemminger
  3 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2017-06-27  0:23 UTC (permalink / raw)
  To: netdev; +Cc: daniel, oss-drivers, Jakub Kicinski

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>
---
 ip/iplink.c           | 4 +++-
 ip/iplink_xdp.c       | 5 ++++-
 ip/xdp.h              | 3 ++-
 man/man8/ip-link.8.in | 8 +++++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/ip/iplink.c b/ip/iplink.c
index 682f7eebd139..811513c01c25 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -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();
diff --git a/ip/iplink_xdp.c b/ip/iplink_xdp.c
index 1b4ef3b836e8..cabb2348562e 100644
--- a/ip/iplink_xdp.c
+++ b/ip/iplink_xdp.c
@@ -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 ||
diff --git a/ip/xdp.h b/ip/xdp.h
index 1b95e0f63a99..5f594132f494 100644
--- a/ip/xdp.h
+++ b/ip/xdp.h
@@ -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__ */
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 5d73538b7ec3..326002d95e87 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -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
-- 
2.11.0

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

* [PATCH iproute2 3/3] bpf: allow requesting XDP HW offload
  2017-06-27  0:23 [PATCH iproute2 0/3] ip-link: XDP flags and offload mode Jakub Kicinski
  2017-06-27  0:23 ` [PATCH iproute2 1/3] bpf: print xdp offloaded mode Jakub Kicinski
  2017-06-27  0:23 ` [PATCH iproute2 2/3] bpf: add xdpdrv for requesting XDP driver mode Jakub Kicinski
@ 2017-06-27  0:23 ` Jakub Kicinski
  2017-06-27  0:31   ` Daniel Borkmann
  2017-06-27 23:15 ` [PATCH iproute2 0/3] ip-link: XDP flags and offload mode Stephen Hemminger
  3 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2017-06-27  0:23 UTC (permalink / raw)
  To: netdev; +Cc: daniel, oss-drivers, Jakub Kicinski

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

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 include/linux/if_link.h | 1 +
 ip/iplink.c             | 5 ++++-
 ip/iplink_xdp.c         | 4 +++-
 ip/xdp.h                | 2 +-
 man/man8/ip-link.8.in   | 7 ++++++-
 5 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 8a41b3bafcd4..3c0b2d365bcb 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -888,6 +888,7 @@ enum {
 #define XDP_FLAGS_UPDATE_IF_NOEXIST	(1U << 0)
 #define XDP_FLAGS_SKB_MODE		(1U << 1)
 #define XDP_FLAGS_DRV_MODE		(1U << 2)
+#define XDP_FLAGS_HW_MODE		(1U << 3)
 #define XDP_FLAGS_MASK			(XDP_FLAGS_UPDATE_IF_NOEXIST | \
 					 XDP_FLAGS_SKB_MODE | \
 					 XDP_FLAGS_DRV_MODE)
diff --git a/ip/iplink.c b/ip/iplink.c
index 811513c01c25..9674cb657322 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -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();
diff --git a/ip/iplink_xdp.c b/ip/iplink_xdp.c
index cabb2348562e..9ae9ee5d0665 100644
--- a/ip/iplink_xdp.c
+++ b/ip/iplink_xdp.c
@@ -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 ||
diff --git a/ip/xdp.h b/ip/xdp.h
index 5f594132f494..ba897a29af58 100644
--- a/ip/xdp.h
+++ b/ip/xdp.h
@@ -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__ */
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 326002d95e87..141d3597f945 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -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
-- 
2.11.0

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

* Re: [PATCH iproute2 1/3] bpf: print xdp offloaded mode
  2017-06-27  0:23 ` [PATCH iproute2 1/3] bpf: print xdp offloaded mode Jakub Kicinski
@ 2017-06-27  0:29   ` Daniel Borkmann
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Borkmann @ 2017-06-27  0:29 UTC (permalink / raw)
  To: Jakub Kicinski, netdev; +Cc: oss-drivers

On 06/27/2017 02:23 AM, Jakub Kicinski wrote:
> Add interpretation of XDP_ATTACHED_HW mode on dump.
>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

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

* Re: [PATCH iproute2 2/3] bpf: add xdpdrv for requesting XDP driver mode
  2017-06-27  0:23 ` [PATCH iproute2 2/3] bpf: add xdpdrv for requesting XDP driver mode Jakub Kicinski
@ 2017-06-27  0:30   ` Daniel Borkmann
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Borkmann @ 2017-06-27  0:30 UTC (permalink / raw)
  To: Jakub Kicinski, netdev; +Cc: oss-drivers

On 06/27/2017 02:23 AM, Jakub Kicinski wrote:
> 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>

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

* Re: [PATCH iproute2 3/3] bpf: allow requesting XDP HW offload
  2017-06-27  0:23 ` [PATCH iproute2 3/3] bpf: allow requesting XDP HW offload Jakub Kicinski
@ 2017-06-27  0:31   ` Daniel Borkmann
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Borkmann @ 2017-06-27  0:31 UTC (permalink / raw)
  To: Jakub Kicinski, netdev; +Cc: oss-drivers

On 06/27/2017 02:23 AM, Jakub Kicinski wrote:
> 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>

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

* Re: [PATCH iproute2 0/3] ip-link: XDP flags and offload mode
  2017-06-27  0:23 [PATCH iproute2 0/3] ip-link: XDP flags and offload mode Jakub Kicinski
                   ` (2 preceding siblings ...)
  2017-06-27  0:23 ` [PATCH iproute2 3/3] bpf: allow requesting XDP HW offload Jakub Kicinski
@ 2017-06-27 23:15 ` Stephen Hemminger
  3 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2017-06-27 23:15 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, daniel, oss-drivers

On Mon, 26 Jun 2017 17:23:50 -0700
Jakub Kicinski <jakub.kicinski@netronome.com> wrote:

> Hi!
> 
> This series adds support for specifying DRV_MODE and new HW_MODE
> flags when binding an XDP program to the driver.  It also teaches
> ip link about "xdpoffload" attachment mode.
> 
> Examples:
> # ip link set dev p4p1 xdpoffload obj prog.o sec '.text'
> # ip link show dev p4p1
> 60: p4p1: <BROADCAST,MULTICAST> mtu 1500 xdpoffload/id:2 qdisc noop state DOWN mode DEFAULT group default qlen 1000
>     link/ether 00:15:4d:12:27:6b brd ff:ff:ff:ff:ff:ff
> # ip link set dev p4p1 xdpoffload off
> 
> Note: this is based on top of Martin's "bpf: Add support for 
> IFLA_XDP_PROG_ID".
> 
> Jakub Kicinski (3):
>   bpf: print xdp offloaded mode
>   bpf: add xdpdrv for requesting XDP driver mode
>   bpf: allow requesting XDP HW offload
> 
>  include/linux/if_link.h |  2 ++
>  ip/iplink.c             |  7 ++++++-
>  ip/iplink_xdp.c         |  9 ++++++++-
>  ip/xdp.h                |  3 ++-
>  man/man8/ip-link.8.in   | 13 ++++++++++++-
>  5 files changed, 30 insertions(+), 4 deletions(-)
> 

Applied to net-next.
Next time please put net-next in the patch subject line (same as for kernel).

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

end of thread, other threads:[~2017-06-27 23:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-27  0:23 [PATCH iproute2 0/3] ip-link: XDP flags and offload mode Jakub Kicinski
2017-06-27  0:23 ` [PATCH iproute2 1/3] bpf: print xdp offloaded mode Jakub Kicinski
2017-06-27  0:29   ` Daniel Borkmann
2017-06-27  0:23 ` [PATCH iproute2 2/3] bpf: add xdpdrv for requesting XDP driver mode Jakub Kicinski
2017-06-27  0:30   ` Daniel Borkmann
2017-06-27  0:23 ` [PATCH iproute2 3/3] bpf: allow requesting XDP HW offload Jakub Kicinski
2017-06-27  0:31   ` Daniel Borkmann
2017-06-27 23:15 ` [PATCH iproute2 0/3] ip-link: XDP flags and offload mode Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).