windows/netuio: add interrupt support
PATCH 1/1 windows/netuio: add interrupt support
Add IOCTL for interrupt event delivery to user space.
* IOCTL_NETUIO_INTR_CONTROL:
Enable/disable the delivery of interrupt events.
This is a software switch to ignore received interrupts. Programming the HW to stop issuing interrupts is up to the user.
* IOCTL_NETUIO_INTR_QUERY:
Wait for an interrupt event on the specified vector.
More than one outstanding request may be issued for the same vector. This can be used to balance the interrupt servicing if the requests are issued using distinct handles waited by different threads. If N identical requests are issued using the same handle, one request will be completed each time the interrupt is triggered.
MSI-X support is advertised for the driver, but the implementation works with any type of interrupts assigned by the kernel.
--- windows/netuio/netuio.inf | 3 + windows/netuio/netuio_dev.c | 109 +++++++++++++++++++++++++++++- windows/netuio/netuio_dev.h | 10 +++ windows/netuio/netuio_interface.h | 22 ++++++ windows/netuio/netuio_queue.c | 102 ++++++++++++++++++++-------- 5 files changed, 214 insertions(+), 32 deletions(-)
windows/netuio/netuio.inf +3 -0
@@ -63,6 +63,9 @@ AddReg=Device.HW.Registry [Device.HW.Registry] ; Ensure that only administrators can access our device object. HKR,,Security,,"D:P(A;;GA;;;SY)(A;;GA;;;BA)" +HKR,Interrupt Management,,0x00000010 +HKR,Interrupt Management\MessageSignaledInterruptProperties,,0x00000010 +HKR,Interrupt Management\MessageSignaledInterruptProperties,MSISupported,0x00010001,1 ;-------------- Service installation [netuio_Device.NT.Services]
windows/netuio/netuio_dev.c +107 -2
134 lines not on this page · raw message
windows/netuio/netuio_dev.h +10 -0
@@ -24,6 +24,13 @@ struct dev_addr {USHORT func_num; }; +/** Interrupt vector associated data. */ +typedef struct NETUIO_INTR_CTX { +WDFQUEUE queue;/**< Queue of requests for this interrupt. */ +}NETUIO_INTR_CTX ; + +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME (NETUIO_INTR_CTX , netuio_intr_ctx_get); +/** * The device context performs the same job as a WDM device extension in the driver frameworks */
@@ -34,6 +41,9 @@ typedef struct _NETUIO_CONTEXT_DATAstruct pci_bar bar[PCI_MAX_BAR ];/**< device BARs */ struct dev_addr addr;/**< B:D:F details of device */ struct mem_map_region dpdk_hw[PCI_MAX_BAR ];/**< mapped region for the device's register space */ +BOOLEAN intr_enabled;/**< Whether interrupt delivery is enabled. */ +WDFINTERRUPT *intr;/**< Interrupt objects indexed by vector. */ +size_t intr_n;/**< Number of interrupt objects. */ }NETUIO_CONTEXT_DATA , *PNETUIO_CONTEXT_DATA ;
windows/netuio/netuio_interface.h +22 -0
@@ -50,6 +50,20 @@ DEFINE_GUID (GUID_DEVINTERFACE_netUIO, 0x08336f60,0x0679,0x4c6c,0x85,0xd2,0xae,0*/ #define IOCTL_NETUIO_PCI_CONFIG_IO CTL_CODE(FILE_DEVICE_NETWORK, 52, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) +/** +* Control whether interrupts are enabled. +* Input: struct netuio_intr_control +* Output: N/A +*/ +#define IOCTL_NETUIO_INTR_CONTROL CTL_CODE(FILE_DEVICE_NETWORK, 53, METHOD_BUFFERED, FILE_ANY_ACCESS) + +/** +* Wait until an interrupt occurs. +* Input: struct netuio_intr_query +* Output: N/A +*/ +#define IOCTL_NETUIO_INTR_QUERY CTL_CODE(FILE_DEVICE_NETWORK, 54, METHOD_BUFFERED, FILE_ANY_ACCESS) +struct mem_region {UINT64 size;/**< memory region size */ LARGE_INTEGER phys_addr;/**< physical address of the memory region */
@@ -83,6 +97,14 @@ struct dpdk_pci_config_io } data; /**< Data to be written, in case of write operations */ }; +struct netuio_intr_control { +UINT32 enable;/**< 1 to enable interrupts, 0 to disable */ +}; + +struct netuio_intr_query { +UINT32 vector;/**< Vector of the interrupt to wait for. */ +}; +#pragma pack(pop)#endif // NETUIO_INTERFACE_H
windows/netuio/netuio_queue.c +72 -30
122 lines not on this page · raw message
Signature · 1 line
2.29.3
Quoted 16 lines · Dmitry Kozlyuk
Add IOCTL for interrupt event delivery to user space.
*
IOCTL_NETUIO_INTR_CONTROL:
Enable/disable the delivery of interrupt events.
This is a software switch to ignore received interrupts. Programming the HW to stop issuing interrupts is up to the user.*
IOCTL_NETUIO_INTR_QUERY:
Wait for an interrupt event on the specified vector.
More than one outstanding request may be issued for the same vector. This can be used to balance the interrupt servicing if the requests are issued using distinct handles waited by different threads. If N identical requests are issued using the same handle, one request will be completed each time the interrupt is triggered.
Quoted 5 lines
MSI-X support is advertised for the driver, but the implementation works with any type of interrupts assigned by the kernel.
Signed-off-by Dmitry Kozlyuk <[email protected]>---
Hi Dmitry,
Is there a corresponding userspace code so I can give it a try? s.t like sending IOCTL_NETUIO_INTR_CONTROL to enable a device's interrupt, and blocked at IOCTL_NETUIO_INTR_QUERY for incoming request in the intr_queue. Thanks
William
2021-10-12 04:11 (UTC+0300), Dmitry Kozlyuk:
Quoted 1 line
[...]
This patchset is not supposed to be merged for now.
It should have been marked as RFC, sorry for the misleading title.
Offline discussions revealed a conflict between edge-triggered interrupts in DPDK contract
and level-triggered IO completions used by this patch and the corresponding userspace part.
I'm experimenting with alternative approaches
and will send a new implementation
when both the kernel and the userspace parts are ready. Thanks to William for preliminary testing
and to Mark for sharing his experience with some alternatives.