Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/gasket/gasket_ioctl.h
- This file was added.
| /* | |||||
| * Copyright (c) 2026 Abdelkader Boudih <freebsd@seuros.com> | |||||
| * | |||||
| * SPDX-License-Identifier: BSD-2-Clause | |||||
| */ | |||||
| /* | |||||
| * Structure layouts match Google's Linux gasket driver so a ported user space | |||||
| * library can share them. The command numbers use native FreeBSD encoding. | |||||
| */ | |||||
| #ifndef _DEV_GASKET_GASKET_IOCTL_H_ | |||||
| #define _DEV_GASKET_GASKET_IOCTL_H_ | |||||
| #include <sys/ioccom.h> | |||||
| #include <sys/types.h> | |||||
| struct gasket_page_table_ioctl { | |||||
| uint64_t page_table_index; | |||||
| uint64_t size; | |||||
| uint64_t host_address; | |||||
| uint64_t device_address; | |||||
| }; | |||||
| #define GASKET_PTE_INUSE 0x1 | |||||
| #define GASKET_DMA_BIDIRECTIONAL (0 << 1) | |||||
| #define GASKET_DMA_TO_DEVICE (1 << 1) | |||||
| #define GASKET_DMA_FROM_DEVICE (2 << 1) | |||||
| #define GASKET_DMA_NONE (3 << 1) | |||||
| /* | |||||
| * The padding is deliberate: without it this structure is 40 bytes where | |||||
| * uint64_t aligns to 8 and 36 where it aligns to 4, and since the size is | |||||
| * encoded into the command number, a 32 bit process would compute a different | |||||
| * GASKET_IOCTL_MAP_BUFFER_FLAGS and get ENOTTY. | |||||
| */ | |||||
| struct gasket_page_table_ioctl_flags { | |||||
| struct gasket_page_table_ioctl base; | |||||
| uint32_t flags; | |||||
| uint32_t _pad; | |||||
| }; | |||||
| struct gasket_coherent_alloc_config_ioctl { | |||||
| uint64_t page_table_index; | |||||
| uint64_t enable; | |||||
| uint64_t size; | |||||
| uint64_t dma_address; | |||||
| }; | |||||
| struct gasket_interrupt_event { | |||||
| uint32_t gie_interrupt; | |||||
| uint32_t gie_dropped; /* lost before this one */ | |||||
| uint64_t gie_count; /* cumulative for this interrupt */ | |||||
| }; | |||||
| /* | |||||
| * Same macros and group as Google's shared gasket_ioctl.h, so a user space | |||||
| * library including that header computes identical values. Only the encoding | |||||
| * differs from Linux, and that falls out of <sys/ioccom.h>. | |||||
| */ | |||||
| #define GASKET_IOC_GROUP 0xDC | |||||
| #define GASKET_IOCTL_RESET _IO(GASKET_IOC_GROUP, 0) | |||||
| #define GASKET_IOCTL_NUMBER_PAGE_TABLES _IOR(GASKET_IOC_GROUP, 4, uint64_t) | |||||
| #define GASKET_IOCTL_PAGE_TABLE_SIZE \ | |||||
| _IOWR(GASKET_IOC_GROUP, 5, struct gasket_page_table_ioctl) | |||||
| #define GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE \ | |||||
| _IOWR(GASKET_IOC_GROUP, 6, struct gasket_page_table_ioctl) | |||||
| #define GASKET_IOCTL_PARTITION_PAGE_TABLE \ | |||||
| _IOW(GASKET_IOC_GROUP, 7, struct gasket_page_table_ioctl) | |||||
| #define GASKET_IOCTL_MAP_BUFFER \ | |||||
| _IOW(GASKET_IOC_GROUP, 8, struct gasket_page_table_ioctl) | |||||
| #define GASKET_IOCTL_UNMAP_BUFFER \ | |||||
| _IOW(GASKET_IOC_GROUP, 9, struct gasket_page_table_ioctl) | |||||
| #define GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS _IO(GASKET_IOC_GROUP, 10) | |||||
| #define GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR \ | |||||
| _IOWR(GASKET_IOC_GROUP, 11, struct gasket_coherent_alloc_config_ioctl) | |||||
| #define GASKET_IOCTL_MAP_BUFFER_FLAGS \ | |||||
| _IOW(GASKET_IOC_GROUP, 12, struct gasket_page_table_ioctl_flags) | |||||
| #ifdef _KERNEL | |||||
| _Static_assert(sizeof(struct gasket_page_table_ioctl) == 32, | |||||
| "gasket_page_table_ioctl changed size, breaking the ioctl ABI"); | |||||
| _Static_assert(sizeof(struct gasket_page_table_ioctl_flags) == 40, | |||||
| "gasket_page_table_ioctl_flags changed size, breaking the ioctl ABI"); | |||||
| _Static_assert(sizeof(struct gasket_coherent_alloc_config_ioctl) == 32, | |||||
| "gasket_coherent_alloc_config_ioctl changed size, breaking the ioctl ABI"); | |||||
| _Static_assert(sizeof(struct gasket_interrupt_event) == 16, | |||||
| "gasket_interrupt_event changed size, breaking the read(2) ABI"); | |||||
| #endif | |||||
| #endif /* _DEV_GASKET_GASKET_IOCTL_H_ */ | |||||