ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / scsi / gdth.h
1 #ifndef _GDTH_H
2 #define _GDTH_H
3
4 /*
5  * Header file for the GDT Disk Array/Storage RAID controllers driver for Linux
6  * 
7  * gdth.h Copyright (C) 1995-03 ICP vortex, Achim Leubner
8  * See gdth.c for further informations and 
9  * below for supported controller types
10  *
11  * <achim_leubner@adaptec.com>
12  *
13  * $Id: gdth.h,v 1.50 2003/09/17 08:29:58 achim Exp $
14  */
15
16 #include <linux/version.h>
17 #include <linux/types.h>
18
19 #ifndef TRUE
20 #define TRUE 1
21 #endif
22 #ifndef FALSE
23 #define FALSE 0
24 #endif
25
26 /* defines, macros */
27
28 /* driver version */
29 #define GDTH_VERSION_STR        "2.08"
30 #define GDTH_VERSION            2
31 #define GDTH_SUBVERSION         8
32
33 /* protocol version */
34 #define PROTOCOL_VERSION        1
35
36 /* OEM IDs */
37 #define OEM_ID_ICP      0x941c
38 #define OEM_ID_INTEL    0x8000
39
40 /* controller classes */
41 #define GDT_ISA         0x01                    /* ISA controller */
42 #define GDT_EISA        0x02                    /* EISA controller */
43 #define GDT_PCI         0x03                    /* PCI controller */
44 #define GDT_PCINEW      0x04                    /* new PCI controller */
45 #define GDT_PCIMPR      0x05                    /* PCI MPR controller */
46 /* GDT_EISA, controller subtypes EISA */
47 #define GDT3_ID         0x0130941c              /* GDT3000/3020 */
48 #define GDT3A_ID        0x0230941c              /* GDT3000A/3020A/3050A */
49 #define GDT3B_ID        0x0330941c              /* GDT3000B/3010A */
50 /* GDT_ISA */
51 #define GDT2_ID         0x0120941c              /* GDT2000/2020 */
52
53 /* vendor ID, device IDs (PCI) */
54 /* these defines should already exist in <linux/pci.h> */
55 #ifndef PCI_VENDOR_ID_VORTEX
56 #define PCI_VENDOR_ID_VORTEX            0x1119  /* PCI controller vendor ID */
57 #endif
58 #ifndef PCI_VENDOR_ID_INTEL
59 #define PCI_VENDOR_ID_INTEL             0x8086  
60 #endif
61
62 #ifndef PCI_DEVICE_ID_VORTEX_GDT60x0
63 /* GDT_PCI */
64 #define PCI_DEVICE_ID_VORTEX_GDT60x0    0       /* GDT6000/6020/6050 */
65 #define PCI_DEVICE_ID_VORTEX_GDT6000B   1       /* GDT6000B/6010 */
66 /* GDT_PCINEW */
67 #define PCI_DEVICE_ID_VORTEX_GDT6x10    2       /* GDT6110/6510 */
68 #define PCI_DEVICE_ID_VORTEX_GDT6x20    3       /* GDT6120/6520 */
69 #define PCI_DEVICE_ID_VORTEX_GDT6530    4       /* GDT6530 */
70 #define PCI_DEVICE_ID_VORTEX_GDT6550    5       /* GDT6550 */
71 /* GDT_PCINEW, wide/ultra SCSI controllers */
72 #define PCI_DEVICE_ID_VORTEX_GDT6x17    6       /* GDT6117/6517 */
73 #define PCI_DEVICE_ID_VORTEX_GDT6x27    7       /* GDT6127/6527 */
74 #define PCI_DEVICE_ID_VORTEX_GDT6537    8       /* GDT6537 */
75 #define PCI_DEVICE_ID_VORTEX_GDT6557    9       /* GDT6557/6557-ECC */
76 /* GDT_PCINEW, wide SCSI controllers */
77 #define PCI_DEVICE_ID_VORTEX_GDT6x15    10      /* GDT6115/6515 */
78 #define PCI_DEVICE_ID_VORTEX_GDT6x25    11      /* GDT6125/6525 */
79 #define PCI_DEVICE_ID_VORTEX_GDT6535    12      /* GDT6535 */
80 #define PCI_DEVICE_ID_VORTEX_GDT6555    13      /* GDT6555/6555-ECC */
81 #endif
82
83 #ifndef PCI_DEVICE_ID_VORTEX_GDT6x17RP
84 /* GDT_MPR, RP series, wide/ultra SCSI */
85 #define PCI_DEVICE_ID_VORTEX_GDT6x17RP  0x100   /* GDT6117RP/GDT6517RP */
86 #define PCI_DEVICE_ID_VORTEX_GDT6x27RP  0x101   /* GDT6127RP/GDT6527RP */
87 #define PCI_DEVICE_ID_VORTEX_GDT6537RP  0x102   /* GDT6537RP */
88 #define PCI_DEVICE_ID_VORTEX_GDT6557RP  0x103   /* GDT6557RP */
89 /* GDT_MPR, RP series, narrow/ultra SCSI */
90 #define PCI_DEVICE_ID_VORTEX_GDT6x11RP  0x104   /* GDT6111RP/GDT6511RP */
91 #define PCI_DEVICE_ID_VORTEX_GDT6x21RP  0x105   /* GDT6121RP/GDT6521RP */
92 #endif
93 #ifndef PCI_DEVICE_ID_VORTEX_GDT6x17RD
94 /* GDT_MPR, RD series, wide/ultra SCSI */
95 #define PCI_DEVICE_ID_VORTEX_GDT6x17RD  0x110   /* GDT6117RD/GDT6517RD */
96 #define PCI_DEVICE_ID_VORTEX_GDT6x27RD  0x111   /* GDT6127RD/GDT6527RD */
97 #define PCI_DEVICE_ID_VORTEX_GDT6537RD  0x112   /* GDT6537RD */
98 #define PCI_DEVICE_ID_VORTEX_GDT6557RD  0x113   /* GDT6557RD */
99 /* GDT_MPR, RD series, narrow/ultra SCSI */
100 #define PCI_DEVICE_ID_VORTEX_GDT6x11RD  0x114   /* GDT6111RD/GDT6511RD */
101 #define PCI_DEVICE_ID_VORTEX_GDT6x21RD  0x115   /* GDT6121RD/GDT6521RD */
102 /* GDT_MPR, RD series, wide/ultra2 SCSI */
103 #define PCI_DEVICE_ID_VORTEX_GDT6x18RD  0x118   /* GDT6118RD/GDT6518RD/
104                                                    GDT6618RD */
105 #define PCI_DEVICE_ID_VORTEX_GDT6x28RD  0x119   /* GDT6128RD/GDT6528RD/
106                                                    GDT6628RD */
107 #define PCI_DEVICE_ID_VORTEX_GDT6x38RD  0x11A   /* GDT6538RD/GDT6638RD */
108 #define PCI_DEVICE_ID_VORTEX_GDT6x58RD  0x11B   /* GDT6558RD/GDT6658RD */
109 /* GDT_MPR, RN series (64-bit PCI), wide/ultra2 SCSI */
110 #define PCI_DEVICE_ID_VORTEX_GDT7x18RN  0x168   /* GDT7118RN/GDT7518RN/
111                                                    GDT7618RN */
112 #define PCI_DEVICE_ID_VORTEX_GDT7x28RN  0x169   /* GDT7128RN/GDT7528RN/
113                                                    GDT7628RN */
114 #define PCI_DEVICE_ID_VORTEX_GDT7x38RN  0x16A   /* GDT7538RN/GDT7638RN */
115 #define PCI_DEVICE_ID_VORTEX_GDT7x58RN  0x16B   /* GDT7558RN/GDT7658RN */
116 #endif
117
118 #ifndef PCI_DEVICE_ID_VORTEX_GDT6x19RD
119 /* GDT_MPR, RD series, Fibre Channel */
120 #define PCI_DEVICE_ID_VORTEX_GDT6x19RD  0x210   /* GDT6519RD/GDT6619RD */
121 #define PCI_DEVICE_ID_VORTEX_GDT6x29RD  0x211   /* GDT6529RD/GDT6629RD */
122 /* GDT_MPR, RN series (64-bit PCI), Fibre Channel */
123 #define PCI_DEVICE_ID_VORTEX_GDT7x19RN  0x260   /* GDT7519RN/GDT7619RN */
124 #define PCI_DEVICE_ID_VORTEX_GDT7x29RN  0x261   /* GDT7529RN/GDT7629RN */
125 #endif
126
127 #ifndef PCI_DEVICE_ID_VORTEX_GDTMAXRP
128 /* GDT_MPR, last device ID */
129 #define PCI_DEVICE_ID_VORTEX_GDTMAXRP   0x2ff   
130 #endif
131
132 #ifndef PCI_DEVICE_ID_VORTEX_GDTNEWRX
133 /* new GDT Rx Controller */
134 #define PCI_DEVICE_ID_VORTEX_GDTNEWRX   0x300
135 #endif
136         
137 #ifndef PCI_DEVICE_ID_INTEL_SRC
138 /* Intel Storage RAID Controller */
139 #define PCI_DEVICE_ID_INTEL_SRC         0x600
140 #endif
141
142 #ifndef PCI_DEVICE_ID_INTEL_SRC_XSCALE
143 /* Intel Storage RAID Controller */
144 #define PCI_DEVICE_ID_INTEL_SRC_XSCALE  0x601
145 #endif
146
147 /* limits */
148 #define GDTH_SCRATCH    PAGE_SIZE               /* 4KB scratch buffer */
149 #define GDTH_SCRATCH_ORD 0                      /* order 0 means 1 page */
150 #define GDTH_MAXCMDS    124
151 #define GDTH_MAXC_P_L   16                      /* max. cmds per lun */
152 #define GDTH_MAX_RAW    2                       /* max. cmds per raw device */
153 #define MAXOFFSETS      128
154 #define MAXHA           16
155 #define MAXID           127
156 #define MAXLUN          8
157 #define MAXBUS          6
158 #define MAX_EVENTS      100                     /* event buffer count */
159 #define MAX_RES_ARGS    40                      /* device reservation, 
160                                                    must be a multiple of 4 */
161 #define MAXCYLS         1024
162 #define HEADS           64
163 #define SECS            32                      /* mapping 64*32 */
164 #define MEDHEADS        127
165 #define MEDSECS         63                      /* mapping 127*63 */
166 #define BIGHEADS        255
167 #define BIGSECS         63                      /* mapping 255*63 */
168
169 /* special command ptr. */
170 #define UNUSED_CMND     ((Scsi_Cmnd *)-1)
171 #define INTERNAL_CMND   ((Scsi_Cmnd *)-2)
172 #define SCREEN_CMND     ((Scsi_Cmnd *)-3)
173 #define SPECIAL_SCP(p)  (p==UNUSED_CMND || p==INTERNAL_CMND || p==SCREEN_CMND)
174
175 /* controller services */
176 #define SCSIRAWSERVICE  3
177 #define CACHESERVICE    9
178 #define SCREENSERVICE   11
179
180 /* screenservice defines */
181 #define MSG_INV_HANDLE  -1                      /* special message handle */
182 #define MSGLEN          16                      /* size of message text */
183 #define MSG_SIZE        34                      /* size of message structure */
184 #define MSG_REQUEST     0                       /* async. event: message */
185
186 /* cacheservice defines */
187 #define SECTOR_SIZE     0x200                   /* always 512 bytes per sec. */
188
189 /* DPMEM constants */
190 #define DPMEM_MAGIC     0xC0FFEE11
191 #define IC_HEADER_BYTES 48
192 #define IC_QUEUE_BYTES  4
193 #define DPMEM_COMMAND_OFFSET    IC_HEADER_BYTES+IC_QUEUE_BYTES*MAXOFFSETS
194
195 /* cluster_type constants */
196 #define CLUSTER_DRIVE         1
197 #define CLUSTER_MOUNTED       2
198 #define CLUSTER_RESERVED      4
199 #define CLUSTER_RESERVE_STATE (CLUSTER_DRIVE|CLUSTER_MOUNTED|CLUSTER_RESERVED)
200
201 /* commands for all services, cache service */
202 #define GDT_INIT        0                       /* service initialization */
203 #define GDT_READ        1                       /* read command */
204 #define GDT_WRITE       2                       /* write command */
205 #define GDT_INFO        3                       /* information about devices */
206 #define GDT_FLUSH       4                       /* flush dirty cache buffers */
207 #define GDT_IOCTL       5                       /* ioctl command */
208 #define GDT_DEVTYPE     9                       /* additional information */
209 #define GDT_MOUNT       10                      /* mount cache device */
210 #define GDT_UNMOUNT     11                      /* unmount cache device */
211 #define GDT_SET_FEAT    12                      /* set feat. (scatter/gather) */
212 #define GDT_GET_FEAT    13                      /* get features */
213 #define GDT_WRITE_THR   16                      /* write through */
214 #define GDT_READ_THR    17                      /* read through */
215 #define GDT_EXT_INFO    18                      /* extended info */
216 #define GDT_RESET       19                      /* controller reset */
217 #define GDT_RESERVE_DRV 20                      /* reserve host drive */
218 #define GDT_RELEASE_DRV 21                      /* release host drive */
219 #define GDT_CLUST_INFO  22                      /* cluster info */
220 #define GDT_RW_ATTRIBS  23                      /* R/W attribs (write thru,..)*/
221 #define GDT_CLUST_RESET 24                      /* releases the cluster drives*/
222 #define GDT_FREEZE_IO   25                      /* freezes all IOs */
223 #define GDT_UNFREEZE_IO 26                      /* unfreezes all IOs */
224
225 /* raw service commands */
226 #define GDT_RESERVE     14                      /* reserve dev. to raw serv. */
227 #define GDT_RELEASE     15                      /* release device */
228 #define GDT_RESERVE_ALL 16                      /* reserve all devices */
229 #define GDT_RELEASE_ALL 17                      /* release all devices */
230 #define GDT_RESET_BUS   18                      /* reset bus */
231 #define GDT_SCAN_START  19                      /* start device scan */
232 #define GDT_SCAN_END    20                      /* stop device scan */  
233
234 /* screen service commands */
235 #define GDT_REALTIME    3                       /* realtime clock to screens. */
236
237 /* IOCTL command defines */
238 #define SCSI_DR_INFO    0x00                    /* SCSI drive info */                   
239 #define SCSI_CHAN_CNT   0x05                    /* SCSI channel count */   
240 #define SCSI_DR_LIST    0x06                    /* SCSI drive list */
241 #define SCSI_DEF_CNT    0x15                    /* grown/primary defects */
242 #define DSK_STATISTICS  0x4b                    /* SCSI disk statistics */
243 #define IOCHAN_DESC     0x5d                    /* description of IO channel */
244 #define IOCHAN_RAW_DESC 0x5e                    /* description of raw IO chn. */
245 #define L_CTRL_PATTERN  0x20000000L             /* SCSI IOCTL mask */
246 #define ARRAY_INFO      0x12                    /* array drive info */
247 #define ARRAY_DRV_LIST  0x0f                    /* array drive list */
248 #define ARRAY_DRV_LIST2 0x34                    /* array drive list (new) */
249 #define LA_CTRL_PATTERN 0x10000000L             /* array IOCTL mask */
250 #define CACHE_DRV_CNT   0x01                    /* cache drive count */
251 #define CACHE_DRV_LIST  0x02                    /* cache drive list */
252 #define CACHE_INFO      0x04                    /* cache info */
253 #define CACHE_CONFIG    0x05                    /* cache configuration */
254 #define CACHE_DRV_INFO  0x07                    /* cache drive info */
255 #define BOARD_FEATURES  0x15                    /* controller features */
256 #define BOARD_INFO      0x28                    /* controller info */
257 #define CACHE_READ_OEM_STRING_RECORD 0x84       /* read OEM string record */ 
258 #define HOST_GET        0x10001L                /* get host drive list */
259 #define IO_CHANNEL      0x00020000L             /* default IO channel */
260 #define INVALID_CHANNEL 0x0000ffffL             /* invalid channel */
261
262 /* service errors */
263 #define S_OK            1                       /* no error */
264 #define S_GENERR        6                       /* general error */
265 #define S_BSY           7                       /* controller busy */
266 #define S_CACHE_UNKNOWN 12                      /* cache serv.: drive unknown */
267 #define S_RAW_SCSI      12                      /* raw serv.: target error */
268 #define S_RAW_ILL       0xff                    /* raw serv.: illegal */
269 #define S_CACHE_RESERV  -24                     /* cache: reserv. conflict */   
270
271 /* timeout values */
272 #define INIT_RETRIES    100000                  /* 100000 * 1ms = 100s */
273 #define INIT_TIMEOUT    100000                  /* 100000 * 1ms = 100s */
274 #define POLL_TIMEOUT    10000                   /* 10000 * 1ms = 10s */
275
276 /* priorities */
277 #define DEFAULT_PRI     0x20
278 #define IOCTL_PRI       0x10
279 #define HIGH_PRI        0x08
280
281 /* data directions */
282 #define GDTH_DATA_IN    0x01000000L             /* data from target */
283 #define GDTH_DATA_OUT   0x00000000L             /* data to target */
284
285 /* BMIC registers (EISA controllers) */
286 #define ID0REG          0x0c80                  /* board ID */
287 #define EINTENABREG     0x0c89                  /* interrupt enable */
288 #define SEMA0REG        0x0c8a                  /* command semaphore */
289 #define SEMA1REG        0x0c8b                  /* status semaphore */
290 #define LDOORREG        0x0c8d                  /* local doorbell */
291 #define EDENABREG       0x0c8e                  /* EISA system doorbell enab. */
292 #define EDOORREG        0x0c8f                  /* EISA system doorbell */
293 #define MAILBOXREG      0x0c90                  /* mailbox reg. (16 bytes) */
294 #define EISAREG         0x0cc0                  /* EISA configuration */
295
296 /* DMA memory mappings */
297 #define GDTH_MAP_NONE   0
298 #define GDTH_MAP_SINGLE 1
299 #define GDTH_MAP_SG     2
300 #define GDTH_MAP_IOCTL  3 
301
302 /* other defines */
303 #define LINUX_OS        8                       /* used for cache optim. */
304 #define SCATTER_GATHER  1                       /* s/g feature */
305 #define SECS32          0x1f                    /* round capacity */
306 #define BIOS_ID_OFFS    0x10                    /* offset contr-ID in ISABIOS */
307 #define LOCALBOARD      0                       /* board node always 0 */
308 #define ASYNCINDEX      0                       /* cmd index async. event */
309 #define SPEZINDEX       1                       /* cmd index unknown service */
310 #define GDT_WR_THROUGH  0x100                   /* WRITE_THROUGH supported */
311
312 #include "gdth_ioctl.h"
313
314 /* screenservice message */
315 typedef struct {                               
316     ulong32     msg_handle;                     /* message handle */
317     ulong32     msg_len;                        /* size of message */
318     ulong32     msg_alen;                       /* answer length */
319     unchar      msg_answer;                     /* answer flag */
320     unchar      msg_ext;                        /* more messages */
321     unchar      msg_reserved[2];
322     char        msg_text[MSGLEN+2];             /* the message text */
323 } PACKED gdth_msg_str;
324
325 /* IOCTL data structures */
326 /* SCSI drive info */
327 typedef struct {
328     unchar      vendor[8];                      /* vendor string */
329     unchar      product[16];                    /* product string */
330     unchar      revision[4];                    /* revision */
331     ulong32     sy_rate;                        /* current rate for sync. tr. */
332     ulong32     sy_max_rate;                    /* max. rate for sync. tr. */
333     ulong32     no_ldrive;                      /* belongs to this log. drv.*/
334     ulong32     blkcnt;                         /* number of blocks */
335     ushort      blksize;                        /* size of block in bytes */
336     unchar      available;                      /* flag: access is available */
337     unchar      init;                           /* medium is initialized */
338     unchar      devtype;                        /* SCSI devicetype */
339     unchar      rm_medium;                      /* medium is removable */
340     unchar      wp_medium;                      /* medium is write protected */
341     unchar      ansi;                           /* SCSI I/II or III? */
342     unchar      protocol;                       /* same as ansi */
343     unchar      sync;                           /* flag: sync. transfer enab. */
344     unchar      disc;                           /* flag: disconnect enabled */
345     unchar      queueing;                       /* flag: command queing enab. */
346     unchar      cached;                         /* flag: caching enabled */
347     unchar      target_id;                      /* target ID of device */
348     unchar      lun;                            /* LUN id of device */
349     unchar      orphan;                         /* flag: drive fragment */
350     ulong32     last_error;                     /* sense key or drive state */
351     ulong32     last_result;                    /* result of last command */
352     ulong32     check_errors;                   /* err. in last surface check */
353     unchar      percent;                        /* progress for surface check */
354     unchar      last_check;                     /* IOCTRL operation */
355     unchar      res[2];
356     ulong32     flags;                          /* from 1.19/2.19: raw reserv.*/
357     unchar      multi_bus;                      /* multi bus dev? (fibre ch.) */
358     unchar      mb_status;                      /* status: available? */
359     unchar      res2[2];
360     unchar      mb_alt_status;                  /* status on second bus */
361     unchar      mb_alt_bid;                     /* number of second bus */
362     unchar      mb_alt_tid;                     /* target id on second bus */
363     unchar      res3;
364     unchar      fc_flag;                        /* from 1.22/2.22: info valid?*/
365     unchar      res4;
366     ushort      fc_frame_size;                  /* frame size (bytes) */
367     char        wwn[8];                         /* world wide name */
368 } PACKED gdth_diskinfo_str;
369
370 /* get SCSI channel count  */
371 typedef struct {
372     ulong32     channel_no;                     /* number of channel */
373     ulong32     drive_cnt;                      /* drive count */
374     unchar      siop_id;                        /* SCSI processor ID */
375     unchar      siop_state;                     /* SCSI processor state */ 
376 } PACKED gdth_getch_str;
377
378 /* get SCSI drive numbers */
379 typedef struct {
380     ulong32     sc_no;                          /* SCSI channel */
381     ulong32     sc_cnt;                         /* sc_list[] elements */
382     ulong32     sc_list[MAXID];                 /* minor device numbers */
383 } PACKED gdth_drlist_str;
384
385 /* get grown/primary defect count */
386 typedef struct {
387     unchar      sddc_type;                      /* 0x08: grown, 0x10: prim. */
388     unchar      sddc_format;                    /* list entry format */
389     unchar      sddc_len;                       /* list entry length */
390     unchar      sddc_res;
391     ulong32     sddc_cnt;                       /* entry count */
392 } PACKED gdth_defcnt_str;
393
394 /* disk statistics */
395 typedef struct {
396     ulong32     bid;                            /* SCSI channel */
397     ulong32     first;                          /* first SCSI disk */
398     ulong32     entries;                        /* number of elements */
399     ulong32     count;                          /* (R) number of init. el. */
400     ulong32     mon_time;                       /* time stamp */
401     struct {
402         unchar  tid;                            /* target ID */
403         unchar  lun;                            /* LUN */
404         unchar  res[2];
405         ulong32 blk_size;                       /* block size in bytes */
406         ulong32 rd_count;                       /* bytes read */
407         ulong32 wr_count;                       /* bytes written */
408         ulong32 rd_blk_count;                   /* blocks read */
409         ulong32 wr_blk_count;                   /* blocks written */
410         ulong32 retries;                        /* retries */
411         ulong32 reassigns;                      /* reassigns */
412     } PACKED list[1];
413 } PACKED gdth_dskstat_str;
414
415 /* IO channel header */
416 typedef struct {
417     ulong32     version;                        /* version (-1UL: newest) */
418     unchar      list_entries;                   /* list entry count */
419     unchar      first_chan;                     /* first channel number */
420     unchar      last_chan;                      /* last channel number */
421     unchar      chan_count;                     /* (R) channel count */
422     ulong32     list_offset;                    /* offset of list[0] */
423 } PACKED gdth_iochan_header;
424
425 /* get IO channel description */
426 typedef struct {
427     gdth_iochan_header  hdr;
428     struct {
429         ulong32         address;                /* channel address */
430         unchar          type;                   /* type (SCSI, FCAL) */
431         unchar          local_no;               /* local number */
432         ushort          features;               /* channel features */
433     } PACKED list[MAXBUS];
434 } PACKED gdth_iochan_str;
435
436 /* get raw IO channel description */
437 typedef struct {
438     gdth_iochan_header  hdr;
439     struct {
440         unchar      proc_id;                    /* processor id */
441         unchar      proc_defect;                /* defect ? */
442         unchar      reserved[2];
443     } PACKED list[MAXBUS];
444 } PACKED gdth_raw_iochan_str;
445
446 /* array drive component */
447 typedef struct {
448     ulong32     al_controller;                  /* controller ID */
449     unchar      al_cache_drive;                 /* cache drive number */
450     unchar      al_status;                      /* cache drive state */
451     unchar      al_res[2];     
452 } PACKED gdth_arraycomp_str;
453
454 /* array drive information */
455 typedef struct {
456     unchar      ai_type;                        /* array type (RAID0,4,5) */
457     unchar      ai_cache_drive_cnt;             /* active cachedrives */
458     unchar      ai_state;                       /* array drive state */
459     unchar      ai_master_cd;                   /* master cachedrive */
460     ulong32     ai_master_controller;           /* ID of master controller */
461     ulong32     ai_size;                        /* user capacity [sectors] */
462     ulong32     ai_striping_size;               /* striping size [sectors] */
463     ulong32     ai_secsize;                     /* sector size [bytes] */
464     ulong32     ai_err_info;                    /* failed cache drive */
465     unchar      ai_name[8];                     /* name of the array drive */
466     unchar      ai_controller_cnt;              /* number of controllers */
467     unchar      ai_removable;                   /* flag: removable */
468     unchar      ai_write_protected;             /* flag: write protected */
469     unchar      ai_devtype;                     /* type: always direct access */
470     gdth_arraycomp_str  ai_drives[35];          /* drive components: */
471     unchar      ai_drive_entries;               /* number of drive components */
472     unchar      ai_protected;                   /* protection flag */
473     unchar      ai_verify_state;                /* state of a parity verify */
474     unchar      ai_ext_state;                   /* extended array drive state */
475     unchar      ai_expand_state;                /* array expand state (>=2.18)*/
476     unchar      ai_reserved[3];
477 } PACKED gdth_arrayinf_str;
478
479 /* get array drive list */
480 typedef struct {
481     ulong32     controller_no;                  /* controller no. */
482     unchar      cd_handle;                      /* master cachedrive */
483     unchar      is_arrayd;                      /* Flag: is array drive? */
484     unchar      is_master;                      /* Flag: is array master? */
485     unchar      is_parity;                      /* Flag: is parity drive? */
486     unchar      is_hotfix;                      /* Flag: is hotfix drive? */
487     unchar      res[3];
488 } PACKED gdth_alist_str;
489
490 typedef struct {
491     ulong32     entries_avail;                  /* allocated entries */
492     ulong32     entries_init;                   /* returned entries */
493     ulong32     first_entry;                    /* first entry number */
494     ulong32     list_offset;                    /* offset of following list */
495     gdth_alist_str list[1];                     /* list */
496 } PACKED gdth_arcdl_str;
497
498 /* cache info/config IOCTL */
499 typedef struct {
500     ulong32     version;                        /* firmware version */
501     ushort      state;                          /* cache state (on/off) */
502     ushort      strategy;                       /* cache strategy */
503     ushort      write_back;                     /* write back state (on/off) */
504     ushort      block_size;                     /* cache block size */
505 } PACKED gdth_cpar_str;
506
507 typedef struct {
508     ulong32     csize;                          /* cache size */
509     ulong32     read_cnt;                       /* read/write counter */
510     ulong32     write_cnt;
511     ulong32     tr_hits;                        /* hits */
512     ulong32     sec_hits;
513     ulong32     sec_miss;                       /* misses */
514 } PACKED gdth_cstat_str;
515
516 typedef struct {
517     gdth_cpar_str   cpar;
518     gdth_cstat_str  cstat;
519 } PACKED gdth_cinfo_str;
520
521 /* cache drive info */
522 typedef struct {
523     unchar      cd_name[8];                     /* cache drive name */
524     ulong32     cd_devtype;                     /* SCSI devicetype */
525     ulong32     cd_ldcnt;                       /* number of log. drives */
526     ulong32     cd_last_error;                  /* last error */
527     unchar      cd_initialized;                 /* drive is initialized */
528     unchar      cd_removable;                   /* media is removable */
529     unchar      cd_write_protected;             /* write protected */
530     unchar      cd_flags;                       /* Pool Hot Fix? */
531     ulong32     ld_blkcnt;                      /* number of blocks */
532     ulong32     ld_blksize;                     /* blocksize */
533     ulong32     ld_dcnt;                        /* number of disks */
534     ulong32     ld_slave;                       /* log. drive index */
535     ulong32     ld_dtype;                       /* type of logical drive */
536     ulong32     ld_last_error;                  /* last error */
537     unchar      ld_name[8];                     /* log. drive name */
538     unchar      ld_error;                       /* error */
539 } PACKED gdth_cdrinfo_str;
540
541 /* OEM string */
542 typedef struct {
543     ulong32     ctl_version;
544     ulong32     file_major_version;
545     ulong32     file_minor_version;
546     ulong32     buffer_size;
547     ulong32     cpy_count;
548     ulong32     ext_error;
549     ulong32     oem_id;
550     ulong32     board_id;
551 } PACKED gdth_oem_str_params;
552
553 typedef struct {
554     unchar      product_0_1_name[16];
555     unchar      product_4_5_name[16];
556     unchar      product_cluster_name[16];
557     unchar      product_reserved[16];
558     unchar      scsi_cluster_target_vendor_id[16];
559     unchar      cluster_raid_fw_name[16];
560     unchar      oem_brand_name[16];
561     unchar      oem_raid_type[16];
562     unchar      bios_type[13];
563     unchar      bios_title[50];
564     unchar      oem_company_name[37];
565     ulong32     pci_id_1;
566     ulong32     pci_id_2;
567     unchar      validation_status[80];
568     unchar      reserved_1[4];
569     unchar      scsi_host_drive_inquiry_vendor_id[16];
570     unchar      library_file_template[16];
571     unchar      reserved_2[16];
572     unchar      tool_name_1[32];
573     unchar      tool_name_2[32];
574     unchar      tool_name_3[32];
575     unchar      oem_contact_1[84];
576     unchar      oem_contact_2[84];
577     unchar      oem_contact_3[84];
578 } PACKED gdth_oem_str;
579
580 typedef struct {
581     gdth_oem_str_params params;
582     gdth_oem_str        text;
583 } PACKED gdth_oem_str_ioctl;
584
585 /* board features */
586 typedef struct {
587     unchar      chaining;                       /* Chaining supported */
588     unchar      striping;                       /* Striping (RAID-0) supp. */
589     unchar      mirroring;                      /* Mirroring (RAID-1) supp. */
590     unchar      raid;                           /* RAID-4/5/10 supported */
591 } PACKED gdth_bfeat_str;
592
593 /* board info IOCTL */
594 typedef struct {
595     ulong32     ser_no;                         /* serial no. */
596     unchar      oem_id[2];                      /* OEM ID */
597     ushort      ep_flags;                       /* eprom flags */
598     ulong32     proc_id;                        /* processor ID */
599     ulong32     memsize;                        /* memory size (bytes) */
600     unchar      mem_banks;                      /* memory banks */
601     unchar      chan_type;                      /* channel type */
602     unchar      chan_count;                     /* channel count */
603     unchar      rdongle_pres;                   /* dongle present? */
604     ulong32     epr_fw_ver;                     /* (eprom) firmware version */
605     ulong32     upd_fw_ver;                     /* (update) firmware version */
606     ulong32     upd_revision;                   /* update revision */
607     char        type_string[16];                /* controller name */
608     char        raid_string[16];                /* RAID firmware name */
609     unchar      update_pres;                    /* update present? */
610     unchar      xor_pres;                       /* XOR engine present? */
611     unchar      prom_type;                      /* ROM type (eprom/flash) */
612     unchar      prom_count;                     /* number of ROM devices */
613     ulong32     dup_pres;                       /* duplexing module present? */
614     ulong32     chan_pres;                      /* number of expansion chn. */
615     ulong32     mem_pres;                       /* memory expansion inst. ? */
616     unchar      ft_bus_system;                  /* fault bus supported? */
617     unchar      subtype_valid;                  /* board_subtype valid? */
618     unchar      board_subtype;                  /* subtype/hardware level */
619     unchar      ramparity_pres;                 /* RAM parity check hardware? */
620 } PACKED gdth_binfo_str; 
621
622 /* get host drive info */
623 typedef struct {
624     char        name[8];                        /* host drive name */
625     ulong32     size;                           /* size (sectors) */
626     unchar      host_drive;                     /* host drive number */
627     unchar      log_drive;                      /* log. drive (master) */
628     unchar      reserved;
629     unchar      rw_attribs;                     /* r/w attribs */
630     ulong32     start_sec;                      /* start sector */
631 } PACKED gdth_hentry_str;
632
633 typedef struct {
634     ulong32     entries;                        /* entry count */
635     ulong32     offset;                         /* offset of entries */
636     unchar      secs_p_head;                    /* sectors/head */
637     unchar      heads_p_cyl;                    /* heads/cylinder */
638     unchar      reserved;
639     unchar      clust_drvtype;                  /* cluster drive type */
640     ulong32     location;                       /* controller number */
641     gdth_hentry_str entry[MAX_HDRIVES];         /* entries */
642 } PACKED gdth_hget_str;    
643
644
645 /* DPRAM structures */
646
647 /* interface area ISA/PCI */
648 typedef struct {
649     unchar              S_Cmd_Indx;             /* special command */
650     unchar volatile     S_Status;               /* status special command */
651     ushort              reserved1;
652     ulong32             S_Info[4];              /* add. info special command */
653     unchar volatile     Sema0;                  /* command semaphore */
654     unchar              reserved2[3];
655     unchar              Cmd_Index;              /* command number */
656     unchar              reserved3[3];
657     ushort volatile     Status;                 /* command status */
658     ushort              Service;                /* service(for async.events) */
659     ulong32             Info[2];                /* additional info */
660     struct {
661         ushort          offset;                 /* command offs. in the DPRAM*/
662         ushort          serv_id;                /* service */
663     } PACKED comm_queue[MAXOFFSETS];            /* command queue */
664     ulong32             bios_reserved[2];
665     unchar              gdt_dpr_cmd[1];         /* commands */
666 } PACKED gdt_dpr_if;
667
668 /* SRAM structure PCI controllers */
669 typedef struct {
670     ulong32     magic;                          /* controller ID from BIOS */
671     ushort      need_deinit;                    /* switch betw. BIOS/driver */
672     unchar      switch_support;                 /* see need_deinit */
673     unchar      padding[9];
674     unchar      os_used[16];                    /* OS code per service */
675     unchar      unused[28];
676     unchar      fw_magic;                       /* contr. ID from firmware */
677 } PACKED gdt_pci_sram;
678
679 /* SRAM structure EISA controllers (but NOT GDT3000/3020) */
680 typedef struct {
681     unchar      os_used[16];                    /* OS code per service */
682     ushort      need_deinit;                    /* switch betw. BIOS/driver */
683     unchar      switch_support;                 /* see need_deinit */
684     unchar      padding;
685 } PACKED gdt_eisa_sram;
686
687
688 /* DPRAM ISA controllers */
689 typedef struct {
690     union {
691         struct {
692             unchar      bios_used[0x3c00-32];   /* 15KB - 32Bytes BIOS */
693             ulong32     magic;                  /* controller (EISA) ID */
694             ushort      need_deinit;            /* switch betw. BIOS/driver */
695             unchar      switch_support;         /* see need_deinit */
696             unchar      padding[9];
697             unchar      os_used[16];            /* OS code per service */
698         } PACKED dp_sram;
699         unchar          bios_area[0x4000];      /* 16KB reserved for BIOS */
700     } bu;
701     union {
702         gdt_dpr_if      ic;                     /* interface area */
703         unchar          if_area[0x3000];        /* 12KB for interface */
704     } u;
705     struct {
706         unchar          memlock;                /* write protection DPRAM */
707         unchar          event;                  /* release event */
708         unchar          irqen;                  /* board interrupts enable */
709         unchar          irqdel;                 /* acknowledge board int. */
710         unchar volatile Sema1;                  /* status semaphore */
711         unchar          rq;                     /* IRQ/DRQ configuration */
712     } PACKED io;
713 } PACKED gdt2_dpram_str;
714
715 /* DPRAM PCI controllers */
716 typedef struct {
717     union {
718         gdt_dpr_if      ic;                     /* interface area */
719         unchar          if_area[0xff0-sizeof(gdt_pci_sram)];
720     } u;
721     gdt_pci_sram        gdt6sr;                 /* SRAM structure */
722     struct {
723         unchar          unused0[1];
724         unchar volatile Sema1;                  /* command semaphore */
725         unchar          unused1[3];
726         unchar          irqen;                  /* board interrupts enable */
727         unchar          unused2[2];
728         unchar          event;                  /* release event */
729         unchar          unused3[3];
730         unchar          irqdel;                 /* acknowledge board int. */
731         unchar          unused4[3];
732     } PACKED io;
733 } PACKED gdt6_dpram_str;
734
735 /* PLX register structure (new PCI controllers) */
736 typedef struct {
737     unchar              cfg_reg;        /* DPRAM cfg.(2:below 1MB,0:anywhere)*/
738     unchar              unused1[0x3f];
739     unchar volatile     sema0_reg;              /* command semaphore */
740     unchar volatile     sema1_reg;              /* status semaphore */
741     unchar              unused2[2];
742     ushort volatile     status;                 /* command status */
743     ushort              service;                /* service */
744     ulong32             info[2];                /* additional info */
745     unchar              unused3[0x10];
746     unchar              ldoor_reg;              /* PCI to local doorbell */
747     unchar              unused4[3];
748     unchar volatile     edoor_reg;              /* local to PCI doorbell */
749     unchar              unused5[3];
750     unchar              control0;               /* control0 register(unused) */
751     unchar              control1;               /* board interrupts enable */
752     unchar              unused6[0x16];
753 } PACKED gdt6c_plx_regs;
754
755 /* DPRAM new PCI controllers */
756 typedef struct {
757     union {
758         gdt_dpr_if      ic;                     /* interface area */
759         unchar          if_area[0x4000-sizeof(gdt_pci_sram)];
760     } u;
761     gdt_pci_sram        gdt6sr;                 /* SRAM structure */
762 } PACKED gdt6c_dpram_str;
763
764 /* i960 register structure (PCI MPR controllers) */
765 typedef struct {
766     unchar              unused1[16];
767     unchar volatile     sema0_reg;              /* command semaphore */
768     unchar              unused2;
769     unchar volatile     sema1_reg;              /* status semaphore */
770     unchar              unused3;
771     ushort volatile     status;                 /* command status */
772     ushort              service;                /* service */
773     ulong32             info[2];                /* additional info */
774     unchar              ldoor_reg;              /* PCI to local doorbell */
775     unchar              unused4[11];
776     unchar volatile     edoor_reg;              /* local to PCI doorbell */
777     unchar              unused5[7];
778     unchar              edoor_en_reg;           /* board interrupts enable */
779     unchar              unused6[27];
780     ulong32             unused7[939];         
781     ulong32             severity;       
782     char                evt_str[256];           /* event string */
783 } PACKED gdt6m_i960_regs;
784
785 /* DPRAM PCI MPR controllers */
786 typedef struct {
787     gdt6m_i960_regs     i960r;                  /* 4KB i960 registers */
788     union {
789         gdt_dpr_if      ic;                     /* interface area */
790         unchar          if_area[0x3000-sizeof(gdt_pci_sram)];
791     } u;
792     gdt_pci_sram        gdt6sr;                 /* SRAM structure */
793 } PACKED gdt6m_dpram_str;
794
795
796 /* PCI resources */
797 typedef struct {
798 #if LINUX_VERSION_CODE >= 0x02015C
799     struct pci_dev      *pdev;
800 #endif
801     ushort              vendor_id;              /* vendor (ICP, Intel, ..) */
802     ushort              device_id;              /* device ID (0,..,9) */
803     ushort              subdevice_id;           /* sub device ID */
804     unchar              bus;                    /* PCI bus */
805     unchar              device_fn;              /* PCI device/function no. */
806     ulong               dpmem;                  /* DPRAM address */
807     ulong               io;                     /* IO address */
808     ulong               io_mm;                  /* IO address mem. mapped */
809     unchar              irq;                    /* IRQ */
810 } gdth_pci_str;
811
812
813 /* controller information structure */
814 typedef struct {
815     ushort              oem_id;                 /* OEM */
816     ushort              type;                   /* controller class */
817     ushort              raw_feat;               /* feat. raw service (s/g,..) */
818     ulong32             stype;                  /* subtype (PCI: device ID) */
819     ushort              subdevice_id;           /* sub device ID (PCI) */
820     ushort              fw_vers;                /* firmware version */
821     ushort              cache_feat;             /* feat. cache serv. (s/g,..) */
822     ushort              bmic;                   /* BMIC address (EISA) */
823     void                *brd;                   /* DPRAM address */
824     ulong32             brd_phys;               /* slot number/BIOS address */
825     gdt6c_plx_regs      *plx;                   /* PLX regs (new PCI contr.) */
826     gdth_cmd_str        *pccb;                  /* address command structure */
827     ulong32             ccb_phys;               /* phys. address */
828     char                *pscratch;              /* scratch (DMA) buffer */
829     ulong32             scratch_phys;           /* phys. address */
830     unchar              scratch_busy;           /* in use? */
831     unchar              scan_mode;              /* current scan mode */
832     unchar              irq;                    /* IRQ */
833     unchar              drq;                    /* DRQ (ISA controllers) */
834     ushort              status;                 /* command status */
835     ushort              service;                /* service/firmware ver./.. */
836     ulong32             info;
837     ulong32             info2;                  /* additional info */
838     Scsi_Cmnd           *req_first;             /* top of request queue */
839     struct {
840         unchar          present;                /* Flag: host drive present? */
841         unchar          is_logdrv;              /* Flag: log. drive (master)? */
842         unchar          is_arraydrv;            /* Flag: array drive? */
843         unchar          is_master;              /* Flag: array drive master? */
844         unchar          is_parity;              /* Flag: parity drive? */
845         unchar          is_hotfix;              /* Flag: hotfix drive? */
846         unchar          master_no;              /* number of master drive */
847         unchar          lock;                   /* drive locked? (hot plug) */
848         unchar          heads;                  /* mapping */
849         unchar          secs;
850         ushort          devtype;                /* further information */
851         ulong32         size;                   /* capacity */
852         unchar          ldr_no;                 /* log. drive no. */
853         unchar          rw_attribs;             /* r/w attributes */
854         unchar          cluster_type;           /* cluster properties */
855         unchar          media_changed;          /* Flag:MOUNT/UNMOUNT occurred*/
856         ulong32         start_sec;              /* start sector */
857     } hdr[MAX_LDRIVES];                         /* host drives */
858     struct {
859         unchar          lock;                   /* channel locked? (hot plug) */
860         unchar          pdev_cnt;               /* physical device count */
861         unchar          local_no;               /* local channel number */
862         unchar          io_cnt[MAXID];          /* current IO count */
863         ulong32         address;                /* channel address */
864         ulong32         id_list[MAXID];         /* IDs of the phys. devices */
865     } raw[MAXBUS];                              /* SCSI channels */
866     struct {
867         Scsi_Cmnd       *cmnd;                  /* pending request */
868         ushort          service;                /* service */
869     } cmd_tab[GDTH_MAXCMDS];                    /* table of pend. requests */
870     unchar              bus_cnt;                /* SCSI bus count */
871     unchar              tid_cnt;                /* Target ID count */
872     unchar              bus_id[MAXBUS];         /* IOP IDs */
873     unchar              virt_bus;               /* number of virtual bus */
874     unchar              more_proc;              /* more /proc info supported */
875     ushort              cmd_cnt;                /* command count in DPRAM */
876     ushort              cmd_len;                /* length of actual command */
877     ushort              cmd_offs_dpmem;         /* actual offset in DPRAM */
878     ushort              ic_all_size;            /* sizeof DPRAM interf. area */
879     gdth_cpar_str       cpar;                   /* controller cache par. */
880     gdth_bfeat_str      bfeat;                  /* controller features */
881     gdth_binfo_str      binfo;                  /* controller info */
882     gdth_evt_data       dvr;                    /* event structure */
883 #if LINUX_VERSION_CODE >= 0x02015F
884     spinlock_t          smp_lock;
885 #endif
886 #if LINUX_VERSION_CODE >= 0x020400
887     struct pci_dev      *pdev;
888 #endif
889     char                oem_name[8];
890 } gdth_ha_str;
891
892 /* structure for scsi_register(), SCSI bus != 0 */
893 typedef struct {
894     ushort      hanum;
895     ushort      busnum;
896 } gdth_num_str;
897
898 /* structure for scsi_register() */
899 typedef struct {
900     gdth_num_str        numext;                 /* must be the first element */
901     gdth_ha_str         haext;
902     gdth_cmd_str        cmdext;
903 } gdth_ext_str;
904
905
906 /* INQUIRY data format */
907 typedef struct {
908     unchar      type_qual;
909     unchar      modif_rmb;
910     unchar      version;
911     unchar      resp_aenc;
912     unchar      add_length;
913     unchar      reserved1;
914     unchar      reserved2;
915     unchar      misc;
916     unchar      vendor[8];
917     unchar      product[16];
918     unchar      revision[4];
919 } PACKED gdth_inq_data;
920
921 /* READ_CAPACITY data format */
922 typedef struct {
923     ulong32     last_block_no;
924     ulong32     block_length;
925 } PACKED gdth_rdcap_data;
926
927 /* REQUEST_SENSE data format */
928 typedef struct {
929     unchar      errorcode;
930     unchar      segno;
931     unchar      key;
932     ulong32     info;
933     unchar      add_length;
934     ulong32     cmd_info;
935     unchar      adsc;
936     unchar      adsq;
937     unchar      fruc;
938     unchar      key_spec[3];
939 } PACKED gdth_sense_data;
940
941 /* MODE_SENSE data format */
942 typedef struct {
943     struct {
944         unchar  data_length;
945         unchar  med_type;
946         unchar  dev_par;
947         unchar  bd_length;
948     } PACKED hd;
949     struct {
950         unchar  dens_code;
951         unchar  block_count[3];
952         unchar  reserved;
953         unchar  block_length[3];
954     } PACKED bd;
955 } PACKED gdth_modep_data;
956
957 /* stack frame */
958 typedef struct {
959     ulong       b[10];                          /* 32/64 bit compiler ! */
960 } PACKED gdth_stackframe;
961
962
963 /* function prototyping */
964
965 int gdth_detect(Scsi_Host_Template *);
966 int gdth_release(struct Scsi_Host *);
967 int gdth_queuecommand(Scsi_Cmnd *,void (*done)(Scsi_Cmnd *));
968 int gdth_abort(Scsi_Cmnd *);
969 #if LINUX_VERSION_CODE >= 0x010346
970 int gdth_reset(Scsi_Cmnd *, unsigned int reset_flags);
971 #else
972 int gdth_reset(Scsi_Cmnd *);
973 #endif
974 const char *gdth_info(struct Scsi_Host *);
975
976 #if LINUX_VERSION_CODE >= 0x020501
977 int gdth_bios_param(struct scsi_device *,struct block_device *,sector_t,int *);
978 int gdth_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int);
979 int gdth_eh_abort(Scsi_Cmnd *scp);
980 int gdth_eh_device_reset(Scsi_Cmnd *scp);
981 int gdth_eh_bus_reset(Scsi_Cmnd *scp);
982 int gdth_eh_host_reset(Scsi_Cmnd *scp);
983 #elif LINUX_VERSION_CODE >= 0x020322
984 int gdth_bios_param(Disk *,kdev_t,int *);
985 int gdth_proc_info(char *,char **,off_t,int,int,int);
986 int gdth_eh_abort(Scsi_Cmnd *scp);
987 int gdth_eh_device_reset(Scsi_Cmnd *scp);
988 int gdth_eh_bus_reset(Scsi_Cmnd *scp);
989 int gdth_eh_host_reset(Scsi_Cmnd *scp);
990 #elif LINUX_VERSION_CODE >= 0x02015F
991 int gdth_bios_param(Disk *,kdev_t,int *);
992 extern struct proc_dir_entry proc_scsi_gdth;
993 int gdth_proc_info(char *,char **,off_t,int,int,int);
994 int gdth_eh_abort(Scsi_Cmnd *scp);
995 int gdth_eh_device_reset(Scsi_Cmnd *scp);
996 int gdth_eh_bus_reset(Scsi_Cmnd *scp);
997 int gdth_eh_host_reset(Scsi_Cmnd *scp);
998 #elif LINUX_VERSION_CODE >= 0x010300
999 int gdth_bios_param(Disk *,kdev_t,int *);
1000 extern struct proc_dir_entry proc_scsi_gdth;
1001 int gdth_proc_info(char *,char **,off_t,int,int,int);
1002 #else
1003 int gdth_bios_param(Disk *,int,int *);
1004 #endif
1005 #endif
1006