From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AAOMgpe3AnBtdoX6LjJgdqQbffSUUQgKAdIlFAK5DdbgktL7DHCvSzTXklEkeiwbouYn0Yxwrllxdg== 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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: , X-List-Received-Date: Thu, 19 Jul 2018 19:13:36 -0000 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(-) 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;