-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathlinux-blktap.h
137 lines (114 loc) · 3.51 KB
/
linux-blktap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
*
* Copyright (C) 2011 Citrix Systems Inc.
*
* This file is part of Blktap2.
*
* Blktap2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* Blktap2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License version 2 for more details.
*
* You should have received a copy of the GNU General Public License
* version 2 along with Blktap2. If not, see
* <http://www.gnu.org/licenses/>.
*
*
*/
#ifndef _LINUX_BLKTAP_H
#define _LINUX_BLKTAP_H
/*
* Control
*/
#define BLKTAP_IOCTL_RESPOND 1
#define BLKTAP_IOCTL_ALLOC_TAP 200
#define BLKTAP_IOCTL_FREE_TAP 201
#define BLKTAP_IOCTL_CREATE_DEVICE 208
#define BLKTAP_IOCTL_REMOVE_DEVICE 207
#define BLKTAP_DEVICE_FLAG_RO 0x00000001UL /* disk is R/O */
#define BLKTAP_DEVICE_FLAG_PSZ 0x00000002UL /* physical sector size */
#define BLKTAP_DEVICE_FLAG_FLUSH 0x00000004UL /* supports FLUSH */
#define BLKTAP_DEVICE_FLAG_TRIM 0x00000008UL /* supports TRIM */
#define BLKTAP_DEVICE_FLAG_TRIM_RZ 0x00000010UL /* trimmed data reads zero */
struct blktap_info {
unsigned int ring_major;
unsigned int bdev_major;
unsigned int ring_minor;
};
struct blktap_device_info {
unsigned long long capacity;
unsigned int sector_size;
unsigned long flags;
unsigned int phys_block_size;
unsigned int phys_block_offset;
unsigned int trim_block_size;
unsigned int trim_block_offset;
};
/*
* I/O ring
*/
#ifdef __KERNEL__
#define BLKTAP_PAGE_SIZE PAGE_SIZE
#endif
#include <xen/interface/io/ring.h>
struct blktap_segment {
uint32_t __pad;
uint8_t first_sect;
uint8_t last_sect;
};
#define BLKTAP_OP_READ 0
#define BLKTAP_OP_WRITE 1
#define BLKTAP_OP_FLUSH 2
#define BLKTAP_OP_TRIM 3
#define BLKTAP_SEGMENT_MAX 11
struct blktap_ring_rw_request {
uint64_t sector_number;
struct blktap_segment seg[BLKTAP_SEGMENT_MAX];
};
struct blktap_ring_tr_request {
uint64_t sector_number;
uint64_t nr_sectors;
};
struct blktap_ring_request {
uint8_t operation;
uint8_t nr_segments;
uint16_t __pad;
uint64_t id;
union {
struct blktap_ring_rw_request rw;
struct blktap_ring_tr_request tr;
} u;
};
#define BLKTAP_RSP_EOPNOTSUPP -2
#define BLKTAP_RSP_ERROR -1
#define BLKTAP_RSP_OKAY 0
struct blktap_ring_response {
uint64_t id;
uint8_t operation;
int16_t status;
};
DEFINE_RING_TYPES(blktap,
struct blktap_ring_request,
struct blktap_ring_response);
#define BLKTAP_RING_SIZE \
((int)__RD32((BLKTAP_PAGE_SIZE - \
(size_t)&((struct blktap_sring*)0)->ring) / \
sizeof(((struct blktap_sring *)0)->ring[0])))
/*
* Ring messages + old ioctls (DEPRECATED)
*/
#define BLKTAP_RING_MESSAGE(_sring) \
((uint8_t*)(&(_sring)->rsp_event + 1))
#define BLKTAP_RING_MESSAGE_CLOSE 3
#define BLKTAP_IOCTL_CREATE_DEVICE_COMPAT 202
#define BLKTAP_NAME_MAX 256
struct blktap2_params {
char name[BLKTAP_NAME_MAX];
unsigned long long capacity;
unsigned long sector_size;
};
#endif /* _LINUX_BLKTAP_H */