ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/xen/blkback/common.h @ 6552:a9873d384da4

Merge.
author adsharma@los-vmm.sc.intel.com
date Thu Aug 25 12:24:48 2005 -0700 (2005-08-25)
parents 112d44270733 fa0754a9f64f
children dfaf788ab18c
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/interrupt.h>
9 #include <linux/slab.h>
10 #include <linux/blkdev.h>
11 #include <linux/vmalloc.h>
12 #include <asm/io.h>
13 #include <asm/setup.h>
14 #include <asm/pgalloc.h>
15 #include <asm-xen/evtchn.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>
19 #include <asm-xen/gnttab.h>
21 #if 0
22 #define ASSERT(_p) \
23 if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s", #_p , \
24 __LINE__, __FILE__); *(int*)0=0; }
25 #define DPRINTK(_f, _a...) printk(KERN_ALERT "(file=%s, line=%d) " _f, \
26 __FILE__ , __LINE__ , ## _a )
27 #else
28 #define ASSERT(_p) ((void)0)
29 #define DPRINTK(_f, _a...) ((void)0)
30 #endif
32 struct vbd {
33 blkif_vdev_t handle; /* what the domain refers to this vbd as */
34 unsigned char readonly; /* Non-zero -> read-only */
35 unsigned char type; /* VDISK_xxx */
36 blkif_pdev_t pdevice; /* phys device that this vbd maps to */
37 struct block_device *bdev;
38 };
40 typedef struct blkif_st {
41 /* Unique identifier for this interface. */
42 domid_t domid;
43 unsigned int handle;
44 /* Physical parameters of the comms window. */
45 unsigned long shmem_frame;
46 unsigned int evtchn;
47 unsigned int remote_evtchn;
48 /* Comms information. */
49 blkif_back_ring_t blk_ring;
50 /* VBDs attached to this interface. */
51 struct vbd vbd;
52 /* Private fields. */
53 enum { DISCONNECTED, CONNECTED } status;
54 #ifdef CONFIG_XEN_BLKDEV_TAP_BE
55 /* Is this a blktap frontend */
56 unsigned int is_blktap;
57 #endif
58 struct list_head blkdev_list;
59 spinlock_t blk_ring_lock;
60 atomic_t refcnt;
62 struct work_struct free_work;
63 u16 shmem_handle;
64 unsigned long shmem_vaddr;
65 grant_ref_t shmem_ref;
66 } blkif_t;
68 void blkif_create(blkif_be_create_t *create);
69 void blkif_destroy(blkif_be_destroy_t *destroy);
70 void blkif_connect(blkif_be_connect_t *connect);
71 int blkif_disconnect(blkif_be_disconnect_t *disconnect, u8 rsp_id);
72 void blkif_disconnect_complete(blkif_t *blkif);
73 blkif_t *alloc_blkif(domid_t domid);
74 void free_blkif_callback(blkif_t *blkif);
75 int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn);
77 #define blkif_get(_b) (atomic_inc(&(_b)->refcnt))
78 #define blkif_put(_b) \
79 do { \
80 if ( atomic_dec_and_test(&(_b)->refcnt) ) \
81 free_blkif_callback(_b); \
82 } while (0)
84 /* Create a vbd. */
85 int vbd_create(blkif_t *blkif, blkif_vdev_t vdevice, blkif_pdev_t pdevice,
86 int readonly);
87 void vbd_free(struct vbd *vbd);
89 unsigned long vbd_size(struct vbd *vbd);
90 unsigned int vbd_info(struct vbd *vbd);
91 unsigned long vbd_secsize(struct vbd *vbd);
93 struct phys_req {
94 unsigned short dev;
95 unsigned short nr_sects;
96 struct block_device *bdev;
97 blkif_sector_t sector_number;
98 };
100 int vbd_translate(struct phys_req *req, blkif_t *blkif, int operation);
102 void blkif_interface_init(void);
104 void blkif_deschedule(blkif_t *blkif);
106 void blkif_xenbus_init(void);
108 irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
110 #endif /* __BLKIF__BACKEND__COMMON_H__ */