netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: William Tu <u9012063@gmail.com>
To: netdev@vger.kernel.org
Cc: dev@openvswitch.org, i.maximets@ovn.org, echaudro@redhat.com,
	bjorn.topel@intel.com, magnus.karlsson@intel.com
Subject: [PATCH net-next] xsk: Enable shared umem support.
Date: Tue,  5 Nov 2019 15:35:38 -0800	[thread overview]
Message-ID: <1572996938-23957-1-git-send-email-u9012063@gmail.com> (raw)

Currently the shared umem feature is not supported in libbpf.
The patch removes the refcount check in libbpf to enable use of
shared umem.  Also, a umem can be shared by multiple netdevs,
so remove the checking at xsk_bind.

Tested using OVS at:
https://mail.openvswitch.org/pipermail/ovs-dev/2019-November/364392.html

Signed-off-by: William Tu <u9012063@gmail.com>
---
 net/xdp/xsk.c       |  5 -----
 tools/lib/bpf/xsk.c | 10 +++++-----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 6040bc2b0088..0f2b16e275e3 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -697,11 +697,6 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
 			sockfd_put(sock);
 			goto out_unlock;
 		}
-		if (umem_xs->dev != dev || umem_xs->queue_id != qid) {
-			err = -EINVAL;
-			sockfd_put(sock);
-			goto out_unlock;
-		}
 
 		xdp_get_umem(umem_xs->umem);
 		WRITE_ONCE(xs->umem, umem_xs->umem);
diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
index 74d84f36a5b2..e6c4eb077dcd 100644
--- a/tools/lib/bpf/xsk.c
+++ b/tools/lib/bpf/xsk.c
@@ -579,16 +579,13 @@ int xsk_socket__create(struct xsk_socket **xsk_ptr, const char *ifname,
 	struct sockaddr_xdp sxdp = {};
 	struct xdp_mmap_offsets off;
 	struct xsk_socket *xsk;
+	bool shared;
 	int err;
 
 	if (!umem || !xsk_ptr || !rx || !tx)
 		return -EFAULT;
 
-	if (umem->refcount) {
-		pr_warn("Error: shared umems not supported by libbpf.\n");
-		return -EBUSY;
-	}
-
+	shared = !!(usr_config->bind_flags & XDP_SHARED_UMEM);
 	xsk = calloc(1, sizeof(*xsk));
 	if (!xsk)
 		return -ENOMEM;
@@ -687,6 +684,9 @@ int xsk_socket__create(struct xsk_socket **xsk_ptr, const char *ifname,
 	sxdp.sxdp_queue_id = xsk->queue_id;
 	sxdp.sxdp_flags = xsk->config.bind_flags;
 
+	if (shared)
+		sxdp.sxdp_shared_umem_fd = umem->fd;
+
 	err = bind(xsk->fd, (struct sockaddr *)&sxdp, sizeof(sxdp));
 	if (err) {
 		err = -errno;
-- 
2.7.4


             reply	other threads:[~2019-11-05 23:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 23:35 William Tu [this message]
2019-11-06 16:53 ` [PATCH net-next] xsk: Enable shared umem support Magnus Karlsson
2019-11-06 17:38   ` William Tu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1572996938-23957-1-git-send-email-u9012063@gmail.com \
    --to=u9012063@gmail.com \
    --cc=bjorn.topel@intel.com \
    --cc=dev@openvswitch.org \
    --cc=echaudro@redhat.com \
    --cc=i.maximets@ovn.org \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).