pmcraid.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  1. /*
  2. * pmcraid.h -- PMC Sierra MaxRAID controller driver header file
  3. *
  4. * Written By: Anil Ravindranath<anil_ravindranath@pmc-sierra.com>
  5. * PMC-Sierra Inc
  6. *
  7. * Copyright (C) 2008, 2009 PMC Sierra Inc.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #ifndef _PMCRAID_H
  24. #define _PMCRAID_H
  25. #include <linux/types.h>
  26. #include <linux/completion.h>
  27. #include <linux/list.h>
  28. #include <scsi/scsi.h>
  29. #include <scsi/scsi_cmnd.h>
  30. #include <linux/cdev.h>
  31. #include <net/netlink.h>
  32. #include <net/genetlink.h>
  33. #include <linux/connector.h>
  34. /*
  35. * Driver name : string representing the driver name
  36. * Device file : /dev file to be used for management interfaces
  37. * Driver version: version string in major_version.minor_version.patch format
  38. * Driver date : date information in "Mon dd yyyy" format
  39. */
  40. #define PMCRAID_DRIVER_NAME "PMC MaxRAID"
  41. #define PMCRAID_DEVFILE "pmcsas"
  42. #define PMCRAID_DRIVER_VERSION "1.0.3"
  43. #define PMCRAID_FW_VERSION_1 0x002
  44. /* Maximum number of adapters supported by current version of the driver */
  45. #define PMCRAID_MAX_ADAPTERS 1024
  46. /* Bit definitions as per firmware, bit position [0][1][2].....[31] */
  47. #define PMC_BIT8(n) (1 << (7-n))
  48. #define PMC_BIT16(n) (1 << (15-n))
  49. #define PMC_BIT32(n) (1 << (31-n))
  50. /* PMC PCI vendor ID and device ID values */
  51. #define PCI_VENDOR_ID_PMC 0x11F8
  52. #define PCI_DEVICE_ID_PMC_MAXRAID 0x5220
  53. /*
  54. * MAX_CMD : maximum commands that can be outstanding with IOA
  55. * MAX_IO_CMD : command blocks available for IO commands
  56. * MAX_HCAM_CMD : command blocks avaibale for HCAMS
  57. * MAX_INTERNAL_CMD : command blocks avaible for internal commands like reset
  58. */
  59. #define PMCRAID_MAX_CMD 1024
  60. #define PMCRAID_MAX_IO_CMD 1020
  61. #define PMCRAID_MAX_HCAM_CMD 2
  62. #define PMCRAID_MAX_INTERNAL_CMD 2
  63. /* MAX_IOADLS : max number of scatter-gather lists supported by IOA
  64. * IOADLS_INTERNAL : number of ioadls included as part of IOARCB.
  65. * IOADLS_EXTERNAL : number of ioadls allocated external to IOARCB
  66. */
  67. #define PMCRAID_IOADLS_INTERNAL 27
  68. #define PMCRAID_IOADLS_EXTERNAL 37
  69. #define PMCRAID_MAX_IOADLS PMCRAID_IOADLS_INTERNAL
  70. /* HRRQ_ENTRY_SIZE : size of hrrq buffer
  71. * IOARCB_ALIGNMENT : alignment required for IOARCB
  72. * IOADL_ALIGNMENT : alignment requirement for IOADLs
  73. * MSIX_VECTORS : number of MSIX vectors supported
  74. */
  75. #define HRRQ_ENTRY_SIZE sizeof(__le32)
  76. #define PMCRAID_IOARCB_ALIGNMENT 32
  77. #define PMCRAID_IOADL_ALIGNMENT 16
  78. #define PMCRAID_IOASA_ALIGNMENT 4
  79. #define PMCRAID_NUM_MSIX_VECTORS 16
  80. /* various other limits */
  81. #define PMCRAID_VENDOR_ID_LEN 8
  82. #define PMCRAID_PRODUCT_ID_LEN 16
  83. #define PMCRAID_SERIAL_NUM_LEN 8
  84. #define PMCRAID_LUN_LEN 8
  85. #define PMCRAID_MAX_CDB_LEN 16
  86. #define PMCRAID_DEVICE_ID_LEN 8
  87. #define PMCRAID_SENSE_DATA_LEN 256
  88. #define PMCRAID_ADD_CMD_PARAM_LEN 48
  89. #define PMCRAID_MAX_BUS_TO_SCAN 1
  90. #define PMCRAID_MAX_NUM_TARGETS_PER_BUS 256
  91. #define PMCRAID_MAX_NUM_LUNS_PER_TARGET 8
  92. /* IOA bus/target/lun number of IOA resources */
  93. #define PMCRAID_IOA_BUS_ID 0xfe
  94. #define PMCRAID_IOA_TARGET_ID 0xff
  95. #define PMCRAID_IOA_LUN_ID 0xff
  96. #define PMCRAID_VSET_BUS_ID 0x1
  97. #define PMCRAID_VSET_LUN_ID 0x0
  98. #define PMCRAID_PHYS_BUS_ID 0x0
  99. #define PMCRAID_VIRTUAL_ENCL_BUS_ID 0x8
  100. #define PMCRAID_MAX_VSET_TARGETS 0x7F
  101. #define PMCRAID_MAX_VSET_LUNS_PER_TARGET 8
  102. #define PMCRAID_IOA_MAX_SECTORS 32767
  103. #define PMCRAID_VSET_MAX_SECTORS 512
  104. #define PMCRAID_MAX_CMD_PER_LUN 254
  105. /* Number of configuration table entries (resources), includes 1 FP,
  106. * 1 Enclosure device
  107. */
  108. #define PMCRAID_MAX_RESOURCES 256
  109. /* Adapter Commands used by driver */
  110. #define PMCRAID_QUERY_RESOURCE_STATE 0xC2
  111. #define PMCRAID_RESET_DEVICE 0xC3
  112. /* options to select reset target */
  113. #define ENABLE_RESET_MODIFIER 0x80
  114. #define RESET_DEVICE_LUN 0x40
  115. #define RESET_DEVICE_TARGET 0x20
  116. #define RESET_DEVICE_BUS 0x10
  117. #define PMCRAID_IDENTIFY_HRRQ 0xC4
  118. #define PMCRAID_QUERY_IOA_CONFIG 0xC5
  119. #define PMCRAID_QUERY_CMD_STATUS 0xCB
  120. #define PMCRAID_ABORT_CMD 0xC7
  121. /* CANCEL ALL command, provides option for setting SYNC_COMPLETE
  122. * on the target resources for which commands got cancelled
  123. */
  124. #define PMCRAID_CANCEL_ALL_REQUESTS 0xCE
  125. #define PMCRAID_SYNC_COMPLETE_AFTER_CANCEL PMC_BIT8(0)
  126. /* HCAM command and types of HCAM supported by IOA */
  127. #define PMCRAID_HOST_CONTROLLED_ASYNC 0xCF
  128. #define PMCRAID_HCAM_CODE_CONFIG_CHANGE 0x01
  129. #define PMCRAID_HCAM_CODE_LOG_DATA 0x02
  130. /* IOA shutdown command and various shutdown types */
  131. #define PMCRAID_IOA_SHUTDOWN 0xF7
  132. #define PMCRAID_SHUTDOWN_NORMAL 0x00
  133. #define PMCRAID_SHUTDOWN_PREPARE_FOR_NORMAL 0x40
  134. #define PMCRAID_SHUTDOWN_NONE 0x100
  135. #define PMCRAID_SHUTDOWN_ABBREV 0x80
  136. /* SET SUPPORTED DEVICES command and the option to select all the
  137. * devices to be supported
  138. */
  139. #define PMCRAID_SET_SUPPORTED_DEVICES 0xFB
  140. #define ALL_DEVICES_SUPPORTED PMC_BIT8(0)
  141. /* This option is used with SCSI WRITE_BUFFER command */
  142. #define PMCRAID_WR_BUF_DOWNLOAD_AND_SAVE 0x05
  143. /* IOASC Codes used by driver */
  144. #define PMCRAID_IOASC_SENSE_MASK 0xFFFFFF00
  145. #define PMCRAID_IOASC_SENSE_KEY(ioasc) ((ioasc) >> 24)
  146. #define PMCRAID_IOASC_SENSE_CODE(ioasc) (((ioasc) & 0x00ff0000) >> 16)
  147. #define PMCRAID_IOASC_SENSE_QUAL(ioasc) (((ioasc) & 0x0000ff00) >> 8)
  148. #define PMCRAID_IOASC_SENSE_STATUS(ioasc) ((ioasc) & 0x000000ff)
  149. #define PMCRAID_IOASC_GOOD_COMPLETION 0x00000000
  150. #define PMCRAID_IOASC_GC_IOARCB_NOTFOUND 0x005A0000
  151. #define PMCRAID_IOASC_NR_INIT_CMD_REQUIRED 0x02040200
  152. #define PMCRAID_IOASC_NR_IOA_RESET_REQUIRED 0x02048000
  153. #define PMCRAID_IOASC_NR_SYNC_REQUIRED 0x023F0000
  154. #define PMCRAID_IOASC_ME_READ_ERROR_NO_REALLOC 0x03110C00
  155. #define PMCRAID_IOASC_HW_CANNOT_COMMUNICATE 0x04050000
  156. #define PMCRAID_IOASC_HW_DEVICE_TIMEOUT 0x04080100
  157. #define PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR 0x04448500
  158. #define PMCRAID_IOASC_HW_IOA_RESET_REQUIRED 0x04448600
  159. #define PMCRAID_IOASC_IR_INVALID_RESOURCE_HANDLE 0x05250000
  160. #define PMCRAID_IOASC_AC_TERMINATED_BY_HOST 0x0B5A0000
  161. #define PMCRAID_IOASC_UA_BUS_WAS_RESET 0x06290000
  162. #define PMCRAID_IOASC_TIME_STAMP_OUT_OF_SYNC 0x06908B00
  163. #define PMCRAID_IOASC_UA_BUS_WAS_RESET_BY_OTHER 0x06298000
  164. /* Driver defined IOASCs */
  165. #define PMCRAID_IOASC_IOA_WAS_RESET 0x10000001
  166. #define PMCRAID_IOASC_PCI_ACCESS_ERROR 0x10000002
  167. /* Various timeout values (in milliseconds) used. If any of these are chip
  168. * specific, move them to pmcraid_chip_details structure.
  169. */
  170. #define PMCRAID_PCI_DEASSERT_TIMEOUT 2000
  171. #define PMCRAID_BIST_TIMEOUT 2000
  172. #define PMCRAID_AENWAIT_TIMEOUT 5000
  173. #define PMCRAID_TRANSOP_TIMEOUT 60000
  174. #define PMCRAID_RESET_TIMEOUT (2 * HZ)
  175. #define PMCRAID_CHECK_FOR_RESET_TIMEOUT ((HZ / 10))
  176. #define PMCRAID_VSET_IO_TIMEOUT (60 * HZ)
  177. #define PMCRAID_INTERNAL_TIMEOUT (60 * HZ)
  178. #define PMCRAID_SHUTDOWN_TIMEOUT (150 * HZ)
  179. #define PMCRAID_RESET_BUS_TIMEOUT (60 * HZ)
  180. #define PMCRAID_RESET_HOST_TIMEOUT (150 * HZ)
  181. #define PMCRAID_REQUEST_SENSE_TIMEOUT (30 * HZ)
  182. #define PMCRAID_SET_SUP_DEV_TIMEOUT (2 * 60 * HZ)
  183. /* structure to represent a scatter-gather element (IOADL descriptor) */
  184. struct pmcraid_ioadl_desc {
  185. __le64 address;
  186. __le32 data_len;
  187. __u8 reserved[3];
  188. __u8 flags;
  189. } __attribute__((packed, aligned(PMCRAID_IOADL_ALIGNMENT)));
  190. /* pmcraid_ioadl_desc.flags values */
  191. #define IOADL_FLAGS_CHAINED PMC_BIT8(0)
  192. #define IOADL_FLAGS_LAST_DESC PMC_BIT8(1)
  193. #define IOADL_FLAGS_READ_LAST PMC_BIT8(1)
  194. #define IOADL_FLAGS_WRITE_LAST PMC_BIT8(1)
  195. /* additional IOARCB data which can be CDB or additional request parameters
  196. * or list of IOADLs. Firmware supports max of 512 bytes for IOARCB, hence then
  197. * number of IOADLs are limted to 27. In case they are more than 27, they will
  198. * be used in chained form
  199. */
  200. struct pmcraid_ioarcb_add_data {
  201. union {
  202. struct pmcraid_ioadl_desc ioadl[PMCRAID_IOADLS_INTERNAL];
  203. __u8 add_cmd_params[PMCRAID_ADD_CMD_PARAM_LEN];
  204. } u;
  205. };
  206. /*
  207. * IOA Request Control Block
  208. */
  209. struct pmcraid_ioarcb {
  210. __le64 ioarcb_bus_addr;
  211. __le32 resource_handle;
  212. __le32 response_handle;
  213. __le64 ioadl_bus_addr;
  214. __le32 ioadl_length;
  215. __le32 data_transfer_length;
  216. __le64 ioasa_bus_addr;
  217. __le16 ioasa_len;
  218. __le16 cmd_timeout;
  219. __le16 add_cmd_param_offset;
  220. __le16 add_cmd_param_length;
  221. __le32 reserved1[2];
  222. __le32 reserved2;
  223. __u8 request_type;
  224. __u8 request_flags0;
  225. __u8 request_flags1;
  226. __u8 hrrq_id;
  227. __u8 cdb[PMCRAID_MAX_CDB_LEN];
  228. struct pmcraid_ioarcb_add_data add_data;
  229. } __attribute__((packed, aligned(PMCRAID_IOARCB_ALIGNMENT)));
  230. /* well known resource handle values */
  231. #define PMCRAID_IOA_RES_HANDLE 0xffffffff
  232. #define PMCRAID_INVALID_RES_HANDLE 0
  233. /* pmcraid_ioarcb.request_type values */
  234. #define REQ_TYPE_SCSI 0x00
  235. #define REQ_TYPE_IOACMD 0x01
  236. #define REQ_TYPE_HCAM 0x02
  237. /* pmcraid_ioarcb.flags0 values */
  238. #define TRANSFER_DIR_WRITE PMC_BIT8(0)
  239. #define INHIBIT_UL_CHECK PMC_BIT8(2)
  240. #define SYNC_OVERRIDE PMC_BIT8(3)
  241. #define SYNC_COMPLETE PMC_BIT8(4)
  242. #define NO_LINK_DESCS PMC_BIT8(5)
  243. /* pmcraid_ioarcb.flags1 values */
  244. #define DELAY_AFTER_RESET PMC_BIT8(0)
  245. #define TASK_TAG_SIMPLE 0x10
  246. #define TASK_TAG_ORDERED 0x20
  247. #define TASK_TAG_QUEUE_HEAD 0x30
  248. /* toggle bit offset in response handle */
  249. #define HRRQ_TOGGLE_BIT 0x01
  250. #define HRRQ_RESPONSE_BIT 0x02
  251. /* IOA Status Area */
  252. struct pmcraid_ioasa_vset {
  253. __le32 failing_lba_hi;
  254. __le32 failing_lba_lo;
  255. __le32 reserved;
  256. } __attribute__((packed, aligned(4)));
  257. struct pmcraid_ioasa {
  258. __le32 ioasc;
  259. __le16 returned_status_length;
  260. __le16 available_status_length;
  261. __le32 residual_data_length;
  262. __le32 ilid;
  263. __le32 fd_ioasc;
  264. __le32 fd_res_address;
  265. __le32 fd_res_handle;
  266. __le32 reserved;
  267. /* resource specific sense information */
  268. union {
  269. struct pmcraid_ioasa_vset vset;
  270. } u;
  271. /* IOA autosense data */
  272. __le16 auto_sense_length;
  273. __le16 error_data_length;
  274. __u8 sense_data[PMCRAID_SENSE_DATA_LEN];
  275. } __attribute__((packed, aligned(4)));
  276. #define PMCRAID_DRIVER_ILID 0xffffffff
  277. /* Config Table Entry per Resource */
  278. struct pmcraid_config_table_entry {
  279. __u8 resource_type;
  280. __u8 bus_protocol;
  281. __le16 array_id;
  282. __u8 common_flags0;
  283. __u8 common_flags1;
  284. __u8 unique_flags0;
  285. __u8 unique_flags1; /*also used as vset target_id */
  286. __le32 resource_handle;
  287. __le32 resource_address;
  288. __u8 device_id[PMCRAID_DEVICE_ID_LEN];
  289. __u8 lun[PMCRAID_LUN_LEN];
  290. } __attribute__((packed, aligned(4)));
  291. /* extended configuration table sizes are also of 32 bytes in size */
  292. struct pmcraid_config_table_entry_ext {
  293. struct pmcraid_config_table_entry cfgte;
  294. };
  295. /* resource types (config_table_entry.resource_type values) */
  296. #define RES_TYPE_AF_DASD 0x00
  297. #define RES_TYPE_GSCSI 0x01
  298. #define RES_TYPE_VSET 0x02
  299. #define RES_TYPE_IOA_FP 0xFF
  300. #define RES_IS_IOA(res) ((res).resource_type == RES_TYPE_IOA_FP)
  301. #define RES_IS_GSCSI(res) ((res).resource_type == RES_TYPE_GSCSI)
  302. #define RES_IS_VSET(res) ((res).resource_type == RES_TYPE_VSET)
  303. #define RES_IS_AFDASD(res) ((res).resource_type == RES_TYPE_AF_DASD)
  304. /* bus_protocol values used by driver */
  305. #define RES_TYPE_VENCLOSURE 0x8
  306. /* config_table_entry.common_flags0 */
  307. #define MULTIPATH_RESOURCE PMC_BIT32(0)
  308. /* unique_flags1 */
  309. #define IMPORT_MODE_MANUAL PMC_BIT8(0)
  310. /* well known resource handle values */
  311. #define RES_HANDLE_IOA 0xFFFFFFFF
  312. #define RES_HANDLE_NONE 0x00000000
  313. /* well known resource address values */
  314. #define RES_ADDRESS_IOAFP 0xFEFFFFFF
  315. #define RES_ADDRESS_INVALID 0xFFFFFFFF
  316. /* BUS/TARGET/LUN values from resource_addrr */
  317. #define RES_BUS(res_addr) (le32_to_cpu(res_addr) & 0xFF)
  318. #define RES_TARGET(res_addr) ((le32_to_cpu(res_addr) >> 16) & 0xFF)
  319. #define RES_LUN(res_addr) 0x0
  320. /* configuration table structure */
  321. struct pmcraid_config_table {
  322. __le16 num_entries;
  323. __u8 table_format;
  324. __u8 reserved1;
  325. __u8 flags;
  326. __u8 reserved2[11];
  327. union {
  328. struct pmcraid_config_table_entry
  329. entries[PMCRAID_MAX_RESOURCES];
  330. struct pmcraid_config_table_entry_ext
  331. entries_ext[PMCRAID_MAX_RESOURCES];
  332. };
  333. } __attribute__((packed, aligned(4)));
  334. /* config_table.flags value */
  335. #define MICROCODE_UPDATE_REQUIRED PMC_BIT32(0)
  336. /*
  337. * HCAM format
  338. */
  339. #define PMCRAID_HOSTRCB_LDNSIZE 4056
  340. /* Error log notification format */
  341. struct pmcraid_hostrcb_error {
  342. __le32 fd_ioasc;
  343. __le32 fd_ra;
  344. __le32 fd_rh;
  345. __le32 prc;
  346. union {
  347. __u8 data[PMCRAID_HOSTRCB_LDNSIZE];
  348. } u;
  349. } __attribute__ ((packed, aligned(4)));
  350. struct pmcraid_hcam_hdr {
  351. __u8 op_code;
  352. __u8 notification_type;
  353. __u8 notification_lost;
  354. __u8 flags;
  355. __u8 overlay_id;
  356. __u8 reserved1[3];
  357. __le32 ilid;
  358. __le32 timestamp1;
  359. __le32 timestamp2;
  360. __le32 data_len;
  361. } __attribute__((packed, aligned(4)));
  362. #define PMCRAID_AEN_GROUP 0x3
  363. struct pmcraid_hcam_ccn {
  364. struct pmcraid_hcam_hdr header;
  365. struct pmcraid_config_table_entry cfg_entry;
  366. struct pmcraid_config_table_entry cfg_entry_old;
  367. } __attribute__((packed, aligned(4)));
  368. #define PMCRAID_CCN_EXT_SIZE 3944
  369. struct pmcraid_hcam_ccn_ext {
  370. struct pmcraid_hcam_hdr header;
  371. struct pmcraid_config_table_entry_ext cfg_entry;
  372. struct pmcraid_config_table_entry_ext cfg_entry_old;
  373. __u8 reserved[PMCRAID_CCN_EXT_SIZE];
  374. } __attribute__((packed, aligned(4)));
  375. struct pmcraid_hcam_ldn {
  376. struct pmcraid_hcam_hdr header;
  377. struct pmcraid_hostrcb_error error_log;
  378. } __attribute__((packed, aligned(4)));
  379. /* pmcraid_hcam.op_code values */
  380. #define HOSTRCB_TYPE_CCN 0xE1
  381. #define HOSTRCB_TYPE_LDN 0xE2
  382. /* pmcraid_hcam.notification_type values */
  383. #define NOTIFICATION_TYPE_ENTRY_CHANGED 0x0
  384. #define NOTIFICATION_TYPE_ENTRY_NEW 0x1
  385. #define NOTIFICATION_TYPE_ENTRY_DELETED 0x2
  386. #define NOTIFICATION_TYPE_STATE_CHANGE 0x3
  387. #define NOTIFICATION_TYPE_ENTRY_STATECHANGED 0x4
  388. #define NOTIFICATION_TYPE_ERROR_LOG 0x10
  389. #define NOTIFICATION_TYPE_INFORMATION_LOG 0x11
  390. #define HOSTRCB_NOTIFICATIONS_LOST PMC_BIT8(0)
  391. /* pmcraid_hcam.flags values */
  392. #define HOSTRCB_INTERNAL_OP_ERROR PMC_BIT8(0)
  393. #define HOSTRCB_ERROR_RESPONSE_SENT PMC_BIT8(1)
  394. /* pmcraid_hcam.overlay_id values */
  395. #define HOSTRCB_OVERLAY_ID_08 0x08
  396. #define HOSTRCB_OVERLAY_ID_09 0x09
  397. #define HOSTRCB_OVERLAY_ID_11 0x11
  398. #define HOSTRCB_OVERLAY_ID_12 0x12
  399. #define HOSTRCB_OVERLAY_ID_13 0x13
  400. #define HOSTRCB_OVERLAY_ID_14 0x14
  401. #define HOSTRCB_OVERLAY_ID_16 0x16
  402. #define HOSTRCB_OVERLAY_ID_17 0x17
  403. #define HOSTRCB_OVERLAY_ID_20 0x20
  404. #define HOSTRCB_OVERLAY_ID_FF 0xFF
  405. /* Implementation specific card details */
  406. struct pmcraid_chip_details {
  407. /* hardware register offsets */
  408. unsigned long ioastatus;
  409. unsigned long ioarrin;
  410. unsigned long mailbox;
  411. unsigned long global_intr_mask;
  412. unsigned long ioa_host_intr;
  413. unsigned long ioa_host_msix_intr;
  414. unsigned long ioa_host_intr_clr;
  415. unsigned long ioa_host_mask;
  416. unsigned long ioa_host_mask_clr;
  417. unsigned long host_ioa_intr;
  418. unsigned long host_ioa_intr_clr;
  419. /* timeout used during transitional to operational state */
  420. unsigned long transop_timeout;
  421. };
  422. /* IOA to HOST doorbells (interrupts) */
  423. #define INTRS_TRANSITION_TO_OPERATIONAL PMC_BIT32(0)
  424. #define INTRS_IOARCB_TRANSFER_FAILED PMC_BIT32(3)
  425. #define INTRS_IOA_UNIT_CHECK PMC_BIT32(4)
  426. #define INTRS_NO_HRRQ_FOR_CMD_RESPONSE PMC_BIT32(5)
  427. #define INTRS_CRITICAL_OP_IN_PROGRESS PMC_BIT32(6)
  428. #define INTRS_IO_DEBUG_ACK PMC_BIT32(7)
  429. #define INTRS_IOARRIN_LOST PMC_BIT32(27)
  430. #define INTRS_SYSTEM_BUS_MMIO_ERROR PMC_BIT32(28)
  431. #define INTRS_IOA_PROCESSOR_ERROR PMC_BIT32(29)
  432. #define INTRS_HRRQ_VALID PMC_BIT32(30)
  433. #define INTRS_OPERATIONAL_STATUS PMC_BIT32(0)
  434. #define INTRS_ALLOW_MSIX_VECTOR0 PMC_BIT32(31)
  435. /* Host to IOA Doorbells */
  436. #define DOORBELL_RUNTIME_RESET PMC_BIT32(1)
  437. #define DOORBELL_IOA_RESET_ALERT PMC_BIT32(7)
  438. #define DOORBELL_IOA_DEBUG_ALERT PMC_BIT32(9)
  439. #define DOORBELL_ENABLE_DESTRUCTIVE_DIAGS PMC_BIT32(8)
  440. #define DOORBELL_IOA_START_BIST PMC_BIT32(23)
  441. #define DOORBELL_INTR_MODE_MSIX PMC_BIT32(25)
  442. #define DOORBELL_INTR_MSIX_CLR PMC_BIT32(26)
  443. #define DOORBELL_RESET_IOA PMC_BIT32(31)
  444. /* Global interrupt mask register value */
  445. #define GLOBAL_INTERRUPT_MASK 0x5ULL
  446. #define PMCRAID_ERROR_INTERRUPTS (INTRS_IOARCB_TRANSFER_FAILED | \
  447. INTRS_IOA_UNIT_CHECK | \
  448. INTRS_NO_HRRQ_FOR_CMD_RESPONSE | \
  449. INTRS_IOARRIN_LOST | \
  450. INTRS_SYSTEM_BUS_MMIO_ERROR | \
  451. INTRS_IOA_PROCESSOR_ERROR)
  452. #define PMCRAID_PCI_INTERRUPTS (PMCRAID_ERROR_INTERRUPTS | \
  453. INTRS_HRRQ_VALID | \
  454. INTRS_TRANSITION_TO_OPERATIONAL |\
  455. INTRS_ALLOW_MSIX_VECTOR0)
  456. /* control_block, associated with each of the commands contains IOARCB, IOADLs
  457. * memory for IOASA. Additional 3 * 16 bytes are allocated in order to support
  458. * additional request parameters (of max size 48) any command.
  459. */
  460. struct pmcraid_control_block {
  461. struct pmcraid_ioarcb ioarcb;
  462. struct pmcraid_ioadl_desc ioadl[PMCRAID_IOADLS_EXTERNAL + 3];
  463. struct pmcraid_ioasa ioasa;
  464. } __attribute__ ((packed, aligned(PMCRAID_IOARCB_ALIGNMENT)));
  465. /* pmcraid_sglist - Scatter-gather list allocated for passthrough ioctls
  466. */
  467. struct pmcraid_sglist {
  468. u32 order;
  469. u32 num_sg;
  470. u32 num_dma_sg;
  471. u32 buffer_len;
  472. struct scatterlist scatterlist[1];
  473. };
  474. /* page D0 inquiry data of focal point resource */
  475. struct pmcraid_inquiry_data {
  476. __u8 ph_dev_type;
  477. __u8 page_code;
  478. __u8 reserved1;
  479. __u8 add_page_len;
  480. __u8 length;
  481. __u8 reserved2;
  482. __le16 fw_version;
  483. __u8 reserved3[16];
  484. };
  485. #define PMCRAID_TIMESTAMP_LEN 12
  486. #define PMCRAID_REQ_TM_STR_LEN 6
  487. #define PMCRAID_SCSI_SET_TIMESTAMP 0xA4
  488. #define PMCRAID_SCSI_SERVICE_ACTION 0x0F
  489. struct pmcraid_timestamp_data {
  490. __u8 reserved1[4];
  491. __u8 timestamp[PMCRAID_REQ_TM_STR_LEN]; /* current time value */
  492. __u8 reserved2[2];
  493. };
  494. /* pmcraid_cmd - LLD representation of SCSI command */
  495. struct pmcraid_cmd {
  496. /* Ptr and bus address of DMA.able control block for this command */
  497. struct pmcraid_control_block *ioa_cb;
  498. dma_addr_t ioa_cb_bus_addr;
  499. dma_addr_t dma_handle;
  500. /* pointer to mid layer structure of SCSI commands */
  501. struct scsi_cmnd *scsi_cmd;
  502. struct list_head free_list;
  503. struct completion wait_for_completion;
  504. struct timer_list timer; /* needed for internal commands */
  505. u32 timeout; /* current timeout value */
  506. u32 index; /* index into the command list */
  507. u8 completion_req; /* for handling internal commands */
  508. u8 release; /* for handling completions */
  509. void (*cmd_done) (struct pmcraid_cmd *);
  510. struct pmcraid_instance *drv_inst;
  511. struct pmcraid_sglist *sglist; /* used for passthrough IOCTLs */
  512. /* scratch used */
  513. union {
  514. /* during reset sequence */
  515. unsigned long time_left;
  516. struct pmcraid_resource_entry *res;
  517. int hrrq_index;
  518. /* used during IO command error handling. Sense buffer
  519. * for REQUEST SENSE command if firmware is not sending
  520. * auto sense data
  521. */
  522. struct {
  523. u8 *sense_buffer;
  524. dma_addr_t sense_buffer_dma;
  525. };
  526. };
  527. };
  528. /*
  529. * Interrupt registers of IOA
  530. */
  531. struct pmcraid_interrupts {
  532. void __iomem *ioa_host_interrupt_reg;
  533. void __iomem *ioa_host_msix_interrupt_reg;
  534. void __iomem *ioa_host_interrupt_clr_reg;
  535. void __iomem *ioa_host_interrupt_mask_reg;
  536. void __iomem *ioa_host_interrupt_mask_clr_reg;
  537. void __iomem *global_interrupt_mask_reg;
  538. void __iomem *host_ioa_interrupt_reg;
  539. void __iomem *host_ioa_interrupt_clr_reg;
  540. };
  541. /* ISR parameters LLD allocates (one for each MSI-X if enabled) vectors */
  542. struct pmcraid_isr_param {
  543. struct pmcraid_instance *drv_inst;
  544. u16 vector; /* allocated msi-x vector */
  545. u8 hrrq_id; /* hrrq entry index */
  546. };
  547. /* AEN message header sent as part of event data to applications */
  548. struct pmcraid_aen_msg {
  549. u32 hostno;
  550. u32 length;
  551. u8 reserved[8];
  552. u8 data[0];
  553. };
  554. /* Controller state event message type */
  555. struct pmcraid_state_msg {
  556. struct pmcraid_aen_msg msg;
  557. u32 ioa_state;
  558. };
  559. #define PMC_DEVICE_EVENT_RESET_START 0x11000000
  560. #define PMC_DEVICE_EVENT_RESET_SUCCESS 0x11000001
  561. #define PMC_DEVICE_EVENT_RESET_FAILED 0x11000002
  562. #define PMC_DEVICE_EVENT_SHUTDOWN_START 0x11000003
  563. #define PMC_DEVICE_EVENT_SHUTDOWN_SUCCESS 0x11000004
  564. #define PMC_DEVICE_EVENT_SHUTDOWN_FAILED 0x11000005
  565. struct pmcraid_hostrcb {
  566. struct pmcraid_instance *drv_inst;
  567. struct pmcraid_aen_msg *msg;
  568. struct pmcraid_hcam_hdr *hcam; /* pointer to hcam buffer */
  569. struct pmcraid_cmd *cmd; /* pointer to command block used */
  570. dma_addr_t baddr; /* system address of hcam buffer */
  571. atomic_t ignore; /* process HCAM response ? */
  572. };
  573. #define PMCRAID_AEN_HDR_SIZE sizeof(struct pmcraid_aen_msg)
  574. /*
  575. * Per adapter structure maintained by LLD
  576. */
  577. struct pmcraid_instance {
  578. /* Array of allowed-to-be-exposed resources, initialized from
  579. * Configutation Table, later updated with CCNs
  580. */
  581. struct pmcraid_resource_entry *res_entries;
  582. struct list_head free_res_q; /* res_entries lists for easy lookup */
  583. struct list_head used_res_q; /* List of to be exposed resources */
  584. spinlock_t resource_lock; /* spinlock to protect resource list */
  585. void __iomem *mapped_dma_addr;
  586. void __iomem *ioa_status; /* Iomapped IOA status register */
  587. void __iomem *mailbox; /* Iomapped mailbox register */
  588. void __iomem *ioarrin; /* IOmapped IOARR IN register */
  589. struct pmcraid_interrupts int_regs;
  590. struct pmcraid_chip_details *chip_cfg;
  591. /* HostRCBs needed for HCAM */
  592. struct pmcraid_hostrcb ldn;
  593. struct pmcraid_hostrcb ccn;
  594. struct pmcraid_state_msg scn; /* controller state change msg */
  595. /* Bus address of start of HRRQ */
  596. dma_addr_t hrrq_start_bus_addr[PMCRAID_NUM_MSIX_VECTORS];
  597. /* Pointer to 1st entry of HRRQ */
  598. __be32 *hrrq_start[PMCRAID_NUM_MSIX_VECTORS];
  599. /* Pointer to last entry of HRRQ */
  600. __be32 *hrrq_end[PMCRAID_NUM_MSIX_VECTORS];
  601. /* Pointer to current pointer of hrrq */
  602. __be32 *hrrq_curr[PMCRAID_NUM_MSIX_VECTORS];
  603. /* Lock for HRRQ access */
  604. spinlock_t hrrq_lock[PMCRAID_NUM_MSIX_VECTORS];
  605. struct pmcraid_inquiry_data *inq_data;
  606. dma_addr_t inq_data_baddr;
  607. struct pmcraid_timestamp_data *timestamp_data;
  608. dma_addr_t timestamp_data_baddr;
  609. /* size of configuration table entry, varies based on the firmware */
  610. u32 config_table_entry_size;
  611. /* Expected toggle bit at host */
  612. u8 host_toggle_bit[PMCRAID_NUM_MSIX_VECTORS];
  613. /* Wait Q for threads to wait for Reset IOA completion */
  614. wait_queue_head_t reset_wait_q;
  615. struct pmcraid_cmd *reset_cmd;
  616. /* structures for supporting SIGIO based AEN. */
  617. struct fasync_struct *aen_queue;
  618. struct mutex aen_queue_lock; /* lock for aen subscribers list */
  619. struct cdev cdev;
  620. struct Scsi_Host *host; /* mid layer interface structure handle */
  621. struct pci_dev *pdev; /* PCI device structure handle */
  622. /* No of Reset IOA retries . IOA marked dead if threshold exceeds */
  623. u8 ioa_reset_attempts;
  624. #define PMCRAID_RESET_ATTEMPTS 3
  625. u8 current_log_level; /* default level for logging IOASC errors */
  626. u8 num_hrrq; /* Number of interrupt vectors allocated */
  627. u8 interrupt_mode; /* current interrupt mode legacy or msix */
  628. dev_t dev; /* Major-Minor numbers for Char device */
  629. /* Used as ISR handler argument */
  630. struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
  631. /* Message id as filled in last fired IOARCB, used to identify HRRQ */
  632. atomic_t last_message_id;
  633. /* configuration table */
  634. struct pmcraid_config_table *cfg_table;
  635. dma_addr_t cfg_table_bus_addr;
  636. /* structures related to command blocks */
  637. struct kmem_cache *cmd_cachep; /* cache for cmd blocks */
  638. struct pci_pool *control_pool; /* pool for control blocks */
  639. char cmd_pool_name[64]; /* name of cmd cache */
  640. char ctl_pool_name[64]; /* name of control cache */
  641. struct pmcraid_cmd *cmd_list[PMCRAID_MAX_CMD];
  642. struct list_head free_cmd_pool;
  643. struct list_head pending_cmd_pool;
  644. spinlock_t free_pool_lock; /* free pool lock */
  645. spinlock_t pending_pool_lock; /* pending pool lock */
  646. /* Tasklet to handle deferred processing */
  647. struct tasklet_struct isr_tasklet[PMCRAID_NUM_MSIX_VECTORS];
  648. /* Work-queue (Shared) for deferred reset processing */
  649. struct work_struct worker_q;
  650. /* No of IO commands pending with FW */
  651. atomic_t outstanding_cmds;
  652. /* should add/delete resources to mid-layer now ?*/
  653. atomic_t expose_resources;
  654. u32 ioa_state:4; /* For IOA Reset sequence FSM */
  655. #define IOA_STATE_OPERATIONAL 0x0
  656. #define IOA_STATE_UNKNOWN 0x1
  657. #define IOA_STATE_DEAD 0x2
  658. #define IOA_STATE_IN_SOFT_RESET 0x3
  659. #define IOA_STATE_IN_HARD_RESET 0x4
  660. #define IOA_STATE_IN_RESET_ALERT 0x5
  661. #define IOA_STATE_IN_BRINGDOWN 0x6
  662. #define IOA_STATE_IN_BRINGUP 0x7
  663. u32 ioa_reset_in_progress:1; /* true if IOA reset is in progress */
  664. u32 ioa_hard_reset:1; /* TRUE if Hard Reset is needed */
  665. u32 ioa_unit_check:1; /* Indicates Unit Check condition */
  666. u32 ioa_bringdown:1; /* whether IOA needs to be brought down */
  667. u32 force_ioa_reset:1; /* force adapter reset ? */
  668. u32 reinit_cfg_table:1; /* reinit config table due to lost CCN */
  669. u32 ioa_shutdown_type:2;/* shutdown type used during reset */
  670. #define SHUTDOWN_NONE 0x0
  671. #define SHUTDOWN_NORMAL 0x1
  672. #define SHUTDOWN_ABBREV 0x2
  673. u32 timestamp_error:1; /* indicate set timestamp for out of sync */
  674. };
  675. /* LLD maintained resource entry structure */
  676. struct pmcraid_resource_entry {
  677. struct list_head queue; /* link to "to be exposed" resources */
  678. union {
  679. struct pmcraid_config_table_entry cfg_entry;
  680. struct pmcraid_config_table_entry_ext cfg_entry_ext;
  681. };
  682. struct scsi_device *scsi_dev; /* Link scsi_device structure */
  683. atomic_t read_failures; /* count of failed READ commands */
  684. atomic_t write_failures; /* count of failed WRITE commands */
  685. /* To indicate add/delete/modify during CCN */
  686. u8 change_detected;
  687. #define RES_CHANGE_ADD 0x1 /* add this to mid-layer */
  688. #define RES_CHANGE_DEL 0x2 /* remove this from mid-layer */
  689. u8 reset_progress; /* Device is resetting */
  690. /*
  691. * When IOA asks for sync (i.e. IOASC = Not Ready, Sync Required), this
  692. * flag will be set, mid layer will be asked to retry. In the next
  693. * attempt, this flag will be checked in queuecommand() to set
  694. * SYNC_COMPLETE flag in IOARCB (flag_0).
  695. */
  696. u8 sync_reqd;
  697. /* target indicates the mapped target_id assigned to this resource if
  698. * this is VSET resource. For non-VSET resources this will be un-used
  699. * or zero
  700. */
  701. u8 target;
  702. };
  703. /* Data structures used in IOASC error code logging */
  704. struct pmcraid_ioasc_error {
  705. u32 ioasc_code; /* IOASC code */
  706. u8 log_level; /* default log level assignment. */
  707. char *error_string;
  708. };
  709. /* Initial log_level assignments for various IOASCs */
  710. #define IOASC_LOG_LEVEL_NONE 0x0 /* no logging */
  711. #define IOASC_LOG_LEVEL_MUST 0x1 /* must log: all high-severity errors */
  712. #define IOASC_LOG_LEVEL_HARD 0x2 /* optional – low severity errors */
  713. /* Error information maintained by LLD. LLD initializes the pmcraid_error_table
  714. * statically.
  715. */
  716. static struct pmcraid_ioasc_error pmcraid_ioasc_error_table[] = {
  717. {0x01180600, IOASC_LOG_LEVEL_HARD,
  718. "Recovered Error, soft media error, sector reassignment suggested"},
  719. {0x015D0000, IOASC_LOG_LEVEL_HARD,
  720. "Recovered Error, failure prediction threshold exceeded"},
  721. {0x015D9200, IOASC_LOG_LEVEL_HARD,
  722. "Recovered Error, soft Cache Card Battery error threshold"},
  723. {0x015D9200, IOASC_LOG_LEVEL_HARD,
  724. "Recovered Error, soft Cache Card Battery error threshold"},
  725. {0x02048000, IOASC_LOG_LEVEL_HARD,
  726. "Not Ready, IOA Reset Required"},
  727. {0x02408500, IOASC_LOG_LEVEL_HARD,
  728. "Not Ready, IOA microcode download required"},
  729. {0x03110B00, IOASC_LOG_LEVEL_HARD,
  730. "Medium Error, data unreadable, reassignment suggested"},
  731. {0x03110C00, IOASC_LOG_LEVEL_MUST,
  732. "Medium Error, data unreadable do not reassign"},
  733. {0x03310000, IOASC_LOG_LEVEL_HARD,
  734. "Medium Error, media corrupted"},
  735. {0x04050000, IOASC_LOG_LEVEL_HARD,
  736. "Hardware Error, IOA can't communicate with device"},
  737. {0x04080000, IOASC_LOG_LEVEL_MUST,
  738. "Hardware Error, device bus error"},
  739. {0x04088000, IOASC_LOG_LEVEL_MUST,
  740. "Hardware Error, device bus is not functioning"},
  741. {0x04118000, IOASC_LOG_LEVEL_HARD,
  742. "Hardware Error, IOA reserved area data check"},
  743. {0x04118100, IOASC_LOG_LEVEL_HARD,
  744. "Hardware Error, IOA reserved area invalid data pattern"},
  745. {0x04118200, IOASC_LOG_LEVEL_HARD,
  746. "Hardware Error, IOA reserved area LRC error"},
  747. {0x04320000, IOASC_LOG_LEVEL_HARD,
  748. "Hardware Error, reassignment space exhausted"},
  749. {0x04330000, IOASC_LOG_LEVEL_HARD,
  750. "Hardware Error, data transfer underlength error"},
  751. {0x04330000, IOASC_LOG_LEVEL_HARD,
  752. "Hardware Error, data transfer overlength error"},
  753. {0x04418000, IOASC_LOG_LEVEL_MUST,
  754. "Hardware Error, PCI bus error"},
  755. {0x04440000, IOASC_LOG_LEVEL_HARD,
  756. "Hardware Error, device error"},
  757. {0x04448200, IOASC_LOG_LEVEL_MUST,
  758. "Hardware Error, IOA error"},
  759. {0x04448300, IOASC_LOG_LEVEL_HARD,
  760. "Hardware Error, undefined device response"},
  761. {0x04448400, IOASC_LOG_LEVEL_HARD,
  762. "Hardware Error, IOA microcode error"},
  763. {0x04448600, IOASC_LOG_LEVEL_HARD,
  764. "Hardware Error, IOA reset required"},
  765. {0x04449200, IOASC_LOG_LEVEL_HARD,
  766. "Hardware Error, hard Cache Fearuee Card Battery error"},
  767. {0x0444A000, IOASC_LOG_LEVEL_HARD,
  768. "Hardware Error, failed device altered"},
  769. {0x0444A200, IOASC_LOG_LEVEL_HARD,
  770. "Hardware Error, data check after reassignment"},
  771. {0x0444A300, IOASC_LOG_LEVEL_HARD,
  772. "Hardware Error, LRC error after reassignment"},
  773. {0x044A0000, IOASC_LOG_LEVEL_HARD,
  774. "Hardware Error, device bus error (msg/cmd phase)"},
  775. {0x04670400, IOASC_LOG_LEVEL_HARD,
  776. "Hardware Error, new device can't be used"},
  777. {0x04678000, IOASC_LOG_LEVEL_HARD,
  778. "Hardware Error, invalid multiadapter configuration"},
  779. {0x04678100, IOASC_LOG_LEVEL_HARD,
  780. "Hardware Error, incorrect connection between enclosures"},
  781. {0x04678200, IOASC_LOG_LEVEL_HARD,
  782. "Hardware Error, connections exceed IOA design limits"},
  783. {0x04678300, IOASC_LOG_LEVEL_HARD,
  784. "Hardware Error, incorrect multipath connection"},
  785. {0x04679000, IOASC_LOG_LEVEL_HARD,
  786. "Hardware Error, command to LUN failed"},
  787. {0x064C8000, IOASC_LOG_LEVEL_HARD,
  788. "Unit Attention, cache exists for missing/failed device"},
  789. {0x06670100, IOASC_LOG_LEVEL_HARD,
  790. "Unit Attention, incompatible exposed mode device"},
  791. {0x06670600, IOASC_LOG_LEVEL_HARD,
  792. "Unit Attention, attachment of logical unit failed"},
  793. {0x06678000, IOASC_LOG_LEVEL_HARD,
  794. "Unit Attention, cables exceed connective design limit"},
  795. {0x06678300, IOASC_LOG_LEVEL_HARD,
  796. "Unit Attention, incomplete multipath connection between" \
  797. "IOA and enclosure"},
  798. {0x06678400, IOASC_LOG_LEVEL_HARD,
  799. "Unit Attention, incomplete multipath connection between" \
  800. "device and enclosure"},
  801. {0x06678500, IOASC_LOG_LEVEL_HARD,
  802. "Unit Attention, incomplete multipath connection between" \
  803. "IOA and remote IOA"},
  804. {0x06678600, IOASC_LOG_LEVEL_HARD,
  805. "Unit Attention, missing remote IOA"},
  806. {0x06679100, IOASC_LOG_LEVEL_HARD,
  807. "Unit Attention, enclosure doesn't support required multipath" \
  808. "function"},
  809. {0x06698200, IOASC_LOG_LEVEL_HARD,
  810. "Unit Attention, corrupt array parity detected on device"},
  811. {0x066B0200, IOASC_LOG_LEVEL_HARD,
  812. "Unit Attention, array exposed"},
  813. {0x066B8200, IOASC_LOG_LEVEL_HARD,
  814. "Unit Attention, exposed array is still protected"},
  815. {0x066B9200, IOASC_LOG_LEVEL_HARD,
  816. "Unit Attention, Multipath redundancy level got worse"},
  817. {0x07270000, IOASC_LOG_LEVEL_HARD,
  818. "Data Protect, device is read/write protected by IOA"},
  819. {0x07278000, IOASC_LOG_LEVEL_HARD,
  820. "Data Protect, IOA doesn't support device attribute"},
  821. {0x07278100, IOASC_LOG_LEVEL_HARD,
  822. "Data Protect, NVRAM mirroring prohibited"},
  823. {0x07278400, IOASC_LOG_LEVEL_HARD,
  824. "Data Protect, array is short 2 or more devices"},
  825. {0x07278600, IOASC_LOG_LEVEL_HARD,
  826. "Data Protect, exposed array is short a required device"},
  827. {0x07278700, IOASC_LOG_LEVEL_HARD,
  828. "Data Protect, array members not at required addresses"},
  829. {0x07278800, IOASC_LOG_LEVEL_HARD,
  830. "Data Protect, exposed mode device resource address conflict"},
  831. {0x07278900, IOASC_LOG_LEVEL_HARD,
  832. "Data Protect, incorrect resource address of exposed mode device"},
  833. {0x07278A00, IOASC_LOG_LEVEL_HARD,
  834. "Data Protect, Array is missing a device and parity is out of sync"},
  835. {0x07278B00, IOASC_LOG_LEVEL_HARD,
  836. "Data Protect, maximum number of arrays already exist"},
  837. {0x07278C00, IOASC_LOG_LEVEL_HARD,
  838. "Data Protect, cannot locate cache data for device"},
  839. {0x07278D00, IOASC_LOG_LEVEL_HARD,
  840. "Data Protect, cache data exits for a changed device"},
  841. {0x07279100, IOASC_LOG_LEVEL_HARD,
  842. "Data Protect, detection of a device requiring format"},
  843. {0x07279200, IOASC_LOG_LEVEL_HARD,
  844. "Data Protect, IOA exceeds maximum number of devices"},
  845. {0x07279600, IOASC_LOG_LEVEL_HARD,
  846. "Data Protect, missing array, volume set is not functional"},
  847. {0x07279700, IOASC_LOG_LEVEL_HARD,
  848. "Data Protect, single device for a volume set"},
  849. {0x07279800, IOASC_LOG_LEVEL_HARD,
  850. "Data Protect, missing multiple devices for a volume set"},
  851. {0x07279900, IOASC_LOG_LEVEL_HARD,
  852. "Data Protect, maximum number of volument sets already exists"},
  853. {0x07279A00, IOASC_LOG_LEVEL_HARD,
  854. "Data Protect, other volume set problem"},
  855. };
  856. /* macros to help in debugging */
  857. #define pmcraid_err(...) \
  858. printk(KERN_ERR "MaxRAID: "__VA_ARGS__)
  859. #define pmcraid_info(...) \
  860. if (pmcraid_debug_log) \
  861. printk(KERN_INFO "MaxRAID: "__VA_ARGS__)
  862. /* check if given command is a SCSI READ or SCSI WRITE command */
  863. #define SCSI_READ_CMD 0x1 /* any of SCSI READ commands */
  864. #define SCSI_WRITE_CMD 0x2 /* any of SCSI WRITE commands */
  865. #define SCSI_CMD_TYPE(opcode) \
  866. ({ u8 op = opcode; u8 __type = 0;\
  867. if (op == READ_6 || op == READ_10 || op == READ_12 || op == READ_16)\
  868. __type = SCSI_READ_CMD;\
  869. else if (op == WRITE_6 || op == WRITE_10 || op == WRITE_12 || \
  870. op == WRITE_16)\
  871. __type = SCSI_WRITE_CMD;\
  872. __type;\
  873. })
  874. #define IS_SCSI_READ_WRITE(opcode) \
  875. ({ u8 __type = SCSI_CMD_TYPE(opcode); \
  876. (__type == SCSI_READ_CMD || __type == SCSI_WRITE_CMD) ? 1 : 0;\
  877. })
  878. /*
  879. * pmcraid_ioctl_header - definition of header structure that precedes all the
  880. * buffers given as ioctl arguments.
  881. *
  882. * .signature : always ASCII string, "PMCRAID"
  883. * .reserved : not used
  884. * .buffer_length : length of the buffer following the header
  885. */
  886. struct pmcraid_ioctl_header {
  887. u8 signature[8];
  888. u32 reserved;
  889. u32 buffer_length;
  890. };
  891. #define PMCRAID_IOCTL_SIGNATURE "PMCRAID"
  892. /*
  893. * pmcraid_passthrough_ioctl_buffer - structure given as argument to
  894. * passthrough(or firmware handled) IOCTL commands. Note that ioarcb requires
  895. * 32-byte alignment so, it is necessary to pack this structure to avoid any
  896. * holes between ioctl_header and passthrough buffer
  897. *
  898. * .ioactl_header : ioctl header
  899. * .ioarcb : filled-up ioarcb buffer, driver always reads this buffer
  900. * .ioasa : buffer for ioasa, driver fills this with IOASA from firmware
  901. * .request_buffer: The I/O buffer (flat), driver reads/writes to this based on
  902. * the transfer directions passed in ioarcb.flags0. Contents
  903. * of this buffer are valid only when ioarcb.data_transfer_len
  904. * is not zero.
  905. */
  906. struct pmcraid_passthrough_ioctl_buffer {
  907. struct pmcraid_ioctl_header ioctl_header;
  908. struct pmcraid_ioarcb ioarcb;
  909. struct pmcraid_ioasa ioasa;
  910. u8 request_buffer[1];
  911. } __attribute__ ((packed));
  912. /*
  913. * keys to differentiate between driver handled IOCTLs and passthrough
  914. * IOCTLs passed to IOA. driver determines the ioctl type using macro
  915. * _IOC_TYPE
  916. */
  917. #define PMCRAID_DRIVER_IOCTL 'D'
  918. #define PMCRAID_PASSTHROUGH_IOCTL 'F'
  919. #define DRV_IOCTL(n, size) \
  920. _IOC(_IOC_READ|_IOC_WRITE, PMCRAID_DRIVER_IOCTL, (n), (size))
  921. #define FMW_IOCTL(n, size) \
  922. _IOC(_IOC_READ|_IOC_WRITE, PMCRAID_PASSTHROUGH_IOCTL, (n), (size))
  923. /*
  924. * _ARGSIZE: macro that gives size of the argument type passed to an IOCTL cmd.
  925. * This is to facilitate applications avoiding un-necessary memory allocations.
  926. * For example, most of driver handled ioctls do not require ioarcb, ioasa.
  927. */
  928. #define _ARGSIZE(arg) (sizeof(struct pmcraid_ioctl_header) + sizeof(arg))
  929. /* Driver handled IOCTL command definitions */
  930. #define PMCRAID_IOCTL_RESET_ADAPTER \
  931. DRV_IOCTL(5, sizeof(struct pmcraid_ioctl_header))
  932. /* passthrough/firmware handled commands */
  933. #define PMCRAID_IOCTL_PASSTHROUGH_COMMAND \
  934. FMW_IOCTL(1, sizeof(struct pmcraid_passthrough_ioctl_buffer))
  935. #define PMCRAID_IOCTL_DOWNLOAD_MICROCODE \
  936. FMW_IOCTL(2, sizeof(struct pmcraid_passthrough_ioctl_buffer))
  937. #endif /* _PMCRAID_H */