* [PATCH bpf-next] xsk: add multi-buffer support for sockets sharing umem
@ 2023-09-07 3:50 Tirthendu Sarkar
2023-09-07 8:12 ` Maciej Fijalkowski
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Tirthendu Sarkar @ 2023-09-07 3:50 UTC (permalink / raw)
To: bpf
Cc: netdev, bjorn, magnus.karlsson, maciej.fijalkowski,
jonathan.lemon, davem, kuba, pabeni, ast, daniel
Userspace applications indicate their multi-buffer capability to xsk
using XSK_USE_SG socket bind flag. For sockets using shared umem the
bind flag may contain XSK_USE_SG only for the first socket. For any
subsequent socket the only option supported is XDP_SHARED_UMEM.
Add option XDP_UMEM_SG_FLAG in umem config flags to store the
multi-buffer handling capability when indicated by XSK_USE_SG option in
bing flag by the first socket. Use this to derive multi-buffer capability
for subsequent sockets in xsk core.
Signed-off-by: Tirthendu Sarkar <tirthendu.sarkar@intel.com>
Fixes: 81470b5c3c66 ("xsk: introduce XSK_USE_SG bind flag for xsk socket")
---
include/net/xdp_sock.h | 2 ++
net/xdp/xsk.c | 2 +-
net/xdp/xsk_buff_pool.c | 3 +++
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
index 1617af380162..69b472604b86 100644
--- a/include/net/xdp_sock.h
+++ b/include/net/xdp_sock.h
@@ -14,6 +14,8 @@
#include <linux/mm.h>
#include <net/sock.h>
+#define XDP_UMEM_SG_FLAG (1 << 1)
+
struct net_device;
struct xsk_queue;
struct xdp_buff;
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 55f8b9b0e06d..7482d0aca504 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -1228,7 +1228,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
xs->dev = dev;
xs->zc = xs->umem->zc;
- xs->sg = !!(flags & XDP_USE_SG);
+ xs->sg = !!(xs->umem->flags & XDP_UMEM_SG_FLAG);
xs->queue_id = qid;
xp_add_xsk(xs->pool, xs);
diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index b3f7b310811e..49cb9f9a09be 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -170,6 +170,9 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
if (err)
return err;
+ if (flags & XDP_USE_SG)
+ pool->umem->flags |= XDP_UMEM_SG_FLAG;
+
if (flags & XDP_USE_NEED_WAKEUP)
pool->uses_need_wakeup = true;
/* Tx needs to be explicitly woken up the first time. Also
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next] xsk: add multi-buffer support for sockets sharing umem
2023-09-07 3:50 [PATCH bpf-next] xsk: add multi-buffer support for sockets sharing umem Tirthendu Sarkar
@ 2023-09-07 8:12 ` Maciej Fijalkowski
2023-09-07 15:12 ` Simon Horman
2023-09-15 18:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Maciej Fijalkowski @ 2023-09-07 8:12 UTC (permalink / raw)
To: Tirthendu Sarkar
Cc: bpf, netdev, bjorn, magnus.karlsson, jonathan.lemon, davem, kuba,
pabeni, ast, daniel
On Thu, Sep 07, 2023 at 09:20:32AM +0530, Tirthendu Sarkar wrote:
> Userspace applications indicate their multi-buffer capability to xsk
> using XSK_USE_SG socket bind flag. For sockets using shared umem the
> bind flag may contain XSK_USE_SG only for the first socket. For any
> subsequent socket the only option supported is XDP_SHARED_UMEM.
>
> Add option XDP_UMEM_SG_FLAG in umem config flags to store the
> multi-buffer handling capability when indicated by XSK_USE_SG option in
> bing flag by the first socket. Use this to derive multi-buffer capability
> for subsequent sockets in xsk core.
>
> Signed-off-by: Tirthendu Sarkar <tirthendu.sarkar@intel.com>
> Fixes: 81470b5c3c66 ("xsk: introduce XSK_USE_SG bind flag for xsk socket")
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> include/net/xdp_sock.h | 2 ++
> net/xdp/xsk.c | 2 +-
> net/xdp/xsk_buff_pool.c | 3 +++
> 3 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
> index 1617af380162..69b472604b86 100644
> --- a/include/net/xdp_sock.h
> +++ b/include/net/xdp_sock.h
> @@ -14,6 +14,8 @@
> #include <linux/mm.h>
> #include <net/sock.h>
>
> +#define XDP_UMEM_SG_FLAG (1 << 1)
> +
> struct net_device;
> struct xsk_queue;
> struct xdp_buff;
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 55f8b9b0e06d..7482d0aca504 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -1228,7 +1228,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
>
> xs->dev = dev;
> xs->zc = xs->umem->zc;
> - xs->sg = !!(flags & XDP_USE_SG);
> + xs->sg = !!(xs->umem->flags & XDP_UMEM_SG_FLAG);
> xs->queue_id = qid;
> xp_add_xsk(xs->pool, xs);
>
> diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
> index b3f7b310811e..49cb9f9a09be 100644
> --- a/net/xdp/xsk_buff_pool.c
> +++ b/net/xdp/xsk_buff_pool.c
> @@ -170,6 +170,9 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
> if (err)
> return err;
>
> + if (flags & XDP_USE_SG)
> + pool->umem->flags |= XDP_UMEM_SG_FLAG;
> +
> if (flags & XDP_USE_NEED_WAKEUP)
> pool->uses_need_wakeup = true;
> /* Tx needs to be explicitly woken up the first time. Also
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next] xsk: add multi-buffer support for sockets sharing umem
2023-09-07 3:50 [PATCH bpf-next] xsk: add multi-buffer support for sockets sharing umem Tirthendu Sarkar
2023-09-07 8:12 ` Maciej Fijalkowski
@ 2023-09-07 15:12 ` Simon Horman
2023-09-11 8:50 ` Sarkar, Tirthendu
2023-09-15 18:10 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2023-09-07 15:12 UTC (permalink / raw)
To: Tirthendu Sarkar
Cc: bpf, netdev, bjorn, magnus.karlsson, maciej.fijalkowski,
jonathan.lemon, davem, kuba, pabeni, ast, daniel
On Thu, Sep 07, 2023 at 09:20:32AM +0530, Tirthendu Sarkar wrote:
> Userspace applications indicate their multi-buffer capability to xsk
> using XSK_USE_SG socket bind flag. For sockets using shared umem the
> bind flag may contain XSK_USE_SG only for the first socket. For any
> subsequent socket the only option supported is XDP_SHARED_UMEM.
>
> Add option XDP_UMEM_SG_FLAG in umem config flags to store the
> multi-buffer handling capability when indicated by XSK_USE_SG option in
> bing flag by the first socket. Use this to derive multi-buffer capability
> for subsequent sockets in xsk core.
>
> Signed-off-by: Tirthendu Sarkar <tirthendu.sarkar@intel.com>
> Fixes: 81470b5c3c66 ("xsk: introduce XSK_USE_SG bind flag for xsk socket")
> ---
> include/net/xdp_sock.h | 2 ++
> net/xdp/xsk.c | 2 +-
> net/xdp/xsk_buff_pool.c | 3 +++
> 3 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
> index 1617af380162..69b472604b86 100644
> --- a/include/net/xdp_sock.h
> +++ b/include/net/xdp_sock.h
> @@ -14,6 +14,8 @@
> #include <linux/mm.h>
> #include <net/sock.h>
>
> +#define XDP_UMEM_SG_FLAG (1 << 1)
nit: This could be BIT(1)
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH bpf-next] xsk: add multi-buffer support for sockets sharing umem
2023-09-07 15:12 ` Simon Horman
@ 2023-09-11 8:50 ` Sarkar, Tirthendu
0 siblings, 0 replies; 5+ messages in thread
From: Sarkar, Tirthendu @ 2023-09-11 8:50 UTC (permalink / raw)
To: Simon Horman
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, bjorn@kernel.org,
Karlsson, Magnus, Fijalkowski, Maciej, jonathan.lemon@gmail.com,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
ast@kernel.org, daniel@iogearbox.net
> -----Original Message-----
> From: Simon Horman <horms@kernel.org>
> Subject: Re: [PATCH bpf-next] xsk: add multi-buffer support for sockets
> sharing umem
>
> On Thu, Sep 07, 2023 at 09:20:32AM +0530, Tirthendu Sarkar wrote:
> > Userspace applications indicate their multi-buffer capability to xsk
> > using XSK_USE_SG socket bind flag. For sockets using shared umem the
> > bind flag may contain XSK_USE_SG only for the first socket. For any
> > subsequent socket the only option supported is XDP_SHARED_UMEM.
> >
> > Add option XDP_UMEM_SG_FLAG in umem config flags to store the
> > multi-buffer handling capability when indicated by XSK_USE_SG option in
> > bing flag by the first socket. Use this to derive multi-buffer capability
> > for subsequent sockets in xsk core.
> >
> > Signed-off-by: Tirthendu Sarkar <tirthendu.sarkar@intel.com>
> > Fixes: 81470b5c3c66 ("xsk: introduce XSK_USE_SG bind flag for xsk socket")
> > ---
> > include/net/xdp_sock.h | 2 ++
> > net/xdp/xsk.c | 2 +-
> > net/xdp/xsk_buff_pool.c | 3 +++
> > 3 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
> > index 1617af380162..69b472604b86 100644
> > --- a/include/net/xdp_sock.h
> > +++ b/include/net/xdp_sock.h
> > @@ -14,6 +14,8 @@
> > #include <linux/mm.h>
> > #include <net/sock.h>
> >
> > +#define XDP_UMEM_SG_FLAG (1 << 1)
>
> nit: This could be BIT(1)
Thanks. We could have a follow up patch with such changes across xsk core.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next] xsk: add multi-buffer support for sockets sharing umem
2023-09-07 3:50 [PATCH bpf-next] xsk: add multi-buffer support for sockets sharing umem Tirthendu Sarkar
2023-09-07 8:12 ` Maciej Fijalkowski
2023-09-07 15:12 ` Simon Horman
@ 2023-09-15 18:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-09-15 18:10 UTC (permalink / raw)
To: Sarkar, Tirthendu
Cc: bpf, netdev, bjorn, magnus.karlsson, maciej.fijalkowski,
jonathan.lemon, davem, kuba, pabeni, ast, daniel
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Thu, 7 Sep 2023 09:20:32 +0530 you wrote:
> Userspace applications indicate their multi-buffer capability to xsk
> using XSK_USE_SG socket bind flag. For sockets using shared umem the
> bind flag may contain XSK_USE_SG only for the first socket. For any
> subsequent socket the only option supported is XDP_SHARED_UMEM.
>
> Add option XDP_UMEM_SG_FLAG in umem config flags to store the
> multi-buffer handling capability when indicated by XSK_USE_SG option in
> bing flag by the first socket. Use this to derive multi-buffer capability
> for subsequent sockets in xsk core.
>
> [...]
Here is the summary with links:
- [bpf-next] xsk: add multi-buffer support for sockets sharing umem
https://git.kernel.org/bpf/bpf-next/c/d609f3d228a8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-09-15 18:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-07 3:50 [PATCH bpf-next] xsk: add multi-buffer support for sockets sharing umem Tirthendu Sarkar
2023-09-07 8:12 ` Maciej Fijalkowski
2023-09-07 15:12 ` Simon Horman
2023-09-11 8:50 ` Sarkar, Tirthendu
2023-09-15 18:10 ` patchwork-bot+netdevbpf
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).