From patchwork Thu Jul 19 19:13:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Nikolaev X-Patchwork-Id: 142378 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2093555ljj; Thu, 19 Jul 2018 12:13:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfob2PgnC9/VNTpbZALKCj9V0UgaVqdUyJKjR/bWMS0oalKu/oKyTT3i9RE2n7euFwrYNJX X-Received: by 2002:a1c:30d2:: with SMTP id w201-v6mr4823768wmw.47.1532027623517; Thu, 19 Jul 2018 12:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532027623; cv=none; d=google.com; s=arc-20160816; b=h3O07Uwde/trjLiBfJ24psvHerKu+DCTfGvN6BVWjfk4VpJQzaq+QSZ0R8snnzzRhv wKlouTd0oh/CtzRYhKj8sAsDOf9/9Rfa2SMFjFbYGmdVz714BFkevqHwbfy1AiEXjYeq rjIiNWp5m5jxIcDKepWFoQRzpkCyWd+O0+kSJnBFkP9DUPJTL+rneFkr8fCdDdrBE6qF HP8WKGlUruCjT0IvQ/gyL/FjgJiPgY45PXCjCmXmfx6b9oV9p860W5Pdm7RHixlWXqDM R4P3dj2XuMiEweAVBEzEX+kXh7I4sIz0XyLjszDeIUR3do3jt6GHM7dRxC9xgLJ9A8ND g+YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:dkim-signature :arc-authentication-results; bh=6cg4XzjXRxCK8ANybJSK+tcCbAgT3r6KNJRCv3E9sqQ=; b=PVG8jNCr0zVSEMAoVqr6N19vrcCxgkK6DzHAR+D9bje4UsH/v+hPWOUg1PB6ge+EXi 7xlANhF61jJ3eO6/vQV3gzx+HF5m/TOqsw2P4isF2PZXn/6Kk8fWrQOx6ICq3vFGX8V7 vOnY31nlNak11cllAcx0Ttq+gkKdsUxL9xJJfUZLGe30+MINo8C9H9f80u+szekdw7xL TFGKc/R0nJdtoieuhAXh+yvTtROn2cT/mid5u5fSL6NpmvBE0OQq0tlujMt2rxLNLUx8 sGuy8zF07Pkcs6rIGY6ZZ78WKl7ZYAdSkVWsxgxAuLGc3cAd+OM9cO24n/M82hgkRUQ+ qM7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Kpl+xXeb; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id c123-v6si181209wmh.108.2018.07.19.12.13.43; Thu, 19 Jul 2018 12:13:43 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Kpl+xXeb; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 27C445B38; Thu, 19 Jul 2018 21:13:37 +0200 (CEST) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 707B65B3C for ; Thu, 19 Jul 2018 21:13:36 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id z6-v6so2491249wma.0 for ; Thu, 19 Jul 2018 12:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=6cg4XzjXRxCK8ANybJSK+tcCbAgT3r6KNJRCv3E9sqQ=; b=Kpl+xXebXMSkf9CNMqS7m0nSGO6l1ZWvqYcJO4PWp8v3mWqKZgPqOlzZxMbS5XA1aw YImmE8Utm7fDyzV3C/qhiGIsC5azrJHXRv5uUnDa2QGZ1lm6zn9/aQj1r6VRduSZshcZ /drXzCtmlO9quKYnHt4OcVJtNK+u0gbVC0HDhhROXwHj8P8eK/nGnolFsBySWlZCa+Y6 5TnY49cyZUKkbLA0qpwgVH7SeePKvMpKJmuUr3bCC8kqrMS7F46iCD6vsXkPi8fsm7d0 1bo5kMzraEMYYZUhMCOALMjQfp/mXosLZeD8iAdFsCACP0xLzOaocuJcA8QGq6UA4swO bhkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=6cg4XzjXRxCK8ANybJSK+tcCbAgT3r6KNJRCv3E9sqQ=; b=BYCq8V6H5MbLX6+GnLeUCVjruCTbz/rFwzJH6onMZEX+rGwjgeeo+8Pn07S2sd26mI V10P02De2h3XZoZBP+VQgDLSO/fgKhDKCKtyoeE8ZaorORwkLZzN74cJC0nDzfsA/jCa b24zAtR0t72q/enJFcCYyZYcWC5oyOLEHGQj1NNs2S4mUjreE3V061OjVSeGNT3hTCtU a9vi2DXp2A2AqD+3hhe6NV/IKa2NEMzOldK61WL/D2+ja38NOcv9U/5kMuYY4sUMSs8P HB2W1FAaS7zRs4i6q3iETpIKZ9UzeJ/6GeEShqfghonPaOWiHsV95ylmqSWZ3TylI15G BhTg== X-Gm-Message-State: AOUpUlEwOzALErct5NC7PBKUpxJvw/fM3X2AIyv22bekd8VuUHri9gOl 3+YvOSe7Gsawkw7oljUmfmZpnfVyzhc= X-Received: by 2002:a1c:64d5:: with SMTP id y204-v6mr4900024wmb.14.1532027615896; Thu, 19 Jul 2018 12:13:35 -0700 (PDT) Received: from [127.0.1.1] ([82.146.27.14]) by smtp.gmail.com with ESMTPSA id m17-v6sm11377480wrg.65.2018.07.19.12.13.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 12:13:35 -0700 (PDT) From: Nikolay Nikolaev To: maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com Cc: dev@dpdk.org Date: Thu, 19 Jul 2018 22:13:34 +0300 Message-ID: <153202761415.21481.4698894052167645234.stgit@T460> In-Reply-To: <153202755842.21481.1772155561595981441.stgit@T460> References: <153202755842.21481.1772155561595981441.stgit@T460> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 2/5] vhost: make message handling functions prepare the reply 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" As VhostUserMsg structure is resued to generate the reply, move the relevant fields update into the respective message handling functions. Signed-off-by: Nikolay Nikolaev --- lib/librte_vhost/vhost_user.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) Reviewed-by: Maxime Coquelin diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index d51616695..e97b2d563 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -146,11 +146,15 @@ vhost_user_reset_owner(struct virtio_net *dev) * The features that we support are requested. */ static uint64_t -vhost_user_get_features(struct virtio_net *dev) +vhost_user_get_features(struct virtio_net *dev, VhostUserMsg *msg) { uint64_t features = 0; rte_vhost_driver_get_features(dev->ifname, &features); + + msg->payload.u64 = features; + msg->size = sizeof(msg->payload.u64); + return features; } @@ -158,11 +162,15 @@ vhost_user_get_features(struct virtio_net *dev) * The queue number that we support are requested. */ static uint32_t -vhost_user_get_queue_num(struct virtio_net *dev) +vhost_user_get_queue_num(struct virtio_net *dev, VhostUserMsg *msg) { uint32_t queue_num = 0; rte_vhost_driver_get_queue_num(dev->ifname, &queue_num); + + msg->payload.u64 = (uint64_t)queue_num; + msg->size = sizeof(msg->payload.u64); + return queue_num; } @@ -1109,6 +1117,8 @@ vhost_user_get_vring_base(struct virtio_net *dev, rte_free(vq->batch_copy_elems); vq->batch_copy_elems = NULL; + msg->size = sizeof(msg->payload.state); + return 0; } @@ -1231,6 +1241,8 @@ vhost_user_set_log_base(struct virtio_net *dev, VhostUserMsg *msg) dev->log_base = dev->log_addr + off; dev->log_size = size; + msg->size = sizeof(msg->payload.u64); + return 0; } @@ -1644,8 +1656,7 @@ vhost_user_msg_handler(int vid, int fd) switch (msg.request.master) { case VHOST_USER_GET_FEATURES: - msg.payload.u64 = vhost_user_get_features(dev); - msg.size = sizeof(msg.payload.u64); + vhost_user_get_features(dev, &msg); send_vhost_reply(fd, &msg); break; case VHOST_USER_SET_FEATURES: @@ -1675,9 +1686,6 @@ vhost_user_msg_handler(int vid, int fd) case VHOST_USER_SET_LOG_BASE: vhost_user_set_log_base(dev, &msg); - - /* it needs a reply */ - msg.size = sizeof(msg.payload.u64); send_vhost_reply(fd, &msg); break; case VHOST_USER_SET_LOG_FD: @@ -1697,7 +1705,6 @@ vhost_user_msg_handler(int vid, int fd) case VHOST_USER_GET_VRING_BASE: vhost_user_get_vring_base(dev, &msg); - msg.size = sizeof(msg.payload.state); send_vhost_reply(fd, &msg); break; @@ -1715,8 +1722,7 @@ vhost_user_msg_handler(int vid, int fd) break; case VHOST_USER_GET_QUEUE_NUM: - msg.payload.u64 = (uint64_t)vhost_user_get_queue_num(dev); - msg.size = sizeof(msg.payload.u64); + vhost_user_get_queue_num(dev, &msg); send_vhost_reply(fd, &msg); break;