ia64/linux-2.6.18-xen.hg

view drivers/xen/scsifront/common.h @ 601:e0c15322ff6d

pvSCSI: More fixes (including locking cleanups)

Signed-off-by: Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>
Signed-off-by: Jun Kamada <kama@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 14 10:15:44 2008 +0100 (2008-07-14)
parents 3b3701ad4eec
children 82ce2e69bb5b
line source
1 /*
2 * Xen SCSI frontend driver
3 *
4 * Copyright (c) 2008, FUJITSU Limited
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation; or, when distributed
9 * separately from the Linux kernel or incorporated into other
10 * software packages, subject to the following license:
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a copy
13 * of this source file (the "Software"), to deal in the Software without
14 * restriction, including without limitation the rights to use, copy, modify,
15 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
16 * and to permit persons to whom the Software is furnished to do so, subject to
17 * the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included in
20 * all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28 * IN THE SOFTWARE.
29 */
31 #ifndef __XEN_DRIVERS_SCSIFRONT_H__
32 #define __XEN_DRIVERS_SCSIFRONT_H__
34 #include <linux/version.h>
35 #include <linux/module.h>
36 #include <linux/kernel.h>
37 #include <linux/device.h>
38 #include <linux/kthread.h>
39 #include <linux/wait.h>
40 #include <linux/interrupt.h>
41 #include <linux/spinlock.h>
42 #include <linux/sched.h>
43 #include <linux/blkdev.h>
44 #include <scsi/scsi_cmnd.h>
45 #include <scsi/scsi_device.h>
46 #include <scsi/scsi.h>
47 #include <scsi/scsi_host.h>
48 #include <xen/xenbus.h>
49 #include <xen/gnttab.h>
50 #include <xen/evtchn.h>
51 #include <xen/interface/xen.h>
52 #include <xen/interface/io/ring.h>
53 #include <xen/interface/io/vscsiif.h>
54 #include <asm/delay.h>
57 #define GRANT_INVALID_REF 0
58 #define VSCSI_IN_ABORT 1
59 #define VSCSI_IN_RESET 2
61 /* tuning point*/
62 #define VSCSIIF_DEFAULT_CMD_PER_LUN 10
63 #define VSCSIIF_MAX_TARGET 64
64 #define VSCSIIF_MAX_LUN 255
66 #define VSCSIIF_RING_SIZE \
67 __RING_SIZE((struct vscsiif_sring *)0, PAGE_SIZE)
68 #define VSCSIIF_MAX_REQS VSCSIIF_RING_SIZE
70 struct vscsifrnt_shadow {
71 uint16_t next_free;
73 /* command between backend and frontend
74 * VSCSIIF_ACT_SCSI_CDB or VSCSIIF_ACT_SCSI_RESET */
75 unsigned char act;
77 /* do reset function */
78 wait_queue_head_t wq_reset; /* reset work queue */
79 int wait_reset; /* reset work queue condition */
80 int32_t rslt_reset; /* reset response status */
81 /* (SUCESS or FAILED) */
83 /* for DMA_TO_DEVICE(1), DMA_FROM_DEVICE(2), DMA_NONE(3)
84 requests */
85 unsigned int sc_data_direction;
87 /* Number of pieces of scatter-gather */
88 unsigned int nr_segments;
90 /* requested struct scsi_cmnd is stored from kernel */
91 unsigned long req_scsi_cmnd;
92 int gref[VSCSIIF_SG_TABLESIZE];
93 };
95 struct vscsifrnt_info {
96 struct xenbus_device *dev;
98 struct Scsi_Host *host;
100 spinlock_t io_lock;
101 spinlock_t shadow_lock;
102 unsigned int evtchn;
103 unsigned int irq;
105 grant_ref_t ring_ref;
106 struct vscsiif_front_ring ring;
107 struct vscsiif_response ring_res;
109 struct vscsifrnt_shadow shadow[VSCSIIF_MAX_REQS];
110 uint32_t shadow_free;
112 struct task_struct *kthread;
113 wait_queue_head_t wq;
114 unsigned int waiting_resp;
116 };
118 #define DPRINTK(_f, _a...) \
119 pr_debug("(file=%s, line=%d) " _f, \
120 __FILE__ , __LINE__ , ## _a )
122 int scsifront_xenbus_init(void);
123 void scsifront_xenbus_unregister(void);
124 int scsifront_schedule(void *data);
125 irqreturn_t scsifront_intr(int irq, void *dev_id, struct pt_regs *ptregs);
126 int scsifront_cmd_done(struct vscsifrnt_info *info);
129 #endif /* __XEN_DRIVERS_SCSIFRONT_H__ */