pmcraid.h 37 KB

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