aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/mpt2sas
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/mpt2sas')
-rw-r--r--drivers/scsi/mpt2sas/Kconfig2
-rw-r--r--drivers/scsi/mpt2sas/mpi/mpi2.h103
-rw-r--r--drivers/scsi/mpt2sas/mpi/mpi2_cnfg.h200
-rw-r--r--drivers/scsi/mpt2sas/mpi/mpi2_history.txt334
-rw-r--r--drivers/scsi/mpt2sas/mpi/mpi2_init.h18
-rw-r--r--drivers/scsi/mpt2sas/mpi/mpi2_ioc.h65
-rw-r--r--drivers/scsi/mpt2sas/mpi/mpi2_tool.h134
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.c446
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.h106
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_config.c22
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_ctl.c61
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_ctl.h2
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_debug.h2
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c568
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_transport.c26
15 files changed, 1681 insertions, 408 deletions
diff --git a/drivers/scsi/mpt2sas/Kconfig b/drivers/scsi/mpt2sas/Kconfig
index 4a86855c23b3..70c4c2467dd8 100644
--- a/drivers/scsi/mpt2sas/Kconfig
+++ b/drivers/scsi/mpt2sas/Kconfig
@@ -2,7 +2,7 @@
2# Kernel configuration file for the MPT2SAS 2# Kernel configuration file for the MPT2SAS
3# 3#
4# This code is based on drivers/scsi/mpt2sas/Kconfig 4# This code is based on drivers/scsi/mpt2sas/Kconfig
5# Copyright (C) 2007-2008 LSI Corporation 5# Copyright (C) 2007-2009 LSI Corporation
6# (mailto:DL-MPTFusionLinux@lsi.com) 6# (mailto:DL-MPTFusionLinux@lsi.com)
7 7
8# This program is free software; you can redistribute it and/or 8# This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt2sas/mpi/mpi2.h b/drivers/scsi/mpt2sas/mpi/mpi2.h
index 7bb2ece8b2e4..f9f6c0839276 100644
--- a/drivers/scsi/mpt2sas/mpi/mpi2.h
+++ b/drivers/scsi/mpt2sas/mpi/mpi2.h
@@ -8,7 +8,7 @@
8 * scatter/gather formats. 8 * scatter/gather formats.
9 * Creation Date: June 21, 2006 9 * Creation Date: June 21, 2006
10 * 10 *
11 * mpi2.h Version: 02.00.11 11 * mpi2.h Version: 02.00.12
12 * 12 *
13 * Version History 13 * Version History
14 * --------------- 14 * ---------------
@@ -45,6 +45,13 @@
45 * 10-02-08 02.00.10 Bumped MPI2_HEADER_VERSION_UNIT. 45 * 10-02-08 02.00.10 Bumped MPI2_HEADER_VERSION_UNIT.
46 * Moved LUN field defines from mpi2_init.h. 46 * Moved LUN field defines from mpi2_init.h.
47 * 01-19-09 02.00.11 Bumped MPI2_HEADER_VERSION_UNIT. 47 * 01-19-09 02.00.11 Bumped MPI2_HEADER_VERSION_UNIT.
48 * 05-06-09 02.00.12 Bumped MPI2_HEADER_VERSION_UNIT.
49 * In all request and reply descriptors, replaced VF_ID
50 * field with MSIxIndex field.
51 * Removed DevHandle field from
52 * MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR and made those
53 * bytes reserved.
54 * Added RAID Accelerator functionality.
48 * -------------------------------------------------------------------------- 55 * --------------------------------------------------------------------------
49 */ 56 */
50 57
@@ -70,7 +77,7 @@
70#define MPI2_VERSION_02_00 (0x0200) 77#define MPI2_VERSION_02_00 (0x0200)
71 78
72/* versioning for this MPI header set */ 79/* versioning for this MPI header set */
73#define MPI2_HEADER_VERSION_UNIT (0x0B) 80#define MPI2_HEADER_VERSION_UNIT (0x0C)
74#define MPI2_HEADER_VERSION_DEV (0x00) 81#define MPI2_HEADER_VERSION_DEV (0x00)
75#define MPI2_HEADER_VERSION_UNIT_MASK (0xFF00) 82#define MPI2_HEADER_VERSION_UNIT_MASK (0xFF00)
76#define MPI2_HEADER_VERSION_UNIT_SHIFT (8) 83#define MPI2_HEADER_VERSION_UNIT_SHIFT (8)
@@ -257,7 +264,7 @@ typedef volatile struct _MPI2_SYSTEM_INTERFACE_REGS
257typedef struct _MPI2_DEFAULT_REQUEST_DESCRIPTOR 264typedef struct _MPI2_DEFAULT_REQUEST_DESCRIPTOR
258{ 265{
259 U8 RequestFlags; /* 0x00 */ 266 U8 RequestFlags; /* 0x00 */
260 U8 VF_ID; /* 0x01 */ 267 U8 MSIxIndex; /* 0x01 */
261 U16 SMID; /* 0x02 */ 268 U16 SMID; /* 0x02 */
262 U16 LMID; /* 0x04 */ 269 U16 LMID; /* 0x04 */
263 U16 DescriptorTypeDependent; /* 0x06 */ 270 U16 DescriptorTypeDependent; /* 0x06 */
@@ -271,6 +278,7 @@ typedef struct _MPI2_DEFAULT_REQUEST_DESCRIPTOR
271#define MPI2_REQ_DESCRIPT_FLAGS_SCSI_TARGET (0x02) 278#define MPI2_REQ_DESCRIPT_FLAGS_SCSI_TARGET (0x02)
272#define MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY (0x06) 279#define MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY (0x06)
273#define MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE (0x08) 280#define MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE (0x08)
281#define MPI2_REQ_DESCRIPT_FLAGS_RAID_ACCELERATOR (0x0A)
274 282
275#define MPI2_REQ_DESCRIPT_FLAGS_IOC_FIFO_MARKER (0x01) 283#define MPI2_REQ_DESCRIPT_FLAGS_IOC_FIFO_MARKER (0x01)
276 284
@@ -279,7 +287,7 @@ typedef struct _MPI2_DEFAULT_REQUEST_DESCRIPTOR
279typedef struct _MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR 287typedef struct _MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR
280{ 288{
281 U8 RequestFlags; /* 0x00 */ 289 U8 RequestFlags; /* 0x00 */
282 U8 VF_ID; /* 0x01 */ 290 U8 MSIxIndex; /* 0x01 */
283 U16 SMID; /* 0x02 */ 291 U16 SMID; /* 0x02 */
284 U16 LMID; /* 0x04 */ 292 U16 LMID; /* 0x04 */
285 U16 Reserved1; /* 0x06 */ 293 U16 Reserved1; /* 0x06 */
@@ -293,7 +301,7 @@ typedef struct _MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR
293typedef struct _MPI2_SCSI_IO_REQUEST_DESCRIPTOR 301typedef struct _MPI2_SCSI_IO_REQUEST_DESCRIPTOR
294{ 302{
295 U8 RequestFlags; /* 0x00 */ 303 U8 RequestFlags; /* 0x00 */
296 U8 VF_ID; /* 0x01 */ 304 U8 MSIxIndex; /* 0x01 */
297 U16 SMID; /* 0x02 */ 305 U16 SMID; /* 0x02 */
298 U16 LMID; /* 0x04 */ 306 U16 LMID; /* 0x04 */
299 U16 DevHandle; /* 0x06 */ 307 U16 DevHandle; /* 0x06 */
@@ -306,7 +314,7 @@ typedef struct _MPI2_SCSI_IO_REQUEST_DESCRIPTOR
306typedef struct _MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR 314typedef struct _MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR
307{ 315{
308 U8 RequestFlags; /* 0x00 */ 316 U8 RequestFlags; /* 0x00 */
309 U8 VF_ID; /* 0x01 */ 317 U8 MSIxIndex; /* 0x01 */
310 U16 SMID; /* 0x02 */ 318 U16 SMID; /* 0x02 */
311 U16 LMID; /* 0x04 */ 319 U16 LMID; /* 0x04 */
312 U16 IoIndex; /* 0x06 */ 320 U16 IoIndex; /* 0x06 */
@@ -315,14 +323,29 @@ typedef struct _MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR
315 Mpi2SCSITargetRequestDescriptor_t, 323 Mpi2SCSITargetRequestDescriptor_t,
316 MPI2_POINTER pMpi2SCSITargetRequestDescriptor_t; 324 MPI2_POINTER pMpi2SCSITargetRequestDescriptor_t;
317 325
326
327/* RAID Accelerator Request Descriptor */
328typedef struct _MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR {
329 U8 RequestFlags; /* 0x00 */
330 U8 MSIxIndex; /* 0x01 */
331 U16 SMID; /* 0x02 */
332 U16 LMID; /* 0x04 */
333 U16 Reserved; /* 0x06 */
334} MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR,
335 MPI2_POINTER PTR_MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR,
336 Mpi2RAIDAcceleratorRequestDescriptor_t,
337 MPI2_POINTER pMpi2RAIDAcceleratorRequestDescriptor_t;
338
339
318/* union of Request Descriptors */ 340/* union of Request Descriptors */
319typedef union _MPI2_REQUEST_DESCRIPTOR_UNION 341typedef union _MPI2_REQUEST_DESCRIPTOR_UNION
320{ 342{
321 MPI2_DEFAULT_REQUEST_DESCRIPTOR Default; 343 MPI2_DEFAULT_REQUEST_DESCRIPTOR Default;
322 MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR HighPriority; 344 MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR HighPriority;
323 MPI2_SCSI_IO_REQUEST_DESCRIPTOR SCSIIO; 345 MPI2_SCSI_IO_REQUEST_DESCRIPTOR SCSIIO;
324 MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR SCSITarget; 346 MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR SCSITarget;
325 U64 Words; 347 MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR RAIDAccelerator;
348 U64 Words;
326} MPI2_REQUEST_DESCRIPTOR_UNION, MPI2_POINTER PTR_MPI2_REQUEST_DESCRIPTOR_UNION, 349} MPI2_REQUEST_DESCRIPTOR_UNION, MPI2_POINTER PTR_MPI2_REQUEST_DESCRIPTOR_UNION,
327 Mpi2RequestDescriptorUnion_t, MPI2_POINTER pMpi2RequestDescriptorUnion_t; 350 Mpi2RequestDescriptorUnion_t, MPI2_POINTER pMpi2RequestDescriptorUnion_t;
328 351
@@ -333,19 +356,20 @@ typedef union _MPI2_REQUEST_DESCRIPTOR_UNION
333typedef struct _MPI2_DEFAULT_REPLY_DESCRIPTOR 356typedef struct _MPI2_DEFAULT_REPLY_DESCRIPTOR
334{ 357{
335 U8 ReplyFlags; /* 0x00 */ 358 U8 ReplyFlags; /* 0x00 */
336 U8 VF_ID; /* 0x01 */ 359 U8 MSIxIndex; /* 0x01 */
337 U16 DescriptorTypeDependent1; /* 0x02 */ 360 U16 DescriptorTypeDependent1; /* 0x02 */
338 U32 DescriptorTypeDependent2; /* 0x04 */ 361 U32 DescriptorTypeDependent2; /* 0x04 */
339} MPI2_DEFAULT_REPLY_DESCRIPTOR, MPI2_POINTER PTR_MPI2_DEFAULT_REPLY_DESCRIPTOR, 362} MPI2_DEFAULT_REPLY_DESCRIPTOR, MPI2_POINTER PTR_MPI2_DEFAULT_REPLY_DESCRIPTOR,
340 Mpi2DefaultReplyDescriptor_t, MPI2_POINTER pMpi2DefaultReplyDescriptor_t; 363 Mpi2DefaultReplyDescriptor_t, MPI2_POINTER pMpi2DefaultReplyDescriptor_t;
341 364
342/* defines for the ReplyFlags field */ 365/* defines for the ReplyFlags field */
343#define MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK (0x0F) 366#define MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK (0x0F)
344#define MPI2_RPY_DESCRIPT_FLAGS_SCSI_IO_SUCCESS (0x00) 367#define MPI2_RPY_DESCRIPT_FLAGS_SCSI_IO_SUCCESS (0x00)
345#define MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY (0x01) 368#define MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY (0x01)
346#define MPI2_RPY_DESCRIPT_FLAGS_TARGETASSIST_SUCCESS (0x02) 369#define MPI2_RPY_DESCRIPT_FLAGS_TARGETASSIST_SUCCESS (0x02)
347#define MPI2_RPY_DESCRIPT_FLAGS_TARGET_COMMAND_BUFFER (0x03) 370#define MPI2_RPY_DESCRIPT_FLAGS_TARGET_COMMAND_BUFFER (0x03)
348#define MPI2_RPY_DESCRIPT_FLAGS_UNUSED (0x0F) 371#define MPI2_RPY_DESCRIPT_FLAGS_RAID_ACCELERATOR_SUCCESS (0x05)
372#define MPI2_RPY_DESCRIPT_FLAGS_UNUSED (0x0F)
349 373
350/* values for marking a reply descriptor as unused */ 374/* values for marking a reply descriptor as unused */
351#define MPI2_RPY_DESCRIPT_UNUSED_WORD0_MARK (0xFFFFFFFF) 375#define MPI2_RPY_DESCRIPT_UNUSED_WORD0_MARK (0xFFFFFFFF)
@@ -355,7 +379,7 @@ typedef struct _MPI2_DEFAULT_REPLY_DESCRIPTOR
355typedef struct _MPI2_ADDRESS_REPLY_DESCRIPTOR 379typedef struct _MPI2_ADDRESS_REPLY_DESCRIPTOR
356{ 380{
357 U8 ReplyFlags; /* 0x00 */ 381 U8 ReplyFlags; /* 0x00 */
358 U8 VF_ID; /* 0x01 */ 382 U8 MSIxIndex; /* 0x01 */
359 U16 SMID; /* 0x02 */ 383 U16 SMID; /* 0x02 */
360 U32 ReplyFrameAddress; /* 0x04 */ 384 U32 ReplyFrameAddress; /* 0x04 */
361} MPI2_ADDRESS_REPLY_DESCRIPTOR, MPI2_POINTER PTR_MPI2_ADDRESS_REPLY_DESCRIPTOR, 385} MPI2_ADDRESS_REPLY_DESCRIPTOR, MPI2_POINTER PTR_MPI2_ADDRESS_REPLY_DESCRIPTOR,
@@ -368,10 +392,10 @@ typedef struct _MPI2_ADDRESS_REPLY_DESCRIPTOR
368typedef struct _MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR 392typedef struct _MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR
369{ 393{
370 U8 ReplyFlags; /* 0x00 */ 394 U8 ReplyFlags; /* 0x00 */
371 U8 VF_ID; /* 0x01 */ 395 U8 MSIxIndex; /* 0x01 */
372 U16 SMID; /* 0x02 */ 396 U16 SMID; /* 0x02 */
373 U16 TaskTag; /* 0x04 */ 397 U16 TaskTag; /* 0x04 */
374 U16 DevHandle; /* 0x06 */ 398 U16 Reserved1; /* 0x06 */
375} MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR, 399} MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR,
376 MPI2_POINTER PTR_MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR, 400 MPI2_POINTER PTR_MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR,
377 Mpi2SCSIIOSuccessReplyDescriptor_t, 401 Mpi2SCSIIOSuccessReplyDescriptor_t,
@@ -382,7 +406,7 @@ typedef struct _MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR
382typedef struct _MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR 406typedef struct _MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR
383{ 407{
384 U8 ReplyFlags; /* 0x00 */ 408 U8 ReplyFlags; /* 0x00 */
385 U8 VF_ID; /* 0x01 */ 409 U8 MSIxIndex; /* 0x01 */
386 U16 SMID; /* 0x02 */ 410 U16 SMID; /* 0x02 */
387 U8 SequenceNumber; /* 0x04 */ 411 U8 SequenceNumber; /* 0x04 */
388 U8 Reserved1; /* 0x05 */ 412 U8 Reserved1; /* 0x05 */
@@ -397,7 +421,7 @@ typedef struct _MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR
397typedef struct _MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR 421typedef struct _MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR
398{ 422{
399 U8 ReplyFlags; /* 0x00 */ 423 U8 ReplyFlags; /* 0x00 */
400 U8 VF_ID; /* 0x01 */ 424 U8 MSIxIndex; /* 0x01 */
401 U8 VP_ID; /* 0x02 */ 425 U8 VP_ID; /* 0x02 */
402 U8 Flags; /* 0x03 */ 426 U8 Flags; /* 0x03 */
403 U16 InitiatorDevHandle; /* 0x04 */ 427 U16 InitiatorDevHandle; /* 0x04 */
@@ -411,15 +435,28 @@ typedef struct _MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR
411#define MPI2_RPY_DESCRIPT_TCB_FLAGS_PHYNUM_MASK (0x3F) 435#define MPI2_RPY_DESCRIPT_TCB_FLAGS_PHYNUM_MASK (0x3F)
412 436
413 437
438/* RAID Accelerator Success Reply Descriptor */
439typedef struct _MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR {
440 U8 ReplyFlags; /* 0x00 */
441 U8 MSIxIndex; /* 0x01 */
442 U16 SMID; /* 0x02 */
443 U32 Reserved; /* 0x04 */
444} MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR,
445 MPI2_POINTER PTR_MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR,
446 Mpi2RAIDAcceleratorSuccessReplyDescriptor_t,
447 MPI2_POINTER pMpi2RAIDAcceleratorSuccessReplyDescriptor_t;
448
449
414/* union of Reply Descriptors */ 450/* union of Reply Descriptors */
415typedef union _MPI2_REPLY_DESCRIPTORS_UNION 451typedef union _MPI2_REPLY_DESCRIPTORS_UNION
416{ 452{
417 MPI2_DEFAULT_REPLY_DESCRIPTOR Default; 453 MPI2_DEFAULT_REPLY_DESCRIPTOR Default;
418 MPI2_ADDRESS_REPLY_DESCRIPTOR AddressReply; 454 MPI2_ADDRESS_REPLY_DESCRIPTOR AddressReply;
419 MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR SCSIIOSuccess; 455 MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR SCSIIOSuccess;
420 MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR TargetAssistSuccess; 456 MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR TargetAssistSuccess;
421 MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR TargetCommandBuffer; 457 MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR TargetCommandBuffer;
422 U64 Words; 458 MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR RAIDAcceleratorSuccess;
459 U64 Words;
423} MPI2_REPLY_DESCRIPTORS_UNION, MPI2_POINTER PTR_MPI2_REPLY_DESCRIPTORS_UNION, 460} MPI2_REPLY_DESCRIPTORS_UNION, MPI2_POINTER PTR_MPI2_REPLY_DESCRIPTORS_UNION,
424 Mpi2ReplyDescriptorsUnion_t, MPI2_POINTER pMpi2ReplyDescriptorsUnion_t; 461 Mpi2ReplyDescriptorsUnion_t, MPI2_POINTER pMpi2ReplyDescriptorsUnion_t;
425 462
@@ -458,6 +495,7 @@ typedef union _MPI2_REPLY_DESCRIPTORS_UNION
458#define MPI2_FUNCTION_DIAG_RELEASE (0x1E) /* Diagnostic Release */ 495#define MPI2_FUNCTION_DIAG_RELEASE (0x1E) /* Diagnostic Release */
459#define MPI2_FUNCTION_TARGET_CMD_BUF_BASE_POST (0x24) /* Target Command Buffer Post Base */ 496#define MPI2_FUNCTION_TARGET_CMD_BUF_BASE_POST (0x24) /* Target Command Buffer Post Base */
460#define MPI2_FUNCTION_TARGET_CMD_BUF_LIST_POST (0x25) /* Target Command Buffer Post List */ 497#define MPI2_FUNCTION_TARGET_CMD_BUF_LIST_POST (0x25) /* Target Command Buffer Post List */
498#define MPI2_FUNCTION_RAID_ACCELERATOR (0x2C) /* RAID Accelerator*/
461 499
462 500
463 501
@@ -555,12 +593,17 @@ typedef union _MPI2_REPLY_DESCRIPTORS_UNION
555 593
556#define MPI2_IOCSTATUS_DIAGNOSTIC_RELEASED (0x00A0) 594#define MPI2_IOCSTATUS_DIAGNOSTIC_RELEASED (0x00A0)
557 595
596/****************************************************************************
597* RAID Accelerator values
598****************************************************************************/
599
600#define MPI2_IOCSTATUS_RAID_ACCEL_ERROR (0x00B0)
558 601
559/**************************************************************************** 602/****************************************************************************
560* IOCStatus flag to indicate that log info is available 603* IOCStatus flag to indicate that log info is available
561****************************************************************************/ 604****************************************************************************/
562 605
563#define MPI2_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE (0x8000) 606#define MPI2_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE (0x8000)
564 607
565/**************************************************************************** 608/****************************************************************************
566* IOCLogInfo Types 609* IOCLogInfo Types
diff --git a/drivers/scsi/mpt2sas/mpi/mpi2_cnfg.h b/drivers/scsi/mpt2sas/mpi/mpi2_cnfg.h
index 2f27cf6d6c65..ab47c4679640 100644
--- a/drivers/scsi/mpt2sas/mpi/mpi2_cnfg.h
+++ b/drivers/scsi/mpt2sas/mpi/mpi2_cnfg.h
@@ -6,7 +6,7 @@
6 * Title: MPI Configuration messages and pages 6 * Title: MPI Configuration messages and pages
7 * Creation Date: November 10, 2006 7 * Creation Date: November 10, 2006
8 * 8 *
9 * mpi2_cnfg.h Version: 02.00.10 9 * mpi2_cnfg.h Version: 02.00.11
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -95,6 +95,11 @@
95 * Added MPI2_SAS_DEVICE0_ASTATUS_DEVICE_BLOCKED define. 95 * Added MPI2_SAS_DEVICE0_ASTATUS_DEVICE_BLOCKED define.
96 * Added PortGroups, DmaGroup, and ControlGroup fields to 96 * Added PortGroups, DmaGroup, and ControlGroup fields to
97 * SAS Device Page 0. 97 * SAS Device Page 0.
98 * 05-06-09 02.00.11 Added structures and defines for IO Unit Page 5 and IO
99 * Unit Page 6.
100 * Added expander reduced functionality data to SAS
101 * Expander Page 0.
102 * Added SAS PHY Page 2 and SAS PHY Page 3.
98 * -------------------------------------------------------------------------- 103 * --------------------------------------------------------------------------
99 */ 104 */
100 105
@@ -723,6 +728,65 @@ typedef struct _MPI2_CONFIG_PAGE_IO_UNIT_3
723#define MPI2_IOUNITPAGE3_GPIO_SETTING_ON (0x0001) 728#define MPI2_IOUNITPAGE3_GPIO_SETTING_ON (0x0001)
724 729
725 730
731/* IO Unit Page 5 */
732
733/*
734 * Upper layer code (drivers, utilities, etc.) should leave this define set to
735 * one and check Header.PageLength or NumDmaEngines at runtime.
736 */
737#ifndef MPI2_IOUNITPAGE5_DMAENGINE_ENTRIES
738#define MPI2_IOUNITPAGE5_DMAENGINE_ENTRIES (1)
739#endif
740
741typedef struct _MPI2_CONFIG_PAGE_IO_UNIT_5 {
742 MPI2_CONFIG_PAGE_HEADER Header; /* 0x00 */
743 U64 RaidAcceleratorBufferBaseAddress; /* 0x04 */
744 U64 RaidAcceleratorBufferSize; /* 0x0C */
745 U64 RaidAcceleratorControlBaseAddress; /* 0x14 */
746 U8 RAControlSize; /* 0x1C */
747 U8 NumDmaEngines; /* 0x1D */
748 U8 RAMinControlSize; /* 0x1E */
749 U8 RAMaxControlSize; /* 0x1F */
750 U32 Reserved1; /* 0x20 */
751 U32 Reserved2; /* 0x24 */
752 U32 Reserved3; /* 0x28 */
753 U32 DmaEngineCapabilities
754 [MPI2_IOUNITPAGE5_DMAENGINE_ENTRIES]; /* 0x2C */
755} MPI2_CONFIG_PAGE_IO_UNIT_5, MPI2_POINTER PTR_MPI2_CONFIG_PAGE_IO_UNIT_5,
756 Mpi2IOUnitPage5_t, MPI2_POINTER pMpi2IOUnitPage5_t;
757
758#define MPI2_IOUNITPAGE5_PAGEVERSION (0x00)
759
760/* defines for IO Unit Page 5 DmaEngineCapabilities field */
761#define MPI2_IOUNITPAGE5_DMA_CAP_MASK_MAX_REQUESTS (0xFF00)
762#define MPI2_IOUNITPAGE5_DMA_CAP_SHIFT_MAX_REQUESTS (16)
763
764#define MPI2_IOUNITPAGE5_DMA_CAP_EEDP (0x0008)
765#define MPI2_IOUNITPAGE5_DMA_CAP_PARITY_GENERATION (0x0004)
766#define MPI2_IOUNITPAGE5_DMA_CAP_HASHING (0x0002)
767#define MPI2_IOUNITPAGE5_DMA_CAP_ENCRYPTION (0x0001)
768
769
770/* IO Unit Page 6 */
771
772typedef struct _MPI2_CONFIG_PAGE_IO_UNIT_6 {
773 MPI2_CONFIG_PAGE_HEADER Header; /* 0x00 */
774 U16 Flags; /* 0x04 */
775 U8 RAHostControlSize; /* 0x06 */
776 U8 Reserved0; /* 0x07 */
777 U64 RaidAcceleratorHostControlBaseAddress; /* 0x08 */
778 U32 Reserved1; /* 0x10 */
779 U32 Reserved2; /* 0x14 */
780 U32 Reserved3; /* 0x18 */
781} MPI2_CONFIG_PAGE_IO_UNIT_6, MPI2_POINTER PTR_MPI2_CONFIG_PAGE_IO_UNIT_6,
782 Mpi2IOUnitPage6_t, MPI2_POINTER pMpi2IOUnitPage6_t;
783
784#define MPI2_IOUNITPAGE6_PAGEVERSION (0x00)
785
786/* defines for IO Unit Page 6 Flags field */
787#define MPI2_IOUNITPAGE6_FLAGS_ENABLE_RAID_ACCELERATOR (0x0001)
788
789
726/**************************************************************************** 790/****************************************************************************
727* IOC Config Pages 791* IOC Config Pages
728****************************************************************************/ 792****************************************************************************/
@@ -1709,10 +1773,14 @@ typedef struct _MPI2_CONFIG_PAGE_EXPANDER_0
1709 U64 ActiveZoneManagerSASAddress;/* 0x2C */ 1773 U64 ActiveZoneManagerSASAddress;/* 0x2C */
1710 U16 ZoneLockInactivityLimit; /* 0x34 */ 1774 U16 ZoneLockInactivityLimit; /* 0x34 */
1711 U16 Reserved1; /* 0x36 */ 1775 U16 Reserved1; /* 0x36 */
1776 U8 TimeToReducedFunc; /* 0x38 */
1777 U8 InitialTimeToReducedFunc; /* 0x39 */
1778 U8 MaxReducedFuncTime; /* 0x3A */
1779 U8 Reserved2; /* 0x3B */
1712} MPI2_CONFIG_PAGE_EXPANDER_0, MPI2_POINTER PTR_MPI2_CONFIG_PAGE_EXPANDER_0, 1780} MPI2_CONFIG_PAGE_EXPANDER_0, MPI2_POINTER PTR_MPI2_CONFIG_PAGE_EXPANDER_0,
1713 Mpi2ExpanderPage0_t, MPI2_POINTER pMpi2ExpanderPage0_t; 1781 Mpi2ExpanderPage0_t, MPI2_POINTER pMpi2ExpanderPage0_t;
1714 1782
1715#define MPI2_SASEXPANDER0_PAGEVERSION (0x05) 1783#define MPI2_SASEXPANDER0_PAGEVERSION (0x06)
1716 1784
1717/* values for SAS Expander Page 0 DiscoveryStatus field */ 1785/* values for SAS Expander Page 0 DiscoveryStatus field */
1718#define MPI2_SAS_EXPANDER0_DS_MAX_ENCLOSURES_EXCEED (0x80000000) 1786#define MPI2_SAS_EXPANDER0_DS_MAX_ENCLOSURES_EXCEED (0x80000000)
@@ -1737,6 +1805,7 @@ typedef struct _MPI2_CONFIG_PAGE_EXPANDER_0
1737#define MPI2_SAS_EXPANDER0_DS_LOOP_DETECTED (0x00000001) 1805#define MPI2_SAS_EXPANDER0_DS_LOOP_DETECTED (0x00000001)
1738 1806
1739/* values for SAS Expander Page 0 Flags field */ 1807/* values for SAS Expander Page 0 Flags field */
1808#define MPI2_SAS_EXPANDER0_FLAGS_REDUCED_FUNCTIONALITY (0x2000)
1740#define MPI2_SAS_EXPANDER0_FLAGS_ZONE_LOCKED (0x1000) 1809#define MPI2_SAS_EXPANDER0_FLAGS_ZONE_LOCKED (0x1000)
1741#define MPI2_SAS_EXPANDER0_FLAGS_SUPPORTED_PHYSICAL_PRES (0x0800) 1810#define MPI2_SAS_EXPANDER0_FLAGS_SUPPORTED_PHYSICAL_PRES (0x0800)
1742#define MPI2_SAS_EXPANDER0_FLAGS_ASSERTED_PHYSICAL_PRES (0x0400) 1811#define MPI2_SAS_EXPANDER0_FLAGS_ASSERTED_PHYSICAL_PRES (0x0400)
@@ -1944,6 +2013,133 @@ typedef struct _MPI2_CONFIG_PAGE_SAS_PHY_1
1944#define MPI2_SASPHY1_PAGEVERSION (0x01) 2013#define MPI2_SASPHY1_PAGEVERSION (0x01)
1945 2014
1946 2015
2016/* SAS PHY Page 2 */
2017
2018typedef struct _MPI2_SASPHY2_PHY_EVENT {
2019 U8 PhyEventCode; /* 0x00 */
2020 U8 Reserved1; /* 0x01 */
2021 U16 Reserved2; /* 0x02 */
2022 U32 PhyEventInfo; /* 0x04 */
2023} MPI2_SASPHY2_PHY_EVENT, MPI2_POINTER PTR_MPI2_SASPHY2_PHY_EVENT,
2024 Mpi2SasPhy2PhyEvent_t, MPI2_POINTER pMpi2SasPhy2PhyEvent_t;
2025
2026/* use MPI2_SASPHY3_EVENT_CODE_ for the PhyEventCode field */
2027
2028
2029/*
2030 * Host code (drivers, BIOS, utilities, etc.) should leave this define set to
2031 * one and check Header.ExtPageLength or NumPhyEvents at runtime.
2032 */
2033#ifndef MPI2_SASPHY2_PHY_EVENT_MAX
2034#define MPI2_SASPHY2_PHY_EVENT_MAX (1)
2035#endif
2036
2037typedef struct _MPI2_CONFIG_PAGE_SAS_PHY_2 {
2038 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /* 0x00 */
2039 U32 Reserved1; /* 0x08 */
2040 U8 NumPhyEvents; /* 0x0C */
2041 U8 Reserved2; /* 0x0D */
2042 U16 Reserved3; /* 0x0E */
2043 MPI2_SASPHY2_PHY_EVENT PhyEvent[MPI2_SASPHY2_PHY_EVENT_MAX];
2044 /* 0x10 */
2045} MPI2_CONFIG_PAGE_SAS_PHY_2, MPI2_POINTER PTR_MPI2_CONFIG_PAGE_SAS_PHY_2,
2046 Mpi2SasPhyPage2_t, MPI2_POINTER pMpi2SasPhyPage2_t;
2047
2048#define MPI2_SASPHY2_PAGEVERSION (0x00)
2049
2050
2051/* SAS PHY Page 3 */
2052
2053typedef struct _MPI2_SASPHY3_PHY_EVENT_CONFIG {
2054 U8 PhyEventCode; /* 0x00 */
2055 U8 Reserved1; /* 0x01 */
2056 U16 Reserved2; /* 0x02 */
2057 U8 CounterType; /* 0x04 */
2058 U8 ThresholdWindow; /* 0x05 */
2059 U8 TimeUnits; /* 0x06 */
2060 U8 Reserved3; /* 0x07 */
2061 U32 EventThreshold; /* 0x08 */
2062 U16 ThresholdFlags; /* 0x0C */
2063 U16 Reserved4; /* 0x0E */
2064} MPI2_SASPHY3_PHY_EVENT_CONFIG, MPI2_POINTER PTR_MPI2_SASPHY3_PHY_EVENT_CONFIG,
2065 Mpi2SasPhy3PhyEventConfig_t, MPI2_POINTER pMpi2SasPhy3PhyEventConfig_t;
2066
2067/* values for PhyEventCode field */
2068#define MPI2_SASPHY3_EVENT_CODE_NO_EVENT (0x00)
2069#define MPI2_SASPHY3_EVENT_CODE_INVALID_DWORD (0x01)
2070#define MPI2_SASPHY3_EVENT_CODE_RUNNING_DISPARITY_ERROR (0x02)
2071#define MPI2_SASPHY3_EVENT_CODE_LOSS_DWORD_SYNC (0x03)
2072#define MPI2_SASPHY3_EVENT_CODE_PHY_RESET_PROBLEM (0x04)
2073#define MPI2_SASPHY3_EVENT_CODE_ELASTICITY_BUF_OVERFLOW (0x05)
2074#define MPI2_SASPHY3_EVENT_CODE_RX_ERROR (0x06)
2075#define MPI2_SASPHY3_EVENT_CODE_RX_ADDR_FRAME_ERROR (0x20)
2076#define MPI2_SASPHY3_EVENT_CODE_TX_AC_OPEN_REJECT (0x21)
2077#define MPI2_SASPHY3_EVENT_CODE_RX_AC_OPEN_REJECT (0x22)
2078#define MPI2_SASPHY3_EVENT_CODE_TX_RC_OPEN_REJECT (0x23)
2079#define MPI2_SASPHY3_EVENT_CODE_RX_RC_OPEN_REJECT (0x24)
2080#define MPI2_SASPHY3_EVENT_CODE_RX_AIP_PARTIAL_WAITING_ON (0x25)
2081#define MPI2_SASPHY3_EVENT_CODE_RX_AIP_CONNECT_WAITING_ON (0x26)
2082#define MPI2_SASPHY3_EVENT_CODE_TX_BREAK (0x27)
2083#define MPI2_SASPHY3_EVENT_CODE_RX_BREAK (0x28)
2084#define MPI2_SASPHY3_EVENT_CODE_BREAK_TIMEOUT (0x29)
2085#define MPI2_SASPHY3_EVENT_CODE_CONNECTION (0x2A)
2086#define MPI2_SASPHY3_EVENT_CODE_PEAKTX_PATHWAY_BLOCKED (0x2B)
2087#define MPI2_SASPHY3_EVENT_CODE_PEAKTX_ARB_WAIT_TIME (0x2C)
2088#define MPI2_SASPHY3_EVENT_CODE_PEAK_ARB_WAIT_TIME (0x2D)
2089#define MPI2_SASPHY3_EVENT_CODE_PEAK_CONNECT_TIME (0x2E)
2090#define MPI2_SASPHY3_EVENT_CODE_TX_SSP_FRAMES (0x40)
2091#define MPI2_SASPHY3_EVENT_CODE_RX_SSP_FRAMES (0x41)
2092#define MPI2_SASPHY3_EVENT_CODE_TX_SSP_ERROR_FRAMES (0x42)
2093#define MPI2_SASPHY3_EVENT_CODE_RX_SSP_ERROR_FRAMES (0x43)
2094#define MPI2_SASPHY3_EVENT_CODE_TX_CREDIT_BLOCKED (0x44)
2095#define MPI2_SASPHY3_EVENT_CODE_RX_CREDIT_BLOCKED (0x45)
2096#define MPI2_SASPHY3_EVENT_CODE_TX_SATA_FRAMES (0x50)
2097#define MPI2_SASPHY3_EVENT_CODE_RX_SATA_FRAMES (0x51)
2098#define MPI2_SASPHY3_EVENT_CODE_SATA_OVERFLOW (0x52)
2099#define MPI2_SASPHY3_EVENT_CODE_TX_SMP_FRAMES (0x60)
2100#define MPI2_SASPHY3_EVENT_CODE_RX_SMP_FRAMES (0x61)
2101#define MPI2_SASPHY3_EVENT_CODE_RX_SMP_ERROR_FRAMES (0x63)
2102#define MPI2_SASPHY3_EVENT_CODE_HOTPLUG_TIMEOUT (0xD0)
2103#define MPI2_SASPHY3_EVENT_CODE_MISALIGNED_MUX_PRIMITIVE (0xD1)
2104#define MPI2_SASPHY3_EVENT_CODE_RX_AIP (0xD2)
2105
2106/* values for the CounterType field */
2107#define MPI2_SASPHY3_COUNTER_TYPE_WRAPPING (0x00)
2108#define MPI2_SASPHY3_COUNTER_TYPE_SATURATING (0x01)
2109#define MPI2_SASPHY3_COUNTER_TYPE_PEAK_VALUE (0x02)
2110
2111/* values for the TimeUnits field */
2112#define MPI2_SASPHY3_TIME_UNITS_10_MICROSECONDS (0x00)
2113#define MPI2_SASPHY3_TIME_UNITS_100_MICROSECONDS (0x01)
2114#define MPI2_SASPHY3_TIME_UNITS_1_MILLISECOND (0x02)
2115#define MPI2_SASPHY3_TIME_UNITS_10_MILLISECONDS (0x03)
2116
2117/* values for the ThresholdFlags field */
2118#define MPI2_SASPHY3_TFLAGS_PHY_RESET (0x0002)
2119#define MPI2_SASPHY3_TFLAGS_EVENT_NOTIFY (0x0001)
2120
2121/*
2122 * Host code (drivers, BIOS, utilities, etc.) should leave this define set to
2123 * one and check Header.ExtPageLength or NumPhyEvents at runtime.
2124 */
2125#ifndef MPI2_SASPHY3_PHY_EVENT_MAX
2126#define MPI2_SASPHY3_PHY_EVENT_MAX (1)
2127#endif
2128
2129typedef struct _MPI2_CONFIG_PAGE_SAS_PHY_3 {
2130 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /* 0x00 */
2131 U32 Reserved1; /* 0x08 */
2132 U8 NumPhyEvents; /* 0x0C */
2133 U8 Reserved2; /* 0x0D */
2134 U16 Reserved3; /* 0x0E */
2135 MPI2_SASPHY3_PHY_EVENT_CONFIG PhyEventConfig
2136 [MPI2_SASPHY3_PHY_EVENT_MAX]; /* 0x10 */
2137} MPI2_CONFIG_PAGE_SAS_PHY_3, MPI2_POINTER PTR_MPI2_CONFIG_PAGE_SAS_PHY_3,
2138 Mpi2SasPhyPage3_t, MPI2_POINTER pMpi2SasPhyPage3_t;
2139
2140#define MPI2_SASPHY3_PAGEVERSION (0x00)
2141
2142
1947/**************************************************************************** 2143/****************************************************************************
1948* SAS Port Config Pages 2144* SAS Port Config Pages
1949****************************************************************************/ 2145****************************************************************************/
diff --git a/drivers/scsi/mpt2sas/mpi/mpi2_history.txt b/drivers/scsi/mpt2sas/mpi/mpi2_history.txt
new file mode 100644
index 000000000000..65fcaa31cb30
--- /dev/null
+++ b/drivers/scsi/mpt2sas/mpi/mpi2_history.txt
@@ -0,0 +1,334 @@
1 ==============================
2 Fusion-MPT MPI 2.0 Header File Change History
3 ==============================
4
5 Copyright (c) 2000-2009 LSI Corporation.
6
7 ---------------------------------------
8 Header Set Release Version: 02.00.12
9 Header Set Release Date: 05-06-09
10 ---------------------------------------
11
12 Filename Current version Prior version
13 ---------- --------------- -------------
14 mpi2.h 02.00.12 02.00.11
15 mpi2_cnfg.h 02.00.11 02.00.10
16 mpi2_init.h 02.00.07 02.00.06
17 mpi2_ioc.h 02.00.11 02.00.10
18 mpi2_raid.h 02.00.03 02.00.03
19 mpi2_sas.h 02.00.02 02.00.02
20 mpi2_targ.h 02.00.03 02.00.03
21 mpi2_tool.h 02.00.03 02.00.02
22 mpi2_type.h 02.00.00 02.00.00
23 mpi2_ra.h 02.00.00
24 mpi2_history.txt 02.00.11 02.00.12
25
26
27 * Date Version Description
28 * -------- -------- ------------------------------------------------------
29
30mpi2.h
31 * 04-30-07 02.00.00 Corresponds to Fusion-MPT MPI Specification Rev A.
32 * 06-04-07 02.00.01 Bumped MPI2_HEADER_VERSION_UNIT.
33 * 06-26-07 02.00.02 Bumped MPI2_HEADER_VERSION_UNIT.
34 * 08-31-07 02.00.03 Bumped MPI2_HEADER_VERSION_UNIT.
35 * Moved ReplyPostHostIndex register to offset 0x6C of the
36 * MPI2_SYSTEM_INTERFACE_REGS and modified the define for
37 * MPI2_REPLY_POST_HOST_INDEX_OFFSET.
38 * Added union of request descriptors.
39 * Added union of reply descriptors.
40 * 10-31-07 02.00.04 Bumped MPI2_HEADER_VERSION_UNIT.
41 * Added define for MPI2_VERSION_02_00.
42 * Fixed the size of the FunctionDependent5 field in the
43 * MPI2_DEFAULT_REPLY structure.
44 * 12-18-07 02.00.05 Bumped MPI2_HEADER_VERSION_UNIT.
45 * Removed the MPI-defined Fault Codes and extended the
46 * product specific codes up to 0xEFFF.
47 * Added a sixth key value for the WriteSequence register
48 * and changed the flush value to 0x0.
49 * Added message function codes for Diagnostic Buffer Post
50 * and Diagnsotic Release.
51 * New IOCStatus define: MPI2_IOCSTATUS_DIAGNOSTIC_RELEASED
52 * Moved MPI2_VERSION_UNION from mpi2_ioc.h.
53 * 02-29-08 02.00.06 Bumped MPI2_HEADER_VERSION_UNIT.
54 * 03-03-08 02.00.07 Bumped MPI2_HEADER_VERSION_UNIT.
55 * 05-21-08 02.00.08 Bumped MPI2_HEADER_VERSION_UNIT.
56 * Added #defines for marking a reply descriptor as unused.
57 * 06-27-08 02.00.09 Bumped MPI2_HEADER_VERSION_UNIT.
58 * 10-02-08 02.00.10 Bumped MPI2_HEADER_VERSION_UNIT.
59 * Moved LUN field defines from mpi2_init.h.
60 * 01-19-09 02.00.11 Bumped MPI2_HEADER_VERSION_UNIT.
61 * 05-06-09 02.00.12 Bumped MPI2_HEADER_VERSION_UNIT.
62 * In all request and reply descriptors, replaced VF_ID
63 * field with MSIxIndex field.
64 * Removed DevHandle field from
65 * MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR and made those
66 * bytes reserved.
67 * Added RAID Accelerator functionality.
68 * --------------------------------------------------------------------------
69
70mpi2_cnfg.h
71 * 04-30-07 02.00.00 Corresponds to Fusion-MPT MPI Specification Rev A.
72 * 06-04-07 02.00.01 Added defines for SAS IO Unit Page 2 PhyFlags.
73 * Added Manufacturing Page 11.
74 * Added MPI2_SAS_EXPANDER0_FLAGS_CONNECTOR_END_DEVICE
75 * define.
76 * 06-26-07 02.00.02 Adding generic structure for product-specific
77 * Manufacturing pages: MPI2_CONFIG_PAGE_MANUFACTURING_PS.
78 * Rework of BIOS Page 2 configuration page.
79 * Fixed MPI2_BIOSPAGE2_BOOT_DEVICE to be a union of the
80 * forms.
81 * Added configuration pages IOC Page 8 and Driver
82 * Persistent Mapping Page 0.
83 * 08-31-07 02.00.03 Modified configuration pages dealing with Integrated
84 * RAID (Manufacturing Page 4, RAID Volume Pages 0 and 1,
85 * RAID Physical Disk Pages 0 and 1, RAID Configuration
86 * Page 0).
87 * Added new value for AccessStatus field of SAS Device
88 * Page 0 (_SATA_NEEDS_INITIALIZATION).
89 * 10-31-07 02.00.04 Added missing SEPDevHandle field to
90 * MPI2_CONFIG_PAGE_SAS_ENCLOSURE_0.
91 * 12-18-07 02.00.05 Modified IO Unit Page 0 to use 32-bit version fields for
92 * NVDATA.
93 * Modified IOC Page 7 to use masks and added field for
94 * SASBroadcastPrimitiveMasks.
95 * Added MPI2_CONFIG_PAGE_BIOS_4.
96 * Added MPI2_CONFIG_PAGE_LOG_0.
97 * 02-29-08 02.00.06 Modified various names to make them 32-character unique.
98 * Added SAS Device IDs.
99 * Updated Integrated RAID configuration pages including
100 * Manufacturing Page 4, IOC Page 6, and RAID Configuration
101 * Page 0.
102 * 05-21-08 02.00.07 Added define MPI2_MANPAGE4_MIX_SSD_SAS_SATA.
103 * Added define MPI2_MANPAGE4_PHYSDISK_128MB_COERCION.
104 * Fixed define MPI2_IOCPAGE8_FLAGS_ENCLOSURE_SLOT_MAPPING.
105 * Added missing MaxNumRoutedSasAddresses field to
106 * MPI2_CONFIG_PAGE_EXPANDER_0.
107 * Added SAS Port Page 0.
108 * Modified structure layout for
109 * MPI2_CONFIG_PAGE_DRIVER_MAPPING_0.
110 * 06-27-08 02.00.08 Changed MPI2_CONFIG_PAGE_RD_PDISK_1 to use
111 * MPI2_RAID_PHYS_DISK1_PATH_MAX to size the array.
112 * 10-02-08 02.00.09 Changed MPI2_RAID_PGAD_CONFIGNUM_MASK from 0x0000FFFF
113 * to 0x000000FF.
114 * Added two new values for the Physical Disk Coercion Size
115 * bits in the Flags field of Manufacturing Page 4.
116 * Added product-specific Manufacturing pages 16 to 31.
117 * Modified Flags bits for controlling write cache on SATA
118 * drives in IO Unit Page 1.
119 * Added new bit to AdditionalControlFlags of SAS IO Unit
120 * Page 1 to control Invalid Topology Correction.
121 * Added SupportedPhysDisks field to RAID Volume Page 1 and
122 * added related defines.
123 * Added additional defines for RAID Volume Page 0
124 * VolumeStatusFlags field.
125 * Modified meaning of RAID Volume Page 0 VolumeSettings
126 * define for auto-configure of hot-swap drives.
127 * Added PhysDiskAttributes field (and related defines) to
128 * RAID Physical Disk Page 0.
129 * Added MPI2_SAS_PHYINFO_PHY_VACANT define.
130 * Added three new DiscoveryStatus bits for SAS IO Unit
131 * Page 0 and SAS Expander Page 0.
132 * Removed multiplexing information from SAS IO Unit pages.
133 * Added BootDeviceWaitTime field to SAS IO Unit Page 4.
134 * Removed Zone Address Resolved bit from PhyInfo and from
135 * Expander Page 0 Flags field.
136 * Added two new AccessStatus values to SAS Device Page 0
137 * for indicating routing problems. Added 3 reserved words
138 * to this page.
139 * 01-19-09 02.00.10 Fixed defines for GPIOVal field of IO Unit Page 3.
140 * Inserted missing reserved field into structure for IOC
141 * Page 6.
142 * Added more pending task bits to RAID Volume Page 0
143 * VolumeStatusFlags defines.
144 * Added MPI2_PHYSDISK0_STATUS_FLAG_NOT_CERTIFIED define.
145 * Added a new DiscoveryStatus bit for SAS IO Unit Page 0
146 * and SAS Expander Page 0 to flag a downstream initiator
147 * when in simplified routing mode.
148 * Removed SATA Init Failure defines for DiscoveryStatus
149 * fields of SAS IO Unit Page 0 and SAS Expander Page 0.
150 * Added MPI2_SAS_DEVICE0_ASTATUS_DEVICE_BLOCKED define.
151 * Added PortGroups, DmaGroup, and ControlGroup fields to
152 * SAS Device Page 0.
153 * 05-06-09 02.00.11 Added structures and defines for IO Unit Page 5 and IO
154 * Unit Page 6.
155 * Added expander reduced functionality data to SAS
156 * Expander Page 0.
157 * Added SAS PHY Page 2 and SAS PHY Page 3.
158 * --------------------------------------------------------------------------
159
160mpi2_init.h
161 * 04-30-07 02.00.00 Corresponds to Fusion-MPT MPI Specification Rev A.
162 * 10-31-07 02.00.01 Fixed name for pMpi2SCSITaskManagementRequest_t.
163 * 12-18-07 02.00.02 Modified Task Management Target Reset Method defines.
164 * 02-29-08 02.00.03 Added Query Task Set and Query Unit Attention.
165 * 03-03-08 02.00.04 Fixed name of struct _MPI2_SCSI_TASK_MANAGE_REPLY.
166 * 05-21-08 02.00.05 Fixed typo in name of Mpi2SepRequest_t.
167 * 10-02-08 02.00.06 Removed Untagged and No Disconnect values from SCSI IO
168 * Control field Task Attribute flags.
169 * Moved LUN field defines to mpi2.h becasue they are
170 * common to many structures.
171 * 05-06-09 02.00.07 Changed task management type of Query Unit Attention to
172 * Query Asynchronous Event.
173 * Defined two new bits in the SlotStatus field of the SCSI
174 * Enclosure Processor Request and Reply.
175 * --------------------------------------------------------------------------
176
177mpi2_ioc.h
178 * 04-30-07 02.00.00 Corresponds to Fusion-MPT MPI Specification Rev A.
179 * 06-04-07 02.00.01 In IOCFacts Reply structure, renamed MaxDevices to
180 * MaxTargets.
181 * Added TotalImageSize field to FWDownload Request.
182 * Added reserved words to FWUpload Request.
183 * 06-26-07 02.00.02 Added IR Configuration Change List Event.
184 * 08-31-07 02.00.03 Removed SystemReplyQueueDepth field from the IOCInit
185 * request and replaced it with
186 * ReplyDescriptorPostQueueDepth and ReplyFreeQueueDepth.
187 * Replaced the MinReplyQueueDepth field of the IOCFacts
188 * reply with MaxReplyDescriptorPostQueueDepth.
189 * Added MPI2_RDPQ_DEPTH_MIN define to specify the minimum
190 * depth for the Reply Descriptor Post Queue.
191 * Added SASAddress field to Initiator Device Table
192 * Overflow Event data.
193 * 10-31-07 02.00.04 Added ReasonCode MPI2_EVENT_SAS_INIT_RC_NOT_RESPONDING
194 * for SAS Initiator Device Status Change Event data.
195 * Modified Reason Code defines for SAS Topology Change
196 * List Event data, including adding a bit for PHY Vacant
197 * status, and adding a mask for the Reason Code.
198 * Added define for
199 * MPI2_EVENT_SAS_TOPO_ES_DELAY_NOT_RESPONDING.
200 * Added define for MPI2_EXT_IMAGE_TYPE_MEGARAID.
201 * 12-18-07 02.00.05 Added Boot Status defines for the IOCExceptions field of
202 * the IOCFacts Reply.
203 * Removed MPI2_IOCFACTS_CAPABILITY_EXTENDED_BUFFER define.
204 * Moved MPI2_VERSION_UNION to mpi2.h.
205 * Changed MPI2_EVENT_NOTIFICATION_REQUEST to use masks
206 * instead of enables, and added SASBroadcastPrimitiveMasks
207 * field.
208 * Added Log Entry Added Event and related structure.
209 * 02-29-08 02.00.06 Added define MPI2_IOCFACTS_CAPABILITY_INTEGRATED_RAID.
210 * Removed define MPI2_IOCFACTS_PROTOCOL_SMP_TARGET.
211 * Added MaxVolumes and MaxPersistentEntries fields to
212 * IOCFacts reply.
213 * Added ProtocalFlags and IOCCapabilities fields to
214 * MPI2_FW_IMAGE_HEADER.
215 * Removed MPI2_PORTENABLE_FLAGS_ENABLE_SINGLE_PORT.
216 * 03-03-08 02.00.07 Fixed MPI2_FW_IMAGE_HEADER by changing Reserved26 to
217 * a U16 (from a U32).
218 * Removed extra 's' from EventMasks name.
219 * 06-27-08 02.00.08 Fixed an offset in a comment.
220 * 10-02-08 02.00.09 Removed SystemReplyFrameSize from MPI2_IOC_INIT_REQUEST.
221 * Removed CurReplyFrameSize from MPI2_IOC_FACTS_REPLY and
222 * renamed MinReplyFrameSize to ReplyFrameSize.
223 * Added MPI2_IOCFACTS_EXCEPT_IR_FOREIGN_CONFIG_MAX.
224 * Added two new RAIDOperation values for Integrated RAID
225 * Operations Status Event data.
226 * Added four new IR Configuration Change List Event data
227 * ReasonCode values.
228 * Added two new ReasonCode defines for SAS Device Status
229 * Change Event data.
230 * Added three new DiscoveryStatus bits for the SAS
231 * Discovery event data.
232 * Added Multiplexing Status Change bit to the PhyStatus
233 * field of the SAS Topology Change List event data.
234 * Removed define for MPI2_INIT_IMAGE_BOOTFLAGS_XMEMCOPY.
235 * BootFlags are now product-specific.
236 * Added defines for the indivdual signature bytes
237 * for MPI2_INIT_IMAGE_FOOTER.
238 * 01-19-09 02.00.10 Added MPI2_IOCFACTS_CAPABILITY_EVENT_REPLAY define.
239 * Added MPI2_EVENT_SAS_DISC_DS_DOWNSTREAM_INITIATOR
240 * define.
241 * Added MPI2_EVENT_SAS_DEV_STAT_RC_SATA_INIT_FAILURE
242 * define.
243 * Removed MPI2_EVENT_SAS_DISC_DS_SATA_INIT_FAILURE define.
244 * 05-06-09 02.00.11 Added MPI2_IOCFACTS_CAPABILITY_RAID_ACCELERATOR define.
245 * Added MPI2_IOCFACTS_CAPABILITY_MSI_X_INDEX define.
246 * Added two new reason codes for SAS Device Status Change
247 * Event.
248 * Added new event: SAS PHY Counter.
249 * --------------------------------------------------------------------------
250
251mpi2_raid.h
252 * 04-30-07 02.00.00 Corresponds to Fusion-MPT MPI Specification Rev A.
253 * 08-31-07 02.00.01 Modifications to RAID Action request and reply,
254 * including the Actions and ActionData.
255 * 02-29-08 02.00.02 Added MPI2_RAID_ACTION_ADATA_DISABL_FULL_REBUILD.
256 * 05-21-08 02.00.03 Added MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS so that
257 * the PhysDisk array in MPI2_RAID_VOLUME_CREATION_STRUCT
258 * can be sized by the build environment.
259 * --------------------------------------------------------------------------
260
261mpi2_sas.h
262 * 04-30-07 02.00.00 Corresponds to Fusion-MPT MPI Specification Rev A.
263 * 06-26-07 02.00.01 Added Clear All Persistent Operation to SAS IO Unit
264 * Control Request.
265 * 10-02-08 02.00.02 Added Set IOC Parameter Operation to SAS IO Unit Control
266 * Request.
267 * --------------------------------------------------------------------------
268
269mpi2_targ.h
270 * 04-30-07 02.00.00 Corresponds to Fusion-MPT MPI Specification Rev A.
271 * 08-31-07 02.00.01 Added Command Buffer Data Location Address Space bits to
272 * BufferPostFlags field of CommandBufferPostBase Request.
273 * 02-29-08 02.00.02 Modified various names to make them 32-character unique.
274 * 10-02-08 02.00.03 Removed NextCmdBufferOffset from
275 * MPI2_TARGET_CMD_BUF_POST_BASE_REQUEST.
276 * Target Status Send Request only takes a single SGE for
277 * response data.
278 * --------------------------------------------------------------------------
279
280mpi2_tool.h
281 * 04-30-07 02.00.00 Corresponds to Fusion-MPT MPI Specification Rev A.
282 * 12-18-07 02.00.01 Added Diagnostic Buffer Post and Diagnostic Release
283 * structures and defines.
284 * 02-29-08 02.00.02 Modified various names to make them 32-character unique.
285 * 05-06-09 02.00.03 Added ISTWI Read Write Tool and Diagnostic CLI Tool.
286 * --------------------------------------------------------------------------
287
288mpi2_type.h
289 * 04-30-07 02.00.00 Corresponds to Fusion-MPT MPI Specification Rev A.
290 * --------------------------------------------------------------------------
291
292mpi2_ra.h
293 * 05-06-09 02.00.00 Initial version.
294 * --------------------------------------------------------------------------
295
296mpi2_history.txt Parts list history
297
298Filename 02.00.12
299---------- --------
300mpi2.h 02.00.12
301mpi2_cnfg.h 02.00.11
302mpi2_init.h 02.00.07
303mpi2_ioc.h 02.00.11
304mpi2_raid.h 02.00.03
305mpi2_sas.h 02.00.02
306mpi2_targ.h 02.00.03
307mpi2_tool.h 02.00.03
308mpi2_type.h 02.00.00
309mpi2_ra.h 02.00.00
310
311Filename 02.00.11 02.00.10 02.00.09 02.00.08 02.00.07 02.00.06
312---------- -------- -------- -------- -------- -------- --------
313mpi2.h 02.00.11 02.00.10 02.00.09 02.00.08 02.00.07 02.00.06
314mpi2_cnfg.h 02.00.10 02.00.09 02.00.08 02.00.07 02.00.06 02.00.06
315mpi2_init.h 02.00.06 02.00.06 02.00.05 02.00.05 02.00.04 02.00.03
316mpi2_ioc.h 02.00.10 02.00.09 02.00.08 02.00.07 02.00.07 02.00.06
317mpi2_raid.h 02.00.03 02.00.03 02.00.03 02.00.03 02.00.02 02.00.02
318mpi2_sas.h 02.00.02 02.00.02 02.00.01 02.00.01 02.00.01 02.00.01
319mpi2_targ.h 02.00.03 02.00.03 02.00.02 02.00.02 02.00.02 02.00.02
320mpi2_tool.h 02.00.02 02.00.02 02.00.02 02.00.02 02.00.02 02.00.02
321mpi2_type.h 02.00.00 02.00.00 02.00.00 02.00.00 02.00.00 02.00.00
322
323Filename 02.00.05 02.00.04 02.00.03 02.00.02 02.00.01 02.00.00
324---------- -------- -------- -------- -------- -------- --------
325mpi2.h 02.00.05 02.00.04 02.00.03 02.00.02 02.00.01 02.00.00
326mpi2_cnfg.h 02.00.05 02.00.04 02.00.03 02.00.02 02.00.01 02.00.00
327mpi2_init.h 02.00.02 02.00.01 02.00.00 02.00.00 02.00.00 02.00.00
328mpi2_ioc.h 02.00.05 02.00.04 02.00.03 02.00.02 02.00.01 02.00.00
329mpi2_raid.h 02.00.01 02.00.01 02.00.01 02.00.00 02.00.00 02.00.00
330mpi2_sas.h 02.00.01 02.00.01 02.00.01 02.00.01 02.00.00 02.00.00
331mpi2_targ.h 02.00.01 02.00.01 02.00.01 02.00.00 02.00.00 02.00.00
332mpi2_tool.h 02.00.01 02.00.00 02.00.00 02.00.00 02.00.00 02.00.00
333mpi2_type.h 02.00.00 02.00.00 02.00.00 02.00.00 02.00.00 02.00.00
334
diff --git a/drivers/scsi/mpt2sas/mpi/mpi2_init.h b/drivers/scsi/mpt2sas/mpi/mpi2_init.h
index f1115f0f0eb2..563e56d2e945 100644
--- a/drivers/scsi/mpt2sas/mpi/mpi2_init.h
+++ b/drivers/scsi/mpt2sas/mpi/mpi2_init.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2000-2008 LSI Corporation. 2 * Copyright (c) 2000-2009 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi2_init.h 5 * Name: mpi2_init.h
6 * Title: MPI SCSI initiator mode messages and structures 6 * Title: MPI SCSI initiator mode messages and structures
7 * Creation Date: June 23, 2006 7 * Creation Date: June 23, 2006
8 * 8 *
9 * mpi2_init.h Version: 02.00.06 9 * mpi2_init.h Version: 02.00.07
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -23,6 +23,10 @@
23 * Control field Task Attribute flags. 23 * Control field Task Attribute flags.
24 * Moved LUN field defines to mpi2.h becasue they are 24 * Moved LUN field defines to mpi2.h becasue they are
25 * common to many structures. 25 * common to many structures.
26 * 05-06-09 02.00.07 Changed task management type of Query Unit Attention to
27 * Query Asynchronous Event.
28 * Defined two new bits in the SlotStatus field of the SCSI
29 * Enclosure Processor Request and Reply.
26 * -------------------------------------------------------------------------- 30 * --------------------------------------------------------------------------
27 */ 31 */
28 32
@@ -289,7 +293,11 @@ typedef struct _MPI2_SCSI_TASK_MANAGE_REQUEST
289#define MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07) 293#define MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07)
290#define MPI2_SCSITASKMGMT_TASKTYPE_CLR_ACA (0x08) 294#define MPI2_SCSITASKMGMT_TASKTYPE_CLR_ACA (0x08)
291#define MPI2_SCSITASKMGMT_TASKTYPE_QRY_TASK_SET (0x09) 295#define MPI2_SCSITASKMGMT_TASKTYPE_QRY_TASK_SET (0x09)
292#define MPI2_SCSITASKMGMT_TASKTYPE_QRY_UNIT_ATTENTION (0x0A) 296#define MPI2_SCSITASKMGMT_TASKTYPE_QRY_ASYNC_EVENT (0x0A)
297
298/* obsolete TaskType name */
299#define MPI2_SCSITASKMGMT_TASKTYPE_QRY_UNIT_ATTENTION \
300 (MPI2_SCSITASKMGMT_TASKTYPE_QRY_ASYNC_EVENT)
293 301
294/* MsgFlags bits */ 302/* MsgFlags bits */
295 303
@@ -375,6 +383,8 @@ typedef struct _MPI2_SEP_REQUEST
375#define MPI2_SEP_REQ_SLOTSTATUS_HOT_SPARE (0x00000100) 383#define MPI2_SEP_REQ_SLOTSTATUS_HOT_SPARE (0x00000100)
376#define MPI2_SEP_REQ_SLOTSTATUS_UNCONFIGURED (0x00000080) 384#define MPI2_SEP_REQ_SLOTSTATUS_UNCONFIGURED (0x00000080)
377#define MPI2_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT (0x00000040) 385#define MPI2_SEP_REQ_SLOTSTATUS_PREDICTED_FAULT (0x00000040)
386#define MPI2_SEP_REQ_SLOTSTATUS_IN_CRITICAL_ARRAY (0x00000010)
387#define MPI2_SEP_REQ_SLOTSTATUS_IN_FAILED_ARRAY (0x00000008)
378#define MPI2_SEP_REQ_SLOTSTATUS_DEV_REBUILDING (0x00000004) 388#define MPI2_SEP_REQ_SLOTSTATUS_DEV_REBUILDING (0x00000004)
379#define MPI2_SEP_REQ_SLOTSTATUS_DEV_FAULTY (0x00000002) 389#define MPI2_SEP_REQ_SLOTSTATUS_DEV_FAULTY (0x00000002)
380#define MPI2_SEP_REQ_SLOTSTATUS_NO_ERROR (0x00000001) 390#define MPI2_SEP_REQ_SLOTSTATUS_NO_ERROR (0x00000001)
@@ -410,6 +420,8 @@ typedef struct _MPI2_SEP_REPLY
410#define MPI2_SEP_REPLY_SLOTSTATUS_HOT_SPARE (0x00000100) 420#define MPI2_SEP_REPLY_SLOTSTATUS_HOT_SPARE (0x00000100)
411#define MPI2_SEP_REPLY_SLOTSTATUS_UNCONFIGURED (0x00000080) 421#define MPI2_SEP_REPLY_SLOTSTATUS_UNCONFIGURED (0x00000080)
412#define MPI2_SEP_REPLY_SLOTSTATUS_PREDICTED_FAULT (0x00000040) 422#define MPI2_SEP_REPLY_SLOTSTATUS_PREDICTED_FAULT (0x00000040)
423#define MPI2_SEP_REPLY_SLOTSTATUS_IN_CRITICAL_ARRAY (0x00000010)
424#define MPI2_SEP_REPLY_SLOTSTATUS_IN_FAILED_ARRAY (0x00000008)
413#define MPI2_SEP_REPLY_SLOTSTATUS_DEV_REBUILDING (0x00000004) 425#define MPI2_SEP_REPLY_SLOTSTATUS_DEV_REBUILDING (0x00000004)
414#define MPI2_SEP_REPLY_SLOTSTATUS_DEV_FAULTY (0x00000002) 426#define MPI2_SEP_REPLY_SLOTSTATUS_DEV_FAULTY (0x00000002)
415#define MPI2_SEP_REPLY_SLOTSTATUS_NO_ERROR (0x00000001) 427#define MPI2_SEP_REPLY_SLOTSTATUS_NO_ERROR (0x00000001)
diff --git a/drivers/scsi/mpt2sas/mpi/mpi2_ioc.h b/drivers/scsi/mpt2sas/mpi/mpi2_ioc.h
index 8c5d81870c03..c294128bdeb4 100644
--- a/drivers/scsi/mpt2sas/mpi/mpi2_ioc.h
+++ b/drivers/scsi/mpt2sas/mpi/mpi2_ioc.h
@@ -6,7 +6,7 @@
6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages 6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages
7 * Creation Date: October 11, 2006 7 * Creation Date: October 11, 2006
8 * 8 *
9 * mpi2_ioc.h Version: 02.00.10 9 * mpi2_ioc.h Version: 02.00.11
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -79,6 +79,11 @@
79 * Added MPI2_EVENT_SAS_DEV_STAT_RC_SATA_INIT_FAILURE 79 * Added MPI2_EVENT_SAS_DEV_STAT_RC_SATA_INIT_FAILURE
80 * define. 80 * define.
81 * Removed MPI2_EVENT_SAS_DISC_DS_SATA_INIT_FAILURE define. 81 * Removed MPI2_EVENT_SAS_DISC_DS_SATA_INIT_FAILURE define.
82 * 05-06-09 02.00.11 Added MPI2_IOCFACTS_CAPABILITY_RAID_ACCELERATOR define.
83 * Added MPI2_IOCFACTS_CAPABILITY_MSI_X_INDEX define.
84 * Added two new reason codes for SAS Device Status Change
85 * Event.
86 * Added new event: SAS PHY Counter.
82 * -------------------------------------------------------------------------- 87 * --------------------------------------------------------------------------
83 */ 88 */
84 89
@@ -261,6 +266,8 @@ typedef struct _MPI2_IOC_FACTS_REPLY
261/* ProductID field uses MPI2_FW_HEADER_PID_ */ 266/* ProductID field uses MPI2_FW_HEADER_PID_ */
262 267
263/* IOCCapabilities */ 268/* IOCCapabilities */
269#define MPI2_IOCFACTS_CAPABILITY_MSI_X_INDEX (0x00008000)
270#define MPI2_IOCFACTS_CAPABILITY_RAID_ACCELERATOR (0x00004000)
264#define MPI2_IOCFACTS_CAPABILITY_EVENT_REPLAY (0x00002000) 271#define MPI2_IOCFACTS_CAPABILITY_EVENT_REPLAY (0x00002000)
265#define MPI2_IOCFACTS_CAPABILITY_INTEGRATED_RAID (0x00001000) 272#define MPI2_IOCFACTS_CAPABILITY_INTEGRATED_RAID (0x00001000)
266#define MPI2_IOCFACTS_CAPABILITY_TLR (0x00000800) 273#define MPI2_IOCFACTS_CAPABILITY_TLR (0x00000800)
@@ -440,6 +447,7 @@ typedef struct _MPI2_EVENT_NOTIFICATION_REPLY
440#define MPI2_EVENT_IR_PHYSICAL_DISK (0x001F) 447#define MPI2_EVENT_IR_PHYSICAL_DISK (0x001F)
441#define MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST (0x0020) 448#define MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST (0x0020)
442#define MPI2_EVENT_LOG_ENTRY_ADDED (0x0021) 449#define MPI2_EVENT_LOG_ENTRY_ADDED (0x0021)
450#define MPI2_EVENT_SAS_PHY_COUNTER (0x0022)
443 451
444 452
445/* Log Entry Added Event data */ 453/* Log Entry Added Event data */
@@ -502,17 +510,19 @@ typedef struct _MPI2_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE
502 MPI2_POINTER pMpi2EventDataSasDeviceStatusChange_t; 510 MPI2_POINTER pMpi2EventDataSasDeviceStatusChange_t;
503 511
504/* SAS Device Status Change Event data ReasonCode values */ 512/* SAS Device Status Change Event data ReasonCode values */
505#define MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA (0x05) 513#define MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA (0x05)
506#define MPI2_EVENT_SAS_DEV_STAT_RC_UNSUPPORTED (0x07) 514#define MPI2_EVENT_SAS_DEV_STAT_RC_UNSUPPORTED (0x07)
507#define MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET (0x08) 515#define MPI2_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET (0x08)
508#define MPI2_EVENT_SAS_DEV_STAT_RC_TASK_ABORT_INTERNAL (0x09) 516#define MPI2_EVENT_SAS_DEV_STAT_RC_TASK_ABORT_INTERNAL (0x09)
509#define MPI2_EVENT_SAS_DEV_STAT_RC_ABORT_TASK_SET_INTERNAL (0x0A) 517#define MPI2_EVENT_SAS_DEV_STAT_RC_ABORT_TASK_SET_INTERNAL (0x0A)
510#define MPI2_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL (0x0B) 518#define MPI2_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL (0x0B)
511#define MPI2_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL (0x0C) 519#define MPI2_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL (0x0C)
512#define MPI2_EVENT_SAS_DEV_STAT_RC_ASYNC_NOTIFICATION (0x0D) 520#define MPI2_EVENT_SAS_DEV_STAT_RC_ASYNC_NOTIFICATION (0x0D)
513#define MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET (0x0E) 521#define MPI2_EVENT_SAS_DEV_STAT_RC_CMP_INTERNAL_DEV_RESET (0x0E)
514#define MPI2_EVENT_SAS_DEV_STAT_RC_CMP_TASK_ABORT_INTERNAL (0x0F) 522#define MPI2_EVENT_SAS_DEV_STAT_RC_CMP_TASK_ABORT_INTERNAL (0x0F)
515#define MPI2_EVENT_SAS_DEV_STAT_RC_SATA_INIT_FAILURE (0x10) 523#define MPI2_EVENT_SAS_DEV_STAT_RC_SATA_INIT_FAILURE (0x10)
524#define MPI2_EVENT_SAS_DEV_STAT_RC_EXPANDER_REDUCED_FUNCTIONALITY (0x11)
525#define MPI2_EVENT_SAS_DEV_STAT_RC_CMP_EXPANDER_REDUCED_FUNCTIONALITY (0x12)
516 526
517 527
518/* Integrated RAID Operation Status Event data */ 528/* Integrated RAID Operation Status Event data */
@@ -822,6 +832,37 @@ typedef struct _MPI2_EVENT_DATA_SAS_ENCL_DEV_STATUS_CHANGE
822#define MPI2_EVENT_SAS_ENCL_RC_NOT_RESPONDING (0x02) 832#define MPI2_EVENT_SAS_ENCL_RC_NOT_RESPONDING (0x02)
823 833
824 834
835/* SAS PHY Counter Event data */
836
837typedef struct _MPI2_EVENT_DATA_SAS_PHY_COUNTER {
838 U64 TimeStamp; /* 0x00 */
839 U32 Reserved1; /* 0x08 */
840 U8 PhyEventCode; /* 0x0C */
841 U8 PhyNum; /* 0x0D */
842 U16 Reserved2; /* 0x0E */
843 U32 PhyEventInfo; /* 0x10 */
844 U8 CounterType; /* 0x14 */
845 U8 ThresholdWindow; /* 0x15 */
846 U8 TimeUnits; /* 0x16 */
847 U8 Reserved3; /* 0x17 */
848 U32 EventThreshold; /* 0x18 */
849 U16 ThresholdFlags; /* 0x1C */
850 U16 Reserved4; /* 0x1E */
851} MPI2_EVENT_DATA_SAS_PHY_COUNTER,
852 MPI2_POINTER PTR_MPI2_EVENT_DATA_SAS_PHY_COUNTER,
853 Mpi2EventDataSasPhyCounter_t, MPI2_POINTER pMpi2EventDataSasPhyCounter_t;
854
855/* use MPI2_SASPHY3_EVENT_CODE_ values from mpi2_cnfg.h for the
856 * PhyEventCode field
857 * use MPI2_SASPHY3_COUNTER_TYPE_ values from mpi2_cnfg.h for the
858 * CounterType field
859 * use MPI2_SASPHY3_TIME_UNITS_ values from mpi2_cnfg.h for the
860 * TimeUnits field
861 * use MPI2_SASPHY3_TFLAGS_ values from mpi2_cnfg.h for the
862 * ThresholdFlags field
863 * */
864
865
825/**************************************************************************** 866/****************************************************************************
826* EventAck message 867* EventAck message
827****************************************************************************/ 868****************************************************************************/
diff --git a/drivers/scsi/mpt2sas/mpi/mpi2_tool.h b/drivers/scsi/mpt2sas/mpi/mpi2_tool.h
index 2ff4e936bd39..007e950f7bfa 100644
--- a/drivers/scsi/mpt2sas/mpi/mpi2_tool.h
+++ b/drivers/scsi/mpt2sas/mpi/mpi2_tool.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2000-2008 LSI Corporation. 2 * Copyright (c) 2000-2009 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi2_tool.h 5 * Name: mpi2_tool.h
6 * Title: MPI diagnostic tool structures and definitions 6 * Title: MPI diagnostic tool structures and definitions
7 * Creation Date: March 26, 2007 7 * Creation Date: March 26, 2007
8 * 8 *
9 * mpi2_tool.h Version: 02.00.02 9 * mpi2_tool.h Version: 02.00.03
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -17,6 +17,7 @@
17 * 12-18-07 02.00.01 Added Diagnostic Buffer Post and Diagnostic Release 17 * 12-18-07 02.00.01 Added Diagnostic Buffer Post and Diagnostic Release
18 * structures and defines. 18 * structures and defines.
19 * 02-29-08 02.00.02 Modified various names to make them 32-character unique. 19 * 02-29-08 02.00.02 Modified various names to make them 32-character unique.
20 * 05-06-09 02.00.03 Added ISTWI Read Write Tool and Diagnostic CLI Tool.
20 * -------------------------------------------------------------------------- 21 * --------------------------------------------------------------------------
21 */ 22 */
22 23
@@ -32,7 +33,10 @@
32/* defines for the Tools */ 33/* defines for the Tools */
33#define MPI2_TOOLBOX_CLEAN_TOOL (0x00) 34#define MPI2_TOOLBOX_CLEAN_TOOL (0x00)
34#define MPI2_TOOLBOX_MEMORY_MOVE_TOOL (0x01) 35#define MPI2_TOOLBOX_MEMORY_MOVE_TOOL (0x01)
36#define MPI2_TOOLBOX_ISTWI_READ_WRITE_TOOL (0x03)
35#define MPI2_TOOLBOX_BEACON_TOOL (0x05) 37#define MPI2_TOOLBOX_BEACON_TOOL (0x05)
38#define MPI2_TOOLBOX_DIAGNOSTIC_CLI_TOOL (0x06)
39
36 40
37/**************************************************************************** 41/****************************************************************************
38* Toolbox reply 42* Toolbox reply
@@ -112,6 +116,77 @@ typedef struct _MPI2_TOOLBOX_MEM_MOVE_REQUEST
112 116
113 117
114/**************************************************************************** 118/****************************************************************************
119* Toolbox ISTWI Read Write Tool
120****************************************************************************/
121
122/* Toolbox ISTWI Read Write Tool request message */
123typedef struct _MPI2_TOOLBOX_ISTWI_READ_WRITE_REQUEST {
124 U8 Tool; /* 0x00 */
125 U8 Reserved1; /* 0x01 */
126 U8 ChainOffset; /* 0x02 */
127 U8 Function; /* 0x03 */
128 U16 Reserved2; /* 0x04 */
129 U8 Reserved3; /* 0x06 */
130 U8 MsgFlags; /* 0x07 */
131 U8 VP_ID; /* 0x08 */
132 U8 VF_ID; /* 0x09 */
133 U16 Reserved4; /* 0x0A */
134 U32 Reserved5; /* 0x0C */
135 U32 Reserved6; /* 0x10 */
136 U8 DevIndex; /* 0x14 */
137 U8 Action; /* 0x15 */
138 U8 SGLFlags; /* 0x16 */
139 U8 Reserved7; /* 0x17 */
140 U16 TxDataLength; /* 0x18 */
141 U16 RxDataLength; /* 0x1A */
142 U32 Reserved8; /* 0x1C */
143 U32 Reserved9; /* 0x20 */
144 U32 Reserved10; /* 0x24 */
145 U32 Reserved11; /* 0x28 */
146 U32 Reserved12; /* 0x2C */
147 MPI2_SGE_SIMPLE_UNION SGL; /* 0x30 */
148} MPI2_TOOLBOX_ISTWI_READ_WRITE_REQUEST,
149 MPI2_POINTER PTR_MPI2_TOOLBOX_ISTWI_READ_WRITE_REQUEST,
150 Mpi2ToolboxIstwiReadWriteRequest_t,
151 MPI2_POINTER pMpi2ToolboxIstwiReadWriteRequest_t;
152
153/* values for the Action field */
154#define MPI2_TOOL_ISTWI_ACTION_READ_DATA (0x01)
155#define MPI2_TOOL_ISTWI_ACTION_WRITE_DATA (0x02)
156#define MPI2_TOOL_ISTWI_ACTION_SEQUENCE (0x03)
157#define MPI2_TOOL_ISTWI_ACTION_RESERVE_BUS (0x10)
158#define MPI2_TOOL_ISTWI_ACTION_RELEASE_BUS (0x11)
159#define MPI2_TOOL_ISTWI_ACTION_RESET (0x12)
160
161/* values for SGLFlags field are in the SGL section of mpi2.h */
162
163
164/* Toolbox ISTWI Read Write Tool reply message */
165typedef struct _MPI2_TOOLBOX_ISTWI_REPLY {
166 U8 Tool; /* 0x00 */
167 U8 Reserved1; /* 0x01 */
168 U8 MsgLength; /* 0x02 */
169 U8 Function; /* 0x03 */
170 U16 Reserved2; /* 0x04 */
171 U8 Reserved3; /* 0x06 */
172 U8 MsgFlags; /* 0x07 */
173 U8 VP_ID; /* 0x08 */
174 U8 VF_ID; /* 0x09 */
175 U16 Reserved4; /* 0x0A */
176 U16 Reserved5; /* 0x0C */
177 U16 IOCStatus; /* 0x0E */
178 U32 IOCLogInfo; /* 0x10 */
179 U8 DevIndex; /* 0x14 */
180 U8 Action; /* 0x15 */
181 U8 IstwiStatus; /* 0x16 */
182 U8 Reserved6; /* 0x17 */
183 U16 TxDataCount; /* 0x18 */
184 U16 RxDataCount; /* 0x1A */
185} MPI2_TOOLBOX_ISTWI_REPLY, MPI2_POINTER PTR_MPI2_TOOLBOX_ISTWI_REPLY,
186 Mpi2ToolboxIstwiReply_t, MPI2_POINTER pMpi2ToolboxIstwiReply_t;
187
188
189/****************************************************************************
115* Toolbox Beacon Tool request 190* Toolbox Beacon Tool request
116****************************************************************************/ 191****************************************************************************/
117 192
@@ -139,6 +214,61 @@ typedef struct _MPI2_TOOLBOX_BEACON_REQUEST
139#define MPI2_TOOLBOX_FLAGS_BEACONMODE_ON (0x01) 214#define MPI2_TOOLBOX_FLAGS_BEACONMODE_ON (0x01)
140 215
141 216
217/****************************************************************************
218* Toolbox Diagnostic CLI Tool
219****************************************************************************/
220
221#define MPI2_TOOLBOX_DIAG_CLI_CMD_LENGTH (0x5C)
222
223/* Toolbox Diagnostic CLI Tool request message */
224typedef struct _MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST {
225 U8 Tool; /* 0x00 */
226 U8 Reserved1; /* 0x01 */
227 U8 ChainOffset; /* 0x02 */
228 U8 Function; /* 0x03 */
229 U16 Reserved2; /* 0x04 */
230 U8 Reserved3; /* 0x06 */
231 U8 MsgFlags; /* 0x07 */
232 U8 VP_ID; /* 0x08 */
233 U8 VF_ID; /* 0x09 */
234 U16 Reserved4; /* 0x0A */
235 U8 SGLFlags; /* 0x0C */
236 U8 Reserved5; /* 0x0D */
237 U16 Reserved6; /* 0x0E */
238 U32 DataLength; /* 0x10 */
239 U8 DiagnosticCliCommand
240 [MPI2_TOOLBOX_DIAG_CLI_CMD_LENGTH]; /* 0x14 */
241 MPI2_SGE_SIMPLE_UNION SGL; /* 0x70 */
242} MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST,
243 MPI2_POINTER PTR_MPI2_TOOLBOX_DIAGNOSTIC_CLI_REQUEST,
244 Mpi2ToolboxDiagnosticCliRequest_t,
245 MPI2_POINTER pMpi2ToolboxDiagnosticCliRequest_t;
246
247/* values for SGLFlags field are in the SGL section of mpi2.h */
248
249
250/* Toolbox Diagnostic CLI Tool reply message */
251typedef struct _MPI2_TOOLBOX_DIAGNOSTIC_CLI_REPLY {
252 U8 Tool; /* 0x00 */
253 U8 Reserved1; /* 0x01 */
254 U8 MsgLength; /* 0x02 */
255 U8 Function; /* 0x03 */
256 U16 Reserved2; /* 0x04 */
257 U8 Reserved3; /* 0x06 */
258 U8 MsgFlags; /* 0x07 */
259 U8 VP_ID; /* 0x08 */
260 U8 VF_ID; /* 0x09 */
261 U16 Reserved4; /* 0x0A */
262 U16 Reserved5; /* 0x0C */
263 U16 IOCStatus; /* 0x0E */
264 U32 IOCLogInfo; /* 0x10 */
265 U32 ReturnedDataLength; /* 0x14 */
266} MPI2_TOOLBOX_DIAGNOSTIC_CLI_REPLY,
267 MPI2_POINTER PTR_MPI2_TOOLBOX_DIAG_CLI_REPLY,
268 Mpi2ToolboxDiagnosticCliReply_t,
269 MPI2_POINTER pMpi2ToolboxDiagnosticCliReply_t;
270
271
142/***************************************************************************** 272/*****************************************************************************
143* 273*
144* Diagnostic Buffer Messages 274* Diagnostic Buffer Messages
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index d95d2f274cb3..670241efa4b5 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -3,7 +3,7 @@
3 * for access to MPT (Message Passing Technology) firmware. 3 * for access to MPT (Message Passing Technology) firmware.
4 * 4 *
5 * This code is based on drivers/scsi/mpt2sas/mpt2_base.c 5 * This code is based on drivers/scsi/mpt2sas/mpt2_base.c
6 * Copyright (C) 2007-2008 LSI Corporation 6 * Copyright (C) 2007-2009 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com) 7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
@@ -63,7 +63,7 @@
63static MPT_CALLBACK mpt_callbacks[MPT_MAX_CALLBACKS]; 63static MPT_CALLBACK mpt_callbacks[MPT_MAX_CALLBACKS];
64 64
65#define FAULT_POLLING_INTERVAL 1000 /* in milliseconds */ 65#define FAULT_POLLING_INTERVAL 1000 /* in milliseconds */
66#define MPT2SAS_MAX_REQUEST_QUEUE 500 /* maximum controller queue depth */ 66#define MPT2SAS_MAX_REQUEST_QUEUE 600 /* maximum controller queue depth */
67 67
68static int max_queue_depth = -1; 68static int max_queue_depth = -1;
69module_param(max_queue_depth, int, 0); 69module_param(max_queue_depth, int, 0);
@@ -543,13 +543,13 @@ mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code)
543 * _base_display_reply_info - 543 * _base_display_reply_info -
544 * @ioc: pointer to scsi command object 544 * @ioc: pointer to scsi command object
545 * @smid: system request message index 545 * @smid: system request message index
546 * @VF_ID: virtual function id 546 * @msix_index: MSIX table index supplied by the OS
547 * @reply: reply message frame(lower 32bit addr) 547 * @reply: reply message frame(lower 32bit addr)
548 * 548 *
549 * Return nothing. 549 * Return nothing.
550 */ 550 */
551static void 551static void
552_base_display_reply_info(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, 552_base_display_reply_info(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
553 u32 reply) 553 u32 reply)
554{ 554{
555 MPI2DefaultReply_t *mpi_reply; 555 MPI2DefaultReply_t *mpi_reply;
@@ -572,22 +572,24 @@ _base_display_reply_info(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID,
572 * mpt2sas_base_done - base internal command completion routine 572 * mpt2sas_base_done - base internal command completion routine
573 * @ioc: pointer to scsi command object 573 * @ioc: pointer to scsi command object
574 * @smid: system request message index 574 * @smid: system request message index
575 * @VF_ID: virtual function id 575 * @msix_index: MSIX table index supplied by the OS
576 * @reply: reply message frame(lower 32bit addr) 576 * @reply: reply message frame(lower 32bit addr)
577 * 577 *
578 * Return nothing. 578 * Return 1 meaning mf should be freed from _base_interrupt
579 * 0 means the mf is freed from this function.
579 */ 580 */
580void 581u8
581mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) 582mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
583 u32 reply)
582{ 584{
583 MPI2DefaultReply_t *mpi_reply; 585 MPI2DefaultReply_t *mpi_reply;
584 586
585 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); 587 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
586 if (mpi_reply && mpi_reply->Function == MPI2_FUNCTION_EVENT_ACK) 588 if (mpi_reply && mpi_reply->Function == MPI2_FUNCTION_EVENT_ACK)
587 return; 589 return 1;
588 590
589 if (ioc->base_cmds.status == MPT2_CMD_NOT_USED) 591 if (ioc->base_cmds.status == MPT2_CMD_NOT_USED)
590 return; 592 return 1;
591 593
592 ioc->base_cmds.status |= MPT2_CMD_COMPLETE; 594 ioc->base_cmds.status |= MPT2_CMD_COMPLETE;
593 if (mpi_reply) { 595 if (mpi_reply) {
@@ -596,18 +598,20 @@ mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
596 } 598 }
597 ioc->base_cmds.status &= ~MPT2_CMD_PENDING; 599 ioc->base_cmds.status &= ~MPT2_CMD_PENDING;
598 complete(&ioc->base_cmds.done); 600 complete(&ioc->base_cmds.done);
601 return 1;
599} 602}
600 603
601/** 604/**
602 * _base_async_event - main callback handler for firmware asyn events 605 * _base_async_event - main callback handler for firmware asyn events
603 * @ioc: pointer to scsi command object 606 * @ioc: pointer to scsi command object
604 * @VF_ID: virtual function id 607 * @msix_index: MSIX table index supplied by the OS
605 * @reply: reply message frame(lower 32bit addr) 608 * @reply: reply message frame(lower 32bit addr)
606 * 609 *
607 * Return nothing. 610 * Return 1 meaning mf should be freed from _base_interrupt
611 * 0 means the mf is freed from this function.
608 */ 612 */
609static void 613static u8
610_base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply) 614_base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, u32 reply)
611{ 615{
612 Mpi2EventNotificationReply_t *mpi_reply; 616 Mpi2EventNotificationReply_t *mpi_reply;
613 Mpi2EventAckRequest_t *ack_request; 617 Mpi2EventAckRequest_t *ack_request;
@@ -615,9 +619,9 @@ _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply)
615 619
616 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); 620 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
617 if (!mpi_reply) 621 if (!mpi_reply)
618 return; 622 return 1;
619 if (mpi_reply->Function != MPI2_FUNCTION_EVENT_NOTIFICATION) 623 if (mpi_reply->Function != MPI2_FUNCTION_EVENT_NOTIFICATION)
620 return; 624 return 1;
621#ifdef CONFIG_SCSI_MPT2SAS_LOGGING 625#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
622 _base_display_event_data(ioc, mpi_reply); 626 _base_display_event_data(ioc, mpi_reply);
623#endif 627#endif
@@ -635,16 +639,47 @@ _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply)
635 ack_request->Function = MPI2_FUNCTION_EVENT_ACK; 639 ack_request->Function = MPI2_FUNCTION_EVENT_ACK;
636 ack_request->Event = mpi_reply->Event; 640 ack_request->Event = mpi_reply->Event;
637 ack_request->EventContext = mpi_reply->EventContext; 641 ack_request->EventContext = mpi_reply->EventContext;
638 ack_request->VF_ID = VF_ID; 642 ack_request->VF_ID = 0; /* TODO */
639 mpt2sas_base_put_smid_default(ioc, smid, VF_ID); 643 ack_request->VP_ID = 0;
644 mpt2sas_base_put_smid_default(ioc, smid);
640 645
641 out: 646 out:
642 647
643 /* scsih callback handler */ 648 /* scsih callback handler */
644 mpt2sas_scsih_event_callback(ioc, VF_ID, reply); 649 mpt2sas_scsih_event_callback(ioc, msix_index, reply);
645 650
646 /* ctl callback handler */ 651 /* ctl callback handler */
647 mpt2sas_ctl_event_callback(ioc, VF_ID, reply); 652 mpt2sas_ctl_event_callback(ioc, msix_index, reply);
653
654 return 1;
655}
656
657/**
658 * _base_get_cb_idx - obtain the callback index
659 * @ioc: per adapter object
660 * @smid: system request message index
661 *
662 * Return callback index.
663 */
664static u8
665_base_get_cb_idx(struct MPT2SAS_ADAPTER *ioc, u16 smid)
666{
667 int i;
668 u8 cb_idx = 0xFF;
669
670 if (smid >= ioc->hi_priority_smid) {
671 if (smid < ioc->internal_smid) {
672 i = smid - ioc->hi_priority_smid;
673 cb_idx = ioc->hpr_lookup[i].cb_idx;
674 } else {
675 i = smid - ioc->internal_smid;
676 cb_idx = ioc->internal_lookup[i].cb_idx;
677 }
678 } else {
679 i = smid - 1;
680 cb_idx = ioc->scsi_lookup[i].cb_idx;
681 }
682 return cb_idx;
648} 683}
649 684
650/** 685/**
@@ -680,7 +715,6 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc)
680{ 715{
681 u32 him_register; 716 u32 him_register;
682 717
683 writel(0, &ioc->chip->HostInterruptStatus);
684 him_register = readl(&ioc->chip->HostInterruptMask); 718 him_register = readl(&ioc->chip->HostInterruptMask);
685 him_register &= ~MPI2_HIM_RIM; 719 him_register &= ~MPI2_HIM_RIM;
686 writel(him_register, &ioc->chip->HostInterruptMask); 720 writel(him_register, &ioc->chip->HostInterruptMask);
@@ -712,9 +746,10 @@ _base_interrupt(int irq, void *bus_id)
712 u16 smid; 746 u16 smid;
713 u8 cb_idx; 747 u8 cb_idx;
714 u32 reply; 748 u32 reply;
715 u8 VF_ID; 749 u8 msix_index;
716 struct MPT2SAS_ADAPTER *ioc = bus_id; 750 struct MPT2SAS_ADAPTER *ioc = bus_id;
717 Mpi2ReplyDescriptorsUnion_t *rpf; 751 Mpi2ReplyDescriptorsUnion_t *rpf;
752 u8 rc;
718 753
719 if (ioc->mask_interrupts) 754 if (ioc->mask_interrupts)
720 return IRQ_NONE; 755 return IRQ_NONE;
@@ -733,7 +768,7 @@ _base_interrupt(int irq, void *bus_id)
733 reply = 0; 768 reply = 0;
734 cb_idx = 0xFF; 769 cb_idx = 0xFF;
735 smid = le16_to_cpu(rpf->Default.DescriptorTypeDependent1); 770 smid = le16_to_cpu(rpf->Default.DescriptorTypeDependent1);
736 VF_ID = rpf->Default.VF_ID; 771 msix_index = rpf->Default.MSIxIndex;
737 if (request_desript_type == 772 if (request_desript_type ==
738 MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) { 773 MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) {
739 reply = le32_to_cpu 774 reply = le32_to_cpu
@@ -745,16 +780,18 @@ _base_interrupt(int irq, void *bus_id)
745 MPI2_RPY_DESCRIPT_FLAGS_TARGETASSIST_SUCCESS) 780 MPI2_RPY_DESCRIPT_FLAGS_TARGETASSIST_SUCCESS)
746 goto next; 781 goto next;
747 if (smid) 782 if (smid)
748 cb_idx = ioc->scsi_lookup[smid - 1].cb_idx; 783 cb_idx = _base_get_cb_idx(ioc, smid);
749 if (smid && cb_idx != 0xFF) { 784 if (smid && cb_idx != 0xFF) {
750 mpt_callbacks[cb_idx](ioc, smid, VF_ID, reply); 785 rc = mpt_callbacks[cb_idx](ioc, smid, msix_index,
786 reply);
751 if (reply) 787 if (reply)
752 _base_display_reply_info(ioc, smid, VF_ID, 788 _base_display_reply_info(ioc, smid, msix_index,
753 reply); 789 reply);
754 mpt2sas_base_free_smid(ioc, smid); 790 if (rc)
791 mpt2sas_base_free_smid(ioc, smid);
755 } 792 }
756 if (!smid) 793 if (!smid)
757 _base_async_event(ioc, VF_ID, reply); 794 _base_async_event(ioc, msix_index, reply);
758 795
759 /* reply free queue handling */ 796 /* reply free queue handling */
760 if (reply) { 797 if (reply) {
@@ -1191,19 +1228,6 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc)
1191} 1228}
1192 1229
1193/** 1230/**
1194 * mpt2sas_base_get_msg_frame_dma - obtain request mf pointer phys addr
1195 * @ioc: per adapter object
1196 * @smid: system request message index(smid zero is invalid)
1197 *
1198 * Returns phys pointer to message frame.
1199 */
1200dma_addr_t
1201mpt2sas_base_get_msg_frame_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid)
1202{
1203 return ioc->request_dma + (smid * ioc->request_sz);
1204}
1205
1206/**
1207 * mpt2sas_base_get_msg_frame - obtain request mf pointer 1231 * mpt2sas_base_get_msg_frame - obtain request mf pointer
1208 * @ioc: per adapter object 1232 * @ioc: per adapter object
1209 * @smid: system request message index(smid zero is invalid) 1233 * @smid: system request message index(smid zero is invalid)
@@ -1258,7 +1282,7 @@ mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr)
1258} 1282}
1259 1283
1260/** 1284/**
1261 * mpt2sas_base_get_smid - obtain a free smid 1285 * mpt2sas_base_get_smid - obtain a free smid from internal queue
1262 * @ioc: per adapter object 1286 * @ioc: per adapter object
1263 * @cb_idx: callback index 1287 * @cb_idx: callback index
1264 * 1288 *
@@ -1272,6 +1296,39 @@ mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx)
1272 u16 smid; 1296 u16 smid;
1273 1297
1274 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 1298 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
1299 if (list_empty(&ioc->internal_free_list)) {
1300 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1301 printk(MPT2SAS_ERR_FMT "%s: smid not available\n",
1302 ioc->name, __func__);
1303 return 0;
1304 }
1305
1306 request = list_entry(ioc->internal_free_list.next,
1307 struct request_tracker, tracker_list);
1308 request->cb_idx = cb_idx;
1309 smid = request->smid;
1310 list_del(&request->tracker_list);
1311 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1312 return smid;
1313}
1314
1315/**
1316 * mpt2sas_base_get_smid_scsiio - obtain a free smid from scsiio queue
1317 * @ioc: per adapter object
1318 * @cb_idx: callback index
1319 * @scmd: pointer to scsi command object
1320 *
1321 * Returns smid (zero is invalid)
1322 */
1323u16
1324mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx,
1325 struct scsi_cmnd *scmd)
1326{
1327 unsigned long flags;
1328 struct request_tracker *request;
1329 u16 smid;
1330
1331 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
1275 if (list_empty(&ioc->free_list)) { 1332 if (list_empty(&ioc->free_list)) {
1276 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); 1333 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1277 printk(MPT2SAS_ERR_FMT "%s: smid not available\n", 1334 printk(MPT2SAS_ERR_FMT "%s: smid not available\n",
@@ -1281,6 +1338,36 @@ mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx)
1281 1338
1282 request = list_entry(ioc->free_list.next, 1339 request = list_entry(ioc->free_list.next,
1283 struct request_tracker, tracker_list); 1340 struct request_tracker, tracker_list);
1341 request->scmd = scmd;
1342 request->cb_idx = cb_idx;
1343 smid = request->smid;
1344 list_del(&request->tracker_list);
1345 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1346 return smid;
1347}
1348
1349/**
1350 * mpt2sas_base_get_smid_hpr - obtain a free smid from hi-priority queue
1351 * @ioc: per adapter object
1352 * @cb_idx: callback index
1353 *
1354 * Returns smid (zero is invalid)
1355 */
1356u16
1357mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx)
1358{
1359 unsigned long flags;
1360 struct request_tracker *request;
1361 u16 smid;
1362
1363 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
1364 if (list_empty(&ioc->hpr_free_list)) {
1365 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1366 return 0;
1367 }
1368
1369 request = list_entry(ioc->hpr_free_list.next,
1370 struct request_tracker, tracker_list);
1284 request->cb_idx = cb_idx; 1371 request->cb_idx = cb_idx;
1285 smid = request->smid; 1372 smid = request->smid;
1286 list_del(&request->tracker_list); 1373 list_del(&request->tracker_list);
@@ -1300,10 +1387,32 @@ void
1300mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid) 1387mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid)
1301{ 1388{
1302 unsigned long flags; 1389 unsigned long flags;
1390 int i;
1303 1391
1304 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 1392 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
1305 ioc->scsi_lookup[smid - 1].cb_idx = 0xFF; 1393 if (smid >= ioc->hi_priority_smid) {
1306 list_add_tail(&ioc->scsi_lookup[smid - 1].tracker_list, 1394 if (smid < ioc->internal_smid) {
1395 /* hi-priority */
1396 i = smid - ioc->hi_priority_smid;
1397 ioc->hpr_lookup[i].cb_idx = 0xFF;
1398 list_add_tail(&ioc->hpr_lookup[i].tracker_list,
1399 &ioc->hpr_free_list);
1400 } else {
1401 /* internal queue */
1402 i = smid - ioc->internal_smid;
1403 ioc->internal_lookup[i].cb_idx = 0xFF;
1404 list_add_tail(&ioc->internal_lookup[i].tracker_list,
1405 &ioc->internal_free_list);
1406 }
1407 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1408 return;
1409 }
1410
1411 /* scsiio queue */
1412 i = smid - 1;
1413 ioc->scsi_lookup[i].cb_idx = 0xFF;
1414 ioc->scsi_lookup[i].scmd = NULL;
1415 list_add_tail(&ioc->scsi_lookup[i].tracker_list,
1307 &ioc->free_list); 1416 &ioc->free_list);
1308 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); 1417 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1309 1418
@@ -1352,21 +1461,19 @@ static inline void _base_writeq(__u64 b, volatile void __iomem *addr,
1352 * mpt2sas_base_put_smid_scsi_io - send SCSI_IO request to firmware 1461 * mpt2sas_base_put_smid_scsi_io - send SCSI_IO request to firmware
1353 * @ioc: per adapter object 1462 * @ioc: per adapter object
1354 * @smid: system request message index 1463 * @smid: system request message index
1355 * @vf_id: virtual function id
1356 * @handle: device handle 1464 * @handle: device handle
1357 * 1465 *
1358 * Return nothing. 1466 * Return nothing.
1359 */ 1467 */
1360void 1468void
1361mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id, 1469mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u16 handle)
1362 u16 handle)
1363{ 1470{
1364 Mpi2RequestDescriptorUnion_t descriptor; 1471 Mpi2RequestDescriptorUnion_t descriptor;
1365 u64 *request = (u64 *)&descriptor; 1472 u64 *request = (u64 *)&descriptor;
1366 1473
1367 1474
1368 descriptor.SCSIIO.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO; 1475 descriptor.SCSIIO.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO;
1369 descriptor.SCSIIO.VF_ID = vf_id; 1476 descriptor.SCSIIO.MSIxIndex = 0; /* TODO */
1370 descriptor.SCSIIO.SMID = cpu_to_le16(smid); 1477 descriptor.SCSIIO.SMID = cpu_to_le16(smid);
1371 descriptor.SCSIIO.DevHandle = cpu_to_le16(handle); 1478 descriptor.SCSIIO.DevHandle = cpu_to_le16(handle);
1372 descriptor.SCSIIO.LMID = 0; 1479 descriptor.SCSIIO.LMID = 0;
@@ -1379,20 +1486,18 @@ mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id,
1379 * mpt2sas_base_put_smid_hi_priority - send Task Managment request to firmware 1486 * mpt2sas_base_put_smid_hi_priority - send Task Managment request to firmware
1380 * @ioc: per adapter object 1487 * @ioc: per adapter object
1381 * @smid: system request message index 1488 * @smid: system request message index
1382 * @vf_id: virtual function id
1383 * 1489 *
1384 * Return nothing. 1490 * Return nothing.
1385 */ 1491 */
1386void 1492void
1387mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid, 1493mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid)
1388 u8 vf_id)
1389{ 1494{
1390 Mpi2RequestDescriptorUnion_t descriptor; 1495 Mpi2RequestDescriptorUnion_t descriptor;
1391 u64 *request = (u64 *)&descriptor; 1496 u64 *request = (u64 *)&descriptor;
1392 1497
1393 descriptor.HighPriority.RequestFlags = 1498 descriptor.HighPriority.RequestFlags =
1394 MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; 1499 MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
1395 descriptor.HighPriority.VF_ID = vf_id; 1500 descriptor.HighPriority.MSIxIndex = 0; /* TODO */
1396 descriptor.HighPriority.SMID = cpu_to_le16(smid); 1501 descriptor.HighPriority.SMID = cpu_to_le16(smid);
1397 descriptor.HighPriority.LMID = 0; 1502 descriptor.HighPriority.LMID = 0;
1398 descriptor.HighPriority.Reserved1 = 0; 1503 descriptor.HighPriority.Reserved1 = 0;
@@ -1404,18 +1509,17 @@ mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid,
1404 * mpt2sas_base_put_smid_default - Default, primarily used for config pages 1509 * mpt2sas_base_put_smid_default - Default, primarily used for config pages
1405 * @ioc: per adapter object 1510 * @ioc: per adapter object
1406 * @smid: system request message index 1511 * @smid: system request message index
1407 * @vf_id: virtual function id
1408 * 1512 *
1409 * Return nothing. 1513 * Return nothing.
1410 */ 1514 */
1411void 1515void
1412mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id) 1516mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid)
1413{ 1517{
1414 Mpi2RequestDescriptorUnion_t descriptor; 1518 Mpi2RequestDescriptorUnion_t descriptor;
1415 u64 *request = (u64 *)&descriptor; 1519 u64 *request = (u64 *)&descriptor;
1416 1520
1417 descriptor.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; 1521 descriptor.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
1418 descriptor.Default.VF_ID = vf_id; 1522 descriptor.Default.MSIxIndex = 0; /* TODO */
1419 descriptor.Default.SMID = cpu_to_le16(smid); 1523 descriptor.Default.SMID = cpu_to_le16(smid);
1420 descriptor.Default.LMID = 0; 1524 descriptor.Default.LMID = 0;
1421 descriptor.Default.DescriptorTypeDependent = 0; 1525 descriptor.Default.DescriptorTypeDependent = 0;
@@ -1427,21 +1531,20 @@ mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id)
1427 * mpt2sas_base_put_smid_target_assist - send Target Assist/Status to firmware 1531 * mpt2sas_base_put_smid_target_assist - send Target Assist/Status to firmware
1428 * @ioc: per adapter object 1532 * @ioc: per adapter object
1429 * @smid: system request message index 1533 * @smid: system request message index
1430 * @vf_id: virtual function id
1431 * @io_index: value used to track the IO 1534 * @io_index: value used to track the IO
1432 * 1535 *
1433 * Return nothing. 1536 * Return nothing.
1434 */ 1537 */
1435void 1538void
1436mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid, 1539mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid,
1437 u8 vf_id, u16 io_index) 1540 u16 io_index)
1438{ 1541{
1439 Mpi2RequestDescriptorUnion_t descriptor; 1542 Mpi2RequestDescriptorUnion_t descriptor;
1440 u64 *request = (u64 *)&descriptor; 1543 u64 *request = (u64 *)&descriptor;
1441 1544
1442 descriptor.SCSITarget.RequestFlags = 1545 descriptor.SCSITarget.RequestFlags =
1443 MPI2_REQ_DESCRIPT_FLAGS_SCSI_TARGET; 1546 MPI2_REQ_DESCRIPT_FLAGS_SCSI_TARGET;
1444 descriptor.SCSITarget.VF_ID = vf_id; 1547 descriptor.SCSITarget.MSIxIndex = 0; /* TODO */
1445 descriptor.SCSITarget.SMID = cpu_to_le16(smid); 1548 descriptor.SCSITarget.SMID = cpu_to_le16(smid);
1446 descriptor.SCSITarget.LMID = 0; 1549 descriptor.SCSITarget.LMID = 0;
1447 descriptor.SCSITarget.IoIndex = cpu_to_le16(io_index); 1550 descriptor.SCSITarget.IoIndex = cpu_to_le16(io_index);
@@ -1717,6 +1820,8 @@ _base_release_memory_pools(struct MPT2SAS_ADAPTER *ioc)
1717 } 1820 }
1718 1821
1719 kfree(ioc->scsi_lookup); 1822 kfree(ioc->scsi_lookup);
1823 kfree(ioc->hpr_lookup);
1824 kfree(ioc->internal_lookup);
1720} 1825}
1721 1826
1722 1827
@@ -1736,7 +1841,6 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1736 u16 num_of_reply_frames; 1841 u16 num_of_reply_frames;
1737 u16 chains_needed_per_io; 1842 u16 chains_needed_per_io;
1738 u32 sz, total_sz; 1843 u32 sz, total_sz;
1739 u16 i;
1740 u32 retry_sz; 1844 u32 retry_sz;
1741 u16 max_request_credit; 1845 u16 max_request_credit;
1742 1846
@@ -1764,7 +1868,10 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1764 MPT2SAS_MAX_REQUEST_QUEUE) ? MPT2SAS_MAX_REQUEST_QUEUE : 1868 MPT2SAS_MAX_REQUEST_QUEUE) ? MPT2SAS_MAX_REQUEST_QUEUE :
1765 facts->RequestCredit; 1869 facts->RequestCredit;
1766 } 1870 }
1767 ioc->request_depth = max_request_credit; 1871
1872 ioc->hba_queue_depth = max_request_credit;
1873 ioc->hi_priority_depth = facts->HighPriorityCredit;
1874 ioc->internal_depth = ioc->hi_priority_depth + 5;
1768 1875
1769 /* request frame size */ 1876 /* request frame size */
1770 ioc->request_sz = facts->IOCRequestFrameSize * 4; 1877 ioc->request_sz = facts->IOCRequestFrameSize * 4;
@@ -1802,7 +1909,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1802 ioc->chains_needed_per_io = chains_needed_per_io; 1909 ioc->chains_needed_per_io = chains_needed_per_io;
1803 1910
1804 /* reply free queue sizing - taking into account for events */ 1911 /* reply free queue sizing - taking into account for events */
1805 num_of_reply_frames = ioc->request_depth + 32; 1912 num_of_reply_frames = ioc->hba_queue_depth + 32;
1806 1913
1807 /* number of replies frames can't be a multiple of 16 */ 1914 /* number of replies frames can't be a multiple of 16 */
1808 /* decrease number of reply frames by 1 */ 1915 /* decrease number of reply frames by 1 */
@@ -1823,7 +1930,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1823 * frames 1930 * frames
1824 */ 1931 */
1825 1932
1826 queue_size = ioc->request_depth + num_of_reply_frames + 1; 1933 queue_size = ioc->hba_queue_depth + num_of_reply_frames + 1;
1827 /* round up to 16 byte boundary */ 1934 /* round up to 16 byte boundary */
1828 if (queue_size % 16) 1935 if (queue_size % 16)
1829 queue_size += 16 - (queue_size % 16); 1936 queue_size += 16 - (queue_size % 16);
@@ -1837,60 +1944,85 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1837 if (queue_diff % 16) 1944 if (queue_diff % 16)
1838 queue_diff += 16 - (queue_diff % 16); 1945 queue_diff += 16 - (queue_diff % 16);
1839 1946
1840 /* adjust request_depth, reply_free_queue_depth, 1947 /* adjust hba_queue_depth, reply_free_queue_depth,
1841 * and queue_size 1948 * and queue_size
1842 */ 1949 */
1843 ioc->request_depth -= queue_diff; 1950 ioc->hba_queue_depth -= queue_diff;
1844 ioc->reply_free_queue_depth -= queue_diff; 1951 ioc->reply_free_queue_depth -= queue_diff;
1845 queue_size -= queue_diff; 1952 queue_size -= queue_diff;
1846 } 1953 }
1847 ioc->reply_post_queue_depth = queue_size; 1954 ioc->reply_post_queue_depth = queue_size;
1848 1955
1849 /* max scsi host queue depth */
1850 ioc->shost->can_queue = ioc->request_depth - INTERNAL_CMDS_COUNT;
1851 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host queue: depth"
1852 "(%d)\n", ioc->name, ioc->shost->can_queue));
1853
1854 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scatter gather: " 1956 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scatter gather: "
1855 "sge_in_main_msg(%d), sge_per_chain(%d), sge_per_io(%d), " 1957 "sge_in_main_msg(%d), sge_per_chain(%d), sge_per_io(%d), "
1856 "chains_per_io(%d)\n", ioc->name, ioc->max_sges_in_main_message, 1958 "chains_per_io(%d)\n", ioc->name, ioc->max_sges_in_main_message,
1857 ioc->max_sges_in_chain_message, ioc->shost->sg_tablesize, 1959 ioc->max_sges_in_chain_message, ioc->shost->sg_tablesize,
1858 ioc->chains_needed_per_io)); 1960 ioc->chains_needed_per_io));
1859 1961
1962 ioc->scsiio_depth = ioc->hba_queue_depth -
1963 ioc->hi_priority_depth - ioc->internal_depth;
1964
1965 /* set the scsi host can_queue depth
1966 * with some internal commands that could be outstanding
1967 */
1968 ioc->shost->can_queue = ioc->scsiio_depth - (2);
1969 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host: "
1970 "can_queue depth (%d)\n", ioc->name, ioc->shost->can_queue));
1971
1860 /* contiguous pool for request and chains, 16 byte align, one extra " 1972 /* contiguous pool for request and chains, 16 byte align, one extra "
1861 * "frame for smid=0 1973 * "frame for smid=0
1862 */ 1974 */
1863 ioc->chain_depth = ioc->chains_needed_per_io * ioc->request_depth; 1975 ioc->chain_depth = ioc->chains_needed_per_io * ioc->scsiio_depth;
1864 sz = ((ioc->request_depth + 1 + ioc->chain_depth) * ioc->request_sz); 1976 sz = ((ioc->scsiio_depth + 1 + ioc->chain_depth) * ioc->request_sz);
1977
1978 /* hi-priority queue */
1979 sz += (ioc->hi_priority_depth * ioc->request_sz);
1980
1981 /* internal queue */
1982 sz += (ioc->internal_depth * ioc->request_sz);
1865 1983
1866 ioc->request_dma_sz = sz; 1984 ioc->request_dma_sz = sz;
1867 ioc->request = pci_alloc_consistent(ioc->pdev, sz, &ioc->request_dma); 1985 ioc->request = pci_alloc_consistent(ioc->pdev, sz, &ioc->request_dma);
1868 if (!ioc->request) { 1986 if (!ioc->request) {
1869 printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent " 1987 printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent "
1870 "failed: req_depth(%d), chains_per_io(%d), frame_sz(%d), " 1988 "failed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), "
1871 "total(%d kB)\n", ioc->name, ioc->request_depth, 1989 "total(%d kB)\n", ioc->name, ioc->hba_queue_depth,
1872 ioc->chains_needed_per_io, ioc->request_sz, sz/1024); 1990 ioc->chains_needed_per_io, ioc->request_sz, sz/1024);
1873 if (ioc->request_depth < MPT2SAS_SAS_QUEUE_DEPTH) 1991 if (ioc->scsiio_depth < MPT2SAS_SAS_QUEUE_DEPTH)
1874 goto out; 1992 goto out;
1875 retry_sz += 64; 1993 retry_sz += 64;
1876 ioc->request_depth = max_request_credit - retry_sz; 1994 ioc->hba_queue_depth = max_request_credit - retry_sz;
1877 goto retry_allocation; 1995 goto retry_allocation;
1878 } 1996 }
1879 1997
1880 if (retry_sz) 1998 if (retry_sz)
1881 printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent " 1999 printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent "
1882 "succeed: req_depth(%d), chains_per_io(%d), frame_sz(%d), " 2000 "succeed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), "
1883 "total(%d kb)\n", ioc->name, ioc->request_depth, 2001 "total(%d kb)\n", ioc->name, ioc->hba_queue_depth,
1884 ioc->chains_needed_per_io, ioc->request_sz, sz/1024); 2002 ioc->chains_needed_per_io, ioc->request_sz, sz/1024);
1885 2003
1886 ioc->chain = ioc->request + ((ioc->request_depth + 1) * 2004
2005 /* hi-priority queue */
2006 ioc->hi_priority = ioc->request + ((ioc->scsiio_depth + 1) *
2007 ioc->request_sz);
2008 ioc->hi_priority_dma = ioc->request_dma + ((ioc->scsiio_depth + 1) *
2009 ioc->request_sz);
2010
2011 /* internal queue */
2012 ioc->internal = ioc->hi_priority + (ioc->hi_priority_depth *
2013 ioc->request_sz);
2014 ioc->internal_dma = ioc->hi_priority_dma + (ioc->hi_priority_depth *
2015 ioc->request_sz);
2016
2017 ioc->chain = ioc->internal + (ioc->internal_depth *
1887 ioc->request_sz); 2018 ioc->request_sz);
1888 ioc->chain_dma = ioc->request_dma + ((ioc->request_depth + 1) * 2019 ioc->chain_dma = ioc->internal_dma + (ioc->internal_depth *
1889 ioc->request_sz); 2020 ioc->request_sz);
2021
1890 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request pool(0x%p): " 2022 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request pool(0x%p): "
1891 "depth(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, 2023 "depth(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name,
1892 ioc->request, ioc->request_depth, ioc->request_sz, 2024 ioc->request, ioc->hba_queue_depth, ioc->request_sz,
1893 ((ioc->request_depth + 1) * ioc->request_sz)/1024)); 2025 (ioc->hba_queue_depth * ioc->request_sz)/1024));
1894 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "chain pool(0x%p): depth" 2026 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "chain pool(0x%p): depth"
1895 "(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, ioc->chain, 2027 "(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, ioc->chain,
1896 ioc->chain_depth, ioc->request_sz, ((ioc->chain_depth * 2028 ioc->chain_depth, ioc->request_sz, ((ioc->chain_depth *
@@ -1899,7 +2031,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1899 ioc->name, (unsigned long long) ioc->request_dma)); 2031 ioc->name, (unsigned long long) ioc->request_dma));
1900 total_sz += sz; 2032 total_sz += sz;
1901 2033
1902 ioc->scsi_lookup = kcalloc(ioc->request_depth, 2034 ioc->scsi_lookup = kcalloc(ioc->scsiio_depth,
1903 sizeof(struct request_tracker), GFP_KERNEL); 2035 sizeof(struct request_tracker), GFP_KERNEL);
1904 if (!ioc->scsi_lookup) { 2036 if (!ioc->scsi_lookup) {
1905 printk(MPT2SAS_ERR_FMT "scsi_lookup: kcalloc failed\n", 2037 printk(MPT2SAS_ERR_FMT "scsi_lookup: kcalloc failed\n",
@@ -1907,12 +2039,38 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1907 goto out; 2039 goto out;
1908 } 2040 }
1909 2041
1910 /* initialize some bits */ 2042 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsiio(0x%p): "
1911 for (i = 0; i < ioc->request_depth; i++) 2043 "depth(%d)\n", ioc->name, ioc->request,
1912 ioc->scsi_lookup[i].smid = i + 1; 2044 ioc->scsiio_depth));
2045
2046 /* initialize hi-priority queue smid's */
2047 ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth,
2048 sizeof(struct request_tracker), GFP_KERNEL);
2049 if (!ioc->hpr_lookup) {
2050 printk(MPT2SAS_ERR_FMT "hpr_lookup: kcalloc failed\n",
2051 ioc->name);
2052 goto out;
2053 }
2054 ioc->hi_priority_smid = ioc->scsiio_depth + 1;
2055 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "hi_priority(0x%p): "
2056 "depth(%d), start smid(%d)\n", ioc->name, ioc->hi_priority,
2057 ioc->hi_priority_depth, ioc->hi_priority_smid));
2058
2059 /* initialize internal queue smid's */
2060 ioc->internal_lookup = kcalloc(ioc->internal_depth,
2061 sizeof(struct request_tracker), GFP_KERNEL);
2062 if (!ioc->internal_lookup) {
2063 printk(MPT2SAS_ERR_FMT "internal_lookup: kcalloc failed\n",
2064 ioc->name);
2065 goto out;
2066 }
2067 ioc->internal_smid = ioc->hi_priority_smid + ioc->hi_priority_depth;
2068 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "internal(0x%p): "
2069 "depth(%d), start smid(%d)\n", ioc->name, ioc->internal,
2070 ioc->internal_depth, ioc->internal_smid));
1913 2071
1914 /* sense buffers, 4 byte align */ 2072 /* sense buffers, 4 byte align */
1915 sz = ioc->request_depth * SCSI_SENSE_BUFFERSIZE; 2073 sz = ioc->scsiio_depth * SCSI_SENSE_BUFFERSIZE;
1916 ioc->sense_dma_pool = pci_pool_create("sense pool", ioc->pdev, sz, 4, 2074 ioc->sense_dma_pool = pci_pool_create("sense pool", ioc->pdev, sz, 4,
1917 0); 2075 0);
1918 if (!ioc->sense_dma_pool) { 2076 if (!ioc->sense_dma_pool) {
@@ -1929,7 +2087,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1929 } 2087 }
1930 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT 2088 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT
1931 "sense pool(0x%p): depth(%d), element_size(%d), pool_size" 2089 "sense pool(0x%p): depth(%d), element_size(%d), pool_size"
1932 "(%d kB)\n", ioc->name, ioc->sense, ioc->request_depth, 2090 "(%d kB)\n", ioc->name, ioc->sense, ioc->scsiio_depth,
1933 SCSI_SENSE_BUFFERSIZE, sz/1024)); 2091 SCSI_SENSE_BUFFERSIZE, sz/1024));
1934 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "sense_dma(0x%llx)\n", 2092 dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "sense_dma(0x%llx)\n",
1935 ioc->name, (unsigned long long)ioc->sense_dma)); 2093 ioc->name, (unsigned long long)ioc->sense_dma));
@@ -2304,7 +2462,7 @@ _base_handshake_req_reply_wait(struct MPT2SAS_ADAPTER *ioc, int request_bytes,
2304 ((request_bytes/4)<<MPI2_DOORBELL_ADD_DWORDS_SHIFT)), 2462 ((request_bytes/4)<<MPI2_DOORBELL_ADD_DWORDS_SHIFT)),
2305 &ioc->chip->Doorbell); 2463 &ioc->chip->Doorbell);
2306 2464
2307 if ((_base_wait_for_doorbell_int(ioc, 5, sleep_flag))) { 2465 if ((_base_wait_for_doorbell_int(ioc, 5, NO_SLEEP))) {
2308 printk(MPT2SAS_ERR_FMT "doorbell handshake " 2466 printk(MPT2SAS_ERR_FMT "doorbell handshake "
2309 "int failed (line=%d)\n", ioc->name, __LINE__); 2467 "int failed (line=%d)\n", ioc->name, __LINE__);
2310 return -EFAULT; 2468 return -EFAULT;
@@ -2454,7 +2612,8 @@ mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
2454 if (mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET || 2612 if (mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET ||
2455 mpi_request->Operation == MPI2_SAS_OP_PHY_LINK_RESET) 2613 mpi_request->Operation == MPI2_SAS_OP_PHY_LINK_RESET)
2456 ioc->ioc_link_reset_in_progress = 1; 2614 ioc->ioc_link_reset_in_progress = 1;
2457 mpt2sas_base_put_smid_default(ioc, smid, mpi_request->VF_ID); 2615 mpt2sas_base_put_smid_default(ioc, smid);
2616 init_completion(&ioc->base_cmds.done);
2458 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 2617 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done,
2459 msecs_to_jiffies(10000)); 2618 msecs_to_jiffies(10000));
2460 if ((mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET || 2619 if ((mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET ||
@@ -2555,7 +2714,8 @@ mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
2555 request = mpt2sas_base_get_msg_frame(ioc, smid); 2714 request = mpt2sas_base_get_msg_frame(ioc, smid);
2556 ioc->base_cmds.smid = smid; 2715 ioc->base_cmds.smid = smid;
2557 memcpy(request, mpi_request, sizeof(Mpi2SepReply_t)); 2716 memcpy(request, mpi_request, sizeof(Mpi2SepReply_t));
2558 mpt2sas_base_put_smid_default(ioc, smid, mpi_request->VF_ID); 2717 mpt2sas_base_put_smid_default(ioc, smid);
2718 init_completion(&ioc->base_cmds.done);
2559 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 2719 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done,
2560 msecs_to_jiffies(10000)); 2720 msecs_to_jiffies(10000));
2561 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { 2721 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) {
@@ -2701,13 +2861,12 @@ _base_get_ioc_facts(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
2701/** 2861/**
2702 * _base_send_ioc_init - send ioc_init to firmware 2862 * _base_send_ioc_init - send ioc_init to firmware
2703 * @ioc: per adapter object 2863 * @ioc: per adapter object
2704 * @VF_ID: virtual function id
2705 * @sleep_flag: CAN_SLEEP or NO_SLEEP 2864 * @sleep_flag: CAN_SLEEP or NO_SLEEP
2706 * 2865 *
2707 * Returns 0 for success, non-zero for failure. 2866 * Returns 0 for success, non-zero for failure.
2708 */ 2867 */
2709static int 2868static int
2710_base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag) 2869_base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
2711{ 2870{
2712 Mpi2IOCInitRequest_t mpi_request; 2871 Mpi2IOCInitRequest_t mpi_request;
2713 Mpi2IOCInitReply_t mpi_reply; 2872 Mpi2IOCInitReply_t mpi_reply;
@@ -2719,7 +2878,8 @@ _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag)
2719 memset(&mpi_request, 0, sizeof(Mpi2IOCInitRequest_t)); 2878 memset(&mpi_request, 0, sizeof(Mpi2IOCInitRequest_t));
2720 mpi_request.Function = MPI2_FUNCTION_IOC_INIT; 2879 mpi_request.Function = MPI2_FUNCTION_IOC_INIT;
2721 mpi_request.WhoInit = MPI2_WHOINIT_HOST_DRIVER; 2880 mpi_request.WhoInit = MPI2_WHOINIT_HOST_DRIVER;
2722 mpi_request.VF_ID = VF_ID; 2881 mpi_request.VF_ID = 0; /* TODO */
2882 mpi_request.VP_ID = 0;
2723 mpi_request.MsgVersion = cpu_to_le16(MPI2_VERSION); 2883 mpi_request.MsgVersion = cpu_to_le16(MPI2_VERSION);
2724 mpi_request.HeaderVersion = cpu_to_le16(MPI2_HEADER_VERSION); 2884 mpi_request.HeaderVersion = cpu_to_le16(MPI2_HEADER_VERSION);
2725 2885
@@ -2795,13 +2955,12 @@ _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag)
2795/** 2955/**
2796 * _base_send_port_enable - send port_enable(discovery stuff) to firmware 2956 * _base_send_port_enable - send port_enable(discovery stuff) to firmware
2797 * @ioc: per adapter object 2957 * @ioc: per adapter object
2798 * @VF_ID: virtual function id
2799 * @sleep_flag: CAN_SLEEP or NO_SLEEP 2958 * @sleep_flag: CAN_SLEEP or NO_SLEEP
2800 * 2959 *
2801 * Returns 0 for success, non-zero for failure. 2960 * Returns 0 for success, non-zero for failure.
2802 */ 2961 */
2803static int 2962static int
2804_base_send_port_enable(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag) 2963_base_send_port_enable(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
2805{ 2964{
2806 Mpi2PortEnableRequest_t *mpi_request; 2965 Mpi2PortEnableRequest_t *mpi_request;
2807 u32 ioc_state; 2966 u32 ioc_state;
@@ -2829,9 +2988,11 @@ _base_send_port_enable(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag)
2829 ioc->base_cmds.smid = smid; 2988 ioc->base_cmds.smid = smid;
2830 memset(mpi_request, 0, sizeof(Mpi2PortEnableRequest_t)); 2989 memset(mpi_request, 0, sizeof(Mpi2PortEnableRequest_t));
2831 mpi_request->Function = MPI2_FUNCTION_PORT_ENABLE; 2990 mpi_request->Function = MPI2_FUNCTION_PORT_ENABLE;
2832 mpi_request->VF_ID = VF_ID; 2991 mpi_request->VF_ID = 0; /* TODO */
2992 mpi_request->VP_ID = 0;
2833 2993
2834 mpt2sas_base_put_smid_default(ioc, smid, VF_ID); 2994 mpt2sas_base_put_smid_default(ioc, smid);
2995 init_completion(&ioc->base_cmds.done);
2835 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 2996 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done,
2836 300*HZ); 2997 300*HZ);
2837 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { 2998 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) {
@@ -2892,13 +3053,12 @@ _base_unmask_events(struct MPT2SAS_ADAPTER *ioc, u16 event)
2892/** 3053/**
2893 * _base_event_notification - send event notification 3054 * _base_event_notification - send event notification
2894 * @ioc: per adapter object 3055 * @ioc: per adapter object
2895 * @VF_ID: virtual function id
2896 * @sleep_flag: CAN_SLEEP or NO_SLEEP 3056 * @sleep_flag: CAN_SLEEP or NO_SLEEP
2897 * 3057 *
2898 * Returns 0 for success, non-zero for failure. 3058 * Returns 0 for success, non-zero for failure.
2899 */ 3059 */
2900static int 3060static int
2901_base_event_notification(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag) 3061_base_event_notification(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
2902{ 3062{
2903 Mpi2EventNotificationRequest_t *mpi_request; 3063 Mpi2EventNotificationRequest_t *mpi_request;
2904 unsigned long timeleft; 3064 unsigned long timeleft;
@@ -2926,11 +3086,13 @@ _base_event_notification(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag)
2926 ioc->base_cmds.smid = smid; 3086 ioc->base_cmds.smid = smid;
2927 memset(mpi_request, 0, sizeof(Mpi2EventNotificationRequest_t)); 3087 memset(mpi_request, 0, sizeof(Mpi2EventNotificationRequest_t));
2928 mpi_request->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; 3088 mpi_request->Function = MPI2_FUNCTION_EVENT_NOTIFICATION;
2929 mpi_request->VF_ID = VF_ID; 3089 mpi_request->VF_ID = 0; /* TODO */
3090 mpi_request->VP_ID = 0;
2930 for (i = 0; i < MPI2_EVENT_NOTIFY_EVENTMASK_WORDS; i++) 3091 for (i = 0; i < MPI2_EVENT_NOTIFY_EVENTMASK_WORDS; i++)
2931 mpi_request->EventMasks[i] = 3092 mpi_request->EventMasks[i] =
2932 le32_to_cpu(ioc->event_masks[i]); 3093 le32_to_cpu(ioc->event_masks[i]);
2933 mpt2sas_base_put_smid_default(ioc, smid, VF_ID); 3094 mpt2sas_base_put_smid_default(ioc, smid);
3095 init_completion(&ioc->base_cmds.done);
2934 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ); 3096 timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ);
2935 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { 3097 if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) {
2936 printk(MPT2SAS_ERR_FMT "%s: timeout\n", 3098 printk(MPT2SAS_ERR_FMT "%s: timeout\n",
@@ -2981,7 +3143,7 @@ mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type)
2981 return; 3143 return;
2982 3144
2983 mutex_lock(&ioc->base_cmds.mutex); 3145 mutex_lock(&ioc->base_cmds.mutex);
2984 _base_event_notification(ioc, 0, CAN_SLEEP); 3146 _base_event_notification(ioc, CAN_SLEEP);
2985 mutex_unlock(&ioc->base_cmds.mutex); 3147 mutex_unlock(&ioc->base_cmds.mutex);
2986} 3148}
2987 3149
@@ -3006,7 +3168,6 @@ _base_diag_reset(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3006 3168
3007 drsprintk(ioc, printk(MPT2SAS_DEBUG_FMT "clear interrupts\n", 3169 drsprintk(ioc, printk(MPT2SAS_DEBUG_FMT "clear interrupts\n",
3008 ioc->name)); 3170 ioc->name));
3009 writel(0, &ioc->chip->HostInterruptStatus);
3010 3171
3011 count = 0; 3172 count = 0;
3012 do { 3173 do {
@@ -3160,30 +3321,60 @@ _base_make_ioc_ready(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
3160/** 3321/**
3161 * _base_make_ioc_operational - put controller in OPERATIONAL state 3322 * _base_make_ioc_operational - put controller in OPERATIONAL state
3162 * @ioc: per adapter object 3323 * @ioc: per adapter object
3163 * @VF_ID: virtual function id
3164 * @sleep_flag: CAN_SLEEP or NO_SLEEP 3324 * @sleep_flag: CAN_SLEEP or NO_SLEEP
3165 * 3325 *
3166 * Returns 0 for success, non-zero for failure. 3326 * Returns 0 for success, non-zero for failure.
3167 */ 3327 */
3168static int 3328static int
3169_base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, 3329_base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3170 int sleep_flag)
3171{ 3330{
3172 int r, i; 3331 int r, i;
3173 unsigned long flags; 3332 unsigned long flags;
3174 u32 reply_address; 3333 u32 reply_address;
3334 u16 smid;
3335 struct _tr_list *delayed_tr, *delayed_tr_next;
3175 3336
3176 dinitprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name, 3337 dinitprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name,
3177 __func__)); 3338 __func__));
3178 3339
3340 /* clean the delayed target reset list */
3341 list_for_each_entry_safe(delayed_tr, delayed_tr_next,
3342 &ioc->delayed_tr_list, list) {
3343 list_del(&delayed_tr->list);
3344 kfree(delayed_tr);
3345 }
3346
3179 /* initialize the scsi lookup free list */ 3347 /* initialize the scsi lookup free list */
3180 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 3348 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
3181 INIT_LIST_HEAD(&ioc->free_list); 3349 INIT_LIST_HEAD(&ioc->free_list);
3182 for (i = 0; i < ioc->request_depth; i++) { 3350 smid = 1;
3351 for (i = 0; i < ioc->scsiio_depth; i++, smid++) {
3183 ioc->scsi_lookup[i].cb_idx = 0xFF; 3352 ioc->scsi_lookup[i].cb_idx = 0xFF;
3353 ioc->scsi_lookup[i].smid = smid;
3354 ioc->scsi_lookup[i].scmd = NULL;
3184 list_add_tail(&ioc->scsi_lookup[i].tracker_list, 3355 list_add_tail(&ioc->scsi_lookup[i].tracker_list,
3185 &ioc->free_list); 3356 &ioc->free_list);
3186 } 3357 }
3358
3359 /* hi-priority queue */
3360 INIT_LIST_HEAD(&ioc->hpr_free_list);
3361 smid = ioc->hi_priority_smid;
3362 for (i = 0; i < ioc->hi_priority_depth; i++, smid++) {
3363 ioc->hpr_lookup[i].cb_idx = 0xFF;
3364 ioc->hpr_lookup[i].smid = smid;
3365 list_add_tail(&ioc->hpr_lookup[i].tracker_list,
3366 &ioc->hpr_free_list);
3367 }
3368
3369 /* internal queue */
3370 INIT_LIST_HEAD(&ioc->internal_free_list);
3371 smid = ioc->internal_smid;
3372 for (i = 0; i < ioc->internal_depth; i++, smid++) {
3373 ioc->internal_lookup[i].cb_idx = 0xFF;
3374 ioc->internal_lookup[i].smid = smid;
3375 list_add_tail(&ioc->internal_lookup[i].tracker_list,
3376 &ioc->internal_free_list);
3377 }
3187 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); 3378 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
3188 3379
3189 /* initialize Reply Free Queue */ 3380 /* initialize Reply Free Queue */
@@ -3196,7 +3387,7 @@ _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
3196 for (i = 0; i < ioc->reply_post_queue_depth; i++) 3387 for (i = 0; i < ioc->reply_post_queue_depth; i++)
3197 ioc->reply_post_free[i].Words = ULLONG_MAX; 3388 ioc->reply_post_free[i].Words = ULLONG_MAX;
3198 3389
3199 r = _base_send_ioc_init(ioc, VF_ID, sleep_flag); 3390 r = _base_send_ioc_init(ioc, sleep_flag);
3200 if (r) 3391 if (r)
3201 return r; 3392 return r;
3202 3393
@@ -3207,14 +3398,14 @@ _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
3207 writel(0, &ioc->chip->ReplyPostHostIndex); 3398 writel(0, &ioc->chip->ReplyPostHostIndex);
3208 3399
3209 _base_unmask_interrupts(ioc); 3400 _base_unmask_interrupts(ioc);
3210 r = _base_event_notification(ioc, VF_ID, sleep_flag); 3401 r = _base_event_notification(ioc, sleep_flag);
3211 if (r) 3402 if (r)
3212 return r; 3403 return r;
3213 3404
3214 if (sleep_flag == CAN_SLEEP) 3405 if (sleep_flag == CAN_SLEEP)
3215 _base_static_config_pages(ioc); 3406 _base_static_config_pages(ioc);
3216 3407
3217 r = _base_send_port_enable(ioc, VF_ID, sleep_flag); 3408 r = _base_send_port_enable(ioc, sleep_flag);
3218 if (r) 3409 if (r)
3219 return r; 3410 return r;
3220 3411
@@ -3278,6 +3469,17 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3278 if (r) 3469 if (r)
3279 goto out_free_resources; 3470 goto out_free_resources;
3280 3471
3472 ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts,
3473 sizeof(Mpi2PortFactsReply_t), GFP_KERNEL);
3474 if (!ioc->pfacts)
3475 goto out_free_resources;
3476
3477 for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) {
3478 r = _base_get_port_facts(ioc, i, CAN_SLEEP);
3479 if (r)
3480 goto out_free_resources;
3481 }
3482
3281 r = _base_allocate_memory_pools(ioc, CAN_SLEEP); 3483 r = _base_allocate_memory_pools(ioc, CAN_SLEEP);
3282 if (r) 3484 if (r)
3283 goto out_free_resources; 3485 goto out_free_resources;
@@ -3286,7 +3488,6 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3286 3488
3287 /* base internal command bits */ 3489 /* base internal command bits */
3288 mutex_init(&ioc->base_cmds.mutex); 3490 mutex_init(&ioc->base_cmds.mutex);
3289 init_completion(&ioc->base_cmds.done);
3290 ioc->base_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); 3491 ioc->base_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3291 ioc->base_cmds.status = MPT2_CMD_NOT_USED; 3492 ioc->base_cmds.status = MPT2_CMD_NOT_USED;
3292 3493
@@ -3294,7 +3495,6 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3294 ioc->transport_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); 3495 ioc->transport_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3295 ioc->transport_cmds.status = MPT2_CMD_NOT_USED; 3496 ioc->transport_cmds.status = MPT2_CMD_NOT_USED;
3296 mutex_init(&ioc->transport_cmds.mutex); 3497 mutex_init(&ioc->transport_cmds.mutex);
3297 init_completion(&ioc->transport_cmds.done);
3298 3498
3299 /* task management internal command bits */ 3499 /* task management internal command bits */
3300 ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); 3500 ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
@@ -3310,7 +3510,6 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3310 ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); 3510 ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
3311 ioc->ctl_cmds.status = MPT2_CMD_NOT_USED; 3511 ioc->ctl_cmds.status = MPT2_CMD_NOT_USED;
3312 mutex_init(&ioc->ctl_cmds.mutex); 3512 mutex_init(&ioc->ctl_cmds.mutex);
3313 init_completion(&ioc->ctl_cmds.done);
3314 3513
3315 for (i = 0; i < MPI2_EVENT_NOTIFY_EVENTMASK_WORDS; i++) 3514 for (i = 0; i < MPI2_EVENT_NOTIFY_EVENTMASK_WORDS; i++)
3316 ioc->event_masks[i] = -1; 3515 ioc->event_masks[i] = -1;
@@ -3327,18 +3526,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3327 _base_unmask_events(ioc, MPI2_EVENT_IR_OPERATION_STATUS); 3526 _base_unmask_events(ioc, MPI2_EVENT_IR_OPERATION_STATUS);
3328 _base_unmask_events(ioc, MPI2_EVENT_TASK_SET_FULL); 3527 _base_unmask_events(ioc, MPI2_EVENT_TASK_SET_FULL);
3329 _base_unmask_events(ioc, MPI2_EVENT_LOG_ENTRY_ADDED); 3528 _base_unmask_events(ioc, MPI2_EVENT_LOG_ENTRY_ADDED);
3330 3529 r = _base_make_ioc_operational(ioc, CAN_SLEEP);
3331 ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts,
3332 sizeof(Mpi2PortFactsReply_t), GFP_KERNEL);
3333 if (!ioc->pfacts)
3334 goto out_free_resources;
3335
3336 for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) {
3337 r = _base_get_port_facts(ioc, i, CAN_SLEEP);
3338 if (r)
3339 goto out_free_resources;
3340 }
3341 r = _base_make_ioc_operational(ioc, 0, CAN_SLEEP);
3342 if (r) 3530 if (r)
3343 goto out_free_resources; 3531 goto out_free_resources;
3344 3532
@@ -3466,7 +3654,7 @@ _wait_for_commands_to_complete(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3466 3654
3467 /* pending command count */ 3655 /* pending command count */
3468 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 3656 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
3469 for (i = 0; i < ioc->request_depth; i++) 3657 for (i = 0; i < ioc->scsiio_depth; i++)
3470 if (ioc->scsi_lookup[i].cb_idx != 0xFF) 3658 if (ioc->scsi_lookup[i].cb_idx != 0xFF)
3471 ioc->pending_io_count++; 3659 ioc->pending_io_count++;
3472 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); 3660 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
@@ -3490,7 +3678,7 @@ int
3490mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag, 3678mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
3491 enum reset_type type) 3679 enum reset_type type)
3492{ 3680{
3493 int r, i; 3681 int r;
3494 unsigned long flags; 3682 unsigned long flags;
3495 3683
3496 dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: enter\n", ioc->name, 3684 dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: enter\n", ioc->name,
@@ -3513,9 +3701,7 @@ mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
3513 if (r) 3701 if (r)
3514 goto out; 3702 goto out;
3515 _base_reset_handler(ioc, MPT2_IOC_AFTER_RESET); 3703 _base_reset_handler(ioc, MPT2_IOC_AFTER_RESET);
3516 for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) 3704 r = _base_make_ioc_operational(ioc, sleep_flag);
3517 r = _base_make_ioc_operational(ioc, ioc->pfacts[i].VF_ID,
3518 sleep_flag);
3519 if (!r) 3705 if (!r)
3520 _base_reset_handler(ioc, MPT2_IOC_DONE_RESET); 3706 _base_reset_handler(ioc, MPT2_IOC_DONE_RESET);
3521 out: 3707 out:
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h
index 2faab1e690e9..0cf6bc236e4d 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
@@ -3,7 +3,7 @@
3 * for access to MPT (Message Passing Technology) firmware. 3 * for access to MPT (Message Passing Technology) firmware.
4 * 4 *
5 * This code is based on drivers/scsi/mpt2sas/mpt2_base.h 5 * This code is based on drivers/scsi/mpt2sas/mpt2_base.h
6 * Copyright (C) 2007-2008 LSI Corporation 6 * Copyright (C) 2007-2009 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com) 7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
@@ -69,10 +69,10 @@
69#define MPT2SAS_DRIVER_NAME "mpt2sas" 69#define MPT2SAS_DRIVER_NAME "mpt2sas"
70#define MPT2SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>" 70#define MPT2SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>"
71#define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver" 71#define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver"
72#define MPT2SAS_DRIVER_VERSION "01.100.06.00" 72#define MPT2SAS_DRIVER_VERSION "02.100.03.00"
73#define MPT2SAS_MAJOR_VERSION 01 73#define MPT2SAS_MAJOR_VERSION 02
74#define MPT2SAS_MINOR_VERSION 100 74#define MPT2SAS_MINOR_VERSION 100
75#define MPT2SAS_BUILD_VERSION 06 75#define MPT2SAS_BUILD_VERSION 03
76#define MPT2SAS_RELEASE_VERSION 00 76#define MPT2SAS_RELEASE_VERSION 00
77 77
78/* 78/*
@@ -264,6 +264,13 @@ struct _internal_cmd {
264 * SAS Topology Structures 264 * SAS Topology Structures
265 */ 265 */
266 266
267#define MPTSAS_STATE_TR_SEND 0x0001
268#define MPTSAS_STATE_TR_COMPLETE 0x0002
269#define MPTSAS_STATE_CNTRL_SEND 0x0004
270#define MPTSAS_STATE_CNTRL_COMPLETE 0x0008
271
272#define MPT2SAS_REQ_SAS_CNTRL 0x0010
273
267/** 274/**
268 * struct _sas_device - attached device information 275 * struct _sas_device - attached device information
269 * @list: sas device list 276 * @list: sas device list
@@ -300,6 +307,7 @@ struct _sas_device {
300 u16 slot; 307 u16 slot;
301 u8 hidden_raid_component; 308 u8 hidden_raid_component;
302 u8 responding; 309 u8 responding;
310 u16 state;
303}; 311};
304 312
305/** 313/**
@@ -436,6 +444,17 @@ struct request_tracker {
436 struct list_head tracker_list; 444 struct list_head tracker_list;
437}; 445};
438 446
447/**
448 * struct _tr_list - target reset list
449 * @handle: device handle
450 * @state: state machine
451 */
452struct _tr_list {
453 struct list_head list;
454 u16 handle;
455 u16 state;
456};
457
439typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr); 458typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
440 459
441/** 460/**
@@ -510,8 +529,9 @@ typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
510 * @config_page_sz: config page size 529 * @config_page_sz: config page size
511 * @config_page: reserve memory for config page payload 530 * @config_page: reserve memory for config page payload
512 * @config_page_dma: 531 * @config_page_dma:
532 * @hba_queue_depth: hba request queue depth
513 * @sge_size: sg element size for either 32/64 bit 533 * @sge_size: sg element size for either 32/64 bit
514 * @request_depth: hba request queue depth 534 * @scsiio_depth: SCSI_IO queue depth
515 * @request_sz: per request frame size 535 * @request_sz: per request frame size
516 * @request: pool of request frames 536 * @request: pool of request frames
517 * @request_dma: 537 * @request_dma:
@@ -528,6 +548,18 @@ typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
528 * @chains_needed_per_io: max chains per io 548 * @chains_needed_per_io: max chains per io
529 * @chain_offset_value_for_main_message: location 1st sg in main 549 * @chain_offset_value_for_main_message: location 1st sg in main
530 * @chain_depth: total chains allocated 550 * @chain_depth: total chains allocated
551 * @hi_priority_smid:
552 * @hi_priority:
553 * @hi_priority_dma:
554 * @hi_priority_depth:
555 * @hpr_lookup:
556 * @hpr_free_list:
557 * @internal_smid:
558 * @internal:
559 * @internal_dma:
560 * @internal_depth:
561 * @internal_lookup:
562 * @internal_free_list:
531 * @sense: pool of sense 563 * @sense: pool of sense
532 * @sense_dma: 564 * @sense_dma:
533 * @sense_dma_pool: 565 * @sense_dma_pool:
@@ -597,6 +629,8 @@ struct MPT2SAS_ADAPTER {
597 u8 ctl_cb_idx; 629 u8 ctl_cb_idx;
598 u8 base_cb_idx; 630 u8 base_cb_idx;
599 u8 config_cb_idx; 631 u8 config_cb_idx;
632 u8 tm_tr_cb_idx;
633 u8 tm_sas_control_cb_idx;
600 struct _internal_cmd base_cmds; 634 struct _internal_cmd base_cmds;
601 struct _internal_cmd transport_cmds; 635 struct _internal_cmd transport_cmds;
602 struct _internal_cmd tm_cmds; 636 struct _internal_cmd tm_cmds;
@@ -643,9 +677,10 @@ struct MPT2SAS_ADAPTER {
643 void *config_page; 677 void *config_page;
644 dma_addr_t config_page_dma; 678 dma_addr_t config_page_dma;
645 679
646 /* request */ 680 /* scsiio request */
681 u16 hba_queue_depth;
647 u16 sge_size; 682 u16 sge_size;
648 u16 request_depth; 683 u16 scsiio_depth;
649 u16 request_sz; 684 u16 request_sz;
650 u8 *request; 685 u8 *request;
651 dma_addr_t request_dma; 686 dma_addr_t request_dma;
@@ -665,6 +700,22 @@ struct MPT2SAS_ADAPTER {
665 u16 chain_offset_value_for_main_message; 700 u16 chain_offset_value_for_main_message;
666 u16 chain_depth; 701 u16 chain_depth;
667 702
703 /* hi-priority queue */
704 u16 hi_priority_smid;
705 u8 *hi_priority;
706 dma_addr_t hi_priority_dma;
707 u16 hi_priority_depth;
708 struct request_tracker *hpr_lookup;
709 struct list_head hpr_free_list;
710
711 /* internal queue */
712 u16 internal_smid;
713 u8 *internal;
714 dma_addr_t internal_dma;
715 u16 internal_depth;
716 struct request_tracker *internal_lookup;
717 struct list_head internal_free_list;
718
668 /* sense */ 719 /* sense */
669 u8 *sense; 720 u8 *sense;
670 dma_addr_t sense_dma; 721 dma_addr_t sense_dma;
@@ -690,6 +741,8 @@ struct MPT2SAS_ADAPTER {
690 struct dma_pool *reply_post_free_dma_pool; 741 struct dma_pool *reply_post_free_dma_pool;
691 u32 reply_post_host_index; 742 u32 reply_post_host_index;
692 743
744 struct list_head delayed_tr_list;
745
693 /* diag buffer support */ 746 /* diag buffer support */
694 u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT]; 747 u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
695 u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT]; 748 u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
@@ -701,7 +754,7 @@ struct MPT2SAS_ADAPTER {
701 u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT]; 754 u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
702}; 755};
703 756
704typedef void (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, 757typedef u8 (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
705 u32 reply); 758 u32 reply);
706 759
707 760
@@ -720,22 +773,28 @@ int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
720void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid); 773void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid);
721void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid); 774void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid);
722void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr); 775void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr);
723dma_addr_t mpt2sas_base_get_msg_frame_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid); 776dma_addr_t mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc,
724dma_addr_t mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid); 777 u16 smid);
778
779/* hi-priority queue */
780u16 mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
781u16 mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx,
782 struct scsi_cmnd *scmd);
725 783
726u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx); 784u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
727void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid); 785void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid);
728void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id, 786void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid,
729 u16 handle); 787 u16 handle);
730void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id); 788void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid);
731void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid, 789void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid,
732 u8 vf_id, u16 io_index); 790 u16 io_index);
733void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id); 791void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid);
734void mpt2sas_base_initialize_callback_handler(void); 792void mpt2sas_base_initialize_callback_handler(void);
735u8 mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func); 793u8 mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func);
736void mpt2sas_base_release_callback_handler(u8 cb_idx); 794void mpt2sas_base_release_callback_handler(u8 cb_idx);
737 795
738void mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply); 796u8 mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
797 u32 reply);
739void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr); 798void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr);
740 799
741u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked); 800u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked);
@@ -749,6 +808,8 @@ int mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
749void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type); 808void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type);
750 809
751/* scsih shared API */ 810/* scsih shared API */
811u8 mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
812 u32 reply);
752void mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun, 813void mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
753 u8 type, u16 smid_task, ulong timeout); 814 u8 type, u16 smid_task, ulong timeout);
754void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle); 815void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
@@ -760,11 +821,11 @@ struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAP
760struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address( 821struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address(
761 struct MPT2SAS_ADAPTER *ioc, u64 sas_address); 822 struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
762 823
763void mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply);
764void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase); 824void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
765 825
766/* config shared API */ 826/* config shared API */
767void mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply); 827u8 mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
828 u32 reply);
768int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys); 829int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys);
769int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc, 830int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
770 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page); 831 Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
@@ -817,14 +878,17 @@ extern struct device_attribute *mpt2sas_host_attrs[];
817extern struct device_attribute *mpt2sas_dev_attrs[]; 878extern struct device_attribute *mpt2sas_dev_attrs[];
818void mpt2sas_ctl_init(void); 879void mpt2sas_ctl_init(void);
819void mpt2sas_ctl_exit(void); 880void mpt2sas_ctl_exit(void);
820void mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply); 881u8 mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
882 u32 reply);
821void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase); 883void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
822void mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply); 884u8 mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
885 u32 reply);
823void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc, 886void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,
824 Mpi2EventNotificationReply_t *mpi_reply); 887 Mpi2EventNotificationReply_t *mpi_reply);
825 888
826/* transport shared API */ 889/* transport shared API */
827void mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply); 890u8 mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
891 u32 reply);
828struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc, 892struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc,
829 u16 handle, u16 parent_handle); 893 u16 handle, u16 parent_handle);
830void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address, 894void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
@@ -838,6 +902,8 @@ void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc, u16 handle,
838extern struct sas_function_template mpt2sas_transport_functions; 902extern struct sas_function_template mpt2sas_transport_functions;
839extern struct scsi_transport_template *mpt2sas_transport_template; 903extern struct scsi_transport_template *mpt2sas_transport_template;
840extern int scsi_internal_device_block(struct scsi_device *sdev); 904extern int scsi_internal_device_block(struct scsi_device *sdev);
905extern u8 mpt2sas_stm_zero_smid_handler(struct MPT2SAS_ADAPTER *ioc,
906 u8 msix_index, u32 reply);
841extern int scsi_internal_device_unblock(struct scsi_device *sdev); 907extern int scsi_internal_device_unblock(struct scsi_device *sdev);
842 908
843#endif /* MPT2SAS_BASE_H_INCLUDED */ 909#endif /* MPT2SAS_BASE_H_INCLUDED */
diff --git a/drivers/scsi/mpt2sas/mpt2sas_config.c b/drivers/scsi/mpt2sas/mpt2sas_config.c
index ab8c560865d8..594a389c6526 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_config.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_config.c
@@ -2,7 +2,7 @@
2 * This module provides common API for accessing firmware configuration pages 2 * This module provides common API for accessing firmware configuration pages
3 * 3 *
4 * This code is based on drivers/scsi/mpt2sas/mpt2_base.c 4 * This code is based on drivers/scsi/mpt2sas/mpt2_base.c
5 * Copyright (C) 2007-2008 LSI Corporation 5 * Copyright (C) 2007-2009 LSI Corporation
6 * (mailto:DL-MPTFusionLinux@lsi.com) 6 * (mailto:DL-MPTFusionLinux@lsi.com)
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
@@ -227,23 +227,25 @@ _config_free_config_dma_memory(struct MPT2SAS_ADAPTER *ioc,
227 * mpt2sas_config_done - config page completion routine 227 * mpt2sas_config_done - config page completion routine
228 * @ioc: per adapter object 228 * @ioc: per adapter object
229 * @smid: system request message index 229 * @smid: system request message index
230 * @VF_ID: virtual function id 230 * @msix_index: MSIX table index supplied by the OS
231 * @reply: reply message frame(lower 32bit addr) 231 * @reply: reply message frame(lower 32bit addr)
232 * Context: none. 232 * Context: none.
233 * 233 *
234 * The callback handler when using _config_request. 234 * The callback handler when using _config_request.
235 * 235 *
236 * Return nothing. 236 * Return 1 meaning mf should be freed from _base_interrupt
237 * 0 means the mf is freed from this function.
237 */ 238 */
238void 239u8
239mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) 240mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
241 u32 reply)
240{ 242{
241 MPI2DefaultReply_t *mpi_reply; 243 MPI2DefaultReply_t *mpi_reply;
242 244
243 if (ioc->config_cmds.status == MPT2_CMD_NOT_USED) 245 if (ioc->config_cmds.status == MPT2_CMD_NOT_USED)
244 return; 246 return 1;
245 if (ioc->config_cmds.smid != smid) 247 if (ioc->config_cmds.smid != smid)
246 return; 248 return 1;
247 ioc->config_cmds.status |= MPT2_CMD_COMPLETE; 249 ioc->config_cmds.status |= MPT2_CMD_COMPLETE;
248 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); 250 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
249 if (mpi_reply) { 251 if (mpi_reply) {
@@ -257,6 +259,7 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
257#endif 259#endif
258 ioc->config_cmds.smid = USHORT_MAX; 260 ioc->config_cmds.smid = USHORT_MAX;
259 complete(&ioc->config_cmds.done); 261 complete(&ioc->config_cmds.done);
262 return 1;
260} 263}
261 264
262/** 265/**
@@ -303,6 +306,9 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
303 retry_count = 0; 306 retry_count = 0;
304 memset(&mem, 0, sizeof(struct config_request)); 307 memset(&mem, 0, sizeof(struct config_request));
305 308
309 mpi_request->VF_ID = 0; /* TODO */
310 mpi_request->VP_ID = 0;
311
306 if (config_page) { 312 if (config_page) {
307 mpi_request->Header.PageVersion = mpi_reply->Header.PageVersion; 313 mpi_request->Header.PageVersion = mpi_reply->Header.PageVersion;
308 mpi_request->Header.PageNumber = mpi_reply->Header.PageNumber; 314 mpi_request->Header.PageNumber = mpi_reply->Header.PageNumber;
@@ -380,7 +386,7 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
380 _config_display_some_debug(ioc, smid, "config_request", NULL); 386 _config_display_some_debug(ioc, smid, "config_request", NULL);
381#endif 387#endif
382 init_completion(&ioc->config_cmds.done); 388 init_completion(&ioc->config_cmds.done);
383 mpt2sas_base_put_smid_default(ioc, smid, config_request->VF_ID); 389 mpt2sas_base_put_smid_default(ioc, smid);
384 timeleft = wait_for_completion_timeout(&ioc->config_cmds.done, 390 timeleft = wait_for_completion_timeout(&ioc->config_cmds.done,
385 timeout*HZ); 391 timeout*HZ);
386 if (!(ioc->config_cmds.status & MPT2_CMD_COMPLETE)) { 392 if (!(ioc->config_cmds.status & MPT2_CMD_COMPLETE)) {
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
index c2a51018910f..57d724633906 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
@@ -3,7 +3,7 @@
3 * controllers 3 * controllers
4 * 4 *
5 * This code is based on drivers/scsi/mpt2sas/mpt2_ctl.c 5 * This code is based on drivers/scsi/mpt2sas/mpt2_ctl.c
6 * Copyright (C) 2007-2008 LSI Corporation 6 * Copyright (C) 2007-2009 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com) 7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
@@ -219,23 +219,25 @@ _ctl_display_some_debug(struct MPT2SAS_ADAPTER *ioc, u16 smid,
219 * mpt2sas_ctl_done - ctl module completion routine 219 * mpt2sas_ctl_done - ctl module completion routine
220 * @ioc: per adapter object 220 * @ioc: per adapter object
221 * @smid: system request message index 221 * @smid: system request message index
222 * @VF_ID: virtual function id 222 * @msix_index: MSIX table index supplied by the OS
223 * @reply: reply message frame(lower 32bit addr) 223 * @reply: reply message frame(lower 32bit addr)
224 * Context: none. 224 * Context: none.
225 * 225 *
226 * The callback handler when using ioc->ctl_cb_idx. 226 * The callback handler when using ioc->ctl_cb_idx.
227 * 227 *
228 * Return nothing. 228 * Return 1 meaning mf should be freed from _base_interrupt
229 * 0 means the mf is freed from this function.
229 */ 230 */
230void 231u8
231mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) 232mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
233 u32 reply)
232{ 234{
233 MPI2DefaultReply_t *mpi_reply; 235 MPI2DefaultReply_t *mpi_reply;
234 236
235 if (ioc->ctl_cmds.status == MPT2_CMD_NOT_USED) 237 if (ioc->ctl_cmds.status == MPT2_CMD_NOT_USED)
236 return; 238 return 1;
237 if (ioc->ctl_cmds.smid != smid) 239 if (ioc->ctl_cmds.smid != smid)
238 return; 240 return 1;
239 ioc->ctl_cmds.status |= MPT2_CMD_COMPLETE; 241 ioc->ctl_cmds.status |= MPT2_CMD_COMPLETE;
240 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); 242 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
241 if (mpi_reply) { 243 if (mpi_reply) {
@@ -247,6 +249,7 @@ mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
247#endif 249#endif
248 ioc->ctl_cmds.status &= ~MPT2_CMD_PENDING; 250 ioc->ctl_cmds.status &= ~MPT2_CMD_PENDING;
249 complete(&ioc->ctl_cmds.done); 251 complete(&ioc->ctl_cmds.done);
252 return 1;
250} 253}
251 254
252/** 255/**
@@ -328,22 +331,25 @@ mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,
328/** 331/**
329 * mpt2sas_ctl_event_callback - firmware event handler (called at ISR time) 332 * mpt2sas_ctl_event_callback - firmware event handler (called at ISR time)
330 * @ioc: per adapter object 333 * @ioc: per adapter object
331 * @VF_ID: virtual function id 334 * @msix_index: MSIX table index supplied by the OS
332 * @reply: reply message frame(lower 32bit addr) 335 * @reply: reply message frame(lower 32bit addr)
333 * Context: interrupt. 336 * Context: interrupt.
334 * 337 *
335 * This function merely adds a new work task into ioc->firmware_event_thread. 338 * This function merely adds a new work task into ioc->firmware_event_thread.
336 * The tasks are worked from _firmware_event_work in user context. 339 * The tasks are worked from _firmware_event_work in user context.
337 * 340 *
338 * Return nothing. 341 * Return 1 meaning mf should be freed from _base_interrupt
342 * 0 means the mf is freed from this function.
339 */ 343 */
340void 344u8
341mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply) 345mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
346 u32 reply)
342{ 347{
343 Mpi2EventNotificationReply_t *mpi_reply; 348 Mpi2EventNotificationReply_t *mpi_reply;
344 349
345 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); 350 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
346 mpt2sas_ctl_add_to_event_log(ioc, mpi_reply); 351 mpt2sas_ctl_add_to_event_log(ioc, mpi_reply);
352 return 1;
347} 353}
348 354
349/** 355/**
@@ -507,7 +513,7 @@ _ctl_set_task_mid(struct MPT2SAS_ADAPTER *ioc, struct mpt2_ioctl_command *karg,
507 513
508 handle = le16_to_cpu(tm_request->DevHandle); 514 handle = le16_to_cpu(tm_request->DevHandle);
509 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 515 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
510 for (i = ioc->request_depth; i && !found; i--) { 516 for (i = ioc->scsiio_depth; i && !found; i--) {
511 scmd = ioc->scsi_lookup[i - 1].scmd; 517 scmd = ioc->scsi_lookup[i - 1].scmd;
512 if (scmd == NULL || scmd->device == NULL || 518 if (scmd == NULL || scmd->device == NULL ||
513 scmd->device->hostdata == NULL) 519 scmd->device->hostdata == NULL)
@@ -614,7 +620,7 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
614 printk(MPT2SAS_INFO_FMT "%s: ioc is operational\n", 620 printk(MPT2SAS_INFO_FMT "%s: ioc is operational\n",
615 ioc->name, __func__); 621 ioc->name, __func__);
616 622
617 smid = mpt2sas_base_get_smid(ioc, ioc->ctl_cb_idx); 623 smid = mpt2sas_base_get_smid_scsiio(ioc, ioc->ctl_cb_idx, NULL);
618 if (!smid) { 624 if (!smid) {
619 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", 625 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
620 ioc->name, __func__); 626 ioc->name, __func__);
@@ -737,7 +743,7 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
737 (u32)mpt2sas_base_get_sense_buffer_dma(ioc, smid); 743 (u32)mpt2sas_base_get_sense_buffer_dma(ioc, smid);
738 priv_sense = mpt2sas_base_get_sense_buffer(ioc, smid); 744 priv_sense = mpt2sas_base_get_sense_buffer(ioc, smid);
739 memset(priv_sense, 0, SCSI_SENSE_BUFFERSIZE); 745 memset(priv_sense, 0, SCSI_SENSE_BUFFERSIZE);
740 mpt2sas_base_put_smid_scsi_io(ioc, smid, 0, 746 mpt2sas_base_put_smid_scsi_io(ioc, smid,
741 le16_to_cpu(mpi_request->FunctionDependent1)); 747 le16_to_cpu(mpi_request->FunctionDependent1));
742 break; 748 break;
743 } 749 }
@@ -759,8 +765,7 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
759 mutex_lock(&ioc->tm_cmds.mutex); 765 mutex_lock(&ioc->tm_cmds.mutex);
760 mpt2sas_scsih_set_tm_flag(ioc, le16_to_cpu( 766 mpt2sas_scsih_set_tm_flag(ioc, le16_to_cpu(
761 tm_request->DevHandle)); 767 tm_request->DevHandle));
762 mpt2sas_base_put_smid_hi_priority(ioc, smid, 768 mpt2sas_base_put_smid_hi_priority(ioc, smid);
763 mpi_request->VF_ID);
764 break; 769 break;
765 } 770 }
766 case MPI2_FUNCTION_SMP_PASSTHROUGH: 771 case MPI2_FUNCTION_SMP_PASSTHROUGH:
@@ -781,7 +786,7 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
781 ioc->ioc_link_reset_in_progress = 1; 786 ioc->ioc_link_reset_in_progress = 1;
782 ioc->ignore_loginfos = 1; 787 ioc->ignore_loginfos = 1;
783 } 788 }
784 mpt2sas_base_put_smid_default(ioc, smid, mpi_request->VF_ID); 789 mpt2sas_base_put_smid_default(ioc, smid);
785 break; 790 break;
786 } 791 }
787 case MPI2_FUNCTION_SAS_IO_UNIT_CONTROL: 792 case MPI2_FUNCTION_SAS_IO_UNIT_CONTROL:
@@ -795,11 +800,11 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
795 ioc->ioc_link_reset_in_progress = 1; 800 ioc->ioc_link_reset_in_progress = 1;
796 ioc->ignore_loginfos = 1; 801 ioc->ignore_loginfos = 1;
797 } 802 }
798 mpt2sas_base_put_smid_default(ioc, smid, mpi_request->VF_ID); 803 mpt2sas_base_put_smid_default(ioc, smid);
799 break; 804 break;
800 } 805 }
801 default: 806 default:
802 mpt2sas_base_put_smid_default(ioc, smid, mpi_request->VF_ID); 807 mpt2sas_base_put_smid_default(ioc, smid);
803 break; 808 break;
804 } 809 }
805 810
@@ -807,6 +812,7 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
807 timeout = MPT2_IOCTL_DEFAULT_TIMEOUT; 812 timeout = MPT2_IOCTL_DEFAULT_TIMEOUT;
808 else 813 else
809 timeout = karg.timeout; 814 timeout = karg.timeout;
815 init_completion(&ioc->ctl_cmds.done);
810 timeleft = wait_for_completion_timeout(&ioc->ctl_cmds.done, 816 timeleft = wait_for_completion_timeout(&ioc->ctl_cmds.done,
811 timeout*HZ); 817 timeout*HZ);
812 if (mpi_request->Function == MPI2_FUNCTION_SCSI_TASK_MGMT) { 818 if (mpi_request->Function == MPI2_FUNCTION_SCSI_TASK_MGMT) {
@@ -1371,6 +1377,8 @@ _ctl_diag_register(void __user *arg, enum block_state state)
1371 mpi_request->Flags = cpu_to_le32(karg.diagnostic_flags); 1377 mpi_request->Flags = cpu_to_le32(karg.diagnostic_flags);
1372 mpi_request->BufferAddress = cpu_to_le64(request_data_dma); 1378 mpi_request->BufferAddress = cpu_to_le64(request_data_dma);
1373 mpi_request->BufferLength = cpu_to_le32(request_data_sz); 1379 mpi_request->BufferLength = cpu_to_le32(request_data_sz);
1380 mpi_request->VF_ID = 0; /* TODO */
1381 mpi_request->VP_ID = 0;
1374 1382
1375 dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: diag_buffer(0x%p), " 1383 dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: diag_buffer(0x%p), "
1376 "dma(0x%llx), sz(%d)\n", ioc->name, __func__, request_data, 1384 "dma(0x%llx), sz(%d)\n", ioc->name, __func__, request_data,
@@ -1380,7 +1388,8 @@ _ctl_diag_register(void __user *arg, enum block_state state)
1380 mpi_request->ProductSpecific[i] = 1388 mpi_request->ProductSpecific[i] =
1381 cpu_to_le32(ioc->product_specific[buffer_type][i]); 1389 cpu_to_le32(ioc->product_specific[buffer_type][i]);
1382 1390
1383 mpt2sas_base_put_smid_default(ioc, smid, mpi_request->VF_ID); 1391 mpt2sas_base_put_smid_default(ioc, smid);
1392 init_completion(&ioc->ctl_cmds.done);
1384 timeleft = wait_for_completion_timeout(&ioc->ctl_cmds.done, 1393 timeleft = wait_for_completion_timeout(&ioc->ctl_cmds.done,
1385 MPT2_IOCTL_DEFAULT_TIMEOUT*HZ); 1394 MPT2_IOCTL_DEFAULT_TIMEOUT*HZ);
1386 1395
@@ -1643,8 +1652,11 @@ _ctl_send_release(struct MPT2SAS_ADAPTER *ioc, u8 buffer_type, u8 *issue_reset)
1643 1652
1644 mpi_request->Function = MPI2_FUNCTION_DIAG_RELEASE; 1653 mpi_request->Function = MPI2_FUNCTION_DIAG_RELEASE;
1645 mpi_request->BufferType = buffer_type; 1654 mpi_request->BufferType = buffer_type;
1655 mpi_request->VF_ID = 0; /* TODO */
1656 mpi_request->VP_ID = 0;
1646 1657
1647 mpt2sas_base_put_smid_default(ioc, smid, mpi_request->VF_ID); 1658 mpt2sas_base_put_smid_default(ioc, smid);
1659 init_completion(&ioc->ctl_cmds.done);
1648 timeleft = wait_for_completion_timeout(&ioc->ctl_cmds.done, 1660 timeleft = wait_for_completion_timeout(&ioc->ctl_cmds.done,
1649 MPT2_IOCTL_DEFAULT_TIMEOUT*HZ); 1661 MPT2_IOCTL_DEFAULT_TIMEOUT*HZ);
1650 1662
@@ -1902,8 +1914,11 @@ _ctl_diag_read_buffer(void __user *arg, enum block_state state)
1902 for (i = 0; i < MPT2_PRODUCT_SPECIFIC_DWORDS; i++) 1914 for (i = 0; i < MPT2_PRODUCT_SPECIFIC_DWORDS; i++)
1903 mpi_request->ProductSpecific[i] = 1915 mpi_request->ProductSpecific[i] =
1904 cpu_to_le32(ioc->product_specific[buffer_type][i]); 1916 cpu_to_le32(ioc->product_specific[buffer_type][i]);
1917 mpi_request->VF_ID = 0; /* TODO */
1918 mpi_request->VP_ID = 0;
1905 1919
1906 mpt2sas_base_put_smid_default(ioc, smid, mpi_request->VF_ID); 1920 mpt2sas_base_put_smid_default(ioc, smid);
1921 init_completion(&ioc->ctl_cmds.done);
1907 timeleft = wait_for_completion_timeout(&ioc->ctl_cmds.done, 1922 timeleft = wait_for_completion_timeout(&ioc->ctl_cmds.done,
1908 MPT2_IOCTL_DEFAULT_TIMEOUT*HZ); 1923 MPT2_IOCTL_DEFAULT_TIMEOUT*HZ);
1909 1924
@@ -2069,6 +2084,7 @@ static long
2069_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 2084_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2070{ 2085{
2071 long ret; 2086 long ret;
2087
2072 lock_kernel(); 2088 lock_kernel();
2073 ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); 2089 ret = _ctl_ioctl_main(file, cmd, (void __user *)arg);
2074 unlock_kernel(); 2090 unlock_kernel();
@@ -2143,6 +2159,7 @@ static long
2143_ctl_ioctl_compat(struct file *file, unsigned cmd, unsigned long arg) 2159_ctl_ioctl_compat(struct file *file, unsigned cmd, unsigned long arg)
2144{ 2160{
2145 long ret; 2161 long ret;
2162
2146 lock_kernel(); 2163 lock_kernel();
2147 if (cmd == MPT2COMMAND32) 2164 if (cmd == MPT2COMMAND32)
2148 ret = _ctl_compat_mpt_command(file, cmd, arg); 2165 ret = _ctl_compat_mpt_command(file, cmd, arg);
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.h b/drivers/scsi/mpt2sas/mpt2sas_ctl.h
index 4da11435533f..211f296dd191 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.h
@@ -3,7 +3,7 @@
3 * controllers 3 * controllers
4 * 4 *
5 * This code is based on drivers/scsi/mpt2sas/mpt2_ctl.h 5 * This code is based on drivers/scsi/mpt2sas/mpt2_ctl.h
6 * Copyright (C) 2007-2008 LSI Corporation 6 * Copyright (C) 2007-2009 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com) 7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt2sas/mpt2sas_debug.h b/drivers/scsi/mpt2sas/mpt2sas_debug.h
index ad325096e842..5308a25cb307 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_debug.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_debug.h
@@ -2,7 +2,7 @@
2 * Logging Support for MPT (Message Passing Technology) based controllers 2 * Logging Support for MPT (Message Passing Technology) based controllers
3 * 3 *
4 * This code is based on drivers/scsi/mpt2sas/mpt2_debug.c 4 * This code is based on drivers/scsi/mpt2sas/mpt2_debug.c
5 * Copyright (C) 2007-2008 LSI Corporation 5 * Copyright (C) 2007-2009 LSI Corporation
6 * (mailto:DL-MPTFusionLinux@lsi.com) 6 * (mailto:DL-MPTFusionLinux@lsi.com)
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 774b34525bba..86ab32d7ab15 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -2,7 +2,7 @@
2 * Scsi Host Layer for MPT (Message Passing Technology) based controllers 2 * Scsi Host Layer for MPT (Message Passing Technology) based controllers
3 * 3 *
4 * This code is based on drivers/scsi/mpt2sas/mpt2_scsih.c 4 * This code is based on drivers/scsi/mpt2sas/mpt2_scsih.c
5 * Copyright (C) 2007-2008 LSI Corporation 5 * Copyright (C) 2007-2009 LSI Corporation
6 * (mailto:DL-MPTFusionLinux@lsi.com) 6 * (mailto:DL-MPTFusionLinux@lsi.com)
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
@@ -79,6 +79,9 @@ static u8 transport_cb_idx = -1;
79static u8 config_cb_idx = -1; 79static u8 config_cb_idx = -1;
80static int mpt_ids; 80static int mpt_ids;
81 81
82static u8 tm_tr_cb_idx = -1 ;
83static u8 tm_sas_control_cb_idx = -1;
84
82/* command line options */ 85/* command line options */
83static u32 logging_level; 86static u32 logging_level;
84MODULE_PARM_DESC(logging_level, " bits for enabling additional logging info " 87MODULE_PARM_DESC(logging_level, " bits for enabling additional logging info "
@@ -109,6 +112,7 @@ struct sense_info {
109 * @work: work object (ioc->fault_reset_work_q) 112 * @work: work object (ioc->fault_reset_work_q)
110 * @ioc: per adapter object 113 * @ioc: per adapter object
111 * @VF_ID: virtual function id 114 * @VF_ID: virtual function id
115 * @VP_ID: virtual port id
112 * @host_reset_handling: handling events during host reset 116 * @host_reset_handling: handling events during host reset
113 * @ignore: flag meaning this event has been marked to ignore 117 * @ignore: flag meaning this event has been marked to ignore
114 * @event: firmware event MPI2_EVENT_XXX defined in mpt2_ioc.h 118 * @event: firmware event MPI2_EVENT_XXX defined in mpt2_ioc.h
@@ -121,6 +125,7 @@ struct fw_event_work {
121 struct work_struct work; 125 struct work_struct work;
122 struct MPT2SAS_ADAPTER *ioc; 126 struct MPT2SAS_ADAPTER *ioc;
123 u8 VF_ID; 127 u8 VF_ID;
128 u8 VP_ID;
124 u8 host_reset_handling; 129 u8 host_reset_handling;
125 u8 ignore; 130 u8 ignore;
126 u16 event; 131 u16 event;
@@ -138,8 +143,10 @@ struct fw_event_work {
138 * @lun: lun number 143 * @lun: lun number
139 * @cdb_length: cdb length 144 * @cdb_length: cdb length
140 * @cdb: cdb contents 145 * @cdb: cdb contents
141 * @valid_reply: flag set for reply message
142 * @timeout: timeout for this command 146 * @timeout: timeout for this command
147 * @VF_ID: virtual function id
148 * @VP_ID: virtual port id
149 * @valid_reply: flag set for reply message
143 * @sense_length: sense length 150 * @sense_length: sense length
144 * @ioc_status: ioc status 151 * @ioc_status: ioc status
145 * @scsi_state: scsi state 152 * @scsi_state: scsi state
@@ -161,6 +168,8 @@ struct _scsi_io_transfer {
161 u8 cdb_length; 168 u8 cdb_length;
162 u8 cdb[32]; 169 u8 cdb[32];
163 u8 timeout; 170 u8 timeout;
171 u8 VF_ID;
172 u8 VP_ID;
164 u8 valid_reply; 173 u8 valid_reply;
165 /* the following bits are only valid when 'valid_reply = 1' */ 174 /* the following bits are only valid when 'valid_reply = 1' */
166 u32 sense_length; 175 u32 sense_length;
@@ -756,66 +765,16 @@ _scsih_is_end_device(u32 device_info)
756} 765}
757 766
758/** 767/**
759 * _scsih_scsi_lookup_get - returns scmd entry 768 * mptscsih_get_scsi_lookup - returns scmd entry
760 * @ioc: per adapter object 769 * @ioc: per adapter object
761 * @smid: system request message index 770 * @smid: system request message index
762 * Context: This function will acquire ioc->scsi_lookup_lock.
763 * 771 *
764 * Returns the smid stored scmd pointer. 772 * Returns the smid stored scmd pointer.
765 */ 773 */
766static struct scsi_cmnd * 774static struct scsi_cmnd *
767_scsih_scsi_lookup_get(struct MPT2SAS_ADAPTER *ioc, u16 smid) 775_scsih_scsi_lookup_get(struct MPT2SAS_ADAPTER *ioc, u16 smid)
768{ 776{
769 unsigned long flags; 777 return ioc->scsi_lookup[smid - 1].scmd;
770 struct scsi_cmnd *scmd;
771
772 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
773 scmd = ioc->scsi_lookup[smid - 1].scmd;
774 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
775 return scmd;
776}
777
778/**
779 * mptscsih_getclear_scsi_lookup - returns scmd entry
780 * @ioc: per adapter object
781 * @smid: system request message index
782 * Context: This function will acquire ioc->scsi_lookup_lock.
783 *
784 * Returns the smid stored scmd pointer, as well as clearing the scmd pointer.
785 */
786static struct scsi_cmnd *
787_scsih_scsi_lookup_getclear(struct MPT2SAS_ADAPTER *ioc, u16 smid)
788{
789 unsigned long flags;
790 struct scsi_cmnd *scmd;
791
792 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
793 scmd = ioc->scsi_lookup[smid - 1].scmd;
794 ioc->scsi_lookup[smid - 1].scmd = NULL;
795 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
796 return scmd;
797}
798
799/**
800 * _scsih_scsi_lookup_set - updates scmd entry in lookup
801 * @ioc: per adapter object
802 * @smid: system request message index
803 * @scmd: pointer to scsi command object
804 * Context: This function will acquire ioc->scsi_lookup_lock.
805 *
806 * This will save scmd pointer in the scsi_lookup array.
807 *
808 * Return nothing.
809 */
810static void
811_scsih_scsi_lookup_set(struct MPT2SAS_ADAPTER *ioc, u16 smid,
812 struct scsi_cmnd *scmd)
813{
814 unsigned long flags;
815
816 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
817 ioc->scsi_lookup[smid - 1].scmd = scmd;
818 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
819} 778}
820 779
821/** 780/**
@@ -838,9 +797,9 @@ _scsih_scsi_lookup_find_by_scmd(struct MPT2SAS_ADAPTER *ioc, struct scsi_cmnd
838 797
839 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 798 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
840 smid = 0; 799 smid = 0;
841 for (i = 0; i < ioc->request_depth; i++) { 800 for (i = 0; i < ioc->scsiio_depth; i++) {
842 if (ioc->scsi_lookup[i].scmd == scmd) { 801 if (ioc->scsi_lookup[i].scmd == scmd) {
843 smid = i + 1; 802 smid = ioc->scsi_lookup[i].smid;
844 goto out; 803 goto out;
845 } 804 }
846 } 805 }
@@ -869,7 +828,7 @@ _scsih_scsi_lookup_find_by_target(struct MPT2SAS_ADAPTER *ioc, int id,
869 828
870 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 829 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
871 found = 0; 830 found = 0;
872 for (i = 0 ; i < ioc->request_depth; i++) { 831 for (i = 0 ; i < ioc->scsiio_depth; i++) {
873 if (ioc->scsi_lookup[i].scmd && 832 if (ioc->scsi_lookup[i].scmd &&
874 (ioc->scsi_lookup[i].scmd->device->id == id && 833 (ioc->scsi_lookup[i].scmd->device->id == id &&
875 ioc->scsi_lookup[i].scmd->device->channel == channel)) { 834 ioc->scsi_lookup[i].scmd->device->channel == channel)) {
@@ -903,7 +862,7 @@ _scsih_scsi_lookup_find_by_lun(struct MPT2SAS_ADAPTER *ioc, int id,
903 862
904 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 863 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
905 found = 0; 864 found = 0;
906 for (i = 0 ; i < ioc->request_depth; i++) { 865 for (i = 0 ; i < ioc->scsiio_depth; i++) {
907 if (ioc->scsi_lookup[i].scmd && 866 if (ioc->scsi_lookup[i].scmd &&
908 (ioc->scsi_lookup[i].scmd->device->id == id && 867 (ioc->scsi_lookup[i].scmd->device->id == id &&
909 ioc->scsi_lookup[i].scmd->device->channel == channel && 868 ioc->scsi_lookup[i].scmd->device->channel == channel &&
@@ -1113,7 +1072,7 @@ _scsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
1113} 1072}
1114 1073
1115/** 1074/**
1116 * _scsih_change_queue_depth - changing device queue tag type 1075 * _scsih_change_queue_type - changing device queue tag type
1117 * @sdev: scsi device struct 1076 * @sdev: scsi device struct
1118 * @tag_type: requested tag type 1077 * @tag_type: requested tag type
1119 * 1078 *
@@ -1679,23 +1638,24 @@ _scsih_response_code(struct MPT2SAS_ADAPTER *ioc, u8 response_code)
1679 * _scsih_tm_done - tm completion routine 1638 * _scsih_tm_done - tm completion routine
1680 * @ioc: per adapter object 1639 * @ioc: per adapter object
1681 * @smid: system request message index 1640 * @smid: system request message index
1682 * @VF_ID: virtual function id 1641 * @msix_index: MSIX table index supplied by the OS
1683 * @reply: reply message frame(lower 32bit addr) 1642 * @reply: reply message frame(lower 32bit addr)
1684 * Context: none. 1643 * Context: none.
1685 * 1644 *
1686 * The callback handler when using scsih_issue_tm. 1645 * The callback handler when using scsih_issue_tm.
1687 * 1646 *
1688 * Return nothing. 1647 * Return 1 meaning mf should be freed from _base_interrupt
1648 * 0 means the mf is freed from this function.
1689 */ 1649 */
1690static void 1650static u8
1691_scsih_tm_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) 1651_scsih_tm_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
1692{ 1652{
1693 MPI2DefaultReply_t *mpi_reply; 1653 MPI2DefaultReply_t *mpi_reply;
1694 1654
1695 if (ioc->tm_cmds.status == MPT2_CMD_NOT_USED) 1655 if (ioc->tm_cmds.status == MPT2_CMD_NOT_USED)
1696 return; 1656 return 1;
1697 if (ioc->tm_cmds.smid != smid) 1657 if (ioc->tm_cmds.smid != smid)
1698 return; 1658 return 1;
1699 ioc->tm_cmds.status |= MPT2_CMD_COMPLETE; 1659 ioc->tm_cmds.status |= MPT2_CMD_COMPLETE;
1700 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); 1660 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
1701 if (mpi_reply) { 1661 if (mpi_reply) {
@@ -1704,6 +1664,7 @@ _scsih_tm_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
1704 } 1664 }
1705 ioc->tm_cmds.status &= ~MPT2_CMD_PENDING; 1665 ioc->tm_cmds.status &= ~MPT2_CMD_PENDING;
1706 complete(&ioc->tm_cmds.done); 1666 complete(&ioc->tm_cmds.done);
1667 return 1;
1707} 1668}
1708 1669
1709/** 1670/**
@@ -1790,7 +1751,6 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
1790 u16 smid = 0; 1751 u16 smid = 0;
1791 u32 ioc_state; 1752 u32 ioc_state;
1792 unsigned long timeleft; 1753 unsigned long timeleft;
1793 u8 VF_ID = 0;
1794 1754
1795 if (ioc->tm_cmds.status != MPT2_CMD_NOT_USED) { 1755 if (ioc->tm_cmds.status != MPT2_CMD_NOT_USED) {
1796 printk(MPT2SAS_INFO_FMT "%s: tm_cmd busy!!!\n", 1756 printk(MPT2SAS_INFO_FMT "%s: tm_cmd busy!!!\n",
@@ -1817,7 +1777,7 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
1817 goto issue_host_reset; 1777 goto issue_host_reset;
1818 } 1778 }
1819 1779
1820 smid = mpt2sas_base_get_smid(ioc, ioc->tm_cb_idx); 1780 smid = mpt2sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx);
1821 if (!smid) { 1781 if (!smid) {
1822 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", 1782 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
1823 ioc->name, __func__); 1783 ioc->name, __func__);
@@ -1825,7 +1785,8 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
1825 } 1785 }
1826 1786
1827 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "sending tm: handle(0x%04x)," 1787 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "sending tm: handle(0x%04x),"
1828 " task_type(0x%02x), smid(%d)\n", ioc->name, handle, type, smid)); 1788 " task_type(0x%02x), smid(%d)\n", ioc->name, handle, type,
1789 smid_task));
1829 ioc->tm_cmds.status = MPT2_CMD_PENDING; 1790 ioc->tm_cmds.status = MPT2_CMD_PENDING;
1830 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); 1791 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid);
1831 ioc->tm_cmds.smid = smid; 1792 ioc->tm_cmds.smid = smid;
@@ -1834,10 +1795,12 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
1834 mpi_request->DevHandle = cpu_to_le16(handle); 1795 mpi_request->DevHandle = cpu_to_le16(handle);
1835 mpi_request->TaskType = type; 1796 mpi_request->TaskType = type;
1836 mpi_request->TaskMID = cpu_to_le16(smid_task); 1797 mpi_request->TaskMID = cpu_to_le16(smid_task);
1798 mpi_request->VP_ID = 0; /* TODO */
1799 mpi_request->VF_ID = 0;
1837 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN); 1800 int_to_scsilun(lun, (struct scsi_lun *)mpi_request->LUN);
1838 mpt2sas_scsih_set_tm_flag(ioc, handle); 1801 mpt2sas_scsih_set_tm_flag(ioc, handle);
1839 init_completion(&ioc->tm_cmds.done); 1802 init_completion(&ioc->tm_cmds.done);
1840 mpt2sas_base_put_smid_hi_priority(ioc, smid, VF_ID); 1803 mpt2sas_base_put_smid_hi_priority(ioc, smid);
1841 timeleft = wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ); 1804 timeleft = wait_for_completion_timeout(&ioc->tm_cmds.done, timeout*HZ);
1842 mpt2sas_scsih_clear_tm_flag(ioc, handle); 1805 mpt2sas_scsih_clear_tm_flag(ioc, handle);
1843 if (!(ioc->tm_cmds.status & MPT2_CMD_COMPLETE)) { 1806 if (!(ioc->tm_cmds.status & MPT2_CMD_COMPLETE)) {
@@ -2075,7 +2038,7 @@ _scsih_target_reset(struct scsi_cmnd *scmd)
2075} 2038}
2076 2039
2077/** 2040/**
2078 * _scsih_abort - eh threads main host reset routine 2041 * _scsih_host_reset - eh threads main host reset routine
2079 * @sdev: scsi device struct 2042 * @sdev: scsi device struct
2080 * 2043 *
2081 * Returns SUCCESS if command aborted else FAILED 2044 * Returns SUCCESS if command aborted else FAILED
@@ -2354,6 +2317,231 @@ _scsih_block_io_to_children_attached_directly(struct MPT2SAS_ADAPTER *ioc,
2354} 2317}
2355 2318
2356/** 2319/**
2320 * _scsih_tm_tr_send - send task management request
2321 * @ioc: per adapter object
2322 * @handle: device handle
2323 * Context: interrupt time.
2324 *
2325 * This code is to initiate the device removal handshake protocal
2326 * with controller firmware. This function will issue target reset
2327 * using high priority request queue. It will send a sas iounit
2328 * controll request (MPI2_SAS_OP_REMOVE_DEVICE) from this completion.
2329 *
2330 * This is designed to send muliple task management request at the same
2331 * time to the fifo. If the fifo is full, we will append the request,
2332 * and process it in a future completion.
2333 */
2334static void
2335_scsih_tm_tr_send(struct MPT2SAS_ADAPTER *ioc, u16 handle)
2336{
2337 Mpi2SCSITaskManagementRequest_t *mpi_request;
2338 struct MPT2SAS_TARGET *sas_target_priv_data;
2339 u16 smid;
2340 struct _sas_device *sas_device;
2341 unsigned long flags;
2342 struct _tr_list *delayed_tr;
2343
2344 if (ioc->shost_recovery) {
2345 printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n",
2346 __func__, ioc->name);
2347 return;
2348 }
2349
2350 spin_lock_irqsave(&ioc->sas_device_lock, flags);
2351 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
2352 if (!sas_device) {
2353 spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
2354 printk(MPT2SAS_ERR_FMT "%s: failed finding sas_device\n",
2355 ioc->name, __func__);
2356 return;
2357 }
2358 spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
2359
2360 /* skip is hidden raid component */
2361 if (sas_device->hidden_raid_component)
2362 return;
2363
2364 smid = mpt2sas_base_get_smid_hpr(ioc, ioc->tm_tr_cb_idx);
2365 if (!smid) {
2366 delayed_tr = kzalloc(sizeof(*delayed_tr), GFP_ATOMIC);
2367 if (!delayed_tr)
2368 return;
2369 INIT_LIST_HEAD(&delayed_tr->list);
2370 delayed_tr->handle = handle;
2371 delayed_tr->state = MPT2SAS_REQ_SAS_CNTRL;
2372 list_add_tail(&delayed_tr->list,
2373 &ioc->delayed_tr_list);
2374 if (sas_device->starget)
2375 dewtprintk(ioc, starget_printk(KERN_INFO,
2376 sas_device->starget, "DELAYED:tr:handle(0x%04x), "
2377 "(open)\n", sas_device->handle));
2378 return;
2379 }
2380
2381 if (sas_device->starget && sas_device->starget->hostdata) {
2382 sas_target_priv_data = sas_device->starget->hostdata;
2383 sas_target_priv_data->tm_busy = 1;
2384 dewtprintk(ioc, starget_printk(KERN_INFO, sas_device->starget,
2385 "tr:handle(0x%04x), (open)\n", sas_device->handle));
2386 }
2387
2388 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid);
2389 memset(mpi_request, 0, sizeof(Mpi2SCSITaskManagementRequest_t));
2390 mpi_request->Function = MPI2_FUNCTION_SCSI_TASK_MGMT;
2391 mpi_request->DevHandle = cpu_to_le16(handle);
2392 mpi_request->TaskType = MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET;
2393 sas_device->state |= MPTSAS_STATE_TR_SEND;
2394 sas_device->state |= MPT2SAS_REQ_SAS_CNTRL;
2395 mpt2sas_base_put_smid_hi_priority(ioc, smid);
2396}
2397
2398
2399
2400/**
2401 * _scsih_sas_control_complete - completion routine
2402 * @ioc: per adapter object
2403 * @smid: system request message index
2404 * @msix_index: MSIX table index supplied by the OS
2405 * @reply: reply message frame(lower 32bit addr)
2406 * Context: interrupt time.
2407 *
2408 * This is the sas iounit controll completion routine.
2409 * This code is part of the code to initiate the device removal
2410 * handshake protocal with controller firmware.
2411 *
2412 * Return 1 meaning mf should be freed from _base_interrupt
2413 * 0 means the mf is freed from this function.
2414 */
2415static u8
2416_scsih_sas_control_complete(struct MPT2SAS_ADAPTER *ioc, u16 smid,
2417 u8 msix_index, u32 reply)
2418{
2419 unsigned long flags;
2420 u16 handle;
2421 struct _sas_device *sas_device;
2422 Mpi2SasIoUnitControlReply_t *mpi_reply =
2423 mpt2sas_base_get_reply_virt_addr(ioc, reply);
2424
2425 handle = le16_to_cpu(mpi_reply->DevHandle);
2426
2427 spin_lock_irqsave(&ioc->sas_device_lock, flags);
2428 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
2429 if (!sas_device) {
2430 spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
2431 printk(MPT2SAS_ERR_FMT "%s: failed finding sas_device\n",
2432 ioc->name, __func__);
2433 return 1;
2434 }
2435 sas_device->state |= MPTSAS_STATE_CNTRL_COMPLETE;
2436 spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
2437
2438 if (sas_device->starget)
2439 dewtprintk(ioc, starget_printk(KERN_INFO, sas_device->starget,
2440 "sc_complete:handle(0x%04x), "
2441 "ioc_status(0x%04x), loginfo(0x%08x)\n",
2442 handle, le16_to_cpu(mpi_reply->IOCStatus),
2443 le32_to_cpu(mpi_reply->IOCLogInfo)));
2444 return 1;
2445}
2446
2447/**
2448 * _scsih_tm_tr_complete -
2449 * @ioc: per adapter object
2450 * @smid: system request message index
2451 * @msix_index: MSIX table index supplied by the OS
2452 * @reply: reply message frame(lower 32bit addr)
2453 * Context: interrupt time.
2454 *
2455 * This is the target reset completion routine.
2456 * This code is part of the code to initiate the device removal
2457 * handshake protocal with controller firmware.
2458 * It will send a sas iounit controll request (MPI2_SAS_OP_REMOVE_DEVICE)
2459 *
2460 * Return 1 meaning mf should be freed from _base_interrupt
2461 * 0 means the mf is freed from this function.
2462 */
2463static u8
2464_scsih_tm_tr_complete(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
2465 u32 reply)
2466{
2467 unsigned long flags;
2468 u16 handle;
2469 struct _sas_device *sas_device;
2470 Mpi2SCSITaskManagementReply_t *mpi_reply =
2471 mpt2sas_base_get_reply_virt_addr(ioc, reply);
2472 Mpi2SasIoUnitControlRequest_t *mpi_request;
2473 u16 smid_sas_ctrl;
2474 struct MPT2SAS_TARGET *sas_target_priv_data;
2475 struct _tr_list *delayed_tr;
2476 u8 rc;
2477
2478 handle = le16_to_cpu(mpi_reply->DevHandle);
2479 spin_lock_irqsave(&ioc->sas_device_lock, flags);
2480 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
2481 if (!sas_device) {
2482 spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
2483 printk(MPT2SAS_ERR_FMT "%s: failed finding sas_device\n",
2484 ioc->name, __func__);
2485 return 1;
2486 }
2487 sas_device->state |= MPTSAS_STATE_TR_COMPLETE;
2488 spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
2489
2490 if (sas_device->starget)
2491 dewtprintk(ioc, starget_printk(KERN_INFO, sas_device->starget,
2492 "tr_complete:handle(0x%04x), (%s) ioc_status(0x%04x), "
2493 "loginfo(0x%08x), completed(%d)\n",
2494 sas_device->handle, (sas_device->state &
2495 MPT2SAS_REQ_SAS_CNTRL) ? "open" : "active",
2496 le16_to_cpu(mpi_reply->IOCStatus),
2497 le32_to_cpu(mpi_reply->IOCLogInfo),
2498 le32_to_cpu(mpi_reply->TerminationCount)));
2499
2500 if (sas_device->starget && sas_device->starget->hostdata) {
2501 sas_target_priv_data = sas_device->starget->hostdata;
2502 sas_target_priv_data->tm_busy = 0;
2503 }
2504
2505 if (!list_empty(&ioc->delayed_tr_list)) {
2506 delayed_tr = list_entry(ioc->delayed_tr_list.next,
2507 struct _tr_list, list);
2508 mpt2sas_base_free_smid(ioc, smid);
2509 if (delayed_tr->state & MPT2SAS_REQ_SAS_CNTRL)
2510 _scsih_tm_tr_send(ioc, delayed_tr->handle);
2511 list_del(&delayed_tr->list);
2512 kfree(delayed_tr);
2513 rc = 0; /* tells base_interrupt not to free mf */
2514 } else
2515 rc = 1;
2516
2517
2518 if (!(sas_device->state & MPT2SAS_REQ_SAS_CNTRL))
2519 return rc;
2520
2521 if (ioc->shost_recovery) {
2522 printk(MPT2SAS_INFO_FMT "%s: host reset in progress!\n",
2523 __func__, ioc->name);
2524 return rc;
2525 }
2526
2527 smid_sas_ctrl = mpt2sas_base_get_smid(ioc, ioc->tm_sas_control_cb_idx);
2528 if (!smid_sas_ctrl) {
2529 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
2530 ioc->name, __func__);
2531 return rc;
2532 }
2533
2534 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid_sas_ctrl);
2535 memset(mpi_request, 0, sizeof(Mpi2SasIoUnitControlRequest_t));
2536 mpi_request->Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL;
2537 mpi_request->Operation = MPI2_SAS_OP_REMOVE_DEVICE;
2538 mpi_request->DevHandle = mpi_reply->DevHandle;
2539 sas_device->state |= MPTSAS_STATE_CNTRL_SEND;
2540 mpt2sas_base_put_smid_default(ioc, smid_sas_ctrl);
2541 return rc;
2542}
2543
2544/**
2357 * _scsih_check_topo_delete_events - sanity check on topo events 2545 * _scsih_check_topo_delete_events - sanity check on topo events
2358 * @ioc: per adapter object 2546 * @ioc: per adapter object
2359 * @event_data: the event data payload 2547 * @event_data: the event data payload
@@ -2375,6 +2563,21 @@ _scsih_check_topo_delete_events(struct MPT2SAS_ADAPTER *ioc,
2375 u16 expander_handle; 2563 u16 expander_handle;
2376 struct _sas_node *sas_expander; 2564 struct _sas_node *sas_expander;
2377 unsigned long flags; 2565 unsigned long flags;
2566 int i, reason_code;
2567 u16 handle;
2568
2569 for (i = 0 ; i < event_data->NumEntries; i++) {
2570 if (event_data->PHY[i].PhyStatus &
2571 MPI2_EVENT_SAS_TOPO_PHYSTATUS_VACANT)
2572 continue;
2573 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle);
2574 if (!handle)
2575 continue;
2576 reason_code = event_data->PHY[i].PhyStatus &
2577 MPI2_EVENT_SAS_TOPO_RC_MASK;
2578 if (reason_code == MPI2_EVENT_SAS_TOPO_RC_TARG_NOT_RESPONDING)
2579 _scsih_tm_tr_send(ioc, handle);
2580 }
2378 2581
2379 expander_handle = le16_to_cpu(event_data->ExpanderDevHandle); 2582 expander_handle = le16_to_cpu(event_data->ExpanderDevHandle);
2380 if (expander_handle < ioc->sas_hba.num_phys) { 2583 if (expander_handle < ioc->sas_hba.num_phys) {
@@ -2433,8 +2636,8 @@ _scsih_flush_running_cmds(struct MPT2SAS_ADAPTER *ioc)
2433 u16 smid; 2636 u16 smid;
2434 u16 count = 0; 2637 u16 count = 0;
2435 2638
2436 for (smid = 1; smid <= ioc->request_depth; smid++) { 2639 for (smid = 1; smid <= ioc->scsiio_depth; smid++) {
2437 scmd = _scsih_scsi_lookup_getclear(ioc, smid); 2640 scmd = _scsih_scsi_lookup_get(ioc, smid);
2438 if (!scmd) 2641 if (!scmd)
2439 continue; 2642 continue;
2440 count++; 2643 count++;
@@ -2616,7 +2819,7 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
2616 if ((sas_device_priv_data->flags & MPT_DEVICE_TLR_ON)) 2819 if ((sas_device_priv_data->flags & MPT_DEVICE_TLR_ON))
2617 mpi_control |= MPI2_SCSIIO_CONTROL_TLR_ON; 2820 mpi_control |= MPI2_SCSIIO_CONTROL_TLR_ON;
2618 2821
2619 smid = mpt2sas_base_get_smid(ioc, ioc->scsi_io_cb_idx); 2822 smid = mpt2sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd);
2620 if (!smid) { 2823 if (!smid) {
2621 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", 2824 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
2622 ioc->name, __func__); 2825 ioc->name, __func__);
@@ -2643,7 +2846,8 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
2643 mpi_request->SGLOffset0 = offsetof(Mpi2SCSIIORequest_t, SGL) / 4; 2846 mpi_request->SGLOffset0 = offsetof(Mpi2SCSIIORequest_t, SGL) / 4;
2644 mpi_request->SGLFlags = cpu_to_le16(MPI2_SCSIIO_SGLFLAGS_TYPE_MPI + 2847 mpi_request->SGLFlags = cpu_to_le16(MPI2_SCSIIO_SGLFLAGS_TYPE_MPI +
2645 MPI2_SCSIIO_SGLFLAGS_SYSTEM_ADDR); 2848 MPI2_SCSIIO_SGLFLAGS_SYSTEM_ADDR);
2646 2849 mpi_request->VF_ID = 0; /* TODO */
2850 mpi_request->VP_ID = 0;
2647 int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *) 2851 int_to_scsilun(sas_device_priv_data->lun, (struct scsi_lun *)
2648 mpi_request->LUN); 2852 mpi_request->LUN);
2649 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len); 2853 memcpy(mpi_request->CDB.CDB32, scmd->cmnd, scmd->cmd_len);
@@ -2657,8 +2861,7 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
2657 } 2861 }
2658 } 2862 }
2659 2863
2660 _scsih_scsi_lookup_set(ioc, smid, scmd); 2864 mpt2sas_base_put_smid_scsi_io(ioc, smid,
2661 mpt2sas_base_put_smid_scsi_io(ioc, smid, 0,
2662 sas_device_priv_data->sas_target->handle); 2865 sas_device_priv_data->sas_target->handle);
2663 return 0; 2866 return 0;
2664 2867
@@ -2954,15 +3157,16 @@ _scsih_smart_predicted_fault(struct MPT2SAS_ADAPTER *ioc, u16 handle)
2954 * _scsih_io_done - scsi request callback 3157 * _scsih_io_done - scsi request callback
2955 * @ioc: per adapter object 3158 * @ioc: per adapter object
2956 * @smid: system request message index 3159 * @smid: system request message index
2957 * @VF_ID: virtual function id 3160 * @msix_index: MSIX table index supplied by the OS
2958 * @reply: reply message frame(lower 32bit addr) 3161 * @reply: reply message frame(lower 32bit addr)
2959 * 3162 *
2960 * Callback handler when using scsih_qcmd. 3163 * Callback handler when using _scsih_qcmd.
2961 * 3164 *
2962 * Return nothing. 3165 * Return 1 meaning mf should be freed from _base_interrupt
3166 * 0 means the mf is freed from this function.
2963 */ 3167 */
2964static void 3168static u8
2965_scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) 3169_scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
2966{ 3170{
2967 Mpi2SCSIIORequest_t *mpi_request; 3171 Mpi2SCSIIORequest_t *mpi_request;
2968 Mpi2SCSIIOReply_t *mpi_reply; 3172 Mpi2SCSIIOReply_t *mpi_reply;
@@ -2976,9 +3180,9 @@ _scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
2976 u32 response_code; 3180 u32 response_code;
2977 3181
2978 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); 3182 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
2979 scmd = _scsih_scsi_lookup_getclear(ioc, smid); 3183 scmd = _scsih_scsi_lookup_get(ioc, smid);
2980 if (scmd == NULL) 3184 if (scmd == NULL)
2981 return; 3185 return 1;
2982 3186
2983 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); 3187 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid);
2984 3188
@@ -3134,6 +3338,7 @@ _scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
3134 out: 3338 out:
3135 scsi_dma_unmap(scmd); 3339 scsi_dma_unmap(scmd);
3136 scmd->scsi_done(scmd); 3340 scmd->scsi_done(scmd);
3341 return 1;
3137} 3342}
3138 3343
3139/** 3344/**
@@ -3398,9 +3603,8 @@ _scsih_expander_add(struct MPT2SAS_ADAPTER *ioc, u16 handle)
3398 } 3603 }
3399 } 3604 }
3400 3605
3401 sas_address = le64_to_cpu(expander_pg0.SASAddress);
3402
3403 spin_lock_irqsave(&ioc->sas_node_lock, flags); 3606 spin_lock_irqsave(&ioc->sas_node_lock, flags);
3607 sas_address = le64_to_cpu(expander_pg0.SASAddress);
3404 sas_expander = mpt2sas_scsih_expander_find_by_sas_address(ioc, 3608 sas_expander = mpt2sas_scsih_expander_find_by_sas_address(ioc,
3405 sas_address); 3609 sas_address);
3406 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); 3610 spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
@@ -3666,6 +3870,12 @@ _scsih_remove_device(struct MPT2SAS_ADAPTER *ioc, u16 handle)
3666 if (ioc->remove_host) 3870 if (ioc->remove_host)
3667 goto out; 3871 goto out;
3668 3872
3873 if ((sas_device->state & MPTSAS_STATE_TR_COMPLETE)) {
3874 dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "\tskip "
3875 "target_reset handle(0x%04x)\n", ioc->name, handle));
3876 goto skip_tr;
3877 }
3878
3669 /* Target Reset to flush out all the outstanding IO */ 3879 /* Target Reset to flush out all the outstanding IO */
3670 device_handle = (sas_device->hidden_raid_component) ? 3880 device_handle = (sas_device->hidden_raid_component) ?
3671 sas_device->volume_handle : handle; 3881 sas_device->volume_handle : handle;
@@ -3682,6 +3892,13 @@ _scsih_remove_device(struct MPT2SAS_ADAPTER *ioc, u16 handle)
3682 if (ioc->shost_recovery) 3892 if (ioc->shost_recovery)
3683 goto out; 3893 goto out;
3684 } 3894 }
3895 skip_tr:
3896
3897 if ((sas_device->state & MPTSAS_STATE_CNTRL_COMPLETE)) {
3898 dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "\tskip "
3899 "sas_cntrl handle(0x%04x)\n", ioc->name, handle));
3900 goto out;
3901 }
3685 3902
3686 /* SAS_IO_UNIT_CNTR - send REMOVE_DEVICE */ 3903 /* SAS_IO_UNIT_CNTR - send REMOVE_DEVICE */
3687 dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "sas_iounit: handle" 3904 dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "sas_iounit: handle"
@@ -3690,7 +3907,8 @@ _scsih_remove_device(struct MPT2SAS_ADAPTER *ioc, u16 handle)
3690 mpi_request.Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL; 3907 mpi_request.Function = MPI2_FUNCTION_SAS_IO_UNIT_CONTROL;
3691 mpi_request.Operation = MPI2_SAS_OP_REMOVE_DEVICE; 3908 mpi_request.Operation = MPI2_SAS_OP_REMOVE_DEVICE;
3692 mpi_request.DevHandle = handle; 3909 mpi_request.DevHandle = handle;
3693 mpi_request.VF_ID = 0; 3910 mpi_request.VF_ID = 0; /* TODO */
3911 mpi_request.VP_ID = 0;
3694 if ((mpt2sas_base_sas_iounit_control(ioc, &mpi_reply, 3912 if ((mpt2sas_base_sas_iounit_control(ioc, &mpi_reply,
3695 &mpi_request)) != 0) { 3913 &mpi_request)) != 0) {
3696 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", 3914 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
@@ -3800,15 +4018,12 @@ _scsih_sas_topology_change_event_debug(struct MPT2SAS_ADAPTER *ioc,
3800/** 4018/**
3801 * _scsih_sas_topology_change_event - handle topology changes 4019 * _scsih_sas_topology_change_event - handle topology changes
3802 * @ioc: per adapter object 4020 * @ioc: per adapter object
3803 * @VF_ID: 4021 * @fw_event: The fw_event_work object
3804 * @event_data: event data payload
3805 * fw_event:
3806 * Context: user. 4022 * Context: user.
3807 * 4023 *
3808 */ 4024 */
3809static void 4025static void
3810_scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, 4026_scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc,
3811 Mpi2EventDataSasTopologyChangeList_t *event_data,
3812 struct fw_event_work *fw_event) 4027 struct fw_event_work *fw_event)
3813{ 4028{
3814 int i; 4029 int i;
@@ -3818,6 +4033,7 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
3818 struct _sas_node *sas_expander; 4033 struct _sas_node *sas_expander;
3819 unsigned long flags; 4034 unsigned long flags;
3820 u8 link_rate_; 4035 u8 link_rate_;
4036 Mpi2EventDataSasTopologyChangeList_t *event_data = fw_event->event_data;
3821 4037
3822#ifdef CONFIG_SCSI_MPT2SAS_LOGGING 4038#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
3823 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) 4039 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
@@ -3851,15 +4067,16 @@ _scsih_sas_topology_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
3851 } 4067 }
3852 if (ioc->shost_recovery) 4068 if (ioc->shost_recovery)
3853 return; 4069 return;
3854 if (event_data->PHY[i].PhyStatus & 4070 phy_number = event_data->StartPhyNum + i;
3855 MPI2_EVENT_SAS_TOPO_PHYSTATUS_VACANT) 4071 reason_code = event_data->PHY[i].PhyStatus &
4072 MPI2_EVENT_SAS_TOPO_RC_MASK;
4073 if ((event_data->PHY[i].PhyStatus &
4074 MPI2_EVENT_SAS_TOPO_PHYSTATUS_VACANT) && (reason_code !=
4075 MPI2_EVENT_SAS_TOPO_RC_TARG_NOT_RESPONDING))
3856 continue; 4076 continue;
3857 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle); 4077 handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle);
3858 if (!handle) 4078 if (!handle)
3859 continue; 4079 continue;
3860 phy_number = event_data->StartPhyNum + i;
3861 reason_code = event_data->PHY[i].PhyStatus &
3862 MPI2_EVENT_SAS_TOPO_RC_MASK;
3863 link_rate_ = event_data->PHY[i].LinkRate >> 4; 4080 link_rate_ = event_data->PHY[i].LinkRate >> 4;
3864 switch (reason_code) { 4081 switch (reason_code) {
3865 case MPI2_EVENT_SAS_TOPO_RC_PHY_CHANGED: 4082 case MPI2_EVENT_SAS_TOPO_RC_PHY_CHANGED:
@@ -3971,19 +4188,19 @@ _scsih_sas_device_status_change_event_debug(struct MPT2SAS_ADAPTER *ioc,
3971/** 4188/**
3972 * _scsih_sas_device_status_change_event - handle device status change 4189 * _scsih_sas_device_status_change_event - handle device status change
3973 * @ioc: per adapter object 4190 * @ioc: per adapter object
3974 * @VF_ID: 4191 * @fw_event: The fw_event_work object
3975 * @event_data: event data payload
3976 * Context: user. 4192 * Context: user.
3977 * 4193 *
3978 * Return nothing. 4194 * Return nothing.
3979 */ 4195 */
3980static void 4196static void
3981_scsih_sas_device_status_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, 4197_scsih_sas_device_status_change_event(struct MPT2SAS_ADAPTER *ioc,
3982 Mpi2EventDataSasDeviceStatusChange_t *event_data) 4198 struct fw_event_work *fw_event)
3983{ 4199{
3984#ifdef CONFIG_SCSI_MPT2SAS_LOGGING 4200#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
3985 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) 4201 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
3986 _scsih_sas_device_status_change_event_debug(ioc, event_data); 4202 _scsih_sas_device_status_change_event_debug(ioc,
4203 fw_event->event_data);
3987#endif 4204#endif
3988} 4205}
3989 4206
@@ -4026,34 +4243,33 @@ _scsih_sas_enclosure_dev_status_change_event_debug(struct MPT2SAS_ADAPTER *ioc,
4026/** 4243/**
4027 * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events 4244 * _scsih_sas_enclosure_dev_status_change_event - handle enclosure events
4028 * @ioc: per adapter object 4245 * @ioc: per adapter object
4029 * @VF_ID: 4246 * @fw_event: The fw_event_work object
4030 * @event_data: event data payload
4031 * Context: user. 4247 * Context: user.
4032 * 4248 *
4033 * Return nothing. 4249 * Return nothing.
4034 */ 4250 */
4035static void 4251static void
4036_scsih_sas_enclosure_dev_status_change_event(struct MPT2SAS_ADAPTER *ioc, 4252_scsih_sas_enclosure_dev_status_change_event(struct MPT2SAS_ADAPTER *ioc,
4037 u8 VF_ID, Mpi2EventDataSasEnclDevStatusChange_t *event_data) 4253 struct fw_event_work *fw_event)
4038{ 4254{
4039#ifdef CONFIG_SCSI_MPT2SAS_LOGGING 4255#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
4040 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) 4256 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
4041 _scsih_sas_enclosure_dev_status_change_event_debug(ioc, 4257 _scsih_sas_enclosure_dev_status_change_event_debug(ioc,
4042 event_data); 4258 fw_event->event_data);
4043#endif 4259#endif
4044} 4260}
4045 4261
4046/** 4262/**
4047 * _scsih_sas_broadcast_primative_event - handle broadcast events 4263 * _scsih_sas_broadcast_primative_event - handle broadcast events
4048 * @ioc: per adapter object 4264 * @ioc: per adapter object
4049 * @event_data: event data payload 4265 * @fw_event: The fw_event_work object
4050 * Context: user. 4266 * Context: user.
4051 * 4267 *
4052 * Return nothing. 4268 * Return nothing.
4053 */ 4269 */
4054static void 4270static void
4055_scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, 4271_scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc,
4056 Mpi2EventDataSasBroadcastPrimitive_t *event_data) 4272 struct fw_event_work *fw_event)
4057{ 4273{
4058 struct scsi_cmnd *scmd; 4274 struct scsi_cmnd *scmd;
4059 u16 smid, handle; 4275 u16 smid, handle;
@@ -4062,11 +4278,12 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4062 u32 termination_count; 4278 u32 termination_count;
4063 u32 query_count; 4279 u32 query_count;
4064 Mpi2SCSITaskManagementReply_t *mpi_reply; 4280 Mpi2SCSITaskManagementReply_t *mpi_reply;
4065 4281#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
4282 Mpi2EventDataSasBroadcastPrimitive_t *event_data = fw_event->event_data;
4283#endif
4066 dewtprintk(ioc, printk(MPT2SAS_DEBUG_FMT "broadcast primative: " 4284 dewtprintk(ioc, printk(MPT2SAS_DEBUG_FMT "broadcast primative: "
4067 "phy number(%d), width(%d)\n", ioc->name, event_data->PhyNum, 4285 "phy number(%d), width(%d)\n", ioc->name, event_data->PhyNum,
4068 event_data->PortWidth)); 4286 event_data->PortWidth));
4069
4070 dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: enter\n", ioc->name, 4287 dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: enter\n", ioc->name,
4071 __func__)); 4288 __func__));
4072 4289
@@ -4074,7 +4291,7 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4074 termination_count = 0; 4291 termination_count = 0;
4075 query_count = 0; 4292 query_count = 0;
4076 mpi_reply = ioc->tm_cmds.reply; 4293 mpi_reply = ioc->tm_cmds.reply;
4077 for (smid = 1; smid <= ioc->request_depth; smid++) { 4294 for (smid = 1; smid <= ioc->scsiio_depth; smid++) {
4078 scmd = _scsih_scsi_lookup_get(ioc, smid); 4295 scmd = _scsih_scsi_lookup_get(ioc, smid);
4079 if (!scmd) 4296 if (!scmd)
4080 continue; 4297 continue;
@@ -4121,23 +4338,25 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4121/** 4338/**
4122 * _scsih_sas_discovery_event - handle discovery events 4339 * _scsih_sas_discovery_event - handle discovery events
4123 * @ioc: per adapter object 4340 * @ioc: per adapter object
4124 * @event_data: event data payload 4341 * @fw_event: The fw_event_work object
4125 * Context: user. 4342 * Context: user.
4126 * 4343 *
4127 * Return nothing. 4344 * Return nothing.
4128 */ 4345 */
4129static void 4346static void
4130_scsih_sas_discovery_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, 4347_scsih_sas_discovery_event(struct MPT2SAS_ADAPTER *ioc,
4131 Mpi2EventDataSasDiscovery_t *event_data) 4348 struct fw_event_work *fw_event)
4132{ 4349{
4350 Mpi2EventDataSasDiscovery_t *event_data = fw_event->event_data;
4351
4133#ifdef CONFIG_SCSI_MPT2SAS_LOGGING 4352#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
4134 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) { 4353 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) {
4135 printk(MPT2SAS_DEBUG_FMT "discovery event: (%s)", ioc->name, 4354 printk(MPT2SAS_DEBUG_FMT "discovery event: (%s)", ioc->name,
4136 (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED) ? 4355 (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED) ?
4137 "start" : "stop"); 4356 "start" : "stop");
4138 if (event_data->DiscoveryStatus) 4357 if (event_data->DiscoveryStatus)
4139 printk(MPT2SAS_DEBUG_FMT ", discovery_status(0x%08x)", 4358 printk("discovery_status(0x%08x)",
4140 ioc->name, le32_to_cpu(event_data->DiscoveryStatus)); 4359 le32_to_cpu(event_data->DiscoveryStatus));
4141 printk("\n"); 4360 printk("\n");
4142 } 4361 }
4143#endif 4362#endif
@@ -4488,19 +4707,19 @@ _scsih_sas_ir_config_change_event_debug(struct MPT2SAS_ADAPTER *ioc,
4488/** 4707/**
4489 * _scsih_sas_ir_config_change_event - handle ir configuration change events 4708 * _scsih_sas_ir_config_change_event - handle ir configuration change events
4490 * @ioc: per adapter object 4709 * @ioc: per adapter object
4491 * @VF_ID: 4710 * @fw_event: The fw_event_work object
4492 * @event_data: event data payload
4493 * Context: user. 4711 * Context: user.
4494 * 4712 *
4495 * Return nothing. 4713 * Return nothing.
4496 */ 4714 */
4497static void 4715static void
4498_scsih_sas_ir_config_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, 4716_scsih_sas_ir_config_change_event(struct MPT2SAS_ADAPTER *ioc,
4499 Mpi2EventDataIrConfigChangeList_t *event_data) 4717 struct fw_event_work *fw_event)
4500{ 4718{
4501 Mpi2EventIrConfigElement_t *element; 4719 Mpi2EventIrConfigElement_t *element;
4502 int i; 4720 int i;
4503 u8 foreign_config; 4721 u8 foreign_config;
4722 Mpi2EventDataIrConfigChangeList_t *event_data = fw_event->event_data;
4504 4723
4505#ifdef CONFIG_SCSI_MPT2SAS_LOGGING 4724#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
4506 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) 4725 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
@@ -4543,14 +4762,14 @@ _scsih_sas_ir_config_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4543/** 4762/**
4544 * _scsih_sas_ir_volume_event - IR volume event 4763 * _scsih_sas_ir_volume_event - IR volume event
4545 * @ioc: per adapter object 4764 * @ioc: per adapter object
4546 * @event_data: event data payload 4765 * @fw_event: The fw_event_work object
4547 * Context: user. 4766 * Context: user.
4548 * 4767 *
4549 * Return nothing. 4768 * Return nothing.
4550 */ 4769 */
4551static void 4770static void
4552_scsih_sas_ir_volume_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, 4771_scsih_sas_ir_volume_event(struct MPT2SAS_ADAPTER *ioc,
4553 Mpi2EventDataIrVolume_t *event_data) 4772 struct fw_event_work *fw_event)
4554{ 4773{
4555 u64 wwid; 4774 u64 wwid;
4556 unsigned long flags; 4775 unsigned long flags;
@@ -4559,6 +4778,7 @@ _scsih_sas_ir_volume_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4559 u32 state; 4778 u32 state;
4560 int rc; 4779 int rc;
4561 struct MPT2SAS_TARGET *sas_target_priv_data; 4780 struct MPT2SAS_TARGET *sas_target_priv_data;
4781 Mpi2EventDataIrVolume_t *event_data = fw_event->event_data;
4562 4782
4563 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED) 4783 if (event_data->ReasonCode != MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED)
4564 return; 4784 return;
@@ -4628,14 +4848,14 @@ _scsih_sas_ir_volume_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4628/** 4848/**
4629 * _scsih_sas_ir_physical_disk_event - PD event 4849 * _scsih_sas_ir_physical_disk_event - PD event
4630 * @ioc: per adapter object 4850 * @ioc: per adapter object
4631 * @event_data: event data payload 4851 * @fw_event: The fw_event_work object
4632 * Context: user. 4852 * Context: user.
4633 * 4853 *
4634 * Return nothing. 4854 * Return nothing.
4635 */ 4855 */
4636static void 4856static void
4637_scsih_sas_ir_physical_disk_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, 4857_scsih_sas_ir_physical_disk_event(struct MPT2SAS_ADAPTER *ioc,
4638 Mpi2EventDataIrPhysicalDisk_t *event_data) 4858 struct fw_event_work *fw_event)
4639{ 4859{
4640 u16 handle; 4860 u16 handle;
4641 u32 state; 4861 u32 state;
@@ -4644,6 +4864,7 @@ _scsih_sas_ir_physical_disk_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4644 Mpi2ConfigReply_t mpi_reply; 4864 Mpi2ConfigReply_t mpi_reply;
4645 Mpi2SasDevicePage0_t sas_device_pg0; 4865 Mpi2SasDevicePage0_t sas_device_pg0;
4646 u32 ioc_status; 4866 u32 ioc_status;
4867 Mpi2EventDataIrPhysicalDisk_t *event_data = fw_event->event_data;
4647 4868
4648 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED) 4869 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED)
4649 return; 4870 return;
@@ -4743,33 +4964,33 @@ _scsih_sas_ir_operation_status_event_debug(struct MPT2SAS_ADAPTER *ioc,
4743/** 4964/**
4744 * _scsih_sas_ir_operation_status_event - handle RAID operation events 4965 * _scsih_sas_ir_operation_status_event - handle RAID operation events
4745 * @ioc: per adapter object 4966 * @ioc: per adapter object
4746 * @VF_ID: 4967 * @fw_event: The fw_event_work object
4747 * @event_data: event data payload
4748 * Context: user. 4968 * Context: user.
4749 * 4969 *
4750 * Return nothing. 4970 * Return nothing.
4751 */ 4971 */
4752static void 4972static void
4753_scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, 4973_scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
4754 Mpi2EventDataIrOperationStatus_t *event_data) 4974 struct fw_event_work *fw_event)
4755{ 4975{
4756#ifdef CONFIG_SCSI_MPT2SAS_LOGGING 4976#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
4757 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) 4977 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
4758 _scsih_sas_ir_operation_status_event_debug(ioc, event_data); 4978 _scsih_sas_ir_operation_status_event_debug(ioc,
4979 fw_event->event_data);
4759#endif 4980#endif
4760} 4981}
4761 4982
4762/** 4983/**
4763 * _scsih_task_set_full - handle task set full 4984 * _scsih_task_set_full - handle task set full
4764 * @ioc: per adapter object 4985 * @ioc: per adapter object
4765 * @event_data: event data payload 4986 * @fw_event: The fw_event_work object
4766 * Context: user. 4987 * Context: user.
4767 * 4988 *
4768 * Throttle back qdepth. 4989 * Throttle back qdepth.
4769 */ 4990 */
4770static void 4991static void
4771_scsih_task_set_full(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, 4992_scsih_task_set_full(struct MPT2SAS_ADAPTER *ioc, struct fw_event_work
4772 Mpi2EventDataTaskSetFull_t *event_data) 4993 *fw_event)
4773{ 4994{
4774 unsigned long flags; 4995 unsigned long flags;
4775 struct _sas_device *sas_device; 4996 struct _sas_device *sas_device;
@@ -4780,6 +5001,7 @@ _scsih_task_set_full(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4780 u16 handle; 5001 u16 handle;
4781 int id, channel; 5002 int id, channel;
4782 u64 sas_address; 5003 u64 sas_address;
5004 Mpi2EventDataTaskSetFull_t *event_data = fw_event->event_data;
4783 5005
4784 current_depth = le16_to_cpu(event_data->CurrentDepth); 5006 current_depth = le16_to_cpu(event_data->CurrentDepth);
4785 handle = le16_to_cpu(event_data->DevHandle); 5007 handle = le16_to_cpu(event_data->DevHandle);
@@ -4868,6 +5090,10 @@ _scsih_mark_responding_sas_device(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
4868 if (sas_device->sas_address == sas_address && 5090 if (sas_device->sas_address == sas_address &&
4869 sas_device->slot == slot && sas_device->starget) { 5091 sas_device->slot == slot && sas_device->starget) {
4870 sas_device->responding = 1; 5092 sas_device->responding = 1;
5093 sas_device->state = 0;
5094 starget = sas_device->starget;
5095 sas_target_priv_data = starget->hostdata;
5096 sas_target_priv_data->tm_busy = 0;
4871 starget_printk(KERN_INFO, sas_device->starget, 5097 starget_printk(KERN_INFO, sas_device->starget,
4872 "handle(0x%04x), sas_addr(0x%016llx), enclosure " 5098 "handle(0x%04x), sas_addr(0x%016llx), enclosure "
4873 "logical id(0x%016llx), slot(%d)\n", handle, 5099 "logical id(0x%016llx), slot(%d)\n", handle,
@@ -4880,8 +5106,6 @@ _scsih_mark_responding_sas_device(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
4880 printk(KERN_INFO "\thandle changed from(0x%04x)!!!\n", 5106 printk(KERN_INFO "\thandle changed from(0x%04x)!!!\n",
4881 sas_device->handle); 5107 sas_device->handle);
4882 sas_device->handle = handle; 5108 sas_device->handle = handle;
4883 starget = sas_device->starget;
4884 sas_target_priv_data = starget->hostdata;
4885 sas_target_priv_data->handle = handle; 5109 sas_target_priv_data->handle = handle;
4886 goto out; 5110 goto out;
4887 } 5111 }
@@ -5227,44 +5451,38 @@ _firmware_event_work(struct work_struct *work)
5227 5451
5228 switch (fw_event->event) { 5452 switch (fw_event->event) {
5229 case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST: 5453 case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST:
5230 _scsih_sas_topology_change_event(ioc, fw_event->VF_ID, 5454 _scsih_sas_topology_change_event(ioc, fw_event);
5231 fw_event->event_data, fw_event);
5232 break; 5455 break;
5233 case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE: 5456 case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE:
5234 _scsih_sas_device_status_change_event(ioc, fw_event->VF_ID, 5457 _scsih_sas_device_status_change_event(ioc,
5235 fw_event->event_data); 5458 fw_event);
5236 break; 5459 break;
5237 case MPI2_EVENT_SAS_DISCOVERY: 5460 case MPI2_EVENT_SAS_DISCOVERY:
5238 _scsih_sas_discovery_event(ioc, fw_event->VF_ID, 5461 _scsih_sas_discovery_event(ioc,
5239 fw_event->event_data); 5462 fw_event);
5240 break; 5463 break;
5241 case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE: 5464 case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE:
5242 _scsih_sas_broadcast_primative_event(ioc, fw_event->VF_ID, 5465 _scsih_sas_broadcast_primative_event(ioc,
5243 fw_event->event_data); 5466 fw_event);
5244 break; 5467 break;
5245 case MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE: 5468 case MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE:
5246 _scsih_sas_enclosure_dev_status_change_event(ioc, 5469 _scsih_sas_enclosure_dev_status_change_event(ioc,
5247 fw_event->VF_ID, fw_event->event_data); 5470 fw_event);
5248 break; 5471 break;
5249 case MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST: 5472 case MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST:
5250 _scsih_sas_ir_config_change_event(ioc, fw_event->VF_ID, 5473 _scsih_sas_ir_config_change_event(ioc, fw_event);
5251 fw_event->event_data);
5252 break; 5474 break;
5253 case MPI2_EVENT_IR_VOLUME: 5475 case MPI2_EVENT_IR_VOLUME:
5254 _scsih_sas_ir_volume_event(ioc, fw_event->VF_ID, 5476 _scsih_sas_ir_volume_event(ioc, fw_event);
5255 fw_event->event_data);
5256 break; 5477 break;
5257 case MPI2_EVENT_IR_PHYSICAL_DISK: 5478 case MPI2_EVENT_IR_PHYSICAL_DISK:
5258 _scsih_sas_ir_physical_disk_event(ioc, fw_event->VF_ID, 5479 _scsih_sas_ir_physical_disk_event(ioc, fw_event);
5259 fw_event->event_data);
5260 break; 5480 break;
5261 case MPI2_EVENT_IR_OPERATION_STATUS: 5481 case MPI2_EVENT_IR_OPERATION_STATUS:
5262 _scsih_sas_ir_operation_status_event(ioc, fw_event->VF_ID, 5482 _scsih_sas_ir_operation_status_event(ioc, fw_event);
5263 fw_event->event_data);
5264 break; 5483 break;
5265 case MPI2_EVENT_TASK_SET_FULL: 5484 case MPI2_EVENT_TASK_SET_FULL:
5266 _scsih_task_set_full(ioc, fw_event->VF_ID, 5485 _scsih_task_set_full(ioc, fw_event);
5267 fw_event->event_data);
5268 break; 5486 break;
5269 } 5487 }
5270 _scsih_fw_event_free(ioc, fw_event); 5488 _scsih_fw_event_free(ioc, fw_event);
@@ -5273,17 +5491,19 @@ _firmware_event_work(struct work_struct *work)
5273/** 5491/**
5274 * mpt2sas_scsih_event_callback - firmware event handler (called at ISR time) 5492 * mpt2sas_scsih_event_callback - firmware event handler (called at ISR time)
5275 * @ioc: per adapter object 5493 * @ioc: per adapter object
5276 * @VF_ID: virtual function id 5494 * @msix_index: MSIX table index supplied by the OS
5277 * @reply: reply message frame(lower 32bit addr) 5495 * @reply: reply message frame(lower 32bit addr)
5278 * Context: interrupt. 5496 * Context: interrupt.
5279 * 5497 *
5280 * This function merely adds a new work task into ioc->firmware_event_thread. 5498 * This function merely adds a new work task into ioc->firmware_event_thread.
5281 * The tasks are worked from _firmware_event_work in user context. 5499 * The tasks are worked from _firmware_event_work in user context.
5282 * 5500 *
5283 * Return nothing. 5501 * Return 1 meaning mf should be freed from _base_interrupt
5502 * 0 means the mf is freed from this function.
5284 */ 5503 */
5285void 5504u8
5286mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply) 5505mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
5506 u32 reply)
5287{ 5507{
5288 struct fw_event_work *fw_event; 5508 struct fw_event_work *fw_event;
5289 Mpi2EventNotificationReply_t *mpi_reply; 5509 Mpi2EventNotificationReply_t *mpi_reply;
@@ -5294,11 +5514,11 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply)
5294 spin_lock_irqsave(&ioc->fw_event_lock, flags); 5514 spin_lock_irqsave(&ioc->fw_event_lock, flags);
5295 if (ioc->fw_events_off || ioc->remove_host) { 5515 if (ioc->fw_events_off || ioc->remove_host) {
5296 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); 5516 spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
5297 return; 5517 return 1;
5298 } 5518 }
5299 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); 5519 spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
5300 5520
5301 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); 5521 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
5302 event = le16_to_cpu(mpi_reply->Event); 5522 event = le16_to_cpu(mpi_reply->Event);
5303 5523
5304 switch (event) { 5524 switch (event) {
@@ -5312,7 +5532,7 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply)
5312 if (baen_data->Primitive != 5532 if (baen_data->Primitive !=
5313 MPI2_EVENT_PRIMITIVE_ASYNCHRONOUS_EVENT || 5533 MPI2_EVENT_PRIMITIVE_ASYNCHRONOUS_EVENT ||
5314 ioc->broadcast_aen_busy) 5534 ioc->broadcast_aen_busy)
5315 return; 5535 return 1;
5316 ioc->broadcast_aen_busy = 1; 5536 ioc->broadcast_aen_busy = 1;
5317 break; 5537 break;
5318 } 5538 }
@@ -5334,14 +5554,14 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply)
5334 break; 5554 break;
5335 5555
5336 default: /* ignore the rest */ 5556 default: /* ignore the rest */
5337 return; 5557 return 1;
5338 } 5558 }
5339 5559
5340 fw_event = kzalloc(sizeof(struct fw_event_work), GFP_ATOMIC); 5560 fw_event = kzalloc(sizeof(struct fw_event_work), GFP_ATOMIC);
5341 if (!fw_event) { 5561 if (!fw_event) {
5342 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", 5562 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
5343 ioc->name, __FILE__, __LINE__, __func__); 5563 ioc->name, __FILE__, __LINE__, __func__);
5344 return; 5564 return 1;
5345 } 5565 }
5346 fw_event->event_data = 5566 fw_event->event_data =
5347 kzalloc(mpi_reply->EventDataLength*4, GFP_ATOMIC); 5567 kzalloc(mpi_reply->EventDataLength*4, GFP_ATOMIC);
@@ -5349,15 +5569,17 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply)
5349 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", 5569 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
5350 ioc->name, __FILE__, __LINE__, __func__); 5570 ioc->name, __FILE__, __LINE__, __func__);
5351 kfree(fw_event); 5571 kfree(fw_event);
5352 return; 5572 return 1;
5353 } 5573 }
5354 5574
5355 memcpy(fw_event->event_data, mpi_reply->EventData, 5575 memcpy(fw_event->event_data, mpi_reply->EventData,
5356 mpi_reply->EventDataLength*4); 5576 mpi_reply->EventDataLength*4);
5357 fw_event->ioc = ioc; 5577 fw_event->ioc = ioc;
5358 fw_event->VF_ID = VF_ID; 5578 fw_event->VF_ID = mpi_reply->VF_ID;
5579 fw_event->VP_ID = mpi_reply->VP_ID;
5359 fw_event->event = event; 5580 fw_event->event = event;
5360 _scsih_fw_event_add(ioc, fw_event); 5581 _scsih_fw_event_add(ioc, fw_event);
5582 return 1;
5361} 5583}
5362 5584
5363/* shost template */ 5585/* shost template */
@@ -5617,7 +5839,7 @@ _scsih_probe_raid(struct MPT2SAS_ADAPTER *ioc)
5617} 5839}
5618 5840
5619/** 5841/**
5620 * _scsih_probe_sas - reporting raid volumes to sas transport 5842 * _scsih_probe_sas - reporting sas devices to sas transport
5621 * @ioc: per adapter object 5843 * @ioc: per adapter object
5622 * 5844 *
5623 * Called during initial loading of the driver. 5845 * Called during initial loading of the driver.
@@ -5714,6 +5936,8 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
5714 ioc->base_cb_idx = base_cb_idx; 5936 ioc->base_cb_idx = base_cb_idx;
5715 ioc->transport_cb_idx = transport_cb_idx; 5937 ioc->transport_cb_idx = transport_cb_idx;
5716 ioc->config_cb_idx = config_cb_idx; 5938 ioc->config_cb_idx = config_cb_idx;
5939 ioc->tm_tr_cb_idx = tm_tr_cb_idx;
5940 ioc->tm_sas_control_cb_idx = tm_sas_control_cb_idx;
5717 ioc->logging_level = logging_level; 5941 ioc->logging_level = logging_level;
5718 /* misc semaphores and spin locks */ 5942 /* misc semaphores and spin locks */
5719 spin_lock_init(&ioc->ioc_reset_in_progress_lock); 5943 spin_lock_init(&ioc->ioc_reset_in_progress_lock);
@@ -5729,6 +5953,7 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
5729 INIT_LIST_HEAD(&ioc->fw_event_list); 5953 INIT_LIST_HEAD(&ioc->fw_event_list);
5730 INIT_LIST_HEAD(&ioc->raid_device_list); 5954 INIT_LIST_HEAD(&ioc->raid_device_list);
5731 INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list); 5955 INIT_LIST_HEAD(&ioc->sas_hba.sas_port_list);
5956 INIT_LIST_HEAD(&ioc->delayed_tr_list);
5732 5957
5733 /* init shost parameters */ 5958 /* init shost parameters */
5734 shost->max_cmd_len = 16; 5959 shost->max_cmd_len = 16;
@@ -5745,6 +5970,7 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
5745 5970
5746 scsi_host_set_prot(shost, SHOST_DIF_TYPE1_PROTECTION 5971 scsi_host_set_prot(shost, SHOST_DIF_TYPE1_PROTECTION
5747 | SHOST_DIF_TYPE3_PROTECTION); 5972 | SHOST_DIF_TYPE3_PROTECTION);
5973 scsi_host_set_guard(shost, SHOST_DIX_GUARD_CRC);
5748 5974
5749 /* event thread */ 5975 /* event thread */
5750 snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name), 5976 snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name),
@@ -5894,6 +6120,11 @@ _scsih_init(void)
5894 /* ctl module callback handler */ 6120 /* ctl module callback handler */
5895 ctl_cb_idx = mpt2sas_base_register_callback_handler(mpt2sas_ctl_done); 6121 ctl_cb_idx = mpt2sas_base_register_callback_handler(mpt2sas_ctl_done);
5896 6122
6123 tm_tr_cb_idx = mpt2sas_base_register_callback_handler(
6124 _scsih_tm_tr_complete);
6125 tm_sas_control_cb_idx = mpt2sas_base_register_callback_handler(
6126 _scsih_sas_control_complete);
6127
5897 mpt2sas_ctl_init(); 6128 mpt2sas_ctl_init();
5898 6129
5899 error = pci_register_driver(&scsih_driver); 6130 error = pci_register_driver(&scsih_driver);
@@ -5924,6 +6155,9 @@ _scsih_exit(void)
5924 mpt2sas_base_release_callback_handler(config_cb_idx); 6155 mpt2sas_base_release_callback_handler(config_cb_idx);
5925 mpt2sas_base_release_callback_handler(ctl_cb_idx); 6156 mpt2sas_base_release_callback_handler(ctl_cb_idx);
5926 6157
6158 mpt2sas_base_release_callback_handler(tm_tr_cb_idx);
6159 mpt2sas_base_release_callback_handler(tm_sas_control_cb_idx);
6160
5927 mpt2sas_ctl_exit(); 6161 mpt2sas_ctl_exit();
5928} 6162}
5929 6163
diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c
index 742324a0a11e..eb98188c7f3f 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_transport.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c
@@ -2,7 +2,7 @@
2 * SAS Transport Layer for MPT (Message Passing Technology) based controllers 2 * SAS Transport Layer for MPT (Message Passing Technology) based controllers
3 * 3 *
4 * This code is based on drivers/scsi/mpt2sas/mpt2_transport.c 4 * This code is based on drivers/scsi/mpt2sas/mpt2_transport.c
5 * Copyright (C) 2007-2008 LSI Corporation 5 * Copyright (C) 2007-2009 LSI Corporation
6 * (mailto:DL-MPTFusionLinux@lsi.com) 6 * (mailto:DL-MPTFusionLinux@lsi.com)
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
@@ -212,25 +212,26 @@ _transport_set_identify(struct MPT2SAS_ADAPTER *ioc, u16 handle,
212 * mpt2sas_transport_done - internal transport layer callback handler. 212 * mpt2sas_transport_done - internal transport layer callback handler.
213 * @ioc: per adapter object 213 * @ioc: per adapter object
214 * @smid: system request message index 214 * @smid: system request message index
215 * @VF_ID: virtual function id 215 * @msix_index: MSIX table index supplied by the OS
216 * @reply: reply message frame(lower 32bit addr) 216 * @reply: reply message frame(lower 32bit addr)
217 * 217 *
218 * Callback handler when sending internal generated transport cmds. 218 * Callback handler when sending internal generated transport cmds.
219 * The callback index passed is `ioc->transport_cb_idx` 219 * The callback index passed is `ioc->transport_cb_idx`
220 * 220 *
221 * Return nothing. 221 * Return 1 meaning mf should be freed from _base_interrupt
222 * 0 means the mf is freed from this function.
222 */ 223 */
223void 224u8
224mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, 225mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
225 u32 reply) 226 u32 reply)
226{ 227{
227 MPI2DefaultReply_t *mpi_reply; 228 MPI2DefaultReply_t *mpi_reply;
228 229
229 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); 230 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
230 if (ioc->transport_cmds.status == MPT2_CMD_NOT_USED) 231 if (ioc->transport_cmds.status == MPT2_CMD_NOT_USED)
231 return; 232 return 1;
232 if (ioc->transport_cmds.smid != smid) 233 if (ioc->transport_cmds.smid != smid)
233 return; 234 return 1;
234 ioc->transport_cmds.status |= MPT2_CMD_COMPLETE; 235 ioc->transport_cmds.status |= MPT2_CMD_COMPLETE;
235 if (mpi_reply) { 236 if (mpi_reply) {
236 memcpy(ioc->transport_cmds.reply, mpi_reply, 237 memcpy(ioc->transport_cmds.reply, mpi_reply,
@@ -239,6 +240,7 @@ mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID,
239 } 240 }
240 ioc->transport_cmds.status &= ~MPT2_CMD_PENDING; 241 ioc->transport_cmds.status &= ~MPT2_CMD_PENDING;
241 complete(&ioc->transport_cmds.done); 242 complete(&ioc->transport_cmds.done);
243 return 1;
242} 244}
243 245
244/* report manufacture request structure */ 246/* report manufacture request structure */
@@ -369,6 +371,8 @@ _transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc,
369 memset(mpi_request, 0, sizeof(Mpi2SmpPassthroughRequest_t)); 371 memset(mpi_request, 0, sizeof(Mpi2SmpPassthroughRequest_t));
370 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; 372 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH;
371 mpi_request->PhysicalPort = 0xFF; 373 mpi_request->PhysicalPort = 0xFF;
374 mpi_request->VF_ID = 0; /* TODO */
375 mpi_request->VP_ID = 0;
372 sas_address_le = (u64 *)&mpi_request->SASAddress; 376 sas_address_le = (u64 *)&mpi_request->SASAddress;
373 *sas_address_le = cpu_to_le64(sas_address); 377 *sas_address_le = cpu_to_le64(sas_address);
374 mpi_request->RequestDataLength = sizeof(struct rep_manu_request); 378 mpi_request->RequestDataLength = sizeof(struct rep_manu_request);
@@ -396,7 +400,8 @@ _transport_expander_report_manufacture(struct MPT2SAS_ADAPTER *ioc,
396 dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT "report_manufacture - " 400 dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT "report_manufacture - "
397 "send to sas_addr(0x%016llx)\n", ioc->name, 401 "send to sas_addr(0x%016llx)\n", ioc->name,
398 (unsigned long long)sas_address)); 402 (unsigned long long)sas_address));
399 mpt2sas_base_put_smid_default(ioc, smid, 0 /* VF_ID */); 403 mpt2sas_base_put_smid_default(ioc, smid);
404 init_completion(&ioc->transport_cmds.done);
400 timeleft = wait_for_completion_timeout(&ioc->transport_cmds.done, 405 timeleft = wait_for_completion_timeout(&ioc->transport_cmds.done,
401 10*HZ); 406 10*HZ);
402 407
@@ -1106,6 +1111,8 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1106 memset(mpi_request, 0, sizeof(Mpi2SmpPassthroughRequest_t)); 1111 memset(mpi_request, 0, sizeof(Mpi2SmpPassthroughRequest_t));
1107 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; 1112 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH;
1108 mpi_request->PhysicalPort = 0xFF; 1113 mpi_request->PhysicalPort = 0xFF;
1114 mpi_request->VF_ID = 0; /* TODO */
1115 mpi_request->VP_ID = 0;
1109 *((u64 *)&mpi_request->SASAddress) = (rphy) ? 1116 *((u64 *)&mpi_request->SASAddress) = (rphy) ?
1110 cpu_to_le64(rphy->identify.sas_address) : 1117 cpu_to_le64(rphy->identify.sas_address) :
1111 cpu_to_le64(ioc->sas_hba.sas_address); 1118 cpu_to_le64(ioc->sas_hba.sas_address);
@@ -1147,7 +1154,8 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1147 dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s - " 1154 dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s - "
1148 "sending smp request\n", ioc->name, __func__)); 1155 "sending smp request\n", ioc->name, __func__));
1149 1156
1150 mpt2sas_base_put_smid_default(ioc, smid, 0 /* VF_ID */); 1157 mpt2sas_base_put_smid_default(ioc, smid);
1158 init_completion(&ioc->transport_cmds.done);
1151 timeleft = wait_for_completion_timeout(&ioc->transport_cmds.done, 1159 timeleft = wait_for_completion_timeout(&ioc->transport_cmds.done,
1152 10*HZ); 1160 10*HZ);
1153 1161