2 * This is the Fusion MPT base driver providing common API layer interface
3 * for access to MPT (Message Passing Technology) firmware.
5 * This code is based on drivers/scsi/mpt2sas/mpt2_base.h
6 * Copyright (C) 2007-2010 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com)
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
21 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
22 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
23 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
24 * solely responsible for determining the appropriateness of using and
25 * distributing the Program and assumes all risks associated with its
26 * exercise of rights under this Agreement, including but not limited to
27 * the risks and costs of program errors, damage to or loss of data,
28 * programs or equipment, and unavailability or interruption of operations.
30 * DISCLAIMER OF LIABILITY
31 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
32 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
34 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
35 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
36 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
37 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
39 * You should have received a copy of the GNU General Public License
40 * along with this program; if not, write to the Free Software
41 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
45 #ifndef MPT2SAS_BASE_H_INCLUDED
46 #define MPT2SAS_BASE_H_INCLUDED
48 #include "mpi/mpi2_type.h"
50 #include "mpi/mpi2_ioc.h"
51 #include "mpi/mpi2_cnfg.h"
52 #include "mpi/mpi2_init.h"
53 #include "mpi/mpi2_raid.h"
54 #include "mpi/mpi2_tool.h"
55 #include "mpi/mpi2_sas.h"
57 #include <scsi/scsi.h>
58 #include <scsi/scsi_cmnd.h>
59 #include <scsi/scsi_device.h>
60 #include <scsi/scsi_host.h>
61 #include <scsi/scsi_tcq.h>
62 #include <scsi/scsi_transport_sas.h>
63 #include <scsi/scsi_dbg.h>
64 #include <scsi/scsi_eh.h>
66 #include "mpt2sas_debug.h"
68 /* driver versioning info */
69 #define MPT2SAS_DRIVER_NAME "mpt2sas"
70 #define MPT2SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>"
71 #define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver"
72 #define MPT2SAS_DRIVER_VERSION "08.100.00.02"
73 #define MPT2SAS_MAJOR_VERSION 08
74 #define MPT2SAS_MINOR_VERSION 100
75 #define MPT2SAS_BUILD_VERSION 00
76 #define MPT2SAS_RELEASE_VERSION 02
79 * Set MPT2SAS_SG_DEPTH value based on user input.
81 #ifdef CONFIG_SCSI_MPT2SAS_MAX_SGE
82 #if CONFIG_SCSI_MPT2SAS_MAX_SGE < 16
83 #define MPT2SAS_SG_DEPTH 16
84 #elif CONFIG_SCSI_MPT2SAS_MAX_SGE > 128
85 #define MPT2SAS_SG_DEPTH 128
87 #define MPT2SAS_SG_DEPTH CONFIG_SCSI_MPT2SAS_MAX_SGE
90 #define MPT2SAS_SG_DEPTH 128 /* MAX_HW_SEGMENTS */
97 #define MPT2SAS_SATA_QUEUE_DEPTH 32
98 #define MPT2SAS_SAS_QUEUE_DEPTH 254
99 #define MPT2SAS_RAID_QUEUE_DEPTH 128
101 #define MPT_NAME_LENGTH 32 /* generic length of strings */
102 #define MPT_STRING_LENGTH 64
104 #define MPT_MAX_CALLBACKS 16
110 #define INTERNAL_CMDS_COUNT 10 /* reserved cmds */
112 #define MPI2_HIM_MASK 0xFFFFFFFF /* mask every bit*/
114 #define MPT2SAS_INVALID_DEVICE_HANDLE 0xFFFF
120 #define MPT2_IOC_PRE_RESET 1 /* prior to host reset */
121 #define MPT2_IOC_AFTER_RESET 2 /* just after host reset */
122 #define MPT2_IOC_DONE_RESET 3 /* links re-initialized */
127 #define MPT2SAS_FMT "%s: "
128 #define MPT2SAS_INFO_FMT KERN_INFO MPT2SAS_FMT
129 #define MPT2SAS_NOTE_FMT KERN_NOTICE MPT2SAS_FMT
130 #define MPT2SAS_WARN_FMT KERN_WARNING MPT2SAS_FMT
131 #define MPT2SAS_ERR_FMT KERN_ERR MPT2SAS_FMT
136 #define MPT2SAS_DELL_BRANDING_SIZE 32
138 #define MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING "Dell 6Gbps SAS HBA"
139 #define MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING "Dell PERC H200 Adapter"
140 #define MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING "Dell PERC H200 Integrated"
141 #define MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING "Dell PERC H200 Modular"
142 #define MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING "Dell PERC H200 Embedded"
143 #define MPT2SAS_DELL_PERC_H200_BRANDING "Dell PERC H200"
144 #define MPT2SAS_DELL_6GBPS_SAS_BRANDING "Dell 6Gbps SAS"
149 #define MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID 0x1F1C
150 #define MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID 0x1F1D
151 #define MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID 0x1F1E
152 #define MPT2SAS_DELL_PERC_H200_MODULAR_SSDID 0x1F1F
153 #define MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID 0x1F20
154 #define MPT2SAS_DELL_PERC_H200_SSDID 0x1F21
155 #define MPT2SAS_DELL_6GBPS_SAS_SSDID 0x1F22
160 #define MPT2SAS_INTEL_RMS2LL080_BRANDING \
161 "Intel Integrated RAID Module RMS2LL080"
162 #define MPT2SAS_INTEL_RMS2LL040_BRANDING \
163 "Intel Integrated RAID Module RMS2LL040"
168 #define MPT2SAS_INTEL_RMS2LL080_SSDID 0x350E
169 #define MPT2SAS_INTEL_RMS2LL040_SSDID 0x350F
175 #define MPT2SAS_HP_3PAR_SSVID 0x1590
176 #define MPT2SAS_HP_2_4_INTERNAL_BRANDING "HP H220 Host Bus Adapter"
177 #define MPT2SAS_HP_2_4_EXTERNAL_BRANDING "HP H221 Host Bus Adapter"
178 #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING "HP H222 Host Bus Adapter"
179 #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING "HP H220i Host Bus Adapter"
180 #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING "HP H210i Host Bus Adapter"
185 #define MPT2SAS_HP_2_4_INTERNAL_SSDID 0x0041
186 #define MPT2SAS_HP_2_4_EXTERNAL_SSDID 0x0042
187 #define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_SSDID 0x0043
188 #define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_SSDID 0x0044
189 #define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_SSDID 0x0046
192 * WarpDrive Specific Log codes
195 #define MPT2_WARPDRIVE_LOGENTRY (0x8002)
196 #define MPT2_WARPDRIVE_LC_SSDT (0x41)
197 #define MPT2_WARPDRIVE_LC_SSDLW (0x43)
198 #define MPT2_WARPDRIVE_LC_SSDLF (0x44)
199 #define MPT2_WARPDRIVE_LC_BRMF (0x4D)
202 * per target private data
204 #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01
205 #define MPT_TARGET_FLAGS_VOLUME 0x02
206 #define MPT_TARGET_FLAGS_DELETED 0x04
209 * struct MPT2SAS_TARGET - starget private hostdata
210 * @starget: starget object
211 * @sas_address: target sas address
212 * @raid_device: raid_device pointer to access volume data
213 * @handle: device handle
214 * @num_luns: number luns
215 * @flags: MPT_TARGET_FLAGS_XXX flags
216 * @deleted: target flaged for deletion
217 * @tm_busy: target is busy with TM request.
219 struct MPT2SAS_TARGET
{
220 struct scsi_target
*starget
;
222 struct _raid_device
*raid_device
;
232 * per device private data
234 #define MPT_DEVICE_FLAGS_INIT 0x01
235 #define MPT_DEVICE_TLR_ON 0x02
238 * struct MPT2SAS_DEVICE - sdev private hostdata
239 * @sas_target: starget private hostdata
241 * @flags: MPT_DEVICE_XXX flags
242 * @configured_lun: lun is configured
243 * @block: device is in SDEV_BLOCK state
244 * @tlr_snoop_check: flag used in determining whether to disable TLR
247 /* OEM Identifiers */
248 #define MFG10_OEM_ID_INVALID (0x00000000)
249 #define MFG10_OEM_ID_DELL (0x00000001)
250 #define MFG10_OEM_ID_FSC (0x00000002)
251 #define MFG10_OEM_ID_SUN (0x00000003)
252 #define MFG10_OEM_ID_IBM (0x00000004)
255 #define MFG10_GF0_OCE_DISABLED (0x00000001)
256 #define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002)
257 #define MFG10_GF0_R10_DISPLAY (0x00000004)
258 #define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008)
259 #define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010)
261 /* OEM Specific Flags will come from OEM specific header files */
262 typedef struct _MPI2_CONFIG_PAGE_MAN_10
{
263 MPI2_CONFIG_PAGE_HEADER Header
; /* 00h */
264 U8 OEMIdentifier
; /* 04h */
265 U8 Reserved1
; /* 05h */
266 U16 Reserved2
; /* 08h */
267 U32 Reserved3
; /* 0Ch */
268 U32 GenericFlags0
; /* 10h */
269 U32 GenericFlags1
; /* 14h */
270 U32 Reserved4
; /* 18h */
271 U32 OEMSpecificFlags0
; /* 1Ch */
272 U32 OEMSpecificFlags1
; /* 20h */
273 U32 Reserved5
[18]; /* 24h-60h*/
274 } MPI2_CONFIG_PAGE_MAN_10
,
275 MPI2_POINTER PTR_MPI2_CONFIG_PAGE_MAN_10
,
276 Mpi2ManufacturingPage10_t
, MPI2_POINTER pMpi2ManufacturingPage10_t
;
278 #define MFG_PAGE10_HIDE_SSDS_MASK (0x00000003)
279 #define MFG_PAGE10_HIDE_ALL_DISKS (0x00)
280 #define MFG_PAGE10_EXPOSE_ALL_DISKS (0x01)
281 #define MFG_PAGE10_HIDE_IF_VOL_PRESENT (0x02)
284 struct MPT2SAS_DEVICE
{
285 struct MPT2SAS_TARGET
*sas_target
;
293 #define MPT2_CMD_NOT_USED 0x8000 /* free */
294 #define MPT2_CMD_COMPLETE 0x0001 /* completed */
295 #define MPT2_CMD_PENDING 0x0002 /* pending */
296 #define MPT2_CMD_REPLY_VALID 0x0004 /* reply is valid */
297 #define MPT2_CMD_RESET 0x0008 /* host reset dropped the command */
300 * struct _internal_cmd - internal commands struct
303 * @reply: reply message pointer
305 * @status: MPT2_CMD_XXX status
306 * @smid: system message id
308 struct _internal_cmd
{
310 struct completion done
;
319 * struct _sas_device - attached device information
320 * @list: sas device list
321 * @starget: starget object
322 * @sas_address: device sas address
323 * @device_name: retrieved from the SAS IDENTIFY frame.
324 * @handle: device handle
325 * @sas_address_parent: sas address of parent expander or sas host
326 * @enclosure_handle: enclosure handle
327 * @enclosure_logical_id: enclosure logical identifier
328 * @volume_handle: volume handle (valid when hidden raid member)
329 * @volume_wwid: volume unique identifier
330 * @device_info: bitfield provides detailed info about the device
332 * @channel: target channel
333 * @slot: number number
334 * @phy: phy identifier provided in sas device page 0
335 * @responding: used in _scsih_sas_device_mark_responding
338 struct list_head list
;
339 struct scsi_target
*starget
;
343 u64 sas_address_parent
;
344 u16 enclosure_handle
;
345 u64 enclosure_logical_id
;
357 * struct _raid_device - raid volume link list
358 * @list: sas device list
359 * @starget: starget object
360 * @sdev: scsi device struct (volumes are single lun)
361 * @wwid: unique identifier for the volume
362 * @handle: device handle
363 * @block_size: Block size of the volume
365 * @channel: target channel
366 * @volume_type: the raid level
367 * @device_info: bitfield provides detailed info about the hidden components
368 * @num_pds: number of hidden raid components
369 * @responding: used in _scsih_raid_device_mark_responding
370 * @percent_complete: resync percent complete
371 * @direct_io_enabled: Whether direct io to PDs are allowed or not
372 * @stripe_exponent: X where 2powX is the stripe sz in blocks
373 * @max_lba: Maximum number of LBA in the volume
374 * @stripe_sz: Stripe Size of the volume
375 * @device_info: Device info of the volume member disk
376 * @pd_handle: Array of handles of the physical drives for direct I/O in le16
378 #define MPT_MAX_WARPDRIVE_PDS 8
379 struct _raid_device
{
380 struct list_head list
;
381 struct scsi_target
*starget
;
382 struct scsi_device
*sdev
;
392 u8 direct_io_enabled
;
397 u16 pd_handle
[MPT_MAX_WARPDRIVE_PDS
];
401 * struct _boot_device - boot device info
402 * @is_raid: flag to indicate whether this is volume
403 * @device: holds pointer for either struct _sas_device or
404 * struct _raid_device
406 struct _boot_device
{
412 * struct _sas_port - wide/narrow sas port information
413 * @port_list: list of ports belonging to expander
414 * @num_phys: number of phys belonging to this port
415 * @remote_identify: attached device identification
416 * @rphy: sas transport rphy object
417 * @port: sas transport wide/narrow port object
418 * @phy_list: _sas_phy list objects belonging to this port
421 struct list_head port_list
;
423 struct sas_identify remote_identify
;
424 struct sas_rphy
*rphy
;
425 struct sas_port
*port
;
426 struct list_head phy_list
;
430 * struct _sas_phy - phy information
431 * @port_siblings: list of phys belonging to a port
432 * @identify: phy identification
433 * @remote_identify: attached device identification
434 * @phy: sas transport phy object
435 * @phy_id: unique phy id
436 * @handle: device handle for this phy
437 * @attached_handle: device handle for attached device
438 * @phy_belongs_to_port: port has been created for this phy
441 struct list_head port_siblings
;
442 struct sas_identify identify
;
443 struct sas_identify remote_identify
;
448 u8 phy_belongs_to_port
;
452 * struct _sas_node - sas_host/expander information
453 * @list: list of expanders
454 * @parent_dev: parent device class
455 * @num_phys: number phys belonging to this sas_host/expander
456 * @sas_address: sas address of this sas_host/expander
457 * @handle: handle for this sas_host/expander
458 * @sas_address_parent: sas address of parent expander or sas host
459 * @enclosure_handle: handle for this a member of an enclosure
460 * @device_info: bitwise defining capabilities of this sas_host/expander
461 * @responding: used in _scsih_expander_device_mark_responding
462 * @phy: a list of phys that make up this sas_host/expander
463 * @sas_port_list: list of ports attached to this sas_host/expander
466 struct list_head list
;
467 struct device
*parent_dev
;
471 u64 sas_address_parent
;
472 u16 enclosure_handle
;
473 u64 enclosure_logical_id
;
475 struct _sas_phy
*phy
;
476 struct list_head sas_port_list
;
480 * enum reset_type - reset state
481 * @FORCE_BIG_HAMMER: issue diagnostic reset
482 * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
490 * struct chain_tracker - firmware chain tracker
491 * @chain_buffer: chain buffer
492 * @chain_buffer_dma: physical address
493 * @tracker_list: list of free request (ioc->free_chain_list)
495 struct chain_tracker
{
497 dma_addr_t chain_buffer_dma
;
498 struct list_head tracker_list
;
502 * struct scsiio_tracker - scsi mf request tracker
503 * @smid: system message id
504 * @scmd: scsi request pointer
505 * @cb_idx: callback index
506 * @direct_io: To indicate whether I/O is direct (WARPDRIVE)
507 * @chain_list: list of chains associated to this IO
508 * @tracker_list: list of free request (ioc->free_list)
510 struct scsiio_tracker
{
512 struct scsi_cmnd
*scmd
;
515 struct list_head chain_list
;
516 struct list_head tracker_list
;
520 * struct request_tracker - firmware request tracker
521 * @smid: system message id
522 * @cb_idx: callback index
523 * @tracker_list: list of free request (ioc->free_list)
525 struct request_tracker
{
528 struct list_head tracker_list
;
532 * struct _tr_list - target reset list
533 * @handle: device handle
534 * @state: state machine
537 struct list_head list
;
542 typedef void (*MPT_ADD_SGE
)(void *paddr
, u32 flags_length
, dma_addr_t dma_addr
);
545 * struct MPT2SAS_ADAPTER - per adapter struct
547 * @shost: shost object
548 * @id: unique adapter id
549 * @pci_irq: irq number
550 * @name: generic ioc string
551 * @tmp_string: tmp string used for logging
552 * @pdev: pci pdev object
553 * @chip: memory mapped register space
554 * @chip_phys: physical addrss prior to mapping
555 * @logging_level: see mpt2sas_debug.h
556 * @fwfault_debug: debuging FW timeouts
557 * @ir_firmware: IR firmware present
558 * @bars: bitmask of BAR's that must be configured
559 * @mask_interrupts: ignore interrupt
560 * @fault_reset_work_q_name: fw fault work queue
561 * @fault_reset_work_q: ""
562 * @fault_reset_work: ""
563 * @firmware_event_name: fw event work queue
564 * @firmware_event_thread: ""
565 * @fw_events_off: flag to turn off fw event handling
567 * @fw_event_list: list of fw events
568 * @aen_event_read_flag: event log was read
569 * @broadcast_aen_busy: broadcast aen waiting to be serviced
570 * @shost_recovery: host reset in progress
571 * @ioc_reset_in_progress_lock:
572 * @ioc_link_reset_in_progress: phy/hard reset in progress
573 * @ignore_loginfos: ignore loginfos during task management
574 * @remove_host: flag for when driver unloads, to avoid sending dev resets
575 * @pci_error_recovery: flag to prevent ioc access until slot reset completes
576 * @wait_for_port_enable_to_complete:
577 * @msix_enable: flag indicating msix is enabled
578 * @msix_vector_count: number msix vectors
579 * @msix_table: virt address to the msix table
580 * @msix_table_backup: backup msix table
581 * @scsi_io_cb_idx: shost generated commands
582 * @tm_cb_idx: task management commands
583 * @scsih_cb_idx: scsih internal commands
584 * @transport_cb_idx: transport internal commands
585 * @ctl_cb_idx: clt internal commands
586 * @base_cb_idx: base internal commands
587 * @config_cb_idx: base internal commands
588 * @tm_tr_cb_idx : device removal target reset handshake
589 * @tm_tr_volume_cb_idx : volume removal target reset
596 * @base_add_sg_single: handler for either 32/64 bit sgl's
597 * @event_type: bits indicating which events to log
598 * @event_context: unique id for each logged event
599 * @event_log: event log pointer
600 * @event_masks: events that are masked
601 * @facts: static facts data
602 * @pfacts: static port facts data
603 * @manu_pg0: static manufacturing page 0
604 * @manu_pg10: static manufacturing page 10
605 * @bios_pg2: static bios page 2
606 * @bios_pg3: static bios page 3
607 * @ioc_pg8: static ioc page 8
608 * @iounit_pg0: static iounit page 0
609 * @iounit_pg1: static iounit page 1
610 * @sas_hba: sas host object
611 * @sas_expander_list: expander object list
613 * @sas_device_list: sas device object list
614 * @sas_device_init_list: sas device object list (used only at init time)
616 * @io_missing_delay: time for IO completed by fw when PDR enabled
617 * @device_missing_delay: time for device missing by fw when PDR enabled
618 * @sas_id : used for setting volume target IDs
619 * @pd_handles : bitmask for PD handles
620 * @pd_handles_sz : size of pd_handle bitmask
621 * @config_page_sz: config page size
622 * @config_page: reserve memory for config page payload
624 * @hba_queue_depth: hba request queue depth
625 * @sge_size: sg element size for either 32/64 bit
626 * @scsiio_depth: SCSI_IO queue depth
627 * @request_sz: per request frame size
628 * @request: pool of request frames
631 * @scsi_lookup: firmware request tracker list
633 * @free_list: free list of request
634 * @chain: pool of chains
638 * @max_sges_in_main_message: number sg elements in main message
639 * @max_sges_in_chain_message: number sg elements per chain
640 * @chains_needed_per_io: max chains per io
641 * @chain_offset_value_for_main_message: location 1st sg in main
642 * @chain_depth: total chains allocated
646 * @hi_priority_depth:
654 * @internal_free_list:
655 * @sense: pool of sense
658 * @reply_depth: hba reply queue depth:
659 * @reply_sz: per reply frame size:
660 * @reply: pool of replys:
663 * @reply_free_queue_depth: reply free depth
664 * @reply_free: pool for reply free queue (32 bit addr)
666 * @reply_free_dma_pool:
667 * @reply_free_host_index: tail index in pool to insert free replys
668 * @reply_post_queue_depth: reply post queue depth
669 * @reply_post_free: pool for reply post (64bit descriptor)
670 * @reply_post_free_dma:
671 * @reply_post_free_dma_pool:
672 * @reply_post_host_index: head index in the pool where FW completes IO
673 * @delayed_tr_list: target reset link list
674 * @delayed_tr_volume_list: volume target reset link list
676 struct MPT2SAS_ADAPTER
{
677 struct list_head list
;
678 struct Scsi_Host
*shost
;
681 char name
[MPT_NAME_LENGTH
];
682 char tmp_string
[MPT_STRING_LENGTH
];
683 struct pci_dev
*pdev
;
684 Mpi2SystemInterfaceRegs_t __iomem
*chip
;
685 resource_size_t chip_phys
;
692 /* fw fault handler */
693 char fault_reset_work_q_name
[20];
694 struct workqueue_struct
*fault_reset_work_q
;
695 struct delayed_work fault_reset_work
;
697 /* fw event handler */
698 char firmware_event_name
[20];
699 struct workqueue_struct
*firmware_event_thread
;
700 spinlock_t fw_event_lock
;
701 struct list_head fw_event_list
;
704 int aen_event_read_flag
;
705 u8 broadcast_aen_busy
;
708 struct mutex reset_in_progress_mutex
;
709 struct completion shost_recovery_done
;
710 spinlock_t ioc_reset_in_progress_lock
;
711 u8 ioc_link_reset_in_progress
;
712 int ioc_reset_in_progress_status
;
716 u8 pci_error_recovery
;
717 u8 wait_for_port_enable_to_complete
;
720 u16 msix_vector_count
;
722 u32
*msix_table_backup
;
725 /* internal commands, callback index */
734 u8 tm_tr_volume_cb_idx
;
735 u8 tm_sas_control_cb_idx
;
736 struct _internal_cmd base_cmds
;
737 struct _internal_cmd transport_cmds
;
738 struct _internal_cmd scsih_cmds
;
739 struct _internal_cmd tm_cmds
;
740 struct _internal_cmd ctl_cmds
;
741 struct _internal_cmd config_cmds
;
743 MPT_ADD_SGE base_add_sg_single
;
746 u32 event_type
[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS
];
749 u32 event_masks
[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS
];
751 /* static config pages */
752 Mpi2IOCFactsReply_t facts
;
753 Mpi2PortFactsReply_t
*pfacts
;
754 Mpi2ManufacturingPage0_t manu_pg0
;
755 Mpi2BiosPage2_t bios_pg2
;
756 Mpi2BiosPage3_t bios_pg3
;
757 Mpi2IOCPage8_t ioc_pg8
;
758 Mpi2IOUnitPage0_t iounit_pg0
;
759 Mpi2IOUnitPage1_t iounit_pg1
;
761 struct _boot_device req_boot_device
;
762 struct _boot_device req_alt_boot_device
;
763 struct _boot_device current_boot_device
;
765 /* sas hba, expander, and device list */
766 struct _sas_node sas_hba
;
767 struct list_head sas_expander_list
;
768 spinlock_t sas_node_lock
;
769 struct list_head sas_device_list
;
770 struct list_head sas_device_init_list
;
771 spinlock_t sas_device_lock
;
772 struct list_head raid_device_list
;
773 spinlock_t raid_device_lock
;
775 u16 device_missing_delay
;
784 dma_addr_t config_page_dma
;
792 dma_addr_t request_dma
;
794 struct scsiio_tracker
*scsi_lookup
;
795 ulong scsi_lookup_pages
;
796 spinlock_t scsi_lookup_lock
;
797 struct list_head free_list
;
798 int pending_io_count
;
799 wait_queue_head_t reset_wq
;
802 struct chain_tracker
*chain_lookup
;
803 struct list_head free_chain_list
;
804 struct dma_pool
*chain_dma_pool
;
806 u16 max_sges_in_main_message
;
807 u16 max_sges_in_chain_message
;
808 u16 chains_needed_per_io
;
809 u16 chain_offset_value_for_main_message
;
812 /* hi-priority queue */
813 u16 hi_priority_smid
;
815 dma_addr_t hi_priority_dma
;
816 u16 hi_priority_depth
;
817 struct request_tracker
*hpr_lookup
;
818 struct list_head hpr_free_list
;
823 dma_addr_t internal_dma
;
825 struct request_tracker
*internal_lookup
;
826 struct list_head internal_free_list
;
830 dma_addr_t sense_dma
;
831 struct dma_pool
*sense_dma_pool
;
836 dma_addr_t reply_dma
;
837 u32 reply_dma_max_address
;
838 u32 reply_dma_min_address
;
839 struct dma_pool
*reply_dma_pool
;
841 /* reply free queue */
842 u16 reply_free_queue_depth
;
844 dma_addr_t reply_free_dma
;
845 struct dma_pool
*reply_free_dma_pool
;
846 u32 reply_free_host_index
;
848 /* reply post queue */
849 u16 reply_post_queue_depth
;
850 Mpi2ReplyDescriptorsUnion_t
*reply_post_free
;
851 dma_addr_t reply_post_free_dma
;
852 struct dma_pool
*reply_post_free_dma_pool
;
853 u32 reply_post_host_index
;
855 struct list_head delayed_tr_list
;
856 struct list_head delayed_tr_volume_list
;
858 /* diag buffer support */
859 u8
*diag_buffer
[MPI2_DIAG_BUF_TYPE_COUNT
];
860 u32 diag_buffer_sz
[MPI2_DIAG_BUF_TYPE_COUNT
];
861 dma_addr_t diag_buffer_dma
[MPI2_DIAG_BUF_TYPE_COUNT
];
862 u8 diag_buffer_status
[MPI2_DIAG_BUF_TYPE_COUNT
];
863 u32 unique_id
[MPI2_DIAG_BUF_TYPE_COUNT
];
864 Mpi2ManufacturingPage10_t manu_pg10
;
865 u32 product_specific
[MPI2_DIAG_BUF_TYPE_COUNT
][23];
866 u32 diagnostic_flags
[MPI2_DIAG_BUF_TYPE_COUNT
];
867 u32 ring_buffer_offset
;
871 u8 mfg_pg10_hide_flag
;
876 typedef u8 (*MPT_CALLBACK
)(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
, u8 msix_index
,
880 /* base shared API */
881 extern struct list_head mpt2sas_ioc_list
;
882 void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER
*ioc
);
883 void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER
*ioc
);
885 int mpt2sas_base_attach(struct MPT2SAS_ADAPTER
*ioc
);
886 void mpt2sas_base_detach(struct MPT2SAS_ADAPTER
*ioc
);
887 int mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER
*ioc
);
888 void mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER
*ioc
);
889 int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER
*ioc
, int sleep_flag
,
890 enum reset_type type
);
892 void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
);
893 void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
);
894 void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER
*ioc
, void *paddr
);
895 __le32
mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER
*ioc
,
898 /* hi-priority queue */
899 u16
mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER
*ioc
, u8 cb_idx
);
900 u16
mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER
*ioc
, u8 cb_idx
,
901 struct scsi_cmnd
*scmd
);
903 u16
mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER
*ioc
, u8 cb_idx
);
904 void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
);
905 void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
,
907 void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
);
908 void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
,
910 void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
);
911 void mpt2sas_base_initialize_callback_handler(void);
912 u8
mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func
);
913 void mpt2sas_base_release_callback_handler(u8 cb_idx
);
915 u8
mpt2sas_base_done(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
, u8 msix_index
,
917 void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER
*ioc
, u32 phys_addr
);
919 u32
mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER
*ioc
, int cooked
);
921 void mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER
*ioc
, u16 fault_code
);
922 int mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER
*ioc
,
923 Mpi2SasIoUnitControlReply_t
*mpi_reply
, Mpi2SasIoUnitControlRequest_t
925 int mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER
*ioc
,
926 Mpi2SepReply_t
*mpi_reply
, Mpi2SepRequest_t
*mpi_request
);
927 void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER
*ioc
, u32
*event_type
);
929 void mpt2sas_halt_firmware(struct MPT2SAS_ADAPTER
*ioc
);
931 /* scsih shared API */
932 u8
mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER
*ioc
, u8 msix_index
,
934 int mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER
*ioc
, u16 handle
,
935 uint channel
, uint id
, uint lun
, u8 type
, u16 smid_task
,
936 ulong timeout
, struct scsi_cmnd
*scmd
);
937 void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER
*ioc
, u16 handle
);
938 void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER
*ioc
, u16 handle
);
939 void mpt2sas_expander_remove(struct MPT2SAS_ADAPTER
*ioc
, u64 sas_address
);
940 void mpt2sas_device_remove(struct MPT2SAS_ADAPTER
*ioc
, u64 sas_address
);
941 struct _sas_node
*mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER
*ioc
,
943 struct _sas_node
*mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER
944 *ioc
, u64 sas_address
);
945 struct _sas_device
*mpt2sas_scsih_sas_device_find_by_sas_address(
946 struct MPT2SAS_ADAPTER
*ioc
, u64 sas_address
);
948 void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER
*ioc
, int reset_phase
);
950 /* config shared API */
951 u8
mpt2sas_config_done(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
, u8 msix_index
,
953 int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER
*ioc
, u8
*num_phys
);
954 int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER
*ioc
,
955 Mpi2ConfigReply_t
*mpi_reply
, Mpi2ManufacturingPage0_t
*config_page
);
956 int mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER
*ioc
,
957 Mpi2ConfigReply_t
*mpi_reply
, Mpi2ManufacturingPage10_t
*config_page
);
958 int mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
959 *mpi_reply
, Mpi2BiosPage2_t
*config_page
);
960 int mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
961 *mpi_reply
, Mpi2BiosPage3_t
*config_page
);
962 int mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
963 *mpi_reply
, Mpi2IOUnitPage0_t
*config_page
);
964 int mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
965 *mpi_reply
, Mpi2SasDevicePage0_t
*config_page
, u32 form
, u32 handle
);
966 int mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
967 *mpi_reply
, Mpi2SasDevicePage1_t
*config_page
, u32 form
, u32 handle
);
968 int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
969 *mpi_reply
, Mpi2SasIOUnitPage0_t
*config_page
, u16 sz
);
970 int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
971 *mpi_reply
, Mpi2IOUnitPage1_t
*config_page
);
972 int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
973 *mpi_reply
, Mpi2IOUnitPage1_t
*config_page
);
974 int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
975 *mpi_reply
, Mpi2SasIOUnitPage1_t
*config_page
, u16 sz
);
976 int mpt2sas_config_set_sas_iounit_pg1(struct MPT2SAS_ADAPTER
*ioc
,
977 Mpi2ConfigReply_t
*mpi_reply
, Mpi2SasIOUnitPage1_t
*config_page
, u16 sz
);
978 int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
979 *mpi_reply
, Mpi2IOCPage8_t
*config_page
);
980 int mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
981 *mpi_reply
, Mpi2ExpanderPage0_t
*config_page
, u32 form
, u32 handle
);
982 int mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
983 *mpi_reply
, Mpi2ExpanderPage1_t
*config_page
, u32 phy_number
, u16 handle
);
984 int mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
985 *mpi_reply
, Mpi2SasEnclosurePage0_t
*config_page
, u32 form
, u32 handle
);
986 int mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
987 *mpi_reply
, Mpi2SasPhyPage0_t
*config_page
, u32 phy_number
);
988 int mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
989 *mpi_reply
, Mpi2SasPhyPage1_t
*config_page
, u32 phy_number
);
990 int mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
991 *mpi_reply
, Mpi2RaidVolPage1_t
*config_page
, u32 form
, u32 handle
);
992 int mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER
*ioc
, u16 handle
, u8
*num_pds
);
993 int mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
994 *mpi_reply
, Mpi2RaidVolPage0_t
*config_page
, u32 form
, u32 handle
, u16 sz
);
995 int mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER
*ioc
, Mpi2ConfigReply_t
996 *mpi_reply
, Mpi2RaidPhysDiskPage0_t
*config_page
, u32 form
,
998 int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER
*ioc
, u16 pd_handle
,
1000 int mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER
*ioc
, u16 volume_handle
,
1002 /* ctl shared API */
1003 extern struct device_attribute
*mpt2sas_host_attrs
[];
1004 extern struct device_attribute
*mpt2sas_dev_attrs
[];
1005 void mpt2sas_ctl_init(void);
1006 void mpt2sas_ctl_exit(void);
1007 u8
mpt2sas_ctl_done(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
, u8 msix_index
,
1009 void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER
*ioc
, int reset_phase
);
1010 u8
mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER
*ioc
, u8 msix_index
,
1012 void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER
*ioc
,
1013 Mpi2EventNotificationReply_t
*mpi_reply
);
1015 void mpt2sas_enable_diag_buffer(struct MPT2SAS_ADAPTER
*ioc
,
1016 u8 bits_to_regsiter
);
1018 /* transport shared API */
1019 u8
mpt2sas_transport_done(struct MPT2SAS_ADAPTER
*ioc
, u16 smid
, u8 msix_index
,
1021 struct _sas_port
*mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER
*ioc
,
1022 u16 handle
, u64 sas_address
);
1023 void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER
*ioc
, u64 sas_address
,
1024 u64 sas_address_parent
);
1025 int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER
*ioc
, struct _sas_phy
1026 *mpt2sas_phy
, Mpi2SasPhyPage0_t phy_pg0
, struct device
*parent_dev
);
1027 int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER
*ioc
, struct _sas_phy
1028 *mpt2sas_phy
, Mpi2ExpanderPage1_t expander_pg1
, struct device
*parent_dev
);
1029 void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER
*ioc
,
1030 u64 sas_address
, u16 handle
, u8 phy_number
, u8 link_rate
);
1031 extern struct sas_function_template mpt2sas_transport_functions
;
1032 extern struct scsi_transport_template
*mpt2sas_transport_template
;
1033 extern int scsi_internal_device_block(struct scsi_device
*sdev
);
1034 extern u8
mpt2sas_stm_zero_smid_handler(struct MPT2SAS_ADAPTER
*ioc
,
1035 u8 msix_index
, u32 reply
);
1036 extern int scsi_internal_device_unblock(struct scsi_device
*sdev
);
1038 #endif /* MPT2SAS_BASE_H_INCLUDED */