Merge branch 'for-linus' of git://git390.marist.edu/pub/scm/linux-2.6
[safe/jmp/linux-2.6] / drivers / scsi / arcmsr / arcmsr.h
1 /*
2 *******************************************************************************
3 **        O.S   : Linux
4 **   FILE NAME  : arcmsr.h
5 **        BY    : Erich Chen
6 **   Description: SCSI RAID Device Driver for
7 **                ARECA RAID Host adapter
8 *******************************************************************************
9 ** Copyright (C) 2002 - 2005, Areca Technology Corporation All rights reserved.
10 **
11 **     Web site: www.areca.com.tw
12 **       E-mail: support@areca.com.tw
13 **
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License version 2 as
16 ** published by the Free Software Foundation.
17 ** This program is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ** GNU General Public License for more details.
21 *******************************************************************************
22 ** Redistribution and use in source and binary forms, with or without
23 ** modification, are permitted provided that the following conditions
24 ** are met:
25 ** 1. Redistributions of source code must retain the above copyright
26 **    notice, this list of conditions and the following disclaimer.
27 ** 2. Redistributions in binary form must reproduce the above copyright
28 **    notice, this list of conditions and the following disclaimer in the
29 **    documentation and/or other materials provided with the distribution.
30 ** 3. The name of the author may not be used to endorse or promote products
31 **    derived from this software without specific prior written permission.
32 **
33 ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
34 ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
35 ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
36 ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
37 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT
38 ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
39 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION)HOWEVER CAUSED AND ON ANY
40 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41 **(INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE OF
42 ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 *******************************************************************************
44 */
45 #include <linux/interrupt.h>
46
47 struct device_attribute;
48 /*The limit of outstanding scsi command that firmware can handle*/
49 #define ARCMSR_MAX_OUTSTANDING_CMD                                              256
50 #define ARCMSR_MAX_FREECCB_NUM                                                  320
51 #define ARCMSR_DRIVER_VERSION                "Driver Version 1.20.00.15 2008/11/03"
52 #define ARCMSR_SCSI_INITIATOR_ID                                                255
53 #define ARCMSR_MAX_XFER_SECTORS                                                 512
54 #define ARCMSR_MAX_XFER_SECTORS_B                                               4096
55 #define ARCMSR_MAX_TARGETID                                                     17
56 #define ARCMSR_MAX_TARGETLUN                                                    8
57 #define ARCMSR_MAX_CMD_PERLUN                            ARCMSR_MAX_OUTSTANDING_CMD
58 #define ARCMSR_MAX_QBUFFER                                                      4096
59 #define ARCMSR_MAX_SG_ENTRIES                                                   38
60 #define ARCMSR_MAX_HBB_POSTQUEUE                                                264
61 /*
62 **********************************************************************************
63 **
64 **********************************************************************************
65 */
66 #define ARC_SUCCESS                                                       0
67 #define ARC_FAILURE                                                       1
68 /*
69 *******************************************************************************
70 **        split 64bits dma addressing
71 *******************************************************************************
72 */
73 #define dma_addr_hi32(addr)               (uint32_t) ((addr>>16)>>16)
74 #define dma_addr_lo32(addr)               (uint32_t) (addr & 0xffffffff)
75 /*
76 *******************************************************************************
77 **        MESSAGE CONTROL CODE
78 *******************************************************************************
79 */
80 struct CMD_MESSAGE
81 {
82       uint32_t HeaderLength;
83       uint8_t  Signature[8];
84       uint32_t Timeout;
85       uint32_t ControlCode;
86       uint32_t ReturnCode;
87       uint32_t Length;
88 };
89 /*
90 *******************************************************************************
91 **        IOP Message Transfer Data for user space
92 *******************************************************************************
93 */
94 struct CMD_MESSAGE_FIELD
95 {
96     struct CMD_MESSAGE                  cmdmessage;
97     uint8_t                             messagedatabuffer[1032];
98 };
99 /* IOP message transfer */
100 #define ARCMSR_MESSAGE_FAIL                     0x0001
101 /* DeviceType */
102 #define ARECA_SATA_RAID                         0x90000000
103 /* FunctionCode */
104 #define FUNCTION_READ_RQBUFFER                  0x0801
105 #define FUNCTION_WRITE_WQBUFFER                 0x0802
106 #define FUNCTION_CLEAR_RQBUFFER                 0x0803
107 #define FUNCTION_CLEAR_WQBUFFER                 0x0804
108 #define FUNCTION_CLEAR_ALLQBUFFER               0x0805
109 #define FUNCTION_RETURN_CODE_3F                 0x0806
110 #define FUNCTION_SAY_HELLO                      0x0807
111 #define FUNCTION_SAY_GOODBYE                    0x0808
112 #define FUNCTION_FLUSH_ADAPTER_CACHE            0x0809
113 #define FUNCTION_GET_FIRMWARE_STATUS                    0x080A
114 #define FUNCTION_HARDWARE_RESET                 0x080B
115 /* ARECA IO CONTROL CODE*/
116 #define ARCMSR_MESSAGE_READ_RQBUFFER       \
117         ARECA_SATA_RAID | FUNCTION_READ_RQBUFFER
118 #define ARCMSR_MESSAGE_WRITE_WQBUFFER      \
119         ARECA_SATA_RAID | FUNCTION_WRITE_WQBUFFER
120 #define ARCMSR_MESSAGE_CLEAR_RQBUFFER      \
121         ARECA_SATA_RAID | FUNCTION_CLEAR_RQBUFFER
122 #define ARCMSR_MESSAGE_CLEAR_WQBUFFER      \
123         ARECA_SATA_RAID | FUNCTION_CLEAR_WQBUFFER
124 #define ARCMSR_MESSAGE_CLEAR_ALLQBUFFER    \
125         ARECA_SATA_RAID | FUNCTION_CLEAR_ALLQBUFFER
126 #define ARCMSR_MESSAGE_RETURN_CODE_3F      \
127         ARECA_SATA_RAID | FUNCTION_RETURN_CODE_3F
128 #define ARCMSR_MESSAGE_SAY_HELLO           \
129         ARECA_SATA_RAID | FUNCTION_SAY_HELLO
130 #define ARCMSR_MESSAGE_SAY_GOODBYE         \
131         ARECA_SATA_RAID | FUNCTION_SAY_GOODBYE
132 #define ARCMSR_MESSAGE_FLUSH_ADAPTER_CACHE \
133         ARECA_SATA_RAID | FUNCTION_FLUSH_ADAPTER_CACHE
134 /* ARECA IOCTL ReturnCode */
135 #define ARCMSR_MESSAGE_RETURNCODE_OK              0x00000001
136 #define ARCMSR_MESSAGE_RETURNCODE_ERROR           0x00000006
137 #define ARCMSR_MESSAGE_RETURNCODE_3F              0x0000003F
138 #define ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON   0x00000088
139 /*
140 *************************************************************
141 **   structure for holding DMA address data
142 *************************************************************
143 */
144 #define IS_SG64_ADDR                0x01000000 /* bit24 */
145 struct  SG32ENTRY
146 {
147         __le32                                  length;
148         __le32                                  address;
149 };
150 struct  SG64ENTRY
151 {
152         __le32                                  length;
153         __le32                                  address;
154         __le32                                  addresshigh;
155 };
156 struct SGENTRY_UNION
157 {
158         union
159         {
160                 struct SG32ENTRY            sg32entry;
161                 struct SG64ENTRY            sg64entry;
162         }u;
163 };
164 /*
165 ********************************************************************
166 **      Q Buffer of IOP Message Transfer
167 ********************************************************************
168 */
169 struct QBUFFER
170 {
171         uint32_t      data_len;
172         uint8_t       data[124];
173 };
174 /*
175 *******************************************************************************
176 **      FIRMWARE INFO for Intel IOP R 80331 processor (Type A)
177 *******************************************************************************
178 */
179 struct FIRMWARE_INFO
180 {
181         uint32_t      signature;                /*0, 00-03*/
182         uint32_t      request_len;              /*1, 04-07*/
183         uint32_t      numbers_queue;            /*2, 08-11*/
184         uint32_t      sdram_size;               /*3, 12-15*/
185         uint32_t      ide_channels;             /*4, 16-19*/
186         char          vendor[40];               /*5, 20-59*/
187         char          model[8];                 /*15, 60-67*/
188         char          firmware_ver[16];         /*17, 68-83*/
189         char          device_map[16];           /*21, 84-99*/
190 };
191 /* signature of set and get firmware config */
192 #define ARCMSR_SIGNATURE_GET_CONFIG                   0x87974060
193 #define ARCMSR_SIGNATURE_SET_CONFIG                   0x87974063
194 /* message code of inbound message register */
195 #define ARCMSR_INBOUND_MESG0_NOP                      0x00000000
196 #define ARCMSR_INBOUND_MESG0_GET_CONFIG               0x00000001
197 #define ARCMSR_INBOUND_MESG0_SET_CONFIG               0x00000002
198 #define ARCMSR_INBOUND_MESG0_ABORT_CMD                0x00000003
199 #define ARCMSR_INBOUND_MESG0_STOP_BGRB                0x00000004
200 #define ARCMSR_INBOUND_MESG0_FLUSH_CACHE              0x00000005
201 #define ARCMSR_INBOUND_MESG0_START_BGRB               0x00000006
202 #define ARCMSR_INBOUND_MESG0_CHK331PENDING            0x00000007
203 #define ARCMSR_INBOUND_MESG0_SYNC_TIMER               0x00000008
204 /* doorbell interrupt generator */
205 #define ARCMSR_INBOUND_DRIVER_DATA_WRITE_OK           0x00000001
206 #define ARCMSR_INBOUND_DRIVER_DATA_READ_OK            0x00000002
207 #define ARCMSR_OUTBOUND_IOP331_DATA_WRITE_OK          0x00000001
208 #define ARCMSR_OUTBOUND_IOP331_DATA_READ_OK           0x00000002
209 /* ccb areca cdb flag */
210 #define ARCMSR_CCBPOST_FLAG_SGL_BSIZE                 0x80000000
211 #define ARCMSR_CCBPOST_FLAG_IAM_BIOS                  0x40000000
212 #define ARCMSR_CCBREPLY_FLAG_IAM_BIOS                 0x40000000
213 #define ARCMSR_CCBREPLY_FLAG_ERROR                    0x10000000
214 /* outbound firmware ok */
215 #define ARCMSR_OUTBOUND_MESG1_FIRMWARE_OK             0x80000000
216
217 /*
218 ************************************************************************
219 **                SPEC. for Areca Type B adapter
220 ************************************************************************
221 */
222 /* ARECA HBB COMMAND for its FIRMWARE */
223 /* window of "instruction flags" from driver to iop */
224 #define ARCMSR_DRV2IOP_DOORBELL                       0x00020400
225 #define ARCMSR_DRV2IOP_DOORBELL_MASK                  0x00020404
226 /* window of "instruction flags" from iop to driver */
227 #define ARCMSR_IOP2DRV_DOORBELL                       0x00020408
228 #define ARCMSR_IOP2DRV_DOORBELL_MASK                  0x0002040C
229 /* ARECA FLAG LANGUAGE */
230 /* ioctl transfer */
231 #define ARCMSR_IOP2DRV_DATA_WRITE_OK                  0x00000001
232 /* ioctl transfer */
233 #define ARCMSR_IOP2DRV_DATA_READ_OK                   0x00000002
234 #define ARCMSR_IOP2DRV_CDB_DONE                       0x00000004
235 #define ARCMSR_IOP2DRV_MESSAGE_CMD_DONE               0x00000008
236
237 #define ARCMSR_DOORBELL_HANDLE_INT                    0x0000000F
238 #define ARCMSR_DOORBELL_INT_CLEAR_PATTERN             0xFF00FFF0
239 #define ARCMSR_MESSAGE_INT_CLEAR_PATTERN              0xFF00FFF7
240 /* (ARCMSR_INBOUND_MESG0_GET_CONFIG<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */
241 #define ARCMSR_MESSAGE_GET_CONFIG                     0x00010008
242 /* (ARCMSR_INBOUND_MESG0_SET_CONFIG<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */
243 #define ARCMSR_MESSAGE_SET_CONFIG                     0x00020008
244 /* (ARCMSR_INBOUND_MESG0_ABORT_CMD<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */
245 #define ARCMSR_MESSAGE_ABORT_CMD                      0x00030008
246 /* (ARCMSR_INBOUND_MESG0_STOP_BGRB<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */
247 #define ARCMSR_MESSAGE_STOP_BGRB                      0x00040008
248 /* (ARCMSR_INBOUND_MESG0_FLUSH_CACHE<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */
249 #define ARCMSR_MESSAGE_FLUSH_CACHE                    0x00050008
250 /* (ARCMSR_INBOUND_MESG0_START_BGRB<<16)|ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED) */
251 #define ARCMSR_MESSAGE_START_BGRB                     0x00060008
252 #define ARCMSR_MESSAGE_START_DRIVER_MODE              0x000E0008
253 #define ARCMSR_MESSAGE_SET_POST_WINDOW                0x000F0008
254 #define ARCMSR_MESSAGE_ACTIVE_EOI_MODE              0x00100008
255 /* ARCMSR_OUTBOUND_MESG1_FIRMWARE_OK */
256 #define ARCMSR_MESSAGE_FIRMWARE_OK                    0x80000000
257 /* ioctl transfer */
258 #define ARCMSR_DRV2IOP_DATA_WRITE_OK                  0x00000001
259 /* ioctl transfer */
260 #define ARCMSR_DRV2IOP_DATA_READ_OK                   0x00000002
261 #define ARCMSR_DRV2IOP_CDB_POSTED                     0x00000004
262 #define ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED             0x00000008
263 #define ARCMSR_DRV2IOP_END_OF_INTERRUPT         0x00000010
264
265 /* data tunnel buffer between user space program and its firmware */
266 /* user space data to iop 128bytes */
267 #define ARCMSR_IOCTL_WBUFFER                          0x0000fe00
268 /* iop data to user space 128bytes */
269 #define ARCMSR_IOCTL_RBUFFER                          0x0000ff00
270 /* iop message_rwbuffer for message command */
271 #define ARCMSR_MSGCODE_RWBUFFER                       0x0000fa00
272 /*
273 *******************************************************************************
274 **    ARECA SCSI COMMAND DESCRIPTOR BLOCK size 0x1F8 (504)
275 *******************************************************************************
276 */
277 struct ARCMSR_CDB
278 {
279         uint8_t                                                 Bus;
280         uint8_t                                                 TargetID;
281         uint8_t                                                 LUN;
282         uint8_t                                                 Function;
283         uint8_t                                                 CdbLength;
284         uint8_t                                                 sgcount;
285         uint8_t                                                 Flags;
286 #define ARCMSR_CDB_FLAG_SGL_BSIZE          0x01
287 #define ARCMSR_CDB_FLAG_BIOS               0x02
288 #define ARCMSR_CDB_FLAG_WRITE              0x04
289 #define ARCMSR_CDB_FLAG_SIMPLEQ            0x00
290 #define ARCMSR_CDB_FLAG_HEADQ              0x08
291 #define ARCMSR_CDB_FLAG_ORDEREDQ           0x10
292
293         uint8_t                                                 Reserved1;
294         uint32_t                                                Context;
295         uint32_t                                                DataLength;
296         uint8_t                                                 Cdb[16];
297         uint8_t                                                 DeviceStatus;
298 #define ARCMSR_DEV_CHECK_CONDITION          0x02
299 #define ARCMSR_DEV_SELECT_TIMEOUT           0xF0
300 #define ARCMSR_DEV_ABORTED                  0xF1
301 #define ARCMSR_DEV_INIT_FAIL                0xF2
302
303         uint8_t                                                 SenseData[15];
304         union
305         {
306                 struct SG32ENTRY                sg32entry[ARCMSR_MAX_SG_ENTRIES];
307                 struct SG64ENTRY                sg64entry[ARCMSR_MAX_SG_ENTRIES];
308         } u;
309 };
310 /*
311 *******************************************************************************
312 **     Messaging Unit (MU) of the Intel R 80331 I/O processor(Type A) and Type B processor
313 *******************************************************************************
314 */
315 struct MessageUnit_A
316 {
317         uint32_t        resrved0[4];                    /*0000 000F*/
318         uint32_t        inbound_msgaddr0;               /*0010 0013*/
319         uint32_t        inbound_msgaddr1;               /*0014 0017*/
320         uint32_t        outbound_msgaddr0;              /*0018 001B*/
321         uint32_t        outbound_msgaddr1;              /*001C 001F*/
322         uint32_t        inbound_doorbell;               /*0020 0023*/
323         uint32_t        inbound_intstatus;              /*0024 0027*/
324         uint32_t        inbound_intmask;                /*0028 002B*/
325         uint32_t        outbound_doorbell;              /*002C 002F*/
326         uint32_t        outbound_intstatus;             /*0030 0033*/
327         uint32_t        outbound_intmask;               /*0034 0037*/
328         uint32_t        reserved1[2];                   /*0038 003F*/
329         uint32_t        inbound_queueport;              /*0040 0043*/
330         uint32_t        outbound_queueport;             /*0044 0047*/
331         uint32_t        reserved2[2];                   /*0048 004F*/
332         uint32_t        reserved3[492];                 /*0050 07FF 492*/
333         uint32_t        reserved4[128];                 /*0800 09FF 128*/
334         uint32_t        message_rwbuffer[256];          /*0a00 0DFF 256*/
335         uint32_t        message_wbuffer[32];            /*0E00 0E7F  32*/
336         uint32_t        reserved5[32];                  /*0E80 0EFF  32*/
337         uint32_t        message_rbuffer[32];            /*0F00 0F7F  32*/
338         uint32_t        reserved6[32];                  /*0F80 0FFF  32*/
339 };
340
341 struct MessageUnit_B
342 {
343         uint32_t        post_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE];
344         uint32_t        done_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE];
345         uint32_t        postq_index;
346         uint32_t        doneq_index;
347         uint32_t                __iomem *drv2iop_doorbell_reg;
348         uint32_t                __iomem *drv2iop_doorbell_mask_reg;
349         uint32_t                __iomem *iop2drv_doorbell_reg;
350         uint32_t                __iomem *iop2drv_doorbell_mask_reg;
351         uint32_t                __iomem *msgcode_rwbuffer_reg;
352         uint32_t                __iomem *ioctl_wbuffer_reg;
353         uint32_t                __iomem *ioctl_rbuffer_reg;
354 };
355
356 /*
357 *******************************************************************************
358 **                 Adapter Control Block
359 *******************************************************************************
360 */
361 struct AdapterControlBlock
362 {
363         uint32_t  adapter_type;                /* adapter A,B..... */
364         #define ACB_ADAPTER_TYPE_A            0x00000001        /* hba I IOP */
365         #define ACB_ADAPTER_TYPE_B            0x00000002        /* hbb M IOP */
366         #define ACB_ADAPTER_TYPE_C            0x00000004        /* hbc P IOP */
367         #define ACB_ADAPTER_TYPE_D            0x00000008        /* hbd A IOP */
368         struct pci_dev *                pdev;
369         struct Scsi_Host *              host;
370         unsigned long                   vir2phy_offset;
371         /* Offset is used in making arc cdb physical to virtual calculations */
372         uint32_t                        outbound_int_enable;
373
374         union {
375                 struct MessageUnit_A __iomem *  pmuA;
376                 struct MessageUnit_B *          pmuB;
377         };
378         /* message unit ATU inbound base address0 */
379
380         uint32_t                        acb_flags;
381         uint8_t                                 adapter_index;
382         #define ACB_F_SCSISTOPADAPTER           0x0001
383         #define ACB_F_MSG_STOP_BGRB             0x0002
384         /* stop RAID background rebuild */
385         #define ACB_F_MSG_START_BGRB            0x0004
386         /* stop RAID background rebuild */
387         #define ACB_F_IOPDATA_OVERFLOW          0x0008
388         /* iop message data rqbuffer overflow */
389         #define ACB_F_MESSAGE_WQBUFFER_CLEARED  0x0010
390         /* message clear wqbuffer */
391         #define ACB_F_MESSAGE_RQBUFFER_CLEARED  0x0020
392         /* message clear rqbuffer */
393         #define ACB_F_MESSAGE_WQBUFFER_READED   0x0040
394         #define ACB_F_BUS_RESET                 0x0080
395         #define ACB_F_IOP_INITED                0x0100
396         /* iop init */
397         #define ACB_F_FIRMWARE_TRAP                     0x0400
398         struct CommandControlBlock *                    pccb_pool[ARCMSR_MAX_FREECCB_NUM];
399         /* used for memory free */
400         struct list_head                ccb_free_list;
401         /* head of free ccb list */
402
403         atomic_t                        ccboutstandingcount;
404         /*The present outstanding command number that in the IOP that
405                                         waiting for being handled by FW*/
406
407         void *                          dma_coherent;
408         /* dma_coherent used for memory free */
409         dma_addr_t                      dma_coherent_handle;
410         /* dma_coherent_handle used for memory free */
411
412         uint8_t                         rqbuffer[ARCMSR_MAX_QBUFFER];
413         /* data collection buffer for read from 80331 */
414         int32_t                         rqbuf_firstindex;
415         /* first of read buffer  */
416         int32_t                         rqbuf_lastindex;
417         /* last of read buffer   */
418         uint8_t                         wqbuffer[ARCMSR_MAX_QBUFFER];
419         /* data collection buffer for write to 80331  */
420         int32_t                         wqbuf_firstindex;
421         /* first of write buffer */
422         int32_t                         wqbuf_lastindex;
423         /* last of write buffer  */
424         uint8_t                         devstate[ARCMSR_MAX_TARGETID][ARCMSR_MAX_TARGETLUN];
425         /* id0 ..... id15, lun0...lun7 */
426 #define ARECA_RAID_GONE               0x55
427 #define ARECA_RAID_GOOD               0xaa
428         uint32_t                        num_resets;
429         uint32_t                        num_aborts;
430         uint32_t                        signature;
431         uint32_t                        firm_request_len;
432         uint32_t                        firm_numbers_queue;
433         uint32_t                        firm_sdram_size;
434         uint32_t                        firm_hd_channels;
435         char                            firm_model[12];
436         char                            firm_version[20];
437         char                    device_map[20];                 /*21,84-99*/
438         struct work_struct              arcmsr_do_message_isr_bh;
439         struct timer_list               eternal_timer;
440         unsigned short          fw_state;
441         atomic_t                        rq_map_token;
442         int                     ante_token_value;
443 };/* HW_DEVICE_EXTENSION */
444 /*
445 *******************************************************************************
446 **                   Command Control Block
447 **             this CCB length must be 32 bytes boundary
448 *******************************************************************************
449 */
450 struct CommandControlBlock
451 {
452         struct ARCMSR_CDB               arcmsr_cdb;
453         /*
454         ** 0-503 (size of CDB = 504):
455         ** arcmsr messenger scsi command descriptor size 504 bytes
456         */
457         uint32_t                        cdb_shifted_phyaddr;
458         /* 504-507 */
459         uint32_t                        reserved1;
460         /* 508-511 */
461 #if BITS_PER_LONG == 64
462         /*  ======================512+64 bytes========================  */
463         struct list_head                list;
464         /* 512-527 16 bytes next/prev ptrs for ccb lists */
465         struct scsi_cmnd *              pcmd;
466         /* 528-535 8 bytes pointer of linux scsi command */
467         struct AdapterControlBlock *    acb;
468         /* 536-543 8 bytes pointer of acb */
469
470         uint16_t                        ccb_flags;
471         /* 544-545 */
472         #define         CCB_FLAG_READ                   0x0000
473         #define         CCB_FLAG_WRITE                  0x0001
474         #define         CCB_FLAG_ERROR                  0x0002
475         #define         CCB_FLAG_FLUSHCACHE             0x0004
476         #define         CCB_FLAG_MASTER_ABORTED         0x0008
477         uint16_t                        startdone;
478         /* 546-547 */
479         #define         ARCMSR_CCB_DONE                 0x0000
480         #define         ARCMSR_CCB_START                0x55AA
481         #define         ARCMSR_CCB_ABORTED              0xAA55
482         #define         ARCMSR_CCB_ILLEGAL              0xFFFF
483         uint32_t                        reserved2[7];
484         /* 548-551 552-555 556-559 560-563 564-567 568-571 572-575 */
485 #else
486         /*  ======================512+32 bytes========================  */
487         struct list_head                list;
488         /* 512-519 8 bytes next/prev ptrs for ccb lists */
489         struct scsi_cmnd *              pcmd;
490         /* 520-523 4 bytes pointer of linux scsi command */
491         struct AdapterControlBlock *    acb;
492         /* 524-527 4 bytes pointer of acb */
493
494         uint16_t                        ccb_flags;
495         /* 528-529 */
496         #define         CCB_FLAG_READ                   0x0000
497         #define         CCB_FLAG_WRITE                  0x0001
498         #define         CCB_FLAG_ERROR                  0x0002
499         #define         CCB_FLAG_FLUSHCACHE             0x0004
500         #define         CCB_FLAG_MASTER_ABORTED         0x0008
501         uint16_t                        startdone;
502         /* 530-531 */
503         #define         ARCMSR_CCB_DONE                 0x0000
504         #define         ARCMSR_CCB_START                0x55AA
505         #define         ARCMSR_CCB_ABORTED              0xAA55
506         #define         ARCMSR_CCB_ILLEGAL              0xFFFF
507         uint32_t                        reserved2[3];
508         /* 532-535 536-539 540-543 */
509 #endif
510         /*  ==========================================================  */
511 };
512 /*
513 *******************************************************************************
514 **    ARECA SCSI sense data
515 *******************************************************************************
516 */
517 struct SENSE_DATA
518 {
519         uint8_t                         ErrorCode:7;
520 #define SCSI_SENSE_CURRENT_ERRORS       0x70
521 #define SCSI_SENSE_DEFERRED_ERRORS      0x71
522         uint8_t                         Valid:1;
523         uint8_t                         SegmentNumber;
524         uint8_t                         SenseKey:4;
525         uint8_t                         Reserved:1;
526         uint8_t                         IncorrectLength:1;
527         uint8_t                         EndOfMedia:1;
528         uint8_t                         FileMark:1;
529         uint8_t                         Information[4];
530         uint8_t                         AdditionalSenseLength;
531         uint8_t                         CommandSpecificInformation[4];
532         uint8_t                         AdditionalSenseCode;
533         uint8_t                         AdditionalSenseCodeQualifier;
534         uint8_t                         FieldReplaceableUnitCode;
535         uint8_t                         SenseKeySpecific[3];
536 };
537 /*
538 *******************************************************************************
539 **  Outbound Interrupt Status Register - OISR
540 *******************************************************************************
541 */
542 #define     ARCMSR_MU_OUTBOUND_INTERRUPT_STATUS_REG                 0x30
543 #define     ARCMSR_MU_OUTBOUND_PCI_INT                              0x10
544 #define     ARCMSR_MU_OUTBOUND_POSTQUEUE_INT                        0x08
545 #define     ARCMSR_MU_OUTBOUND_DOORBELL_INT                         0x04
546 #define     ARCMSR_MU_OUTBOUND_MESSAGE1_INT                         0x02
547 #define     ARCMSR_MU_OUTBOUND_MESSAGE0_INT                         0x01
548 #define     ARCMSR_MU_OUTBOUND_HANDLE_INT                 \
549                     (ARCMSR_MU_OUTBOUND_MESSAGE0_INT      \
550                      |ARCMSR_MU_OUTBOUND_MESSAGE1_INT     \
551                      |ARCMSR_MU_OUTBOUND_DOORBELL_INT     \
552                      |ARCMSR_MU_OUTBOUND_POSTQUEUE_INT    \
553                      |ARCMSR_MU_OUTBOUND_PCI_INT)
554 /*
555 *******************************************************************************
556 **  Outbound Interrupt Mask Register - OIMR
557 *******************************************************************************
558 */
559 #define     ARCMSR_MU_OUTBOUND_INTERRUPT_MASK_REG                   0x34
560 #define     ARCMSR_MU_OUTBOUND_PCI_INTMASKENABLE                    0x10
561 #define     ARCMSR_MU_OUTBOUND_POSTQUEUE_INTMASKENABLE              0x08
562 #define     ARCMSR_MU_OUTBOUND_DOORBELL_INTMASKENABLE               0x04
563 #define     ARCMSR_MU_OUTBOUND_MESSAGE1_INTMASKENABLE               0x02
564 #define     ARCMSR_MU_OUTBOUND_MESSAGE0_INTMASKENABLE               0x01
565 #define     ARCMSR_MU_OUTBOUND_ALL_INTMASKENABLE                    0x1F
566
567 extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *);
568 extern void arcmsr_iop_message_read(struct AdapterControlBlock *);
569 extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *);
570 extern struct device_attribute *arcmsr_host_attrs[];
571 extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *);
572 void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb);