DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, yliu@fridaylinux.org, mark.b.kavanagh@intel.com,
	thomas@monjalon.net, ktraynor@redhat.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [PATCH v2 2/3] vhost: add flag to enable iommu support
Date: Mon,  6 Nov 2017 21:38:11 +0100	[thread overview]
Message-ID: <20171106203812.18428-3-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20171106203812.18428-1-maxime.coquelin@redhat.com>

Qemu versions from v2.7.0 to v2.9.0 have their reply-ack protocol
feature implementation broken with multiqueue. The reply-ack
protocol feature is optional except for IOMMU feature.

This patch introduce a new RTE_VHOST_USER_IOMMU_SUPPORT flag to
enable VIRTIO_F_IOMMU_PLATFORM virtio feature.

By default, the IOMMU support is now disabled.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 doc/guides/prog_guide/vhost_lib.rst    | 14 ++++++++++++++
 doc/guides/rel_notes/release_17_11.rst |  3 ++-
 lib/librte_vhost/rte_vhost.h           |  1 +
 lib/librte_vhost/socket.c              |  6 ++++++
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst
index d02e3cf50..e71bdbd51 100644
--- a/doc/guides/prog_guide/vhost_lib.rst
+++ b/doc/guides/prog_guide/vhost_lib.rst
@@ -110,6 +110,20 @@ The following is an overview of some key Vhost API functions:
       of those segments, thus the fewer the segments, the quicker we will get
       the mapping. NOTE: we may speed it by using tree searching in future.
 
+  - ``RTE_VHOST_USER_IOMMU_SUPPORT``
+
+    IOMMU support will be enabled when this flag is set. It is disabled by
+    default.
+
+    Enabling this flag makes possible to use guest vIOMMU to protect vhost
+    from accessing memory the virtio device isn't allowed to, when the feature
+    is negotiated and an IOMMU device is declared.
+
+    However, this feature enables vhost-user's reply-ack protocol feature,
+    which implementation is buggy in Qemu v2.7.0-v2.9.0 when doing multiqueue.
+    Enabling this flag with these Qemu version results in Qemu being blocked
+    when multiple queue pairs are declared.
+
 * ``rte_vhost_driver_set_features(path, features)``
 
   This function sets the feature bits the vhost-user driver supports. The
diff --git a/doc/guides/rel_notes/release_17_11.rst b/doc/guides/rel_notes/release_17_11.rst
index b96b23614..06f2a302c 100644
--- a/doc/guides/rel_notes/release_17_11.rst
+++ b/doc/guides/rel_notes/release_17_11.rst
@@ -162,7 +162,8 @@ New Features
 * **Added IOMMU support to libvhost-user**
 
   Implemented device IOTLB in Vhost-user backend, and enabled Virtio's IOMMU
-  feature.
+  feature. The feature is disabled by default, and can be enabled by setting
+  RTE_VHOST_USER_IOMMU_SUPPORT flag at vhost device registration time.
 
 * **Added the Event Ethernet Adapter Library.**
 
diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
index fe5c94c69..f65364495 100644
--- a/lib/librte_vhost/rte_vhost.h
+++ b/lib/librte_vhost/rte_vhost.h
@@ -56,6 +56,7 @@ extern "C" {
 #define RTE_VHOST_USER_CLIENT		(1ULL << 0)
 #define RTE_VHOST_USER_NO_RECONNECT	(1ULL << 1)
 #define RTE_VHOST_USER_DEQUEUE_ZERO_COPY	(1ULL << 2)
+#define RTE_VHOST_USER_IOMMU_SUPPORT	(1ULL << 3)
 
 /**
  * Information relating to memory regions including offsets to
diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
index 701815021..422da002f 100644
--- a/lib/librte_vhost/socket.c
+++ b/lib/librte_vhost/socket.c
@@ -68,6 +68,7 @@ struct vhost_user_socket {
 	bool is_server;
 	bool reconnect;
 	bool dequeue_zero_copy;
+	bool iommu_support;
 
 	/*
 	 * The "supported_features" indicates the feature bits the
@@ -669,6 +670,11 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
 	vsocket->supported_features = VIRTIO_NET_SUPPORTED_FEATURES;
 	vsocket->features           = VIRTIO_NET_SUPPORTED_FEATURES;
 
+	if (!(flags & RTE_VHOST_USER_IOMMU_SUPPORT)) {
+		vsocket->supported_features &= ~(1ULL << VIRTIO_F_IOMMU_PLATFORM);
+		vsocket->features &= ~(1ULL << VIRTIO_F_IOMMU_PLATFORM);
+	}
+
 	if ((flags & RTE_VHOST_USER_CLIENT) != 0) {
 		vsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT);
 		if (vsocket->reconnect && reconn_tid == 0) {
-- 
2.13.6

  parent reply	other threads:[~2017-11-06 20:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03 17:57 [dpdk-dev] [PATCH] vhost: disable reply-ack protocol feature if iommu feature disabled Maxime Coquelin
2017-11-06 14:22 ` Kavanagh, Mark B
2017-11-06 20:38 ` [dpdk-dev] [PATCH v2 0/3] vhost: disable iommu support by default Maxime Coquelin
2017-11-06 20:38   ` [dpdk-dev] [PATCH v2 1/3] vhost: disable reply-ack protocol feature if iommu feature disabled Maxime Coquelin
2017-11-06 20:38   ` Maxime Coquelin [this message]
2017-11-06 20:38   ` [dpdk-dev] [PATCH v2 3/3] net: vhost: add iommu-support parameter to enable IOMMU feature Maxime Coquelin
2017-11-07  3:32   ` [dpdk-dev] [PATCH v2 0/3] vhost: disable iommu support by default Yuanhan Liu
2017-11-07 13:20     ` Thomas Monjalon
2017-11-07 10:56   ` Kavanagh, Mark B
2017-11-07 11:04     ` Maxime Coquelin
2017-11-07 11:08       ` Kavanagh, Mark B
2017-11-07 12:27         ` Maxime Coquelin
2017-11-07 11:25     ` Kevin Traynor
2017-11-07 11:30       ` Maxime Coquelin
2017-11-07 11:51         ` Kevin Traynor

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=20171106203812.18428-3-maxime.coquelin@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ktraynor@redhat.com \
    --cc=mark.b.kavanagh@intel.com \
    --cc=thomas@monjalon.net \
    --cc=yliu@fridaylinux.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).