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 01CDBA00C3; Thu, 12 May 2022 15:15:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E505A40E64; Thu, 12 May 2022 15:15:46 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 9F92F40DDD for ; Thu, 12 May 2022 15:15:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652361345; x=1683897345; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Nk4cupDjvxH1/JNkyVXTJguK+dab00iuw3ZnviBYnEw=; b=mpq1NuKFbgr2nOjSNG9MUo7e8FXYSgVtlYhw7XQvfCCKbZ2V4r+ROR1v EqSVMwzOkoekbp4WuWaJb2qb5h/Lbtm0n9YdHw6f42Zpbgsz5Ohot87XC 9DUPJs3kuePokAWdLJePmHBuXwU3JIb2YfdzwL3eDcYIcGHRHb5jW5JXW cB80605Q/sKh+WhciBXh5otjffXc6hNFkAs1kxCglBciYKDDnUW0uS/r7 JHXzOuM8Se/qEjRjYaDGfpxiK+ivgeKR4XMFBEo9Q21Yrh6VCPPmHHVAW zvExQD9jgE6wKUnZeq93jK0rvW9K3B2qG6IoP4bqK/ASPmvbU6uLdxujd w==; X-IronPort-AV: E=McAfee;i="6400,9594,10344"; a="250520964" X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="250520964" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 06:14:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="814917329" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga006.fm.intel.com with ESMTP; 12 May 2022 06:14:26 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) 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 06:14:25 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX611.amr.corp.intel.com (10.22.229.24) 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 06:14:25 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Thu, 12 May 2022 06:14:25 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.49) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Thu, 12 May 2022 06:14:25 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ezwPn3N7DJSwwrCCOQhnECSjjswksB3xdeVXMmWHdV8OO1sIeSk9Djx+wZbgM7oBzoNTOTujGyCxNewFRwkG4kVVdFj8aU+e55rrf9+x8M39dt1j++nBAMbQJWlvf/tl2rjKLbP+ZyElCBMTim7P4YgjmxVR5Egkjm2ehqd87Pkv3P+TC1fC9md/QXxmorMgkHxcTct35nCV6+HZDzYgqU39wTRveyrBkhOZ4fTyf5aWaSKbmnAFuh7mZQepiR6Ep8pBO0v1guNaxxoEqr0Oy0nWkkqEHjIfzisWFWJ3VNVCc+/PPQYGPaSIQrhEY8CRE2OGr0xsRThyAkmCp0c8qQ== 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=0exH6thOyER0EgdHxJWePpxPbCavEQpbBtTo+ZPWpA0=; b=mehhJ202OhHi96W8YKG4W6qtvf4ZXV3Jiih2fv8nUsAxBM+N6jDEDvgwwt0auNeyHRJT9SQR9kYUooJDWfJlyywpxIKqaerutsyWlifklsKOjL6J9FarbPJrOQBasLwiZDP6VvHS0JQVGzyNM2SrfP1sRBTWYBqj/PZzwOg6hvqIV+lUJR+tGr8YafbYjI4wM3TzYEEgx27az2T0LhUGHgBcZoG5XDiQhPlt09C2UpF7imHPbxOUtrG+GM8r6M7Skwg1J3pxhgfJySnrELD0/dEnULheJ8HSDjnoLsHmt2tZF7+DgyTEWLb4ZCYdalUGYxiziMe3UOc3kecJf+mO7g== 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 BYAPR11MB2951.namprd11.prod.outlook.com (2603:10b6:a03:90::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22; Thu, 12 May 2022 13:14:23 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::2c8f:42df:ed85:99e5]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::2c8f:42df:ed85:99e5%4]) with mapi id 15.20.5227.023; Thu, 12 May 2022 13:14:23 +0000 From: "Xia, Chenbo" 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 Thread-Topic: [PATCH v7 07/18] vhost: add API to get vDPA device type Thread-Index: AQHYWheEEUvX4oem80u/j3IFPr7F0q0bTbrA Date: Thu, 12 May 2022 13:14:22 +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: <1651048206-282372-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: 2870834f-87af-4a9b-2aaf-08da341954ee x-ms-traffictypediagnostic: BYAPR11MB2951:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr 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: WC1RYL9w1gwIy+c9IzP7s30fPcV2AHkap7jKktd6dGgjhuNEA4543zpwVpv2hcxDh4ccRdH0pQ69FqsnRoRPyftkyXfjcXSOC1b5cKZaF0L3nLEVAujv7dZKstB4XJRaBLu2nCIl0fh/sjHSZvyEgxdqQG6lKS7RpdA4wdUIXyV0lgeZBSwkKd/IXY+tZ1w4zirM43VqQlW/SaufZf+oH9S2YpDykLDOY0DTJ4MkA2ETylM8QH7hpueG7+BXuxKupbZBRFdwukZJXf/7xwB748cHgu9QIb/LKxZGAUYCt8kRMAjgfiZFAwSzjGlc2nRXgiChvpUAjwIp0OOtrTGHTOJWdh3s113oC4AC9dITnOFgfXkzkinTAkfe/1OqiTCCpnMbti+eRh5OBtamHYA4KlKP6VyOqQ34b7bCk2NYZ6v0lipo7W6OMVjgx2DTni7cXmQ4CHWpQ2c+SMa4OaFlkEzZAhoOt4YPoyziDIwGBAXrpUqcBSYM8MjEpg/cfbCbG5ZoGYACp/zGOBB2T3QcckruRjip3JtdBaSBeo7JbownrFKqUyA41BB6bJ+qzyDSll61rEJsXHlTO+P0qVkO956VuJIj8iBA4wyaop8bZNeam5fRhpWfo+HhaEDRVVX0DockH3eior9ob1gCWD3IFNBpDR35uLB1aoV4ydsCoRMr9EeO48TXVIznWvw6/xxFYZSr06ZERGAs3AUhDJUARJRJTMEsKzyDydyv51OAaBw2as8P2SyQhxT0M5AjvVPxkYGsoak4MYjDz6zDB7ZIFjF0DaS4RNpkhxSLIQ2F+Vs= 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)(33656002)(83380400001)(5660300002)(508600001)(52536014)(8936002)(71200400001)(107886003)(6506007)(38100700002)(53546011)(186003)(966005)(86362001)(9686003)(26005)(2906002)(7696005)(55016003)(316002)(82960400001)(122000001)(110136005)(54906003)(4326008)(64756008)(38070700005)(66556008)(76116006)(66476007)(66946007)(66446008)(8676002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?cls0xBwsKdlp4UVtBEWgsaWkmnGhdU8ovi1iMETL7NaJTLeQ0VQXOftqbnha?= =?us-ascii?Q?VCjEbtcyghDMArrHGE5nQgSKxbtXIMVv0qNBxZluEZMSd08r4HnfcsXj/Ls6?= =?us-ascii?Q?PYXogq9nkBtlVnks8nfCrVZj9ZSwYQQ9nJRWdNIqZ991UUQR/skm+5SqT4Ib?= =?us-ascii?Q?atiVrtn7qJjdOKzVZ733OZbG/4vIn2pqehbt6dOVgjB3p9hVUBeWA4z3xzgr?= =?us-ascii?Q?3hjOWst0N2DlCjWL7kV7V6Vm7S1qQGN1urjd24YszeFBWSJuA4eWltIe2uiQ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lhNHyoTCpBEVJWK1HZjVk+/AbtE4ZT?= =?us-ascii?Q?ZFzDHpScicb90QttIXx4ZZF/d+iaP0K+GOZ91ERWSP0MZRecKH05xXMcInXG?= =?us-ascii?Q?lHkfJ8dqfcMq2oDzbZbuPvmrMgyFhPZg4XUhc9D4bB2f8CitcvXhZywXwbNh?= =?us-ascii?Q?RtI/TnjEYtLcCKvKiNMP2Csx7QtgFrVGYusGGfaOEuqE5pRdaD5LdeOz2qk4?= =?us-ascii?Q?SrY1FKN5ThHSxFmVStW0L4v0Jp7zAVCT/c5tFynOyqsVS7xLdYt/B9sVcJxl?= =?us-ascii?Q?vHiEm3JQpMs8ZA65AfoEoA40UP+LlfMo/TuG3e6L243gN4Ec8YW38gBqvZzk?= =?us-ascii?Q?ehH+k11Nq1UEdr7mxZHna41Q2+gifj0DNEglP8F8eDspa0oa3kKIpi3LwbHC?= =?us-ascii?Q?hoy1DrGq6WZtOa4G/PXsdvgiQe3R11EURZ2FjeN9ZsswzIhnEmHPX+BKSIUl?= =?us-ascii?Q?VjWzS5WXBz4knSIiTlw6Ari2yHphZG53TYOiGNBNSiTMgRFQpKr4krONdDDg?= =?us-ascii?Q?h/ZzRwQ+hgJU+FHxUq4fSV2S2Jbz5edEi4UhuT1gT0CfJP7nGMoVOjgXjqXT?= =?us-ascii?Q?ND6+YobuxA=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: 2870834f-87af-4a9b-2aaf-08da341954ee X-MS-Exchange-CrossTenant-originalarrivaltime: 12 May 2022 13:14:22.9911 (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: VuO2B2m5V8ggkfGUVRxxPH7xn9gvYW9ddGbsU5+pSkCPzuHgJk5tnH1UgT088e/prLFTaYtzGEmNEfn8mPG0NA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2951 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, 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 >=20 > 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. >=20 > 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(+) >=20 > 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 > + > 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..7da90e8 100644 > --- a/lib/vhost/socket.c > +++ b/lib/vhost/socket.c > @@ -619,6 +619,45 @@ 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(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; > + } If vendor's vdpa driver does not implement this callback, should return typ= e 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. > + > + *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 0a66c58..fe4e8de 100644 > --- a/lib/vhost/version.map > +++ b/lib/vhost/version.map > @@ -87,6 +87,8 @@ EXPERIMENTAL { >=20 > # added in 22.03 > rte_vhost_async_dma_configure; > + > + rte_vhost_driver_get_vdpa_dev_type; Missed '# added in 22.07' tag, but when you do v8, this may not be a proble= m as other patches may add this tag with new API introduced. And introducing new API will need update of release note. Please refer to http://git.dpdk.org/next/dpdk-next-virtio/commit/?id=3D8688= 83e899af386abcc298ea80ec7f6a18d8a8e7 as an example. Thanks, Chenbo > }; >=20 > INTERNAL { > -- > 1.8.3.1