This source file includes following definitions.
- sas_device_get
- sas_device_free
- sas_device_put
- pcie_device_get
- pcie_device_free
- pcie_device_put
- mpt3sas_scsih_is_pcie_scsi_device
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 #ifndef MPT3SAS_BASE_H_INCLUDED
47 #define MPT3SAS_BASE_H_INCLUDED
48
49 #include "mpi/mpi2_type.h"
50 #include "mpi/mpi2.h"
51 #include "mpi/mpi2_ioc.h"
52 #include "mpi/mpi2_cnfg.h"
53 #include "mpi/mpi2_init.h"
54 #include "mpi/mpi2_raid.h"
55 #include "mpi/mpi2_tool.h"
56 #include "mpi/mpi2_sas.h"
57 #include "mpi/mpi2_pci.h"
58 #include "mpi/mpi2_image.h"
59
60 #include <scsi/scsi.h>
61 #include <scsi/scsi_cmnd.h>
62 #include <scsi/scsi_device.h>
63 #include <scsi/scsi_host.h>
64 #include <scsi/scsi_tcq.h>
65 #include <scsi/scsi_transport_sas.h>
66 #include <scsi/scsi_dbg.h>
67 #include <scsi/scsi_eh.h>
68 #include <linux/pci.h>
69 #include <linux/poll.h>
70 #include <linux/irq_poll.h>
71
72 #include "mpt3sas_debug.h"
73 #include "mpt3sas_trigger_diag.h"
74
75
76 #define MPT3SAS_DRIVER_NAME "mpt3sas"
77 #define MPT3SAS_AUTHOR "Avago Technologies <MPT-FusionLinux.pdl@avagotech.com>"
78 #define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver"
79 #define MPT3SAS_DRIVER_VERSION "31.100.00.00"
80 #define MPT3SAS_MAJOR_VERSION 31
81 #define MPT3SAS_MINOR_VERSION 100
82 #define MPT3SAS_BUILD_VERSION 0
83 #define MPT3SAS_RELEASE_VERSION 00
84
85 #define MPT2SAS_DRIVER_NAME "mpt2sas"
86 #define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver"
87 #define MPT2SAS_DRIVER_VERSION "20.102.00.00"
88 #define MPT2SAS_MAJOR_VERSION 20
89 #define MPT2SAS_MINOR_VERSION 102
90 #define MPT2SAS_BUILD_VERSION 0
91 #define MPT2SAS_RELEASE_VERSION 00
92
93
94
95
96 #define MPT_MAX_PHYS_SEGMENTS SG_CHUNK_SIZE
97 #define MPT_MIN_PHYS_SEGMENTS 16
98 #define MPT_KDUMP_MIN_PHYS_SEGMENTS 32
99
100 #define MCPU_MAX_CHAINS_PER_IO 3
101
102 #ifdef CONFIG_SCSI_MPT3SAS_MAX_SGE
103 #define MPT3SAS_SG_DEPTH CONFIG_SCSI_MPT3SAS_MAX_SGE
104 #else
105 #define MPT3SAS_SG_DEPTH MPT_MAX_PHYS_SEGMENTS
106 #endif
107
108 #ifdef CONFIG_SCSI_MPT2SAS_MAX_SGE
109 #define MPT2SAS_SG_DEPTH CONFIG_SCSI_MPT2SAS_MAX_SGE
110 #else
111 #define MPT2SAS_SG_DEPTH MPT_MAX_PHYS_SEGMENTS
112 #endif
113
114
115
116
117 #define MPT3SAS_SATA_QUEUE_DEPTH 32
118 #define MPT3SAS_SAS_QUEUE_DEPTH 254
119 #define MPT3SAS_RAID_QUEUE_DEPTH 128
120 #define MPT3SAS_KDUMP_SCSI_IO_DEPTH 200
121
122 #define MPT3SAS_RAID_MAX_SECTORS 8192
123 #define MPT3SAS_HOST_PAGE_SIZE_4K 12
124 #define MPT3SAS_NVME_QUEUE_DEPTH 128
125 #define MPT_NAME_LENGTH 32
126 #define MPT_STRING_LENGTH 64
127 #define MPI_FRAME_START_OFFSET 256
128 #define REPLY_FREE_POOL_SIZE 512
129
130 #define MPT_MAX_CALLBACKS 32
131
132 #define INTERNAL_CMDS_COUNT 10
133
134 #define INTERNAL_SCSIIO_CMDS_COUNT 3
135
136 #define MPI3_HIM_MASK 0xFFFFFFFF
137
138 #define MPT3SAS_INVALID_DEVICE_HANDLE 0xFFFF
139
140 #define MAX_CHAIN_ELEMT_SZ 16
141 #define DEFAULT_NUM_FWCHAIN_ELEMTS 8
142
143 #define FW_IMG_HDR_READ_TIMEOUT 15
144
145 #define IOC_OPERATIONAL_WAIT_COUNT 10
146
147
148
149
150 #define NVME_PRP_SIZE 8
151 #define NVME_ERROR_RESPONSE_SIZE 16
152 #define NVME_TASK_ABORT_MIN_TIMEOUT 6
153 #define NVME_TASK_ABORT_MAX_TIMEOUT 60
154 #define NVME_TASK_MNGT_CUSTOM_MASK (0x0010)
155 #define NVME_PRP_PAGE_SIZE 4096
156
157 struct mpt3sas_nvme_cmd {
158 u8 rsvd[24];
159 __le64 prp1;
160 __le64 prp2;
161 };
162
163
164
165
166 #define ioc_err(ioc, fmt, ...) \
167 pr_err("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
168 #define ioc_notice(ioc, fmt, ...) \
169 pr_notice("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
170 #define ioc_warn(ioc, fmt, ...) \
171 pr_warn("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
172 #define ioc_info(ioc, fmt, ...) \
173 pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
174
175
176
177
178
179 #define MPT2_WARPDRIVE_LOGENTRY (0x8002)
180 #define MPT2_WARPDRIVE_LC_SSDT (0x41)
181 #define MPT2_WARPDRIVE_LC_SSDLW (0x43)
182 #define MPT2_WARPDRIVE_LC_SSDLF (0x44)
183 #define MPT2_WARPDRIVE_LC_BRMF (0x4D)
184
185
186
187
188 #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01
189 #define MPT_TARGET_FLAGS_VOLUME 0x02
190 #define MPT_TARGET_FLAGS_DELETED 0x04
191 #define MPT_TARGET_FASTPATH_IO 0x08
192 #define MPT_TARGET_FLAGS_PCIE_DEVICE 0x10
193
194 #define SAS2_PCI_DEVICE_B0_REVISION (0x01)
195 #define SAS3_PCI_DEVICE_C0_REVISION (0x02)
196
197
198 #define MPI26_ATLAS_PCIe_SWITCH_DEVID (0x00B2)
199
200
201
202
203 #define MPT2SAS_INTEL_RMS25JB080_BRANDING \
204 "Intel(R) Integrated RAID Module RMS25JB080"
205 #define MPT2SAS_INTEL_RMS25JB040_BRANDING \
206 "Intel(R) Integrated RAID Module RMS25JB040"
207 #define MPT2SAS_INTEL_RMS25KB080_BRANDING \
208 "Intel(R) Integrated RAID Module RMS25KB080"
209 #define MPT2SAS_INTEL_RMS25KB040_BRANDING \
210 "Intel(R) Integrated RAID Module RMS25KB040"
211 #define MPT2SAS_INTEL_RMS25LB040_BRANDING \
212 "Intel(R) Integrated RAID Module RMS25LB040"
213 #define MPT2SAS_INTEL_RMS25LB080_BRANDING \
214 "Intel(R) Integrated RAID Module RMS25LB080"
215 #define MPT2SAS_INTEL_RMS2LL080_BRANDING \
216 "Intel Integrated RAID Module RMS2LL080"
217 #define MPT2SAS_INTEL_RMS2LL040_BRANDING \
218 "Intel Integrated RAID Module RMS2LL040"
219 #define MPT2SAS_INTEL_RS25GB008_BRANDING \
220 "Intel(R) RAID Controller RS25GB008"
221 #define MPT2SAS_INTEL_SSD910_BRANDING \
222 "Intel(R) SSD 910 Series"
223
224 #define MPT3SAS_INTEL_RMS3JC080_BRANDING \
225 "Intel(R) Integrated RAID Module RMS3JC080"
226 #define MPT3SAS_INTEL_RS3GC008_BRANDING \
227 "Intel(R) RAID Controller RS3GC008"
228 #define MPT3SAS_INTEL_RS3FC044_BRANDING \
229 "Intel(R) RAID Controller RS3FC044"
230 #define MPT3SAS_INTEL_RS3UC080_BRANDING \
231 "Intel(R) RAID Controller RS3UC080"
232
233
234
235
236 #define MPT2SAS_INTEL_RMS25JB080_SSDID 0x3516
237 #define MPT2SAS_INTEL_RMS25JB040_SSDID 0x3517
238 #define MPT2SAS_INTEL_RMS25KB080_SSDID 0x3518
239 #define MPT2SAS_INTEL_RMS25KB040_SSDID 0x3519
240 #define MPT2SAS_INTEL_RMS25LB040_SSDID 0x351A
241 #define MPT2SAS_INTEL_RMS25LB080_SSDID 0x351B
242 #define MPT2SAS_INTEL_RMS2LL080_SSDID 0x350E
243 #define MPT2SAS_INTEL_RMS2LL040_SSDID 0x350F
244 #define MPT2SAS_INTEL_RS25GB008_SSDID 0x3000
245 #define MPT2SAS_INTEL_SSD910_SSDID 0x3700
246
247 #define MPT3SAS_INTEL_RMS3JC080_SSDID 0x3521
248 #define MPT3SAS_INTEL_RS3GC008_SSDID 0x3522
249 #define MPT3SAS_INTEL_RS3FC044_SSDID 0x3523
250 #define MPT3SAS_INTEL_RS3UC080_SSDID 0x3524
251
252
253
254
255 #define MPT2SAS_DELL_BRANDING_SIZE 32
256
257 #define MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING "Dell 6Gbps SAS HBA"
258 #define MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING "Dell PERC H200 Adapter"
259 #define MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING "Dell PERC H200 Integrated"
260 #define MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING "Dell PERC H200 Modular"
261 #define MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING "Dell PERC H200 Embedded"
262 #define MPT2SAS_DELL_PERC_H200_BRANDING "Dell PERC H200"
263 #define MPT2SAS_DELL_6GBPS_SAS_BRANDING "Dell 6Gbps SAS"
264
265 #define MPT3SAS_DELL_12G_HBA_BRANDING \
266 "Dell 12Gbps HBA"
267
268
269
270
271 #define MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID 0x1F1C
272 #define MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID 0x1F1D
273 #define MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID 0x1F1E
274 #define MPT2SAS_DELL_PERC_H200_MODULAR_SSDID 0x1F1F
275 #define MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID 0x1F20
276 #define MPT2SAS_DELL_PERC_H200_SSDID 0x1F21
277 #define MPT2SAS_DELL_6GBPS_SAS_SSDID 0x1F22
278
279 #define MPT3SAS_DELL_12G_HBA_SSDID 0x1F46
280
281
282
283
284 #define MPT3SAS_CISCO_12G_8E_HBA_BRANDING \
285 "Cisco 9300-8E 12G SAS HBA"
286 #define MPT3SAS_CISCO_12G_8I_HBA_BRANDING \
287 "Cisco 9300-8i 12G SAS HBA"
288 #define MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING \
289 "Cisco 12G Modular SAS Pass through Controller"
290 #define MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_BRANDING \
291 "UCS C3X60 12G SAS Pass through Controller"
292
293
294
295 #define MPT3SAS_CISCO_12G_8E_HBA_SSDID 0x14C
296 #define MPT3SAS_CISCO_12G_8I_HBA_SSDID 0x154
297 #define MPT3SAS_CISCO_12G_AVILA_HBA_SSDID 0x155
298 #define MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_SSDID 0x156
299
300
301
302
303 #define MPT3_DIAG_BUFFER_IS_REGISTERED (0x01)
304 #define MPT3_DIAG_BUFFER_IS_RELEASED (0x02)
305 #define MPT3_DIAG_BUFFER_IS_DIAG_RESET (0x04)
306
307
308
309
310 #define MPT2SAS_HP_3PAR_SSVID 0x1590
311
312 #define MPT2SAS_HP_2_4_INTERNAL_BRANDING \
313 "HP H220 Host Bus Adapter"
314 #define MPT2SAS_HP_2_4_EXTERNAL_BRANDING \
315 "HP H221 Host Bus Adapter"
316 #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING \
317 "HP H222 Host Bus Adapter"
318 #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING \
319 "HP H220i Host Bus Adapter"
320 #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING \
321 "HP H210i Host Bus Adapter"
322
323
324
325
326 #define MPT2SAS_HP_2_4_INTERNAL_SSDID 0x0041
327 #define MPT2SAS_HP_2_4_EXTERNAL_SSDID 0x0042
328 #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_SSDID 0x0043
329 #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_SSDID 0x0044
330 #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_SSDID 0x0046
331
332
333
334
335
336
337 #define MAX_COMBINED_MSIX_VECTORS(gen35) ((gen35 == 1) ? 16 : 8)
338 #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G3 12
339 #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G35 16
340 #define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET (0x10)
341
342
343 #define MFG10_OEM_ID_INVALID (0x00000000)
344 #define MFG10_OEM_ID_DELL (0x00000001)
345 #define MFG10_OEM_ID_FSC (0x00000002)
346 #define MFG10_OEM_ID_SUN (0x00000003)
347 #define MFG10_OEM_ID_IBM (0x00000004)
348
349
350 #define MFG10_GF0_OCE_DISABLED (0x00000001)
351 #define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002)
352 #define MFG10_GF0_R10_DISPLAY (0x00000004)
353 #define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008)
354 #define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010)
355
356 #define VIRTUAL_IO_FAILED_RETRY (0x32010081)
357
358
359 #define MPT3SAS_DEVICE_HIGH_IOPS_DEPTH 8
360 #define MPT3SAS_HIGH_IOPS_REPLY_QUEUES 8
361 #define MPT3SAS_HIGH_IOPS_BATCH_COUNT 16
362 #define MPT3SAS_GEN35_MAX_MSIX_QUEUES 128
363
364
365 struct Mpi2ManufacturingPage10_t {
366 MPI2_CONFIG_PAGE_HEADER Header;
367 U8 OEMIdentifier;
368 U8 Reserved1;
369 U16 Reserved2;
370 U32 Reserved3;
371 U32 GenericFlags0;
372 U32 GenericFlags1;
373 U32 Reserved4;
374 U32 OEMSpecificFlags0;
375 U32 OEMSpecificFlags1;
376 U32 Reserved5[18];
377 };
378
379
380
381 struct Mpi2ManufacturingPage11_t {
382 MPI2_CONFIG_PAGE_HEADER Header;
383 __le32 Reserved1;
384 u8 Reserved2;
385 u8 EEDPTagMode;
386 u8 Reserved3;
387 u8 Reserved4;
388 __le32 Reserved5[8];
389 u16 AddlFlags2;
390 u8 AddlFlags3;
391 u8 Reserved6;
392 __le32 Reserved7[7];
393 u8 NVMeAbortTO;
394 u8 Reserved8;
395 u16 Reserved9;
396 __le32 Reserved10[4];
397 };
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412 struct MPT3SAS_TARGET {
413 struct scsi_target *starget;
414 u64 sas_address;
415 struct _raid_device *raid_device;
416 u16 handle;
417 int num_luns;
418 u32 flags;
419 u8 deleted;
420 u8 tm_busy;
421 struct _sas_device *sas_dev;
422 struct _pcie_device *pcie_dev;
423 };
424
425
426
427
428
429 #define MPT_DEVICE_FLAGS_INIT 0x01
430
431 #define MFG_PAGE10_HIDE_SSDS_MASK (0x00000003)
432 #define MFG_PAGE10_HIDE_ALL_DISKS (0x00)
433 #define MFG_PAGE10_EXPOSE_ALL_DISKS (0x01)
434 #define MFG_PAGE10_HIDE_IF_VOL_PRESENT (0x02)
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449 struct MPT3SAS_DEVICE {
450 struct MPT3SAS_TARGET *sas_target;
451 unsigned int lun;
452 u32 flags;
453 u8 configured_lun;
454 u8 block;
455 u8 tlr_snoop_check;
456 u8 ignore_delay_remove;
457
458 u8 ncq_prio_enable;
459
460
461
462
463
464
465
466
467
468
469 unsigned long ata_command_pending;
470
471 };
472
473 #define MPT3_CMD_NOT_USED 0x8000
474 #define MPT3_CMD_COMPLETE 0x0001
475 #define MPT3_CMD_PENDING 0x0002
476 #define MPT3_CMD_REPLY_VALID 0x0004
477 #define MPT3_CMD_RESET 0x0008
478
479
480
481
482
483
484
485
486
487
488 struct _internal_cmd {
489 struct mutex mutex;
490 struct completion done;
491 void *reply;
492 void *sense;
493 u16 status;
494 u16 smid;
495 };
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524 struct _sas_device {
525 struct list_head list;
526 struct scsi_target *starget;
527 u64 sas_address;
528 u64 device_name;
529 u16 handle;
530 u64 sas_address_parent;
531 u16 enclosure_handle;
532 u64 enclosure_logical_id;
533 u16 volume_handle;
534 u64 volume_wwid;
535 u32 device_info;
536 int id;
537 int channel;
538 u16 slot;
539 u8 phy;
540 u8 responding;
541 u8 fast_path;
542 u8 pfa_led_on;
543 u8 pend_sas_rphy_add;
544 u8 enclosure_level;
545 u8 chassis_slot;
546 u8 is_chassis_slot_valid;
547 u8 connector_name[5];
548 struct kref refcount;
549 };
550
551 static inline void sas_device_get(struct _sas_device *s)
552 {
553 kref_get(&s->refcount);
554 }
555
556 static inline void sas_device_free(struct kref *r)
557 {
558 kfree(container_of(r, struct _sas_device, refcount));
559 }
560
561 static inline void sas_device_put(struct _sas_device *s)
562 {
563 kref_put(&s->refcount, sas_device_free);
564 }
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589 struct _pcie_device {
590 struct list_head list;
591 struct scsi_target *starget;
592 u64 wwid;
593 u16 handle;
594 u32 device_info;
595 int id;
596 int channel;
597 u16 slot;
598 u8 port_num;
599 u8 responding;
600 u8 fast_path;
601 u32 nvme_mdts;
602 u16 enclosure_handle;
603 u64 enclosure_logical_id;
604 u8 enclosure_level;
605 u8 connector_name[4];
606 u8 *serial_number;
607 u8 reset_timeout;
608 u8 access_status;
609 struct kref refcount;
610 };
611
612
613
614
615
616
617
618
619
620 static inline void pcie_device_get(struct _pcie_device *p)
621 {
622 kref_get(&p->refcount);
623 }
624
625
626
627
628
629
630
631
632 static inline void pcie_device_free(struct kref *r)
633 {
634 kfree(container_of(r, struct _pcie_device, refcount));
635 }
636
637
638
639
640
641
642
643
644
645
646
647
648 static inline void pcie_device_put(struct _pcie_device *p)
649 {
650 kref_put(&p->refcount, pcie_device_free);
651 }
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675 #define MPT_MAX_WARPDRIVE_PDS 8
676 struct _raid_device {
677 struct list_head list;
678 struct scsi_target *starget;
679 struct scsi_device *sdev;
680 u64 wwid;
681 u16 handle;
682 u16 block_sz;
683 int id;
684 int channel;
685 u8 volume_type;
686 u8 num_pds;
687 u8 responding;
688 u8 percent_complete;
689 u8 direct_io_enabled;
690 u8 stripe_exponent;
691 u8 block_exponent;
692 u64 max_lba;
693 u32 stripe_sz;
694 u32 device_info;
695 u16 pd_handle[MPT_MAX_WARPDRIVE_PDS];
696 };
697
698
699
700
701
702
703
704
705 struct _boot_device {
706 int channel;
707 void *device;
708 };
709
710
711
712
713
714
715
716
717
718
719 struct _sas_port {
720 struct list_head port_list;
721 u8 num_phys;
722 struct sas_identify remote_identify;
723 struct sas_rphy *rphy;
724 struct sas_port *port;
725 struct list_head phy_list;
726 };
727
728
729
730
731
732
733
734
735
736
737
738
739 struct _sas_phy {
740 struct list_head port_siblings;
741 struct sas_identify identify;
742 struct sas_identify remote_identify;
743 struct sas_phy *phy;
744 u8 phy_id;
745 u16 handle;
746 u16 attached_handle;
747 u8 phy_belongs_to_port;
748 };
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764 struct _sas_node {
765 struct list_head list;
766 struct device *parent_dev;
767 u8 num_phys;
768 u64 sas_address;
769 u16 handle;
770 u64 sas_address_parent;
771 u16 enclosure_handle;
772 u64 enclosure_logical_id;
773 u8 responding;
774 struct _sas_phy *phy;
775 struct list_head sas_port_list;
776 };
777
778
779
780
781
782
783
784 struct _enclosure_node {
785 struct list_head list;
786 Mpi2SasEnclosurePage0_t pg0;
787 };
788
789
790
791
792
793
794 enum reset_type {
795 FORCE_BIG_HAMMER,
796 SOFT_RESET,
797 };
798
799
800
801
802
803
804 struct pcie_sg_list {
805 void *pcie_sgl;
806 dma_addr_t pcie_sgl_dma;
807 };
808
809
810
811
812
813
814
815 struct chain_tracker {
816 void *chain_buffer;
817 dma_addr_t chain_buffer_dma;
818 };
819
820 struct chain_lookup {
821 struct chain_tracker *chains_per_smid;
822 atomic_t chain_offset;
823 };
824
825
826
827
828
829
830
831
832
833 struct scsiio_tracker {
834 u16 smid;
835 struct scsi_cmnd *scmd;
836 u8 cb_idx;
837 u8 direct_io;
838 struct pcie_sg_list pcie_sg_list;
839 struct list_head chain_list;
840 u16 msix_io;
841 };
842
843
844
845
846
847
848
849 struct request_tracker {
850 u16 smid;
851 u8 cb_idx;
852 struct list_head tracker_list;
853 };
854
855
856
857
858
859
860 struct _tr_list {
861 struct list_head list;
862 u16 handle;
863 u16 state;
864 };
865
866
867
868
869
870 struct _sc_list {
871 struct list_head list;
872 u16 handle;
873 };
874
875
876
877
878
879
880 struct _event_ack_list {
881 struct list_head list;
882 U16 Event;
883 U32 EventContext;
884 };
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900 struct adapter_reply_queue {
901 struct MPT3SAS_ADAPTER *ioc;
902 u8 msix_index;
903 u32 reply_post_host_index;
904 Mpi2ReplyDescriptorsUnion_t *reply_post_free;
905 char name[MPT_NAME_LENGTH];
906 atomic_t busy;
907 u32 os_irq;
908 struct irq_poll irqpoll;
909 bool irq_poll_scheduled;
910 bool irq_line_enable;
911 struct list_head list;
912 };
913
914 typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
915
916
917 typedef int (*MPT_BUILD_SG_SCMD)(struct MPT3SAS_ADAPTER *ioc,
918 struct scsi_cmnd *scmd, u16 smid, struct _pcie_device *pcie_device);
919 typedef void (*MPT_BUILD_SG)(struct MPT3SAS_ADAPTER *ioc, void *psge,
920 dma_addr_t data_out_dma, size_t data_out_sz,
921 dma_addr_t data_in_dma, size_t data_in_sz);
922 typedef void (*MPT_BUILD_ZERO_LEN_SGE)(struct MPT3SAS_ADAPTER *ioc,
923 void *paddr);
924
925
926 typedef void (*NVME_BUILD_PRP)(struct MPT3SAS_ADAPTER *ioc, u16 smid,
927 Mpi26NVMeEncapsulatedRequest_t *nvme_encap_request,
928 dma_addr_t data_out_dma, size_t data_out_sz, dma_addr_t data_in_dma,
929 size_t data_in_sz);
930
931
932 typedef void (*PUT_SMID_IO_FP_HIP) (struct MPT3SAS_ADAPTER *ioc, u16 smid,
933 u16 funcdep);
934 typedef void (*PUT_SMID_DEFAULT) (struct MPT3SAS_ADAPTER *ioc, u16 smid);
935 typedef u32 (*BASE_READ_REG) (const volatile void __iomem *addr);
936
937
938
939
940 typedef u8 (*GET_MSIX_INDEX) (struct MPT3SAS_ADAPTER *ioc,
941 struct scsi_cmnd *scmd);
942
943
944 union mpi3_version_union {
945 MPI2_VERSION_STRUCT Struct;
946 u32 Word;
947 };
948
949 struct mpt3sas_facts {
950 u16 MsgVersion;
951 u16 HeaderVersion;
952 u8 IOCNumber;
953 u8 VP_ID;
954 u8 VF_ID;
955 u16 IOCExceptions;
956 u16 IOCStatus;
957 u32 IOCLogInfo;
958 u8 MaxChainDepth;
959 u8 WhoInit;
960 u8 NumberOfPorts;
961 u8 MaxMSIxVectors;
962 u16 RequestCredit;
963 u16 ProductID;
964 u32 IOCCapabilities;
965 union mpi3_version_union FWVersion;
966 u16 IOCRequestFrameSize;
967 u16 IOCMaxChainSegmentSize;
968 u16 MaxInitiators;
969 u16 MaxTargets;
970 u16 MaxSasExpanders;
971 u16 MaxEnclosures;
972 u16 ProtocolFlags;
973 u16 HighPriorityCredit;
974 u16 MaxReplyDescriptorPostQueueDepth;
975 u8 ReplyFrameSize;
976 u8 MaxVolumes;
977 u16 MaxDevHandle;
978 u16 MaxPersistentEntries;
979 u16 MinDevHandle;
980 u8 CurrentHostPageSize;
981 };
982
983 struct mpt3sas_port_facts {
984 u8 PortNumber;
985 u8 VP_ID;
986 u8 VF_ID;
987 u8 PortType;
988 u16 MaxPostedCmdBuffers;
989 };
990
991 struct reply_post_struct {
992 Mpi2ReplyDescriptorsUnion_t *reply_post_free;
993 dma_addr_t reply_post_free_dma;
994 };
995
996 typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct MPT3SAS_ADAPTER *ioc);
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172 struct MPT3SAS_ADAPTER {
1173 struct list_head list;
1174 struct Scsi_Host *shost;
1175 u8 id;
1176 int cpu_count;
1177 char name[MPT_NAME_LENGTH];
1178 char driver_name[MPT_NAME_LENGTH - 8];
1179 char tmp_string[MPT_STRING_LENGTH];
1180 struct pci_dev *pdev;
1181 Mpi2SystemInterfaceRegs_t __iomem *chip;
1182 phys_addr_t chip_phys;
1183 int logging_level;
1184 int fwfault_debug;
1185 u8 ir_firmware;
1186 int bars;
1187 u8 mask_interrupts;
1188 int dma_mask;
1189
1190
1191 char fault_reset_work_q_name[20];
1192 struct workqueue_struct *fault_reset_work_q;
1193 struct delayed_work fault_reset_work;
1194
1195
1196 char firmware_event_name[20];
1197 struct workqueue_struct *firmware_event_thread;
1198 spinlock_t fw_event_lock;
1199 struct list_head fw_event_list;
1200
1201
1202 int aen_event_read_flag;
1203 u8 broadcast_aen_busy;
1204 u16 broadcast_aen_pending;
1205 u8 shost_recovery;
1206 u8 got_task_abort_from_ioctl;
1207
1208 struct mutex reset_in_progress_mutex;
1209 spinlock_t ioc_reset_in_progress_lock;
1210 u8 ioc_link_reset_in_progress;
1211
1212 u8 ignore_loginfos;
1213 u8 remove_host;
1214 u8 pci_error_recovery;
1215 u8 wait_for_discovery_to_complete;
1216 u8 is_driver_loading;
1217 u8 port_enable_failed;
1218 u8 start_scan;
1219 u16 start_scan_failed;
1220
1221 u8 msix_enable;
1222 u16 msix_vector_count;
1223 u8 *cpu_msix_table;
1224 u16 cpu_msix_table_sz;
1225 resource_size_t __iomem **reply_post_host_index;
1226 u32 ioc_reset_count;
1227 MPT3SAS_FLUSH_RUNNING_CMDS schedule_dead_ioc_flush_running_cmds;
1228 u32 non_operational_loop;
1229 atomic64_t total_io_cnt;
1230 atomic64_t high_iops_outstanding;
1231 bool msix_load_balance;
1232 u16 thresh_hold;
1233 u8 high_iops_queues;
1234 u32 drv_support_bitmap;
1235 bool enable_sdev_max_qd;
1236
1237
1238 u8 scsi_io_cb_idx;
1239 u8 tm_cb_idx;
1240 u8 transport_cb_idx;
1241 u8 scsih_cb_idx;
1242 u8 ctl_cb_idx;
1243 u8 base_cb_idx;
1244 u8 port_enable_cb_idx;
1245 u8 config_cb_idx;
1246 u8 tm_tr_cb_idx;
1247 u8 tm_tr_volume_cb_idx;
1248 u8 tm_sas_control_cb_idx;
1249 struct _internal_cmd base_cmds;
1250 struct _internal_cmd port_enable_cmds;
1251 struct _internal_cmd transport_cmds;
1252 struct _internal_cmd scsih_cmds;
1253 struct _internal_cmd tm_cmds;
1254 struct _internal_cmd ctl_cmds;
1255 struct _internal_cmd config_cmds;
1256
1257 MPT_ADD_SGE base_add_sg_single;
1258
1259
1260 MPT_BUILD_SG_SCMD build_sg_scmd;
1261 MPT_BUILD_SG build_sg;
1262 MPT_BUILD_ZERO_LEN_SGE build_zero_len_sge;
1263 u16 sge_size_ieee;
1264 u16 hba_mpi_version_belonged;
1265
1266
1267 MPT_BUILD_SG build_sg_mpi;
1268 MPT_BUILD_ZERO_LEN_SGE build_zero_len_sge_mpi;
1269
1270
1271 NVME_BUILD_PRP build_nvme_prp;
1272
1273
1274 u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
1275 u32 event_context;
1276 void *event_log;
1277 u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
1278
1279 u8 tm_custom_handling;
1280 u8 nvme_abort_timeout;
1281
1282
1283
1284 struct mpt3sas_facts facts;
1285 struct mpt3sas_facts prev_fw_facts;
1286 struct mpt3sas_port_facts *pfacts;
1287 Mpi2ManufacturingPage0_t manu_pg0;
1288 struct Mpi2ManufacturingPage10_t manu_pg10;
1289 struct Mpi2ManufacturingPage11_t manu_pg11;
1290 Mpi2BiosPage2_t bios_pg2;
1291 Mpi2BiosPage3_t bios_pg3;
1292 Mpi2IOCPage8_t ioc_pg8;
1293 Mpi2IOUnitPage0_t iounit_pg0;
1294 Mpi2IOUnitPage1_t iounit_pg1;
1295 Mpi2IOUnitPage8_t iounit_pg8;
1296 Mpi2IOCPage1_t ioc_pg1_copy;
1297
1298 struct _boot_device req_boot_device;
1299 struct _boot_device req_alt_boot_device;
1300 struct _boot_device current_boot_device;
1301
1302
1303 struct _sas_node sas_hba;
1304 struct list_head sas_expander_list;
1305 struct list_head enclosure_list;
1306 spinlock_t sas_node_lock;
1307 struct list_head sas_device_list;
1308 struct list_head sas_device_init_list;
1309 spinlock_t sas_device_lock;
1310 struct list_head pcie_device_list;
1311 struct list_head pcie_device_init_list;
1312 spinlock_t pcie_device_lock;
1313
1314 struct list_head raid_device_list;
1315 spinlock_t raid_device_lock;
1316 u8 io_missing_delay;
1317 u16 device_missing_delay;
1318 int sas_id;
1319 int pcie_target_id;
1320
1321 void *blocking_handles;
1322 void *pd_handles;
1323 u16 pd_handles_sz;
1324
1325 void *pend_os_device_add;
1326 u16 pend_os_device_add_sz;
1327
1328
1329 u16 config_page_sz;
1330 void *config_page;
1331 dma_addr_t config_page_dma;
1332 void *config_vaddr;
1333
1334
1335 u16 hba_queue_depth;
1336 u16 sge_size;
1337 u16 scsiio_depth;
1338 u16 request_sz;
1339 u8 *request;
1340 dma_addr_t request_dma;
1341 u32 request_dma_sz;
1342 struct pcie_sg_list *pcie_sg_lookup;
1343 spinlock_t scsi_lookup_lock;
1344 int pending_io_count;
1345 wait_queue_head_t reset_wq;
1346
1347
1348 struct dma_pool *pcie_sgl_dma_pool;
1349
1350 u32 page_size;
1351
1352
1353 struct chain_lookup *chain_lookup;
1354 struct list_head free_chain_list;
1355 struct dma_pool *chain_dma_pool;
1356 ulong chain_pages;
1357 u16 max_sges_in_main_message;
1358 u16 max_sges_in_chain_message;
1359 u16 chains_needed_per_io;
1360 u32 chain_depth;
1361 u16 chain_segment_sz;
1362 u16 chains_per_prp_buffer;
1363
1364
1365 u16 hi_priority_smid;
1366 u8 *hi_priority;
1367 dma_addr_t hi_priority_dma;
1368 u16 hi_priority_depth;
1369 struct request_tracker *hpr_lookup;
1370 struct list_head hpr_free_list;
1371
1372
1373 u16 internal_smid;
1374 u8 *internal;
1375 dma_addr_t internal_dma;
1376 u16 internal_depth;
1377 struct request_tracker *internal_lookup;
1378 struct list_head internal_free_list;
1379
1380
1381 u8 *sense;
1382 dma_addr_t sense_dma;
1383 struct dma_pool *sense_dma_pool;
1384
1385
1386 u16 reply_sz;
1387 u8 *reply;
1388 dma_addr_t reply_dma;
1389 u32 reply_dma_max_address;
1390 u32 reply_dma_min_address;
1391 struct dma_pool *reply_dma_pool;
1392
1393
1394 u16 reply_free_queue_depth;
1395 __le32 *reply_free;
1396 dma_addr_t reply_free_dma;
1397 struct dma_pool *reply_free_dma_pool;
1398 u32 reply_free_host_index;
1399
1400
1401 u16 reply_post_queue_depth;
1402 struct reply_post_struct *reply_post;
1403 u8 rdpq_array_capable;
1404 u8 rdpq_array_enable;
1405 u8 rdpq_array_enable_assigned;
1406 struct dma_pool *reply_post_free_dma_pool;
1407 struct dma_pool *reply_post_free_array_dma_pool;
1408 Mpi2IOCInitRDPQArrayEntry *reply_post_free_array;
1409 dma_addr_t reply_post_free_array_dma;
1410 u8 reply_queue_count;
1411 struct list_head reply_queue_list;
1412
1413 u8 combined_reply_queue;
1414 u8 combined_reply_index_count;
1415 u8 smp_affinity_enable;
1416
1417 resource_size_t **replyPostRegisterIndex;
1418
1419 struct list_head delayed_tr_list;
1420 struct list_head delayed_tr_volume_list;
1421 struct list_head delayed_sc_list;
1422 struct list_head delayed_event_ack_list;
1423 u8 temp_sensors_count;
1424 struct mutex pci_access_mutex;
1425
1426
1427 u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
1428 u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
1429 dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
1430 u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
1431 u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
1432 u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
1433 u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
1434 u32 ring_buffer_offset;
1435 u32 ring_buffer_sz;
1436 u8 is_warpdrive;
1437 u8 is_mcpu_endpoint;
1438 u8 hide_ir_msg;
1439 u8 mfg_pg10_hide_flag;
1440 u8 hide_drives;
1441 spinlock_t diag_trigger_lock;
1442 u8 diag_trigger_active;
1443 u8 atomic_desc_capable;
1444 BASE_READ_REG base_readl;
1445 struct SL_WH_MASTER_TRIGGER_T diag_trigger_master;
1446 struct SL_WH_EVENT_TRIGGERS_T diag_trigger_event;
1447 struct SL_WH_SCSI_TRIGGERS_T diag_trigger_scsi;
1448 struct SL_WH_MPI_TRIGGERS_T diag_trigger_mpi;
1449 void *device_remove_in_progress;
1450 u16 device_remove_in_progress_sz;
1451 u8 is_gen35_ioc;
1452 u8 is_aero_ioc;
1453 PUT_SMID_IO_FP_HIP put_smid_scsi_io;
1454 PUT_SMID_IO_FP_HIP put_smid_fast_path;
1455 PUT_SMID_IO_FP_HIP put_smid_hi_priority;
1456 PUT_SMID_DEFAULT put_smid_default;
1457 GET_MSIX_INDEX get_msix_index_for_smlio;
1458 };
1459
1460 #define MPT_DRV_SUPPORT_BITMAP_MEMMOVE 0x00000001
1461
1462 typedef u8 (*MPT_CALLBACK)(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1463 u32 reply);
1464
1465
1466
1467 extern struct list_head mpt3sas_ioc_list;
1468 extern char driver_name[MPT_NAME_LENGTH];
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479 extern spinlock_t gioc_lock;
1480
1481 void mpt3sas_base_start_watchdog(struct MPT3SAS_ADAPTER *ioc);
1482 void mpt3sas_base_stop_watchdog(struct MPT3SAS_ADAPTER *ioc);
1483
1484 int mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc);
1485 void mpt3sas_base_detach(struct MPT3SAS_ADAPTER *ioc);
1486 int mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc);
1487 void mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc);
1488 void mpt3sas_free_enclosure_list(struct MPT3SAS_ADAPTER *ioc);
1489 int mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc,
1490 enum reset_type type);
1491
1492 void *mpt3sas_base_get_msg_frame(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1493 void *mpt3sas_base_get_sense_buffer(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1494 __le32 mpt3sas_base_get_sense_buffer_dma(struct MPT3SAS_ADAPTER *ioc,
1495 u16 smid);
1496 void *mpt3sas_base_get_pcie_sgl(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1497 dma_addr_t mpt3sas_base_get_pcie_sgl_dma(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1498 void mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc);
1499
1500 void mpt3sas_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid,
1501 u16 handle);
1502 void mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid,
1503 u16 msix_task);
1504 void mpt3sas_base_put_smid_nvme_encap(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1505 void mpt3sas_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1506
1507 u16 mpt3sas_base_get_smid_hpr(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx);
1508 u16 mpt3sas_base_get_smid_scsiio(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx,
1509 struct scsi_cmnd *scmd);
1510 void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc,
1511 struct scsiio_tracker *st);
1512
1513 u16 mpt3sas_base_get_smid(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx);
1514 void mpt3sas_base_free_smid(struct MPT3SAS_ADAPTER *ioc, u16 smid);
1515 void mpt3sas_base_initialize_callback_handler(void);
1516 u8 mpt3sas_base_register_callback_handler(MPT_CALLBACK cb_func);
1517 void mpt3sas_base_release_callback_handler(u8 cb_idx);
1518
1519 u8 mpt3sas_base_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1520 u32 reply);
1521 u8 mpt3sas_port_enable_done(struct MPT3SAS_ADAPTER *ioc, u16 smid,
1522 u8 msix_index, u32 reply);
1523 void *mpt3sas_base_get_reply_virt_addr(struct MPT3SAS_ADAPTER *ioc,
1524 u32 phys_addr);
1525
1526 u32 mpt3sas_base_get_iocstate(struct MPT3SAS_ADAPTER *ioc, int cooked);
1527
1528 void mpt3sas_base_fault_info(struct MPT3SAS_ADAPTER *ioc , u16 fault_code);
1529 int mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc,
1530 Mpi2SasIoUnitControlReply_t *mpi_reply,
1531 Mpi2SasIoUnitControlRequest_t *mpi_request);
1532 int mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc,
1533 Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
1534
1535 void mpt3sas_base_validate_event_type(struct MPT3SAS_ADAPTER *ioc,
1536 u32 *event_type);
1537
1538 void mpt3sas_halt_firmware(struct MPT3SAS_ADAPTER *ioc);
1539
1540 void mpt3sas_base_update_missing_delay(struct MPT3SAS_ADAPTER *ioc,
1541 u16 device_missing_delay, u8 io_missing_delay);
1542
1543 int mpt3sas_port_enable(struct MPT3SAS_ADAPTER *ioc);
1544
1545 void
1546 mpt3sas_wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc);
1547
1548 u8 mpt3sas_base_check_cmd_timeout(struct MPT3SAS_ADAPTER *ioc,
1549 u8 status, void *mpi_request, int sz);
1550 int mpt3sas_wait_for_ioc(struct MPT3SAS_ADAPTER *ioc, int wait_count);
1551
1552
1553 struct scsi_cmnd *mpt3sas_scsih_scsi_lookup_get(struct MPT3SAS_ADAPTER *ioc,
1554 u16 smid);
1555 u8 mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
1556 u32 reply);
1557 void mpt3sas_scsih_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
1558 void mpt3sas_scsih_after_reset_handler(struct MPT3SAS_ADAPTER *ioc);
1559 void mpt3sas_scsih_reset_done_handler(struct MPT3SAS_ADAPTER *ioc);
1560
1561 int mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, u64 lun,
1562 u8 type, u16 smid_task, u16 msix_task, u8 timeout, u8 tr_method);
1563 int mpt3sas_scsih_issue_locked_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle,
1564 u64 lun, u8 type, u16 smid_task, u16 msix_task,
1565 u8 timeout, u8 tr_method);
1566
1567 void mpt3sas_scsih_set_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle);
1568 void mpt3sas_scsih_clear_tm_flag(struct MPT3SAS_ADAPTER *ioc, u16 handle);
1569 void mpt3sas_expander_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
1570 void mpt3sas_device_remove_by_sas_address(struct MPT3SAS_ADAPTER *ioc,
1571 u64 sas_address);
1572 u8 mpt3sas_check_for_pending_internal_cmds(struct MPT3SAS_ADAPTER *ioc,
1573 u16 smid);
1574
1575 struct _sas_node *mpt3sas_scsih_expander_find_by_handle(
1576 struct MPT3SAS_ADAPTER *ioc, u16 handle);
1577 struct _sas_node *mpt3sas_scsih_expander_find_by_sas_address(
1578 struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
1579 struct _sas_device *mpt3sas_get_sdev_by_addr(
1580 struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
1581 struct _sas_device *__mpt3sas_get_sdev_by_addr(
1582 struct MPT3SAS_ADAPTER *ioc, u64 sas_address);
1583 struct _sas_device *mpt3sas_get_sdev_by_handle(struct MPT3SAS_ADAPTER *ioc,
1584 u16 handle);
1585 struct _pcie_device *mpt3sas_get_pdev_by_handle(struct MPT3SAS_ADAPTER *ioc,
1586 u16 handle);
1587
1588 void mpt3sas_port_enable_complete(struct MPT3SAS_ADAPTER *ioc);
1589 struct _raid_device *
1590 mpt3sas_raid_device_find_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle);
1591 void mpt3sas_scsih_change_queue_depth(struct scsi_device *sdev, int qdepth);
1592
1593
1594 u8 mpt3sas_config_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1595 u32 reply);
1596 int mpt3sas_config_get_number_hba_phys(struct MPT3SAS_ADAPTER *ioc,
1597 u8 *num_phys);
1598 int mpt3sas_config_get_manufacturing_pg0(struct MPT3SAS_ADAPTER *ioc,
1599 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
1600 int mpt3sas_config_get_manufacturing_pg7(struct MPT3SAS_ADAPTER *ioc,
1601 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage7_t *config_page,
1602 u16 sz);
1603 int mpt3sas_config_get_manufacturing_pg10(struct MPT3SAS_ADAPTER *ioc,
1604 Mpi2ConfigReply_t *mpi_reply,
1605 struct Mpi2ManufacturingPage10_t *config_page);
1606
1607 int mpt3sas_config_get_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc,
1608 Mpi2ConfigReply_t *mpi_reply,
1609 struct Mpi2ManufacturingPage11_t *config_page);
1610 int mpt3sas_config_set_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc,
1611 Mpi2ConfigReply_t *mpi_reply,
1612 struct Mpi2ManufacturingPage11_t *config_page);
1613
1614 int mpt3sas_config_get_bios_pg2(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1615 *mpi_reply, Mpi2BiosPage2_t *config_page);
1616 int mpt3sas_config_get_bios_pg3(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1617 *mpi_reply, Mpi2BiosPage3_t *config_page);
1618 int mpt3sas_config_get_iounit_pg0(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1619 *mpi_reply, Mpi2IOUnitPage0_t *config_page);
1620 int mpt3sas_config_get_sas_device_pg0(struct MPT3SAS_ADAPTER *ioc,
1621 Mpi2ConfigReply_t *mpi_reply, Mpi2SasDevicePage0_t *config_page,
1622 u32 form, u32 handle);
1623 int mpt3sas_config_get_sas_device_pg1(struct MPT3SAS_ADAPTER *ioc,
1624 Mpi2ConfigReply_t *mpi_reply, Mpi2SasDevicePage1_t *config_page,
1625 u32 form, u32 handle);
1626 int mpt3sas_config_get_pcie_device_pg0(struct MPT3SAS_ADAPTER *ioc,
1627 Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage0_t *config_page,
1628 u32 form, u32 handle);
1629 int mpt3sas_config_get_pcie_device_pg2(struct MPT3SAS_ADAPTER *ioc,
1630 Mpi2ConfigReply_t *mpi_reply, Mpi26PCIeDevicePage2_t *config_page,
1631 u32 form, u32 handle);
1632 int mpt3sas_config_get_sas_iounit_pg0(struct MPT3SAS_ADAPTER *ioc,
1633 Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage0_t *config_page,
1634 u16 sz);
1635 int mpt3sas_config_get_iounit_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1636 *mpi_reply, Mpi2IOUnitPage1_t *config_page);
1637 int mpt3sas_config_get_iounit_pg3(struct MPT3SAS_ADAPTER *ioc,
1638 Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage3_t *config_page, u16 sz);
1639 int mpt3sas_config_set_iounit_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1640 *mpi_reply, Mpi2IOUnitPage1_t *config_page);
1641 int mpt3sas_config_get_iounit_pg8(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1642 *mpi_reply, Mpi2IOUnitPage8_t *config_page);
1643 int mpt3sas_config_get_sas_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
1644 Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page,
1645 u16 sz);
1646 int mpt3sas_config_set_sas_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
1647 Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page,
1648 u16 sz);
1649 int mpt3sas_config_get_ioc_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1650 *mpi_reply, Mpi2IOCPage1_t *config_page);
1651 int mpt3sas_config_set_ioc_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1652 *mpi_reply, Mpi2IOCPage1_t *config_page);
1653 int mpt3sas_config_get_ioc_pg8(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1654 *mpi_reply, Mpi2IOCPage8_t *config_page);
1655 int mpt3sas_config_get_expander_pg0(struct MPT3SAS_ADAPTER *ioc,
1656 Mpi2ConfigReply_t *mpi_reply, Mpi2ExpanderPage0_t *config_page,
1657 u32 form, u32 handle);
1658 int mpt3sas_config_get_expander_pg1(struct MPT3SAS_ADAPTER *ioc,
1659 Mpi2ConfigReply_t *mpi_reply, Mpi2ExpanderPage1_t *config_page,
1660 u32 phy_number, u16 handle);
1661 int mpt3sas_config_get_enclosure_pg0(struct MPT3SAS_ADAPTER *ioc,
1662 Mpi2ConfigReply_t *mpi_reply, Mpi2SasEnclosurePage0_t *config_page,
1663 u32 form, u32 handle);
1664 int mpt3sas_config_get_phy_pg0(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1665 *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
1666 int mpt3sas_config_get_phy_pg1(struct MPT3SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1667 *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
1668 int mpt3sas_config_get_raid_volume_pg1(struct MPT3SAS_ADAPTER *ioc,
1669 Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form,
1670 u32 handle);
1671 int mpt3sas_config_get_number_pds(struct MPT3SAS_ADAPTER *ioc, u16 handle,
1672 u8 *num_pds);
1673 int mpt3sas_config_get_raid_volume_pg0(struct MPT3SAS_ADAPTER *ioc,
1674 Mpi2ConfigReply_t *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form,
1675 u32 handle, u16 sz);
1676 int mpt3sas_config_get_phys_disk_pg0(struct MPT3SAS_ADAPTER *ioc,
1677 Mpi2ConfigReply_t *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page,
1678 u32 form, u32 form_specific);
1679 int mpt3sas_config_get_volume_handle(struct MPT3SAS_ADAPTER *ioc, u16 pd_handle,
1680 u16 *volume_handle);
1681 int mpt3sas_config_get_volume_wwid(struct MPT3SAS_ADAPTER *ioc,
1682 u16 volume_handle, u64 *wwid);
1683
1684
1685 extern struct device_attribute *mpt3sas_host_attrs[];
1686 extern struct device_attribute *mpt3sas_dev_attrs[];
1687 void mpt3sas_ctl_init(ushort hbas_to_enumerate);
1688 void mpt3sas_ctl_exit(ushort hbas_to_enumerate);
1689 u8 mpt3sas_ctl_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1690 u32 reply);
1691 void mpt3sas_ctl_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
1692 void mpt3sas_ctl_after_reset_handler(struct MPT3SAS_ADAPTER *ioc);
1693 void mpt3sas_ctl_reset_done_handler(struct MPT3SAS_ADAPTER *ioc);
1694 u8 mpt3sas_ctl_event_callback(struct MPT3SAS_ADAPTER *ioc,
1695 u8 msix_index, u32 reply);
1696 void mpt3sas_ctl_add_to_event_log(struct MPT3SAS_ADAPTER *ioc,
1697 Mpi2EventNotificationReply_t *mpi_reply);
1698
1699 void mpt3sas_enable_diag_buffer(struct MPT3SAS_ADAPTER *ioc,
1700 u8 bits_to_register);
1701 int mpt3sas_send_diag_release(struct MPT3SAS_ADAPTER *ioc, u8 buffer_type,
1702 u8 *issue_reset);
1703
1704
1705 extern struct scsi_transport_template *mpt3sas_transport_template;
1706 u8 mpt3sas_transport_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1707 u32 reply);
1708 struct _sas_port *mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc,
1709 u16 handle, u64 sas_address);
1710 void mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address,
1711 u64 sas_address_parent);
1712 int mpt3sas_transport_add_host_phy(struct MPT3SAS_ADAPTER *ioc, struct _sas_phy
1713 *mpt3sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
1714 int mpt3sas_transport_add_expander_phy(struct MPT3SAS_ADAPTER *ioc,
1715 struct _sas_phy *mpt3sas_phy, Mpi2ExpanderPage1_t expander_pg1,
1716 struct device *parent_dev);
1717 void mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc,
1718 u64 sas_address, u16 handle, u8 phy_number, u8 link_rate);
1719 extern struct sas_function_template mpt3sas_transport_functions;
1720 extern struct scsi_transport_template *mpt3sas_transport_template;
1721
1722 void mpt3sas_send_trigger_data_event(struct MPT3SAS_ADAPTER *ioc,
1723 struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
1724 void mpt3sas_process_trigger_data(struct MPT3SAS_ADAPTER *ioc,
1725 struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
1726 void mpt3sas_trigger_master(struct MPT3SAS_ADAPTER *ioc,
1727 u32 tigger_bitmask);
1728 void mpt3sas_trigger_event(struct MPT3SAS_ADAPTER *ioc, u16 event,
1729 u16 log_entry_qualifier);
1730 void mpt3sas_trigger_scsi(struct MPT3SAS_ADAPTER *ioc, u8 sense_key,
1731 u8 asc, u8 ascq);
1732 void mpt3sas_trigger_mpi(struct MPT3SAS_ADAPTER *ioc, u16 ioc_status,
1733 u32 loginfo);
1734
1735
1736 u8 mpt3sas_get_num_volumes(struct MPT3SAS_ADAPTER *ioc);
1737 void mpt3sas_init_warpdrive_properties(struct MPT3SAS_ADAPTER *ioc,
1738 struct _raid_device *raid_device);
1739 void
1740 mpt3sas_setup_direct_io(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
1741 struct _raid_device *raid_device, Mpi25SCSIIORequest_t *mpi_request);
1742
1743
1744 bool scsih_ncq_prio_supp(struct scsi_device *sdev);
1745
1746
1747
1748
1749
1750
1751
1752
1753 static inline int
1754 mpt3sas_scsih_is_pcie_scsi_device(u32 device_info)
1755 {
1756 if ((device_info &
1757 MPI26_PCIE_DEVINFO_MASK_DEVICE_TYPE) == MPI26_PCIE_DEVINFO_SCSI)
1758 return 1;
1759 else
1760 return 0;
1761 }
1762 #endif