Skip to content

Commit

Permalink
xsk: Add shared umem support between devices
Browse files Browse the repository at this point in the history
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 <magnus.karlsson@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Björn Töpel <bjorn.topel@intel.com>
Link: https://lore.kernel.org/bpf/1598603189-32145-13-git-send-email-magnus.karlsson@intel.com
  • Loading branch information
magnus-karlsson authored and borkmann committed Aug 31, 2020
1 parent b5aea28 commit a113243
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions net/xdp/xsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,14 +701,11 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
sockfd_put(sock);
goto out_unlock;
}
if (umem_xs->dev != dev) {
err = -EINVAL;
sockfd_put(sock);
goto out_unlock;
}

if (umem_xs->queue_id != qid) {
/* Share the umem with another socket on another qid */
if (umem_xs->queue_id != qid || umem_xs->dev != dev) {
/* Share the umem with another socket on another qid
* and/or device.
*/
xs->pool = xp_create_and_assign_umem(xs,
umem_xs->umem);
if (!xs->pool) {
Expand Down

0 comments on commit a113243

Please sign in to comment.