Skip to content

Commit d609f3d

Browse files
tirthendu-intelAlexei Starovoitov
authored andcommitted
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: Tirthendu Sarkar <tirthendu.sarkar@intel.com> Fixes: 81470b5 ("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>
1 parent 5c04433 commit d609f3d

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

include/net/xdp_sock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/mm.h>
1515
#include <net/sock.h>
1616

17+
#define XDP_UMEM_SG_FLAG (1 << 1)
18+
1719
struct net_device;
1820
struct xsk_queue;
1921
struct xdp_buff;

net/xdp/xsk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
12281228

12291229
xs->dev = dev;
12301230
xs->zc = xs->umem->zc;
1231-
xs->sg = !!(flags & XDP_USE_SG);
1231+
xs->sg = !!(xs->umem->flags & XDP_UMEM_SG_FLAG);
12321232
xs->queue_id = qid;
12331233
xp_add_xsk(xs->pool, xs);
12341234

net/xdp/xsk_buff_pool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
170170
if (err)
171171
return err;
172172

173+
if (flags & XDP_USE_SG)
174+
pool->umem->flags |= XDP_UMEM_SG_FLAG;
175+
173176
if (flags & XDP_USE_NEED_WAKEUP)
174177
pool->uses_need_wakeup = true;
175178
/* Tx needs to be explicitly woken up the first time. Also

0 commit comments

Comments
 (0)