1 #ifndef BINJECT_H
2 #define BINJECT_H
3 
4 #include <linux/types.h>
5 
6 #define BINJECT_MAGIC		0x89
7 #define BINJECT_VER		0x01
8 #define BINJECT_MAGIC_SHIFT	8
9 #define BINJECT_VER_MASK	((1 << BINJECT_MAGIC_SHIFT) - 1)
10 
11 struct b_user_cmd {
12 	__u16 magic;	/* INPUT */
13 	__u16 type;	/* INPUT */
14 	__u32 error;	/* OUTPUT */
15 	__u32 flags;	/* INPUT */
16 	__u32 len;	/* INPUT */
17 	__u64 offset;	/* INPUT */
18 	__u64 buf;	/* INPUT */
19 	__u64 usr_ptr;	/* PASSED THROUGH */
20 	__u64 nsec;	/* OUTPUT */
21 };
22 
23 struct b_ioctl_cmd {
24 	int fd;
25 	int minor;
26 };
27 
28 #define BINJECT_IOCTL_CHR	'J'
29 #define B_IOCTL_ADD		_IOWR(BINJECT_IOCTL_CHR, 1, struct b_ioctl_cmd)
30 #define B_IOCTL_DEL		_IOWR(BINJECT_IOCTL_CHR, 2, struct b_ioctl_cmd)
31 
32 enum {
33 	B_TYPE_READ		= 0,
34 	B_TYPE_WRITE,
35 	B_TYPE_DISCARD,
36 	B_TYPE_READVOID,
37 	B_TYPE_WRITEZERO,
38 	B_TYPE_READBARRIER,
39 	B_TYPE_WRITEBARRIER,
40 	B_TYPE_NR
41 };
42 
43 enum {
44 	__B_FLAG_SYNC	= 0,
45 	__B_FLAG_UNPLUG,
46 	__B_FLAG_NOIDLE,
47 	__B_FLAG_BARRIER,
48 	__B_FLAG_META,
49 	__B_FLAG_RAHEAD,
50 	__B_FLAG_FAILFAST_DEV,
51 	__B_FLAG_FAILFAST_TRANSPORT,
52 	__B_FLAG_FAILFAST_DRIVER,
53 	__B_FLAG_NR,
54 
55 	B_FLAG_SYNC			= 1 << __B_FLAG_SYNC,
56 	B_FLAG_UNPLUG			= 1 << __B_FLAG_UNPLUG,
57 	B_FLAG_NOIDLE			= 1 << __B_FLAG_NOIDLE,
58 	B_FLAG_BARRIER			= 1 << __B_FLAG_BARRIER,
59 	B_FLAG_META			= 1 << __B_FLAG_META,
60 	B_FLAG_RAHEAD			= 1 << __B_FLAG_RAHEAD,
61 	B_FLAG_FAILFAST_DEV		= 1 << __B_FLAG_FAILFAST_DEV,
62 	B_FLAG_FAILFAST_TRANSPORT	= 1 << __B_FLAG_FAILFAST_TRANSPORT,
63 	B_FLAG_FAILFAST_DRIVER		= 1 << __B_FLAG_FAILFAST_DRIVER,
64 };
65 
66 static inline void binject_buc_set_magic(struct b_user_cmd *buc)
67 {
68 	buc->magic = (BINJECT_MAGIC << BINJECT_MAGIC_SHIFT) | BINJECT_VER;
69 }
70 
71 #endif
72