mpt2sas_base.h 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  1. /*
  2. * This is the Fusion MPT base driver providing common API layer interface
  3. * for access to MPT (Message Passing Technology) firmware.
  4. *
  5. * This code is based on drivers/scsi/mpt2sas/mpt2_base.h
  6. * Copyright (C) 2007-2010 LSI Corporation
  7. * (mailto:DL-MPTFusionLinux@lsi.com)
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (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. * NO WARRANTY
  20. * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
  21. * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
  22. * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  23. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
  24. * solely responsible for determining the appropriateness of using and
  25. * distributing the Program and assumes all risks associated with its
  26. * exercise of rights under this Agreement, including but not limited to
  27. * the risks and costs of program errors, damage to or loss of data,
  28. * programs or equipment, and unavailability or interruption of operations.
  29. * DISCLAIMER OF LIABILITY
  30. * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
  31. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
  33. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  34. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  35. * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
  36. * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
  37. * You should have received a copy of the GNU General Public License
  38. * along with this program; if not, write to the Free Software
  39. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  40. * USA.
  41. */
  42. #ifndef MPT2SAS_BASE_H_INCLUDED
  43. #define MPT2SAS_BASE_H_INCLUDED
  44. #include "mpi/mpi2_type.h"
  45. #include "mpi/mpi2.h"
  46. #include "mpi/mpi2_ioc.h"
  47. #include "mpi/mpi2_cnfg.h"
  48. #include "mpi/mpi2_init.h"
  49. #include "mpi/mpi2_raid.h"
  50. #include "mpi/mpi2_tool.h"
  51. #include "mpi/mpi2_sas.h"
  52. #include <scsi/scsi.h>
  53. #include <scsi/scsi_cmnd.h>
  54. #include <scsi/scsi_device.h>
  55. #include <scsi/scsi_host.h>
  56. #include <scsi/scsi_tcq.h>
  57. #include <scsi/scsi_transport_sas.h>
  58. #include <scsi/scsi_dbg.h>
  59. #include <scsi/scsi_eh.h>
  60. #include "mpt2sas_debug.h"
  61. /* driver versioning info */
  62. #define MPT2SAS_DRIVER_NAME "mpt2sas"
  63. #define MPT2SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>"
  64. #define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver"
  65. #define MPT2SAS_DRIVER_VERSION "12.100.00.00"
  66. #define MPT2SAS_MAJOR_VERSION 12
  67. #define MPT2SAS_MINOR_VERSION 100
  68. #define MPT2SAS_BUILD_VERSION 00
  69. #define MPT2SAS_RELEASE_VERSION 00
  70. /*
  71. * Set MPT2SAS_SG_DEPTH value based on user input.
  72. */
  73. #ifdef CONFIG_SCSI_MPT2SAS_MAX_SGE
  74. #if CONFIG_SCSI_MPT2SAS_MAX_SGE < 16
  75. #define MPT2SAS_SG_DEPTH 16
  76. #elif CONFIG_SCSI_MPT2SAS_MAX_SGE > 128
  77. #define MPT2SAS_SG_DEPTH 128
  78. #else
  79. #define MPT2SAS_SG_DEPTH CONFIG_SCSI_MPT2SAS_MAX_SGE
  80. #endif
  81. #else
  82. #define MPT2SAS_SG_DEPTH 128 /* MAX_HW_SEGMENTS */
  83. #endif
  84. /*
  85. * Generic Defines
  86. */
  87. #define MPT2SAS_SATA_QUEUE_DEPTH 32
  88. #define MPT2SAS_SAS_QUEUE_DEPTH 254
  89. #define MPT2SAS_RAID_QUEUE_DEPTH 128
  90. #define MPT_NAME_LENGTH 32 /* generic length of strings */
  91. #define MPT_STRING_LENGTH 64
  92. #define MPT_MAX_CALLBACKS 16
  93. #define CAN_SLEEP 1
  94. #define NO_SLEEP 0
  95. #define INTERNAL_CMDS_COUNT 10 /* reserved cmds */
  96. #define MPI2_HIM_MASK 0xFFFFFFFF /* mask every bit*/
  97. #define MPT2SAS_INVALID_DEVICE_HANDLE 0xFFFF
  98. /*
  99. * reset phases
  100. */
  101. #define MPT2_IOC_PRE_RESET 1 /* prior to host reset */
  102. #define MPT2_IOC_AFTER_RESET 2 /* just after host reset */
  103. #define MPT2_IOC_DONE_RESET 3 /* links re-initialized */
  104. /*
  105. * logging format
  106. */
  107. #define MPT2SAS_FMT "%s: "
  108. #define MPT2SAS_INFO_FMT KERN_INFO MPT2SAS_FMT
  109. #define MPT2SAS_NOTE_FMT KERN_NOTICE MPT2SAS_FMT
  110. #define MPT2SAS_WARN_FMT KERN_WARNING MPT2SAS_FMT
  111. #define MPT2SAS_ERR_FMT KERN_ERR MPT2SAS_FMT
  112. /*
  113. * Dell HBA branding
  114. */
  115. #define MPT2SAS_DELL_BRANDING_SIZE 32
  116. #define MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING "Dell 6Gbps SAS HBA"
  117. #define MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING "Dell PERC H200 Adapter"
  118. #define MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING "Dell PERC H200 Integrated"
  119. #define MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING "Dell PERC H200 Modular"
  120. #define MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING "Dell PERC H200 Embedded"
  121. #define MPT2SAS_DELL_PERC_H200_BRANDING "Dell PERC H200"
  122. #define MPT2SAS_DELL_6GBPS_SAS_BRANDING "Dell 6Gbps SAS"
  123. /*
  124. * Dell HBA SSDIDs
  125. */
  126. #define MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID 0x1F1C
  127. #define MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID 0x1F1D
  128. #define MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID 0x1F1E
  129. #define MPT2SAS_DELL_PERC_H200_MODULAR_SSDID 0x1F1F
  130. #define MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID 0x1F20
  131. #define MPT2SAS_DELL_PERC_H200_SSDID 0x1F21
  132. #define MPT2SAS_DELL_6GBPS_SAS_SSDID 0x1F22
  133. /*
  134. * Intel HBA branding
  135. */
  136. #define MPT2SAS_INTEL_RMS25JB080_BRANDING \
  137. "Intel(R) Integrated RAID Module RMS25JB080"
  138. #define MPT2SAS_INTEL_RMS25JB040_BRANDING \
  139. "Intel(R) Integrated RAID Module RMS25JB040"
  140. #define MPT2SAS_INTEL_RMS25KB080_BRANDING \
  141. "Intel(R) Integrated RAID Module RMS25KB080"
  142. #define MPT2SAS_INTEL_RMS25KB040_BRANDING \
  143. "Intel(R) Integrated RAID Module RMS25KB040"
  144. #define MPT2SAS_INTEL_RMS2LL080_BRANDING \
  145. "Intel Integrated RAID Module RMS2LL080"
  146. #define MPT2SAS_INTEL_RMS2LL040_BRANDING \
  147. "Intel Integrated RAID Module RMS2LL040"
  148. #define MPT2SAS_INTEL_RS25GB008_BRANDING \
  149. "Intel(R) RAID Controller RS25GB008"
  150. #define MPT2SAS_INTEL_RAMSDALE_BRANDING \
  151. "Intel 720 Series SSD"
  152. /*
  153. * Intel HBA SSDIDs
  154. */
  155. #define MPT2SAS_INTEL_RMS25JB080_SSDID 0x3516
  156. #define MPT2SAS_INTEL_RMS25JB040_SSDID 0x3517
  157. #define MPT2SAS_INTEL_RMS25KB080_SSDID 0x3518
  158. #define MPT2SAS_INTEL_RMS25KB040_SSDID 0x3519
  159. #define MPT2SAS_INTEL_RMS2LL080_SSDID 0x350E
  160. #define MPT2SAS_INTEL_RMS2LL040_SSDID 0x350F
  161. #define MPT2SAS_INTEL_RS25GB008_SSDID 0x3000
  162. #define MPT2SAS_INTEL_RAMSDALE_SSDID 0x3700
  163. /*
  164. * HP HBA branding
  165. */
  166. #define MPT2SAS_HP_3PAR_SSVID 0x1590
  167. #define MPT2SAS_HP_2_4_INTERNAL_BRANDING "HP H220 Host Bus Adapter"
  168. #define MPT2SAS_HP_2_4_EXTERNAL_BRANDING "HP H221 Host Bus Adapter"
  169. #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING "HP H222 Host Bus Adapter"
  170. #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING "HP H220i Host Bus Adapter"
  171. #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING "HP H210i Host Bus Adapter"
  172. /*
  173. * HO HBA SSDIDs
  174. */
  175. #define MPT2SAS_HP_2_4_INTERNAL_SSDID 0x0041
  176. #define MPT2SAS_HP_2_4_EXTERNAL_SSDID 0x0042
  177. #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_SSDID 0x0043
  178. #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_SSDID 0x0044
  179. #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_SSDID 0x0046
  180. /*
  181. * WarpDrive Specific Log codes
  182. */
  183. #define MPT2_WARPDRIVE_LOGENTRY (0x8002)
  184. #define MPT2_WARPDRIVE_LC_SSDT (0x41)
  185. #define MPT2_WARPDRIVE_LC_SSDLW (0x43)
  186. #define MPT2_WARPDRIVE_LC_SSDLF (0x44)
  187. #define MPT2_WARPDRIVE_LC_BRMF (0x4D)
  188. /*
  189. * per target private data
  190. */
  191. #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01
  192. #define MPT_TARGET_FLAGS_VOLUME 0x02
  193. #define MPT_TARGET_FLAGS_DELETED 0x04
  194. /**
  195. * struct MPT2SAS_TARGET - starget private hostdata
  196. * @starget: starget object
  197. * @sas_address: target sas address
  198. * @raid_device: raid_device pointer to access volume data
  199. * @handle: device handle
  200. * @num_luns: number luns
  201. * @flags: MPT_TARGET_FLAGS_XXX flags
  202. * @deleted: target flaged for deletion
  203. * @tm_busy: target is busy with TM request.
  204. */
  205. struct MPT2SAS_TARGET {
  206. struct scsi_target *starget;
  207. u64 sas_address;
  208. struct _raid_device *raid_device;
  209. u16 handle;
  210. int num_luns;
  211. u32 flags;
  212. u8 deleted;
  213. u8 tm_busy;
  214. };
  215. /*
  216. * per device private data
  217. */
  218. #define MPT_DEVICE_FLAGS_INIT 0x01
  219. #define MPT_DEVICE_TLR_ON 0x02
  220. /**
  221. * struct MPT2SAS_DEVICE - sdev private hostdata
  222. * @sas_target: starget private hostdata
  223. * @lun: lun number
  224. * @flags: MPT_DEVICE_XXX flags
  225. * @configured_lun: lun is configured
  226. * @block: device is in SDEV_BLOCK state
  227. * @tlr_snoop_check: flag used in determining whether to disable TLR
  228. */
  229. /* OEM Identifiers */
  230. #define MFG10_OEM_ID_INVALID (0x00000000)
  231. #define MFG10_OEM_ID_DELL (0x00000001)
  232. #define MFG10_OEM_ID_FSC (0x00000002)
  233. #define MFG10_OEM_ID_SUN (0x00000003)
  234. #define MFG10_OEM_ID_IBM (0x00000004)
  235. /* GENERIC Flags 0*/
  236. #define MFG10_GF0_OCE_DISABLED (0x00000001)
  237. #define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002)
  238. #define MFG10_GF0_R10_DISPLAY (0x00000004)
  239. #define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008)
  240. #define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010)
  241. /* OEM Specific Flags will come from OEM specific header files */
  242. typedef struct _MPI2_CONFIG_PAGE_MAN_10 {
  243. MPI2_CONFIG_PAGE_HEADER Header; /* 00h */
  244. U8 OEMIdentifier; /* 04h */
  245. U8 Reserved1; /* 05h */
  246. U16 Reserved2; /* 08h */
  247. U32 Reserved3; /* 0Ch */
  248. U32 GenericFlags0; /* 10h */
  249. U32 GenericFlags1; /* 14h */
  250. U32 Reserved4; /* 18h */
  251. U32 OEMSpecificFlags0; /* 1Ch */
  252. U32 OEMSpecificFlags1; /* 20h */
  253. U32 Reserved5[18]; /* 24h-60h*/
  254. } MPI2_CONFIG_PAGE_MAN_10,
  255. MPI2_POINTER PTR_MPI2_CONFIG_PAGE_MAN_10,
  256. Mpi2ManufacturingPage10_t, MPI2_POINTER pMpi2ManufacturingPage10_t;
  257. #define MFG_PAGE10_HIDE_SSDS_MASK (0x00000003)
  258. #define MFG_PAGE10_HIDE_ALL_DISKS (0x00)
  259. #define MFG_PAGE10_EXPOSE_ALL_DISKS (0x01)
  260. #define MFG_PAGE10_HIDE_IF_VOL_PRESENT (0x02)
  261. struct MPT2SAS_DEVICE {
  262. struct MPT2SAS_TARGET *sas_target;
  263. unsigned int lun;
  264. u32 flags;
  265. u8 configured_lun;
  266. u8 block;
  267. u8 tlr_snoop_check;
  268. };
  269. #define MPT2_CMD_NOT_USED 0x8000 /* free */
  270. #define MPT2_CMD_COMPLETE 0x0001 /* completed */
  271. #define MPT2_CMD_PENDING 0x0002 /* pending */
  272. #define MPT2_CMD_REPLY_VALID 0x0004 /* reply is valid */
  273. #define MPT2_CMD_RESET 0x0008 /* host reset dropped the command */
  274. /**
  275. * struct _internal_cmd - internal commands struct
  276. * @mutex: mutex
  277. * @done: completion
  278. * @reply: reply message pointer
  279. * @sense: sense data
  280. * @status: MPT2_CMD_XXX status
  281. * @smid: system message id
  282. */
  283. struct _internal_cmd {
  284. struct mutex mutex;
  285. struct completion done;
  286. void *reply;
  287. void *sense;
  288. u16 status;
  289. u16 smid;
  290. };
  291. /**
  292. * struct _sas_device - attached device information
  293. * @list: sas device list
  294. * @starget: starget object
  295. * @sas_address: device sas address
  296. * @device_name: retrieved from the SAS IDENTIFY frame.
  297. * @handle: device handle
  298. * @sas_address_parent: sas address of parent expander or sas host
  299. * @enclosure_handle: enclosure handle
  300. * @enclosure_logical_id: enclosure logical identifier
  301. * @volume_handle: volume handle (valid when hidden raid member)
  302. * @volume_wwid: volume unique identifier
  303. * @device_info: bitfield provides detailed info about the device
  304. * @id: target id
  305. * @channel: target channel
  306. * @slot: number number
  307. * @phy: phy identifier provided in sas device page 0
  308. * @responding: used in _scsih_sas_device_mark_responding
  309. */
  310. struct _sas_device {
  311. struct list_head list;
  312. struct scsi_target *starget;
  313. u64 sas_address;
  314. u64 device_name;
  315. u16 handle;
  316. u64 sas_address_parent;
  317. u16 enclosure_handle;
  318. u64 enclosure_logical_id;
  319. u16 volume_handle;
  320. u64 volume_wwid;
  321. u32 device_info;
  322. int id;
  323. int channel;
  324. u16 slot;
  325. u8 phy;
  326. u8 responding;
  327. };
  328. /**
  329. * struct _raid_device - raid volume link list
  330. * @list: sas device list
  331. * @starget: starget object
  332. * @sdev: scsi device struct (volumes are single lun)
  333. * @wwid: unique identifier for the volume
  334. * @handle: device handle
  335. * @block_size: Block size of the volume
  336. * @id: target id
  337. * @channel: target channel
  338. * @volume_type: the raid level
  339. * @device_info: bitfield provides detailed info about the hidden components
  340. * @num_pds: number of hidden raid components
  341. * @responding: used in _scsih_raid_device_mark_responding
  342. * @percent_complete: resync percent complete
  343. * @direct_io_enabled: Whether direct io to PDs are allowed or not
  344. * @stripe_exponent: X where 2powX is the stripe sz in blocks
  345. * @block_exponent: X where 2powX is the block sz in bytes
  346. * @max_lba: Maximum number of LBA in the volume
  347. * @stripe_sz: Stripe Size of the volume
  348. * @device_info: Device info of the volume member disk
  349. * @pd_handle: Array of handles of the physical drives for direct I/O in le16
  350. */
  351. #define MPT_MAX_WARPDRIVE_PDS 8
  352. struct _raid_device {
  353. struct list_head list;
  354. struct scsi_target *starget;
  355. struct scsi_device *sdev;
  356. u64 wwid;
  357. u16 handle;
  358. u16 block_sz;
  359. int id;
  360. int channel;
  361. u8 volume_type;
  362. u8 num_pds;
  363. u8 responding;
  364. u8 percent_complete;
  365. u8 direct_io_enabled;
  366. u8 stripe_exponent;
  367. u8 block_exponent;
  368. u64 max_lba;
  369. u32 stripe_sz;
  370. u32 device_info;
  371. u16 pd_handle[MPT_MAX_WARPDRIVE_PDS];
  372. };
  373. /**
  374. * struct _boot_device - boot device info
  375. * @is_raid: flag to indicate whether this is volume
  376. * @device: holds pointer for either struct _sas_device or
  377. * struct _raid_device
  378. */
  379. struct _boot_device {
  380. u8 is_raid;
  381. void *device;
  382. };
  383. /**
  384. * struct _sas_port - wide/narrow sas port information
  385. * @port_list: list of ports belonging to expander
  386. * @num_phys: number of phys belonging to this port
  387. * @remote_identify: attached device identification
  388. * @rphy: sas transport rphy object
  389. * @port: sas transport wide/narrow port object
  390. * @phy_list: _sas_phy list objects belonging to this port
  391. */
  392. struct _sas_port {
  393. struct list_head port_list;
  394. u8 num_phys;
  395. struct sas_identify remote_identify;
  396. struct sas_rphy *rphy;
  397. struct sas_port *port;
  398. struct list_head phy_list;
  399. };
  400. /**
  401. * struct _sas_phy - phy information
  402. * @port_siblings: list of phys belonging to a port
  403. * @identify: phy identification
  404. * @remote_identify: attached device identification
  405. * @phy: sas transport phy object
  406. * @phy_id: unique phy id
  407. * @handle: device handle for this phy
  408. * @attached_handle: device handle for attached device
  409. * @phy_belongs_to_port: port has been created for this phy
  410. */
  411. struct _sas_phy {
  412. struct list_head port_siblings;
  413. struct sas_identify identify;
  414. struct sas_identify remote_identify;
  415. struct sas_phy *phy;
  416. u8 phy_id;
  417. u16 handle;
  418. u16 attached_handle;
  419. u8 phy_belongs_to_port;
  420. };
  421. /**
  422. * struct _sas_node - sas_host/expander information
  423. * @list: list of expanders
  424. * @parent_dev: parent device class
  425. * @num_phys: number phys belonging to this sas_host/expander
  426. * @sas_address: sas address of this sas_host/expander
  427. * @handle: handle for this sas_host/expander
  428. * @sas_address_parent: sas address of parent expander or sas host
  429. * @enclosure_handle: handle for this a member of an enclosure
  430. * @device_info: bitwise defining capabilities of this sas_host/expander
  431. * @responding: used in _scsih_expander_device_mark_responding
  432. * @phy: a list of phys that make up this sas_host/expander
  433. * @sas_port_list: list of ports attached to this sas_host/expander
  434. */
  435. struct _sas_node {
  436. struct list_head list;
  437. struct device *parent_dev;
  438. u8 num_phys;
  439. u64 sas_address;
  440. u16 handle;
  441. u64 sas_address_parent;
  442. u16 enclosure_handle;
  443. u64 enclosure_logical_id;
  444. u8 responding;
  445. struct _sas_phy *phy;
  446. struct list_head sas_port_list;
  447. };
  448. /**
  449. * enum reset_type - reset state
  450. * @FORCE_BIG_HAMMER: issue diagnostic reset
  451. * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
  452. */
  453. enum reset_type {
  454. FORCE_BIG_HAMMER,
  455. SOFT_RESET,
  456. };
  457. /**
  458. * struct chain_tracker - firmware chain tracker
  459. * @chain_buffer: chain buffer
  460. * @chain_buffer_dma: physical address
  461. * @tracker_list: list of free request (ioc->free_chain_list)
  462. */
  463. struct chain_tracker {
  464. void *chain_buffer;
  465. dma_addr_t chain_buffer_dma;
  466. struct list_head tracker_list;
  467. };
  468. /**
  469. * struct scsiio_tracker - scsi mf request tracker
  470. * @smid: system message id
  471. * @scmd: scsi request pointer
  472. * @cb_idx: callback index
  473. * @direct_io: To indicate whether I/O is direct (WARPDRIVE)
  474. * @chain_list: list of chains associated to this IO
  475. * @tracker_list: list of free request (ioc->free_list)
  476. */
  477. struct scsiio_tracker {
  478. u16 smid;
  479. struct scsi_cmnd *scmd;
  480. u8 cb_idx;
  481. u8 direct_io;
  482. struct list_head chain_list;
  483. struct list_head tracker_list;
  484. };
  485. /**
  486. * struct request_tracker - firmware request tracker
  487. * @smid: system message id
  488. * @cb_idx: callback index
  489. * @tracker_list: list of free request (ioc->free_list)
  490. */
  491. struct request_tracker {
  492. u16 smid;
  493. u8 cb_idx;
  494. struct list_head tracker_list;
  495. };
  496. /**
  497. * struct _tr_list - target reset list
  498. * @handle: device handle
  499. * @state: state machine
  500. */
  501. struct _tr_list {
  502. struct list_head list;
  503. u16 handle;
  504. u16 state;
  505. };
  506. typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
  507. /**
  508. * struct adapter_reply_queue - the reply queue struct
  509. * @ioc: per adapter object
  510. * @msix_index: msix index into vector table
  511. * @vector: irq vector
  512. * @reply_post_host_index: head index in the pool where FW completes IO
  513. * @reply_post_free: reply post base virt address
  514. * @name: the name registered to request_irq()
  515. * @busy: isr is actively processing replies on another cpu
  516. * @list: this list
  517. */
  518. struct adapter_reply_queue {
  519. struct MPT2SAS_ADAPTER *ioc;
  520. u8 msix_index;
  521. unsigned int vector;
  522. u32 reply_post_host_index;
  523. Mpi2ReplyDescriptorsUnion_t *reply_post_free;
  524. char name[MPT_NAME_LENGTH];
  525. atomic_t busy;
  526. struct list_head list;
  527. };
  528. /* IOC Facts and Port Facts converted from little endian to cpu */
  529. union mpi2_version_union {
  530. MPI2_VERSION_STRUCT Struct;
  531. u32 Word;
  532. };
  533. struct mpt2sas_facts {
  534. u16 MsgVersion;
  535. u16 HeaderVersion;
  536. u8 IOCNumber;
  537. u8 VP_ID;
  538. u8 VF_ID;
  539. u16 IOCExceptions;
  540. u16 IOCStatus;
  541. u32 IOCLogInfo;
  542. u8 MaxChainDepth;
  543. u8 WhoInit;
  544. u8 NumberOfPorts;
  545. u8 MaxMSIxVectors;
  546. u16 RequestCredit;
  547. u16 ProductID;
  548. u32 IOCCapabilities;
  549. union mpi2_version_union FWVersion;
  550. u16 IOCRequestFrameSize;
  551. u16 Reserved3;
  552. u16 MaxInitiators;
  553. u16 MaxTargets;
  554. u16 MaxSasExpanders;
  555. u16 MaxEnclosures;
  556. u16 ProtocolFlags;
  557. u16 HighPriorityCredit;
  558. u16 MaxReplyDescriptorPostQueueDepth;
  559. u8 ReplyFrameSize;
  560. u8 MaxVolumes;
  561. u16 MaxDevHandle;
  562. u16 MaxPersistentEntries;
  563. u16 MinDevHandle;
  564. };
  565. struct mpt2sas_port_facts {
  566. u8 PortNumber;
  567. u8 VP_ID;
  568. u8 VF_ID;
  569. u8 PortType;
  570. u16 MaxPostedCmdBuffers;
  571. };
  572. /**
  573. * enum mutex_type - task management mutex type
  574. * @TM_MUTEX_OFF: mutex is not required becuase calling function is acquiring it
  575. * @TM_MUTEX_ON: mutex is required
  576. */
  577. enum mutex_type {
  578. TM_MUTEX_OFF = 0,
  579. TM_MUTEX_ON = 1,
  580. };
  581. typedef void (*MPT2SAS_FLUSH_RUNNING_CMDS)(struct MPT2SAS_ADAPTER *ioc);
  582. /**
  583. * struct MPT2SAS_ADAPTER - per adapter struct
  584. * @list: ioc_list
  585. * @shost: shost object
  586. * @id: unique adapter id
  587. * @cpu_count: number online cpus
  588. * @name: generic ioc string
  589. * @tmp_string: tmp string used for logging
  590. * @pdev: pci pdev object
  591. * @chip: memory mapped register space
  592. * @chip_phys: physical addrss prior to mapping
  593. * @logging_level: see mpt2sas_debug.h
  594. * @fwfault_debug: debuging FW timeouts
  595. * @ir_firmware: IR firmware present
  596. * @bars: bitmask of BAR's that must be configured
  597. * @mask_interrupts: ignore interrupt
  598. * @fault_reset_work_q_name: fw fault work queue
  599. * @fault_reset_work_q: ""
  600. * @fault_reset_work: ""
  601. * @firmware_event_name: fw event work queue
  602. * @firmware_event_thread: ""
  603. * @fw_events_off: flag to turn off fw event handling
  604. * @fw_event_lock:
  605. * @fw_event_list: list of fw events
  606. * @aen_event_read_flag: event log was read
  607. * @broadcast_aen_busy: broadcast aen waiting to be serviced
  608. * @shost_recovery: host reset in progress
  609. * @ioc_reset_in_progress_lock:
  610. * @ioc_link_reset_in_progress: phy/hard reset in progress
  611. * @ignore_loginfos: ignore loginfos during task management
  612. * @remove_host: flag for when driver unloads, to avoid sending dev resets
  613. * @pci_error_recovery: flag to prevent ioc access until slot reset completes
  614. * @wait_for_discovery_to_complete: flag set at driver load time when
  615. * waiting on reporting devices
  616. * @is_driver_loading: flag set at driver load time
  617. * @port_enable_failed: flag set when port enable has failed
  618. * @start_scan: flag set from scan_start callback, cleared from _mpt2sas_fw_work
  619. * @start_scan_failed: means port enable failed, return's the ioc_status
  620. * @msix_enable: flag indicating msix is enabled
  621. * @msix_vector_count: number msix vectors
  622. * @cpu_msix_table: table for mapping cpus to msix index
  623. * @cpu_msix_table_sz: table size
  624. * @schedule_dead_ioc_flush_running_cmds: callback to flush pending commands
  625. * @scsi_io_cb_idx: shost generated commands
  626. * @tm_cb_idx: task management commands
  627. * @scsih_cb_idx: scsih internal commands
  628. * @transport_cb_idx: transport internal commands
  629. * @ctl_cb_idx: clt internal commands
  630. * @base_cb_idx: base internal commands
  631. * @config_cb_idx: base internal commands
  632. * @tm_tr_cb_idx : device removal target reset handshake
  633. * @tm_tr_volume_cb_idx : volume removal target reset
  634. * @base_cmds:
  635. * @transport_cmds:
  636. * @scsih_cmds:
  637. * @tm_cmds:
  638. * @ctl_cmds:
  639. * @config_cmds:
  640. * @base_add_sg_single: handler for either 32/64 bit sgl's
  641. * @event_type: bits indicating which events to log
  642. * @event_context: unique id for each logged event
  643. * @event_log: event log pointer
  644. * @event_masks: events that are masked
  645. * @facts: static facts data
  646. * @pfacts: static port facts data
  647. * @manu_pg0: static manufacturing page 0
  648. * @manu_pg10: static manufacturing page 10
  649. * @bios_pg2: static bios page 2
  650. * @bios_pg3: static bios page 3
  651. * @ioc_pg8: static ioc page 8
  652. * @iounit_pg0: static iounit page 0
  653. * @iounit_pg1: static iounit page 1
  654. * @sas_hba: sas host object
  655. * @sas_expander_list: expander object list
  656. * @sas_node_lock:
  657. * @sas_device_list: sas device object list
  658. * @sas_device_init_list: sas device object list (used only at init time)
  659. * @sas_device_lock:
  660. * @io_missing_delay: time for IO completed by fw when PDR enabled
  661. * @device_missing_delay: time for device missing by fw when PDR enabled
  662. * @sas_id : used for setting volume target IDs
  663. * @pd_handles : bitmask for PD handles
  664. * @pd_handles_sz : size of pd_handle bitmask
  665. * @config_page_sz: config page size
  666. * @config_page: reserve memory for config page payload
  667. * @config_page_dma:
  668. * @hba_queue_depth: hba request queue depth
  669. * @sge_size: sg element size for either 32/64 bit
  670. * @scsiio_depth: SCSI_IO queue depth
  671. * @request_sz: per request frame size
  672. * @request: pool of request frames
  673. * @request_dma:
  674. * @request_dma_sz:
  675. * @scsi_lookup: firmware request tracker list
  676. * @scsi_lookup_lock:
  677. * @free_list: free list of request
  678. * @chain: pool of chains
  679. * @pending_io_count:
  680. * @reset_wq:
  681. * @chain_dma:
  682. * @max_sges_in_main_message: number sg elements in main message
  683. * @max_sges_in_chain_message: number sg elements per chain
  684. * @chains_needed_per_io: max chains per io
  685. * @chain_offset_value_for_main_message: location 1st sg in main
  686. * @chain_depth: total chains allocated
  687. * @hi_priority_smid:
  688. * @hi_priority:
  689. * @hi_priority_dma:
  690. * @hi_priority_depth:
  691. * @hpr_lookup:
  692. * @hpr_free_list:
  693. * @internal_smid:
  694. * @internal:
  695. * @internal_dma:
  696. * @internal_depth:
  697. * @internal_lookup:
  698. * @internal_free_list:
  699. * @sense: pool of sense
  700. * @sense_dma:
  701. * @sense_dma_pool:
  702. * @reply_depth: hba reply queue depth:
  703. * @reply_sz: per reply frame size:
  704. * @reply: pool of replys:
  705. * @reply_dma:
  706. * @reply_dma_pool:
  707. * @reply_free_queue_depth: reply free depth
  708. * @reply_free: pool for reply free queue (32 bit addr)
  709. * @reply_free_dma:
  710. * @reply_free_dma_pool:
  711. * @reply_free_host_index: tail index in pool to insert free replys
  712. * @reply_post_queue_depth: reply post queue depth
  713. * @reply_post_free: pool for reply post (64bit descriptor)
  714. * @reply_post_free_dma:
  715. * @reply_queue_count: number of reply queue's
  716. * @reply_queue_list: link list contaning the reply queue info
  717. * @reply_post_host_index: head index in the pool where FW completes IO
  718. * @delayed_tr_list: target reset link list
  719. * @delayed_tr_volume_list: volume target reset link list
  720. */
  721. struct MPT2SAS_ADAPTER {
  722. struct list_head list;
  723. struct Scsi_Host *shost;
  724. u8 id;
  725. int cpu_count;
  726. char name[MPT_NAME_LENGTH];
  727. char tmp_string[MPT_STRING_LENGTH];
  728. struct pci_dev *pdev;
  729. Mpi2SystemInterfaceRegs_t __iomem *chip;
  730. resource_size_t chip_phys;
  731. int logging_level;
  732. int fwfault_debug;
  733. u8 ir_firmware;
  734. int bars;
  735. u8 mask_interrupts;
  736. /* fw fault handler */
  737. char fault_reset_work_q_name[20];
  738. struct workqueue_struct *fault_reset_work_q;
  739. struct delayed_work fault_reset_work;
  740. /* fw event handler */
  741. char firmware_event_name[20];
  742. struct workqueue_struct *firmware_event_thread;
  743. spinlock_t fw_event_lock;
  744. struct list_head fw_event_list;
  745. /* misc flags */
  746. int aen_event_read_flag;
  747. u8 broadcast_aen_busy;
  748. u16 broadcast_aen_pending;
  749. u8 shost_recovery;
  750. struct mutex reset_in_progress_mutex;
  751. spinlock_t ioc_reset_in_progress_lock;
  752. u8 ioc_link_reset_in_progress;
  753. u8 ioc_reset_in_progress_status;
  754. u8 ignore_loginfos;
  755. u8 remove_host;
  756. u8 pci_error_recovery;
  757. u8 wait_for_discovery_to_complete;
  758. struct completion port_enable_done;
  759. u8 is_driver_loading;
  760. u8 port_enable_failed;
  761. u8 start_scan;
  762. u16 start_scan_failed;
  763. u8 msix_enable;
  764. u16 msix_vector_count;
  765. u8 *cpu_msix_table;
  766. resource_size_t **reply_post_host_index;
  767. u16 cpu_msix_table_sz;
  768. u32 ioc_reset_count;
  769. MPT2SAS_FLUSH_RUNNING_CMDS schedule_dead_ioc_flush_running_cmds;
  770. /* internal commands, callback index */
  771. u8 scsi_io_cb_idx;
  772. u8 tm_cb_idx;
  773. u8 transport_cb_idx;
  774. u8 scsih_cb_idx;
  775. u8 ctl_cb_idx;
  776. u8 base_cb_idx;
  777. u8 port_enable_cb_idx;
  778. u8 config_cb_idx;
  779. u8 tm_tr_cb_idx;
  780. u8 tm_tr_volume_cb_idx;
  781. u8 tm_sas_control_cb_idx;
  782. struct _internal_cmd base_cmds;
  783. struct _internal_cmd port_enable_cmds;
  784. struct _internal_cmd transport_cmds;
  785. struct _internal_cmd scsih_cmds;
  786. struct _internal_cmd tm_cmds;
  787. struct _internal_cmd ctl_cmds;
  788. struct _internal_cmd config_cmds;
  789. MPT_ADD_SGE base_add_sg_single;
  790. /* event log */
  791. u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  792. u32 event_context;
  793. void *event_log;
  794. u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  795. /* static config pages */
  796. struct mpt2sas_facts facts;
  797. struct mpt2sas_port_facts *pfacts;
  798. Mpi2ManufacturingPage0_t manu_pg0;
  799. Mpi2BiosPage2_t bios_pg2;
  800. Mpi2BiosPage3_t bios_pg3;
  801. Mpi2IOCPage8_t ioc_pg8;
  802. Mpi2IOUnitPage0_t iounit_pg0;
  803. Mpi2IOUnitPage1_t iounit_pg1;
  804. struct _boot_device req_boot_device;
  805. struct _boot_device req_alt_boot_device;
  806. struct _boot_device current_boot_device;
  807. /* sas hba, expander, and device list */
  808. struct _sas_node sas_hba;
  809. struct list_head sas_expander_list;
  810. spinlock_t sas_node_lock;
  811. struct list_head sas_device_list;
  812. struct list_head sas_device_init_list;
  813. spinlock_t sas_device_lock;
  814. struct list_head raid_device_list;
  815. spinlock_t raid_device_lock;
  816. u8 io_missing_delay;
  817. u16 device_missing_delay;
  818. int sas_id;
  819. void *pd_handles;
  820. u16 pd_handles_sz;
  821. /* config page */
  822. u16 config_page_sz;
  823. void *config_page;
  824. dma_addr_t config_page_dma;
  825. /* scsiio request */
  826. u16 hba_queue_depth;
  827. u16 sge_size;
  828. u16 scsiio_depth;
  829. u16 request_sz;
  830. u8 *request;
  831. dma_addr_t request_dma;
  832. u32 request_dma_sz;
  833. struct scsiio_tracker *scsi_lookup;
  834. ulong scsi_lookup_pages;
  835. spinlock_t scsi_lookup_lock;
  836. struct list_head free_list;
  837. int pending_io_count;
  838. wait_queue_head_t reset_wq;
  839. /* chain */
  840. struct chain_tracker *chain_lookup;
  841. struct list_head free_chain_list;
  842. struct dma_pool *chain_dma_pool;
  843. ulong chain_pages;
  844. u16 max_sges_in_main_message;
  845. u16 max_sges_in_chain_message;
  846. u16 chains_needed_per_io;
  847. u16 chain_offset_value_for_main_message;
  848. u32 chain_depth;
  849. /* hi-priority queue */
  850. u16 hi_priority_smid;
  851. u8 *hi_priority;
  852. dma_addr_t hi_priority_dma;
  853. u16 hi_priority_depth;
  854. struct request_tracker *hpr_lookup;
  855. struct list_head hpr_free_list;
  856. /* internal queue */
  857. u16 internal_smid;
  858. u8 *internal;
  859. dma_addr_t internal_dma;
  860. u16 internal_depth;
  861. struct request_tracker *internal_lookup;
  862. struct list_head internal_free_list;
  863. /* sense */
  864. u8 *sense;
  865. dma_addr_t sense_dma;
  866. struct dma_pool *sense_dma_pool;
  867. /* reply */
  868. u16 reply_sz;
  869. u8 *reply;
  870. dma_addr_t reply_dma;
  871. u32 reply_dma_max_address;
  872. u32 reply_dma_min_address;
  873. struct dma_pool *reply_dma_pool;
  874. /* reply free queue */
  875. u16 reply_free_queue_depth;
  876. __le32 *reply_free;
  877. dma_addr_t reply_free_dma;
  878. struct dma_pool *reply_free_dma_pool;
  879. u32 reply_free_host_index;
  880. /* reply post queue */
  881. u16 reply_post_queue_depth;
  882. Mpi2ReplyDescriptorsUnion_t *reply_post_free;
  883. dma_addr_t reply_post_free_dma;
  884. struct dma_pool *reply_post_free_dma_pool;
  885. u8 reply_queue_count;
  886. struct list_head reply_queue_list;
  887. struct list_head delayed_tr_list;
  888. struct list_head delayed_tr_volume_list;
  889. /* diag buffer support */
  890. u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
  891. u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
  892. dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
  893. u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
  894. u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
  895. Mpi2ManufacturingPage10_t manu_pg10;
  896. u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
  897. u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
  898. u32 ring_buffer_offset;
  899. u32 ring_buffer_sz;
  900. u8 is_warpdrive;
  901. u8 hide_ir_msg;
  902. u8 mfg_pg10_hide_flag;
  903. u8 hide_drives;
  904. };
  905. typedef u8 (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  906. u32 reply);
  907. /* base shared API */
  908. extern struct list_head mpt2sas_ioc_list;
  909. void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc);
  910. void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc);
  911. int mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc);
  912. void mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc);
  913. int mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc);
  914. void mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc);
  915. int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
  916. enum reset_type type);
  917. void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  918. void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  919. void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr);
  920. __le32 mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc,
  921. u16 smid);
  922. void mpt2sas_base_flush_reply_queues(struct MPT2SAS_ADAPTER *ioc);
  923. /* hi-priority queue */
  924. u16 mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
  925. u16 mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx,
  926. struct scsi_cmnd *scmd);
  927. u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
  928. void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  929. void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid,
  930. u16 handle);
  931. void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  932. void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid,
  933. u16 io_index);
  934. void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  935. void mpt2sas_base_initialize_callback_handler(void);
  936. u8 mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func);
  937. void mpt2sas_base_release_callback_handler(u8 cb_idx);
  938. u8 mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  939. u32 reply);
  940. u8 mpt2sas_port_enable_done(struct MPT2SAS_ADAPTER *ioc, u16 smid,
  941. u8 msix_index, u32 reply);
  942. void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr);
  943. u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked);
  944. void mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code);
  945. int mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
  946. Mpi2SasIoUnitControlReply_t *mpi_reply, Mpi2SasIoUnitControlRequest_t
  947. *mpi_request);
  948. int mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
  949. Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
  950. void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type);
  951. void mpt2sas_halt_firmware(struct MPT2SAS_ADAPTER *ioc);
  952. void mpt2sas_base_update_missing_delay(struct MPT2SAS_ADAPTER *ioc,
  953. u16 device_missing_delay, u8 io_missing_delay);
  954. int mpt2sas_port_enable(struct MPT2SAS_ADAPTER *ioc);
  955. /* scsih shared API */
  956. u8 mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
  957. u32 reply);
  958. int mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle,
  959. uint channel, uint id, uint lun, u8 type, u16 smid_task,
  960. ulong timeout, unsigned long serial_number, enum mutex_type m_type);
  961. void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
  962. void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
  963. void mpt2sas_expander_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
  964. void mpt2sas_device_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
  965. struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *ioc,
  966. u16 handle);
  967. struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER
  968. *ioc, u64 sas_address);
  969. struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address(
  970. struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
  971. void mpt2sas_port_enable_complete(struct MPT2SAS_ADAPTER *ioc);
  972. void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
  973. /* config shared API */
  974. u8 mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  975. u32 reply);
  976. int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys);
  977. int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
  978. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
  979. int mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc,
  980. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage10_t *config_page);
  981. int mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  982. *mpi_reply, Mpi2BiosPage2_t *config_page);
  983. int mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  984. *mpi_reply, Mpi2BiosPage3_t *config_page);
  985. int mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  986. *mpi_reply, Mpi2IOUnitPage0_t *config_page);
  987. int mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  988. *mpi_reply, Mpi2SasDevicePage0_t *config_page, u32 form, u32 handle);
  989. int mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  990. *mpi_reply, Mpi2SasDevicePage1_t *config_page, u32 form, u32 handle);
  991. int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  992. *mpi_reply, Mpi2SasIOUnitPage0_t *config_page, u16 sz);
  993. int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  994. *mpi_reply, Mpi2IOUnitPage1_t *config_page);
  995. int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  996. *mpi_reply, Mpi2IOUnitPage1_t *config_page);
  997. int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  998. *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
  999. int mpt2sas_config_set_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
  1000. Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
  1001. int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1002. *mpi_reply, Mpi2IOCPage8_t *config_page);
  1003. int mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1004. *mpi_reply, Mpi2ExpanderPage0_t *config_page, u32 form, u32 handle);
  1005. int mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1006. *mpi_reply, Mpi2ExpanderPage1_t *config_page, u32 phy_number, u16 handle);
  1007. int mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1008. *mpi_reply, Mpi2SasEnclosurePage0_t *config_page, u32 form, u32 handle);
  1009. int mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1010. *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
  1011. int mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1012. *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
  1013. int mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1014. *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form, u32 handle);
  1015. int mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 *num_pds);
  1016. int mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1017. *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form, u32 handle, u16 sz);
  1018. int mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1019. *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 form,
  1020. u32 form_specific);
  1021. int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
  1022. u16 *volume_handle);
  1023. int mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER *ioc, u16 volume_handle,
  1024. u64 *wwid);
  1025. /* ctl shared API */
  1026. extern struct device_attribute *mpt2sas_host_attrs[];
  1027. extern struct device_attribute *mpt2sas_dev_attrs[];
  1028. void mpt2sas_ctl_init(void);
  1029. void mpt2sas_ctl_exit(void);
  1030. u8 mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1031. u32 reply);
  1032. void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
  1033. u8 mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
  1034. u32 reply);
  1035. void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,
  1036. Mpi2EventNotificationReply_t *mpi_reply);
  1037. void mpt2sas_enable_diag_buffer(struct MPT2SAS_ADAPTER *ioc,
  1038. u8 bits_to_regsiter);
  1039. /* transport shared API */
  1040. u8 mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1041. u32 reply);
  1042. struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc,
  1043. u16 handle, u64 sas_address);
  1044. void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
  1045. u64 sas_address_parent);
  1046. int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
  1047. *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
  1048. int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
  1049. *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev);
  1050. void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc,
  1051. u64 sas_address, u16 handle, u8 phy_number, u8 link_rate);
  1052. extern struct sas_function_template mpt2sas_transport_functions;
  1053. extern struct scsi_transport_template *mpt2sas_transport_template;
  1054. extern int scsi_internal_device_block(struct scsi_device *sdev);
  1055. extern u8 mpt2sas_stm_zero_smid_handler(struct MPT2SAS_ADAPTER *ioc,
  1056. u8 msix_index, u32 reply);
  1057. extern int scsi_internal_device_unblock(struct scsi_device *sdev);
  1058. #endif /* MPT2SAS_BASE_H_INCLUDED */