mpt2sas_base.h 39 KB

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