From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by dpdk.org (Postfix) with ESMTP id 46BFC7E80 for ; Thu, 6 Nov 2014 12:05:39 +0100 (CET) Received: by mail-pd0-f178.google.com with SMTP id fp1so972691pdb.9 for ; Thu, 06 Nov 2014 03:15:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UB47Od72zXgoQUno0orsfcoz4N0XTAaMKAxLXVtHgp4=; b=Cq7ImXcMT6AG6aHnmt8ApDQqaFS4xjD7uinw8runM25SbE5pP0WeHAVBPMXn1NBaJs Ue8QOQHzUEYZnKjAGoz9czGDbKVY9Tukjl1ebdvm70wkX7C3POrdMmKSE9JOgO2+Q322 jR6hQuz8daRXo7FzCWv7YPzjrtaIAn2al4yycLyCCtZrWkczNfr+onEDFFjK9bk3pgSd e9fcl2V4k86GVL1iHj7ucRdL7QGosP9gqHCQPGst53uY65p8m6l27a1qBE0xaPJS1Onc j3oxWh7GFWcjXx78s008J/a0v5Cga4jsXZwkg2EnqHtIBSSNjg0p0e979leUS1qsGamk rjYw== X-Gm-Message-State: ALoCoQn/kcvJomY5Jgu168AtF/ZsrkKDwbnBqWNMabkaHRMsgp1/ydpEDXdnPZiI5czXaJjag7Bi X-Received: by 10.68.213.138 with SMTP id ns10mr3754095pbc.50.1415272505917; Thu, 06 Nov 2014 03:15:05 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id jc3sm5652315pbb.49.2014.11.06.03.15.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Nov 2014 03:15:05 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Thu, 6 Nov 2014 20:14:29 +0900 Message-Id: <1415272471-3299-6-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415272471-3299-1-git-send-email-mukawa@igel.co.jp> References: <1415272471-3299-1-git-send-email-mukawa@igel.co.jp> 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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2014 11:05:39 -0000 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 --- 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