mpt2sas_base.h revision ed79f1280d1bc54f168abcffc8c3e0bf8ffb1873
1/* 2 * This is the Fusion MPT base driver providing common API layer interface 3 * for access to MPT (Message Passing Technology) firmware. 4 * 5 * This code is based on drivers/scsi/mpt2sas/mpt2_base.h 6 * Copyright (C) 2007-2008 LSI Corporation 7 * (mailto:DL-MPTFusionLinux@lsi.com) 8 * 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. 13 * 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. 18 * 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. 29 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 38 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. 43 */ 44 45#ifndef MPT2SAS_BASE_H_INCLUDED 46#define MPT2SAS_BASE_H_INCLUDED 47 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" 56 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> 65 66#include "mpt2sas_debug.h" 67 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 "01.100.04.00" 73#define MPT2SAS_MAJOR_VERSION 01 74#define MPT2SAS_MINOR_VERSION 100 75#define MPT2SAS_BUILD_VERSION 04 76#define MPT2SAS_RELEASE_VERSION 00 77 78/* 79 * Set MPT2SAS_SG_DEPTH value based on user input. 80 */ 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 92 93 94/* 95 * Generic Defines 96 */ 97#define MPT2SAS_SATA_QUEUE_DEPTH 32 98#define MPT2SAS_SAS_QUEUE_DEPTH 254 99#define MPT2SAS_RAID_QUEUE_DEPTH 128 100 101#define MPT_NAME_LENGTH 32 /* generic length of strings */ 102#define MPT_STRING_LENGTH 64 103 104#define MPT_MAX_CALLBACKS 16 105 106#define CAN_SLEEP 1 107#define NO_SLEEP 0 108 109#define INTERNAL_CMDS_COUNT 10 /* reserved cmds */ 110 111#define MPI2_HIM_MASK 0xFFFFFFFF /* mask every bit*/ 112 113#define MPT2SAS_INVALID_DEVICE_HANDLE 0xFFFF 114 115 116/* 117 * reset phases 118 */ 119#define MPT2_IOC_PRE_RESET 1 /* prior to host reset */ 120#define MPT2_IOC_AFTER_RESET 2 /* just after host reset */ 121#define MPT2_IOC_DONE_RESET 3 /* links re-initialized */ 122#define MPT2_IOC_RUNNING 4 /* shost running */ 123 124/* 125 * logging format 126 */ 127#define MPT2SAS_FMT "%s: " 128#define MPT2SAS_DEBUG_FMT KERN_DEBUG MPT2SAS_FMT 129#define MPT2SAS_INFO_FMT KERN_INFO MPT2SAS_FMT 130#define MPT2SAS_NOTE_FMT KERN_NOTICE MPT2SAS_FMT 131#define MPT2SAS_WARN_FMT KERN_WARNING MPT2SAS_FMT 132#define MPT2SAS_ERR_FMT KERN_ERR MPT2SAS_FMT 133 134/* 135 * Dell HBA branding 136 */ 137#define MPT2SAS_DELL_BRANDING_SIZE 32 138 139#define MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING "Dell 6Gbps SAS HBA" 140#define MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING "Dell PERC H200 Adapter" 141#define MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING "Dell PERC H200 Integrated" 142#define MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING "Dell PERC H200 Modular" 143#define MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING "Dell PERC H200 Embedded" 144#define MPT2SAS_DELL_PERC_H200_BRANDING "Dell PERC H200" 145#define MPT2SAS_DELL_6GBPS_SAS_BRANDING "Dell 6Gbps SAS" 146 147/* 148 * Dell HBA SSDIDs 149 */ 150#define MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID 0x1F1C 151#define MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID 0x1F1D 152#define MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID 0x1F1E 153#define MPT2SAS_DELL_PERC_H200_MODULAR_SSDID 0x1F1F 154#define MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID 0x1F20 155#define MPT2SAS_DELL_PERC_H200_SSDID 0x1F21 156#define MPT2SAS_DELL_6GBPS_SAS_SSDID 0x1F22 157 158/* 159 * per target private data 160 */ 161#define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01 162#define MPT_TARGET_FLAGS_VOLUME 0x02 163#define MPT_TARGET_FLAGS_DELETED 0x04 164 165/** 166 * struct MPT2SAS_TARGET - starget private hostdata 167 * @starget: starget object 168 * @sas_address: target sas address 169 * @handle: device handle 170 * @num_luns: number luns 171 * @flags: MPT_TARGET_FLAGS_XXX flags 172 * @deleted: target flaged for deletion 173 * @tm_busy: target is busy with TM request. 174 */ 175struct MPT2SAS_TARGET { 176 struct scsi_target *starget; 177 u64 sas_address; 178 u16 handle; 179 int num_luns; 180 u32 flags; 181 u8 deleted; 182 u8 tm_busy; 183}; 184 185/* 186 * per device private data 187 */ 188#define MPT_DEVICE_FLAGS_INIT 0x01 189#define MPT_DEVICE_TLR_ON 0x02 190 191/** 192 * struct MPT2SAS_DEVICE - sdev private hostdata 193 * @sas_target: starget private hostdata 194 * @lun: lun number 195 * @flags: MPT_DEVICE_XXX flags 196 * @configured_lun: lun is configured 197 * @block: device is in SDEV_BLOCK state 198 * @tlr_snoop_check: flag used in determining whether to disable TLR 199 */ 200 201/* OEM Identifiers */ 202#define MFG10_OEM_ID_INVALID (0x00000000) 203#define MFG10_OEM_ID_DELL (0x00000001) 204#define MFG10_OEM_ID_FSC (0x00000002) 205#define MFG10_OEM_ID_SUN (0x00000003) 206#define MFG10_OEM_ID_IBM (0x00000004) 207 208/* GENERIC Flags 0*/ 209#define MFG10_GF0_OCE_DISABLED (0x00000001) 210#define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002) 211#define MFG10_GF0_R10_DISPLAY (0x00000004) 212#define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008) 213#define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010) 214 215/* OEM Specific Flags will come from OEM specific header files */ 216typedef struct _MPI2_CONFIG_PAGE_MAN_10 { 217 MPI2_CONFIG_PAGE_HEADER Header; /* 00h */ 218 U8 OEMIdentifier; /* 04h */ 219 U8 Reserved1; /* 05h */ 220 U16 Reserved2; /* 08h */ 221 U32 Reserved3; /* 0Ch */ 222 U32 GenericFlags0; /* 10h */ 223 U32 GenericFlags1; /* 14h */ 224 U32 Reserved4; /* 18h */ 225 U32 OEMSpecificFlags0; /* 1Ch */ 226 U32 OEMSpecificFlags1; /* 20h */ 227 U32 Reserved5[18]; /* 24h-60h*/ 228} MPI2_CONFIG_PAGE_MAN_10, 229 MPI2_POINTER PTR_MPI2_CONFIG_PAGE_MAN_10, 230 Mpi2ManufacturingPage10_t, MPI2_POINTER pMpi2ManufacturingPage10_t; 231 232struct MPT2SAS_DEVICE { 233 struct MPT2SAS_TARGET *sas_target; 234 unsigned int lun; 235 u32 flags; 236 u8 configured_lun; 237 u8 block; 238 u8 tlr_snoop_check; 239}; 240 241#define MPT2_CMD_NOT_USED 0x8000 /* free */ 242#define MPT2_CMD_COMPLETE 0x0001 /* completed */ 243#define MPT2_CMD_PENDING 0x0002 /* pending */ 244#define MPT2_CMD_REPLY_VALID 0x0004 /* reply is valid */ 245#define MPT2_CMD_RESET 0x0008 /* host reset dropped the command */ 246 247/** 248 * struct _internal_cmd - internal commands struct 249 * @mutex: mutex 250 * @done: completion 251 * @reply: reply message pointer 252 * @status: MPT2_CMD_XXX status 253 * @smid: system message id 254 */ 255struct _internal_cmd { 256 struct mutex mutex; 257 struct completion done; 258 void *reply; 259 u16 status; 260 u16 smid; 261}; 262 263/* 264 * SAS Topology Structures 265 */ 266 267/** 268 * struct _sas_device - attached device information 269 * @list: sas device list 270 * @starget: starget object 271 * @sas_address: device sas address 272 * @device_name: retrieved from the SAS IDENTIFY frame. 273 * @handle: device handle 274 * @parent_handle: handle to parent device 275 * @enclosure_handle: enclosure handle 276 * @enclosure_logical_id: enclosure logical identifier 277 * @volume_handle: volume handle (valid when hidden raid member) 278 * @volume_wwid: volume unique identifier 279 * @device_info: bitfield provides detailed info about the device 280 * @id: target id 281 * @channel: target channel 282 * @slot: number number 283 * @hidden_raid_component: set to 1 when this is a raid member 284 * @responding: used in _scsih_sas_device_mark_responding 285 */ 286struct _sas_device { 287 struct list_head list; 288 struct scsi_target *starget; 289 u64 sas_address; 290 u64 device_name; 291 u16 handle; 292 u16 parent_handle; 293 u16 enclosure_handle; 294 u64 enclosure_logical_id; 295 u16 volume_handle; 296 u64 volume_wwid; 297 u32 device_info; 298 int id; 299 int channel; 300 u16 slot; 301 u8 hidden_raid_component; 302 u8 responding; 303}; 304 305/** 306 * struct _raid_device - raid volume link list 307 * @list: sas device list 308 * @starget: starget object 309 * @sdev: scsi device struct (volumes are single lun) 310 * @wwid: unique identifier for the volume 311 * @handle: device handle 312 * @id: target id 313 * @channel: target channel 314 * @volume_type: the raid level 315 * @device_info: bitfield provides detailed info about the hidden components 316 * @num_pds: number of hidden raid components 317 * @responding: used in _scsih_raid_device_mark_responding 318 */ 319struct _raid_device { 320 struct list_head list; 321 struct scsi_target *starget; 322 struct scsi_device *sdev; 323 u64 wwid; 324 u16 handle; 325 int id; 326 int channel; 327 u8 volume_type; 328 u32 device_info; 329 u8 num_pds; 330 u8 responding; 331}; 332 333/** 334 * struct _boot_device - boot device info 335 * @is_raid: flag to indicate whether this is volume 336 * @device: holds pointer for either struct _sas_device or 337 * struct _raid_device 338 */ 339struct _boot_device { 340 u8 is_raid; 341 void *device; 342}; 343 344/** 345 * struct _sas_port - wide/narrow sas port information 346 * @port_list: list of ports belonging to expander 347 * @handle: device handle for this port 348 * @sas_address: sas address of this port 349 * @num_phys: number of phys belonging to this port 350 * @remote_identify: attached device identification 351 * @rphy: sas transport rphy object 352 * @port: sas transport wide/narrow port object 353 * @phy_list: _sas_phy list objects belonging to this port 354 */ 355struct _sas_port { 356 struct list_head port_list; 357 u16 handle; 358 u64 sas_address; 359 u8 num_phys; 360 struct sas_identify remote_identify; 361 struct sas_rphy *rphy; 362 struct sas_port *port; 363 struct list_head phy_list; 364}; 365 366/** 367 * struct _sas_phy - phy information 368 * @port_siblings: list of phys belonging to a port 369 * @identify: phy identification 370 * @remote_identify: attached device identification 371 * @phy: sas transport phy object 372 * @phy_id: unique phy id 373 * @handle: device handle for this phy 374 * @attached_handle: device handle for attached device 375 */ 376struct _sas_phy { 377 struct list_head port_siblings; 378 struct sas_identify identify; 379 struct sas_identify remote_identify; 380 struct sas_phy *phy; 381 u8 phy_id; 382 u16 handle; 383 u16 attached_handle; 384}; 385 386/** 387 * struct _sas_node - sas_host/expander information 388 * @list: list of expanders 389 * @parent_dev: parent device class 390 * @num_phys: number phys belonging to this sas_host/expander 391 * @sas_address: sas address of this sas_host/expander 392 * @handle: handle for this sas_host/expander 393 * @parent_handle: parent handle 394 * @enclosure_handle: handle for this a member of an enclosure 395 * @device_info: bitwise defining capabilities of this sas_host/expander 396 * @responding: used in _scsih_expander_device_mark_responding 397 * @phy: a list of phys that make up this sas_host/expander 398 * @sas_port_list: list of ports attached to this sas_host/expander 399 */ 400struct _sas_node { 401 struct list_head list; 402 struct device *parent_dev; 403 u8 num_phys; 404 u64 sas_address; 405 u16 handle; 406 u16 parent_handle; 407 u16 enclosure_handle; 408 u64 enclosure_logical_id; 409 u8 responding; 410 struct _sas_phy *phy; 411 struct list_head sas_port_list; 412}; 413 414/** 415 * enum reset_type - reset state 416 * @FORCE_BIG_HAMMER: issue diagnostic reset 417 * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer 418 */ 419enum reset_type { 420 FORCE_BIG_HAMMER, 421 SOFT_RESET, 422}; 423 424/** 425 * struct request_tracker - firmware request tracker 426 * @smid: system message id 427 * @scmd: scsi request pointer 428 * @cb_idx: callback index 429 * @chain_list: list of chains associated to this IO 430 * @tracker_list: list of free request (ioc->free_list) 431 */ 432struct request_tracker { 433 u16 smid; 434 struct scsi_cmnd *scmd; 435 u8 cb_idx; 436 struct list_head tracker_list; 437}; 438 439typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr); 440 441/** 442 * struct MPT2SAS_ADAPTER - per adapter struct 443 * @list: ioc_list 444 * @shost: shost object 445 * @id: unique adapter id 446 * @pci_irq: irq number 447 * @name: generic ioc string 448 * @tmp_string: tmp string used for logging 449 * @pdev: pci pdev object 450 * @chip: memory mapped register space 451 * @chip_phys: physical addrss prior to mapping 452 * @pio_chip: I/O mapped register space 453 * @logging_level: see mpt2sas_debug.h 454 * @ir_firmware: IR firmware present 455 * @bars: bitmask of BAR's that must be configured 456 * @mask_interrupts: ignore interrupt 457 * @fault_reset_work_q_name: fw fault work queue 458 * @fault_reset_work_q: "" 459 * @fault_reset_work: "" 460 * @firmware_event_name: fw event work queue 461 * @firmware_event_thread: "" 462 * @fw_events_off: flag to turn off fw event handling 463 * @fw_event_lock: 464 * @fw_event_list: list of fw events 465 * @aen_event_read_flag: event log was read 466 * @broadcast_aen_busy: broadcast aen waiting to be serviced 467 * @shost_recovery: host reset in progress 468 * @ioc_reset_in_progress_lock: 469 * @ioc_link_reset_in_progress: phy/hard reset in progress 470 * @ignore_loginfos: ignore loginfos during task managment 471 * @remove_host: flag for when driver unloads, to avoid sending dev resets 472 * @wait_for_port_enable_to_complete: 473 * @msix_enable: flag indicating msix is enabled 474 * @msix_vector_count: number msix vectors 475 * @msix_table: virt address to the msix table 476 * @msix_table_backup: backup msix table 477 * @scsi_io_cb_idx: shost generated commands 478 * @tm_cb_idx: task management commands 479 * @transport_cb_idx: transport internal commands 480 * @ctl_cb_idx: clt internal commands 481 * @base_cb_idx: base internal commands 482 * @config_cb_idx: base internal commands 483 * @base_cmds: 484 * @transport_cmds: 485 * @tm_cmds: 486 * @ctl_cmds: 487 * @config_cmds: 488 * @base_add_sg_single: handler for either 32/64 bit sgl's 489 * @event_type: bits indicating which events to log 490 * @event_context: unique id for each logged event 491 * @event_log: event log pointer 492 * @event_masks: events that are masked 493 * @facts: static facts data 494 * @pfacts: static port facts data 495 * @manu_pg0: static manufacturing page 0 496 * @manu_pg10: static manufacturing page 10 497 * @bios_pg2: static bios page 2 498 * @bios_pg3: static bios page 3 499 * @ioc_pg8: static ioc page 8 500 * @iounit_pg0: static iounit page 0 501 * @iounit_pg1: static iounit page 1 502 * @sas_hba: sas host object 503 * @sas_expander_list: expander object list 504 * @sas_node_lock: 505 * @sas_device_list: sas device object list 506 * @sas_device_init_list: sas device object list (used only at init time) 507 * @sas_device_lock: 508 * @io_missing_delay: time for IO completed by fw when PDR enabled 509 * @device_missing_delay: time for device missing by fw when PDR enabled 510 * @config_page_sz: config page size 511 * @config_page: reserve memory for config page payload 512 * @config_page_dma: 513 * @sge_size: sg element size for either 32/64 bit 514 * @request_depth: hba request queue depth 515 * @request_sz: per request frame size 516 * @request: pool of request frames 517 * @request_dma: 518 * @request_dma_sz: 519 * @scsi_lookup: firmware request tracker list 520 * @scsi_lookup_lock: 521 * @free_list: free list of request 522 * @chain: pool of chains 523 * @pending_io_count: 524 * @reset_wq: 525 * @chain_dma: 526 * @max_sges_in_main_message: number sg elements in main message 527 * @max_sges_in_chain_message: number sg elements per chain 528 * @chains_needed_per_io: max chains per io 529 * @chain_offset_value_for_main_message: location 1st sg in main 530 * @chain_depth: total chains allocated 531 * @sense: pool of sense 532 * @sense_dma: 533 * @sense_dma_pool: 534 * @reply_depth: hba reply queue depth: 535 * @reply_sz: per reply frame size: 536 * @reply: pool of replys: 537 * @reply_dma: 538 * @reply_dma_pool: 539 * @reply_free_queue_depth: reply free depth 540 * @reply_free: pool for reply free queue (32 bit addr) 541 * @reply_free_dma: 542 * @reply_free_dma_pool: 543 * @reply_free_host_index: tail index in pool to insert free replys 544 * @reply_post_queue_depth: reply post queue depth 545 * @reply_post_free: pool for reply post (64bit descriptor) 546 * @reply_post_free_dma: 547 * @reply_post_free_dma_pool: 548 * @reply_post_host_index: head index in the pool where FW completes IO 549 */ 550struct MPT2SAS_ADAPTER { 551 struct list_head list; 552 struct Scsi_Host *shost; 553 u8 id; 554 u32 pci_irq; 555 char name[MPT_NAME_LENGTH]; 556 char tmp_string[MPT_STRING_LENGTH]; 557 struct pci_dev *pdev; 558 Mpi2SystemInterfaceRegs_t __iomem *chip; 559 unsigned long chip_phys; 560 unsigned long pio_chip; 561 int logging_level; 562 u8 ir_firmware; 563 int bars; 564 u8 mask_interrupts; 565 566 /* fw fault handler */ 567 char fault_reset_work_q_name[20]; 568 struct workqueue_struct *fault_reset_work_q; 569 struct delayed_work fault_reset_work; 570 571 /* fw event handler */ 572 char firmware_event_name[20]; 573 struct workqueue_struct *firmware_event_thread; 574 u8 fw_events_off; 575 spinlock_t fw_event_lock; 576 struct list_head fw_event_list; 577 578 /* misc flags */ 579 int aen_event_read_flag; 580 u8 broadcast_aen_busy; 581 u8 shost_recovery; 582 spinlock_t ioc_reset_in_progress_lock; 583 u8 ioc_link_reset_in_progress; 584 u8 ignore_loginfos; 585 u8 remove_host; 586 u8 wait_for_port_enable_to_complete; 587 588 u8 msix_enable; 589 u16 msix_vector_count; 590 u32 *msix_table; 591 u32 *msix_table_backup; 592 593 /* internal commands, callback index */ 594 u8 scsi_io_cb_idx; 595 u8 tm_cb_idx; 596 u8 transport_cb_idx; 597 u8 ctl_cb_idx; 598 u8 base_cb_idx; 599 u8 config_cb_idx; 600 struct _internal_cmd base_cmds; 601 struct _internal_cmd transport_cmds; 602 struct _internal_cmd tm_cmds; 603 struct _internal_cmd ctl_cmds; 604 struct _internal_cmd config_cmds; 605 606 MPT_ADD_SGE base_add_sg_single; 607 608 /* event log */ 609 u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS]; 610 u32 event_context; 611 void *event_log; 612 u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS]; 613 614 /* static config pages */ 615 Mpi2IOCFactsReply_t facts; 616 Mpi2PortFactsReply_t *pfacts; 617 Mpi2ManufacturingPage0_t manu_pg0; 618 Mpi2BiosPage2_t bios_pg2; 619 Mpi2BiosPage3_t bios_pg3; 620 Mpi2IOCPage8_t ioc_pg8; 621 Mpi2IOUnitPage0_t iounit_pg0; 622 Mpi2IOUnitPage1_t iounit_pg1; 623 624 struct _boot_device req_boot_device; 625 struct _boot_device req_alt_boot_device; 626 struct _boot_device current_boot_device; 627 628 /* sas hba, expander, and device list */ 629 struct _sas_node sas_hba; 630 struct list_head sas_expander_list; 631 spinlock_t sas_node_lock; 632 struct list_head sas_device_list; 633 struct list_head sas_device_init_list; 634 spinlock_t sas_device_lock; 635 struct list_head raid_device_list; 636 spinlock_t raid_device_lock; 637 u8 io_missing_delay; 638 u16 device_missing_delay; 639 int sas_id; 640 641 /* config page */ 642 u16 config_page_sz; 643 void *config_page; 644 dma_addr_t config_page_dma; 645 646 /* request */ 647 u16 sge_size; 648 u16 request_depth; 649 u16 request_sz; 650 u8 *request; 651 dma_addr_t request_dma; 652 u32 request_dma_sz; 653 struct request_tracker *scsi_lookup; 654 spinlock_t scsi_lookup_lock; 655 struct list_head free_list; 656 int pending_io_count; 657 wait_queue_head_t reset_wq; 658 659 /* chain */ 660 u8 *chain; 661 dma_addr_t chain_dma; 662 u16 max_sges_in_main_message; 663 u16 max_sges_in_chain_message; 664 u16 chains_needed_per_io; 665 u16 chain_offset_value_for_main_message; 666 u16 chain_depth; 667 668 /* sense */ 669 u8 *sense; 670 dma_addr_t sense_dma; 671 struct dma_pool *sense_dma_pool; 672 673 /* reply */ 674 u16 reply_sz; 675 u8 *reply; 676 dma_addr_t reply_dma; 677 struct dma_pool *reply_dma_pool; 678 679 /* reply free queue */ 680 u16 reply_free_queue_depth; 681 u32 *reply_free; 682 dma_addr_t reply_free_dma; 683 struct dma_pool *reply_free_dma_pool; 684 u32 reply_free_host_index; 685 686 /* reply post queue */ 687 u16 reply_post_queue_depth; 688 Mpi2ReplyDescriptorsUnion_t *reply_post_free; 689 dma_addr_t reply_post_free_dma; 690 struct dma_pool *reply_post_free_dma_pool; 691 u32 reply_post_host_index; 692 693 /* diag buffer support */ 694 u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT]; 695 u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT]; 696 dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT]; 697 u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT]; 698 u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT]; 699 Mpi2ManufacturingPage10_t manu_pg10; 700 u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23]; 701 u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT]; 702}; 703 704typedef void (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, 705 u32 reply); 706 707 708/* base shared API */ 709extern struct list_head mpt2sas_ioc_list; 710void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc); 711void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc); 712 713int mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc); 714void mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc); 715int mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc); 716void mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc); 717int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag, 718 enum reset_type type); 719 720void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid); 721void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid); 722void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr); 723dma_addr_t mpt2sas_base_get_msg_frame_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid); 724dma_addr_t mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid); 725 726u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx); 727void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid); 728void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id, 729 u16 handle); 730void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id); 731void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid, 732 u8 vf_id, u16 io_index); 733void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id); 734void mpt2sas_base_initialize_callback_handler(void); 735u8 mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func); 736void mpt2sas_base_release_callback_handler(u8 cb_idx); 737 738void mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply); 739void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr); 740 741u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked); 742 743void mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code); 744int mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc, 745 Mpi2SasIoUnitControlReply_t *mpi_reply, Mpi2SasIoUnitControlRequest_t 746 *mpi_request); 747int mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc, 748 Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request); 749void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type); 750 751/* scsih shared API */ 752void mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun, 753 u8 type, u16 smid_task, ulong timeout); 754void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle); 755void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle); 756struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *ioc, 757 u16 handle); 758struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER 759 *ioc, u64 sas_address); 760struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address( 761 struct MPT2SAS_ADAPTER *ioc, u64 sas_address); 762 763void mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply); 764void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase); 765 766/* config shared API */ 767void mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply); 768int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys); 769int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, 770 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page); 771int mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc, 772 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage10_t *config_page); 773int mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 774 *mpi_reply, Mpi2BiosPage2_t *config_page); 775int mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 776 *mpi_reply, Mpi2BiosPage3_t *config_page); 777int mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 778 *mpi_reply, Mpi2IOUnitPage0_t *config_page); 779int mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 780 *mpi_reply, Mpi2SasDevicePage0_t *config_page, u32 form, u32 handle); 781int mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 782 *mpi_reply, Mpi2SasDevicePage1_t *config_page, u32 form, u32 handle); 783int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 784 *mpi_reply, Mpi2SasIOUnitPage0_t *config_page, u16 sz); 785int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 786 *mpi_reply, Mpi2IOUnitPage1_t *config_page); 787int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 788 *mpi_reply, Mpi2IOUnitPage1_t config_page); 789int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 790 *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz); 791int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 792 *mpi_reply, Mpi2IOCPage8_t *config_page); 793int mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 794 *mpi_reply, Mpi2ExpanderPage0_t *config_page, u32 form, u32 handle); 795int mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 796 *mpi_reply, Mpi2ExpanderPage1_t *config_page, u32 phy_number, u16 handle); 797int mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 798 *mpi_reply, Mpi2SasEnclosurePage0_t *config_page, u32 form, u32 handle); 799int mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 800 *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number); 801int mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 802 *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number); 803int mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 804 *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form, u32 handle); 805int mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 *num_pds); 806int mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 807 *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form, u32 handle, u16 sz); 808int mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t 809 *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 form, 810 u32 form_specific); 811int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle, 812 u16 *volume_handle); 813int mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER *ioc, u16 volume_handle, 814 u64 *wwid); 815/* ctl shared API */ 816extern struct device_attribute *mpt2sas_host_attrs[]; 817extern struct device_attribute *mpt2sas_dev_attrs[]; 818void mpt2sas_ctl_init(void); 819void mpt2sas_ctl_exit(void); 820void mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply); 821void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase); 822void mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply); 823void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc, 824 Mpi2EventNotificationReply_t *mpi_reply); 825 826/* transport shared API */ 827void mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply); 828struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, 829 u16 handle, u16 parent_handle); 830void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address, 831 u16 parent_handle); 832int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy 833 *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev); 834int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy 835 *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev); 836void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc, u16 handle, 837 u16 attached_handle, u8 phy_number, u8 link_rate); 838extern struct sas_function_template mpt2sas_transport_functions; 839extern struct scsi_transport_template *mpt2sas_transport_template; 840extern int scsi_internal_device_block(struct scsi_device *sdev); 841extern int scsi_internal_device_unblock(struct scsi_device *sdev); 842 843#endif /* MPT2SAS_BASE_H_INCLUDED */ 844