DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tetsuya Mukawa <mukawa@igel.co.jp>
To: dev@dpdk.org
Cc: nakajima.yoshihiro@lab.ntt.co.jp, masutani.hitoshi@lab.ntt.co.jp
Subject: [dpdk-dev] [RFC PATCH 5/7] lib/librte_vhost: Add a vhost session abstraction
Date: Thu,  6 Nov 2014 20:14:29 +0900
Message-ID: <1415272471-3299-6-git-send-email-mukawa@igel.co.jp> (raw)
In-Reply-To: <1415272471-3299-1-git-send-email-mukawa@igel.co.jp>

Vhost session relates vhost communication layer to virtio-net
device layer. Because vhost-cuse and vhost-user have different
session information, the patch is needed.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_vhost/rte_virtio_net.h  | 2 +-
 lib/librte_vhost/vhost-net-cdev.c  | 8 ++++----
 lib/librte_vhost/vhost-net.h       | 7 ++++++-
 lib/librte_vhost/virtio-net-cdev.c | 7 ++++---
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h
index a36c0e3..a9e20ea 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -85,7 +85,7 @@ struct vhost_driver {
 	vhost_driver_type_t	type;		/**< driver type. */
 	const char		*dev_name;	/**< accessing device name. */
 	union {
-		struct fuse_session *session;	/**< fuse session. */
+		struct fuse_session *cuse_session;	/**< fuse session. */
 	};
 };
 
diff --git a/lib/librte_vhost/vhost-net-cdev.c b/lib/librte_vhost/vhost-net-cdev.c
index 090c6fc..6754548 100644
--- a/lib/librte_vhost/vhost-net-cdev.c
+++ b/lib/librte_vhost/vhost-net-cdev.c
@@ -67,7 +67,7 @@ fuse_req_to_vhost_ctx(fuse_req_t req, struct fuse_file_info *fi)
 	struct fuse_ctx const *const req_ctx = fuse_req_ctx(req);
 
 	ctx.type = VHOST_DRV_CUSE;
-	ctx.pid = req_ctx->pid;
+	ctx.cdev.pid = req_ctx->pid;
 	ctx.fh = fi->fh;
 
 	return ctx;
@@ -345,9 +345,9 @@ vhost_cuse_driver_register(struct vhost_driver *drv)
 
 	ops = get_virtio_net_callbacks(drv->type);
 
-	drv->session = cuse_lowlevel_setup(3, fuse_argv,
+	drv->cuse_session = cuse_lowlevel_setup(3, fuse_argv,
 				&cuse_info, &vhost_net_ops, 0, NULL);
-	if (drv->session == NULL)
+	if (drv->cuse_session == NULL)
 		return -1;
 
 	return 0;
@@ -359,7 +359,7 @@ vhost_cuse_driver_register(struct vhost_driver *drv)
 static int
 vhost_cuse_driver_session_start(struct vhost_driver *drv)
 {
-	fuse_session_loop(drv->session);
+	fuse_session_loop(drv->cuse_session);
 
 	return 0;
 }
diff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h
index 64873d0..ef04832 100644
--- a/lib/librte_vhost/vhost-net.h
+++ b/lib/librte_vhost/vhost-net.h
@@ -72,14 +72,19 @@
 #define PRINT_PACKET(device, addr, size, header) do {} while (0)
 #endif
 
+struct vhost_device_cuse_ctx {
+	pid_t   pid;	/* PID of process calling the IOCTL. */
+};
 
 /*
  * Structure used to identify device context.
  */
 struct vhost_device_ctx {
 	vhost_driver_type_t	type;	/* driver type. */
-	pid_t			pid;	/* PID of process calling the IOCTL. */
 	uint64_t		fh;	/* Populated with fi->fh to track the device index. */
+	union {
+		struct vhost_device_cuse_ctx cdev;
+	};
 };
 
 /*
diff --git a/lib/librte_vhost/virtio-net-cdev.c b/lib/librte_vhost/virtio-net-cdev.c
index 70bc578..ac97551 100644
--- a/lib/librte_vhost/virtio-net-cdev.c
+++ b/lib/librte_vhost/virtio-net-cdev.c
@@ -412,7 +412,8 @@ cuse_set_mem_table(struct vhost_device_ctx ctx, const void *mem_regions_addr,
 		if (mem->regions[regionidx].guest_phys_address == 0x0) {
 			mem->base_address = mem->regions[regionidx].userspace_address;
 			/* Map VM memory file */
-			if (cdev_host_memory_map(dev, mem, ctx.pid, mem->base_address) != 0) {
+			if (cdev_host_memory_map(dev, mem, ctx.cdev.pid,
+						mem->base_address) != 0) {
 				free(mem);
 				return -1;
 			}
@@ -543,7 +544,7 @@ cuse_set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
 	vq->kickfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
 	eventfd_kick.source_fd = vq->kickfd;
 	eventfd_kick.target_fd = file->fd;
-	eventfd_kick.target_pid = ctx.pid;
+	eventfd_kick.target_pid = ctx.cdev.pid;
 
 	if (eventfd_copy(dev, &eventfd_kick))
 		return -1;
@@ -577,7 +578,7 @@ cuse_set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
 	vq->callfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
 	eventfd_call.source_fd = vq->callfd;
 	eventfd_call.target_fd = file->fd;
-	eventfd_call.target_pid = ctx.pid;
+	eventfd_call.target_pid = ctx.cdev.pid;
 
 	if (eventfd_copy(dev, &eventfd_call))
 		return -1;
-- 
1.9.1

  parent reply	other threads:[~2014-11-06 11:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-06 11:14 [dpdk-dev] [RFC PATCH 0/7] lib/librte_vhost: Add vhost-user extension Tetsuya Mukawa
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 1/7] lib/librte_vhost: Fix host_memory_map() to handle various memory regions Tetsuya Mukawa
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 2/7] lib/librte_vhost: Add an abstraction layer for vhost backends Tetsuya Mukawa
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 3/7] lib/librte_vhost: Add an abstraction layer tointerpret messages Tetsuya Mukawa
2014-11-07 20:43   ` Xie, Huawei
2014-11-10  5:12     ` Tetsuya Mukawa
2014-11-10  8:07       ` Xie, Huawei
2014-11-10  8:44         ` Tetsuya Mukawa
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 4/7] lib/librte_vhost: Move vhost vhost-cuse device list and accessor functions Tetsuya Mukawa
2014-11-06 11:14 ` Tetsuya Mukawa [this message]
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 6/7] lib/librte_vhost: Add vhost-cuse/user specific initialization Tetsuya Mukawa
2014-11-06 11:14 ` [dpdk-dev] [RFC PATCH 7/7] lib/librte_vhost: Add vhost-user implementation Tetsuya Mukawa
2014-11-07 21:25   ` Xie, Huawei
2014-11-10  5:11     ` Tetsuya Mukawa
2014-11-10  8:18       ` Xie, Huawei
2014-11-10  8:55         ` Tetsuya Mukawa
2014-11-14  0:07   ` Xie, Huawei
2014-11-14  4:41     ` Tetsuya Mukawa
2014-11-07  3:33 ` [dpdk-dev] [RFC PATCH 0/7] lib/librte_vhost: Add vhost-user extension Xie, Huawei
2014-11-07  5:09   ` Tetsuya Mukawa
     [not found]     ` <C37D651A908B024F974696C65296B57B0F2E3C93@SHSMSX101.ccr.corp.intel.com>
2014-11-07  6:16       ` Tetsuya Mukawa

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=1415272471-3299-6-git-send-email-mukawa@igel.co.jp \
    --to=mukawa@igel.co.jp \
    --cc=dev@dpdk.org \
    --cc=masutani.hitoshi@lab.ntt.co.jp \
    --cc=nakajima.yoshihiro@lab.ntt.co.jp \
    /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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git