ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/xen/blkfront/block.h @ 13233:d275951acf10

[LINUX] Extend the event-channel interfaces to provide helper methods
for creating interdomain event channels bound to IRQ handlers.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@localhost.localdomain
date Sat Dec 30 18:23:27 2006 +0000 (2006-12-30)
parents 4eaadb2ae198
children 3adf00179a63
line source
1 /******************************************************************************
2 * block.h
3 *
4 * Shared definitions between all levels of XenLinux Virtual block devices.
5 *
6 * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
7 * Modifications by Mark A. Williamson are (c) Intel Research Cambridge
8 * Copyright (c) 2004-2005, Christian Limpach
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation; or, when distributed
13 * separately from the Linux kernel or incorporated into other
14 * software packages, subject to the following license:
15 *
16 * Permission is hereby granted, free of charge, to any person obtaining a copy
17 * of this source file (the "Software"), to deal in the Software without
18 * restriction, including without limitation the rights to use, copy, modify,
19 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
20 * and to permit persons to whom the Software is furnished to do so, subject to
21 * the following conditions:
22 *
23 * The above copyright notice and this permission notice shall be included in
24 * all copies or substantial portions of the Software.
25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
32 * IN THE SOFTWARE.
33 */
35 #ifndef __XEN_DRIVERS_BLOCK_H__
36 #define __XEN_DRIVERS_BLOCK_H__
38 #include <linux/config.h>
39 #include <linux/version.h>
40 #include <linux/module.h>
41 #include <linux/kernel.h>
42 #include <linux/sched.h>
43 #include <linux/slab.h>
44 #include <linux/string.h>
45 #include <linux/errno.h>
46 #include <linux/fs.h>
47 #include <linux/hdreg.h>
48 #include <linux/blkdev.h>
49 #include <linux/major.h>
50 #include <linux/devfs_fs_kernel.h>
51 #include <asm/hypervisor.h>
52 #include <xen/xenbus.h>
53 #include <xen/gnttab.h>
54 #include <xen/interface/xen.h>
55 #include <xen/interface/io/blkif.h>
56 #include <xen/interface/io/ring.h>
57 #include <asm/io.h>
58 #include <asm/atomic.h>
59 #include <asm/uaccess.h>
61 #if 1
62 #define IPRINTK(fmt, args...) \
63 printk(KERN_INFO "xen_blk: " fmt, ##args)
64 #else
65 #define IPRINTK(fmt, args...) ((void)0)
66 #endif
68 #if 1
69 #define WPRINTK(fmt, args...) \
70 printk(KERN_WARNING "xen_blk: " fmt, ##args)
71 #else
72 #define WPRINTK(fmt, args...) ((void)0)
73 #endif
75 #define DPRINTK(_f, _a...) pr_debug(_f, ## _a)
77 #if 0
78 #define DPRINTK_IOCTL(_f, _a...) printk(KERN_ALERT _f, ## _a)
79 #else
80 #define DPRINTK_IOCTL(_f, _a...) ((void)0)
81 #endif
83 struct xlbd_type_info
84 {
85 int partn_shift;
86 int disks_per_major;
87 char *devname;
88 char *diskname;
89 };
91 struct xlbd_major_info
92 {
93 int major;
94 int index;
95 int usage;
96 struct xlbd_type_info *type;
97 };
99 struct blk_shadow {
100 blkif_request_t req;
101 unsigned long request;
102 unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST];
103 };
105 #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
107 /*
108 * We have one of these per vbd, whether ide, scsi or 'other'. They
109 * hang in private_data off the gendisk structure. We may end up
110 * putting all kinds of interesting stuff here :-)
111 */
112 struct blkfront_info
113 {
114 struct xenbus_device *xbdev;
115 dev_t dev;
116 struct gendisk *gd;
117 int vdevice;
118 blkif_vdev_t handle;
119 int connected;
120 int ring_ref;
121 blkif_front_ring_t ring;
122 unsigned int irq;
123 struct xlbd_major_info *mi;
124 request_queue_t *rq;
125 struct work_struct work;
126 struct gnttab_free_callback callback;
127 struct blk_shadow shadow[BLK_RING_SIZE];
128 unsigned long shadow_free;
129 int feature_barrier;
131 /**
132 * The number of people holding this device open. We won't allow a
133 * hot-unplug unless this is 0.
134 */
135 int users;
136 };
138 extern spinlock_t blkif_io_lock;
140 extern int blkif_open(struct inode *inode, struct file *filep);
141 extern int blkif_release(struct inode *inode, struct file *filep);
142 extern int blkif_ioctl(struct inode *inode, struct file *filep,
143 unsigned command, unsigned long argument);
144 extern int blkif_getgeo(struct block_device *, struct hd_geometry *);
145 extern int blkif_check(dev_t dev);
146 extern int blkif_revalidate(dev_t dev);
147 extern void do_blkif_request (request_queue_t *rq);
149 /* Virtual block-device subsystem. */
150 /* Note that xlvbd_add doesn't call add_disk for you: you're expected
151 to call add_disk on info->gd once the disk is properly connected
152 up. */
153 int xlvbd_add(blkif_sector_t capacity, int device,
154 u16 vdisk_info, u16 sector_size, struct blkfront_info *info);
155 void xlvbd_del(struct blkfront_info *info);
156 int xlvbd_barrier(struct blkfront_info *info);
158 #endif /* __XEN_DRIVERS_BLOCK_H__ */