myrs.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Linux Driver for Mylex DAC960/AcceleRAID/eXtremeRAID PCI RAID Controllers
  4. *
  5. * This driver supports the newer, SCSI-based firmware interface only.
  6. *
  7. * Copyright 2018 Hannes Reinecke, SUSE Linux GmbH <[email protected]>
  8. *
  9. * Based on the original DAC960 driver, which has
  10. * Copyright 1998-2001 by Leonard N. Zubkoff <[email protected]>
  11. * Portions Copyright 2002 by Mylex (An IBM Business Unit)
  12. */
  13. #ifndef _MYRS_H
  14. #define _MYRS_H
  15. #define MYRS_MAILBOX_TIMEOUT 1000000
  16. #define MYRS_DCMD_TAG 1
  17. #define MYRS_MCMD_TAG 2
  18. #define MYRS_LINE_BUFFER_SIZE 128
  19. #define MYRS_PRIMARY_MONITOR_INTERVAL (10 * HZ)
  20. #define MYRS_SECONDARY_MONITOR_INTERVAL (60 * HZ)
  21. /* Maximum number of Scatter/Gather Segments supported */
  22. #define MYRS_SG_LIMIT 128
  23. /*
  24. * Number of Command and Status Mailboxes used by the
  25. * DAC960 V2 Firmware Memory Mailbox Interface.
  26. */
  27. #define MYRS_MAX_CMD_MBOX 512
  28. #define MYRS_MAX_STAT_MBOX 512
  29. #define MYRS_DCDB_SIZE 16
  30. #define MYRS_SENSE_SIZE 14
  31. /*
  32. * DAC960 V2 Firmware Command Opcodes.
  33. */
  34. enum myrs_cmd_opcode {
  35. MYRS_CMD_OP_MEMCOPY = 0x01,
  36. MYRS_CMD_OP_SCSI_10_PASSTHRU = 0x02,
  37. MYRS_CMD_OP_SCSI_255_PASSTHRU = 0x03,
  38. MYRS_CMD_OP_SCSI_10 = 0x04,
  39. MYRS_CMD_OP_SCSI_256 = 0x05,
  40. MYRS_CMD_OP_IOCTL = 0x20,
  41. } __packed;
  42. /*
  43. * DAC960 V2 Firmware IOCTL Opcodes.
  44. */
  45. enum myrs_ioctl_opcode {
  46. MYRS_IOCTL_GET_CTLR_INFO = 0x01,
  47. MYRS_IOCTL_GET_LDEV_INFO_VALID = 0x03,
  48. MYRS_IOCTL_GET_PDEV_INFO_VALID = 0x05,
  49. MYRS_IOCTL_GET_HEALTH_STATUS = 0x11,
  50. MYRS_IOCTL_GET_EVENT = 0x15,
  51. MYRS_IOCTL_START_DISCOVERY = 0x81,
  52. MYRS_IOCTL_SET_DEVICE_STATE = 0x82,
  53. MYRS_IOCTL_INIT_PDEV_START = 0x84,
  54. MYRS_IOCTL_INIT_PDEV_STOP = 0x85,
  55. MYRS_IOCTL_INIT_LDEV_START = 0x86,
  56. MYRS_IOCTL_INIT_LDEV_STOP = 0x87,
  57. MYRS_IOCTL_RBLD_DEVICE_START = 0x88,
  58. MYRS_IOCTL_RBLD_DEVICE_STOP = 0x89,
  59. MYRS_IOCTL_MAKE_CONSISTENT_START = 0x8A,
  60. MYRS_IOCTL_MAKE_CONSISTENT_STOP = 0x8B,
  61. MYRS_IOCTL_CC_START = 0x8C,
  62. MYRS_IOCTL_CC_STOP = 0x8D,
  63. MYRS_IOCTL_SET_MEM_MBOX = 0x8E,
  64. MYRS_IOCTL_RESET_DEVICE = 0x90,
  65. MYRS_IOCTL_FLUSH_DEVICE_DATA = 0x91,
  66. MYRS_IOCTL_PAUSE_DEVICE = 0x92,
  67. MYRS_IOCTL_UNPAUS_EDEVICE = 0x93,
  68. MYRS_IOCTL_LOCATE_DEVICE = 0x94,
  69. MYRS_IOCTL_CREATE_CONFIGURATION = 0xC0,
  70. MYRS_IOCTL_DELETE_LDEV = 0xC1,
  71. MYRS_IOCTL_REPLACE_INTERNALDEVICE = 0xC2,
  72. MYRS_IOCTL_RENAME_LDEV = 0xC3,
  73. MYRS_IOCTL_ADD_CONFIGURATION = 0xC4,
  74. MYRS_IOCTL_XLATE_PDEV_TO_LDEV = 0xC5,
  75. MYRS_IOCTL_CLEAR_CONFIGURATION = 0xCA,
  76. } __packed;
  77. /*
  78. * DAC960 V2 Firmware Command Status Codes.
  79. */
  80. #define MYRS_STATUS_SUCCESS 0x00
  81. #define MYRS_STATUS_FAILED 0x02
  82. #define MYRS_STATUS_DEVICE_BUSY 0x08
  83. #define MYRS_STATUS_DEVICE_NON_RESPONSIVE 0x0E
  84. #define MYRS_STATUS_DEVICE_NON_RESPONSIVE2 0x0F
  85. #define MYRS_STATUS_RESERVATION_CONFLICT 0x18
  86. /*
  87. * DAC960 V2 Firmware Memory Type structure.
  88. */
  89. struct myrs_mem_type {
  90. enum {
  91. MYRS_MEMTYPE_RESERVED = 0x00,
  92. MYRS_MEMTYPE_DRAM = 0x01,
  93. MYRS_MEMTYPE_EDRAM = 0x02,
  94. MYRS_MEMTYPE_EDO = 0x03,
  95. MYRS_MEMTYPE_SDRAM = 0x04,
  96. MYRS_MEMTYPE_LAST = 0x1F,
  97. } __packed mem_type:5; /* Byte 0 Bits 0-4 */
  98. unsigned rsvd:1; /* Byte 0 Bit 5 */
  99. unsigned mem_parity:1; /* Byte 0 Bit 6 */
  100. unsigned mem_ecc:1; /* Byte 0 Bit 7 */
  101. };
  102. /*
  103. * DAC960 V2 Firmware Processor Type structure.
  104. */
  105. enum myrs_cpu_type {
  106. MYRS_CPUTYPE_i960CA = 0x01,
  107. MYRS_CPUTYPE_i960RD = 0x02,
  108. MYRS_CPUTYPE_i960RN = 0x03,
  109. MYRS_CPUTYPE_i960RP = 0x04,
  110. MYRS_CPUTYPE_NorthBay = 0x05,
  111. MYRS_CPUTYPE_StrongArm = 0x06,
  112. MYRS_CPUTYPE_i960RM = 0x07,
  113. } __packed;
  114. /*
  115. * DAC960 V2 Firmware Get Controller Info reply structure.
  116. */
  117. struct myrs_ctlr_info {
  118. unsigned char rsvd1; /* Byte 0 */
  119. enum {
  120. MYRS_SCSI_BUS = 0x00,
  121. MYRS_Fibre_BUS = 0x01,
  122. MYRS_PCI_BUS = 0x03
  123. } __packed bus; /* Byte 1 */
  124. enum {
  125. MYRS_CTLR_DAC960E = 0x01,
  126. MYRS_CTLR_DAC960M = 0x08,
  127. MYRS_CTLR_DAC960PD = 0x10,
  128. MYRS_CTLR_DAC960PL = 0x11,
  129. MYRS_CTLR_DAC960PU = 0x12,
  130. MYRS_CTLR_DAC960PE = 0x13,
  131. MYRS_CTLR_DAC960PG = 0x14,
  132. MYRS_CTLR_DAC960PJ = 0x15,
  133. MYRS_CTLR_DAC960PTL0 = 0x16,
  134. MYRS_CTLR_DAC960PR = 0x17,
  135. MYRS_CTLR_DAC960PRL = 0x18,
  136. MYRS_CTLR_DAC960PT = 0x19,
  137. MYRS_CTLR_DAC1164P = 0x1A,
  138. MYRS_CTLR_DAC960PTL1 = 0x1B,
  139. MYRS_CTLR_EXR2000P = 0x1C,
  140. MYRS_CTLR_EXR3000P = 0x1D,
  141. MYRS_CTLR_ACCELERAID352 = 0x1E,
  142. MYRS_CTLR_ACCELERAID170 = 0x1F,
  143. MYRS_CTLR_ACCELERAID160 = 0x20,
  144. MYRS_CTLR_DAC960S = 0x60,
  145. MYRS_CTLR_DAC960SU = 0x61,
  146. MYRS_CTLR_DAC960SX = 0x62,
  147. MYRS_CTLR_DAC960SF = 0x63,
  148. MYRS_CTLR_DAC960SS = 0x64,
  149. MYRS_CTLR_DAC960FL = 0x65,
  150. MYRS_CTLR_DAC960LL = 0x66,
  151. MYRS_CTLR_DAC960FF = 0x67,
  152. MYRS_CTLR_DAC960HP = 0x68,
  153. MYRS_CTLR_RAIDBRICK = 0x69,
  154. MYRS_CTLR_METEOR_FL = 0x6A,
  155. MYRS_CTLR_METEOR_FF = 0x6B
  156. } __packed ctlr_type; /* Byte 2 */
  157. unsigned char rsvd2; /* Byte 3 */
  158. unsigned short bus_speed_mhz; /* Bytes 4-5 */
  159. unsigned char bus_width; /* Byte 6 */
  160. unsigned char flash_code; /* Byte 7 */
  161. unsigned char ports_present; /* Byte 8 */
  162. unsigned char rsvd3[7]; /* Bytes 9-15 */
  163. unsigned char bus_name[16]; /* Bytes 16-31 */
  164. unsigned char ctlr_name[16]; /* Bytes 32-47 */
  165. unsigned char rsvd4[16]; /* Bytes 48-63 */
  166. /* Firmware Release Information */
  167. unsigned char fw_major_version; /* Byte 64 */
  168. unsigned char fw_minor_version; /* Byte 65 */
  169. unsigned char fw_turn_number; /* Byte 66 */
  170. unsigned char fw_build_number; /* Byte 67 */
  171. unsigned char fw_release_day; /* Byte 68 */
  172. unsigned char fw_release_month; /* Byte 69 */
  173. unsigned char fw_release_year_hi; /* Byte 70 */
  174. unsigned char fw_release_year_lo; /* Byte 71 */
  175. /* Hardware Release Information */
  176. unsigned char hw_rev; /* Byte 72 */
  177. unsigned char rsvd5[3]; /* Bytes 73-75 */
  178. unsigned char hw_release_day; /* Byte 76 */
  179. unsigned char hw_release_month; /* Byte 77 */
  180. unsigned char hw_release_year_hi; /* Byte 78 */
  181. unsigned char hw_release_year_lo; /* Byte 79 */
  182. /* Hardware Manufacturing Information */
  183. unsigned char manuf_batch_num; /* Byte 80 */
  184. unsigned char rsvd6; /* Byte 81 */
  185. unsigned char manuf_plant_num; /* Byte 82 */
  186. unsigned char rsvd7; /* Byte 83 */
  187. unsigned char hw_manuf_day; /* Byte 84 */
  188. unsigned char hw_manuf_month; /* Byte 85 */
  189. unsigned char hw_manuf_year_hi; /* Byte 86 */
  190. unsigned char hw_manuf_year_lo; /* Byte 87 */
  191. unsigned char max_pd_per_xld; /* Byte 88 */
  192. unsigned char max_ild_per_xld; /* Byte 89 */
  193. unsigned short nvram_size_kb; /* Bytes 90-91 */
  194. unsigned char max_xld; /* Byte 92 */
  195. unsigned char rsvd8[3]; /* Bytes 93-95 */
  196. /* Unique Information per Controller */
  197. unsigned char serial_number[16]; /* Bytes 96-111 */
  198. unsigned char rsvd9[16]; /* Bytes 112-127 */
  199. /* Vendor Information */
  200. unsigned char rsvd10[3]; /* Bytes 128-130 */
  201. unsigned char oem_code; /* Byte 131 */
  202. unsigned char vendor[16]; /* Bytes 132-147 */
  203. /* Other Physical/Controller/Operation Information */
  204. unsigned char bbu_present:1; /* Byte 148 Bit 0 */
  205. unsigned char cluster_mode:1; /* Byte 148 Bit 1 */
  206. unsigned char rsvd11:6; /* Byte 148 Bits 2-7 */
  207. unsigned char rsvd12[3]; /* Bytes 149-151 */
  208. /* Physical Device Scan Information */
  209. unsigned char pscan_active:1; /* Byte 152 Bit 0 */
  210. unsigned char rsvd13:7; /* Byte 152 Bits 1-7 */
  211. unsigned char pscan_chan; /* Byte 153 */
  212. unsigned char pscan_target; /* Byte 154 */
  213. unsigned char pscan_lun; /* Byte 155 */
  214. /* Maximum Command Data Transfer Sizes */
  215. unsigned short max_transfer_size; /* Bytes 156-157 */
  216. unsigned short max_sge; /* Bytes 158-159 */
  217. /* Logical/Physical Device Counts */
  218. unsigned short ldev_present; /* Bytes 160-161 */
  219. unsigned short ldev_critical; /* Bytes 162-163 */
  220. unsigned short ldev_offline; /* Bytes 164-165 */
  221. unsigned short pdev_present; /* Bytes 166-167 */
  222. unsigned short pdisk_present; /* Bytes 168-169 */
  223. unsigned short pdisk_critical; /* Bytes 170-171 */
  224. unsigned short pdisk_offline; /* Bytes 172-173 */
  225. unsigned short max_tcq; /* Bytes 174-175 */
  226. /* Channel and Target ID Information */
  227. unsigned char physchan_present; /* Byte 176 */
  228. unsigned char virtchan_present; /* Byte 177 */
  229. unsigned char physchan_max; /* Byte 178 */
  230. unsigned char virtchan_max; /* Byte 179 */
  231. unsigned char max_targets[16]; /* Bytes 180-195 */
  232. unsigned char rsvd14[12]; /* Bytes 196-207 */
  233. /* Memory/Cache Information */
  234. unsigned short mem_size_mb; /* Bytes 208-209 */
  235. unsigned short cache_size_mb; /* Bytes 210-211 */
  236. unsigned int valid_cache_bytes; /* Bytes 212-215 */
  237. unsigned int dirty_cache_bytes; /* Bytes 216-219 */
  238. unsigned short mem_speed_mhz; /* Bytes 220-221 */
  239. unsigned char mem_data_width; /* Byte 222 */
  240. struct myrs_mem_type mem_type; /* Byte 223 */
  241. unsigned char cache_mem_type_name[16]; /* Bytes 224-239 */
  242. /* Execution Memory Information */
  243. unsigned short exec_mem_size_mb; /* Bytes 240-241 */
  244. unsigned short exec_l2_cache_size_mb; /* Bytes 242-243 */
  245. unsigned char rsvd15[8]; /* Bytes 244-251 */
  246. unsigned short exec_mem_speed_mhz; /* Bytes 252-253 */
  247. unsigned char exec_mem_data_width; /* Byte 254 */
  248. struct myrs_mem_type exec_mem_type; /* Byte 255 */
  249. unsigned char exec_mem_type_name[16]; /* Bytes 256-271 */
  250. /* CPU Type Information */
  251. struct { /* Bytes 272-335 */
  252. unsigned short cpu_speed_mhz;
  253. enum myrs_cpu_type cpu_type;
  254. unsigned char cpu_count;
  255. unsigned char rsvd16[12];
  256. unsigned char cpu_name[16];
  257. } __packed cpu[2];
  258. /* Debugging/Profiling/Command Time Tracing Information */
  259. unsigned short cur_prof_page_num; /* Bytes 336-337 */
  260. unsigned short num_prof_waiters; /* Bytes 338-339 */
  261. unsigned short cur_trace_page_num; /* Bytes 340-341 */
  262. unsigned short num_trace_waiters; /* Bytes 342-343 */
  263. unsigned char rsvd18[8]; /* Bytes 344-351 */
  264. /* Error Counters on Physical Devices */
  265. unsigned short pdev_bus_resets; /* Bytes 352-353 */
  266. unsigned short pdev_parity_errors; /* Bytes 355-355 */
  267. unsigned short pdev_soft_errors; /* Bytes 356-357 */
  268. unsigned short pdev_cmds_failed; /* Bytes 358-359 */
  269. unsigned short pdev_misc_errors; /* Bytes 360-361 */
  270. unsigned short pdev_cmd_timeouts; /* Bytes 362-363 */
  271. unsigned short pdev_sel_timeouts; /* Bytes 364-365 */
  272. unsigned short pdev_retries_done; /* Bytes 366-367 */
  273. unsigned short pdev_aborts_done; /* Bytes 368-369 */
  274. unsigned short pdev_host_aborts_done; /* Bytes 370-371 */
  275. unsigned short pdev_predicted_failures; /* Bytes 372-373 */
  276. unsigned short pdev_host_cmds_failed; /* Bytes 374-375 */
  277. unsigned short pdev_hard_errors; /* Bytes 376-377 */
  278. unsigned char rsvd19[6]; /* Bytes 378-383 */
  279. /* Error Counters on Logical Devices */
  280. unsigned short ldev_soft_errors; /* Bytes 384-385 */
  281. unsigned short ldev_cmds_failed; /* Bytes 386-387 */
  282. unsigned short ldev_host_aborts_done; /* Bytes 388-389 */
  283. unsigned char rsvd20[2]; /* Bytes 390-391 */
  284. /* Error Counters on Controller */
  285. unsigned short ctlr_mem_errors; /* Bytes 392-393 */
  286. unsigned short ctlr_host_aborts_done; /* Bytes 394-395 */
  287. unsigned char rsvd21[4]; /* Bytes 396-399 */
  288. /* Long Duration Activity Information */
  289. unsigned short bg_init_active; /* Bytes 400-401 */
  290. unsigned short ldev_init_active; /* Bytes 402-403 */
  291. unsigned short pdev_init_active; /* Bytes 404-405 */
  292. unsigned short cc_active; /* Bytes 406-407 */
  293. unsigned short rbld_active; /* Bytes 408-409 */
  294. unsigned short exp_active; /* Bytes 410-411 */
  295. unsigned short patrol_active; /* Bytes 412-413 */
  296. unsigned char rsvd22[2]; /* Bytes 414-415 */
  297. /* Flash ROM Information */
  298. unsigned char flash_type; /* Byte 416 */
  299. unsigned char rsvd23; /* Byte 417 */
  300. unsigned short flash_size_MB; /* Bytes 418-419 */
  301. unsigned int flash_limit; /* Bytes 420-423 */
  302. unsigned int flash_count; /* Bytes 424-427 */
  303. unsigned char rsvd24[4]; /* Bytes 428-431 */
  304. unsigned char flash_type_name[16]; /* Bytes 432-447 */
  305. /* Firmware Run Time Information */
  306. unsigned char rbld_rate; /* Byte 448 */
  307. unsigned char bg_init_rate; /* Byte 449 */
  308. unsigned char fg_init_rate; /* Byte 450 */
  309. unsigned char cc_rate; /* Byte 451 */
  310. unsigned char rsvd25[4]; /* Bytes 452-455 */
  311. unsigned int max_dp; /* Bytes 456-459 */
  312. unsigned int free_dp; /* Bytes 460-463 */
  313. unsigned int max_iop; /* Bytes 464-467 */
  314. unsigned int free_iop; /* Bytes 468-471 */
  315. unsigned short max_combined_len; /* Bytes 472-473 */
  316. unsigned short num_cfg_groups; /* Bytes 474-475 */
  317. unsigned installation_abort_status:1; /* Byte 476 Bit 0 */
  318. unsigned maint_mode_status:1; /* Byte 476 Bit 1 */
  319. unsigned rsvd26:6; /* Byte 476 Bits 2-7 */
  320. unsigned char rsvd27[6]; /* Bytes 477-511 */
  321. unsigned char rsvd28[512]; /* Bytes 512-1023 */
  322. };
  323. /*
  324. * DAC960 V2 Firmware Device State type.
  325. */
  326. enum myrs_devstate {
  327. MYRS_DEVICE_UNCONFIGURED = 0x00,
  328. MYRS_DEVICE_ONLINE = 0x01,
  329. MYRS_DEVICE_REBUILD = 0x03,
  330. MYRS_DEVICE_MISSING = 0x04,
  331. MYRS_DEVICE_SUSPECTED_CRITICAL = 0x05,
  332. MYRS_DEVICE_OFFLINE = 0x08,
  333. MYRS_DEVICE_CRITICAL = 0x09,
  334. MYRS_DEVICE_SUSPECTED_DEAD = 0x0C,
  335. MYRS_DEVICE_COMMANDED_OFFLINE = 0x10,
  336. MYRS_DEVICE_STANDBY = 0x21,
  337. MYRS_DEVICE_INVALID_STATE = 0xFF,
  338. } __packed;
  339. /*
  340. * DAC960 V2 RAID Levels
  341. */
  342. enum myrs_raid_level {
  343. MYRS_RAID_LEVEL0 = 0x0, /* RAID 0 */
  344. MYRS_RAID_LEVEL1 = 0x1, /* RAID 1 */
  345. MYRS_RAID_LEVEL3 = 0x3, /* RAID 3 right asymmetric parity */
  346. MYRS_RAID_LEVEL5 = 0x5, /* RAID 5 right asymmetric parity */
  347. MYRS_RAID_LEVEL6 = 0x6, /* RAID 6 (Mylex RAID 6) */
  348. MYRS_RAID_JBOD = 0x7, /* RAID 7 (JBOD) */
  349. MYRS_RAID_NEWSPAN = 0x8, /* New Mylex SPAN */
  350. MYRS_RAID_LEVEL3F = 0x9, /* RAID 3 fixed parity */
  351. MYRS_RAID_LEVEL3L = 0xb, /* RAID 3 left symmetric parity */
  352. MYRS_RAID_SPAN = 0xc, /* current spanning implementation */
  353. MYRS_RAID_LEVEL5L = 0xd, /* RAID 5 left symmetric parity */
  354. MYRS_RAID_LEVELE = 0xe, /* RAID E (concatenation) */
  355. MYRS_RAID_PHYSICAL = 0xf, /* physical device */
  356. } __packed;
  357. enum myrs_stripe_size {
  358. MYRS_STRIPE_SIZE_0 = 0x0, /* no stripe (RAID 1, RAID 7, etc) */
  359. MYRS_STRIPE_SIZE_512B = 0x1,
  360. MYRS_STRIPE_SIZE_1K = 0x2,
  361. MYRS_STRIPE_SIZE_2K = 0x3,
  362. MYRS_STRIPE_SIZE_4K = 0x4,
  363. MYRS_STRIPE_SIZE_8K = 0x5,
  364. MYRS_STRIPE_SIZE_16K = 0x6,
  365. MYRS_STRIPE_SIZE_32K = 0x7,
  366. MYRS_STRIPE_SIZE_64K = 0x8,
  367. MYRS_STRIPE_SIZE_128K = 0x9,
  368. MYRS_STRIPE_SIZE_256K = 0xa,
  369. MYRS_STRIPE_SIZE_512K = 0xb,
  370. MYRS_STRIPE_SIZE_1M = 0xc,
  371. } __packed;
  372. enum myrs_cacheline_size {
  373. MYRS_CACHELINE_ZERO = 0x0, /* caching cannot be enabled */
  374. MYRS_CACHELINE_512B = 0x1,
  375. MYRS_CACHELINE_1K = 0x2,
  376. MYRS_CACHELINE_2K = 0x3,
  377. MYRS_CACHELINE_4K = 0x4,
  378. MYRS_CACHELINE_8K = 0x5,
  379. MYRS_CACHELINE_16K = 0x6,
  380. MYRS_CACHELINE_32K = 0x7,
  381. MYRS_CACHELINE_64K = 0x8,
  382. } __packed;
  383. /*
  384. * DAC960 V2 Firmware Get Logical Device Info reply structure.
  385. */
  386. struct myrs_ldev_info {
  387. unsigned char ctlr; /* Byte 0 */
  388. unsigned char channel; /* Byte 1 */
  389. unsigned char target; /* Byte 2 */
  390. unsigned char lun; /* Byte 3 */
  391. enum myrs_devstate dev_state; /* Byte 4 */
  392. unsigned char raid_level; /* Byte 5 */
  393. enum myrs_stripe_size stripe_size; /* Byte 6 */
  394. enum myrs_cacheline_size cacheline_size; /* Byte 7 */
  395. struct {
  396. enum {
  397. MYRS_READCACHE_DISABLED = 0x0,
  398. MYRS_READCACHE_ENABLED = 0x1,
  399. MYRS_READAHEAD_ENABLED = 0x2,
  400. MYRS_INTELLIGENT_READAHEAD_ENABLED = 0x3,
  401. MYRS_READCACHE_LAST = 0x7,
  402. } __packed rce:3; /* Byte 8 Bits 0-2 */
  403. enum {
  404. MYRS_WRITECACHE_DISABLED = 0x0,
  405. MYRS_LOGICALDEVICE_RO = 0x1,
  406. MYRS_WRITECACHE_ENABLED = 0x2,
  407. MYRS_INTELLIGENT_WRITECACHE_ENABLED = 0x3,
  408. MYRS_WRITECACHE_LAST = 0x7,
  409. } __packed wce:3; /* Byte 8 Bits 3-5 */
  410. unsigned rsvd1:1; /* Byte 8 Bit 6 */
  411. unsigned ldev_init_done:1; /* Byte 8 Bit 7 */
  412. } ldev_control; /* Byte 8 */
  413. /* Logical Device Operations Status */
  414. unsigned char cc_active:1; /* Byte 9 Bit 0 */
  415. unsigned char rbld_active:1; /* Byte 9 Bit 1 */
  416. unsigned char bg_init_active:1; /* Byte 9 Bit 2 */
  417. unsigned char fg_init_active:1; /* Byte 9 Bit 3 */
  418. unsigned char migration_active:1; /* Byte 9 Bit 4 */
  419. unsigned char patrol_active:1; /* Byte 9 Bit 5 */
  420. unsigned char rsvd2:2; /* Byte 9 Bits 6-7 */
  421. unsigned char raid5_writeupdate; /* Byte 10 */
  422. unsigned char raid5_algo; /* Byte 11 */
  423. unsigned short ldev_num; /* Bytes 12-13 */
  424. /* BIOS Info */
  425. unsigned char bios_disabled:1; /* Byte 14 Bit 0 */
  426. unsigned char cdrom_boot:1; /* Byte 14 Bit 1 */
  427. unsigned char drv_coercion:1; /* Byte 14 Bit 2 */
  428. unsigned char write_same_disabled:1; /* Byte 14 Bit 3 */
  429. unsigned char hba_mode:1; /* Byte 14 Bit 4 */
  430. enum {
  431. MYRS_GEOMETRY_128_32 = 0x0,
  432. MYRS_GEOMETRY_255_63 = 0x1,
  433. MYRS_GEOMETRY_RSVD1 = 0x2,
  434. MYRS_GEOMETRY_RSVD2 = 0x3
  435. } __packed drv_geom:2; /* Byte 14 Bits 5-6 */
  436. unsigned char super_ra_enabled:1; /* Byte 14 Bit 7 */
  437. unsigned char rsvd3; /* Byte 15 */
  438. /* Error Counters */
  439. unsigned short soft_errs; /* Bytes 16-17 */
  440. unsigned short cmds_failed; /* Bytes 18-19 */
  441. unsigned short cmds_aborted; /* Bytes 20-21 */
  442. unsigned short deferred_write_errs; /* Bytes 22-23 */
  443. unsigned int rsvd4; /* Bytes 24-27 */
  444. unsigned int rsvd5; /* Bytes 28-31 */
  445. /* Device Size Information */
  446. unsigned short rsvd6; /* Bytes 32-33 */
  447. unsigned short devsize_bytes; /* Bytes 34-35 */
  448. unsigned int orig_devsize; /* Bytes 36-39 */
  449. unsigned int cfg_devsize; /* Bytes 40-43 */
  450. unsigned int rsvd7; /* Bytes 44-47 */
  451. unsigned char ldev_name[32]; /* Bytes 48-79 */
  452. unsigned char inquiry[36]; /* Bytes 80-115 */
  453. unsigned char rsvd8[12]; /* Bytes 116-127 */
  454. u64 last_read_lba; /* Bytes 128-135 */
  455. u64 last_write_lba; /* Bytes 136-143 */
  456. u64 cc_lba; /* Bytes 144-151 */
  457. u64 rbld_lba; /* Bytes 152-159 */
  458. u64 bg_init_lba; /* Bytes 160-167 */
  459. u64 fg_init_lba; /* Bytes 168-175 */
  460. u64 migration_lba; /* Bytes 176-183 */
  461. u64 patrol_lba; /* Bytes 184-191 */
  462. unsigned char rsvd9[64]; /* Bytes 192-255 */
  463. };
  464. /*
  465. * DAC960 V2 Firmware Get Physical Device Info reply structure.
  466. */
  467. struct myrs_pdev_info {
  468. unsigned char rsvd1; /* Byte 0 */
  469. unsigned char channel; /* Byte 1 */
  470. unsigned char target; /* Byte 2 */
  471. unsigned char lun; /* Byte 3 */
  472. /* Configuration Status Bits */
  473. unsigned char pdev_fault_tolerant:1; /* Byte 4 Bit 0 */
  474. unsigned char pdev_connected:1; /* Byte 4 Bit 1 */
  475. unsigned char pdev_local_to_ctlr:1; /* Byte 4 Bit 2 */
  476. unsigned char rsvd2:5; /* Byte 4 Bits 3-7 */
  477. /* Multiple Host/Controller Status Bits */
  478. unsigned char remote_host_dead:1; /* Byte 5 Bit 0 */
  479. unsigned char remove_ctlr_dead:1; /* Byte 5 Bit 1 */
  480. unsigned char rsvd3:6; /* Byte 5 Bits 2-7 */
  481. enum myrs_devstate dev_state; /* Byte 6 */
  482. unsigned char nego_data_width; /* Byte 7 */
  483. unsigned short nego_sync_rate; /* Bytes 8-9 */
  484. /* Multiported Physical Device Information */
  485. unsigned char num_ports; /* Byte 10 */
  486. unsigned char drv_access_bitmap; /* Byte 11 */
  487. unsigned int rsvd4; /* Bytes 12-15 */
  488. unsigned char ip_address[16]; /* Bytes 16-31 */
  489. unsigned short max_tags; /* Bytes 32-33 */
  490. /* Physical Device Operations Status */
  491. unsigned char cc_in_progress:1; /* Byte 34 Bit 0 */
  492. unsigned char rbld_in_progress:1; /* Byte 34 Bit 1 */
  493. unsigned char makecc_in_progress:1; /* Byte 34 Bit 2 */
  494. unsigned char pdevinit_in_progress:1; /* Byte 34 Bit 3 */
  495. unsigned char migration_in_progress:1; /* Byte 34 Bit 4 */
  496. unsigned char patrol_in_progress:1; /* Byte 34 Bit 5 */
  497. unsigned char rsvd5:2; /* Byte 34 Bits 6-7 */
  498. unsigned char long_op_status; /* Byte 35 */
  499. unsigned char parity_errs; /* Byte 36 */
  500. unsigned char soft_errs; /* Byte 37 */
  501. unsigned char hard_errs; /* Byte 38 */
  502. unsigned char misc_errs; /* Byte 39 */
  503. unsigned char cmd_timeouts; /* Byte 40 */
  504. unsigned char retries; /* Byte 41 */
  505. unsigned char aborts; /* Byte 42 */
  506. unsigned char pred_failures; /* Byte 43 */
  507. unsigned int rsvd6; /* Bytes 44-47 */
  508. unsigned short rsvd7; /* Bytes 48-49 */
  509. unsigned short devsize_bytes; /* Bytes 50-51 */
  510. unsigned int orig_devsize; /* Bytes 52-55 */
  511. unsigned int cfg_devsize; /* Bytes 56-59 */
  512. unsigned int rsvd8; /* Bytes 60-63 */
  513. unsigned char pdev_name[16]; /* Bytes 64-79 */
  514. unsigned char rsvd9[16]; /* Bytes 80-95 */
  515. unsigned char rsvd10[32]; /* Bytes 96-127 */
  516. unsigned char inquiry[36]; /* Bytes 128-163 */
  517. unsigned char rsvd11[20]; /* Bytes 164-183 */
  518. unsigned char rsvd12[8]; /* Bytes 184-191 */
  519. u64 last_read_lba; /* Bytes 192-199 */
  520. u64 last_write_lba; /* Bytes 200-207 */
  521. u64 cc_lba; /* Bytes 208-215 */
  522. u64 rbld_lba; /* Bytes 216-223 */
  523. u64 makecc_lba; /* Bytes 224-231 */
  524. u64 devinit_lba; /* Bytes 232-239 */
  525. u64 migration_lba; /* Bytes 240-247 */
  526. u64 patrol_lba; /* Bytes 248-255 */
  527. unsigned char rsvd13[256]; /* Bytes 256-511 */
  528. };
  529. /*
  530. * DAC960 V2 Firmware Health Status Buffer structure.
  531. */
  532. struct myrs_fwstat {
  533. unsigned int uptime_usecs; /* Bytes 0-3 */
  534. unsigned int uptime_msecs; /* Bytes 4-7 */
  535. unsigned int seconds; /* Bytes 8-11 */
  536. unsigned char rsvd1[4]; /* Bytes 12-15 */
  537. unsigned int epoch; /* Bytes 16-19 */
  538. unsigned char rsvd2[4]; /* Bytes 20-23 */
  539. unsigned int dbg_msgbuf_idx; /* Bytes 24-27 */
  540. unsigned int coded_msgbuf_idx; /* Bytes 28-31 */
  541. unsigned int cur_timetrace_page; /* Bytes 32-35 */
  542. unsigned int cur_prof_page; /* Bytes 36-39 */
  543. unsigned int next_evseq; /* Bytes 40-43 */
  544. unsigned char rsvd3[4]; /* Bytes 44-47 */
  545. unsigned char rsvd4[16]; /* Bytes 48-63 */
  546. unsigned char rsvd5[64]; /* Bytes 64-127 */
  547. };
  548. /*
  549. * DAC960 V2 Firmware Get Event reply structure.
  550. */
  551. struct myrs_event {
  552. unsigned int ev_seq; /* Bytes 0-3 */
  553. unsigned int ev_time; /* Bytes 4-7 */
  554. unsigned int ev_code; /* Bytes 8-11 */
  555. unsigned char rsvd1; /* Byte 12 */
  556. unsigned char channel; /* Byte 13 */
  557. unsigned char target; /* Byte 14 */
  558. unsigned char lun; /* Byte 15 */
  559. unsigned int rsvd2; /* Bytes 16-19 */
  560. unsigned int ev_parm; /* Bytes 20-23 */
  561. unsigned char sense_data[40]; /* Bytes 24-63 */
  562. };
  563. /*
  564. * DAC960 V2 Firmware Command Control Bits structure.
  565. */
  566. struct myrs_cmd_ctrl {
  567. unsigned char fua:1; /* Byte 0 Bit 0 */
  568. unsigned char disable_pgout:1; /* Byte 0 Bit 1 */
  569. unsigned char rsvd1:1; /* Byte 0 Bit 2 */
  570. unsigned char add_sge_mem:1; /* Byte 0 Bit 3 */
  571. unsigned char dma_ctrl_to_host:1; /* Byte 0 Bit 4 */
  572. unsigned char rsvd2:1; /* Byte 0 Bit 5 */
  573. unsigned char no_autosense:1; /* Byte 0 Bit 6 */
  574. unsigned char disc_prohibited:1; /* Byte 0 Bit 7 */
  575. };
  576. /*
  577. * DAC960 V2 Firmware Command Timeout structure.
  578. */
  579. struct myrs_cmd_tmo {
  580. unsigned char tmo_val:6; /* Byte 0 Bits 0-5 */
  581. enum {
  582. MYRS_TMO_SCALE_SECONDS = 0,
  583. MYRS_TMO_SCALE_MINUTES = 1,
  584. MYRS_TMO_SCALE_HOURS = 2,
  585. MYRS_TMO_SCALE_RESERVED = 3
  586. } __packed tmo_scale:2; /* Byte 0 Bits 6-7 */
  587. };
  588. /*
  589. * DAC960 V2 Firmware Physical Device structure.
  590. */
  591. struct myrs_pdev {
  592. unsigned char lun; /* Byte 0 */
  593. unsigned char target; /* Byte 1 */
  594. unsigned char channel:3; /* Byte 2 Bits 0-2 */
  595. unsigned char ctlr:5; /* Byte 2 Bits 3-7 */
  596. } __packed;
  597. /*
  598. * DAC960 V2 Firmware Logical Device structure.
  599. */
  600. struct myrs_ldev {
  601. unsigned short ldev_num; /* Bytes 0-1 */
  602. unsigned char rsvd:3; /* Byte 2 Bits 0-2 */
  603. unsigned char ctlr:5; /* Byte 2 Bits 3-7 */
  604. } __packed;
  605. /*
  606. * DAC960 V2 Firmware Operation Device type.
  607. */
  608. enum myrs_opdev {
  609. MYRS_PHYSICAL_DEVICE = 0x00,
  610. MYRS_RAID_DEVICE = 0x01,
  611. MYRS_PHYSICAL_CHANNEL = 0x02,
  612. MYRS_RAID_CHANNEL = 0x03,
  613. MYRS_PHYSICAL_CONTROLLER = 0x04,
  614. MYRS_RAID_CONTROLLER = 0x05,
  615. MYRS_CONFIGURATION_GROUP = 0x10,
  616. MYRS_ENCLOSURE = 0x11,
  617. } __packed;
  618. /*
  619. * DAC960 V2 Firmware Translate Physical To Logical Device structure.
  620. */
  621. struct myrs_devmap {
  622. unsigned short ldev_num; /* Bytes 0-1 */
  623. unsigned short rsvd; /* Bytes 2-3 */
  624. unsigned char prev_boot_ctlr; /* Byte 4 */
  625. unsigned char prev_boot_channel; /* Byte 5 */
  626. unsigned char prev_boot_target; /* Byte 6 */
  627. unsigned char prev_boot_lun; /* Byte 7 */
  628. };
  629. /*
  630. * DAC960 V2 Firmware Scatter/Gather List Entry structure.
  631. */
  632. struct myrs_sge {
  633. u64 sge_addr; /* Bytes 0-7 */
  634. u64 sge_count; /* Bytes 8-15 */
  635. };
  636. /*
  637. * DAC960 V2 Firmware Data Transfer Memory Address structure.
  638. */
  639. union myrs_sgl {
  640. struct myrs_sge sge[2]; /* Bytes 0-31 */
  641. struct {
  642. unsigned short sge0_len; /* Bytes 0-1 */
  643. unsigned short sge1_len; /* Bytes 2-3 */
  644. unsigned short sge2_len; /* Bytes 4-5 */
  645. unsigned short rsvd; /* Bytes 6-7 */
  646. u64 sge0_addr; /* Bytes 8-15 */
  647. u64 sge1_addr; /* Bytes 16-23 */
  648. u64 sge2_addr; /* Bytes 24-31 */
  649. } ext;
  650. };
  651. /*
  652. * 64 Byte DAC960 V2 Firmware Command Mailbox structure.
  653. */
  654. union myrs_cmd_mbox {
  655. unsigned int words[16]; /* Words 0-15 */
  656. struct {
  657. unsigned short id; /* Bytes 0-1 */
  658. enum myrs_cmd_opcode opcode; /* Byte 2 */
  659. struct myrs_cmd_ctrl control; /* Byte 3 */
  660. u32 dma_size:24; /* Bytes 4-6 */
  661. unsigned char dma_num; /* Byte 7 */
  662. u64 sense_addr; /* Bytes 8-15 */
  663. unsigned int rsvd1:24; /* Bytes 16-18 */
  664. struct myrs_cmd_tmo tmo; /* Byte 19 */
  665. unsigned char sense_len; /* Byte 20 */
  666. enum myrs_ioctl_opcode ioctl_opcode; /* Byte 21 */
  667. unsigned char rsvd2[10]; /* Bytes 22-31 */
  668. union myrs_sgl dma_addr; /* Bytes 32-63 */
  669. } common;
  670. struct {
  671. unsigned short id; /* Bytes 0-1 */
  672. enum myrs_cmd_opcode opcode; /* Byte 2 */
  673. struct myrs_cmd_ctrl control; /* Byte 3 */
  674. u32 dma_size; /* Bytes 4-7 */
  675. u64 sense_addr; /* Bytes 8-15 */
  676. struct myrs_pdev pdev; /* Bytes 16-18 */
  677. struct myrs_cmd_tmo tmo; /* Byte 19 */
  678. unsigned char sense_len; /* Byte 20 */
  679. unsigned char cdb_len; /* Byte 21 */
  680. unsigned char cdb[10]; /* Bytes 22-31 */
  681. union myrs_sgl dma_addr; /* Bytes 32-63 */
  682. } SCSI_10;
  683. struct {
  684. unsigned short id; /* Bytes 0-1 */
  685. enum myrs_cmd_opcode opcode; /* Byte 2 */
  686. struct myrs_cmd_ctrl control; /* Byte 3 */
  687. u32 dma_size; /* Bytes 4-7 */
  688. u64 sense_addr; /* Bytes 8-15 */
  689. struct myrs_pdev pdev; /* Bytes 16-18 */
  690. struct myrs_cmd_tmo tmo; /* Byte 19 */
  691. unsigned char sense_len; /* Byte 20 */
  692. unsigned char cdb_len; /* Byte 21 */
  693. unsigned short rsvd; /* Bytes 22-23 */
  694. u64 cdb_addr; /* Bytes 24-31 */
  695. union myrs_sgl dma_addr; /* Bytes 32-63 */
  696. } SCSI_255;
  697. struct {
  698. unsigned short id; /* Bytes 0-1 */
  699. enum myrs_cmd_opcode opcode; /* Byte 2 */
  700. struct myrs_cmd_ctrl control; /* Byte 3 */
  701. u32 dma_size:24; /* Bytes 4-6 */
  702. unsigned char dma_num; /* Byte 7 */
  703. u64 sense_addr; /* Bytes 8-15 */
  704. unsigned short rsvd1; /* Bytes 16-17 */
  705. unsigned char ctlr_num; /* Byte 18 */
  706. struct myrs_cmd_tmo tmo; /* Byte 19 */
  707. unsigned char sense_len; /* Byte 20 */
  708. enum myrs_ioctl_opcode ioctl_opcode; /* Byte 21 */
  709. unsigned char rsvd2[10]; /* Bytes 22-31 */
  710. union myrs_sgl dma_addr; /* Bytes 32-63 */
  711. } ctlr_info;
  712. struct {
  713. unsigned short id; /* Bytes 0-1 */
  714. enum myrs_cmd_opcode opcode; /* Byte 2 */
  715. struct myrs_cmd_ctrl control; /* Byte 3 */
  716. u32 dma_size:24; /* Bytes 4-6 */
  717. unsigned char dma_num; /* Byte 7 */
  718. u64 sense_addr; /* Bytes 8-15 */
  719. struct myrs_ldev ldev; /* Bytes 16-18 */
  720. struct myrs_cmd_tmo tmo; /* Byte 19 */
  721. unsigned char sense_len; /* Byte 20 */
  722. enum myrs_ioctl_opcode ioctl_opcode; /* Byte 21 */
  723. unsigned char rsvd[10]; /* Bytes 22-31 */
  724. union myrs_sgl dma_addr; /* Bytes 32-63 */
  725. } ldev_info;
  726. struct {
  727. unsigned short id; /* Bytes 0-1 */
  728. enum myrs_cmd_opcode opcode; /* Byte 2 */
  729. struct myrs_cmd_ctrl control; /* Byte 3 */
  730. u32 dma_size:24; /* Bytes 4-6 */
  731. unsigned char dma_num; /* Byte 7 */
  732. u64 sense_addr; /* Bytes 8-15 */
  733. struct myrs_pdev pdev; /* Bytes 16-18 */
  734. struct myrs_cmd_tmo tmo; /* Byte 19 */
  735. unsigned char sense_len; /* Byte 20 */
  736. enum myrs_ioctl_opcode ioctl_opcode; /* Byte 21 */
  737. unsigned char rsvd[10]; /* Bytes 22-31 */
  738. union myrs_sgl dma_addr; /* Bytes 32-63 */
  739. } pdev_info;
  740. struct {
  741. unsigned short id; /* Bytes 0-1 */
  742. enum myrs_cmd_opcode opcode; /* Byte 2 */
  743. struct myrs_cmd_ctrl control; /* Byte 3 */
  744. u32 dma_size:24; /* Bytes 4-6 */
  745. unsigned char dma_num; /* Byte 7 */
  746. u64 sense_addr; /* Bytes 8-15 */
  747. unsigned short evnum_upper; /* Bytes 16-17 */
  748. unsigned char ctlr_num; /* Byte 18 */
  749. struct myrs_cmd_tmo tmo; /* Byte 19 */
  750. unsigned char sense_len; /* Byte 20 */
  751. enum myrs_ioctl_opcode ioctl_opcode; /* Byte 21 */
  752. unsigned short evnum_lower; /* Bytes 22-23 */
  753. unsigned char rsvd[8]; /* Bytes 24-31 */
  754. union myrs_sgl dma_addr; /* Bytes 32-63 */
  755. } get_event;
  756. struct {
  757. unsigned short id; /* Bytes 0-1 */
  758. enum myrs_cmd_opcode opcode; /* Byte 2 */
  759. struct myrs_cmd_ctrl control; /* Byte 3 */
  760. u32 dma_size:24; /* Bytes 4-6 */
  761. unsigned char dma_num; /* Byte 7 */
  762. u64 sense_addr; /* Bytes 8-15 */
  763. union {
  764. struct myrs_ldev ldev; /* Bytes 16-18 */
  765. struct myrs_pdev pdev; /* Bytes 16-18 */
  766. };
  767. struct myrs_cmd_tmo tmo; /* Byte 19 */
  768. unsigned char sense_len; /* Byte 20 */
  769. enum myrs_ioctl_opcode ioctl_opcode; /* Byte 21 */
  770. enum myrs_devstate state; /* Byte 22 */
  771. unsigned char rsvd[9]; /* Bytes 23-31 */
  772. union myrs_sgl dma_addr; /* Bytes 32-63 */
  773. } set_devstate;
  774. struct {
  775. unsigned short id; /* Bytes 0-1 */
  776. enum myrs_cmd_opcode opcode; /* Byte 2 */
  777. struct myrs_cmd_ctrl control; /* Byte 3 */
  778. u32 dma_size:24; /* Bytes 4-6 */
  779. unsigned char dma_num; /* Byte 7 */
  780. u64 sense_addr; /* Bytes 8-15 */
  781. struct myrs_ldev ldev; /* Bytes 16-18 */
  782. struct myrs_cmd_tmo tmo; /* Byte 19 */
  783. unsigned char sense_len; /* Byte 20 */
  784. enum myrs_ioctl_opcode ioctl_opcode; /* Byte 21 */
  785. unsigned char restore_consistency:1; /* Byte 22 Bit 0 */
  786. unsigned char initialized_area_only:1; /* Byte 22 Bit 1 */
  787. unsigned char rsvd1:6; /* Byte 22 Bits 2-7 */
  788. unsigned char rsvd2[9]; /* Bytes 23-31 */
  789. union myrs_sgl dma_addr; /* Bytes 32-63 */
  790. } cc;
  791. struct {
  792. unsigned short id; /* Bytes 0-1 */
  793. enum myrs_cmd_opcode opcode; /* Byte 2 */
  794. struct myrs_cmd_ctrl control; /* Byte 3 */
  795. unsigned char first_cmd_mbox_size_kb; /* Byte 4 */
  796. unsigned char first_stat_mbox_size_kb; /* Byte 5 */
  797. unsigned char second_cmd_mbox_size_kb; /* Byte 6 */
  798. unsigned char second_stat_mbox_size_kb; /* Byte 7 */
  799. u64 sense_addr; /* Bytes 8-15 */
  800. unsigned int rsvd1:24; /* Bytes 16-18 */
  801. struct myrs_cmd_tmo tmo; /* Byte 19 */
  802. unsigned char sense_len; /* Byte 20 */
  803. enum myrs_ioctl_opcode ioctl_opcode; /* Byte 21 */
  804. unsigned char fwstat_buf_size_kb; /* Byte 22 */
  805. unsigned char rsvd2; /* Byte 23 */
  806. u64 fwstat_buf_addr; /* Bytes 24-31 */
  807. u64 first_cmd_mbox_addr; /* Bytes 32-39 */
  808. u64 first_stat_mbox_addr; /* Bytes 40-47 */
  809. u64 second_cmd_mbox_addr; /* Bytes 48-55 */
  810. u64 second_stat_mbox_addr; /* Bytes 56-63 */
  811. } set_mbox;
  812. struct {
  813. unsigned short id; /* Bytes 0-1 */
  814. enum myrs_cmd_opcode opcode; /* Byte 2 */
  815. struct myrs_cmd_ctrl control; /* Byte 3 */
  816. u32 dma_size:24; /* Bytes 4-6 */
  817. unsigned char dma_num; /* Byte 7 */
  818. u64 sense_addr; /* Bytes 8-15 */
  819. struct myrs_pdev pdev; /* Bytes 16-18 */
  820. struct myrs_cmd_tmo tmo; /* Byte 19 */
  821. unsigned char sense_len; /* Byte 20 */
  822. enum myrs_ioctl_opcode ioctl_opcode; /* Byte 21 */
  823. enum myrs_opdev opdev; /* Byte 22 */
  824. unsigned char rsvd[9]; /* Bytes 23-31 */
  825. union myrs_sgl dma_addr; /* Bytes 32-63 */
  826. } dev_op;
  827. };
  828. /*
  829. * DAC960 V2 Firmware Controller Status Mailbox structure.
  830. */
  831. struct myrs_stat_mbox {
  832. unsigned short id; /* Bytes 0-1 */
  833. unsigned char status; /* Byte 2 */
  834. unsigned char sense_len; /* Byte 3 */
  835. int residual; /* Bytes 4-7 */
  836. };
  837. struct myrs_cmdblk {
  838. union myrs_cmd_mbox mbox;
  839. unsigned char status;
  840. unsigned char sense_len;
  841. int residual;
  842. struct completion *complete;
  843. struct myrs_sge *sgl;
  844. dma_addr_t sgl_addr;
  845. unsigned char *dcdb;
  846. dma_addr_t dcdb_dma;
  847. unsigned char *sense;
  848. dma_addr_t sense_addr;
  849. };
  850. /*
  851. * DAC960 Driver Controller structure.
  852. */
  853. struct myrs_hba {
  854. void __iomem *io_base;
  855. void __iomem *mmio_base;
  856. phys_addr_t io_addr;
  857. phys_addr_t pci_addr;
  858. unsigned int irq;
  859. unsigned char model_name[28];
  860. unsigned char fw_version[12];
  861. struct Scsi_Host *host;
  862. struct pci_dev *pdev;
  863. unsigned int epoch;
  864. unsigned int next_evseq;
  865. /* Monitor flags */
  866. bool needs_update;
  867. bool disable_enc_msg;
  868. struct workqueue_struct *work_q;
  869. char work_q_name[20];
  870. struct delayed_work monitor_work;
  871. unsigned long primary_monitor_time;
  872. unsigned long secondary_monitor_time;
  873. spinlock_t queue_lock;
  874. struct dma_pool *sg_pool;
  875. struct dma_pool *sense_pool;
  876. struct dma_pool *dcdb_pool;
  877. void (*write_cmd_mbox)(union myrs_cmd_mbox *next_mbox,
  878. union myrs_cmd_mbox *cmd_mbox);
  879. void (*get_cmd_mbox)(void __iomem *base);
  880. void (*disable_intr)(void __iomem *base);
  881. void (*reset)(void __iomem *base);
  882. dma_addr_t cmd_mbox_addr;
  883. size_t cmd_mbox_size;
  884. union myrs_cmd_mbox *first_cmd_mbox;
  885. union myrs_cmd_mbox *last_cmd_mbox;
  886. union myrs_cmd_mbox *next_cmd_mbox;
  887. union myrs_cmd_mbox *prev_cmd_mbox1;
  888. union myrs_cmd_mbox *prev_cmd_mbox2;
  889. dma_addr_t stat_mbox_addr;
  890. size_t stat_mbox_size;
  891. struct myrs_stat_mbox *first_stat_mbox;
  892. struct myrs_stat_mbox *last_stat_mbox;
  893. struct myrs_stat_mbox *next_stat_mbox;
  894. struct myrs_cmdblk dcmd_blk;
  895. struct myrs_cmdblk mcmd_blk;
  896. struct mutex dcmd_mutex;
  897. struct myrs_fwstat *fwstat_buf;
  898. dma_addr_t fwstat_addr;
  899. struct myrs_ctlr_info *ctlr_info;
  900. struct mutex cinfo_mutex;
  901. struct myrs_event *event_buf;
  902. };
  903. typedef unsigned char (*enable_mbox_t)(void __iomem *base, dma_addr_t addr);
  904. typedef int (*myrs_hwinit_t)(struct pci_dev *pdev,
  905. struct myrs_hba *c, void __iomem *base);
  906. struct myrs_privdata {
  907. myrs_hwinit_t hw_init;
  908. irq_handler_t irq_handler;
  909. unsigned int mmio_size;
  910. };
  911. /*
  912. * DAC960 GEM Series Controller Interface Register Offsets.
  913. */
  914. #define DAC960_GEM_mmio_size 0x600
  915. enum DAC960_GEM_reg_offset {
  916. DAC960_GEM_IDB_READ_OFFSET = 0x214,
  917. DAC960_GEM_IDB_CLEAR_OFFSET = 0x218,
  918. DAC960_GEM_ODB_READ_OFFSET = 0x224,
  919. DAC960_GEM_ODB_CLEAR_OFFSET = 0x228,
  920. DAC960_GEM_IRQSTS_OFFSET = 0x208,
  921. DAC960_GEM_IRQMASK_READ_OFFSET = 0x22C,
  922. DAC960_GEM_IRQMASK_CLEAR_OFFSET = 0x230,
  923. DAC960_GEM_CMDMBX_OFFSET = 0x510,
  924. DAC960_GEM_CMDSTS_OFFSET = 0x518,
  925. DAC960_GEM_ERRSTS_READ_OFFSET = 0x224,
  926. DAC960_GEM_ERRSTS_CLEAR_OFFSET = 0x228,
  927. };
  928. /*
  929. * DAC960 GEM Series Inbound Door Bell Register.
  930. */
  931. #define DAC960_GEM_IDB_HWMBOX_NEW_CMD 0x01
  932. #define DAC960_GEM_IDB_HWMBOX_ACK_STS 0x02
  933. #define DAC960_GEM_IDB_GEN_IRQ 0x04
  934. #define DAC960_GEM_IDB_CTRL_RESET 0x08
  935. #define DAC960_GEM_IDB_MMBOX_NEW_CMD 0x10
  936. #define DAC960_GEM_IDB_HWMBOX_FULL 0x01
  937. #define DAC960_GEM_IDB_INIT_IN_PROGRESS 0x02
  938. /*
  939. * DAC960 GEM Series Outbound Door Bell Register.
  940. */
  941. #define DAC960_GEM_ODB_HWMBOX_ACK_IRQ 0x01
  942. #define DAC960_GEM_ODB_MMBOX_ACK_IRQ 0x02
  943. #define DAC960_GEM_ODB_HWMBOX_STS_AVAIL 0x01
  944. #define DAC960_GEM_ODB_MMBOX_STS_AVAIL 0x02
  945. /*
  946. * DAC960 GEM Series Interrupt Mask Register.
  947. */
  948. #define DAC960_GEM_IRQMASK_HWMBOX_IRQ 0x01
  949. #define DAC960_GEM_IRQMASK_MMBOX_IRQ 0x02
  950. /*
  951. * DAC960 GEM Series Error Status Register.
  952. */
  953. #define DAC960_GEM_ERRSTS_PENDING 0x20
  954. /*
  955. * dma_addr_writeql is provided to write dma_addr_t types
  956. * to a 64-bit pci address space register. The controller
  957. * will accept having the register written as two 32-bit
  958. * values.
  959. *
  960. * In HIGHMEM kernels, dma_addr_t is a 64-bit value.
  961. * without HIGHMEM, dma_addr_t is a 32-bit value.
  962. *
  963. * The compiler should always fix up the assignment
  964. * to u.wq appropriately, depending upon the size of
  965. * dma_addr_t.
  966. */
  967. static inline
  968. void dma_addr_writeql(dma_addr_t addr, void __iomem *write_address)
  969. {
  970. union {
  971. u64 wq;
  972. uint wl[2];
  973. } u;
  974. u.wq = addr;
  975. writel(u.wl[0], write_address);
  976. writel(u.wl[1], write_address + 4);
  977. }
  978. /*
  979. * DAC960 BA Series Controller Interface Register Offsets.
  980. */
  981. #define DAC960_BA_mmio_size 0x80
  982. enum DAC960_BA_reg_offset {
  983. DAC960_BA_IRQSTS_OFFSET = 0x30,
  984. DAC960_BA_IRQMASK_OFFSET = 0x34,
  985. DAC960_BA_CMDMBX_OFFSET = 0x50,
  986. DAC960_BA_CMDSTS_OFFSET = 0x58,
  987. DAC960_BA_IDB_OFFSET = 0x60,
  988. DAC960_BA_ODB_OFFSET = 0x61,
  989. DAC960_BA_ERRSTS_OFFSET = 0x63,
  990. };
  991. /*
  992. * DAC960 BA Series Inbound Door Bell Register.
  993. */
  994. #define DAC960_BA_IDB_HWMBOX_NEW_CMD 0x01
  995. #define DAC960_BA_IDB_HWMBOX_ACK_STS 0x02
  996. #define DAC960_BA_IDB_GEN_IRQ 0x04
  997. #define DAC960_BA_IDB_CTRL_RESET 0x08
  998. #define DAC960_BA_IDB_MMBOX_NEW_CMD 0x10
  999. #define DAC960_BA_IDB_HWMBOX_EMPTY 0x01
  1000. #define DAC960_BA_IDB_INIT_DONE 0x02
  1001. /*
  1002. * DAC960 BA Series Outbound Door Bell Register.
  1003. */
  1004. #define DAC960_BA_ODB_HWMBOX_ACK_IRQ 0x01
  1005. #define DAC960_BA_ODB_MMBOX_ACK_IRQ 0x02
  1006. #define DAC960_BA_ODB_HWMBOX_STS_AVAIL 0x01
  1007. #define DAC960_BA_ODB_MMBOX_STS_AVAIL 0x02
  1008. /*
  1009. * DAC960 BA Series Interrupt Mask Register.
  1010. */
  1011. #define DAC960_BA_IRQMASK_DISABLE_IRQ 0x04
  1012. #define DAC960_BA_IRQMASK_DISABLEW_I2O 0x08
  1013. /*
  1014. * DAC960 BA Series Error Status Register.
  1015. */
  1016. #define DAC960_BA_ERRSTS_PENDING 0x04
  1017. /*
  1018. * DAC960 LP Series Controller Interface Register Offsets.
  1019. */
  1020. #define DAC960_LP_mmio_size 0x80
  1021. enum DAC960_LP_reg_offset {
  1022. DAC960_LP_CMDMBX_OFFSET = 0x10,
  1023. DAC960_LP_CMDSTS_OFFSET = 0x18,
  1024. DAC960_LP_IDB_OFFSET = 0x20,
  1025. DAC960_LP_ODB_OFFSET = 0x2C,
  1026. DAC960_LP_ERRSTS_OFFSET = 0x2E,
  1027. DAC960_LP_IRQSTS_OFFSET = 0x30,
  1028. DAC960_LP_IRQMASK_OFFSET = 0x34,
  1029. };
  1030. /*
  1031. * DAC960 LP Series Inbound Door Bell Register.
  1032. */
  1033. #define DAC960_LP_IDB_HWMBOX_NEW_CMD 0x01
  1034. #define DAC960_LP_IDB_HWMBOX_ACK_STS 0x02
  1035. #define DAC960_LP_IDB_GEN_IRQ 0x04
  1036. #define DAC960_LP_IDB_CTRL_RESET 0x08
  1037. #define DAC960_LP_IDB_MMBOX_NEW_CMD 0x10
  1038. #define DAC960_LP_IDB_HWMBOX_FULL 0x01
  1039. #define DAC960_LP_IDB_INIT_IN_PROGRESS 0x02
  1040. /*
  1041. * DAC960 LP Series Outbound Door Bell Register.
  1042. */
  1043. #define DAC960_LP_ODB_HWMBOX_ACK_IRQ 0x01
  1044. #define DAC960_LP_ODB_MMBOX_ACK_IRQ 0x02
  1045. #define DAC960_LP_ODB_HWMBOX_STS_AVAIL 0x01
  1046. #define DAC960_LP_ODB_MMBOX_STS_AVAIL 0x02
  1047. /*
  1048. * DAC960 LP Series Interrupt Mask Register.
  1049. */
  1050. #define DAC960_LP_IRQMASK_DISABLE_IRQ 0x04
  1051. /*
  1052. * DAC960 LP Series Error Status Register.
  1053. */
  1054. #define DAC960_LP_ERRSTS_PENDING 0x04
  1055. #endif /* _MYRS_H */