mpt2sas_base.h 40 KB

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