From patchwork Thu May 5 08:59:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianfeng Tan X-Patchwork-Id: 12395 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 8ED875684; Thu, 5 May 2016 10:59:43 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 302062C69 for ; Thu, 5 May 2016 10:59:42 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 05 May 2016 01:59:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,581,1455004800"; d="scan'208";a="959365808" Received: from dpdk06.sh.intel.com ([10.239.128.225]) by fmsmga001.fm.intel.com with ESMTP; 05 May 2016 01:59:40 -0700 From: Jianfeng Tan To: dev@dpdk.org Cc: Jianfeng Tan , yuanhan.liu@linux.intel.com, nakajima.yoshihiro@lab.ntt.co.jp, nhorman@tuxdriver.com Date: Thu, 5 May 2016 08:59:39 +0000 Message-Id: <1462438781-139674-2-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1462438781-139674-1-git-send-email-jianfeng.tan@intel.com> References: <1462438781-139674-1-git-send-email-jianfeng.tan@intel.com> Subject: [dpdk-dev] [PATCH 1/3] virtio-user: add mq in vhost user adapter 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch mainly adds method in vhost user adapter to communicate enable/disable queues messages with vhost user backend. Signed-off-by: Jianfeng Tan --- drivers/net/virtio/virtio_user/vhost.h | 4 ++++ drivers/net/virtio/virtio_user/vhost_user.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/net/virtio/virtio_user/vhost.h b/drivers/net/virtio/virtio_user/vhost.h index 5cd3543..fe236a7 100644 --- a/drivers/net/virtio/virtio_user/vhost.h +++ b/drivers/net/virtio/virtio_user/vhost.h @@ -209,8 +209,12 @@ enum { #define VHOST_KERNEL 0 #define VHOST_USER 1 +#define VHOST_USER_F_PROTOCOL_FEATURES 30 +#define VHOST_USER_MQ (1ULL << VHOST_USER_F_PROTOCOL_FEATURES) + int vhost_user_sock(int vhostfd, unsigned long int req, void *arg); int vhost_user_setup(const char *path); +int vhost_user_enable_queue_pair(int vhostfd, unsigned pair_idx, int enable); int vhost_kernel_ioctl(int vhostfd, unsigned long int req, void *arg); int vhost_kernel_setup(const char *path, const char *ifname, int *p_tapfd); diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index 6fd648c..d8f7996 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -263,6 +263,7 @@ vhost_user_sock(int vhostfd, unsigned long int req, void *arg) case VHOST_USER_SET_VRING_NUM: case VHOST_USER_SET_VRING_BASE: + case VHOST_USER_SET_VRING_ENABLE: memcpy(&msg.payload.state, arg, sizeof(msg.payload.state)); msg.size = sizeof(m.payload.state); break; @@ -373,3 +374,23 @@ vhost_user_setup(const char *path) return fd; } + +int +vhost_user_enable_queue_pair(int vhostfd, unsigned pair_idx, int enable) +{ + int i; + + for (i = 0; i < 2; ++i) { + struct vhost_vring_state state = { + .index = pair_idx * 2 + i, + .num = enable, + }; + + if (vhost_user_sock(vhostfd, + VHOST_USER_SET_VRING_ENABLE, &state)) + return -1; + } + + return 0; + +}