* [dpdk-dev] [PATCH] bus/pci: netuio interface for windows
@ 2020-09-11 1:59 Pallavi Kadam
2020-09-13 18:42 ` Tal Shnaiderman
2020-09-15 23:28 ` [dpdk-dev] [PATCH v2] " Pallavi Kadam
0 siblings, 2 replies; 20+ messages in thread
From: Pallavi Kadam @ 2020-09-11 1:59 UTC (permalink / raw)
To: dev, thomas
Cc: ranjit.menon, dmitry.kozliuk, Narcisa.Vasile, talshn, pallavi.kadam
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.
Note: Few definitions and structures have been copied from
netuio_interface.h file from
("[v3] windows/netuio: add Windows NetUIO kernel driver") series
and this will be fixed once the exact path for netuio source code is known.
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
---
drivers/bus/pci/windows/pci.c | 293 +++++++++++++++++++++++++++++-----
1 file changed, 257 insertions(+), 36 deletions(-)
diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index c80bd5571..38db87a2a 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -17,6 +17,42 @@ DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node, 0x540b947e, 0x8b40, 0x45bc,
0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 3);
#endif
+/* 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_USERMODE \
+ CTL_CODE(FILE_DEVICE_NETWORK, 51, METHOD_BUFFERED, \
+ FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+
+#define MAX_DEVICENAME_SZ 255
+
+static const char netuio_class[] = "netuio class";
+static const char net_class[] = "net class";
+
+#pragma pack(push)
+#pragma pack(8)
+struct mem_region {
+ UINT64 size; /* memory region size */
+ LARGE_INTEGER phys_addr; /* physical address of the memory region */
+ 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];
+ USHORT reserved;
+};
+#pragma pack(pop)
+
/*
* This code is used to simulate a PCI probe by parsing information in
* the registry hive for PCI devices.
@@ -172,34 +208,148 @@ pci_uio_remap_resource(struct rte_pci_device *dev __rte_unused)
}
static int
-get_device_pci_address(HDEVINFO dev_info,
- PSP_DEVINFO_DATA device_info_data, struct rte_pci_addr *addr)
+send_ioctl(HANDLE f, DWORD ioctl,
+ void *in_buf, DWORD in_buf_size, void *out_buf, DWORD out_buf_size)
{
- BOOL res;
- ULONG bus_num, dev_and_func;
+ BOOL res;
+ DWORD bytes_ret = 0;
- res = SetupDiGetDeviceRegistryProperty(dev_info, device_info_data,
- SPDRP_BUSNUMBER, NULL, (PBYTE)&bus_num, sizeof(bus_num), NULL);
+ res = DeviceIoControl(f, ioctl, in_buf, in_buf_size,
+ out_buf, out_buf_size, &bytes_ret, NULL);
if (!res) {
- RTE_LOG_WIN32_ERR(
- "SetupDiGetDeviceRegistryProperty(SPDRP_BUSNUMBER)");
+ RTE_LOG_WIN32_ERR("DeviceIoControl:IOCTL query failed");
return -1;
}
- res = SetupDiGetDeviceRegistryProperty(dev_info, device_info_data,
- SPDRP_ADDRESS, NULL, (PBYTE)&dev_and_func, sizeof(dev_and_func),
+ return ERROR_SUCCESS;
+}
+
+/*
+ * get device resource information by sending ioctl to netuio driver
+ */
+static int
+get_netuio_device_info(HDEVINFO dev_info, PSP_DEVINFO_DATA dev_info_data,
+ struct rte_pci_device *dev)
+{
+ int ret = -1;
+ BOOL res;
+ DWORD required_size = 0;
+ TCHAR dev_instance_id[MAX_DEVICENAME_SZ];
+ HANDLE netuio = INVALID_HANDLE_VALUE;
+ HDEVINFO di_set = INVALID_HANDLE_VALUE;
+ SP_DEVICE_INTERFACE_DATA dev_ifx_data = { 0 };
+ PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail = NULL;
+ struct device_info hw_info = { 0 };
+ unsigned int idx;
+ DEVPROPTYPE property_type;
+ DWORD numa_node;
+
+ /* obtain the driver interface for this device */
+ res = SetupDiGetDeviceInstanceId(dev_info, dev_info_data,
+ dev_instance_id, sizeof(dev_instance_id), &required_size);
+ if (!res) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInstanceId");
+ return -1;
+ }
+
+ /* obtain the device information set */
+ di_set = SetupDiGetClassDevs(&GUID_DEVINTERFACE_NETUIO, dev_instance_id,
+ NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+ if (di_set == INVALID_HANDLE_VALUE) {
+ RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(device information set)");
+ return -1;
+ }
+
+ dev_ifx_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
+
+ /* enumerate the netUIO interfaces for this device information set */
+ res = 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 detail */
+ required_size = 0;
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data, NULL, 0,
+ &required_size, NULL);
+ if (!res) {
+ /* ERROR_INSUFFICIENT_BUFFER is expected */
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+ }
+
+ dev_ifx_detail = 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 = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
+
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data,
+ dev_ifx_detail, required_size, NULL, NULL);
+ if (!res) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+
+ /* open the kernel driver */
+ netuio = CreateFile(dev_ifx_detail->DevicePath,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
NULL);
+ if (netuio == 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_USERMODE, NULL, 0,
+ &hw_info, sizeof(hw_info)) != ERROR_SUCCESS) {
+ RTE_LOG(ERR, EAL, "Unable to send ioctl to driver.\n");
+ goto end;
+ }
+
+ /* set relevant values into the dev structure */
+ for (idx = 0; idx < PCI_MAX_RESOURCE; idx++) {
+ dev->mem_resource[idx].phys_addr =
+ hw_info.hw[idx].phys_addr.QuadPart;
+ dev->mem_resource[idx].addr =
+ hw_info.hw[idx].user_mapped_virt_addr;
+ dev->mem_resource[idx].len = hw_info.hw[idx].size;
+ }
+
+ /* get NUMA node using DEVPKEY_Device_Numa_Node */
+ res = 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(
- "SetupDiGetDeviceRegistryProperty(SPDRP_ADDRESS)");
- return -1;
+ "SetupDiGetDevicePropertyW(DEVPKEY_Device_Numa_Node)");
+ goto end;
}
+ dev->device.numa_node = numa_node;
- addr->domain = 0;
- addr->bus = bus_num;
- addr->devid = dev_and_func >> 16;
- addr->function = dev_and_func & 0xffff;
- return 0;
+ ret = ERROR_SUCCESS;
+end:
+ if (netuio != INVALID_HANDLE_VALUE)
+ CloseHandle(netuio);
+
+ if (dev_ifx_detail)
+ free(dev_ifx_detail);
+
+ if (di_set != INVALID_HANDLE_VALUE)
+ SetupDiDestroyDeviceInfoList(di_set);
+
+ return ret;
}
static int
@@ -209,6 +359,7 @@ get_device_resource_info(HDEVINFO dev_info,
DEVPROPTYPE property_type;
DWORD numa_node;
BOOL res;
+ int ret;
switch (dev->kdrv) {
case RTE_KDRV_NONE:
@@ -228,6 +379,18 @@ get_device_resource_info(HDEVINFO dev_info,
dev->mem_resource[0].len = 0;
dev->mem_resource[0].addr = NULL;
break;
+ case RTE_KDRV_NIC_UIO:
+ /* get device info from netuio kernel driver */
+ ret = get_netuio_device_info(dev_info, dev_info_data, dev);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL,
+ "Could not retrieve device info for PCI device "
+ 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,
@@ -274,7 +437,7 @@ parse_pci_hardware_id(const char *buf, struct rte_pci_id *pci_id)
uint32_t subvendor_id = 0;
ids = sscanf_s(buf, "PCI\\VEN_%" PRIx16 "&DEV_%" PRIx16 "&SUBSYS_%"
- PRIx32, &vendor_id, &device_id, &subvendor_id);
+ PRIx32, &vendor_id, &device_id, &subvendor_id);
if (ids != 3)
return -1;
@@ -286,13 +449,46 @@ parse_pci_hardware_id(const char *buf, struct rte_pci_id *pci_id)
}
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 = RTE_KDRV_NONE;
+ /* set kernel driver type based on device class */
+ if (IsEqualGUID((const void *)&(device_info_data->ClassGuid),
+ (const void *)&GUID_DEVCLASS_NETUIO))
+ dev->kdrv = RTE_KDRV_NIC_UIO;
+ else
+ dev->kdrv = RTE_KDRV_NONE;
+}
+
+static int
+get_device_pci_address(HDEVINFO dev_info,
+ PSP_DEVINFO_DATA device_info_data, struct rte_pci_addr *addr)
+{
+ BOOL res;
+ ULONG bus_num, dev_and_func;
+
+ res = SetupDiGetDeviceRegistryProperty(dev_info, device_info_data,
+ SPDRP_BUSNUMBER, NULL, (PBYTE)&bus_num, sizeof(bus_num), NULL);
+ if (!res) {
+ RTE_LOG_WIN32_ERR(
+ "SetupDiGetDeviceRegistryProperty(SPDRP_BUSNUMBER)");
+ return -1;
+ }
+
+ res = SetupDiGetDeviceRegistryProperty(dev_info, device_info_data,
+ SPDRP_ADDRESS, NULL, (PBYTE)&dev_and_func, sizeof(dev_and_func),
+ NULL);
+ if (!res) {
+ RTE_LOG_WIN32_ERR(
+ "SetupDiGetDeviceRegistryProperty(SPDRP_ADDRESS)");
+ return -1;
+ }
+
+ addr->domain = 0;
+ addr->bus = bus_num;
+ addr->devid = dev_and_func >> 16;
+ addr->function = dev_and_func & 0xffff;
+ return 0;
}
static int
@@ -335,7 +531,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
pci_name_set(dev);
- get_kernel_driver_type(dev);
+ set_kernel_driver_type(device_info_data, dev);
/* get resources */
if (get_device_resource_info(dev_info, device_info_data, dev)
@@ -376,26 +572,29 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
}
/*
- * Scan the contents of the PCI bus
- * and add all network class devices into the devices list.
+ * Scan for devices in specified device class
+ * and add them into the devices list.
*/
-int
-rte_pci_scan(void)
+static int
+pci_scan_device_class(const GUID *guid)
{
int ret = -1;
DWORD device_index = 0, found_device = 0;
HDEVINFO dev_info;
SP_DEVINFO_DATA device_info_data;
+ const char *class;
- /* for debug purposes, PCI can be disabled */
- if (!rte_eal_has_pci())
- return 0;
+ if (IsEqualGUID((const void *)guid,
+ (const void *)&GUID_DEVCLASS_NETUIO))
+ class = netuio_class;
+ else
+ class = net_class;
- dev_info = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, TEXT("PCI"), NULL,
- DIGCF_PRESENT);
+ dev_info = SetupDiGetClassDevs(guid, TEXT("PCI"), NULL, DIGCF_PRESENT);
if (dev_info == INVALID_HANDLE_VALUE) {
RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(pci_scan)");
- RTE_LOG(ERR, EAL, "Unable to enumerate PCI devices.\n");
+ RTE_LOG(ERR, EAL, "Unable to enumerate %s PCI devices.\n",
+ class);
goto end;
}
@@ -415,7 +614,8 @@ rte_pci_scan(void)
device_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
}
- RTE_LOG(DEBUG, EAL, "PCI scan found %lu devices\n", found_device);
+ RTE_LOG(DEBUG, EAL, "PCI scan found %lu %s devices\n",
+ found_device, class);
ret = 0;
end:
if (dev_info != INVALID_HANDLE_VALUE)
@@ -423,3 +623,24 @@ rte_pci_scan(void)
return ret;
}
+
+/*
+ * Scan the contents of the PCI bus looking for devices
+ */
+int
+rte_pci_scan(void)
+{
+ int ret = -1;
+
+ /* for debug purposes, PCI can be disabled */
+ if (!rte_eal_has_pci())
+ return 0;
+
+ /* first, scan for netUIO class devices */
+ ret = pci_scan_device_class(&GUID_DEVCLASS_NETUIO);
+
+ /* then, scan for the standard net class devices */
+ ret = pci_scan_device_class(&GUID_DEVCLASS_NET);
+
+ return ret;
+}
--
2.18.0.windows.1
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH] bus/pci: netuio interface for windows
2020-09-11 1:59 [dpdk-dev] [PATCH] bus/pci: netuio interface for windows Pallavi Kadam
@ 2020-09-13 18:42 ` Tal Shnaiderman
2020-09-15 20:13 ` Ranjit Menon
2020-09-15 23:28 ` [dpdk-dev] [PATCH v2] " Pallavi Kadam
1 sibling, 1 reply; 20+ messages in thread
From: Tal Shnaiderman @ 2020-09-13 18:42 UTC (permalink / raw)
To: Pallavi Kadam, dev, NBU-Contact-Thomas Monjalon
Cc: ranjit.menon, dmitry.kozliuk, Narcisa.Vasile
> Subject: [PATCH] bus/pci: netuio interface for windows
>
> 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.
>
> Note: Few definitions and structures have been copied from
> netuio_interface.h file from ("[v3] windows/netuio: add Windows NetUIO
> kernel driver") series and this will be fixed once the exact path for netuio
> source code is known.
>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
> drivers/bus/pci/windows/pci.c | 293 +++++++++++++++++++++++++++++--
> ---
> 1 file changed, 257 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
> index c80bd5571..38db87a2a 100644
> --- a/drivers/bus/pci/windows/pci.c
> +++ b/drivers/bus/pci/windows/pci.c
I think it will be better to split the pci implementation into 2 files and add pci_netuio.c
(similarly to Linux with pci_uio.c and pci_vfio.c), moving all of the netuio-specific definitions and functions in this patch to the new file.
[snip]
> -int
> -rte_pci_scan(void)
> +static int
> +pci_scan_device_class(const GUID *guid)
> {
> int ret = -1;
> DWORD device_index = 0, found_device = 0;
> HDEVINFO dev_info;
> SP_DEVINFO_DATA device_info_data;
> + const char *class;
>
> - /* for debug purposes, PCI can be disabled */
> - if (!rte_eal_has_pci())
> - return 0;
> + if (IsEqualGUID((const void *)guid,
> + (const void *)&GUID_DEVCLASS_NETUIO))
> + class = netuio_class;
> + else
> + class = net_class;
>
> - dev_info = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, TEXT("PCI"),
> NULL,
> - DIGCF_PRESENT);
> + dev_info = SetupDiGetClassDevs(guid, TEXT("PCI"), NULL,
> + DIGCF_PRESENT);
Is there a way to get both GUID_DEVCLASS_NET and GUID_DEVCLASS_NETUIO in a single call here?
We could avoid calling this function twice if we could get all of the devices.
> if (dev_info == INVALID_HANDLE_VALUE) {
> RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(pci_scan)");
> - RTE_LOG(ERR, EAL, "Unable to enumerate PCI devices.\n");
> + RTE_LOG(ERR, EAL, "Unable to enumerate %s PCI devices.\n",
> + class);
> goto end;
> }
>
> @@ -415,7 +614,8 @@ rte_pci_scan(void)
> device_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
> }
>
> - RTE_LOG(DEBUG, EAL, "PCI scan found %lu devices\n", found_device);
> + RTE_LOG(DEBUG, EAL, "PCI scan found %lu %s devices\n",
> + found_device, class);
> ret = 0;
> end:
> if (dev_info != INVALID_HANDLE_VALUE) @@ -423,3 +623,24 @@
> rte_pci_scan(void)
>
> return ret;
> }
> +
> +/*
> + * Scan the contents of the PCI bus looking for devices */ int
> +rte_pci_scan(void)
> +{
> + int ret = -1;
> +
> + /* for debug purposes, PCI can be disabled */
> + if (!rte_eal_has_pci())
> + return 0;
> +
> + /* first, scan for netUIO class devices */
> + ret = pci_scan_device_class(&GUID_DEVCLASS_NETUIO);
ret is overwritten later on.
> +
> + /* then, scan for the standard net class devices */
> + ret = pci_scan_device_class(&GUID_DEVCLASS_NET);
> +
> + return ret;
> +}
> --
> 2.18.0.windows.1
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH] bus/pci: netuio interface for windows
2020-09-13 18:42 ` Tal Shnaiderman
@ 2020-09-15 20:13 ` Ranjit Menon
0 siblings, 0 replies; 20+ messages in thread
From: Ranjit Menon @ 2020-09-15 20:13 UTC (permalink / raw)
To: Tal Shnaiderman, Pallavi Kadam, dev, NBU-Contact-Thomas Monjalon
Cc: dmitry.kozliuk, Narcisa.Vasile
Hi, Tal
On 9/13/2020 11:42 AM, Tal Shnaiderman wrote:
>> Subject: [PATCH] bus/pci: netuio interface for windows
>>
>> 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.
>>
>> Note: Few definitions and structures have been copied from
>> netuio_interface.h file from ("[v3] windows/netuio: add Windows NetUIO
>> kernel driver") series and this will be fixed once the exact path for netuio
>> source code is known.
>>
>> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
>> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
>> ---
>> drivers/bus/pci/windows/pci.c | 293 +++++++++++++++++++++++++++++--
>> ---
>> 1 file changed, 257 insertions(+), 36 deletions(-)
>>
>> diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
>> index c80bd5571..38db87a2a 100644
>> --- a/drivers/bus/pci/windows/pci.c
>> +++ b/drivers/bus/pci/windows/pci.c
> I think it will be better to split the pci implementation into 2 files and add pci_netuio.c
> (similarly to Linux with pci_uio.c and pci_vfio.c), moving all of the netuio-specific definitions and functions in this patch to the new file.
>
> [snip]
I think this is a good suggestion. We'll work on this in V2.
>> -int
>> -rte_pci_scan(void)
>> +static int
>> +pci_scan_device_class(const GUID *guid)
>> {
>> int ret = -1;
>> DWORD device_index = 0, found_device = 0;
>> HDEVINFO dev_info;
>> SP_DEVINFO_DATA device_info_data;
>> + const char *class;
>>
>> - /* for debug purposes, PCI can be disabled */
>> - if (!rte_eal_has_pci())
>> - return 0;
>> + if (IsEqualGUID((const void *)guid,
>> + (const void *)&GUID_DEVCLASS_NETUIO))
>> + class = netuio_class;
>> + else
>> + class = net_class;
>>
>> - dev_info = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, TEXT("PCI"),
>> NULL,
>> - DIGCF_PRESENT);
>> + dev_info = SetupDiGetClassDevs(guid, TEXT("PCI"), NULL,
>> + DIGCF_PRESENT);
> Is there a way to get both GUID_DEVCLASS_NET and GUID_DEVCLASS_NETUIO in a single call here?
> We could avoid calling this function twice if we could get all of the devices.
Yes. I think we have a way to make it work so that we can avoid calling
this function twice.
We can scan for all device classes and then only filter out net and
netuio class devices.
>> if (dev_info == INVALID_HANDLE_VALUE) {
>> RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(pci_scan)");
>> - RTE_LOG(ERR, EAL, "Unable to enumerate PCI devices.\n");
>> + RTE_LOG(ERR, EAL, "Unable to enumerate %s PCI devices.\n",
>> + class);
>> goto end;
>> }
>>
>> @@ -415,7 +614,8 @@ rte_pci_scan(void)
>> device_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
>> }
>>
>> - RTE_LOG(DEBUG, EAL, "PCI scan found %lu devices\n", found_device);
>> + RTE_LOG(DEBUG, EAL, "PCI scan found %lu %s devices\n",
>> + found_device, class);
>> ret = 0;
>> end:
>> if (dev_info != INVALID_HANDLE_VALUE) @@ -423,3 +623,24 @@
>> rte_pci_scan(void)
>>
>> return ret;
>> }
>> +
>> +/*
>> + * Scan the contents of the PCI bus looking for devices */ int
>> +rte_pci_scan(void)
>> +{
>> + int ret = -1;
>> +
>> + /* for debug purposes, PCI can be disabled */
>> + if (!rte_eal_has_pci())
>> + return 0;
>> +
>> + /* first, scan for netUIO class devices */
>> + ret = pci_scan_device_class(&GUID_DEVCLASS_NETUIO);
> ret is overwritten later on.
>
>> +
>> + /* then, scan for the standard net class devices */
>> + ret = pci_scan_device_class(&GUID_DEVCLASS_NET);
>> +
>> + return ret;
>> +}
>> --
>> 2.18.0.windows.1
> thanks,
ranjit m.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [dpdk-dev] [PATCH v2] bus/pci: netuio interface for windows
2020-09-11 1:59 [dpdk-dev] [PATCH] bus/pci: netuio interface for windows Pallavi Kadam
2020-09-13 18:42 ` Tal Shnaiderman
@ 2020-09-15 23:28 ` Pallavi Kadam
2020-09-16 1:54 ` Stephen Hemminger
2020-09-21 21:08 ` [dpdk-dev] [PATCH v3] " Pallavi Kadam
1 sibling, 2 replies; 20+ messages in thread
From: Pallavi Kadam @ 2020-09-15 23:28 UTC (permalink / raw)
To: dev, thomas
Cc: ranjit.menon, John.Alexander, dmitry.kozliuk, Narcisa.Vasile,
talshn, pallavi.kadam
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.
Note: Few definitions and structures have been copied from
netuio_interface.h file from
("[v3] windows/netuio: add Windows NetUIO kernel driver") series
and this will be fixed once the exact path for netuio source code is known.
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
Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
---
drivers/bus/pci/meson.build | 3 +-
drivers/bus/pci/windows/pci.c | 51 ++++++---
drivers/bus/pci/windows/pci_netuio.c | 165 +++++++++++++++++++++++++++
drivers/bus/pci/windows/pci_netuio.h | 60 ++++++++++
4 files changed, 263 insertions(+), 16 deletions(-)
create mode 100644 drivers/bus/pci/windows/pci_netuio.c
create mode 100644 drivers/bus/pci/windows/pci_netuio.h
diff --git a/drivers/bus/pci/meson.build b/drivers/bus/pci/meson.build
index b649a17c2..977800495 100644
--- a/drivers/bus/pci/meson.build
+++ b/drivers/bus/pci/meson.build
@@ -18,7 +18,8 @@ if is_freebsd
includes += include_directories('bsd')
endif
if is_windows
- sources += files('windows/pci.c')
+ sources += files('windows/pci.c',
+ 'windows/pci_netuio.c')
includes += include_directories('windows')
endif
diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index c80bd5571..28cdff373 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -8,6 +8,7 @@
#include <rte_eal.h>
#include "private.h"
+#include "pci_netuio.h"
#include <devpkey.h>
@@ -209,6 +210,7 @@ get_device_resource_info(HDEVINFO dev_info,
DEVPROPTYPE property_type;
DWORD numa_node;
BOOL res;
+ int ret;
switch (dev->kdrv) {
case RTE_KDRV_NONE:
@@ -228,6 +230,18 @@ get_device_resource_info(HDEVINFO dev_info,
dev->mem_resource[0].len = 0;
dev->mem_resource[0].addr = NULL;
break;
+ case RTE_KDRV_NIC_UIO:
+ /* get device info from netuio kernel driver */
+ ret = get_netuio_device_info(dev_info, dev_info_data, dev);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL,
+ "Could not retrieve device info for PCI device "
+ 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,
@@ -286,13 +300,15 @@ parse_pci_hardware_id(const char *buf, struct rte_pci_id *pci_id)
}
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 = RTE_KDRV_NONE;
+ /* set kernel driver type based on device class */
+ if (IsEqualGUID((const void *)&(device_info_data->ClassGuid),
+ (const void *)&GUID_DEVCLASS_NETUIO))
+ dev->kdrv = RTE_KDRV_NIC_UIO;
+ else
+ dev->kdrv = RTE_KDRV_NONE;
}
static int
@@ -335,7 +351,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
pci_name_set(dev);
- get_kernel_driver_type(dev);
+ set_kernel_driver_type(device_info_data, dev);
/* get resources */
if (get_device_resource_info(dev_info, device_info_data, dev)
@@ -391,8 +407,8 @@ rte_pci_scan(void)
if (!rte_eal_has_pci())
return 0;
- dev_info = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, TEXT("PCI"), NULL,
- DIGCF_PRESENT);
+ dev_info = SetupDiGetClassDevs(NULL, TEXT("PCI"), NULL,
+ DIGCF_PRESENT | DIGCF_ALLCLASSES);
if (dev_info == INVALID_HANDLE_VALUE) {
RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(pci_scan)");
RTE_LOG(ERR, EAL, "Unable to enumerate PCI devices.\n");
@@ -405,12 +421,17 @@ rte_pci_scan(void)
while (SetupDiEnumDeviceInfo(dev_info, device_index,
&device_info_data)) {
device_index++;
- ret = pci_scan_one(dev_info, &device_info_data);
- if (ret == ERROR_SUCCESS)
- found_device++;
- else if (ret != ERROR_CONTINUE)
- goto end;
-
+ /* we only want to enumerate netuio & net class devices */
+ if (IsEqualGUID((const void *)&(device_info_data.ClassGuid),
+ (const void *)&GUID_DEVCLASS_NETUIO) ||
+ IsEqualGUID((const void *)&(device_info_data.ClassGuid),
+ (const void *)&GUID_DEVCLASS_NET)) {
+ ret = pci_scan_one(dev_info, &device_info_data);
+ if (ret == ERROR_SUCCESS)
+ found_device++;
+ else if (ret != ERROR_CONTINUE)
+ goto end;
+ }
memset(&device_info_data, 0, sizeof(SP_DEVINFO_DATA));
device_info_data.cbSize = 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..d2cfa6ba2
--- /dev/null
+++ b/drivers/bus/pci/windows/pci_netuio.c
@@ -0,0 +1,165 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+
+#include <rte_windows.h>
+#include <rte_errno.h>
+#include <rte_log.h>
+#include <rte_eal_memconfig.h>
+#include <rte_eal.h>
+
+#include "private.h"
+#include "pci_netuio.h"
+
+#include <devpkey.h>
+
+#ifdef RTE_TOOLCHAIN_GCC
+#include <devpropdef.h>
+DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node, 0x540b947e, 0x8b40, 0x45bc,
+ 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 3);
+#endif
+
+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 = 0;
+
+ res = 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;
+}
+
+/*
+ * 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 = -1;
+ BOOL res;
+ DWORD required_size = 0;
+ TCHAR dev_instance_id[MAX_DEVICENAME_SZ];
+ HANDLE netuio = INVALID_HANDLE_VALUE;
+ HDEVINFO di_set = INVALID_HANDLE_VALUE;
+ SP_DEVICE_INTERFACE_DATA dev_ifx_data = { 0 };
+ PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail = NULL;
+ struct device_info hw_info = { 0 };
+ unsigned int idx;
+ DEVPROPTYPE property_type;
+ DWORD numa_node;
+
+ /* obtain the driver interface for this device */
+ res = SetupDiGetDeviceInstanceId(dev_info, dev_info_data,
+ dev_instance_id, sizeof(dev_instance_id), &required_size);
+ if (!res) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInstanceId");
+ return -1;
+ }
+
+ /* obtain the device information set */
+ di_set = SetupDiGetClassDevs(&GUID_DEVINTERFACE_NETUIO, dev_instance_id,
+ NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+ if (di_set == INVALID_HANDLE_VALUE) {
+ RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(device information set)");
+ return -1;
+ }
+
+ dev_ifx_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
+
+ /* enumerate the netUIO interfaces for this device information set */
+ res = 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 detail */
+ required_size = 0;
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data, NULL, 0,
+ &required_size, NULL);
+ if (!res) {
+ /* ERROR_INSUFFICIENT_BUFFER is expected */
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+ }
+
+ dev_ifx_detail = 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 = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
+
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data,
+ dev_ifx_detail, required_size, NULL, NULL);
+ if (!res) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+
+ /* open the kernel driver */
+ netuio = CreateFile(dev_ifx_detail->DevicePath,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (netuio == 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_USERMODE, NULL, 0,
+ &hw_info, sizeof(hw_info)) != ERROR_SUCCESS) {
+ RTE_LOG(ERR, EAL, "Unable to send ioctl to driver.\n");
+ goto end;
+ }
+
+ /* set relevant values into the dev structure */
+ for (idx = 0; idx < PCI_MAX_RESOURCE; idx++) {
+ dev->mem_resource[idx].phys_addr =
+ hw_info.hw[idx].phys_addr.QuadPart;
+ dev->mem_resource[idx].addr =
+ hw_info.hw[idx].user_mapped_virt_addr;
+ dev->mem_resource[idx].len = hw_info.hw[idx].size;
+ }
+
+ /* get NUMA node using DEVPKEY_Device_Numa_Node */
+ res = 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)");
+ goto end;
+ }
+ dev->device.numa_node = numa_node;
+
+ ret = ERROR_SUCCESS;
+end:
+ if (netuio != INVALID_HANDLE_VALUE)
+ CloseHandle(netuio);
+
+ if (dev_ifx_detail)
+ free(dev_ifx_detail);
+
+ if (di_set != 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..94a353a40
--- /dev/null
+++ b/drivers/bus/pci/windows/pci_netuio.h
@@ -0,0 +1,60 @@
+/* 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_USERMODE \
+ 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 region */
+ 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];
+ USHORT reserved;
+};
+#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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH v2] bus/pci: netuio interface for windows
2020-09-15 23:28 ` [dpdk-dev] [PATCH v2] " Pallavi Kadam
@ 2020-09-16 1:54 ` Stephen Hemminger
2020-09-17 0:48 ` Ranjit Menon
2020-09-21 21:08 ` [dpdk-dev] [PATCH v3] " Pallavi Kadam
1 sibling, 1 reply; 20+ messages in thread
From: Stephen Hemminger @ 2020-09-16 1:54 UTC (permalink / raw)
To: Pallavi Kadam
Cc: dev, thomas, ranjit.menon, John.Alexander, dmitry.kozliuk,
Narcisa.Vasile, talshn
On Tue, 15 Sep 2020 16:28:03 -0700
Pallavi Kadam <pallavi.kadam@intel.com> wrote:
> + if (IsEqualGUID((const void *)&(device_info_data->ClassGuid),
> + (const void *)&GUID_DEVCLASS_NETUIO))
Is there anyway to get rid of casts and have the right types?
Casts are evil
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH v2] bus/pci: netuio interface for windows
2020-09-16 1:54 ` Stephen Hemminger
@ 2020-09-17 0:48 ` Ranjit Menon
2020-09-17 1:20 ` Ranjit Menon
0 siblings, 1 reply; 20+ messages in thread
From: Ranjit Menon @ 2020-09-17 0:48 UTC (permalink / raw)
To: Stephen Hemminger, Pallavi Kadam
Cc: dev, thomas, John.Alexander, dmitry.kozliuk, Narcisa.Vasile, talshn
Hi, Stephen
On 9/15/2020 6:54 PM, Stephen Hemminger wrote:
> On Tue, 15 Sep 2020 16:28:03 -0700
> Pallavi Kadam <pallavi.kadam@intel.com> wrote:
>
>> + if (IsEqualGUID((const void *)&(device_info_data->ClassGuid),
>> + (const void *)&GUID_DEVCLASS_NETUIO))
> Is there anyway to get rid of casts and have the right types?
> Casts are evil
Unfortunately, this macro is defined inside the Windows SDK and it
simply calls the C library function memcmp() which expects a (void *).
Would something like this be acceptable?
const void *guid = &(device_info_data->ClassGuid);
const void *guid_netuio = &GUID_DEVCLASS_NETUIO;
if (IsEqualGUID(guid, guid_netuio)
....
ranjit m.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH v2] bus/pci: netuio interface for windows
2020-09-17 0:48 ` Ranjit Menon
@ 2020-09-17 1:20 ` Ranjit Menon
0 siblings, 0 replies; 20+ messages in thread
From: Ranjit Menon @ 2020-09-17 1:20 UTC (permalink / raw)
To: Stephen Hemminger, Pallavi Kadam
Cc: dev, thomas, John.Alexander, dmitry.kozliuk, Narcisa.Vasile, talshn
On 9/16/2020 5:48 PM, Ranjit Menon wrote:
> Hi, Stephen
>
> On 9/15/2020 6:54 PM, Stephen Hemminger wrote:
>> On Tue, 15 Sep 2020 16:28:03 -0700
>> Pallavi Kadam <pallavi.kadam@intel.com> wrote:
>>
>>> + if (IsEqualGUID((const void *)&(device_info_data->ClassGuid),
>>> + (const void *)&GUID_DEVCLASS_NETUIO))
>> Is there anyway to get rid of casts and have the right types?
>> Casts are evil
>
> Unfortunately, this macro is defined inside the Windows SDK and it
> simply calls the C library function memcmp() which expects a (void *).
>
> Would something like this be acceptable?
>
> const void *guid = &(device_info_data->ClassGuid);
>
> const void *guid_netuio = &GUID_DEVCLASS_NETUIO;
>
> if (IsEqualGUID(guid, guid_netuio)
>
> ....
Actually, ignore what I wrote above! It's a void * - it doesn't need a
cast.
We'll fix this in V3.
ranjit m.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [dpdk-dev] [PATCH v3] bus/pci: netuio interface for windows
2020-09-15 23:28 ` [dpdk-dev] [PATCH v2] " Pallavi Kadam
2020-09-16 1:54 ` Stephen Hemminger
@ 2020-09-21 21:08 ` Pallavi Kadam
2020-09-22 3:05 ` [dpdk-dev] [PATCH v4] " Pallavi Kadam
1 sibling, 1 reply; 20+ messages in thread
From: Pallavi Kadam @ 2020-09-21 21:08 UTC (permalink / raw)
To: dev, thomas
Cc: ranjit.menon, John.Alexander, dmitry.kozliuk, Narcisa.Vasile,
talshn, pallavi.kadam
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.
Note: Few definitions and structures have been copied from
netuio_interface.h file from
("[v3] windows/netuio: add Windows NetUIO kernel driver") series
and this will be fixed once the exact path for netuio source code is known.
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
Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
---
drivers/bus/pci/meson.build | 3 +-
drivers/bus/pci/windows/pci.c | 50 +++++---
drivers/bus/pci/windows/pci_netuio.c | 164 +++++++++++++++++++++++++++
drivers/bus/pci/windows/pci_netuio.h | 60 ++++++++++
4 files changed, 261 insertions(+), 16 deletions(-)
create mode 100644 drivers/bus/pci/windows/pci_netuio.c
create mode 100644 drivers/bus/pci/windows/pci_netuio.h
diff --git a/drivers/bus/pci/meson.build b/drivers/bus/pci/meson.build
index b649a17c2..977800495 100644
--- a/drivers/bus/pci/meson.build
+++ b/drivers/bus/pci/meson.build
@@ -18,7 +18,8 @@ if is_freebsd
includes += include_directories('bsd')
endif
if is_windows
- sources += files('windows/pci.c')
+ sources += files('windows/pci.c',
+ 'windows/pci_netuio.c')
includes += include_directories('windows')
endif
diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index 9e5c8fafb..d36212084 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -8,6 +8,7 @@
#include <rte_eal.h>
#include "private.h"
+#include "pci_netuio.h"
#include <devpkey.h>
@@ -209,6 +210,7 @@ get_device_resource_info(HDEVINFO dev_info,
DEVPROPTYPE property_type;
DWORD numa_node;
BOOL res;
+ int ret;
switch (dev->kdrv) {
case RTE_PCI_KDRV_NONE:
@@ -228,6 +230,18 @@ get_device_resource_info(HDEVINFO dev_info,
dev->mem_resource[0].len = 0;
dev->mem_resource[0].addr = NULL;
break;
+ case RTE_PCI_KDRV_NIC_UIO:
+ /* get device info from netuio kernel driver */
+ ret = get_netuio_device_info(dev_info, dev_info_data, dev);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL,
+ "Could not retrieve device info for PCI device "
+ 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,
@@ -286,13 +300,14 @@ parse_pci_hardware_id(const char *buf, struct rte_pci_id *pci_id)
}
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 = RTE_PCI_KDRV_NONE;
+ /* set kernel driver type based on device class */
+ if (IsEqualGUID(&(device_info_data->ClassGuid), &GUID_DEVCLASS_NETUIO))
+ dev->kdrv = RTE_PCI_KDRV_NIC_UIO;
+ else
+ dev->kdrv = RTE_PCI_KDRV_NONE;
}
static int
@@ -335,7 +350,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
pci_name_set(dev);
- get_kernel_driver_type(dev);
+ set_kernel_driver_type(device_info_data, dev);
/* get resources */
if (get_device_resource_info(dev_info, device_info_data, dev)
@@ -391,8 +406,8 @@ rte_pci_scan(void)
if (!rte_eal_has_pci())
return 0;
- dev_info = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, TEXT("PCI"), NULL,
- DIGCF_PRESENT);
+ dev_info = SetupDiGetClassDevs(NULL, TEXT("PCI"), NULL,
+ DIGCF_PRESENT | DIGCF_ALLCLASSES);
if (dev_info == INVALID_HANDLE_VALUE) {
RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(pci_scan)");
RTE_LOG(ERR, EAL, "Unable to enumerate PCI devices.\n");
@@ -405,12 +420,17 @@ rte_pci_scan(void)
while (SetupDiEnumDeviceInfo(dev_info, device_index,
&device_info_data)) {
device_index++;
- ret = pci_scan_one(dev_info, &device_info_data);
- if (ret == ERROR_SUCCESS)
- found_device++;
- else if (ret != ERROR_CONTINUE)
- goto end;
-
+ /* we only want to enumerate netuio & net class devices */
+ if (IsEqualGUID(&(device_info_data.ClassGuid),
+ &GUID_DEVCLASS_NETUIO) ||
+ IsEqualGUID(&(device_info_data.ClassGuid),
+ &GUID_DEVCLASS_NET)) {
+ ret = pci_scan_one(dev_info, &device_info_data);
+ if (ret == ERROR_SUCCESS)
+ found_device++;
+ else if (ret != ERROR_CONTINUE)
+ goto end;
+ }
memset(&device_info_data, 0, sizeof(SP_DEVINFO_DATA));
device_info_data.cbSize = 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..fe9a69673
--- /dev/null
+++ b/drivers/bus/pci/windows/pci_netuio.c
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+
+#include <rte_windows.h>
+#include <rte_errno.h>
+#include <rte_log.h>
+#include <rte_eal.h>
+
+#include "private.h"
+#include "pci_netuio.h"
+
+#include <devpkey.h>
+
+#ifdef RTE_TOOLCHAIN_GCC
+#include <devpropdef.h>
+DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node, 0x540b947e, 0x8b40, 0x45bc,
+ 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 3);
+#endif
+
+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 = 0;
+
+ res = 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;
+}
+
+/*
+ * 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 = -1;
+ BOOL res;
+ DWORD required_size = 0;
+ TCHAR dev_instance_id[MAX_DEVICENAME_SZ];
+ HANDLE netuio = INVALID_HANDLE_VALUE;
+ HDEVINFO di_set = INVALID_HANDLE_VALUE;
+ SP_DEVICE_INTERFACE_DATA dev_ifx_data = { 0 };
+ PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail = NULL;
+ struct device_info hw_info = { 0 };
+ unsigned int idx;
+ DEVPROPTYPE property_type;
+ DWORD numa_node;
+
+ /* obtain the driver interface for this device */
+ res = SetupDiGetDeviceInstanceId(dev_info, dev_info_data,
+ dev_instance_id, sizeof(dev_instance_id), &required_size);
+ if (!res) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInstanceId");
+ return -1;
+ }
+
+ /* obtain the device information set */
+ di_set = SetupDiGetClassDevs(&GUID_DEVINTERFACE_NETUIO, dev_instance_id,
+ NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+ if (di_set == INVALID_HANDLE_VALUE) {
+ RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(device information set)");
+ return -1;
+ }
+
+ dev_ifx_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
+
+ /* enumerate the netUIO interfaces for this device information set */
+ res = 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 detail */
+ required_size = 0;
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data, NULL, 0,
+ &required_size, NULL);
+ if (!res) {
+ /* ERROR_INSUFFICIENT_BUFFER is expected */
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+ }
+
+ dev_ifx_detail = 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 = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
+
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data,
+ dev_ifx_detail, required_size, NULL, NULL);
+ if (!res) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+
+ /* open the kernel driver */
+ netuio = CreateFile(dev_ifx_detail->DevicePath,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (netuio == 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_USERMODE, NULL, 0,
+ &hw_info, sizeof(hw_info)) != ERROR_SUCCESS) {
+ RTE_LOG(ERR, EAL, "Unable to send ioctl to driver.\n");
+ goto end;
+ }
+
+ /* set relevant values into the dev structure */
+ for (idx = 0; idx < PCI_MAX_RESOURCE; idx++) {
+ dev->mem_resource[idx].phys_addr =
+ hw_info.hw[idx].phys_addr.QuadPart;
+ dev->mem_resource[idx].addr =
+ hw_info.hw[idx].user_mapped_virt_addr;
+ dev->mem_resource[idx].len = hw_info.hw[idx].size;
+ }
+
+ /* get NUMA node using DEVPKEY_Device_Numa_Node */
+ res = 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)");
+ goto end;
+ }
+ dev->device.numa_node = numa_node;
+
+ ret = ERROR_SUCCESS;
+end:
+ if (netuio != INVALID_HANDLE_VALUE)
+ CloseHandle(netuio);
+
+ if (dev_ifx_detail)
+ free(dev_ifx_detail);
+
+ if (di_set != 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..94a353a40
--- /dev/null
+++ b/drivers/bus/pci/windows/pci_netuio.h
@@ -0,0 +1,60 @@
+/* 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_USERMODE \
+ 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 region */
+ 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];
+ USHORT reserved;
+};
+#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
^ permalink raw reply [flat|nested] 20+ messages in thread
* [dpdk-dev] [PATCH v4] bus/pci: netuio interface for windows
2020-09-21 21:08 ` [dpdk-dev] [PATCH v3] " Pallavi Kadam
@ 2020-09-22 3:05 ` Pallavi Kadam
2020-09-25 1:53 ` [dpdk-dev] [PATCH v5] " Pallavi Kadam
0 siblings, 1 reply; 20+ messages in thread
From: Pallavi Kadam @ 2020-09-22 3:05 UTC (permalink / raw)
To: dev, thomas
Cc: ranjit.menon, John.Alexander, dmitry.kozliuk, Narcisa.Vasile,
talshn, pallavi.kadam
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.
Note: Few definitions and structures have been copied from
netuio_interface.h file from
("[v3] windows/netuio: add Windows NetUIO kernel driver") series
and this will be fixed once the exact path for netuio source code is known.
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
Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
---
drivers/bus/pci/meson.build | 3 +-
drivers/bus/pci/windows/pci.c | 50 +++++---
drivers/bus/pci/windows/pci_netuio.c | 164 +++++++++++++++++++++++++++
drivers/bus/pci/windows/pci_netuio.h | 59 ++++++++++
4 files changed, 260 insertions(+), 16 deletions(-)
create mode 100644 drivers/bus/pci/windows/pci_netuio.c
create mode 100644 drivers/bus/pci/windows/pci_netuio.h
diff --git a/drivers/bus/pci/meson.build b/drivers/bus/pci/meson.build
index b649a17c2..977800495 100644
--- a/drivers/bus/pci/meson.build
+++ b/drivers/bus/pci/meson.build
@@ -18,7 +18,8 @@ if is_freebsd
includes += include_directories('bsd')
endif
if is_windows
- sources += files('windows/pci.c')
+ sources += files('windows/pci.c',
+ 'windows/pci_netuio.c')
includes += include_directories('windows')
endif
diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index 9e5c8fafb..d36212084 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -8,6 +8,7 @@
#include <rte_eal.h>
#include "private.h"
+#include "pci_netuio.h"
#include <devpkey.h>
@@ -209,6 +210,7 @@ get_device_resource_info(HDEVINFO dev_info,
DEVPROPTYPE property_type;
DWORD numa_node;
BOOL res;
+ int ret;
switch (dev->kdrv) {
case RTE_PCI_KDRV_NONE:
@@ -228,6 +230,18 @@ get_device_resource_info(HDEVINFO dev_info,
dev->mem_resource[0].len = 0;
dev->mem_resource[0].addr = NULL;
break;
+ case RTE_PCI_KDRV_NIC_UIO:
+ /* get device info from netuio kernel driver */
+ ret = get_netuio_device_info(dev_info, dev_info_data, dev);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL,
+ "Could not retrieve device info for PCI device "
+ 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,
@@ -286,13 +300,14 @@ parse_pci_hardware_id(const char *buf, struct rte_pci_id *pci_id)
}
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 = RTE_PCI_KDRV_NONE;
+ /* set kernel driver type based on device class */
+ if (IsEqualGUID(&(device_info_data->ClassGuid), &GUID_DEVCLASS_NETUIO))
+ dev->kdrv = RTE_PCI_KDRV_NIC_UIO;
+ else
+ dev->kdrv = RTE_PCI_KDRV_NONE;
}
static int
@@ -335,7 +350,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
pci_name_set(dev);
- get_kernel_driver_type(dev);
+ set_kernel_driver_type(device_info_data, dev);
/* get resources */
if (get_device_resource_info(dev_info, device_info_data, dev)
@@ -391,8 +406,8 @@ rte_pci_scan(void)
if (!rte_eal_has_pci())
return 0;
- dev_info = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, TEXT("PCI"), NULL,
- DIGCF_PRESENT);
+ dev_info = SetupDiGetClassDevs(NULL, TEXT("PCI"), NULL,
+ DIGCF_PRESENT | DIGCF_ALLCLASSES);
if (dev_info == INVALID_HANDLE_VALUE) {
RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(pci_scan)");
RTE_LOG(ERR, EAL, "Unable to enumerate PCI devices.\n");
@@ -405,12 +420,17 @@ rte_pci_scan(void)
while (SetupDiEnumDeviceInfo(dev_info, device_index,
&device_info_data)) {
device_index++;
- ret = pci_scan_one(dev_info, &device_info_data);
- if (ret == ERROR_SUCCESS)
- found_device++;
- else if (ret != ERROR_CONTINUE)
- goto end;
-
+ /* we only want to enumerate netuio & net class devices */
+ if (IsEqualGUID(&(device_info_data.ClassGuid),
+ &GUID_DEVCLASS_NETUIO) ||
+ IsEqualGUID(&(device_info_data.ClassGuid),
+ &GUID_DEVCLASS_NET)) {
+ ret = pci_scan_one(dev_info, &device_info_data);
+ if (ret == ERROR_SUCCESS)
+ found_device++;
+ else if (ret != ERROR_CONTINUE)
+ goto end;
+ }
memset(&device_info_data, 0, sizeof(SP_DEVINFO_DATA));
device_info_data.cbSize = 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..fe9a69673
--- /dev/null
+++ b/drivers/bus/pci/windows/pci_netuio.c
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+
+#include <rte_windows.h>
+#include <rte_errno.h>
+#include <rte_log.h>
+#include <rte_eal.h>
+
+#include "private.h"
+#include "pci_netuio.h"
+
+#include <devpkey.h>
+
+#ifdef RTE_TOOLCHAIN_GCC
+#include <devpropdef.h>
+DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node, 0x540b947e, 0x8b40, 0x45bc,
+ 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 3);
+#endif
+
+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 = 0;
+
+ res = 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;
+}
+
+/*
+ * 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 = -1;
+ BOOL res;
+ DWORD required_size = 0;
+ TCHAR dev_instance_id[MAX_DEVICENAME_SZ];
+ HANDLE netuio = INVALID_HANDLE_VALUE;
+ HDEVINFO di_set = INVALID_HANDLE_VALUE;
+ SP_DEVICE_INTERFACE_DATA dev_ifx_data = { 0 };
+ PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail = NULL;
+ struct device_info hw_info = { 0 };
+ unsigned int idx;
+ DEVPROPTYPE property_type;
+ DWORD numa_node;
+
+ /* obtain the driver interface for this device */
+ res = SetupDiGetDeviceInstanceId(dev_info, dev_info_data,
+ dev_instance_id, sizeof(dev_instance_id), &required_size);
+ if (!res) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInstanceId");
+ return -1;
+ }
+
+ /* obtain the device information set */
+ di_set = SetupDiGetClassDevs(&GUID_DEVINTERFACE_NETUIO, dev_instance_id,
+ NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+ if (di_set == INVALID_HANDLE_VALUE) {
+ RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(device information set)");
+ return -1;
+ }
+
+ dev_ifx_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
+
+ /* enumerate the netUIO interfaces for this device information set */
+ res = 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 detail */
+ required_size = 0;
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data, NULL, 0,
+ &required_size, NULL);
+ if (!res) {
+ /* ERROR_INSUFFICIENT_BUFFER is expected */
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+ }
+
+ dev_ifx_detail = 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 = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
+
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data,
+ dev_ifx_detail, required_size, NULL, NULL);
+ if (!res) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+
+ /* open the kernel driver */
+ netuio = CreateFile(dev_ifx_detail->DevicePath,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (netuio == 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_USERMODE, NULL, 0,
+ &hw_info, sizeof(hw_info)) != ERROR_SUCCESS) {
+ RTE_LOG(ERR, EAL, "Unable to send ioctl to driver.\n");
+ goto end;
+ }
+
+ /* set relevant values into the dev structure */
+ for (idx = 0; idx < PCI_MAX_RESOURCE; idx++) {
+ dev->mem_resource[idx].phys_addr =
+ hw_info.hw[idx].phys_addr.QuadPart;
+ dev->mem_resource[idx].addr =
+ hw_info.hw[idx].user_mapped_virt_addr;
+ dev->mem_resource[idx].len = hw_info.hw[idx].size;
+ }
+
+ /* get NUMA node using DEVPKEY_Device_Numa_Node */
+ res = 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)");
+ goto end;
+ }
+ dev->device.numa_node = numa_node;
+
+ ret = ERROR_SUCCESS;
+end:
+ if (netuio != INVALID_HANDLE_VALUE)
+ CloseHandle(netuio);
+
+ if (dev_ifx_detail)
+ free(dev_ifx_detail);
+
+ if (di_set != 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..b65e57f46
--- /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_USERMODE \
+ 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 region */
+ 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* [dpdk-dev] [PATCH v5] bus/pci: netuio interface for windows
2020-09-22 3:05 ` [dpdk-dev] [PATCH v4] " Pallavi Kadam
@ 2020-09-25 1:53 ` Pallavi Kadam
2020-09-29 8:28 ` Tal Shnaiderman
2020-10-06 21:57 ` [dpdk-dev] [PATCH v6] " Pallavi Kadam
0 siblings, 2 replies; 20+ messages in thread
From: Pallavi Kadam @ 2020-09-25 1:53 UTC (permalink / raw)
To: dev, thomas
Cc: ranjit.menon, John.Alexander, dmitry.kozliuk, Narcisa.Vasile,
talshn, pallavi.kadam
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.
Note: Few definitions and structures have been copied from
netuio_interface.h file from
("[v4] windows/netuio: add Windows NetUIO kernel driver") series
and this will be fixed once the exact path for netuio source code is known.
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
Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
---
drivers/bus/pci/meson.build | 3 +-
drivers/bus/pci/windows/pci.c | 50 +++++---
drivers/bus/pci/windows/pci_netuio.c | 171 +++++++++++++++++++++++++++
drivers/bus/pci/windows/pci_netuio.h | 59 +++++++++
4 files changed, 267 insertions(+), 16 deletions(-)
create mode 100644 drivers/bus/pci/windows/pci_netuio.c
create mode 100644 drivers/bus/pci/windows/pci_netuio.h
diff --git a/drivers/bus/pci/meson.build b/drivers/bus/pci/meson.build
index b649a17c2..977800495 100644
--- a/drivers/bus/pci/meson.build
+++ b/drivers/bus/pci/meson.build
@@ -18,7 +18,8 @@ if is_freebsd
includes += include_directories('bsd')
endif
if is_windows
- sources += files('windows/pci.c')
+ sources += files('windows/pci.c',
+ 'windows/pci_netuio.c')
includes += include_directories('windows')
endif
diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index 9e5c8fafb..d36212084 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -8,6 +8,7 @@
#include <rte_eal.h>
#include "private.h"
+#include "pci_netuio.h"
#include <devpkey.h>
@@ -209,6 +210,7 @@ get_device_resource_info(HDEVINFO dev_info,
DEVPROPTYPE property_type;
DWORD numa_node;
BOOL res;
+ int ret;
switch (dev->kdrv) {
case RTE_PCI_KDRV_NONE:
@@ -228,6 +230,18 @@ get_device_resource_info(HDEVINFO dev_info,
dev->mem_resource[0].len = 0;
dev->mem_resource[0].addr = NULL;
break;
+ case RTE_PCI_KDRV_NIC_UIO:
+ /* get device info from netuio kernel driver */
+ ret = get_netuio_device_info(dev_info, dev_info_data, dev);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL,
+ "Could not retrieve device info for PCI device "
+ 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,
@@ -286,13 +300,14 @@ parse_pci_hardware_id(const char *buf, struct rte_pci_id *pci_id)
}
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 = RTE_PCI_KDRV_NONE;
+ /* set kernel driver type based on device class */
+ if (IsEqualGUID(&(device_info_data->ClassGuid), &GUID_DEVCLASS_NETUIO))
+ dev->kdrv = RTE_PCI_KDRV_NIC_UIO;
+ else
+ dev->kdrv = RTE_PCI_KDRV_NONE;
}
static int
@@ -335,7 +350,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
pci_name_set(dev);
- get_kernel_driver_type(dev);
+ set_kernel_driver_type(device_info_data, dev);
/* get resources */
if (get_device_resource_info(dev_info, device_info_data, dev)
@@ -391,8 +406,8 @@ rte_pci_scan(void)
if (!rte_eal_has_pci())
return 0;
- dev_info = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, TEXT("PCI"), NULL,
- DIGCF_PRESENT);
+ dev_info = SetupDiGetClassDevs(NULL, TEXT("PCI"), NULL,
+ DIGCF_PRESENT | DIGCF_ALLCLASSES);
if (dev_info == INVALID_HANDLE_VALUE) {
RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(pci_scan)");
RTE_LOG(ERR, EAL, "Unable to enumerate PCI devices.\n");
@@ -405,12 +420,17 @@ rte_pci_scan(void)
while (SetupDiEnumDeviceInfo(dev_info, device_index,
&device_info_data)) {
device_index++;
- ret = pci_scan_one(dev_info, &device_info_data);
- if (ret == ERROR_SUCCESS)
- found_device++;
- else if (ret != ERROR_CONTINUE)
- goto end;
-
+ /* we only want to enumerate netuio & net class devices */
+ if (IsEqualGUID(&(device_info_data.ClassGuid),
+ &GUID_DEVCLASS_NETUIO) ||
+ IsEqualGUID(&(device_info_data.ClassGuid),
+ &GUID_DEVCLASS_NET)) {
+ ret = pci_scan_one(dev_info, &device_info_data);
+ if (ret == ERROR_SUCCESS)
+ found_device++;
+ else if (ret != ERROR_CONTINUE)
+ goto end;
+ }
memset(&device_info_data, 0, sizeof(SP_DEVINFO_DATA));
device_info_data.cbSize = 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..f0ebc2102
--- /dev/null
+++ b/drivers/bus/pci/windows/pci_netuio.c
@@ -0,0 +1,171 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+
+#include <rte_windows.h>
+#include <rte_errno.h>
+#include <rte_log.h>
+#include <rte_eal.h>
+
+#include "private.h"
+#include "pci_netuio.h"
+
+#include <devpkey.h>
+
+#ifdef RTE_TOOLCHAIN_GCC
+#include <devpropdef.h>
+DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node, 0x540b947e, 0x8b40, 0x45bc,
+ 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 3);
+#endif
+
+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 = 0;
+
+ res = 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;
+}
+
+/*
+ * 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 = -1;
+ BOOL res;
+ DWORD required_size = 0;
+ TCHAR dev_instance_id[MAX_DEVICENAME_SZ];
+ HANDLE netuio = INVALID_HANDLE_VALUE;
+ HDEVINFO di_set = INVALID_HANDLE_VALUE;
+ SP_DEVICE_INTERFACE_DATA dev_ifx_data = { 0 };
+ PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail = NULL;
+ struct device_info hw_info = { 0 };
+ unsigned int idx;
+ DEVPROPTYPE property_type;
+ DWORD numa_node;
+
+ /* obtain the driver interface for this device */
+ res = SetupDiGetDeviceInstanceId(dev_info, dev_info_data,
+ dev_instance_id, sizeof(dev_instance_id), &required_size);
+ if (!res) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInstanceId");
+ return -1;
+ }
+
+ /* obtain the device information set */
+ di_set = SetupDiGetClassDevs(&GUID_DEVINTERFACE_NETUIO, dev_instance_id,
+ NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+ if (di_set == INVALID_HANDLE_VALUE) {
+ RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(device information set)");
+ return -1;
+ }
+
+ dev_ifx_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
+
+ /* enumerate the netUIO interfaces for this device information set */
+ res = 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 detail */
+ required_size = 0;
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data, NULL, 0,
+ &required_size, NULL);
+ if (!res) {
+ /* ERROR_INSUFFICIENT_BUFFER is expected */
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+ }
+
+ dev_ifx_detail = 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 = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
+
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data,
+ dev_ifx_detail, required_size, NULL, NULL);
+ if (!res) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+
+ /* open the kernel driver */
+ netuio = CreateFile(dev_ifx_detail->DevicePath,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (netuio == 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_USERMODE, NULL, 0,
+ &hw_info, sizeof(hw_info)) != ERROR_SUCCESS) {
+ RTE_LOG(ERR, EAL, "Unable to send ioctl to driver.\n");
+ goto end;
+ }
+
+ /* set relevant values into the dev structure */
+ for (idx = 0; idx < PCI_MAX_RESOURCE; idx++) {
+ dev->mem_resource[idx].phys_addr =
+ hw_info.hw[idx].phys_addr.QuadPart;
+ dev->mem_resource[idx].addr =
+ hw_info.hw[idx].user_mapped_virt_addr;
+ dev->mem_resource[idx].len = hw_info.hw[idx].size;
+ }
+
+ /* get NUMA node using DEVPKEY_Device_Numa_Node */
+ res = 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)");
+ goto end;
+ }
+ dev->device.numa_node = numa_node;
+
+ ret = ERROR_SUCCESS;
+end:
+ if (ret != ERROR_SUCCESS) {
+ /* Only close the handle to the driver in case of an error.
+ * Otherwise, we want to keep the handle open. Closing it
+ * here will cause the driver to unmap all the process-mapped
+ * values resulting in invalid addresses.
+ */
+ if (netuio != INVALID_HANDLE_VALUE)
+ CloseHandle(netuio);
+ }
+
+ if (dev_ifx_detail)
+ free(dev_ifx_detail);
+
+ if (di_set != 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..b65e57f46
--- /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_USERMODE \
+ 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 region */
+ 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH v5] bus/pci: netuio interface for windows
2020-09-25 1:53 ` [dpdk-dev] [PATCH v5] " Pallavi Kadam
@ 2020-09-29 8:28 ` Tal Shnaiderman
2020-09-29 17:29 ` Ranjit Menon
2020-10-06 23:31 ` Kadam, Pallavi
2020-10-06 21:57 ` [dpdk-dev] [PATCH v6] " Pallavi Kadam
1 sibling, 2 replies; 20+ messages in thread
From: Tal Shnaiderman @ 2020-09-29 8:28 UTC (permalink / raw)
To: Pallavi Kadam, dev, NBU-Contact-Thomas Monjalon
Cc: ranjit.menon, John.Alexander, dmitry.kozliuk, Narcisa.Vasile
> Subject: [PATCH v5] bus/pci: netuio interface for windows
>
> 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.
>
> Note: Few definitions and structures have been copied from
> netuio_interface.h file from ("[v4] windows/netuio: add Windows NetUIO
> kernel driver") series and this will be fixed once the exact path for netuio
> source code is known.
>
> 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
>
> Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
[snip]
> +/*
> + * 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)
> +{
[snip]
> + /* get NUMA node using DEVPKEY_Device_Numa_Node */
> + res = 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)");
> + goto end;
> + }
> + dev->device.numa_node = numa_node;
The is the same code RTE_PCI_KDRV_NONE devices are using to get numa node id, I suggest removing it and changing the original code in get_device_resource_info to work on both RTE_PCI_KDRV_NONE and RTE_PCI_KDRV_NIC_UIO
In general:
Regarding the issue Ranjit mentioned in the last community call on duplicated detection of netuio devices both as GUID_DEVCLASS_NETUIO and GUID_DEVCLASS_NET, in pci_scan_one there is actually code that take cares of duplicated detection by leaving only one in the device list, up until nor I saw it in action only in virtualization where BDF of several devices was equal.
Assuming this is resolved with the addition of segment id as domain id the change we need is to give precedence to GUID_DEVCLASS_NETUIO, something like:
@@ -372,11 +372,15 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
} else if (ret < 0) {
rte_pci_insert_device(dev2, dev);
} else { /* already registered */
+ if (IsEqualGUID(&(device_info_data.ClassGuid),
+ &GUID_DEVCLASS_NETUIO) {
dev2->kdrv = dev->kdrv;
dev2->max_vfs = dev->max_vfs;
memmove(dev2->mem_resource, dev->mem_resource,
sizeof(dev->mem_resource));
+ }
free(dev);
}
return 0;
}
The other pci.c changes of the patch LGTM, I'd prefer someone from MSFT to review in depth the pci_netuio.c/.h, the only other comment I have on it is a suggestion to break down the get_netuio_device_info function into several helper functions (get_netuio_device_information_set, allocate_netuio_interface_detail, etc)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH v5] bus/pci: netuio interface for windows
2020-09-29 8:28 ` Tal Shnaiderman
@ 2020-09-29 17:29 ` Ranjit Menon
2020-09-30 7:58 ` Tal Shnaiderman
2020-10-06 23:31 ` Kadam, Pallavi
1 sibling, 1 reply; 20+ messages in thread
From: Ranjit Menon @ 2020-09-29 17:29 UTC (permalink / raw)
To: Tal Shnaiderman, Pallavi Kadam, dev, NBU-Contact-Thomas Monjalon
Cc: John.Alexander, dmitry.kozliuk, Narcisa.Vasile
Hi Tal,
On 9/29/2020 1:28 AM, Tal Shnaiderman wrote:
[snip]
> In general:
>
> Regarding the issue Ranjit mentioned in the last community call on duplicated detection of netuio devices both as GUID_DEVCLASS_NETUIO and GUID_DEVCLASS_NET, in pci_scan_one there is actually code that take cares of duplicated detection by leaving only one in the device list, up until nor I saw it in action only in virtualization where BDF of several devices was equal.
>
> Assuming this is resolved with the addition of segment id as domain id the change we need is to give precedence to GUID_DEVCLASS_NETUIO, something like:
>
> @@ -372,11 +372,15 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
> } else if (ret < 0) {
> rte_pci_insert_device(dev2, dev);
> } else { /* already registered */
> + if (IsEqualGUID(&(device_info_data.ClassGuid),
> + &GUID_DEVCLASS_NETUIO) {
> dev2->kdrv = dev->kdrv;
> dev2->max_vfs = dev->max_vfs;
> memmove(dev2->mem_resource, dev->mem_resource,
> sizeof(dev->mem_resource));
> + }
> free(dev);
> }
> return 0;
> }
The issue I raised is slightly different: How do we distinguish between
different GUID_DEVCLASS_NET class devices - those that can support DPDK
and those that can't?
For instance, say we have 3 NICs in the system - MLX5 NIC, Intel i40e
NIC and Intel ice NIC - all loaded with standard ethernet (NDIS) drivers.
Now if I load and bind the netuio driver to the Intel ice NIC, I have
one GUID_DEVCLASS_NETUIO class device and two GUID_DEVCLASS_NET class
devices.
If I run the pci scan now, it will detect all 3 devices and add them to
the list. However, the Intel i40e NIC which is correctly detected as a
GUID_DEVCLASS_NET class and is bound to the standard NDIS driver cannot
support DPDK and should be excluded from the list.
I think the suggestion at the community meeting was to define a DEV
interface which can be queried for confirming DPDK support. In such a
case, the MLX5 driver should support this interface, where as our
standard i40e (NDIS) driver will not. This check can be used to exclude
this device from the list.
ranjit m.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH v5] bus/pci: netuio interface for windows
2020-09-29 17:29 ` Ranjit Menon
@ 2020-09-30 7:58 ` Tal Shnaiderman
0 siblings, 0 replies; 20+ messages in thread
From: Tal Shnaiderman @ 2020-09-30 7:58 UTC (permalink / raw)
To: Ranjit Menon, Pallavi Kadam, dev, NBU-Contact-Thomas Monjalon
Cc: John.Alexander, dmitry.kozliuk, Narcisa.Vasile
> Subject: Re: [PATCH v5] bus/pci: netuio interface for windows
>
> Hi Tal,
>
> The issue I raised is slightly different: How do we distinguish between
> different GUID_DEVCLASS_NET class devices - those that can support DPDK
> and those that can't?
>
> For instance, say we have 3 NICs in the system - MLX5 NIC, Intel i40e NIC and
> Intel ice NIC - all loaded with standard ethernet (NDIS) drivers.
>
> Now if I load and bind the netuio driver to the Intel ice NIC, I have one
> GUID_DEVCLASS_NETUIO class device and two GUID_DEVCLASS_NET class
> devices.
>
> If I run the pci scan now, it will detect all 3 devices and add them to the list.
> However, the Intel i40e NIC which is correctly detected as a
> GUID_DEVCLASS_NET class and is bound to the standard NDIS driver cannot
> support DPDK and should be excluded from the list.
>
> I think the suggestion at the community meeting was to define a DEV
> interface which can be queried for confirming DPDK support. In such a case,
> the MLX5 driver should support this interface, where as our standard i40e
> (NDIS) driver will not. This check can be used to exclude this device from the
> list.
>
> ranjit m.
Thanks for the explanation Ranjit,
BTW, what will happen if a user does tries to use a NETUIO NIC recognized as NET?
It will have nulls for the needed mem_resource fields so will it fails or crash?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH v5] bus/pci: netuio interface for windows
2020-09-29 8:28 ` Tal Shnaiderman
2020-09-29 17:29 ` Ranjit Menon
@ 2020-10-06 23:31 ` Kadam, Pallavi
1 sibling, 0 replies; 20+ messages in thread
From: Kadam, Pallavi @ 2020-10-06 23:31 UTC (permalink / raw)
To: Tal Shnaiderman, dev, NBU-Contact-Thomas Monjalon
Cc: ranjit.menon, John.Alexander, dmitry.kozliuk, Narcisa.Vasile
On 9/29/2020 1:28 AM, Tal Shnaiderman wrote:
>> Subject: [PATCH v5] bus/pci: netuio interface for windows
>>
>> 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.
>>
>> Note: Few definitions and structures have been copied from
>> netuio_interface.h file from ("[v4] windows/netuio: add Windows NetUIO
>> kernel driver") series and this will be fixed once the exact path for netuio
>> source code is known.
>>
>> 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
>>
>> Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
>> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
>> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
>> ---
> [snip]
>
>> +/*
>> + * 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)
>> +{
> [snip]
>
>> + /* get NUMA node using DEVPKEY_Device_Numa_Node */
>> + res = 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)");
>> + goto end;
>> + }
>> + dev->device.numa_node = numa_node;
> The is the same code RTE_PCI_KDRV_NONE devices are using to get numa node id, I suggest removing it and changing the original code in get_device_resource_info to work on both RTE_PCI_KDRV_NONE and RTE_PCI_KDRV_NIC_UIO
Thanks, Tal. We have modified get numa node id code to support both
RTE_PCI_KDRV_NONE and RTE_PCI_KDRV_NIC_UIO and split up the
get_netuio_device_info function into multiple functions in v6.
>
> In general:
>
> Regarding the issue Ranjit mentioned in the last community call on duplicated detection of netuio devices both as GUID_DEVCLASS_NETUIO and GUID_DEVCLASS_NET, in pci_scan_one there is actually code that take cares of duplicated detection by leaving only one in the device list, up until nor I saw it in action only in virtualization where BDF of several devices was equal.
>
> Assuming this is resolved with the addition of segment id as domain id the change we need is to give precedence to GUID_DEVCLASS_NETUIO, something like:
>
> @@ -372,11 +372,15 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
> } else if (ret < 0) {
> rte_pci_insert_device(dev2, dev);
> } else { /* already registered */
> + if (IsEqualGUID(&(device_info_data.ClassGuid),
> + &GUID_DEVCLASS_NETUIO) {
> dev2->kdrv = dev->kdrv;
> dev2->max_vfs = dev->max_vfs;
> memmove(dev2->mem_resource, dev->mem_resource,
> sizeof(dev->mem_resource));
> + }
> free(dev);
> }
> return 0;
> }
>
> The other pci.c changes of the patch LGTM, I'd prefer someone from MSFT to review in depth the pci_netuio.c/.h, the only other comment I have on it is a suggestion to break down the get_netuio_device_info function into several helper functions (get_netuio_device_information_set, allocate_netuio_interface_detail, etc)
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [dpdk-dev] [PATCH v6] bus/pci: netuio interface for windows
2020-09-25 1:53 ` [dpdk-dev] [PATCH v5] " Pallavi Kadam
2020-09-29 8:28 ` Tal Shnaiderman
@ 2020-10-06 21:57 ` Pallavi Kadam
2020-10-08 17:46 ` Tal Shnaiderman
2020-10-08 18:56 ` [dpdk-dev] [PATCH v7] " Pallavi Kadam
1 sibling, 2 replies; 20+ messages in thread
From: Pallavi Kadam @ 2020-10-06 21:57 UTC (permalink / raw)
To: dev, thomas
Cc: ranjit.menon, John.Alexander, dmitry.kozliuk, Narcisa.Vasile,
talshn, pallavi.kadam
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.
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 netuio source code is known.
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
Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
---
drivers/bus/pci/meson.build | 3 +-
drivers/bus/pci/windows/pci.c | 73 ++++++----
drivers/bus/pci/windows/pci_netuio.c | 190 +++++++++++++++++++++++++++
drivers/bus/pci/windows/pci_netuio.h | 59 +++++++++
4 files changed, 297 insertions(+), 28 deletions(-)
create mode 100644 drivers/bus/pci/windows/pci_netuio.c
create mode 100644 drivers/bus/pci/windows/pci_netuio.h
diff --git a/drivers/bus/pci/meson.build b/drivers/bus/pci/meson.build
index b649a17c2..977800495 100644
--- a/drivers/bus/pci/meson.build
+++ b/drivers/bus/pci/meson.build
@@ -18,7 +18,8 @@ if is_freebsd
includes += include_directories('bsd')
endif
if is_windows
- sources += files('windows/pci.c')
+ sources += files('windows/pci.c',
+ 'windows/pci_netuio.c')
includes += include_directories('windows')
endif
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 <rte_windows.h>
#include <rte_errno.h>
#include <rte_log.h>
-#include <rte_eal_memconfig.h>
#include <rte_eal.h>
#include "private.h"
+#include "pci_netuio.h"
#include <devpkey.h>
@@ -209,25 +209,27 @@ get_device_resource_info(HDEVINFO dev_info,
DEVPROPTYPE property_type;
DWORD numa_node;
BOOL res;
+ int ret;
switch (dev->kdrv) {
case RTE_PCI_KDRV_NONE:
- /* Get NUMA node using DEVPKEY_Device_Numa_Node */
- res = 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 = numa_node;
/* mem_resource - Unneeded for RTE_PCI_KDRV_NONE */
dev->mem_resource[0].phys_addr = 0;
dev->mem_resource[0].len = 0;
dev->mem_resource[0].addr = NULL;
break;
+ case RTE_PCI_KDRV_NIC_UIO:
+ /* get device info from netuio kernel driver */
+ ret = get_netuio_device_info(dev_info, dev_info_data, dev);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL,
+ "Could not retrieve device info for PCI device "
+ 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;
}
+ /* Get NUMA node using DEVPKEY_Device_Numa_Node */
+ res = 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 = numa_node;
+
return ERROR_SUCCESS;
}
@@ -286,13 +299,14 @@ parse_pci_hardware_id(const char *buf, struct rte_pci_id *pci_id)
}
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 = RTE_PCI_KDRV_NONE;
+ /* set kernel driver type based on device class */
+ if (IsEqualGUID(&(device_info_data->ClassGuid), &GUID_DEVCLASS_NETUIO))
+ dev->kdrv = RTE_PCI_KDRV_NIC_UIO;
+ else
+ dev->kdrv = RTE_PCI_KDRV_NONE;
}
static int
@@ -335,7 +349,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
pci_name_set(dev);
- get_kernel_driver_type(dev);
+ set_kernel_driver_type(device_info_data, dev);
/* 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;
- dev_info = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, TEXT("PCI"), NULL,
- DIGCF_PRESENT);
+ dev_info = SetupDiGetClassDevs(NULL, TEXT("PCI"), NULL,
+ DIGCF_PRESENT | DIGCF_ALLCLASSES);
if (dev_info == 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 = pci_scan_one(dev_info, &device_info_data);
- if (ret == ERROR_SUCCESS)
- found_device++;
- else if (ret != 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 = pci_scan_one(dev_info, &device_info_data);
+ if (ret == ERROR_SUCCESS)
+ found_device++;
+ else if (ret != ERROR_CONTINUE)
+ goto end;
+ }
memset(&device_info_data, 0, sizeof(SP_DEVINFO_DATA));
device_info_data.cbSize = 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..5c9790684
--- /dev/null
+++ b/drivers/bus/pci/windows/pci_netuio.c
@@ -0,0 +1,190 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation.
+ */
+
+#include <rte_windows.h>
+#include <rte_errno.h>
+#include <rte_log.h>
+#include <rte_eal.h>
+
+#include "private.h"
+#include "pci_netuio.h"
+
+#include <devpkey.h>
+
+#ifdef RTE_TOOLCHAIN_GCC
+#include <devpropdef.h>
+DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node, 0x540b947e, 0x8b40, 0x45bc,
+ 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 3);
+#endif
+
+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 = 0;
+
+ res = 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 = 0;
+ TCHAR dev_instance_id[MAX_DEVICENAME_SZ];
+ HDEVINFO di_set = INVALID_HANDLE_VALUE;
+
+ /* obtain the driver interface for this device */
+ res = 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 = SetupDiGetClassDevs(&GUID_DEVINTERFACE_NETUIO,
+ dev_instance_id, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+ if (di_set == 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 = 0;
+ SP_DEVICE_INTERFACE_DATA dev_ifx_data = { 0 };
+ PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail = NULL;
+
+ dev_ifx_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
+
+ /* enumerate the netUIO interfaces for this device information set */
+ res = 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 detail */
+ required_size = 0;
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data, NULL, 0,
+ &required_size, NULL);
+ if (!res) {
+ /* ERROR_INSUFFICIENT_BUFFER is expected */
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+ }
+
+ dev_ifx_detail = 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 = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
+
+ res = 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 = 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 = -1;
+ HDEVINFO di_set = INVALID_HANDLE_VALUE;
+ PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail = NULL;
+ HANDLE netuio = INVALID_HANDLE_VALUE;
+ struct device_info hw_info = { 0 };
+ unsigned int idx;
+
+ /* obtain the device information set for this device */
+ di_set = get_netuio_device_information_set(dev_info, dev_info_data);
+ if (di_set == INVALID_HANDLE_VALUE)
+ goto end;
+
+ /* obtain the device interface detail for this device */
+ dev_ifx_detail = get_netuio_device_interface_detail(di_set);
+ if (!dev_ifx_detail)
+ goto end;
+
+ /* open the kernel driver */
+ netuio = CreateFile(dev_ifx_detail->DevicePath,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (netuio == 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)) != ERROR_SUCCESS) {
+ RTE_LOG(ERR, EAL, "Unable to send ioctl to driver.\n");
+ goto end;
+ }
+
+ /* set relevant values into the dev structure */
+ for (idx = 0; idx < PCI_MAX_RESOURCE; idx++) {
+ dev->mem_resource[idx].phys_addr =
+ hw_info.hw[idx].phys_addr.QuadPart;
+ dev->mem_resource[idx].addr =
+ hw_info.hw[idx].user_mapped_virt_addr;
+ dev->mem_resource[idx].len = hw_info.hw[idx].size;
+ }
+
+ ret = ERROR_SUCCESS;
+end:
+ if (ret != ERROR_SUCCESS) {
+ /* Only close the handle to the driver in case of an error.
+ * Otherwise, we want to keep the handle open. Closing it
+ * here will cause the driver to unmap all the process-mapped
+ * values resulting in invalid addresses.
+ */
+ if (netuio != INVALID_HANDLE_VALUE)
+ CloseHandle(netuio);
+ }
+
+ if (dev_ifx_detail)
+ free(dev_ifx_detail);
+
+ if (di_set != 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 region */
+ 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH v6] bus/pci: netuio interface for windows
2020-10-06 21:57 ` [dpdk-dev] [PATCH v6] " Pallavi Kadam
@ 2020-10-08 17:46 ` Tal Shnaiderman
2020-10-08 18:56 ` [dpdk-dev] [PATCH v7] " Pallavi Kadam
1 sibling, 0 replies; 20+ messages in thread
From: Tal Shnaiderman @ 2020-10-08 17:46 UTC (permalink / raw)
To: Pallavi Kadam, dev, NBU-Contact-Thomas Monjalon
Cc: ranjit.menon, John.Alexander, dmitry.kozliuk, Narcisa.Vasile
> Subject: [PATCH v6] bus/pci: netuio interface for windows
>
> External email: Use caution opening links or attachments
>
>
> 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.
>
> 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 netuio
> source code is known.
>
> 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
>
> Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
<snip>
> diff --git a/drivers/bus/pci/windows/pci_netuio.c
> b/drivers/bus/pci/windows/pci_netuio.c
> new file mode 100644
> index 000000000..5c9790684
> --- /dev/null
> +++ b/drivers/bus/pci/windows/pci_netuio.c
> @@ -0,0 +1,190 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2020 Intel Corporation.
> + */
> +
> +#include <rte_windows.h>
> +#include <rte_errno.h>
> +#include <rte_log.h>
> +#include <rte_eal.h>
> +
> +#include "private.h"
> +#include "pci_netuio.h"
> +
> +#include <devpkey.h>
> +
> +#ifdef RTE_TOOLCHAIN_GCC
> +#include <devpropdef.h>
> +DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node, 0x540b947e, 0x8b40,
> 0x45bc,
> + 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 3); #endif
The whole ifdef section and the devpkey.h include can be removed since Numa detection is done in pci.c.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [dpdk-dev] [PATCH v7] bus/pci: netuio interface for windows
2020-10-06 21:57 ` [dpdk-dev] [PATCH v6] " Pallavi Kadam
2020-10-08 17:46 ` Tal Shnaiderman
@ 2020-10-08 18:56 ` Pallavi Kadam
2020-10-08 21:50 ` Tal Shnaiderman
2020-10-09 2:12 ` Narcisa Ana Maria Vasile
1 sibling, 2 replies; 20+ messages in thread
From: Pallavi Kadam @ 2020-10-08 18:56 UTC (permalink / raw)
To: dev, thomas
Cc: ranjit.menon, John.Alexander, dmitry.kozliuk, Narcisa.Vasile,
talshn, khot, pallavi.kadam
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.
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 netuio source code is known.
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
Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
---
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
diff --git a/drivers/bus/pci/meson.build b/drivers/bus/pci/meson.build
index b649a17c2..977800495 100644
--- a/drivers/bus/pci/meson.build
+++ b/drivers/bus/pci/meson.build
@@ -18,7 +18,8 @@ if is_freebsd
includes += include_directories('bsd')
endif
if is_windows
- sources += files('windows/pci.c')
+ sources += files('windows/pci.c',
+ 'windows/pci_netuio.c')
includes += include_directories('windows')
endif
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 <rte_windows.h>
#include <rte_errno.h>
#include <rte_log.h>
-#include <rte_eal_memconfig.h>
#include <rte_eal.h>
#include "private.h"
+#include "pci_netuio.h"
#include <devpkey.h>
@@ -209,25 +209,27 @@ get_device_resource_info(HDEVINFO dev_info,
DEVPROPTYPE property_type;
DWORD numa_node;
BOOL res;
+ int ret;
switch (dev->kdrv) {
case RTE_PCI_KDRV_NONE:
- /* Get NUMA node using DEVPKEY_Device_Numa_Node */
- res = 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 = numa_node;
/* mem_resource - Unneeded for RTE_PCI_KDRV_NONE */
dev->mem_resource[0].phys_addr = 0;
dev->mem_resource[0].len = 0;
dev->mem_resource[0].addr = NULL;
break;
+ case RTE_PCI_KDRV_NIC_UIO:
+ /* get device info from netuio kernel driver */
+ ret = get_netuio_device_info(dev_info, dev_info_data, dev);
+ if (ret != 0) {
+ RTE_LOG(DEBUG, EAL,
+ "Could not retrieve device info for PCI device "
+ 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;
}
+ /* Get NUMA node using DEVPKEY_Device_Numa_Node */
+ res = 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 = numa_node;
+
return ERROR_SUCCESS;
}
@@ -286,13 +299,14 @@ parse_pci_hardware_id(const char *buf, struct rte_pci_id *pci_id)
}
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 = RTE_PCI_KDRV_NONE;
+ /* set kernel driver type based on device class */
+ if (IsEqualGUID(&(device_info_data->ClassGuid), &GUID_DEVCLASS_NETUIO))
+ dev->kdrv = RTE_PCI_KDRV_NIC_UIO;
+ else
+ dev->kdrv = RTE_PCI_KDRV_NONE;
}
static int
@@ -335,7 +349,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
pci_name_set(dev);
- get_kernel_driver_type(dev);
+ set_kernel_driver_type(device_info_data, dev);
/* 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;
- dev_info = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, TEXT("PCI"), NULL,
- DIGCF_PRESENT);
+ dev_info = SetupDiGetClassDevs(NULL, TEXT("PCI"), NULL,
+ DIGCF_PRESENT | DIGCF_ALLCLASSES);
if (dev_info == 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 = pci_scan_one(dev_info, &device_info_data);
- if (ret == ERROR_SUCCESS)
- found_device++;
- else if (ret != 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 = pci_scan_one(dev_info, &device_info_data);
+ if (ret == ERROR_SUCCESS)
+ found_device++;
+ else if (ret != ERROR_CONTINUE)
+ goto end;
+ }
memset(&device_info_data, 0, sizeof(SP_DEVINFO_DATA));
device_info_data.cbSize = 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 <rte_windows.h>
+#include <rte_errno.h>
+#include <rte_log.h>
+#include <rte_eal.h>
+
+#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 = 0;
+
+ res = 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 = 0;
+ TCHAR dev_instance_id[MAX_DEVICENAME_SZ];
+ HDEVINFO di_set = INVALID_HANDLE_VALUE;
+
+ /* obtain the driver interface for this device */
+ res = 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 = SetupDiGetClassDevs(&GUID_DEVINTERFACE_NETUIO,
+ dev_instance_id, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+ if (di_set == 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 = 0;
+ SP_DEVICE_INTERFACE_DATA dev_ifx_data = { 0 };
+ PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail = NULL;
+
+ dev_ifx_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
+
+ /* enumerate the netUIO interfaces for this device information set */
+ res = 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 detail */
+ required_size = 0;
+ res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data, NULL, 0,
+ &required_size, NULL);
+ if (!res) {
+ /* ERROR_INSUFFICIENT_BUFFER is expected */
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
+ goto end;
+ }
+ }
+
+ dev_ifx_detail = 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 = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
+
+ res = 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 = 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 = -1;
+ HDEVINFO di_set = INVALID_HANDLE_VALUE;
+ PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail = NULL;
+ HANDLE netuio = INVALID_HANDLE_VALUE;
+ struct device_info hw_info = { 0 };
+ unsigned int idx;
+
+ /* obtain the device information set for this device */
+ di_set = get_netuio_device_information_set(dev_info, dev_info_data);
+ if (di_set == INVALID_HANDLE_VALUE)
+ goto end;
+
+ /* obtain the device interface detail for this device */
+ dev_ifx_detail = get_netuio_device_interface_detail(di_set);
+ if (!dev_ifx_detail)
+ goto end;
+
+ /* open the kernel driver */
+ netuio = CreateFile(dev_ifx_detail->DevicePath,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (netuio == 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)) != ERROR_SUCCESS) {
+ RTE_LOG(ERR, EAL, "Unable to send ioctl to driver.\n");
+ goto end;
+ }
+
+ /* set relevant values into the dev structure */
+ for (idx = 0; idx < PCI_MAX_RESOURCE; idx++) {
+ dev->mem_resource[idx].phys_addr =
+ hw_info.hw[idx].phys_addr.QuadPart;
+ dev->mem_resource[idx].addr =
+ hw_info.hw[idx].user_mapped_virt_addr;
+ dev->mem_resource[idx].len = hw_info.hw[idx].size;
+ }
+
+ ret = ERROR_SUCCESS;
+end:
+ if (ret != ERROR_SUCCESS) {
+ /* Only close the handle to the driver in case of an error.
+ * Otherwise, we want to keep the handle open. Closing it
+ * here will cause the driver to unmap all the process-mapped
+ * values resulting in invalid addresses.
+ */
+ if (netuio != INVALID_HANDLE_VALUE)
+ CloseHandle(netuio);
+ }
+
+ if (dev_ifx_detail)
+ free(dev_ifx_detail);
+
+ if (di_set != 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 region */
+ 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH v7] bus/pci: netuio interface for windows
2020-10-08 18:56 ` [dpdk-dev] [PATCH v7] " Pallavi Kadam
@ 2020-10-08 21:50 ` Tal Shnaiderman
2020-10-09 2:12 ` Narcisa Ana Maria Vasile
1 sibling, 0 replies; 20+ messages in thread
From: Tal Shnaiderman @ 2020-10-08 21:50 UTC (permalink / raw)
To: Pallavi Kadam, dev, NBU-Contact-Thomas Monjalon
Cc: ranjit.menon, John.Alexander, dmitry.kozliuk, Narcisa.Vasile, khot
> Subject: [PATCH v7] bus/pci: netuio interface for windows
>
> 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.
>
> 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 netuio
> source code is known.
>
> 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
>
> Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
> 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
>
> diff --git a/drivers/bus/pci/meson.build b/drivers/bus/pci/meson.build index
> b649a17c2..977800495 100644
> --- a/drivers/bus/pci/meson.build
> +++ b/drivers/bus/pci/meson.build
> @@ -18,7 +18,8 @@ if is_freebsd
> includes += include_directories('bsd') endif if is_windows
> - sources += files('windows/pci.c')
> + sources += files('windows/pci.c',
> + 'windows/pci_netuio.c')
> includes += include_directories('windows') endif
>
> 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 <rte_windows.h>
> #include <rte_errno.h>
> #include <rte_log.h>
> -#include <rte_eal_memconfig.h>
> #include <rte_eal.h>
>
> #include "private.h"
> +#include "pci_netuio.h"
>
> #include <devpkey.h>
>
> @@ -209,25 +209,27 @@ get_device_resource_info(HDEVINFO dev_info,
> DEVPROPTYPE property_type;
> DWORD numa_node;
> BOOL res;
> + int ret;
>
> switch (dev->kdrv) {
> case RTE_PCI_KDRV_NONE:
> - /* Get NUMA node using DEVPKEY_Device_Numa_Node */
> - res = 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 = numa_node;
> /* mem_resource - Unneeded for RTE_PCI_KDRV_NONE */
> dev->mem_resource[0].phys_addr = 0;
> dev->mem_resource[0].len = 0;
> dev->mem_resource[0].addr = NULL;
> break;
> + case RTE_PCI_KDRV_NIC_UIO:
> + /* get device info from netuio kernel driver */
> + ret = get_netuio_device_info(dev_info, dev_info_data, dev);
> + if (ret != 0) {
> + RTE_LOG(DEBUG, EAL,
> + "Could not retrieve device info for PCI device "
> + 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;
> }
>
> + /* Get NUMA node using DEVPKEY_Device_Numa_Node */
> + res = 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 = numa_node;
> +
> return ERROR_SUCCESS;
> }
>
> @@ -286,13 +299,14 @@ parse_pci_hardware_id(const char *buf, struct
> rte_pci_id *pci_id) }
>
> 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 = RTE_PCI_KDRV_NONE;
> + /* set kernel driver type based on device class */
> + if (IsEqualGUID(&(device_info_data->ClassGuid),
> &GUID_DEVCLASS_NETUIO))
> + dev->kdrv = RTE_PCI_KDRV_NIC_UIO;
> + else
> + dev->kdrv = RTE_PCI_KDRV_NONE;
> }
>
> static int
> @@ -335,7 +349,7 @@ pci_scan_one(HDEVINFO dev_info,
> PSP_DEVINFO_DATA device_info_data)
>
> pci_name_set(dev);
>
> - get_kernel_driver_type(dev);
> + set_kernel_driver_type(device_info_data, dev);
>
> /* 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;
>
> - dev_info = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, TEXT("PCI"),
> NULL,
> - DIGCF_PRESENT);
> + dev_info = SetupDiGetClassDevs(NULL, TEXT("PCI"), NULL,
> + DIGCF_PRESENT | DIGCF_ALLCLASSES);
> if (dev_info == 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 = pci_scan_one(dev_info, &device_info_data);
> - if (ret == ERROR_SUCCESS)
> - found_device++;
> - else if (ret != 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 = pci_scan_one(dev_info, &device_info_data);
> + if (ret == ERROR_SUCCESS)
> + found_device++;
> + else if (ret != ERROR_CONTINUE)
> + goto end;
> + }
> memset(&device_info_data, 0, sizeof(SP_DEVINFO_DATA));
> device_info_data.cbSize = 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 <rte_windows.h>
> +#include <rte_errno.h>
> +#include <rte_log.h>
> +#include <rte_eal.h>
> +
> +#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 = 0;
> +
> + res = 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 = 0;
> + TCHAR dev_instance_id[MAX_DEVICENAME_SZ];
> + HDEVINFO di_set = INVALID_HANDLE_VALUE;
> +
> + /* obtain the driver interface for this device */
> + res = 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 = SetupDiGetClassDevs(&GUID_DEVINTERFACE_NETUIO,
> + dev_instance_id, NULL, DIGCF_PRESENT |
> DIGCF_DEVICEINTERFACE);
> + if (di_set == 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 = 0;
> + SP_DEVICE_INTERFACE_DATA dev_ifx_data = { 0 };
> + PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail = NULL;
> +
> + dev_ifx_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
> +
> + /* enumerate the netUIO interfaces for this device information set */
> + res = 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 detail */
> + required_size = 0;
> + res = SetupDiGetDeviceInterfaceDetail(di_set, &dev_ifx_data, NULL, 0,
> + &required_size, NULL);
> + if (!res) {
> + /* ERROR_INSUFFICIENT_BUFFER is expected */
> + if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
> + RTE_LOG_WIN32_ERR("SetupDiGetDeviceInterfaceDetail");
> + goto end;
> + }
> + }
> +
> + dev_ifx_detail = 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 =
> + sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
> +
> + res = 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 = 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 = -1;
> + HDEVINFO di_set = INVALID_HANDLE_VALUE;
> + PSP_DEVICE_INTERFACE_DETAIL_DATA dev_ifx_detail = NULL;
> + HANDLE netuio = INVALID_HANDLE_VALUE;
> + struct device_info hw_info = { 0 };
> + unsigned int idx;
> +
> + /* obtain the device information set for this device */
> + di_set = get_netuio_device_information_set(dev_info, dev_info_data);
> + if (di_set == INVALID_HANDLE_VALUE)
> + goto end;
> +
> + /* obtain the device interface detail for this device */
> + dev_ifx_detail = get_netuio_device_interface_detail(di_set);
> + if (!dev_ifx_detail)
> + goto end;
> +
> + /* open the kernel driver */
> + netuio = CreateFile(dev_ifx_detail->DevicePath,
> + GENERIC_READ | GENERIC_WRITE,
> + FILE_SHARE_READ | FILE_SHARE_WRITE,
> + NULL,
> + OPEN_EXISTING,
> + FILE_ATTRIBUTE_NORMAL,
> + NULL);
> + if (netuio == 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)) != ERROR_SUCCESS) {
> + RTE_LOG(ERR, EAL, "Unable to send ioctl to driver.\n");
> + goto end;
> + }
> +
> + /* set relevant values into the dev structure */
> + for (idx = 0; idx < PCI_MAX_RESOURCE; idx++) {
> + dev->mem_resource[idx].phys_addr =
> + hw_info.hw[idx].phys_addr.QuadPart;
> + dev->mem_resource[idx].addr =
> + hw_info.hw[idx].user_mapped_virt_addr;
> + dev->mem_resource[idx].len = hw_info.hw[idx].size;
> + }
> +
> + ret = ERROR_SUCCESS;
> +end:
> + if (ret != ERROR_SUCCESS) {
> + /* Only close the handle to the driver in case of an error.
> + * Otherwise, we want to keep the handle open. Closing it
> + * here will cause the driver to unmap all the process-mapped
> + * values resulting in invalid addresses.
> + */
> + if (netuio != INVALID_HANDLE_VALUE)
> + CloseHandle(netuio);
> + }
> +
> + if (dev_ifx_detail)
> + free(dev_ifx_detail);
> +
> + if (di_set != 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 region
> */
> + 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 <talshn@nvidia.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH v7] bus/pci: netuio interface for windows
2020-10-08 18:56 ` [dpdk-dev] [PATCH v7] " Pallavi Kadam
2020-10-08 21:50 ` Tal Shnaiderman
@ 2020-10-09 2:12 ` Narcisa Ana Maria Vasile
2020-10-14 20:27 ` Thomas Monjalon
1 sibling, 1 reply; 20+ messages in thread
From: Narcisa Ana Maria Vasile @ 2020-10-09 2:12 UTC (permalink / raw)
To: Pallavi Kadam
Cc: dev, thomas, ranjit.menon, John.Alexander, dmitry.kozliuk,
Narcisa.Vasile, talshn, khot
On Thu, Oct 08, 2020 at 11:56:45AM -0700, Pallavi Kadam wrote:
> 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.
>
> 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 netuio source code is known.
>
> 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
>
> Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
> 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
>
Reviewed-by: Narcisa Vasile <navasile@linux.microsoft.com>
Acked-by: Narcisa Vasile <navasile@linux.microsoft.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [dpdk-dev] [PATCH v7] bus/pci: netuio interface for windows
2020-10-09 2:12 ` Narcisa Ana Maria Vasile
@ 2020-10-14 20:27 ` Thomas Monjalon
0 siblings, 0 replies; 20+ messages in thread
From: Thomas Monjalon @ 2020-10-14 20:27 UTC (permalink / raw)
To: Pallavi Kadam
Cc: dev, ranjit.menon, John.Alexander, dmitry.kozliuk,
Narcisa.Vasile, talshn, khot, Narcisa Ana Maria Vasile
09/10/2020 04:12, Narcisa Ana Maria Vasile:
> On Thu, Oct 08, 2020 at 11:56:45AM -0700, Pallavi Kadam wrote:
> > 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.
> >
> > 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 netuio source code is known.
> >
> > 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
> >
> > Signed-off-by: John Alexander <John.Alexander@datapath.co.uk>
> > Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> > Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
>
> Reviewed-by: Narcisa Vasile <navasile@linux.microsoft.com>
> Acked-by: Narcisa Vasile <navasile@linux.microsoft.com>
Applied, thanks
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2020-10-14 20:27 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-11 1:59 [dpdk-dev] [PATCH] bus/pci: netuio interface for windows Pallavi Kadam
2020-09-13 18:42 ` Tal Shnaiderman
2020-09-15 20:13 ` Ranjit Menon
2020-09-15 23:28 ` [dpdk-dev] [PATCH v2] " Pallavi Kadam
2020-09-16 1:54 ` Stephen Hemminger
2020-09-17 0:48 ` Ranjit Menon
2020-09-17 1:20 ` Ranjit Menon
2020-09-21 21:08 ` [dpdk-dev] [PATCH v3] " Pallavi Kadam
2020-09-22 3:05 ` [dpdk-dev] [PATCH v4] " Pallavi Kadam
2020-09-25 1:53 ` [dpdk-dev] [PATCH v5] " Pallavi Kadam
2020-09-29 8:28 ` Tal Shnaiderman
2020-09-29 17:29 ` Ranjit Menon
2020-09-30 7:58 ` Tal Shnaiderman
2020-10-06 23:31 ` Kadam, Pallavi
2020-10-06 21:57 ` [dpdk-dev] [PATCH v6] " Pallavi Kadam
2020-10-08 17:46 ` Tal Shnaiderman
2020-10-08 18:56 ` [dpdk-dev] [PATCH v7] " Pallavi Kadam
2020-10-08 21:50 ` Tal Shnaiderman
2020-10-09 2:12 ` Narcisa Ana Maria Vasile
2020-10-14 20:27 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).