aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/blkdev.h2
-rw-r--r--include/linux/chio.h168
-rw-r--r--include/linux/major.h1
-rw-r--r--include/scsi/scsi.h4
-rw-r--r--include/scsi/scsi_device.h4
-rw-r--r--include/scsi/scsi_host.h25
-rw-r--r--include/scsi/scsi_transport.h38
7 files changed, 240 insertions, 2 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index ef1afc178c0a..4a99b76c5a33 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -544,7 +544,7 @@ extern void blk_end_sync_rq(struct request *rq);
544extern void blk_attempt_remerge(request_queue_t *, struct request *); 544extern void blk_attempt_remerge(request_queue_t *, struct request *);
545extern void __blk_attempt_remerge(request_queue_t *, struct request *); 545extern void __blk_attempt_remerge(request_queue_t *, struct request *);
546extern struct request *blk_get_request(request_queue_t *, int, int); 546extern struct request *blk_get_request(request_queue_t *, int, int);
547extern void blk_insert_request(request_queue_t *, struct request *, int, void *, int); 547extern void blk_insert_request(request_queue_t *, struct request *, int, void *);
548extern void blk_requeue_request(request_queue_t *, struct request *); 548extern void blk_requeue_request(request_queue_t *, struct request *);
549extern void blk_plug_device(request_queue_t *); 549extern void blk_plug_device(request_queue_t *);
550extern int blk_remove_plug(request_queue_t *); 550extern int blk_remove_plug(request_queue_t *);
diff --git a/include/linux/chio.h b/include/linux/chio.h
new file mode 100644
index 000000000000..63035ae67e63
--- /dev/null
+++ b/include/linux/chio.h
@@ -0,0 +1,168 @@
1/*
2 * ioctl interface for the scsi media changer driver
3 */
4
5/* changer element types */
6#define CHET_MT 0 /* media transport element (robot) */
7#define CHET_ST 1 /* storage element (media slots) */
8#define CHET_IE 2 /* import/export element */
9#define CHET_DT 3 /* data transfer element (tape/cdrom/whatever) */
10#define CHET_V1 4 /* vendor specific #1 */
11#define CHET_V2 5 /* vendor specific #2 */
12#define CHET_V3 6 /* vendor specific #3 */
13#define CHET_V4 7 /* vendor specific #4 */
14
15
16/*
17 * CHIOGPARAMS
18 * query changer properties
19 *
20 * CHIOVGPARAMS
21 * query vendor-specific element types
22 *
23 * accessing elements works by specifing type and unit of the element.
24 * for eample, storage elements are addressed with type = CHET_ST and
25 * unit = 0 .. cp_nslots-1
26 *
27 */
28struct changer_params {
29 int cp_curpicker; /* current transport element */
30 int cp_npickers; /* number of transport elements (CHET_MT) */
31 int cp_nslots; /* number of storage elements (CHET_ST) */
32 int cp_nportals; /* number of import/export elements (CHET_IE) */
33 int cp_ndrives; /* number of data transfer elements (CHET_DT) */
34};
35struct changer_vendor_params {
36 int cvp_n1; /* number of vendor specific elems (CHET_V1) */
37 char cvp_label1[16];
38 int cvp_n2; /* number of vendor specific elems (CHET_V2) */
39 char cvp_label2[16];
40 int cvp_n3; /* number of vendor specific elems (CHET_V3) */
41 char cvp_label3[16];
42 int cvp_n4; /* number of vendor specific elems (CHET_V4) */
43 char cvp_label4[16];
44 int reserved[8];
45};
46
47
48/*
49 * CHIOMOVE
50 * move a medium from one element to another
51 */
52struct changer_move {
53 int cm_fromtype; /* type/unit of source element */
54 int cm_fromunit;
55 int cm_totype; /* type/unit of destination element */
56 int cm_tounit;
57 int cm_flags;
58};
59#define CM_INVERT 1 /* flag: rotate media (for double-sided like MOD) */
60
61
62/*
63 * CHIOEXCHANGE
64 * move one medium from element #1 to element #2,
65 * and another one from element #2 to element #3.
66 * element #1 and #3 are allowed to be identical.
67 */
68struct changer_exchange {
69 int ce_srctype; /* type/unit of element #1 */
70 int ce_srcunit;
71 int ce_fdsttype; /* type/unit of element #2 */
72 int ce_fdstunit;
73 int ce_sdsttype; /* type/unit of element #3 */
74 int ce_sdstunit;
75 int ce_flags;
76};
77#define CE_INVERT1 1
78#define CE_INVERT2 2
79
80
81/*
82 * CHIOPOSITION
83 * move the transport element (robot arm) to a specific element.
84 */
85struct changer_position {
86 int cp_type;
87 int cp_unit;
88 int cp_flags;
89};
90#define CP_INVERT 1
91
92
93/*
94 * CHIOGSTATUS
95 * get element status for all elements of a specific type
96 */
97struct changer_element_status {
98 int ces_type;
99 unsigned char *ces_data;
100};
101#define CESTATUS_FULL 0x01 /* full */
102#define CESTATUS_IMPEXP 0x02 /* media was imported (inserted by sysop) */
103#define CESTATUS_EXCEPT 0x04 /* error condition */
104#define CESTATUS_ACCESS 0x08 /* access allowed */
105#define CESTATUS_EXENAB 0x10 /* element can export media */
106#define CESTATUS_INENAB 0x20 /* element can import media */
107
108
109/*
110 * CHIOGELEM
111 * get more detailed status informtion for a single element
112 */
113struct changer_get_element {
114 int cge_type; /* type/unit */
115 int cge_unit;
116 int cge_status; /* status */
117 int cge_errno; /* errno */
118 int cge_srctype; /* source element of the last move/exchange */
119 int cge_srcunit;
120 int cge_id; /* scsi id (for data transfer elements) */
121 int cge_lun; /* scsi lun (for data transfer elements) */
122 char cge_pvoltag[36]; /* primary volume tag */
123 char cge_avoltag[36]; /* alternate volume tag */
124 int cge_flags;
125};
126/* flags */
127#define CGE_ERRNO 0x01 /* errno available */
128#define CGE_INVERT 0x02 /* media inverted */
129#define CGE_SRC 0x04 /* media src available */
130#define CGE_IDLUN 0x08 /* ID+LUN available */
131#define CGE_PVOLTAG 0x10 /* primary volume tag available */
132#define CGE_AVOLTAG 0x20 /* alternate volume tag available */
133
134
135/*
136 * CHIOSVOLTAG
137 * set volume tag
138 */
139struct changer_set_voltag {
140 int csv_type; /* type/unit */
141 int csv_unit;
142 char csv_voltag[36]; /* volume tag */
143 int csv_flags;
144};
145#define CSV_PVOLTAG 0x01 /* primary volume tag */
146#define CSV_AVOLTAG 0x02 /* alternate volume tag */
147#define CSV_CLEARTAG 0x04 /* clear volume tag */
148
149/* ioctls */
150#define CHIOMOVE _IOW('c', 1,struct changer_move)
151#define CHIOEXCHANGE _IOW('c', 2,struct changer_exchange)
152#define CHIOPOSITION _IOW('c', 3,struct changer_position)
153#define CHIOGPICKER _IOR('c', 4,int) /* not impl. */
154#define CHIOSPICKER _IOW('c', 5,int) /* not impl. */
155#define CHIOGPARAMS _IOR('c', 6,struct changer_params)
156#define CHIOGSTATUS _IOW('c', 8,struct changer_element_status)
157#define CHIOGELEM _IOW('c',16,struct changer_get_element)
158#define CHIOINITELEM _IO('c',17)
159#define CHIOSVOLTAG _IOW('c',18,struct changer_set_voltag)
160#define CHIOGVPARAMS _IOR('c',19,struct changer_vendor_params)
161
162/* ---------------------------------------------------------------------- */
163
164/*
165 * Local variables:
166 * c-basic-offset: 8
167 * End:
168 */
diff --git a/include/linux/major.h b/include/linux/major.h
index 4b62c42b842c..e36a46702d94 100644
--- a/include/linux/major.h
+++ b/include/linux/major.h
@@ -100,6 +100,7 @@
100#define I2O_MAJOR 80 /* 80->87 */ 100#define I2O_MAJOR 80 /* 80->87 */
101 101
102#define SHMIQ_MAJOR 85 /* Linux/mips, SGI /dev/shmiq */ 102#define SHMIQ_MAJOR 85 /* Linux/mips, SGI /dev/shmiq */
103#define SCSI_CHANGER_MAJOR 86
103 104
104#define IDE6_MAJOR 88 105#define IDE6_MAJOR 88
105#define IDE7_MAJOR 89 106#define IDE7_MAJOR 89
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 659ecf48fb4a..1fb233741513 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -41,6 +41,7 @@ extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
41#define FORMAT_UNIT 0x04 41#define FORMAT_UNIT 0x04
42#define READ_BLOCK_LIMITS 0x05 42#define READ_BLOCK_LIMITS 0x05
43#define REASSIGN_BLOCKS 0x07 43#define REASSIGN_BLOCKS 0x07
44#define INITIALIZE_ELEMENT_STATUS 0x07
44#define READ_6 0x08 45#define READ_6 0x08
45#define WRITE_6 0x0a 46#define WRITE_6 0x0a
46#define SEEK_6 0x0b 47#define SEEK_6 0x0b
@@ -65,6 +66,7 @@ extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
65#define READ_10 0x28 66#define READ_10 0x28
66#define WRITE_10 0x2a 67#define WRITE_10 0x2a
67#define SEEK_10 0x2b 68#define SEEK_10 0x2b
69#define POSITION_TO_ELEMENT 0x2b
68#define WRITE_VERIFY 0x2e 70#define WRITE_VERIFY 0x2e
69#define VERIFY 0x2f 71#define VERIFY 0x2f
70#define SEARCH_HIGH 0x30 72#define SEARCH_HIGH 0x30
@@ -97,6 +99,7 @@ extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
97#define PERSISTENT_RESERVE_OUT 0x5f 99#define PERSISTENT_RESERVE_OUT 0x5f
98#define REPORT_LUNS 0xa0 100#define REPORT_LUNS 0xa0
99#define MOVE_MEDIUM 0xa5 101#define MOVE_MEDIUM 0xa5
102#define EXCHANGE_MEDIUM 0xa6
100#define READ_12 0xa8 103#define READ_12 0xa8
101#define WRITE_12 0xaa 104#define WRITE_12 0xaa
102#define WRITE_VERIFY_12 0xae 105#define WRITE_VERIFY_12 0xae
@@ -210,6 +213,7 @@ static inline int scsi_status_is_good(int status)
210#define TYPE_COMM 0x09 /* Communications device */ 213#define TYPE_COMM 0x09 /* Communications device */
211#define TYPE_ENCLOSURE 0x0d /* Enclosure Services Device */ 214#define TYPE_ENCLOSURE 0x0d /* Enclosure Services Device */
212#define TYPE_RAID 0x0c 215#define TYPE_RAID 0x0c
216#define TYPE_RBC 0x0e
213#define TYPE_NO_LUN 0x7f 217#define TYPE_NO_LUN 0x7f
214 218
215/* 219/*
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index c018020d9160..63c91dd85ca1 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -154,7 +154,9 @@ struct scsi_target {
154 unsigned int id; /* target id ... replace 154 unsigned int id; /* target id ... replace
155 * scsi_device.id eventually */ 155 * scsi_device.id eventually */
156 unsigned long create:1; /* signal that it needs to be added */ 156 unsigned long create:1; /* signal that it needs to be added */
157 unsigned long starget_data[0]; 157 void *hostdata; /* available to low-level driver */
158 unsigned long starget_data[0]; /* for the transport */
159 /* starget_data must be the last element!!!! */
158} __attribute__((aligned(sizeof(unsigned long)))); 160} __attribute__((aligned(sizeof(unsigned long))));
159 161
160#define to_scsi_target(d) container_of(d, struct scsi_target, dev) 162#define to_scsi_target(d) container_of(d, struct scsi_target, dev)
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 1cee1e100943..db9914adeac9 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -10,6 +10,7 @@ struct block_device;
10struct module; 10struct module;
11struct scsi_cmnd; 11struct scsi_cmnd;
12struct scsi_device; 12struct scsi_device;
13struct scsi_target;
13struct Scsi_Host; 14struct Scsi_Host;
14struct scsi_host_cmd_pool; 15struct scsi_host_cmd_pool;
15struct scsi_transport_template; 16struct scsi_transport_template;
@@ -228,6 +229,30 @@ struct scsi_host_template {
228 void (* slave_destroy)(struct scsi_device *); 229 void (* slave_destroy)(struct scsi_device *);
229 230
230 /* 231 /*
232 * Before the mid layer attempts to scan for a new device attached
233 * to a target where no target currently exists, it will call this
234 * entry in your driver. Should your driver need to allocate any
235 * structs or perform any other init items in order to send commands
236 * to a currently unused target, then this is where you can perform
237 * those allocations.
238 *
239 * Return values: 0 on success, non-0 on failure
240 *
241 * Status: OPTIONAL
242 */
243 int (* target_alloc)(struct scsi_target *);
244
245 /*
246 * Immediately prior to deallocating the target structure, and
247 * after all activity to attached scsi devices has ceased, the
248 * midlayer calls this point so that the driver may deallocate
249 * and terminate any references to the target.
250 *
251 * Status: OPTIONAL
252 */
253 void (* target_destroy)(struct scsi_target *);
254
255 /*
231 * fill in this function to allow the queue depth of this host 256 * fill in this function to allow the queue depth of this host
232 * to be changeable (on a per device basis). returns either 257 * to be changeable (on a per device basis). returns either
233 * the current queue depth setting (may be different from what 258 * the current queue depth setting (may be different from what
diff --git a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h
index 2dcee7a84752..a4f1837a33b1 100644
--- a/include/scsi/scsi_transport.h
+++ b/include/scsi/scsi_transport.h
@@ -21,6 +21,7 @@
21#define SCSI_TRANSPORT_H 21#define SCSI_TRANSPORT_H
22 22
23#include <linux/transport_class.h> 23#include <linux/transport_class.h>
24#include <scsi/scsi_host.h>
24 25
25struct scsi_transport_template { 26struct scsi_transport_template {
26 /* the attribute containers */ 27 /* the attribute containers */
@@ -32,8 +33,11 @@ struct scsi_transport_template {
32 * space of this size will be left at the end of the 33 * space of this size will be left at the end of the
33 * scsi_* structure */ 34 * scsi_* structure */
34 int device_size; 35 int device_size;
36 int device_private_offset;
35 int target_size; 37 int target_size;
38 int target_private_offset;
36 int host_size; 39 int host_size;
40 /* no private offset for the host; there's an alternative mechanism */
37 41
38 /* 42 /*
39 * True if the transport wants to use a host-based work-queue 43 * True if the transport wants to use a host-based work-queue
@@ -45,4 +49,38 @@ struct scsi_transport_template {
45 dev_to_shost((tc)->dev) 49 dev_to_shost((tc)->dev)
46 50
47 51
52/* Private area maintenance. The driver requested allocations come
53 * directly after the transport class allocations (if any). The idea
54 * is that you *must* call these only once. The code assumes that the
55 * initial values are the ones the transport specific code requires */
56static inline void
57scsi_transport_reserve_target(struct scsi_transport_template * t, int space)
58{
59 BUG_ON(t->target_private_offset != 0);
60 t->target_private_offset = ALIGN(t->target_size, sizeof(void *));
61 t->target_size = t->target_private_offset + space;
62}
63static inline void
64scsi_transport_reserve_device(struct scsi_transport_template * t, int space)
65{
66 BUG_ON(t->device_private_offset != 0);
67 t->device_private_offset = ALIGN(t->device_size, sizeof(void *));
68 t->device_size = t->device_private_offset + space;
69}
70static inline void *
71scsi_transport_target_data(struct scsi_target *starget)
72{
73 struct Scsi_Host *shost = dev_to_shost(&starget->dev);
74 return (u8 *)starget->starget_data
75 + shost->transportt->target_private_offset;
76
77}
78static inline void *
79scsi_transport_device_data(struct scsi_device *sdev)
80{
81 struct Scsi_Host *shost = sdev->host;
82 return (u8 *)sdev->sdev_data
83 + shost->transportt->device_private_offset;
84}
85
48#endif /* SCSI_TRANSPORT_H */ 86#endif /* SCSI_TRANSPORT_H */