Commit d609f3d2 authored by Tirthendu Sarkar's avatar Tirthendu Sarkar Committed by Alexei Starovoitov

xsk: add multi-buffer support for sockets sharing umem

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: default avatarTirthendu Sarkar <tirthendu.sarkar@intel.com>
Fixes: 81470b5c ("xsk: introduce XSK_USE_SG bind flag for xsk socket")
Acked-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://lore.kernel.org/r/20230907035032.2627879-1-tirthendu.sarkar@intel.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 5c04433d
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <net/sock.h> #include <net/sock.h>
#define XDP_UMEM_SG_FLAG (1 << 1)
struct net_device; struct net_device;
struct xsk_queue; struct xsk_queue;
struct xdp_buff; struct xdp_buff;
......
...@@ -1228,7 +1228,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len) ...@@ -1228,7 +1228,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
xs->dev = dev; xs->dev = dev;
xs->zc = xs->umem->zc; xs->zc = xs->umem->zc;
xs->sg = !!(flags & XDP_USE_SG); xs->sg = !!(xs->umem->flags & XDP_UMEM_SG_FLAG);
xs->queue_id = qid; xs->queue_id = qid;
xp_add_xsk(xs->pool, xs); xp_add_xsk(xs->pool, xs);
......
...@@ -170,6 +170,9 @@ int xp_assign_dev(struct xsk_buff_pool *pool, ...@@ -170,6 +170,9 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
if (err) if (err)
return err; return err;
if (flags & XDP_USE_SG)
pool->umem->flags |= XDP_UMEM_SG_FLAG;
if (flags & XDP_USE_NEED_WAKEUP) if (flags & XDP_USE_NEED_WAKEUP)
pool->uses_need_wakeup = true; pool->uses_need_wakeup = true;
/* Tx needs to be explicitly woken up the first time. Also /* Tx needs to be explicitly woken up the first time. Also
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment