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 6C3C1A04B3; Mon, 16 Dec 2019 06:05:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7EB811C06C; Mon, 16 Dec 2019 06:05:45 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 97EA41C067 for ; Mon, 16 Dec 2019 06:05:43 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Dec 2019 21:05:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,320,1571727600"; d="scan'208";a="239933492" Received: from dpdk-virtio-tbie-2.sh.intel.com (HELO ___) ([10.67.104.74]) by fmsmga004.fm.intel.com with ESMTP; 15 Dec 2019 21:05:41 -0800 Date: Mon, 16 Dec 2019 13:06:00 +0800 From: Tiwei Bie To: Li Feng Cc: Maxime Coquelin , Zhihong Wang , dev@dpdk.org Message-ID: <20191216050559.GA129906@___> References: <20191202145735.9763-1-fengli@smartx.com> <20191205053833.29068-1-fengli@smartx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191205053833.29068-1-fengli@smartx.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v3] 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" On Thu, Dec 05, 2019 at 01:38:33PM +0800, Li Feng wrote: > 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 > compacity of backend has changed. capacity? > > Signed-off-by: Li Feng > --- > 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 | 12 ++++++++++++ > lib/librte_vhost/rte_vhost_version.map | 1 + > lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++ > lib/librte_vhost/vhost_user.h | 1 + > 4 files changed, 45 insertions(+) > > diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h > index 7b5dc87c2..fc28da264 100644 > --- a/lib/librte_vhost/rte_vhost.h > +++ b/lib/librte_vhost/rte_vhost.h > @@ -977,6 +977,18 @@ __rte_experimental > int > rte_vhost_get_vdpa_device_id(int vid); > > +/** > + * Notify the guest that should get config from backend. > + * > + * @param vid > + * vhost device ID > + * @return > + * 0 on success, < 0 on failure > + */ > +__rte_experimental > +int > +rte_vhost_user_slave_config_change(int vid); Normally the prefix in vhost API is rte_vhost_ not rte_vhost_user_ > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map > index c512377fe..acf013d6d 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_user_slave_config_change; > }; > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c > index 0cfb8b792..10f2e47d5 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm) > return 0; > } > > +static int > +vhost_user_slave_config_change(struct virtio_net *dev) > +{ > + int ret; > + struct VhostUserMsg msg = { > + .request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG, > + .flags = VHOST_USER_VERSION, Will it be better to also set VHOST_USER_NEED_REPLY? > + .size = 0, > + }; > + > + ret = send_vhost_message(dev->slave_req_fd, &msg); > + if (ret < 0) { > + RTE_LOG(ERR, VHOST_CONFIG, > + "Failed to send config change (%d)\n", > + ret); Looks better to indent the code by 3 tabs. > + return ret; > + } > + > + return 0; > +} > + > +int > +rte_vhost_user_slave_config_change(int vid) > +{ > + struct virtio_net *dev; > + dev = get_device(vid); > + if (!dev) > + return -ENODEV; > + return vhost_user_slave_config_change(dev); > +} I'm wondering will it be better to provide a generic API to allow external backends to send any slave messages? > + > 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 = 0, > VHOST_USER_SLAVE_IOTLB_MSG = 1, > + VHOST_USER_SLAVE_CONFIG_CHANGE_MSG = 2, > VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG = 3, > VHOST_USER_SLAVE_MAX > } VhostUserSlaveRequest; > -- > 2.11.0 > > > -- > The SmartX email address is only for business purpose. Any sent message > that is not related to the business is not authorized or permitted by > SmartX. > 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权. > >