]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/dev/xen/blkfront/block.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / dev / xen / blkfront / block.h
1 /*
2  * 
3  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
8  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
9  * IN THE SOFTWARE.
10  *
11  * $FreeBSD$
12  */
13
14
15 #ifndef __XEN_DRIVERS_BLOCK_H__
16 #define __XEN_DRIVERS_BLOCK_H__
17 #include <xen/interface/io/blkif.h>
18
19 struct xlbd_type_info
20 {
21         int partn_shift;
22         int disks_per_major;
23         char *devname;
24         char *diskname;
25 };
26
27 struct xlbd_major_info
28 {
29         int major;
30         int index;
31         int usage;
32         struct xlbd_type_info *type;
33 };
34
35 struct blk_shadow {
36         blkif_request_t req;
37         unsigned long request;
38         unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST];
39 };
40
41 #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
42
43
44 struct xb_softc {
45         device_t                  xb_dev;
46         struct disk               *xb_disk;             /* disk params */
47         struct bio_queue_head     xb_bioq;              /* sort queue */
48         int                       xb_unit;
49         int                       xb_flags;
50         struct blkfront_info      *xb_info;
51         LIST_ENTRY(xb_softc)      entry;
52 #define XB_OPEN (1<<0)          /* drive is open (can't shut down) */
53 };
54
55
56 /*
57  * We have one of these per vbd, whether ide, scsi or 'other'.  They
58  * hang in private_data off the gendisk structure. We may end up
59  * putting all kinds of interesting stuff here :-)
60  */
61 struct blkfront_info
62 {
63         device_t xbdev;
64         dev_t dev;
65         struct gendisk *gd;
66         int vdevice;
67         blkif_vdev_t handle;
68         int connected;
69         int ring_ref;
70         blkif_front_ring_t ring;
71         unsigned int irq;
72         struct xlbd_major_info *mi;
73 #if 0
74         request_queue_t *rq;
75         struct work_struct work;
76 #endif
77         struct gnttab_free_callback callback;
78         struct blk_shadow shadow[BLK_RING_SIZE];
79         unsigned long shadow_free;
80         struct xb_softc *sc;
81         int feature_barrier;
82         int is_ready;
83         /**
84          * The number of people holding this device open.  We won't allow a
85          * hot-unplug unless this is 0.
86          */
87         int users;
88 };
89 /* Note that xlvbd_add doesn't call add_disk for you: you're expected
90    to call add_disk on info->gd once the disk is properly connected
91    up. */
92 int xlvbd_add(device_t, blkif_sector_t capacity, int device,
93               uint16_t vdisk_info, uint16_t sector_size, struct blkfront_info *info);
94 void xlvbd_del(struct blkfront_info *info);
95
96 #endif /* __XEN_DRIVERS_BLOCK_H__ */
97