[SCSI] mpt2sas: setting SDEV into RUNNING state from Interrupt context
[linux-2.6-block.git] / drivers / scsi / mpt2sas / mpt2sas_base.h
CommitLineData
635374e7
EM
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>
3c621b3e 64#include <scsi/scsi_eh.h>
635374e7
EM
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"
f9b14c91 72#define MPT2SAS_DRIVER_VERSION "01.100.04.00"
2b69a8a2 73#define MPT2SAS_MAJOR_VERSION 01
635374e7 74#define MPT2SAS_MINOR_VERSION 100
f9b14c91 75#define MPT2SAS_BUILD_VERSION 04
3b8b5c9b 76#define MPT2SAS_RELEASE_VERSION 00
635374e7
EM
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 */
cd4e12e8 122#define MPT2_IOC_RUNNING 4 /* shost running */
635374e7
EM
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
f0f9cc1f
EM
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
635374e7
EM
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 */
200struct MPT2SAS_DEVICE {
201 struct MPT2SAS_TARGET *sas_target;
202 unsigned int lun;
203 u32 flags;
204 u8 configured_lun;
205 u8 block;
206 u8 tlr_snoop_check;
207};
208
209#define MPT2_CMD_NOT_USED 0x8000 /* free */
210#define MPT2_CMD_COMPLETE 0x0001 /* completed */
211#define MPT2_CMD_PENDING 0x0002 /* pending */
212#define MPT2_CMD_REPLY_VALID 0x0004 /* reply is valid */
213#define MPT2_CMD_RESET 0x0008 /* host reset dropped the command */
214
215/**
216 * struct _internal_cmd - internal commands struct
217 * @mutex: mutex
218 * @done: completion
219 * @reply: reply message pointer
220 * @status: MPT2_CMD_XXX status
221 * @smid: system message id
222 */
223struct _internal_cmd {
224 struct mutex mutex;
225 struct completion done;
226 void *reply;
227 u16 status;
228 u16 smid;
229};
230
231/*
232 * SAS Topology Structures
233 */
234
235/**
236 * struct _sas_device - attached device information
237 * @list: sas device list
238 * @starget: starget object
239 * @sas_address: device sas address
240 * @device_name: retrieved from the SAS IDENTIFY frame.
241 * @handle: device handle
242 * @parent_handle: handle to parent device
243 * @enclosure_handle: enclosure handle
244 * @enclosure_logical_id: enclosure logical identifier
245 * @volume_handle: volume handle (valid when hidden raid member)
246 * @volume_wwid: volume unique identifier
247 * @device_info: bitfield provides detailed info about the device
248 * @id: target id
249 * @channel: target channel
250 * @slot: number number
251 * @hidden_raid_component: set to 1 when this is a raid member
252 * @responding: used in _scsih_sas_device_mark_responding
253 */
254struct _sas_device {
255 struct list_head list;
256 struct scsi_target *starget;
257 u64 sas_address;
258 u64 device_name;
259 u16 handle;
260 u16 parent_handle;
261 u16 enclosure_handle;
262 u64 enclosure_logical_id;
263 u16 volume_handle;
264 u64 volume_wwid;
265 u32 device_info;
266 int id;
267 int channel;
268 u16 slot;
269 u8 hidden_raid_component;
270 u8 responding;
271};
272
273/**
274 * struct _raid_device - raid volume link list
275 * @list: sas device list
276 * @starget: starget object
277 * @sdev: scsi device struct (volumes are single lun)
278 * @wwid: unique identifier for the volume
279 * @handle: device handle
280 * @id: target id
281 * @channel: target channel
282 * @volume_type: the raid level
283 * @device_info: bitfield provides detailed info about the hidden components
284 * @num_pds: number of hidden raid components
285 * @responding: used in _scsih_raid_device_mark_responding
286 */
287struct _raid_device {
288 struct list_head list;
289 struct scsi_target *starget;
290 struct scsi_device *sdev;
291 u64 wwid;
292 u16 handle;
293 int id;
294 int channel;
295 u8 volume_type;
296 u32 device_info;
297 u8 num_pds;
298 u8 responding;
299};
300
301/**
302 * struct _boot_device - boot device info
303 * @is_raid: flag to indicate whether this is volume
304 * @device: holds pointer for either struct _sas_device or
305 * struct _raid_device
306 */
307struct _boot_device {
308 u8 is_raid;
309 void *device;
310};
311
312/**
313 * struct _sas_port - wide/narrow sas port information
314 * @port_list: list of ports belonging to expander
315 * @handle: device handle for this port
316 * @sas_address: sas address of this port
317 * @num_phys: number of phys belonging to this port
318 * @remote_identify: attached device identification
319 * @rphy: sas transport rphy object
320 * @port: sas transport wide/narrow port object
321 * @phy_list: _sas_phy list objects belonging to this port
322 */
323struct _sas_port {
324 struct list_head port_list;
325 u16 handle;
326 u64 sas_address;
327 u8 num_phys;
328 struct sas_identify remote_identify;
329 struct sas_rphy *rphy;
330 struct sas_port *port;
331 struct list_head phy_list;
332};
333
334/**
335 * struct _sas_phy - phy information
336 * @port_siblings: list of phys belonging to a port
337 * @identify: phy identification
338 * @remote_identify: attached device identification
339 * @phy: sas transport phy object
340 * @phy_id: unique phy id
341 * @handle: device handle for this phy
342 * @attached_handle: device handle for attached device
343 */
344struct _sas_phy {
345 struct list_head port_siblings;
346 struct sas_identify identify;
347 struct sas_identify remote_identify;
348 struct sas_phy *phy;
349 u8 phy_id;
350 u16 handle;
351 u16 attached_handle;
352};
353
354/**
355 * struct _sas_node - sas_host/expander information
356 * @list: list of expanders
357 * @parent_dev: parent device class
358 * @num_phys: number phys belonging to this sas_host/expander
359 * @sas_address: sas address of this sas_host/expander
360 * @handle: handle for this sas_host/expander
361 * @parent_handle: parent handle
362 * @enclosure_handle: handle for this a member of an enclosure
363 * @device_info: bitwise defining capabilities of this sas_host/expander
364 * @responding: used in _scsih_expander_device_mark_responding
365 * @phy: a list of phys that make up this sas_host/expander
366 * @sas_port_list: list of ports attached to this sas_host/expander
367 */
368struct _sas_node {
369 struct list_head list;
370 struct device *parent_dev;
371 u8 num_phys;
372 u64 sas_address;
373 u16 handle;
374 u16 parent_handle;
375 u16 enclosure_handle;
376 u64 enclosure_logical_id;
377 u8 responding;
378 struct _sas_phy *phy;
379 struct list_head sas_port_list;
380};
381
382/**
383 * enum reset_type - reset state
384 * @FORCE_BIG_HAMMER: issue diagnostic reset
385 * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
386 */
387enum reset_type {
388 FORCE_BIG_HAMMER,
389 SOFT_RESET,
390};
391
392/**
393 * struct request_tracker - firmware request tracker
394 * @smid: system message id
395 * @scmd: scsi request pointer
396 * @cb_idx: callback index
397 * @chain_list: list of chains associated to this IO
398 * @tracker_list: list of free request (ioc->free_list)
399 */
400struct request_tracker {
401 u16 smid;
402 struct scsi_cmnd *scmd;
403 u8 cb_idx;
404 struct list_head tracker_list;
405};
406
407typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
408
409/**
410 * struct MPT2SAS_ADAPTER - per adapter struct
411 * @list: ioc_list
412 * @shost: shost object
413 * @id: unique adapter id
414 * @pci_irq: irq number
415 * @name: generic ioc string
416 * @tmp_string: tmp string used for logging
417 * @pdev: pci pdev object
418 * @chip: memory mapped register space
419 * @chip_phys: physical addrss prior to mapping
420 * @pio_chip: I/O mapped register space
421 * @logging_level: see mpt2sas_debug.h
422 * @ir_firmware: IR firmware present
423 * @bars: bitmask of BAR's that must be configured
424 * @mask_interrupts: ignore interrupt
425 * @fault_reset_work_q_name: fw fault work queue
426 * @fault_reset_work_q: ""
427 * @fault_reset_work: ""
428 * @firmware_event_name: fw event work queue
429 * @firmware_event_thread: ""
430 * @fw_events_off: flag to turn off fw event handling
431 * @fw_event_lock:
432 * @fw_event_list: list of fw events
433 * @aen_event_read_flag: event log was read
434 * @broadcast_aen_busy: broadcast aen waiting to be serviced
155dd4c7 435 * @shost_recovery: host reset in progress
635374e7
EM
436 * @ioc_reset_in_progress_lock:
437 * @ioc_link_reset_in_progress: phy/hard reset in progress
438 * @ignore_loginfos: ignore loginfos during task managment
439 * @remove_host: flag for when driver unloads, to avoid sending dev resets
440 * @wait_for_port_enable_to_complete:
441 * @msix_enable: flag indicating msix is enabled
442 * @msix_vector_count: number msix vectors
443 * @msix_table: virt address to the msix table
444 * @msix_table_backup: backup msix table
445 * @scsi_io_cb_idx: shost generated commands
446 * @tm_cb_idx: task management commands
447 * @transport_cb_idx: transport internal commands
448 * @ctl_cb_idx: clt internal commands
449 * @base_cb_idx: base internal commands
450 * @config_cb_idx: base internal commands
451 * @base_cmds:
452 * @transport_cmds:
453 * @tm_cmds:
454 * @ctl_cmds:
455 * @config_cmds:
456 * @base_add_sg_single: handler for either 32/64 bit sgl's
457 * @event_type: bits indicating which events to log
458 * @event_context: unique id for each logged event
459 * @event_log: event log pointer
460 * @event_masks: events that are masked
461 * @facts: static facts data
462 * @pfacts: static port facts data
463 * @manu_pg0: static manufacturing page 0
464 * @bios_pg2: static bios page 2
465 * @bios_pg3: static bios page 3
466 * @ioc_pg8: static ioc page 8
467 * @iounit_pg0: static iounit page 0
468 * @iounit_pg1: static iounit page 1
469 * @sas_hba: sas host object
470 * @sas_expander_list: expander object list
471 * @sas_node_lock:
472 * @sas_device_list: sas device object list
473 * @sas_device_init_list: sas device object list (used only at init time)
474 * @sas_device_lock:
475 * @io_missing_delay: time for IO completed by fw when PDR enabled
476 * @device_missing_delay: time for device missing by fw when PDR enabled
477 * @config_page_sz: config page size
478 * @config_page: reserve memory for config page payload
479 * @config_page_dma:
480 * @sge_size: sg element size for either 32/64 bit
481 * @request_depth: hba request queue depth
482 * @request_sz: per request frame size
483 * @request: pool of request frames
484 * @request_dma:
485 * @request_dma_sz:
486 * @scsi_lookup: firmware request tracker list
487 * @scsi_lookup_lock:
488 * @free_list: free list of request
489 * @chain: pool of chains
490 * @pending_io_count:
491 * @reset_wq:
492 * @chain_dma:
493 * @max_sges_in_main_message: number sg elements in main message
494 * @max_sges_in_chain_message: number sg elements per chain
495 * @chains_needed_per_io: max chains per io
496 * @chain_offset_value_for_main_message: location 1st sg in main
497 * @chain_depth: total chains allocated
498 * @sense: pool of sense
499 * @sense_dma:
500 * @sense_dma_pool:
501 * @reply_depth: hba reply queue depth:
502 * @reply_sz: per reply frame size:
503 * @reply: pool of replys:
504 * @reply_dma:
505 * @reply_dma_pool:
506 * @reply_free_queue_depth: reply free depth
507 * @reply_free: pool for reply free queue (32 bit addr)
508 * @reply_free_dma:
509 * @reply_free_dma_pool:
510 * @reply_free_host_index: tail index in pool to insert free replys
511 * @reply_post_queue_depth: reply post queue depth
512 * @reply_post_free: pool for reply post (64bit descriptor)
513 * @reply_post_free_dma:
514 * @reply_post_free_dma_pool:
515 * @reply_post_host_index: head index in the pool where FW completes IO
516 */
517struct MPT2SAS_ADAPTER {
518 struct list_head list;
519 struct Scsi_Host *shost;
520 u8 id;
521 u32 pci_irq;
522 char name[MPT_NAME_LENGTH];
523 char tmp_string[MPT_STRING_LENGTH];
524 struct pci_dev *pdev;
525 Mpi2SystemInterfaceRegs_t __iomem *chip;
526 unsigned long chip_phys;
527 unsigned long pio_chip;
528 int logging_level;
529 u8 ir_firmware;
530 int bars;
531 u8 mask_interrupts;
532
533 /* fw fault handler */
534 char fault_reset_work_q_name[20];
535 struct workqueue_struct *fault_reset_work_q;
536 struct delayed_work fault_reset_work;
537
538 /* fw event handler */
539 char firmware_event_name[20];
540 struct workqueue_struct *firmware_event_thread;
541 u8 fw_events_off;
542 spinlock_t fw_event_lock;
543 struct list_head fw_event_list;
544
545 /* misc flags */
546 int aen_event_read_flag;
547 u8 broadcast_aen_busy;
635374e7
EM
548 u8 shost_recovery;
549 spinlock_t ioc_reset_in_progress_lock;
550 u8 ioc_link_reset_in_progress;
551 u8 ignore_loginfos;
552 u8 remove_host;
553 u8 wait_for_port_enable_to_complete;
554
555 u8 msix_enable;
556 u16 msix_vector_count;
557 u32 *msix_table;
558 u32 *msix_table_backup;
559
560 /* internal commands, callback index */
561 u8 scsi_io_cb_idx;
562 u8 tm_cb_idx;
563 u8 transport_cb_idx;
564 u8 ctl_cb_idx;
565 u8 base_cb_idx;
566 u8 config_cb_idx;
567 struct _internal_cmd base_cmds;
568 struct _internal_cmd transport_cmds;
569 struct _internal_cmd tm_cmds;
570 struct _internal_cmd ctl_cmds;
571 struct _internal_cmd config_cmds;
572
573 MPT_ADD_SGE base_add_sg_single;
574
575 /* event log */
576 u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
577 u32 event_context;
578 void *event_log;
579 u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
580
581 /* static config pages */
582 Mpi2IOCFactsReply_t facts;
583 Mpi2PortFactsReply_t *pfacts;
584 Mpi2ManufacturingPage0_t manu_pg0;
585 Mpi2BiosPage2_t bios_pg2;
586 Mpi2BiosPage3_t bios_pg3;
587 Mpi2IOCPage8_t ioc_pg8;
588 Mpi2IOUnitPage0_t iounit_pg0;
589 Mpi2IOUnitPage1_t iounit_pg1;
590
591 struct _boot_device req_boot_device;
592 struct _boot_device req_alt_boot_device;
593 struct _boot_device current_boot_device;
594
595 /* sas hba, expander, and device list */
596 struct _sas_node sas_hba;
597 struct list_head sas_expander_list;
598 spinlock_t sas_node_lock;
599 struct list_head sas_device_list;
600 struct list_head sas_device_init_list;
601 spinlock_t sas_device_lock;
602 struct list_head raid_device_list;
603 spinlock_t raid_device_lock;
604 u8 io_missing_delay;
605 u16 device_missing_delay;
606 int sas_id;
607
608 /* config page */
609 u16 config_page_sz;
610 void *config_page;
611 dma_addr_t config_page_dma;
612
613 /* request */
614 u16 sge_size;
615 u16 request_depth;
616 u16 request_sz;
617 u8 *request;
618 dma_addr_t request_dma;
619 u32 request_dma_sz;
620 struct request_tracker *scsi_lookup;
621 spinlock_t scsi_lookup_lock;
622 struct list_head free_list;
623 int pending_io_count;
624 wait_queue_head_t reset_wq;
625
626 /* chain */
627 u8 *chain;
628 dma_addr_t chain_dma;
629 u16 max_sges_in_main_message;
630 u16 max_sges_in_chain_message;
631 u16 chains_needed_per_io;
632 u16 chain_offset_value_for_main_message;
633 u16 chain_depth;
634
635 /* sense */
636 u8 *sense;
637 dma_addr_t sense_dma;
638 struct dma_pool *sense_dma_pool;
639
640 /* reply */
641 u16 reply_sz;
642 u8 *reply;
643 dma_addr_t reply_dma;
644 struct dma_pool *reply_dma_pool;
645
646 /* reply free queue */
647 u16 reply_free_queue_depth;
648 u32 *reply_free;
649 dma_addr_t reply_free_dma;
650 struct dma_pool *reply_free_dma_pool;
651 u32 reply_free_host_index;
652
653 /* reply post queue */
654 u16 reply_post_queue_depth;
655 Mpi2ReplyDescriptorsUnion_t *reply_post_free;
656 dma_addr_t reply_post_free_dma;
657 struct dma_pool *reply_post_free_dma_pool;
658 u32 reply_post_host_index;
659
660 /* diag buffer support */
661 u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
662 u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
663 dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
664 u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
665 u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
666 u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
667 u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
668};
669
670typedef void (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID,
671 u32 reply);
672
673
674/* base shared API */
ba33fadf 675extern struct list_head mpt2sas_ioc_list;
e4750c98
KD
676void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc);
677void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc);
635374e7
EM
678
679int mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc);
680void mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc);
681int mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc);
682void mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc);
683int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
684 enum reset_type type);
685
686void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid);
687void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid);
688void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr);
689dma_addr_t mpt2sas_base_get_msg_frame_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid);
690dma_addr_t mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid);
691
692u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
693void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid);
694void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id,
695 u16 handle);
696void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id);
697void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid,
698 u8 vf_id, u16 io_index);
699void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id);
700void mpt2sas_base_initialize_callback_handler(void);
701u8 mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func);
702void mpt2sas_base_release_callback_handler(u8 cb_idx);
703
704void mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply);
705void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr);
706
707u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked);
708
709void mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code);
710int mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
711 Mpi2SasIoUnitControlReply_t *mpi_reply, Mpi2SasIoUnitControlRequest_t
712 *mpi_request);
713int mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
714 Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
715void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type);
716
717/* scsih shared API */
718void mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
719 u8 type, u16 smid_task, ulong timeout);
720void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
721void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
722struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *ioc,
723 u16 handle);
724struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER
725 *ioc, u64 sas_address);
726struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address(
727 struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
728
729void mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply);
730void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
731
732/* config shared API */
733void mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply);
734int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys);
735int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
736 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
737int mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
738 *mpi_reply, Mpi2BiosPage2_t *config_page);
739int mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
740 *mpi_reply, Mpi2BiosPage3_t *config_page);
741int mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
742 *mpi_reply, Mpi2IOUnitPage0_t *config_page);
743int mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
744 *mpi_reply, Mpi2SasDevicePage0_t *config_page, u32 form, u32 handle);
745int mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
746 *mpi_reply, Mpi2SasDevicePage1_t *config_page, u32 form, u32 handle);
747int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
748 *mpi_reply, Mpi2SasIOUnitPage0_t *config_page, u16 sz);
749int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
750 *mpi_reply, Mpi2IOUnitPage1_t *config_page);
751int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
752 *mpi_reply, Mpi2IOUnitPage1_t config_page);
753int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
754 *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
755int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
756 *mpi_reply, Mpi2IOCPage8_t *config_page);
757int mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
758 *mpi_reply, Mpi2ExpanderPage0_t *config_page, u32 form, u32 handle);
759int mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
760 *mpi_reply, Mpi2ExpanderPage1_t *config_page, u32 phy_number, u16 handle);
761int mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
762 *mpi_reply, Mpi2SasEnclosurePage0_t *config_page, u32 form, u32 handle);
763int mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
764 *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
765int mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
766 *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
767int mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
768 *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form, u32 handle);
769int mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 *num_pds);
770int mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
771 *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form, u32 handle, u16 sz);
772int mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
773 *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 form,
774 u32 form_specific);
775int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
776 u16 *volume_handle);
777int mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER *ioc, u16 volume_handle,
778 u64 *wwid);
779
780/* ctl shared API */
781extern struct device_attribute *mpt2sas_host_attrs[];
782extern struct device_attribute *mpt2sas_dev_attrs[];
783void mpt2sas_ctl_init(void);
784void mpt2sas_ctl_exit(void);
785void mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply);
786void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
787void mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply);
788void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,
789 Mpi2EventNotificationReply_t *mpi_reply);
790
791/* transport shared API */
792void mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply);
793struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc,
794 u16 handle, u16 parent_handle);
795void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
796 u16 parent_handle);
797int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
798 *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
799int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
800 *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev);
cc0f5207 801void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc, u16 handle,
635374e7
EM
802 u16 attached_handle, u8 phy_number, u8 link_rate);
803extern struct sas_function_template mpt2sas_transport_functions;
804extern struct scsi_transport_template *mpt2sas_transport_template;
34a03bef
KD
805extern int scsi_internal_device_block(struct scsi_device *sdev);
806extern int scsi_internal_device_unblock(struct scsi_device *sdev);
635374e7
EM
807
808#endif /* MPT2SAS_BASE_H_INCLUDED */