From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 28421C37C for ; Wed, 15 Jun 2016 11:07:30 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 15 Jun 2016 02:07:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,475,1459839600"; d="scan'208";a="719348150" Received: from dpdk06.sh.intel.com ([10.239.128.225]) by FMSMGA003.fm.intel.com with ESMTP; 15 Jun 2016 02:07:29 -0700 From: Jianfeng Tan To: dev@dpdk.org Cc: Jianfeng Tan , rich.lane@bigswitch.com, yuanhan.liu@linux.intel.com, mst@redhat.com, nakajima.yoshihiro@lab.ntt.co.jp, p.fedin@samsung.com, ann.zhuangyanying@huawei.com, mukawa@igel.co.jp, nhorman@tuxdriver.com Date: Wed, 15 Jun 2016 09:07:15 +0000 Message-Id: <1465981637-38015-2-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1465981637-38015-1-git-send-email-jianfeng.tan@intel.com> References: <1462438781-139674-1-git-send-email-jianfeng.tan@intel.com> <1465981637-38015-1-git-send-email-jianfeng.tan@intel.com> Subject: [dpdk-dev] [PATCH v3 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: , X-List-Received-Date: Wed, 15 Jun 2016 09:07:30 -0000 This patch mainly adds method in vhost user adapter to communicate enable/disable queues messages with vhost user backend, aka, VHOST_USER_SET_VRING_ENABLE. Signed-off-by: Jianfeng Tan --- drivers/net/virtio/virtio_user/vhost.h | 5 +++++ drivers/net/virtio/virtio_user/vhost_user.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/net/virtio/virtio_user/vhost.h b/drivers/net/virtio/virtio_user/vhost.h index 4e04ede..8d1e505 100644 --- a/drivers/net/virtio/virtio_user/vhost.h +++ b/drivers/net/virtio/virtio_user/vhost.h @@ -136,6 +136,11 @@ struct vhost_user_msg { /* The version of the protocol we support */ #define VHOST_USER_VERSION 0x1 +#define VHOST_USER_F_PROTOCOL_FEATURES 30 +#define VHOST_USER_MQ (1ULL << VHOST_USER_F_PROTOCOL_FEATURES) + int vhost_user_sock(int vhostfd, uint64_t req, void *arg); int vhost_user_setup(const char *path); +int vhost_user_enable_queue_pair(int vhostfd, unsigned pair_idx, int enable); + #endif diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index 47bbf74..98d98b6 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -234,6 +234,7 @@ static const char * const vhost_msg_strings[] = { [VHOST_USER_SET_VRING_ADDR] = "VHOST_USER_SET_VRING_ADDR", [VHOST_USER_SET_VRING_KICK] = "VHOST_USER_SET_VRING_KICK", [VHOST_USER_SET_MEM_TABLE] = "VHOST_USER_SET_MEM_TABLE", + [VHOST_USER_SET_VRING_ENABLE] = "VHOST_USER_SET_VRING_ENABLE", NULL, }; @@ -286,6 +287,7 @@ vhost_user_sock(int vhostfd, uint64_t 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; @@ -402,3 +404,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; + +} -- 2.1.4