2 #ifndef __BLKIF__BACKEND__COMMON_H__
3 #define __BLKIF__BACKEND__COMMON_H__
5 #include <linux/config.h>
6 #include <linux/version.h>
7 #include <linux/module.h>
8 #include <linux/rbtree.h>
9 #include <linux/interrupt.h>
10 #include <linux/slab.h>
11 #include <linux/blkdev.h>
13 #include <asm/setup.h>
14 #include <asm/pgalloc.h>
15 #include <asm-xen/ctrl_if.h>
16 #include <asm-xen/hypervisor.h>
17 #include <asm-xen/xen-public/io/blkif.h>
18 #include <asm-xen/xen-public/io/ring.h>
22 if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s", #_p , \
23 __LINE__, __FILE__); *(int*)0=0; }
24 #define DPRINTK(_f, _a...) printk(KERN_ALERT "(file=%s, line=%d) " _f, \
25 __FILE__ , __LINE__ , ## _a )
27 #define ASSERT(_p) ((void)0)
28 #define DPRINTK(_f, _a...) ((void)0)
31 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
32 typedef struct rb_root rb_root_t;
33 typedef struct rb_node rb_node_t;
38 typedef struct blkif_st {
39 /* Unique identifier for this interface. */
42 /* Physical parameters of the comms window. */
43 unsigned long shmem_frame;
46 /* Comms information. */
47 blkif_back_ring_t blk_ring;
48 /* VBDs attached to this interface. */
49 rb_root_t vbd_rb; /* Mapping from 16-bit vdevices to VBDs.*/
50 spinlock_t vbd_lock; /* Protects VBD mapping. */
52 enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
54 * DISCONNECT response is deferred until pending requests are ack'ed.
55 * We therefore need to store the id from the original request.
58 #ifdef CONFIG_XEN_BLKDEV_TAP_BE
59 /* Is this a blktap frontend */
60 unsigned int is_blktap;
62 struct blkif_st *hash_next;
63 struct list_head blkdev_list;
64 spinlock_t blk_ring_lock;
67 struct work_struct work;
70 void blkif_create(blkif_be_create_t *create);
71 void blkif_destroy(blkif_be_destroy_t *destroy);
72 void blkif_connect(blkif_be_connect_t *connect);
73 int blkif_disconnect(blkif_be_disconnect_t *disconnect, u8 rsp_id);
74 void blkif_disconnect_complete(blkif_t *blkif);
75 blkif_t *blkif_find_by_handle(domid_t domid, unsigned int handle);
76 #define blkif_get(_b) (atomic_inc(&(_b)->refcnt))
77 #define blkif_put(_b) \
79 if ( atomic_dec_and_test(&(_b)->refcnt) ) \
80 blkif_disconnect_complete(_b); \
83 void vbd_create(blkif_be_vbd_create_t *create);
84 void vbd_destroy(blkif_be_vbd_destroy_t *delete);
85 int vbd_probe(blkif_t *blkif, vdisk_t *vbd_info, int max_vbds);
86 void destroy_all_vbds(blkif_t *blkif);
90 unsigned short nr_sects;
91 struct block_device *bdev;
92 blkif_sector_t sector_number;
95 int vbd_translate(struct phys_req *req, blkif_t *blkif, int operation);
97 void blkif_interface_init(void);
98 void blkif_ctrlif_init(void);
100 void blkif_deschedule(blkif_t *blkif);
102 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
104 #endif /* __BLKIF__BACKEND__COMMON_H__ */