mpt3sas_base.h 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628
  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/mpt3sas/mpt3sas_base.h
  6. * Copyright (C) 2012-2014 LSI Corporation
  7. * Copyright (C) 2013-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 MPT3SAS_BASE_H_INCLUDED
  44. #define MPT3SAS_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 "mpi/mpi2_pci.h"
  54. #include <scsi/scsi.h>
  55. #include <scsi/scsi_cmnd.h>
  56. #include <scsi/scsi_device.h>
  57. #include <scsi/scsi_host.h>
  58. #include <scsi/scsi_tcq.h>
  59. #include <scsi/scsi_transport_sas.h>
  60. #include <scsi/scsi_dbg.h>
  61. #include <scsi/scsi_eh.h>
  62. #include <linux/pci.h>
  63. #include <linux/poll.h>
  64. #include "mpt3sas_debug.h"
  65. #include "mpt3sas_trigger_diag.h"
  66. /* driver versioning info */
  67. #define MPT3SAS_DRIVER_NAME "mpt3sas"
  68. #define MPT3SAS_AUTHOR "Avago Technologies <MPT-FusionLinux.pdl@avagotech.com>"
  69. #define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver"
  70. #define MPT3SAS_DRIVER_VERSION "17.100.00.00"
  71. #define MPT3SAS_MAJOR_VERSION 17
  72. #define MPT3SAS_MINOR_VERSION 100
  73. #define MPT3SAS_BUILD_VERSION 0
  74. #define MPT3SAS_RELEASE_VERSION 00
  75. #define MPT2SAS_DRIVER_NAME "mpt2sas"
  76. #define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver"
  77. #define MPT2SAS_DRIVER_VERSION "20.102.00.00"
  78. #define MPT2SAS_MAJOR_VERSION 20
  79. #define MPT2SAS_MINOR_VERSION 102
  80. #define MPT2SAS_BUILD_VERSION 0
  81. #define MPT2SAS_RELEASE_VERSION 00
  82. /*
  83. * Set MPT3SAS_SG_DEPTH value based on user input.
  84. */
  85. #define MPT_MAX_PHYS_SEGMENTS SG_CHUNK_SIZE
  86. #define MPT_MIN_PHYS_SEGMENTS 16
  87. #define MPT_KDUMP_MIN_PHYS_SEGMENTS 32
  88. #ifdef CONFIG_SCSI_MPT3SAS_MAX_SGE
  89. #define MPT3SAS_SG_DEPTH CONFIG_SCSI_MPT3SAS_MAX_SGE
  90. #else
  91. #define MPT3SAS_SG_DEPTH MPT_MAX_PHYS_SEGMENTS
  92. #endif
  93. #ifdef CONFIG_SCSI_MPT2SAS_MAX_SGE
  94. #define MPT2SAS_SG_DEPTH CONFIG_SCSI_MPT2SAS_MAX_SGE
  95. #else
  96. #define MPT2SAS_SG_DEPTH MPT_MAX_PHYS_SEGMENTS
  97. #endif
  98. /*
  99. * Generic Defines
  100. */
  101. #define MPT3SAS_SATA_QUEUE_DEPTH 32
  102. #define MPT3SAS_SAS_QUEUE_DEPTH 254
  103. #define MPT3SAS_RAID_QUEUE_DEPTH 128
  104. #define MPT3SAS_KDUMP_SCSI_IO_DEPTH 200
  105. #define MPT3SAS_RAID_MAX_SECTORS 8192
  106. #define MPT3SAS_HOST_PAGE_SIZE_4K 12
  107. #define MPT3SAS_NVME_QUEUE_DEPTH 128
  108. #define MPT_NAME_LENGTH 32 /* generic length of strings */
  109. #define MPT_STRING_LENGTH 64
  110. #define MPT_MAX_CALLBACKS 32
  111. #define INTERNAL_CMDS_COUNT 10 /* reserved cmds */
  112. /* reserved for issuing internally framed scsi io cmds */
  113. #define INTERNAL_SCSIIO_CMDS_COUNT 3
  114. #define MPI3_HIM_MASK 0xFFFFFFFF /* mask every bit*/
  115. #define MPT3SAS_INVALID_DEVICE_HANDLE 0xFFFF
  116. #define MAX_CHAIN_ELEMT_SZ 16
  117. #define DEFAULT_NUM_FWCHAIN_ELEMTS 8
  118. /*
  119. * NVMe defines
  120. */
  121. #define NVME_PRP_SIZE 8 /* PRP size */
  122. #define NVME_CMD_PRP1_OFFSET 24 /* PRP1 offset in NVMe cmd */
  123. #define NVME_CMD_PRP2_OFFSET 32 /* PRP2 offset in NVMe cmd */
  124. #define NVME_ERROR_RESPONSE_SIZE 16 /* Max NVME Error Response */
  125. #define NVME_PRP_PAGE_SIZE 4096 /* Page size */
  126. /*
  127. * reset phases
  128. */
  129. #define MPT3_IOC_PRE_RESET 1 /* prior to host reset */
  130. #define MPT3_IOC_AFTER_RESET 2 /* just after host reset */
  131. #define MPT3_IOC_DONE_RESET 3 /* links re-initialized */
  132. /*
  133. * logging format
  134. */
  135. #define MPT3SAS_FMT "%s: "
  136. /*
  137. * WarpDrive Specific Log codes
  138. */
  139. #define MPT2_WARPDRIVE_LOGENTRY (0x8002)
  140. #define MPT2_WARPDRIVE_LC_SSDT (0x41)
  141. #define MPT2_WARPDRIVE_LC_SSDLW (0x43)
  142. #define MPT2_WARPDRIVE_LC_SSDLF (0x44)
  143. #define MPT2_WARPDRIVE_LC_BRMF (0x4D)
  144. /*
  145. * per target private data
  146. */
  147. #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01
  148. #define MPT_TARGET_FLAGS_VOLUME 0x02
  149. #define MPT_TARGET_FLAGS_DELETED 0x04
  150. #define MPT_TARGET_FASTPATH_IO 0x08
  151. #define MPT_TARGET_FLAGS_PCIE_DEVICE 0x10
  152. #define SAS2_PCI_DEVICE_B0_REVISION (0x01)
  153. #define SAS3_PCI_DEVICE_C0_REVISION (0x02)
  154. /*
  155. * Intel HBA branding
  156. */
  157. #define MPT2SAS_INTEL_RMS25JB080_BRANDING \
  158. "Intel(R) Integrated RAID Module RMS25JB080"
  159. #define MPT2SAS_INTEL_RMS25JB040_BRANDING \
  160. "Intel(R) Integrated RAID Module RMS25JB040"
  161. #define MPT2SAS_INTEL_RMS25KB080_BRANDING \
  162. "Intel(R) Integrated RAID Module RMS25KB080"
  163. #define MPT2SAS_INTEL_RMS25KB040_BRANDING \
  164. "Intel(R) Integrated RAID Module RMS25KB040"
  165. #define MPT2SAS_INTEL_RMS25LB040_BRANDING \
  166. "Intel(R) Integrated RAID Module RMS25LB040"
  167. #define MPT2SAS_INTEL_RMS25LB080_BRANDING \
  168. "Intel(R) Integrated RAID Module RMS25LB080"
  169. #define MPT2SAS_INTEL_RMS2LL080_BRANDING \
  170. "Intel Integrated RAID Module RMS2LL080"
  171. #define MPT2SAS_INTEL_RMS2LL040_BRANDING \
  172. "Intel Integrated RAID Module RMS2LL040"
  173. #define MPT2SAS_INTEL_RS25GB008_BRANDING \
  174. "Intel(R) RAID Controller RS25GB008"
  175. #define MPT2SAS_INTEL_SSD910_BRANDING \
  176. "Intel(R) SSD 910 Series"
  177. #define MPT3SAS_INTEL_RMS3JC080_BRANDING \
  178. "Intel(R) Integrated RAID Module RMS3JC080"
  179. #define MPT3SAS_INTEL_RS3GC008_BRANDING \
  180. "Intel(R) RAID Controller RS3GC008"
  181. #define MPT3SAS_INTEL_RS3FC044_BRANDING \
  182. "Intel(R) RAID Controller RS3FC044"
  183. #define MPT3SAS_INTEL_RS3UC080_BRANDING \
  184. "Intel(R) RAID Controller RS3UC080"
  185. /*
  186. * Intel HBA SSDIDs
  187. */
  188. #define MPT2SAS_INTEL_RMS25JB080_SSDID 0x3516
  189. #define MPT2SAS_INTEL_RMS25JB040_SSDID 0x3517
  190. #define MPT2SAS_INTEL_RMS25KB080_SSDID 0x3518
  191. #define MPT2SAS_INTEL_RMS25KB040_SSDID 0x3519
  192. #define MPT2SAS_INTEL_RMS25LB040_SSDID 0x351A
  193. #define MPT2SAS_INTEL_RMS25LB080_SSDID 0x351B
  194. #define MPT2SAS_INTEL_RMS2LL080_SSDID 0x350E
  195. #define MPT2SAS_INTEL_RMS2LL040_SSDID 0x350F
  196. #define MPT2SAS_INTEL_RS25GB008_SSDID 0x3000
  197. #define MPT2SAS_INTEL_SSD910_SSDID 0x3700
  198. #define MPT3SAS_INTEL_RMS3JC080_SSDID 0x3521
  199. #define MPT3SAS_INTEL_RS3GC008_SSDID 0x3522
  200. #define MPT3SAS_INTEL_RS3FC044_SSDID 0x3523
  201. #define MPT3SAS_INTEL_RS3UC080_SSDID 0x3524
  202. /*
  203. * Dell HBA branding
  204. */
  205. #define MPT2SAS_DELL_BRANDING_SIZE 32
  206. #define MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING "Dell 6Gbps SAS HBA"
  207. #define MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING "Dell PERC H200 Adapter"
  208. #define MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING "Dell PERC H200 Integrated"
  209. #define MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING "Dell PERC H200 Modular"
  210. #define MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING "Dell PERC H200 Embedded"
  211. #define MPT2SAS_DELL_PERC_H200_BRANDING "Dell PERC H200"
  212. #define MPT2SAS_DELL_6GBPS_SAS_BRANDING "Dell 6Gbps SAS"
  213. #define MPT3SAS_DELL_12G_HBA_BRANDING \
  214. "Dell 12Gbps HBA"
  215. /*
  216. * Dell HBA SSDIDs
  217. */
  218. #define MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID 0x1F1C
  219. #define MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID 0x1F1D
  220. #define MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID 0x1F1E
  221. #define MPT2SAS_DELL_PERC_H200_MODULAR_SSDID 0x1F1F
  222. #define MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID 0x1F20
  223. #define MPT2SAS_DELL_PERC_H200_SSDID 0x1F21
  224. #define MPT2SAS_DELL_6GBPS_SAS_SSDID 0x1F22
  225. #define MPT3SAS_DELL_12G_HBA_SSDID 0x1F46
  226. /*
  227. * Cisco HBA branding
  228. */
  229. #define MPT3SAS_CISCO_12G_8E_HBA_BRANDING \
  230. "Cisco 9300-8E 12G SAS HBA"
  231. #define MPT3SAS_CISCO_12G_8I_HBA_BRANDING \
  232. "Cisco 9300-8i 12G SAS HBA"
  233. #define MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING \
  234. "Cisco 12G Modular SAS Pass through Controller"
  235. #define MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_BRANDING \
  236. "UCS C3X60 12G SAS Pass through Controller"
  237. /*
  238. * Cisco HBA SSSDIDs
  239. */
  240. #define MPT3SAS_CISCO_12G_8E_HBA_SSDID 0x14C
  241. #define MPT3SAS_CISCO_12G_8I_HBA_SSDID 0x154
  242. #define MPT3SAS_CISCO_12G_AVILA_HBA_SSDID 0x155
  243. #define MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_SSDID 0x156
  244. /*
  245. * status bits for ioc->diag_buffer_status
  246. */
  247. #define MPT3_DIAG_BUFFER_IS_REGISTERED (0x01)
  248. #define MPT3_DIAG_BUFFER_IS_RELEASED (0x02)
  249. #define MPT3_DIAG_BUFFER_IS_DIAG_RESET (0x04)
  250. /*
  251. * HP HBA branding
  252. */
  253. #define MPT2SAS_HP_3PAR_SSVID 0x1590
  254. #define MPT2SAS_HP_2_4_INTERNAL_BRANDING \
  255. "HP H220 Host Bus Adapter"
  256. #define MPT2SAS_HP_2_4_EXTERNAL_BRANDING \
  257. "HP H221 Host Bus Adapter"
  258. #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING \
  259. "HP H222 Host Bus Adapter"
  260. #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING \
  261. "HP H220i Host Bus Adapter"
  262. #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING \
  263. "HP H210i Host Bus Adapter"
  264. /*
  265. * HO HBA SSDIDs
  266. */
  267. #define MPT2SAS_HP_2_4_INTERNAL_SSDID 0x0041
  268. #define MPT2SAS_HP_2_4_EXTERNAL_SSDID 0x0042
  269. #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_SSDID 0x0043
  270. #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_SSDID 0x0044
  271. #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_SSDID 0x0046
  272. /*
  273. * Combined Reply Queue constants,
  274. * There are twelve Supplemental Reply Post Host Index Registers
  275. * and each register is at offset 0x10 bytes from the previous one.
  276. */
  277. #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G3 12
  278. #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G35 16
  279. #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET (0x10)
  280. /* OEM Identifiers */
  281. #define MFG10_OEM_ID_INVALID (0x00000000)
  282. #define MFG10_OEM_ID_DELL (0x00000001)
  283. #define MFG10_OEM_ID_FSC (0x00000002)
  284. #define MFG10_OEM_ID_SUN (0x00000003)
  285. #define MFG10_OEM_ID_IBM (0x00000004)
  286. /* GENERIC Flags 0*/
  287. #define MFG10_GF0_OCE_DISABLED (0x00000001)
  288. #define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002)
  289. #define MFG10_GF0_R10_DISPLAY (0x00000004)
  290. #define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008)
  291. #define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010)
  292. #define VIRTUAL_IO_FAILED_RETRY (0x32010081)
  293. /* OEM Specific Flags will come from OEM specific header files */
  294. struct Mpi2ManufacturingPage10_t {
  295. MPI2_CONFIG_PAGE_HEADER Header; /* 00h */
  296. U8 OEMIdentifier; /* 04h */
  297. U8 Reserved1; /* 05h */
  298. U16 Reserved2; /* 08h */
  299. U32 Reserved3; /* 0Ch */
  300. U32 GenericFlags0; /* 10h */
  301. U32 GenericFlags1; /* 14h */
  302. U32 Reserved4; /* 18h */
  303. U32 OEMSpecificFlags0; /* 1Ch */
  304. U32 OEMSpecificFlags1; /* 20h */
  305. U32 Reserved5[18]; /* 24h - 60h*/
  306. };
  307. /* Miscellaneous options */
  308. struct Mpi2ManufacturingPage11_t {
  309. MPI2_CONFIG_PAGE_HEADER Header; /* 00h */
  310. __le32 Reserved1; /* 04h */
  311. u8 Reserved2; /* 08h */
  312. u8 EEDPTagMode; /* 09h */
  313. u8 Reserved3; /* 0Ah */
  314. u8 Reserved4; /* 0Bh */
  315. __le32 Reserved5[23]; /* 0Ch-60h*/
  316. };
  317. /**
  318. * struct MPT3SAS_TARGET - starget private hostdata
  319. * @starget: starget object
  320. * @sas_address: target sas address
  321. * @raid_device: raid_device pointer to access volume data
  322. * @handle: device handle
  323. * @num_luns: number luns
  324. * @flags: MPT_TARGET_FLAGS_XXX flags
  325. * @deleted: target flaged for deletion
  326. * @tm_busy: target is busy with TM request.
  327. * @sas_dev: The sas_device associated with this target
  328. * @pcie_dev: The pcie device associated with this target
  329. */
  330. struct MPT3SAS_TARGET {
  331. struct scsi_target *starget;
  332. u64 sas_address;
  333. struct _raid_device *raid_device;
  334. u16 handle;
  335. int num_luns;
  336. u32 flags;
  337. u8 deleted;
  338. u8 tm_busy;
  339. struct _sas_device *sas_dev;
  340. struct _pcie_device *pcie_dev;
  341. };
  342. /*
  343. * per device private data
  344. */
  345. #define MPT_DEVICE_FLAGS_INIT 0x01
  346. #define MFG_PAGE10_HIDE_SSDS_MASK (0x00000003)
  347. #define MFG_PAGE10_HIDE_ALL_DISKS (0x00)
  348. #define MFG_PAGE10_EXPOSE_ALL_DISKS (0x01)
  349. #define MFG_PAGE10_HIDE_IF_VOL_PRESENT (0x02)
  350. /**
  351. * struct MPT3SAS_DEVICE - sdev private hostdata
  352. * @sas_target: starget private hostdata
  353. * @lun: lun number
  354. * @flags: MPT_DEVICE_XXX flags
  355. * @configured_lun: lun is configured
  356. * @block: device is in SDEV_BLOCK state
  357. * @tlr_snoop_check: flag used in determining whether to disable TLR
  358. * @eedp_enable: eedp support enable bit
  359. * @eedp_type: 0(type_1), 1(type_2), 2(type_3)
  360. * @eedp_block_length: block size
  361. * @ata_command_pending: SATL passthrough outstanding for device
  362. */
  363. struct MPT3SAS_DEVICE {
  364. struct MPT3SAS_TARGET *sas_target;
  365. unsigned int lun;
  366. u32 flags;
  367. u8 configured_lun;
  368. u8 block;
  369. u8 tlr_snoop_check;
  370. u8 ignore_delay_remove;
  371. /* Iopriority Command Handling */
  372. u8 ncq_prio_enable;
  373. /*
  374. * Bug workaround for SATL handling: the mpt2/3sas firmware
  375. * doesn't return BUSY or TASK_SET_FULL for subsequent
  376. * commands while a SATL pass through is in operation as the
  377. * spec requires, it simply does nothing with them until the
  378. * pass through completes, causing them possibly to timeout if
  379. * the passthrough is a long executing command (like format or
  380. * secure erase). This variable allows us to do the right
  381. * thing while a SATL command is pending.
  382. */
  383. unsigned long ata_command_pending;
  384. };
  385. #define MPT3_CMD_NOT_USED 0x8000 /* free */
  386. #define MPT3_CMD_COMPLETE 0x0001 /* completed */
  387. #define MPT3_CMD_PENDING 0x0002 /* pending */
  388. #define MPT3_CMD_REPLY_VALID 0x0004 /* reply is valid */
  389. #define MPT3_CMD_RESET 0x0008 /* host reset dropped the command */
  390. /**
  391. * struct _internal_cmd - internal commands struct
  392. * @mutex: mutex
  393. * @done: completion
  394. * @reply: reply message pointer
  395. * @sense: sense data
  396. * @status: MPT3_CMD_XXX status
  397. * @smid: system message id
  398. */
  399. struct _internal_cmd {
  400. struct mutex mutex;
  401. struct completion done;
  402. void *reply;
  403. void *sense;
  404. u16 status;
  405. u16 smid;
  406. };
  407. /**
  408. * struct _sas_device - attached device information
  409. * @list: sas device list
  410. * @starget: starget object
  411. * @sas_address: device sas address
  412. * @device_name: retrieved from the SAS IDENTIFY frame.
  413. * @handle: device handle
  414. * @sas_address_parent: sas address of parent expander or sas host
  415. * @enclosure_handle: enclosure handle
  416. * @enclosure_logical_id: enclosure logical identifier
  417. * @volume_handle: volume handle (valid when hidden raid member)
  418. * @volume_wwid: volume unique identifier
  419. * @device_info: bitfield provides detailed info about the device
  420. * @id: target id
  421. * @channel: target channel
  422. * @slot: number number
  423. * @phy: phy identifier provided in sas device page 0
  424. * @responding: used in _scsih_sas_device_mark_responding
  425. * @fast_path: fast path feature enable bit
  426. * @pfa_led_on: flag for PFA LED status
  427. * @pend_sas_rphy_add: flag to check if device is in sas_rphy_add()
  428. * addition routine.
  429. * @chassis_slot: chassis slot
  430. * @is_chassis_slot_valid: chassis slot valid or not
  431. */
  432. struct _sas_device {
  433. struct list_head list;
  434. struct scsi_target *starget;
  435. u64 sas_address;
  436. u64 device_name;
  437. u16 handle;
  438. u64 sas_address_parent;
  439. u16 enclosure_handle;
  440. u64 enclosure_logical_id;
  441. u16 volume_handle;
  442. u64 volume_wwid;
  443. u32 device_info;
  444. int id;
  445. int channel;
  446. u16 slot;
  447. u8 phy;
  448. u8 responding;
  449. u8 fast_path;
  450. u8 pfa_led_on;
  451. u8 pend_sas_rphy_add;
  452. u8 enclosure_level;
  453. u8 chassis_slot;
  454. u8 is_chassis_slot_valid;
  455. u8 connector_name[5];
  456. struct kref refcount;
  457. };
  458. static inline void sas_device_get(struct _sas_device *s)
  459. {
  460. kref_get(&s->refcount);
  461. }
  462. static inline void sas_device_free(struct kref *r)
  463. {
  464. kfree(container_of(r, struct _sas_device, refcount));
  465. }
  466. static inline void sas_device_put(struct _sas_device *s)
  467. {
  468. kref_put(&s->refcount, sas_device_free);
  469. }
  470. /*
  471. * struct _pcie_device - attached PCIe device information
  472. * @list: pcie device list
  473. * @starget: starget object
  474. * @wwid: device WWID
  475. * @handle: device handle
  476. * @device_info: bitfield provides detailed info about the device
  477. * @id: target id
  478. * @channel: target channel
  479. * @slot: slot number
  480. * @port_num: port number
  481. * @responding: used in _scsih_pcie_device_mark_responding
  482. * @fast_path: fast path feature enable bit
  483. * @nvme_mdts: MaximumDataTransferSize from PCIe Device Page 2 for
  484. * NVMe device only
  485. * @enclosure_handle: enclosure handle
  486. * @enclosure_logical_id: enclosure logical identifier
  487. * @enclosure_level: The level of device's enclosure from the controller
  488. * @connector_name: ASCII value of the Connector's name
  489. * @serial_number: pointer of serial number string allocated runtime
  490. * @refcount: reference count for deletion
  491. */
  492. struct _pcie_device {
  493. struct list_head list;
  494. struct scsi_target *starget;
  495. u64 wwid;
  496. u16 handle;
  497. u32 device_info;
  498. int id;
  499. int channel;
  500. u16 slot;
  501. u8 port_num;
  502. u8 responding;
  503. u8 fast_path;
  504. u32 nvme_mdts;
  505. u16 enclosure_handle;
  506. u64 enclosure_logical_id;
  507. u8 enclosure_level;
  508. u8 connector_name[4];
  509. u8 *serial_number;
  510. struct kref refcount;
  511. };
  512. /**
  513. * pcie_device_get - Increment the pcie device reference count
  514. *
  515. * @p: pcie_device object
  516. *
  517. * When ever this function called it will increment the
  518. * reference count of the pcie device for which this function called.
  519. *
  520. */
  521. static inline void pcie_device_get(struct _pcie_device *p)
  522. {
  523. kref_get(&p->refcount);
  524. }
  525. /**
  526. * pcie_device_free - Release the pcie device object
  527. * @r - kref object
  528. *
  529. * Free's the pcie device object. It will be called when reference count
  530. * reaches to zero.
  531. */
  532. static inline void pcie_device_free(struct kref *r)
  533. {
  534. kfree(container_of(r, struct _pcie_device, refcount));
  535. }
  536. /**
  537. * pcie_device_put - Decrement the pcie device reference count
  538. *
  539. * @p: pcie_device object
  540. *
  541. * When ever this function called it will decrement the
  542. * reference count of the pcie device for which this function called.
  543. *
  544. * When refernce count reaches to Zero, this will call pcie_device_free to the
  545. * pcie_device object.
  546. */
  547. static inline void pcie_device_put(struct _pcie_device *p)
  548. {
  549. kref_put(&p->refcount, pcie_device_free);
  550. }
  551. /**
  552. * struct _raid_device - raid volume link list
  553. * @list: sas device list
  554. * @starget: starget object
  555. * @sdev: scsi device struct (volumes are single lun)
  556. * @wwid: unique identifier for the volume
  557. * @handle: device handle
  558. * @block_size: Block size of the volume
  559. * @id: target id
  560. * @channel: target channel
  561. * @volume_type: the raid level
  562. * @device_info: bitfield provides detailed info about the hidden components
  563. * @num_pds: number of hidden raid components
  564. * @responding: used in _scsih_raid_device_mark_responding
  565. * @percent_complete: resync percent complete
  566. * @direct_io_enabled: Whether direct io to PDs are allowed or not
  567. * @stripe_exponent: X where 2powX is the stripe sz in blocks
  568. * @block_exponent: X where 2powX is the block sz in bytes
  569. * @max_lba: Maximum number of LBA in the volume
  570. * @stripe_sz: Stripe Size of the volume
  571. * @device_info: Device info of the volume member disk
  572. * @pd_handle: Array of handles of the physical drives for direct I/O in le16
  573. */
  574. #define MPT_MAX_WARPDRIVE_PDS 8
  575. struct _raid_device {
  576. struct list_head list;
  577. struct scsi_target *starget;
  578. struct scsi_device *sdev;
  579. u64 wwid;
  580. u16 handle;
  581. u16 block_sz;
  582. int id;
  583. int channel;
  584. u8 volume_type;
  585. u8 num_pds;
  586. u8 responding;
  587. u8 percent_complete;
  588. u8 direct_io_enabled;
  589. u8 stripe_exponent;
  590. u8 block_exponent;
  591. u64 max_lba;
  592. u32 stripe_sz;
  593. u32 device_info;
  594. u16 pd_handle[MPT_MAX_WARPDRIVE_PDS];
  595. };
  596. /**
  597. * struct _boot_device - boot device info
  598. *
  599. * @channel: sas, raid, or pcie channel
  600. * @device: holds pointer for struct _sas_device, struct _raid_device or
  601. * struct _pcie_device
  602. */
  603. struct _boot_device {
  604. int channel;
  605. void *device;
  606. };
  607. /**
  608. * struct _sas_port - wide/narrow sas port information
  609. * @port_list: list of ports belonging to expander
  610. * @num_phys: number of phys belonging to this port
  611. * @remote_identify: attached device identification
  612. * @rphy: sas transport rphy object
  613. * @port: sas transport wide/narrow port object
  614. * @phy_list: _sas_phy list objects belonging to this port
  615. */
  616. struct _sas_port {
  617. struct list_head port_list;
  618. u8 num_phys;
  619. struct sas_identify remote_identify;
  620. struct sas_rphy *rphy;
  621. struct sas_port *port;
  622. struct list_head phy_list;
  623. };
  624. /**
  625. * struct _sas_phy - phy information
  626. * @port_siblings: list of phys belonging to a port
  627. * @identify: phy identification
  628. * @remote_identify: attached device identification
  629. * @phy: sas transport phy object
  630. * @phy_id: unique phy id
  631. * @handle: device handle for this phy
  632. * @attached_handle: device handle for attached device
  633. * @phy_belongs_to_port: port has been created for this phy
  634. */
  635. struct _sas_phy {
  636. struct list_head port_siblings;
  637. struct sas_identify identify;
  638. struct sas_identify remote_identify;
  639. struct sas_phy *phy;
  640. u8 phy_id;
  641. u16 handle;
  642. u16 attached_handle;
  643. u8 phy_belongs_to_port;
  644. };
  645. /**
  646. * struct _sas_node - sas_host/expander information
  647. * @list: list of expanders
  648. * @parent_dev: parent device class
  649. * @num_phys: number phys belonging to this sas_host/expander
  650. * @sas_address: sas address of this sas_host/expander
  651. * @handle: handle for this sas_host/expander
  652. * @sas_address_parent: sas address of parent expander or sas host
  653. * @enclosure_handle: handle for this a member of an enclosure
  654. * @device_info: bitwise defining capabilities of this sas_host/expander
  655. * @responding: used in _scsih_expander_device_mark_responding
  656. * @phy: a list of phys that make up this sas_host/expander
  657. * @sas_port_list: list of ports attached to this sas_host/expander
  658. */
  659. struct _sas_node {
  660. struct list_head list;
  661. struct device *parent_dev;
  662. u8 num_phys;
  663. u64 sas_address;
  664. u16 handle;
  665. u64 sas_address_parent;
  666. u16 enclosure_handle;
  667. u64 enclosure_logical_id;
  668. u8 responding;
  669. struct _sas_phy *phy;
  670. struct list_head sas_port_list;
  671. };
  672. /**
  673. * enum reset_type - reset state
  674. * @FORCE_BIG_HAMMER: issue diagnostic reset
  675. * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
  676. */
  677. enum reset_type {
  678. FORCE_BIG_HAMMER,
  679. SOFT_RESET,
  680. };
  681. /**
  682. * struct pcie_sg_list - PCIe SGL buffer (contiguous per I/O)
  683. * @pcie_sgl: PCIe native SGL for NVMe devices
  684. * @pcie_sgl_dma: physical address
  685. */
  686. struct pcie_sg_list {
  687. void *pcie_sgl;
  688. dma_addr_t pcie_sgl_dma;
  689. };
  690. /**
  691. * struct chain_tracker - firmware chain tracker
  692. * @chain_buffer: chain buffer
  693. * @chain_buffer_dma: physical address
  694. * @tracker_list: list of free request (ioc->free_chain_list)
  695. */
  696. struct chain_tracker {
  697. void *chain_buffer;
  698. dma_addr_t chain_buffer_dma;
  699. struct list_head tracker_list;
  700. };
  701. /**
  702. * struct scsiio_tracker - scsi mf request tracker
  703. * @smid: system message id
  704. * @scmd: scsi request pointer
  705. * @cb_idx: callback index
  706. * @direct_io: To indicate whether I/O is direct (WARPDRIVE)
  707. * @tracker_list: list of free request (ioc->free_list)
  708. * @msix_io: IO's msix
  709. */
  710. struct scsiio_tracker {
  711. u16 smid;
  712. struct scsi_cmnd *scmd;
  713. u8 cb_idx;
  714. u8 direct_io;
  715. struct pcie_sg_list pcie_sg_list;
  716. struct list_head chain_list;
  717. struct list_head tracker_list;
  718. u16 msix_io;
  719. };
  720. /**
  721. * struct request_tracker - firmware request tracker
  722. * @smid: system message id
  723. * @cb_idx: callback index
  724. * @tracker_list: list of free request (ioc->free_list)
  725. */
  726. struct request_tracker {
  727. u16 smid;
  728. u8 cb_idx;
  729. struct list_head tracker_list;
  730. };
  731. /**
  732. * struct _tr_list - target reset list
  733. * @handle: device handle
  734. * @state: state machine
  735. */
  736. struct _tr_list {
  737. struct list_head list;
  738. u16 handle;
  739. u16 state;
  740. };
  741. /**
  742. * struct _sc_list - delayed SAS_IO_UNIT_CONTROL message list
  743. * @handle: device handle
  744. */
  745. struct _sc_list {
  746. struct list_head list;
  747. u16 handle;
  748. };
  749. /**
  750. * struct _event_ack_list - delayed event acknowledgment list
  751. * @Event: Event ID
  752. * @EventContext: used to track the event uniquely
  753. */
  754. struct _event_ack_list {
  755. struct list_head list;
  756. u16 Event;
  757. u32 EventContext;
  758. };
  759. /**
  760. * struct adapter_reply_queue - the reply queue struct
  761. * @ioc: per adapter object
  762. * @msix_index: msix index into vector table
  763. * @vector: irq vector
  764. * @reply_post_host_index: head index in the pool where FW completes IO
  765. * @reply_post_free: reply post base virt address
  766. * @name: the name registered to request_irq()
  767. * @busy: isr is actively processing replies on another cpu
  768. * @list: this list
  769. */
  770. struct adapter_reply_queue {
  771. struct MPT3SAS_ADAPTER *ioc;
  772. u8 msix_index;
  773. u32 reply_post_host_index;
  774. Mpi2ReplyDescriptorsUnion_t *reply_post_free;
  775. char name[MPT_NAME_LENGTH];
  776. atomic_t busy;
  777. struct list_head list;
  778. };
  779. typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
  780. /* SAS3.0 support */
  781. typedef int (*MPT_BUILD_SG_SCMD)(struct MPT3SAS_ADAPTER *ioc,
  782. struct scsi_cmnd *scmd, u16 smid, struct _pcie_device *pcie_device);
  783. typedef void (*MPT_BUILD_SG)(struct MPT3SAS_ADAPTER *ioc, void *psge,
  784. dma_addr_t data_out_dma, size_t data_out_sz,
  785. dma_addr_t data_in_dma, size_t data_in_sz);
  786. typedef void (*MPT_BUILD_ZERO_LEN_SGE)(struct MPT3SAS_ADAPTER *ioc,
  787. void *paddr);
  788. /* SAS3.5 support */
  789. typedef void (*NVME_BUILD_PRP)(struct MPT3SAS_ADAPTER *ioc, u16 smid,
  790. Mpi26NVMeEncapsulatedRequest_t *nvme_encap_request,
  791. dma_addr_t data_out_dma, size_t data_out_sz, dma_addr_t data_in_dma,
  792. size_t data_in_sz);
  793. /* To support atomic and non atomic descriptors*/
  794. typedef void (*PUT_SMID_IO_FP_HIP) (struct MPT3SAS_ADAPTER *ioc, u16 smid,
  795. u16 funcdep);
  796. typedef void (*PUT_SMID_DEFAULT) (struct MPT3SAS_ADAPTER *ioc, u16 smid);
  797. /* IOC Facts and Port Facts converted from little endian to cpu */
  798. union mpi3_version_union {
  799. MPI2_VERSION_STRUCT Struct;
  800. u32 Word;
  801. };
  802. struct mpt3sas_facts {
  803. u16 MsgVersion;
  804. u16 HeaderVersion;
  805. u8 IOCNumber;
  806. u8 VP_ID;
  807. u8 VF_ID;
  808. u16 IOCExceptions;
  809. u16 IOCStatus;
  810. u32 IOCLogInfo;
  811. u8 MaxChainDepth;
  812. u8 WhoInit;
  813. u8 NumberOfPorts;
  814. u8 MaxMSIxVectors;
  815. u16 RequestCredit;
  816. u16 ProductID;
  817. u32 IOCCapabilities;
  818. union mpi3_version_union FWVersion;
  819. u16 IOCRequestFrameSize;
  820. u16 IOCMaxChainSegmentSize;
  821. u16 MaxInitiators;
  822. u16 MaxTargets;
  823. u16 MaxSasExpanders;
  824. u16 MaxEnclosures;
  825. u16 ProtocolFlags;
  826. u16 HighPriorityCredit;
  827. u16 MaxReplyDescriptorPostQueueDepth;
  828. u8 ReplyFrameSize;
  829. u8 MaxVolumes;
  830. u16 MaxDevHandle;
  831. u16 MaxPersistentEntries;
  832. u16 MinDevHandle;
  833. u8 CurrentHostPageSize;
  834. };
  835. struct mpt3sas_port_facts {
  836. u8 PortNumber;
  837. u8 VP_ID;
  838. u8 VF_ID;
  839. u8 PortType;
  840. u16 MaxPostedCmdBuffers;
  841. };
  842. struct reply_post_struct {
  843. Mpi2ReplyDescriptorsUnion_t *reply_post_free;
  844. dma_addr_t reply_post_free_dma;
  845. };
  846. typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc);
  847. /**
  848. * struct MPT3SAS_ADAPTER - per adapter struct
  849. * @list: ioc_list
  850. * @shost: shost object
  851. * @id: unique adapter id
  852. * @cpu_count: number online cpus
  853. * @name: generic ioc string
  854. * @tmp_string: tmp string used for logging
  855. * @pdev: pci pdev object
  856. * @pio_chip: physical io register space
  857. * @chip: memory mapped register space
  858. * @chip_phys: physical addrss prior to mapping
  859. * @logging_level: see mpt3sas_debug.h
  860. * @fwfault_debug: debuging FW timeouts
  861. * @ir_firmware: IR firmware present
  862. * @bars: bitmask of BAR's that must be configured
  863. * @mask_interrupts: ignore interrupt
  864. * @dma_mask: used to set the consistent dma mask
  865. * @pci_access_mutex: Mutex to synchronize ioctl, sysfs show path and
  866. * pci resource handling
  867. * @fault_reset_work_q_name: fw fault work queue
  868. * @fault_reset_work_q: ""
  869. * @fault_reset_work: ""
  870. * @firmware_event_name: fw event work queue
  871. * @firmware_event_thread: ""
  872. * @fw_event_lock:
  873. * @fw_event_list: list of fw events
  874. * @aen_event_read_flag: event log was read
  875. * @broadcast_aen_busy: broadcast aen waiting to be serviced
  876. * @shost_recovery: host reset in progress
  877. * @ioc_reset_in_progress_lock:
  878. * @ioc_link_reset_in_progress: phy/hard reset in progress
  879. * @ignore_loginfos: ignore loginfos during task management
  880. * @remove_host: flag for when driver unloads, to avoid sending dev resets
  881. * @pci_error_recovery: flag to prevent ioc access until slot reset completes
  882. * @wait_for_discovery_to_complete: flag set at driver load time when
  883. * waiting on reporting devices
  884. * @is_driver_loading: flag set at driver load time
  885. * @port_enable_failed: flag set when port enable has failed
  886. * @start_scan: flag set from scan_start callback, cleared from _mpt3sas_fw_work
  887. * @start_scan_failed: means port enable failed, return's the ioc_status
  888. * @msix_enable: flag indicating msix is enabled
  889. * @msix_vector_count: number msix vectors
  890. * @cpu_msix_table: table for mapping cpus to msix index
  891. * @cpu_msix_table_sz: table size
  892. * @schedule_dead_ioc_flush_running_cmds: callback to flush pending commands
  893. * @scsi_io_cb_idx: shost generated commands
  894. * @tm_cb_idx: task management commands
  895. * @scsih_cb_idx: scsih internal commands
  896. * @transport_cb_idx: transport internal commands
  897. * @ctl_cb_idx: clt internal commands
  898. * @base_cb_idx: base internal commands
  899. * @config_cb_idx: base internal commands
  900. * @tm_tr_cb_idx : device removal target reset handshake
  901. * @tm_tr_volume_cb_idx : volume removal target reset
  902. * @base_cmds:
  903. * @transport_cmds:
  904. * @scsih_cmds:
  905. * @tm_cmds:
  906. * @ctl_cmds:
  907. * @config_cmds:
  908. * @base_add_sg_single: handler for either 32/64 bit sgl's
  909. * @event_type: bits indicating which events to log
  910. * @event_context: unique id for each logged event
  911. * @event_log: event log pointer
  912. * @event_masks: events that are masked
  913. * @facts: static facts data
  914. * @pfacts: static port facts data
  915. * @manu_pg0: static manufacturing page 0
  916. * @manu_pg10: static manufacturing page 10
  917. * @manu_pg11: static manufacturing page 11
  918. * @bios_pg2: static bios page 2
  919. * @bios_pg3: static bios page 3
  920. * @ioc_pg8: static ioc page 8
  921. * @iounit_pg0: static iounit page 0
  922. * @iounit_pg1: static iounit page 1
  923. * @iounit_pg8: static iounit page 8
  924. * @sas_hba: sas host object
  925. * @sas_expander_list: expander object list
  926. * @sas_node_lock:
  927. * @sas_device_list: sas device object list
  928. * @sas_device_init_list: sas device object list (used only at init time)
  929. * @sas_device_lock:
  930. * @pcie_device_list: pcie device object list
  931. * @pcie_device_init_list: pcie device object list (used only at init time)
  932. * @pcie_device_lock:
  933. * @io_missing_delay: time for IO completed by fw when PDR enabled
  934. * @device_missing_delay: time for device missing by fw when PDR enabled
  935. * @sas_id : used for setting volume target IDs
  936. * @pcie_target_id: used for setting pcie target IDs
  937. * @blocking_handles: bitmask used to identify which devices need blocking
  938. * @pd_handles : bitmask for PD handles
  939. * @pd_handles_sz : size of pd_handle bitmask
  940. * @config_page_sz: config page size
  941. * @config_page: reserve memory for config page payload
  942. * @config_page_dma:
  943. * @hba_queue_depth: hba request queue depth
  944. * @sge_size: sg element size for either 32/64 bit
  945. * @scsiio_depth: SCSI_IO queue depth
  946. * @request_sz: per request frame size
  947. * @request: pool of request frames
  948. * @request_dma:
  949. * @request_dma_sz:
  950. * @scsi_lookup: firmware request tracker list
  951. * @scsi_lookup_lock:
  952. * @free_list: free list of request
  953. * @pending_io_count:
  954. * @reset_wq:
  955. * @chain: pool of chains
  956. * @chain_dma:
  957. * @max_sges_in_main_message: number sg elements in main message
  958. * @max_sges_in_chain_message: number sg elements per chain
  959. * @chains_needed_per_io: max chains per io
  960. * @chain_depth: total chains allocated
  961. * @chain_segment_sz: gives the max number of
  962. * SGEs accommodate on single chain buffer
  963. * @hi_priority_smid:
  964. * @hi_priority:
  965. * @hi_priority_dma:
  966. * @hi_priority_depth:
  967. * @hpr_lookup:
  968. * @hpr_free_list:
  969. * @internal_smid:
  970. * @internal:
  971. * @internal_dma:
  972. * @internal_depth:
  973. * @internal_lookup:
  974. * @internal_free_list:
  975. * @sense: pool of sense
  976. * @sense_dma:
  977. * @sense_dma_pool:
  978. * @reply_depth: hba reply queue depth:
  979. * @reply_sz: per reply frame size:
  980. * @reply: pool of replys:
  981. * @reply_dma:
  982. * @reply_dma_pool:
  983. * @reply_free_queue_depth: reply free depth
  984. * @reply_free: pool for reply free queue (32 bit addr)
  985. * @reply_free_dma:
  986. * @reply_free_dma_pool:
  987. * @reply_free_host_index: tail index in pool to insert free replys
  988. * @reply_post_queue_depth: reply post queue depth
  989. * @reply_post_struct: struct for reply_post_free physical & virt address
  990. * @rdpq_array_capable: FW supports multiple reply queue addresses in ioc_init
  991. * @rdpq_array_enable: rdpq_array support is enabled in the driver
  992. * @rdpq_array_enable_assigned: this ensures that rdpq_array_enable flag
  993. * is assigned only ones
  994. * @reply_queue_count: number of reply queue's
  995. * @reply_queue_list: link list contaning the reply queue info
  996. * @msix96_vector: 96 MSI-X vector support
  997. * @replyPostRegisterIndex: index of next position in Reply Desc Post Queue
  998. * @delayed_tr_list: target reset link list
  999. * @delayed_tr_volume_list: volume target reset link list
  1000. * @delayed_sc_list:
  1001. * @delayed_event_ack_list:
  1002. * @temp_sensors_count: flag to carry the number of temperature sensors
  1003. * @pci_access_mutex: Mutex to synchronize ioctl,sysfs show path and
  1004. * pci resource handling. PCI resource freeing will lead to free
  1005. * vital hardware/memory resource, which might be in use by cli/sysfs
  1006. * path functions resulting in Null pointer reference followed by kernel
  1007. * crash. To avoid the above race condition we use mutex syncrhonization
  1008. * which ensures the syncrhonization between cli/sysfs_show path.
  1009. */
  1010. struct MPT3SAS_ADAPTER {
  1011. struct list_head list;
  1012. struct Scsi_Host *shost;
  1013. u8 id;
  1014. int cpu_count;
  1015. char name[MPT_NAME_LENGTH];
  1016. char driver_name[MPT_NAME_LENGTH - 8];
  1017. char tmp_string[MPT_STRING_LENGTH];
  1018. struct pci_dev *pdev;
  1019. Mpi2SystemInterfaceRegs_t __iomem *chip;
  1020. resource_size_t chip_phys;
  1021. int logging_level;
  1022. int fwfault_debug;
  1023. u8 ir_firmware;
  1024. int bars;
  1025. u8 mask_interrupts;
  1026. int dma_mask;
  1027. /* fw fault handler */
  1028. char fault_reset_work_q_name[20];
  1029. struct workqueue_struct *fault_reset_work_q;
  1030. struct delayed_work fault_reset_work;
  1031. /* fw event handler */
  1032. char firmware_event_name[20];
  1033. struct workqueue_struct *firmware_event_thread;
  1034. spinlock_t fw_event_lock;
  1035. struct list_head fw_event_list;
  1036. /* misc flags */
  1037. int aen_event_read_flag;
  1038. u8 broadcast_aen_busy;
  1039. u16 broadcast_aen_pending;
  1040. u8 shost_recovery;
  1041. u8 got_task_abort_from_ioctl;
  1042. struct mutex reset_in_progress_mutex;
  1043. spinlock_t ioc_reset_in_progress_lock;
  1044. u8 ioc_link_reset_in_progress;
  1045. u8 ioc_reset_in_progress_status;
  1046. u8 ignore_loginfos;
  1047. u8 remove_host;
  1048. u8 pci_error_recovery;
  1049. u8 wait_for_discovery_to_complete;
  1050. u8 is_driver_loading;
  1051. u8 port_enable_failed;
  1052. u8 start_scan;
  1053. u16 start_scan_failed;
  1054. u8 msix_enable;
  1055. u16 msix_vector_count;
  1056. u8 *cpu_msix_table;
  1057. u16 cpu_msix_table_sz;
  1058. resource_size_t __iomem **reply_post_host_index;
  1059. u32 ioc_reset_count;
  1060. MPT3SAS_FLUSH_RUNNING_CMDS schedule_dead_ioc_flush_running_cmds;
  1061. u32 non_operational_loop;
  1062. /* internal commands, callback index */
  1063. u8 scsi_io_cb_idx;
  1064. u8 tm_cb_idx;
  1065. u8 transport_cb_idx;
  1066. u8 scsih_cb_idx;
  1067. u8 ctl_cb_idx;
  1068. u8 base_cb_idx;
  1069. u8 port_enable_cb_idx;
  1070. u8 config_cb_idx;
  1071. u8 tm_tr_cb_idx;
  1072. u8 tm_tr_volume_cb_idx;
  1073. u8 tm_sas_control_cb_idx;
  1074. struct _internal_cmd base_cmds;
  1075. struct _internal_cmd port_enable_cmds;
  1076. struct _internal_cmd transport_cmds;
  1077. struct _internal_cmd scsih_cmds;
  1078. struct _internal_cmd tm_cmds;
  1079. struct _internal_cmd ctl_cmds;
  1080. struct _internal_cmd config_cmds;
  1081. MPT_ADD_SGE base_add_sg_single;
  1082. /* function ptr for either IEEE or MPI sg elements */
  1083. MPT_BUILD_SG_SCMD build_sg_scmd;
  1084. MPT_BUILD_SG build_sg;
  1085. MPT_BUILD_ZERO_LEN_SGE build_zero_len_sge;
  1086. u16 sge_size_ieee;
  1087. u16 hba_mpi_version_belonged;
  1088. /* function ptr for MPI sg elements only */
  1089. MPT_BUILD_SG build_sg_mpi;
  1090. MPT_BUILD_ZERO_LEN_SGE build_zero_len_sge_mpi;
  1091. /* function ptr for NVMe PRP elements only */
  1092. NVME_BUILD_PRP build_nvme_prp;
  1093. /* event log */
  1094. u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  1095. u32 event_context;
  1096. void *event_log;
  1097. u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  1098. /* static config pages */
  1099. struct mpt3sas_facts facts;
  1100. struct mpt3sas_port_facts *pfacts;
  1101. Mpi2ManufacturingPage0_t manu_pg0;
  1102. struct Mpi2ManufacturingPage10_t manu_pg10;
  1103. struct Mpi2ManufacturingPage11_t manu_pg11;
  1104. Mpi2BiosPage2_t bios_pg2;
  1105. Mpi2BiosPage3_t bios_pg3;
  1106. Mpi2IOCPage8_t ioc_pg8;
  1107. Mpi2IOUnitPage0_t iounit_pg0;
  1108. Mpi2IOUnitPage1_t iounit_pg1;
  1109. Mpi2IOUnitPage8_t iounit_pg8;
  1110. struct _boot_device req_boot_device;
  1111. struct _boot_device req_alt_boot_device;
  1112. struct _boot_device current_boot_device;
  1113. /* sas hba, expander, and device list */
  1114. struct _sas_node sas_hba;
  1115. struct list_head sas_expander_list;
  1116. spinlock_t sas_node_lock;
  1117. struct list_head sas_device_list;
  1118. struct list_head sas_device_init_list;
  1119. spinlock_t sas_device_lock;
  1120. struct list_head pcie_device_list;
  1121. struct list_head pcie_device_init_list;
  1122. spinlock_t pcie_device_lock;
  1123. struct list_head raid_device_list;
  1124. spinlock_t raid_device_lock;
  1125. u8 io_missing_delay;
  1126. u16 device_missing_delay;
  1127. int sas_id;
  1128. int pcie_target_id;
  1129. void *blocking_handles;
  1130. void *pd_handles;
  1131. u16 pd_handles_sz;
  1132. void *pend_os_device_add;
  1133. u16 pend_os_device_add_sz;
  1134. /* config page */
  1135. u16 config_page_sz;
  1136. void *config_page;
  1137. dma_addr_t config_page_dma;
  1138. /* scsiio request */
  1139. u16 hba_queue_depth;
  1140. u16 sge_size;
  1141. u16 scsiio_depth;
  1142. u16 request_sz;
  1143. u8 *request;
  1144. dma_addr_t request_dma;
  1145. u32 request_dma_sz;
  1146. struct scsiio_tracker *scsi_lookup;
  1147. ulong scsi_lookup_pages;
  1148. spinlock_t scsi_lookup_lock;
  1149. struct list_head free_list;
  1150. int pending_io_count;
  1151. wait_queue_head_t reset_wq;
  1152. /* PCIe SGL */
  1153. struct dma_pool *pcie_sgl_dma_pool;
  1154. /* Host Page Size */
  1155. u32 page_size;
  1156. /* chain */
  1157. struct chain_tracker *chain_lookup;
  1158. struct list_head free_chain_list;
  1159. struct dma_pool *chain_dma_pool;
  1160. ulong chain_pages;
  1161. u16 max_sges_in_main_message;
  1162. u16 max_sges_in_chain_message;
  1163. u16 chains_needed_per_io;
  1164. u32 chain_depth;
  1165. u16 chain_segment_sz;
  1166. /* hi-priority queue */
  1167. u16 hi_priority_smid;
  1168. u8 *hi_priority;
  1169. dma_addr_t hi_priority_dma;
  1170. u16 hi_priority_depth;
  1171. struct request_tracker *hpr_lookup;
  1172. struct list_head hpr_free_list;
  1173. /* internal queue */
  1174. u16 internal_smid;
  1175. u8 *internal;
  1176. dma_addr_t internal_dma;
  1177. u16 internal_depth;
  1178. struct request_tracker *internal_lookup;
  1179. struct list_head internal_free_list;
  1180. /* sense */
  1181. u8 *sense;
  1182. dma_addr_t sense_dma;
  1183. struct dma_pool *sense_dma_pool;
  1184. /* reply */
  1185. u16 reply_sz;
  1186. u8 *reply;
  1187. dma_addr_t reply_dma;
  1188. u32 reply_dma_max_address;
  1189. u32 reply_dma_min_address;
  1190. struct dma_pool *reply_dma_pool;
  1191. /* reply free queue */
  1192. u16 reply_free_queue_depth;
  1193. __le32 *reply_free;
  1194. dma_addr_t reply_free_dma;
  1195. struct dma_pool *reply_free_dma_pool;
  1196. u32 reply_free_host_index;
  1197. /* reply post queue */
  1198. u16 reply_post_queue_depth;
  1199. struct reply_post_struct *reply_post;
  1200. u8 rdpq_array_capable;
  1201. u8 rdpq_array_enable;
  1202. u8 rdpq_array_enable_assigned;
  1203. struct dma_pool *reply_post_free_dma_pool;
  1204. u8 reply_queue_count;
  1205. struct list_head reply_queue_list;
  1206. u8 combined_reply_queue;
  1207. u8 combined_reply_index_count;
  1208. /* reply post register index */
  1209. resource_size_t **replyPostRegisterIndex;
  1210. struct list_head delayed_tr_list;
  1211. struct list_head delayed_tr_volume_list;
  1212. struct list_head delayed_sc_list;
  1213. struct list_head delayed_event_ack_list;
  1214. u8 temp_sensors_count;
  1215. struct mutex pci_access_mutex;
  1216. /* diag buffer support */
  1217. u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
  1218. u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
  1219. dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
  1220. u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
  1221. u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
  1222. u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
  1223. u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
  1224. u32 ring_buffer_offset;
  1225. u32 ring_buffer_sz;
  1226. u8 is_warpdrive;
  1227. u8 hide_ir_msg;
  1228. u8 mfg_pg10_hide_flag;
  1229. u8 hide_drives;
  1230. spinlock_t diag_trigger_lock;
  1231. u8 diag_trigger_active;
  1232. struct SL_WH_MASTER_TRIGGER_T diag_trigger_master;
  1233. struct SL_WH_EVENT_TRIGGERS_T diag_trigger_event;
  1234. struct SL_WH_SCSI_TRIGGERS_T diag_trigger_scsi;
  1235. struct SL_WH_MPI_TRIGGERS_T diag_trigger_mpi;
  1236. void *device_remove_in_progress;
  1237. u16 device_remove_in_progress_sz;
  1238. u8 is_gen35_ioc;
  1239. u8 atomic_desc_capable;
  1240. PUT_SMID_IO_FP_HIP put_smid_scsi_io;
  1241. PUT_SMID_IO_FP_HIP put_smid_fast_path;
  1242. PUT_SMID_IO_FP_HIP put_smid_hi_priority;
  1243. PUT_SMID_DEFAULT put_smid_default;
  1244. PUT_SMID_DEFAULT put_smid_nvme_encap;
  1245. };
  1246. typedef u8 (*MPT_CALLBACK)(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1247. u32 reply);
  1248. /* base shared API */
  1249. extern struct list_head mpt3sas_ioc_list;
  1250. extern char driver_name[MPT_NAME_LENGTH];
  1251. /* spinlock on list operations over IOCs
  1252. * Case: when multiple warpdrive cards(IOCs) are in use
  1253. * Each IOC will added to the ioc list structure on initialization.
  1254. * Watchdog threads run at regular intervals to check IOC for any
  1255. * fault conditions which will trigger the dead_ioc thread to
  1256. * deallocate pci resource, resulting deleting the IOC netry from list,
  1257. * this deletion need to protected by spinlock to enusre that
  1258. * ioc removal is syncrhonized, if not synchronized it might lead to
  1259. * list_del corruption as the ioc list is traversed in cli path.
  1260. */
  1261. extern spinlock_t gioc_lock;
  1262. void mpt3sas_base_start_watchdog(struct MPT3SAS_ADAPTER *ioc);
  1263. void mpt3sas_base_stop_watchdog(struct MPT3SAS_ADAPTER *ioc);
  1264. int mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc);
  1265. void mpt3sas_base_detach(struct MPT3SAS_ADAPTER *ioc);
  1266. int mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc);
  1267. void mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc);
  1268. int mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc,
  1269. enum reset_type type);
  1270. void *mpt3sas_base_get_msg_frame(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1271. void *mpt3sas_base_get_sense_buffer(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1272. __le32 mpt3sas_base_get_sense_buffer_dma(struct MPT3SAS_ADAPTER *ioc,
  1273. u16 smid);
  1274. void *mpt3sas_base_get_pcie_sgl(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1275. dma_addr_t mpt3sas_base_get_pcie_sgl_dma(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1276. void mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc);
  1277. /* hi-priority queue */
  1278. u16 mpt3sas_base_get_smid_hpr(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx);
  1279. u16 mpt3sas_base_get_smid_scsiio(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx,
  1280. struct scsi_cmnd *scmd);
  1281. u16 mpt3sas_base_get_smid(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx);
  1282. void mpt3sas_base_free_smid(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1283. void mpt3sas_base_initialize_callback_handler(void);
  1284. u8 mpt3sas_base_register_callback_handler(MPT_CALLBACK cb_func);
  1285. void mpt3sas_base_release_callback_handler(u8 cb_idx);
  1286. u8 mpt3sas_base_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1287. u32 reply);
  1288. u8 mpt3sas_port_enable_done(struct MPT3SAS_ADAPTER *ioc, u16 smid,
  1289. u8 msix_index, u32 reply);
  1290. void *mpt3sas_base_get_reply_virt_addr(struct MPT3SAS_ADAPTER *ioc,
  1291. u32 phys_addr);
  1292. u32 mpt3sas_base_get_iocstate(struct MPT3SAS_ADAPTER *ioc, int cooked);
  1293. void mpt3sas_base_fault_info(struct MPT3SAS_ADAPTER *ioc , u16 fault_code);
  1294. int mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc,
  1295. Mpi2SasIoUnitControlReply_t *mpi_reply,
  1296. Mpi2SasIoUnitControlRequest_t *mpi_request);
  1297. int mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc,
  1298. Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
  1299. void mpt3sas_base_validate_event_type(struct MPT3SAS_ADAPTER *ioc,
  1300. u32 *event_type);
  1301. void mpt3sas_halt_firmware(struct MPT3SAS_ADAPTER *ioc);
  1302. void mpt3sas_base_update_missing_delay(struct MPT3SAS_ADAPTER *ioc,
  1303. u16 device_missing_delay, u8 io_missing_delay);
  1304. int mpt3sas_port_enable(struct MPT3SAS_ADAPTER *ioc);
  1305. /* scsih shared API */
  1306. u8 mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
  1307. u32 reply);
  1308. void mpt3sas_scsih_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase);
  1309. int mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle,
  1310. uint channel, uint id, uint lun, u8 type, u16 smid_task,
  1311. ulong timeout);
  1312. int mpt3sas_scsih_issue_locked_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle,
  1313. uint channel, uint id, uint lun, u8 type, u16 smid_task,
  1314. ulong timeout);
  1315. void mpt3sas_scsih_set_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle);
  1316. void mpt3sas_scsih_clear_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle);
  1317. void mpt3sas_expander_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
  1318. void mpt3sas_device_remove_by_sas_address(struct MPT3SAS_ADAPTER *ioc,
  1319. u64 sas_address);
  1320. u8 mpt3sas_check_for_pending_internal_cmds(struct MPT3SAS_ADAPTER *ioc,
  1321. u16 smid);
  1322. struct _sas_node *mpt3sas_scsih_expander_find_by_handle(
  1323. struct MPT3SAS_ADAPTER *ioc, u16 handle);
  1324. struct _sas_node *mpt3sas_scsih_expander_find_by_sas_address(
  1325. struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
  1326. struct _sas_device *mpt3sas_get_sdev_by_addr(
  1327. struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
  1328. struct _sas_device *__mpt3sas_get_sdev_by_addr(
  1329. struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
  1330. struct _sas_device *mpt3sas_get_sdev_by_handle(struct MPT3SAS_ADAPTER *ioc,
  1331. u16 handle);
  1332. struct _pcie_device *mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc,
  1333. u16 handle);
  1334. void mpt3sas_port_enable_complete(struct MPT3SAS_ADAPTER *ioc);
  1335. struct _raid_device *
  1336. mpt3sas_raid_device_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle);
  1337. /* config shared API */
  1338. u8 mpt3sas_config_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1339. u32 reply);
  1340. int mpt3sas_config_get_number_hba_phys(struct MPT3SAS_ADAPTER *ioc,
  1341. u8 *num_phys);
  1342. int mpt3sas_config_get_manufacturing_pg0(struct MPT3SAS_ADAPTER *ioc,
  1343. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
  1344. int mpt3sas_config_get_manufacturing_pg7(struct MPT3SAS_ADAPTER *ioc,
  1345. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage7_t *config_page,
  1346. u16 sz);
  1347. int mpt3sas_config_get_manufacturing_pg10(struct MPT3SAS_ADAPTER *ioc,
  1348. Mpi2ConfigReply_t *mpi_reply,
  1349. struct Mpi2ManufacturingPage10_t *config_page);
  1350. int mpt3sas_config_get_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc,
  1351. Mpi2ConfigReply_t *mpi_reply,
  1352. struct Mpi2ManufacturingPage11_t *config_page);
  1353. int mpt3sas_config_set_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc,
  1354. Mpi2ConfigReply_t *mpi_reply,
  1355. struct Mpi2ManufacturingPage11_t *config_page);
  1356. int mpt3sas_config_get_bios_pg2(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1357. *mpi_reply, Mpi2BiosPage2_t *config_page);
  1358. int mpt3sas_config_get_bios_pg3(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1359. *mpi_reply, Mpi2BiosPage3_t *config_page);
  1360. int mpt3sas_config_get_iounit_pg0(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1361. *mpi_reply, Mpi2IOUnitPage0_t *config_page);
  1362. int mpt3sas_config_get_sas_device_pg0(struct MPT3SAS_ADAPTER *ioc,
  1363. Mpi2ConfigReply_t *mpi_reply, Mpi2SasDevicePage0_t *config_page,
  1364. u32 form, u32 handle);
  1365. int mpt3sas_config_get_sas_device_pg1(struct MPT3SAS_ADAPTER *ioc,
  1366. Mpi2ConfigReply_t *mpi_reply, Mpi2SasDevicePage1_t *config_page,
  1367. u32 form, u32 handle);
  1368. int mpt3sas_config_get_pcie_device_pg0(struct MPT3SAS_ADAPTER *ioc,
  1369. Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage0_t *config_page,
  1370. u32 form, u32 handle);
  1371. int mpt3sas_config_get_pcie_device_pg2(struct MPT3SAS_ADAPTER *ioc,
  1372. Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage2_t *config_page,
  1373. u32 form, u32 handle);
  1374. int mpt3sas_config_get_sas_iounit_pg0(struct MPT3SAS_ADAPTER *ioc,
  1375. Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage0_t *config_page,
  1376. u16 sz);
  1377. int mpt3sas_config_get_iounit_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1378. *mpi_reply, Mpi2IOUnitPage1_t *config_page);
  1379. int mpt3sas_config_get_iounit_pg3(struct MPT3SAS_ADAPTER *ioc,
  1380. Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage3_t *config_page, u16 sz);
  1381. int mpt3sas_config_set_iounit_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1382. *mpi_reply, Mpi2IOUnitPage1_t *config_page);
  1383. int mpt3sas_config_get_iounit_pg8(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1384. *mpi_reply, Mpi2IOUnitPage8_t *config_page);
  1385. int mpt3sas_config_get_sas_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
  1386. Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page,
  1387. u16 sz);
  1388. int mpt3sas_config_set_sas_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
  1389. Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page,
  1390. u16 sz);
  1391. int mpt3sas_config_get_ioc_pg8(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1392. *mpi_reply, Mpi2IOCPage8_t *config_page);
  1393. int mpt3sas_config_get_expander_pg0(struct MPT3SAS_ADAPTER *ioc,
  1394. Mpi2ConfigReply_t *mpi_reply, Mpi2ExpanderPage0_t *config_page,
  1395. u32 form, u32 handle);
  1396. int mpt3sas_config_get_expander_pg1(struct MPT3SAS_ADAPTER *ioc,
  1397. Mpi2ConfigReply_t *mpi_reply, Mpi2ExpanderPage1_t *config_page,
  1398. u32 phy_number, u16 handle);
  1399. int mpt3sas_config_get_enclosure_pg0(struct MPT3SAS_ADAPTER *ioc,
  1400. Mpi2ConfigReply_t *mpi_reply, Mpi2SasEnclosurePage0_t *config_page,
  1401. u32 form, u32 handle);
  1402. int mpt3sas_config_get_phy_pg0(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1403. *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
  1404. int mpt3sas_config_get_phy_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1405. *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
  1406. int mpt3sas_config_get_raid_volume_pg1(struct MPT3SAS_ADAPTER *ioc,
  1407. Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form,
  1408. u32 handle);
  1409. int mpt3sas_config_get_number_pds(struct MPT3SAS_ADAPTER *ioc, u16 handle,
  1410. u8 *num_pds);
  1411. int mpt3sas_config_get_raid_volume_pg0(struct MPT3SAS_ADAPTER *ioc,
  1412. Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form,
  1413. u32 handle, u16 sz);
  1414. int mpt3sas_config_get_phys_disk_pg0(struct MPT3SAS_ADAPTER *ioc,
  1415. Mpi2ConfigReply_t *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page,
  1416. u32 form, u32 form_specific);
  1417. int mpt3sas_config_get_volume_handle(struct MPT3SAS_ADAPTER *ioc, u16 pd_handle,
  1418. u16 *volume_handle);
  1419. int mpt3sas_config_get_volume_wwid(struct MPT3SAS_ADAPTER *ioc,
  1420. u16 volume_handle, u64 *wwid);
  1421. /* ctl shared API */
  1422. extern struct device_attribute *mpt3sas_host_attrs[];
  1423. extern struct device_attribute *mpt3sas_dev_attrs[];
  1424. void mpt3sas_ctl_init(ushort hbas_to_enumerate);
  1425. void mpt3sas_ctl_exit(ushort hbas_to_enumerate);
  1426. u8 mpt3sas_ctl_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1427. u32 reply);
  1428. void mpt3sas_ctl_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase);
  1429. u8 mpt3sas_ctl_event_callback(struct MPT3SAS_ADAPTER *ioc,
  1430. u8 msix_index, u32 reply);
  1431. void mpt3sas_ctl_add_to_event_log(struct MPT3SAS_ADAPTER *ioc,
  1432. Mpi2EventNotificationReply_t *mpi_reply);
  1433. void mpt3sas_enable_diag_buffer(struct MPT3SAS_ADAPTER *ioc,
  1434. u8 bits_to_register);
  1435. int mpt3sas_send_diag_release(struct MPT3SAS_ADAPTER *ioc, u8 buffer_type,
  1436. u8 *issue_reset);
  1437. /* transport shared API */
  1438. extern struct scsi_transport_template *mpt3sas_transport_template;
  1439. u8 mpt3sas_transport_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1440. u32 reply);
  1441. struct _sas_port *mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc,
  1442. u16 handle, u64 sas_address);
  1443. void mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
  1444. u64 sas_address_parent);
  1445. int mpt3sas_transport_add_host_phy(struct MPT3SAS_ADAPTER *ioc, struct _sas_phy
  1446. *mpt3sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
  1447. int mpt3sas_transport_add_expander_phy(struct MPT3SAS_ADAPTER *ioc,
  1448. struct _sas_phy *mpt3sas_phy, Mpi2ExpanderPage1_t expander_pg1,
  1449. struct device *parent_dev);
  1450. void mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc,
  1451. u64 sas_address, u16 handle, u8 phy_number, u8 link_rate);
  1452. extern struct sas_function_template mpt3sas_transport_functions;
  1453. extern struct scsi_transport_template *mpt3sas_transport_template;
  1454. /* trigger data externs */
  1455. void mpt3sas_send_trigger_data_event(struct MPT3SAS_ADAPTER *ioc,
  1456. struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
  1457. void mpt3sas_process_trigger_data(struct MPT3SAS_ADAPTER *ioc,
  1458. struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
  1459. void mpt3sas_trigger_master(struct MPT3SAS_ADAPTER *ioc,
  1460. u32 tigger_bitmask);
  1461. void mpt3sas_trigger_event(struct MPT3SAS_ADAPTER *ioc, u16 event,
  1462. u16 log_entry_qualifier);
  1463. void mpt3sas_trigger_scsi(struct MPT3SAS_ADAPTER *ioc, u8 sense_key,
  1464. u8 asc, u8 ascq);
  1465. void mpt3sas_trigger_mpi(struct MPT3SAS_ADAPTER *ioc, u16 ioc_status,
  1466. u32 loginfo);
  1467. /* warpdrive APIs */
  1468. u8 mpt3sas_get_num_volumes(struct MPT3SAS_ADAPTER *ioc);
  1469. void mpt3sas_init_warpdrive_properties(struct MPT3SAS_ADAPTER *ioc,
  1470. struct _raid_device *raid_device);
  1471. u8
  1472. mpt3sas_scsi_direct_io_get(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1473. void
  1474. mpt3sas_scsi_direct_io_set(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 direct_io);
  1475. void
  1476. mpt3sas_setup_direct_io(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
  1477. struct _raid_device *raid_device, Mpi25SCSIIORequest_t *mpi_request,
  1478. u16 smid);
  1479. /* NCQ Prio Handling Check */
  1480. bool scsih_ncq_prio_supp(struct scsi_device *sdev);
  1481. #endif /* MPT3SAS_BASE_H_INCLUDED */