• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is auto-generated. Modifications will be lost.
3  *
4  * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5  * for more information.
6  */
7 #ifndef USER_BLK_DRV_CMD_INC_H
8 #define USER_BLK_DRV_CMD_INC_H
9 #include <linux/types.h>
10 #define UBLK_CMD_GET_QUEUE_AFFINITY 0x01
11 #define UBLK_CMD_GET_DEV_INFO 0x02
12 #define UBLK_CMD_ADD_DEV 0x04
13 #define UBLK_CMD_DEL_DEV 0x05
14 #define UBLK_CMD_START_DEV 0x06
15 #define UBLK_CMD_STOP_DEV 0x07
16 #define UBLK_CMD_SET_PARAMS 0x08
17 #define UBLK_CMD_GET_PARAMS 0x09
18 #define UBLK_CMD_START_USER_RECOVERY 0x10
19 #define UBLK_CMD_END_USER_RECOVERY 0x11
20 #define UBLK_CMD_GET_DEV_INFO2 0x12
21 #define UBLK_U_CMD_GET_QUEUE_AFFINITY _IOR('u', UBLK_CMD_GET_QUEUE_AFFINITY, struct ublksrv_ctrl_cmd)
22 #define UBLK_U_CMD_GET_DEV_INFO _IOR('u', UBLK_CMD_GET_DEV_INFO, struct ublksrv_ctrl_cmd)
23 #define UBLK_U_CMD_ADD_DEV _IOWR('u', UBLK_CMD_ADD_DEV, struct ublksrv_ctrl_cmd)
24 #define UBLK_U_CMD_DEL_DEV _IOWR('u', UBLK_CMD_DEL_DEV, struct ublksrv_ctrl_cmd)
25 #define UBLK_U_CMD_START_DEV _IOWR('u', UBLK_CMD_START_DEV, struct ublksrv_ctrl_cmd)
26 #define UBLK_U_CMD_STOP_DEV _IOWR('u', UBLK_CMD_STOP_DEV, struct ublksrv_ctrl_cmd)
27 #define UBLK_U_CMD_SET_PARAMS _IOWR('u', UBLK_CMD_SET_PARAMS, struct ublksrv_ctrl_cmd)
28 #define UBLK_U_CMD_GET_PARAMS _IOR('u', UBLK_CMD_GET_PARAMS, struct ublksrv_ctrl_cmd)
29 #define UBLK_U_CMD_START_USER_RECOVERY _IOWR('u', UBLK_CMD_START_USER_RECOVERY, struct ublksrv_ctrl_cmd)
30 #define UBLK_U_CMD_END_USER_RECOVERY _IOWR('u', UBLK_CMD_END_USER_RECOVERY, struct ublksrv_ctrl_cmd)
31 #define UBLK_U_CMD_GET_DEV_INFO2 _IOR('u', UBLK_CMD_GET_DEV_INFO2, struct ublksrv_ctrl_cmd)
32 #define UBLK_U_CMD_GET_FEATURES _IOR('u', 0x13, struct ublksrv_ctrl_cmd)
33 #define UBLK_U_CMD_DEL_DEV_ASYNC _IOR('u', 0x14, struct ublksrv_ctrl_cmd)
34 #define UBLK_FEATURES_LEN 8
35 #define UBLK_IO_FETCH_REQ 0x20
36 #define UBLK_IO_COMMIT_AND_FETCH_REQ 0x21
37 #define UBLK_IO_NEED_GET_DATA 0x22
38 #define UBLK_U_IO_FETCH_REQ _IOWR('u', UBLK_IO_FETCH_REQ, struct ublksrv_io_cmd)
39 #define UBLK_U_IO_COMMIT_AND_FETCH_REQ _IOWR('u', UBLK_IO_COMMIT_AND_FETCH_REQ, struct ublksrv_io_cmd)
40 #define UBLK_U_IO_NEED_GET_DATA _IOWR('u', UBLK_IO_NEED_GET_DATA, struct ublksrv_io_cmd)
41 #define UBLK_IO_RES_OK 0
42 #define UBLK_IO_RES_NEED_GET_DATA 1
43 #define UBLK_IO_RES_ABORT (- ENODEV)
44 #define UBLKSRV_CMD_BUF_OFFSET 0
45 #define UBLKSRV_IO_BUF_OFFSET 0x80000000
46 #define UBLK_MAX_QUEUE_DEPTH 4096
47 #define UBLK_IO_BUF_OFF 0
48 #define UBLK_IO_BUF_BITS 25
49 #define UBLK_IO_BUF_BITS_MASK ((1ULL << UBLK_IO_BUF_BITS) - 1)
50 #define UBLK_TAG_OFF UBLK_IO_BUF_BITS
51 #define UBLK_TAG_BITS 16
52 #define UBLK_TAG_BITS_MASK ((1ULL << UBLK_TAG_BITS) - 1)
53 #define UBLK_QID_OFF (UBLK_TAG_OFF + UBLK_TAG_BITS)
54 #define UBLK_QID_BITS 12
55 #define UBLK_QID_BITS_MASK ((1ULL << UBLK_QID_BITS) - 1)
56 #define UBLK_MAX_NR_QUEUES (1U << UBLK_QID_BITS)
57 #define UBLKSRV_IO_BUF_TOTAL_BITS (UBLK_QID_OFF + UBLK_QID_BITS)
58 #define UBLKSRV_IO_BUF_TOTAL_SIZE (1ULL << UBLKSRV_IO_BUF_TOTAL_BITS)
59 #define UBLK_F_SUPPORT_ZERO_COPY (1ULL << 0)
60 #define UBLK_F_URING_CMD_COMP_IN_TASK (1ULL << 1)
61 #define UBLK_F_NEED_GET_DATA (1UL << 2)
62 #define UBLK_F_USER_RECOVERY (1UL << 3)
63 #define UBLK_F_USER_RECOVERY_REISSUE (1UL << 4)
64 #define UBLK_F_UNPRIVILEGED_DEV (1UL << 5)
65 #define UBLK_F_CMD_IOCTL_ENCODE (1UL << 6)
66 #define UBLK_F_USER_COPY (1UL << 7)
67 #define UBLK_F_ZONED (1ULL << 8)
68 #define UBLK_S_DEV_DEAD 0
69 #define UBLK_S_DEV_LIVE 1
70 #define UBLK_S_DEV_QUIESCED 2
71 struct ublksrv_ctrl_cmd {
72   __u32 dev_id;
73   __u16 queue_id;
74   __u16 len;
75   __u64 addr;
76   __u64 data[1];
77   __u16 dev_path_len;
78   __u16 pad;
79   __u32 reserved;
80 };
81 struct ublksrv_ctrl_dev_info {
82   __u16 nr_hw_queues;
83   __u16 queue_depth;
84   __u16 state;
85   __u16 pad0;
86   __u32 max_io_buf_bytes;
87   __u32 dev_id;
88   __s32 ublksrv_pid;
89   __u32 pad1;
90   __u64 flags;
91   __u64 ublksrv_flags;
92   __u32 owner_uid;
93   __u32 owner_gid;
94   __u64 reserved1;
95   __u64 reserved2;
96 };
97 #define UBLK_IO_OP_READ 0
98 #define UBLK_IO_OP_WRITE 1
99 #define UBLK_IO_OP_FLUSH 2
100 #define UBLK_IO_OP_DISCARD 3
101 #define UBLK_IO_OP_WRITE_SAME 4
102 #define UBLK_IO_OP_WRITE_ZEROES 5
103 #define UBLK_IO_OP_ZONE_OPEN 10
104 #define UBLK_IO_OP_ZONE_CLOSE 11
105 #define UBLK_IO_OP_ZONE_FINISH 12
106 #define UBLK_IO_OP_ZONE_APPEND 13
107 #define UBLK_IO_OP_ZONE_RESET_ALL 14
108 #define UBLK_IO_OP_ZONE_RESET 15
109 #define UBLK_IO_OP_REPORT_ZONES 18
110 #define UBLK_IO_F_FAILFAST_DEV (1U << 8)
111 #define UBLK_IO_F_FAILFAST_TRANSPORT (1U << 9)
112 #define UBLK_IO_F_FAILFAST_DRIVER (1U << 10)
113 #define UBLK_IO_F_META (1U << 11)
114 #define UBLK_IO_F_FUA (1U << 13)
115 #define UBLK_IO_F_NOUNMAP (1U << 15)
116 #define UBLK_IO_F_SWAP (1U << 16)
117 struct ublksrv_io_desc {
118   __u32 op_flags;
119   union {
120     __u32 nr_sectors;
121     __u32 nr_zones;
122   };
123   __u64 start_sector;
124   __u64 addr;
125 };
126 struct ublksrv_io_cmd {
127   __u16 q_id;
128   __u16 tag;
129   __s32 result;
130   union {
131     __u64 addr;
132     __u64 zone_append_lba;
133   };
134 };
135 struct ublk_param_basic {
136 #define UBLK_ATTR_READ_ONLY (1 << 0)
137 #define UBLK_ATTR_ROTATIONAL (1 << 1)
138 #define UBLK_ATTR_VOLATILE_CACHE (1 << 2)
139 #define UBLK_ATTR_FUA (1 << 3)
140   __u32 attrs;
141   __u8 logical_bs_shift;
142   __u8 physical_bs_shift;
143   __u8 io_opt_shift;
144   __u8 io_min_shift;
145   __u32 max_sectors;
146   __u32 chunk_sectors;
147   __u64 dev_sectors;
148   __u64 virt_boundary_mask;
149 };
150 struct ublk_param_discard {
151   __u32 discard_alignment;
152   __u32 discard_granularity;
153   __u32 max_discard_sectors;
154   __u32 max_write_zeroes_sectors;
155   __u16 max_discard_segments;
156   __u16 reserved0;
157 };
158 struct ublk_param_devt {
159   __u32 char_major;
160   __u32 char_minor;
161   __u32 disk_major;
162   __u32 disk_minor;
163 };
164 struct ublk_param_zoned {
165   __u32 max_open_zones;
166   __u32 max_active_zones;
167   __u32 max_zone_append_sectors;
168   __u8 reserved[20];
169 };
170 struct ublk_params {
171   __u32 len;
172 #define UBLK_PARAM_TYPE_BASIC (1 << 0)
173 #define UBLK_PARAM_TYPE_DISCARD (1 << 1)
174 #define UBLK_PARAM_TYPE_DEVT (1 << 2)
175 #define UBLK_PARAM_TYPE_ZONED (1 << 3)
176   __u32 types;
177   struct ublk_param_basic basic;
178   struct ublk_param_discard discard;
179   struct ublk_param_devt devt;
180   struct ublk_param_zoned zoned;
181 };
182 #endif
183