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