blob: b6dd3a5de7f9d50600db25d86c66e79590042ea1 [file] [log] [blame]
Eric Moore635374e2009-03-09 01:21:12 -06001/*
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
Kashyap, Desai31b7f2e2010-03-17 16:28:04 +05306 * Copyright (C) 2007-2010 LSI Corporation
Eric Moore635374e2009-03-09 01:21:12 -06007 * (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>
Eric Moore3c621b32009-05-18 12:59:41 -060064#include <scsi/scsi_eh.h>
Eric Moore635374e2009-03-09 01:21:12 -060065
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"
nagalakshmi.nandigama@lsi.combe4a07a02012-03-20 12:10:28 +053072#define MPT2SAS_DRIVER_VERSION "13.100.00.00"
73#define MPT2SAS_MAJOR_VERSION 13
Eric Moore635374e2009-03-09 01:21:12 -060074#define MPT2SAS_MINOR_VERSION 100
Kashyap, Desai1a7d7ea2010-03-17 16:28:34 +053075#define MPT2SAS_BUILD_VERSION 00
nagalakshmi.nandigama@lsi.com6e880202011-10-19 15:37:54 +053076#define MPT2SAS_RELEASE_VERSION 00
Eric Moore635374e2009-03-09 01:21:12 -060077
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
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530104#define MPT_MAX_CALLBACKS 16
105
Eric Moore635374e2009-03-09 01:21:12 -0600106
107#define CAN_SLEEP 1
108#define NO_SLEEP 0
109
110#define INTERNAL_CMDS_COUNT 10 /* reserved cmds */
111
112#define MPI2_HIM_MASK 0xFFFFFFFF /* mask every bit*/
113
114#define MPT2SAS_INVALID_DEVICE_HANDLE 0xFFFF
115
116
117/*
118 * reset phases
119 */
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 */
123
124/*
125 * logging format
126 */
127#define MPT2SAS_FMT "%s: "
Eric Moore635374e2009-03-09 01:21:12 -0600128#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
132
133/*
Eric Mooref0f9cc12009-04-21 15:40:48 -0600134 * Dell HBA branding
135 */
136#define MPT2SAS_DELL_BRANDING_SIZE 32
137
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"
145
146/*
147 * Dell HBA SSDIDs
148 */
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
156
157/*
Kashyap, Desaifb396be2011-01-04 11:36:37 +0530158 * Intel HBA branding
159 */
nagalakshmi.nandigama@lsi.com8bad3052011-12-01 07:52:42 +0530160#define MPT2SAS_INTEL_RMS25JB080_BRANDING \
161 "Intel(R) Integrated RAID Module RMS25JB080"
162#define MPT2SAS_INTEL_RMS25JB040_BRANDING \
163 "Intel(R) Integrated RAID Module RMS25JB040"
164#define MPT2SAS_INTEL_RMS25KB080_BRANDING \
165 "Intel(R) Integrated RAID Module RMS25KB080"
166#define MPT2SAS_INTEL_RMS25KB040_BRANDING \
167 "Intel(R) Integrated RAID Module RMS25KB040"
Kashyap, Desaifb396be2011-01-04 11:36:37 +0530168#define MPT2SAS_INTEL_RMS2LL080_BRANDING \
169 "Intel Integrated RAID Module RMS2LL080"
170#define MPT2SAS_INTEL_RMS2LL040_BRANDING \
171 "Intel Integrated RAID Module RMS2LL040"
Kashyap, Desaiab3e5f62011-06-14 10:57:31 +0530172#define MPT2SAS_INTEL_RS25GB008_BRANDING \
173 "Intel(R) RAID Controller RS25GB008"
nagalakshmi.nandigama@lsi.com70e73f92011-12-01 07:43:00 +0530174#define MPT2SAS_INTEL_RAMSDALE_BRANDING \
175 "Intel 720 Series SSD"
Kashyap, Desaifb396be2011-01-04 11:36:37 +0530176/*
177 * Intel HBA SSDIDs
178 */
nagalakshmi.nandigama@lsi.com8bad3052011-12-01 07:52:42 +0530179#define MPT2SAS_INTEL_RMS25JB080_SSDID 0x3516
180#define MPT2SAS_INTEL_RMS25JB040_SSDID 0x3517
181#define MPT2SAS_INTEL_RMS25KB080_SSDID 0x3518
182#define MPT2SAS_INTEL_RMS25KB040_SSDID 0x3519
Kashyap, Desaifb396be2011-01-04 11:36:37 +0530183#define MPT2SAS_INTEL_RMS2LL080_SSDID 0x350E
184#define MPT2SAS_INTEL_RMS2LL040_SSDID 0x350F
Kashyap, Desaiab3e5f62011-06-14 10:57:31 +0530185#define MPT2SAS_INTEL_RS25GB008_SSDID 0x3000
nagalakshmi.nandigama@lsi.com70e73f92011-12-01 07:43:00 +0530186#define MPT2SAS_INTEL_RAMSDALE_SSDID 0x3700
Kashyap, Desai0a2385c2011-03-15 20:04:26 +0530187
188/*
189 * HP HBA branding
190 */
191#define MPT2SAS_HP_3PAR_SSVID 0x1590
192#define MPT2SAS_HP_2_4_INTERNAL_BRANDING "HP H220 Host Bus Adapter"
193#define MPT2SAS_HP_2_4_EXTERNAL_BRANDING "HP H221 Host Bus Adapter"
194#define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING "HP H222 Host Bus Adapter"
195#define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING "HP H220i Host Bus Adapter"
196#define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING "HP H210i Host Bus Adapter"
197
198/*
199 * HO HBA SSDIDs
200 */
201#define MPT2SAS_HP_2_4_INTERNAL_SSDID 0x0041
202#define MPT2SAS_HP_2_4_EXTERNAL_SSDID 0x0042
203#define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_SSDID 0x0043
204#define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_SSDID 0x0044
205#define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_SSDID 0x0046
206
Kashyap, Desaifb396be2011-01-04 11:36:37 +0530207/*
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530208 * WarpDrive Specific Log codes
209 */
210
211#define MPT2_WARPDRIVE_LOGENTRY (0x8002)
212#define MPT2_WARPDRIVE_LC_SSDT (0x41)
213#define MPT2_WARPDRIVE_LC_SSDLW (0x43)
214#define MPT2_WARPDRIVE_LC_SSDLF (0x44)
215#define MPT2_WARPDRIVE_LC_BRMF (0x4D)
216
217/*
Eric Moore635374e2009-03-09 01:21:12 -0600218 * per target private data
219 */
220#define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01
221#define MPT_TARGET_FLAGS_VOLUME 0x02
222#define MPT_TARGET_FLAGS_DELETED 0x04
223
224/**
225 * struct MPT2SAS_TARGET - starget private hostdata
226 * @starget: starget object
227 * @sas_address: target sas address
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530228 * @raid_device: raid_device pointer to access volume data
Eric Moore635374e2009-03-09 01:21:12 -0600229 * @handle: device handle
230 * @num_luns: number luns
231 * @flags: MPT_TARGET_FLAGS_XXX flags
232 * @deleted: target flaged for deletion
233 * @tm_busy: target is busy with TM request.
234 */
235struct MPT2SAS_TARGET {
236 struct scsi_target *starget;
237 u64 sas_address;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530238 struct _raid_device *raid_device;
Eric Moore635374e2009-03-09 01:21:12 -0600239 u16 handle;
240 int num_luns;
241 u32 flags;
242 u8 deleted;
243 u8 tm_busy;
244};
245
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530246
Eric Moore635374e2009-03-09 01:21:12 -0600247/*
248 * per device private data
249 */
250#define MPT_DEVICE_FLAGS_INIT 0x01
251#define MPT_DEVICE_TLR_ON 0x02
252
253/**
254 * struct MPT2SAS_DEVICE - sdev private hostdata
255 * @sas_target: starget private hostdata
256 * @lun: lun number
257 * @flags: MPT_DEVICE_XXX flags
258 * @configured_lun: lun is configured
259 * @block: device is in SDEV_BLOCK state
260 * @tlr_snoop_check: flag used in determining whether to disable TLR
261 */
Kashyap, Desaied79f122009-08-20 13:23:49 +0530262
263/* OEM Identifiers */
264#define MFG10_OEM_ID_INVALID (0x00000000)
265#define MFG10_OEM_ID_DELL (0x00000001)
266#define MFG10_OEM_ID_FSC (0x00000002)
267#define MFG10_OEM_ID_SUN (0x00000003)
268#define MFG10_OEM_ID_IBM (0x00000004)
269
270/* GENERIC Flags 0*/
271#define MFG10_GF0_OCE_DISABLED (0x00000001)
272#define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002)
273#define MFG10_GF0_R10_DISPLAY (0x00000004)
274#define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008)
275#define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010)
276
277/* OEM Specific Flags will come from OEM specific header files */
278typedef struct _MPI2_CONFIG_PAGE_MAN_10 {
279 MPI2_CONFIG_PAGE_HEADER Header; /* 00h */
280 U8 OEMIdentifier; /* 04h */
281 U8 Reserved1; /* 05h */
282 U16 Reserved2; /* 08h */
283 U32 Reserved3; /* 0Ch */
284 U32 GenericFlags0; /* 10h */
285 U32 GenericFlags1; /* 14h */
286 U32 Reserved4; /* 18h */
287 U32 OEMSpecificFlags0; /* 1Ch */
288 U32 OEMSpecificFlags1; /* 20h */
289 U32 Reserved5[18]; /* 24h-60h*/
290} MPI2_CONFIG_PAGE_MAN_10,
291 MPI2_POINTER PTR_MPI2_CONFIG_PAGE_MAN_10,
292 Mpi2ManufacturingPage10_t, MPI2_POINTER pMpi2ManufacturingPage10_t;
293
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530294#define MFG_PAGE10_HIDE_SSDS_MASK (0x00000003)
295#define MFG_PAGE10_HIDE_ALL_DISKS (0x00)
296#define MFG_PAGE10_EXPOSE_ALL_DISKS (0x01)
297#define MFG_PAGE10_HIDE_IF_VOL_PRESENT (0x02)
298
299
Eric Moore635374e2009-03-09 01:21:12 -0600300struct MPT2SAS_DEVICE {
301 struct MPT2SAS_TARGET *sas_target;
302 unsigned int lun;
303 u32 flags;
304 u8 configured_lun;
305 u8 block;
306 u8 tlr_snoop_check;
307};
308
309#define MPT2_CMD_NOT_USED 0x8000 /* free */
310#define MPT2_CMD_COMPLETE 0x0001 /* completed */
311#define MPT2_CMD_PENDING 0x0002 /* pending */
312#define MPT2_CMD_REPLY_VALID 0x0004 /* reply is valid */
313#define MPT2_CMD_RESET 0x0008 /* host reset dropped the command */
314
315/**
316 * struct _internal_cmd - internal commands struct
317 * @mutex: mutex
318 * @done: completion
319 * @reply: reply message pointer
Kashyap, Desai769578f2010-06-17 13:49:28 +0530320 * @sense: sense data
Eric Moore635374e2009-03-09 01:21:12 -0600321 * @status: MPT2_CMD_XXX status
322 * @smid: system message id
323 */
324struct _internal_cmd {
325 struct mutex mutex;
326 struct completion done;
327 void *reply;
Kashyap, Desai769578f2010-06-17 13:49:28 +0530328 void *sense;
Eric Moore635374e2009-03-09 01:21:12 -0600329 u16 status;
330 u16 smid;
331};
332
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530333
Eric Moore635374e2009-03-09 01:21:12 -0600334/**
335 * struct _sas_device - attached device information
336 * @list: sas device list
337 * @starget: starget object
338 * @sas_address: device sas address
339 * @device_name: retrieved from the SAS IDENTIFY frame.
340 * @handle: device handle
Kashyap, Desaic5e039b2009-09-23 17:21:29 +0530341 * @sas_address_parent: sas address of parent expander or sas host
Eric Moore635374e2009-03-09 01:21:12 -0600342 * @enclosure_handle: enclosure handle
343 * @enclosure_logical_id: enclosure logical identifier
344 * @volume_handle: volume handle (valid when hidden raid member)
345 * @volume_wwid: volume unique identifier
346 * @device_info: bitfield provides detailed info about the device
347 * @id: target id
348 * @channel: target channel
349 * @slot: number number
Kashyap, Desai7fbae672010-06-17 13:45:17 +0530350 * @phy: phy identifier provided in sas device page 0
Eric Moore635374e2009-03-09 01:21:12 -0600351 * @responding: used in _scsih_sas_device_mark_responding
352 */
353struct _sas_device {
354 struct list_head list;
355 struct scsi_target *starget;
356 u64 sas_address;
357 u64 device_name;
358 u16 handle;
Kashyap, Desaic5e039b2009-09-23 17:21:29 +0530359 u64 sas_address_parent;
Eric Moore635374e2009-03-09 01:21:12 -0600360 u16 enclosure_handle;
361 u64 enclosure_logical_id;
362 u16 volume_handle;
363 u64 volume_wwid;
364 u32 device_info;
365 int id;
366 int channel;
367 u16 slot;
Kashyap, Desai7fbae672010-06-17 13:45:17 +0530368 u8 phy;
Eric Moore635374e2009-03-09 01:21:12 -0600369 u8 responding;
370};
371
372/**
373 * struct _raid_device - raid volume link list
374 * @list: sas device list
375 * @starget: starget object
376 * @sdev: scsi device struct (volumes are single lun)
377 * @wwid: unique identifier for the volume
378 * @handle: device handle
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530379 * @block_size: Block size of the volume
Eric Moore635374e2009-03-09 01:21:12 -0600380 * @id: target id
381 * @channel: target channel
382 * @volume_type: the raid level
383 * @device_info: bitfield provides detailed info about the hidden components
384 * @num_pds: number of hidden raid components
385 * @responding: used in _scsih_raid_device_mark_responding
Kashyap, Desaif7c95ef2009-12-16 18:54:42 +0530386 * @percent_complete: resync percent complete
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530387 * @direct_io_enabled: Whether direct io to PDs are allowed or not
388 * @stripe_exponent: X where 2powX is the stripe sz in blocks
nagalakshmi.nandigama@lsi.comba96bd02011-12-01 07:51:55 +0530389 * @block_exponent: X where 2powX is the block sz in bytes
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530390 * @max_lba: Maximum number of LBA in the volume
391 * @stripe_sz: Stripe Size of the volume
392 * @device_info: Device info of the volume member disk
393 * @pd_handle: Array of handles of the physical drives for direct I/O in le16
Eric Moore635374e2009-03-09 01:21:12 -0600394 */
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530395#define MPT_MAX_WARPDRIVE_PDS 8
Eric Moore635374e2009-03-09 01:21:12 -0600396struct _raid_device {
397 struct list_head list;
398 struct scsi_target *starget;
399 struct scsi_device *sdev;
400 u64 wwid;
401 u16 handle;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530402 u16 block_sz;
Eric Moore635374e2009-03-09 01:21:12 -0600403 int id;
404 int channel;
405 u8 volume_type;
Eric Moore635374e2009-03-09 01:21:12 -0600406 u8 num_pds;
407 u8 responding;
Kashyap, Desaif7c95ef2009-12-16 18:54:42 +0530408 u8 percent_complete;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530409 u8 direct_io_enabled;
410 u8 stripe_exponent;
nagalakshmi.nandigama@lsi.comba96bd02011-12-01 07:51:55 +0530411 u8 block_exponent;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530412 u64 max_lba;
413 u32 stripe_sz;
414 u32 device_info;
415 u16 pd_handle[MPT_MAX_WARPDRIVE_PDS];
Eric Moore635374e2009-03-09 01:21:12 -0600416};
417
418/**
419 * struct _boot_device - boot device info
420 * @is_raid: flag to indicate whether this is volume
421 * @device: holds pointer for either struct _sas_device or
422 * struct _raid_device
423 */
424struct _boot_device {
425 u8 is_raid;
426 void *device;
427};
428
429/**
430 * struct _sas_port - wide/narrow sas port information
431 * @port_list: list of ports belonging to expander
Eric Moore635374e2009-03-09 01:21:12 -0600432 * @num_phys: number of phys belonging to this port
433 * @remote_identify: attached device identification
434 * @rphy: sas transport rphy object
435 * @port: sas transport wide/narrow port object
436 * @phy_list: _sas_phy list objects belonging to this port
437 */
438struct _sas_port {
439 struct list_head port_list;
Eric Moore635374e2009-03-09 01:21:12 -0600440 u8 num_phys;
441 struct sas_identify remote_identify;
442 struct sas_rphy *rphy;
443 struct sas_port *port;
444 struct list_head phy_list;
445};
446
447/**
448 * struct _sas_phy - phy information
449 * @port_siblings: list of phys belonging to a port
450 * @identify: phy identification
451 * @remote_identify: attached device identification
452 * @phy: sas transport phy object
453 * @phy_id: unique phy id
454 * @handle: device handle for this phy
455 * @attached_handle: device handle for attached device
Kashyap, Desai38c29112010-04-05 14:18:34 +0530456 * @phy_belongs_to_port: port has been created for this phy
Eric Moore635374e2009-03-09 01:21:12 -0600457 */
458struct _sas_phy {
459 struct list_head port_siblings;
460 struct sas_identify identify;
461 struct sas_identify remote_identify;
462 struct sas_phy *phy;
463 u8 phy_id;
464 u16 handle;
465 u16 attached_handle;
Kashyap, Desai38c29112010-04-05 14:18:34 +0530466 u8 phy_belongs_to_port;
Eric Moore635374e2009-03-09 01:21:12 -0600467};
468
469/**
470 * struct _sas_node - sas_host/expander information
471 * @list: list of expanders
472 * @parent_dev: parent device class
473 * @num_phys: number phys belonging to this sas_host/expander
474 * @sas_address: sas address of this sas_host/expander
475 * @handle: handle for this sas_host/expander
Kashyap, Desaic5e039b2009-09-23 17:21:29 +0530476 * @sas_address_parent: sas address of parent expander or sas host
Eric Moore635374e2009-03-09 01:21:12 -0600477 * @enclosure_handle: handle for this a member of an enclosure
478 * @device_info: bitwise defining capabilities of this sas_host/expander
479 * @responding: used in _scsih_expander_device_mark_responding
480 * @phy: a list of phys that make up this sas_host/expander
481 * @sas_port_list: list of ports attached to this sas_host/expander
482 */
483struct _sas_node {
484 struct list_head list;
485 struct device *parent_dev;
486 u8 num_phys;
487 u64 sas_address;
488 u16 handle;
Kashyap, Desaic5e039b2009-09-23 17:21:29 +0530489 u64 sas_address_parent;
Eric Moore635374e2009-03-09 01:21:12 -0600490 u16 enclosure_handle;
491 u64 enclosure_logical_id;
492 u8 responding;
493 struct _sas_phy *phy;
494 struct list_head sas_port_list;
495};
496
497/**
498 * enum reset_type - reset state
499 * @FORCE_BIG_HAMMER: issue diagnostic reset
500 * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
501 */
502enum reset_type {
503 FORCE_BIG_HAMMER,
504 SOFT_RESET,
505};
506
507/**
Kashyap, Desai35f805b2010-11-13 04:34:06 +0530508 * struct chain_tracker - firmware chain tracker
509 * @chain_buffer: chain buffer
510 * @chain_buffer_dma: physical address
511 * @tracker_list: list of free request (ioc->free_chain_list)
512 */
513struct chain_tracker {
514 void *chain_buffer;
515 dma_addr_t chain_buffer_dma;
516 struct list_head tracker_list;
517};
518
519/**
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530520 * struct scsiio_tracker - scsi mf request tracker
Eric Moore635374e2009-03-09 01:21:12 -0600521 * @smid: system message id
522 * @scmd: scsi request pointer
523 * @cb_idx: callback index
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530524 * @direct_io: To indicate whether I/O is direct (WARPDRIVE)
Eric Moore635374e2009-03-09 01:21:12 -0600525 * @chain_list: list of chains associated to this IO
526 * @tracker_list: list of free request (ioc->free_list)
527 */
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530528struct scsiio_tracker {
Eric Moore635374e2009-03-09 01:21:12 -0600529 u16 smid;
530 struct scsi_cmnd *scmd;
531 u8 cb_idx;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530532 u8 direct_io;
Kashyap, Desai35f805b2010-11-13 04:34:06 +0530533 struct list_head chain_list;
Eric Moore635374e2009-03-09 01:21:12 -0600534 struct list_head tracker_list;
535};
536
Kashyap, Desai77e63ed2009-09-14 11:04:23 +0530537/**
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530538 * struct request_tracker - firmware request tracker
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530539 * @smid: system message id
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530540 * @cb_idx: callback index
541 * @tracker_list: list of free request (ioc->free_list)
542 */
543struct request_tracker {
544 u16 smid;
545 u8 cb_idx;
546 struct list_head tracker_list;
547};
548
549/**
Kashyap, Desai77e63ed2009-09-14 11:04:23 +0530550 * struct _tr_list - target reset list
551 * @handle: device handle
552 * @state: state machine
553 */
554struct _tr_list {
555 struct list_head list;
556 u16 handle;
557 u16 state;
558};
559
Eric Moore635374e2009-03-09 01:21:12 -0600560typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
561
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530562/**
563 * struct adapter_reply_queue - the reply queue struct
564 * @ioc: per adapter object
565 * @msix_index: msix index into vector table
566 * @vector: irq vector
567 * @reply_post_host_index: head index in the pool where FW completes IO
568 * @reply_post_free: reply post base virt address
569 * @name: the name registered to request_irq()
570 * @busy: isr is actively processing replies on another cpu
571 * @list: this list
572*/
573struct adapter_reply_queue {
574 struct MPT2SAS_ADAPTER *ioc;
575 u8 msix_index;
576 unsigned int vector;
577 u32 reply_post_host_index;
578 Mpi2ReplyDescriptorsUnion_t *reply_post_free;
579 char name[MPT_NAME_LENGTH];
580 atomic_t busy;
581 struct list_head list;
582};
583
Kashyap, Desaic97951e2011-06-14 10:54:56 +0530584/* IOC Facts and Port Facts converted from little endian to cpu */
585union mpi2_version_union {
586 MPI2_VERSION_STRUCT Struct;
587 u32 Word;
588};
589
590struct mpt2sas_facts {
591 u16 MsgVersion;
592 u16 HeaderVersion;
593 u8 IOCNumber;
594 u8 VP_ID;
595 u8 VF_ID;
596 u16 IOCExceptions;
597 u16 IOCStatus;
598 u32 IOCLogInfo;
599 u8 MaxChainDepth;
600 u8 WhoInit;
601 u8 NumberOfPorts;
602 u8 MaxMSIxVectors;
603 u16 RequestCredit;
604 u16 ProductID;
605 u32 IOCCapabilities;
606 union mpi2_version_union FWVersion;
607 u16 IOCRequestFrameSize;
608 u16 Reserved3;
609 u16 MaxInitiators;
610 u16 MaxTargets;
611 u16 MaxSasExpanders;
612 u16 MaxEnclosures;
613 u16 ProtocolFlags;
614 u16 HighPriorityCredit;
615 u16 MaxReplyDescriptorPostQueueDepth;
616 u8 ReplyFrameSize;
617 u8 MaxVolumes;
618 u16 MaxDevHandle;
619 u16 MaxPersistentEntries;
620 u16 MinDevHandle;
621};
622
623struct mpt2sas_port_facts {
624 u8 PortNumber;
625 u8 VP_ID;
626 u8 VF_ID;
627 u8 PortType;
628 u16 MaxPostedCmdBuffers;
629};
630
Eric Moore635374e2009-03-09 01:21:12 -0600631/**
Kashyap, Desaif93213d2011-06-14 10:56:43 +0530632 * enum mutex_type - task management mutex type
633 * @TM_MUTEX_OFF: mutex is not required becuase calling function is acquiring it
634 * @TM_MUTEX_ON: mutex is required
635 */
636enum mutex_type {
637 TM_MUTEX_OFF = 0,
638 TM_MUTEX_ON = 1,
639};
640
nagalakshmi.nandigama@lsi.com845a0e42011-12-01 07:42:04 +0530641typedef void (*MPT2SAS_FLUSH_RUNNING_CMDS)(struct MPT2SAS_ADAPTER *ioc);
Kashyap, Desaif93213d2011-06-14 10:56:43 +0530642/**
Eric Moore635374e2009-03-09 01:21:12 -0600643 * struct MPT2SAS_ADAPTER - per adapter struct
644 * @list: ioc_list
645 * @shost: shost object
646 * @id: unique adapter id
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530647 * @cpu_count: number online cpus
Eric Moore635374e2009-03-09 01:21:12 -0600648 * @name: generic ioc string
649 * @tmp_string: tmp string used for logging
650 * @pdev: pci pdev object
651 * @chip: memory mapped register space
652 * @chip_phys: physical addrss prior to mapping
Eric Moore635374e2009-03-09 01:21:12 -0600653 * @logging_level: see mpt2sas_debug.h
Kashyap, Desaifa7f3162009-09-23 17:26:58 +0530654 * @fwfault_debug: debuging FW timeouts
Eric Moore635374e2009-03-09 01:21:12 -0600655 * @ir_firmware: IR firmware present
656 * @bars: bitmask of BAR's that must be configured
657 * @mask_interrupts: ignore interrupt
658 * @fault_reset_work_q_name: fw fault work queue
659 * @fault_reset_work_q: ""
660 * @fault_reset_work: ""
661 * @firmware_event_name: fw event work queue
662 * @firmware_event_thread: ""
663 * @fw_events_off: flag to turn off fw event handling
664 * @fw_event_lock:
665 * @fw_event_list: list of fw events
666 * @aen_event_read_flag: event log was read
667 * @broadcast_aen_busy: broadcast aen waiting to be serviced
Kashyap, Desai155dd4c2009-08-20 13:22:00 +0530668 * @shost_recovery: host reset in progress
Eric Moore635374e2009-03-09 01:21:12 -0600669 * @ioc_reset_in_progress_lock:
670 * @ioc_link_reset_in_progress: phy/hard reset in progress
Uwe Kleine-König65155b32010-06-11 12:17:01 +0200671 * @ignore_loginfos: ignore loginfos during task management
Eric Moore635374e2009-03-09 01:21:12 -0600672 * @remove_host: flag for when driver unloads, to avoid sending dev resets
Eric Moore3cb54692010-07-08 14:44:34 -0600673 * @pci_error_recovery: flag to prevent ioc access until slot reset completes
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +0530674 * @wait_for_discovery_to_complete: flag set at driver load time when
675 * waiting on reporting devices
676 * @is_driver_loading: flag set at driver load time
677 * @port_enable_failed: flag set when port enable has failed
678 * @start_scan: flag set from scan_start callback, cleared from _mpt2sas_fw_work
679 * @start_scan_failed: means port enable failed, return's the ioc_status
Eric Moore635374e2009-03-09 01:21:12 -0600680 * @msix_enable: flag indicating msix is enabled
681 * @msix_vector_count: number msix vectors
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530682 * @cpu_msix_table: table for mapping cpus to msix index
683 * @cpu_msix_table_sz: table size
nagalakshmi.nandigama@lsi.com845a0e42011-12-01 07:42:04 +0530684 * @schedule_dead_ioc_flush_running_cmds: callback to flush pending commands
Eric Moore635374e2009-03-09 01:21:12 -0600685 * @scsi_io_cb_idx: shost generated commands
686 * @tm_cb_idx: task management commands
Kashyap, Desai744090d2009-10-05 15:56:56 +0530687 * @scsih_cb_idx: scsih internal commands
Eric Moore635374e2009-03-09 01:21:12 -0600688 * @transport_cb_idx: transport internal commands
689 * @ctl_cb_idx: clt internal commands
690 * @base_cb_idx: base internal commands
691 * @config_cb_idx: base internal commands
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530692 * @tm_tr_cb_idx : device removal target reset handshake
693 * @tm_tr_volume_cb_idx : volume removal target reset
Eric Moore635374e2009-03-09 01:21:12 -0600694 * @base_cmds:
695 * @transport_cmds:
Kashyap, Desai744090d2009-10-05 15:56:56 +0530696 * @scsih_cmds:
Eric Moore635374e2009-03-09 01:21:12 -0600697 * @tm_cmds:
698 * @ctl_cmds:
699 * @config_cmds:
700 * @base_add_sg_single: handler for either 32/64 bit sgl's
701 * @event_type: bits indicating which events to log
702 * @event_context: unique id for each logged event
703 * @event_log: event log pointer
704 * @event_masks: events that are masked
705 * @facts: static facts data
706 * @pfacts: static port facts data
707 * @manu_pg0: static manufacturing page 0
Kashyap, Desaied79f122009-08-20 13:23:49 +0530708 * @manu_pg10: static manufacturing page 10
Eric Moore635374e2009-03-09 01:21:12 -0600709 * @bios_pg2: static bios page 2
710 * @bios_pg3: static bios page 3
711 * @ioc_pg8: static ioc page 8
712 * @iounit_pg0: static iounit page 0
713 * @iounit_pg1: static iounit page 1
714 * @sas_hba: sas host object
715 * @sas_expander_list: expander object list
716 * @sas_node_lock:
717 * @sas_device_list: sas device object list
718 * @sas_device_init_list: sas device object list (used only at init time)
719 * @sas_device_lock:
720 * @io_missing_delay: time for IO completed by fw when PDR enabled
721 * @device_missing_delay: time for device missing by fw when PDR enabled
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530722 * @sas_id : used for setting volume target IDs
nagalakshmi.nandigama@lsi.com09da0b32012-03-20 12:06:50 +0530723 * @blocking_handles: bitmask used to identify which devices need blocking
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530724 * @pd_handles : bitmask for PD handles
725 * @pd_handles_sz : size of pd_handle bitmask
Eric Moore635374e2009-03-09 01:21:12 -0600726 * @config_page_sz: config page size
727 * @config_page: reserve memory for config page payload
728 * @config_page_dma:
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530729 * @hba_queue_depth: hba request queue depth
Eric Moore635374e2009-03-09 01:21:12 -0600730 * @sge_size: sg element size for either 32/64 bit
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530731 * @scsiio_depth: SCSI_IO queue depth
Eric Moore635374e2009-03-09 01:21:12 -0600732 * @request_sz: per request frame size
733 * @request: pool of request frames
734 * @request_dma:
735 * @request_dma_sz:
736 * @scsi_lookup: firmware request tracker list
737 * @scsi_lookup_lock:
738 * @free_list: free list of request
739 * @chain: pool of chains
740 * @pending_io_count:
741 * @reset_wq:
742 * @chain_dma:
743 * @max_sges_in_main_message: number sg elements in main message
744 * @max_sges_in_chain_message: number sg elements per chain
745 * @chains_needed_per_io: max chains per io
746 * @chain_offset_value_for_main_message: location 1st sg in main
747 * @chain_depth: total chains allocated
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530748 * @hi_priority_smid:
749 * @hi_priority:
750 * @hi_priority_dma:
751 * @hi_priority_depth:
752 * @hpr_lookup:
753 * @hpr_free_list:
754 * @internal_smid:
755 * @internal:
756 * @internal_dma:
757 * @internal_depth:
758 * @internal_lookup:
759 * @internal_free_list:
Eric Moore635374e2009-03-09 01:21:12 -0600760 * @sense: pool of sense
761 * @sense_dma:
762 * @sense_dma_pool:
763 * @reply_depth: hba reply queue depth:
764 * @reply_sz: per reply frame size:
765 * @reply: pool of replys:
766 * @reply_dma:
767 * @reply_dma_pool:
768 * @reply_free_queue_depth: reply free depth
769 * @reply_free: pool for reply free queue (32 bit addr)
770 * @reply_free_dma:
771 * @reply_free_dma_pool:
772 * @reply_free_host_index: tail index in pool to insert free replys
773 * @reply_post_queue_depth: reply post queue depth
774 * @reply_post_free: pool for reply post (64bit descriptor)
775 * @reply_post_free_dma:
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530776 * @reply_queue_count: number of reply queue's
777 * @reply_queue_list: link list contaning the reply queue info
Eric Moore635374e2009-03-09 01:21:12 -0600778 * @reply_post_host_index: head index in the pool where FW completes IO
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530779 * @delayed_tr_list: target reset link list
780 * @delayed_tr_volume_list: volume target reset link list
Eric Moore635374e2009-03-09 01:21:12 -0600781 */
782struct MPT2SAS_ADAPTER {
783 struct list_head list;
784 struct Scsi_Host *shost;
785 u8 id;
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530786 int cpu_count;
Eric Moore635374e2009-03-09 01:21:12 -0600787 char name[MPT_NAME_LENGTH];
788 char tmp_string[MPT_STRING_LENGTH];
789 struct pci_dev *pdev;
790 Mpi2SystemInterfaceRegs_t __iomem *chip;
Kashyap, Desai6846e752009-12-16 18:51:45 +0530791 resource_size_t chip_phys;
Eric Moore635374e2009-03-09 01:21:12 -0600792 int logging_level;
Kashyap, Desaifa7f3162009-09-23 17:26:58 +0530793 int fwfault_debug;
Eric Moore635374e2009-03-09 01:21:12 -0600794 u8 ir_firmware;
795 int bars;
796 u8 mask_interrupts;
797
798 /* fw fault handler */
799 char fault_reset_work_q_name[20];
800 struct workqueue_struct *fault_reset_work_q;
801 struct delayed_work fault_reset_work;
802
803 /* fw event handler */
804 char firmware_event_name[20];
805 struct workqueue_struct *firmware_event_thread;
Eric Moore635374e2009-03-09 01:21:12 -0600806 spinlock_t fw_event_lock;
807 struct list_head fw_event_list;
808
809 /* misc flags */
810 int aen_event_read_flag;
811 u8 broadcast_aen_busy;
Kashyap, Desaif93213d2011-06-14 10:56:43 +0530812 u16 broadcast_aen_pending;
Eric Moore635374e2009-03-09 01:21:12 -0600813 u8 shost_recovery;
Kashyap, Desaid2742132010-06-17 13:28:55 +0530814
815 struct mutex reset_in_progress_mutex;
Eric Moore635374e2009-03-09 01:21:12 -0600816 spinlock_t ioc_reset_in_progress_lock;
817 u8 ioc_link_reset_in_progress;
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +0530818 u8 ioc_reset_in_progress_status;
Kashyap, Desaid2742132010-06-17 13:28:55 +0530819
Eric Moore635374e2009-03-09 01:21:12 -0600820 u8 ignore_loginfos;
821 u8 remove_host;
Eric Moore3cb54692010-07-08 14:44:34 -0600822 u8 pci_error_recovery;
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +0530823 u8 wait_for_discovery_to_complete;
824 struct completion port_enable_done;
825 u8 is_driver_loading;
826 u8 port_enable_failed;
827
828 u8 start_scan;
829 u16 start_scan_failed;
Eric Moore635374e2009-03-09 01:21:12 -0600830
831 u8 msix_enable;
832 u16 msix_vector_count;
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530833 u8 *cpu_msix_table;
834 resource_size_t **reply_post_host_index;
835 u16 cpu_msix_table_sz;
Kashyap, Desaid32a8c12010-06-17 13:36:53 +0530836 u32 ioc_reset_count;
nagalakshmi.nandigama@lsi.com845a0e42011-12-01 07:42:04 +0530837 MPT2SAS_FLUSH_RUNNING_CMDS schedule_dead_ioc_flush_running_cmds;
Eric Moore635374e2009-03-09 01:21:12 -0600838
839 /* internal commands, callback index */
840 u8 scsi_io_cb_idx;
841 u8 tm_cb_idx;
842 u8 transport_cb_idx;
Kashyap, Desai744090d2009-10-05 15:56:56 +0530843 u8 scsih_cb_idx;
Eric Moore635374e2009-03-09 01:21:12 -0600844 u8 ctl_cb_idx;
845 u8 base_cb_idx;
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +0530846 u8 port_enable_cb_idx;
Eric Moore635374e2009-03-09 01:21:12 -0600847 u8 config_cb_idx;
Kashyap, Desai77e63ed2009-09-14 11:04:23 +0530848 u8 tm_tr_cb_idx;
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530849 u8 tm_tr_volume_cb_idx;
Kashyap, Desai77e63ed2009-09-14 11:04:23 +0530850 u8 tm_sas_control_cb_idx;
Eric Moore635374e2009-03-09 01:21:12 -0600851 struct _internal_cmd base_cmds;
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +0530852 struct _internal_cmd port_enable_cmds;
Eric Moore635374e2009-03-09 01:21:12 -0600853 struct _internal_cmd transport_cmds;
Kashyap, Desai744090d2009-10-05 15:56:56 +0530854 struct _internal_cmd scsih_cmds;
Eric Moore635374e2009-03-09 01:21:12 -0600855 struct _internal_cmd tm_cmds;
856 struct _internal_cmd ctl_cmds;
857 struct _internal_cmd config_cmds;
858
859 MPT_ADD_SGE base_add_sg_single;
860
861 /* event log */
862 u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
863 u32 event_context;
864 void *event_log;
865 u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
866
867 /* static config pages */
Kashyap, Desaic97951e2011-06-14 10:54:56 +0530868 struct mpt2sas_facts facts;
869 struct mpt2sas_port_facts *pfacts;
Eric Moore635374e2009-03-09 01:21:12 -0600870 Mpi2ManufacturingPage0_t manu_pg0;
871 Mpi2BiosPage2_t bios_pg2;
872 Mpi2BiosPage3_t bios_pg3;
873 Mpi2IOCPage8_t ioc_pg8;
874 Mpi2IOUnitPage0_t iounit_pg0;
875 Mpi2IOUnitPage1_t iounit_pg1;
876
877 struct _boot_device req_boot_device;
878 struct _boot_device req_alt_boot_device;
879 struct _boot_device current_boot_device;
880
881 /* sas hba, expander, and device list */
882 struct _sas_node sas_hba;
883 struct list_head sas_expander_list;
884 spinlock_t sas_node_lock;
885 struct list_head sas_device_list;
886 struct list_head sas_device_init_list;
887 spinlock_t sas_device_lock;
888 struct list_head raid_device_list;
889 spinlock_t raid_device_lock;
890 u8 io_missing_delay;
891 u16 device_missing_delay;
892 int sas_id;
nagalakshmi.nandigama@lsi.com09da0b32012-03-20 12:06:50 +0530893 void *blocking_handles;
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530894 void *pd_handles;
895 u16 pd_handles_sz;
896
Eric Moore635374e2009-03-09 01:21:12 -0600897 /* config page */
898 u16 config_page_sz;
899 void *config_page;
900 dma_addr_t config_page_dma;
901
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530902 /* scsiio request */
903 u16 hba_queue_depth;
Eric Moore635374e2009-03-09 01:21:12 -0600904 u16 sge_size;
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530905 u16 scsiio_depth;
Eric Moore635374e2009-03-09 01:21:12 -0600906 u16 request_sz;
907 u8 *request;
908 dma_addr_t request_dma;
909 u32 request_dma_sz;
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530910 struct scsiio_tracker *scsi_lookup;
Kashyap, Desai89009fb2010-03-17 16:22:52 +0530911 ulong scsi_lookup_pages;
912 spinlock_t scsi_lookup_lock;
Eric Moore635374e2009-03-09 01:21:12 -0600913 struct list_head free_list;
914 int pending_io_count;
915 wait_queue_head_t reset_wq;
916
917 /* chain */
Kashyap, Desai35f805b2010-11-13 04:34:06 +0530918 struct chain_tracker *chain_lookup;
919 struct list_head free_chain_list;
920 struct dma_pool *chain_dma_pool;
921 ulong chain_pages;
Eric Moore635374e2009-03-09 01:21:12 -0600922 u16 max_sges_in_main_message;
923 u16 max_sges_in_chain_message;
924 u16 chains_needed_per_io;
925 u16 chain_offset_value_for_main_message;
Kashyap, Desai89009fb2010-03-17 16:22:52 +0530926 u32 chain_depth;
Eric Moore635374e2009-03-09 01:21:12 -0600927
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530928 /* hi-priority queue */
929 u16 hi_priority_smid;
930 u8 *hi_priority;
931 dma_addr_t hi_priority_dma;
932 u16 hi_priority_depth;
933 struct request_tracker *hpr_lookup;
934 struct list_head hpr_free_list;
935
936 /* internal queue */
937 u16 internal_smid;
938 u8 *internal;
939 dma_addr_t internal_dma;
940 u16 internal_depth;
941 struct request_tracker *internal_lookup;
942 struct list_head internal_free_list;
943
Eric Moore635374e2009-03-09 01:21:12 -0600944 /* sense */
945 u8 *sense;
946 dma_addr_t sense_dma;
947 struct dma_pool *sense_dma_pool;
948
949 /* reply */
950 u16 reply_sz;
951 u8 *reply;
952 dma_addr_t reply_dma;
Kashyap, Desaidd3741d2010-11-13 04:31:14 +0530953 u32 reply_dma_max_address;
954 u32 reply_dma_min_address;
Eric Moore635374e2009-03-09 01:21:12 -0600955 struct dma_pool *reply_dma_pool;
956
957 /* reply free queue */
958 u16 reply_free_queue_depth;
Kashyap, Desaic97951e2011-06-14 10:54:56 +0530959 __le32 *reply_free;
Eric Moore635374e2009-03-09 01:21:12 -0600960 dma_addr_t reply_free_dma;
961 struct dma_pool *reply_free_dma_pool;
962 u32 reply_free_host_index;
963
964 /* reply post queue */
965 u16 reply_post_queue_depth;
966 Mpi2ReplyDescriptorsUnion_t *reply_post_free;
967 dma_addr_t reply_post_free_dma;
968 struct dma_pool *reply_post_free_dma_pool;
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530969 u8 reply_queue_count;
970 struct list_head reply_queue_list;
Eric Moore635374e2009-03-09 01:21:12 -0600971
Kashyap, Desai77e63ed2009-09-14 11:04:23 +0530972 struct list_head delayed_tr_list;
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530973 struct list_head delayed_tr_volume_list;
Kashyap, Desai77e63ed2009-09-14 11:04:23 +0530974
Eric Moore635374e2009-03-09 01:21:12 -0600975 /* diag buffer support */
976 u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
977 u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
978 dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
979 u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
980 u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
Kashyap, Desaied79f122009-08-20 13:23:49 +0530981 Mpi2ManufacturingPage10_t manu_pg10;
Eric Moore635374e2009-03-09 01:21:12 -0600982 u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
983 u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
Kashyap, Desai570c67a2010-06-17 13:43:17 +0530984 u32 ring_buffer_offset;
985 u32 ring_buffer_sz;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530986 u8 is_warpdrive;
987 u8 hide_ir_msg;
988 u8 mfg_pg10_hide_flag;
989 u8 hide_drives;
990
Eric Moore635374e2009-03-09 01:21:12 -0600991};
992
Kashyap, Desai77e63ed2009-09-14 11:04:23 +0530993typedef u8 (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
994 u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -0600995
996
997/* base shared API */
Eric Mooreba33fad2009-03-15 21:37:18 -0600998extern struct list_head mpt2sas_ioc_list;
Kashyap, Desaie4750c92009-08-07 19:37:59 +0530999void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc);
1000void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc);
Eric Moore635374e2009-03-09 01:21:12 -06001001
1002int mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc);
1003void mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc);
1004int mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc);
1005void mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc);
1006int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
1007 enum reset_type type);
1008
1009void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid);
1010void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid);
1011void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr);
Kashyap, Desaiec9472c2009-09-23 17:34:13 +05301012__le32 mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc,
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301013 u16 smid);
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +05301014void mpt2sas_base_flush_reply_queues(struct MPT2SAS_ADAPTER *ioc);
Eric Moore635374e2009-03-09 01:21:12 -06001015
Kashyap, Desai595bb0b2009-09-14 11:02:48 +05301016/* hi-priority queue */
1017u16 mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
1018u16 mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx,
1019 struct scsi_cmnd *scmd);
1020
Eric Moore635374e2009-03-09 01:21:12 -06001021u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
1022void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid);
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301023void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid,
Eric Moore635374e2009-03-09 01:21:12 -06001024 u16 handle);
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301025void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid);
Eric Moore635374e2009-03-09 01:21:12 -06001026void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid,
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301027 u16 io_index);
1028void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid);
Eric Moore635374e2009-03-09 01:21:12 -06001029void mpt2sas_base_initialize_callback_handler(void);
1030u8 mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func);
1031void mpt2sas_base_release_callback_handler(u8 cb_idx);
1032
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301033u8 mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301034 u32 reply);
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +05301035u8 mpt2sas_port_enable_done(struct MPT2SAS_ADAPTER *ioc, u16 smid,
1036 u8 msix_index, u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -06001037void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr);
1038
1039u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked);
1040
1041void mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code);
1042int mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
1043 Mpi2SasIoUnitControlReply_t *mpi_reply, Mpi2SasIoUnitControlRequest_t
1044 *mpi_request);
1045int mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
1046 Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
1047void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type);
1048
Kashyap, Desaifa7f3162009-09-23 17:26:58 +05301049void mpt2sas_halt_firmware(struct MPT2SAS_ADAPTER *ioc);
1050
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +05301051int mpt2sas_port_enable(struct MPT2SAS_ADAPTER *ioc);
1052
Eric Moore635374e2009-03-09 01:21:12 -06001053/* scsih shared API */
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301054u8 mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
1055 u32 reply);
Kashyap, Desai8ed9a032010-03-17 16:25:59 +05301056int mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle,
Kashyap, Desaif93213d2011-06-14 10:56:43 +05301057 uint channel, uint id, uint lun, u8 type, u16 smid_task,
1058 ulong timeout, unsigned long serial_number, enum mutex_type m_type);
Eric Moore635374e2009-03-09 01:21:12 -06001059void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
1060void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
Kashyap, Desai7f6f7942010-11-13 04:35:30 +05301061void mpt2sas_expander_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
nagalakshmi.nandigama@lsi.com09da0b32012-03-20 12:06:50 +05301062void mpt2sas_device_remove_by_sas_address(struct MPT2SAS_ADAPTER *ioc,
1063 u64 sas_address);
Eric Moore635374e2009-03-09 01:21:12 -06001064struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *ioc,
1065 u16 handle);
1066struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER
1067 *ioc, u64 sas_address);
1068struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address(
1069 struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
1070
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +05301071void mpt2sas_port_enable_complete(struct MPT2SAS_ADAPTER *ioc);
1072
Eric Moore635374e2009-03-09 01:21:12 -06001073void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
1074
1075/* config shared API */
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301076u8 mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301077 u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -06001078int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys);
1079int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
1080 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
Kashyap, Desaied79f122009-08-20 13:23:49 +05301081int mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc,
1082 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage10_t *config_page);
Eric Moore635374e2009-03-09 01:21:12 -06001083int mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1084 *mpi_reply, Mpi2BiosPage2_t *config_page);
1085int mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1086 *mpi_reply, Mpi2BiosPage3_t *config_page);
1087int mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1088 *mpi_reply, Mpi2IOUnitPage0_t *config_page);
1089int mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1090 *mpi_reply, Mpi2SasDevicePage0_t *config_page, u32 form, u32 handle);
1091int mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1092 *mpi_reply, Mpi2SasDevicePage1_t *config_page, u32 form, u32 handle);
1093int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1094 *mpi_reply, Mpi2SasIOUnitPage0_t *config_page, u16 sz);
1095int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1096 *mpi_reply, Mpi2IOUnitPage1_t *config_page);
1097int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
Kashyap, Desai5b768582009-08-20 13:24:31 +05301098 *mpi_reply, Mpi2IOUnitPage1_t *config_page);
Eric Moore635374e2009-03-09 01:21:12 -06001099int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1100 *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
Kashyap, Desai50d5c602009-12-16 18:55:26 +05301101int mpt2sas_config_set_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
1102 Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
Eric Moore635374e2009-03-09 01:21:12 -06001103int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1104 *mpi_reply, Mpi2IOCPage8_t *config_page);
1105int mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1106 *mpi_reply, Mpi2ExpanderPage0_t *config_page, u32 form, u32 handle);
1107int mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1108 *mpi_reply, Mpi2ExpanderPage1_t *config_page, u32 phy_number, u16 handle);
1109int mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1110 *mpi_reply, Mpi2SasEnclosurePage0_t *config_page, u32 form, u32 handle);
1111int mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1112 *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
1113int mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1114 *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
1115int mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1116 *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form, u32 handle);
1117int mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 *num_pds);
1118int mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1119 *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form, u32 handle, u16 sz);
1120int mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1121 *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 form,
1122 u32 form_specific);
1123int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
1124 u16 *volume_handle);
1125int mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER *ioc, u16 volume_handle,
1126 u64 *wwid);
Eric Moore635374e2009-03-09 01:21:12 -06001127/* ctl shared API */
1128extern struct device_attribute *mpt2sas_host_attrs[];
1129extern struct device_attribute *mpt2sas_dev_attrs[];
1130void mpt2sas_ctl_init(void);
1131void mpt2sas_ctl_exit(void);
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301132u8 mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301133 u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -06001134void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301135u8 mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301136 u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -06001137void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,
1138 Mpi2EventNotificationReply_t *mpi_reply);
1139
Kashyap, Desai32e0eb52009-09-23 17:28:09 +05301140void mpt2sas_enable_diag_buffer(struct MPT2SAS_ADAPTER *ioc,
1141 u8 bits_to_regsiter);
1142
Eric Moore635374e2009-03-09 01:21:12 -06001143/* transport shared API */
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301144u8 mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1145 u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -06001146struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc,
Kashyap, Desaic5e039b2009-09-23 17:21:29 +05301147 u16 handle, u64 sas_address);
Eric Moore635374e2009-03-09 01:21:12 -06001148void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
Kashyap, Desaic5e039b2009-09-23 17:21:29 +05301149 u64 sas_address_parent);
Eric Moore635374e2009-03-09 01:21:12 -06001150int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
1151 *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
1152int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
1153 *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev);
Kashyap, Desaic5e039b2009-09-23 17:21:29 +05301154void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc,
1155 u64 sas_address, u16 handle, u8 phy_number, u8 link_rate);
Eric Moore635374e2009-03-09 01:21:12 -06001156extern struct sas_function_template mpt2sas_transport_functions;
1157extern struct scsi_transport_template *mpt2sas_transport_template;
Kashyap, Desai34a03be2009-08-20 13:23:19 +05301158extern int scsi_internal_device_block(struct scsi_device *sdev);
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301159extern u8 mpt2sas_stm_zero_smid_handler(struct MPT2SAS_ADAPTER *ioc,
1160 u8 msix_index, u32 reply);
Kashyap, Desai34a03be2009-08-20 13:23:19 +05301161extern int scsi_internal_device_unblock(struct scsi_device *sdev);
Eric Moore635374e2009-03-09 01:21:12 -06001162
1163#endif /* MPT2SAS_BASE_H_INCLUDED */