mpt2sas_base.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  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 "09.100.00.00"
  66. #define MPT2SAS_MAJOR_VERSION 09
  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_RMS2LL080_BRANDING \
  137. "Intel Integrated RAID Module RMS2LL080"
  138. #define MPT2SAS_INTEL_RMS2LL040_BRANDING \
  139. "Intel Integrated RAID Module RMS2LL040"
  140. #define MPT2SAS_INTEL_RS25GB008_BRANDING \
  141. "Intel(R) RAID Controller RS25GB008"
  142. /*
  143. * Intel HBA SSDIDs
  144. */
  145. #define MPT2SAS_INTEL_RMS2LL080_SSDID 0x350E
  146. #define MPT2SAS_INTEL_RMS2LL040_SSDID 0x350F
  147. #define MPT2SAS_INTEL_RS25GB008_SSDID 0x3000
  148. /*
  149. * HP HBA branding
  150. */
  151. #define MPT2SAS_HP_3PAR_SSVID 0x1590
  152. #define MPT2SAS_HP_2_4_INTERNAL_BRANDING "HP H220 Host Bus Adapter"
  153. #define MPT2SAS_HP_2_4_EXTERNAL_BRANDING "HP H221 Host Bus Adapter"
  154. #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING "HP H222 Host Bus Adapter"
  155. #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING "HP H220i Host Bus Adapter"
  156. #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING "HP H210i Host Bus Adapter"
  157. /*
  158. * HO HBA SSDIDs
  159. */
  160. #define MPT2SAS_HP_2_4_INTERNAL_SSDID 0x0041
  161. #define MPT2SAS_HP_2_4_EXTERNAL_SSDID 0x0042
  162. #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_SSDID 0x0043
  163. #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_SSDID 0x0044
  164. #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_SSDID 0x0046
  165. /*
  166. * WarpDrive Specific Log codes
  167. */
  168. #define MPT2_WARPDRIVE_LOGENTRY (0x8002)
  169. #define MPT2_WARPDRIVE_LC_SSDT (0x41)
  170. #define MPT2_WARPDRIVE_LC_SSDLW (0x43)
  171. #define MPT2_WARPDRIVE_LC_SSDLF (0x44)
  172. #define MPT2_WARPDRIVE_LC_BRMF (0x4D)
  173. /*
  174. * per target private data
  175. */
  176. #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01
  177. #define MPT_TARGET_FLAGS_VOLUME 0x02
  178. #define MPT_TARGET_FLAGS_DELETED 0x04
  179. /**
  180. * struct MPT2SAS_TARGET - starget private hostdata
  181. * @starget: starget object
  182. * @sas_address: target sas address
  183. * @raid_device: raid_device pointer to access volume data
  184. * @handle: device handle
  185. * @num_luns: number luns
  186. * @flags: MPT_TARGET_FLAGS_XXX flags
  187. * @deleted: target flaged for deletion
  188. * @tm_busy: target is busy with TM request.
  189. */
  190. struct MPT2SAS_TARGET {
  191. struct scsi_target *starget;
  192. u64 sas_address;
  193. struct _raid_device *raid_device;
  194. u16 handle;
  195. int num_luns;
  196. u32 flags;
  197. u8 deleted;
  198. u8 tm_busy;
  199. };
  200. /*
  201. * per device private data
  202. */
  203. #define MPT_DEVICE_FLAGS_INIT 0x01
  204. #define MPT_DEVICE_TLR_ON 0x02
  205. /**
  206. * struct MPT2SAS_DEVICE - sdev private hostdata
  207. * @sas_target: starget private hostdata
  208. * @lun: lun number
  209. * @flags: MPT_DEVICE_XXX flags
  210. * @configured_lun: lun is configured
  211. * @block: device is in SDEV_BLOCK state
  212. * @tlr_snoop_check: flag used in determining whether to disable TLR
  213. */
  214. /* OEM Identifiers */
  215. #define MFG10_OEM_ID_INVALID (0x00000000)
  216. #define MFG10_OEM_ID_DELL (0x00000001)
  217. #define MFG10_OEM_ID_FSC (0x00000002)
  218. #define MFG10_OEM_ID_SUN (0x00000003)
  219. #define MFG10_OEM_ID_IBM (0x00000004)
  220. /* GENERIC Flags 0*/
  221. #define MFG10_GF0_OCE_DISABLED (0x00000001)
  222. #define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002)
  223. #define MFG10_GF0_R10_DISPLAY (0x00000004)
  224. #define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008)
  225. #define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010)
  226. /* OEM Specific Flags will come from OEM specific header files */
  227. typedef struct _MPI2_CONFIG_PAGE_MAN_10 {
  228. MPI2_CONFIG_PAGE_HEADER Header; /* 00h */
  229. U8 OEMIdentifier; /* 04h */
  230. U8 Reserved1; /* 05h */
  231. U16 Reserved2; /* 08h */
  232. U32 Reserved3; /* 0Ch */
  233. U32 GenericFlags0; /* 10h */
  234. U32 GenericFlags1; /* 14h */
  235. U32 Reserved4; /* 18h */
  236. U32 OEMSpecificFlags0; /* 1Ch */
  237. U32 OEMSpecificFlags1; /* 20h */
  238. U32 Reserved5[18]; /* 24h-60h*/
  239. } MPI2_CONFIG_PAGE_MAN_10,
  240. MPI2_POINTER PTR_MPI2_CONFIG_PAGE_MAN_10,
  241. Mpi2ManufacturingPage10_t, MPI2_POINTER pMpi2ManufacturingPage10_t;
  242. #define MFG_PAGE10_HIDE_SSDS_MASK (0x00000003)
  243. #define MFG_PAGE10_HIDE_ALL_DISKS (0x00)
  244. #define MFG_PAGE10_EXPOSE_ALL_DISKS (0x01)
  245. #define MFG_PAGE10_HIDE_IF_VOL_PRESENT (0x02)
  246. struct MPT2SAS_DEVICE {
  247. struct MPT2SAS_TARGET *sas_target;
  248. unsigned int lun;
  249. u32 flags;
  250. u8 configured_lun;
  251. u8 block;
  252. u8 tlr_snoop_check;
  253. };
  254. #define MPT2_CMD_NOT_USED 0x8000 /* free */
  255. #define MPT2_CMD_COMPLETE 0x0001 /* completed */
  256. #define MPT2_CMD_PENDING 0x0002 /* pending */
  257. #define MPT2_CMD_REPLY_VALID 0x0004 /* reply is valid */
  258. #define MPT2_CMD_RESET 0x0008 /* host reset dropped the command */
  259. /**
  260. * struct _internal_cmd - internal commands struct
  261. * @mutex: mutex
  262. * @done: completion
  263. * @reply: reply message pointer
  264. * @sense: sense data
  265. * @status: MPT2_CMD_XXX status
  266. * @smid: system message id
  267. */
  268. struct _internal_cmd {
  269. struct mutex mutex;
  270. struct completion done;
  271. void *reply;
  272. void *sense;
  273. u16 status;
  274. u16 smid;
  275. };
  276. /**
  277. * struct _sas_device - attached device information
  278. * @list: sas device list
  279. * @starget: starget object
  280. * @sas_address: device sas address
  281. * @device_name: retrieved from the SAS IDENTIFY frame.
  282. * @handle: device handle
  283. * @sas_address_parent: sas address of parent expander or sas host
  284. * @enclosure_handle: enclosure handle
  285. * @enclosure_logical_id: enclosure logical identifier
  286. * @volume_handle: volume handle (valid when hidden raid member)
  287. * @volume_wwid: volume unique identifier
  288. * @device_info: bitfield provides detailed info about the device
  289. * @id: target id
  290. * @channel: target channel
  291. * @slot: number number
  292. * @phy: phy identifier provided in sas device page 0
  293. * @responding: used in _scsih_sas_device_mark_responding
  294. */
  295. struct _sas_device {
  296. struct list_head list;
  297. struct scsi_target *starget;
  298. u64 sas_address;
  299. u64 device_name;
  300. u16 handle;
  301. u64 sas_address_parent;
  302. u16 enclosure_handle;
  303. u64 enclosure_logical_id;
  304. u16 volume_handle;
  305. u64 volume_wwid;
  306. u32 device_info;
  307. int id;
  308. int channel;
  309. u16 slot;
  310. u8 phy;
  311. u8 responding;
  312. };
  313. /**
  314. * struct _raid_device - raid volume link list
  315. * @list: sas device list
  316. * @starget: starget object
  317. * @sdev: scsi device struct (volumes are single lun)
  318. * @wwid: unique identifier for the volume
  319. * @handle: device handle
  320. * @block_size: Block size of the volume
  321. * @id: target id
  322. * @channel: target channel
  323. * @volume_type: the raid level
  324. * @device_info: bitfield provides detailed info about the hidden components
  325. * @num_pds: number of hidden raid components
  326. * @responding: used in _scsih_raid_device_mark_responding
  327. * @percent_complete: resync percent complete
  328. * @direct_io_enabled: Whether direct io to PDs are allowed or not
  329. * @stripe_exponent: X where 2powX is the stripe sz in blocks
  330. * @max_lba: Maximum number of LBA in the volume
  331. * @stripe_sz: Stripe Size of the volume
  332. * @device_info: Device info of the volume member disk
  333. * @pd_handle: Array of handles of the physical drives for direct I/O in le16
  334. */
  335. #define MPT_MAX_WARPDRIVE_PDS 8
  336. struct _raid_device {
  337. struct list_head list;
  338. struct scsi_target *starget;
  339. struct scsi_device *sdev;
  340. u64 wwid;
  341. u16 handle;
  342. u16 block_sz;
  343. int id;
  344. int channel;
  345. u8 volume_type;
  346. u8 num_pds;
  347. u8 responding;
  348. u8 percent_complete;
  349. u8 direct_io_enabled;
  350. u8 stripe_exponent;
  351. u64 max_lba;
  352. u32 stripe_sz;
  353. u32 device_info;
  354. u16 pd_handle[MPT_MAX_WARPDRIVE_PDS];
  355. };
  356. /**
  357. * struct _boot_device - boot device info
  358. * @is_raid: flag to indicate whether this is volume
  359. * @device: holds pointer for either struct _sas_device or
  360. * struct _raid_device
  361. */
  362. struct _boot_device {
  363. u8 is_raid;
  364. void *device;
  365. };
  366. /**
  367. * struct _sas_port - wide/narrow sas port information
  368. * @port_list: list of ports belonging to expander
  369. * @num_phys: number of phys belonging to this port
  370. * @remote_identify: attached device identification
  371. * @rphy: sas transport rphy object
  372. * @port: sas transport wide/narrow port object
  373. * @phy_list: _sas_phy list objects belonging to this port
  374. */
  375. struct _sas_port {
  376. struct list_head port_list;
  377. u8 num_phys;
  378. struct sas_identify remote_identify;
  379. struct sas_rphy *rphy;
  380. struct sas_port *port;
  381. struct list_head phy_list;
  382. };
  383. /**
  384. * struct _sas_phy - phy information
  385. * @port_siblings: list of phys belonging to a port
  386. * @identify: phy identification
  387. * @remote_identify: attached device identification
  388. * @phy: sas transport phy object
  389. * @phy_id: unique phy id
  390. * @handle: device handle for this phy
  391. * @attached_handle: device handle for attached device
  392. * @phy_belongs_to_port: port has been created for this phy
  393. */
  394. struct _sas_phy {
  395. struct list_head port_siblings;
  396. struct sas_identify identify;
  397. struct sas_identify remote_identify;
  398. struct sas_phy *phy;
  399. u8 phy_id;
  400. u16 handle;
  401. u16 attached_handle;
  402. u8 phy_belongs_to_port;
  403. };
  404. /**
  405. * struct _sas_node - sas_host/expander information
  406. * @list: list of expanders
  407. * @parent_dev: parent device class
  408. * @num_phys: number phys belonging to this sas_host/expander
  409. * @sas_address: sas address of this sas_host/expander
  410. * @handle: handle for this sas_host/expander
  411. * @sas_address_parent: sas address of parent expander or sas host
  412. * @enclosure_handle: handle for this a member of an enclosure
  413. * @device_info: bitwise defining capabilities of this sas_host/expander
  414. * @responding: used in _scsih_expander_device_mark_responding
  415. * @phy: a list of phys that make up this sas_host/expander
  416. * @sas_port_list: list of ports attached to this sas_host/expander
  417. */
  418. struct _sas_node {
  419. struct list_head list;
  420. struct device *parent_dev;
  421. u8 num_phys;
  422. u64 sas_address;
  423. u16 handle;
  424. u64 sas_address_parent;
  425. u16 enclosure_handle;
  426. u64 enclosure_logical_id;
  427. u8 responding;
  428. struct _sas_phy *phy;
  429. struct list_head sas_port_list;
  430. };
  431. /**
  432. * enum reset_type - reset state
  433. * @FORCE_BIG_HAMMER: issue diagnostic reset
  434. * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
  435. */
  436. enum reset_type {
  437. FORCE_BIG_HAMMER,
  438. SOFT_RESET,
  439. };
  440. /**
  441. * struct chain_tracker - firmware chain tracker
  442. * @chain_buffer: chain buffer
  443. * @chain_buffer_dma: physical address
  444. * @tracker_list: list of free request (ioc->free_chain_list)
  445. */
  446. struct chain_tracker {
  447. void *chain_buffer;
  448. dma_addr_t chain_buffer_dma;
  449. struct list_head tracker_list;
  450. };
  451. /**
  452. * struct scsiio_tracker - scsi mf request tracker
  453. * @smid: system message id
  454. * @scmd: scsi request pointer
  455. * @cb_idx: callback index
  456. * @direct_io: To indicate whether I/O is direct (WARPDRIVE)
  457. * @chain_list: list of chains associated to this IO
  458. * @tracker_list: list of free request (ioc->free_list)
  459. */
  460. struct scsiio_tracker {
  461. u16 smid;
  462. struct scsi_cmnd *scmd;
  463. u8 cb_idx;
  464. u8 direct_io;
  465. struct list_head chain_list;
  466. struct list_head tracker_list;
  467. };
  468. /**
  469. * struct request_tracker - firmware request tracker
  470. * @smid: system message id
  471. * @cb_idx: callback index
  472. * @tracker_list: list of free request (ioc->free_list)
  473. */
  474. struct request_tracker {
  475. u16 smid;
  476. u8 cb_idx;
  477. struct list_head tracker_list;
  478. };
  479. /**
  480. * struct _tr_list - target reset list
  481. * @handle: device handle
  482. * @state: state machine
  483. */
  484. struct _tr_list {
  485. struct list_head list;
  486. u16 handle;
  487. u16 state;
  488. };
  489. typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
  490. /* IOC Facts and Port Facts converted from little endian to cpu */
  491. union mpi2_version_union {
  492. MPI2_VERSION_STRUCT Struct;
  493. u32 Word;
  494. };
  495. struct mpt2sas_facts {
  496. u16 MsgVersion;
  497. u16 HeaderVersion;
  498. u8 IOCNumber;
  499. u8 VP_ID;
  500. u8 VF_ID;
  501. u16 IOCExceptions;
  502. u16 IOCStatus;
  503. u32 IOCLogInfo;
  504. u8 MaxChainDepth;
  505. u8 WhoInit;
  506. u8 NumberOfPorts;
  507. u8 MaxMSIxVectors;
  508. u16 RequestCredit;
  509. u16 ProductID;
  510. u32 IOCCapabilities;
  511. union mpi2_version_union FWVersion;
  512. u16 IOCRequestFrameSize;
  513. u16 Reserved3;
  514. u16 MaxInitiators;
  515. u16 MaxTargets;
  516. u16 MaxSasExpanders;
  517. u16 MaxEnclosures;
  518. u16 ProtocolFlags;
  519. u16 HighPriorityCredit;
  520. u16 MaxReplyDescriptorPostQueueDepth;
  521. u8 ReplyFrameSize;
  522. u8 MaxVolumes;
  523. u16 MaxDevHandle;
  524. u16 MaxPersistentEntries;
  525. u16 MinDevHandle;
  526. };
  527. struct mpt2sas_port_facts {
  528. u8 PortNumber;
  529. u8 VP_ID;
  530. u8 VF_ID;
  531. u8 PortType;
  532. u16 MaxPostedCmdBuffers;
  533. };
  534. /**
  535. * enum mutex_type - task management mutex type
  536. * @TM_MUTEX_OFF: mutex is not required becuase calling function is acquiring it
  537. * @TM_MUTEX_ON: mutex is required
  538. */
  539. enum mutex_type {
  540. TM_MUTEX_OFF = 0,
  541. TM_MUTEX_ON = 1,
  542. };
  543. /**
  544. * struct MPT2SAS_ADAPTER - per adapter struct
  545. * @list: ioc_list
  546. * @shost: shost object
  547. * @id: unique adapter id
  548. * @pci_irq: irq number
  549. * @name: generic ioc string
  550. * @tmp_string: tmp string used for logging
  551. * @pdev: pci pdev object
  552. * @chip: memory mapped register space
  553. * @chip_phys: physical addrss prior to mapping
  554. * @logging_level: see mpt2sas_debug.h
  555. * @fwfault_debug: debuging FW timeouts
  556. * @ir_firmware: IR firmware present
  557. * @bars: bitmask of BAR's that must be configured
  558. * @mask_interrupts: ignore interrupt
  559. * @fault_reset_work_q_name: fw fault work queue
  560. * @fault_reset_work_q: ""
  561. * @fault_reset_work: ""
  562. * @firmware_event_name: fw event work queue
  563. * @firmware_event_thread: ""
  564. * @fw_events_off: flag to turn off fw event handling
  565. * @fw_event_lock:
  566. * @fw_event_list: list of fw events
  567. * @aen_event_read_flag: event log was read
  568. * @broadcast_aen_busy: broadcast aen waiting to be serviced
  569. * @shost_recovery: host reset in progress
  570. * @ioc_reset_in_progress_lock:
  571. * @ioc_link_reset_in_progress: phy/hard reset in progress
  572. * @ignore_loginfos: ignore loginfos during task management
  573. * @remove_host: flag for when driver unloads, to avoid sending dev resets
  574. * @pci_error_recovery: flag to prevent ioc access until slot reset completes
  575. * @wait_for_port_enable_to_complete:
  576. * @msix_enable: flag indicating msix is enabled
  577. * @msix_vector_count: number msix vectors
  578. * @msix_table: virt address to the msix table
  579. * @msix_table_backup: backup msix table
  580. * @scsi_io_cb_idx: shost generated commands
  581. * @tm_cb_idx: task management commands
  582. * @scsih_cb_idx: scsih internal commands
  583. * @transport_cb_idx: transport internal commands
  584. * @ctl_cb_idx: clt internal commands
  585. * @base_cb_idx: base internal commands
  586. * @config_cb_idx: base internal commands
  587. * @tm_tr_cb_idx : device removal target reset handshake
  588. * @tm_tr_volume_cb_idx : volume removal target reset
  589. * @base_cmds:
  590. * @transport_cmds:
  591. * @scsih_cmds:
  592. * @tm_cmds:
  593. * @ctl_cmds:
  594. * @config_cmds:
  595. * @base_add_sg_single: handler for either 32/64 bit sgl's
  596. * @event_type: bits indicating which events to log
  597. * @event_context: unique id for each logged event
  598. * @event_log: event log pointer
  599. * @event_masks: events that are masked
  600. * @facts: static facts data
  601. * @pfacts: static port facts data
  602. * @manu_pg0: static manufacturing page 0
  603. * @manu_pg10: static manufacturing page 10
  604. * @bios_pg2: static bios page 2
  605. * @bios_pg3: static bios page 3
  606. * @ioc_pg8: static ioc page 8
  607. * @iounit_pg0: static iounit page 0
  608. * @iounit_pg1: static iounit page 1
  609. * @sas_hba: sas host object
  610. * @sas_expander_list: expander object list
  611. * @sas_node_lock:
  612. * @sas_device_list: sas device object list
  613. * @sas_device_init_list: sas device object list (used only at init time)
  614. * @sas_device_lock:
  615. * @io_missing_delay: time for IO completed by fw when PDR enabled
  616. * @device_missing_delay: time for device missing by fw when PDR enabled
  617. * @sas_id : used for setting volume target IDs
  618. * @pd_handles : bitmask for PD handles
  619. * @pd_handles_sz : size of pd_handle bitmask
  620. * @config_page_sz: config page size
  621. * @config_page: reserve memory for config page payload
  622. * @config_page_dma:
  623. * @hba_queue_depth: hba request queue depth
  624. * @sge_size: sg element size for either 32/64 bit
  625. * @scsiio_depth: SCSI_IO queue depth
  626. * @request_sz: per request frame size
  627. * @request: pool of request frames
  628. * @request_dma:
  629. * @request_dma_sz:
  630. * @scsi_lookup: firmware request tracker list
  631. * @scsi_lookup_lock:
  632. * @free_list: free list of request
  633. * @chain: pool of chains
  634. * @pending_io_count:
  635. * @reset_wq:
  636. * @chain_dma:
  637. * @max_sges_in_main_message: number sg elements in main message
  638. * @max_sges_in_chain_message: number sg elements per chain
  639. * @chains_needed_per_io: max chains per io
  640. * @chain_offset_value_for_main_message: location 1st sg in main
  641. * @chain_depth: total chains allocated
  642. * @hi_priority_smid:
  643. * @hi_priority:
  644. * @hi_priority_dma:
  645. * @hi_priority_depth:
  646. * @hpr_lookup:
  647. * @hpr_free_list:
  648. * @internal_smid:
  649. * @internal:
  650. * @internal_dma:
  651. * @internal_depth:
  652. * @internal_lookup:
  653. * @internal_free_list:
  654. * @sense: pool of sense
  655. * @sense_dma:
  656. * @sense_dma_pool:
  657. * @reply_depth: hba reply queue depth:
  658. * @reply_sz: per reply frame size:
  659. * @reply: pool of replys:
  660. * @reply_dma:
  661. * @reply_dma_pool:
  662. * @reply_free_queue_depth: reply free depth
  663. * @reply_free: pool for reply free queue (32 bit addr)
  664. * @reply_free_dma:
  665. * @reply_free_dma_pool:
  666. * @reply_free_host_index: tail index in pool to insert free replys
  667. * @reply_post_queue_depth: reply post queue depth
  668. * @reply_post_free: pool for reply post (64bit descriptor)
  669. * @reply_post_free_dma:
  670. * @reply_post_free_dma_pool:
  671. * @reply_post_host_index: head index in the pool where FW completes IO
  672. * @delayed_tr_list: target reset link list
  673. * @delayed_tr_volume_list: volume target reset link list
  674. */
  675. struct MPT2SAS_ADAPTER {
  676. struct list_head list;
  677. struct Scsi_Host *shost;
  678. u8 id;
  679. u32 pci_irq;
  680. char name[MPT_NAME_LENGTH];
  681. char tmp_string[MPT_STRING_LENGTH];
  682. struct pci_dev *pdev;
  683. Mpi2SystemInterfaceRegs_t __iomem *chip;
  684. resource_size_t chip_phys;
  685. int logging_level;
  686. int fwfault_debug;
  687. u8 ir_firmware;
  688. int bars;
  689. u8 mask_interrupts;
  690. /* fw fault handler */
  691. char fault_reset_work_q_name[20];
  692. struct workqueue_struct *fault_reset_work_q;
  693. struct delayed_work fault_reset_work;
  694. /* fw event handler */
  695. char firmware_event_name[20];
  696. struct workqueue_struct *firmware_event_thread;
  697. spinlock_t fw_event_lock;
  698. struct list_head fw_event_list;
  699. /* misc flags */
  700. int aen_event_read_flag;
  701. u8 broadcast_aen_busy;
  702. u16 broadcast_aen_pending;
  703. u8 shost_recovery;
  704. struct mutex reset_in_progress_mutex;
  705. struct completion shost_recovery_done;
  706. spinlock_t ioc_reset_in_progress_lock;
  707. u8 ioc_link_reset_in_progress;
  708. int ioc_reset_in_progress_status;
  709. u8 ignore_loginfos;
  710. u8 remove_host;
  711. u8 pci_error_recovery;
  712. u8 wait_for_port_enable_to_complete;
  713. u8 msix_enable;
  714. u16 msix_vector_count;
  715. u32 *msix_table;
  716. u32 *msix_table_backup;
  717. u32 ioc_reset_count;
  718. /* internal commands, callback index */
  719. u8 scsi_io_cb_idx;
  720. u8 tm_cb_idx;
  721. u8 transport_cb_idx;
  722. u8 scsih_cb_idx;
  723. u8 ctl_cb_idx;
  724. u8 base_cb_idx;
  725. u8 config_cb_idx;
  726. u8 tm_tr_cb_idx;
  727. u8 tm_tr_volume_cb_idx;
  728. u8 tm_sas_control_cb_idx;
  729. struct _internal_cmd base_cmds;
  730. struct _internal_cmd transport_cmds;
  731. struct _internal_cmd scsih_cmds;
  732. struct _internal_cmd tm_cmds;
  733. struct _internal_cmd ctl_cmds;
  734. struct _internal_cmd config_cmds;
  735. MPT_ADD_SGE base_add_sg_single;
  736. /* event log */
  737. u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  738. u32 event_context;
  739. void *event_log;
  740. u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  741. /* static config pages */
  742. struct mpt2sas_facts facts;
  743. struct mpt2sas_port_facts *pfacts;
  744. Mpi2ManufacturingPage0_t manu_pg0;
  745. Mpi2BiosPage2_t bios_pg2;
  746. Mpi2BiosPage3_t bios_pg3;
  747. Mpi2IOCPage8_t ioc_pg8;
  748. Mpi2IOUnitPage0_t iounit_pg0;
  749. Mpi2IOUnitPage1_t iounit_pg1;
  750. struct _boot_device req_boot_device;
  751. struct _boot_device req_alt_boot_device;
  752. struct _boot_device current_boot_device;
  753. /* sas hba, expander, and device list */
  754. struct _sas_node sas_hba;
  755. struct list_head sas_expander_list;
  756. spinlock_t sas_node_lock;
  757. struct list_head sas_device_list;
  758. struct list_head sas_device_init_list;
  759. spinlock_t sas_device_lock;
  760. struct list_head raid_device_list;
  761. spinlock_t raid_device_lock;
  762. u8 io_missing_delay;
  763. u16 device_missing_delay;
  764. int sas_id;
  765. void *pd_handles;
  766. u16 pd_handles_sz;
  767. /* config page */
  768. u16 config_page_sz;
  769. void *config_page;
  770. dma_addr_t config_page_dma;
  771. /* scsiio request */
  772. u16 hba_queue_depth;
  773. u16 sge_size;
  774. u16 scsiio_depth;
  775. u16 request_sz;
  776. u8 *request;
  777. dma_addr_t request_dma;
  778. u32 request_dma_sz;
  779. struct scsiio_tracker *scsi_lookup;
  780. ulong scsi_lookup_pages;
  781. spinlock_t scsi_lookup_lock;
  782. struct list_head free_list;
  783. int pending_io_count;
  784. wait_queue_head_t reset_wq;
  785. /* chain */
  786. struct chain_tracker *chain_lookup;
  787. struct list_head free_chain_list;
  788. struct dma_pool *chain_dma_pool;
  789. ulong chain_pages;
  790. u16 max_sges_in_main_message;
  791. u16 max_sges_in_chain_message;
  792. u16 chains_needed_per_io;
  793. u16 chain_offset_value_for_main_message;
  794. u32 chain_depth;
  795. /* hi-priority queue */
  796. u16 hi_priority_smid;
  797. u8 *hi_priority;
  798. dma_addr_t hi_priority_dma;
  799. u16 hi_priority_depth;
  800. struct request_tracker *hpr_lookup;
  801. struct list_head hpr_free_list;
  802. /* internal queue */
  803. u16 internal_smid;
  804. u8 *internal;
  805. dma_addr_t internal_dma;
  806. u16 internal_depth;
  807. struct request_tracker *internal_lookup;
  808. struct list_head internal_free_list;
  809. /* sense */
  810. u8 *sense;
  811. dma_addr_t sense_dma;
  812. struct dma_pool *sense_dma_pool;
  813. /* reply */
  814. u16 reply_sz;
  815. u8 *reply;
  816. dma_addr_t reply_dma;
  817. u32 reply_dma_max_address;
  818. u32 reply_dma_min_address;
  819. struct dma_pool *reply_dma_pool;
  820. /* reply free queue */
  821. u16 reply_free_queue_depth;
  822. __le32 *reply_free;
  823. dma_addr_t reply_free_dma;
  824. struct dma_pool *reply_free_dma_pool;
  825. u32 reply_free_host_index;
  826. /* reply post queue */
  827. u16 reply_post_queue_depth;
  828. Mpi2ReplyDescriptorsUnion_t *reply_post_free;
  829. dma_addr_t reply_post_free_dma;
  830. struct dma_pool *reply_post_free_dma_pool;
  831. u32 reply_post_host_index;
  832. struct list_head delayed_tr_list;
  833. struct list_head delayed_tr_volume_list;
  834. /* diag buffer support */
  835. u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
  836. u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
  837. dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
  838. u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
  839. u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
  840. Mpi2ManufacturingPage10_t manu_pg10;
  841. u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
  842. u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
  843. u32 ring_buffer_offset;
  844. u32 ring_buffer_sz;
  845. u8 is_warpdrive;
  846. u8 hide_ir_msg;
  847. u8 mfg_pg10_hide_flag;
  848. u8 hide_drives;
  849. };
  850. typedef u8 (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  851. u32 reply);
  852. /* base shared API */
  853. extern struct list_head mpt2sas_ioc_list;
  854. void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc);
  855. void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc);
  856. int mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc);
  857. void mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc);
  858. int mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc);
  859. void mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc);
  860. int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
  861. enum reset_type type);
  862. void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  863. void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  864. void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr);
  865. __le32 mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc,
  866. u16 smid);
  867. /* hi-priority queue */
  868. u16 mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
  869. u16 mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx,
  870. struct scsi_cmnd *scmd);
  871. u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
  872. void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  873. void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid,
  874. u16 handle);
  875. void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  876. void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid,
  877. u16 io_index);
  878. void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  879. void mpt2sas_base_initialize_callback_handler(void);
  880. u8 mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func);
  881. void mpt2sas_base_release_callback_handler(u8 cb_idx);
  882. u8 mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  883. u32 reply);
  884. void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr);
  885. u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked);
  886. void mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code);
  887. int mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
  888. Mpi2SasIoUnitControlReply_t *mpi_reply, Mpi2SasIoUnitControlRequest_t
  889. *mpi_request);
  890. int mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
  891. Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
  892. void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type);
  893. void mpt2sas_halt_firmware(struct MPT2SAS_ADAPTER *ioc);
  894. /* scsih shared API */
  895. u8 mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
  896. u32 reply);
  897. int mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle,
  898. uint channel, uint id, uint lun, u8 type, u16 smid_task,
  899. ulong timeout, unsigned long serial_number, enum mutex_type m_type);
  900. void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
  901. void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
  902. void mpt2sas_expander_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
  903. void mpt2sas_device_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
  904. struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *ioc,
  905. u16 handle);
  906. struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER
  907. *ioc, u64 sas_address);
  908. struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address(
  909. struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
  910. void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
  911. /* config shared API */
  912. u8 mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  913. u32 reply);
  914. int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys);
  915. int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
  916. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
  917. int mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc,
  918. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage10_t *config_page);
  919. int mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  920. *mpi_reply, Mpi2BiosPage2_t *config_page);
  921. int mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  922. *mpi_reply, Mpi2BiosPage3_t *config_page);
  923. int mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  924. *mpi_reply, Mpi2IOUnitPage0_t *config_page);
  925. int mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  926. *mpi_reply, Mpi2SasDevicePage0_t *config_page, u32 form, u32 handle);
  927. int mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  928. *mpi_reply, Mpi2SasDevicePage1_t *config_page, u32 form, u32 handle);
  929. int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  930. *mpi_reply, Mpi2SasIOUnitPage0_t *config_page, u16 sz);
  931. int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  932. *mpi_reply, Mpi2IOUnitPage1_t *config_page);
  933. int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  934. *mpi_reply, Mpi2IOUnitPage1_t *config_page);
  935. int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  936. *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
  937. int mpt2sas_config_set_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
  938. Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
  939. int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  940. *mpi_reply, Mpi2IOCPage8_t *config_page);
  941. int mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  942. *mpi_reply, Mpi2ExpanderPage0_t *config_page, u32 form, u32 handle);
  943. int mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  944. *mpi_reply, Mpi2ExpanderPage1_t *config_page, u32 phy_number, u16 handle);
  945. int mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  946. *mpi_reply, Mpi2SasEnclosurePage0_t *config_page, u32 form, u32 handle);
  947. int mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  948. *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
  949. int mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  950. *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
  951. int mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  952. *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form, u32 handle);
  953. int mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 *num_pds);
  954. int mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  955. *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form, u32 handle, u16 sz);
  956. int mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  957. *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 form,
  958. u32 form_specific);
  959. int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
  960. u16 *volume_handle);
  961. int mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER *ioc, u16 volume_handle,
  962. u64 *wwid);
  963. /* ctl shared API */
  964. extern struct device_attribute *mpt2sas_host_attrs[];
  965. extern struct device_attribute *mpt2sas_dev_attrs[];
  966. void mpt2sas_ctl_init(void);
  967. void mpt2sas_ctl_exit(void);
  968. u8 mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  969. u32 reply);
  970. void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
  971. u8 mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
  972. u32 reply);
  973. void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,
  974. Mpi2EventNotificationReply_t *mpi_reply);
  975. void mpt2sas_enable_diag_buffer(struct MPT2SAS_ADAPTER *ioc,
  976. u8 bits_to_regsiter);
  977. /* transport shared API */
  978. u8 mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  979. u32 reply);
  980. struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc,
  981. u16 handle, u64 sas_address);
  982. void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
  983. u64 sas_address_parent);
  984. int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
  985. *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
  986. int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
  987. *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev);
  988. void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc,
  989. u64 sas_address, u16 handle, u8 phy_number, u8 link_rate);
  990. extern struct sas_function_template mpt2sas_transport_functions;
  991. extern struct scsi_transport_template *mpt2sas_transport_template;
  992. extern int scsi_internal_device_block(struct scsi_device *sdev);
  993. extern u8 mpt2sas_stm_zero_smid_handler(struct MPT2SAS_ADAPTER *ioc,
  994. u8 msix_index, u32 reply);
  995. extern int scsi_internal_device_unblock(struct scsi_device *sdev);
  996. #endif /* MPT2SAS_BASE_H_INCLUDED */