arcmsr.h 22 KB

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