pmcraid.h 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  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. u8 *sense_buffer;
  495. /* pointer to mid layer structure of SCSI commands */
  496. struct scsi_cmnd *scsi_cmd;
  497. struct list_head free_list;
  498. struct completion wait_for_completion;
  499. struct timer_list timer; /* needed for internal commands */
  500. u32 timeout; /* current timeout value */
  501. u32 index; /* index into the command list */
  502. u8 completion_req; /* for handling internal commands */
  503. u8 release; /* for handling completions */
  504. void (*cmd_done) (struct pmcraid_cmd *);
  505. struct pmcraid_instance *drv_inst;
  506. struct pmcraid_sglist *sglist; /* used for passthrough IOCTLs */
  507. /* scratch used */
  508. union {
  509. /* during reset sequence */
  510. unsigned long time_left;
  511. struct pmcraid_resource_entry *res;
  512. int hrrq_index;
  513. /* used during IO command error handling. Sense buffer
  514. * for REQUEST SENSE command if firmware is not sending
  515. * auto sense data
  516. */
  517. struct {
  518. u8 *sense_buffer;
  519. dma_addr_t sense_buffer_dma;
  520. };
  521. };
  522. };
  523. /*
  524. * Interrupt registers of IOA
  525. */
  526. struct pmcraid_interrupts {
  527. void __iomem *ioa_host_interrupt_reg;
  528. void __iomem *ioa_host_msix_interrupt_reg;
  529. void __iomem *ioa_host_interrupt_clr_reg;
  530. void __iomem *ioa_host_interrupt_mask_reg;
  531. void __iomem *ioa_host_interrupt_mask_clr_reg;
  532. void __iomem *global_interrupt_mask_reg;
  533. void __iomem *host_ioa_interrupt_reg;
  534. void __iomem *host_ioa_interrupt_clr_reg;
  535. };
  536. /* ISR parameters LLD allocates (one for each MSI-X if enabled) vectors */
  537. struct pmcraid_isr_param {
  538. struct pmcraid_instance *drv_inst;
  539. u16 vector; /* allocated msi-x vector */
  540. u8 hrrq_id; /* hrrq entry index */
  541. };
  542. /* AEN message header sent as part of event data to applications */
  543. struct pmcraid_aen_msg {
  544. u32 hostno;
  545. u32 length;
  546. u8 reserved[8];
  547. u8 data[0];
  548. };
  549. /* Controller state event message type */
  550. struct pmcraid_state_msg {
  551. struct pmcraid_aen_msg msg;
  552. u32 ioa_state;
  553. };
  554. #define PMC_DEVICE_EVENT_RESET_START 0x11000000
  555. #define PMC_DEVICE_EVENT_RESET_SUCCESS 0x11000001
  556. #define PMC_DEVICE_EVENT_RESET_FAILED 0x11000002
  557. #define PMC_DEVICE_EVENT_SHUTDOWN_START 0x11000003
  558. #define PMC_DEVICE_EVENT_SHUTDOWN_SUCCESS 0x11000004
  559. #define PMC_DEVICE_EVENT_SHUTDOWN_FAILED 0x11000005
  560. struct pmcraid_hostrcb {
  561. struct pmcraid_instance *drv_inst;
  562. struct pmcraid_aen_msg *msg;
  563. struct pmcraid_hcam_hdr *hcam; /* pointer to hcam buffer */
  564. struct pmcraid_cmd *cmd; /* pointer to command block used */
  565. dma_addr_t baddr; /* system address of hcam buffer */
  566. atomic_t ignore; /* process HCAM response ? */
  567. };
  568. #define PMCRAID_AEN_HDR_SIZE sizeof(struct pmcraid_aen_msg)
  569. /*
  570. * Per adapter structure maintained by LLD
  571. */
  572. struct pmcraid_instance {
  573. /* Array of allowed-to-be-exposed resources, initialized from
  574. * Configutation Table, later updated with CCNs
  575. */
  576. struct pmcraid_resource_entry *res_entries;
  577. struct list_head free_res_q; /* res_entries lists for easy lookup */
  578. struct list_head used_res_q; /* List of to be exposed resources */
  579. spinlock_t resource_lock; /* spinlock to protect resource list */
  580. void __iomem *mapped_dma_addr;
  581. void __iomem *ioa_status; /* Iomapped IOA status register */
  582. void __iomem *mailbox; /* Iomapped mailbox register */
  583. void __iomem *ioarrin; /* IOmapped IOARR IN register */
  584. struct pmcraid_interrupts int_regs;
  585. struct pmcraid_chip_details *chip_cfg;
  586. /* HostRCBs needed for HCAM */
  587. struct pmcraid_hostrcb ldn;
  588. struct pmcraid_hostrcb ccn;
  589. struct pmcraid_state_msg scn; /* controller state change msg */
  590. /* Bus address of start of HRRQ */
  591. dma_addr_t hrrq_start_bus_addr[PMCRAID_NUM_MSIX_VECTORS];
  592. /* Pointer to 1st entry of HRRQ */
  593. __be32 *hrrq_start[PMCRAID_NUM_MSIX_VECTORS];
  594. /* Pointer to last entry of HRRQ */
  595. __be32 *hrrq_end[PMCRAID_NUM_MSIX_VECTORS];
  596. /* Pointer to current pointer of hrrq */
  597. __be32 *hrrq_curr[PMCRAID_NUM_MSIX_VECTORS];
  598. /* Lock for HRRQ access */
  599. spinlock_t hrrq_lock[PMCRAID_NUM_MSIX_VECTORS];
  600. struct pmcraid_inquiry_data *inq_data;
  601. dma_addr_t inq_data_baddr;
  602. /* size of configuration table entry, varies based on the firmware */
  603. u32 config_table_entry_size;
  604. /* Expected toggle bit at host */
  605. u8 host_toggle_bit[PMCRAID_NUM_MSIX_VECTORS];
  606. /* Wait Q for threads to wait for Reset IOA completion */
  607. wait_queue_head_t reset_wait_q;
  608. struct pmcraid_cmd *reset_cmd;
  609. /* structures for supporting SIGIO based AEN. */
  610. struct fasync_struct *aen_queue;
  611. struct mutex aen_queue_lock; /* lock for aen subscribers list */
  612. struct cdev cdev;
  613. struct Scsi_Host *host; /* mid layer interface structure handle */
  614. struct pci_dev *pdev; /* PCI device structure handle */
  615. /* No of Reset IOA retries . IOA marked dead if threshold exceeds */
  616. u8 ioa_reset_attempts;
  617. #define PMCRAID_RESET_ATTEMPTS 3
  618. u8 current_log_level; /* default level for logging IOASC errors */
  619. u8 num_hrrq; /* Number of interrupt vectors allocated */
  620. u8 interrupt_mode; /* current interrupt mode legacy or msix */
  621. dev_t dev; /* Major-Minor numbers for Char device */
  622. /* Used as ISR handler argument */
  623. struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
  624. /* Message id as filled in last fired IOARCB, used to identify HRRQ */
  625. atomic_t last_message_id;
  626. /* configuration table */
  627. struct pmcraid_config_table *cfg_table;
  628. dma_addr_t cfg_table_bus_addr;
  629. /* structures related to command blocks */
  630. struct kmem_cache *cmd_cachep; /* cache for cmd blocks */
  631. struct pci_pool *control_pool; /* pool for control blocks */
  632. char cmd_pool_name[64]; /* name of cmd cache */
  633. char ctl_pool_name[64]; /* name of control cache */
  634. struct pmcraid_cmd *cmd_list[PMCRAID_MAX_CMD];
  635. struct list_head free_cmd_pool;
  636. struct list_head pending_cmd_pool;
  637. spinlock_t free_pool_lock; /* free pool lock */
  638. spinlock_t pending_pool_lock; /* pending pool lock */
  639. /* Tasklet to handle deferred processing */
  640. struct tasklet_struct isr_tasklet[PMCRAID_NUM_MSIX_VECTORS];
  641. /* Work-queue (Shared) for deferred reset processing */
  642. struct work_struct worker_q;
  643. /* No of IO commands pending with FW */
  644. atomic_t outstanding_cmds;
  645. /* should add/delete resources to mid-layer now ?*/
  646. atomic_t expose_resources;
  647. u32 ioa_state:4; /* For IOA Reset sequence FSM */
  648. #define IOA_STATE_OPERATIONAL 0x0
  649. #define IOA_STATE_UNKNOWN 0x1
  650. #define IOA_STATE_DEAD 0x2
  651. #define IOA_STATE_IN_SOFT_RESET 0x3
  652. #define IOA_STATE_IN_HARD_RESET 0x4
  653. #define IOA_STATE_IN_RESET_ALERT 0x5
  654. #define IOA_STATE_IN_BRINGDOWN 0x6
  655. #define IOA_STATE_IN_BRINGUP 0x7
  656. u32 ioa_reset_in_progress:1; /* true if IOA reset is in progress */
  657. u32 ioa_hard_reset:1; /* TRUE if Hard Reset is needed */
  658. u32 ioa_unit_check:1; /* Indicates Unit Check condition */
  659. u32 ioa_bringdown:1; /* whether IOA needs to be brought down */
  660. u32 force_ioa_reset:1; /* force adapter reset ? */
  661. u32 reinit_cfg_table:1; /* reinit config table due to lost CCN */
  662. u32 ioa_shutdown_type:2;/* shutdown type used during reset */
  663. #define SHUTDOWN_NONE 0x0
  664. #define SHUTDOWN_NORMAL 0x1
  665. #define SHUTDOWN_ABBREV 0x2
  666. };
  667. /* LLD maintained resource entry structure */
  668. struct pmcraid_resource_entry {
  669. struct list_head queue; /* link to "to be exposed" resources */
  670. union {
  671. struct pmcraid_config_table_entry cfg_entry;
  672. struct pmcraid_config_table_entry_ext cfg_entry_ext;
  673. };
  674. struct scsi_device *scsi_dev; /* Link scsi_device structure */
  675. atomic_t read_failures; /* count of failed READ commands */
  676. atomic_t write_failures; /* count of failed WRITE commands */
  677. /* To indicate add/delete/modify during CCN */
  678. u8 change_detected;
  679. #define RES_CHANGE_ADD 0x1 /* add this to mid-layer */
  680. #define RES_CHANGE_DEL 0x2 /* remove this from mid-layer */
  681. u8 reset_progress; /* Device is resetting */
  682. /*
  683. * When IOA asks for sync (i.e. IOASC = Not Ready, Sync Required), this
  684. * flag will be set, mid layer will be asked to retry. In the next
  685. * attempt, this flag will be checked in queuecommand() to set
  686. * SYNC_COMPLETE flag in IOARCB (flag_0).
  687. */
  688. u8 sync_reqd;
  689. /* target indicates the mapped target_id assigned to this resource if
  690. * this is VSET resource. For non-VSET resources this will be un-used
  691. * or zero
  692. */
  693. u8 target;
  694. };
  695. /* Data structures used in IOASC error code logging */
  696. struct pmcraid_ioasc_error {
  697. u32 ioasc_code; /* IOASC code */
  698. u8 log_level; /* default log level assignment. */
  699. char *error_string;
  700. };
  701. /* Initial log_level assignments for various IOASCs */
  702. #define IOASC_LOG_LEVEL_NONE 0x0 /* no logging */
  703. #define IOASC_LOG_LEVEL_MUST 0x1 /* must log: all high-severity errors */
  704. #define IOASC_LOG_LEVEL_HARD 0x2 /* optional – low severity errors */
  705. /* Error information maintained by LLD. LLD initializes the pmcraid_error_table
  706. * statically.
  707. */
  708. static struct pmcraid_ioasc_error pmcraid_ioasc_error_table[] = {
  709. {0x01180600, IOASC_LOG_LEVEL_HARD,
  710. "Recovered Error, soft media error, sector reassignment suggested"},
  711. {0x015D0000, IOASC_LOG_LEVEL_HARD,
  712. "Recovered Error, failure prediction thresold exceeded"},
  713. {0x015D9200, IOASC_LOG_LEVEL_HARD,
  714. "Recovered Error, soft Cache Card Battery error thresold"},
  715. {0x015D9200, IOASC_LOG_LEVEL_HARD,
  716. "Recovered Error, soft Cache Card Battery error thresold"},
  717. {0x02048000, IOASC_LOG_LEVEL_HARD,
  718. "Not Ready, IOA Reset Required"},
  719. {0x02408500, IOASC_LOG_LEVEL_HARD,
  720. "Not Ready, IOA microcode download required"},
  721. {0x03110B00, IOASC_LOG_LEVEL_HARD,
  722. "Medium Error, data unreadable, reassignment suggested"},
  723. {0x03110C00, IOASC_LOG_LEVEL_MUST,
  724. "Medium Error, data unreadable do not reassign"},
  725. {0x03310000, IOASC_LOG_LEVEL_HARD,
  726. "Medium Error, media corrupted"},
  727. {0x04050000, IOASC_LOG_LEVEL_HARD,
  728. "Hardware Error, IOA can't communicate with device"},
  729. {0x04080000, IOASC_LOG_LEVEL_MUST,
  730. "Hardware Error, device bus error"},
  731. {0x04088000, IOASC_LOG_LEVEL_MUST,
  732. "Hardware Error, device bus is not functioning"},
  733. {0x04118000, IOASC_LOG_LEVEL_HARD,
  734. "Hardware Error, IOA reserved area data check"},
  735. {0x04118100, IOASC_LOG_LEVEL_HARD,
  736. "Hardware Error, IOA reserved area invalid data pattern"},
  737. {0x04118200, IOASC_LOG_LEVEL_HARD,
  738. "Hardware Error, IOA reserved area LRC error"},
  739. {0x04320000, IOASC_LOG_LEVEL_HARD,
  740. "Hardware Error, reassignment space exhausted"},
  741. {0x04330000, IOASC_LOG_LEVEL_HARD,
  742. "Hardware Error, data transfer underlength error"},
  743. {0x04330000, IOASC_LOG_LEVEL_HARD,
  744. "Hardware Error, data transfer overlength error"},
  745. {0x04418000, IOASC_LOG_LEVEL_MUST,
  746. "Hardware Error, PCI bus error"},
  747. {0x04440000, IOASC_LOG_LEVEL_HARD,
  748. "Hardware Error, device error"},
  749. {0x04448200, IOASC_LOG_LEVEL_MUST,
  750. "Hardware Error, IOA error"},
  751. {0x04448300, IOASC_LOG_LEVEL_HARD,
  752. "Hardware Error, undefined device response"},
  753. {0x04448400, IOASC_LOG_LEVEL_HARD,
  754. "Hardware Error, IOA microcode error"},
  755. {0x04448600, IOASC_LOG_LEVEL_HARD,
  756. "Hardware Error, IOA reset required"},
  757. {0x04449200, IOASC_LOG_LEVEL_HARD,
  758. "Hardware Error, hard Cache Fearuee Card Battery error"},
  759. {0x0444A000, IOASC_LOG_LEVEL_HARD,
  760. "Hardware Error, failed device altered"},
  761. {0x0444A200, IOASC_LOG_LEVEL_HARD,
  762. "Hardware Error, data check after reassignment"},
  763. {0x0444A300, IOASC_LOG_LEVEL_HARD,
  764. "Hardware Error, LRC error after reassignment"},
  765. {0x044A0000, IOASC_LOG_LEVEL_HARD,
  766. "Hardware Error, device bus error (msg/cmd phase)"},
  767. {0x04670400, IOASC_LOG_LEVEL_HARD,
  768. "Hardware Error, new device can't be used"},
  769. {0x04678000, IOASC_LOG_LEVEL_HARD,
  770. "Hardware Error, invalid multiadapter configuration"},
  771. {0x04678100, IOASC_LOG_LEVEL_HARD,
  772. "Hardware Error, incorrect connection between enclosures"},
  773. {0x04678200, IOASC_LOG_LEVEL_HARD,
  774. "Hardware Error, connections exceed IOA design limits"},
  775. {0x04678300, IOASC_LOG_LEVEL_HARD,
  776. "Hardware Error, incorrect multipath connection"},
  777. {0x04679000, IOASC_LOG_LEVEL_HARD,
  778. "Hardware Error, command to LUN failed"},
  779. {0x064C8000, IOASC_LOG_LEVEL_HARD,
  780. "Unit Attention, cache exists for missing/failed device"},
  781. {0x06670100, IOASC_LOG_LEVEL_HARD,
  782. "Unit Attention, incompatible exposed mode device"},
  783. {0x06670600, IOASC_LOG_LEVEL_HARD,
  784. "Unit Attention, attachment of logical unit failed"},
  785. {0x06678000, IOASC_LOG_LEVEL_HARD,
  786. "Unit Attention, cables exceed connective design limit"},
  787. {0x06678300, IOASC_LOG_LEVEL_HARD,
  788. "Unit Attention, incomplete multipath connection between" \
  789. "IOA and enclosure"},
  790. {0x06678400, IOASC_LOG_LEVEL_HARD,
  791. "Unit Attention, incomplete multipath connection between" \
  792. "device and enclosure"},
  793. {0x06678500, IOASC_LOG_LEVEL_HARD,
  794. "Unit Attention, incomplete multipath connection between" \
  795. "IOA and remote IOA"},
  796. {0x06678600, IOASC_LOG_LEVEL_HARD,
  797. "Unit Attention, missing remote IOA"},
  798. {0x06679100, IOASC_LOG_LEVEL_HARD,
  799. "Unit Attention, enclosure doesn't support required multipath" \
  800. "function"},
  801. {0x06698200, IOASC_LOG_LEVEL_HARD,
  802. "Unit Attention, corrupt array parity detected on device"},
  803. {0x066B0200, IOASC_LOG_LEVEL_HARD,
  804. "Unit Attention, array exposed"},
  805. {0x066B8200, IOASC_LOG_LEVEL_HARD,
  806. "Unit Attention, exposed array is still protected"},
  807. {0x066B9200, IOASC_LOG_LEVEL_HARD,
  808. "Unit Attention, Multipath redundancy level got worse"},
  809. {0x07270000, IOASC_LOG_LEVEL_HARD,
  810. "Data Protect, device is read/write protected by IOA"},
  811. {0x07278000, IOASC_LOG_LEVEL_HARD,
  812. "Data Protect, IOA doesn't support device attribute"},
  813. {0x07278100, IOASC_LOG_LEVEL_HARD,
  814. "Data Protect, NVRAM mirroring prohibited"},
  815. {0x07278400, IOASC_LOG_LEVEL_HARD,
  816. "Data Protect, array is short 2 or more devices"},
  817. {0x07278600, IOASC_LOG_LEVEL_HARD,
  818. "Data Protect, exposed array is short a required device"},
  819. {0x07278700, IOASC_LOG_LEVEL_HARD,
  820. "Data Protect, array members not at required addresses"},
  821. {0x07278800, IOASC_LOG_LEVEL_HARD,
  822. "Data Protect, exposed mode device resource address conflict"},
  823. {0x07278900, IOASC_LOG_LEVEL_HARD,
  824. "Data Protect, incorrect resource address of exposed mode device"},
  825. {0x07278A00, IOASC_LOG_LEVEL_HARD,
  826. "Data Protect, Array is missing a device and parity is out of sync"},
  827. {0x07278B00, IOASC_LOG_LEVEL_HARD,
  828. "Data Protect, maximum number of arrays already exist"},
  829. {0x07278C00, IOASC_LOG_LEVEL_HARD,
  830. "Data Protect, cannot locate cache data for device"},
  831. {0x07278D00, IOASC_LOG_LEVEL_HARD,
  832. "Data Protect, cache data exits for a changed device"},
  833. {0x07279100, IOASC_LOG_LEVEL_HARD,
  834. "Data Protect, detection of a device requiring format"},
  835. {0x07279200, IOASC_LOG_LEVEL_HARD,
  836. "Data Protect, IOA exceeds maximum number of devices"},
  837. {0x07279600, IOASC_LOG_LEVEL_HARD,
  838. "Data Protect, missing array, volume set is not functional"},
  839. {0x07279700, IOASC_LOG_LEVEL_HARD,
  840. "Data Protect, single device for a volume set"},
  841. {0x07279800, IOASC_LOG_LEVEL_HARD,
  842. "Data Protect, missing multiple devices for a volume set"},
  843. {0x07279900, IOASC_LOG_LEVEL_HARD,
  844. "Data Protect, maximum number of volument sets already exists"},
  845. {0x07279A00, IOASC_LOG_LEVEL_HARD,
  846. "Data Protect, other volume set problem"},
  847. };
  848. /* macros to help in debugging */
  849. #define pmcraid_err(...) \
  850. printk(KERN_ERR "MaxRAID: "__VA_ARGS__)
  851. #define pmcraid_info(...) \
  852. if (pmcraid_debug_log) \
  853. printk(KERN_INFO "MaxRAID: "__VA_ARGS__)
  854. /* check if given command is a SCSI READ or SCSI WRITE command */
  855. #define SCSI_READ_CMD 0x1 /* any of SCSI READ commands */
  856. #define SCSI_WRITE_CMD 0x2 /* any of SCSI WRITE commands */
  857. #define SCSI_CMD_TYPE(opcode) \
  858. ({ u8 op = opcode; u8 __type = 0;\
  859. if (op == READ_6 || op == READ_10 || op == READ_12 || op == READ_16)\
  860. __type = SCSI_READ_CMD;\
  861. else if (op == WRITE_6 || op == WRITE_10 || op == WRITE_12 || \
  862. op == WRITE_16)\
  863. __type = SCSI_WRITE_CMD;\
  864. __type;\
  865. })
  866. #define IS_SCSI_READ_WRITE(opcode) \
  867. ({ u8 __type = SCSI_CMD_TYPE(opcode); \
  868. (__type == SCSI_READ_CMD || __type == SCSI_WRITE_CMD) ? 1 : 0;\
  869. })
  870. /*
  871. * pmcraid_ioctl_header - definition of header structure that preceeds all the
  872. * buffers given as ioctl arguments.
  873. *
  874. * .signature : always ASCII string, "PMCRAID"
  875. * .reserved : not used
  876. * .buffer_length : length of the buffer following the header
  877. */
  878. struct pmcraid_ioctl_header {
  879. u8 signature[8];
  880. u32 reserved;
  881. u32 buffer_length;
  882. };
  883. #define PMCRAID_IOCTL_SIGNATURE "PMCRAID"
  884. /*
  885. * pmcraid_passthrough_ioctl_buffer - structure given as argument to
  886. * passthrough(or firmware handled) IOCTL commands. Note that ioarcb requires
  887. * 32-byte alignment so, it is necessary to pack this structure to avoid any
  888. * holes between ioctl_header and passthrough buffer
  889. *
  890. * .ioactl_header : ioctl header
  891. * .ioarcb : filled-up ioarcb buffer, driver always reads this buffer
  892. * .ioasa : buffer for ioasa, driver fills this with IOASA from firmware
  893. * .request_buffer: The I/O buffer (flat), driver reads/writes to this based on
  894. * the transfer directions passed in ioarcb.flags0. Contents
  895. * of this buffer are valid only when ioarcb.data_transfer_len
  896. * is not zero.
  897. */
  898. struct pmcraid_passthrough_ioctl_buffer {
  899. struct pmcraid_ioctl_header ioctl_header;
  900. struct pmcraid_ioarcb ioarcb;
  901. struct pmcraid_ioasa ioasa;
  902. u8 request_buffer[1];
  903. } __attribute__ ((packed));
  904. /*
  905. * keys to differentiate between driver handled IOCTLs and passthrough
  906. * IOCTLs passed to IOA. driver determines the ioctl type using macro
  907. * _IOC_TYPE
  908. */
  909. #define PMCRAID_DRIVER_IOCTL 'D'
  910. #define PMCRAID_PASSTHROUGH_IOCTL 'F'
  911. #define DRV_IOCTL(n, size) \
  912. _IOC(_IOC_READ|_IOC_WRITE, PMCRAID_DRIVER_IOCTL, (n), (size))
  913. #define FMW_IOCTL(n, size) \
  914. _IOC(_IOC_READ|_IOC_WRITE, PMCRAID_PASSTHROUGH_IOCTL, (n), (size))
  915. /*
  916. * _ARGSIZE: macro that gives size of the argument type passed to an IOCTL cmd.
  917. * This is to facilitate applications avoiding un-necessary memory allocations.
  918. * For example, most of driver handled ioctls do not require ioarcb, ioasa.
  919. */
  920. #define _ARGSIZE(arg) (sizeof(struct pmcraid_ioctl_header) + sizeof(arg))
  921. /* Driver handled IOCTL command definitions */
  922. #define PMCRAID_IOCTL_RESET_ADAPTER \
  923. DRV_IOCTL(5, sizeof(struct pmcraid_ioctl_header))
  924. /* passthrough/firmware handled commands */
  925. #define PMCRAID_IOCTL_PASSTHROUGH_COMMAND \
  926. FMW_IOCTL(1, sizeof(struct pmcraid_passthrough_ioctl_buffer))
  927. #define PMCRAID_IOCTL_DOWNLOAD_MICROCODE \
  928. FMW_IOCTL(2, sizeof(struct pmcraid_passthrough_ioctl_buffer))
  929. #endif /* _PMCRAID_H */