1
2#ifndef _UAPIBLKTRACE_H
3#define _UAPIBLKTRACE_H
4
5#include <linux/types.h>
6
7
8
9
10enum blktrace_cat {
11 BLK_TC_READ = 1 << 0,
12 BLK_TC_WRITE = 1 << 1,
13 BLK_TC_FLUSH = 1 << 2,
14 BLK_TC_SYNC = 1 << 3,
15 BLK_TC_SYNCIO = BLK_TC_SYNC,
16 BLK_TC_QUEUE = 1 << 4,
17 BLK_TC_REQUEUE = 1 << 5,
18 BLK_TC_ISSUE = 1 << 6,
19 BLK_TC_COMPLETE = 1 << 7,
20 BLK_TC_FS = 1 << 8,
21 BLK_TC_PC = 1 << 9,
22 BLK_TC_NOTIFY = 1 << 10,
23 BLK_TC_AHEAD = 1 << 11,
24 BLK_TC_META = 1 << 12,
25 BLK_TC_DISCARD = 1 << 13,
26 BLK_TC_DRV_DATA = 1 << 14,
27 BLK_TC_FUA = 1 << 15,
28
29 BLK_TC_END = 1 << 15,
30};
31
32#define BLK_TC_SHIFT (16)
33#define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT)
34
35
36
37
38enum blktrace_act {
39 __BLK_TA_QUEUE = 1,
40 __BLK_TA_BACKMERGE,
41 __BLK_TA_FRONTMERGE,
42 __BLK_TA_GETRQ,
43 __BLK_TA_SLEEPRQ,
44 __BLK_TA_REQUEUE,
45 __BLK_TA_ISSUE,
46 __BLK_TA_COMPLETE,
47 __BLK_TA_PLUG,
48 __BLK_TA_UNPLUG_IO,
49 __BLK_TA_UNPLUG_TIMER,
50 __BLK_TA_INSERT,
51 __BLK_TA_SPLIT,
52 __BLK_TA_BOUNCE,
53 __BLK_TA_REMAP,
54 __BLK_TA_ABORT,
55 __BLK_TA_DRV_DATA,
56 __BLK_TA_CGROUP = 1 << 8,
57};
58
59
60
61
62enum blktrace_notify {
63 __BLK_TN_PROCESS = 0,
64 __BLK_TN_TIMESTAMP,
65 __BLK_TN_MESSAGE,
66 __BLK_TN_CGROUP = __BLK_TA_CGROUP,
67};
68
69
70
71
72
73#define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE))
74#define BLK_TA_BACKMERGE (__BLK_TA_BACKMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
75#define BLK_TA_FRONTMERGE (__BLK_TA_FRONTMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
76#define BLK_TA_GETRQ (__BLK_TA_GETRQ | BLK_TC_ACT(BLK_TC_QUEUE))
77#define BLK_TA_SLEEPRQ (__BLK_TA_SLEEPRQ | BLK_TC_ACT(BLK_TC_QUEUE))
78#define BLK_TA_REQUEUE (__BLK_TA_REQUEUE | BLK_TC_ACT(BLK_TC_REQUEUE))
79#define BLK_TA_ISSUE (__BLK_TA_ISSUE | BLK_TC_ACT(BLK_TC_ISSUE))
80#define BLK_TA_COMPLETE (__BLK_TA_COMPLETE| BLK_TC_ACT(BLK_TC_COMPLETE))
81#define BLK_TA_PLUG (__BLK_TA_PLUG | BLK_TC_ACT(BLK_TC_QUEUE))
82#define BLK_TA_UNPLUG_IO (__BLK_TA_UNPLUG_IO | BLK_TC_ACT(BLK_TC_QUEUE))
83#define BLK_TA_UNPLUG_TIMER (__BLK_TA_UNPLUG_TIMER | BLK_TC_ACT(BLK_TC_QUEUE))
84#define BLK_TA_INSERT (__BLK_TA_INSERT | BLK_TC_ACT(BLK_TC_QUEUE))
85#define BLK_TA_SPLIT (__BLK_TA_SPLIT)
86#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE)
87#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE))
88#define BLK_TA_ABORT (__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE))
89#define BLK_TA_DRV_DATA (__BLK_TA_DRV_DATA | BLK_TC_ACT(BLK_TC_DRV_DATA))
90
91#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
92#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
93#define BLK_TN_MESSAGE (__BLK_TN_MESSAGE | BLK_TC_ACT(BLK_TC_NOTIFY))
94
95#define BLK_IO_TRACE_MAGIC 0x65617400
96#define BLK_IO_TRACE_VERSION 0x07
97
98
99
100
101struct blk_io_trace {
102 __u32 magic;
103 __u32 sequence;
104 __u64 time;
105 __u64 sector;
106 __u32 bytes;
107 __u32 action;
108 __u32 pid;
109 __u32 device;
110 __u32 cpu;
111 __u16 error;
112 __u16 pdu_len;
113
114};
115
116
117
118
119struct blk_io_trace_remap {
120 __be32 device_from;
121 __be32 device_to;
122 __be64 sector_from;
123};
124
125enum {
126 Blktrace_setup = 1,
127 Blktrace_running,
128 Blktrace_stopped,
129};
130
131#define BLKTRACE_BDEV_SIZE 32
132
133
134
135
136struct blk_user_trace_setup {
137 char name[BLKTRACE_BDEV_SIZE];
138 __u16 act_mask;
139 __u32 buf_size;
140 __u32 buf_nr;
141 __u64 start_lba;
142 __u64 end_lba;
143 __u32 pid;
144};
145
146#endif
147