megaraid_sas.h 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  1. /*
  2. *
  3. * Linux MegaRAID driver for SAS based RAID controllers
  4. *
  5. * Copyright (c) 2003-2005 LSI Corporation.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. *
  12. * FILE : megaraid_sas.h
  13. */
  14. #ifndef LSI_MEGARAID_SAS_H
  15. #define LSI_MEGARAID_SAS_H
  16. /*
  17. * MegaRAID SAS Driver meta data
  18. */
  19. #define MEGASAS_VERSION "00.00.04.01"
  20. #define MEGASAS_RELDATE "July 24, 2008"
  21. #define MEGASAS_EXT_VERSION "Thu July 24 11:41:51 PST 2008"
  22. /*
  23. * Device IDs
  24. */
  25. #define PCI_DEVICE_ID_LSI_SAS1078R 0x0060
  26. #define PCI_DEVICE_ID_LSI_SAS1078DE 0x007C
  27. #define PCI_DEVICE_ID_LSI_VERDE_ZCR 0x0413
  28. #define PCI_DEVICE_ID_LSI_SAS1078GEN2 0x0078
  29. #define PCI_DEVICE_ID_LSI_SAS0079GEN2 0x0079
  30. #define PCI_DEVICE_ID_LSI_SAS0073SKINNY 0x0073
  31. #define PCI_DEVICE_ID_LSI_SAS0071SKINNY 0x0071
  32. /*
  33. * =====================================
  34. * MegaRAID SAS MFI firmware definitions
  35. * =====================================
  36. */
  37. /*
  38. * MFI stands for MegaRAID SAS FW Interface. This is just a moniker for
  39. * protocol between the software and firmware. Commands are issued using
  40. * "message frames"
  41. */
  42. /*
  43. * FW posts its state in upper 4 bits of outbound_msg_0 register
  44. */
  45. #define MFI_STATE_MASK 0xF0000000
  46. #define MFI_STATE_UNDEFINED 0x00000000
  47. #define MFI_STATE_BB_INIT 0x10000000
  48. #define MFI_STATE_FW_INIT 0x40000000
  49. #define MFI_STATE_WAIT_HANDSHAKE 0x60000000
  50. #define MFI_STATE_FW_INIT_2 0x70000000
  51. #define MFI_STATE_DEVICE_SCAN 0x80000000
  52. #define MFI_STATE_BOOT_MESSAGE_PENDING 0x90000000
  53. #define MFI_STATE_FLUSH_CACHE 0xA0000000
  54. #define MFI_STATE_READY 0xB0000000
  55. #define MFI_STATE_OPERATIONAL 0xC0000000
  56. #define MFI_STATE_FAULT 0xF0000000
  57. #define MEGAMFI_FRAME_SIZE 64
  58. /*
  59. * During FW init, clear pending cmds & reset state using inbound_msg_0
  60. *
  61. * ABORT : Abort all pending cmds
  62. * READY : Move from OPERATIONAL to READY state; discard queue info
  63. * MFIMODE : Discard (possible) low MFA posted in 64-bit mode (??)
  64. * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
  65. * HOTPLUG : Resume from Hotplug
  66. * MFI_STOP_ADP : Send signal to FW to stop processing
  67. */
  68. #define MFI_INIT_ABORT 0x00000001
  69. #define MFI_INIT_READY 0x00000002
  70. #define MFI_INIT_MFIMODE 0x00000004
  71. #define MFI_INIT_CLEAR_HANDSHAKE 0x00000008
  72. #define MFI_INIT_HOTPLUG 0x00000010
  73. #define MFI_STOP_ADP 0x00000020
  74. #define MFI_RESET_FLAGS MFI_INIT_READY| \
  75. MFI_INIT_MFIMODE| \
  76. MFI_INIT_ABORT
  77. /*
  78. * MFI frame flags
  79. */
  80. #define MFI_FRAME_POST_IN_REPLY_QUEUE 0x0000
  81. #define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE 0x0001
  82. #define MFI_FRAME_SGL32 0x0000
  83. #define MFI_FRAME_SGL64 0x0002
  84. #define MFI_FRAME_SENSE32 0x0000
  85. #define MFI_FRAME_SENSE64 0x0004
  86. #define MFI_FRAME_DIR_NONE 0x0000
  87. #define MFI_FRAME_DIR_WRITE 0x0008
  88. #define MFI_FRAME_DIR_READ 0x0010
  89. #define MFI_FRAME_DIR_BOTH 0x0018
  90. /*
  91. * Definition for cmd_status
  92. */
  93. #define MFI_CMD_STATUS_POLL_MODE 0xFF
  94. /*
  95. * MFI command opcodes
  96. */
  97. #define MFI_CMD_INIT 0x00
  98. #define MFI_CMD_LD_READ 0x01
  99. #define MFI_CMD_LD_WRITE 0x02
  100. #define MFI_CMD_LD_SCSI_IO 0x03
  101. #define MFI_CMD_PD_SCSI_IO 0x04
  102. #define MFI_CMD_DCMD 0x05
  103. #define MFI_CMD_ABORT 0x06
  104. #define MFI_CMD_SMP 0x07
  105. #define MFI_CMD_STP 0x08
  106. #define MR_DCMD_CTRL_GET_INFO 0x01010000
  107. #define MR_DCMD_CTRL_CACHE_FLUSH 0x01101000
  108. #define MR_FLUSH_CTRL_CACHE 0x01
  109. #define MR_FLUSH_DISK_CACHE 0x02
  110. #define MR_DCMD_CTRL_SHUTDOWN 0x01050000
  111. #define MR_DCMD_HIBERNATE_SHUTDOWN 0x01060000
  112. #define MR_ENABLE_DRIVE_SPINDOWN 0x01
  113. #define MR_DCMD_CTRL_EVENT_GET_INFO 0x01040100
  114. #define MR_DCMD_CTRL_EVENT_GET 0x01040300
  115. #define MR_DCMD_CTRL_EVENT_WAIT 0x01040500
  116. #define MR_DCMD_LD_GET_PROPERTIES 0x03030000
  117. #define MR_DCMD_CLUSTER 0x08000000
  118. #define MR_DCMD_CLUSTER_RESET_ALL 0x08010100
  119. #define MR_DCMD_CLUSTER_RESET_LD 0x08010200
  120. #define MR_DCMD_PD_LIST_QUERY 0x02010100
  121. /*
  122. * MFI command completion codes
  123. */
  124. enum MFI_STAT {
  125. MFI_STAT_OK = 0x00,
  126. MFI_STAT_INVALID_CMD = 0x01,
  127. MFI_STAT_INVALID_DCMD = 0x02,
  128. MFI_STAT_INVALID_PARAMETER = 0x03,
  129. MFI_STAT_INVALID_SEQUENCE_NUMBER = 0x04,
  130. MFI_STAT_ABORT_NOT_POSSIBLE = 0x05,
  131. MFI_STAT_APP_HOST_CODE_NOT_FOUND = 0x06,
  132. MFI_STAT_APP_IN_USE = 0x07,
  133. MFI_STAT_APP_NOT_INITIALIZED = 0x08,
  134. MFI_STAT_ARRAY_INDEX_INVALID = 0x09,
  135. MFI_STAT_ARRAY_ROW_NOT_EMPTY = 0x0a,
  136. MFI_STAT_CONFIG_RESOURCE_CONFLICT = 0x0b,
  137. MFI_STAT_DEVICE_NOT_FOUND = 0x0c,
  138. MFI_STAT_DRIVE_TOO_SMALL = 0x0d,
  139. MFI_STAT_FLASH_ALLOC_FAIL = 0x0e,
  140. MFI_STAT_FLASH_BUSY = 0x0f,
  141. MFI_STAT_FLASH_ERROR = 0x10,
  142. MFI_STAT_FLASH_IMAGE_BAD = 0x11,
  143. MFI_STAT_FLASH_IMAGE_INCOMPLETE = 0x12,
  144. MFI_STAT_FLASH_NOT_OPEN = 0x13,
  145. MFI_STAT_FLASH_NOT_STARTED = 0x14,
  146. MFI_STAT_FLUSH_FAILED = 0x15,
  147. MFI_STAT_HOST_CODE_NOT_FOUNT = 0x16,
  148. MFI_STAT_LD_CC_IN_PROGRESS = 0x17,
  149. MFI_STAT_LD_INIT_IN_PROGRESS = 0x18,
  150. MFI_STAT_LD_LBA_OUT_OF_RANGE = 0x19,
  151. MFI_STAT_LD_MAX_CONFIGURED = 0x1a,
  152. MFI_STAT_LD_NOT_OPTIMAL = 0x1b,
  153. MFI_STAT_LD_RBLD_IN_PROGRESS = 0x1c,
  154. MFI_STAT_LD_RECON_IN_PROGRESS = 0x1d,
  155. MFI_STAT_LD_WRONG_RAID_LEVEL = 0x1e,
  156. MFI_STAT_MAX_SPARES_EXCEEDED = 0x1f,
  157. MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20,
  158. MFI_STAT_MFC_HW_ERROR = 0x21,
  159. MFI_STAT_NO_HW_PRESENT = 0x22,
  160. MFI_STAT_NOT_FOUND = 0x23,
  161. MFI_STAT_NOT_IN_ENCL = 0x24,
  162. MFI_STAT_PD_CLEAR_IN_PROGRESS = 0x25,
  163. MFI_STAT_PD_TYPE_WRONG = 0x26,
  164. MFI_STAT_PR_DISABLED = 0x27,
  165. MFI_STAT_ROW_INDEX_INVALID = 0x28,
  166. MFI_STAT_SAS_CONFIG_INVALID_ACTION = 0x29,
  167. MFI_STAT_SAS_CONFIG_INVALID_DATA = 0x2a,
  168. MFI_STAT_SAS_CONFIG_INVALID_PAGE = 0x2b,
  169. MFI_STAT_SAS_CONFIG_INVALID_TYPE = 0x2c,
  170. MFI_STAT_SCSI_DONE_WITH_ERROR = 0x2d,
  171. MFI_STAT_SCSI_IO_FAILED = 0x2e,
  172. MFI_STAT_SCSI_RESERVATION_CONFLICT = 0x2f,
  173. MFI_STAT_SHUTDOWN_FAILED = 0x30,
  174. MFI_STAT_TIME_NOT_SET = 0x31,
  175. MFI_STAT_WRONG_STATE = 0x32,
  176. MFI_STAT_LD_OFFLINE = 0x33,
  177. MFI_STAT_PEER_NOTIFICATION_REJECTED = 0x34,
  178. MFI_STAT_PEER_NOTIFICATION_FAILED = 0x35,
  179. MFI_STAT_RESERVATION_IN_PROGRESS = 0x36,
  180. MFI_STAT_I2C_ERRORS_DETECTED = 0x37,
  181. MFI_STAT_PCI_ERRORS_DETECTED = 0x38,
  182. MFI_STAT_INVALID_STATUS = 0xFF
  183. };
  184. /*
  185. * Number of mailbox bytes in DCMD message frame
  186. */
  187. #define MFI_MBOX_SIZE 12
  188. enum MR_EVT_CLASS {
  189. MR_EVT_CLASS_DEBUG = -2,
  190. MR_EVT_CLASS_PROGRESS = -1,
  191. MR_EVT_CLASS_INFO = 0,
  192. MR_EVT_CLASS_WARNING = 1,
  193. MR_EVT_CLASS_CRITICAL = 2,
  194. MR_EVT_CLASS_FATAL = 3,
  195. MR_EVT_CLASS_DEAD = 4,
  196. };
  197. enum MR_EVT_LOCALE {
  198. MR_EVT_LOCALE_LD = 0x0001,
  199. MR_EVT_LOCALE_PD = 0x0002,
  200. MR_EVT_LOCALE_ENCL = 0x0004,
  201. MR_EVT_LOCALE_BBU = 0x0008,
  202. MR_EVT_LOCALE_SAS = 0x0010,
  203. MR_EVT_LOCALE_CTRL = 0x0020,
  204. MR_EVT_LOCALE_CONFIG = 0x0040,
  205. MR_EVT_LOCALE_CLUSTER = 0x0080,
  206. MR_EVT_LOCALE_ALL = 0xffff,
  207. };
  208. enum MR_EVT_ARGS {
  209. MR_EVT_ARGS_NONE,
  210. MR_EVT_ARGS_CDB_SENSE,
  211. MR_EVT_ARGS_LD,
  212. MR_EVT_ARGS_LD_COUNT,
  213. MR_EVT_ARGS_LD_LBA,
  214. MR_EVT_ARGS_LD_OWNER,
  215. MR_EVT_ARGS_LD_LBA_PD_LBA,
  216. MR_EVT_ARGS_LD_PROG,
  217. MR_EVT_ARGS_LD_STATE,
  218. MR_EVT_ARGS_LD_STRIP,
  219. MR_EVT_ARGS_PD,
  220. MR_EVT_ARGS_PD_ERR,
  221. MR_EVT_ARGS_PD_LBA,
  222. MR_EVT_ARGS_PD_LBA_LD,
  223. MR_EVT_ARGS_PD_PROG,
  224. MR_EVT_ARGS_PD_STATE,
  225. MR_EVT_ARGS_PCI,
  226. MR_EVT_ARGS_RATE,
  227. MR_EVT_ARGS_STR,
  228. MR_EVT_ARGS_TIME,
  229. MR_EVT_ARGS_ECC,
  230. MR_EVT_ARGS_LD_PROP,
  231. MR_EVT_ARGS_PD_SPARE,
  232. MR_EVT_ARGS_PD_INDEX,
  233. MR_EVT_ARGS_DIAG_PASS,
  234. MR_EVT_ARGS_DIAG_FAIL,
  235. MR_EVT_ARGS_PD_LBA_LBA,
  236. MR_EVT_ARGS_PORT_PHY,
  237. MR_EVT_ARGS_PD_MISSING,
  238. MR_EVT_ARGS_PD_ADDRESS,
  239. MR_EVT_ARGS_BITMAP,
  240. MR_EVT_ARGS_CONNECTOR,
  241. MR_EVT_ARGS_PD_PD,
  242. MR_EVT_ARGS_PD_FRU,
  243. MR_EVT_ARGS_PD_PATHINFO,
  244. MR_EVT_ARGS_PD_POWER_STATE,
  245. MR_EVT_ARGS_GENERIC,
  246. };
  247. /*
  248. * define constants for device list query options
  249. */
  250. enum MR_PD_QUERY_TYPE {
  251. MR_PD_QUERY_TYPE_ALL = 0,
  252. MR_PD_QUERY_TYPE_STATE = 1,
  253. MR_PD_QUERY_TYPE_POWER_STATE = 2,
  254. MR_PD_QUERY_TYPE_MEDIA_TYPE = 3,
  255. MR_PD_QUERY_TYPE_SPEED = 4,
  256. MR_PD_QUERY_TYPE_EXPOSED_TO_HOST = 5,
  257. };
  258. enum MR_PD_STATE {
  259. MR_PD_STATE_UNCONFIGURED_GOOD = 0x00,
  260. MR_PD_STATE_UNCONFIGURED_BAD = 0x01,
  261. MR_PD_STATE_HOT_SPARE = 0x02,
  262. MR_PD_STATE_OFFLINE = 0x10,
  263. MR_PD_STATE_FAILED = 0x11,
  264. MR_PD_STATE_REBUILD = 0x14,
  265. MR_PD_STATE_ONLINE = 0x18,
  266. MR_PD_STATE_COPYBACK = 0x20,
  267. MR_PD_STATE_SYSTEM = 0x40,
  268. };
  269. /*
  270. * defines the physical drive address structure
  271. */
  272. struct MR_PD_ADDRESS {
  273. u16 deviceId;
  274. u16 enclDeviceId;
  275. union {
  276. struct {
  277. u8 enclIndex;
  278. u8 slotNumber;
  279. } mrPdAddress;
  280. struct {
  281. u8 enclPosition;
  282. u8 enclConnectorIndex;
  283. } mrEnclAddress;
  284. };
  285. u8 scsiDevType;
  286. union {
  287. u8 connectedPortBitmap;
  288. u8 connectedPortNumbers;
  289. };
  290. u64 sasAddr[2];
  291. } __packed;
  292. /*
  293. * defines the physical drive list structure
  294. */
  295. struct MR_PD_LIST {
  296. u32 size;
  297. u32 count;
  298. struct MR_PD_ADDRESS addr[1];
  299. } __packed;
  300. struct megasas_pd_list {
  301. u16 tid;
  302. u8 driveType;
  303. u8 driveState;
  304. } __packed;
  305. /*
  306. * SAS controller properties
  307. */
  308. struct megasas_ctrl_prop {
  309. u16 seq_num;
  310. u16 pred_fail_poll_interval;
  311. u16 intr_throttle_count;
  312. u16 intr_throttle_timeouts;
  313. u8 rebuild_rate;
  314. u8 patrol_read_rate;
  315. u8 bgi_rate;
  316. u8 cc_rate;
  317. u8 recon_rate;
  318. u8 cache_flush_interval;
  319. u8 spinup_drv_count;
  320. u8 spinup_delay;
  321. u8 cluster_enable;
  322. u8 coercion_mode;
  323. u8 alarm_enable;
  324. u8 disable_auto_rebuild;
  325. u8 disable_battery_warn;
  326. u8 ecc_bucket_size;
  327. u16 ecc_bucket_leak_rate;
  328. u8 restore_hotspare_on_insertion;
  329. u8 expose_encl_devices;
  330. u8 reserved[38];
  331. } __packed;
  332. /*
  333. * SAS controller information
  334. */
  335. struct megasas_ctrl_info {
  336. /*
  337. * PCI device information
  338. */
  339. struct {
  340. u16 vendor_id;
  341. u16 device_id;
  342. u16 sub_vendor_id;
  343. u16 sub_device_id;
  344. u8 reserved[24];
  345. } __attribute__ ((packed)) pci;
  346. /*
  347. * Host interface information
  348. */
  349. struct {
  350. u8 PCIX:1;
  351. u8 PCIE:1;
  352. u8 iSCSI:1;
  353. u8 SAS_3G:1;
  354. u8 reserved_0:4;
  355. u8 reserved_1[6];
  356. u8 port_count;
  357. u64 port_addr[8];
  358. } __attribute__ ((packed)) host_interface;
  359. /*
  360. * Device (backend) interface information
  361. */
  362. struct {
  363. u8 SPI:1;
  364. u8 SAS_3G:1;
  365. u8 SATA_1_5G:1;
  366. u8 SATA_3G:1;
  367. u8 reserved_0:4;
  368. u8 reserved_1[6];
  369. u8 port_count;
  370. u64 port_addr[8];
  371. } __attribute__ ((packed)) device_interface;
  372. /*
  373. * List of components residing in flash. All str are null terminated
  374. */
  375. u32 image_check_word;
  376. u32 image_component_count;
  377. struct {
  378. char name[8];
  379. char version[32];
  380. char build_date[16];
  381. char built_time[16];
  382. } __attribute__ ((packed)) image_component[8];
  383. /*
  384. * List of flash components that have been flashed on the card, but
  385. * are not in use, pending reset of the adapter. This list will be
  386. * empty if a flash operation has not occurred. All stings are null
  387. * terminated
  388. */
  389. u32 pending_image_component_count;
  390. struct {
  391. char name[8];
  392. char version[32];
  393. char build_date[16];
  394. char build_time[16];
  395. } __attribute__ ((packed)) pending_image_component[8];
  396. u8 max_arms;
  397. u8 max_spans;
  398. u8 max_arrays;
  399. u8 max_lds;
  400. char product_name[80];
  401. char serial_no[32];
  402. /*
  403. * Other physical/controller/operation information. Indicates the
  404. * presence of the hardware
  405. */
  406. struct {
  407. u32 bbu:1;
  408. u32 alarm:1;
  409. u32 nvram:1;
  410. u32 uart:1;
  411. u32 reserved:28;
  412. } __attribute__ ((packed)) hw_present;
  413. u32 current_fw_time;
  414. /*
  415. * Maximum data transfer sizes
  416. */
  417. u16 max_concurrent_cmds;
  418. u16 max_sge_count;
  419. u32 max_request_size;
  420. /*
  421. * Logical and physical device counts
  422. */
  423. u16 ld_present_count;
  424. u16 ld_degraded_count;
  425. u16 ld_offline_count;
  426. u16 pd_present_count;
  427. u16 pd_disk_present_count;
  428. u16 pd_disk_pred_failure_count;
  429. u16 pd_disk_failed_count;
  430. /*
  431. * Memory size information
  432. */
  433. u16 nvram_size;
  434. u16 memory_size;
  435. u16 flash_size;
  436. /*
  437. * Error counters
  438. */
  439. u16 mem_correctable_error_count;
  440. u16 mem_uncorrectable_error_count;
  441. /*
  442. * Cluster information
  443. */
  444. u8 cluster_permitted;
  445. u8 cluster_active;
  446. /*
  447. * Additional max data transfer sizes
  448. */
  449. u16 max_strips_per_io;
  450. /*
  451. * Controller capabilities structures
  452. */
  453. struct {
  454. u32 raid_level_0:1;
  455. u32 raid_level_1:1;
  456. u32 raid_level_5:1;
  457. u32 raid_level_1E:1;
  458. u32 raid_level_6:1;
  459. u32 reserved:27;
  460. } __attribute__ ((packed)) raid_levels;
  461. struct {
  462. u32 rbld_rate:1;
  463. u32 cc_rate:1;
  464. u32 bgi_rate:1;
  465. u32 recon_rate:1;
  466. u32 patrol_rate:1;
  467. u32 alarm_control:1;
  468. u32 cluster_supported:1;
  469. u32 bbu:1;
  470. u32 spanning_allowed:1;
  471. u32 dedicated_hotspares:1;
  472. u32 revertible_hotspares:1;
  473. u32 foreign_config_import:1;
  474. u32 self_diagnostic:1;
  475. u32 mixed_redundancy_arr:1;
  476. u32 global_hot_spares:1;
  477. u32 reserved:17;
  478. } __attribute__ ((packed)) adapter_operations;
  479. struct {
  480. u32 read_policy:1;
  481. u32 write_policy:1;
  482. u32 io_policy:1;
  483. u32 access_policy:1;
  484. u32 disk_cache_policy:1;
  485. u32 reserved:27;
  486. } __attribute__ ((packed)) ld_operations;
  487. struct {
  488. u8 min;
  489. u8 max;
  490. u8 reserved[2];
  491. } __attribute__ ((packed)) stripe_sz_ops;
  492. struct {
  493. u32 force_online:1;
  494. u32 force_offline:1;
  495. u32 force_rebuild:1;
  496. u32 reserved:29;
  497. } __attribute__ ((packed)) pd_operations;
  498. struct {
  499. u32 ctrl_supports_sas:1;
  500. u32 ctrl_supports_sata:1;
  501. u32 allow_mix_in_encl:1;
  502. u32 allow_mix_in_ld:1;
  503. u32 allow_sata_in_cluster:1;
  504. u32 reserved:27;
  505. } __attribute__ ((packed)) pd_mix_support;
  506. /*
  507. * Define ECC single-bit-error bucket information
  508. */
  509. u8 ecc_bucket_count;
  510. u8 reserved_2[11];
  511. /*
  512. * Include the controller properties (changeable items)
  513. */
  514. struct megasas_ctrl_prop properties;
  515. /*
  516. * Define FW pkg version (set in envt v'bles on OEM basis)
  517. */
  518. char package_version[0x60];
  519. u8 pad[0x800 - 0x6a0];
  520. } __packed;
  521. /*
  522. * ===============================
  523. * MegaRAID SAS driver definitions
  524. * ===============================
  525. */
  526. #define MEGASAS_MAX_PD_CHANNELS 2
  527. #define MEGASAS_MAX_LD_CHANNELS 2
  528. #define MEGASAS_MAX_CHANNELS (MEGASAS_MAX_PD_CHANNELS + \
  529. MEGASAS_MAX_LD_CHANNELS)
  530. #define MEGASAS_MAX_DEV_PER_CHANNEL 128
  531. #define MEGASAS_DEFAULT_INIT_ID -1
  532. #define MEGASAS_MAX_LUN 8
  533. #define MEGASAS_MAX_LD 64
  534. #define MEGASAS_MAX_PD (MEGASAS_MAX_PD_CHANNELS * \
  535. MEGASAS_MAX_DEV_PER_CHANNEL)
  536. #define MEGASAS_DBG_LVL 1
  537. #define MEGASAS_FW_BUSY 1
  538. /* Frame Type */
  539. #define IO_FRAME 0
  540. #define PTHRU_FRAME 1
  541. /*
  542. * When SCSI mid-layer calls driver's reset routine, driver waits for
  543. * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
  544. * that the driver cannot _actually_ abort or reset pending commands. While
  545. * it is waiting for the commands to complete, it prints a diagnostic message
  546. * every MEGASAS_RESET_NOTICE_INTERVAL seconds
  547. */
  548. #define MEGASAS_RESET_WAIT_TIME 180
  549. #define MEGASAS_INTERNAL_CMD_WAIT_TIME 180
  550. #define MEGASAS_RESET_NOTICE_INTERVAL 5
  551. #define MEGASAS_IOCTL_CMD 0
  552. #define MEGASAS_DEFAULT_CMD_TIMEOUT 90
  553. /*
  554. * FW reports the maximum of number of commands that it can accept (maximum
  555. * commands that can be outstanding) at any time. The driver must report a
  556. * lower number to the mid layer because it can issue a few internal commands
  557. * itself (E.g, AEN, abort cmd, IOCTLs etc). The number of commands it needs
  558. * is shown below
  559. */
  560. #define MEGASAS_INT_CMDS 32
  561. /*
  562. * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
  563. * SGLs based on the size of dma_addr_t
  564. */
  565. #define IS_DMA64 (sizeof(dma_addr_t) == 8)
  566. #define MFI_OB_INTR_STATUS_MASK 0x00000002
  567. #define MFI_POLL_TIMEOUT_SECS 60
  568. #define MEGASAS_COMPLETION_TIMER_INTERVAL (HZ/10)
  569. #define MFI_REPLY_1078_MESSAGE_INTERRUPT 0x80000000
  570. #define MFI_REPLY_GEN2_MESSAGE_INTERRUPT 0x00000001
  571. #define MFI_GEN2_ENABLE_INTERRUPT_MASK (0x00000001 | 0x00000004)
  572. #define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT 0x40000000
  573. #define MFI_SKINNY_ENABLE_INTERRUPT_MASK (0x00000001)
  574. /*
  575. * register set for both 1068 and 1078 controllers
  576. * structure extended for 1078 registers
  577. */
  578. struct megasas_register_set {
  579. u32 reserved_0[4]; /*0000h*/
  580. u32 inbound_msg_0; /*0010h*/
  581. u32 inbound_msg_1; /*0014h*/
  582. u32 outbound_msg_0; /*0018h*/
  583. u32 outbound_msg_1; /*001Ch*/
  584. u32 inbound_doorbell; /*0020h*/
  585. u32 inbound_intr_status; /*0024h*/
  586. u32 inbound_intr_mask; /*0028h*/
  587. u32 outbound_doorbell; /*002Ch*/
  588. u32 outbound_intr_status; /*0030h*/
  589. u32 outbound_intr_mask; /*0034h*/
  590. u32 reserved_1[2]; /*0038h*/
  591. u32 inbound_queue_port; /*0040h*/
  592. u32 outbound_queue_port; /*0044h*/
  593. u32 reserved_2[22]; /*0048h*/
  594. u32 outbound_doorbell_clear; /*00A0h*/
  595. u32 reserved_3[3]; /*00A4h*/
  596. u32 outbound_scratch_pad ; /*00B0h*/
  597. u32 reserved_4[3]; /*00B4h*/
  598. u32 inbound_low_queue_port ; /*00C0h*/
  599. u32 inbound_high_queue_port ; /*00C4h*/
  600. u32 reserved_5; /*00C8h*/
  601. u32 index_registers[820]; /*00CCh*/
  602. } __attribute__ ((packed));
  603. struct megasas_sge32 {
  604. u32 phys_addr;
  605. u32 length;
  606. } __attribute__ ((packed));
  607. struct megasas_sge64 {
  608. u64 phys_addr;
  609. u32 length;
  610. } __attribute__ ((packed));
  611. union megasas_sgl {
  612. struct megasas_sge32 sge32[1];
  613. struct megasas_sge64 sge64[1];
  614. } __attribute__ ((packed));
  615. struct megasas_header {
  616. u8 cmd; /*00h */
  617. u8 sense_len; /*01h */
  618. u8 cmd_status; /*02h */
  619. u8 scsi_status; /*03h */
  620. u8 target_id; /*04h */
  621. u8 lun; /*05h */
  622. u8 cdb_len; /*06h */
  623. u8 sge_count; /*07h */
  624. u32 context; /*08h */
  625. u32 pad_0; /*0Ch */
  626. u16 flags; /*10h */
  627. u16 timeout; /*12h */
  628. u32 data_xferlen; /*14h */
  629. } __attribute__ ((packed));
  630. union megasas_sgl_frame {
  631. struct megasas_sge32 sge32[8];
  632. struct megasas_sge64 sge64[5];
  633. } __attribute__ ((packed));
  634. struct megasas_init_frame {
  635. u8 cmd; /*00h */
  636. u8 reserved_0; /*01h */
  637. u8 cmd_status; /*02h */
  638. u8 reserved_1; /*03h */
  639. u32 reserved_2; /*04h */
  640. u32 context; /*08h */
  641. u32 pad_0; /*0Ch */
  642. u16 flags; /*10h */
  643. u16 reserved_3; /*12h */
  644. u32 data_xfer_len; /*14h */
  645. u32 queue_info_new_phys_addr_lo; /*18h */
  646. u32 queue_info_new_phys_addr_hi; /*1Ch */
  647. u32 queue_info_old_phys_addr_lo; /*20h */
  648. u32 queue_info_old_phys_addr_hi; /*24h */
  649. u32 reserved_4[6]; /*28h */
  650. } __attribute__ ((packed));
  651. struct megasas_init_queue_info {
  652. u32 init_flags; /*00h */
  653. u32 reply_queue_entries; /*04h */
  654. u32 reply_queue_start_phys_addr_lo; /*08h */
  655. u32 reply_queue_start_phys_addr_hi; /*0Ch */
  656. u32 producer_index_phys_addr_lo; /*10h */
  657. u32 producer_index_phys_addr_hi; /*14h */
  658. u32 consumer_index_phys_addr_lo; /*18h */
  659. u32 consumer_index_phys_addr_hi; /*1Ch */
  660. } __attribute__ ((packed));
  661. struct megasas_io_frame {
  662. u8 cmd; /*00h */
  663. u8 sense_len; /*01h */
  664. u8 cmd_status; /*02h */
  665. u8 scsi_status; /*03h */
  666. u8 target_id; /*04h */
  667. u8 access_byte; /*05h */
  668. u8 reserved_0; /*06h */
  669. u8 sge_count; /*07h */
  670. u32 context; /*08h */
  671. u32 pad_0; /*0Ch */
  672. u16 flags; /*10h */
  673. u16 timeout; /*12h */
  674. u32 lba_count; /*14h */
  675. u32 sense_buf_phys_addr_lo; /*18h */
  676. u32 sense_buf_phys_addr_hi; /*1Ch */
  677. u32 start_lba_lo; /*20h */
  678. u32 start_lba_hi; /*24h */
  679. union megasas_sgl sgl; /*28h */
  680. } __attribute__ ((packed));
  681. struct megasas_pthru_frame {
  682. u8 cmd; /*00h */
  683. u8 sense_len; /*01h */
  684. u8 cmd_status; /*02h */
  685. u8 scsi_status; /*03h */
  686. u8 target_id; /*04h */
  687. u8 lun; /*05h */
  688. u8 cdb_len; /*06h */
  689. u8 sge_count; /*07h */
  690. u32 context; /*08h */
  691. u32 pad_0; /*0Ch */
  692. u16 flags; /*10h */
  693. u16 timeout; /*12h */
  694. u32 data_xfer_len; /*14h */
  695. u32 sense_buf_phys_addr_lo; /*18h */
  696. u32 sense_buf_phys_addr_hi; /*1Ch */
  697. u8 cdb[16]; /*20h */
  698. union megasas_sgl sgl; /*30h */
  699. } __attribute__ ((packed));
  700. struct megasas_dcmd_frame {
  701. u8 cmd; /*00h */
  702. u8 reserved_0; /*01h */
  703. u8 cmd_status; /*02h */
  704. u8 reserved_1[4]; /*03h */
  705. u8 sge_count; /*07h */
  706. u32 context; /*08h */
  707. u32 pad_0; /*0Ch */
  708. u16 flags; /*10h */
  709. u16 timeout; /*12h */
  710. u32 data_xfer_len; /*14h */
  711. u32 opcode; /*18h */
  712. union { /*1Ch */
  713. u8 b[12];
  714. u16 s[6];
  715. u32 w[3];
  716. } mbox;
  717. union megasas_sgl sgl; /*28h */
  718. } __attribute__ ((packed));
  719. struct megasas_abort_frame {
  720. u8 cmd; /*00h */
  721. u8 reserved_0; /*01h */
  722. u8 cmd_status; /*02h */
  723. u8 reserved_1; /*03h */
  724. u32 reserved_2; /*04h */
  725. u32 context; /*08h */
  726. u32 pad_0; /*0Ch */
  727. u16 flags; /*10h */
  728. u16 reserved_3; /*12h */
  729. u32 reserved_4; /*14h */
  730. u32 abort_context; /*18h */
  731. u32 pad_1; /*1Ch */
  732. u32 abort_mfi_phys_addr_lo; /*20h */
  733. u32 abort_mfi_phys_addr_hi; /*24h */
  734. u32 reserved_5[6]; /*28h */
  735. } __attribute__ ((packed));
  736. struct megasas_smp_frame {
  737. u8 cmd; /*00h */
  738. u8 reserved_1; /*01h */
  739. u8 cmd_status; /*02h */
  740. u8 connection_status; /*03h */
  741. u8 reserved_2[3]; /*04h */
  742. u8 sge_count; /*07h */
  743. u32 context; /*08h */
  744. u32 pad_0; /*0Ch */
  745. u16 flags; /*10h */
  746. u16 timeout; /*12h */
  747. u32 data_xfer_len; /*14h */
  748. u64 sas_addr; /*18h */
  749. union {
  750. struct megasas_sge32 sge32[2]; /* [0]: resp [1]: req */
  751. struct megasas_sge64 sge64[2]; /* [0]: resp [1]: req */
  752. } sgl;
  753. } __attribute__ ((packed));
  754. struct megasas_stp_frame {
  755. u8 cmd; /*00h */
  756. u8 reserved_1; /*01h */
  757. u8 cmd_status; /*02h */
  758. u8 reserved_2; /*03h */
  759. u8 target_id; /*04h */
  760. u8 reserved_3[2]; /*05h */
  761. u8 sge_count; /*07h */
  762. u32 context; /*08h */
  763. u32 pad_0; /*0Ch */
  764. u16 flags; /*10h */
  765. u16 timeout; /*12h */
  766. u32 data_xfer_len; /*14h */
  767. u16 fis[10]; /*18h */
  768. u32 stp_flags;
  769. union {
  770. struct megasas_sge32 sge32[2]; /* [0]: resp [1]: data */
  771. struct megasas_sge64 sge64[2]; /* [0]: resp [1]: data */
  772. } sgl;
  773. } __attribute__ ((packed));
  774. union megasas_frame {
  775. struct megasas_header hdr;
  776. struct megasas_init_frame init;
  777. struct megasas_io_frame io;
  778. struct megasas_pthru_frame pthru;
  779. struct megasas_dcmd_frame dcmd;
  780. struct megasas_abort_frame abort;
  781. struct megasas_smp_frame smp;
  782. struct megasas_stp_frame stp;
  783. u8 raw_bytes[64];
  784. };
  785. struct megasas_cmd;
  786. union megasas_evt_class_locale {
  787. struct {
  788. u16 locale;
  789. u8 reserved;
  790. s8 class;
  791. } __attribute__ ((packed)) members;
  792. u32 word;
  793. } __attribute__ ((packed));
  794. struct megasas_evt_log_info {
  795. u32 newest_seq_num;
  796. u32 oldest_seq_num;
  797. u32 clear_seq_num;
  798. u32 shutdown_seq_num;
  799. u32 boot_seq_num;
  800. } __attribute__ ((packed));
  801. struct megasas_progress {
  802. u16 progress;
  803. u16 elapsed_seconds;
  804. } __attribute__ ((packed));
  805. struct megasas_evtarg_ld {
  806. u16 target_id;
  807. u8 ld_index;
  808. u8 reserved;
  809. } __attribute__ ((packed));
  810. struct megasas_evtarg_pd {
  811. u16 device_id;
  812. u8 encl_index;
  813. u8 slot_number;
  814. } __attribute__ ((packed));
  815. struct megasas_evt_detail {
  816. u32 seq_num;
  817. u32 time_stamp;
  818. u32 code;
  819. union megasas_evt_class_locale cl;
  820. u8 arg_type;
  821. u8 reserved1[15];
  822. union {
  823. struct {
  824. struct megasas_evtarg_pd pd;
  825. u8 cdb_length;
  826. u8 sense_length;
  827. u8 reserved[2];
  828. u8 cdb[16];
  829. u8 sense[64];
  830. } __attribute__ ((packed)) cdbSense;
  831. struct megasas_evtarg_ld ld;
  832. struct {
  833. struct megasas_evtarg_ld ld;
  834. u64 count;
  835. } __attribute__ ((packed)) ld_count;
  836. struct {
  837. u64 lba;
  838. struct megasas_evtarg_ld ld;
  839. } __attribute__ ((packed)) ld_lba;
  840. struct {
  841. struct megasas_evtarg_ld ld;
  842. u32 prevOwner;
  843. u32 newOwner;
  844. } __attribute__ ((packed)) ld_owner;
  845. struct {
  846. u64 ld_lba;
  847. u64 pd_lba;
  848. struct megasas_evtarg_ld ld;
  849. struct megasas_evtarg_pd pd;
  850. } __attribute__ ((packed)) ld_lba_pd_lba;
  851. struct {
  852. struct megasas_evtarg_ld ld;
  853. struct megasas_progress prog;
  854. } __attribute__ ((packed)) ld_prog;
  855. struct {
  856. struct megasas_evtarg_ld ld;
  857. u32 prev_state;
  858. u32 new_state;
  859. } __attribute__ ((packed)) ld_state;
  860. struct {
  861. u64 strip;
  862. struct megasas_evtarg_ld ld;
  863. } __attribute__ ((packed)) ld_strip;
  864. struct megasas_evtarg_pd pd;
  865. struct {
  866. struct megasas_evtarg_pd pd;
  867. u32 err;
  868. } __attribute__ ((packed)) pd_err;
  869. struct {
  870. u64 lba;
  871. struct megasas_evtarg_pd pd;
  872. } __attribute__ ((packed)) pd_lba;
  873. struct {
  874. u64 lba;
  875. struct megasas_evtarg_pd pd;
  876. struct megasas_evtarg_ld ld;
  877. } __attribute__ ((packed)) pd_lba_ld;
  878. struct {
  879. struct megasas_evtarg_pd pd;
  880. struct megasas_progress prog;
  881. } __attribute__ ((packed)) pd_prog;
  882. struct {
  883. struct megasas_evtarg_pd pd;
  884. u32 prevState;
  885. u32 newState;
  886. } __attribute__ ((packed)) pd_state;
  887. struct {
  888. u16 vendorId;
  889. u16 deviceId;
  890. u16 subVendorId;
  891. u16 subDeviceId;
  892. } __attribute__ ((packed)) pci;
  893. u32 rate;
  894. char str[96];
  895. struct {
  896. u32 rtc;
  897. u32 elapsedSeconds;
  898. } __attribute__ ((packed)) time;
  899. struct {
  900. u32 ecar;
  901. u32 elog;
  902. char str[64];
  903. } __attribute__ ((packed)) ecc;
  904. u8 b[96];
  905. u16 s[48];
  906. u32 w[24];
  907. u64 d[12];
  908. } args;
  909. char description[128];
  910. } __attribute__ ((packed));
  911. struct megasas_instance_template {
  912. void (*fire_cmd)(dma_addr_t ,u32 ,struct megasas_register_set __iomem *);
  913. void (*enable_intr)(struct megasas_register_set __iomem *) ;
  914. void (*disable_intr)(struct megasas_register_set __iomem *);
  915. int (*clear_intr)(struct megasas_register_set __iomem *);
  916. u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
  917. };
  918. struct megasas_instance {
  919. u32 *producer;
  920. dma_addr_t producer_h;
  921. u32 *consumer;
  922. dma_addr_t consumer_h;
  923. u32 *reply_queue;
  924. dma_addr_t reply_queue_h;
  925. unsigned long base_addr;
  926. struct megasas_register_set __iomem *reg_set;
  927. struct megasas_pd_list pd_list[MEGASAS_MAX_PD];
  928. s8 init_id;
  929. u16 max_num_sge;
  930. u16 max_fw_cmds;
  931. u32 max_sectors_per_req;
  932. struct megasas_cmd **cmd_list;
  933. struct list_head cmd_pool;
  934. spinlock_t cmd_pool_lock;
  935. /* used to synch producer, consumer ptrs in dpc */
  936. spinlock_t completion_lock;
  937. struct dma_pool *frame_dma_pool;
  938. struct dma_pool *sense_dma_pool;
  939. struct megasas_evt_detail *evt_detail;
  940. dma_addr_t evt_detail_h;
  941. struct megasas_cmd *aen_cmd;
  942. struct mutex aen_mutex;
  943. struct semaphore ioctl_sem;
  944. struct Scsi_Host *host;
  945. wait_queue_head_t int_cmd_wait_q;
  946. wait_queue_head_t abort_cmd_wait_q;
  947. struct pci_dev *pdev;
  948. u32 unique_id;
  949. atomic_t fw_outstanding;
  950. u32 hw_crit_error;
  951. struct megasas_instance_template *instancet;
  952. struct tasklet_struct isr_tasklet;
  953. u8 flag;
  954. u8 unload;
  955. unsigned long last_time;
  956. struct timer_list io_completion_timer;
  957. };
  958. #define MEGASAS_IS_LOGICAL(scp) \
  959. (scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1
  960. #define MEGASAS_DEV_INDEX(inst, scp) \
  961. ((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \
  962. scp->device->id
  963. struct megasas_cmd {
  964. union megasas_frame *frame;
  965. dma_addr_t frame_phys_addr;
  966. u8 *sense;
  967. dma_addr_t sense_phys_addr;
  968. u32 index;
  969. u8 sync_cmd;
  970. u8 cmd_status;
  971. u16 abort_aen;
  972. struct list_head list;
  973. struct scsi_cmnd *scmd;
  974. struct megasas_instance *instance;
  975. u32 frame_count;
  976. };
  977. #define MAX_MGMT_ADAPTERS 1024
  978. #define MAX_IOCTL_SGE 16
  979. struct megasas_iocpacket {
  980. u16 host_no;
  981. u16 __pad1;
  982. u32 sgl_off;
  983. u32 sge_count;
  984. u32 sense_off;
  985. u32 sense_len;
  986. union {
  987. u8 raw[128];
  988. struct megasas_header hdr;
  989. } frame;
  990. struct iovec sgl[MAX_IOCTL_SGE];
  991. } __attribute__ ((packed));
  992. struct megasas_aen {
  993. u16 host_no;
  994. u16 __pad1;
  995. u32 seq_num;
  996. u32 class_locale_word;
  997. } __attribute__ ((packed));
  998. #ifdef CONFIG_COMPAT
  999. struct compat_megasas_iocpacket {
  1000. u16 host_no;
  1001. u16 __pad1;
  1002. u32 sgl_off;
  1003. u32 sge_count;
  1004. u32 sense_off;
  1005. u32 sense_len;
  1006. union {
  1007. u8 raw[128];
  1008. struct megasas_header hdr;
  1009. } frame;
  1010. struct compat_iovec sgl[MAX_IOCTL_SGE];
  1011. } __attribute__ ((packed));
  1012. #define MEGASAS_IOC_FIRMWARE32 _IOWR('M', 1, struct compat_megasas_iocpacket)
  1013. #endif
  1014. #define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket)
  1015. #define MEGASAS_IOC_GET_AEN _IOW('M', 3, struct megasas_aen)
  1016. struct megasas_mgmt_info {
  1017. u16 count;
  1018. struct megasas_instance *instance[MAX_MGMT_ADAPTERS];
  1019. int max_index;
  1020. };
  1021. #endif /*LSI_MEGARAID_SAS_H */