pmcraid.h 37 KB

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