1 /* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note */
2 /*
3  * Copyright (C) 2020 Google, Inc
4  * Copyright (C) 2020 Palmer Dabbelt <palmerdabbelt@google.com>
5  */
6 
7 #ifndef _LINUX_DM_USER_H
8 #define _LINUX_DM_USER_H
9 
10 #include <linux/types.h>
11 
12 /*
13  * dm-user proxies device mapper ops between the kernel and userspace.  It's
14  * essentially just an RPC mechanism: all kernel calls create a request,
15  * userspace handles that with a response.  Userspace obtains requests via
16  * read() and provides responses via write().
17  *
18  * See Documentation/block/dm-user.rst for more information.
19  */
20 
21 #define DM_USER_REQ_MAP_READ 0
22 #define DM_USER_REQ_MAP_WRITE 1
23 #define DM_USER_REQ_MAP_FLUSH 2
24 #define DM_USER_REQ_MAP_DISCARD 3
25 #define DM_USER_REQ_MAP_SECURE_ERASE 4
26 #define DM_USER_REQ_MAP_WRITE_SAME 5
27 #define DM_USER_REQ_MAP_WRITE_ZEROES 6
28 #define DM_USER_REQ_MAP_ZONE_OPEN 7
29 #define DM_USER_REQ_MAP_ZONE_CLOSE 8
30 #define DM_USER_REQ_MAP_ZONE_FINISH 9
31 #define DM_USER_REQ_MAP_ZONE_APPEND 10
32 #define DM_USER_REQ_MAP_ZONE_RESET 11
33 #define DM_USER_REQ_MAP_ZONE_RESET_ALL 12
34 
35 #define DM_USER_REQ_MAP_FLAG_FAILFAST_DEV 0x00001
36 #define DM_USER_REQ_MAP_FLAG_FAILFAST_TRANSPORT 0x00002
37 #define DM_USER_REQ_MAP_FLAG_FAILFAST_DRIVER 0x00004
38 #define DM_USER_REQ_MAP_FLAG_SYNC 0x00008
39 #define DM_USER_REQ_MAP_FLAG_META 0x00010
40 #define DM_USER_REQ_MAP_FLAG_PRIO 0x00020
41 #define DM_USER_REQ_MAP_FLAG_NOMERGE 0x00040
42 #define DM_USER_REQ_MAP_FLAG_IDLE 0x00080
43 #define DM_USER_REQ_MAP_FLAG_INTEGRITY 0x00100
44 #define DM_USER_REQ_MAP_FLAG_FUA 0x00200
45 #define DM_USER_REQ_MAP_FLAG_PREFLUSH 0x00400
46 #define DM_USER_REQ_MAP_FLAG_RAHEAD 0x00800
47 #define DM_USER_REQ_MAP_FLAG_BACKGROUND 0x01000
48 #define DM_USER_REQ_MAP_FLAG_NOWAIT 0x02000
49 #define DM_USER_REQ_MAP_FLAG_CGROUP_PUNT 0x04000
50 #define DM_USER_REQ_MAP_FLAG_NOUNMAP 0x08000
51 #define DM_USER_REQ_MAP_FLAG_HIPRI 0x10000
52 #define DM_USER_REQ_MAP_FLAG_DRV 0x20000
53 #define DM_USER_REQ_MAP_FLAG_SWAP 0x40000
54 
55 #define DM_USER_RESP_SUCCESS 0
56 #define DM_USER_RESP_ERROR 1
57 #define DM_USER_RESP_UNSUPPORTED 2
58 
59 struct dm_user_message {
60 	__u64 seq;
61 	__u64 type;
62 	__u64 flags;
63 	__u64 sector;
64 	__u64 len;
65 	__u8 buf[];
66 };
67 
68 #endif
69