mpt3sas_base.h 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072
  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: [email protected])
  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 "mpi/mpi2_image.h"
  55. #include <scsi/scsi.h>
  56. #include <scsi/scsi_cmnd.h>
  57. #include <scsi/scsi_device.h>
  58. #include <scsi/scsi_host.h>
  59. #include <scsi/scsi_tcq.h>
  60. #include <scsi/scsi_transport_sas.h>
  61. #include <scsi/scsi_dbg.h>
  62. #include <scsi/scsi_eh.h>
  63. #include <linux/pci.h>
  64. #include <linux/poll.h>
  65. #include <linux/irq_poll.h>
  66. #include "mpt3sas_debug.h"
  67. #include "mpt3sas_trigger_diag.h"
  68. #include "mpt3sas_trigger_pages.h"
  69. /* driver versioning info */
  70. #define MPT3SAS_DRIVER_NAME "mpt3sas"
  71. #define MPT3SAS_AUTHOR "Avago Technologies <[email protected]>"
  72. #define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver"
  73. #define MPT3SAS_DRIVER_VERSION "43.100.00.00"
  74. #define MPT3SAS_MAJOR_VERSION 43
  75. #define MPT3SAS_MINOR_VERSION 100
  76. #define MPT3SAS_BUILD_VERSION 0
  77. #define MPT3SAS_RELEASE_VERSION 00
  78. #define MPT2SAS_DRIVER_NAME "mpt2sas"
  79. #define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver"
  80. #define MPT2SAS_DRIVER_VERSION "20.102.00.00"
  81. #define MPT2SAS_MAJOR_VERSION 20
  82. #define MPT2SAS_MINOR_VERSION 102
  83. #define MPT2SAS_BUILD_VERSION 0
  84. #define MPT2SAS_RELEASE_VERSION 00
  85. /* CoreDump: Default timeout */
  86. #define MPT3SAS_DEFAULT_COREDUMP_TIMEOUT_SECONDS (15) /*15 seconds*/
  87. #define MPT3SAS_COREDUMP_LOOP_DONE (0xFF)
  88. #define MPT3SAS_TIMESYNC_TIMEOUT_SECONDS (10) /* 10 seconds */
  89. #define MPT3SAS_TIMESYNC_UPDATE_INTERVAL (900) /* 15 minutes */
  90. #define MPT3SAS_TIMESYNC_UNIT_MASK (0x80) /* bit 7 */
  91. #define MPT3SAS_TIMESYNC_MASK (0x7F) /* 0 - 6 bits */
  92. #define SECONDS_PER_MIN (60)
  93. #define SECONDS_PER_HOUR (3600)
  94. #define MPT3SAS_COREDUMP_LOOP_DONE (0xFF)
  95. #define MPI26_SET_IOC_PARAMETER_SYNC_TIMESTAMP (0x81)
  96. /*
  97. * Set MPT3SAS_SG_DEPTH value based on user input.
  98. */
  99. #define MPT_MAX_PHYS_SEGMENTS SG_CHUNK_SIZE
  100. #define MPT_MIN_PHYS_SEGMENTS 16
  101. #define MPT_KDUMP_MIN_PHYS_SEGMENTS 32
  102. #define MCPU_MAX_CHAINS_PER_IO 3
  103. #ifdef CONFIG_SCSI_MPT3SAS_MAX_SGE
  104. #define MPT3SAS_SG_DEPTH CONFIG_SCSI_MPT3SAS_MAX_SGE
  105. #else
  106. #define MPT3SAS_SG_DEPTH MPT_MAX_PHYS_SEGMENTS
  107. #endif
  108. #ifdef CONFIG_SCSI_MPT2SAS_MAX_SGE
  109. #define MPT2SAS_SG_DEPTH CONFIG_SCSI_MPT2SAS_MAX_SGE
  110. #else
  111. #define MPT2SAS_SG_DEPTH MPT_MAX_PHYS_SEGMENTS
  112. #endif
  113. /*
  114. * Generic Defines
  115. */
  116. #define MPT3SAS_SATA_QUEUE_DEPTH 32
  117. #define MPT3SAS_SAS_QUEUE_DEPTH 254
  118. #define MPT3SAS_RAID_QUEUE_DEPTH 128
  119. #define MPT3SAS_KDUMP_SCSI_IO_DEPTH 200
  120. #define MPT3SAS_RAID_MAX_SECTORS 8192
  121. #define MPT3SAS_HOST_PAGE_SIZE_4K 12
  122. #define MPT3SAS_NVME_QUEUE_DEPTH 128
  123. #define MPT_NAME_LENGTH 32 /* generic length of strings */
  124. #define MPT_STRING_LENGTH 64
  125. #define MPI_FRAME_START_OFFSET 256
  126. #define REPLY_FREE_POOL_SIZE 512 /*(32 maxcredix *4)*(4 times)*/
  127. #define MPT_MAX_CALLBACKS 32
  128. #define MPT_MAX_HBA_NUM_PHYS 32
  129. #define INTERNAL_CMDS_COUNT 10 /* reserved cmds */
  130. /* reserved for issuing internally framed scsi io cmds */
  131. #define INTERNAL_SCSIIO_CMDS_COUNT 3
  132. #define MPI3_HIM_MASK 0xFFFFFFFF /* mask every bit*/
  133. #define MPT3SAS_INVALID_DEVICE_HANDLE 0xFFFF
  134. #define MAX_CHAIN_ELEMT_SZ 16
  135. #define DEFAULT_NUM_FWCHAIN_ELEMTS 8
  136. #define IO_UNIT_CONTROL_SHUTDOWN_TIMEOUT 6
  137. #define FW_IMG_HDR_READ_TIMEOUT 15
  138. #define IOC_OPERATIONAL_WAIT_COUNT 10
  139. /*
  140. * NVMe defines
  141. */
  142. #define NVME_PRP_SIZE 8 /* PRP size */
  143. #define NVME_ERROR_RESPONSE_SIZE 16 /* Max NVME Error Response */
  144. #define NVME_TASK_ABORT_MIN_TIMEOUT 6
  145. #define NVME_TASK_ABORT_MAX_TIMEOUT 60
  146. #define NVME_TASK_MNGT_CUSTOM_MASK (0x0010)
  147. #define NVME_PRP_PAGE_SIZE 4096 /* Page size */
  148. struct mpt3sas_nvme_cmd {
  149. u8 rsvd[24];
  150. __le64 prp1;
  151. __le64 prp2;
  152. };
  153. /*
  154. * logging format
  155. */
  156. #define ioc_err(ioc, fmt, ...) \
  157. pr_err("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
  158. #define ioc_notice(ioc, fmt, ...) \
  159. pr_notice("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
  160. #define ioc_warn(ioc, fmt, ...) \
  161. pr_warn("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
  162. #define ioc_info(ioc, fmt, ...) \
  163. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
  164. /*
  165. * WarpDrive Specific Log codes
  166. */
  167. #define MPT2_WARPDRIVE_LOGENTRY (0x8002)
  168. #define MPT2_WARPDRIVE_LC_SSDT (0x41)
  169. #define MPT2_WARPDRIVE_LC_SSDLW (0x43)
  170. #define MPT2_WARPDRIVE_LC_SSDLF (0x44)
  171. #define MPT2_WARPDRIVE_LC_BRMF (0x4D)
  172. /*
  173. * per target private data
  174. */
  175. #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01
  176. #define MPT_TARGET_FLAGS_VOLUME 0x02
  177. #define MPT_TARGET_FLAGS_DELETED 0x04
  178. #define MPT_TARGET_FASTPATH_IO 0x08
  179. #define MPT_TARGET_FLAGS_PCIE_DEVICE 0x10
  180. #define SAS2_PCI_DEVICE_B0_REVISION (0x01)
  181. #define SAS3_PCI_DEVICE_C0_REVISION (0x02)
  182. /* Atlas PCIe Switch Management Port */
  183. #define MPI26_ATLAS_PCIe_SWITCH_DEVID (0x00B2)
  184. /*
  185. * Intel HBA branding
  186. */
  187. #define MPT2SAS_INTEL_RMS25JB080_BRANDING \
  188. "Intel(R) Integrated RAID Module RMS25JB080"
  189. #define MPT2SAS_INTEL_RMS25JB040_BRANDING \
  190. "Intel(R) Integrated RAID Module RMS25JB040"
  191. #define MPT2SAS_INTEL_RMS25KB080_BRANDING \
  192. "Intel(R) Integrated RAID Module RMS25KB080"
  193. #define MPT2SAS_INTEL_RMS25KB040_BRANDING \
  194. "Intel(R) Integrated RAID Module RMS25KB040"
  195. #define MPT2SAS_INTEL_RMS25LB040_BRANDING \
  196. "Intel(R) Integrated RAID Module RMS25LB040"
  197. #define MPT2SAS_INTEL_RMS25LB080_BRANDING \
  198. "Intel(R) Integrated RAID Module RMS25LB080"
  199. #define MPT2SAS_INTEL_RMS2LL080_BRANDING \
  200. "Intel Integrated RAID Module RMS2LL080"
  201. #define MPT2SAS_INTEL_RMS2LL040_BRANDING \
  202. "Intel Integrated RAID Module RMS2LL040"
  203. #define MPT2SAS_INTEL_RS25GB008_BRANDING \
  204. "Intel(R) RAID Controller RS25GB008"
  205. #define MPT2SAS_INTEL_SSD910_BRANDING \
  206. "Intel(R) SSD 910 Series"
  207. #define MPT3SAS_INTEL_RMS3JC080_BRANDING \
  208. "Intel(R) Integrated RAID Module RMS3JC080"
  209. #define MPT3SAS_INTEL_RS3GC008_BRANDING \
  210. "Intel(R) RAID Controller RS3GC008"
  211. #define MPT3SAS_INTEL_RS3FC044_BRANDING \
  212. "Intel(R) RAID Controller RS3FC044"
  213. #define MPT3SAS_INTEL_RS3UC080_BRANDING \
  214. "Intel(R) RAID Controller RS3UC080"
  215. /*
  216. * Intel HBA SSDIDs
  217. */
  218. #define MPT2SAS_INTEL_RMS25JB080_SSDID 0x3516
  219. #define MPT2SAS_INTEL_RMS25JB040_SSDID 0x3517
  220. #define MPT2SAS_INTEL_RMS25KB080_SSDID 0x3518
  221. #define MPT2SAS_INTEL_RMS25KB040_SSDID 0x3519
  222. #define MPT2SAS_INTEL_RMS25LB040_SSDID 0x351A
  223. #define MPT2SAS_INTEL_RMS25LB080_SSDID 0x351B
  224. #define MPT2SAS_INTEL_RMS2LL080_SSDID 0x350E
  225. #define MPT2SAS_INTEL_RMS2LL040_SSDID 0x350F
  226. #define MPT2SAS_INTEL_RS25GB008_SSDID 0x3000
  227. #define MPT2SAS_INTEL_SSD910_SSDID 0x3700
  228. #define MPT3SAS_INTEL_RMS3JC080_SSDID 0x3521
  229. #define MPT3SAS_INTEL_RS3GC008_SSDID 0x3522
  230. #define MPT3SAS_INTEL_RS3FC044_SSDID 0x3523
  231. #define MPT3SAS_INTEL_RS3UC080_SSDID 0x3524
  232. /*
  233. * Dell HBA branding
  234. */
  235. #define MPT2SAS_DELL_BRANDING_SIZE 32
  236. #define MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING "Dell 6Gbps SAS HBA"
  237. #define MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING "Dell PERC H200 Adapter"
  238. #define MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING "Dell PERC H200 Integrated"
  239. #define MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING "Dell PERC H200 Modular"
  240. #define MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING "Dell PERC H200 Embedded"
  241. #define MPT2SAS_DELL_PERC_H200_BRANDING "Dell PERC H200"
  242. #define MPT2SAS_DELL_6GBPS_SAS_BRANDING "Dell 6Gbps SAS"
  243. #define MPT3SAS_DELL_12G_HBA_BRANDING \
  244. "Dell 12Gbps HBA"
  245. /*
  246. * Dell HBA SSDIDs
  247. */
  248. #define MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID 0x1F1C
  249. #define MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID 0x1F1D
  250. #define MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID 0x1F1E
  251. #define MPT2SAS_DELL_PERC_H200_MODULAR_SSDID 0x1F1F
  252. #define MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID 0x1F20
  253. #define MPT2SAS_DELL_PERC_H200_SSDID 0x1F21
  254. #define MPT2SAS_DELL_6GBPS_SAS_SSDID 0x1F22
  255. #define MPT3SAS_DELL_12G_HBA_SSDID 0x1F46
  256. /*
  257. * Cisco HBA branding
  258. */
  259. #define MPT3SAS_CISCO_12G_8E_HBA_BRANDING \
  260. "Cisco 9300-8E 12G SAS HBA"
  261. #define MPT3SAS_CISCO_12G_8I_HBA_BRANDING \
  262. "Cisco 9300-8i 12G SAS HBA"
  263. #define MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING \
  264. "Cisco 12G Modular SAS Pass through Controller"
  265. #define MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_BRANDING \
  266. "UCS C3X60 12G SAS Pass through Controller"
  267. /*
  268. * Cisco HBA SSSDIDs
  269. */
  270. #define MPT3SAS_CISCO_12G_8E_HBA_SSDID 0x14C
  271. #define MPT3SAS_CISCO_12G_8I_HBA_SSDID 0x154
  272. #define MPT3SAS_CISCO_12G_AVILA_HBA_SSDID 0x155
  273. #define MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_SSDID 0x156
  274. /*
  275. * status bits for ioc->diag_buffer_status
  276. */
  277. #define MPT3_DIAG_BUFFER_IS_REGISTERED (0x01)
  278. #define MPT3_DIAG_BUFFER_IS_RELEASED (0x02)
  279. #define MPT3_DIAG_BUFFER_IS_DIAG_RESET (0x04)
  280. #define MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED (0x08)
  281. #define MPT3_DIAG_BUFFER_IS_APP_OWNED (0x10)
  282. /*
  283. * HP HBA branding
  284. */
  285. #define MPT2SAS_HP_3PAR_SSVID 0x1590
  286. #define MPT2SAS_HP_2_4_INTERNAL_BRANDING \
  287. "HP H220 Host Bus Adapter"
  288. #define MPT2SAS_HP_2_4_EXTERNAL_BRANDING \
  289. "HP H221 Host Bus Adapter"
  290. #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING \
  291. "HP H222 Host Bus Adapter"
  292. #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING \
  293. "HP H220i Host Bus Adapter"
  294. #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING \
  295. "HP H210i Host Bus Adapter"
  296. /*
  297. * HO HBA SSDIDs
  298. */
  299. #define MPT2SAS_HP_2_4_INTERNAL_SSDID 0x0041
  300. #define MPT2SAS_HP_2_4_EXTERNAL_SSDID 0x0042
  301. #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_SSDID 0x0043
  302. #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_SSDID 0x0044
  303. #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_SSDID 0x0046
  304. /*
  305. * Combined Reply Queue constants,
  306. * There are twelve Supplemental Reply Post Host Index Registers
  307. * and each register is at offset 0x10 bytes from the previous one.
  308. */
  309. #define MAX_COMBINED_MSIX_VECTORS(gen35) ((gen35 == 1) ? 16 : 8)
  310. #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G3 12
  311. #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G35 16
  312. #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET (0x10)
  313. #define MPT3_MIN_IRQS 1
  314. /* OEM Identifiers */
  315. #define MFG10_OEM_ID_INVALID (0x00000000)
  316. #define MFG10_OEM_ID_DELL (0x00000001)
  317. #define MFG10_OEM_ID_FSC (0x00000002)
  318. #define MFG10_OEM_ID_SUN (0x00000003)
  319. #define MFG10_OEM_ID_IBM (0x00000004)
  320. /* GENERIC Flags 0*/
  321. #define MFG10_GF0_OCE_DISABLED (0x00000001)
  322. #define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002)
  323. #define MFG10_GF0_R10_DISPLAY (0x00000004)
  324. #define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008)
  325. #define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010)
  326. #define VIRTUAL_IO_FAILED_RETRY (0x32010081)
  327. /* High IOPs definitions */
  328. #define MPT3SAS_DEVICE_HIGH_IOPS_DEPTH 8
  329. #define MPT3SAS_HIGH_IOPS_REPLY_QUEUES 8
  330. #define MPT3SAS_HIGH_IOPS_BATCH_COUNT 16
  331. #define MPT3SAS_GEN35_MAX_MSIX_QUEUES 128
  332. #define RDPQ_MAX_INDEX_IN_ONE_CHUNK 16
  333. /* OEM Specific Flags will come from OEM specific header files */
  334. struct Mpi2ManufacturingPage10_t {
  335. MPI2_CONFIG_PAGE_HEADER Header; /* 00h */
  336. U8 OEMIdentifier; /* 04h */
  337. U8 Reserved1; /* 05h */
  338. U16 Reserved2; /* 08h */
  339. U32 Reserved3; /* 0Ch */
  340. U32 GenericFlags0; /* 10h */
  341. U32 GenericFlags1; /* 14h */
  342. U32 Reserved4; /* 18h */
  343. U32 OEMSpecificFlags0; /* 1Ch */
  344. U32 OEMSpecificFlags1; /* 20h */
  345. U32 Reserved5[18]; /* 24h - 60h*/
  346. };
  347. /* Miscellaneous options */
  348. struct Mpi2ManufacturingPage11_t {
  349. MPI2_CONFIG_PAGE_HEADER Header; /* 00h */
  350. __le32 Reserved1; /* 04h */
  351. u8 Reserved2; /* 08h */
  352. u8 EEDPTagMode; /* 09h */
  353. u8 Reserved3; /* 0Ah */
  354. u8 Reserved4; /* 0Bh */
  355. __le32 Reserved5[8]; /* 0Ch-2Ch */
  356. u16 AddlFlags2; /* 2Ch */
  357. u8 AddlFlags3; /* 2Eh */
  358. u8 Reserved6; /* 2Fh */
  359. __le32 Reserved7[7]; /* 30h - 4Bh */
  360. u8 NVMeAbortTO; /* 4Ch */
  361. u8 NumPerDevEvents; /* 4Dh */
  362. u8 HostTraceBufferDecrementSizeKB; /* 4Eh */
  363. u8 HostTraceBufferFlags; /* 4Fh */
  364. u16 HostTraceBufferMaxSizeKB; /* 50h */
  365. u16 HostTraceBufferMinSizeKB; /* 52h */
  366. u8 CoreDumpTOSec; /* 54h */
  367. u8 TimeSyncInterval; /* 55h */
  368. u16 Reserved9; /* 56h */
  369. __le32 Reserved10; /* 58h */
  370. };
  371. /**
  372. * struct MPT3SAS_TARGET - starget private hostdata
  373. * @starget: starget object
  374. * @sas_address: target sas address
  375. * @raid_device: raid_device pointer to access volume data
  376. * @handle: device handle
  377. * @num_luns: number luns
  378. * @flags: MPT_TARGET_FLAGS_XXX flags
  379. * @deleted: target flaged for deletion
  380. * @tm_busy: target is busy with TM request.
  381. * @port: hba port entry containing target's port number info
  382. * @sas_dev: The sas_device associated with this target
  383. * @pcie_dev: The pcie device associated with this target
  384. */
  385. struct MPT3SAS_TARGET {
  386. struct scsi_target *starget;
  387. u64 sas_address;
  388. struct _raid_device *raid_device;
  389. u16 handle;
  390. int num_luns;
  391. u32 flags;
  392. u8 deleted;
  393. u8 tm_busy;
  394. struct hba_port *port;
  395. struct _sas_device *sas_dev;
  396. struct _pcie_device *pcie_dev;
  397. };
  398. /*
  399. * per device private data
  400. */
  401. #define MPT_DEVICE_FLAGS_INIT 0x01
  402. #define MFG_PAGE10_HIDE_SSDS_MASK (0x00000003)
  403. #define MFG_PAGE10_HIDE_ALL_DISKS (0x00)
  404. #define MFG_PAGE10_EXPOSE_ALL_DISKS (0x01)
  405. #define MFG_PAGE10_HIDE_IF_VOL_PRESENT (0x02)
  406. /**
  407. * struct MPT3SAS_DEVICE - sdev private hostdata
  408. * @sas_target: starget private hostdata
  409. * @lun: lun number
  410. * @flags: MPT_DEVICE_XXX flags
  411. * @configured_lun: lun is configured
  412. * @block: device is in SDEV_BLOCK state
  413. * @tlr_snoop_check: flag used in determining whether to disable TLR
  414. * @eedp_enable: eedp support enable bit
  415. * @eedp_type: 0(type_1), 1(type_2), 2(type_3)
  416. * @eedp_block_length: block size
  417. * @ata_command_pending: SATL passthrough outstanding for device
  418. */
  419. struct MPT3SAS_DEVICE {
  420. struct MPT3SAS_TARGET *sas_target;
  421. unsigned int lun;
  422. u32 flags;
  423. u8 configured_lun;
  424. u8 block;
  425. u8 tlr_snoop_check;
  426. u8 ignore_delay_remove;
  427. /* Iopriority Command Handling */
  428. u8 ncq_prio_enable;
  429. /*
  430. * Bug workaround for SATL handling: the mpt2/3sas firmware
  431. * doesn't return BUSY or TASK_SET_FULL for subsequent
  432. * commands while a SATL pass through is in operation as the
  433. * spec requires, it simply does nothing with them until the
  434. * pass through completes, causing them possibly to timeout if
  435. * the passthrough is a long executing command (like format or
  436. * secure erase). This variable allows us to do the right
  437. * thing while a SATL command is pending.
  438. */
  439. unsigned long ata_command_pending;
  440. };
  441. #define MPT3_CMD_NOT_USED 0x8000 /* free */
  442. #define MPT3_CMD_COMPLETE 0x0001 /* completed */
  443. #define MPT3_CMD_PENDING 0x0002 /* pending */
  444. #define MPT3_CMD_REPLY_VALID 0x0004 /* reply is valid */
  445. #define MPT3_CMD_RESET 0x0008 /* host reset dropped the command */
  446. #define MPT3_CMD_COMPLETE_ASYNC 0x0010 /* tells whether cmd completes in same thread or not */
  447. /**
  448. * struct _internal_cmd - internal commands struct
  449. * @mutex: mutex
  450. * @done: completion
  451. * @reply: reply message pointer
  452. * @sense: sense data
  453. * @status: MPT3_CMD_XXX status
  454. * @smid: system message id
  455. */
  456. struct _internal_cmd {
  457. struct mutex mutex;
  458. struct completion done;
  459. void *reply;
  460. void *sense;
  461. u16 status;
  462. u16 smid;
  463. };
  464. /**
  465. * struct _sas_device - attached device information
  466. * @list: sas device list
  467. * @starget: starget object
  468. * @sas_address: device sas address
  469. * @device_name: retrieved from the SAS IDENTIFY frame.
  470. * @handle: device handle
  471. * @sas_address_parent: sas address of parent expander or sas host
  472. * @enclosure_handle: enclosure handle
  473. * @enclosure_logical_id: enclosure logical identifier
  474. * @volume_handle: volume handle (valid when hidden raid member)
  475. * @volume_wwid: volume unique identifier
  476. * @device_info: bitfield provides detailed info about the device
  477. * @id: target id
  478. * @channel: target channel
  479. * @slot: number number
  480. * @phy: phy identifier provided in sas device page 0
  481. * @responding: used in _scsih_sas_device_mark_responding
  482. * @fast_path: fast path feature enable bit
  483. * @pfa_led_on: flag for PFA LED status
  484. * @pend_sas_rphy_add: flag to check if device is in sas_rphy_add()
  485. * addition routine.
  486. * @chassis_slot: chassis slot
  487. * @is_chassis_slot_valid: chassis slot valid or not
  488. * @port: hba port entry containing device's port number info
  489. * @rphy: device's sas_rphy address used to identify this device structure in
  490. * target_alloc callback function
  491. */
  492. struct _sas_device {
  493. struct list_head list;
  494. struct scsi_target *starget;
  495. u64 sas_address;
  496. u64 device_name;
  497. u16 handle;
  498. u64 sas_address_parent;
  499. u16 enclosure_handle;
  500. u64 enclosure_logical_id;
  501. u16 volume_handle;
  502. u64 volume_wwid;
  503. u32 device_info;
  504. int id;
  505. int channel;
  506. u16 slot;
  507. u8 phy;
  508. u8 responding;
  509. u8 fast_path;
  510. u8 pfa_led_on;
  511. u8 pend_sas_rphy_add;
  512. u8 enclosure_level;
  513. u8 chassis_slot;
  514. u8 is_chassis_slot_valid;
  515. u8 connector_name[5];
  516. struct kref refcount;
  517. u8 port_type;
  518. struct hba_port *port;
  519. struct sas_rphy *rphy;
  520. };
  521. static inline void sas_device_get(struct _sas_device *s)
  522. {
  523. kref_get(&s->refcount);
  524. }
  525. static inline void sas_device_free(struct kref *r)
  526. {
  527. kfree(container_of(r, struct _sas_device, refcount));
  528. }
  529. static inline void sas_device_put(struct _sas_device *s)
  530. {
  531. kref_put(&s->refcount, sas_device_free);
  532. }
  533. /*
  534. * struct _pcie_device - attached PCIe device information
  535. * @list: pcie device list
  536. * @starget: starget object
  537. * @wwid: device WWID
  538. * @handle: device handle
  539. * @device_info: bitfield provides detailed info about the device
  540. * @id: target id
  541. * @channel: target channel
  542. * @slot: slot number
  543. * @port_num: port number
  544. * @responding: used in _scsih_pcie_device_mark_responding
  545. * @fast_path: fast path feature enable bit
  546. * @nvme_mdts: MaximumDataTransferSize from PCIe Device Page 2 for
  547. * NVMe device only
  548. * @enclosure_handle: enclosure handle
  549. * @enclosure_logical_id: enclosure logical identifier
  550. * @enclosure_level: The level of device's enclosure from the controller
  551. * @connector_name: ASCII value of the Connector's name
  552. * @serial_number: pointer of serial number string allocated runtime
  553. * @access_status: Device's Access Status
  554. * @shutdown_latency: NVMe device's RTD3 Entry Latency
  555. * @refcount: reference count for deletion
  556. */
  557. struct _pcie_device {
  558. struct list_head list;
  559. struct scsi_target *starget;
  560. u64 wwid;
  561. u16 handle;
  562. u32 device_info;
  563. int id;
  564. int channel;
  565. u16 slot;
  566. u8 port_num;
  567. u8 responding;
  568. u8 fast_path;
  569. u32 nvme_mdts;
  570. u16 enclosure_handle;
  571. u64 enclosure_logical_id;
  572. u8 enclosure_level;
  573. u8 connector_name[4];
  574. u8 *serial_number;
  575. u8 reset_timeout;
  576. u8 access_status;
  577. u16 shutdown_latency;
  578. struct kref refcount;
  579. };
  580. /**
  581. * pcie_device_get - Increment the pcie device reference count
  582. *
  583. * @p: pcie_device object
  584. *
  585. * When ever this function called it will increment the
  586. * reference count of the pcie device for which this function called.
  587. *
  588. */
  589. static inline void pcie_device_get(struct _pcie_device *p)
  590. {
  591. kref_get(&p->refcount);
  592. }
  593. /**
  594. * pcie_device_free - Release the pcie device object
  595. * @r - kref object
  596. *
  597. * Free's the pcie device object. It will be called when reference count
  598. * reaches to zero.
  599. */
  600. static inline void pcie_device_free(struct kref *r)
  601. {
  602. kfree(container_of(r, struct _pcie_device, refcount));
  603. }
  604. /**
  605. * pcie_device_put - Decrement the pcie device reference count
  606. *
  607. * @p: pcie_device object
  608. *
  609. * When ever this function called it will decrement the
  610. * reference count of the pcie device for which this function called.
  611. *
  612. * When refernce count reaches to Zero, this will call pcie_device_free to the
  613. * pcie_device object.
  614. */
  615. static inline void pcie_device_put(struct _pcie_device *p)
  616. {
  617. kref_put(&p->refcount, pcie_device_free);
  618. }
  619. /**
  620. * struct _raid_device - raid volume link list
  621. * @list: sas device list
  622. * @starget: starget object
  623. * @sdev: scsi device struct (volumes are single lun)
  624. * @wwid: unique identifier for the volume
  625. * @handle: device handle
  626. * @block_size: Block size of the volume
  627. * @id: target id
  628. * @channel: target channel
  629. * @volume_type: the raid level
  630. * @device_info: bitfield provides detailed info about the hidden components
  631. * @num_pds: number of hidden raid components
  632. * @responding: used in _scsih_raid_device_mark_responding
  633. * @percent_complete: resync percent complete
  634. * @direct_io_enabled: Whether direct io to PDs are allowed or not
  635. * @stripe_exponent: X where 2powX is the stripe sz in blocks
  636. * @block_exponent: X where 2powX is the block sz in bytes
  637. * @max_lba: Maximum number of LBA in the volume
  638. * @stripe_sz: Stripe Size of the volume
  639. * @device_info: Device info of the volume member disk
  640. * @pd_handle: Array of handles of the physical drives for direct I/O in le16
  641. */
  642. #define MPT_MAX_WARPDRIVE_PDS 8
  643. struct _raid_device {
  644. struct list_head list;
  645. struct scsi_target *starget;
  646. struct scsi_device *sdev;
  647. u64 wwid;
  648. u16 handle;
  649. u16 block_sz;
  650. int id;
  651. int channel;
  652. u8 volume_type;
  653. u8 num_pds;
  654. u8 responding;
  655. u8 percent_complete;
  656. u8 direct_io_enabled;
  657. u8 stripe_exponent;
  658. u8 block_exponent;
  659. u64 max_lba;
  660. u32 stripe_sz;
  661. u32 device_info;
  662. u16 pd_handle[MPT_MAX_WARPDRIVE_PDS];
  663. };
  664. /**
  665. * struct _boot_device - boot device info
  666. *
  667. * @channel: sas, raid, or pcie channel
  668. * @device: holds pointer for struct _sas_device, struct _raid_device or
  669. * struct _pcie_device
  670. */
  671. struct _boot_device {
  672. int channel;
  673. void *device;
  674. };
  675. /**
  676. * struct _sas_port - wide/narrow sas port information
  677. * @port_list: list of ports belonging to expander
  678. * @num_phys: number of phys belonging to this port
  679. * @remote_identify: attached device identification
  680. * @rphy: sas transport rphy object
  681. * @port: sas transport wide/narrow port object
  682. * @hba_port: hba port entry containing port's port number info
  683. * @phy_list: _sas_phy list objects belonging to this port
  684. */
  685. struct _sas_port {
  686. struct list_head port_list;
  687. u8 num_phys;
  688. struct sas_identify remote_identify;
  689. struct sas_rphy *rphy;
  690. struct sas_port *port;
  691. struct hba_port *hba_port;
  692. struct list_head phy_list;
  693. };
  694. /**
  695. * struct _sas_phy - phy information
  696. * @port_siblings: list of phys belonging to a port
  697. * @identify: phy identification
  698. * @remote_identify: attached device identification
  699. * @phy: sas transport phy object
  700. * @phy_id: unique phy id
  701. * @handle: device handle for this phy
  702. * @attached_handle: device handle for attached device
  703. * @phy_belongs_to_port: port has been created for this phy
  704. * @port: hba port entry containing port number info
  705. */
  706. struct _sas_phy {
  707. struct list_head port_siblings;
  708. struct sas_identify identify;
  709. struct sas_identify remote_identify;
  710. struct sas_phy *phy;
  711. u8 phy_id;
  712. u16 handle;
  713. u16 attached_handle;
  714. u8 phy_belongs_to_port;
  715. u8 hba_vphy;
  716. struct hba_port *port;
  717. };
  718. /**
  719. * struct _sas_node - sas_host/expander information
  720. * @list: list of expanders
  721. * @parent_dev: parent device class
  722. * @num_phys: number phys belonging to this sas_host/expander
  723. * @sas_address: sas address of this sas_host/expander
  724. * @handle: handle for this sas_host/expander
  725. * @sas_address_parent: sas address of parent expander or sas host
  726. * @enclosure_handle: handle for this a member of an enclosure
  727. * @device_info: bitwise defining capabilities of this sas_host/expander
  728. * @responding: used in _scsih_expander_device_mark_responding
  729. * @nr_phys_allocated: Allocated memory for this many count phys
  730. * @phy: a list of phys that make up this sas_host/expander
  731. * @sas_port_list: list of ports attached to this sas_host/expander
  732. * @port: hba port entry containing node's port number info
  733. * @rphy: sas_rphy object of this expander
  734. */
  735. struct _sas_node {
  736. struct list_head list;
  737. struct device *parent_dev;
  738. u8 num_phys;
  739. u64 sas_address;
  740. u16 handle;
  741. u64 sas_address_parent;
  742. u16 enclosure_handle;
  743. u64 enclosure_logical_id;
  744. u8 responding;
  745. u8 nr_phys_allocated;
  746. struct hba_port *port;
  747. struct _sas_phy *phy;
  748. struct list_head sas_port_list;
  749. struct sas_rphy *rphy;
  750. };
  751. /**
  752. * struct _enclosure_node - enclosure information
  753. * @list: list of enclosures
  754. * @pg0: enclosure pg0;
  755. */
  756. struct _enclosure_node {
  757. struct list_head list;
  758. Mpi2SasEnclosurePage0_t pg0;
  759. };
  760. /**
  761. * enum reset_type - reset state
  762. * @FORCE_BIG_HAMMER: issue diagnostic reset
  763. * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
  764. */
  765. enum reset_type {
  766. FORCE_BIG_HAMMER,
  767. SOFT_RESET,
  768. };
  769. /**
  770. * struct pcie_sg_list - PCIe SGL buffer (contiguous per I/O)
  771. * @pcie_sgl: PCIe native SGL for NVMe devices
  772. * @pcie_sgl_dma: physical address
  773. */
  774. struct pcie_sg_list {
  775. void *pcie_sgl;
  776. dma_addr_t pcie_sgl_dma;
  777. };
  778. /**
  779. * struct chain_tracker - firmware chain tracker
  780. * @chain_buffer: chain buffer
  781. * @chain_buffer_dma: physical address
  782. * @tracker_list: list of free request (ioc->free_chain_list)
  783. */
  784. struct chain_tracker {
  785. void *chain_buffer;
  786. dma_addr_t chain_buffer_dma;
  787. };
  788. struct chain_lookup {
  789. struct chain_tracker *chains_per_smid;
  790. atomic_t chain_offset;
  791. };
  792. /**
  793. * struct scsiio_tracker - scsi mf request tracker
  794. * @smid: system message id
  795. * @cb_idx: callback index
  796. * @direct_io: To indicate whether I/O is direct (WARPDRIVE)
  797. * @chain_list: list of associated firmware chain tracker
  798. * @msix_io: IO's msix
  799. */
  800. struct scsiio_tracker {
  801. u16 smid;
  802. struct scsi_cmnd *scmd;
  803. u8 cb_idx;
  804. u8 direct_io;
  805. struct pcie_sg_list pcie_sg_list;
  806. struct list_head chain_list;
  807. u16 msix_io;
  808. };
  809. /**
  810. * struct request_tracker - firmware request tracker
  811. * @smid: system message id
  812. * @cb_idx: callback index
  813. * @tracker_list: list of free request (ioc->free_list)
  814. */
  815. struct request_tracker {
  816. u16 smid;
  817. u8 cb_idx;
  818. struct list_head tracker_list;
  819. };
  820. /**
  821. * struct _tr_list - target reset list
  822. * @handle: device handle
  823. * @state: state machine
  824. */
  825. struct _tr_list {
  826. struct list_head list;
  827. u16 handle;
  828. u16 state;
  829. };
  830. /**
  831. * struct _sc_list - delayed SAS_IO_UNIT_CONTROL message list
  832. * @handle: device handle
  833. */
  834. struct _sc_list {
  835. struct list_head list;
  836. u16 handle;
  837. };
  838. /**
  839. * struct _event_ack_list - delayed event acknowledgment list
  840. * @Event: Event ID
  841. * @EventContext: used to track the event uniquely
  842. */
  843. struct _event_ack_list {
  844. struct list_head list;
  845. U16 Event;
  846. U32 EventContext;
  847. };
  848. /**
  849. * struct adapter_reply_queue - the reply queue struct
  850. * @ioc: per adapter object
  851. * @msix_index: msix index into vector table
  852. * @vector: irq vector
  853. * @reply_post_host_index: head index in the pool where FW completes IO
  854. * @reply_post_free: reply post base virt address
  855. * @name: the name registered to request_irq()
  856. * @busy: isr is actively processing replies on another cpu
  857. * @os_irq: irq number
  858. * @irqpoll: irq_poll object
  859. * @irq_poll_scheduled: Tells whether irq poll is scheduled or not
  860. * @is_iouring_poll_q: Tells whether reply queues is assigned
  861. * to io uring poll queues or not
  862. * @list: this list
  863. */
  864. struct adapter_reply_queue {
  865. struct MPT3SAS_ADAPTER *ioc;
  866. u8 msix_index;
  867. u32 reply_post_host_index;
  868. Mpi2ReplyDescriptorsUnion_t *reply_post_free;
  869. char name[MPT_NAME_LENGTH];
  870. atomic_t busy;
  871. u32 os_irq;
  872. struct irq_poll irqpoll;
  873. bool irq_poll_scheduled;
  874. bool irq_line_enable;
  875. bool is_iouring_poll_q;
  876. struct list_head list;
  877. };
  878. /**
  879. * struct io_uring_poll_queue - the io uring poll queue structure
  880. * @busy: Tells whether io uring poll queue is busy or not
  881. * @pause: Tells whether IOs are paused on io uring poll queue or not
  882. * @reply_q: reply queue mapped for io uring poll queue
  883. */
  884. struct io_uring_poll_queue {
  885. atomic_t busy;
  886. atomic_t pause;
  887. struct adapter_reply_queue *reply_q;
  888. };
  889. typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
  890. /* SAS3.0 support */
  891. typedef int (*MPT_BUILD_SG_SCMD)(struct MPT3SAS_ADAPTER *ioc,
  892. struct scsi_cmnd *scmd, u16 smid, struct _pcie_device *pcie_device);
  893. typedef void (*MPT_BUILD_SG)(struct MPT3SAS_ADAPTER *ioc, void *psge,
  894. dma_addr_t data_out_dma, size_t data_out_sz,
  895. dma_addr_t data_in_dma, size_t data_in_sz);
  896. typedef void (*MPT_BUILD_ZERO_LEN_SGE)(struct MPT3SAS_ADAPTER *ioc,
  897. void *paddr);
  898. /* SAS3.5 support */
  899. typedef void (*NVME_BUILD_PRP)(struct MPT3SAS_ADAPTER *ioc, u16 smid,
  900. Mpi26NVMeEncapsulatedRequest_t *nvme_encap_request,
  901. dma_addr_t data_out_dma, size_t data_out_sz, dma_addr_t data_in_dma,
  902. size_t data_in_sz);
  903. /* To support atomic and non atomic descriptors*/
  904. typedef void (*PUT_SMID_IO_FP_HIP) (struct MPT3SAS_ADAPTER *ioc, u16 smid,
  905. u16 funcdep);
  906. typedef void (*PUT_SMID_DEFAULT) (struct MPT3SAS_ADAPTER *ioc, u16 smid);
  907. typedef u32 (*BASE_READ_REG) (const volatile void __iomem *addr);
  908. /*
  909. * To get high iops reply queue's msix index when high iops mode is enabled
  910. * else get the msix index of general reply queues.
  911. */
  912. typedef u8 (*GET_MSIX_INDEX) (struct MPT3SAS_ADAPTER *ioc,
  913. struct scsi_cmnd *scmd);
  914. /* IOC Facts and Port Facts converted from little endian to cpu */
  915. union mpi3_version_union {
  916. MPI2_VERSION_STRUCT Struct;
  917. u32 Word;
  918. };
  919. struct mpt3sas_facts {
  920. u16 MsgVersion;
  921. u16 HeaderVersion;
  922. u8 IOCNumber;
  923. u8 VP_ID;
  924. u8 VF_ID;
  925. u16 IOCExceptions;
  926. u16 IOCStatus;
  927. u32 IOCLogInfo;
  928. u8 MaxChainDepth;
  929. u8 WhoInit;
  930. u8 NumberOfPorts;
  931. u8 MaxMSIxVectors;
  932. u16 RequestCredit;
  933. u16 ProductID;
  934. u32 IOCCapabilities;
  935. union mpi3_version_union FWVersion;
  936. u16 IOCRequestFrameSize;
  937. u16 IOCMaxChainSegmentSize;
  938. u16 MaxInitiators;
  939. u16 MaxTargets;
  940. u16 MaxSasExpanders;
  941. u16 MaxEnclosures;
  942. u16 ProtocolFlags;
  943. u16 HighPriorityCredit;
  944. u16 MaxReplyDescriptorPostQueueDepth;
  945. u8 ReplyFrameSize;
  946. u8 MaxVolumes;
  947. u16 MaxDevHandle;
  948. u16 MaxPersistentEntries;
  949. u16 MinDevHandle;
  950. u8 CurrentHostPageSize;
  951. };
  952. struct mpt3sas_port_facts {
  953. u8 PortNumber;
  954. u8 VP_ID;
  955. u8 VF_ID;
  956. u8 PortType;
  957. u16 MaxPostedCmdBuffers;
  958. };
  959. struct reply_post_struct {
  960. Mpi2ReplyDescriptorsUnion_t *reply_post_free;
  961. dma_addr_t reply_post_free_dma;
  962. };
  963. /**
  964. * struct virtual_phy - vSES phy structure
  965. * sas_address: SAS Address of vSES device
  966. * phy_mask: vSES device's phy number
  967. * flags: flags used to manage this structure
  968. */
  969. struct virtual_phy {
  970. struct list_head list;
  971. u64 sas_address;
  972. u32 phy_mask;
  973. u8 flags;
  974. };
  975. #define MPT_VPHY_FLAG_DIRTY_PHY 0x01
  976. /**
  977. * struct hba_port - Saves each HBA's Wide/Narrow port info
  978. * @sas_address: sas address of this wide/narrow port's attached device
  979. * @phy_mask: HBA PHY's belonging to this port
  980. * @port_id: port number
  981. * @flags: hba port flags
  982. * @vphys_mask : mask of vSES devices Phy number
  983. * @vphys_list : list containing vSES device structures
  984. */
  985. struct hba_port {
  986. struct list_head list;
  987. u64 sas_address;
  988. u32 phy_mask;
  989. u8 port_id;
  990. u8 flags;
  991. u32 vphys_mask;
  992. struct list_head vphys_list;
  993. };
  994. /* hba port flags */
  995. #define HBA_PORT_FLAG_DIRTY_PORT 0x01
  996. #define HBA_PORT_FLAG_NEW_PORT 0x02
  997. #define MULTIPATH_DISABLED_PORT_ID 0xFF
  998. /**
  999. * struct htb_rel_query - diagnostic buffer release reason
  1000. * @unique_id - unique id associated with this buffer.
  1001. * @buffer_rel_condition - Release condition ioctl/sysfs/reset
  1002. * @reserved
  1003. * @trigger_type - Master/Event/scsi/MPI
  1004. * @trigger_info_dwords - Data Correspondig to trigger type
  1005. */
  1006. struct htb_rel_query {
  1007. u16 buffer_rel_condition;
  1008. u16 reserved;
  1009. u32 trigger_type;
  1010. u32 trigger_info_dwords[2];
  1011. };
  1012. /* Buffer_rel_condition bit fields */
  1013. /* Bit 0 - Diag Buffer not Released */
  1014. #define MPT3_DIAG_BUFFER_NOT_RELEASED (0x00)
  1015. /* Bit 0 - Diag Buffer Released */
  1016. #define MPT3_DIAG_BUFFER_RELEASED (0x01)
  1017. /*
  1018. * Bit 1 - Diag Buffer Released by IOCTL,
  1019. * This bit is valid only if Bit 0 is one
  1020. */
  1021. #define MPT3_DIAG_BUFFER_REL_IOCTL (0x02 | MPT3_DIAG_BUFFER_RELEASED)
  1022. /*
  1023. * Bit 2 - Diag Buffer Released by Trigger,
  1024. * This bit is valid only if Bit 0 is one
  1025. */
  1026. #define MPT3_DIAG_BUFFER_REL_TRIGGER (0x04 | MPT3_DIAG_BUFFER_RELEASED)
  1027. /*
  1028. * Bit 3 - Diag Buffer Released by SysFs,
  1029. * This bit is valid only if Bit 0 is one
  1030. */
  1031. #define MPT3_DIAG_BUFFER_REL_SYSFS (0x08 | MPT3_DIAG_BUFFER_RELEASED)
  1032. /* DIAG RESET Master trigger flags */
  1033. #define MPT_DIAG_RESET_ISSUED_BY_DRIVER 0x00000000
  1034. #define MPT_DIAG_RESET_ISSUED_BY_USER 0x00000001
  1035. typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc);
  1036. /**
  1037. * struct MPT3SAS_ADAPTER - per adapter struct
  1038. * @list: ioc_list
  1039. * @shost: shost object
  1040. * @id: unique adapter id
  1041. * @cpu_count: number online cpus
  1042. * @name: generic ioc string
  1043. * @tmp_string: tmp string used for logging
  1044. * @pdev: pci pdev object
  1045. * @pio_chip: physical io register space
  1046. * @chip: memory mapped register space
  1047. * @chip_phys: physical addrss prior to mapping
  1048. * @logging_level: see mpt3sas_debug.h
  1049. * @fwfault_debug: debuging FW timeouts
  1050. * @ir_firmware: IR firmware present
  1051. * @bars: bitmask of BAR's that must be configured
  1052. * @mask_interrupts: ignore interrupt
  1053. * @pci_access_mutex: Mutex to synchronize ioctl, sysfs show path and
  1054. * pci resource handling
  1055. * @fault_reset_work_q_name: fw fault work queue
  1056. * @fault_reset_work_q: ""
  1057. * @fault_reset_work: ""
  1058. * @firmware_event_name: fw event work queue
  1059. * @firmware_event_thread: ""
  1060. * @fw_event_lock:
  1061. * @fw_event_list: list of fw events
  1062. * @current_evet: current processing firmware event
  1063. * @fw_event_cleanup: set to one while cleaning up the fw events
  1064. * @aen_event_read_flag: event log was read
  1065. * @broadcast_aen_busy: broadcast aen waiting to be serviced
  1066. * @shost_recovery: host reset in progress
  1067. * @ioc_reset_in_progress_lock:
  1068. * @ioc_link_reset_in_progress: phy/hard reset in progress
  1069. * @ignore_loginfos: ignore loginfos during task management
  1070. * @remove_host: flag for when driver unloads, to avoid sending dev resets
  1071. * @pci_error_recovery: flag to prevent ioc access until slot reset completes
  1072. * @wait_for_discovery_to_complete: flag set at driver load time when
  1073. * waiting on reporting devices
  1074. * @is_driver_loading: flag set at driver load time
  1075. * @port_enable_failed: flag set when port enable has failed
  1076. * @start_scan: flag set from scan_start callback, cleared from _mpt3sas_fw_work
  1077. * @start_scan_failed: means port enable failed, return's the ioc_status
  1078. * @msix_enable: flag indicating msix is enabled
  1079. * @msix_vector_count: number msix vectors
  1080. * @cpu_msix_table: table for mapping cpus to msix index
  1081. * @cpu_msix_table_sz: table size
  1082. * @total_io_cnt: Gives total IO count, used to load balance the interrupts
  1083. * @ioc_coredump_loop: will have non-zero value when FW is in CoreDump state
  1084. * @timestamp_update_count: Counter to fire timeSync command
  1085. * time_sync_interval: Time sync interval read from man page 11
  1086. * @high_iops_outstanding: used to load balance the interrupts
  1087. * within high iops reply queues
  1088. * @msix_load_balance: Enables load balancing of interrupts across
  1089. * the multiple MSIXs
  1090. * @schedule_dead_ioc_flush_running_cmds: callback to flush pending commands
  1091. * @thresh_hold: Max number of reply descriptors processed
  1092. * before updating Host Index
  1093. * @iopoll_q_start_index: starting index of io uring poll queues
  1094. * in reply queue list
  1095. * @drv_internal_flags: Bit map internal to driver
  1096. * @drv_support_bitmap: driver's supported feature bit map
  1097. * @use_32bit_dma: Flag to use 32 bit consistent dma mask
  1098. * @scsi_io_cb_idx: shost generated commands
  1099. * @tm_cb_idx: task management commands
  1100. * @scsih_cb_idx: scsih internal commands
  1101. * @transport_cb_idx: transport internal commands
  1102. * @ctl_cb_idx: clt internal commands
  1103. * @base_cb_idx: base internal commands
  1104. * @config_cb_idx: base internal commands
  1105. * @tm_tr_cb_idx : device removal target reset handshake
  1106. * @tm_tr_volume_cb_idx : volume removal target reset
  1107. * @base_cmds:
  1108. * @transport_cmds:
  1109. * @scsih_cmds:
  1110. * @tm_cmds:
  1111. * @ctl_cmds:
  1112. * @config_cmds:
  1113. * @base_add_sg_single: handler for either 32/64 bit sgl's
  1114. * @event_type: bits indicating which events to log
  1115. * @event_context: unique id for each logged event
  1116. * @event_log: event log pointer
  1117. * @event_masks: events that are masked
  1118. * @max_shutdown_latency: timeout value for NVMe shutdown operation,
  1119. * which is equal that NVMe drive's RTD3 Entry Latency
  1120. * which has reported maximum RTD3 Entry Latency value
  1121. * among attached NVMe drives.
  1122. * @facts: static facts data
  1123. * @prev_fw_facts: previous fw facts data
  1124. * @pfacts: static port facts data
  1125. * @manu_pg0: static manufacturing page 0
  1126. * @manu_pg10: static manufacturing page 10
  1127. * @manu_pg11: static manufacturing page 11
  1128. * @bios_pg2: static bios page 2
  1129. * @bios_pg3: static bios page 3
  1130. * @ioc_pg8: static ioc page 8
  1131. * @iounit_pg0: static iounit page 0
  1132. * @iounit_pg1: static iounit page 1
  1133. * @iounit_pg8: static iounit page 8
  1134. * @sas_hba: sas host object
  1135. * @sas_expander_list: expander object list
  1136. * @enclosure_list: enclosure object list
  1137. * @sas_node_lock:
  1138. * @sas_device_list: sas device object list
  1139. * @sas_device_init_list: sas device object list (used only at init time)
  1140. * @sas_device_lock:
  1141. * @pcie_device_list: pcie device object list
  1142. * @pcie_device_init_list: pcie device object list (used only at init time)
  1143. * @pcie_device_lock:
  1144. * @io_missing_delay: time for IO completed by fw when PDR enabled
  1145. * @device_missing_delay: time for device missing by fw when PDR enabled
  1146. * @sas_id : used for setting volume target IDs
  1147. * @pcie_target_id: used for setting pcie target IDs
  1148. * @blocking_handles: bitmask used to identify which devices need blocking
  1149. * @pd_handles : bitmask for PD handles
  1150. * @pd_handles_sz : size of pd_handle bitmask
  1151. * @config_page_sz: config page size
  1152. * @config_page: reserve memory for config page payload
  1153. * @config_page_dma:
  1154. * @hba_queue_depth: hba request queue depth
  1155. * @sge_size: sg element size for either 32/64 bit
  1156. * @scsiio_depth: SCSI_IO queue depth
  1157. * @request_sz: per request frame size
  1158. * @request: pool of request frames
  1159. * @request_dma:
  1160. * @request_dma_sz:
  1161. * @scsi_lookup: firmware request tracker list
  1162. * @scsi_lookup_lock:
  1163. * @free_list: free list of request
  1164. * @pending_io_count:
  1165. * @reset_wq:
  1166. * @chain: pool of chains
  1167. * @chain_dma:
  1168. * @max_sges_in_main_message: number sg elements in main message
  1169. * @max_sges_in_chain_message: number sg elements per chain
  1170. * @chains_needed_per_io: max chains per io
  1171. * @chain_depth: total chains allocated
  1172. * @chain_segment_sz: gives the max number of
  1173. * SGEs accommodate on single chain buffer
  1174. * @hi_priority_smid:
  1175. * @hi_priority:
  1176. * @hi_priority_dma:
  1177. * @hi_priority_depth:
  1178. * @hpr_lookup:
  1179. * @hpr_free_list:
  1180. * @internal_smid:
  1181. * @internal:
  1182. * @internal_dma:
  1183. * @internal_depth:
  1184. * @internal_lookup:
  1185. * @internal_free_list:
  1186. * @sense: pool of sense
  1187. * @sense_dma:
  1188. * @sense_dma_pool:
  1189. * @reply_depth: hba reply queue depth:
  1190. * @reply_sz: per reply frame size:
  1191. * @reply: pool of replys:
  1192. * @reply_dma:
  1193. * @reply_dma_pool:
  1194. * @reply_free_queue_depth: reply free depth
  1195. * @reply_free: pool for reply free queue (32 bit addr)
  1196. * @reply_free_dma:
  1197. * @reply_free_dma_pool:
  1198. * @reply_free_host_index: tail index in pool to insert free replys
  1199. * @reply_post_queue_depth: reply post queue depth
  1200. * @reply_post_struct: struct for reply_post_free physical & virt address
  1201. * @rdpq_array_capable: FW supports multiple reply queue addresses in ioc_init
  1202. * @rdpq_array_enable: rdpq_array support is enabled in the driver
  1203. * @rdpq_array_enable_assigned: this ensures that rdpq_array_enable flag
  1204. * is assigned only ones
  1205. * @reply_queue_count: number of reply queue's
  1206. * @reply_queue_list: link list contaning the reply queue info
  1207. * @msix96_vector: 96 MSI-X vector support
  1208. * @replyPostRegisterIndex: index of next position in Reply Desc Post Queue
  1209. * @delayed_tr_list: target reset link list
  1210. * @delayed_tr_volume_list: volume target reset link list
  1211. * @delayed_sc_list:
  1212. * @delayed_event_ack_list:
  1213. * @temp_sensors_count: flag to carry the number of temperature sensors
  1214. * @pci_access_mutex: Mutex to synchronize ioctl,sysfs show path and
  1215. * pci resource handling. PCI resource freeing will lead to free
  1216. * vital hardware/memory resource, which might be in use by cli/sysfs
  1217. * path functions resulting in Null pointer reference followed by kernel
  1218. * crash. To avoid the above race condition we use mutex syncrhonization
  1219. * which ensures the syncrhonization between cli/sysfs_show path.
  1220. * @atomic_desc_capable: Atomic Request Descriptor support.
  1221. * @GET_MSIX_INDEX: Get the msix index of high iops queues.
  1222. * @multipath_on_hba: flag to determine multipath on hba is enabled or not
  1223. * @port_table_list: list containing HBA's wide/narrow port's info
  1224. */
  1225. struct MPT3SAS_ADAPTER {
  1226. struct list_head list;
  1227. struct Scsi_Host *shost;
  1228. u8 id;
  1229. int cpu_count;
  1230. char name[MPT_NAME_LENGTH];
  1231. char driver_name[MPT_NAME_LENGTH - 8];
  1232. char tmp_string[MPT_STRING_LENGTH];
  1233. struct pci_dev *pdev;
  1234. Mpi2SystemInterfaceRegs_t __iomem *chip;
  1235. phys_addr_t chip_phys;
  1236. int logging_level;
  1237. int fwfault_debug;
  1238. u8 ir_firmware;
  1239. int bars;
  1240. u8 mask_interrupts;
  1241. /* fw fault handler */
  1242. char fault_reset_work_q_name[20];
  1243. struct workqueue_struct *fault_reset_work_q;
  1244. struct delayed_work fault_reset_work;
  1245. /* fw event handler */
  1246. char firmware_event_name[20];
  1247. struct workqueue_struct *firmware_event_thread;
  1248. spinlock_t fw_event_lock;
  1249. struct list_head fw_event_list;
  1250. struct fw_event_work *current_event;
  1251. u8 fw_events_cleanup;
  1252. /* misc flags */
  1253. int aen_event_read_flag;
  1254. u8 broadcast_aen_busy;
  1255. u16 broadcast_aen_pending;
  1256. u8 shost_recovery;
  1257. u8 got_task_abort_from_ioctl;
  1258. struct mutex reset_in_progress_mutex;
  1259. spinlock_t ioc_reset_in_progress_lock;
  1260. u8 ioc_link_reset_in_progress;
  1261. u8 ignore_loginfos;
  1262. u8 remove_host;
  1263. u8 pci_error_recovery;
  1264. u8 wait_for_discovery_to_complete;
  1265. u8 is_driver_loading;
  1266. u8 port_enable_failed;
  1267. u8 start_scan;
  1268. u16 start_scan_failed;
  1269. u8 msix_enable;
  1270. u16 msix_vector_count;
  1271. u8 *cpu_msix_table;
  1272. u16 cpu_msix_table_sz;
  1273. resource_size_t __iomem **reply_post_host_index;
  1274. u32 ioc_reset_count;
  1275. MPT3SAS_FLUSH_RUNNING_CMDS schedule_dead_ioc_flush_running_cmds;
  1276. u32 non_operational_loop;
  1277. u8 ioc_coredump_loop;
  1278. u32 timestamp_update_count;
  1279. u32 time_sync_interval;
  1280. atomic64_t total_io_cnt;
  1281. atomic64_t high_iops_outstanding;
  1282. bool msix_load_balance;
  1283. u16 thresh_hold;
  1284. u8 high_iops_queues;
  1285. u8 iopoll_q_start_index;
  1286. u32 drv_internal_flags;
  1287. u32 drv_support_bitmap;
  1288. u32 dma_mask;
  1289. bool enable_sdev_max_qd;
  1290. bool use_32bit_dma;
  1291. struct io_uring_poll_queue *io_uring_poll_queues;
  1292. /* internal commands, callback index */
  1293. u8 scsi_io_cb_idx;
  1294. u8 tm_cb_idx;
  1295. u8 transport_cb_idx;
  1296. u8 scsih_cb_idx;
  1297. u8 ctl_cb_idx;
  1298. u8 base_cb_idx;
  1299. u8 port_enable_cb_idx;
  1300. u8 config_cb_idx;
  1301. u8 tm_tr_cb_idx;
  1302. u8 tm_tr_volume_cb_idx;
  1303. u8 tm_sas_control_cb_idx;
  1304. struct _internal_cmd base_cmds;
  1305. struct _internal_cmd port_enable_cmds;
  1306. struct _internal_cmd transport_cmds;
  1307. struct _internal_cmd scsih_cmds;
  1308. struct _internal_cmd tm_cmds;
  1309. struct _internal_cmd ctl_cmds;
  1310. struct _internal_cmd config_cmds;
  1311. MPT_ADD_SGE base_add_sg_single;
  1312. /* function ptr for either IEEE or MPI sg elements */
  1313. MPT_BUILD_SG_SCMD build_sg_scmd;
  1314. MPT_BUILD_SG build_sg;
  1315. MPT_BUILD_ZERO_LEN_SGE build_zero_len_sge;
  1316. u16 sge_size_ieee;
  1317. u16 hba_mpi_version_belonged;
  1318. /* function ptr for MPI sg elements only */
  1319. MPT_BUILD_SG build_sg_mpi;
  1320. MPT_BUILD_ZERO_LEN_SGE build_zero_len_sge_mpi;
  1321. /* function ptr for NVMe PRP elements only */
  1322. NVME_BUILD_PRP build_nvme_prp;
  1323. /* event log */
  1324. u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  1325. u32 event_context;
  1326. void *event_log;
  1327. u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  1328. u8 tm_custom_handling;
  1329. u8 nvme_abort_timeout;
  1330. u16 max_shutdown_latency;
  1331. u16 max_wideport_qd;
  1332. u16 max_narrowport_qd;
  1333. u16 max_nvme_qd;
  1334. u8 max_sata_qd;
  1335. /* static config pages */
  1336. struct mpt3sas_facts facts;
  1337. struct mpt3sas_facts prev_fw_facts;
  1338. struct mpt3sas_port_facts *pfacts;
  1339. Mpi2ManufacturingPage0_t manu_pg0;
  1340. struct Mpi2ManufacturingPage10_t manu_pg10;
  1341. struct Mpi2ManufacturingPage11_t manu_pg11;
  1342. Mpi2BiosPage2_t bios_pg2;
  1343. Mpi2BiosPage3_t bios_pg3;
  1344. Mpi2IOCPage8_t ioc_pg8;
  1345. Mpi2IOUnitPage0_t iounit_pg0;
  1346. Mpi2IOUnitPage1_t iounit_pg1;
  1347. Mpi2IOUnitPage8_t iounit_pg8;
  1348. Mpi2IOCPage1_t ioc_pg1_copy;
  1349. struct _boot_device req_boot_device;
  1350. struct _boot_device req_alt_boot_device;
  1351. struct _boot_device current_boot_device;
  1352. /* sas hba, expander, and device list */
  1353. struct _sas_node sas_hba;
  1354. struct list_head sas_expander_list;
  1355. struct list_head enclosure_list;
  1356. spinlock_t sas_node_lock;
  1357. struct list_head sas_device_list;
  1358. struct list_head sas_device_init_list;
  1359. spinlock_t sas_device_lock;
  1360. struct list_head pcie_device_list;
  1361. struct list_head pcie_device_init_list;
  1362. spinlock_t pcie_device_lock;
  1363. struct list_head raid_device_list;
  1364. spinlock_t raid_device_lock;
  1365. u8 io_missing_delay;
  1366. u16 device_missing_delay;
  1367. int sas_id;
  1368. int pcie_target_id;
  1369. void *blocking_handles;
  1370. void *pd_handles;
  1371. u16 pd_handles_sz;
  1372. void *pend_os_device_add;
  1373. u16 pend_os_device_add_sz;
  1374. /* config page */
  1375. u16 config_page_sz;
  1376. void *config_page;
  1377. dma_addr_t config_page_dma;
  1378. void *config_vaddr;
  1379. /* scsiio request */
  1380. u16 hba_queue_depth;
  1381. u16 sge_size;
  1382. u16 scsiio_depth;
  1383. u16 request_sz;
  1384. u8 *request;
  1385. dma_addr_t request_dma;
  1386. u32 request_dma_sz;
  1387. struct pcie_sg_list *pcie_sg_lookup;
  1388. spinlock_t scsi_lookup_lock;
  1389. int pending_io_count;
  1390. wait_queue_head_t reset_wq;
  1391. u16 *io_queue_num;
  1392. /* PCIe SGL */
  1393. struct dma_pool *pcie_sgl_dma_pool;
  1394. /* Host Page Size */
  1395. u32 page_size;
  1396. /* chain */
  1397. struct chain_lookup *chain_lookup;
  1398. struct list_head free_chain_list;
  1399. struct dma_pool *chain_dma_pool;
  1400. ulong chain_pages;
  1401. u16 max_sges_in_main_message;
  1402. u16 max_sges_in_chain_message;
  1403. u16 chains_needed_per_io;
  1404. u32 chain_depth;
  1405. u16 chain_segment_sz;
  1406. u16 chains_per_prp_buffer;
  1407. /* hi-priority queue */
  1408. u16 hi_priority_smid;
  1409. u8 *hi_priority;
  1410. dma_addr_t hi_priority_dma;
  1411. u16 hi_priority_depth;
  1412. struct request_tracker *hpr_lookup;
  1413. struct list_head hpr_free_list;
  1414. /* internal queue */
  1415. u16 internal_smid;
  1416. u8 *internal;
  1417. dma_addr_t internal_dma;
  1418. u16 internal_depth;
  1419. struct request_tracker *internal_lookup;
  1420. struct list_head internal_free_list;
  1421. /* sense */
  1422. u8 *sense;
  1423. dma_addr_t sense_dma;
  1424. struct dma_pool *sense_dma_pool;
  1425. /* reply */
  1426. u16 reply_sz;
  1427. u8 *reply;
  1428. dma_addr_t reply_dma;
  1429. u32 reply_dma_max_address;
  1430. u32 reply_dma_min_address;
  1431. struct dma_pool *reply_dma_pool;
  1432. /* reply free queue */
  1433. u16 reply_free_queue_depth;
  1434. __le32 *reply_free;
  1435. dma_addr_t reply_free_dma;
  1436. struct dma_pool *reply_free_dma_pool;
  1437. u32 reply_free_host_index;
  1438. /* reply post queue */
  1439. u16 reply_post_queue_depth;
  1440. struct reply_post_struct *reply_post;
  1441. u8 rdpq_array_capable;
  1442. u8 rdpq_array_enable;
  1443. u8 rdpq_array_enable_assigned;
  1444. struct dma_pool *reply_post_free_dma_pool;
  1445. struct dma_pool *reply_post_free_array_dma_pool;
  1446. Mpi2IOCInitRDPQArrayEntry *reply_post_free_array;
  1447. dma_addr_t reply_post_free_array_dma;
  1448. u8 reply_queue_count;
  1449. struct list_head reply_queue_list;
  1450. u8 combined_reply_queue;
  1451. u8 combined_reply_index_count;
  1452. u8 smp_affinity_enable;
  1453. /* reply post register index */
  1454. resource_size_t __iomem **replyPostRegisterIndex;
  1455. struct list_head delayed_tr_list;
  1456. struct list_head delayed_tr_volume_list;
  1457. struct list_head delayed_sc_list;
  1458. struct list_head delayed_event_ack_list;
  1459. u8 temp_sensors_count;
  1460. struct mutex pci_access_mutex;
  1461. /* diag buffer support */
  1462. u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
  1463. u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
  1464. dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
  1465. u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
  1466. u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
  1467. u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
  1468. u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
  1469. u32 ring_buffer_offset;
  1470. u32 ring_buffer_sz;
  1471. struct htb_rel_query htb_rel;
  1472. u8 reset_from_user;
  1473. u8 is_warpdrive;
  1474. u8 is_mcpu_endpoint;
  1475. u8 hide_ir_msg;
  1476. u8 mfg_pg10_hide_flag;
  1477. u8 hide_drives;
  1478. spinlock_t diag_trigger_lock;
  1479. u8 diag_trigger_active;
  1480. u8 atomic_desc_capable;
  1481. BASE_READ_REG base_readl;
  1482. BASE_READ_REG base_readl_ext_retry;
  1483. struct SL_WH_MASTER_TRIGGER_T diag_trigger_master;
  1484. struct SL_WH_EVENT_TRIGGERS_T diag_trigger_event;
  1485. struct SL_WH_SCSI_TRIGGERS_T diag_trigger_scsi;
  1486. struct SL_WH_MPI_TRIGGERS_T diag_trigger_mpi;
  1487. u8 supports_trigger_pages;
  1488. void *device_remove_in_progress;
  1489. u16 device_remove_in_progress_sz;
  1490. u8 is_gen35_ioc;
  1491. u8 is_aero_ioc;
  1492. struct dentry *debugfs_root;
  1493. struct dentry *ioc_dump;
  1494. PUT_SMID_IO_FP_HIP put_smid_scsi_io;
  1495. PUT_SMID_IO_FP_HIP put_smid_fast_path;
  1496. PUT_SMID_IO_FP_HIP put_smid_hi_priority;
  1497. PUT_SMID_DEFAULT put_smid_default;
  1498. GET_MSIX_INDEX get_msix_index_for_smlio;
  1499. u8 multipath_on_hba;
  1500. struct list_head port_table_list;
  1501. };
  1502. struct mpt3sas_debugfs_buffer {
  1503. void *buf;
  1504. u32 len;
  1505. };
  1506. #define MPT_DRV_SUPPORT_BITMAP_MEMMOVE 0x00000001
  1507. #define MPT_DRV_SUPPORT_BITMAP_ADDNLQUERY 0x00000002
  1508. #define MPT_DRV_INTERNAL_FIRST_PE_ISSUED 0x00000001
  1509. typedef u8 (*MPT_CALLBACK)(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1510. u32 reply);
  1511. /*
  1512. * struct ATTO_SAS_NVRAM - ATTO NVRAM settings stored
  1513. * in Manufacturing page 1 used to get
  1514. * ATTO SasAddr.
  1515. */
  1516. struct ATTO_SAS_NVRAM {
  1517. u8 Signature[4];
  1518. u8 Version;
  1519. #define ATTO_SASNVR_VERSION 0
  1520. u8 Checksum;
  1521. #define ATTO_SASNVR_CKSUM_SEED 0x5A
  1522. u8 Pad[10];
  1523. u8 SasAddr[8];
  1524. #define ATTO_SAS_ADDR_ALIGN 64
  1525. u8 Reserved[232];
  1526. };
  1527. #define ATTO_SAS_ADDR_DEVNAME_BIAS 63
  1528. union ATTO_SAS_ADDRESS {
  1529. U8 b[8];
  1530. U16 w[4];
  1531. U32 d[2];
  1532. U64 q;
  1533. };
  1534. /* base shared API */
  1535. extern struct list_head mpt3sas_ioc_list;
  1536. extern char driver_name[MPT_NAME_LENGTH];
  1537. /* spinlock on list operations over IOCs
  1538. * Case: when multiple warpdrive cards(IOCs) are in use
  1539. * Each IOC will added to the ioc list structure on initialization.
  1540. * Watchdog threads run at regular intervals to check IOC for any
  1541. * fault conditions which will trigger the dead_ioc thread to
  1542. * deallocate pci resource, resulting deleting the IOC netry from list,
  1543. * this deletion need to protected by spinlock to enusre that
  1544. * ioc removal is syncrhonized, if not synchronized it might lead to
  1545. * list_del corruption as the ioc list is traversed in cli path.
  1546. */
  1547. extern spinlock_t gioc_lock;
  1548. void mpt3sas_base_start_watchdog(struct MPT3SAS_ADAPTER *ioc);
  1549. void mpt3sas_base_stop_watchdog(struct MPT3SAS_ADAPTER *ioc);
  1550. int mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc);
  1551. void mpt3sas_base_detach(struct MPT3SAS_ADAPTER *ioc);
  1552. int mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc);
  1553. void mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc);
  1554. void mpt3sas_free_enclosure_list(struct MPT3SAS_ADAPTER *ioc);
  1555. int mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc,
  1556. enum reset_type type);
  1557. void *mpt3sas_base_get_msg_frame(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1558. void *mpt3sas_base_get_sense_buffer(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1559. __le32 mpt3sas_base_get_sense_buffer_dma(struct MPT3SAS_ADAPTER *ioc,
  1560. u16 smid);
  1561. void *mpt3sas_base_get_pcie_sgl(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1562. dma_addr_t mpt3sas_base_get_pcie_sgl_dma(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1563. void mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc, u8 poll);
  1564. void mpt3sas_base_mask_interrupts(struct MPT3SAS_ADAPTER *ioc);
  1565. void mpt3sas_base_unmask_interrupts(struct MPT3SAS_ADAPTER *ioc);
  1566. void mpt3sas_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid,
  1567. u16 handle);
  1568. void mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid,
  1569. u16 msix_task);
  1570. void mpt3sas_base_put_smid_nvme_encap(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1571. void mpt3sas_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1572. /* hi-priority queue */
  1573. u16 mpt3sas_base_get_smid_hpr(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx);
  1574. u16 mpt3sas_base_get_smid_scsiio(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx,
  1575. struct scsi_cmnd *scmd);
  1576. void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc,
  1577. struct scsiio_tracker *st);
  1578. u16 mpt3sas_base_get_smid(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx);
  1579. void mpt3sas_base_free_smid(struct MPT3SAS_ADAPTER *ioc, u16 smid);
  1580. void mpt3sas_base_initialize_callback_handler(void);
  1581. u8 mpt3sas_base_register_callback_handler(MPT_CALLBACK cb_func);
  1582. void mpt3sas_base_release_callback_handler(u8 cb_idx);
  1583. u8 mpt3sas_base_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1584. u32 reply);
  1585. u8 mpt3sas_port_enable_done(struct MPT3SAS_ADAPTER *ioc, u16 smid,
  1586. u8 msix_index, u32 reply);
  1587. void *mpt3sas_base_get_reply_virt_addr(struct MPT3SAS_ADAPTER *ioc,
  1588. u32 phys_addr);
  1589. u32 mpt3sas_base_get_iocstate(struct MPT3SAS_ADAPTER *ioc, int cooked);
  1590. void mpt3sas_base_fault_info(struct MPT3SAS_ADAPTER *ioc , u16 fault_code);
  1591. #define mpt3sas_print_fault_code(ioc, fault_code) \
  1592. do { pr_err("%s fault info from func: %s\n", ioc->name, __func__); \
  1593. mpt3sas_base_fault_info(ioc, fault_code); } while (0)
  1594. void mpt3sas_base_coredump_info(struct MPT3SAS_ADAPTER *ioc, u16 fault_code);
  1595. #define mpt3sas_print_coredump_info(ioc, fault_code) \
  1596. do { pr_err("%s fault info from func: %s\n", ioc->name, __func__); \
  1597. mpt3sas_base_coredump_info(ioc, fault_code); } while (0)
  1598. int mpt3sas_base_wait_for_coredump_completion(struct MPT3SAS_ADAPTER *ioc,
  1599. const char *caller);
  1600. int mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc,
  1601. Mpi2SasIoUnitControlReply_t *mpi_reply,
  1602. Mpi2SasIoUnitControlRequest_t *mpi_request);
  1603. int mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc,
  1604. Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
  1605. void mpt3sas_base_validate_event_type(struct MPT3SAS_ADAPTER *ioc,
  1606. u32 *event_type);
  1607. void mpt3sas_halt_firmware(struct MPT3SAS_ADAPTER *ioc);
  1608. void mpt3sas_base_update_missing_delay(struct MPT3SAS_ADAPTER *ioc,
  1609. u16 device_missing_delay, u8 io_missing_delay);
  1610. int mpt3sas_base_check_for_fault_and_issue_reset(
  1611. struct MPT3SAS_ADAPTER *ioc);
  1612. int mpt3sas_port_enable(struct MPT3SAS_ADAPTER *ioc);
  1613. void
  1614. mpt3sas_wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc);
  1615. u8 mpt3sas_base_check_cmd_timeout(struct MPT3SAS_ADAPTER *ioc,
  1616. u8 status, void *mpi_request, int sz);
  1617. #define mpt3sas_check_cmd_timeout(ioc, status, mpi_request, sz, issue_reset) \
  1618. do { ioc_err(ioc, "In func: %s\n", __func__); \
  1619. issue_reset = mpt3sas_base_check_cmd_timeout(ioc, \
  1620. status, mpi_request, sz); } while (0)
  1621. int mpt3sas_wait_for_ioc(struct MPT3SAS_ADAPTER *ioc, int wait_count);
  1622. int mpt3sas_base_make_ioc_ready(struct MPT3SAS_ADAPTER *ioc, enum reset_type type);
  1623. void mpt3sas_base_free_irq(struct MPT3SAS_ADAPTER *ioc);
  1624. void mpt3sas_base_disable_msix(struct MPT3SAS_ADAPTER *ioc);
  1625. int mpt3sas_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);
  1626. void mpt3sas_base_pause_mq_polling(struct MPT3SAS_ADAPTER *ioc);
  1627. void mpt3sas_base_resume_mq_polling(struct MPT3SAS_ADAPTER *ioc);
  1628. /* scsih shared API */
  1629. struct scsi_cmnd *mpt3sas_scsih_scsi_lookup_get(struct MPT3SAS_ADAPTER *ioc,
  1630. u16 smid);
  1631. u8 mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
  1632. u32 reply);
  1633. void mpt3sas_scsih_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
  1634. void mpt3sas_scsih_clear_outstanding_scsi_tm_commands(
  1635. struct MPT3SAS_ADAPTER *ioc);
  1636. void mpt3sas_scsih_reset_done_handler(struct MPT3SAS_ADAPTER *ioc);
  1637. int mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle,
  1638. uint channel, uint id, u64 lun, u8 type, u16 smid_task,
  1639. u16 msix_task, u8 timeout, u8 tr_method);
  1640. int mpt3sas_scsih_issue_locked_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle,
  1641. uint channel, uint id, u64 lun, u8 type, u16 smid_task,
  1642. u16 msix_task, u8 timeout, u8 tr_method);
  1643. void mpt3sas_scsih_set_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle);
  1644. void mpt3sas_scsih_clear_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle);
  1645. void mpt3sas_expander_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
  1646. struct hba_port *port);
  1647. void mpt3sas_device_remove_by_sas_address(struct MPT3SAS_ADAPTER *ioc,
  1648. u64 sas_address, struct hba_port *port);
  1649. u8 mpt3sas_check_for_pending_internal_cmds(struct MPT3SAS_ADAPTER *ioc,
  1650. u16 smid);
  1651. struct hba_port *
  1652. mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc, u8 port,
  1653. u8 bypass_dirty_port_flag);
  1654. struct _sas_node *mpt3sas_scsih_expander_find_by_handle(
  1655. struct MPT3SAS_ADAPTER *ioc, u16 handle);
  1656. struct _sas_node *mpt3sas_scsih_expander_find_by_sas_address(
  1657. struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
  1658. struct hba_port *port);
  1659. struct _sas_device *mpt3sas_get_sdev_by_addr(
  1660. struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
  1661. struct hba_port *port);
  1662. struct _sas_device *__mpt3sas_get_sdev_by_addr(
  1663. struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
  1664. struct hba_port *port);
  1665. struct _sas_device *mpt3sas_get_sdev_by_handle(struct MPT3SAS_ADAPTER *ioc,
  1666. u16 handle);
  1667. struct _pcie_device *mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc,
  1668. u16 handle);
  1669. void mpt3sas_port_enable_complete(struct MPT3SAS_ADAPTER *ioc);
  1670. struct _raid_device *
  1671. mpt3sas_raid_device_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle);
  1672. void mpt3sas_scsih_change_queue_depth(struct scsi_device *sdev, int qdepth);
  1673. struct _sas_device *
  1674. __mpt3sas_get_sdev_by_rphy(struct MPT3SAS_ADAPTER *ioc, struct sas_rphy *rphy);
  1675. struct virtual_phy *
  1676. mpt3sas_get_vphy_by_phy(struct MPT3SAS_ADAPTER *ioc,
  1677. struct hba_port *port, u32 phy);
  1678. /* config shared API */
  1679. u8 mpt3sas_config_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1680. u32 reply);
  1681. int mpt3sas_config_get_number_hba_phys(struct MPT3SAS_ADAPTER *ioc,
  1682. u8 *num_phys);
  1683. int mpt3sas_config_get_manufacturing_pg0(struct MPT3SAS_ADAPTER *ioc,
  1684. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
  1685. int mpt3sas_config_get_manufacturing_pg1(struct MPT3SAS_ADAPTER *ioc,
  1686. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage1_t *config_page);
  1687. int mpt3sas_config_get_manufacturing_pg7(struct MPT3SAS_ADAPTER *ioc,
  1688. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage7_t *config_page,
  1689. u16 sz);
  1690. int mpt3sas_config_get_manufacturing_pg10(struct MPT3SAS_ADAPTER *ioc,
  1691. Mpi2ConfigReply_t *mpi_reply,
  1692. struct Mpi2ManufacturingPage10_t *config_page);
  1693. int mpt3sas_config_get_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc,
  1694. Mpi2ConfigReply_t *mpi_reply,
  1695. struct Mpi2ManufacturingPage11_t *config_page);
  1696. int mpt3sas_config_set_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc,
  1697. Mpi2ConfigReply_t *mpi_reply,
  1698. struct Mpi2ManufacturingPage11_t *config_page);
  1699. int mpt3sas_config_get_bios_pg2(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1700. *mpi_reply, Mpi2BiosPage2_t *config_page);
  1701. int mpt3sas_config_get_bios_pg3(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1702. *mpi_reply, Mpi2BiosPage3_t *config_page);
  1703. int mpt3sas_config_set_bios_pg4(struct MPT3SAS_ADAPTER *ioc,
  1704. Mpi2ConfigReply_t *mpi_reply, Mpi2BiosPage4_t *config_page,
  1705. int sz_config_page);
  1706. int mpt3sas_config_get_bios_pg4(struct MPT3SAS_ADAPTER *ioc,
  1707. Mpi2ConfigReply_t *mpi_reply, Mpi2BiosPage4_t *config_page,
  1708. int sz_config_page);
  1709. int mpt3sas_config_get_iounit_pg0(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1710. *mpi_reply, Mpi2IOUnitPage0_t *config_page);
  1711. int mpt3sas_config_get_sas_device_pg0(struct MPT3SAS_ADAPTER *ioc,
  1712. Mpi2ConfigReply_t *mpi_reply, Mpi2SasDevicePage0_t *config_page,
  1713. u32 form, u32 handle);
  1714. int mpt3sas_config_get_sas_device_pg1(struct MPT3SAS_ADAPTER *ioc,
  1715. Mpi2ConfigReply_t *mpi_reply, Mpi2SasDevicePage1_t *config_page,
  1716. u32 form, u32 handle);
  1717. int mpt3sas_config_get_pcie_device_pg0(struct MPT3SAS_ADAPTER *ioc,
  1718. Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage0_t *config_page,
  1719. u32 form, u32 handle);
  1720. int mpt3sas_config_get_pcie_device_pg2(struct MPT3SAS_ADAPTER *ioc,
  1721. Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage2_t *config_page,
  1722. u32 form, u32 handle);
  1723. int mpt3sas_config_get_pcie_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
  1724. Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeIOUnitPage1_t *config_page,
  1725. u16 sz);
  1726. int mpt3sas_config_get_sas_iounit_pg0(struct MPT3SAS_ADAPTER *ioc,
  1727. Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage0_t *config_page,
  1728. u16 sz);
  1729. int mpt3sas_config_get_iounit_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1730. *mpi_reply, Mpi2IOUnitPage1_t *config_page);
  1731. int mpt3sas_config_get_iounit_pg3(struct MPT3SAS_ADAPTER *ioc,
  1732. Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage3_t *config_page, u16 sz);
  1733. int mpt3sas_config_set_iounit_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1734. *mpi_reply, Mpi2IOUnitPage1_t *config_page);
  1735. int mpt3sas_config_get_iounit_pg8(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1736. *mpi_reply, Mpi2IOUnitPage8_t *config_page);
  1737. int mpt3sas_config_get_sas_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
  1738. Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page,
  1739. u16 sz);
  1740. int mpt3sas_config_set_sas_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
  1741. Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page,
  1742. u16 sz);
  1743. int mpt3sas_config_get_ioc_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1744. *mpi_reply, Mpi2IOCPage1_t *config_page);
  1745. int mpt3sas_config_set_ioc_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1746. *mpi_reply, Mpi2IOCPage1_t *config_page);
  1747. int mpt3sas_config_get_ioc_pg8(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1748. *mpi_reply, Mpi2IOCPage8_t *config_page);
  1749. int mpt3sas_config_get_expander_pg0(struct MPT3SAS_ADAPTER *ioc,
  1750. Mpi2ConfigReply_t *mpi_reply, Mpi2ExpanderPage0_t *config_page,
  1751. u32 form, u32 handle);
  1752. int mpt3sas_config_get_expander_pg1(struct MPT3SAS_ADAPTER *ioc,
  1753. Mpi2ConfigReply_t *mpi_reply, Mpi2ExpanderPage1_t *config_page,
  1754. u32 phy_number, u16 handle);
  1755. int mpt3sas_config_get_enclosure_pg0(struct MPT3SAS_ADAPTER *ioc,
  1756. Mpi2ConfigReply_t *mpi_reply, Mpi2SasEnclosurePage0_t *config_page,
  1757. u32 form, u32 handle);
  1758. int mpt3sas_config_get_phy_pg0(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1759. *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
  1760. int mpt3sas_config_get_phy_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  1761. *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
  1762. int mpt3sas_config_get_raid_volume_pg1(struct MPT3SAS_ADAPTER *ioc,
  1763. Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form,
  1764. u32 handle);
  1765. int mpt3sas_config_get_number_pds(struct MPT3SAS_ADAPTER *ioc, u16 handle,
  1766. u8 *num_pds);
  1767. int mpt3sas_config_get_raid_volume_pg0(struct MPT3SAS_ADAPTER *ioc,
  1768. Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form,
  1769. u32 handle, u16 sz);
  1770. int mpt3sas_config_get_phys_disk_pg0(struct MPT3SAS_ADAPTER *ioc,
  1771. Mpi2ConfigReply_t *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page,
  1772. u32 form, u32 form_specific);
  1773. int mpt3sas_config_get_volume_handle(struct MPT3SAS_ADAPTER *ioc, u16 pd_handle,
  1774. u16 *volume_handle);
  1775. int mpt3sas_config_get_volume_wwid(struct MPT3SAS_ADAPTER *ioc,
  1776. u16 volume_handle, u64 *wwid);
  1777. int
  1778. mpt3sas_config_get_driver_trigger_pg0(struct MPT3SAS_ADAPTER *ioc,
  1779. Mpi2ConfigReply_t *mpi_reply, Mpi26DriverTriggerPage0_t *config_page);
  1780. int
  1781. mpt3sas_config_get_driver_trigger_pg1(struct MPT3SAS_ADAPTER *ioc,
  1782. Mpi2ConfigReply_t *mpi_reply, Mpi26DriverTriggerPage1_t *config_page);
  1783. int
  1784. mpt3sas_config_get_driver_trigger_pg2(struct MPT3SAS_ADAPTER *ioc,
  1785. Mpi2ConfigReply_t *mpi_reply, Mpi26DriverTriggerPage2_t *config_page);
  1786. int
  1787. mpt3sas_config_get_driver_trigger_pg3(struct MPT3SAS_ADAPTER *ioc,
  1788. Mpi2ConfigReply_t *mpi_reply, Mpi26DriverTriggerPage3_t *config_page);
  1789. int
  1790. mpt3sas_config_get_driver_trigger_pg4(struct MPT3SAS_ADAPTER *ioc,
  1791. Mpi2ConfigReply_t *mpi_reply, Mpi26DriverTriggerPage4_t *config_page);
  1792. int
  1793. mpt3sas_config_update_driver_trigger_pg1(struct MPT3SAS_ADAPTER *ioc,
  1794. struct SL_WH_MASTER_TRIGGER_T *master_tg, bool set);
  1795. int
  1796. mpt3sas_config_update_driver_trigger_pg2(struct MPT3SAS_ADAPTER *ioc,
  1797. struct SL_WH_EVENT_TRIGGERS_T *event_tg, bool set);
  1798. int
  1799. mpt3sas_config_update_driver_trigger_pg3(struct MPT3SAS_ADAPTER *ioc,
  1800. struct SL_WH_SCSI_TRIGGERS_T *scsi_tg, bool set);
  1801. int
  1802. mpt3sas_config_update_driver_trigger_pg4(struct MPT3SAS_ADAPTER *ioc,
  1803. struct SL_WH_MPI_TRIGGERS_T *mpi_tg, bool set);
  1804. /* ctl shared API */
  1805. extern const struct attribute_group *mpt3sas_host_groups[];
  1806. extern const struct attribute_group *mpt3sas_dev_groups[];
  1807. void mpt3sas_ctl_init(ushort hbas_to_enumerate);
  1808. void mpt3sas_ctl_exit(ushort hbas_to_enumerate);
  1809. u8 mpt3sas_ctl_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1810. u32 reply);
  1811. void mpt3sas_ctl_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
  1812. void mpt3sas_ctl_clear_outstanding_ioctls(struct MPT3SAS_ADAPTER *ioc);
  1813. void mpt3sas_ctl_reset_done_handler(struct MPT3SAS_ADAPTER *ioc);
  1814. u8 mpt3sas_ctl_event_callback(struct MPT3SAS_ADAPTER *ioc,
  1815. u8 msix_index, u32 reply);
  1816. void mpt3sas_ctl_add_to_event_log(struct MPT3SAS_ADAPTER *ioc,
  1817. Mpi2EventNotificationReply_t *mpi_reply);
  1818. void mpt3sas_enable_diag_buffer(struct MPT3SAS_ADAPTER *ioc,
  1819. u8 bits_to_register);
  1820. int mpt3sas_send_diag_release(struct MPT3SAS_ADAPTER *ioc, u8 buffer_type,
  1821. u8 *issue_reset);
  1822. /* transport shared API */
  1823. extern struct scsi_transport_template *mpt3sas_transport_template;
  1824. u8 mpt3sas_transport_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  1825. u32 reply);
  1826. struct _sas_port *mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc,
  1827. u16 handle, u64 sas_address, struct hba_port *port);
  1828. void mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
  1829. u64 sas_address_parent, struct hba_port *port);
  1830. int mpt3sas_transport_add_host_phy(struct MPT3SAS_ADAPTER *ioc, struct _sas_phy
  1831. *mpt3sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
  1832. int mpt3sas_transport_add_expander_phy(struct MPT3SAS_ADAPTER *ioc,
  1833. struct _sas_phy *mpt3sas_phy, Mpi2ExpanderPage1_t expander_pg1,
  1834. struct device *parent_dev);
  1835. void mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc,
  1836. u64 sas_address, u16 handle, u8 phy_number, u8 link_rate,
  1837. struct hba_port *port);
  1838. extern struct sas_function_template mpt3sas_transport_functions;
  1839. extern struct scsi_transport_template *mpt3sas_transport_template;
  1840. void
  1841. mpt3sas_transport_del_phy_from_an_existing_port(struct MPT3SAS_ADAPTER *ioc,
  1842. struct _sas_node *sas_node, struct _sas_phy *mpt3sas_phy);
  1843. void
  1844. mpt3sas_transport_add_phy_to_an_existing_port(struct MPT3SAS_ADAPTER *ioc,
  1845. struct _sas_node *sas_node, struct _sas_phy *mpt3sas_phy,
  1846. u64 sas_address, struct hba_port *port);
  1847. /* trigger data externs */
  1848. void mpt3sas_send_trigger_data_event(struct MPT3SAS_ADAPTER *ioc,
  1849. struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
  1850. void mpt3sas_process_trigger_data(struct MPT3SAS_ADAPTER *ioc,
  1851. struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
  1852. void mpt3sas_trigger_master(struct MPT3SAS_ADAPTER *ioc,
  1853. u32 trigger_bitmask);
  1854. void mpt3sas_trigger_event(struct MPT3SAS_ADAPTER *ioc, u16 event,
  1855. u16 log_entry_qualifier);
  1856. void mpt3sas_trigger_scsi(struct MPT3SAS_ADAPTER *ioc, u8 sense_key,
  1857. u8 asc, u8 ascq);
  1858. void mpt3sas_trigger_mpi(struct MPT3SAS_ADAPTER *ioc, u16 ioc_status,
  1859. u32 loginfo);
  1860. /* warpdrive APIs */
  1861. u8 mpt3sas_get_num_volumes(struct MPT3SAS_ADAPTER *ioc);
  1862. void mpt3sas_init_warpdrive_properties(struct MPT3SAS_ADAPTER *ioc,
  1863. struct _raid_device *raid_device);
  1864. void
  1865. mpt3sas_setup_direct_io(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
  1866. struct _raid_device *raid_device, Mpi25SCSIIORequest_t *mpi_request);
  1867. /* NCQ Prio Handling Check */
  1868. bool scsih_ncq_prio_supp(struct scsi_device *sdev);
  1869. void mpt3sas_setup_debugfs(struct MPT3SAS_ADAPTER *ioc);
  1870. void mpt3sas_destroy_debugfs(struct MPT3SAS_ADAPTER *ioc);
  1871. void mpt3sas_init_debugfs(void);
  1872. void mpt3sas_exit_debugfs(void);
  1873. /**
  1874. * _scsih_is_pcie_scsi_device - determines if device is an pcie scsi device
  1875. * @device_info: bitfield providing information about the device.
  1876. * Context: none
  1877. *
  1878. * Returns 1 if scsi device.
  1879. */
  1880. static inline int
  1881. mpt3sas_scsih_is_pcie_scsi_device(u32 device_info)
  1882. {
  1883. if ((device_info &
  1884. MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE) == MPI26_PCIE_DEVINFO_SCSI)
  1885. return 1;
  1886. else
  1887. return 0;
  1888. }
  1889. #endif /* MPT3SAS_BASE_H_INCLUDED */