[dpdk-dev] [PATCH v4] windows/netuio: add Windows NetUIO kernel driver
Ranjit Menon
ranjit.menon at intel.com
Tue Sep 22 23:36:50 CEST 2020
On 9/18/2020 7:52 PM, Narcisa Ana Maria Vasile wrote:
> From: Narcisa Vasile <navasile at microsoft.com>
>
> The Windows netuio kernel driver provides the DPDK userspace application
> with direct access to hardware, by mapping the HW registers in userspace
> and allowing read/write operations from/to the device
> configuration space.
>
> Two IOCTLs are defined by the netuio interface:
> * IOCTL_NETUIO_MAP_HW_INTO_USERMODE
> - used for mapping the device registers into userspace
> * IOCTL_NETUIO_PCI_CONFIG_IO
> - used to read/write from/into the device configuration space
>
> Note:
> Requests to map the device BARs into userspace need to be processed
> in the thread context of the process that initiated the mapping request.
> Otherwise, the BARs might end up mapped into an arbitrary process
> address space.
> EvtIoInCallerContext is used to ensure the requests are handled
> in the right user thread context. Other requests (PCI config)
> are sent back to the framework and processed by the EvtIoDeviceControl
> callback.
>
> Cc: Harini Ramakrishnan <Harini.Ramakrishnan at microsoft.com>
> Cc: Omar Cardona <ocardona at microsoft.com>
> Cc: Dmitry Malloy <dmitrym at microsoft.com>
> Signed-off-by: Narcisa Vasile <navasile at microsoft.com>
> ---
>
> v4:
> Fixed issues reported by DmitryK:
> * Fix whitespaces issues
> * Fix status not checked
> * Remove NULL checks for device and file context getters
> * Use %x for BDF
> * Add comment for BAR traversing
> * Remove complex calculations that were only needed in ASSERT
> * Remove netuio_evt_driver_context_cleanup as not needed
> * Check GetBusData/SetBusData returned bytes
> * General cleanup
>
> windows/.gitattributes | 4 +
> windows/.gitignore | 2 +
> windows/netuio/README.rst | 58 +++++
> windows/netuio/netuio.inf | 77 ++++++
> windows/netuio/netuio.sln | 24 ++
> windows/netuio/netuio.vcxproj | 113 +++++++++
> windows/netuio/netuio.vcxproj.filters | 54 +++++
> windows/netuio/netuio_dev.c | 273 +++++++++++++++++++++
> windows/netuio/netuio_dev.h | 66 +++++
> windows/netuio/netuio_drv.c | 131 ++++++++++
> windows/netuio/netuio_drv.h | 30 +++
> windows/netuio/netuio_interface.h | 88 +++++++
> windows/netuio/netuio_queue.c | 334 ++++++++++++++++++++++++++
> windows/netuio/netuio_queue.h | 21 ++
> 14 files changed, 1275 insertions(+)
> create mode 100644 windows/.gitattributes
> create mode 100644 windows/.gitignore
> create mode 100644 windows/netuio/README.rst
> create mode 100644 windows/netuio/netuio.inf
> create mode 100644 windows/netuio/netuio.sln
> create mode 100644 windows/netuio/netuio.vcxproj
> create mode 100644 windows/netuio/netuio.vcxproj.filters
> create mode 100644 windows/netuio/netuio_dev.c
> create mode 100644 windows/netuio/netuio_dev.h
> create mode 100644 windows/netuio/netuio_drv.c
> create mode 100644 windows/netuio/netuio_drv.h
> create mode 100644 windows/netuio/netuio_interface.h
> create mode 100644 windows/netuio/netuio_queue.c
> create mode 100644 windows/netuio/netuio_queue.h
<snip>
> diff --git a/windows/netuio/netuio_interface.h b/windows/netuio/netuio_interface.h
> new file mode 100644
> index 000000000..232b5bc2d
> --- /dev/null
> +++ b/windows/netuio/netuio_interface.h
> @@ -0,0 +1,88 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2020 Microsoft Corporation.
> + */
> +
> + /**
> + * @file netuio kernel driver interface
> + */
> +
> +#ifndef NETUIO_INTERFACE_H
> +#define NETUIO_INTERFACE_H
> +
> +/**
> + * All structures in this file are packed on an 8B boundary.
> + */
> +#pragma pack(push)
> +#pragma pack(8)
> +
> +/**
> + * Define an Interface Guid so that any app can find the device and talk to it.
> + */
> +DEFINE_GUID (GUID_DEVINTERFACE_netUIO, 0x08336f60,0x0679,0x4c6c,0x85,0xd2,0xae,0x7c,0xed,0x65,0xff,0xf7); // {08336f60-0679-4c6c-85d2-ae7ced65fff7}
> +
> +/**
> + * Device name definitions
> + */
> +#define NETUIO_DEVICE_SYMBOLIC_LINK_UNICODE L"\\DosDevices\\netuio"
> +#define NETUIO_MAX_SYMLINK_LEN 255
> +
> +/**
> + * IOCTL_NETUIO_MAP_HW_INTO_USERMODE is used for mapping the device registers
> + * into userspace. It returns the physical address, virtual address
> + * and the size of the memory region where the BARs were mapped.
> + */
> +#define IOCTL_NETUIO_MAP_HW_INTO_USERMODE CTL_CODE(FILE_DEVICE_NETWORK, 51, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
Not critical, but can we rename this IOCTL code to
IOCTL_NETUIO_MAP_HW_INTO_USERSPACE since that seems more appropriate and it is what the comment is referring to?
<snip>
ranjit m.
More information about the dev
mailing list