From patchwork Fri Aug 25 09:40:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianfeng Tan X-Patchwork-Id: 27947 X-Patchwork-Delegate: yuanhan.liu@linux.intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 1584A8CF4; Fri, 25 Aug 2017 11:39:39 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id BA1BE7D8F for ; Fri, 25 Aug 2017 11:39:34 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Aug 2017 02:39:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,424,1498546800"; d="scan'208";a="144456060" Received: from dpdk06.sh.intel.com ([10.67.111.82]) by fmsmga006.fm.intel.com with ESMTP; 25 Aug 2017 02:39:32 -0700 From: Jianfeng Tan To: dev@dpdk.org Cc: bruce.richardson@intel.com, konstantin.ananyev@intel.com, pablo.de.lara.guarch@intel.com, thomas@monjalon.net, yliu@fridaylinux.org, maxime.coquelin@redhat.com, mtetsuyah@gmail.com, ferruh.yigit@intel.com, Jianfeng Tan Date: Fri, 25 Aug 2017 09:40:50 +0000 Message-Id: <1503654052-84730-11-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503654052-84730-1-git-send-email-jianfeng.tan@intel.com> References: <1503654052-84730-1-git-send-email-jianfeng.tan@intel.com> Subject: [dpdk-dev] [PATCH 10/12] vhost: support to kick in secondary process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" To support kick in secondary process, we propose callfd_pri and kickfd_pri to store the value in primary process; and by a new API, rte_vhost_set_vring_effective_fd(), we can set effective callfd and kickfd which can be used by secondary process. Note in this case, either primary process or the secondary process can kick the frontend; that is, they cannot kick a vring at the same time. Signed-off-by: Jianfeng Tan --- lib/librte_vhost/rte_vhost.h | 3 +++ lib/librte_vhost/vhost.c | 27 +++++++++++++++++++++++++-- lib/librte_vhost/vhost.h | 3 +++ lib/librte_vhost/vhost_user.c | 4 ++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h index 8c974eb..c82f249 100644 --- a/lib/librte_vhost/rte_vhost.h +++ b/lib/librte_vhost/rte_vhost.h @@ -432,6 +432,9 @@ int rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem); int rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx, struct rte_vhost_vring *vring); +int rte_vhost_set_vring_effective_fd(int vid, uint16_t vring_idx, + int callfd, int kickfd); + /** * Get vhost RX queue avail count. * diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 2b687ea..d2e4500 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -435,13 +435,36 @@ rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx, vring->used = vq->used; vring->log_guest_addr = vq->log_guest_addr; - vring->callfd = vq->callfd; - vring->kickfd = vq->kickfd; + vring->callfd = vq->callfd_pri; + vring->kickfd = vq->kickfd_pri; vring->size = vq->size; return 0; } +int +rte_vhost_set_vring_effective_fd(int vid, uint16_t vring_idx, + int callfd, int kickfd) +{ + struct virtio_net *dev; + struct vhost_virtqueue *vq; + + dev = get_device(vid); + if (!dev) + return -1; + + if (vring_idx >= VHOST_MAX_VRING) + return -1; + + vq = dev->virtqueue[vring_idx]; + if (!vq) + return -1; + + vq->callfd = callfd; + vq->kickfd = kickfd; + + return 0; +} uint16_t rte_vhost_avail_entries(int vid, uint16_t queue_id) { diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index bc1f31e..be57c52 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -98,9 +98,12 @@ struct vhost_virtqueue { /* Backend value to determine if device should started/stopped */ int backend; /* Used to notify the guest (trigger interrupt) */ + int callfd_pri; int callfd; /* Currently unused as polling mode is enabled */ + int kickfd_pri; int kickfd; + int enabled; /* Physical address of used ring, for logging */ diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index ad2e8d3..72f2b40 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -664,7 +664,7 @@ vhost_user_set_vring_call(struct virtio_net *dev, struct VhostUserMsg *pmsg) if (vq->callfd >= 0) close(vq->callfd); - vq->callfd = file.fd; + vq->callfd_pri = vq->callfd = file.fd; } static void @@ -684,7 +684,7 @@ vhost_user_set_vring_kick(struct virtio_net *dev, struct VhostUserMsg *pmsg) vq = dev->virtqueue[file.index]; if (vq->kickfd >= 0) close(vq->kickfd); - vq->kickfd = file.fd; + vq->kickfd_pri = vq->kickfd = file.fd; } static void