From patchwork Tue Jun 26 16:19:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Nikolaev X-Patchwork-Id: 140006 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5441295lji; Tue, 26 Jun 2018 09:19:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfThfcF3W9GBDdEbHgzU8vndVzxTcnx2UTCZrrQXesC820FJl5mlvUz5pa2ntUIDB4xANk8 X-Received: by 2002:a1c:8cc8:: with SMTP id o191-v6mr2193081wmd.75.1530029963369; Tue, 26 Jun 2018 09:19:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530029963; cv=none; d=google.com; s=arc-20160816; b=TTK2QwGTzsfyJ18UQweu9Y2dh6zSBRCyl6ZfxMs9VcGR76UaWtNzovG4ID0BlqJLJ4 SuKvTno5S24PN2JGORVL+pm67qWNYxjZY5qN+o6hvKHaUGzOG3S5Ejc0dnThfir47cPy NAIhH95jRszB2zMNQXTsmqV6vDuEyTyMC4hGfW8/F+3mQoL9ca/ebZNSGMMU+hE4GiWy /197YbFxb6wObd7wieGmGUR8eb2JS4yBObRLb7DCIzzx/GVTwb5JI4LwNtYDh5YVNQ5K Q3Nwwgqlcnu7k9zEweO3eoRfoGKgYE9Tc0i0n03/E+/bHUp9zyldP1IuOPO8wPehuYCt gQfw== 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=of+2Ji+OknmxObvfuCoPCYZwA7RB2jj3EFPLZN0ePgY=; b=JOHGQnzGsXN+ESCh9orlfpgQNeij+/iDda1AEWhldYtUsH79nlr1b8GRzmkvraicpa VookzELwBOhcqoAdsaDczrRXltWbIqviiDz0Yc4p8rvN+0CJSF1rkWbhqVPZpALch2mE eup84r+50PUQ0TL7fnvfe0n8tzaV2ByJjXANYGJ4b9DV0KQruI3NI2UvkDTTYL00qyoH O3yTo8/S7xCXyT0I74JNLrzSw9pQsieEQvoagFgeljMt7k4TU/k2p82cpJPTZqk3yOzh oIJRdf0KsGqxf1syiIDQTqA74FB8wsI8yT2lCBiAUrOJQAIDO9Ks6rUjrWfho7C8hNIQ 00Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=O3w0fyCJ; 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 k82-v6si1335425wmh.214.2018.06.26.09.19.23; Tue, 26 Jun 2018 09:19:23 -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=O3w0fyCJ; 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 0D5071BB37; Tue, 26 Jun 2018 18:19:21 +0200 (CEST) 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-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 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: , 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(-) 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;