ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/xen/blkback/common.h @ 6316:f7dfaa2af90c

merge?
author cl349@firebug.cl.cam.ac.uk
date Sun Aug 21 11:02:00 2005 +0000 (2005-08-21)
parents 1872e09bfba3
children 6721abf6b16d
line source
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>
12 #include <linux/vmalloc.h>
13 #include <asm/io.h>
14 #include <asm/setup.h>
15 #include <asm/pgalloc.h>
16 #include <asm-xen/evtchn.h>
17 #include <asm-xen/hypervisor.h>
18 #include <asm-xen/xen-public/io/blkif.h>
19 #include <asm-xen/xen-public/io/ring.h>
20 #ifdef CONFIG_XEN_BLKDEV_GRANT
21 #include <asm-xen/gnttab.h>
22 #endif
24 #if 0
25 #define ASSERT(_p) \
26 if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s", #_p , \
27 __LINE__, __FILE__); *(int*)0=0; }
28 #define DPRINTK(_f, _a...) printk(KERN_ALERT "(file=%s, line=%d) " _f, \
29 __FILE__ , __LINE__ , ## _a )
30 #else
31 #define ASSERT(_p) ((void)0)
32 #define DPRINTK(_f, _a...) ((void)0)
33 #endif
35 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
36 typedef struct rb_root rb_root_t;
37 typedef struct rb_node rb_node_t;
38 #else
39 struct block_device;
40 #endif
42 typedef struct blkif_st {
43 /* Unique identifier for this interface. */
44 domid_t domid;
45 unsigned int handle;
46 /* Physical parameters of the comms window. */
47 unsigned long shmem_frame;
48 unsigned int evtchn;
49 unsigned int remote_evtchn;
50 /* Comms information. */
51 blkif_back_ring_t blk_ring;
52 /* VBDs attached to this interface. */
53 rb_root_t vbd_rb; /* Mapping from 16-bit vdevices to VBDs.*/
54 spinlock_t vbd_lock; /* Protects VBD mapping. */
55 /* Private fields. */
56 enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
57 /*
58 * DISCONNECT response is deferred until pending requests are ack'ed.
59 * We therefore need to store the id from the original request.
60 */
61 u8 disconnect_rspid;
62 #ifdef CONFIG_XEN_BLKDEV_TAP_BE
63 /* Is this a blktap frontend */
64 unsigned int is_blktap;
65 #endif
66 struct blkif_st *hash_next;
67 struct list_head blkdev_list;
68 spinlock_t blk_ring_lock;
69 atomic_t refcnt;
71 struct work_struct work;
72 #ifdef CONFIG_XEN_BLKDEV_GRANT
73 u16 shmem_handle;
74 unsigned long shmem_vaddr;
75 grant_ref_t shmem_ref;
76 #endif
77 } blkif_t;
79 void blkif_create(blkif_be_create_t *create);
80 void blkif_destroy(blkif_be_destroy_t *destroy);
81 void blkif_connect(blkif_be_connect_t *connect);
82 int blkif_disconnect(blkif_be_disconnect_t *disconnect, u8 rsp_id);
83 void blkif_disconnect_complete(blkif_t *blkif);
84 blkif_t *blkif_find(domid_t domid);
85 void free_blkif(blkif_t *blkif);
86 int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn);
88 #define blkif_get(_b) (atomic_inc(&(_b)->refcnt))
89 #define blkif_put(_b) \
90 do { \
91 if ( atomic_dec_and_test(&(_b)->refcnt) ) \
92 free_blkif(_b); \
93 } while (0)
95 struct vbd;
96 void vbd_free(blkif_t *blkif, struct vbd *vbd);
98 /* Creates inactive vbd. */
99 struct vbd *vbd_create(blkif_t *blkif, blkif_vdev_t vdevice, blkif_pdev_t pdevice, int readonly);
100 int vbd_is_active(struct vbd *vbd);
101 void vbd_activate(blkif_t *blkif, struct vbd *vbd);
103 unsigned long vbd_size(struct vbd *vbd);
104 unsigned int vbd_info(struct vbd *vbd);
105 unsigned long vbd_secsize(struct vbd *vbd);
106 void vbd_destroy(blkif_be_vbd_destroy_t *delete);
107 void destroy_all_vbds(blkif_t *blkif);
109 struct phys_req {
110 unsigned short dev;
111 unsigned short nr_sects;
112 struct block_device *bdev;
113 blkif_sector_t sector_number;
114 };
116 int vbd_translate(struct phys_req *req, blkif_t *blkif, int operation);
118 void blkif_interface_init(void);
120 void blkif_deschedule(blkif_t *blkif);
122 void blkif_xenbus_init(void);
124 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
126 #endif /* __BLKIF__BACKEND__COMMON_H__ */