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 BF648A04FF; Tue, 24 May 2022 04:55:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 663E542684; Tue, 24 May 2022 04:55:28 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 29CEE4068E for ; Tue, 24 May 2022 04:55:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653360926; x=1684896926; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=O2MDmuR5zrZGbQqKHVXD/DcAuUGijEGfUjkWAwjo7y4=; b=MkW3/eM5sOqDaMHF1Q25/CTwApuNdJdBGEbfw9H/LQgd4XbYXpucbxYo PW6LW6GQIE7YwZZlSe0NvOoT3ISaRgtSiSqpD+B8gBSN278d6EJHq0pHS ScniDf60yP544H7/uiwj+fI84aQRgEcgFcPbbKw+kLGnFk7UDScbaev3m WHJ39FU7omifsibMaLh0OpTX/tUpydEWKvJ/fWnjRpqeQAfY8inPpKV2A p10GH3qPTOCHlRxF1IXRLlV2zxXnoYqZMlJS7kXNmC8dzVUZcWSF8fJbg 28P512kGLcB+qp48zlP7A7syzt8Rt/OVFaN8retUB8T7Isb+jbrTu5ex1 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10356"; a="273140512" X-IronPort-AV: E=Sophos;i="5.91,247,1647327600"; d="scan'208";a="273140512" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2022 19:55:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,247,1647327600"; d="scan'208";a="629684921" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga008.fm.intel.com with ESMTP; 23 May 2022 19:55:24 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx602.amr.corp.intel.com (10.18.126.82) 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 19:55:24 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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 via Frontend Transport; Mon, 23 May 2022 19:55:24 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.48) by edgegateway.intel.com (192.55.55.68) 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 19:55:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QaAlWUn9QrRslJGKBgb19eHTLLU7zvRi7lwg/DDyhPEBXRVyAT7fcxESx1iMoFfwx6sLrpHP1LICOU0TaAyQqwP1BoUYCf6LQgWqiy6/65rKRcUfBsDerKWXmmkO0xcOV8r/rnrpnPH6Tm5IFsCpb6G1VhPwcKdFKFAB3REY2lJTWBnJK2UZFuN5HhIZqBY7M1QwPoGLw9UM5lO3rLf6WI8TlUpmDCq/37SihMWGFXjfFsxMPikDq50TsB1QSlvg6EUngmYmKH6NPe3L7HEQa34h7bksoI+AR/jQ66ACeJH1o5VYOApPKAwbaL6DIx4+T0sNZI6U6IAZFN669C0nFw== 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=83fxOUDRg2L4aa5KkD6Qj+htOMQuJG8bA1SgXNRwTS4=; b=YYtqWsP2a3SLeCYtGrQfjsKmSFtVDHRjPlNwPc5ttAPIh4E2/sL+9dNbFA5wzmmllVVWMjKbBlz6i040+FB7NaSRtNuf8pNrKT8WOIQDbUYlwLgyM3snS3+j041RQPpToMlSvv2MDkWJGSzep5E4PiTBOIwdw3Kn7Lp63xFB9e4LBFQH6MP6MbAb/M90gFvGZHS0XN630m1wEmx9oostp0Fz0eLVY49sCeFoYJ9udfnXaB7eQu+VBBHYG3UtlQHGfYgSqQtJZe2d6ojeZVqaZOOvYsJ/z+5Ss+NNMtXbwUMyKrLTJ+iUcbR20JjSmtEro8Bh6Pxu3ol0QHooYz3o1w== 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 DM6PR11MB4754.namprd11.prod.outlook.com (2603:10b6:5:2ad::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.17; Tue, 24 May 2022 02:55:22 +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; Tue, 24 May 2022 02:55:22 +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 v9 04/13] vdpa/ifc: add blk ops for ifc device Thread-Topic: [PATCH v9 04/13] vdpa/ifc: add blk ops for ifc device Thread-Index: AQHYbo8NOJHBF6P7GEe/SfRfRmPr460tVhfA Date: Tue, 24 May 2022 02:55:22 +0000 Message-ID: References: <1643093258-47258-2-git-send-email-andy.pei@intel.com> <1653298524-232138-1-git-send-email-andy.pei@intel.com> <1653298524-232138-5-git-send-email-andy.pei@intel.com> In-Reply-To: <1653298524-232138-5-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: b3f2fd30-1fde-4c0d-ec7f-08da3d30d85a x-ms-traffictypediagnostic: DM6PR11MB4754: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: vbEWsVMFnVvnvI68aQRysg2Fl35sCG0Fba6pUW5mWJOXMgc32WNbkqBY1CX4uSc0CvIGFNW2R9OHl+PJksNlu76JLZoJq+iyX658qLUh3RQ5vlDx/GxFCvU0VRwCL37LRo8yKs/QVxHtymdiiaMJdA+1NRW+WkP7G28x9wE3NsfgNFlu17LzZCoB9/BN4swGAuc+0Z7fUOwr2JhQdU+0P9W0OvC4UZTeHYUK168ix6Rz76cpI4LZGphn5HYnhPp23a92Pn6Atm75AzRFVajfonIeVEx+2XnUPuB24NrZ+I+ocg8l6mI+4PXDgtvFzZK6XXbT+40DmqSQUItDi1Ch0YtuUyIicR2FHC3vJiwy+kNeNaSvp3TMvRPRXsSGMgHHThoMZG4at8YgmERA++Q1zUj5NKSQzlpAb+CeIrqifzJeqxGx8PiRQVipwLT6WIzmGKScAmSZpap503tbVYOdkbV9tZCNree1NBzBcky61Qah9Y7KBq9tsSc2JSwjt/FPcTf78uJ7cnnFNwTsJkiBqWTFu3P4ttCKL/zaHWz17pUnXw4WTSfhyB4aKJp9VXXO7C/+idMjKTQrppxOZN3OD27gTS7pOi2TeXwf+3h6y2qTE3aXBZ/0bjXhtVW9pWduVC/PZ94tvRFj/bYxz4XA5awenrIVXnEGHMz6Wr41WP3Ej6+CttB3LTPtasMdCUvgmgQu/KbXwitz2cFcZDSQ7g== 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)(107886003)(7696005)(6506007)(53546011)(8936002)(55016003)(5660300002)(33656002)(2906002)(52536014)(66946007)(76116006)(66476007)(8676002)(4326008)(64756008)(66446008)(86362001)(54906003)(38070700005)(122000001)(82960400001)(83380400001)(71200400001)(38100700002)(26005)(9686003)(186003)(316002)(110136005)(508600001)(66556008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?pD+0Ne1opdHtCTmNJ/ThaOvVLY4q0ZFkKue5gu1C57pUuA6JEpQNks3jItLe?= =?us-ascii?Q?a45EOz530yyhCFM1GAr3mK9Qh/OEK3jdBFn8fxUN9go2lCMZ8+sm0qLs9RBN?= =?us-ascii?Q?/pHOHg0C/vyRor75gLTnZDvmJuVvTZ1iGSL+kIdkSqq4D+KOFjtNOyDnMffs?= =?us-ascii?Q?jzV+0bk0PJUAcE2ArxPaKZx3CcY8LY+RH0qDxYxw0SvaSLj3ohN7w8b/lSyl?= =?us-ascii?Q?ZdGdjaoMECpg5BrwDL2uOfk+ZpomcCXbGvmgjn9BPTOOlIyipYKiDLsuQg6F?= =?us-ascii?Q?dPdjPb1o5JUVGqzwZFgWMBxJTUtbe8GnT43WbbtRJTSxeRDhHAfzjEKI3X25?= =?us-ascii?Q?rPmm9cXPAgfoZQciZTp4FNzqvG70KkDW7yGGqYs0rotn3w3m6hATmn4FCPdu?= =?us-ascii?Q?m5hKeFvwPJ9ecJbyG7qn0LimB3CL3ldIMIIkANQ33y1uFdABtIlI/YBaNqKv?= =?us-ascii?Q?syCn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I05Kii+Qw?= =?us-ascii?Q?CBTlOUKWtR+BC6z5JCAk6IQfXI4dWK/NftLWxPacmsfX7NYQyYthhUhDJfSl?= =?us-ascii?Q?+GnzqmjB3FRX6Pd//XnUdhbN0eVAF4c8tKz98WXh0HY1UzCyl8/BPplNgrPE?= =?us-ascii?Q?c2uFcWvGqwD6calgSpeTVVmpT/M23ljAtdgnTmDMUIX1vK1Ja/l1HJK/SMiO?= =?us-ascii?Q?dFPSqX7CDwZCKPcG40XQG4p67ct/XjcCmonf5uWwAs35h1zK6W+nkAWDpVnL?= =?us-ascii?Q?cl6ZzNfsYdFG3M5p6h/bONqHmkOg4wPlwZCN7HeySvv0Rj2WNj6LNfe+Smk9?= =?us-ascii?Q?rLRqvbKsbHRufKr4gMEdx0ZzoXu76snBamYyAIN7M06BJ2U3PJBDZPXHoK+4?= =?us-ascii?Q?OS2R3IyS4A=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: b3f2fd30-1fde-4c0d-ec7f-08da3d30d85a X-MS-Exchange-CrossTenant-originalarrivaltime: 24 May 2022 02:55:22.3283 (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: UhyNON/ZnGDzfmXt7pxX0ZWLESd925EjqJDWhjlpdOaxwJnrCt20CNjozwIECj15bfVvAoLYCVenNNAAZSM2Tw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4754 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: Monday, May 23, 2022 5:35 PM > To: dev@dpdk.org > Cc: Xia, Chenbo ; maxime.coquelin@redhat.com; Cao, > Gang ; Liu, Changpeng ; Xu, > Rosen ; Xiao, QimaiX > Subject: [PATCH v9 04/13] vdpa/ifc: add blk ops for ifc device >=20 > For virtio blk device, re-use part of ifc driver ops. > Implement ifcvf_blk_get_config for virtio blk device. > Support VHOST_USER_PROTOCOL_F_CONFIG feature for virtio > blk device. >=20 > Signed-off-by: Andy Pei > --- > drivers/vdpa/ifc/base/ifcvf.h | 4 ++ > drivers/vdpa/ifc/ifcvf_vdpa.c | 91 > ++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 94 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/vdpa/ifc/base/ifcvf.h b/drivers/vdpa/ifc/base/ifcvf.= h > index a761d49..b6fdfdb 100644 > --- a/drivers/vdpa/ifc/base/ifcvf.h > +++ b/drivers/vdpa/ifc/base/ifcvf.h > @@ -65,6 +65,10 @@ > #define IFCVF_32_BIT_MASK 0xffffffff >=20 >=20 > +#ifndef VHOST_USER_PROTOCOL_F_CONFIG > +#define VHOST_USER_PROTOCOL_F_CONFIG 9 > +#endif > + > struct ifcvf_pci_cap { > u8 cap_vndr; /* Generic PCI field: PCI_CAP_ID_VNDR */ > u8 cap_next; /* Generic PCI field: next ptr. */ > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.= c > index 1eed90b..c1fc1d7 100644 > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c > @@ -1087,6 +1087,10 @@ struct rte_vdpa_dev_info { > 1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER | \ > 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD | \ > 1ULL << VHOST_USER_PROTOCOL_F_STATUS) > + > +#define VDPA_BLK_PROTOCOL_FEATURES \ > + (1ULL << VHOST_USER_PROTOCOL_F_CONFIG) > + > static int > ifcvf_get_protocol_features(struct rte_vdpa_device *vdev, uint64_t > *features) > { > @@ -1199,6 +1203,91 @@ struct rte_vdpa_dev_info { > return device_id; > } >=20 > +static int > +ifcvf_blk_get_config(int vid, uint8_t *config, uint32_t size) > +{ > + struct virtio_blk_config *dev_cfg; > + struct ifcvf_internal *internal; > + struct rte_vdpa_device *vdev; > + struct internal_list *list; > + uint32_t i; > + uint64_t capacity =3D 0; > + uint8_t *byte; > + > + if (size !=3D sizeof(struct virtio_blk_config)) { > + DRV_LOG(ERR, "Invalid len: %u, required: %u", > + size, (uint32_t)sizeof(struct virtio_blk_config)); > + return -1; > + } > + > + vdev =3D rte_vhost_get_vdpa_device(vid); Check vdev is not NULL here. Thanks Chenbo > + list =3D find_internal_resource_by_vdev(vdev); > + if (list =3D=3D NULL) { > + DRV_LOG(ERR, "Invalid vDPA device: %p", vdev); > + return -1; > + } > + > + internal =3D list->internal; > + > + for (i =3D 0; i < sizeof(struct virtio_blk_config); i++) > + config[i] =3D *((u8 *)internal->hw.blk_cfg + i); > + > + dev_cfg =3D (struct virtio_blk_config *)internal->hw.blk_cfg; > + > + /* cannot read 64-bit register in one attempt, so read byte by byte. > */ > + for (i =3D 0; i < sizeof(internal->hw.blk_cfg->capacity); i++) { > + byte =3D (uint8_t *)&internal->hw.blk_cfg->capacity + i; > + capacity |=3D (uint64_t)*byte << (i * 8); > + } > + /* The capacity is number of sectors in 512-byte. > + * So right shift 1 bit we get in K, > + * another right shift 10 bits we get in M, > + * right shift 10 more bits, we get in G. > + * To show capacity in G, we right shift 21 bits in total. > + */ > + DRV_LOG(DEBUG, "capacity : %"PRIu64"G", capacity >> 21); > + > + DRV_LOG(DEBUG, "size_max : 0x%08x", dev_cfg->size_max); > + DRV_LOG(DEBUG, "seg_max : 0x%08x", dev_cfg->seg_max); > + DRV_LOG(DEBUG, "blk_size : 0x%08x", dev_cfg->blk_size); > + DRV_LOG(DEBUG, "geometry"); > + DRV_LOG(DEBUG, " cylinders: %u", dev_cfg->geometry.cylinders); > + DRV_LOG(DEBUG, " heads : %u", dev_cfg->geometry.heads); > + DRV_LOG(DEBUG, " sectors : %u", dev_cfg->geometry.sectors); > + DRV_LOG(DEBUG, "num_queues: 0x%08x", dev_cfg->num_queues); > + > + DRV_LOG(DEBUG, "config: [%x] [%x] [%x] [%x] [%x] [%x] [%x] [%x]\n", > + config[0], config[1], config[2], config[3], config[4], > + config[5], config[6], config[7]); > + return 0; > +} > + > +static int > +ifcvf_blk_get_protocol_features(struct rte_vdpa_device *vdev, > + uint64_t *features) > +{ > + RTE_SET_USED(vdev); > + > + *features =3D VDPA_SUPPORTED_PROTOCOL_FEATURES; > + *features |=3D VDPA_BLK_PROTOCOL_FEATURES; > + return 0; > +} > + > +static struct rte_vdpa_dev_ops ifcvf_blk_ops =3D { > + .get_queue_num =3D ifcvf_get_queue_num, > + .get_features =3D ifcvf_get_vdpa_features, > + .set_features =3D ifcvf_set_features, > + .get_protocol_features =3D ifcvf_blk_get_protocol_features, > + .dev_conf =3D ifcvf_dev_config, > + .dev_close =3D ifcvf_dev_close, > + .set_vring_state =3D ifcvf_set_vring_state, > + .migration_done =3D NULL, > + .get_vfio_group_fd =3D ifcvf_get_vfio_group_fd, > + .get_vfio_device_fd =3D ifcvf_get_vfio_device_fd, > + .get_notify_area =3D ifcvf_get_notify_area, > + .get_config =3D ifcvf_blk_get_config, > +}; > + > struct rte_vdpa_dev_info dev_info[] =3D { > { > .features =3D (1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE) | > @@ -1211,7 +1300,7 @@ struct rte_vdpa_dev_info dev_info[] =3D { > { > .features =3D (1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | > (1ULL << VHOST_F_LOG_ALL), > - .ops =3D NULL, > + .ops =3D &ifcvf_blk_ops, > }, > }; >=20 > -- > 1.8.3.1