pmcraid.h 35 KB

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