ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / scsi / gdth_ioctl.h
1 #ifndef _GDTH_IOCTL_H
2 #define _GDTH_IOCTL_H
3
4 /* gdth_ioctl.h
5  * $Id: gdth_ioctl.h,v 1.11 2003/02/27 14:59:03 achim Exp $
6  */
7
8 /* IOCTLs */
9 #define GDTIOCTL_MASK       ('J'<<8)
10 #define GDTIOCTL_GENERAL    (GDTIOCTL_MASK | 0) /* general IOCTL */
11 #define GDTIOCTL_DRVERS     (GDTIOCTL_MASK | 1) /* get driver version */
12 #define GDTIOCTL_CTRTYPE    (GDTIOCTL_MASK | 2) /* get controller type */
13 #define GDTIOCTL_OSVERS     (GDTIOCTL_MASK | 3) /* get OS version */
14 #define GDTIOCTL_HDRLIST    (GDTIOCTL_MASK | 4) /* get host drive list */
15 #define GDTIOCTL_CTRCNT     (GDTIOCTL_MASK | 5) /* get controller count */
16 #define GDTIOCTL_LOCKDRV    (GDTIOCTL_MASK | 6) /* lock host drive */
17 #define GDTIOCTL_LOCKCHN    (GDTIOCTL_MASK | 7) /* lock channel */
18 #define GDTIOCTL_EVENT      (GDTIOCTL_MASK | 8) /* read controller events */
19 #define GDTIOCTL_SCSI       (GDTIOCTL_MASK | 9) /* SCSI command */
20 #define GDTIOCTL_RESET_BUS  (GDTIOCTL_MASK |10) /* reset SCSI bus */
21 #define GDTIOCTL_RESCAN     (GDTIOCTL_MASK |11) /* rescan host drives */
22 #define GDTIOCTL_RESET_DRV  (GDTIOCTL_MASK |12) /* reset (remote) drv. res. */
23
24 #define GDTIOCTL_MAGIC      0xaffe0004
25 #define EVENT_SIZE          294 
26 #define GDTH_MAXSG      32                      /* max. s/g elements */
27
28 #define MAX_LDRIVES     255                     /* max. log. drive count */
29 #ifdef GDTH_IOCTL_PROC
30 #define MAX_HDRIVES     100                     /* max. host drive count */
31 #else
32 #define MAX_HDRIVES     MAX_LDRIVES             /* max. host drive count */
33 #endif
34
35 /* typedefs */
36 #ifdef __KERNEL__
37 typedef u32     ulong32;
38 #endif
39 #define PACKED  __attribute__((packed))
40
41 /* scatter/gather element */
42 typedef struct {
43     ulong32     sg_ptr;                         /* address */
44     ulong32     sg_len;                         /* length */
45 } PACKED gdth_sg_str;
46
47 /* command structure */
48 typedef struct {
49     ulong32     BoardNode;                      /* board node (always 0) */
50     ulong32     CommandIndex;                   /* command number */
51     ushort      OpCode;                         /* the command (READ,..) */
52     union {
53         struct {
54             ushort      DeviceNo;               /* number of cache drive */
55             ulong32     BlockNo;                /* block number */
56             ulong32     BlockCnt;               /* block count */
57             ulong32     DestAddr;               /* dest. addr. (if s/g: -1) */
58             ulong32     sg_canz;                /* s/g element count */
59             gdth_sg_str sg_lst[GDTH_MAXSG];     /* s/g list */
60         } PACKED cache;                         /* cache service cmd. str. */
61         struct {
62             ushort      param_size;             /* size of p_param buffer */
63             ulong32     subfunc;                /* IOCTL function */
64             ulong32     channel;                /* device */
65             ulong32     p_param;                /* buffer */
66         } PACKED ioctl;                         /* IOCTL command structure */
67         struct {
68             ushort      reserved;
69             union {
70                 struct {
71                     ulong32  msg_handle;        /* message handle */
72                     ulong32  msg_addr;          /* message buffer address */
73                 } PACKED msg;
74                 unchar       data[12];          /* buffer for rtc data, ... */
75             } su;
76         } PACKED screen;                        /* screen service cmd. str. */
77         struct {
78             ushort      reserved;
79             ulong32     direction;              /* data direction */
80             ulong32     mdisc_time;             /* disc. time (0: no timeout)*/
81             ulong32     mcon_time;              /* connect time(0: no to.) */
82             ulong32     sdata;                  /* dest. addr. (if s/g: -1) */
83             ulong32     sdlen;                  /* data length (bytes) */
84             ulong32     clen;                   /* SCSI cmd. length(6,10,12) */
85             unchar      cmd[12];                /* SCSI command */
86             unchar      target;                 /* target ID */
87             unchar      lun;                    /* LUN */
88             unchar      bus;                    /* SCSI bus number */
89             unchar      priority;               /* only 0 used */
90             ulong32     sense_len;              /* sense data length */
91             ulong32     sense_data;             /* sense data addr. */
92             ulong32     link_p;                 /* linked cmds (not supp.) */
93             ulong32     sg_ranz;                /* s/g element count */
94             gdth_sg_str sg_lst[GDTH_MAXSG];     /* s/g list */
95         } PACKED raw;                           /* raw service cmd. struct. */
96     } u;
97     /* additional variables */
98     unchar      Service;                        /* controller service */
99     unchar      reserved;
100     ushort      Status;                         /* command result */
101     ulong32     Info;                           /* additional information */
102     void        *RequestBuffer;                 /* request buffer */
103 } PACKED gdth_cmd_str;
104
105 /* controller event structure */
106 #define ES_ASYNC    1
107 #define ES_DRIVER   2
108 #define ES_TEST     3
109 #define ES_SYNC     4
110 typedef struct {
111     ushort                  size;               /* size of structure */
112     union {
113         char                stream[16];
114         struct {
115             ushort          ionode;
116             ushort          service;
117             ulong32         index;
118         } PACKED driver;
119         struct {
120             ushort          ionode;
121             ushort          service;
122             ushort          status;
123             ulong32         info;
124             unchar          scsi_coord[3];
125         } PACKED async;
126         struct {
127             ushort          ionode;
128             ushort          service;
129             ushort          status;
130             ulong32         info;
131             ushort          hostdrive;
132             unchar          scsi_coord[3];
133             unchar          sense_key;
134         } PACKED sync;
135         struct {
136             ulong32         l1, l2, l3, l4;
137         } PACKED test;
138     } eu;
139     ulong32                 severity;
140     unchar                  event_string[256];          
141 } PACKED gdth_evt_data;
142
143 typedef struct {
144     ulong32         first_stamp;
145     ulong32         last_stamp;
146     ushort          same_count;
147     ushort          event_source;
148     ushort          event_idx;
149     unchar          application;
150     unchar          reserved;
151     gdth_evt_data   event_data;
152 } PACKED gdth_evt_str;
153
154
155 #ifdef GDTH_IOCTL_PROC
156 /* IOCTL structure (write) */
157 typedef struct {
158     ulong32                 magic;              /* IOCTL magic */
159     ushort                  ioctl;              /* IOCTL */
160     ushort                  ionode;             /* controller number */
161     ushort                  service;            /* controller service */
162     ushort                  timeout;            /* timeout */
163     union {
164         struct {
165             unchar          command[512];       /* controller command */
166             unchar          data[1];            /* add. data */
167         } general;
168         struct {
169             unchar          lock;               /* lock/unlock */
170             unchar          drive_cnt;          /* drive count */
171             ushort          drives[MAX_HDRIVES];/* drives */
172         } lockdrv;
173         struct {
174             unchar          lock;               /* lock/unlock */
175             unchar          channel;            /* channel */
176         } lockchn;
177         struct {
178             int             erase;              /* erase event ? */
179             int             handle;
180             unchar          evt[EVENT_SIZE];    /* event structure */
181         } event;
182         struct {
183             unchar          bus;                /* SCSI bus */
184             unchar          target;             /* target ID */
185             unchar          lun;                /* LUN */
186             unchar          cmd_len;            /* command length */
187             unchar          cmd[12];            /* SCSI command */
188         } scsi;
189         struct {
190             ushort          hdr_no;             /* host drive number */
191             unchar          flag;               /* old meth./add/remove */
192         } rescan;
193     } iu;
194 } gdth_iowr_str;
195
196 /* IOCTL structure (read) */
197 typedef struct {
198     ulong32                 size;               /* buffer size */
199     ulong32                 status;             /* IOCTL error code */
200     union {
201         struct {
202             unchar          data[1];            /* data */
203         } general;
204         struct {
205             ushort          version;            /* driver version */
206         } drvers;
207         struct {
208             unchar          type;               /* controller type */
209             ushort          info;               /* slot etc. */
210             ushort          oem_id;             /* OEM ID */
211             ushort          bios_ver;           /* not used */
212             ushort          access;             /* not used */
213             ushort          ext_type;           /* extended type */
214             ushort          device_id;          /* device ID */
215             ushort          sub_device_id;      /* sub device ID */
216         } ctrtype;
217         struct {
218             unchar          version;            /* OS version */
219             unchar          subversion;         /* OS subversion */
220             ushort          revision;           /* revision */
221         } osvers;
222         struct {
223             ushort          count;              /* controller count */
224         } ctrcnt;
225         struct {
226             int             handle;
227             unchar          evt[EVENT_SIZE];    /* event structure */
228         } event;
229         struct {
230             unchar          bus;                /* SCSI bus, 0xff: invalid */
231             unchar          target;             /* target ID */
232             unchar          lun;                /* LUN */
233             unchar          cluster_type;       /* cluster properties */
234         } hdr_list[MAX_HDRIVES];                /* index is host drive number */
235     } iu;
236 } gdth_iord_str;
237 #endif
238
239 #ifdef GDTH_IOCTL_CHRDEV
240 /* GDTIOCTL_GENERAL */
241 typedef struct {
242     ushort ionode;                              /* controller number */
243     ushort timeout;                             /* timeout */
244     ulong32 info;                               /* error info */ 
245     ushort status;                              /* status */
246     ulong data_len;                             /* data buffer size */
247     ulong sense_len;                            /* sense buffer size */
248     gdth_cmd_str command;                       /* command */                   
249 } gdth_ioctl_general;
250
251 /* GDTIOCTL_LOCKDRV */
252 typedef struct {
253     ushort ionode;                              /* controller number */
254     unchar lock;                                /* lock/unlock */
255     unchar drive_cnt;                           /* drive count */
256     ushort drives[MAX_HDRIVES];                 /* drives */
257 } gdth_ioctl_lockdrv;
258
259 /* GDTIOCTL_LOCKCHN */
260 typedef struct {
261     ushort ionode;                              /* controller number */
262     unchar lock;                                /* lock/unlock */
263     unchar channel;                             /* channel */
264 } gdth_ioctl_lockchn;
265
266 /* GDTIOCTL_OSVERS */
267 typedef struct {
268     unchar version;                             /* OS version */
269     unchar subversion;                          /* OS subversion */
270     ushort revision;                            /* revision */
271 } gdth_ioctl_osvers;
272
273 /* GDTIOCTL_CTRTYPE */
274 typedef struct {
275     ushort ionode;                              /* controller number */
276     unchar type;                                /* controller type */
277     ushort info;                                /* slot etc. */
278     ushort oem_id;                              /* OEM ID */
279     ushort bios_ver;                            /* not used */
280     ushort access;                              /* not used */
281     ushort ext_type;                            /* extended type */
282     ushort device_id;                           /* device ID */
283     ushort sub_device_id;                       /* sub device ID */
284 } gdth_ioctl_ctrtype;
285
286 /* GDTIOCTL_EVENT */
287 typedef struct {
288     ushort ionode;
289     int erase;                                  /* erase event? */
290     int handle;                                 /* event handle */
291     gdth_evt_str event;
292 } gdth_ioctl_event;
293
294 /* GDTIOCTL_RESCAN/GDTIOCTL_HDRLIST */
295 typedef struct {
296     ushort ionode;                              /* controller number */
297     unchar flag;                                /* add/remove */
298     ushort hdr_no;                              /* drive no. */
299     struct {
300         unchar bus;                             /* SCSI bus */
301         unchar target;                          /* target ID */
302         unchar lun;                             /* LUN */
303         unchar cluster_type;                    /* cluster properties */
304     } hdr_list[MAX_HDRIVES];                    /* index is host drive number */
305 } gdth_ioctl_rescan;
306
307 /* GDTIOCTL_RESET_BUS/GDTIOCTL_RESET_DRV */
308 typedef struct {
309     ushort ionode;                              /* controller number */
310     ushort number;                              /* bus/host drive number */
311     ushort status;                              /* status */
312 } gdth_ioctl_reset;
313 #endif
314
315 #endif