arcmsr.h 22 KB

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