| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
| /* const.h: Macros for dealing with constants. */ | ||
|
|
||
| #ifndef _LINUX_CONST_H | ||
| #define _LINUX_CONST_H | ||
|
|
||
| /* Some constant macros are used in both assembler and | ||
| * C code. Therefore we cannot annotate them always with | ||
| * 'UL' and other type specifiers unilaterally. We | ||
| * use the following macros to deal with this. | ||
| * | ||
| * Similarly, _AT() will cast an expression with a type in C, but | ||
| * leave it unchanged in asm. | ||
| */ | ||
|
|
||
| #ifdef __ASSEMBLY__ | ||
| #define _AC(X,Y) X | ||
| #define _AT(T,X) X | ||
| #else | ||
| #define __AC(X,Y) (X##Y) | ||
| #define _AC(X,Y) __AC(X,Y) | ||
| #define _AT(T,X) ((T)(X)) | ||
| #endif | ||
|
|
||
| #define _UL(x) (_AC(x, UL)) | ||
| #define _ULL(x) (_AC(x, ULL)) | ||
|
|
||
| #define _BITUL(x) (_UL(1) << (x)) | ||
| #define _BITULL(x) (_ULL(1) << (x)) | ||
|
|
||
| #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) | ||
| #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) | ||
|
|
||
| #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) | ||
|
|
||
| #endif /* _LINUX_CONST_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
| #ifndef _LINUX_MEMFD_H | ||
| #define _LINUX_MEMFD_H | ||
|
|
||
| #include <asm-generic/hugetlb_encode.h> | ||
|
|
||
| /* flags for memfd_create(2) (unsigned int) */ | ||
| #define MFD_CLOEXEC 0x0001U | ||
| #define MFD_ALLOW_SEALING 0x0002U | ||
| #define MFD_HUGETLB 0x0004U | ||
| /* not executable and sealed to prevent changing to executable. */ | ||
| #define MFD_NOEXEC_SEAL 0x0008U | ||
| /* executable */ | ||
| #define MFD_EXEC 0x0010U | ||
|
|
||
| /* | ||
| * Huge page size encoding when MFD_HUGETLB is specified, and a huge page | ||
| * size other than the default is desired. See hugetlb_encode.h. | ||
| * All known huge page size encodings are provided here. It is the | ||
| * responsibility of the application to know which sizes are supported on | ||
| * the running system. See mmap(2) man page for details. | ||
| */ | ||
| #define MFD_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT | ||
| #define MFD_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK | ||
|
|
||
| #define MFD_HUGE_64KB HUGETLB_FLAG_ENCODE_64KB | ||
| #define MFD_HUGE_512KB HUGETLB_FLAG_ENCODE_512KB | ||
| #define MFD_HUGE_1MB HUGETLB_FLAG_ENCODE_1MB | ||
| #define MFD_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB | ||
| #define MFD_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB | ||
| #define MFD_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB | ||
| #define MFD_HUGE_32MB HUGETLB_FLAG_ENCODE_32MB | ||
| #define MFD_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB | ||
| #define MFD_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB | ||
| #define MFD_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB | ||
| #define MFD_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB | ||
| #define MFD_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB | ||
|
|
||
| #endif /* _LINUX_MEMFD_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
| /* | ||
| * Definitions for the NVM Express ioctl interface | ||
| * Copyright (c) 2011-2014, Intel Corporation. | ||
| */ | ||
|
|
||
| #ifndef _LINUX_NVME_IOCTL_H | ||
| #define _LINUX_NVME_IOCTL_H | ||
|
|
||
| #include <linux/types.h> | ||
|
|
||
| struct nvme_user_io { | ||
| __u8 opcode; | ||
| __u8 flags; | ||
| __u16 control; | ||
| __u16 nblocks; | ||
| __u16 rsvd; | ||
| __u64 metadata; | ||
| __u64 addr; | ||
| __u64 slba; | ||
| __u32 dsmgmt; | ||
| __u32 reftag; | ||
| __u16 apptag; | ||
| __u16 appmask; | ||
| }; | ||
|
|
||
| struct nvme_passthru_cmd { | ||
| __u8 opcode; | ||
| __u8 flags; | ||
| __u16 rsvd1; | ||
| __u32 nsid; | ||
| __u32 cdw2; | ||
| __u32 cdw3; | ||
| __u64 metadata; | ||
| __u64 addr; | ||
| __u32 metadata_len; | ||
| __u32 data_len; | ||
| __u32 cdw10; | ||
| __u32 cdw11; | ||
| __u32 cdw12; | ||
| __u32 cdw13; | ||
| __u32 cdw14; | ||
| __u32 cdw15; | ||
| __u32 timeout_ms; | ||
| __u32 result; | ||
| }; | ||
|
|
||
| struct nvme_passthru_cmd64 { | ||
| __u8 opcode; | ||
| __u8 flags; | ||
| __u16 rsvd1; | ||
| __u32 nsid; | ||
| __u32 cdw2; | ||
| __u32 cdw3; | ||
| __u64 metadata; | ||
| __u64 addr; | ||
| __u32 metadata_len; | ||
| union { | ||
| __u32 data_len; /* for non-vectored io */ | ||
| __u32 vec_cnt; /* for vectored io */ | ||
| }; | ||
| __u32 cdw10; | ||
| __u32 cdw11; | ||
| __u32 cdw12; | ||
| __u32 cdw13; | ||
| __u32 cdw14; | ||
| __u32 cdw15; | ||
| __u32 timeout_ms; | ||
| __u32 rsvd2; | ||
| __u64 result; | ||
| }; | ||
|
|
||
| /* same as struct nvme_passthru_cmd64, minus the 8b result field */ | ||
| struct nvme_uring_cmd { | ||
| __u8 opcode; | ||
| __u8 flags; | ||
| __u16 rsvd1; | ||
| __u32 nsid; | ||
| __u32 cdw2; | ||
| __u32 cdw3; | ||
| __u64 metadata; | ||
| __u64 addr; | ||
| __u32 metadata_len; | ||
| __u32 data_len; | ||
| __u32 cdw10; | ||
| __u32 cdw11; | ||
| __u32 cdw12; | ||
| __u32 cdw13; | ||
| __u32 cdw14; | ||
| __u32 cdw15; | ||
| __u32 timeout_ms; | ||
| __u32 rsvd2; | ||
| }; | ||
|
|
||
| #define nvme_admin_cmd nvme_passthru_cmd | ||
|
|
||
| #define NVME_IOCTL_ID _IO('N', 0x40) | ||
| #define NVME_IOCTL_ADMIN_CMD _IOWR('N', 0x41, struct nvme_admin_cmd) | ||
| #define NVME_IOCTL_SUBMIT_IO _IOW('N', 0x42, struct nvme_user_io) | ||
| #define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd) | ||
| #define NVME_IOCTL_RESET _IO('N', 0x44) | ||
| #define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45) | ||
| #define NVME_IOCTL_RESCAN _IO('N', 0x46) | ||
| #define NVME_IOCTL_ADMIN64_CMD _IOWR('N', 0x47, struct nvme_passthru_cmd64) | ||
| #define NVME_IOCTL_IO64_CMD _IOWR('N', 0x48, struct nvme_passthru_cmd64) | ||
| #define NVME_IOCTL_IO64_CMD_VEC _IOWR('N', 0x49, struct nvme_passthru_cmd64) | ||
|
|
||
| /* io_uring async commands: */ | ||
| #define NVME_URING_CMD_IO _IOWR('N', 0x80, struct nvme_uring_cmd) | ||
| #define NVME_URING_CMD_IO_VEC _IOWR('N', 0x81, struct nvme_uring_cmd) | ||
| #define NVME_URING_CMD_ADMIN _IOWR('N', 0x82, struct nvme_uring_cmd) | ||
| #define NVME_URING_CMD_ADMIN_VEC _IOWR('N', 0x83, struct nvme_uring_cmd) | ||
|
|
||
| #endif /* _LINUX_NVME_IOCTL_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
| #ifndef _LINUX_STDDEF_H | ||
| #define _LINUX_STDDEF_H | ||
|
|
||
|
|
||
|
|
||
| #ifndef __always_inline | ||
| #define __always_inline __inline__ | ||
| #endif | ||
|
|
||
| /** | ||
| * __struct_group() - Create a mirrored named and anonyomous struct | ||
| * | ||
| * @TAG: The tag name for the named sub-struct (usually empty) | ||
| * @NAME: The identifier name of the mirrored sub-struct | ||
| * @ATTRS: Any struct attributes (usually empty) | ||
| * @MEMBERS: The member declarations for the mirrored structs | ||
| * | ||
| * Used to create an anonymous union of two structs with identical layout | ||
| * and size: one anonymous and one named. The former's members can be used | ||
| * normally without sub-struct naming, and the latter can be used to | ||
| * reason about the start, end, and size of the group of struct members. | ||
| * The named struct can also be explicitly tagged for layer reuse, as well | ||
| * as both having struct attributes appended. | ||
| */ | ||
| #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \ | ||
| union { \ | ||
| struct { MEMBERS } ATTRS; \ | ||
| struct TAG { MEMBERS } ATTRS NAME; \ | ||
| } | ||
|
|
||
| /** | ||
| * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union | ||
| * | ||
| * @TYPE: The type of each flexible array element | ||
| * @NAME: The name of the flexible array member | ||
| * | ||
| * In order to have a flexible array member in a union or alone in a | ||
| * struct, it needs to be wrapped in an anonymous struct with at least 1 | ||
| * named member, but that member can be empty. | ||
| */ | ||
| #define __DECLARE_FLEX_ARRAY(TYPE, NAME) \ | ||
| struct { \ | ||
| struct { } __empty_ ## NAME; \ | ||
| TYPE NAME[]; \ | ||
| } | ||
| #endif |