From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 049D3A052A;
	Tue,  2 Feb 2021 15:04:37 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id B61782402DD;
	Tue,  2 Feb 2021 15:04:36 +0100 (CET)
Received: from hqnvemgate24.nvidia.com (hqnvemgate24.nvidia.com
 [216.228.121.143])
 by mails.dpdk.org (Postfix) with ESMTP id 7D3402402DB
 for <dev@dpdk.org>; Tue,  2 Feb 2021 15:04:35 +0100 (CET)
Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by
 hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA)
 id <B60195bf20000>; Tue, 02 Feb 2021 06:04:34 -0800
Received: from HQMAIL105.nvidia.com ([172.20.161.6])
 by hqpgpgate102.nvidia.com (PGP Universal service);
 Tue, 02 Feb 2021 06:04:34 -0800
X-PGP-Universal: processed;
 by hqpgpgate102.nvidia.com on Tue, 02 Feb 2021 06:04:34 -0800
Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL105.nvidia.com
 (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 2 Feb
 2021 14:04:34 +0000
Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL111.nvidia.com
 (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 2 Feb
 2021 14:04:32 +0000
Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.176)
 by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id
 15.0.1473.3 via Frontend Transport; Tue, 2 Feb 2021 14:04:32 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=Pz9maqbNWI7cFjtJPrSqZGYZ2WNtpfHI/cijsbh9BgFhuoUE7IDpmln6ptYPA30kpFNrSDm4gBtw0ALC5ZUOZzRHCaanQ+F5Luv+3aPZmxg9tna1hOfPjzhZYav1s3UXHS0k+bYFfpEch7AH1d/8OD9eFm4PFJCB7TvIC7dz+r3ylO3pqfLy3w2h71LlhEalnvOiPchk6/i2itOJU2Om2bZHYmx/c/KuqtxV+zZTZ2AxtcQSbOGERog1eCNob7Sda2KuL6kG46N281yvlC7WwTy4WYLzVznGIRWzitRkyIMOJ/zrvCssCkupdPzqrk+1sCkYIByUPuWViyK4CGi4BA==
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-SenderADCheck;
 bh=WAcC15Nadt6FwZleFAhfxtocYpmP5diPGkqfo0xzQqM=;
 b=UIjGsed6GWbvAfpVnciXGqSTAgW1emedK9ssDDvQTtIxqBeArvSvHj6Z6GNz3sZVl9NsuBm33KoQRqanhH0P1qX8G9I9pYvrkEdRq4HXKluj223Mwc5Juo2FQZT3rmLWbo7a+KYFrOwoONZOdQE995P0evlIRROfvAz7Ox2pLyRv4y+7hHJqnvwgQHDuXiKhcH/WgfSxp14xu8basn1BvNf942Se6quVfb0rC1NXDdCREX1xbdkae/Jr+HG42R3+xJU4F41WiSFX02D3vQ/XO23QAGTAK1SaPgJgheUJBeeDlv6v7HeLrmOjJZhzW+ZoGQOPfOqAzScvNf9BnvnbmA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com;
 dkim=pass header.d=nvidia.com; arc=none
Received: from DM6PR12MB3945.namprd12.prod.outlook.com (2603:10b6:5:1c2::27)
 by DM5PR1201MB0267.namprd12.prod.outlook.com (2603:10b6:4:55::17) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.19; Tue, 2 Feb
 2021 14:04:30 +0000
Received: from DM6PR12MB3945.namprd12.prod.outlook.com
 ([fe80::d1dc:9fb2:4724:53df]) by DM6PR12MB3945.namprd12.prod.outlook.com
 ([fe80::d1dc:9fb2:4724:53df%7]) with mapi id 15.20.3805.024; Tue, 2 Feb 2021
 14:04:30 +0000
From: Tal Shnaiderman <talshn@nvidia.com>
To: Nick Connolly <nick.connolly@mayadata.io>, "dmitry.kozliuk@gmail.com"
 <dmitry.kozliuk@gmail.com>, "pallavi.kadam@intel.com"
 <pallavi.kadam@intel.com>, NBU-Contact-Thomas Monjalon <thomas@monjalon.net>
CC: "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [PATCH v5] bus/pci: nvme on Windows requires class id and bus
Thread-Index: AQHW+WsCMvrMDez8mEWGA/brQeW6hapE5Vbw
Date: Tue, 2 Feb 2021 14:04:30 +0000
Message-ID: <DM6PR12MB39458CA4E4F783068371E1E3A4B59@DM6PR12MB3945.namprd12.prod.outlook.com>
References: <20210125170821.11306-1-nick.connolly@mayadata.io>
 <20210202135447.28868-1-nick.connolly@mayadata.io>
In-Reply-To: <20210202135447.28868-1-nick.connolly@mayadata.io>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
authentication-results: mayadata.io; dkim=none (message not signed)
 header.d=none;mayadata.io; dmarc=none action=none header.from=nvidia.com;
x-originating-ip: [77.137.141.17]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 9f21528e-5c84-4de7-240e-08d8c78375db
x-ms-traffictypediagnostic: DM5PR1201MB0267:
x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr
x-microsoft-antispam-prvs: <DM5PR1201MB0267AD434F5D61BB2B771BFEA4B59@DM5PR1201MB0267.namprd12.prod.outlook.com>
x-header: ProcessedBy-CMR-outbound
x-ms-oob-tlc-oobclassifiers: OLM:3513;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: Xa0ZxQUnhIGqAzsA0sDcfsECagtjUIb6NL622VWro05hpF07jm45heW8eOAWdKOg3giPbOShboaUXKzizpmjN/4+AiHnTuCjSQVZUerXZycYeRdkofbtaY3GtNB3A7rCwTOzq+szYlWMePQOWbLwoLu6YvJrVKsERfUx4gQpKQ3G88WsiPh6TjZaDclpcNHLHYBfHiFFc1YWgiH6OkwoTFhMX96viB12MsFpCQfSolmLayikAXF5rIsgND8BzO7hZC5M5CF+JSj8ul2mvqNApILue4853x0lDt+fp7CEyQVmBn79sAPK5SwQhBHV86c3CO+GWDJpGM/LN+4bHWibJN3f7QqOdaPufR5whdqDN4CtTNCZiQPhaU1TPLwWv3ZZRHBCd18EMea2DLS/gEe87mhOUWr8LMOkqO+j95ExwMng4k6x+F2kWGQLE6b/UE64pT9wxIq7pvYo1y6xbYWpr/AEWCmxy2VIoLlS0N8WaIBjSgCYFFFVZ6MYWiuuWNm3T/hUB4OztkaHDYbjJ8dh+g==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:DM6PR12MB3945.namprd12.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(4636009)(39860400002)(396003)(346002)(376002)(366004)(136003)(110136005)(76116006)(9686003)(478600001)(33656002)(66446008)(316002)(66476007)(66556008)(8676002)(186003)(64756008)(4326008)(83380400001)(52536014)(7696005)(55016002)(26005)(71200400001)(5660300002)(66946007)(6506007)(2906002)(8936002)(86362001);
 DIR:OUT; SFP:1101; 
x-ms-exchange-antispam-messagedata: =?us-ascii?Q?KJBpSgcWdQ6bIH21iCkoINUKxcg8sjzDKAPV3C8m//q1WB6YO+df5sSKlJeD?=
 =?us-ascii?Q?fwqZYtfPvju5CCiGE/Y3obC8MNKqAEfoeKC8mpZVnxrmzkUnQNMpa8uiZ4N3?=
 =?us-ascii?Q?HnjtJPFGl58ALCSJwhICPwR33KWHD4CJsYPPn4fAEW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OwF+Y?=
 =?us-ascii?Q?0Y/TXa4WoDoKohupwIWCLB0DfScsEhO97uVeNTsNQuedv7T+VUtcy5TOKi+X?=
 =?us-ascii?Q?zYNREJFw?=
x-ms-exchange-transport-forked: True
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: DM6PR12MB3945.namprd12.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 9f21528e-5c84-4de7-240e-08d8c78375db
X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2021 14:04:30.3804 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: rF8L3B8JDyhTvQmJhwi1hYx4CEbQSC1QsRE6sJ/zeELqSrxDh+C8pF8sxvLdGuq9RQfkDihgGC2o5iSTMliKsw==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0267
X-OriginatorOrg: Nvidia.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1;
 t=1612274674; bh=WAcC15Nadt6FwZleFAhfxtocYpmP5diPGkqfo0xzQqM=;
 h=X-PGP-Universal:ARC-Seal:ARC-Message-Signature:
 ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:
 Thread-Index:Date:Message-ID:References:In-Reply-To:
 Accept-Language:Content-Language:X-MS-Has-Attach:
 X-MS-TNEF-Correlator:authentication-results:x-originating-ip:
 x-ms-publictraffictype:x-ms-office365-filtering-correlation-id:
 x-ms-traffictypediagnostic:x-ld-processed:
 x-microsoft-antispam-prvs:x-header:x-ms-oob-tlc-oobclassifiers:
 x-ms-exchange-senderadcheck:x-microsoft-antispam:
 x-microsoft-antispam-message-info:x-forefront-antispam-report:
 x-ms-exchange-antispam-messagedata:x-ms-exchange-transport-forked:
 Content-Type:Content-Transfer-Encoding:MIME-Version:
 X-MS-Exchange-CrossTenant-AuthAs:
 X-MS-Exchange-CrossTenant-AuthSource:
 X-MS-Exchange-CrossTenant-Network-Message-Id:
 X-MS-Exchange-CrossTenant-originalarrivaltime:
 X-MS-Exchange-CrossTenant-fromentityheader:
 X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype:
 X-MS-Exchange-CrossTenant-userprincipalname:
 X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg;
 b=lp4Y8VDr6KR0X3FvKV09DQAky+7Z/Yfi4S1yKbrgOB8GaEQJ19sb1PGlipdqa7AUR
 RjRp7hb5IeeI/frKgDFmlPPgISC8tgnSZ5waJJJE2fvl8LHtoiOoy3N0nvtSbHH3zA
 0gr91Hvt8D32F9cZY0MoMSgZW9bQeBgeCdsxSsnKV/sIaFuhRD6AD8/U/VuRm8gavD
 R0zAE71xaIPOD0qJF9a5eFBwJEW4itiTRD/pljAA28ejQo98shDbTQbZswy4pHKZj3
 cAAfD3WHCO8sDeKf2sX9C0b8aI5Ki9Id/PtRGuvmOtiyMdE8KV61gURr+NKC/GhBB6
 fzqBPFRN4vQfw==
Subject: Re: [dpdk-dev] [PATCH v5] bus/pci: nvme on Windows requires class
 id and bus
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

> Subject: [PATCH v5] bus/pci: nvme on Windows requires class id and bus
>=20
> External email: Use caution opening links or attachments
>=20
>=20
> Attaching to an NVMe disk on Windows using SPDK requires the PCI class ID
> and device.bus fields. Decode the class ID from the PCI device info strin=
gs if it
> is present and set device.bus.
>=20
> Signed-off-by: Nick Connolly <nick.connolly@mayadata.io>
> ---
> v5:
> * Add missing version history
>=20
> v4:
> * Use #define to determine length of Class ID
>=20
> v3:
> * Put version history at top - v2 mistakenly had it after the diffs
>=20
> v2:
> * If only a 4-digit class ID is available, convert it to 6-digit format
>=20
>  drivers/bus/pci/windows/pci.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
>=20
> diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.=
c
> index f66258452..dceb0f4b2 100644
> --- a/drivers/bus/pci/windows/pci.c
> +++ b/drivers/bus/pci/windows/pci.c
> @@ -23,6 +23,9 @@ DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node,
> 0x540b947e, 0x8b40, 0x45bc,
>   * the registry hive for PCI devices.
>   */
>=20
> +/* Class ID consists of hexadecimal digits */
> +#define RTE_PCI_DRV_CLASSID_DIGIT      "0123456789abcdefABCDEF"
> +
>  /* The functions below are not implemented on Windows,
>   * but need to be defined for compilation purposes
>   */
> @@ -280,17 +283,29 @@ parse_pci_hardware_id(const char *buf, struct
> rte_pci_id *pci_id)  {
>         int ids =3D 0;
>         uint16_t vendor_id, device_id;
> -       uint32_t subvendor_id =3D 0;
> +       uint32_t subvendor_id =3D 0, class_id =3D 0;
> +       const char *cp;
>=20
>         ids =3D sscanf_s(buf, "PCI\\VEN_%" PRIx16 "&DEV_%" PRIx16
> "&SUBSYS_%"
>                 PRIx32, &vendor_id, &device_id, &subvendor_id);
>         if (ids !=3D 3)
>                 return -1;
>=20
> +       /* Try and find PCI class ID */
> +       for (cp =3D buf; !(cp[0] =3D=3D 0 && cp[1] =3D=3D 0); cp++)
> +               if (*cp =3D=3D '&' && sscanf_s(cp,
> +                               "&CC_%" PRIx32, &class_id) =3D=3D 1) {
> +                       /* Convert 4-digit class IDs to 6-digit format */
> +                       if (strspn(cp + 4, RTE_PCI_DRV_CLASSID_DIGIT) =3D=
=3D 4)
> +                               class_id <<=3D 8;
> +                       break;
> +               }
> +
>         pci_id->vendor_id =3D vendor_id;
>         pci_id->device_id =3D device_id;
>         pci_id->subsystem_device_id =3D subvendor_id >> 16;
>         pci_id->subsystem_vendor_id =3D subvendor_id & 0xffff;
> +       pci_id->class_id =3D class_id;
>         return 0;
>  }
>=20
> @@ -339,6 +354,7 @@ pci_scan_one(HDEVINFO dev_info,
> PSP_DEVINFO_DATA device_info_data)
>         if (ret !=3D 0)
>                 goto end;
>=20
> +       dev->device.bus =3D &rte_pci_bus.bus;
>         dev->addr =3D addr;
>         dev->id =3D pci_id;
>         dev->max_vfs =3D 0; /* TODO: get max_vfs */
> --
> 2.25.1

Acked-by: Tal Shnaiderman <talshn@nvidia.com>