0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef MPI3MR_H_INCLUDED
0011 #define MPI3MR_H_INCLUDED
0012
0013 #include <linux/blkdev.h>
0014 #include <linux/blk-mq.h>
0015 #include <linux/blk-mq-pci.h>
0016 #include <linux/delay.h>
0017 #include <linux/dmapool.h>
0018 #include <linux/errno.h>
0019 #include <linux/init.h>
0020 #include <linux/io.h>
0021 #include <linux/interrupt.h>
0022 #include <linux/kernel.h>
0023 #include <linux/miscdevice.h>
0024 #include <linux/module.h>
0025 #include <linux/pci.h>
0026 #include <linux/poll.h>
0027 #include <linux/sched.h>
0028 #include <linux/slab.h>
0029 #include <linux/types.h>
0030 #include <linux/uaccess.h>
0031 #include <linux/utsname.h>
0032 #include <linux/version.h>
0033 #include <linux/workqueue.h>
0034 #include <asm/unaligned.h>
0035 #include <scsi/scsi.h>
0036 #include <scsi/scsi_cmnd.h>
0037 #include <scsi/scsi_dbg.h>
0038 #include <scsi/scsi_device.h>
0039 #include <scsi/scsi_host.h>
0040 #include <scsi/scsi_tcq.h>
0041 #include <uapi/scsi/scsi_bsg_mpi3mr.h>
0042
0043 #include "mpi/mpi30_transport.h"
0044 #include "mpi/mpi30_cnfg.h"
0045 #include "mpi/mpi30_image.h"
0046 #include "mpi/mpi30_init.h"
0047 #include "mpi/mpi30_ioc.h"
0048 #include "mpi/mpi30_sas.h"
0049 #include "mpi/mpi30_pci.h"
0050 #include "mpi3mr_debug.h"
0051
0052
0053 extern spinlock_t mrioc_list_lock;
0054 extern struct list_head mrioc_list;
0055 extern int prot_mask;
0056 extern atomic64_t event_counter;
0057
0058 #define MPI3MR_DRIVER_VERSION "8.0.0.69.0"
0059 #define MPI3MR_DRIVER_RELDATE "16-March-2022"
0060
0061 #define MPI3MR_DRIVER_NAME "mpi3mr"
0062 #define MPI3MR_DRIVER_LICENSE "GPL"
0063 #define MPI3MR_DRIVER_AUTHOR "Broadcom Inc. <mpi3mr-linuxdrv.pdl@broadcom.com>"
0064 #define MPI3MR_DRIVER_DESC "MPI3 Storage Controller Device Driver"
0065
0066 #define MPI3MR_NAME_LENGTH 32
0067 #define IOCNAME "%s: "
0068
0069 #define MPI3MR_MAX_SECTORS 2048
0070
0071
0072 #define MPI3MR_PAGE_SIZE_4K 4096
0073 #define MPI3MR_SG_DEPTH (MPI3MR_PAGE_SIZE_4K / sizeof(struct mpi3_sge_common))
0074
0075
0076 #define MPI3MR_MAX_CMDS_LUN 128
0077 #define MPI3MR_MAX_CDB_LENGTH 32
0078
0079
0080 #define MPI3MR_ADMIN_REQ_Q_SIZE (2 * MPI3MR_PAGE_SIZE_4K)
0081 #define MPI3MR_ADMIN_REPLY_Q_SIZE (4 * MPI3MR_PAGE_SIZE_4K)
0082 #define MPI3MR_ADMIN_REQ_FRAME_SZ 128
0083 #define MPI3MR_ADMIN_REPLY_FRAME_SZ 16
0084
0085
0086 #define MPI3MR_OP_REQ_Q_QD 512
0087 #define MPI3MR_OP_REP_Q_QD 1024
0088 #define MPI3MR_OP_REP_Q_QD4K 4096
0089 #define MPI3MR_OP_REQ_Q_SEG_SIZE 4096
0090 #define MPI3MR_OP_REP_Q_SEG_SIZE 4096
0091 #define MPI3MR_MAX_SEG_LIST_SIZE 4096
0092
0093
0094 #define MPI3MR_HOSTTAG_INVALID 0xFFFF
0095 #define MPI3MR_HOSTTAG_INITCMDS 1
0096 #define MPI3MR_HOSTTAG_BSG_CMDS 2
0097 #define MPI3MR_HOSTTAG_PEL_ABORT 3
0098 #define MPI3MR_HOSTTAG_PEL_WAIT 4
0099 #define MPI3MR_HOSTTAG_BLK_TMS 5
0100
0101 #define MPI3MR_NUM_DEVRMCMD 16
0102 #define MPI3MR_HOSTTAG_DEVRMCMD_MIN (MPI3MR_HOSTTAG_BLK_TMS + 1)
0103 #define MPI3MR_HOSTTAG_DEVRMCMD_MAX (MPI3MR_HOSTTAG_DEVRMCMD_MIN + \
0104 MPI3MR_NUM_DEVRMCMD - 1)
0105
0106 #define MPI3MR_INTERNAL_CMDS_RESVD MPI3MR_HOSTTAG_DEVRMCMD_MAX
0107 #define MPI3MR_NUM_EVTACKCMD 4
0108 #define MPI3MR_HOSTTAG_EVTACKCMD_MIN (MPI3MR_HOSTTAG_DEVRMCMD_MAX + 1)
0109 #define MPI3MR_HOSTTAG_EVTACKCMD_MAX (MPI3MR_HOSTTAG_EVTACKCMD_MIN + \
0110 MPI3MR_NUM_EVTACKCMD - 1)
0111
0112
0113 #define MPI3MR_HOST_IOS_KDUMP 128
0114
0115
0116 #define MPI3MR_INTADMCMD_TIMEOUT 60
0117 #define MPI3MR_PORTENABLE_TIMEOUT 300
0118 #define MPI3MR_ABORTTM_TIMEOUT 60
0119 #define MPI3MR_RESETTM_TIMEOUT 60
0120 #define MPI3MR_RESET_HOST_IOWAIT_TIMEOUT 5
0121 #define MPI3MR_TSUPDATE_INTERVAL 900
0122 #define MPI3MR_DEFAULT_SHUTDOWN_TIME 120
0123 #define MPI3MR_RAID_ERRREC_RESET_TIMEOUT 180
0124 #define MPI3MR_PREPARE_FOR_RESET_TIMEOUT 180
0125 #define MPI3MR_RESET_ACK_TIMEOUT 30
0126
0127 #define MPI3MR_WATCHDOG_INTERVAL 1000
0128
0129 #define MPI3MR_SCMD_TIMEOUT (60 * HZ)
0130 #define MPI3MR_EH_SCMD_TIMEOUT (60 * HZ)
0131
0132
0133 #define MPI3MR_CMD_NOTUSED 0x8000
0134 #define MPI3MR_CMD_COMPLETE 0x0001
0135 #define MPI3MR_CMD_PENDING 0x0002
0136 #define MPI3MR_CMD_REPLY_VALID 0x0004
0137 #define MPI3MR_CMD_RESET 0x0008
0138
0139
0140 #define MPI3MR_NUM_EVT_REPLIES 64
0141 #define MPI3MR_SENSE_BUF_SZ 256
0142 #define MPI3MR_SENSEBUF_FACTOR 3
0143 #define MPI3MR_CHAINBUF_FACTOR 3
0144 #define MPI3MR_CHAINBUFDIX_FACTOR 2
0145
0146
0147 #define MPI3MR_INVALID_DEV_HANDLE 0xFFFF
0148
0149
0150 #define MPI3MR_HOSTDIAG_UNLOCK_RETRY_COUNT 5
0151 #define MPI3MR_MAX_RESET_RETRY_COUNT 3
0152
0153
0154 #define MPI3MR_RI_MASK_RESPCODE (0x000000FF)
0155 #define MPI3MR_RSP_IO_QUEUED_ON_IOC \
0156 MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC
0157
0158 #define MPI3MR_DEFAULT_MDTS (128 * 1024)
0159 #define MPI3MR_DEFAULT_PGSZEXP (12)
0160
0161
0162 #define MPI3MR_DEV_RMHS_RETRY_COUNT 3
0163 #define MPI3MR_PEL_RETRY_COUNT 3
0164
0165
0166 #define MPI3MR_DEFAULT_SDEV_QD 32
0167
0168
0169 #define MPI3MR_IRQ_POLL_SLEEP 2
0170 #define MPI3MR_IRQ_POLL_TRIGGER_IOCOUNT 8
0171
0172
0173 #define MPI3MR_CTLR_SECURITY_STATUS_MASK 0x0C
0174 #define MPI3MR_CTLR_SECURE_DBG_STATUS_MASK 0x02
0175
0176 #define MPI3MR_INVALID_DEVICE 0x00
0177 #define MPI3MR_CONFIG_SECURE_DEVICE 0x04
0178 #define MPI3MR_HARD_SECURE_DEVICE 0x08
0179 #define MPI3MR_TAMPERED_DEVICE 0x0C
0180
0181
0182 #define MPI3MR_SGEFLAGS_SYSTEM_SIMPLE_END_OF_LIST \
0183 (MPI3_SGE_FLAGS_ELEMENT_TYPE_SIMPLE | MPI3_SGE_FLAGS_DLAS_SYSTEM | \
0184 MPI3_SGE_FLAGS_END_OF_LIST)
0185
0186
0187 #define REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, offset) (qidx + offset)
0188
0189
0190
0191
0192
0193 #define MPI3MR_MAX_APP_XFER_SIZE (1 * 1024 * 1024)
0194 #define MPI3MR_MAX_APP_XFER_SEGMENTS 512
0195
0196
0197
0198
0199 #define MPI3MR_MAX_APP_XFER_SECTORS (2048 + 512)
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211 struct mpi3mr_nvme_pt_sge {
0212 u64 base_addr;
0213 u32 length;
0214 u16 rsvd;
0215 u8 rsvd1;
0216 u8 sgl_type;
0217 };
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231 struct mpi3mr_buf_map {
0232 void *bsg_buf;
0233 u32 bsg_buf_len;
0234 void *kern_buf;
0235 u32 kern_buf_len;
0236 dma_addr_t kern_buf_dma;
0237 u8 data_dir;
0238 };
0239
0240
0241 enum mpi3mr_iocstate {
0242 MRIOC_STATE_READY = 1,
0243 MRIOC_STATE_RESET,
0244 MRIOC_STATE_FAULT,
0245 MRIOC_STATE_BECOMING_READY,
0246 MRIOC_STATE_RESET_REQUESTED,
0247 MRIOC_STATE_UNRECOVERABLE,
0248 };
0249
0250
0251 enum mpi3mr_reset_reason {
0252 MPI3MR_RESET_FROM_BRINGUP = 1,
0253 MPI3MR_RESET_FROM_FAULT_WATCH = 2,
0254 MPI3MR_RESET_FROM_APP = 3,
0255 MPI3MR_RESET_FROM_EH_HOS = 4,
0256 MPI3MR_RESET_FROM_TM_TIMEOUT = 5,
0257 MPI3MR_RESET_FROM_APP_TIMEOUT = 6,
0258 MPI3MR_RESET_FROM_MUR_FAILURE = 7,
0259 MPI3MR_RESET_FROM_CTLR_CLEANUP = 8,
0260 MPI3MR_RESET_FROM_CIACTIV_FAULT = 9,
0261 MPI3MR_RESET_FROM_PE_TIMEOUT = 10,
0262 MPI3MR_RESET_FROM_TSU_TIMEOUT = 11,
0263 MPI3MR_RESET_FROM_DELREQQ_TIMEOUT = 12,
0264 MPI3MR_RESET_FROM_DELREPQ_TIMEOUT = 13,
0265 MPI3MR_RESET_FROM_CREATEREPQ_TIMEOUT = 14,
0266 MPI3MR_RESET_FROM_CREATEREQQ_TIMEOUT = 15,
0267 MPI3MR_RESET_FROM_IOCFACTS_TIMEOUT = 16,
0268 MPI3MR_RESET_FROM_IOCINIT_TIMEOUT = 17,
0269 MPI3MR_RESET_FROM_EVTNOTIFY_TIMEOUT = 18,
0270 MPI3MR_RESET_FROM_EVTACK_TIMEOUT = 19,
0271 MPI3MR_RESET_FROM_CIACTVRST_TIMER = 20,
0272 MPI3MR_RESET_FROM_GETPKGVER_TIMEOUT = 21,
0273 MPI3MR_RESET_FROM_PELABORT_TIMEOUT = 22,
0274 MPI3MR_RESET_FROM_SYSFS = 23,
0275 MPI3MR_RESET_FROM_SYSFS_TIMEOUT = 24,
0276 MPI3MR_RESET_FROM_FIRMWARE = 27,
0277 };
0278
0279
0280 enum queue_type {
0281 MPI3MR_DEFAULT_QUEUE = 0,
0282 MPI3MR_POLL_QUEUE,
0283 };
0284
0285
0286
0287
0288
0289
0290 struct mpi3mr_compimg_ver {
0291 u16 build_num;
0292 u16 cust_id;
0293 u8 ph_minor;
0294 u8 ph_major;
0295 u8 gen_minor;
0296 u8 gen_major;
0297 };
0298
0299
0300
0301
0302
0303
0304 struct mpi3mr_ioc_facts {
0305 u32 ioc_capabilities;
0306 struct mpi3mr_compimg_ver fw_ver;
0307 u32 mpi_version;
0308 u16 max_reqs;
0309 u16 product_id;
0310 u16 op_req_sz;
0311 u16 reply_sz;
0312 u16 exceptions;
0313 u16 max_perids;
0314 u16 max_pds;
0315 u16 max_sasexpanders;
0316 u16 max_sasinitiators;
0317 u16 max_enclosures;
0318 u16 max_pcie_switches;
0319 u16 max_nvme;
0320 u16 max_vds;
0321 u16 max_hpds;
0322 u16 max_advhpds;
0323 u16 max_raid_pds;
0324 u16 min_devhandle;
0325 u16 max_devhandle;
0326 u16 max_op_req_q;
0327 u16 max_op_reply_q;
0328 u16 shutdown_timeout;
0329 u8 ioc_num;
0330 u8 who_init;
0331 u16 max_msix_vectors;
0332 u8 personality;
0333 u8 dma_mask;
0334 u8 protocol_flags;
0335 u8 sge_mod_mask;
0336 u8 sge_mod_value;
0337 u8 sge_mod_shift;
0338 u8 max_dev_per_tg;
0339 u16 max_io_throttle_group;
0340 u16 io_throttle_data_length;
0341 u16 io_throttle_low;
0342 u16 io_throttle_high;
0343
0344 };
0345
0346
0347
0348
0349
0350
0351
0352
0353 struct segments {
0354 void *segment;
0355 dma_addr_t segment_dma;
0356 };
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373 struct op_req_qinfo {
0374 u16 ci;
0375 u16 pi;
0376 u16 num_requests;
0377 u16 qid;
0378 u16 reply_qid;
0379 u16 num_segments;
0380 u16 segment_qd;
0381 spinlock_t q_lock;
0382 struct segments *q_segments;
0383 void *q_segment_list;
0384 dma_addr_t q_segment_list_dma;
0385 };
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404 struct op_reply_qinfo {
0405 u16 ci;
0406 u16 qid;
0407 u16 num_replies;
0408 u16 num_segments;
0409 u16 segment_qd;
0410 struct segments *q_segments;
0411 void *q_segment_list;
0412 dma_addr_t q_segment_list_dma;
0413 u8 ephase;
0414 atomic_t pend_ios;
0415 bool enable_irq_poll;
0416 atomic_t in_use;
0417 enum queue_type qtype;
0418 };
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428 struct mpi3mr_intr_info {
0429 struct mpi3mr_ioc *mrioc;
0430 u16 msix_index;
0431 struct op_reply_qinfo *op_reply_q;
0432 char name[MPI3MR_NAME_LENGTH];
0433 };
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448 struct mpi3mr_throttle_group_info {
0449 u8 io_divert;
0450 u8 need_qd_reduction;
0451 u8 qd_reduction;
0452 u16 fw_qd;
0453 u16 modified_qd;
0454 u16 id;
0455 u32 high;
0456 u32 low;
0457 atomic_t pend_large_data_sz;
0458 };
0459
0460
0461
0462
0463
0464
0465
0466
0467 struct tgt_dev_sas_sata {
0468 u64 sas_address;
0469 u16 dev_info;
0470 };
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483 struct tgt_dev_pcie {
0484 u32 mdts;
0485 u16 capb;
0486 u8 pgsz;
0487 u8 abort_to;
0488 u8 reset_to;
0489 u16 dev_info;
0490 };
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503 struct tgt_dev_vd {
0504 u8 state;
0505 u8 tg_qd_reduction;
0506 u16 tg_id;
0507 u32 tg_high;
0508 u32 tg_low;
0509 struct mpi3mr_throttle_group_info *tg;
0510 };
0511
0512
0513
0514
0515
0516 union _form_spec_inf {
0517 struct tgt_dev_sas_sata sas_sata_inf;
0518 struct tgt_dev_pcie pcie_inf;
0519 struct tgt_dev_vd vd_inf;
0520 };
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543 struct mpi3mr_tgt_dev {
0544 struct list_head list;
0545 struct scsi_target *starget;
0546 u16 dev_handle;
0547 u16 parent_handle;
0548 u16 slot;
0549 u16 encl_handle;
0550 u16 perst_id;
0551 u8 dev_type;
0552 u8 is_hidden;
0553 u8 host_exposed;
0554 u8 io_throttle_enabled;
0555 u16 q_depth;
0556 u64 wwid;
0557 union _form_spec_inf dev_spec;
0558 struct kref ref_count;
0559 };
0560
0561
0562
0563
0564
0565
0566
0567 static inline void mpi3mr_tgtdev_get(struct mpi3mr_tgt_dev *s)
0568 {
0569 kref_get(&s->ref_count);
0570 }
0571
0572
0573
0574
0575
0576
0577
0578 static inline void mpi3mr_free_tgtdev(struct kref *r)
0579 {
0580 kfree(container_of(r, struct mpi3mr_tgt_dev, ref_count));
0581 }
0582
0583
0584
0585
0586
0587
0588
0589 static inline void mpi3mr_tgtdev_put(struct mpi3mr_tgt_dev *s)
0590 {
0591 kref_put(&s->ref_count, mpi3mr_free_tgtdev);
0592 }
0593
0594
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613 struct mpi3mr_stgt_priv_data {
0614 struct scsi_target *starget;
0615 u16 dev_handle;
0616 u16 perst_id;
0617 u32 num_luns;
0618 atomic_t block_io;
0619 u8 dev_removed;
0620 u8 dev_removedelay;
0621 u8 dev_type;
0622 u8 io_throttle_enabled;
0623 u8 io_divert;
0624 struct mpi3mr_throttle_group_info *throttle_group;
0625 struct mpi3mr_tgt_dev *tgt_dev;
0626 u32 pend_count;
0627 };
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638 struct mpi3mr_sdev_priv_data {
0639 struct mpi3mr_stgt_priv_data *tgt_priv_data;
0640 u32 lun_id;
0641 u8 ncq_prio_enable;
0642 u32 pend_count;
0643 };
0644
0645
0646
0647
0648
0649
0650
0651
0652
0653
0654
0655
0656
0657
0658
0659
0660
0661
0662
0663 struct mpi3mr_drv_cmd {
0664 struct mutex mutex;
0665 struct completion done;
0666 void *reply;
0667 u8 *sensebuf;
0668 u8 iou_rc;
0669 u16 state;
0670 u16 dev_handle;
0671 u16 ioc_status;
0672 u32 ioc_loginfo;
0673 u8 is_waiting;
0674 u8 is_sense;
0675 u8 retry_count;
0676 u16 host_tag;
0677
0678 void (*callback)(struct mpi3mr_ioc *mrioc,
0679 struct mpi3mr_drv_cmd *drv_cmd);
0680 };
0681
0682
0683
0684
0685
0686
0687
0688
0689
0690 struct chain_element {
0691 void *addr;
0692 dma_addr_t dma_addr;
0693 };
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707 struct scmd_priv {
0708 u16 host_tag;
0709 u8 in_lld_scope;
0710 u8 meta_sg_valid;
0711 struct scsi_cmnd *scmd;
0712 u16 req_q_idx;
0713 int chain_idx;
0714 int meta_chain_idx;
0715 u8 mpi3mr_scsiio_req[MPI3MR_ADMIN_REQ_FRAME_SZ];
0716 };
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728
0729
0730
0731
0732
0733
0734
0735
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757
0758
0759
0760
0761
0762
0763
0764
0765
0766
0767
0768
0769
0770
0771
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783
0784
0785
0786
0787
0788
0789
0790
0791
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834
0835
0836
0837
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856
0857
0858 struct mpi3mr_ioc {
0859 struct list_head list;
0860 struct pci_dev *pdev;
0861 struct Scsi_Host *shost;
0862 u8 id;
0863 int cpu_count;
0864 bool enable_segqueue;
0865 u32 irqpoll_sleep;
0866
0867 char name[MPI3MR_NAME_LENGTH];
0868 char driver_name[MPI3MR_NAME_LENGTH];
0869
0870 volatile struct mpi3_sysif_registers __iomem *sysif_regs;
0871 resource_size_t sysif_regs_phys;
0872 int bars;
0873 u64 dma_mask;
0874
0875 u16 msix_count;
0876 u8 intr_enabled;
0877
0878 u16 num_admin_req;
0879 u32 admin_req_q_sz;
0880 u16 admin_req_pi;
0881 u16 admin_req_ci;
0882 void *admin_req_base;
0883 dma_addr_t admin_req_dma;
0884 spinlock_t admin_req_lock;
0885
0886 u16 num_admin_replies;
0887 u32 admin_reply_q_sz;
0888 u16 admin_reply_ci;
0889 u8 admin_reply_ephase;
0890 void *admin_reply_base;
0891 dma_addr_t admin_reply_dma;
0892
0893 u32 ready_timeout;
0894
0895 struct mpi3mr_intr_info *intr_info;
0896 u16 intr_info_count;
0897 bool is_intr_info_set;
0898
0899 u16 num_queues;
0900 u16 num_op_req_q;
0901 struct op_req_qinfo *req_qinfo;
0902
0903 u16 num_op_reply_q;
0904 struct op_reply_qinfo *op_reply_qinfo;
0905
0906 struct mpi3mr_drv_cmd init_cmds;
0907 struct mpi3mr_ioc_facts facts;
0908 u16 op_reply_desc_sz;
0909
0910 u32 num_reply_bufs;
0911 struct dma_pool *reply_buf_pool;
0912 u8 *reply_buf;
0913 dma_addr_t reply_buf_dma;
0914 dma_addr_t reply_buf_dma_max_address;
0915
0916 u16 reply_free_qsz;
0917 u16 reply_sz;
0918 struct dma_pool *reply_free_q_pool;
0919 __le64 *reply_free_q;
0920 dma_addr_t reply_free_q_dma;
0921 spinlock_t reply_free_queue_lock;
0922 u32 reply_free_queue_host_index;
0923
0924 u32 num_sense_bufs;
0925 struct dma_pool *sense_buf_pool;
0926 u8 *sense_buf;
0927 dma_addr_t sense_buf_dma;
0928
0929 u16 sense_buf_q_sz;
0930 struct dma_pool *sense_buf_q_pool;
0931 __le64 *sense_buf_q;
0932 dma_addr_t sense_buf_q_dma;
0933 spinlock_t sbq_lock;
0934 u32 sbq_host_index;
0935 u32 event_masks[MPI3_EVENT_NOTIFY_EVENTMASK_WORDS];
0936
0937 char fwevt_worker_name[MPI3MR_NAME_LENGTH];
0938 struct workqueue_struct *fwevt_worker_thread;
0939 spinlock_t fwevt_lock;
0940 struct list_head fwevt_list;
0941
0942 char watchdog_work_q_name[20];
0943 struct workqueue_struct *watchdog_work_q;
0944 struct delayed_work watchdog_work;
0945 spinlock_t watchdog_lock;
0946
0947 u8 is_driver_loading;
0948 u8 scan_started;
0949 u16 scan_failed;
0950 u8 stop_drv_processing;
0951
0952 u16 max_host_ios;
0953 spinlock_t tgtdev_lock;
0954 struct list_head tgtdev_list;
0955
0956 u32 chain_buf_count;
0957 struct dma_pool *chain_buf_pool;
0958 struct chain_element *chain_sgl_list;
0959 u16 chain_bitmap_sz;
0960 void *chain_bitmap;
0961 spinlock_t chain_buf_lock;
0962
0963 struct mpi3mr_drv_cmd bsg_cmds;
0964 struct mpi3mr_drv_cmd host_tm_cmds;
0965 struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD];
0966 struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD];
0967 u16 devrem_bitmap_sz;
0968 void *devrem_bitmap;
0969 u16 dev_handle_bitmap_sz;
0970 void *removepend_bitmap;
0971 struct list_head delayed_rmhs_list;
0972 u16 evtack_cmds_bitmap_sz;
0973 void *evtack_cmds_bitmap;
0974 struct list_head delayed_evtack_cmds_list;
0975
0976 u32 ts_update_counter;
0977 u8 reset_in_progress;
0978 u8 unrecoverable;
0979 int prev_reset_result;
0980 struct mutex reset_mutex;
0981 wait_queue_head_t reset_waitq;
0982
0983 u8 prepare_for_reset;
0984 u16 prepare_for_reset_timeout_counter;
0985
0986 void *prp_list_virt;
0987 dma_addr_t prp_list_dma;
0988 u32 prp_sz;
0989
0990 u16 diagsave_timeout;
0991 int logging_level;
0992 u16 flush_io_count;
0993
0994 struct mpi3mr_fwevt *current_event;
0995 struct mpi3_driver_info_layout driver_info;
0996 u16 change_count;
0997
0998 u8 pel_enabled;
0999 u8 pel_abort_requested;
1000 u8 pel_class;
1001 u16 pel_locale;
1002 struct mpi3mr_drv_cmd pel_cmds;
1003 struct mpi3mr_drv_cmd pel_abort_cmd;
1004
1005 u32 pel_newest_seqnum;
1006 void *pel_seqnum_virt;
1007 dma_addr_t pel_seqnum_dma;
1008 u32 pel_seqnum_sz;
1009
1010 u16 op_reply_q_offset;
1011 u16 default_qcount;
1012 u16 active_poll_qcount;
1013 u16 requested_poll_qcount;
1014
1015 struct device bsg_dev;
1016 struct request_queue *bsg_queue;
1017 u8 stop_bsgs;
1018 u8 *logdata_buf;
1019 u16 logdata_buf_idx;
1020 u16 logdata_entry_sz;
1021
1022 atomic_t pend_large_data_sz;
1023 u32 io_throttle_data_length;
1024 u32 io_throttle_high;
1025 u32 io_throttle_low;
1026 u16 num_io_throttle_group;
1027 struct mpi3mr_throttle_group_info *throttle_groups;
1028 };
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046 struct mpi3mr_fwevt {
1047 struct list_head list;
1048 struct work_struct work;
1049 struct mpi3mr_ioc *mrioc;
1050 u16 event_id;
1051 bool send_ack;
1052 bool process_evt;
1053 u32 evt_ctx;
1054 u16 event_data_size;
1055 bool pending_at_sml;
1056 bool discard;
1057 struct kref ref_count;
1058 char event_data[] __aligned(4);
1059 };
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069 struct delayed_dev_rmhs_node {
1070 struct list_head list;
1071 u16 handle;
1072 u8 iou_rc;
1073 };
1074
1075
1076
1077
1078
1079
1080
1081 struct delayed_evt_ack_node {
1082 struct list_head list;
1083 u8 event;
1084 u32 event_ctx;
1085 };
1086
1087 int mpi3mr_setup_resources(struct mpi3mr_ioc *mrioc);
1088 void mpi3mr_cleanup_resources(struct mpi3mr_ioc *mrioc);
1089 int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc);
1090 int mpi3mr_reinit_ioc(struct mpi3mr_ioc *mrioc, u8 is_resume);
1091 void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc);
1092 int mpi3mr_issue_port_enable(struct mpi3mr_ioc *mrioc, u8 async);
1093 int mpi3mr_admin_request_post(struct mpi3mr_ioc *mrioc, void *admin_req,
1094 u16 admin_req_sz, u8 ignore_reset);
1095 int mpi3mr_op_request_post(struct mpi3mr_ioc *mrioc,
1096 struct op_req_qinfo *opreqq, u8 *req);
1097 void mpi3mr_add_sg_single(void *paddr, u8 flags, u32 length,
1098 dma_addr_t dma_addr);
1099 void mpi3mr_build_zero_len_sge(void *paddr);
1100 void *mpi3mr_get_sensebuf_virt_addr(struct mpi3mr_ioc *mrioc,
1101 dma_addr_t phys_addr);
1102 void *mpi3mr_get_reply_virt_addr(struct mpi3mr_ioc *mrioc,
1103 dma_addr_t phys_addr);
1104 void mpi3mr_repost_sense_buf(struct mpi3mr_ioc *mrioc,
1105 u64 sense_buf_dma);
1106
1107 void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc);
1108 void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc);
1109 void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,
1110 struct mpi3_event_notification_reply *event_reply);
1111 void mpi3mr_process_op_reply_desc(struct mpi3mr_ioc *mrioc,
1112 struct mpi3_default_reply_descriptor *reply_desc,
1113 u64 *reply_dma, u16 qidx);
1114 void mpi3mr_start_watchdog(struct mpi3mr_ioc *mrioc);
1115 void mpi3mr_stop_watchdog(struct mpi3mr_ioc *mrioc);
1116
1117 int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
1118 u32 reset_reason, u8 snapdump);
1119 void mpi3mr_ioc_disable_intr(struct mpi3mr_ioc *mrioc);
1120 void mpi3mr_ioc_enable_intr(struct mpi3mr_ioc *mrioc);
1121
1122 enum mpi3mr_iocstate mpi3mr_get_iocstate(struct mpi3mr_ioc *mrioc);
1123 int mpi3mr_process_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
1124 u32 event_ctx);
1125
1126 void mpi3mr_wait_for_host_io(struct mpi3mr_ioc *mrioc, u32 timeout);
1127 void mpi3mr_cleanup_fwevt_list(struct mpi3mr_ioc *mrioc);
1128 void mpi3mr_flush_host_io(struct mpi3mr_ioc *mrioc);
1129 void mpi3mr_invalidate_devhandles(struct mpi3mr_ioc *mrioc);
1130 void mpi3mr_rfresh_tgtdevs(struct mpi3mr_ioc *mrioc);
1131 void mpi3mr_flush_delayed_cmd_lists(struct mpi3mr_ioc *mrioc);
1132 void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);
1133 void mpi3mr_print_fault_info(struct mpi3mr_ioc *mrioc);
1134 void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);
1135 int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
1136 struct op_reply_qinfo *op_reply_q);
1137 int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);
1138 void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc);
1139 void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc);
1140 int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
1141 u16 handle, uint lun, u16 htag, ulong timeout,
1142 struct mpi3mr_drv_cmd *drv_cmd,
1143 u8 *resp_code, struct scsi_cmnd *scmd);
1144 struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(
1145 struct mpi3mr_ioc *mrioc, u16 handle);
1146 void mpi3mr_pel_get_seqnum_complete(struct mpi3mr_ioc *mrioc,
1147 struct mpi3mr_drv_cmd *drv_cmd);
1148 int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc,
1149 struct mpi3mr_drv_cmd *drv_cmd);
1150 void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data,
1151 u16 event_data_size);
1152 extern const struct attribute_group *mpi3mr_host_groups[];
1153 extern const struct attribute_group *mpi3mr_dev_groups[];
1154 #endif