From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 97BA2A04F0; Thu, 19 Dec 2019 09:55:30 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 21F831BC25; Thu, 19 Dec 2019 09:55:29 +0100 (CET) Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by dpdk.org (Postfix) with ESMTP id 54DAA1252 for ; Thu, 19 Dec 2019 09:55:27 +0100 (CET) Received: by mail-pj1-f68.google.com with SMTP id r67so2194494pjb.0 for ; Thu, 19 Dec 2019 00:55:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:content-transfer-encoding; bh=HzRPKKSHbyojXPx0bXimng8T5d6fxvPCUJ2mu2W5ea0=; b=MVIOywUQdLAfECwoliBblUow6972PDY85aC6ZkkWH97iWC43KTweRm5YMwYMQwzrU7 HgQEld4RQvSMuwTfK6j5hn63PwyuyTTW/y3nlYgfNoiid3m3spEeroqbbC3roc7MXWaZ zalv/0U4QYWEzo+0Fq2S7795PftKTSZcsj7M5sdtdx1FqzWBhPmpv7CBn6qf9Zb5pWm5 hPWOINRNXCBcqHJ5WXYBXyKFFCP6MKiC5hgMGqLHfYtsb9cmX9wgHuqOqVzx1Pod6iMb CovxzATHKJ6GrcOLmmksUyPl8hU/8JkjiuMo7mmLIMNWzY3epocUr49wIwa+KDqPfU00 hWNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:content-transfer-encoding; bh=HzRPKKSHbyojXPx0bXimng8T5d6fxvPCUJ2mu2W5ea0=; b=hu0NEAEQrrXNqRPs4+usw2s1+VR9JGRzOZ25xUIe5rfkftFjnJ9euJfFeJnvX0luc2 xklPcvG4DJGVo55+sg8QcdVe6lDfRRpkTC5G4ACkcJ3tX0T+fPeMSiPrq8pE6nAFJX12 NgOWFe487N7AQ00f275U2vlhW/FO37BLAfryDlOhyEiXb5IwI/3bTLcmSie8FMrpbnsJ 99F26Rs4nPoDjW37g0Ka1SK7FWK2GhErw+YftxYaV9YL9BMyEvGZJjC8qcmfA7MWebaw OGy5DNJDvqVwkAYqeFFMBVvdLZmKIaMKlQ3XaBgVi+XvdeN5Xn1cV4ARnOqG6yGqCyZn H2iw== MIME-Version: 1.0 X-Gm-Message-State: APjAAAWO954c6ARpefzvO26Z6pM34nWxLoMujRPYNHwytdjiRb9t96vO GP4g+pU2sVmVTLbiiUa/9UUwW09hQDNNMyY7vSL9D6WQF1pa6IYRWDqKctEeKsYx/DKtc7/9 X-Google-Smtp-Source: APXvYqxU2kni2hVt5NAyXgMkPko+m1vtUPECea77LBHseW+o1xwoncE08cblZ7SZk8twHZ9zXYXlZQ== X-Received: by 2002:a17:90a:4498:: with SMTP id t24mr8275927pjg.98.1576745726255; Thu, 19 Dec 2019 00:55:26 -0800 (PST) Received: from 31_216.localdomain (199.168.142.16.16clouds.com. [199.168.142.16]) by smtp.gmail.com with ESMTPSA id t187sm6901714pfd.21.2019.12.19.00.55.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2019 00:55:25 -0800 (PST) From: Li Feng To: Maxime Coquelin , Tiwei Bie , Zhihong Wang Cc: dev@dpdk.org, kyle@smartx.com, Li Feng Date: Thu, 19 Dec 2019 16:54:06 +0800 Message-Id: <20191219085406.16524-1-fengli@smartx.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191202145735.9763-1-fengli@smartx.com> References: <20191202145735.9763-1-fengli@smartx.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH v4] vhost: add config change slave msg support 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" This msg is used to notify qemu that should get the config of backend. For example, vhost-user-blk uses this msg to notify guest os the capacity of backend has changed. The need_reply flag is not mandatory because it will block the sender thread and master process will send get_config message to fetch the configuration, this need an extra thread to process the vhost message. Signed-off-by: Li Feng --- v4: * Fix type and code style. * Add need_reply support. v3: * Move the declare to rte_vhost.h * Add the symbol in rte_vhost_version.map v2: * Fix a little log typo. lib/librte_vhost/rte_vhost.h | 15 +++++++++++++++ lib/librte_vhost/rte_vhost_version.map | 1 + lib/librte_vhost/vhost_user.c | 35 ++++++++++++++++++++++++++++++= ++++ lib/librte_vhost/vhost_user.h | 1 + 4 files changed, 52 insertions(+) diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h index 7b5dc87c2..c7b619ae0 100644 --- a/lib/librte_vhost/rte_vhost.h +++ b/lib/librte_vhost/rte_vhost.h @@ -10,6 +10,7 @@ * Interface to vhost-user */ =20 +#include #include #include =20 @@ -977,6 +978,20 @@ __rte_experimental int rte_vhost_get_vdpa_device_id(int vid); =20 +/** + * Notify the guest that should get virtio configuration space from backen= d. + * + * @param vid + * vhost device ID + * @param need_reply + * wait for the master response the status of this operation + * @return + * 0 on success, < 0 on failure + */ +__rte_experimental +int +rte_vhost_slave_config_change(int vid, bool need_reply); + #ifdef __cplusplus } #endif diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_= vhost_version.map index c512377fe..051d08c12 100644 --- a/lib/librte_vhost/rte_vhost_version.map +++ b/lib/librte_vhost/rte_vhost_version.map @@ -65,4 +65,5 @@ EXPERIMENTAL { rte_vhost_clr_inflight_desc_packed; rte_vhost_get_vhost_ring_inflight; rte_vhost_get_vring_base_from_inflight; + rte_vhost_slave_config_change; }; diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 0cfb8b792..aed1210b1 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2840,6 +2840,41 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64= _t iova, uint8_t perm) return 0; } =20 +static int +vhost_user_slave_config_change(struct virtio_net *dev, bool need_reply) +{ + int ret; + uint32_t flags =3D VHOST_USER_VERSION; + if (need_reply) + flags |=3D VHOST_USER_NEED_REPLY; + struct VhostUserMsg msg =3D { + .request.slave =3D VHOST_USER_SLAVE_CONFIG_CHANGE_MSG, + .flags =3D flags, + .size =3D 0, + }; + + ret =3D send_vhost_slave_message(dev, &msg); + if (ret < 0) { + RTE_LOG(ERR, VHOST_CONFIG, + "Failed to send config change (%d)\n", + ret); + return ret; + } + if (need_reply) + return process_slave_message_reply(dev, &msg); + return 0; +} + +int +rte_vhost_slave_config_change(int vid, bool need_reply) +{ + struct virtio_net *dev; + dev =3D get_device(vid); + if (!dev) + return -ENODEV; + return vhost_user_slave_config_change(dev, need_reply); +} + static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev= , int index, int fd, uint64_t offset, diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h index 6563f7315..86c364a93 100644 --- a/lib/librte_vhost/vhost_user.h +++ b/lib/librte_vhost/vhost_user.h @@ -62,6 +62,7 @@ typedef enum VhostUserRequest { typedef enum VhostUserSlaveRequest { VHOST_USER_SLAVE_NONE =3D 0, VHOST_USER_SLAVE_IOTLB_MSG =3D 1, + VHOST_USER_SLAVE_CONFIG_CHANGE_MSG =3D 2, VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG =3D 3, VHOST_USER_SLAVE_MAX } VhostUserSlaveRequest; --=20 2.11.0 --=20 The SmartX email address is only for business purpose. Any sent message=20 that is not related to the business is not authorized or permitted by=20 SmartX. =E6=9C=AC=E9=82=AE=E7=AE=B1=E4=B8=BA=E5=8C=97=E4=BA=AC=E5=BF=97=E5=87=8C=E6= =B5=B7=E7=BA=B3=E7=A7=91=E6=8A=80=E6=9C=89=E9=99=90=E5=85=AC=E5=8F=B8=EF=BC= =88SmartX=EF=BC=89=E5=B7=A5=E4=BD=9C=E9=82=AE=E7=AE=B1. =E5=A6=82=E6=9C=AC= =E9=82=AE=E7=AE=B1=E5=8F=91=E5=87=BA=E7=9A=84=E9=82=AE=E4=BB=B6=E4=B8=8E=E5= =B7=A5=E4=BD=9C=E6=97=A0=E5=85=B3,=E8=AF=A5=E9=82=AE=E4=BB=B6=E6=9C=AA=E5= =BE=97=E5=88=B0=E6=9C=AC=E5=85=AC=E5=8F=B8=E4=BB=BB=E4=BD=95=E7=9A=84=E6=98= =8E=E7=A4=BA=E6=88=96=E9=BB=98=E7=A4=BA=E7=9A=84=E6=8E=88=E6=9D=83.