mmc: tmio: fix regression in TMIO_MMC_WRPROTECT_DISABLE handling
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / scsi / mpt2sas / mpt2sas_base.h
blob500328245f6159fa1713ce4b0ae20df11513c603
1 /*
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.
19 * NO WARRANTY
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,
42 * USA.
45 #ifndef MPT2SAS_BASE_H_INCLUDED
46 #define MPT2SAS_BASE_H_INCLUDED
48 #include "mpi/mpi2_type.h"
49 #include "mpi/mpi2.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.00"
73 #define MPT2SAS_MAJOR_VERSION 08
74 #define MPT2SAS_MINOR_VERSION 100
75 #define MPT2SAS_BUILD_VERSION 00
76 #define MPT2SAS_RELEASE_VERSION 00
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
86 #else
87 #define MPT2SAS_SG_DEPTH CONFIG_SCSI_MPT2SAS_MAX_SGE
88 #endif
89 #else
90 #define MPT2SAS_SG_DEPTH 128 /* MAX_HW_SEGMENTS */
91 #endif
95 * Generic Defines
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
107 #define CAN_SLEEP 1
108 #define NO_SLEEP 0
110 #define INTERNAL_CMDS_COUNT 10 /* reserved cmds */
112 #define MPI2_HIM_MASK 0xFFFFFFFF /* mask every bit*/
114 #define MPT2SAS_INVALID_DEVICE_HANDLE 0xFFFF
118 * reset phases
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 */
125 * logging format
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
134 * Dell HBA branding
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"
147 * Dell HBA SSDIDs
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
158 * Intel HBA branding
160 #define MPT2SAS_INTEL_RMS2LL080_BRANDING \
161 "Intel Integrated RAID Module RMS2LL080"
162 #define MPT2SAS_INTEL_RMS2LL040_BRANDING \
163 "Intel Integrated RAID Module RMS2LL040"
166 * Intel HBA SSDIDs
168 #define MPT2SAS_INTEL_RMS2LL080_SSDID 0x350E
169 #define MPT2SAS_INTEL_RMS2LL040_SSDID 0x350F
173 * HP HBA branding
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"
183 * HO HBA SSDIDs
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 * per target private data
194 #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01
195 #define MPT_TARGET_FLAGS_VOLUME 0x02
196 #define MPT_TARGET_FLAGS_DELETED 0x04
199 * struct MPT2SAS_TARGET - starget private hostdata
200 * @starget: starget object
201 * @sas_address: target sas address
202 * @handle: device handle
203 * @num_luns: number luns
204 * @flags: MPT_TARGET_FLAGS_XXX flags
205 * @deleted: target flaged for deletion
206 * @tm_busy: target is busy with TM request.
208 struct MPT2SAS_TARGET {
209 struct scsi_target *starget;
210 u64 sas_address;
211 u16 handle;
212 int num_luns;
213 u32 flags;
214 u8 deleted;
215 u8 tm_busy;
219 * per device private data
221 #define MPT_DEVICE_FLAGS_INIT 0x01
222 #define MPT_DEVICE_TLR_ON 0x02
225 * struct MPT2SAS_DEVICE - sdev private hostdata
226 * @sas_target: starget private hostdata
227 * @lun: lun number
228 * @flags: MPT_DEVICE_XXX flags
229 * @configured_lun: lun is configured
230 * @block: device is in SDEV_BLOCK state
231 * @tlr_snoop_check: flag used in determining whether to disable TLR
234 /* OEM Identifiers */
235 #define MFG10_OEM_ID_INVALID (0x00000000)
236 #define MFG10_OEM_ID_DELL (0x00000001)
237 #define MFG10_OEM_ID_FSC (0x00000002)
238 #define MFG10_OEM_ID_SUN (0x00000003)
239 #define MFG10_OEM_ID_IBM (0x00000004)
241 /* GENERIC Flags 0*/
242 #define MFG10_GF0_OCE_DISABLED (0x00000001)
243 #define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002)
244 #define MFG10_GF0_R10_DISPLAY (0x00000004)
245 #define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008)
246 #define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010)
248 /* OEM Specific Flags will come from OEM specific header files */
249 typedef struct _MPI2_CONFIG_PAGE_MAN_10 {
250 MPI2_CONFIG_PAGE_HEADER Header; /* 00h */
251 U8 OEMIdentifier; /* 04h */
252 U8 Reserved1; /* 05h */
253 U16 Reserved2; /* 08h */
254 U32 Reserved3; /* 0Ch */
255 U32 GenericFlags0; /* 10h */
256 U32 GenericFlags1; /* 14h */
257 U32 Reserved4; /* 18h */
258 U32 OEMSpecificFlags0; /* 1Ch */
259 U32 OEMSpecificFlags1; /* 20h */
260 U32 Reserved5[18]; /* 24h-60h*/
261 } MPI2_CONFIG_PAGE_MAN_10,
262 MPI2_POINTER PTR_MPI2_CONFIG_PAGE_MAN_10,
263 Mpi2ManufacturingPage10_t, MPI2_POINTER pMpi2ManufacturingPage10_t;
265 struct MPT2SAS_DEVICE {
266 struct MPT2SAS_TARGET *sas_target;
267 unsigned int lun;
268 u32 flags;
269 u8 configured_lun;
270 u8 block;
271 u8 tlr_snoop_check;
274 #define MPT2_CMD_NOT_USED 0x8000 /* free */
275 #define MPT2_CMD_COMPLETE 0x0001 /* completed */
276 #define MPT2_CMD_PENDING 0x0002 /* pending */
277 #define MPT2_CMD_REPLY_VALID 0x0004 /* reply is valid */
278 #define MPT2_CMD_RESET 0x0008 /* host reset dropped the command */
281 * struct _internal_cmd - internal commands struct
282 * @mutex: mutex
283 * @done: completion
284 * @reply: reply message pointer
285 * @sense: sense data
286 * @status: MPT2_CMD_XXX status
287 * @smid: system message id
289 struct _internal_cmd {
290 struct mutex mutex;
291 struct completion done;
292 void *reply;
293 void *sense;
294 u16 status;
295 u16 smid;
300 * struct _sas_device - attached device information
301 * @list: sas device list
302 * @starget: starget object
303 * @sas_address: device sas address
304 * @device_name: retrieved from the SAS IDENTIFY frame.
305 * @handle: device handle
306 * @sas_address_parent: sas address of parent expander or sas host
307 * @enclosure_handle: enclosure handle
308 * @enclosure_logical_id: enclosure logical identifier
309 * @volume_handle: volume handle (valid when hidden raid member)
310 * @volume_wwid: volume unique identifier
311 * @device_info: bitfield provides detailed info about the device
312 * @id: target id
313 * @channel: target channel
314 * @slot: number number
315 * @phy: phy identifier provided in sas device page 0
316 * @responding: used in _scsih_sas_device_mark_responding
318 struct _sas_device {
319 struct list_head list;
320 struct scsi_target *starget;
321 u64 sas_address;
322 u64 device_name;
323 u16 handle;
324 u64 sas_address_parent;
325 u16 enclosure_handle;
326 u64 enclosure_logical_id;
327 u16 volume_handle;
328 u64 volume_wwid;
329 u32 device_info;
330 int id;
331 int channel;
332 u16 slot;
333 u8 phy;
334 u8 responding;
338 * struct _raid_device - raid volume link list
339 * @list: sas device list
340 * @starget: starget object
341 * @sdev: scsi device struct (volumes are single lun)
342 * @wwid: unique identifier for the volume
343 * @handle: device handle
344 * @id: target id
345 * @channel: target channel
346 * @volume_type: the raid level
347 * @device_info: bitfield provides detailed info about the hidden components
348 * @num_pds: number of hidden raid components
349 * @responding: used in _scsih_raid_device_mark_responding
350 * @percent_complete: resync percent complete
352 struct _raid_device {
353 struct list_head list;
354 struct scsi_target *starget;
355 struct scsi_device *sdev;
356 u64 wwid;
357 u16 handle;
358 int id;
359 int channel;
360 u8 volume_type;
361 u32 device_info;
362 u8 num_pds;
363 u8 responding;
364 u8 percent_complete;
368 * struct _boot_device - boot device info
369 * @is_raid: flag to indicate whether this is volume
370 * @device: holds pointer for either struct _sas_device or
371 * struct _raid_device
373 struct _boot_device {
374 u8 is_raid;
375 void *device;
379 * struct _sas_port - wide/narrow sas port information
380 * @port_list: list of ports belonging to expander
381 * @num_phys: number of phys belonging to this port
382 * @remote_identify: attached device identification
383 * @rphy: sas transport rphy object
384 * @port: sas transport wide/narrow port object
385 * @phy_list: _sas_phy list objects belonging to this port
387 struct _sas_port {
388 struct list_head port_list;
389 u8 num_phys;
390 struct sas_identify remote_identify;
391 struct sas_rphy *rphy;
392 struct sas_port *port;
393 struct list_head phy_list;
397 * struct _sas_phy - phy information
398 * @port_siblings: list of phys belonging to a port
399 * @identify: phy identification
400 * @remote_identify: attached device identification
401 * @phy: sas transport phy object
402 * @phy_id: unique phy id
403 * @handle: device handle for this phy
404 * @attached_handle: device handle for attached device
405 * @phy_belongs_to_port: port has been created for this phy
407 struct _sas_phy {
408 struct list_head port_siblings;
409 struct sas_identify identify;
410 struct sas_identify remote_identify;
411 struct sas_phy *phy;
412 u8 phy_id;
413 u16 handle;
414 u16 attached_handle;
415 u8 phy_belongs_to_port;
419 * struct _sas_node - sas_host/expander information
420 * @list: list of expanders
421 * @parent_dev: parent device class
422 * @num_phys: number phys belonging to this sas_host/expander
423 * @sas_address: sas address of this sas_host/expander
424 * @handle: handle for this sas_host/expander
425 * @sas_address_parent: sas address of parent expander or sas host
426 * @enclosure_handle: handle for this a member of an enclosure
427 * @device_info: bitwise defining capabilities of this sas_host/expander
428 * @responding: used in _scsih_expander_device_mark_responding
429 * @phy: a list of phys that make up this sas_host/expander
430 * @sas_port_list: list of ports attached to this sas_host/expander
432 struct _sas_node {
433 struct list_head list;
434 struct device *parent_dev;
435 u8 num_phys;
436 u64 sas_address;
437 u16 handle;
438 u64 sas_address_parent;
439 u16 enclosure_handle;
440 u64 enclosure_logical_id;
441 u8 responding;
442 struct _sas_phy *phy;
443 struct list_head sas_port_list;
447 * enum reset_type - reset state
448 * @FORCE_BIG_HAMMER: issue diagnostic reset
449 * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
451 enum reset_type {
452 FORCE_BIG_HAMMER,
453 SOFT_RESET,
457 * struct chain_tracker - firmware chain tracker
458 * @chain_buffer: chain buffer
459 * @chain_buffer_dma: physical address
460 * @tracker_list: list of free request (ioc->free_chain_list)
462 struct chain_tracker {
463 void *chain_buffer;
464 dma_addr_t chain_buffer_dma;
465 struct list_head tracker_list;
469 * struct scsiio_tracker - scsi mf request tracker
470 * @smid: system message id
471 * @scmd: scsi request pointer
472 * @cb_idx: callback index
473 * @chain_list: list of chains associated to this IO
474 * @tracker_list: list of free request (ioc->free_list)
476 struct scsiio_tracker {
477 u16 smid;
478 struct scsi_cmnd *scmd;
479 u8 cb_idx;
480 struct list_head chain_list;
481 struct list_head tracker_list;
485 * struct request_tracker - misc mf request tracker
486 * @smid: system message id
487 * @scmd: scsi request pointer
488 * @cb_idx: callback index
489 * @tracker_list: list of free request (ioc->free_list)
491 struct request_tracker {
492 u16 smid;
493 u8 cb_idx;
494 struct list_head tracker_list;
498 * struct _tr_list - target reset list
499 * @handle: device handle
500 * @state: state machine
502 struct _tr_list {
503 struct list_head list;
504 u16 handle;
505 u16 state;
508 typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
511 * struct MPT2SAS_ADAPTER - per adapter struct
512 * @list: ioc_list
513 * @shost: shost object
514 * @id: unique adapter id
515 * @pci_irq: irq number
516 * @name: generic ioc string
517 * @tmp_string: tmp string used for logging
518 * @pdev: pci pdev object
519 * @chip: memory mapped register space
520 * @chip_phys: physical addrss prior to mapping
521 * @logging_level: see mpt2sas_debug.h
522 * @fwfault_debug: debuging FW timeouts
523 * @ir_firmware: IR firmware present
524 * @bars: bitmask of BAR's that must be configured
525 * @mask_interrupts: ignore interrupt
526 * @fault_reset_work_q_name: fw fault work queue
527 * @fault_reset_work_q: ""
528 * @fault_reset_work: ""
529 * @firmware_event_name: fw event work queue
530 * @firmware_event_thread: ""
531 * @fw_events_off: flag to turn off fw event handling
532 * @fw_event_lock:
533 * @fw_event_list: list of fw events
534 * @aen_event_read_flag: event log was read
535 * @broadcast_aen_busy: broadcast aen waiting to be serviced
536 * @shost_recovery: host reset in progress
537 * @ioc_reset_in_progress_lock:
538 * @ioc_link_reset_in_progress: phy/hard reset in progress
539 * @ignore_loginfos: ignore loginfos during task management
540 * @remove_host: flag for when driver unloads, to avoid sending dev resets
541 * @pci_error_recovery: flag to prevent ioc access until slot reset completes
542 * @wait_for_port_enable_to_complete:
543 * @msix_enable: flag indicating msix is enabled
544 * @msix_vector_count: number msix vectors
545 * @msix_table: virt address to the msix table
546 * @msix_table_backup: backup msix table
547 * @scsi_io_cb_idx: shost generated commands
548 * @tm_cb_idx: task management commands
549 * @scsih_cb_idx: scsih internal commands
550 * @transport_cb_idx: transport internal commands
551 * @ctl_cb_idx: clt internal commands
552 * @base_cb_idx: base internal commands
553 * @config_cb_idx: base internal commands
554 * @tm_tr_cb_idx : device removal target reset handshake
555 * @tm_tr_volume_cb_idx : volume removal target reset
556 * @base_cmds:
557 * @transport_cmds:
558 * @scsih_cmds:
559 * @tm_cmds:
560 * @ctl_cmds:
561 * @config_cmds:
562 * @base_add_sg_single: handler for either 32/64 bit sgl's
563 * @event_type: bits indicating which events to log
564 * @event_context: unique id for each logged event
565 * @event_log: event log pointer
566 * @event_masks: events that are masked
567 * @facts: static facts data
568 * @pfacts: static port facts data
569 * @manu_pg0: static manufacturing page 0
570 * @manu_pg10: static manufacturing page 10
571 * @bios_pg2: static bios page 2
572 * @bios_pg3: static bios page 3
573 * @ioc_pg8: static ioc page 8
574 * @iounit_pg0: static iounit page 0
575 * @iounit_pg1: static iounit page 1
576 * @sas_hba: sas host object
577 * @sas_expander_list: expander object list
578 * @sas_node_lock:
579 * @sas_device_list: sas device object list
580 * @sas_device_init_list: sas device object list (used only at init time)
581 * @sas_device_lock:
582 * @io_missing_delay: time for IO completed by fw when PDR enabled
583 * @device_missing_delay: time for device missing by fw when PDR enabled
584 * @sas_id : used for setting volume target IDs
585 * @pd_handles : bitmask for PD handles
586 * @pd_handles_sz : size of pd_handle bitmask
587 * @config_page_sz: config page size
588 * @config_page: reserve memory for config page payload
589 * @config_page_dma:
590 * @hba_queue_depth: hba request queue depth
591 * @sge_size: sg element size for either 32/64 bit
592 * @scsiio_depth: SCSI_IO queue depth
593 * @request_sz: per request frame size
594 * @request: pool of request frames
595 * @request_dma:
596 * @request_dma_sz:
597 * @scsi_lookup: firmware request tracker list
598 * @scsi_lookup_lock:
599 * @free_list: free list of request
600 * @chain: pool of chains
601 * @pending_io_count:
602 * @reset_wq:
603 * @chain_dma:
604 * @max_sges_in_main_message: number sg elements in main message
605 * @max_sges_in_chain_message: number sg elements per chain
606 * @chains_needed_per_io: max chains per io
607 * @chain_offset_value_for_main_message: location 1st sg in main
608 * @chain_depth: total chains allocated
609 * @hi_priority_smid:
610 * @hi_priority:
611 * @hi_priority_dma:
612 * @hi_priority_depth:
613 * @hpr_lookup:
614 * @hpr_free_list:
615 * @internal_smid:
616 * @internal:
617 * @internal_dma:
618 * @internal_depth:
619 * @internal_lookup:
620 * @internal_free_list:
621 * @sense: pool of sense
622 * @sense_dma:
623 * @sense_dma_pool:
624 * @reply_depth: hba reply queue depth:
625 * @reply_sz: per reply frame size:
626 * @reply: pool of replys:
627 * @reply_dma:
628 * @reply_dma_pool:
629 * @reply_free_queue_depth: reply free depth
630 * @reply_free: pool for reply free queue (32 bit addr)
631 * @reply_free_dma:
632 * @reply_free_dma_pool:
633 * @reply_free_host_index: tail index in pool to insert free replys
634 * @reply_post_queue_depth: reply post queue depth
635 * @reply_post_free: pool for reply post (64bit descriptor)
636 * @reply_post_free_dma:
637 * @reply_post_free_dma_pool:
638 * @reply_post_host_index: head index in the pool where FW completes IO
639 * @delayed_tr_list: target reset link list
640 * @delayed_tr_volume_list: volume target reset link list
642 struct MPT2SAS_ADAPTER {
643 struct list_head list;
644 struct Scsi_Host *shost;
645 u8 id;
646 u32 pci_irq;
647 char name[MPT_NAME_LENGTH];
648 char tmp_string[MPT_STRING_LENGTH];
649 struct pci_dev *pdev;
650 Mpi2SystemInterfaceRegs_t __iomem *chip;
651 resource_size_t chip_phys;
652 int logging_level;
653 int fwfault_debug;
654 u8 ir_firmware;
655 int bars;
656 u8 mask_interrupts;
658 /* fw fault handler */
659 char fault_reset_work_q_name[20];
660 struct workqueue_struct *fault_reset_work_q;
661 struct delayed_work fault_reset_work;
663 /* fw event handler */
664 char firmware_event_name[20];
665 struct workqueue_struct *firmware_event_thread;
666 spinlock_t fw_event_lock;
667 struct list_head fw_event_list;
669 /* misc flags */
670 int aen_event_read_flag;
671 u8 broadcast_aen_busy;
672 u8 shost_recovery;
674 struct mutex reset_in_progress_mutex;
675 struct completion shost_recovery_done;
676 spinlock_t ioc_reset_in_progress_lock;
677 u8 ioc_link_reset_in_progress;
678 int ioc_reset_in_progress_status;
680 u8 ignore_loginfos;
681 u8 remove_host;
682 u8 pci_error_recovery;
683 u8 wait_for_port_enable_to_complete;
685 u8 msix_enable;
686 u16 msix_vector_count;
687 u32 *msix_table;
688 u32 *msix_table_backup;
689 u32 ioc_reset_count;
691 /* internal commands, callback index */
692 u8 scsi_io_cb_idx;
693 u8 tm_cb_idx;
694 u8 transport_cb_idx;
695 u8 scsih_cb_idx;
696 u8 ctl_cb_idx;
697 u8 base_cb_idx;
698 u8 config_cb_idx;
699 u8 tm_tr_cb_idx;
700 u8 tm_tr_volume_cb_idx;
701 u8 tm_sas_control_cb_idx;
702 struct _internal_cmd base_cmds;
703 struct _internal_cmd transport_cmds;
704 struct _internal_cmd scsih_cmds;
705 struct _internal_cmd tm_cmds;
706 struct _internal_cmd ctl_cmds;
707 struct _internal_cmd config_cmds;
709 MPT_ADD_SGE base_add_sg_single;
711 /* event log */
712 u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
713 u32 event_context;
714 void *event_log;
715 u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
717 /* static config pages */
718 Mpi2IOCFactsReply_t facts;
719 Mpi2PortFactsReply_t *pfacts;
720 Mpi2ManufacturingPage0_t manu_pg0;
721 Mpi2BiosPage2_t bios_pg2;
722 Mpi2BiosPage3_t bios_pg3;
723 Mpi2IOCPage8_t ioc_pg8;
724 Mpi2IOUnitPage0_t iounit_pg0;
725 Mpi2IOUnitPage1_t iounit_pg1;
727 struct _boot_device req_boot_device;
728 struct _boot_device req_alt_boot_device;
729 struct _boot_device current_boot_device;
731 /* sas hba, expander, and device list */
732 struct _sas_node sas_hba;
733 struct list_head sas_expander_list;
734 spinlock_t sas_node_lock;
735 struct list_head sas_device_list;
736 struct list_head sas_device_init_list;
737 spinlock_t sas_device_lock;
738 struct list_head raid_device_list;
739 spinlock_t raid_device_lock;
740 u8 io_missing_delay;
741 u16 device_missing_delay;
742 int sas_id;
744 void *pd_handles;
745 u16 pd_handles_sz;
747 /* config page */
748 u16 config_page_sz;
749 void *config_page;
750 dma_addr_t config_page_dma;
752 /* scsiio request */
753 u16 hba_queue_depth;
754 u16 sge_size;
755 u16 scsiio_depth;
756 u16 request_sz;
757 u8 *request;
758 dma_addr_t request_dma;
759 u32 request_dma_sz;
760 struct scsiio_tracker *scsi_lookup;
761 ulong scsi_lookup_pages;
762 spinlock_t scsi_lookup_lock;
763 struct list_head free_list;
764 int pending_io_count;
765 wait_queue_head_t reset_wq;
767 /* chain */
768 struct chain_tracker *chain_lookup;
769 struct list_head free_chain_list;
770 struct dma_pool *chain_dma_pool;
771 ulong chain_pages;
772 u16 max_sges_in_main_message;
773 u16 max_sges_in_chain_message;
774 u16 chains_needed_per_io;
775 u16 chain_offset_value_for_main_message;
776 u32 chain_depth;
778 /* hi-priority queue */
779 u16 hi_priority_smid;
780 u8 *hi_priority;
781 dma_addr_t hi_priority_dma;
782 u16 hi_priority_depth;
783 struct request_tracker *hpr_lookup;
784 struct list_head hpr_free_list;
786 /* internal queue */
787 u16 internal_smid;
788 u8 *internal;
789 dma_addr_t internal_dma;
790 u16 internal_depth;
791 struct request_tracker *internal_lookup;
792 struct list_head internal_free_list;
794 /* sense */
795 u8 *sense;
796 dma_addr_t sense_dma;
797 struct dma_pool *sense_dma_pool;
799 /* reply */
800 u16 reply_sz;
801 u8 *reply;
802 dma_addr_t reply_dma;
803 u32 reply_dma_max_address;
804 u32 reply_dma_min_address;
805 struct dma_pool *reply_dma_pool;
807 /* reply free queue */
808 u16 reply_free_queue_depth;
809 u32 *reply_free;
810 dma_addr_t reply_free_dma;
811 struct dma_pool *reply_free_dma_pool;
812 u32 reply_free_host_index;
814 /* reply post queue */
815 u16 reply_post_queue_depth;
816 Mpi2ReplyDescriptorsUnion_t *reply_post_free;
817 dma_addr_t reply_post_free_dma;
818 struct dma_pool *reply_post_free_dma_pool;
819 u32 reply_post_host_index;
821 struct list_head delayed_tr_list;
822 struct list_head delayed_tr_volume_list;
824 /* diag buffer support */
825 u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
826 u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
827 dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
828 u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
829 u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
830 Mpi2ManufacturingPage10_t manu_pg10;
831 u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
832 u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
833 u32 ring_buffer_offset;
834 u32 ring_buffer_sz;
837 typedef u8 (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
838 u32 reply);
841 /* base shared API */
842 extern struct list_head mpt2sas_ioc_list;
843 void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc);
844 void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc);
846 int mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc);
847 void mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc);
848 int mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc);
849 void mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc);
850 int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
851 enum reset_type type);
853 void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid);
854 void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid);
855 void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr);
856 __le32 mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc,
857 u16 smid);
859 /* hi-priority queue */
860 u16 mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
861 u16 mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx,
862 struct scsi_cmnd *scmd);
864 u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
865 void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid);
866 void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid,
867 u16 handle);
868 void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid);
869 void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid,
870 u16 io_index);
871 void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid);
872 void mpt2sas_base_initialize_callback_handler(void);
873 u8 mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func);
874 void mpt2sas_base_release_callback_handler(u8 cb_idx);
876 u8 mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
877 u32 reply);
878 void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr);
880 u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked);
882 void mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code);
883 int mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
884 Mpi2SasIoUnitControlReply_t *mpi_reply, Mpi2SasIoUnitControlRequest_t
885 *mpi_request);
886 int mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
887 Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
888 void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type);
890 void mpt2sas_halt_firmware(struct MPT2SAS_ADAPTER *ioc);
892 /* scsih shared API */
893 u8 mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
894 u32 reply);
895 int mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle,
896 uint channel, uint id, uint lun, u8 type, u16 smid_task,
897 ulong timeout, struct scsi_cmnd *scmd);
898 void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
899 void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
900 void mpt2sas_expander_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
901 void mpt2sas_device_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
902 struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *ioc,
903 u16 handle);
904 struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER
905 *ioc, u64 sas_address);
906 struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address(
907 struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
909 void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
911 /* config shared API */
912 u8 mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
913 u32 reply);
914 int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys);
915 int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
916 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
917 int mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc,
918 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage10_t *config_page);
919 int mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
920 *mpi_reply, Mpi2BiosPage2_t *config_page);
921 int mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
922 *mpi_reply, Mpi2BiosPage3_t *config_page);
923 int mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
924 *mpi_reply, Mpi2IOUnitPage0_t *config_page);
925 int mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
926 *mpi_reply, Mpi2SasDevicePage0_t *config_page, u32 form, u32 handle);
927 int mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
928 *mpi_reply, Mpi2SasDevicePage1_t *config_page, u32 form, u32 handle);
929 int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
930 *mpi_reply, Mpi2SasIOUnitPage0_t *config_page, u16 sz);
931 int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
932 *mpi_reply, Mpi2IOUnitPage1_t *config_page);
933 int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
934 *mpi_reply, Mpi2IOUnitPage1_t *config_page);
935 int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
936 *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
937 int mpt2sas_config_set_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
938 Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
939 int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
940 *mpi_reply, Mpi2IOCPage8_t *config_page);
941 int mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
942 *mpi_reply, Mpi2ExpanderPage0_t *config_page, u32 form, u32 handle);
943 int mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
944 *mpi_reply, Mpi2ExpanderPage1_t *config_page, u32 phy_number, u16 handle);
945 int mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
946 *mpi_reply, Mpi2SasEnclosurePage0_t *config_page, u32 form, u32 handle);
947 int mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
948 *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
949 int mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
950 *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
951 int mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
952 *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form, u32 handle);
953 int mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 *num_pds);
954 int mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
955 *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form, u32 handle, u16 sz);
956 int mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
957 *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 form,
958 u32 form_specific);
959 int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
960 u16 *volume_handle);
961 int mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER *ioc, u16 volume_handle,
962 u64 *wwid);
963 /* ctl shared API */
964 extern struct device_attribute *mpt2sas_host_attrs[];
965 extern struct device_attribute *mpt2sas_dev_attrs[];
966 void mpt2sas_ctl_init(void);
967 void mpt2sas_ctl_exit(void);
968 u8 mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
969 u32 reply);
970 void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
971 u8 mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
972 u32 reply);
973 void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,
974 Mpi2EventNotificationReply_t *mpi_reply);
976 void mpt2sas_enable_diag_buffer(struct MPT2SAS_ADAPTER *ioc,
977 u8 bits_to_regsiter);
979 /* transport shared API */
980 u8 mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
981 u32 reply);
982 struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc,
983 u16 handle, u64 sas_address);
984 void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
985 u64 sas_address_parent);
986 int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
987 *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
988 int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
989 *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev);
990 void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc,
991 u64 sas_address, u16 handle, u8 phy_number, u8 link_rate);
992 extern struct sas_function_template mpt2sas_transport_functions;
993 extern struct scsi_transport_template *mpt2sas_transport_template;
994 extern int scsi_internal_device_block(struct scsi_device *sdev);
995 extern u8 mpt2sas_stm_zero_smid_handler(struct MPT2SAS_ADAPTER *ioc,
996 u8 msix_index, u32 reply);
997 extern int scsi_internal_device_unblock(struct scsi_device *sdev);
999 #endif /* MPT2SAS_BASE_H_INCLUDED */