mpi3mr.h 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Driver for Broadcom MPI3 Storage Controllers
  4. *
  5. * Copyright (C) 2017-2023 Broadcom Inc.
  6. * (mailto: mpi3mr-linuxdrv.pdl@broadcom.com)
  7. *
  8. */
  9. #ifndef MPI3MR_H_INCLUDED
  10. #define MPI3MR_H_INCLUDED
  11. #include <linux/blkdev.h>
  12. #include <linux/blk-mq.h>
  13. #include <linux/blk-mq-pci.h>
  14. #include <linux/delay.h>
  15. #include <linux/dmapool.h>
  16. #include <linux/errno.h>
  17. #include <linux/init.h>
  18. #include <linux/io.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/kernel.h>
  21. #include <linux/miscdevice.h>
  22. #include <linux/module.h>
  23. #include <linux/pci.h>
  24. #include <linux/aer.h>
  25. #include <linux/poll.h>
  26. #include <linux/sched.h>
  27. #include <linux/slab.h>
  28. #include <linux/types.h>
  29. #include <linux/uaccess.h>
  30. #include <linux/utsname.h>
  31. #include <linux/workqueue.h>
  32. #include <linux/unaligned.h>
  33. #include <scsi/scsi.h>
  34. #include <scsi/scsi_cmnd.h>
  35. #include <scsi/scsi_dbg.h>
  36. #include <scsi/scsi_device.h>
  37. #include <scsi/scsi_host.h>
  38. #include <scsi/scsi_tcq.h>
  39. #include <uapi/scsi/scsi_bsg_mpi3mr.h>
  40. #include <scsi/scsi_transport_sas.h>
  41. #include "mpi/mpi30_transport.h"
  42. #include "mpi/mpi30_cnfg.h"
  43. #include "mpi/mpi30_image.h"
  44. #include "mpi/mpi30_init.h"
  45. #include "mpi/mpi30_ioc.h"
  46. #include "mpi/mpi30_sas.h"
  47. #include "mpi/mpi30_pci.h"
  48. #include "mpi/mpi30_tool.h"
  49. #include "mpi3mr_debug.h"
  50. /* Global list and lock for storing multiple adapters managed by the driver */
  51. extern spinlock_t mrioc_list_lock;
  52. extern struct list_head mrioc_list;
  53. extern int prot_mask;
  54. extern atomic64_t event_counter;
  55. #define MPI3MR_DRIVER_VERSION "8.12.0.0.50"
  56. #define MPI3MR_DRIVER_RELDATE "05-Sept-2024"
  57. #define MPI3MR_DRIVER_NAME "mpi3mr"
  58. #define MPI3MR_DRIVER_LICENSE "GPL"
  59. #define MPI3MR_DRIVER_AUTHOR "Broadcom Inc. <mpi3mr-linuxdrv.pdl@broadcom.com>"
  60. #define MPI3MR_DRIVER_DESC "MPI3 Storage Controller Device Driver"
  61. #define MPI3MR_NAME_LENGTH 64
  62. #define IOCNAME "%s: "
  63. #define MPI3MR_DEFAULT_MAX_IO_SIZE (1 * 1024 * 1024)
  64. /* Definitions for internal SGL and Chain SGL buffers */
  65. #define MPI3MR_PAGE_SIZE_4K 4096
  66. #define MPI3MR_DEFAULT_SGL_ENTRIES 256
  67. #define MPI3MR_MAX_SGL_ENTRIES 2048
  68. /* Definitions for MAX values for shost */
  69. #define MPI3MR_MAX_CMDS_LUN 128
  70. #define MPI3MR_MAX_CDB_LENGTH 32
  71. /* Admin queue management definitions */
  72. #define MPI3MR_ADMIN_REQ_Q_SIZE (2 * MPI3MR_PAGE_SIZE_4K)
  73. #define MPI3MR_ADMIN_REPLY_Q_SIZE (4 * MPI3MR_PAGE_SIZE_4K)
  74. #define MPI3MR_ADMIN_REQ_FRAME_SZ 128
  75. #define MPI3MR_ADMIN_REPLY_FRAME_SZ 16
  76. /* Operational queue management definitions */
  77. #define MPI3MR_OP_REQ_Q_QD 512
  78. #define MPI3MR_OP_REP_Q_QD 1024
  79. #define MPI3MR_OP_REP_Q_QD4K 4096
  80. #define MPI3MR_OP_REQ_Q_SEG_SIZE 4096
  81. #define MPI3MR_OP_REP_Q_SEG_SIZE 4096
  82. #define MPI3MR_MAX_SEG_LIST_SIZE 4096
  83. /* Reserved Host Tag definitions */
  84. #define MPI3MR_HOSTTAG_INVALID 0xFFFF
  85. #define MPI3MR_HOSTTAG_INITCMDS 1
  86. #define MPI3MR_HOSTTAG_BSG_CMDS 2
  87. #define MPI3MR_HOSTTAG_PEL_ABORT 3
  88. #define MPI3MR_HOSTTAG_PEL_WAIT 4
  89. #define MPI3MR_HOSTTAG_BLK_TMS 5
  90. #define MPI3MR_HOSTTAG_CFG_CMDS 6
  91. #define MPI3MR_HOSTTAG_TRANSPORT_CMDS 7
  92. #define MPI3MR_NUM_DEVRMCMD 16
  93. #define MPI3MR_HOSTTAG_DEVRMCMD_MIN (MPI3MR_HOSTTAG_TRANSPORT_CMDS + 1)
  94. #define MPI3MR_HOSTTAG_DEVRMCMD_MAX (MPI3MR_HOSTTAG_DEVRMCMD_MIN + \
  95. MPI3MR_NUM_DEVRMCMD - 1)
  96. #define MPI3MR_INTERNAL_CMDS_RESVD MPI3MR_HOSTTAG_DEVRMCMD_MAX
  97. #define MPI3MR_NUM_EVTACKCMD 4
  98. #define MPI3MR_HOSTTAG_EVTACKCMD_MIN (MPI3MR_HOSTTAG_DEVRMCMD_MAX + 1)
  99. #define MPI3MR_HOSTTAG_EVTACKCMD_MAX (MPI3MR_HOSTTAG_EVTACKCMD_MIN + \
  100. MPI3MR_NUM_EVTACKCMD - 1)
  101. /* Reduced resource count definition for crash kernel */
  102. #define MPI3MR_HOST_IOS_KDUMP 128
  103. /* command/controller interaction timeout definitions in seconds */
  104. #define MPI3MR_INTADMCMD_TIMEOUT 60
  105. #define MPI3MR_PORTENABLE_TIMEOUT 300
  106. #define MPI3MR_PORTENABLE_POLL_INTERVAL 5
  107. #define MPI3MR_ABORTTM_TIMEOUT 60
  108. #define MPI3MR_RESETTM_TIMEOUT 60
  109. #define MPI3MR_RESET_HOST_IOWAIT_TIMEOUT 5
  110. #define MPI3MR_TSUPDATE_INTERVAL 900
  111. #define MPI3MR_DEFAULT_SHUTDOWN_TIME 120
  112. #define MPI3MR_RAID_ERRREC_RESET_TIMEOUT 180
  113. #define MPI3MR_PREPARE_FOR_RESET_TIMEOUT 180
  114. #define MPI3MR_RESET_ACK_TIMEOUT 30
  115. #define MPI3MR_MUR_TIMEOUT 120
  116. #define MPI3MR_RESET_TIMEOUT 510
  117. #define MPI3MR_WATCHDOG_INTERVAL 1000 /* in milli seconds */
  118. #define MPI3MR_RESET_TOPOLOGY_SETTLE_TIME 10
  119. #define MPI3MR_SCMD_TIMEOUT (60 * HZ)
  120. #define MPI3MR_EH_SCMD_TIMEOUT (60 * HZ)
  121. /* Internal admin command state definitions*/
  122. #define MPI3MR_CMD_NOTUSED 0x8000
  123. #define MPI3MR_CMD_COMPLETE 0x0001
  124. #define MPI3MR_CMD_PENDING 0x0002
  125. #define MPI3MR_CMD_REPLY_VALID 0x0004
  126. #define MPI3MR_CMD_RESET 0x0008
  127. /* Definitions for Event replies and sense buffer allocated per controller */
  128. #define MPI3MR_NUM_EVT_REPLIES 64
  129. #define MPI3MR_SENSE_BUF_SZ 256
  130. #define MPI3MR_SENSEBUF_FACTOR 3
  131. #define MPI3MR_CHAINBUF_FACTOR 3
  132. #define MPI3MR_CHAINBUFDIX_FACTOR 2
  133. /* Invalid target device handle */
  134. #define MPI3MR_INVALID_DEV_HANDLE 0xFFFF
  135. /* Controller Reset related definitions */
  136. #define MPI3MR_HOSTDIAG_UNLOCK_RETRY_COUNT 5
  137. #define MPI3MR_MAX_RESET_RETRY_COUNT 3
  138. /* ResponseCode definitions */
  139. #define MPI3MR_RI_MASK_RESPCODE (0x000000FF)
  140. #define MPI3MR_RSP_IO_QUEUED_ON_IOC \
  141. MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC
  142. #define MPI3MR_DEFAULT_MDTS (128 * 1024)
  143. #define MPI3MR_DEFAULT_PGSZEXP (12)
  144. /* Command retry count definitions */
  145. #define MPI3MR_DEV_RMHS_RETRY_COUNT 3
  146. #define MPI3MR_PEL_RETRY_COUNT 3
  147. /* Default target device queue depth */
  148. #define MPI3MR_DEFAULT_SDEV_QD 32
  149. /* Definitions for Threaded IRQ poll*/
  150. #define MPI3MR_IRQ_POLL_SLEEP 20
  151. #define MPI3MR_IRQ_POLL_TRIGGER_IOCOUNT 8
  152. /* Definitions for the controller security status*/
  153. #define MPI3MR_CTLR_SECURITY_STATUS_MASK 0x0C
  154. #define MPI3MR_CTLR_SECURE_DBG_STATUS_MASK 0x02
  155. #define MPI3MR_INVALID_DEVICE 0x00
  156. #define MPI3MR_CONFIG_SECURE_DEVICE 0x04
  157. #define MPI3MR_HARD_SECURE_DEVICE 0x08
  158. #define MPI3MR_TAMPERED_DEVICE 0x0C
  159. #define MPI3MR_DEFAULT_HDB_MAX_SZ (4 * 1024 * 1024)
  160. #define MPI3MR_DEFAULT_HDB_DEC_SZ (1 * 1024 * 1024)
  161. #define MPI3MR_DEFAULT_HDB_MIN_SZ (2 * 1024 * 1024)
  162. #define MPI3MR_MAX_NUM_HDB 2
  163. #define MPI3MR_HDB_TRIGGER_TYPE_UNKNOWN 0
  164. #define MPI3MR_HDB_TRIGGER_TYPE_FAULT 1
  165. #define MPI3MR_HDB_TRIGGER_TYPE_ELEMENT 2
  166. #define MPI3MR_HDB_TRIGGER_TYPE_GLOBAL 3
  167. #define MPI3MR_HDB_TRIGGER_TYPE_SOFT_RESET 4
  168. #define MPI3MR_HDB_TRIGGER_TYPE_FW_RELEASED 5
  169. #define MPI3MR_HDB_REFRESH_TYPE_RESERVED 0
  170. #define MPI3MR_HDB_REFRESH_TYPE_CURRENT 1
  171. #define MPI3MR_HDB_REFRESH_TYPE_DEFAULT 2
  172. #define MPI3MR_HDB_HDB_REFRESH_TYPE_PERSISTENT 3
  173. #define MPI3MR_DEFAULT_HDB_SZ (4 * 1024 * 1024)
  174. #define MPI3MR_MAX_NUM_HDB 2
  175. #define MPI3MR_HDB_QUERY_ELEMENT_TRIGGER_FORMAT_INDEX 0
  176. #define MPI3MR_HDB_QUERY_ELEMENT_TRIGGER_FORMAT_DATA 1
  177. #define MPI3MR_THRESHOLD_REPLY_COUNT 100
  178. /* SGE Flag definition */
  179. #define MPI3MR_SGEFLAGS_SYSTEM_SIMPLE_END_OF_LIST \
  180. (MPI3_SGE_FLAGS_ELEMENT_TYPE_SIMPLE | MPI3_SGE_FLAGS_DLAS_SYSTEM | \
  181. MPI3_SGE_FLAGS_END_OF_LIST)
  182. /* MSI Index from Reply Queue Index */
  183. #define REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, offset) (qidx + offset)
  184. /*
  185. * Maximum data transfer size definitions for management
  186. * application commands
  187. */
  188. #define MPI3MR_MAX_APP_XFER_SIZE (1 * 1024 * 1024)
  189. #define MPI3MR_MAX_APP_XFER_SEGMENTS 512
  190. /*
  191. * 2048 sectors are for data buffers and additional 512 sectors for
  192. * other buffers
  193. */
  194. #define MPI3MR_MAX_APP_XFER_SECTORS (2048 + 512)
  195. #define MPI3MR_WRITE_SAME_MAX_LEN_256_BLKS 256
  196. #define MPI3MR_WRITE_SAME_MAX_LEN_2048_BLKS 2048
  197. #define MPI3MR_DRIVER_EVENT_PROCESS_TRIGGER (0xFFFD)
  198. /**
  199. * struct mpi3mr_nvme_pt_sge - Structure to store SGEs for NVMe
  200. * Encapsulated commands.
  201. *
  202. * @base_addr: Physical address
  203. * @length: SGE length
  204. * @rsvd: Reserved
  205. * @rsvd1: Reserved
  206. * @sub_type: sgl sub type
  207. * @type: sgl type
  208. */
  209. struct mpi3mr_nvme_pt_sge {
  210. __le64 base_addr;
  211. __le32 length;
  212. u16 rsvd;
  213. u8 rsvd1;
  214. u8 sub_type:4;
  215. u8 type:4;
  216. };
  217. /**
  218. * struct mpi3mr_buf_map - local structure to
  219. * track kernel and user buffers associated with an BSG
  220. * structure.
  221. *
  222. * @bsg_buf: BSG buffer virtual address
  223. * @bsg_buf_len: BSG buffer length
  224. * @kern_buf: Kernel buffer virtual address
  225. * @kern_buf_len: Kernel buffer length
  226. * @kern_buf_dma: Kernel buffer DMA address
  227. * @data_dir: Data direction.
  228. */
  229. struct mpi3mr_buf_map {
  230. void *bsg_buf;
  231. u32 bsg_buf_len;
  232. void *kern_buf;
  233. u32 kern_buf_len;
  234. dma_addr_t kern_buf_dma;
  235. u8 data_dir;
  236. u16 num_dma_desc;
  237. struct dma_memory_desc *dma_desc;
  238. };
  239. /* IOC State definitions */
  240. enum mpi3mr_iocstate {
  241. MRIOC_STATE_READY = 1,
  242. MRIOC_STATE_RESET,
  243. MRIOC_STATE_FAULT,
  244. MRIOC_STATE_BECOMING_READY,
  245. MRIOC_STATE_RESET_REQUESTED,
  246. MRIOC_STATE_UNRECOVERABLE,
  247. };
  248. /* Reset reason code definitions*/
  249. enum mpi3mr_reset_reason {
  250. MPI3MR_RESET_FROM_BRINGUP = 1,
  251. MPI3MR_RESET_FROM_FAULT_WATCH = 2,
  252. MPI3MR_RESET_FROM_APP = 3,
  253. MPI3MR_RESET_FROM_EH_HOS = 4,
  254. MPI3MR_RESET_FROM_TM_TIMEOUT = 5,
  255. MPI3MR_RESET_FROM_APP_TIMEOUT = 6,
  256. MPI3MR_RESET_FROM_MUR_FAILURE = 7,
  257. MPI3MR_RESET_FROM_CTLR_CLEANUP = 8,
  258. MPI3MR_RESET_FROM_CIACTIV_FAULT = 9,
  259. MPI3MR_RESET_FROM_PE_TIMEOUT = 10,
  260. MPI3MR_RESET_FROM_TSU_TIMEOUT = 11,
  261. MPI3MR_RESET_FROM_DELREQQ_TIMEOUT = 12,
  262. MPI3MR_RESET_FROM_DELREPQ_TIMEOUT = 13,
  263. MPI3MR_RESET_FROM_CREATEREPQ_TIMEOUT = 14,
  264. MPI3MR_RESET_FROM_CREATEREQQ_TIMEOUT = 15,
  265. MPI3MR_RESET_FROM_IOCFACTS_TIMEOUT = 16,
  266. MPI3MR_RESET_FROM_IOCINIT_TIMEOUT = 17,
  267. MPI3MR_RESET_FROM_EVTNOTIFY_TIMEOUT = 18,
  268. MPI3MR_RESET_FROM_EVTACK_TIMEOUT = 19,
  269. MPI3MR_RESET_FROM_CIACTVRST_TIMER = 20,
  270. MPI3MR_RESET_FROM_GETPKGVER_TIMEOUT = 21,
  271. MPI3MR_RESET_FROM_PELABORT_TIMEOUT = 22,
  272. MPI3MR_RESET_FROM_SYSFS = 23,
  273. MPI3MR_RESET_FROM_SYSFS_TIMEOUT = 24,
  274. MPI3MR_RESET_FROM_DIAG_BUFFER_POST_TIMEOUT = 25,
  275. MPI3MR_RESET_FROM_DIAG_BUFFER_RELEASE_TIMEOUT = 26,
  276. MPI3MR_RESET_FROM_FIRMWARE = 27,
  277. MPI3MR_RESET_FROM_CFG_REQ_TIMEOUT = 29,
  278. MPI3MR_RESET_FROM_SAS_TRANSPORT_TIMEOUT = 30,
  279. MPI3MR_RESET_FROM_TRIGGER = 31,
  280. };
  281. #define MPI3MR_RESET_REASON_OSTYPE_LINUX 1
  282. #define MPI3MR_RESET_REASON_OSTYPE_SHIFT 28
  283. #define MPI3MR_RESET_REASON_IOCNUM_SHIFT 20
  284. /* Queue type definitions */
  285. enum queue_type {
  286. MPI3MR_DEFAULT_QUEUE = 0,
  287. MPI3MR_POLL_QUEUE,
  288. };
  289. /**
  290. * struct mpi3mr_compimg_ver - replica of component image
  291. * version defined in mpi30_image.h in host endianness
  292. *
  293. */
  294. struct mpi3mr_compimg_ver {
  295. u16 build_num;
  296. u16 cust_id;
  297. u8 ph_minor;
  298. u8 ph_major;
  299. u8 gen_minor;
  300. u8 gen_major;
  301. };
  302. /**
  303. * struct mpi3mr_ioc_facs - replica of component image version
  304. * defined in mpi30_ioc.h in host endianness
  305. *
  306. */
  307. struct mpi3mr_ioc_facts {
  308. u32 ioc_capabilities;
  309. struct mpi3mr_compimg_ver fw_ver;
  310. u32 mpi_version;
  311. u32 diag_trace_sz;
  312. u32 diag_fw_sz;
  313. u32 diag_drvr_sz;
  314. u16 max_reqs;
  315. u16 product_id;
  316. u16 op_req_sz;
  317. u16 reply_sz;
  318. u16 exceptions;
  319. u16 max_perids;
  320. u16 max_pds;
  321. u16 max_sasexpanders;
  322. u32 max_data_length;
  323. u16 max_sasinitiators;
  324. u16 max_enclosures;
  325. u16 max_pcie_switches;
  326. u16 max_nvme;
  327. u16 max_vds;
  328. u16 max_hpds;
  329. u16 max_advhpds;
  330. u16 max_raid_pds;
  331. u16 min_devhandle;
  332. u16 max_devhandle;
  333. u16 max_op_req_q;
  334. u16 max_op_reply_q;
  335. u16 shutdown_timeout;
  336. u8 ioc_num;
  337. u8 who_init;
  338. u16 max_msix_vectors;
  339. u8 personality;
  340. u8 dma_mask;
  341. u8 protocol_flags;
  342. u8 sge_mod_mask;
  343. u8 sge_mod_value;
  344. u8 sge_mod_shift;
  345. u8 max_dev_per_tg;
  346. u16 max_io_throttle_group;
  347. u16 io_throttle_data_length;
  348. u16 io_throttle_low;
  349. u16 io_throttle_high;
  350. };
  351. /**
  352. * struct segments - memory descriptor structure to store
  353. * virtual and dma addresses for operational queue segments.
  354. *
  355. * @segment: virtual address
  356. * @segment_dma: dma address
  357. */
  358. struct segments {
  359. void *segment;
  360. dma_addr_t segment_dma;
  361. };
  362. /**
  363. * struct op_req_qinfo - Operational Request Queue Information
  364. *
  365. * @ci: consumer index
  366. * @pi: producer index
  367. * @num_request: Maximum number of entries in the queue
  368. * @qid: Queue Id starting from 1
  369. * @reply_qid: Associated reply queue Id
  370. * @num_segments: Number of discontiguous memory segments
  371. * @segment_qd: Depth of each segments
  372. * @q_lock: Concurrent queue access lock
  373. * @q_segments: Segment descriptor pointer
  374. * @q_segment_list: Segment list base virtual address
  375. * @q_segment_list_dma: Segment list base DMA address
  376. */
  377. struct op_req_qinfo {
  378. u16 ci;
  379. u16 pi;
  380. u16 num_requests;
  381. u16 qid;
  382. u16 reply_qid;
  383. u16 num_segments;
  384. u16 segment_qd;
  385. spinlock_t q_lock;
  386. struct segments *q_segments;
  387. void *q_segment_list;
  388. dma_addr_t q_segment_list_dma;
  389. };
  390. /**
  391. * struct op_reply_qinfo - Operational Reply Queue Information
  392. *
  393. * @ci: consumer index
  394. * @qid: Queue Id starting from 1
  395. * @num_replies: Maximum number of entries in the queue
  396. * @num_segments: Number of discontiguous memory segments
  397. * @segment_qd: Depth of each segments
  398. * @q_segments: Segment descriptor pointer
  399. * @q_segment_list: Segment list base virtual address
  400. * @q_segment_list_dma: Segment list base DMA address
  401. * @ephase: Expected phased identifier for the reply queue
  402. * @pend_ios: Number of IOs pending in HW for this queue
  403. * @enable_irq_poll: Flag to indicate polling is enabled
  404. * @in_use: Queue is handled by poll/ISR
  405. * @qtype: Type of queue (types defined in enum queue_type)
  406. */
  407. struct op_reply_qinfo {
  408. u16 ci;
  409. u16 qid;
  410. u16 num_replies;
  411. u16 num_segments;
  412. u16 segment_qd;
  413. struct segments *q_segments;
  414. void *q_segment_list;
  415. dma_addr_t q_segment_list_dma;
  416. u8 ephase;
  417. atomic_t pend_ios;
  418. bool enable_irq_poll;
  419. atomic_t in_use;
  420. enum queue_type qtype;
  421. };
  422. /**
  423. * struct mpi3mr_intr_info - Interrupt cookie information
  424. *
  425. * @mrioc: Adapter instance reference
  426. * @os_irq: irq number
  427. * @msix_index: MSIx index
  428. * @op_reply_q: Associated operational reply queue
  429. * @name: Dev name for the irq claiming device
  430. */
  431. struct mpi3mr_intr_info {
  432. struct mpi3mr_ioc *mrioc;
  433. int os_irq;
  434. u16 msix_index;
  435. struct op_reply_qinfo *op_reply_q;
  436. char name[MPI3MR_NAME_LENGTH];
  437. };
  438. /**
  439. * struct mpi3mr_throttle_group_info - Throttle group info
  440. *
  441. * @io_divert: Flag indicates io divert is on or off for the TG
  442. * @need_qd_reduction: Flag to indicate QD reduction is needed
  443. * @qd_reduction: Queue Depth reduction in units of 10%
  444. * @fw_qd: QueueDepth value reported by the firmware
  445. * @modified_qd: Modified QueueDepth value due to throttling
  446. * @id: Throttle Group ID.
  447. * @high: High limit to turn on throttling in 512 byte blocks
  448. * @low: Low limit to turn off throttling in 512 byte blocks
  449. * @pend_large_data_sz: Counter to track pending large data
  450. */
  451. struct mpi3mr_throttle_group_info {
  452. u8 io_divert;
  453. u8 need_qd_reduction;
  454. u8 qd_reduction;
  455. u16 fw_qd;
  456. u16 modified_qd;
  457. u16 id;
  458. u32 high;
  459. u32 low;
  460. atomic_t pend_large_data_sz;
  461. };
  462. /* HBA port flags */
  463. #define MPI3MR_HBA_PORT_FLAG_DIRTY 0x01
  464. #define MPI3MR_HBA_PORT_FLAG_NEW 0x02
  465. /* IOCTL data transfer sge*/
  466. #define MPI3MR_NUM_IOCTL_SGE 256
  467. #define MPI3MR_IOCTL_SGE_SIZE (8 * 1024)
  468. /**
  469. * struct mpi3mr_hba_port - HBA's port information
  470. * @port_id: Port number
  471. * @flags: HBA port flags
  472. */
  473. struct mpi3mr_hba_port {
  474. struct list_head list;
  475. u8 port_id;
  476. u8 flags;
  477. };
  478. /**
  479. * struct mpi3mr_sas_port - Internal SAS port information
  480. * @port_list: List of ports belonging to a SAS node
  481. * @num_phys: Number of phys associated with port
  482. * @marked_responding: used while refresing the sas ports
  483. * @lowest_phy: lowest phy ID of current sas port, valid for controller port
  484. * @phy_mask: phy_mask of current sas port, valid for controller port
  485. * @hba_port: HBA port entry
  486. * @remote_identify: Attached device identification
  487. * @rphy: SAS transport layer rphy object
  488. * @port: SAS transport layer port object
  489. * @phy_list: mpi3mr_sas_phy objects belonging to this port
  490. */
  491. struct mpi3mr_sas_port {
  492. struct list_head port_list;
  493. u8 num_phys;
  494. u8 marked_responding;
  495. int lowest_phy;
  496. u64 phy_mask;
  497. struct mpi3mr_hba_port *hba_port;
  498. struct sas_identify remote_identify;
  499. struct sas_rphy *rphy;
  500. struct sas_port *port;
  501. struct list_head phy_list;
  502. };
  503. /**
  504. * struct mpi3mr_sas_phy - Internal SAS Phy information
  505. * @port_siblings: List of phys belonging to a port
  506. * @identify: Phy identification
  507. * @remote_identify: Attached device identification
  508. * @phy: SAS transport layer Phy object
  509. * @phy_id: Unique phy id within a port
  510. * @handle: Firmware device handle for this phy
  511. * @attached_handle: Firmware device handle for attached device
  512. * @phy_belongs_to_port: Flag to indicate phy belongs to port
  513. @hba_port: HBA port entry
  514. */
  515. struct mpi3mr_sas_phy {
  516. struct list_head port_siblings;
  517. struct sas_identify identify;
  518. struct sas_identify remote_identify;
  519. struct sas_phy *phy;
  520. u8 phy_id;
  521. u16 handle;
  522. u16 attached_handle;
  523. u8 phy_belongs_to_port;
  524. struct mpi3mr_hba_port *hba_port;
  525. };
  526. /**
  527. * struct mpi3mr_sas_node - SAS host/expander information
  528. * @list: List of sas nodes in a controller
  529. * @parent_dev: Parent device class
  530. * @num_phys: Number phys belonging to sas_node
  531. * @sas_address: SAS address of sas_node
  532. * @handle: Firmware device handle for this sas_host/expander
  533. * @sas_address_parent: SAS address of parent expander or host
  534. * @enclosure_handle: Firmware handle of enclosure of this node
  535. * @device_info: Capabilities of this sas_host/expander
  536. * @non_responding: used to refresh the expander devices during reset
  537. * @host_node: Flag to indicate this is a host_node
  538. * @hba_port: HBA port entry
  539. * @phy: A list of phys that make up this sas_host/expander
  540. * @sas_port_list: List of internal ports of this node
  541. * @rphy: sas_rphy object of this expander node
  542. */
  543. struct mpi3mr_sas_node {
  544. struct list_head list;
  545. struct device *parent_dev;
  546. u8 num_phys;
  547. u64 sas_address;
  548. u16 handle;
  549. u64 sas_address_parent;
  550. u16 enclosure_handle;
  551. u64 enclosure_logical_id;
  552. u8 non_responding;
  553. u8 host_node;
  554. struct mpi3mr_hba_port *hba_port;
  555. struct mpi3mr_sas_phy *phy;
  556. struct list_head sas_port_list;
  557. struct sas_rphy *rphy;
  558. };
  559. /**
  560. * struct mpi3mr_enclosure_node - enclosure information
  561. * @list: List of enclosures
  562. * @pg0: Enclosure page 0;
  563. */
  564. struct mpi3mr_enclosure_node {
  565. struct list_head list;
  566. struct mpi3_enclosure_page0 pg0;
  567. };
  568. /**
  569. * struct tgt_dev_sas_sata - SAS/SATA device specific
  570. * information cached from firmware given data
  571. *
  572. * @sas_address: World wide unique SAS address
  573. * @sas_address_parent: Sas address of parent expander or host
  574. * @dev_info: Device information bits
  575. * @phy_id: Phy identifier provided in device page 0
  576. * @attached_phy_id: Attached phy identifier provided in device page 0
  577. * @sas_transport_attached: Is this device exposed to transport
  578. * @pend_sas_rphy_add: Flag to check device is in process of add
  579. * @hba_port: HBA port entry
  580. * @rphy: SAS transport layer rphy object
  581. */
  582. struct tgt_dev_sas_sata {
  583. u64 sas_address;
  584. u64 sas_address_parent;
  585. u16 dev_info;
  586. u8 phy_id;
  587. u8 attached_phy_id;
  588. u8 sas_transport_attached;
  589. u8 pend_sas_rphy_add;
  590. struct mpi3mr_hba_port *hba_port;
  591. struct sas_rphy *rphy;
  592. };
  593. /**
  594. * struct tgt_dev_pcie - PCIe device specific information cached
  595. * from firmware given data
  596. *
  597. * @mdts: Maximum data transfer size
  598. * @capb: Device capabilities
  599. * @pgsz: Device page size
  600. * @abort_to: Timeout for abort TM
  601. * @reset_to: Timeout for Target/LUN reset TM
  602. * @dev_info: Device information bits
  603. */
  604. struct tgt_dev_pcie {
  605. u32 mdts;
  606. u16 capb;
  607. u8 pgsz;
  608. u8 abort_to;
  609. u8 reset_to;
  610. u16 dev_info;
  611. };
  612. /**
  613. * struct tgt_dev_vd - virtual device specific information
  614. * cached from firmware given data
  615. *
  616. * @state: State of the VD
  617. * @tg_qd_reduction: Queue Depth reduction in units of 10%
  618. * @tg_id: VDs throttle group ID
  619. * @high: High limit to turn on throttling in 512 byte blocks
  620. * @low: Low limit to turn off throttling in 512 byte blocks
  621. * @tg: Pointer to throttle group info
  622. */
  623. struct tgt_dev_vd {
  624. u8 state;
  625. u8 tg_qd_reduction;
  626. u16 tg_id;
  627. u32 tg_high;
  628. u32 tg_low;
  629. struct mpi3mr_throttle_group_info *tg;
  630. };
  631. /**
  632. * union _form_spec_inf - union of device specific information
  633. */
  634. union _form_spec_inf {
  635. struct tgt_dev_sas_sata sas_sata_inf;
  636. struct tgt_dev_pcie pcie_inf;
  637. struct tgt_dev_vd vd_inf;
  638. };
  639. enum mpi3mr_dev_state {
  640. MPI3MR_DEV_CREATED = 1,
  641. MPI3MR_DEV_REMOVE_HS_STARTED = 2,
  642. MPI3MR_DEV_DELETED = 3,
  643. };
  644. /**
  645. * struct mpi3mr_tgt_dev - target device data structure
  646. *
  647. * @list: List pointer
  648. * @starget: Scsi_target pointer
  649. * @dev_handle: FW device handle
  650. * @parent_handle: FW parent device handle
  651. * @slot: Slot number
  652. * @encl_handle: FW enclosure handle
  653. * @perst_id: FW assigned Persistent ID
  654. * @devpg0_flag: Device Page0 flag
  655. * @dev_type: SAS/SATA/PCIE device type
  656. * @is_hidden: Should be exposed to upper layers or not
  657. * @host_exposed: Already exposed to host or not
  658. * @io_unit_port: IO Unit port ID
  659. * @non_stl: Is this device not to be attached with SAS TL
  660. * @io_throttle_enabled: I/O throttling needed or not
  661. * @wslen: Write same max length
  662. * @q_depth: Device specific Queue Depth
  663. * @wwid: World wide ID
  664. * @enclosure_logical_id: Enclosure logical identifier
  665. * @dev_spec: Device type specific information
  666. * @ref_count: Reference count
  667. * @state: device state
  668. */
  669. struct mpi3mr_tgt_dev {
  670. struct list_head list;
  671. struct scsi_target *starget;
  672. u16 dev_handle;
  673. u16 parent_handle;
  674. u16 slot;
  675. u16 encl_handle;
  676. u16 perst_id;
  677. u16 devpg0_flag;
  678. u8 dev_type;
  679. u8 is_hidden;
  680. u8 host_exposed;
  681. u8 io_unit_port;
  682. u8 non_stl;
  683. u8 io_throttle_enabled;
  684. u16 wslen;
  685. u16 q_depth;
  686. u64 wwid;
  687. u64 enclosure_logical_id;
  688. union _form_spec_inf dev_spec;
  689. struct kref ref_count;
  690. enum mpi3mr_dev_state state;
  691. };
  692. /**
  693. * mpi3mr_tgtdev_get - k reference incrementor
  694. * @s: Target device reference
  695. *
  696. * Increment target device reference count.
  697. */
  698. static inline void mpi3mr_tgtdev_get(struct mpi3mr_tgt_dev *s)
  699. {
  700. kref_get(&s->ref_count);
  701. }
  702. /**
  703. * mpi3mr_free_tgtdev - target device memory dealloctor
  704. * @r: k reference pointer of the target device
  705. *
  706. * Free target device memory when no reference.
  707. */
  708. static inline void mpi3mr_free_tgtdev(struct kref *r)
  709. {
  710. kfree(container_of(r, struct mpi3mr_tgt_dev, ref_count));
  711. }
  712. /**
  713. * mpi3mr_tgtdev_put - k reference decrementor
  714. * @s: Target device reference
  715. *
  716. * Decrement target device reference count.
  717. */
  718. static inline void mpi3mr_tgtdev_put(struct mpi3mr_tgt_dev *s)
  719. {
  720. kref_put(&s->ref_count, mpi3mr_free_tgtdev);
  721. }
  722. /**
  723. * struct mpi3mr_stgt_priv_data - SCSI target private structure
  724. *
  725. * @starget: Scsi_target pointer
  726. * @dev_handle: FW device handle
  727. * @perst_id: FW assigned Persistent ID
  728. * @num_luns: Number of Logical Units
  729. * @block_io: I/O blocked to the device or not
  730. * @dev_removed: Device removed in the Firmware
  731. * @dev_removedelay: Device is waiting to be removed in FW
  732. * @dev_type: Device type
  733. * @dev_nvme_dif: Device is NVMe DIF enabled
  734. * @wslen: Write same max length
  735. * @io_throttle_enabled: I/O throttling needed or not
  736. * @io_divert: Flag indicates io divert is on or off for the dev
  737. * @throttle_group: Pointer to throttle group info
  738. * @tgt_dev: Internal target device pointer
  739. * @pend_count: Counter to track pending I/Os during error
  740. * handling
  741. */
  742. struct mpi3mr_stgt_priv_data {
  743. struct scsi_target *starget;
  744. u16 dev_handle;
  745. u16 perst_id;
  746. u32 num_luns;
  747. atomic_t block_io;
  748. u8 dev_removed;
  749. u8 dev_removedelay;
  750. u8 dev_type;
  751. u8 dev_nvme_dif;
  752. u16 wslen;
  753. u8 io_throttle_enabled;
  754. u8 io_divert;
  755. struct mpi3mr_throttle_group_info *throttle_group;
  756. struct mpi3mr_tgt_dev *tgt_dev;
  757. u32 pend_count;
  758. };
  759. /**
  760. * struct mpi3mr_stgt_priv_data - SCSI device private structure
  761. *
  762. * @tgt_priv_data: Scsi_target private data pointer
  763. * @lun_id: LUN ID of the device
  764. * @ncq_prio_enable: NCQ priority enable for SATA device
  765. * @pend_count: Counter to track pending I/Os during error
  766. * handling
  767. * @wslen: Write same max length
  768. */
  769. struct mpi3mr_sdev_priv_data {
  770. struct mpi3mr_stgt_priv_data *tgt_priv_data;
  771. u32 lun_id;
  772. u8 ncq_prio_enable;
  773. u32 pend_count;
  774. u16 wslen;
  775. };
  776. /**
  777. * struct mpi3mr_drv_cmd - Internal command tracker
  778. *
  779. * @mutex: Command mutex
  780. * @done: Completeor for wakeup
  781. * @reply: Firmware reply for internal commands
  782. * @sensebuf: Sensebuf for SCSI IO commands
  783. * @iou_rc: IO Unit control reason code
  784. * @state: Command State
  785. * @dev_handle: Firmware handle for device specific commands
  786. * @ioc_status: IOC status from the firmware
  787. * @ioc_loginfo:IOC log info from the firmware
  788. * @is_waiting: Is the command issued in block mode
  789. * @is_sense: Is Sense data present
  790. * @retry_count: Retry count for retriable commands
  791. * @host_tag: Host tag used by the command
  792. * @callback: Callback for non blocking commands
  793. */
  794. struct mpi3mr_drv_cmd {
  795. struct mutex mutex;
  796. struct completion done;
  797. void *reply;
  798. u8 *sensebuf;
  799. u8 iou_rc;
  800. u16 state;
  801. u16 dev_handle;
  802. u16 ioc_status;
  803. u32 ioc_loginfo;
  804. u8 is_waiting;
  805. u8 is_sense;
  806. u8 retry_count;
  807. u16 host_tag;
  808. void (*callback)(struct mpi3mr_ioc *mrioc,
  809. struct mpi3mr_drv_cmd *drv_cmd);
  810. };
  811. /**
  812. * union mpi3mr_trigger_data - Trigger data information
  813. * @fault: Fault code
  814. * @global: Global trigger data
  815. * @element: element trigger data
  816. */
  817. union mpi3mr_trigger_data {
  818. u16 fault;
  819. u64 global;
  820. union mpi3_driver2_trigger_element element;
  821. };
  822. /**
  823. * struct trigger_event_data - store trigger related
  824. * information.
  825. *
  826. * @trace_hdb: Trace diag buffer descriptor reference
  827. * @fw_hdb: FW diag buffer descriptor reference
  828. * @trigger_type: Trigger type
  829. * @trigger_specific_data: Trigger specific data
  830. * @snapdump: Snapdump enable or disable flag
  831. */
  832. struct trigger_event_data {
  833. struct diag_buffer_desc *trace_hdb;
  834. struct diag_buffer_desc *fw_hdb;
  835. u8 trigger_type;
  836. union mpi3mr_trigger_data trigger_specific_data;
  837. bool snapdump;
  838. };
  839. /**
  840. * struct diag_buffer_desc - memory descriptor structure to
  841. * store virtual, dma addresses, size, buffer status for host
  842. * diagnostic buffers.
  843. *
  844. * @type: Buffer type
  845. * @trigger_data: Trigger data
  846. * @trigger_type: Trigger type
  847. * @status: Buffer status
  848. * @size: Buffer size
  849. * @addr: Virtual address
  850. * @dma_addr: Buffer DMA address
  851. */
  852. struct diag_buffer_desc {
  853. u8 type;
  854. union mpi3mr_trigger_data trigger_data;
  855. u8 trigger_type;
  856. u8 status;
  857. u32 size;
  858. void *addr;
  859. dma_addr_t dma_addr;
  860. };
  861. /**
  862. * struct dma_memory_desc - memory descriptor structure to store
  863. * virtual address, dma address and size for any generic dma
  864. * memory allocations in the driver.
  865. *
  866. * @size: buffer size
  867. * @addr: virtual address
  868. * @dma_addr: dma address
  869. */
  870. struct dma_memory_desc {
  871. u32 size;
  872. void *addr;
  873. dma_addr_t dma_addr;
  874. };
  875. /**
  876. * struct chain_element - memory descriptor structure to store
  877. * virtual and dma addresses for chain elements.
  878. *
  879. * @addr: virtual address
  880. * @dma_addr: dma address
  881. */
  882. struct chain_element {
  883. void *addr;
  884. dma_addr_t dma_addr;
  885. };
  886. /**
  887. * struct scmd_priv - SCSI command private data
  888. *
  889. * @host_tag: Host tag specific to operational queue
  890. * @in_lld_scope: Command in LLD scope or not
  891. * @meta_sg_valid: DIX command with meta data SGL or not
  892. * @scmd: SCSI Command pointer
  893. * @req_q_idx: Operational request queue index
  894. * @chain_idx: Chain frame index
  895. * @meta_chain_idx: Chain frame index of meta data SGL
  896. * @mpi3mr_scsiio_req: MPI SCSI IO request
  897. */
  898. struct scmd_priv {
  899. u16 host_tag;
  900. u8 in_lld_scope;
  901. u8 meta_sg_valid;
  902. struct scsi_cmnd *scmd;
  903. u16 req_q_idx;
  904. int chain_idx;
  905. int meta_chain_idx;
  906. u8 mpi3mr_scsiio_req[MPI3MR_ADMIN_REQ_FRAME_SZ];
  907. };
  908. /**
  909. * struct mpi3mr_ioc - Adapter anchor structure stored in shost
  910. * private data
  911. *
  912. * @list: List pointer
  913. * @pdev: PCI device pointer
  914. * @shost: Scsi_Host pointer
  915. * @id: Controller ID
  916. * @cpu_count: Number of online CPUs
  917. * @irqpoll_sleep: usleep unit used in threaded isr irqpoll
  918. * @name: Controller ASCII name
  919. * @driver_name: Driver ASCII name
  920. * @sysif_regs: System interface registers virtual address
  921. * @sysif_regs_phys: System interface registers physical address
  922. * @bars: PCI BARS
  923. * @dma_mask: DMA mask
  924. * @msix_count: Number of MSIX vectors used
  925. * @intr_enabled: Is interrupts enabled
  926. * @num_admin_req: Number of admin requests
  927. * @admin_req_q_sz: Admin request queue size
  928. * @admin_req_pi: Admin request queue producer index
  929. * @admin_req_ci: Admin request queue consumer index
  930. * @admin_req_base: Admin request queue base virtual address
  931. * @admin_req_dma: Admin request queue base dma address
  932. * @admin_req_lock: Admin queue access lock
  933. * @num_admin_replies: Number of admin replies
  934. * @admin_reply_q_sz: Admin reply queue size
  935. * @admin_reply_ci: Admin reply queue consumer index
  936. * @admin_reply_ephase:Admin reply queue expected phase
  937. * @admin_reply_base: Admin reply queue base virtual address
  938. * @admin_reply_dma: Admin reply queue base dma address
  939. * @admin_reply_q_in_use: Queue is handled by poll/ISR
  940. * @ready_timeout: Controller ready timeout
  941. * @intr_info: Interrupt cookie pointer
  942. * @intr_info_count: Number of interrupt cookies
  943. * @is_intr_info_set: Flag to indicate intr info is setup
  944. * @num_queues: Number of operational queues
  945. * @num_op_req_q: Number of operational request queues
  946. * @req_qinfo: Operational request queue info pointer
  947. * @num_op_reply_q: Number of operational reply queues
  948. * @op_reply_qinfo: Operational reply queue info pointer
  949. * @init_cmds: Command tracker for initialization commands
  950. * @cfg_cmds: Command tracker for configuration requests
  951. * @facts: Cached IOC facts data
  952. * @op_reply_desc_sz: Operational reply descriptor size
  953. * @num_reply_bufs: Number of reply buffers allocated
  954. * @reply_buf_pool: Reply buffer pool
  955. * @reply_buf: Reply buffer base virtual address
  956. * @reply_buf_dma: Reply buffer DMA address
  957. * @reply_buf_dma_max_address: Reply DMA address max limit
  958. * @reply_free_qsz: Reply free queue size
  959. * @reply_free_q_pool: Reply free queue pool
  960. * @reply_free_q: Reply free queue base virtual address
  961. * @reply_free_q_dma: Reply free queue base DMA address
  962. * @reply_free_queue_lock: Reply free queue lock
  963. * @reply_free_queue_host_index: Reply free queue host index
  964. * @num_sense_bufs: Number of sense buffers
  965. * @sense_buf_pool: Sense buffer pool
  966. * @sense_buf: Sense buffer base virtual address
  967. * @sense_buf_dma: Sense buffer base DMA address
  968. * @sense_buf_q_sz: Sense buffer queue size
  969. * @sense_buf_q_pool: Sense buffer queue pool
  970. * @sense_buf_q: Sense buffer queue virtual address
  971. * @sense_buf_q_dma: Sense buffer queue DMA address
  972. * @sbq_lock: Sense buffer queue lock
  973. * @sbq_host_index: Sense buffer queuehost index
  974. * @event_masks: Event mask bitmap
  975. * @fwevt_worker_thread: Firmware event worker thread
  976. * @fwevt_lock: Firmware event lock
  977. * @fwevt_list: Firmware event list
  978. * @watchdog_work_q_name: Fault watchdog worker thread name
  979. * @watchdog_work_q: Fault watchdog worker thread
  980. * @watchdog_work: Fault watchdog work
  981. * @watchdog_lock: Fault watchdog lock
  982. * @is_driver_loading: Is driver still loading
  983. * @scan_started: Async scan started
  984. * @scan_failed: Asycn scan failed
  985. * @stop_drv_processing: Stop all command processing
  986. * @device_refresh_on: Don't process the events until devices are refreshed
  987. * @max_host_ios: Maximum host I/O count
  988. * @max_sgl_entries: Max SGL entries per I/O
  989. * @chain_buf_count: Chain buffer count
  990. * @chain_buf_pool: Chain buffer pool
  991. * @chain_sgl_list: Chain SGL list
  992. * @chain_bitmap: Chain buffer allocator bitmap
  993. * @chain_buf_lock: Chain buffer list lock
  994. * @bsg_cmds: Command tracker for BSG command
  995. * @host_tm_cmds: Command tracker for task management commands
  996. * @dev_rmhs_cmds: Command tracker for device removal commands
  997. * @evtack_cmds: Command tracker for event ack commands
  998. * @devrem_bitmap: Device removal bitmap
  999. * @dev_handle_bitmap_bits: Number of bits in device handle bitmap
  1000. * @removepend_bitmap: Remove pending bitmap
  1001. * @delayed_rmhs_list: Delayed device removal list
  1002. * @evtack_cmds_bitmap: Event Ack bitmap
  1003. * @delayed_evtack_cmds_list: Delayed event acknowledgment list
  1004. * @ts_update_counter: Timestamp update counter
  1005. * @ts_update_interval: Timestamp update interval
  1006. * @reset_in_progress: Reset in progress flag
  1007. * @unrecoverable: Controller unrecoverable flag
  1008. * @prev_reset_result: Result of previous reset
  1009. * @reset_mutex: Controller reset mutex
  1010. * @reset_waitq: Controller reset wait queue
  1011. * @prepare_for_reset: Prepare for reset event received
  1012. * @prepare_for_reset_timeout_counter: Prepare for reset timeout
  1013. * @prp_list_virt: NVMe encapsulated PRP list virtual base
  1014. * @prp_list_dma: NVMe encapsulated PRP list DMA
  1015. * @prp_sz: NVME encapsulated PRP list size
  1016. * @diagsave_timeout: Diagnostic information save timeout
  1017. * @logging_level: Controller debug logging level
  1018. * @flush_io_count: I/O count to flush after reset
  1019. * @current_event: Firmware event currently in process
  1020. * @driver_info: Driver, Kernel, OS information to firmware
  1021. * @change_count: Topology change count
  1022. * @pel_enabled: Persistent Event Log(PEL) enabled or not
  1023. * @pel_abort_requested: PEL abort is requested or not
  1024. * @pel_class: PEL Class identifier
  1025. * @pel_locale: PEL Locale identifier
  1026. * @pel_cmds: Command tracker for PEL wait command
  1027. * @pel_abort_cmd: Command tracker for PEL abort command
  1028. * @pel_newest_seqnum: Newest PEL sequenece number
  1029. * @pel_seqnum_virt: PEL sequence number virtual address
  1030. * @pel_seqnum_dma: PEL sequence number DMA address
  1031. * @pel_seqnum_sz: PEL sequenece number size
  1032. * @op_reply_q_offset: Operational reply queue offset with MSIx
  1033. * @default_qcount: Total Default queues
  1034. * @active_poll_qcount: Currently active poll queue count
  1035. * @requested_poll_qcount: User requested poll queue count
  1036. * @bsg_dev: BSG device structure
  1037. * @bsg_queue: Request queue for BSG device
  1038. * @stop_bsgs: Stop BSG request flag
  1039. * @logdata_buf: Circular buffer to store log data entries
  1040. * @logdata_buf_idx: Index of entry in buffer to store
  1041. * @logdata_entry_sz: log data entry size
  1042. * @pend_large_data_sz: Counter to track pending large data
  1043. * @io_throttle_data_length: I/O size to track in 512b blocks
  1044. * @io_throttle_high: I/O size to start throttle in 512b blocks
  1045. * @io_throttle_low: I/O size to stop throttle in 512b blocks
  1046. * @num_io_throttle_group: Maximum number of throttle groups
  1047. * @throttle_groups: Pointer to throttle group info structures
  1048. * @sas_transport_enabled: SAS transport enabled or not
  1049. * @scsi_device_channel: Channel ID for SCSI devices
  1050. * @transport_cmds: Command tracker for SAS transport commands
  1051. * @sas_hba: SAS node for the controller
  1052. * @sas_expander_list: SAS node list of expanders
  1053. * @sas_node_lock: Lock to protect SAS node list
  1054. * @hba_port_table_list: List of HBA Ports
  1055. * @enclosure_list: List of Enclosure objects
  1056. * @diag_buffers: Host diagnostic buffers
  1057. * @driver_pg2: Driver page 2 pointer
  1058. * @reply_trigger_present: Reply trigger present flag
  1059. * @event_trigger_present: Event trigger present flag
  1060. * @scsisense_trigger_present: Scsi sense trigger present flag
  1061. * @ioctl_dma_pool: DMA pool for IOCTL data buffers
  1062. * @ioctl_sge: DMA buffer descriptors for IOCTL data
  1063. * @ioctl_chain_sge: DMA buffer descriptor for IOCTL chain
  1064. * @ioctl_resp_sge: DMA buffer descriptor for Mgmt cmd response
  1065. * @ioctl_sges_allocated: Flag for IOCTL SGEs allocated or not
  1066. * @trace_release_trigger_active: Trace trigger active flag
  1067. * @fw_release_trigger_active: Fw release trigger active flag
  1068. * @snapdump_trigger_active: Snapdump trigger active flag
  1069. * @pci_err_recovery: PCI error recovery in progress
  1070. * @block_on_pci_err: Block IO during PCI error recovery
  1071. */
  1072. struct mpi3mr_ioc {
  1073. struct list_head list;
  1074. struct pci_dev *pdev;
  1075. struct Scsi_Host *shost;
  1076. u8 id;
  1077. int cpu_count;
  1078. bool enable_segqueue;
  1079. u32 irqpoll_sleep;
  1080. char name[MPI3MR_NAME_LENGTH];
  1081. char driver_name[MPI3MR_NAME_LENGTH];
  1082. volatile struct mpi3_sysif_registers __iomem *sysif_regs;
  1083. resource_size_t sysif_regs_phys;
  1084. int bars;
  1085. u64 dma_mask;
  1086. u16 msix_count;
  1087. u8 intr_enabled;
  1088. u16 num_admin_req;
  1089. u32 admin_req_q_sz;
  1090. u16 admin_req_pi;
  1091. u16 admin_req_ci;
  1092. void *admin_req_base;
  1093. dma_addr_t admin_req_dma;
  1094. spinlock_t admin_req_lock;
  1095. u16 num_admin_replies;
  1096. u32 admin_reply_q_sz;
  1097. u16 admin_reply_ci;
  1098. u8 admin_reply_ephase;
  1099. void *admin_reply_base;
  1100. dma_addr_t admin_reply_dma;
  1101. atomic_t admin_reply_q_in_use;
  1102. u32 ready_timeout;
  1103. struct mpi3mr_intr_info *intr_info;
  1104. u16 intr_info_count;
  1105. bool is_intr_info_set;
  1106. u16 num_queues;
  1107. u16 num_op_req_q;
  1108. struct op_req_qinfo *req_qinfo;
  1109. u16 num_op_reply_q;
  1110. struct op_reply_qinfo *op_reply_qinfo;
  1111. struct mpi3mr_drv_cmd init_cmds;
  1112. struct mpi3mr_drv_cmd cfg_cmds;
  1113. struct mpi3mr_ioc_facts facts;
  1114. u16 op_reply_desc_sz;
  1115. u32 num_reply_bufs;
  1116. struct dma_pool *reply_buf_pool;
  1117. u8 *reply_buf;
  1118. dma_addr_t reply_buf_dma;
  1119. dma_addr_t reply_buf_dma_max_address;
  1120. u16 reply_free_qsz;
  1121. u16 reply_sz;
  1122. struct dma_pool *reply_free_q_pool;
  1123. __le64 *reply_free_q;
  1124. dma_addr_t reply_free_q_dma;
  1125. spinlock_t reply_free_queue_lock;
  1126. u32 reply_free_queue_host_index;
  1127. u32 num_sense_bufs;
  1128. struct dma_pool *sense_buf_pool;
  1129. u8 *sense_buf;
  1130. dma_addr_t sense_buf_dma;
  1131. u16 sense_buf_q_sz;
  1132. struct dma_pool *sense_buf_q_pool;
  1133. __le64 *sense_buf_q;
  1134. dma_addr_t sense_buf_q_dma;
  1135. spinlock_t sbq_lock;
  1136. u32 sbq_host_index;
  1137. u32 event_masks[MPI3_EVENT_NOTIFY_EVENTMASK_WORDS];
  1138. struct workqueue_struct *fwevt_worker_thread;
  1139. spinlock_t fwevt_lock;
  1140. struct list_head fwevt_list;
  1141. char watchdog_work_q_name[50];
  1142. struct workqueue_struct *watchdog_work_q;
  1143. struct delayed_work watchdog_work;
  1144. spinlock_t watchdog_lock;
  1145. u8 is_driver_loading;
  1146. u8 scan_started;
  1147. u16 scan_failed;
  1148. u8 stop_drv_processing;
  1149. u8 device_refresh_on;
  1150. u16 max_host_ios;
  1151. spinlock_t tgtdev_lock;
  1152. struct list_head tgtdev_list;
  1153. u16 max_sgl_entries;
  1154. u32 chain_buf_count;
  1155. struct dma_pool *chain_buf_pool;
  1156. struct chain_element *chain_sgl_list;
  1157. unsigned long *chain_bitmap;
  1158. spinlock_t chain_buf_lock;
  1159. struct mpi3mr_drv_cmd bsg_cmds;
  1160. struct mpi3mr_drv_cmd host_tm_cmds;
  1161. struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD];
  1162. struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD];
  1163. unsigned long *devrem_bitmap;
  1164. u16 dev_handle_bitmap_bits;
  1165. unsigned long *removepend_bitmap;
  1166. struct list_head delayed_rmhs_list;
  1167. unsigned long *evtack_cmds_bitmap;
  1168. struct list_head delayed_evtack_cmds_list;
  1169. u16 ts_update_counter;
  1170. u16 ts_update_interval;
  1171. u8 reset_in_progress;
  1172. u8 unrecoverable;
  1173. int prev_reset_result;
  1174. struct mutex reset_mutex;
  1175. wait_queue_head_t reset_waitq;
  1176. u8 prepare_for_reset;
  1177. u16 prepare_for_reset_timeout_counter;
  1178. void *prp_list_virt;
  1179. dma_addr_t prp_list_dma;
  1180. u32 prp_sz;
  1181. u16 diagsave_timeout;
  1182. int logging_level;
  1183. u16 flush_io_count;
  1184. struct mpi3mr_fwevt *current_event;
  1185. struct mpi3_driver_info_layout driver_info;
  1186. u16 change_count;
  1187. u8 pel_enabled;
  1188. u8 pel_abort_requested;
  1189. u8 pel_class;
  1190. u16 pel_locale;
  1191. struct mpi3mr_drv_cmd pel_cmds;
  1192. struct mpi3mr_drv_cmd pel_abort_cmd;
  1193. u32 pel_newest_seqnum;
  1194. void *pel_seqnum_virt;
  1195. dma_addr_t pel_seqnum_dma;
  1196. u32 pel_seqnum_sz;
  1197. u16 op_reply_q_offset;
  1198. u16 default_qcount;
  1199. u16 active_poll_qcount;
  1200. u16 requested_poll_qcount;
  1201. struct device bsg_dev;
  1202. struct request_queue *bsg_queue;
  1203. u8 stop_bsgs;
  1204. u8 *logdata_buf;
  1205. u16 logdata_buf_idx;
  1206. u16 logdata_entry_sz;
  1207. atomic_t pend_large_data_sz;
  1208. u32 io_throttle_data_length;
  1209. u32 io_throttle_high;
  1210. u32 io_throttle_low;
  1211. u16 num_io_throttle_group;
  1212. struct mpi3mr_throttle_group_info *throttle_groups;
  1213. u8 sas_transport_enabled;
  1214. u8 scsi_device_channel;
  1215. struct mpi3mr_drv_cmd transport_cmds;
  1216. struct mpi3mr_sas_node sas_hba;
  1217. struct list_head sas_expander_list;
  1218. spinlock_t sas_node_lock;
  1219. struct list_head hba_port_table_list;
  1220. struct list_head enclosure_list;
  1221. struct dma_pool *ioctl_dma_pool;
  1222. struct dma_memory_desc ioctl_sge[MPI3MR_NUM_IOCTL_SGE];
  1223. struct dma_memory_desc ioctl_chain_sge;
  1224. struct dma_memory_desc ioctl_resp_sge;
  1225. bool ioctl_sges_allocated;
  1226. bool reply_trigger_present;
  1227. bool event_trigger_present;
  1228. bool scsisense_trigger_present;
  1229. struct diag_buffer_desc diag_buffers[MPI3MR_MAX_NUM_HDB];
  1230. struct mpi3_driver_page2 *driver_pg2;
  1231. spinlock_t trigger_lock;
  1232. bool snapdump_trigger_active;
  1233. bool trace_release_trigger_active;
  1234. bool fw_release_trigger_active;
  1235. bool pci_err_recovery;
  1236. bool block_on_pci_err;
  1237. };
  1238. /**
  1239. * struct mpi3mr_fwevt - Firmware event structure.
  1240. *
  1241. * @list: list head
  1242. * @work: Work structure
  1243. * @mrioc: Adapter instance reference
  1244. * @event_id: MPI3 firmware event ID
  1245. * @send_ack: Event acknowledgment required or not
  1246. * @process_evt: Bottomhalf processing required or not
  1247. * @evt_ctx: Event context to send in Ack
  1248. * @event_data_size: size of the event data in bytes
  1249. * @pending_at_sml: waiting for device add/remove API to complete
  1250. * @discard: discard this event
  1251. * @ref_count: kref count
  1252. * @event_data: Actual MPI3 event data
  1253. */
  1254. struct mpi3mr_fwevt {
  1255. struct list_head list;
  1256. struct work_struct work;
  1257. struct mpi3mr_ioc *mrioc;
  1258. u16 event_id;
  1259. bool send_ack;
  1260. bool process_evt;
  1261. u32 evt_ctx;
  1262. u16 event_data_size;
  1263. bool pending_at_sml;
  1264. bool discard;
  1265. struct kref ref_count;
  1266. char event_data[] __aligned(4);
  1267. };
  1268. /**
  1269. * struct delayed_dev_rmhs_node - Delayed device removal node
  1270. *
  1271. * @list: list head
  1272. * @handle: Device handle
  1273. * @iou_rc: IO Unit Control Reason Code
  1274. */
  1275. struct delayed_dev_rmhs_node {
  1276. struct list_head list;
  1277. u16 handle;
  1278. u8 iou_rc;
  1279. };
  1280. /**
  1281. * struct delayed_evt_ack_node - Delayed event ack node
  1282. * @list: list head
  1283. * @event: MPI3 event ID
  1284. * @event_ctx: event context
  1285. */
  1286. struct delayed_evt_ack_node {
  1287. struct list_head list;
  1288. u8 event;
  1289. u32 event_ctx;
  1290. };
  1291. int mpi3mr_setup_resources(struct mpi3mr_ioc *mrioc);
  1292. void mpi3mr_cleanup_resources(struct mpi3mr_ioc *mrioc);
  1293. int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc);
  1294. int mpi3mr_reinit_ioc(struct mpi3mr_ioc *mrioc, u8 is_resume);
  1295. void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc);
  1296. int mpi3mr_issue_port_enable(struct mpi3mr_ioc *mrioc, u8 async);
  1297. int mpi3mr_admin_request_post(struct mpi3mr_ioc *mrioc, void *admin_req,
  1298. u16 admin_req_sz, u8 ignore_reset);
  1299. int mpi3mr_op_request_post(struct mpi3mr_ioc *mrioc,
  1300. struct op_req_qinfo *opreqq, u8 *req);
  1301. void mpi3mr_add_sg_single(void *paddr, u8 flags, u32 length,
  1302. dma_addr_t dma_addr);
  1303. void mpi3mr_build_zero_len_sge(void *paddr);
  1304. void *mpi3mr_get_sensebuf_virt_addr(struct mpi3mr_ioc *mrioc,
  1305. dma_addr_t phys_addr);
  1306. void *mpi3mr_get_reply_virt_addr(struct mpi3mr_ioc *mrioc,
  1307. dma_addr_t phys_addr);
  1308. void mpi3mr_repost_sense_buf(struct mpi3mr_ioc *mrioc,
  1309. u64 sense_buf_dma);
  1310. void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc);
  1311. void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc);
  1312. void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,
  1313. struct mpi3_event_notification_reply *event_reply);
  1314. void mpi3mr_process_op_reply_desc(struct mpi3mr_ioc *mrioc,
  1315. struct mpi3_default_reply_descriptor *reply_desc,
  1316. u64 *reply_dma, u16 qidx);
  1317. void mpi3mr_start_watchdog(struct mpi3mr_ioc *mrioc);
  1318. void mpi3mr_stop_watchdog(struct mpi3mr_ioc *mrioc);
  1319. int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
  1320. u16 reset_reason, u8 snapdump);
  1321. void mpi3mr_ioc_disable_intr(struct mpi3mr_ioc *mrioc);
  1322. void mpi3mr_ioc_enable_intr(struct mpi3mr_ioc *mrioc);
  1323. enum mpi3mr_iocstate mpi3mr_get_iocstate(struct mpi3mr_ioc *mrioc);
  1324. int mpi3mr_process_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
  1325. u32 event_ctx);
  1326. void mpi3mr_wait_for_host_io(struct mpi3mr_ioc *mrioc, u32 timeout);
  1327. void mpi3mr_cleanup_fwevt_list(struct mpi3mr_ioc *mrioc);
  1328. void mpi3mr_flush_host_io(struct mpi3mr_ioc *mrioc);
  1329. void mpi3mr_invalidate_devhandles(struct mpi3mr_ioc *mrioc);
  1330. void mpi3mr_flush_delayed_cmd_lists(struct mpi3mr_ioc *mrioc);
  1331. void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);
  1332. void mpi3mr_print_fault_info(struct mpi3mr_ioc *mrioc);
  1333. void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);
  1334. int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
  1335. struct op_reply_qinfo *op_reply_q);
  1336. int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);
  1337. void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc);
  1338. void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc);
  1339. int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
  1340. u16 handle, uint lun, u16 htag, ulong timeout,
  1341. struct mpi3mr_drv_cmd *drv_cmd,
  1342. u8 *resp_code, struct scsi_cmnd *scmd);
  1343. struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(
  1344. struct mpi3mr_ioc *mrioc, u16 handle);
  1345. void mpi3mr_pel_get_seqnum_complete(struct mpi3mr_ioc *mrioc,
  1346. struct mpi3mr_drv_cmd *drv_cmd);
  1347. int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc,
  1348. struct mpi3mr_drv_cmd *drv_cmd);
  1349. void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data,
  1350. u16 event_data_size);
  1351. struct mpi3mr_enclosure_node *mpi3mr_enclosure_find_by_handle(
  1352. struct mpi3mr_ioc *mrioc, u16 handle);
  1353. extern const struct attribute_group *mpi3mr_host_groups[];
  1354. extern const struct attribute_group *mpi3mr_dev_groups[];
  1355. extern struct sas_function_template mpi3mr_transport_functions;
  1356. extern struct scsi_transport_template *mpi3mr_transport_template;
  1357. int mpi3mr_cfg_get_dev_pg0(struct mpi3mr_ioc *mrioc, u16 *ioc_status,
  1358. struct mpi3_device_page0 *dev_pg0, u16 pg_sz, u32 form, u32 form_spec);
  1359. int mpi3mr_cfg_get_sas_phy_pg0(struct mpi3mr_ioc *mrioc, u16 *ioc_status,
  1360. struct mpi3_sas_phy_page0 *phy_pg0, u16 pg_sz, u32 form,
  1361. u32 form_spec);
  1362. int mpi3mr_cfg_get_sas_phy_pg1(struct mpi3mr_ioc *mrioc, u16 *ioc_status,
  1363. struct mpi3_sas_phy_page1 *phy_pg1, u16 pg_sz, u32 form,
  1364. u32 form_spec);
  1365. int mpi3mr_cfg_get_sas_exp_pg0(struct mpi3mr_ioc *mrioc, u16 *ioc_status,
  1366. struct mpi3_sas_expander_page0 *exp_pg0, u16 pg_sz, u32 form,
  1367. u32 form_spec);
  1368. int mpi3mr_cfg_get_sas_exp_pg1(struct mpi3mr_ioc *mrioc, u16 *ioc_status,
  1369. struct mpi3_sas_expander_page1 *exp_pg1, u16 pg_sz, u32 form,
  1370. u32 form_spec);
  1371. int mpi3mr_cfg_get_enclosure_pg0(struct mpi3mr_ioc *mrioc, u16 *ioc_status,
  1372. struct mpi3_enclosure_page0 *encl_pg0, u16 pg_sz, u32 form,
  1373. u32 form_spec);
  1374. int mpi3mr_cfg_get_sas_io_unit_pg0(struct mpi3mr_ioc *mrioc,
  1375. struct mpi3_sas_io_unit_page0 *sas_io_unit_pg0, u16 pg_sz);
  1376. int mpi3mr_cfg_get_sas_io_unit_pg1(struct mpi3mr_ioc *mrioc,
  1377. struct mpi3_sas_io_unit_page1 *sas_io_unit_pg1, u16 pg_sz);
  1378. int mpi3mr_cfg_set_sas_io_unit_pg1(struct mpi3mr_ioc *mrioc,
  1379. struct mpi3_sas_io_unit_page1 *sas_io_unit_pg1, u16 pg_sz);
  1380. int mpi3mr_cfg_get_driver_pg1(struct mpi3mr_ioc *mrioc,
  1381. struct mpi3_driver_page1 *driver_pg1, u16 pg_sz);
  1382. int mpi3mr_cfg_get_driver_pg2(struct mpi3mr_ioc *mrioc,
  1383. struct mpi3_driver_page2 *driver_pg2, u16 pg_sz, u8 page_type);
  1384. u8 mpi3mr_is_expander_device(u16 device_info);
  1385. int mpi3mr_expander_add(struct mpi3mr_ioc *mrioc, u16 handle);
  1386. void mpi3mr_expander_remove(struct mpi3mr_ioc *mrioc, u64 sas_address,
  1387. struct mpi3mr_hba_port *hba_port);
  1388. struct mpi3mr_sas_node *__mpi3mr_expander_find_by_handle(struct mpi3mr_ioc
  1389. *mrioc, u16 handle);
  1390. struct mpi3mr_hba_port *mpi3mr_get_hba_port_by_id(struct mpi3mr_ioc *mrioc,
  1391. u8 port_id);
  1392. void mpi3mr_sas_host_refresh(struct mpi3mr_ioc *mrioc);
  1393. void mpi3mr_sas_host_add(struct mpi3mr_ioc *mrioc);
  1394. void mpi3mr_update_links(struct mpi3mr_ioc *mrioc,
  1395. u64 sas_address_parent, u16 handle, u8 phy_number, u8 link_rate,
  1396. struct mpi3mr_hba_port *hba_port);
  1397. void mpi3mr_remove_tgtdev_from_host(struct mpi3mr_ioc *mrioc,
  1398. struct mpi3mr_tgt_dev *tgtdev);
  1399. int mpi3mr_report_tgtdev_to_sas_transport(struct mpi3mr_ioc *mrioc,
  1400. struct mpi3mr_tgt_dev *tgtdev);
  1401. void mpi3mr_remove_tgtdev_from_sas_transport(struct mpi3mr_ioc *mrioc,
  1402. struct mpi3mr_tgt_dev *tgtdev);
  1403. struct mpi3mr_tgt_dev *__mpi3mr_get_tgtdev_by_addr_and_rphy(
  1404. struct mpi3mr_ioc *mrioc, u64 sas_address, struct sas_rphy *rphy);
  1405. void mpi3mr_print_device_event_notice(struct mpi3mr_ioc *mrioc,
  1406. bool device_add);
  1407. void mpi3mr_refresh_sas_ports(struct mpi3mr_ioc *mrioc);
  1408. void mpi3mr_refresh_expanders(struct mpi3mr_ioc *mrioc);
  1409. void mpi3mr_add_event_wait_for_device_refresh(struct mpi3mr_ioc *mrioc);
  1410. void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc);
  1411. void mpi3mr_flush_cmds_for_unrecovered_controller(struct mpi3mr_ioc *mrioc);
  1412. void mpi3mr_free_enclosure_list(struct mpi3mr_ioc *mrioc);
  1413. int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc);
  1414. void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
  1415. struct mpi3mr_sas_node *sas_expander);
  1416. void mpi3mr_alloc_diag_bufs(struct mpi3mr_ioc *mrioc);
  1417. int mpi3mr_post_diag_bufs(struct mpi3mr_ioc *mrioc);
  1418. int mpi3mr_issue_diag_buf_release(struct mpi3mr_ioc *mrioc,
  1419. struct diag_buffer_desc *diag_buffer);
  1420. void mpi3mr_release_diag_bufs(struct mpi3mr_ioc *mrioc, u8 skip_rel_action);
  1421. void mpi3mr_set_trigger_data_in_hdb(struct diag_buffer_desc *hdb,
  1422. u8 type, union mpi3mr_trigger_data *trigger_data, bool force);
  1423. int mpi3mr_refresh_trigger(struct mpi3mr_ioc *mrioc, u8 page_type);
  1424. struct diag_buffer_desc *mpi3mr_diag_buffer_for_type(struct mpi3mr_ioc *mrioc,
  1425. u8 buf_type);
  1426. int mpi3mr_issue_diag_buf_post(struct mpi3mr_ioc *mrioc,
  1427. struct diag_buffer_desc *diag_buffer);
  1428. void mpi3mr_set_trigger_data_in_all_hdb(struct mpi3mr_ioc *mrioc,
  1429. u8 type, union mpi3mr_trigger_data *trigger_data, bool force);
  1430. void mpi3mr_reply_trigger(struct mpi3mr_ioc *mrioc, u16 iocstatus,
  1431. u32 iocloginfo);
  1432. void mpi3mr_hdb_trigger_data_event(struct mpi3mr_ioc *mrioc,
  1433. struct trigger_event_data *event_data);
  1434. void mpi3mr_scsisense_trigger(struct mpi3mr_ioc *mrioc, u8 senseky, u8 asc,
  1435. u8 ascq);
  1436. void mpi3mr_event_trigger(struct mpi3mr_ioc *mrioc, u8 event);
  1437. void mpi3mr_global_trigger(struct mpi3mr_ioc *mrioc, u64 trigger_data);
  1438. void mpi3mr_hdbstatuschg_evt_th(struct mpi3mr_ioc *mrioc,
  1439. struct mpi3_event_notification_reply *event_reply);
  1440. #endif /*MPI3MR_H_INCLUDED*/