| 1 | /* SPDX-License-Identifier: BSD-3-Clause |
| 2 | * Copyright(c) 2020 Microsoft Corporation. |
| 3 | */ |
| 4 | |
| 5 | /** |
| 6 | * @file netuio kernel driver interface |
| 7 | */ |
| 8 | |
| 9 | #ifndef NETUIO_INTERFACE_H |
| 10 | #define NETUIO_INTERFACE_H |
| 11 | |
| 12 | /** |
| 13 | * All structures in this file are packed on an 8B boundary. |
| 14 | */ |
| 15 | #pragma pack(push) |
| 16 | #pragma pack(8) |
| 17 | |
| 18 | /** |
| 19 | * Define an Interface Guid so that any app can find the device and talk to it. |
| 20 | */ |
| 21 | DEFINE_GUID (GUID_DEVINTERFACE_netUIO, 0x08336f60,0x0679,0x4c6c,0x85,0xd2,0xae,0x7c,0xed,0x65,0xff,0xf7); // {08336f60-0679-4c6c-85d2-ae7ced65fff7} |
| 22 | |
| 23 | /** |
| 24 | * Device name definitions |
| 25 | */ |
| 26 | #define NETUIO_DEVICE_SYMBOLIC_LINK_UNICODE L"\\DosDevices\\netuio" |
| 27 | #define NETUIO_MAX_SYMLINK_LEN 255 |
| 28 | |
| 29 | /** |
| 30 | * IOCTL_NETUIO_MAP_HW_INTO_USERSPACE is used for mapping the device registers |
| 31 | * into userspace. It returns the physical address, virtual address |
| 32 | * and the size of the memory region where the BARs were mapped. |
| 33 | */ |
| 34 | #define IOCTL_NETUIO_MAP_HW_INTO_USERSPACE CTL_CODE(FILE_DEVICE_NETWORK, 51, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) |
| 35 | |
| 36 | /** |
| 37 | * IOCTL_NETUIO_PCI_CONFIG_IO is used to read/write from/into the device |
| 38 | * configuration space. |
| 39 | * |
| 40 | * Input: |
| 41 | * - the operation type (read/write) |
| 42 | * - the offset into the device data where the operation begins |
| 43 | * - the length of data to read/write. |
| 44 | * - in case of a write operation, the data to be written to the device |
| 45 | * configuration space. |
| 46 | * |
| 47 | * Output: |
| 48 | * - in case of a read operation, the output buffer is filled |
| 49 | * with the data read from the configuration space. |
| 50 | */ |
| 51 | #define IOCTL_NETUIO_PCI_CONFIG_IO CTL_CODE(FILE_DEVICE_NETWORK, 52, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) |
| 52 | |
| 53 | struct mem_region { |
| 54 | UINT64 size; /**< memory region size */ |
| 55 | LARGE_INTEGER phys_addr; /**< physical address of the memory region */ |
| 56 | PVOID virt_addr; /**< virtual address of the memory region */ |
| 57 | PVOID user_mapped_virt_addr; /**< virtual address of the region mapped into user process context */ |
| 58 | }; |
| 59 | |
| 60 | enum pci_io { |
| 61 | PCI_IO_READ = 0, |
| 62 | PCI_IO_WRITE = 1 |
| 63 | }; |
| 64 | |
| 65 | #define PCI_MAX_BAR 6 |
| 66 | |
| 67 | struct device_info |
| 68 | { |
| 69 | struct mem_region hw[PCI_MAX_BAR]; |
| 70 | }; |
| 71 | |
| 72 | struct dpdk_pci_config_io |
| 73 | { |
| 74 | UINT32 offset; /**< offset into the device config space where the reading/writing starts */ |
| 75 | UINT8 op; /**< operation type: read or write */ |
| 76 | UINT32 access_size; /**< 1, 2, 4, or 8 bytes */ |
| 77 | |
| 78 | union dpdk_pci_config_io_data { |
| 79 | UINT8 u8; |
| 80 | UINT16 u16; |
| 81 | UINT32 u32; |
| 82 | UINT64 u64; |
| 83 | } data; /**< Data to be written, in case of write operations */ |
| 84 | }; |
| 85 | |
| 86 | #pragma pack(pop) |
| 87 | |
| 88 | #endif // NETUIO_INTERFACE_H |