From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 4C52D1B901 for ; Tue, 26 Jun 2018 18:19:19 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id u18-v6so2488102wmc.1 for ; Tue, 26 Jun 2018 09:19:19 -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=of+2Ji+OknmxObvfuCoPCYZwA7RB2jj3EFPLZN0ePgY=; b=O3w0fyCJYfuoPcBK+lvvzV5iDsB4B7SgkJcuKmKQ6AD/JZVWznDwHnHt53FzbC4EK+ OCZAOZFiMvx1FFGcJlXCJIsuahosidneRk5bUZskW1aJseg4QoYZ1MtkX4U1K26ll/+i r5XiiOW05xJE9qIC2YgRJ11xC0bApqOwtubUlwSDPeqBofFBWBLRl3HmqnZwI4ZJUkXI oTM4MG3qlcu4f032mgpEH2/kviHswf3Dzu8LEFrim8mdkUQRnW5POO6nUQEkyIUFDQwK RsFSYa/5uXvmXjA+7H2+4Bsikb7m1Y/uriJJFPJ95rIjKXrmykDyul+zvBr9QCrkYrx8 OFKw== 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=of+2Ji+OknmxObvfuCoPCYZwA7RB2jj3EFPLZN0ePgY=; b=Bkkvyvh/8H4jaylGeilOpScxHZQcuR2GA1UpV3Sp47cSbTqsEvAUtIRe5xfq6DWQ4l Yz1/ICqCJ5y0PsCuwqjMe0SiHEretDE6/q7ZYAhC2xj0qqVDTrURMxfGaQbtXutcWxHh MJ+ZQH3klVXeqzG4TtQr+eBRCxl4PMntjkJH2tn2rg6NJEP975Exo/z+oNKGXO0Fg6Xx gI9P2nQwvh/3KFauzL28IkCmKQ3gMuwNyLBJ9Jz+PJ8p92NwJbPHcc6OS9aDiduC8TDs UlEhEmJXQXHsFD51IJIAvRKHuayNKvvmPQfcACuz6ALV+95NgO6x4Fps4kCwi7AAbhYw ja8A== X-Gm-Message-State: APt69E3oVMNxFIIfYEc5tCkjvTmFNEBnsGAa4C3DOJUJPnLJSMVJS211 Uy7ti7vzJeJgUkEsVyhc6A3X0Qme X-Google-Smtp-Source: AAOMgpfYKWRzTpeT7NMn/4Z3Gnx6TneolTs8wr2kGT/q7JjmesKkNG5rhj/PXxdKnIeBXL3j/PDznA== X-Received: by 2002:a1c:6b56:: with SMTP id g83-v6mr2191407wmc.143.1530029958757; Tue, 26 Jun 2018 09:19:18 -0700 (PDT) Received: from [127.0.1.1] ([82.146.27.14]) by smtp.gmail.com with ESMTPSA id n10-v6sm2973138wrs.64.2018.06.26.09.19.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jun 2018 09:19:18 -0700 (PDT) From: Nikolay Nikolaev To: maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com Cc: dev@dpdk.org Date: Tue, 26 Jun 2018 19:19:17 +0300 Message-ID: <153002995700.22089.6499516015793208840.stgit@T460> In-Reply-To: <153002988259.22089.8523468795459281187.stgit@T460> References: <153002988259.22089.8523468795459281187.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 v1 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: Tue, 26 Jun 2018 16:19:19 -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 9b5598871..1bc3d1629 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; } @@ -1022,6 +1030,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; } @@ -1144,6 +1154,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; } @@ -1557,8 +1569,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: @@ -1588,9 +1599,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: @@ -1610,7 +1618,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; @@ -1628,8 +1635,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;