Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | **************************************************************************** |
| 3 | *** |
| 4 | *** This header was automatically generated from a Linux kernel header |
| 5 | *** of the same name, to make information necessary for userspace to |
| 6 | *** call into the kernel available to libc. It contains only constants, |
| 7 | *** structures, and macros generated from the original header, and thus, |
| 8 | *** contains no copyrightable information. |
| 9 | *** |
| 10 | *** To edit the content of this header, modify the corresponding |
| 11 | *** source file (e.g. under external/kernel-headers/original/) then |
| 12 | *** run bionic/libc/kernel/tools/update_all.py |
| 13 | *** |
| 14 | *** Any manual change here will be lost the next time this script will |
| 15 | *** be run. You've been warned! |
| 16 | *** |
| 17 | **************************************************************************** |
| 18 | ****************************************************************************/ |
| 19 | #ifndef USER_BLK_DRV_CMD_INC_H |
| 20 | #define USER_BLK_DRV_CMD_INC_H |
| 21 | #include <linux/types.h> |
| 22 | #define UBLK_CMD_GET_QUEUE_AFFINITY 0x01 |
| 23 | #define UBLK_CMD_GET_DEV_INFO 0x02 |
| 24 | #define UBLK_CMD_ADD_DEV 0x04 |
| 25 | #define UBLK_CMD_DEL_DEV 0x05 |
| 26 | #define UBLK_CMD_START_DEV 0x06 |
| 27 | #define UBLK_CMD_STOP_DEV 0x07 |
| 28 | #define UBLK_CMD_SET_PARAMS 0x08 |
| 29 | #define UBLK_CMD_GET_PARAMS 0x09 |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 30 | #define UBLK_CMD_START_USER_RECOVERY 0x10 |
| 31 | #define UBLK_CMD_END_USER_RECOVERY 0x11 |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame^] | 32 | #define UBLK_CMD_GET_DEV_INFO2 0x12 |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 33 | #define UBLK_IO_FETCH_REQ 0x20 |
| 34 | #define UBLK_IO_COMMIT_AND_FETCH_REQ 0x21 |
| 35 | #define UBLK_IO_NEED_GET_DATA 0x22 |
| 36 | #define UBLK_IO_RES_OK 0 |
| 37 | #define UBLK_IO_RES_NEED_GET_DATA 1 |
| 38 | #define UBLK_IO_RES_ABORT (- ENODEV) |
| 39 | #define UBLKSRV_CMD_BUF_OFFSET 0 |
| 40 | #define UBLKSRV_IO_BUF_OFFSET 0x80000000 |
| 41 | #define UBLK_MAX_QUEUE_DEPTH 4096 |
| 42 | #define UBLK_F_SUPPORT_ZERO_COPY (1ULL << 0) |
| 43 | #define UBLK_F_URING_CMD_COMP_IN_TASK (1ULL << 1) |
| 44 | #define UBLK_F_NEED_GET_DATA (1UL << 2) |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 45 | #define UBLK_F_USER_RECOVERY (1UL << 3) |
| 46 | #define UBLK_F_USER_RECOVERY_REISSUE (1UL << 4) |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame^] | 47 | #define UBLK_F_UNPRIVILEGED_DEV (1UL << 5) |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 48 | #define UBLK_S_DEV_DEAD 0 |
| 49 | #define UBLK_S_DEV_LIVE 1 |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 50 | #define UBLK_S_DEV_QUIESCED 2 |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 51 | struct ublksrv_ctrl_cmd { |
| 52 | __u32 dev_id; |
| 53 | __u16 queue_id; |
| 54 | __u16 len; |
| 55 | __u64 addr; |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame^] | 56 | __u64 data[1]; |
| 57 | __u16 dev_path_len; |
| 58 | __u16 pad; |
| 59 | __u32 reserved; |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 60 | }; |
| 61 | struct ublksrv_ctrl_dev_info { |
| 62 | __u16 nr_hw_queues; |
| 63 | __u16 queue_depth; |
| 64 | __u16 state; |
| 65 | __u16 pad0; |
| 66 | __u32 max_io_buf_bytes; |
| 67 | __u32 dev_id; |
| 68 | __s32 ublksrv_pid; |
| 69 | __u32 pad1; |
| 70 | __u64 flags; |
| 71 | __u64 ublksrv_flags; |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame^] | 72 | __u32 owner_uid; |
| 73 | __u32 owner_gid; |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 74 | __u64 reserved1; |
| 75 | __u64 reserved2; |
| 76 | }; |
| 77 | #define UBLK_IO_OP_READ 0 |
| 78 | #define UBLK_IO_OP_WRITE 1 |
| 79 | #define UBLK_IO_OP_FLUSH 2 |
| 80 | #define UBLK_IO_OP_DISCARD 3 |
| 81 | #define UBLK_IO_OP_WRITE_SAME 4 |
| 82 | #define UBLK_IO_OP_WRITE_ZEROES 5 |
| 83 | #define UBLK_IO_F_FAILFAST_DEV (1U << 8) |
| 84 | #define UBLK_IO_F_FAILFAST_TRANSPORT (1U << 9) |
| 85 | #define UBLK_IO_F_FAILFAST_DRIVER (1U << 10) |
| 86 | #define UBLK_IO_F_META (1U << 11) |
| 87 | #define UBLK_IO_F_FUA (1U << 13) |
| 88 | #define UBLK_IO_F_NOUNMAP (1U << 15) |
| 89 | #define UBLK_IO_F_SWAP (1U << 16) |
| 90 | struct ublksrv_io_desc { |
| 91 | __u32 op_flags; |
| 92 | __u32 nr_sectors; |
| 93 | __u64 start_sector; |
| 94 | __u64 addr; |
| 95 | }; |
| 96 | struct ublksrv_io_cmd { |
| 97 | __u16 q_id; |
| 98 | __u16 tag; |
| 99 | __s32 result; |
| 100 | __u64 addr; |
| 101 | }; |
| 102 | struct ublk_param_basic { |
| 103 | #define UBLK_ATTR_READ_ONLY (1 << 0) |
| 104 | #define UBLK_ATTR_ROTATIONAL (1 << 1) |
| 105 | #define UBLK_ATTR_VOLATILE_CACHE (1 << 2) |
| 106 | #define UBLK_ATTR_FUA (1 << 3) |
| 107 | __u32 attrs; |
| 108 | __u8 logical_bs_shift; |
| 109 | __u8 physical_bs_shift; |
| 110 | __u8 io_opt_shift; |
| 111 | __u8 io_min_shift; |
| 112 | __u32 max_sectors; |
| 113 | __u32 chunk_sectors; |
| 114 | __u64 dev_sectors; |
| 115 | __u64 virt_boundary_mask; |
| 116 | }; |
| 117 | struct ublk_param_discard { |
| 118 | __u32 discard_alignment; |
| 119 | __u32 discard_granularity; |
| 120 | __u32 max_discard_sectors; |
| 121 | __u32 max_write_zeroes_sectors; |
| 122 | __u16 max_discard_segments; |
| 123 | __u16 reserved0; |
| 124 | }; |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame^] | 125 | struct ublk_param_devt { |
| 126 | __u32 char_major; |
| 127 | __u32 char_minor; |
| 128 | __u32 disk_major; |
| 129 | __u32 disk_minor; |
| 130 | }; |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 131 | struct ublk_params { |
| 132 | __u32 len; |
| 133 | #define UBLK_PARAM_TYPE_BASIC (1 << 0) |
| 134 | #define UBLK_PARAM_TYPE_DISCARD (1 << 1) |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame^] | 135 | #define UBLK_PARAM_TYPE_DEVT (1 << 2) |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 136 | __u32 types; |
| 137 | struct ublk_param_basic basic; |
| 138 | struct ublk_param_discard discard; |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame^] | 139 | struct ublk_param_devt devt; |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 140 | }; |
| 141 | #endif |