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 805EBA04FD; Mon, 23 May 2022 09:26:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2A3804014F; Mon, 23 May 2022 09:26:25 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id CF74E40041 for ; Mon, 23 May 2022 09:26:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653290784; x=1684826784; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=lUIh/nS56yG43mmxIhqMb1OCClz6iebNInhtxkoDDZs=; b=dikmPo2XNxYvS2rQugZuuL9FNmyotRqDACIuSAEBeX2py9h4ggQYamlp ODzuuxchNTWeFgATmWseThiiWCP+70jwCsiYWG7BvW45AdJHEzIbw7txw M9/IKZQbSkodmhrnznRUqUQKj/Rp5YHJmzZS8I6nyPdws2gFPdUqTgvNp Q+D8KLcPX7HYy2RMTXYvR3H0dxZOmHcuwCdXVN8YROG+yeO0DSqGefnQK 2iMLBmeU0gZcjBoD2GPf2cSqZNPsRXo6zTA1kpukUZhMiEHcuoO86qDJK rc8Z0km87QbcokAcJCeavvjatluJDmWD0DQYTsXJd7p50/HMEguiajp5W w==; X-IronPort-AV: E=McAfee;i="6400,9594,10355"; a="253009649" X-IronPort-AV: E=Sophos;i="5.91,245,1647327600"; d="scan'208";a="253009649" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2022 00:26:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,245,1647327600"; d="scan'208";a="577261130" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga007.fm.intel.com with ESMTP; 23 May 2022 00:26:19 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 23 May 2022 00:26:18 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 23 May 2022 00:26:18 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Mon, 23 May 2022 00:26:18 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.49) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Mon, 23 May 2022 00:26:18 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AF4vwE4Nbf6OtoPUyusZJf71Btzq/29IOPlYgdE7zlBl3p4z+gY1vX3ZEpx4DJP3tTUSWsO8gYJ6igZHlCdEHBfzpjsMckhT5UpCihD8rYiZ8mCh5d1KxcA/sESzl3TnZBGt/5BYPQUfK2oQhdLr7shte04tqNoynCBX0P0J18v99yDGbyZE4W8Tho2HADDyHvKOCuei5SQZN7QvDM4+k9ewKm9iJxyxFgjVI/2IUlf8mDPGcuWqFQVuKtDdum12nOtHyHTbAYpssaXIgQI6RV7j5Cl5ckv+0l57RrP4QTYUB1iPvkWksNvWkVVwUerZSuysFNLQOAhhirycTjgMAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=piW3/P8n5eHBTKs56Bo9mb+zsYxKXWw4jzss+V27cqE=; b=ZEmI0m6VoJ0F/InXebuFAP3amaoxe8L1YQrMAIBZYxMEGOgb2lAXE9eLBd3dOCxbvUPGfyHviLXvwubc4aig6RKys+y7bblB3DktKT7LF5xZHyVwpvWaagJ2hodFtpjUv271LbrhISQRGmeUgwaGTwUZQwVDp6qzOiczcnzqnXfMFrcu5zKzNe2xnLBs1v6pt9jwQms4WTs+aH3VbhjoV8yVGtCoU/m9g10KOtQzLvoqha3/UdkgNSEL+Gabz2cxD8v03hyYAZrWmBuZJ6zA02LOURk02vM7hfSDyqlfbtB+q+9MFe1iXq3ZhWMUl6yC7xOzF5Yfd2YTvReB79+xKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by DS0PR11MB6422.namprd11.prod.outlook.com (2603:10b6:8:c6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.17; Mon, 23 May 2022 07:26:17 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::54e1:e802:17c8:93f]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::54e1:e802:17c8:93f%7]) with mapi id 15.20.5273.023; Mon, 23 May 2022 07:26:17 +0000 From: "Xia, Chenbo" To: "Pei, Andy" , "dev@dpdk.org" CC: "maxime.coquelin@redhat.com" , "Cao, Gang" , "Liu, Changpeng" , "Xu, Rosen" , "Xiao, QimaiX" Subject: RE: [PATCH v8 07/13] vhost: add API to get vDPA device type Thread-Topic: [PATCH v8 07/13] vhost: add API to get vDPA device type Thread-Index: AQHYarddJPdnEMsGeUSG+J70iyAshq0sFfBw Date: Mon, 23 May 2022 07:26:17 +0000 Message-ID: References: <1643093258-47258-2-git-send-email-andy.pei@intel.com> <1652876035-70513-1-git-send-email-andy.pei@intel.com> <1652876035-70513-8-git-send-email-andy.pei@intel.com> In-Reply-To: <1652876035-70513-8-git-send-email-andy.pei@intel.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 71ee7145-e675-41fe-9940-08da3c8d8694 x-ms-traffictypediagnostic: DS0PR11MB6422:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: vF3zx/UX+0iVHyWi0VJbMJcpR8mu+OtsnsbQZPXaFIFhDhnl5tEEN9sBbjLlAIRo/pyUOzM/Wo4CZdpFO9Mdm1OOpA+HCAHWpGjSS5q2qr3Nj6dikdcTTv70888zUmMx/sdsHKV/XOW2SMrAGaMhklErVQepTpIaBaAkG4ufKNLcC6lKaCDXfK6XnvKkxnbUcUc0SvioNufTcSg1kGsfdKYTMIAxpbLkK/oBI5YHZ4w6wMyrllZt0qtMwEXVOcDefu5DuJCveTyA+YdcYRLzTlbliixllvqwZ/q/ORYlixD2bbn3UlUjpLb4l04Ukmh7ukN1be4y+j+3N4y79oAjLB0vM/KGptnBMlLKZSu7rn1D6fU2h1vJh8q5SIBkHTmLuzvIxgmwETHayNjSBbHCaaGwkLGGp8KoRWIh4H0KAcsCSoIhhOvPHwxRwD3ul4JHQ/1jsapMOujOOyg0Tz2turBDvucqlCJw6g/zTbsgiX1iH29ftwHQpoQhn2kVtqSsOibW42SA+vBWiLOtlhtAqh5oR61PjcYpp/e+Stb4sgRmeR3YHLO4qQXyv00h5pd1dZVOdkOcTYK12pZJed5YKPo0P8zv5xV3KNHRLPo7XLMS1worUxrjTSLy8NMGOWCivxLoksKhcwccd6/rYwH/Aa3h2bOy+A2kRjiPKzn0VxbM3GLo7cVhx1wr3ejCYTOUS2j7RV0IuOXvgfpERxr9IQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(186003)(53546011)(6506007)(5660300002)(508600001)(55016003)(26005)(7696005)(8936002)(86362001)(71200400001)(107886003)(83380400001)(33656002)(9686003)(2906002)(52536014)(54906003)(4326008)(82960400001)(38070700005)(122000001)(66556008)(66446008)(8676002)(38100700002)(316002)(76116006)(66946007)(66476007)(64756008)(110136005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?jmcUVrYe833yrC4OZ1eMd4YrztUs12zc047JO2g5UJr0lYXOO8GD6f3LO0tN?= =?us-ascii?Q?HEmvmavqvj5pmNGS+eG/7uZESlPvIOe4cnXY0XCg1CSL//pMwB5hLr47S7m0?= =?us-ascii?Q?Y/YcgiNpsKbYpeWrArWrvG+gOAay+MUH36mdKVUw8CFpH2nptNvy3ooPLAE7?= =?us-ascii?Q?NRpkuhIfI/+oy8wYBkur/USS9HntFAX6mvUUHrSttS+1l6RCixfGdTZCbnjO?= =?us-ascii?Q?2EInK815s/T3WKOsHvzKUBKinP1USdkLCHsiqkVHzB1OBFBNZkShlktMLuQt?= =?us-ascii?Q?yRftConV4DIDeXmNjKLOFMI04rzNDp0JRMSeHcYR5A20fVZ3MXvMMPX5Y1Jv?= =?us-ascii?Q?FukUcMhFUTm1xpAbp4rH9SH8g1KY0RidEh6h0Wwvg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UBhOuEuPPwZCVNKZeDqkhVP1Hg0acguqLjW1rSgGlV3XtM9YF9CoVTgtmm7/?= =?us-ascii?Q?fqHAA7desZkXiPZ+cnQNqamin6G7v+xykZJyWxg7bO1gJZS3Fqb2DnyQbx79?= =?us-ascii?Q?ko14bYSUPIDbgPxPCTcrOwlp9alMIFohqjYUVc5ZLKk/VbkfFqJHU9atBhMe?= =?us-ascii?Q?0x4XossuxeEiesqTRVc1TeyibzyR5zjv6HNiCVVRWQL0hD0korfZhvVQZrx1?= =?us-ascii?Q?zTfkVVMqxCvtnwSzUB+fyNkBss/v1IhDrRhLVQcf2gE/2LGQ+BsuFNlqF00P?= =?us-ascii?Q?rJpyPS8/RDP7N6SMMD1kkYlbx8E1bghvMjxRwFwxwiasse0oXsOIVnL9NO7I?= =?us-ascii?Q?L0uBXT2/j9Fvg+fIjAw9sveE2KZbesmnyfN0KPUNv/wIG+CX6XMDnGFa0FBI?= =?us-ascii?Q?h0jsJ/99Q1rTIlv6zfE9jhjH1Oonbd3jbBs2OMc85DVe2XVZxviW7UHdeG2B?= =?us-ascii?Q?IYfDpf59sg=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71ee7145-e675-41fe-9940-08da3c8d8694 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 May 2022 07:26:17.1662 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: pqDtbpUKmL0/ln+gTKJqhs02+mWqJNz68jCmmyUZRAsz4DueDiEJArgBamFuuGYksO04dadEMw7hksdLEVdzVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB6422 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: Pei, Andy > Sent: Wednesday, May 18, 2022 8:14 PM > To: dev@dpdk.org > Cc: Xia, Chenbo ; maxime.coquelin@redhat.com; Cao, > Gang ; Liu, Changpeng ; Xu, > Rosen ; Xiao, QimaiX > Subject: [PATCH v8 07/13] vhost: add API to get vDPA device type >=20 > Vhost backend of different devices have different features. > Add a API to get vDPA device type, net device or blk device an API > currently, so users can set different features for different > kinds of devices. >=20 > Signed-off-by: Andy Pei > --- > doc/guides/prog_guide/vhost_lib.rst | 5 ++++ > doc/guides/rel_notes/release_22_07.rst | 4 ++++ > lib/vhost/rte_vhost.h | 17 +++++++++++++ > lib/vhost/socket.c | 44 > ++++++++++++++++++++++++++++++++++ > lib/vhost/vdpa_driver.h | 3 +++ > lib/vhost/version.map | 1 + > 6 files changed, 74 insertions(+) >=20 > diff --git a/doc/guides/prog_guide/vhost_lib.rst > b/doc/guides/prog_guide/vhost_lib.rst > index f287b76..0337b38 100644 > --- a/doc/guides/prog_guide/vhost_lib.rst > +++ b/doc/guides/prog_guide/vhost_lib.rst > @@ -282,6 +282,11 @@ The following is an overview of some key Vhost API > functions: > Clear inflight packets which are submitted to DMA engine in vhost asyn= c > data > path. Completed packets are returned to applications through ``pkts``. >=20 > +* ``rte_vhost_driver_get_vdpa_dev_type(path, type)`` > + > + Get device type of vDPA device, such as VDPA_DEVICE_TYPE_NET, > + VDPA_DEVICE_TYPE_BLK. > + > Vhost-user Implementations > -------------------------- >=20 > diff --git a/doc/guides/rel_notes/release_22_07.rst > b/doc/guides/rel_notes/release_22_07.rst > index e49cace..9550977 100644 > --- a/doc/guides/rel_notes/release_22_07.rst > +++ b/doc/guides/rel_notes/release_22_07.rst > @@ -104,6 +104,10 @@ New Features > * ``RTE_EVENT_QUEUE_ATTR_WEIGHT`` > * ``RTE_EVENT_QUEUE_ATTR_AFFINITY`` >=20 > +* **Added vhost API to get the device type of a vDPA device.** > + > + Added an API which can get the device type of vDPA device. > + Release note has a requirement of order, check comment under 'New features' in release notes. Based on these comments, you should put this after 'Added vhost API to get the number of in-flight packets' >=20 > Removed Items > ------------- > 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 @@ >=20 > #define RTE_MAX_VHOST_DEVICE 1024 >=20 > +#define VDPA_DEVICE_TYPE_NET 0 > +#define VDPA_DEVICE_TYPE_BLK 1 These will be new APIs of vhost lib. I suggest to rename them by adding prefix 'RTE_VHOST_' Thanks, Chenbo > + > struct rte_vdpa_device; >=20 > /** > @@ -486,6 +489,20 @@ struct rte_vdpa_device * > rte_vhost_driver_get_vdpa_device(const char *path); >=20 > /** > + * 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..ef0f401 100644 > --- a/lib/vhost/socket.c > +++ b/lib/vhost/socket.c > @@ -619,6 +619,50 @@ struct rte_vdpa_device * > } >=20 > 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) { > + ret =3D vdpa_dev->ops->get_dev_type(vdpa_dev, &vdpa_type); > + if (ret) { > + VHOST_LOG_CONFIG(ERR, > + "(%s) failed to get vdpa dev type for > socket file.\n", > + path); > + ret =3D -1; > + goto unlock_exit; > + } > + } else { > + vdpa_type =3D VDPA_DEVICE_TYPE_NET; > + } > + > + *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); > }; >=20 > /** > diff --git a/lib/vhost/version.map b/lib/vhost/version.map > index 5841315..583b4f3 100644 > --- a/lib/vhost/version.map > +++ b/lib/vhost/version.map > @@ -90,6 +90,7 @@ EXPERIMENTAL { >=20 > # added in 22.07 > rte_vhost_async_get_inflight_thread_unsafe; > + rte_vhost_driver_get_vdpa_dev_type; >=20 > }; >=20 > -- > 1.8.3.1