blob: 97ea360c6920e20f13160b3d96610f84f04ab0b7 [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
Sreekanth Reddye9edbe32014-09-12 15:35:18 +05306 * Copyright (C) 2007-2014 LSI Corporation
Sreekanth Reddya03bd152015-01-12 11:39:02 +05307 * Copyright (C) 20013-2014 Avago Technologies
8 * (mailto: MPT-FusionLinux.pdl@avagotech.com)
Eric Moore635374e2009-03-09 01:21:12 -06009 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * NO WARRANTY
21 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
22 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
23 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
24 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
25 * solely responsible for determining the appropriateness of using and
26 * distributing the Program and assumes all risks associated with its
27 * exercise of rights under this Agreement, including but not limited to
28 * the risks and costs of program errors, damage to or loss of data,
29 * programs or equipment, and unavailability or interruption of operations.
30
31 * DISCLAIMER OF LIABILITY
32 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
33 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
38 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
39
40 * You should have received a copy of the GNU General Public License
41 * along with this program; if not, write to the Free Software
42 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
43 * USA.
44 */
45
46#ifndef MPT2SAS_BASE_H_INCLUDED
47#define MPT2SAS_BASE_H_INCLUDED
48
49#include "mpi/mpi2_type.h"
50#include "mpi/mpi2.h"
51#include "mpi/mpi2_ioc.h"
52#include "mpi/mpi2_cnfg.h"
53#include "mpi/mpi2_init.h"
54#include "mpi/mpi2_raid.h"
55#include "mpi/mpi2_tool.h"
56#include "mpi/mpi2_sas.h"
57
58#include <scsi/scsi.h>
59#include <scsi/scsi_cmnd.h>
60#include <scsi/scsi_device.h>
61#include <scsi/scsi_host.h>
62#include <scsi/scsi_tcq.h>
63#include <scsi/scsi_transport_sas.h>
64#include <scsi/scsi_dbg.h>
Eric Moore3c621b32009-05-18 12:59:41 -060065#include <scsi/scsi_eh.h>
Eric Moore635374e2009-03-09 01:21:12 -060066
67#include "mpt2sas_debug.h"
68
69/* driver versioning info */
70#define MPT2SAS_DRIVER_NAME "mpt2sas"
Sreekanth Reddya03bd152015-01-12 11:39:02 +053071#define MPT2SAS_AUTHOR "Avago Technologies <MPT-FusionLinux.pdl@avagotech.com>"
Eric Moore635374e2009-03-09 01:21:12 -060072#define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver"
Sreekanth Reddya63bb9b2015-01-12 11:39:04 +053073#define MPT2SAS_DRIVER_VERSION "20.100.00.00"
74#define MPT2SAS_MAJOR_VERSION 20
Eric Moore635374e2009-03-09 01:21:12 -060075#define MPT2SAS_MINOR_VERSION 100
Kashyap, Desai1a7d7ea2010-03-17 16:28:34 +053076#define MPT2SAS_BUILD_VERSION 00
nagalakshmi.nandigama@lsi.com6e880202011-10-19 15:37:54 +053077#define MPT2SAS_RELEASE_VERSION 00
Eric Moore635374e2009-03-09 01:21:12 -060078
79/*
80 * Set MPT2SAS_SG_DEPTH value based on user input.
81 */
82#ifdef CONFIG_SCSI_MPT2SAS_MAX_SGE
83#if CONFIG_SCSI_MPT2SAS_MAX_SGE < 16
84#define MPT2SAS_SG_DEPTH 16
85#elif CONFIG_SCSI_MPT2SAS_MAX_SGE > 128
86#define MPT2SAS_SG_DEPTH 128
87#else
88#define MPT2SAS_SG_DEPTH CONFIG_SCSI_MPT2SAS_MAX_SGE
89#endif
90#else
91#define MPT2SAS_SG_DEPTH 128 /* MAX_HW_SEGMENTS */
92#endif
93
94
95/*
96 * Generic Defines
97 */
98#define MPT2SAS_SATA_QUEUE_DEPTH 32
99#define MPT2SAS_SAS_QUEUE_DEPTH 254
100#define MPT2SAS_RAID_QUEUE_DEPTH 128
101
102#define MPT_NAME_LENGTH 32 /* generic length of strings */
103#define MPT_STRING_LENGTH 64
104
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530105#define MPT_MAX_CALLBACKS 16
106
Eric Moore635374e2009-03-09 01:21:12 -0600107
108#define CAN_SLEEP 1
109#define NO_SLEEP 0
110
111#define INTERNAL_CMDS_COUNT 10 /* reserved cmds */
112
113#define MPI2_HIM_MASK 0xFFFFFFFF /* mask every bit*/
114
115#define MPT2SAS_INVALID_DEVICE_HANDLE 0xFFFF
116
117
118/*
119 * reset phases
120 */
121#define MPT2_IOC_PRE_RESET 1 /* prior to host reset */
122#define MPT2_IOC_AFTER_RESET 2 /* just after host reset */
123#define MPT2_IOC_DONE_RESET 3 /* links re-initialized */
124
125/*
126 * logging format
127 */
128#define MPT2SAS_FMT "%s: "
Eric Moore635374e2009-03-09 01:21:12 -0600129#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/*
Eric Mooref0f9cc12009-04-21 15:40:48 -0600135 * 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/*
Kashyap, Desaifb396be2011-01-04 11:36:37 +0530159 * Intel HBA branding
160 */
nagalakshmi.nandigama@lsi.com8bad3052011-12-01 07:52:42 +0530161#define MPT2SAS_INTEL_RMS25JB080_BRANDING \
162 "Intel(R) Integrated RAID Module RMS25JB080"
163#define MPT2SAS_INTEL_RMS25JB040_BRANDING \
164 "Intel(R) Integrated RAID Module RMS25JB040"
165#define MPT2SAS_INTEL_RMS25KB080_BRANDING \
166 "Intel(R) Integrated RAID Module RMS25KB080"
167#define MPT2SAS_INTEL_RMS25KB040_BRANDING \
168 "Intel(R) Integrated RAID Module RMS25KB040"
Sreekanth Reddy7887ea72013-02-01 21:49:30 +0530169#define MPT2SAS_INTEL_RMS25LB040_BRANDING \
170 "Intel(R) Integrated RAID Module RMS25LB040"
171#define MPT2SAS_INTEL_RMS25LB080_BRANDING \
172 "Intel(R) Integrated RAID Module RMS25LB080"
Kashyap, Desaifb396be2011-01-04 11:36:37 +0530173#define MPT2SAS_INTEL_RMS2LL080_BRANDING \
174 "Intel Integrated RAID Module RMS2LL080"
175#define MPT2SAS_INTEL_RMS2LL040_BRANDING \
176 "Intel Integrated RAID Module RMS2LL040"
Kashyap, Desaiab3e5f62011-06-14 10:57:31 +0530177#define MPT2SAS_INTEL_RS25GB008_BRANDING \
178 "Intel(R) RAID Controller RS25GB008"
sreekanth.reddy@lsi.come17eee42012-07-17 15:56:05 +0530179#define MPT2SAS_INTEL_SSD910_BRANDING \
180 "Intel(R) SSD 910 Series"
Kashyap, Desaifb396be2011-01-04 11:36:37 +0530181/*
182 * Intel HBA SSDIDs
183 */
nagalakshmi.nandigama@lsi.com8bad3052011-12-01 07:52:42 +0530184#define MPT2SAS_INTEL_RMS25JB080_SSDID 0x3516
185#define MPT2SAS_INTEL_RMS25JB040_SSDID 0x3517
186#define MPT2SAS_INTEL_RMS25KB080_SSDID 0x3518
187#define MPT2SAS_INTEL_RMS25KB040_SSDID 0x3519
Sreekanth Reddy7887ea72013-02-01 21:49:30 +0530188#define MPT2SAS_INTEL_RMS25LB040_SSDID 0x351A
189#define MPT2SAS_INTEL_RMS25LB080_SSDID 0x351B
Kashyap, Desaifb396be2011-01-04 11:36:37 +0530190#define MPT2SAS_INTEL_RMS2LL080_SSDID 0x350E
191#define MPT2SAS_INTEL_RMS2LL040_SSDID 0x350F
Kashyap, Desaiab3e5f62011-06-14 10:57:31 +0530192#define MPT2SAS_INTEL_RS25GB008_SSDID 0x3000
sreekanth.reddy@lsi.come17eee42012-07-17 15:56:05 +0530193#define MPT2SAS_INTEL_SSD910_SSDID 0x3700
Kashyap, Desai0a2385c2011-03-15 20:04:26 +0530194
195/*
196 * HP HBA branding
197 */
198#define MPT2SAS_HP_3PAR_SSVID 0x1590
199#define MPT2SAS_HP_2_4_INTERNAL_BRANDING "HP H220 Host Bus Adapter"
200#define MPT2SAS_HP_2_4_EXTERNAL_BRANDING "HP H221 Host Bus Adapter"
201#define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING "HP H222 Host Bus Adapter"
202#define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING "HP H220i Host Bus Adapter"
203#define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING "HP H210i Host Bus Adapter"
204
205/*
206 * HO HBA SSDIDs
207 */
208#define MPT2SAS_HP_2_4_INTERNAL_SSDID 0x0041
209#define MPT2SAS_HP_2_4_EXTERNAL_SSDID 0x0042
210#define MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_SSDID 0x0043
211#define MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_SSDID 0x0044
212#define MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_SSDID 0x0046
213
Kashyap, Desaifb396be2011-01-04 11:36:37 +0530214/*
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530215 * WarpDrive Specific Log codes
216 */
217
218#define MPT2_WARPDRIVE_LOGENTRY (0x8002)
219#define MPT2_WARPDRIVE_LC_SSDT (0x41)
220#define MPT2_WARPDRIVE_LC_SSDLW (0x43)
221#define MPT2_WARPDRIVE_LC_SSDLF (0x44)
222#define MPT2_WARPDRIVE_LC_BRMF (0x4D)
223
224/*
Eric Moore635374e2009-03-09 01:21:12 -0600225 * per target private data
226 */
227#define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01
228#define MPT_TARGET_FLAGS_VOLUME 0x02
229#define MPT_TARGET_FLAGS_DELETED 0x04
230
231/**
232 * struct MPT2SAS_TARGET - starget private hostdata
233 * @starget: starget object
234 * @sas_address: target sas address
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530235 * @raid_device: raid_device pointer to access volume data
Eric Moore635374e2009-03-09 01:21:12 -0600236 * @handle: device handle
237 * @num_luns: number luns
238 * @flags: MPT_TARGET_FLAGS_XXX flags
239 * @deleted: target flaged for deletion
240 * @tm_busy: target is busy with TM request.
Calvin Owensd224fe02015-08-13 18:48:09 -0700241 * @sdev: The sas_device associated with this target
Eric Moore635374e2009-03-09 01:21:12 -0600242 */
243struct MPT2SAS_TARGET {
244 struct scsi_target *starget;
245 u64 sas_address;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530246 struct _raid_device *raid_device;
Eric Moore635374e2009-03-09 01:21:12 -0600247 u16 handle;
248 int num_luns;
249 u32 flags;
250 u8 deleted;
251 u8 tm_busy;
Calvin Owensd224fe02015-08-13 18:48:09 -0700252 struct _sas_device *sdev;
Eric Moore635374e2009-03-09 01:21:12 -0600253};
254
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530255
Eric Moore635374e2009-03-09 01:21:12 -0600256/*
257 * per device private data
258 */
259#define MPT_DEVICE_FLAGS_INIT 0x01
260#define MPT_DEVICE_TLR_ON 0x02
261
262/**
263 * struct MPT2SAS_DEVICE - sdev private hostdata
264 * @sas_target: starget private hostdata
265 * @lun: lun number
266 * @flags: MPT_DEVICE_XXX flags
267 * @configured_lun: lun is configured
268 * @block: device is in SDEV_BLOCK state
269 * @tlr_snoop_check: flag used in determining whether to disable TLR
270 */
Kashyap, Desaied79f122009-08-20 13:23:49 +0530271
272/* OEM Identifiers */
273#define MFG10_OEM_ID_INVALID (0x00000000)
274#define MFG10_OEM_ID_DELL (0x00000001)
275#define MFG10_OEM_ID_FSC (0x00000002)
276#define MFG10_OEM_ID_SUN (0x00000003)
277#define MFG10_OEM_ID_IBM (0x00000004)
278
279/* GENERIC Flags 0*/
280#define MFG10_GF0_OCE_DISABLED (0x00000001)
281#define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002)
282#define MFG10_GF0_R10_DISPLAY (0x00000004)
283#define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008)
284#define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010)
285
286/* OEM Specific Flags will come from OEM specific header files */
287typedef struct _MPI2_CONFIG_PAGE_MAN_10 {
288 MPI2_CONFIG_PAGE_HEADER Header; /* 00h */
289 U8 OEMIdentifier; /* 04h */
290 U8 Reserved1; /* 05h */
291 U16 Reserved2; /* 08h */
292 U32 Reserved3; /* 0Ch */
293 U32 GenericFlags0; /* 10h */
294 U32 GenericFlags1; /* 14h */
295 U32 Reserved4; /* 18h */
296 U32 OEMSpecificFlags0; /* 1Ch */
297 U32 OEMSpecificFlags1; /* 20h */
298 U32 Reserved5[18]; /* 24h-60h*/
299} MPI2_CONFIG_PAGE_MAN_10,
300 MPI2_POINTER PTR_MPI2_CONFIG_PAGE_MAN_10,
301 Mpi2ManufacturingPage10_t, MPI2_POINTER pMpi2ManufacturingPage10_t;
302
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530303#define MFG_PAGE10_HIDE_SSDS_MASK (0x00000003)
304#define MFG_PAGE10_HIDE_ALL_DISKS (0x00)
305#define MFG_PAGE10_EXPOSE_ALL_DISKS (0x01)
306#define MFG_PAGE10_HIDE_IF_VOL_PRESENT (0x02)
307
308
Eric Moore635374e2009-03-09 01:21:12 -0600309struct MPT2SAS_DEVICE {
310 struct MPT2SAS_TARGET *sas_target;
311 unsigned int lun;
312 u32 flags;
313 u8 configured_lun;
314 u8 block;
315 u8 tlr_snoop_check;
316};
317
318#define MPT2_CMD_NOT_USED 0x8000 /* free */
319#define MPT2_CMD_COMPLETE 0x0001 /* completed */
320#define MPT2_CMD_PENDING 0x0002 /* pending */
321#define MPT2_CMD_REPLY_VALID 0x0004 /* reply is valid */
322#define MPT2_CMD_RESET 0x0008 /* host reset dropped the command */
323
324/**
325 * struct _internal_cmd - internal commands struct
326 * @mutex: mutex
327 * @done: completion
328 * @reply: reply message pointer
Kashyap, Desai769578f2010-06-17 13:49:28 +0530329 * @sense: sense data
Eric Moore635374e2009-03-09 01:21:12 -0600330 * @status: MPT2_CMD_XXX status
331 * @smid: system message id
332 */
333struct _internal_cmd {
334 struct mutex mutex;
335 struct completion done;
336 void *reply;
Kashyap, Desai769578f2010-06-17 13:49:28 +0530337 void *sense;
Eric Moore635374e2009-03-09 01:21:12 -0600338 u16 status;
339 u16 smid;
340};
341
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530342
Eric Moore635374e2009-03-09 01:21:12 -0600343/**
344 * struct _sas_device - attached device information
345 * @list: sas device list
346 * @starget: starget object
347 * @sas_address: device sas address
348 * @device_name: retrieved from the SAS IDENTIFY frame.
349 * @handle: device handle
Kashyap, Desaic5e039b2009-09-23 17:21:29 +0530350 * @sas_address_parent: sas address of parent expander or sas host
Eric Moore635374e2009-03-09 01:21:12 -0600351 * @enclosure_handle: enclosure handle
352 * @enclosure_logical_id: enclosure logical identifier
353 * @volume_handle: volume handle (valid when hidden raid member)
354 * @volume_wwid: volume unique identifier
355 * @device_info: bitfield provides detailed info about the device
356 * @id: target id
357 * @channel: target channel
358 * @slot: number number
Kashyap, Desai7fbae672010-06-17 13:45:17 +0530359 * @phy: phy identifier provided in sas device page 0
Eric Moore635374e2009-03-09 01:21:12 -0600360 * @responding: used in _scsih_sas_device_mark_responding
Sreekanth Reddybd58ea32014-09-12 15:35:19 +0530361 * @pfa_led_on: flag for PFA LED status
Eric Moore635374e2009-03-09 01:21:12 -0600362 */
363struct _sas_device {
364 struct list_head list;
365 struct scsi_target *starget;
366 u64 sas_address;
367 u64 device_name;
368 u16 handle;
Kashyap, Desaic5e039b2009-09-23 17:21:29 +0530369 u64 sas_address_parent;
Eric Moore635374e2009-03-09 01:21:12 -0600370 u16 enclosure_handle;
371 u64 enclosure_logical_id;
372 u16 volume_handle;
373 u64 volume_wwid;
374 u32 device_info;
375 int id;
376 int channel;
377 u16 slot;
Kashyap, Desai7fbae672010-06-17 13:45:17 +0530378 u8 phy;
Eric Moore635374e2009-03-09 01:21:12 -0600379 u8 responding;
Sreekanth Reddybd58ea32014-09-12 15:35:19 +0530380 u8 pfa_led_on;
Calvin Owensd224fe02015-08-13 18:48:09 -0700381 struct kref refcount;
Eric Moore635374e2009-03-09 01:21:12 -0600382};
383
Calvin Owensd224fe02015-08-13 18:48:09 -0700384static inline void sas_device_get(struct _sas_device *s)
385{
386 kref_get(&s->refcount);
387}
388
389static inline void sas_device_free(struct kref *r)
390{
391 kfree(container_of(r, struct _sas_device, refcount));
392}
393
394static inline void sas_device_put(struct _sas_device *s)
395{
396 kref_put(&s->refcount, sas_device_free);
397}
398
Eric Moore635374e2009-03-09 01:21:12 -0600399/**
400 * struct _raid_device - raid volume link list
401 * @list: sas device list
402 * @starget: starget object
403 * @sdev: scsi device struct (volumes are single lun)
404 * @wwid: unique identifier for the volume
405 * @handle: device handle
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530406 * @block_size: Block size of the volume
Eric Moore635374e2009-03-09 01:21:12 -0600407 * @id: target id
408 * @channel: target channel
409 * @volume_type: the raid level
410 * @device_info: bitfield provides detailed info about the hidden components
411 * @num_pds: number of hidden raid components
412 * @responding: used in _scsih_raid_device_mark_responding
Kashyap, Desaif7c95ef2009-12-16 18:54:42 +0530413 * @percent_complete: resync percent complete
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530414 * @direct_io_enabled: Whether direct io to PDs are allowed or not
415 * @stripe_exponent: X where 2powX is the stripe sz in blocks
nagalakshmi.nandigama@lsi.comba96bd02011-12-01 07:51:55 +0530416 * @block_exponent: X where 2powX is the block sz in bytes
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530417 * @max_lba: Maximum number of LBA in the volume
418 * @stripe_sz: Stripe Size of the volume
419 * @device_info: Device info of the volume member disk
420 * @pd_handle: Array of handles of the physical drives for direct I/O in le16
Eric Moore635374e2009-03-09 01:21:12 -0600421 */
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530422#define MPT_MAX_WARPDRIVE_PDS 8
Eric Moore635374e2009-03-09 01:21:12 -0600423struct _raid_device {
424 struct list_head list;
425 struct scsi_target *starget;
426 struct scsi_device *sdev;
427 u64 wwid;
428 u16 handle;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530429 u16 block_sz;
Eric Moore635374e2009-03-09 01:21:12 -0600430 int id;
431 int channel;
432 u8 volume_type;
Eric Moore635374e2009-03-09 01:21:12 -0600433 u8 num_pds;
434 u8 responding;
Kashyap, Desaif7c95ef2009-12-16 18:54:42 +0530435 u8 percent_complete;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530436 u8 direct_io_enabled;
437 u8 stripe_exponent;
nagalakshmi.nandigama@lsi.comba96bd02011-12-01 07:51:55 +0530438 u8 block_exponent;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530439 u64 max_lba;
440 u32 stripe_sz;
441 u32 device_info;
442 u16 pd_handle[MPT_MAX_WARPDRIVE_PDS];
Eric Moore635374e2009-03-09 01:21:12 -0600443};
444
445/**
446 * struct _boot_device - boot device info
447 * @is_raid: flag to indicate whether this is volume
448 * @device: holds pointer for either struct _sas_device or
449 * struct _raid_device
450 */
451struct _boot_device {
452 u8 is_raid;
453 void *device;
454};
455
456/**
457 * struct _sas_port - wide/narrow sas port information
458 * @port_list: list of ports belonging to expander
Eric Moore635374e2009-03-09 01:21:12 -0600459 * @num_phys: number of phys belonging to this port
460 * @remote_identify: attached device identification
461 * @rphy: sas transport rphy object
462 * @port: sas transport wide/narrow port object
463 * @phy_list: _sas_phy list objects belonging to this port
464 */
465struct _sas_port {
466 struct list_head port_list;
Eric Moore635374e2009-03-09 01:21:12 -0600467 u8 num_phys;
468 struct sas_identify remote_identify;
469 struct sas_rphy *rphy;
470 struct sas_port *port;
471 struct list_head phy_list;
472};
473
474/**
475 * struct _sas_phy - phy information
476 * @port_siblings: list of phys belonging to a port
477 * @identify: phy identification
478 * @remote_identify: attached device identification
479 * @phy: sas transport phy object
480 * @phy_id: unique phy id
481 * @handle: device handle for this phy
482 * @attached_handle: device handle for attached device
Kashyap, Desai38c29112010-04-05 14:18:34 +0530483 * @phy_belongs_to_port: port has been created for this phy
Eric Moore635374e2009-03-09 01:21:12 -0600484 */
485struct _sas_phy {
486 struct list_head port_siblings;
487 struct sas_identify identify;
488 struct sas_identify remote_identify;
489 struct sas_phy *phy;
490 u8 phy_id;
491 u16 handle;
492 u16 attached_handle;
Kashyap, Desai38c29112010-04-05 14:18:34 +0530493 u8 phy_belongs_to_port;
Eric Moore635374e2009-03-09 01:21:12 -0600494};
495
496/**
497 * struct _sas_node - sas_host/expander information
498 * @list: list of expanders
499 * @parent_dev: parent device class
500 * @num_phys: number phys belonging to this sas_host/expander
501 * @sas_address: sas address of this sas_host/expander
502 * @handle: handle for this sas_host/expander
Kashyap, Desaic5e039b2009-09-23 17:21:29 +0530503 * @sas_address_parent: sas address of parent expander or sas host
Eric Moore635374e2009-03-09 01:21:12 -0600504 * @enclosure_handle: handle for this a member of an enclosure
505 * @device_info: bitwise defining capabilities of this sas_host/expander
506 * @responding: used in _scsih_expander_device_mark_responding
507 * @phy: a list of phys that make up this sas_host/expander
508 * @sas_port_list: list of ports attached to this sas_host/expander
509 */
510struct _sas_node {
511 struct list_head list;
512 struct device *parent_dev;
513 u8 num_phys;
514 u64 sas_address;
515 u16 handle;
Kashyap, Desaic5e039b2009-09-23 17:21:29 +0530516 u64 sas_address_parent;
Eric Moore635374e2009-03-09 01:21:12 -0600517 u16 enclosure_handle;
518 u64 enclosure_logical_id;
519 u8 responding;
520 struct _sas_phy *phy;
521 struct list_head sas_port_list;
522};
523
524/**
525 * enum reset_type - reset state
526 * @FORCE_BIG_HAMMER: issue diagnostic reset
527 * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
528 */
529enum reset_type {
530 FORCE_BIG_HAMMER,
531 SOFT_RESET,
532};
533
534/**
Kashyap, Desai35f805b2010-11-13 04:34:06 +0530535 * struct chain_tracker - firmware chain tracker
536 * @chain_buffer: chain buffer
537 * @chain_buffer_dma: physical address
538 * @tracker_list: list of free request (ioc->free_chain_list)
539 */
540struct chain_tracker {
541 void *chain_buffer;
542 dma_addr_t chain_buffer_dma;
543 struct list_head tracker_list;
544};
545
546/**
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530547 * struct scsiio_tracker - scsi mf request tracker
Eric Moore635374e2009-03-09 01:21:12 -0600548 * @smid: system message id
549 * @scmd: scsi request pointer
550 * @cb_idx: callback index
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530551 * @direct_io: To indicate whether I/O is direct (WARPDRIVE)
Eric Moore635374e2009-03-09 01:21:12 -0600552 * @chain_list: list of chains associated to this IO
553 * @tracker_list: list of free request (ioc->free_list)
554 */
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530555struct scsiio_tracker {
Eric Moore635374e2009-03-09 01:21:12 -0600556 u16 smid;
557 struct scsi_cmnd *scmd;
558 u8 cb_idx;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530559 u8 direct_io;
Kashyap, Desai35f805b2010-11-13 04:34:06 +0530560 struct list_head chain_list;
Eric Moore635374e2009-03-09 01:21:12 -0600561 struct list_head tracker_list;
562};
563
Kashyap, Desai77e63ed2009-09-14 11:04:23 +0530564/**
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +0530565 * struct request_tracker - firmware request tracker
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530566 * @smid: system message id
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530567 * @cb_idx: callback index
568 * @tracker_list: list of free request (ioc->free_list)
569 */
570struct request_tracker {
571 u16 smid;
572 u8 cb_idx;
573 struct list_head tracker_list;
574};
575
576/**
Kashyap, Desai77e63ed2009-09-14 11:04:23 +0530577 * struct _tr_list - target reset list
578 * @handle: device handle
579 * @state: state machine
580 */
581struct _tr_list {
582 struct list_head list;
583 u16 handle;
584 u16 state;
585};
586
Eric Moore635374e2009-03-09 01:21:12 -0600587typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
588
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530589/**
590 * struct adapter_reply_queue - the reply queue struct
591 * @ioc: per adapter object
592 * @msix_index: msix index into vector table
593 * @vector: irq vector
594 * @reply_post_host_index: head index in the pool where FW completes IO
595 * @reply_post_free: reply post base virt address
596 * @name: the name registered to request_irq()
597 * @busy: isr is actively processing replies on another cpu
598 * @list: this list
599*/
600struct adapter_reply_queue {
601 struct MPT2SAS_ADAPTER *ioc;
602 u8 msix_index;
603 unsigned int vector;
604 u32 reply_post_host_index;
605 Mpi2ReplyDescriptorsUnion_t *reply_post_free;
606 char name[MPT_NAME_LENGTH];
607 atomic_t busy;
Sreekanth Reddy14b3114d2015-01-12 11:39:03 +0530608 cpumask_var_t affinity_hint;
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530609 struct list_head list;
610};
611
Kashyap, Desaic97951e2011-06-14 10:54:56 +0530612/* IOC Facts and Port Facts converted from little endian to cpu */
613union mpi2_version_union {
614 MPI2_VERSION_STRUCT Struct;
615 u32 Word;
616};
617
618struct mpt2sas_facts {
619 u16 MsgVersion;
620 u16 HeaderVersion;
621 u8 IOCNumber;
622 u8 VP_ID;
623 u8 VF_ID;
624 u16 IOCExceptions;
625 u16 IOCStatus;
626 u32 IOCLogInfo;
627 u8 MaxChainDepth;
628 u8 WhoInit;
629 u8 NumberOfPorts;
630 u8 MaxMSIxVectors;
631 u16 RequestCredit;
632 u16 ProductID;
633 u32 IOCCapabilities;
634 union mpi2_version_union FWVersion;
635 u16 IOCRequestFrameSize;
636 u16 Reserved3;
637 u16 MaxInitiators;
638 u16 MaxTargets;
639 u16 MaxSasExpanders;
640 u16 MaxEnclosures;
641 u16 ProtocolFlags;
642 u16 HighPriorityCredit;
643 u16 MaxReplyDescriptorPostQueueDepth;
644 u8 ReplyFrameSize;
645 u8 MaxVolumes;
646 u16 MaxDevHandle;
647 u16 MaxPersistentEntries;
648 u16 MinDevHandle;
649};
650
651struct mpt2sas_port_facts {
652 u8 PortNumber;
653 u8 VP_ID;
654 u8 VF_ID;
655 u8 PortType;
656 u16 MaxPostedCmdBuffers;
657};
658
Sreekanth Reddy5fb1bf82014-09-12 15:35:22 +0530659struct reply_post_struct {
660 Mpi2ReplyDescriptorsUnion_t *reply_post_free;
661 dma_addr_t reply_post_free_dma;
662};
663
Eric Moore635374e2009-03-09 01:21:12 -0600664/**
Kashyap, Desaif93213d2011-06-14 10:56:43 +0530665 * enum mutex_type - task management mutex type
666 * @TM_MUTEX_OFF: mutex is not required becuase calling function is acquiring it
667 * @TM_MUTEX_ON: mutex is required
668 */
669enum mutex_type {
670 TM_MUTEX_OFF = 0,
671 TM_MUTEX_ON = 1,
672};
673
nagalakshmi.nandigama@lsi.com845a0e42011-12-01 07:42:04 +0530674typedef void (*MPT2SAS_FLUSH_RUNNING_CMDS)(struct MPT2SAS_ADAPTER *ioc);
Kashyap, Desaif93213d2011-06-14 10:56:43 +0530675/**
Eric Moore635374e2009-03-09 01:21:12 -0600676 * struct MPT2SAS_ADAPTER - per adapter struct
677 * @list: ioc_list
678 * @shost: shost object
679 * @id: unique adapter id
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530680 * @cpu_count: number online cpus
Eric Moore635374e2009-03-09 01:21:12 -0600681 * @name: generic ioc string
682 * @tmp_string: tmp string used for logging
683 * @pdev: pci pdev object
684 * @chip: memory mapped register space
685 * @chip_phys: physical addrss prior to mapping
Eric Moore635374e2009-03-09 01:21:12 -0600686 * @logging_level: see mpt2sas_debug.h
Kashyap, Desaifa7f3162009-09-23 17:26:58 +0530687 * @fwfault_debug: debuging FW timeouts
Eric Moore635374e2009-03-09 01:21:12 -0600688 * @ir_firmware: IR firmware present
689 * @bars: bitmask of BAR's that must be configured
690 * @mask_interrupts: ignore interrupt
Sreekanth Reddy5fb1bf82014-09-12 15:35:22 +0530691 * @dma_mask: used to set the consistent dma mask
Eric Moore635374e2009-03-09 01:21:12 -0600692 * @fault_reset_work_q_name: fw fault work queue
693 * @fault_reset_work_q: ""
694 * @fault_reset_work: ""
695 * @firmware_event_name: fw event work queue
696 * @firmware_event_thread: ""
697 * @fw_events_off: flag to turn off fw event handling
698 * @fw_event_lock:
699 * @fw_event_list: list of fw events
700 * @aen_event_read_flag: event log was read
701 * @broadcast_aen_busy: broadcast aen waiting to be serviced
Kashyap, Desai155dd4c2009-08-20 13:22:00 +0530702 * @shost_recovery: host reset in progress
Eric Moore635374e2009-03-09 01:21:12 -0600703 * @ioc_reset_in_progress_lock:
704 * @ioc_link_reset_in_progress: phy/hard reset in progress
Uwe Kleine-König65155b32010-06-11 12:17:01 +0200705 * @ignore_loginfos: ignore loginfos during task management
Eric Moore635374e2009-03-09 01:21:12 -0600706 * @remove_host: flag for when driver unloads, to avoid sending dev resets
Eric Moore3cb54692010-07-08 14:44:34 -0600707 * @pci_error_recovery: flag to prevent ioc access until slot reset completes
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +0530708 * @wait_for_discovery_to_complete: flag set at driver load time when
709 * waiting on reporting devices
710 * @is_driver_loading: flag set at driver load time
711 * @port_enable_failed: flag set when port enable has failed
712 * @start_scan: flag set from scan_start callback, cleared from _mpt2sas_fw_work
713 * @start_scan_failed: means port enable failed, return's the ioc_status
Eric Moore635374e2009-03-09 01:21:12 -0600714 * @msix_enable: flag indicating msix is enabled
715 * @msix_vector_count: number msix vectors
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530716 * @cpu_msix_table: table for mapping cpus to msix index
717 * @cpu_msix_table_sz: table size
nagalakshmi.nandigama@lsi.com845a0e42011-12-01 07:42:04 +0530718 * @schedule_dead_ioc_flush_running_cmds: callback to flush pending commands
Eric Moore635374e2009-03-09 01:21:12 -0600719 * @scsi_io_cb_idx: shost generated commands
720 * @tm_cb_idx: task management commands
Kashyap, Desai744090d2009-10-05 15:56:56 +0530721 * @scsih_cb_idx: scsih internal commands
Eric Moore635374e2009-03-09 01:21:12 -0600722 * @transport_cb_idx: transport internal commands
723 * @ctl_cb_idx: clt internal commands
724 * @base_cb_idx: base internal commands
725 * @config_cb_idx: base internal commands
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530726 * @tm_tr_cb_idx : device removal target reset handshake
727 * @tm_tr_volume_cb_idx : volume removal target reset
Eric Moore635374e2009-03-09 01:21:12 -0600728 * @base_cmds:
729 * @transport_cmds:
Kashyap, Desai744090d2009-10-05 15:56:56 +0530730 * @scsih_cmds:
Eric Moore635374e2009-03-09 01:21:12 -0600731 * @tm_cmds:
732 * @ctl_cmds:
733 * @config_cmds:
734 * @base_add_sg_single: handler for either 32/64 bit sgl's
735 * @event_type: bits indicating which events to log
736 * @event_context: unique id for each logged event
737 * @event_log: event log pointer
738 * @event_masks: events that are masked
739 * @facts: static facts data
740 * @pfacts: static port facts data
741 * @manu_pg0: static manufacturing page 0
Kashyap, Desaied79f122009-08-20 13:23:49 +0530742 * @manu_pg10: static manufacturing page 10
Eric Moore635374e2009-03-09 01:21:12 -0600743 * @bios_pg2: static bios page 2
744 * @bios_pg3: static bios page 3
745 * @ioc_pg8: static ioc page 8
746 * @iounit_pg0: static iounit page 0
747 * @iounit_pg1: static iounit page 1
Sreekanth Reddy2d8ce8c2015-01-12 11:38:56 +0530748 * @iounit_pg8: static iounit page 8
Eric Moore635374e2009-03-09 01:21:12 -0600749 * @sas_hba: sas host object
750 * @sas_expander_list: expander object list
751 * @sas_node_lock:
752 * @sas_device_list: sas device object list
753 * @sas_device_init_list: sas device object list (used only at init time)
754 * @sas_device_lock:
755 * @io_missing_delay: time for IO completed by fw when PDR enabled
756 * @device_missing_delay: time for device missing by fw when PDR enabled
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530757 * @sas_id : used for setting volume target IDs
nagalakshmi.nandigama@lsi.com09da0b32012-03-20 12:06:50 +0530758 * @blocking_handles: bitmask used to identify which devices need blocking
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530759 * @pd_handles : bitmask for PD handles
760 * @pd_handles_sz : size of pd_handle bitmask
Eric Moore635374e2009-03-09 01:21:12 -0600761 * @config_page_sz: config page size
762 * @config_page: reserve memory for config page payload
763 * @config_page_dma:
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530764 * @hba_queue_depth: hba request queue depth
Eric Moore635374e2009-03-09 01:21:12 -0600765 * @sge_size: sg element size for either 32/64 bit
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530766 * @scsiio_depth: SCSI_IO queue depth
Eric Moore635374e2009-03-09 01:21:12 -0600767 * @request_sz: per request frame size
768 * @request: pool of request frames
769 * @request_dma:
770 * @request_dma_sz:
771 * @scsi_lookup: firmware request tracker list
772 * @scsi_lookup_lock:
773 * @free_list: free list of request
774 * @chain: pool of chains
775 * @pending_io_count:
776 * @reset_wq:
777 * @chain_dma:
778 * @max_sges_in_main_message: number sg elements in main message
779 * @max_sges_in_chain_message: number sg elements per chain
780 * @chains_needed_per_io: max chains per io
781 * @chain_offset_value_for_main_message: location 1st sg in main
782 * @chain_depth: total chains allocated
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530783 * @hi_priority_smid:
784 * @hi_priority:
785 * @hi_priority_dma:
786 * @hi_priority_depth:
787 * @hpr_lookup:
788 * @hpr_free_list:
789 * @internal_smid:
790 * @internal:
791 * @internal_dma:
792 * @internal_depth:
793 * @internal_lookup:
794 * @internal_free_list:
Eric Moore635374e2009-03-09 01:21:12 -0600795 * @sense: pool of sense
796 * @sense_dma:
797 * @sense_dma_pool:
798 * @reply_depth: hba reply queue depth:
799 * @reply_sz: per reply frame size:
800 * @reply: pool of replys:
801 * @reply_dma:
802 * @reply_dma_pool:
803 * @reply_free_queue_depth: reply free depth
804 * @reply_free: pool for reply free queue (32 bit addr)
805 * @reply_free_dma:
806 * @reply_free_dma_pool:
807 * @reply_free_host_index: tail index in pool to insert free replys
808 * @reply_post_queue_depth: reply post queue depth
Sreekanth Reddy5fb1bf82014-09-12 15:35:22 +0530809 * @reply_post_struct: struct for reply_post_free physical & virt address
810 * @rdpq_array_capable: FW supports multiple reply queue addresses in ioc_init
811 * @rdpq_array_enable: rdpq_array support is enabled in the driver
812 * @rdpq_array_enable_assigned: this ensures that rdpq_array_enable flag
813 * is assigned only ones
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530814 * @reply_queue_count: number of reply queue's
815 * @reply_queue_list: link list contaning the reply queue info
Eric Moore635374e2009-03-09 01:21:12 -0600816 * @reply_post_host_index: head index in the pool where FW completes IO
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530817 * @delayed_tr_list: target reset link list
818 * @delayed_tr_volume_list: volume target reset link list
Sreekanth Reddy2d8ce8c2015-01-12 11:38:56 +0530819 * @@temp_sensors_count: flag to carry the number of temperature sensors
Nagarajkumar Narayanan6229b412015-08-18 13:27:10 +0530820 * @pci_access_mutex: Mutex to synchronize ioctl,sysfs show path and
821 * pci resource handling. PCI resource freeing will lead to free
822 * vital hardware/memory resource, which might be in use by cli/sysfs
823 * path functions resulting in Null pointer reference followed by kernel
824 * crash. To avoid the above race condition we use mutex syncrhonization
825 * which ensures the syncrhonization between cli/sysfs_show path
Eric Moore635374e2009-03-09 01:21:12 -0600826 */
827struct MPT2SAS_ADAPTER {
828 struct list_head list;
829 struct Scsi_Host *shost;
830 u8 id;
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530831 int cpu_count;
Eric Moore635374e2009-03-09 01:21:12 -0600832 char name[MPT_NAME_LENGTH];
833 char tmp_string[MPT_STRING_LENGTH];
834 struct pci_dev *pdev;
835 Mpi2SystemInterfaceRegs_t __iomem *chip;
Kashyap, Desai6846e752009-12-16 18:51:45 +0530836 resource_size_t chip_phys;
Eric Moore635374e2009-03-09 01:21:12 -0600837 int logging_level;
Kashyap, Desaifa7f3162009-09-23 17:26:58 +0530838 int fwfault_debug;
Eric Moore635374e2009-03-09 01:21:12 -0600839 u8 ir_firmware;
840 int bars;
841 u8 mask_interrupts;
Sreekanth Reddy5fb1bf82014-09-12 15:35:22 +0530842 int dma_mask;
Eric Moore635374e2009-03-09 01:21:12 -0600843
844 /* fw fault handler */
845 char fault_reset_work_q_name[20];
846 struct workqueue_struct *fault_reset_work_q;
847 struct delayed_work fault_reset_work;
848
849 /* fw event handler */
850 char firmware_event_name[20];
851 struct workqueue_struct *firmware_event_thread;
Eric Moore635374e2009-03-09 01:21:12 -0600852 spinlock_t fw_event_lock;
853 struct list_head fw_event_list;
854
855 /* misc flags */
856 int aen_event_read_flag;
857 u8 broadcast_aen_busy;
Kashyap, Desaif93213d2011-06-14 10:56:43 +0530858 u16 broadcast_aen_pending;
Eric Moore635374e2009-03-09 01:21:12 -0600859 u8 shost_recovery;
Kashyap, Desaid2742132010-06-17 13:28:55 +0530860
861 struct mutex reset_in_progress_mutex;
Eric Moore635374e2009-03-09 01:21:12 -0600862 spinlock_t ioc_reset_in_progress_lock;
863 u8 ioc_link_reset_in_progress;
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +0530864 u8 ioc_reset_in_progress_status;
Kashyap, Desaid2742132010-06-17 13:28:55 +0530865
Eric Moore635374e2009-03-09 01:21:12 -0600866 u8 ignore_loginfos;
867 u8 remove_host;
Eric Moore3cb54692010-07-08 14:44:34 -0600868 u8 pci_error_recovery;
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +0530869 u8 wait_for_discovery_to_complete;
870 struct completion port_enable_done;
871 u8 is_driver_loading;
872 u8 port_enable_failed;
873
874 u8 start_scan;
875 u16 start_scan_failed;
Eric Moore635374e2009-03-09 01:21:12 -0600876
877 u8 msix_enable;
878 u16 msix_vector_count;
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530879 u8 *cpu_msix_table;
Joe Lawrence42de5972014-06-25 17:04:06 -0400880 resource_size_t __iomem **reply_post_host_index;
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +0530881 u16 cpu_msix_table_sz;
Kashyap, Desaid32a8c12010-06-17 13:36:53 +0530882 u32 ioc_reset_count;
nagalakshmi.nandigama@lsi.com845a0e42011-12-01 07:42:04 +0530883 MPT2SAS_FLUSH_RUNNING_CMDS schedule_dead_ioc_flush_running_cmds;
Sreekanth Reddyb4730fb2012-12-18 14:45:30 +0100884 u32 non_operational_loop;
Eric Moore635374e2009-03-09 01:21:12 -0600885
886 /* internal commands, callback index */
887 u8 scsi_io_cb_idx;
888 u8 tm_cb_idx;
889 u8 transport_cb_idx;
Kashyap, Desai744090d2009-10-05 15:56:56 +0530890 u8 scsih_cb_idx;
Eric Moore635374e2009-03-09 01:21:12 -0600891 u8 ctl_cb_idx;
892 u8 base_cb_idx;
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +0530893 u8 port_enable_cb_idx;
Eric Moore635374e2009-03-09 01:21:12 -0600894 u8 config_cb_idx;
Kashyap, Desai77e63ed2009-09-14 11:04:23 +0530895 u8 tm_tr_cb_idx;
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530896 u8 tm_tr_volume_cb_idx;
Kashyap, Desai77e63ed2009-09-14 11:04:23 +0530897 u8 tm_sas_control_cb_idx;
Eric Moore635374e2009-03-09 01:21:12 -0600898 struct _internal_cmd base_cmds;
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +0530899 struct _internal_cmd port_enable_cmds;
Eric Moore635374e2009-03-09 01:21:12 -0600900 struct _internal_cmd transport_cmds;
Kashyap, Desai744090d2009-10-05 15:56:56 +0530901 struct _internal_cmd scsih_cmds;
Eric Moore635374e2009-03-09 01:21:12 -0600902 struct _internal_cmd tm_cmds;
903 struct _internal_cmd ctl_cmds;
904 struct _internal_cmd config_cmds;
905
906 MPT_ADD_SGE base_add_sg_single;
907
908 /* event log */
909 u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
910 u32 event_context;
911 void *event_log;
912 u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
913
914 /* static config pages */
Kashyap, Desaic97951e2011-06-14 10:54:56 +0530915 struct mpt2sas_facts facts;
916 struct mpt2sas_port_facts *pfacts;
Eric Moore635374e2009-03-09 01:21:12 -0600917 Mpi2ManufacturingPage0_t manu_pg0;
918 Mpi2BiosPage2_t bios_pg2;
919 Mpi2BiosPage3_t bios_pg3;
920 Mpi2IOCPage8_t ioc_pg8;
921 Mpi2IOUnitPage0_t iounit_pg0;
922 Mpi2IOUnitPage1_t iounit_pg1;
Sreekanth Reddy2d8ce8c2015-01-12 11:38:56 +0530923 Mpi2IOUnitPage8_t iounit_pg8;
Eric Moore635374e2009-03-09 01:21:12 -0600924
925 struct _boot_device req_boot_device;
926 struct _boot_device req_alt_boot_device;
927 struct _boot_device current_boot_device;
928
929 /* sas hba, expander, and device list */
930 struct _sas_node sas_hba;
931 struct list_head sas_expander_list;
932 spinlock_t sas_node_lock;
933 struct list_head sas_device_list;
934 struct list_head sas_device_init_list;
935 spinlock_t sas_device_lock;
936 struct list_head raid_device_list;
937 spinlock_t raid_device_lock;
938 u8 io_missing_delay;
939 u16 device_missing_delay;
940 int sas_id;
nagalakshmi.nandigama@lsi.com09da0b32012-03-20 12:06:50 +0530941 void *blocking_handles;
Kashyap, Desaif3eedd62010-06-17 13:46:13 +0530942 void *pd_handles;
943 u16 pd_handles_sz;
944
Eric Moore635374e2009-03-09 01:21:12 -0600945 /* config page */
946 u16 config_page_sz;
947 void *config_page;
948 dma_addr_t config_page_dma;
949
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530950 /* scsiio request */
951 u16 hba_queue_depth;
Eric Moore635374e2009-03-09 01:21:12 -0600952 u16 sge_size;
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530953 u16 scsiio_depth;
Eric Moore635374e2009-03-09 01:21:12 -0600954 u16 request_sz;
955 u8 *request;
956 dma_addr_t request_dma;
957 u32 request_dma_sz;
Kashyap, Desaid5bd3491c2011-01-04 11:39:20 +0530958 struct scsiio_tracker *scsi_lookup;
Kashyap, Desai89009fb2010-03-17 16:22:52 +0530959 ulong scsi_lookup_pages;
960 spinlock_t scsi_lookup_lock;
Eric Moore635374e2009-03-09 01:21:12 -0600961 struct list_head free_list;
962 int pending_io_count;
963 wait_queue_head_t reset_wq;
964
965 /* chain */
Kashyap, Desai35f805b2010-11-13 04:34:06 +0530966 struct chain_tracker *chain_lookup;
967 struct list_head free_chain_list;
968 struct dma_pool *chain_dma_pool;
969 ulong chain_pages;
Eric Moore635374e2009-03-09 01:21:12 -0600970 u16 max_sges_in_main_message;
971 u16 max_sges_in_chain_message;
972 u16 chains_needed_per_io;
973 u16 chain_offset_value_for_main_message;
Kashyap, Desai89009fb2010-03-17 16:22:52 +0530974 u32 chain_depth;
Eric Moore635374e2009-03-09 01:21:12 -0600975
Kashyap, Desai595bb0b2009-09-14 11:02:48 +0530976 /* hi-priority queue */
977 u16 hi_priority_smid;
978 u8 *hi_priority;
979 dma_addr_t hi_priority_dma;
980 u16 hi_priority_depth;
981 struct request_tracker *hpr_lookup;
982 struct list_head hpr_free_list;
983
984 /* internal queue */
985 u16 internal_smid;
986 u8 *internal;
987 dma_addr_t internal_dma;
988 u16 internal_depth;
989 struct request_tracker *internal_lookup;
990 struct list_head internal_free_list;
991
Eric Moore635374e2009-03-09 01:21:12 -0600992 /* sense */
993 u8 *sense;
994 dma_addr_t sense_dma;
995 struct dma_pool *sense_dma_pool;
996
997 /* reply */
998 u16 reply_sz;
999 u8 *reply;
1000 dma_addr_t reply_dma;
Kashyap, Desaidd3741d2010-11-13 04:31:14 +05301001 u32 reply_dma_max_address;
1002 u32 reply_dma_min_address;
Eric Moore635374e2009-03-09 01:21:12 -06001003 struct dma_pool *reply_dma_pool;
1004
1005 /* reply free queue */
1006 u16 reply_free_queue_depth;
Kashyap, Desaic97951e2011-06-14 10:54:56 +05301007 __le32 *reply_free;
Eric Moore635374e2009-03-09 01:21:12 -06001008 dma_addr_t reply_free_dma;
1009 struct dma_pool *reply_free_dma_pool;
1010 u32 reply_free_host_index;
1011
1012 /* reply post queue */
1013 u16 reply_post_queue_depth;
Sreekanth Reddy5fb1bf82014-09-12 15:35:22 +05301014 struct reply_post_struct *reply_post;
1015 u8 rdpq_array_capable;
1016 u8 rdpq_array_enable;
1017 u8 rdpq_array_enable_assigned;
Eric Moore635374e2009-03-09 01:21:12 -06001018 struct dma_pool *reply_post_free_dma_pool;
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +05301019 u8 reply_queue_count;
1020 struct list_head reply_queue_list;
Eric Moore635374e2009-03-09 01:21:12 -06001021
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301022 struct list_head delayed_tr_list;
Kashyap, Desaif3eedd62010-06-17 13:46:13 +05301023 struct list_head delayed_tr_volume_list;
Sreekanth Reddy2d8ce8c2015-01-12 11:38:56 +05301024 u8 temp_sensors_count;
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301025
Eric Moore635374e2009-03-09 01:21:12 -06001026 /* diag buffer support */
1027 u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
1028 u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
1029 dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
1030 u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
1031 u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
Kashyap, Desaied79f122009-08-20 13:23:49 +05301032 Mpi2ManufacturingPage10_t manu_pg10;
Eric Moore635374e2009-03-09 01:21:12 -06001033 u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
1034 u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
Kashyap, Desai570c67a2010-06-17 13:43:17 +05301035 u32 ring_buffer_offset;
1036 u32 ring_buffer_sz;
Kashyap, Desai0bdccdb2011-04-07 12:32:49 +05301037 u8 is_warpdrive;
1038 u8 hide_ir_msg;
1039 u8 mfg_pg10_hide_flag;
1040 u8 hide_drives;
1041
Nagarajkumar Narayanan6229b412015-08-18 13:27:10 +05301042 struct mutex pci_access_mutex;
Eric Moore635374e2009-03-09 01:21:12 -06001043};
1044
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301045typedef u8 (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1046 u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -06001047
1048
1049/* base shared API */
Eric Mooreba33fad2009-03-15 21:37:18 -06001050extern struct list_head mpt2sas_ioc_list;
Nagarajkumar Narayanan6229b412015-08-18 13:27:10 +05301051/* spinlock on list operations over IOCs
1052 * Case: when multiple warpdrive cards(IOCs) are in use
1053 * Each IOC will added to the ioc list stucture on initialization.
1054 * Watchdog threads run at regular intervals to check IOC for any
1055 * fault conditions which will trigger the dead_ioc thread to
1056 * deallocate pci resource, resulting deleting the IOC netry from list,
1057 * this deletion need to protected by spinlock to enusre that
1058 * ioc removal is syncrhonized, if not synchronized it might lead to
1059 * list_del corruption as the ioc list is traversed in cli path
1060 */
1061extern spinlock_t gioc_lock;
Kashyap, Desaie4750c92009-08-07 19:37:59 +05301062void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc);
1063void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc);
Eric Moore635374e2009-03-09 01:21:12 -06001064
1065int mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc);
1066void mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc);
1067int mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc);
1068void mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc);
1069int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
1070 enum reset_type type);
1071
1072void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid);
1073void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid);
1074void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr);
Kashyap, Desaiec9472c2009-09-23 17:34:13 +05301075__le32 mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc,
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301076 u16 smid);
nagalakshmi.nandigama@lsi.com911ae942011-09-08 06:18:50 +05301077void mpt2sas_base_flush_reply_queues(struct MPT2SAS_ADAPTER *ioc);
Eric Moore635374e2009-03-09 01:21:12 -06001078
Kashyap, Desai595bb0b2009-09-14 11:02:48 +05301079/* hi-priority queue */
1080u16 mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
1081u16 mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx,
1082 struct scsi_cmnd *scmd);
1083
Eric Moore635374e2009-03-09 01:21:12 -06001084u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
1085void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid);
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301086void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid,
Eric Moore635374e2009-03-09 01:21:12 -06001087 u16 handle);
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301088void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid);
Eric Moore635374e2009-03-09 01:21:12 -06001089void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid,
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301090 u16 io_index);
1091void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid);
Eric Moore635374e2009-03-09 01:21:12 -06001092void mpt2sas_base_initialize_callback_handler(void);
1093u8 mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func);
1094void mpt2sas_base_release_callback_handler(u8 cb_idx);
1095
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301096u8 mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301097 u32 reply);
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +05301098u8 mpt2sas_port_enable_done(struct MPT2SAS_ADAPTER *ioc, u16 smid,
1099 u8 msix_index, u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -06001100void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr);
1101
1102u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked);
1103
1104void mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code);
1105int mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
1106 Mpi2SasIoUnitControlReply_t *mpi_reply, Mpi2SasIoUnitControlRequest_t
1107 *mpi_request);
1108int mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
1109 Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
1110void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type);
1111
Kashyap, Desaifa7f3162009-09-23 17:26:58 +05301112void mpt2sas_halt_firmware(struct MPT2SAS_ADAPTER *ioc);
1113
Reddy, Sreekanthb0df96a02013-02-26 16:59:59 +05301114void mpt2sas_base_update_missing_delay(struct MPT2SAS_ADAPTER *ioc,
1115 u16 device_missing_delay, u8 io_missing_delay);
1116
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +05301117int mpt2sas_port_enable(struct MPT2SAS_ADAPTER *ioc);
1118
Eric Moore635374e2009-03-09 01:21:12 -06001119/* scsih shared API */
Sreekanth Reddy6409a7d2013-07-25 11:24:35 +05301120void mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301121 u32 reply);
Kashyap, Desai8ed9a032010-03-17 16:25:59 +05301122int mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle,
Kashyap, Desaif93213d2011-06-14 10:56:43 +05301123 uint channel, uint id, uint lun, u8 type, u16 smid_task,
Matthew Wilcox2e45c8b2014-03-27 16:40:32 -04001124 ulong timeout, enum mutex_type m_type);
Eric Moore635374e2009-03-09 01:21:12 -06001125void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
1126void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
Kashyap, Desai7f6f7942010-11-13 04:35:30 +05301127void mpt2sas_expander_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
nagalakshmi.nandigama@lsi.com09da0b32012-03-20 12:06:50 +05301128void mpt2sas_device_remove_by_sas_address(struct MPT2SAS_ADAPTER *ioc,
1129 u64 sas_address);
Eric Moore635374e2009-03-09 01:21:12 -06001130struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *ioc,
1131 u16 handle);
1132struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER
1133 *ioc, u64 sas_address);
Calvin Owensd224fe02015-08-13 18:48:09 -07001134struct _sas_device *mpt2sas_get_sdev_by_addr(
1135 struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
1136struct _sas_device *__mpt2sas_get_sdev_by_addr(
Eric Moore635374e2009-03-09 01:21:12 -06001137 struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
1138
nagalakshmi.nandigama@lsi.com921cd802011-10-19 15:36:26 +05301139void mpt2sas_port_enable_complete(struct MPT2SAS_ADAPTER *ioc);
Eric Moore635374e2009-03-09 01:21:12 -06001140void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
1141
1142/* config shared API */
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301143u8 mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301144 u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -06001145int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys);
1146int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
1147 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
Kashyap, Desaied79f122009-08-20 13:23:49 +05301148int mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc,
1149 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage10_t *config_page);
Eric Moore635374e2009-03-09 01:21:12 -06001150int mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1151 *mpi_reply, Mpi2BiosPage2_t *config_page);
1152int mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1153 *mpi_reply, Mpi2BiosPage3_t *config_page);
1154int mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1155 *mpi_reply, Mpi2IOUnitPage0_t *config_page);
1156int mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1157 *mpi_reply, Mpi2SasDevicePage0_t *config_page, u32 form, u32 handle);
1158int mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1159 *mpi_reply, Mpi2SasDevicePage1_t *config_page, u32 form, u32 handle);
1160int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1161 *mpi_reply, Mpi2SasIOUnitPage0_t *config_page, u16 sz);
1162int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1163 *mpi_reply, Mpi2IOUnitPage1_t *config_page);
1164int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
Kashyap, Desai5b768582009-08-20 13:24:31 +05301165 *mpi_reply, Mpi2IOUnitPage1_t *config_page);
Sreekanth Reddy2d8ce8c2015-01-12 11:38:56 +05301166int mpt2sas_config_get_iounit_pg8(struct MPT2SAS_ADAPTER *ioc,
1167 Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage8_t *config_page);
sreekanth.reddy@lsi.com6c265662012-07-17 15:56:07 +05301168int mpt2sas_config_get_iounit_pg3(struct MPT2SAS_ADAPTER *ioc,
1169 Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage3_t *config_page, u16 sz);
Eric Moore635374e2009-03-09 01:21:12 -06001170int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1171 *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
Kashyap, Desai50d5c602009-12-16 18:55:26 +05301172int mpt2sas_config_set_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
1173 Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
Eric Moore635374e2009-03-09 01:21:12 -06001174int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1175 *mpi_reply, Mpi2IOCPage8_t *config_page);
1176int mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1177 *mpi_reply, Mpi2ExpanderPage0_t *config_page, u32 form, u32 handle);
1178int mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1179 *mpi_reply, Mpi2ExpanderPage1_t *config_page, u32 phy_number, u16 handle);
1180int mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1181 *mpi_reply, Mpi2SasEnclosurePage0_t *config_page, u32 form, u32 handle);
1182int mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1183 *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
1184int mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1185 *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
1186int mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1187 *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form, u32 handle);
1188int mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 *num_pds);
1189int mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1190 *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form, u32 handle, u16 sz);
1191int mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1192 *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 form,
1193 u32 form_specific);
1194int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
1195 u16 *volume_handle);
1196int mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER *ioc, u16 volume_handle,
1197 u64 *wwid);
Eric Moore635374e2009-03-09 01:21:12 -06001198/* ctl shared API */
1199extern struct device_attribute *mpt2sas_host_attrs[];
1200extern struct device_attribute *mpt2sas_dev_attrs[];
1201void mpt2sas_ctl_init(void);
1202void mpt2sas_ctl_exit(void);
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301203u8 mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301204 u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -06001205void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
Sreekanth Reddy6409a7d2013-07-25 11:24:35 +05301206void mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
Kashyap, Desai7b936b02009-09-25 11:44:41 +05301207 u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -06001208void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,
1209 Mpi2EventNotificationReply_t *mpi_reply);
1210
Kashyap, Desai32e0eb52009-09-23 17:28:09 +05301211void mpt2sas_enable_diag_buffer(struct MPT2SAS_ADAPTER *ioc,
1212 u8 bits_to_regsiter);
1213
Eric Moore635374e2009-03-09 01:21:12 -06001214/* transport shared API */
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301215u8 mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1216 u32 reply);
Eric Moore635374e2009-03-09 01:21:12 -06001217struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc,
Kashyap, Desaic5e039b2009-09-23 17:21:29 +05301218 u16 handle, u64 sas_address);
Eric Moore635374e2009-03-09 01:21:12 -06001219void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
Kashyap, Desaic5e039b2009-09-23 17:21:29 +05301220 u64 sas_address_parent);
Eric Moore635374e2009-03-09 01:21:12 -06001221int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
1222 *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
1223int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
1224 *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev);
Kashyap, Desaic5e039b2009-09-23 17:21:29 +05301225void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc,
1226 u64 sas_address, u16 handle, u8 phy_number, u8 link_rate);
Eric Moore635374e2009-03-09 01:21:12 -06001227extern struct sas_function_template mpt2sas_transport_functions;
1228extern struct scsi_transport_template *mpt2sas_transport_template;
Kashyap, Desai34a03be2009-08-20 13:23:19 +05301229extern int scsi_internal_device_block(struct scsi_device *sdev);
Kashyap, Desai77e63ed2009-09-14 11:04:23 +05301230extern u8 mpt2sas_stm_zero_smid_handler(struct MPT2SAS_ADAPTER *ioc,
1231 u8 msix_index, u32 reply);
Mike Christie5d9fb5c2012-05-17 23:56:57 -05001232extern int scsi_internal_device_unblock(struct scsi_device *sdev,
1233 enum scsi_device_state new_state);
Eric Moore635374e2009-03-09 01:21:12 -06001234
1235#endif /* MPT2SAS_BASE_H_INCLUDED */