• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
30 #define UBLK_CMD_START_USER_RECOVERY 0x10
31 #define UBLK_CMD_END_USER_RECOVERY 0x11
32 #define UBLK_IO_FETCH_REQ 0x20
33 #define UBLK_IO_COMMIT_AND_FETCH_REQ 0x21
34 #define UBLK_IO_NEED_GET_DATA 0x22
35 #define UBLK_IO_RES_OK 0
36 #define UBLK_IO_RES_NEED_GET_DATA 1
37 #define UBLK_IO_RES_ABORT (- ENODEV)
38 #define UBLKSRV_CMD_BUF_OFFSET 0
39 #define UBLKSRV_IO_BUF_OFFSET 0x80000000
40 #define UBLK_MAX_QUEUE_DEPTH 4096
41 #define UBLK_F_SUPPORT_ZERO_COPY (1ULL << 0)
42 #define UBLK_F_URING_CMD_COMP_IN_TASK (1ULL << 1)
43 #define UBLK_F_NEED_GET_DATA (1UL << 2)
44 #define UBLK_F_USER_RECOVERY (1UL << 3)
45 #define UBLK_F_USER_RECOVERY_REISSUE (1UL << 4)
46 #define UBLK_S_DEV_DEAD 0
47 #define UBLK_S_DEV_LIVE 1
48 #define UBLK_S_DEV_QUIESCED 2
49 struct ublksrv_ctrl_cmd {
50   __u32 dev_id;
51   __u16 queue_id;
52   __u16 len;
53   __u64 addr;
54   __u64 data[2];
55 };
56 struct ublksrv_ctrl_dev_info {
57   __u16 nr_hw_queues;
58   __u16 queue_depth;
59   __u16 state;
60   __u16 pad0;
61   __u32 max_io_buf_bytes;
62   __u32 dev_id;
63   __s32 ublksrv_pid;
64   __u32 pad1;
65   __u64 flags;
66   __u64 ublksrv_flags;
67   __u64 reserved0;
68   __u64 reserved1;
69   __u64 reserved2;
70 };
71 #define UBLK_IO_OP_READ 0
72 #define UBLK_IO_OP_WRITE 1
73 #define UBLK_IO_OP_FLUSH 2
74 #define UBLK_IO_OP_DISCARD 3
75 #define UBLK_IO_OP_WRITE_SAME 4
76 #define UBLK_IO_OP_WRITE_ZEROES 5
77 #define UBLK_IO_F_FAILFAST_DEV (1U << 8)
78 #define UBLK_IO_F_FAILFAST_TRANSPORT (1U << 9)
79 #define UBLK_IO_F_FAILFAST_DRIVER (1U << 10)
80 #define UBLK_IO_F_META (1U << 11)
81 #define UBLK_IO_F_FUA (1U << 13)
82 #define UBLK_IO_F_NOUNMAP (1U << 15)
83 #define UBLK_IO_F_SWAP (1U << 16)
84 struct ublksrv_io_desc {
85   __u32 op_flags;
86   __u32 nr_sectors;
87   __u64 start_sector;
88   __u64 addr;
89 };
90 struct ublksrv_io_cmd {
91   __u16 q_id;
92   __u16 tag;
93   __s32 result;
94   __u64 addr;
95 };
96 struct ublk_param_basic {
97 #define UBLK_ATTR_READ_ONLY (1 << 0)
98 #define UBLK_ATTR_ROTATIONAL (1 << 1)
99 #define UBLK_ATTR_VOLATILE_CACHE (1 << 2)
100 #define UBLK_ATTR_FUA (1 << 3)
101   __u32 attrs;
102   __u8 logical_bs_shift;
103   __u8 physical_bs_shift;
104   __u8 io_opt_shift;
105   __u8 io_min_shift;
106   __u32 max_sectors;
107   __u32 chunk_sectors;
108   __u64 dev_sectors;
109   __u64 virt_boundary_mask;
110 };
111 struct ublk_param_discard {
112   __u32 discard_alignment;
113   __u32 discard_granularity;
114   __u32 max_discard_sectors;
115   __u32 max_write_zeroes_sectors;
116   __u16 max_discard_segments;
117   __u16 reserved0;
118 };
119 struct ublk_params {
120   __u32 len;
121 #define UBLK_PARAM_TYPE_BASIC (1 << 0)
122 #define UBLK_PARAM_TYPE_DISCARD (1 << 1)
123   __u32 types;
124   struct ublk_param_basic basic;
125   struct ublk_param_discard discard;
126 };
127 #endif
128