DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hao Chen <chenh@yusur.tech>
To: dev@dpdk.org
Cc: zy@yusur.tech, Maxime Coquelin <maxime.coquelin@redhat.com>,
	Chenbo Xia <chenbo.xia@intel.com>
Subject: [PATCH v3] examples/vdpa: support running in nested virtualization environment
Date: Tue, 25 Oct 2022 02:19:39 -0400	[thread overview]
Message-ID: <20221025061939.3229676-1-chenh@yusur.tech> (raw)
In-Reply-To: <20221025060848.3227766-1-chenh@yusur.tech>

When we run dpdk vdpa in the nested virtual machine vm-L1 and ping
test in vm-L2, the ping is NG. The reason for troubleshooting is
that the virtio net in vm-L2 sends control information to the vring,
and the qemu back-end device in vm-L1 cannot obtain correct data
from the vring. This problem is related to the opening of the vIOMMU.

This patch add option '--iommu-support' to use guest vIOMMU to
protect vhost, then the ping test in vm-L2 is OK.
This option is required in a nested virtualization environment.

Signed-off-by: Hao Chen <chenh@yusur.tech>
---
v3:
*Modify mail title.

v2:
*fprintf all string including the eal one.
*remove exit(1).

 examples/vdpa/main.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c
index 4c7e81d7b6..71149461c6 100644
--- a/examples/vdpa/main.c
+++ b/examples/vdpa/main.c
@@ -43,16 +43,18 @@ static char iface[MAX_PATH_LEN];
 static int devcnt;
 static int interactive;
 static int client_mode;
+static int iommu_support;
 
 /* display usage */
 static void
 vdpa_usage(const char *prgname)
 {
-	printf("Usage: %s [EAL options] -- "
-				 "	--interactive|-i: run in interactive mode.\n"
-				 "	--iface <path>: specify the path prefix of the socket files, e.g. /tmp/vhost-user-.\n"
-				 "	--client: register a vhost-user socket as client mode.\n",
-				 prgname);
+	const char *usage_str = "	--interactive|-i: run in interactive mode.\n"
+				"	--iface <path>: specify the path prefix of the socket files, e.g. /tmp/vhost-user-.\n"
+				"	--client: register a vhost-user socket as client mode.\n"
+				"	--iommu-support: use guest vIOMMU to protect vhost.\n";
+
+	fprintf(stderr, "Usage: %s [EAL options] --\n%s", prgname, usage_str);
 }
 
 static int
@@ -63,6 +65,7 @@ parse_args(int argc, char **argv)
 		{"iface", required_argument, NULL, 0},
 		{"interactive", no_argument, &interactive, 1},
 		{"client", no_argument, &client_mode, 1},
+		{"iommu-support", no_argument, &iommu_support, 1},
 		{NULL, 0, 0, 0},
 	};
 	int opt, idx;
@@ -220,6 +223,10 @@ start_vdpa(struct vdpa_port *vport)
 			socket_path);
 		return -1;
 	}
+
+	if (iommu_support)
+		vport->flags |= RTE_VHOST_USER_IOMMU_SUPPORT;
+
 	ret = rte_vhost_driver_register(socket_path, vport->flags);
 	if (ret != 0)
 		rte_exit(EXIT_FAILURE,
-- 
2.27.0


  reply	other threads:[~2022-10-25  6:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11  2:55 [PATCH] example: vdpa: support run " Hao Chen
2022-10-17  7:23 ` Xia, Chenbo
2022-10-25  6:08 ` [PATCH v2] " Hao Chen
2022-10-25  6:19   ` Hao Chen [this message]
2022-10-26  6:10     ` [PATCH v3] examples/vdpa: support running " Maxime Coquelin
2022-10-26  6:48       ` Hao Chen
2022-11-14  3:04     ` [PATCH v4] " Hao Chen
2023-01-19 10:16       ` Maxime Coquelin
2023-02-03 14:47       ` Maxime Coquelin

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=20221025061939.3229676-1-chenh@yusur.tech \
    --to=chenh@yusur.tech \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=zy@yusur.tech \
    /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).