Skip to content

Commit a113243

Browse files
magnus-karlssonborkmann
authored andcommitted
xsk: Add shared umem support between devices
Add support to share a umem between different devices. This mode can be invoked with the XDP_SHARED_UMEM bind flag. Previously, sharing was only supported within the same device. Note that when sharing a umem between devices, just as in the case of sharing a umem between queue ids, you need to create a fill ring and a completion ring and tie them to the socket (with two setsockopts, one for each ring) before you do the bind with the XDP_SHARED_UMEM flag. This so that the single-producer single-consumer semantics of the rings can be upheld. Signed-off-by: Magnus Karlsson <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Björn Töpel <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent b5aea28 commit a113243

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

net/xdp/xsk.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -701,14 +701,11 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
701701
sockfd_put(sock);
702702
goto out_unlock;
703703
}
704-
if (umem_xs->dev != dev) {
705-
err = -EINVAL;
706-
sockfd_put(sock);
707-
goto out_unlock;
708-
}
709704

710-
if (umem_xs->queue_id != qid) {
711-
/* Share the umem with another socket on another qid */
705+
if (umem_xs->queue_id != qid || umem_xs->dev != dev) {
706+
/* Share the umem with another socket on another qid
707+
* and/or device.
708+
*/
712709
xs->pool = xp_create_and_assign_umem(xs,
713710
umem_xs->umem);
714711
if (!xs->pool) {

0 commit comments

Comments
 (0)