From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E4860A00C3; Fri, 13 May 2022 06:15:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C34B40DDE; Fri, 13 May 2022 06:15:44 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id DBE4B40698 for ; Fri, 13 May 2022 06:15:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652415343; x=1683951343; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=XrHWkrSfea86fHp8OZt4P5NL7ssjnXB4PPsUWXoOpko=; b=hF2S+dTBR4tXJHRJjuwDWYiybehsPEBPmI0jqB3kU+xJGzxasDkmx6y9 /KTEZuvNQ79r6FXNlD+9yfruBPXkQikqJ1oVAoj0/3YxZf9+mFDp1si5E V+R/1OiFG/VQMQTHhDNm6hjrkJ2E0LX70wuLtw1ogLGQAVST2Vx/YfFOa h77dt4KazSjm0u5r8zbD2hDrygyQUZCrLvj1DqJ/X/tREcAtg9+OMzis4 0bwNEbjoWlwJnam4VKx8TSmopAbaRyqRbe16djGqGdY9WTqlAG+TEXjxj 1i9qRE3bxMSP+nt+8o2Uzqi8k7CRzLrrOBxQ+79n70oW/415fgAynwFfl A==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="333243752" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="333243752" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 21:15:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="698336858" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga004.jf.intel.com with ESMTP; 12 May 2022 21:15:37 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 12 May 2022 21:15:37 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 12 May 2022 21:15:36 -0700 Received: from fmsmsx612.amr.corp.intel.com ([10.18.126.92]) by fmsmsx612.amr.corp.intel.com ([10.18.126.92]) with mapi id 15.01.2308.027; Thu, 12 May 2022 21:15:36 -0700 From: "Pei, Andy" To: "Xia, Chenbo" , "dev@dpdk.org" CC: "maxime.coquelin@redhat.com" , "Cao, Gang" , "Liu, Changpeng" Subject: RE: [PATCH v7 07/18] vhost: add API to get vDPA device type Thread-Topic: [PATCH v7 07/18] vhost: add API to get vDPA device type Thread-Index: AQHYWheEEUvX4oem80u/j3IFPr7F0q0bTbrAgAD90TA= Date: Fri, 13 May 2022 04:15:36 +0000 Message-ID: References: <1643093258-47258-2-git-send-email-andy.pei@intel.com> <1651048206-282372-1-git-send-email-andy.pei@intel.com> <1651048206-282372-8-git-send-email-andy.pei@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.401.20 dlp-reaction: no-action x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Chenbo, Thanks for your reply. My reply is inline. > -----Original Message----- > From: Xia, Chenbo > Sent: Thursday, May 12, 2022 9:14 PM > To: Pei, Andy ; dev@dpdk.org > Cc: maxime.coquelin@redhat.com; Cao, Gang ; Liu, > Changpeng > Subject: RE: [PATCH v7 07/18] vhost: add API to get vDPA device type >=20 > > -----Original Message----- > > From: Pei, Andy > > Sent: Wednesday, April 27, 2022 4:30 PM > > To: dev@dpdk.org > > Cc: Xia, Chenbo ; maxime.coquelin@redhat.com; > > Cao, Gang ; Liu, Changpeng > > > > Subject: [PATCH v7 07/18] vhost: add API to get vDPA device type > > > > Vhost backend of different devices have different features. > > Add a API to get vDPA device type, net device or blk device currently, > > so users can set different features for different kinds of devices. > > > > Signed-off-by: Andy Pei > > --- > > lib/vhost/rte_vhost.h | 17 +++++++++++++++++ > > lib/vhost/socket.c | 39 +++++++++++++++++++++++++++++++++++++++ > > lib/vhost/vdpa_driver.h | 3 +++ > > lib/vhost/version.map | 2 ++ > > 4 files changed, 61 insertions(+) > > > > diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h index > > c733f85..c977a24 100644 > > --- a/lib/vhost/rte_vhost.h > > +++ b/lib/vhost/rte_vhost.h > > @@ -117,6 +117,9 @@ > > > > #define RTE_MAX_VHOST_DEVICE 1024 > > > > +#define VDPA_DEVICE_TYPE_NET 0 > > +#define VDPA_DEVICE_TYPE_BLK 1 > > + > > struct rte_vdpa_device; > > > > /** > > @@ -486,6 +489,20 @@ struct rte_vdpa_device * > > rte_vhost_driver_get_vdpa_device(const char *path); > > > > /** > > + * Get the device type of the vdpa device. > > + * > > + * @param path > > + * The vhost-user socket file path > > + * @param type > > + * the device type of the vdpa device > > + * @return > > + * 0 on success, -1 on failure > > + */ > > +__rte_experimental > > +int > > +rte_vhost_driver_get_vdpa_dev_type(const char *path, uint32_t *type); > > + > > +/** > > * Set the feature bits the vhost-user driver supports. > > * > > * @param path > > diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c index > > b304339..7da90e8 100644 > > --- a/lib/vhost/socket.c > > +++ b/lib/vhost/socket.c > > @@ -619,6 +619,45 @@ struct rte_vdpa_device * } > > > > int > > +rte_vhost_driver_get_vdpa_dev_type(const char *path, uint32_t *type) > > +{ > > + struct vhost_user_socket *vsocket; > > + struct rte_vdpa_device *vdpa_dev; > > + uint32_t vdpa_type =3D 0; > > + int ret =3D 0; > > + > > + pthread_mutex_lock(&vhost_user.mutex); > > + vsocket =3D find_vhost_user_socket(path); > > + if (!vsocket) { > > + VHOST_LOG_CONFIG(ERR, > > + "(%s) socket file is not registered yet.\n", > > + path); > > + ret =3D -1; > > + goto unlock_exit; > > + } > > + > > + vdpa_dev =3D vsocket->vdpa_dev; > > + if (!vdpa_dev) { > > + ret =3D -1; > > + goto unlock_exit; > > + } > > + > > + if (vdpa_dev->ops->get_dev_type(vdpa_dev, &vdpa_type) < 0) { > > + VHOST_LOG_CONFIG(ERR, > > + "(%s) failed to get vdpa dev type for socket file.\n", > > + path); > > + ret =3D -1; > > + goto unlock_exit; > > + } >=20 > If vendor's vdpa driver does not implement this callback, should return t= ype > NET. > Another way to do may be make every vdpa driver implement the callback, > but since other vendors only have one type. I prefer the first way. >=20 Yes, I agree with you. I will send a new version to fix this. > > + > > + *type =3D vdpa_type; > > + > > +unlock_exit: > > + pthread_mutex_unlock(&vhost_user.mutex); > > + return ret; > > +} > > + > > +int > > rte_vhost_driver_disable_features(const char *path, uint64_t > > features) { > > struct vhost_user_socket *vsocket; > > diff --git a/lib/vhost/vdpa_driver.h b/lib/vhost/vdpa_driver.h index > > e59a834..9cbd7cd 100644 > > --- a/lib/vhost/vdpa_driver.h > > +++ b/lib/vhost/vdpa_driver.h > > @@ -78,6 +78,9 @@ struct rte_vdpa_dev_ops { > > /** Set the device configuration space */ > > int (*set_config)(int vid, uint8_t *config, uint32_t offset, > > uint32_t size, uint32_t flags); > > + > > + /** get device type: net device, blk device... */ > > + int (*get_dev_type)(struct rte_vdpa_device *dev, uint32_t *type); > > }; > > > > /** > > diff --git a/lib/vhost/version.map b/lib/vhost/version.map index > > 0a66c58..fe4e8de 100644 > > --- a/lib/vhost/version.map > > +++ b/lib/vhost/version.map > > @@ -87,6 +87,8 @@ EXPERIMENTAL { > > > > # added in 22.03 > > rte_vhost_async_dma_configure; > > + > > + rte_vhost_driver_get_vdpa_dev_type; >=20 > Missed '# added in 22.07' tag, but when you do v8, this may not be a > problem as other patches may add this tag with new API introduced. >=20 > And introducing new API will need update of release note. > Please refer to http://git.dpdk.org/next/dpdk-next- > virtio/commit/?id=3D868883e899af386abcc298ea80ec7f6a18d8a8e7 > as an example. >=20 > Thanks, > Chenbo >=20 Sure. I will refer to this. > > }; > > > > INTERNAL { > > -- > > 1.8.3.1 >=20