~mitya57/ubuntu/precise/blktap-dkms/lp1157421

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