Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | /* |
| 3 | * Driver for Broadcom MPI3 Storage Controllers |
| 4 | * |
| 5 | * Copyright (C) 2017-2021 Broadcom Inc. |
| 6 | * (mailto: mpi3mr-linuxdrv.pdl@broadcom.com) |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | #ifndef MPI3MR_H_INCLUDED |
| 11 | #define MPI3MR_H_INCLUDED |
| 12 | |
| 13 | #include <linux/blkdev.h> |
| 14 | #include <linux/blk-mq.h> |
| 15 | #include <linux/blk-mq-pci.h> |
| 16 | #include <linux/delay.h> |
| 17 | #include <linux/dmapool.h> |
| 18 | #include <linux/errno.h> |
| 19 | #include <linux/init.h> |
| 20 | #include <linux/io.h> |
| 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/kernel.h> |
| 23 | #include <linux/miscdevice.h> |
| 24 | #include <linux/module.h> |
| 25 | #include <linux/pci.h> |
| 26 | #include <linux/poll.h> |
| 27 | #include <linux/sched.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/types.h> |
| 30 | #include <linux/uaccess.h> |
| 31 | #include <linux/utsname.h> |
| 32 | #include <linux/version.h> |
| 33 | #include <linux/workqueue.h> |
| 34 | #include <asm/unaligned.h> |
| 35 | #include <scsi/scsi.h> |
| 36 | #include <scsi/scsi_cmnd.h> |
| 37 | #include <scsi/scsi_dbg.h> |
| 38 | #include <scsi/scsi_device.h> |
| 39 | #include <scsi/scsi_host.h> |
| 40 | #include <scsi/scsi_tcq.h> |
| 41 | |
| 42 | #include "mpi/mpi30_transport.h" |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 43 | #include "mpi/mpi30_cnfg.h" |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 44 | #include "mpi/mpi30_image.h" |
| 45 | #include "mpi/mpi30_init.h" |
| 46 | #include "mpi/mpi30_ioc.h" |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 47 | #include "mpi/mpi30_sas.h" |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 48 | #include "mpi3mr_debug.h" |
| 49 | |
| 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 | |
| 54 | #define MPI3MR_DRIVER_VERSION "00.255.45.01" |
| 55 | #define MPI3MR_DRIVER_RELDATE "12-December-2020" |
| 56 | |
| 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 | |
| 62 | #define MPI3MR_NAME_LENGTH 32 |
| 63 | #define IOCNAME "%s: " |
| 64 | |
| 65 | /* Definitions for internal SGL and Chain SGL buffers */ |
| 66 | #define MPI3MR_PAGE_SIZE_4K 4096 |
| 67 | #define MPI3MR_SG_DEPTH (MPI3MR_PAGE_SIZE_4K / sizeof(struct mpi3_sge_common)) |
| 68 | |
| 69 | /* Definitions for MAX values for shost */ |
| 70 | #define MPI3MR_MAX_CMDS_LUN 7 |
| 71 | #define MPI3MR_MAX_CDB_LENGTH 32 |
| 72 | |
| 73 | /* Admin queue management definitions */ |
| 74 | #define MPI3MR_ADMIN_REQ_Q_SIZE (2 * MPI3MR_PAGE_SIZE_4K) |
| 75 | #define MPI3MR_ADMIN_REPLY_Q_SIZE (4 * MPI3MR_PAGE_SIZE_4K) |
| 76 | #define MPI3MR_ADMIN_REQ_FRAME_SZ 128 |
| 77 | #define MPI3MR_ADMIN_REPLY_FRAME_SZ 16 |
| 78 | |
Kashyap Desai | c956623 | 2021-05-20 20:55:24 +0530 | [diff] [blame] | 79 | /* Operational queue management definitions */ |
| 80 | #define MPI3MR_OP_REQ_Q_QD 512 |
| 81 | #define MPI3MR_OP_REP_Q_QD 4096 |
| 82 | #define MPI3MR_OP_REQ_Q_SEG_SIZE 4096 |
| 83 | #define MPI3MR_OP_REP_Q_SEG_SIZE 4096 |
| 84 | #define MPI3MR_MAX_SEG_LIST_SIZE 4096 |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 85 | |
| 86 | /* Reserved Host Tag definitions */ |
| 87 | #define MPI3MR_HOSTTAG_INVALID 0xFFFF |
| 88 | #define MPI3MR_HOSTTAG_INITCMDS 1 |
| 89 | #define MPI3MR_HOSTTAG_IOCTLCMDS 2 |
| 90 | #define MPI3MR_HOSTTAG_BLK_TMS 5 |
| 91 | |
| 92 | #define MPI3MR_NUM_DEVRMCMD 1 |
| 93 | #define MPI3MR_HOSTTAG_DEVRMCMD_MIN (MPI3MR_HOSTTAG_BLK_TMS + 1) |
| 94 | #define MPI3MR_HOSTTAG_DEVRMCMD_MAX (MPI3MR_HOSTTAG_DEVRMCMD_MIN + \ |
| 95 | MPI3MR_NUM_DEVRMCMD - 1) |
| 96 | |
| 97 | #define MPI3MR_INTERNAL_CMDS_RESVD MPI3MR_HOSTTAG_DEVRMCMD_MAX |
| 98 | |
| 99 | /* Reduced resource count definition for crash kernel */ |
| 100 | #define MPI3MR_HOST_IOS_KDUMP 128 |
| 101 | |
| 102 | /* command/controller interaction timeout definitions in seconds */ |
| 103 | #define MPI3MR_INTADMCMD_TIMEOUT 10 |
Kashyap Desai | 023ab2a | 2021-05-20 20:55:25 +0530 | [diff] [blame] | 104 | #define MPI3MR_PORTENABLE_TIMEOUT 300 |
Kashyap Desai | e844adb | 2021-05-20 20:55:34 +0530 | [diff] [blame] | 105 | #define MPI3MR_ABORTTM_TIMEOUT 30 |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 106 | #define MPI3MR_RESETTM_TIMEOUT 30 |
Kashyap Desai | fb9b045 | 2021-05-20 20:55:30 +0530 | [diff] [blame] | 107 | #define MPI3MR_RESET_HOST_IOWAIT_TIMEOUT 5 |
Kashyap Desai | 54dfcff | 2021-05-20 20:55:31 +0530 | [diff] [blame] | 108 | #define MPI3MR_TSUPDATE_INTERVAL 900 |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 109 | #define MPI3MR_DEFAULT_SHUTDOWN_TIME 120 |
| 110 | |
| 111 | #define MPI3MR_WATCHDOG_INTERVAL 1000 /* in milli seconds */ |
| 112 | |
| 113 | /* Internal admin command state definitions*/ |
| 114 | #define MPI3MR_CMD_NOTUSED 0x8000 |
| 115 | #define MPI3MR_CMD_COMPLETE 0x0001 |
| 116 | #define MPI3MR_CMD_PENDING 0x0002 |
| 117 | #define MPI3MR_CMD_REPLY_VALID 0x0004 |
| 118 | #define MPI3MR_CMD_RESET 0x0008 |
| 119 | |
| 120 | /* Definitions for Event replies and sense buffer allocated per controller */ |
| 121 | #define MPI3MR_NUM_EVT_REPLIES 64 |
| 122 | #define MPI3MR_SENSEBUF_SZ 256 |
| 123 | #define MPI3MR_SENSEBUF_FACTOR 3 |
| 124 | #define MPI3MR_CHAINBUF_FACTOR 3 |
| 125 | |
| 126 | /* Invalid target device handle */ |
| 127 | #define MPI3MR_INVALID_DEV_HANDLE 0xFFFF |
| 128 | |
| 129 | /* Controller Reset related definitions */ |
| 130 | #define MPI3MR_HOSTDIAG_UNLOCK_RETRY_COUNT 5 |
| 131 | #define MPI3MR_MAX_RESET_RETRY_COUNT 3 |
| 132 | |
| 133 | /* ResponseCode definitions */ |
| 134 | #define MPI3MR_RI_MASK_RESPCODE (0x000000FF) |
| 135 | #define MPI3MR_RSP_TM_COMPLETE 0x00 |
| 136 | #define MPI3MR_RSP_INVALID_FRAME 0x02 |
| 137 | #define MPI3MR_RSP_TM_NOT_SUPPORTED 0x04 |
| 138 | #define MPI3MR_RSP_TM_FAILED 0x05 |
| 139 | #define MPI3MR_RSP_TM_SUCCEEDED 0x08 |
| 140 | #define MPI3MR_RSP_TM_INVALID_LUN 0x09 |
| 141 | #define MPI3MR_RSP_TM_OVERLAPPED_TAG 0x0A |
| 142 | #define MPI3MR_RSP_IO_QUEUED_ON_IOC \ |
| 143 | MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC |
| 144 | |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 145 | #define MPI3MR_DEFAULT_MDTS (128 * 1024) |
| 146 | /* Command retry count definitions */ |
| 147 | #define MPI3MR_DEV_RMHS_RETRY_COUNT 3 |
| 148 | |
Kashyap Desai | 0ea1773 | 2021-05-20 20:55:35 +0530 | [diff] [blame] | 149 | /* Default target device queue depth */ |
| 150 | #define MPI3MR_DEFAULT_SDEV_QD 32 |
| 151 | |
Kashyap Desai | 463429f | 2021-05-20 20:55:38 +0530 | [diff] [blame] | 152 | /* Definitions for Threaded IRQ poll*/ |
| 153 | #define MPI3MR_IRQ_POLL_SLEEP 2 |
| 154 | #define MPI3MR_IRQ_POLL_TRIGGER_IOCOUNT 8 |
| 155 | |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 156 | /* SGE Flag definition */ |
| 157 | #define MPI3MR_SGEFLAGS_SYSTEM_SIMPLE_END_OF_LIST \ |
| 158 | (MPI3_SGE_FLAGS_ELEMENT_TYPE_SIMPLE | MPI3_SGE_FLAGS_DLAS_SYSTEM | \ |
| 159 | MPI3_SGE_FLAGS_END_OF_LIST) |
| 160 | |
Kashyap Desai | c956623 | 2021-05-20 20:55:24 +0530 | [diff] [blame] | 161 | /* MSI Index from Reply Queue Index */ |
| 162 | #define REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, offset) (qidx + offset) |
| 163 | |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 164 | /* IOC State definitions */ |
| 165 | enum mpi3mr_iocstate { |
| 166 | MRIOC_STATE_READY = 1, |
| 167 | MRIOC_STATE_RESET, |
| 168 | MRIOC_STATE_FAULT, |
| 169 | MRIOC_STATE_BECOMING_READY, |
| 170 | MRIOC_STATE_RESET_REQUESTED, |
| 171 | MRIOC_STATE_UNRECOVERABLE, |
| 172 | }; |
| 173 | |
| 174 | /* Reset reason code definitions*/ |
| 175 | enum mpi3mr_reset_reason { |
| 176 | MPI3MR_RESET_FROM_BRINGUP = 1, |
| 177 | MPI3MR_RESET_FROM_FAULT_WATCH = 2, |
| 178 | MPI3MR_RESET_FROM_IOCTL = 3, |
| 179 | MPI3MR_RESET_FROM_EH_HOS = 4, |
| 180 | MPI3MR_RESET_FROM_TM_TIMEOUT = 5, |
| 181 | MPI3MR_RESET_FROM_IOCTL_TIMEOUT = 6, |
| 182 | MPI3MR_RESET_FROM_MUR_FAILURE = 7, |
| 183 | MPI3MR_RESET_FROM_CTLR_CLEANUP = 8, |
| 184 | MPI3MR_RESET_FROM_CIACTIV_FAULT = 9, |
| 185 | MPI3MR_RESET_FROM_PE_TIMEOUT = 10, |
| 186 | MPI3MR_RESET_FROM_TSU_TIMEOUT = 11, |
| 187 | MPI3MR_RESET_FROM_DELREQQ_TIMEOUT = 12, |
| 188 | MPI3MR_RESET_FROM_DELREPQ_TIMEOUT = 13, |
| 189 | MPI3MR_RESET_FROM_CREATEREPQ_TIMEOUT = 14, |
| 190 | MPI3MR_RESET_FROM_CREATEREQQ_TIMEOUT = 15, |
| 191 | MPI3MR_RESET_FROM_IOCFACTS_TIMEOUT = 16, |
| 192 | MPI3MR_RESET_FROM_IOCINIT_TIMEOUT = 17, |
| 193 | MPI3MR_RESET_FROM_EVTNOTIFY_TIMEOUT = 18, |
| 194 | MPI3MR_RESET_FROM_EVTACK_TIMEOUT = 19, |
| 195 | MPI3MR_RESET_FROM_CIACTVRST_TIMER = 20, |
| 196 | MPI3MR_RESET_FROM_GETPKGVER_TIMEOUT = 21, |
Kashyap Desai | f061178 | 2021-05-20 20:55:39 +0530 | [diff] [blame^] | 197 | MPI3MR_RESET_FROM_PELABORT_TIMEOUT = 22, |
| 198 | MPI3MR_RESET_FROM_SYSFS = 23, |
| 199 | MPI3MR_RESET_FROM_SYSFS_TIMEOUT = 24 |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 200 | }; |
| 201 | |
| 202 | /** |
| 203 | * struct mpi3mr_compimg_ver - replica of component image |
| 204 | * version defined in mpi30_image.h in host endianness |
| 205 | * |
| 206 | */ |
| 207 | struct mpi3mr_compimg_ver { |
| 208 | u16 build_num; |
| 209 | u16 cust_id; |
| 210 | u8 ph_minor; |
| 211 | u8 ph_major; |
| 212 | u8 gen_minor; |
| 213 | u8 gen_major; |
| 214 | }; |
| 215 | |
| 216 | /** |
| 217 | * struct mpi3mr_ioc_facs - replica of component image version |
| 218 | * defined in mpi30_ioc.h in host endianness |
| 219 | * |
| 220 | */ |
| 221 | struct mpi3mr_ioc_facts { |
| 222 | u32 ioc_capabilities; |
| 223 | struct mpi3mr_compimg_ver fw_ver; |
| 224 | u32 mpi_version; |
| 225 | u16 max_reqs; |
| 226 | u16 product_id; |
| 227 | u16 op_req_sz; |
| 228 | u16 reply_sz; |
| 229 | u16 exceptions; |
| 230 | u16 max_perids; |
| 231 | u16 max_pds; |
| 232 | u16 max_sasexpanders; |
| 233 | u16 max_sasinitiators; |
| 234 | u16 max_enclosures; |
| 235 | u16 max_pcie_switches; |
| 236 | u16 max_nvme; |
| 237 | u16 max_vds; |
| 238 | u16 max_hpds; |
| 239 | u16 max_advhpds; |
| 240 | u16 max_raidpds; |
| 241 | u16 min_devhandle; |
| 242 | u16 max_devhandle; |
| 243 | u16 max_op_req_q; |
| 244 | u16 max_op_reply_q; |
| 245 | u16 shutdown_timeout; |
| 246 | u8 ioc_num; |
| 247 | u8 who_init; |
| 248 | u16 max_msix_vectors; |
| 249 | u8 personality; |
| 250 | u8 dma_mask; |
| 251 | u8 protocol_flags; |
| 252 | u8 sge_mod_mask; |
| 253 | u8 sge_mod_value; |
| 254 | u8 sge_mod_shift; |
| 255 | }; |
| 256 | |
| 257 | /** |
Kashyap Desai | c956623 | 2021-05-20 20:55:24 +0530 | [diff] [blame] | 258 | * struct segments - memory descriptor structure to store |
| 259 | * virtual and dma addresses for operational queue segments. |
| 260 | * |
| 261 | * @segment: virtual address |
| 262 | * @segment_dma: dma address |
| 263 | */ |
| 264 | struct segments { |
| 265 | void *segment; |
| 266 | dma_addr_t segment_dma; |
| 267 | }; |
| 268 | |
| 269 | /** |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 270 | * struct op_req_qinfo - Operational Request Queue Information |
| 271 | * |
| 272 | * @ci: consumer index |
| 273 | * @pi: producer index |
Kashyap Desai | c956623 | 2021-05-20 20:55:24 +0530 | [diff] [blame] | 274 | * @num_request: Maximum number of entries in the queue |
| 275 | * @qid: Queue Id starting from 1 |
| 276 | * @reply_qid: Associated reply queue Id |
| 277 | * @num_segments: Number of discontiguous memory segments |
| 278 | * @segment_qd: Depth of each segments |
| 279 | * @q_lock: Concurrent queue access lock |
| 280 | * @q_segments: Segment descriptor pointer |
| 281 | * @q_segment_list: Segment list base virtual address |
| 282 | * @q_segment_list_dma: Segment list base DMA address |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 283 | */ |
| 284 | struct op_req_qinfo { |
| 285 | u16 ci; |
| 286 | u16 pi; |
Kashyap Desai | c956623 | 2021-05-20 20:55:24 +0530 | [diff] [blame] | 287 | u16 num_requests; |
| 288 | u16 qid; |
| 289 | u16 reply_qid; |
| 290 | u16 num_segments; |
| 291 | u16 segment_qd; |
| 292 | spinlock_t q_lock; |
| 293 | struct segments *q_segments; |
| 294 | void *q_segment_list; |
| 295 | dma_addr_t q_segment_list_dma; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 296 | }; |
| 297 | |
| 298 | /** |
| 299 | * struct op_reply_qinfo - Operational Reply Queue Information |
| 300 | * |
| 301 | * @ci: consumer index |
| 302 | * @qid: Queue Id starting from 1 |
Kashyap Desai | c956623 | 2021-05-20 20:55:24 +0530 | [diff] [blame] | 303 | * @num_replies: Maximum number of entries in the queue |
| 304 | * @num_segments: Number of discontiguous memory segments |
| 305 | * @segment_qd: Depth of each segments |
| 306 | * @q_segments: Segment descriptor pointer |
| 307 | * @q_segment_list: Segment list base virtual address |
| 308 | * @q_segment_list_dma: Segment list base DMA address |
| 309 | * @ephase: Expected phased identifier for the reply queue |
Kashyap Desai | 463429f | 2021-05-20 20:55:38 +0530 | [diff] [blame] | 310 | * @pend_ios: Number of IOs pending in HW for this queue |
| 311 | * @enable_irq_poll: Flag to indicate polling is enabled |
| 312 | * @in_use: Queue is handled by poll/ISR |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 313 | */ |
| 314 | struct op_reply_qinfo { |
| 315 | u16 ci; |
| 316 | u16 qid; |
Kashyap Desai | c956623 | 2021-05-20 20:55:24 +0530 | [diff] [blame] | 317 | u16 num_replies; |
| 318 | u16 num_segments; |
| 319 | u16 segment_qd; |
| 320 | struct segments *q_segments; |
| 321 | void *q_segment_list; |
| 322 | dma_addr_t q_segment_list_dma; |
| 323 | u8 ephase; |
Kashyap Desai | 463429f | 2021-05-20 20:55:38 +0530 | [diff] [blame] | 324 | atomic_t pend_ios; |
| 325 | bool enable_irq_poll; |
| 326 | atomic_t in_use; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 327 | }; |
| 328 | |
| 329 | /** |
| 330 | * struct mpi3mr_intr_info - Interrupt cookie information |
| 331 | * |
| 332 | * @mrioc: Adapter instance reference |
| 333 | * @msix_index: MSIx index |
| 334 | * @op_reply_q: Associated operational reply queue |
| 335 | * @name: Dev name for the irq claiming device |
| 336 | */ |
| 337 | struct mpi3mr_intr_info { |
| 338 | struct mpi3mr_ioc *mrioc; |
| 339 | u16 msix_index; |
| 340 | struct op_reply_qinfo *op_reply_q; |
| 341 | char name[MPI3MR_NAME_LENGTH]; |
| 342 | }; |
| 343 | |
Kashyap Desai | 023ab2a | 2021-05-20 20:55:25 +0530 | [diff] [blame] | 344 | /** |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 345 | * struct tgt_dev_sas_sata - SAS/SATA device specific |
| 346 | * information cached from firmware given data |
| 347 | * |
| 348 | * @sas_address: World wide unique SAS address |
| 349 | * @dev_info: Device information bits |
| 350 | */ |
| 351 | struct tgt_dev_sas_sata { |
| 352 | u64 sas_address; |
| 353 | u16 dev_info; |
| 354 | }; |
| 355 | |
| 356 | /** |
| 357 | * struct tgt_dev_pcie - PCIe device specific information cached |
| 358 | * from firmware given data |
| 359 | * |
| 360 | * @mdts: Maximum data transfer size |
| 361 | * @capb: Device capabilities |
| 362 | * @pgsz: Device page size |
| 363 | * @abort_to: Timeout for abort TM |
| 364 | * @reset_to: Timeout for Target/LUN reset TM |
| 365 | */ |
| 366 | struct tgt_dev_pcie { |
| 367 | u32 mdts; |
| 368 | u16 capb; |
| 369 | u8 pgsz; |
| 370 | u8 abort_to; |
| 371 | u8 reset_to; |
| 372 | }; |
| 373 | |
| 374 | /** |
| 375 | * struct tgt_dev_volume - virtual device specific information |
| 376 | * cached from firmware given data |
| 377 | * |
| 378 | * @state: State of the VD |
| 379 | */ |
| 380 | struct tgt_dev_volume { |
| 381 | u8 state; |
| 382 | }; |
| 383 | |
| 384 | /** |
| 385 | * union _form_spec_inf - union of device specific information |
| 386 | */ |
| 387 | union _form_spec_inf { |
| 388 | struct tgt_dev_sas_sata sas_sata_inf; |
| 389 | struct tgt_dev_pcie pcie_inf; |
| 390 | struct tgt_dev_volume vol_inf; |
| 391 | }; |
| 392 | |
| 393 | |
| 394 | |
| 395 | /** |
| 396 | * struct mpi3mr_tgt_dev - target device data structure |
| 397 | * |
| 398 | * @list: List pointer |
| 399 | * @starget: Scsi_target pointer |
| 400 | * @dev_handle: FW device handle |
| 401 | * @parent_handle: FW parent device handle |
| 402 | * @slot: Slot number |
| 403 | * @encl_handle: FW enclosure handle |
| 404 | * @perst_id: FW assigned Persistent ID |
| 405 | * @dev_type: SAS/SATA/PCIE device type |
| 406 | * @is_hidden: Should be exposed to upper layers or not |
| 407 | * @host_exposed: Already exposed to host or not |
| 408 | * @q_depth: Device specific Queue Depth |
| 409 | * @wwid: World wide ID |
| 410 | * @dev_spec: Device type specific information |
| 411 | * @ref_count: Reference count |
| 412 | */ |
| 413 | struct mpi3mr_tgt_dev { |
| 414 | struct list_head list; |
| 415 | struct scsi_target *starget; |
| 416 | u16 dev_handle; |
| 417 | u16 parent_handle; |
| 418 | u16 slot; |
| 419 | u16 encl_handle; |
| 420 | u16 perst_id; |
| 421 | u8 dev_type; |
| 422 | u8 is_hidden; |
| 423 | u8 host_exposed; |
| 424 | u16 q_depth; |
| 425 | u64 wwid; |
| 426 | union _form_spec_inf dev_spec; |
| 427 | struct kref ref_count; |
| 428 | }; |
| 429 | |
| 430 | /** |
| 431 | * mpi3mr_tgtdev_get - k reference incrementor |
| 432 | * @s: Target device reference |
| 433 | * |
| 434 | * Increment target device reference count. |
| 435 | */ |
| 436 | static inline void mpi3mr_tgtdev_get(struct mpi3mr_tgt_dev *s) |
| 437 | { |
| 438 | kref_get(&s->ref_count); |
| 439 | } |
| 440 | |
| 441 | /** |
| 442 | * mpi3mr_free_tgtdev - target device memory dealloctor |
| 443 | * @r: k reference pointer of the target device |
| 444 | * |
| 445 | * Free target device memory when no reference. |
| 446 | */ |
| 447 | static inline void mpi3mr_free_tgtdev(struct kref *r) |
| 448 | { |
| 449 | kfree(container_of(r, struct mpi3mr_tgt_dev, ref_count)); |
| 450 | } |
| 451 | |
| 452 | /** |
| 453 | * mpi3mr_tgtdev_put - k reference decrementor |
| 454 | * @s: Target device reference |
| 455 | * |
| 456 | * Decrement target device reference count. |
| 457 | */ |
| 458 | static inline void mpi3mr_tgtdev_put(struct mpi3mr_tgt_dev *s) |
| 459 | { |
| 460 | kref_put(&s->ref_count, mpi3mr_free_tgtdev); |
| 461 | } |
| 462 | |
| 463 | |
| 464 | /** |
Kashyap Desai | 023ab2a | 2021-05-20 20:55:25 +0530 | [diff] [blame] | 465 | * struct mpi3mr_stgt_priv_data - SCSI target private structure |
| 466 | * |
| 467 | * @starget: Scsi_target pointer |
| 468 | * @dev_handle: FW device handle |
| 469 | * @perst_id: FW assigned Persistent ID |
| 470 | * @num_luns: Number of Logical Units |
| 471 | * @block_io: I/O blocked to the device or not |
| 472 | * @dev_removed: Device removed in the Firmware |
| 473 | * @dev_removedelay: Device is waiting to be removed in FW |
| 474 | * @dev_type: Device type |
| 475 | * @tgt_dev: Internal target device pointer |
| 476 | */ |
| 477 | struct mpi3mr_stgt_priv_data { |
| 478 | struct scsi_target *starget; |
| 479 | u16 dev_handle; |
| 480 | u16 perst_id; |
| 481 | u32 num_luns; |
| 482 | atomic_t block_io; |
| 483 | u8 dev_removed; |
| 484 | u8 dev_removedelay; |
| 485 | u8 dev_type; |
| 486 | struct mpi3mr_tgt_dev *tgt_dev; |
| 487 | }; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 488 | |
Kashyap Desai | 023ab2a | 2021-05-20 20:55:25 +0530 | [diff] [blame] | 489 | /** |
| 490 | * struct mpi3mr_stgt_priv_data - SCSI device private structure |
| 491 | * |
| 492 | * @tgt_priv_data: Scsi_target private data pointer |
| 493 | * @lun_id: LUN ID of the device |
| 494 | * @ncq_prio_enable: NCQ priority enable for SATA device |
| 495 | */ |
| 496 | struct mpi3mr_sdev_priv_data { |
| 497 | struct mpi3mr_stgt_priv_data *tgt_priv_data; |
| 498 | u32 lun_id; |
| 499 | u8 ncq_prio_enable; |
| 500 | }; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 501 | |
| 502 | /** |
| 503 | * struct mpi3mr_drv_cmd - Internal command tracker |
| 504 | * |
| 505 | * @mutex: Command mutex |
| 506 | * @done: Completeor for wakeup |
| 507 | * @reply: Firmware reply for internal commands |
| 508 | * @sensebuf: Sensebuf for SCSI IO commands |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 509 | * @iou_rc: IO Unit control reason code |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 510 | * @state: Command State |
| 511 | * @dev_handle: Firmware handle for device specific commands |
| 512 | * @ioc_status: IOC status from the firmware |
| 513 | * @ioc_loginfo:IOC log info from the firmware |
| 514 | * @is_waiting: Is the command issued in block mode |
| 515 | * @retry_count: Retry count for retriable commands |
| 516 | * @host_tag: Host tag used by the command |
| 517 | * @callback: Callback for non blocking commands |
| 518 | */ |
| 519 | struct mpi3mr_drv_cmd { |
| 520 | struct mutex mutex; |
| 521 | struct completion done; |
| 522 | void *reply; |
| 523 | u8 *sensebuf; |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 524 | u8 iou_rc; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 525 | u16 state; |
| 526 | u16 dev_handle; |
| 527 | u16 ioc_status; |
| 528 | u32 ioc_loginfo; |
| 529 | u8 is_waiting; |
| 530 | u8 retry_count; |
| 531 | u16 host_tag; |
| 532 | |
| 533 | void (*callback)(struct mpi3mr_ioc *mrioc, |
| 534 | struct mpi3mr_drv_cmd *drv_cmd); |
| 535 | }; |
| 536 | |
| 537 | |
| 538 | /** |
| 539 | * struct chain_element - memory descriptor structure to store |
| 540 | * virtual and dma addresses for chain elements. |
| 541 | * |
| 542 | * @addr: virtual address |
| 543 | * @dma_addr: dma address |
| 544 | */ |
| 545 | struct chain_element { |
| 546 | void *addr; |
| 547 | dma_addr_t dma_addr; |
| 548 | }; |
| 549 | |
| 550 | /** |
| 551 | * struct scmd_priv - SCSI command private data |
| 552 | * |
| 553 | * @host_tag: Host tag specific to operational queue |
| 554 | * @in_lld_scope: Command in LLD scope or not |
| 555 | * @scmd: SCSI Command pointer |
| 556 | * @req_q_idx: Operational request queue index |
| 557 | * @chain_idx: Chain frame index |
| 558 | * @mpi3mr_scsiio_req: MPI SCSI IO request |
| 559 | */ |
| 560 | struct scmd_priv { |
| 561 | u16 host_tag; |
| 562 | u8 in_lld_scope; |
| 563 | struct scsi_cmnd *scmd; |
| 564 | u16 req_q_idx; |
| 565 | int chain_idx; |
| 566 | u8 mpi3mr_scsiio_req[MPI3MR_ADMIN_REQ_FRAME_SZ]; |
| 567 | }; |
| 568 | |
| 569 | /** |
| 570 | * struct mpi3mr_ioc - Adapter anchor structure stored in shost |
| 571 | * private data |
| 572 | * |
| 573 | * @list: List pointer |
| 574 | * @pdev: PCI device pointer |
| 575 | * @shost: Scsi_Host pointer |
| 576 | * @id: Controller ID |
| 577 | * @cpu_count: Number of online CPUs |
Kashyap Desai | 463429f | 2021-05-20 20:55:38 +0530 | [diff] [blame] | 578 | * @irqpoll_sleep: usleep unit used in threaded isr irqpoll |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 579 | * @name: Controller ASCII name |
| 580 | * @driver_name: Driver ASCII name |
| 581 | * @sysif_regs: System interface registers virtual address |
| 582 | * @sysif_regs_phys: System interface registers physical address |
| 583 | * @bars: PCI BARS |
| 584 | * @dma_mask: DMA mask |
| 585 | * @msix_count: Number of MSIX vectors used |
| 586 | * @intr_enabled: Is interrupts enabled |
| 587 | * @num_admin_req: Number of admin requests |
| 588 | * @admin_req_q_sz: Admin request queue size |
| 589 | * @admin_req_pi: Admin request queue producer index |
| 590 | * @admin_req_ci: Admin request queue consumer index |
| 591 | * @admin_req_base: Admin request queue base virtual address |
| 592 | * @admin_req_dma: Admin request queue base dma address |
| 593 | * @admin_req_lock: Admin queue access lock |
| 594 | * @num_admin_replies: Number of admin replies |
| 595 | * @admin_reply_q_sz: Admin reply queue size |
| 596 | * @admin_reply_ci: Admin reply queue consumer index |
| 597 | * @admin_reply_ephase:Admin reply queue expected phase |
| 598 | * @admin_reply_base: Admin reply queue base virtual address |
| 599 | * @admin_reply_dma: Admin reply queue base dma address |
| 600 | * @ready_timeout: Controller ready timeout |
| 601 | * @intr_info: Interrupt cookie pointer |
| 602 | * @intr_info_count: Number of interrupt cookies |
| 603 | * @num_queues: Number of operational queues |
| 604 | * @num_op_req_q: Number of operational request queues |
| 605 | * @req_qinfo: Operational request queue info pointer |
| 606 | * @num_op_reply_q: Number of operational reply queues |
| 607 | * @op_reply_qinfo: Operational reply queue info pointer |
| 608 | * @init_cmds: Command tracker for initialization commands |
| 609 | * @facts: Cached IOC facts data |
| 610 | * @op_reply_desc_sz: Operational reply descriptor size |
| 611 | * @num_reply_bufs: Number of reply buffers allocated |
| 612 | * @reply_buf_pool: Reply buffer pool |
| 613 | * @reply_buf: Reply buffer base virtual address |
| 614 | * @reply_buf_dma: Reply buffer DMA address |
| 615 | * @reply_buf_dma_max_address: Reply DMA address max limit |
| 616 | * @reply_free_qsz: Reply free queue size |
| 617 | * @reply_free_q_pool: Reply free queue pool |
| 618 | * @reply_free_q: Reply free queue base virtual address |
| 619 | * @reply_free_q_dma: Reply free queue base DMA address |
| 620 | * @reply_free_queue_lock: Reply free queue lock |
| 621 | * @reply_free_queue_host_index: Reply free queue host index |
| 622 | * @num_sense_bufs: Number of sense buffers |
| 623 | * @sense_buf_pool: Sense buffer pool |
| 624 | * @sense_buf: Sense buffer base virtual address |
| 625 | * @sense_buf_dma: Sense buffer base DMA address |
| 626 | * @sense_buf_q_sz: Sense buffer queue size |
| 627 | * @sense_buf_q_pool: Sense buffer queue pool |
| 628 | * @sense_buf_q: Sense buffer queue virtual address |
| 629 | * @sense_buf_q_dma: Sense buffer queue DMA address |
| 630 | * @sbq_lock: Sense buffer queue lock |
| 631 | * @sbq_host_index: Sense buffer queuehost index |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 632 | * @event_masks: Event mask bitmap |
| 633 | * @fwevt_worker_name: Firmware event worker thread name |
| 634 | * @fwevt_worker_thread: Firmware event worker thread |
| 635 | * @fwevt_lock: Firmware event lock |
| 636 | * @fwevt_list: Firmware event list |
Kashyap Desai | 672ae26 | 2021-05-20 20:55:26 +0530 | [diff] [blame] | 637 | * @watchdog_work_q_name: Fault watchdog worker thread name |
| 638 | * @watchdog_work_q: Fault watchdog worker thread |
| 639 | * @watchdog_work: Fault watchdog work |
| 640 | * @watchdog_lock: Fault watchdog lock |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 641 | * @is_driver_loading: Is driver still loading |
Kashyap Desai | 023ab2a | 2021-05-20 20:55:25 +0530 | [diff] [blame] | 642 | * @scan_started: Async scan started |
| 643 | * @scan_failed: Asycn scan failed |
| 644 | * @stop_drv_processing: Stop all command processing |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 645 | * @max_host_ios: Maximum host I/O count |
| 646 | * @chain_buf_count: Chain buffer count |
| 647 | * @chain_buf_pool: Chain buffer pool |
| 648 | * @chain_sgl_list: Chain SGL list |
| 649 | * @chain_bitmap_sz: Chain buffer allocator bitmap size |
| 650 | * @chain_bitmap: Chain buffer allocator bitmap |
Kashyap Desai | 023ab2a | 2021-05-20 20:55:25 +0530 | [diff] [blame] | 651 | * @chain_buf_lock: Chain buffer list lock |
Kashyap Desai | e844adb | 2021-05-20 20:55:34 +0530 | [diff] [blame] | 652 | * @host_tm_cmds: Command tracker for task management commands |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 653 | * @dev_rmhs_cmds: Command tracker for device removal commands |
| 654 | * @devrem_bitmap_sz: Device removal bitmap size |
| 655 | * @devrem_bitmap: Device removal bitmap |
| 656 | * @dev_handle_bitmap_sz: Device handle bitmap size |
| 657 | * @removepend_bitmap: Remove pending bitmap |
| 658 | * @delayed_rmhs_list: Delayed device removal list |
Kashyap Desai | 54dfcff | 2021-05-20 20:55:31 +0530 | [diff] [blame] | 659 | * @ts_update_counter: Timestamp update counter |
Kashyap Desai | fb9b045 | 2021-05-20 20:55:30 +0530 | [diff] [blame] | 660 | * @fault_dbg: Fault debug flag |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 661 | * @reset_in_progress: Reset in progress flag |
| 662 | * @unrecoverable: Controller unrecoverable flag |
Kashyap Desai | fb9b045 | 2021-05-20 20:55:30 +0530 | [diff] [blame] | 663 | * @reset_mutex: Controller reset mutex |
| 664 | * @reset_waitq: Controller reset wait queue |
Kashyap Desai | 672ae26 | 2021-05-20 20:55:26 +0530 | [diff] [blame] | 665 | * @diagsave_timeout: Diagnostic information save timeout |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 666 | * @logging_level: Controller debug logging level |
Kashyap Desai | fb9b045 | 2021-05-20 20:55:30 +0530 | [diff] [blame] | 667 | * @flush_io_count: I/O count to flush after reset |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 668 | * @current_event: Firmware event currently in process |
| 669 | * @driver_info: Driver, Kernel, OS information to firmware |
| 670 | * @change_count: Topology change count |
Kashyap Desai | c956623 | 2021-05-20 20:55:24 +0530 | [diff] [blame] | 671 | * @op_reply_q_offset: Operational reply queue offset with MSIx |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 672 | */ |
| 673 | struct mpi3mr_ioc { |
| 674 | struct list_head list; |
| 675 | struct pci_dev *pdev; |
| 676 | struct Scsi_Host *shost; |
| 677 | u8 id; |
| 678 | int cpu_count; |
Kashyap Desai | c956623 | 2021-05-20 20:55:24 +0530 | [diff] [blame] | 679 | bool enable_segqueue; |
Kashyap Desai | 463429f | 2021-05-20 20:55:38 +0530 | [diff] [blame] | 680 | u32 irqpoll_sleep; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 681 | |
| 682 | char name[MPI3MR_NAME_LENGTH]; |
| 683 | char driver_name[MPI3MR_NAME_LENGTH]; |
| 684 | |
| 685 | volatile struct mpi3_sysif_registers __iomem *sysif_regs; |
| 686 | resource_size_t sysif_regs_phys; |
| 687 | int bars; |
| 688 | u64 dma_mask; |
| 689 | |
| 690 | u16 msix_count; |
| 691 | u8 intr_enabled; |
| 692 | |
| 693 | u16 num_admin_req; |
| 694 | u32 admin_req_q_sz; |
| 695 | u16 admin_req_pi; |
| 696 | u16 admin_req_ci; |
| 697 | void *admin_req_base; |
| 698 | dma_addr_t admin_req_dma; |
| 699 | spinlock_t admin_req_lock; |
| 700 | |
| 701 | u16 num_admin_replies; |
| 702 | u32 admin_reply_q_sz; |
| 703 | u16 admin_reply_ci; |
| 704 | u8 admin_reply_ephase; |
| 705 | void *admin_reply_base; |
| 706 | dma_addr_t admin_reply_dma; |
| 707 | |
| 708 | u32 ready_timeout; |
| 709 | |
| 710 | struct mpi3mr_intr_info *intr_info; |
| 711 | u16 intr_info_count; |
| 712 | |
| 713 | u16 num_queues; |
| 714 | u16 num_op_req_q; |
| 715 | struct op_req_qinfo *req_qinfo; |
| 716 | |
| 717 | u16 num_op_reply_q; |
| 718 | struct op_reply_qinfo *op_reply_qinfo; |
| 719 | |
| 720 | struct mpi3mr_drv_cmd init_cmds; |
| 721 | struct mpi3mr_ioc_facts facts; |
| 722 | u16 op_reply_desc_sz; |
| 723 | |
| 724 | u32 num_reply_bufs; |
| 725 | struct dma_pool *reply_buf_pool; |
| 726 | u8 *reply_buf; |
| 727 | dma_addr_t reply_buf_dma; |
| 728 | dma_addr_t reply_buf_dma_max_address; |
| 729 | |
| 730 | u16 reply_free_qsz; |
| 731 | struct dma_pool *reply_free_q_pool; |
| 732 | __le64 *reply_free_q; |
| 733 | dma_addr_t reply_free_q_dma; |
| 734 | spinlock_t reply_free_queue_lock; |
| 735 | u32 reply_free_queue_host_index; |
| 736 | |
| 737 | u32 num_sense_bufs; |
| 738 | struct dma_pool *sense_buf_pool; |
| 739 | u8 *sense_buf; |
| 740 | dma_addr_t sense_buf_dma; |
| 741 | |
| 742 | u16 sense_buf_q_sz; |
| 743 | struct dma_pool *sense_buf_q_pool; |
| 744 | __le64 *sense_buf_q; |
| 745 | dma_addr_t sense_buf_q_dma; |
| 746 | spinlock_t sbq_lock; |
| 747 | u32 sbq_host_index; |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 748 | u32 event_masks[MPI3_EVENT_NOTIFY_EVENTMASK_WORDS]; |
| 749 | |
| 750 | char fwevt_worker_name[MPI3MR_NAME_LENGTH]; |
| 751 | struct workqueue_struct *fwevt_worker_thread; |
| 752 | spinlock_t fwevt_lock; |
| 753 | struct list_head fwevt_list; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 754 | |
Kashyap Desai | 672ae26 | 2021-05-20 20:55:26 +0530 | [diff] [blame] | 755 | char watchdog_work_q_name[20]; |
| 756 | struct workqueue_struct *watchdog_work_q; |
| 757 | struct delayed_work watchdog_work; |
| 758 | spinlock_t watchdog_lock; |
| 759 | |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 760 | u8 is_driver_loading; |
Kashyap Desai | 023ab2a | 2021-05-20 20:55:25 +0530 | [diff] [blame] | 761 | u8 scan_started; |
| 762 | u16 scan_failed; |
| 763 | u8 stop_drv_processing; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 764 | |
| 765 | u16 max_host_ios; |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 766 | spinlock_t tgtdev_lock; |
| 767 | struct list_head tgtdev_list; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 768 | |
| 769 | u32 chain_buf_count; |
| 770 | struct dma_pool *chain_buf_pool; |
| 771 | struct chain_element *chain_sgl_list; |
| 772 | u16 chain_bitmap_sz; |
| 773 | void *chain_bitmap; |
Kashyap Desai | 023ab2a | 2021-05-20 20:55:25 +0530 | [diff] [blame] | 774 | spinlock_t chain_buf_lock; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 775 | |
Kashyap Desai | e844adb | 2021-05-20 20:55:34 +0530 | [diff] [blame] | 776 | struct mpi3mr_drv_cmd host_tm_cmds; |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 777 | struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD]; |
| 778 | u16 devrem_bitmap_sz; |
| 779 | void *devrem_bitmap; |
| 780 | u16 dev_handle_bitmap_sz; |
| 781 | void *removepend_bitmap; |
| 782 | struct list_head delayed_rmhs_list; |
| 783 | |
Kashyap Desai | 54dfcff | 2021-05-20 20:55:31 +0530 | [diff] [blame] | 784 | u32 ts_update_counter; |
Kashyap Desai | fb9b045 | 2021-05-20 20:55:30 +0530 | [diff] [blame] | 785 | u8 fault_dbg; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 786 | u8 reset_in_progress; |
| 787 | u8 unrecoverable; |
Kashyap Desai | fb9b045 | 2021-05-20 20:55:30 +0530 | [diff] [blame] | 788 | struct mutex reset_mutex; |
| 789 | wait_queue_head_t reset_waitq; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 790 | |
Kashyap Desai | 672ae26 | 2021-05-20 20:55:26 +0530 | [diff] [blame] | 791 | u16 diagsave_timeout; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 792 | int logging_level; |
Kashyap Desai | fb9b045 | 2021-05-20 20:55:30 +0530 | [diff] [blame] | 793 | u16 flush_io_count; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 794 | |
| 795 | struct mpi3mr_fwevt *current_event; |
| 796 | struct mpi3_driver_info_layout driver_info; |
| 797 | u16 change_count; |
Kashyap Desai | c956623 | 2021-05-20 20:55:24 +0530 | [diff] [blame] | 798 | u16 op_reply_q_offset; |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 799 | }; |
| 800 | |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 801 | /** |
| 802 | * struct mpi3mr_fwevt - Firmware event structure. |
| 803 | * |
| 804 | * @list: list head |
| 805 | * @work: Work structure |
| 806 | * @mrioc: Adapter instance reference |
| 807 | * @event_id: MPI3 firmware event ID |
| 808 | * @send_ack: Event acknowledgment required or not |
| 809 | * @process_evt: Bottomhalf processing required or not |
| 810 | * @evt_ctx: Event context to send in Ack |
| 811 | * @ref_count: kref count |
| 812 | * @event_data: Actual MPI3 event data |
| 813 | */ |
| 814 | struct mpi3mr_fwevt { |
| 815 | struct list_head list; |
| 816 | struct work_struct work; |
| 817 | struct mpi3mr_ioc *mrioc; |
| 818 | u16 event_id; |
| 819 | bool send_ack; |
| 820 | bool process_evt; |
| 821 | u32 evt_ctx; |
| 822 | struct kref ref_count; |
| 823 | char event_data[0] __aligned(4); |
| 824 | }; |
| 825 | |
| 826 | |
| 827 | /** |
| 828 | * struct delayed_dev_rmhs_node - Delayed device removal node |
| 829 | * |
| 830 | * @list: list head |
| 831 | * @handle: Device handle |
| 832 | * @iou_rc: IO Unit Control Reason Code |
| 833 | */ |
| 834 | struct delayed_dev_rmhs_node { |
| 835 | struct list_head list; |
| 836 | u16 handle; |
| 837 | u8 iou_rc; |
| 838 | }; |
| 839 | |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 840 | int mpi3mr_setup_resources(struct mpi3mr_ioc *mrioc); |
| 841 | void mpi3mr_cleanup_resources(struct mpi3mr_ioc *mrioc); |
Kashyap Desai | fb9b045 | 2021-05-20 20:55:30 +0530 | [diff] [blame] | 842 | int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc, u8 re_init); |
| 843 | void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc, u8 re_init); |
Kashyap Desai | 023ab2a | 2021-05-20 20:55:25 +0530 | [diff] [blame] | 844 | int mpi3mr_issue_port_enable(struct mpi3mr_ioc *mrioc, u8 async); |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 845 | int mpi3mr_admin_request_post(struct mpi3mr_ioc *mrioc, void *admin_req, |
| 846 | u16 admin_req_sz, u8 ignore_reset); |
Kashyap Desai | 023ab2a | 2021-05-20 20:55:25 +0530 | [diff] [blame] | 847 | int mpi3mr_op_request_post(struct mpi3mr_ioc *mrioc, |
| 848 | struct op_req_qinfo *opreqq, u8 *req); |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 849 | void mpi3mr_add_sg_single(void *paddr, u8 flags, u32 length, |
| 850 | dma_addr_t dma_addr); |
| 851 | void mpi3mr_build_zero_len_sge(void *paddr); |
| 852 | void *mpi3mr_get_sensebuf_virt_addr(struct mpi3mr_ioc *mrioc, |
| 853 | dma_addr_t phys_addr); |
| 854 | void *mpi3mr_get_reply_virt_addr(struct mpi3mr_ioc *mrioc, |
| 855 | dma_addr_t phys_addr); |
| 856 | void mpi3mr_repost_sense_buf(struct mpi3mr_ioc *mrioc, |
| 857 | u64 sense_buf_dma); |
| 858 | |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 859 | void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc, |
| 860 | struct mpi3_event_notification_reply *event_reply); |
Kashyap Desai | 023ab2a | 2021-05-20 20:55:25 +0530 | [diff] [blame] | 861 | void mpi3mr_process_op_reply_desc(struct mpi3mr_ioc *mrioc, |
| 862 | struct mpi3_default_reply_descriptor *reply_desc, |
| 863 | u64 *reply_dma, u16 qidx); |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 864 | void mpi3mr_start_watchdog(struct mpi3mr_ioc *mrioc); |
| 865 | void mpi3mr_stop_watchdog(struct mpi3mr_ioc *mrioc); |
| 866 | |
| 867 | int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc, |
| 868 | u32 reset_reason, u8 snapdump); |
Kashyap Desai | fb9b045 | 2021-05-20 20:55:30 +0530 | [diff] [blame] | 869 | int mpi3mr_diagfault_reset_handler(struct mpi3mr_ioc *mrioc, |
| 870 | u32 reset_reason); |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 871 | void mpi3mr_ioc_disable_intr(struct mpi3mr_ioc *mrioc); |
| 872 | void mpi3mr_ioc_enable_intr(struct mpi3mr_ioc *mrioc); |
| 873 | |
| 874 | enum mpi3mr_iocstate mpi3mr_get_iocstate(struct mpi3mr_ioc *mrioc); |
Kashyap Desai | 13ef29e | 2021-05-20 20:55:27 +0530 | [diff] [blame] | 875 | int mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event, |
| 876 | u32 event_ctx); |
| 877 | |
| 878 | void mpi3mr_wait_for_host_io(struct mpi3mr_ioc *mrioc, u32 timeout); |
| 879 | void mpi3mr_cleanup_fwevt_list(struct mpi3mr_ioc *mrioc); |
| 880 | void mpi3mr_flush_host_io(struct mpi3mr_ioc *mrioc); |
| 881 | void mpi3mr_invalidate_devhandles(struct mpi3mr_ioc *mrioc); |
| 882 | void mpi3mr_rfresh_tgtdevs(struct mpi3mr_ioc *mrioc); |
| 883 | void mpi3mr_flush_delayed_rmhs_list(struct mpi3mr_ioc *mrioc); |
Kashyap Desai | 824a156 | 2021-05-20 20:55:23 +0530 | [diff] [blame] | 884 | |
| 885 | #endif /*MPI3MR_H_INCLUDED*/ |