]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xsk: add multi-buffer support for sockets sharing umem
authorTirthendu Sarkar <tirthendu.sarkar@intel.com>
Thu, 7 Sep 2023 03:50:32 +0000 (09:20 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 15 Sep 2023 18:00:22 +0000 (11:00 -0700)
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>
Link: https://lore.kernel.org/r/20230907035032.2627879-1-tirthendu.sarkar@intel.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/net/xdp_sock.h
net/xdp/xsk.c
net/xdp/xsk_buff_pool.c

index 1617af3801620f034b00ef570ae3d530e53851bd..69b472604b86f5a8dd678a2327449f72e98ece0b 100644 (file)
@@ -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;
index 55f8b9b0e06d1ff88e918de56dce9635f3a19f08..7482d0aca5046ed637fcbeca7f5e403ed60eec08 100644 (file)
@@ -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);
 
index b3f7b310811edfa492b81fe026859dd17017df8d..49cb9f9a09beedb8f029da2325ea1fad1d338e0c 100644 (file)
@@ -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