ia64/linux-2.6.18-xen.hg

annotate drivers/xen/blktap/common.h @ 663:035670ec617c

blktap: Fix Reconnect demand by Frontend

Signed-off-by: Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Sep 09 15:13:29 2008 +0100 (2008-09-09)
parents a533be77c572
children
rev   line source
ian@26 1 /*
ian@26 2 * This program is free software; you can redistribute it and/or
ian@26 3 * modify it under the terms of the GNU General Public License version 2
ian@26 4 * as published by the Free Software Foundation; or, when distributed
ian@26 5 * separately from the Linux kernel or incorporated into other
ian@26 6 * software packages, subject to the following license:
ian@26 7 *
ian@26 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
ian@26 9 * of this source file (the "Software"), to deal in the Software without
ian@26 10 * restriction, including without limitation the rights to use, copy, modify,
ian@26 11 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
ian@26 12 * and to permit persons to whom the Software is furnished to do so, subject to
ian@26 13 * the following conditions:
ian@26 14 *
ian@26 15 * The above copyright notice and this permission notice shall be included in
ian@26 16 * all copies or substantial portions of the Software.
ian@26 17 *
ian@26 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
ian@26 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
ian@26 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
ian@26 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
ian@26 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
ian@26 23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
ian@26 24 * IN THE SOFTWARE.
ian@26 25 */
ian@26 26
ian@26 27 #ifndef __BLKIF__BACKEND__COMMON_H__
ian@26 28 #define __BLKIF__BACKEND__COMMON_H__
ian@26 29
ian@26 30 #include <linux/version.h>
ian@26 31 #include <linux/module.h>
ian@26 32 #include <linux/interrupt.h>
ian@26 33 #include <linux/slab.h>
ian@26 34 #include <linux/blkdev.h>
ian@26 35 #include <linux/vmalloc.h>
ian@26 36 #include <asm/io.h>
ian@26 37 #include <asm/setup.h>
ian@26 38 #include <asm/pgalloc.h>
ian@26 39 #include <xen/evtchn.h>
ian@26 40 #include <asm/hypervisor.h>
ian@26 41 #include <xen/blkif.h>
ian@26 42 #include <xen/gnttab.h>
ian@26 43 #include <xen/driver_util.h>
ian@26 44
ian@26 45 #define DPRINTK(_f, _a...) pr_debug("(file=%s, line=%d) " _f, \
ian@26 46 __FILE__ , __LINE__ , ## _a )
ian@26 47
ian@26 48 #define WPRINTK(fmt, args...) printk(KERN_WARNING "blk_tap: " fmt, ##args)
ian@26 49
ian@26 50 struct backend_info;
ian@26 51
ian@26 52 typedef struct blkif_st {
ian@26 53 /* Unique identifier for this interface. */
ian@26 54 domid_t domid;
ian@26 55 unsigned int handle;
ian@26 56 /* Physical parameters of the comms window. */
ian@26 57 unsigned int irq;
ian@26 58 /* Comms information. */
ian@26 59 enum blkif_protocol blk_protocol;
ian@26 60 blkif_back_rings_t blk_rings;
ian@26 61 struct vm_struct *blk_ring_area;
ian@26 62 /* Back pointer to the backend_info. */
ian@26 63 struct backend_info *be;
ian@26 64 /* Private fields. */
ian@26 65 spinlock_t blk_ring_lock;
ian@26 66 atomic_t refcnt;
ian@26 67
ian@26 68 wait_queue_head_t wq;
ian@26 69 struct task_struct *xenblkd;
ian@26 70 unsigned int waiting_reqs;
ian@26 71 request_queue_t *plug;
ian@26 72
ian@26 73 /* statistics */
ian@26 74 unsigned long st_print;
ian@26 75 int st_rd_req;
ian@26 76 int st_wr_req;
ian@26 77 int st_oo_req;
ian@26 78 int st_rd_sect;
ian@26 79 int st_wr_sect;
ian@26 80
ian@26 81 wait_queue_head_t waiting_to_free;
ian@26 82
ian@26 83 grant_handle_t shmem_handle;
ian@26 84 grant_ref_t shmem_ref;
ian@26 85
ian@26 86 int dev_num;
ian@26 87 uint64_t sectors;
ian@26 88 } blkif_t;
ian@26 89
ian@26 90 blkif_t *tap_alloc_blkif(domid_t domid);
ian@26 91 void tap_blkif_free(blkif_t *blkif);
keir@663 92 void tap_blkif_kmem_cache_free(blkif_t *blkif);
ian@26 93 int tap_blkif_map(blkif_t *blkif, unsigned long shared_page,
ian@26 94 unsigned int evtchn);
ian@26 95 void tap_blkif_unmap(blkif_t *blkif);
ian@26 96
ian@26 97 #define blkif_get(_b) (atomic_inc(&(_b)->refcnt))
ian@26 98 #define blkif_put(_b) \
ian@26 99 do { \
ian@26 100 if (atomic_dec_and_test(&(_b)->refcnt)) \
ian@26 101 wake_up(&(_b)->waiting_to_free);\
ian@26 102 } while (0)
ian@26 103
ian@26 104
ian@26 105 struct phys_req {
ian@26 106 unsigned short dev;
ian@26 107 unsigned short nr_sects;
ian@26 108 struct block_device *bdev;
ian@26 109 blkif_sector_t sector_number;
ian@26 110 };
ian@26 111
ian@26 112 void tap_blkif_interface_init(void);
ian@26 113
ian@26 114 void tap_blkif_xenbus_init(void);
ian@26 115
ian@26 116 irqreturn_t tap_blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
ian@26 117 int tap_blkif_schedule(void *arg);
ian@26 118
ian@26 119 int dom_to_devid(domid_t domid, int xenbus_id, blkif_t *blkif);
ian@26 120 void signal_tapdisk(int idx);
ian@26 121
ian@26 122 #endif /* __BLKIF__BACKEND__COMMON_H__ */