From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7D7B3A04BC; Thu, 8 Oct 2020 23:50:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5C7D81BB4F; Thu, 8 Oct 2020 23:50:45 +0200 (CEST) Received: from hqnvemgate25.nvidia.com (hqnvemgate25.nvidia.com [216.228.121.64]) by dpdk.org (Postfix) with ESMTP id 113AE1BB43 for ; Thu, 8 Oct 2020 23:50:43 +0200 (CEST) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 08 Oct 2020 14:49:46 -0700 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 8 Oct 2020 21:50:34 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.171) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Thu, 8 Oct 2020 21:50:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FBr6xhRAvZx+c5phHfPg3M5ZwwNoU4gIr+/XsM0LT30xOK5AQdvlx9cbImpObtdHP905q9l6yXlsqXmIYUoDQArGWT3DFc3gR3CDtR0bjbdslQMf4zJEMAcsi9pqYcrXDIYz79i+133o0W+xnoTvAacfhPkYGac19XUSbsToDoYPUdJi3SyroSZ7qmDQzQ9pU5H3FdwkGRv02Qxsdn60uPR2UtXRrUKnB3a0HH98oejVRJXKtUZkj9e4+c0iezrVKQxkVS+SgTqD8hTYgT5zPR09q47hspLxQvfWF+wMx63OM3Ys5L64ePTpfYixmTpaM3wsxvm+Mvks+KFxdxejMg== 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=isSQuiLFhxD15mgNgTeBi6bU/a7gs0PWMn9YO0V4o44=; b=kmvpakJTwYfuvJgPGq4/NoDHrmp9bE8ZNuni0B82FHKPe+NPYx0SincdEIsR846YCGk2RFA9YKuwIBnd+zzjYsHiCj2aavKfLE5NqidHR2nR+DfV5gq1ehySaOW96CjJ7t92Mk8d0UtqEF97yYeqVgy3wubw633YC6VEFdcJRYg8loVlQocZfqVijW4y1YTXW1gwLwK1oomvhF6P91yhw/MvzcPToDPtyeK++98+4uXxUEmUwJtWjMeEvkvKHUSD/GwZNqbNUI/Ydgu9Rg0Bh+mQdrYY7cCkD9jIYqtvVA4txOMF9ncZLIGJm430jyG9YSXowiO0nj5xd44/eLBhnA== 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 BYAPR12MB3285.namprd12.prod.outlook.com (2603:10b6:a03:134::14) by BY5PR12MB3793.namprd12.prod.outlook.com (2603:10b6:a03:1ad::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 8 Oct 2020 21:50:31 +0000 Received: from BYAPR12MB3285.namprd12.prod.outlook.com ([fe80::9577:cc9f:6780:4c6c]) by BYAPR12MB3285.namprd12.prod.outlook.com ([fe80::9577:cc9f:6780:4c6c%7]) with mapi id 15.20.3455.024; Thu, 8 Oct 2020 21:50:31 +0000 From: Tal Shnaiderman To: Pallavi Kadam , "dev@dpdk.org" , NBU-Contact-Thomas Monjalon CC: "ranjit.menon@intel.com" , "John.Alexander@datapath.co.uk" , "dmitry.kozliuk@gmail.com" , "Narcisa.Vasile@microsoft.com" , "khot@microsoft.com" Thread-Topic: [PATCH v7] bus/pci: netuio interface for windows Thread-Index: AQHWnajSL09WyW4LfUG+5tAJW27zkamOPgdw Date: Thu, 8 Oct 2020 21:50:31 +0000 Message-ID: References: <20201006215730.1584-1-pallavi.kadam@intel.com> <20201008185645.12248-1-pallavi.kadam@intel.com> In-Reply-To: <20201008185645.12248-1-pallavi.kadam@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; 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: 0ccdff23-c5bb-4283-513c-08d86bd42da6 x-ms-traffictypediagnostic: BY5PR12MB3793: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:773; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: G2NNyAQk6ZkCXDMdbrQkiY71Ni0+olh1oi2jPgOqZcAJxIVKDmzM7fb6p8iutssBzG+pzdH/Q6xnJ+SZ1Yh7huAkVY/ZEyMyKKxsUJ1Lo9AXs7/oz3u0LQFzvqjWCXmyV1GHwkC4RoqG6SacWhkhkHKn2jlzpZT5UDGiny3FHHrJmjgRwFAe782oQTObo/Dt51GQZaNoQvWPMio1jCXV1MxmUrgrYFegNK+Jtlhs6TcifYVAl9gC3IX1H00PQq3gmhfSo6rlgGxE/Pt5an/bybQiXL3kOtEh/Sm0KZpiGIaZJyudziCfOHpN838KEmwgBvE68Eo1iwOoGNW7lNZh1g== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR12MB3285.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(376002)(136003)(39860400002)(396003)(9686003)(110136005)(33656002)(54906003)(52536014)(66446008)(64756008)(66556008)(5660300002)(66476007)(55016002)(76116006)(26005)(66946007)(186003)(4326008)(71200400001)(30864003)(8676002)(316002)(6506007)(7696005)(2906002)(8936002)(478600001)(83380400001)(86362001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: Yw1fV7pzP1SUBn8TDbt0sG/+QWMG01cyFvrODxXqSIwJm7kB93En06tqc5HRhmZYAeM+nLMn7UtloLrf/bULY1FE3XhHc4cW2tBZC9NzNNB8LULT5C2gSTzxvXzKgZqghvr5FV0NbGdDmICIqmYYLN7ZshkZ8WWubwVbQVbV8gpJaVB+iPrirgL2i9gzDGQpLlVyu14njnSVPH5d/Lzv5SBqHbdwc5fsP1XT0T1AqnwqjrrTQVk8HNmAHReKx92hhUFQRQFXCuTNfNgL3xkkKhUa8r6fRzLbOZc+rBZBdaU0iWlnxiabL+aGtDwLEoQvI+43WO0kBqIiIM6xkB1dgmbQThqCSukSnUU+Tn9l+sKZzBANskW2uAR2XL3LLZRWIkhznIAfz/XFog4HywOZP+EAwA/3R94XAdrr8YtNuu25jGaHFB1hUTaTnpN2iRJ8KjLv08bqSpEm9g8rTwn6m5CRtVebcXRgBmxqPbys7uFTfnACQsTMX5q8rjJk4ybwJfDpPJPshRAfJIXMUvLl1Gm0K9f8UrI+AGgJ++CEHn3uoUr0lHpn8Tm1BBBoOiIJrl3/v8DftIlKd1+4yvBE5DuxUocI4ZTWvzF6MBsusphC9gdPmLxAtyq2G/yOVYO+lofncRgoxjrjpQ1k5rHpMA== 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: BYAPR12MB3285.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ccdff23-c5bb-4283-513c-08d86bd42da6 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Oct 2020 21:50:31.4449 (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: 4kO9NvKIHDnt3scDUyUW/o01pnNYyTLGrdJZr878hra/1siKN+0VS/f29T0QrevAEWU/wFx6/Av1FGyLC9gJOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3793 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1602193786; bh=isSQuiLFhxD15mgNgTeBi6bU/a7gs0PWMn9YO0V4o44=; h=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-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=LCEbWfDB8FrHDjb7Lil/edM+TByEtk6fppgiZFh/QIWtUlgK2EJtZWe8bF6I8aONO MPqRviu5kfkMsH1TtPzyyqg3S4HtiLRanjt0W9RqIFvc3SqEUnPENS8MIUCKosb/F5 WGzL/O+fIzDGKyKUOSLZkKFuf7i4ueduZaaYqzaZGVKZr4gitazG+iW9Sv7/Dm43cE P3KwWTtyEA7h3KtlPm1u/uJWLHuAsmfT00e1ZeFF6RbwTNpYTTxQQefka96sSznjjr 72+PY/J3UzCohbwR889uck7NCwLR5UCyiz+1kFEtWbT4tdwHzzhZBXfrxOBO/doy1/ H+Fq8cKDgXNQg== Subject: Re: [dpdk-dev] [PATCH v7] bus/pci: netuio interface for windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > Subject: [PATCH v7] bus/pci: netuio interface for windows=20 >=20 > This patch adds implementations to probe PCI devices bound to netuio with > the help of "netuio" class device changes. > Now Windows will support both "netuio" and "net" device class and can set > kernel driver type based on the device class selection. >=20 > Note: Few definitions and structures have been copied from > netuio_interface.h file from ("[v5] windows/netuio: add Windows NetUIO > kernel driver") series and this will be fixed once the exact path for net= uio > source code is known. >=20 > v7 changes: > Removed device property key from pci_netuio.c as Numa detection > is done only in pci.c file > v6 changes: > - Split up the get_netuio_device_info() function into smaller > functions > - Moved get numa node id code to get_device_resource_info() in > order to work on both RTE_PCI_KDRV_NONE and > RTE_PCI_KDRV_NIC_UIO > v5 changes: > Changed when netuio driver handle is closed > v4 changes: > Removed 'reserved' member as it is not used > v3 changes: > Removed the casts > v2 changes: > - Moved all netuio specific definitions and functions to > pci_netuio.c and pci_netuio.h files > - Added a single function call to scan all the devices >=20 > Signed-off-by: John Alexander > Signed-off-by: Pallavi Kadam > Reviewed-by: Ranjit Menon > --- > drivers/bus/pci/meson.build | 3 +- > drivers/bus/pci/windows/pci.c | 73 +++++++---- > drivers/bus/pci/windows/pci_netuio.c | 182 > +++++++++++++++++++++++++++ drivers/bus/pci/windows/pci_netuio.h | > 59 +++++++++ > 4 files changed, 289 insertions(+), 28 deletions(-) create mode 100644 > drivers/bus/pci/windows/pci_netuio.c > create mode 100644 drivers/bus/pci/windows/pci_netuio.h >=20 > diff --git a/drivers/bus/pci/meson.build b/drivers/bus/pci/meson.build in= dex > b649a17c2..977800495 100644 > --- a/drivers/bus/pci/meson.build > +++ b/drivers/bus/pci/meson.build > @@ -18,7 +18,8 @@ if is_freebsd > includes +=3D include_directories('bsd') endif if is_windows > - sources +=3D files('windows/pci.c') > + sources +=3D files('windows/pci.c', > + 'windows/pci_netuio.c') > includes +=3D include_directories('windows') endif >=20 > diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.= c > index 9e5c8fafb..30f218cc4 100644 > --- a/drivers/bus/pci/windows/pci.c > +++ b/drivers/bus/pci/windows/pci.c > @@ -4,10 +4,10 @@ > #include > #include > #include > -#include > #include >=20 > #include "private.h" > +#include "pci_netuio.h" >=20 > #include >=20 > @@ -209,25 +209,27 @@ get_device_resource_info(HDEVINFO dev_info, > DEVPROPTYPE property_type; > DWORD numa_node; > BOOL res; > + int ret; >=20 > switch (dev->kdrv) { > case RTE_PCI_KDRV_NONE: > - /* Get NUMA node using DEVPKEY_Device_Numa_Node */ > - res =3D SetupDiGetDevicePropertyW(dev_info, dev_info_data= , > - &DEVPKEY_Device_Numa_Node, &property_type, > - (BYTE *)&numa_node, sizeof(numa_node), NULL, 0); > - if (!res) { > - RTE_LOG_WIN32_ERR( > - "SetupDiGetDevicePropertyW" > - "(DEVPKEY_Device_Numa_Node)"); > - return -1; > - } > - dev->device.numa_node =3D numa_node; > /* mem_resource - Unneeded for RTE_PCI_KDRV_NONE */ > dev->mem_resource[0].phys_addr =3D 0; > dev->mem_resource[0].len =3D 0; > dev->mem_resource[0].addr =3D NULL; > break; > + case RTE_PCI_KDRV_NIC_UIO: > + /* get device info from netuio kernel driver */ > + ret =3D get_netuio_device_info(dev_info, dev_info_data, d= ev); > + if (ret !=3D 0) { > + RTE_LOG(DEBUG, EAL, > + "Could not retrieve device info for PCI d= evice " > + PCI_PRI_FMT, > + dev->addr.domain, dev->addr.bus, > + dev->addr.devid, dev->addr.function); > + return ret; > + } > + break; > default: > /* kernel driver type is unsupported */ > RTE_LOG(DEBUG, EAL, > @@ -238,6 +240,17 @@ get_device_resource_info(HDEVINFO dev_info, > return -1; > } >=20 > + /* Get NUMA node using DEVPKEY_Device_Numa_Node */ > + res =3D SetupDiGetDevicePropertyW(dev_info, dev_info_data, > + &DEVPKEY_Device_Numa_Node, &property_type, > + (BYTE *)&numa_node, sizeof(numa_node), NULL, 0); > + if (!res) { > + RTE_LOG_WIN32_ERR("SetupDiGetDevicePropertyW" > + "(DEVPKEY_Device_Numa_Node)"); > + return -1; > + } > + dev->device.numa_node =3D numa_node; > + > return ERROR_SUCCESS; > } >=20 > @@ -286,13 +299,14 @@ parse_pci_hardware_id(const char *buf, struct > rte_pci_id *pci_id) } >=20 > static void > -get_kernel_driver_type(struct rte_pci_device *dev) > +set_kernel_driver_type(PSP_DEVINFO_DATA device_info_data, > + struct rte_pci_device *dev) > { > - /* > - * If another kernel driver is supported the relevant checking > - * functions should be here > - */ > - dev->kdrv =3D RTE_PCI_KDRV_NONE; > + /* set kernel driver type based on device class */ > + if (IsEqualGUID(&(device_info_data->ClassGuid), > &GUID_DEVCLASS_NETUIO)) > + dev->kdrv =3D RTE_PCI_KDRV_NIC_UIO; > + else > + dev->kdrv =3D RTE_PCI_KDRV_NONE; > } >=20 > static int > @@ -335,7 +349,7 @@ pci_scan_one(HDEVINFO dev_info, > PSP_DEVINFO_DATA device_info_data) >=20 > pci_name_set(dev); >=20 > - get_kernel_driver_type(dev); > + set_kernel_driver_type(device_info_data, dev); >=20 > /* get resources */ > if (get_device_resource_info(dev_info, device_info_data, dev) @@ = - > 391,8 +405,8 @@ rte_pci_scan(void) > if (!rte_eal_has_pci()) > return 0; >=20 > - dev_info =3D SetupDiGetClassDevs(&GUID_DEVCLASS_NET, TEXT("PCI"), > NULL, > - DIGCF_PRESENT); > + dev_info =3D SetupDiGetClassDevs(NULL, TEXT("PCI"), NULL, > + DIGCF_PRESENT | DIGCF_ALLCLASSES); > if (dev_info =3D=3D INVALID_HANDLE_VALUE) { > RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(pci_scan)"); > RTE_LOG(ERR, EAL, "Unable to enumerate PCI devices.\n"); = @@ - > 405,12 +419,17 @@ rte_pci_scan(void) > while (SetupDiEnumDeviceInfo(dev_info, device_index, > &device_info_data)) { > device_index++; > - ret =3D pci_scan_one(dev_info, &device_info_data); > - if (ret =3D=3D ERROR_SUCCESS) > - found_device++; > - else if (ret !=3D ERROR_CONTINUE) > - goto end; > - > + /* we only want to enumerate net & netuio class devices *= / > + if (IsEqualGUID(&(device_info_data.ClassGuid), > + &GUID_DEVCLASS_NET) || > + IsEqualGUID(&(device_info_data.ClassGuid), > + &GUID_DEVCLASS_NETUIO)) { > + ret =3D pci_scan_one(dev_info, &device_info_data)= ; > + if (ret =3D=3D ERROR_SUCCESS) > + found_device++; > + else if (ret !=3D ERROR_CONTINUE) > + goto end; > + } > memset(&device_info_data, 0, sizeof(SP_DEVINFO_DATA)); > device_info_data.cbSize =3D sizeof(SP_DEVINFO_DATA); > } > diff --git a/drivers/bus/pci/windows/pci_netuio.c > b/drivers/bus/pci/windows/pci_netuio.c > new file mode 100644 > index 000000000..670194839 > --- /dev/null > +++ b/drivers/bus/pci/windows/pci_netuio.c > @@ -0,0 +1,182 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2020 Intel Corporation. > + */ > + > +#include > +#include > +#include > +#include > + > +#include "private.h" > +#include "pci_netuio.h" > + > +static int > +send_ioctl(HANDLE f, DWORD ioctl, > + void *in_buf, DWORD in_buf_size, void *out_buf, DWORD > +out_buf_size) { > + BOOL res; > + DWORD bytes_ret =3D 0; > + > + res =3D DeviceIoControl(f, ioctl, in_buf, in_buf_size, > + out_buf, out_buf_size, &bytes_ret, NULL); > + if (!res) { > + RTE_LOG_WIN32_ERR("DeviceIoControl:IOCTL query failed"); > + return -1; > + } > + > + return ERROR_SUCCESS; > +} > + > +static HDEVINFO > +get_netuio_device_information_set(HDEVINFO dev_info, > + PSP_DEVINFO_DATA dev_info_data) > +{ > + BOOL res; > + DWORD required_size =3D 0; > + TCHAR dev_instance_id[MAX_DEVICENAME_SZ]; > + HDEVINFO di_set =3D INVALID_HANDLE_VALUE; > + > + /* obtain the driver interface for this device */ > + res =3D SetupDiGetDeviceInstanceId(dev_info, dev_info_data, > + dev_instance_id, sizeof(dev_instance_id), &required_size)= ; > + if (!res) { > + RTE_LOG_WIN32_ERR("SetupDiGetDeviceInstanceId"); > + goto end; > + } > + > + /* return the device information set for this device */ > + di_set =3D SetupDiGetClassDevs(&GUID_DEVINTERFACE_NETUIO, > + dev_instance_id, NULL, DIGCF_PRESENT | > DIGCF_DEVICEINTERFACE); > + if (di_set =3D=3D INVALID_HANDLE_VALUE) { > + RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(device information > set)"); > + goto end; > + } > +end: > + return di_set; > +} > + > +static PSP_DEVICE_INTERFACE_DETAIL_DATA > +get_netuio_device_interface_detail(HDEVINFO di_set) { > + BOOL res; > + DWORD required_size =3D 0; > + SP_DEVICE_INTERFACE_DATA dev_ifx_data =3D { 0 }; > + PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail =3D NULL; > + > + dev_ifx_data.cbSize =3D sizeof(SP_DEVICE_INTERFACE_DATA); > + > + /* enumerate the netUIO interfaces for this device information se= t */ > + res =3D SetupDiEnumDeviceInterfaces(di_set, 0, > &GUID_DEVINTERFACE_NETUIO, > + 0, &dev_ifx_data); > + if (!res) { > + RTE_LOG_WIN32_ERR("SetupDiEnumDeviceInterfaces: no device > interface"); > + goto end; > + } > + > + /* request and allocate required size for the device interface de= tail */ > + required_size =3D 0; > + res =3D SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data, NU= LL, 0, > + &required_size, NULL); > + if (!res) { > + /* ERROR_INSUFFICIENT_BUFFER is expected */ > + if (GetLastError() !=3D ERROR_INSUFFICIENT_BUFFER) { > + RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetai= l"); > + goto end; > + } > + } > + > + dev_ifx_detail =3D malloc(required_size); > + if (!dev_ifx_detail) { > + RTE_LOG(ERR, EAL, "Could not allocate memory for dev > interface.\n"); > + goto end; > + } > + dev_ifx_detail->cbSize =3D > + sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); > + > + res =3D SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data, > + dev_ifx_detail, required_size, NULL, NULL); > + if (!res) { > + RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail"); > + free(dev_ifx_detail); > + dev_ifx_detail =3D NULL; > + goto end; > + } > + > +end: > + return dev_ifx_detail; > +} > + > +/* > + * get device resource information by sending ioctl to netuio driver > +*/ int get_netuio_device_info(HDEVINFO dev_info, PSP_DEVINFO_DATA > +dev_info_data, > + struct rte_pci_device *dev) > +{ > + int ret =3D -1; > + HDEVINFO di_set =3D INVALID_HANDLE_VALUE; > + PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail =3D NULL; > + HANDLE netuio =3D INVALID_HANDLE_VALUE; > + struct device_info hw_info =3D { 0 }; > + unsigned int idx; > + > + /* obtain the device information set for this device */ > + di_set =3D get_netuio_device_information_set(dev_info, dev_info_d= ata); > + if (di_set =3D=3D INVALID_HANDLE_VALUE) > + goto end; > + > + /* obtain the device interface detail for this device */ > + dev_ifx_detail =3D get_netuio_device_interface_detail(di_set); > + if (!dev_ifx_detail) > + goto end; > + > + /* open the kernel driver */ > + netuio =3D CreateFile(dev_ifx_detail->DevicePath, > + GENERIC_READ | GENERIC_WRITE, > + FILE_SHARE_READ | FILE_SHARE_WRITE, > + NULL, > + OPEN_EXISTING, > + FILE_ATTRIBUTE_NORMAL, > + NULL); > + if (netuio =3D=3D INVALID_HANDLE_VALUE) { > + RTE_LOG_WIN32_ERR("CreateFile"); > + RTE_LOG(ERR, EAL, "Unable to open driver file \"%s\".\n", > + dev_ifx_detail->DevicePath); > + goto end; > + } > + > + /* send ioctl to retrieve device information */ > + if (send_ioctl(netuio, IOCTL_NETUIO_MAP_HW_INTO_USERSPACE, > NULL, 0, > + &hw_info, sizeof(hw_info)) !=3D ERROR_SUCCESS) { > + RTE_LOG(ERR, EAL, "Unable to send ioctl to driver.\n"); > + goto end; > + } > + > + /* set relevant values into the dev structure */ > + for (idx =3D 0; idx < PCI_MAX_RESOURCE; idx++) { > + dev->mem_resource[idx].phys_addr =3D > + hw_info.hw[idx].phys_addr.QuadPart; > + dev->mem_resource[idx].addr =3D > + hw_info.hw[idx].user_mapped_virt_addr; > + dev->mem_resource[idx].len =3D hw_info.hw[idx].size; > + } > + > + ret =3D ERROR_SUCCESS; > +end: > + if (ret !=3D ERROR_SUCCESS) { > + /* Only close the handle to the driver in case of an erro= r. > + * Otherwise, we want to keep the handle open. Closing it > + * here will cause the driver to unmap all the process-ma= pped > + * values resulting in invalid addresses. > + */ > + if (netuio !=3D INVALID_HANDLE_VALUE) > + CloseHandle(netuio); > + } > + > + if (dev_ifx_detail) > + free(dev_ifx_detail); > + > + if (di_set !=3D INVALID_HANDLE_VALUE) > + SetupDiDestroyDeviceInfoList(di_set); > + > + return ret; > +} > diff --git a/drivers/bus/pci/windows/pci_netuio.h > b/drivers/bus/pci/windows/pci_netuio.h > new file mode 100644 > index 000000000..9a77806b5 > --- /dev/null > +++ b/drivers/bus/pci/windows/pci_netuio.h > @@ -0,0 +1,59 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2020 Intel Corporation > + */ > + > +#ifndef _PCI_NETUIO_H_ > +#define _PCI_NETUIO_H_ > + > +/* GUID definition for device class netUIO */ > +DEFINE_GUID(GUID_DEVCLASS_NETUIO, 0x78912bc1, 0xcb8e, 0x4b28, > + 0xa3, 0x29, 0xf3, 0x22, 0xeb, 0xad, 0xbe, 0x0f); > + > +/* GUID definition for the netuio device interface */ > +DEFINE_GUID(GUID_DEVINTERFACE_NETUIO, 0x08336f60, 0x0679, 0x4c6c, > + 0x85, 0xd2, 0xae, 0x7c, 0xed, 0x65, 0xff, 0xf7); > + > +/* IOCTL code definitions */ > +#define IOCTL_NETUIO_MAP_HW_INTO_USERSPACE \ > + CTL_CODE(FILE_DEVICE_NETWORK, 51, METHOD_BUFFERED, \ > + FILE_READ_ACCESS | FILE_WRITE_ACCESS) > + > +#define MAX_DEVICENAME_SZ 255 > + > +#pragma pack(push) > +#pragma pack(8) > +struct mem_region { > + UINT64 size; /* memory region size */ > + LARGE_INTEGER phys_addr; /* physical address of the memory regio= n > */ > + PVOID virt_addr; /* virtual address of the memory region */ > + PVOID user_mapped_virt_addr; /* virtual address of the region > mapped */ > + /* into user process context */ > +}; > + > +#define PCI_MAX_BAR 6 > + > +struct device_info { > + struct mem_region hw[PCI_MAX_BAR]; }; #pragma pack(pop) > + > +/** > + * Get device resource information by sending ioctl to netuio driver > + * > + * This function is private to EAL. > + * > + * @param dev_info > + * HDEVINFO handle to device information set > + * @param dev_info_data > + * SP_DEVINFO_DATA structure holding information about this > enumerated device > + * @param dev > + * PCI device context for this device > + * @return > + * - 0 on success. > + * - negative on error. > + */ > +int > +get_netuio_device_info(HDEVINFO dev_info, PSP_DEVINFO_DATA > dev_info_data, > + struct rte_pci_device *dev); > + > +#endif /* _PCI_NETUIO_H_ */ > -- > 2.18.0.windows.1 Reviewed-by: Tal Shnaiderman