From patchwork Mon Dec 12 17:54:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 17873 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 C6CAF47D1; Mon, 12 Dec 2016 18:54:12 +0100 (CET) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id B17A5370 for ; Mon, 12 Dec 2016 18:54:07 +0100 (CET) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27206C054907; Mon, 12 Dec 2016 17:54:07 +0000 (UTC) Received: from max-t460s.redhat.com (ovpn-116-168.ams2.redhat.com [10.36.116.168]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBCHs4sK028717; Mon, 12 Dec 2016 12:54:05 -0500 From: Maxime Coquelin To: yuanhan.liu@linux.intel.com, dev@dpdk.org Cc: Maxime Coquelin Date: Mon, 12 Dec 2016 18:54:00 +0100 Message-Id: <20161212175400.7978-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 12 Dec 2016 17:54:07 +0000 (UTC) Subject: [dpdk-dev] [PATCH] vhost: Introduce vhost-user's REPLY_ACK feature 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" REPLY_ACK features provide a generic way for QEMU to ensure both completion and success of a request. As described in vhost-user spec in QEMU repository, QEMU sets VHOST_USER_NEED_REPLY flag (bit 3) when expecting a reply_ack from the backend. Backend must reply with 0 for success or non-zero otherwise when flag is set. Currently, only VHOST_USER_SET_MEM_TABLE request implements reply_ack, in order to synchronize mapping updates. This patch enables REPLY_ACK feature generally, but only checks error code for VHOST_USER_SET_MEM_TABLE. Signed-off-by: Maxime Coquelin --- Hi, The intend of this patch is not to fix a known issue, but it is nice to have this feature, and it will be used by upcoming MTU feature if it remains in its current form. Thanks, Maxime lib/librte_vhost/vhost_user.c | 11 ++++++++++- lib/librte_vhost/vhost_user.h | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 6b83c15..9ce80cb 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -903,6 +903,7 @@ send_vhost_message(int sockfd, struct VhostUserMsg *msg) return 0; msg->flags &= ~VHOST_USER_VERSION_MASK; + msg->flags &= ~VHOST_USER_NEED_REPLY; msg->flags |= VHOST_USER_VERSION; msg->flags |= VHOST_USER_REPLY_MASK; @@ -938,6 +939,7 @@ vhost_user_msg_handler(int vid, int fd) return -1; } + ret = 0; RTE_LOG(INFO, VHOST_CONFIG, "read message %s\n", vhost_message_str[msg.request]); switch (msg.request) { @@ -967,7 +969,7 @@ vhost_user_msg_handler(int vid, int fd) break; case VHOST_USER_SET_MEM_TABLE: - vhost_user_set_mem_table(dev, &msg); + ret = vhost_user_set_mem_table(dev, &msg); break; case VHOST_USER_SET_LOG_BASE: @@ -1025,9 +1027,16 @@ vhost_user_msg_handler(int vid, int fd) break; default: + ret = -1; break; } + if (msg.flags & VHOST_USER_NEED_REPLY) { + msg.payload.u64 = !!ret; + msg.size = sizeof(msg.payload.u64); + send_vhost_message(fd, &msg); + } + return 0; } diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h index ba78d32..179e441 100644 --- a/lib/librte_vhost/vhost_user.h +++ b/lib/librte_vhost/vhost_user.h @@ -46,10 +46,12 @@ #define VHOST_USER_PROTOCOL_F_MQ 0 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 #define VHOST_USER_PROTOCOL_F_RARP 2 +#define VHOST_USER_PROTOCOL_F_REPLY_ACK 3 #define VHOST_USER_PROTOCOL_FEATURES ((1ULL << VHOST_USER_PROTOCOL_F_MQ) | \ (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) |\ - (1ULL << VHOST_USER_PROTOCOL_F_RARP)) + (1ULL << VHOST_USER_PROTOCOL_F_RARP) | \ + (1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK)) typedef enum VhostUserRequest { VHOST_USER_NONE = 0, @@ -98,6 +100,7 @@ typedef struct VhostUserMsg { #define VHOST_USER_VERSION_MASK 0x3 #define VHOST_USER_REPLY_MASK (0x1 << 2) +#define VHOST_USER_NEED_REPLY (0x1 << 3) uint32_t flags; uint32_t size; /* the following payload size */ union {