]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Fusion-MPT driver update
authorPam Delaney <pdelaney@lsil.com>
Mon, 16 Sep 2002 02:31:42 +0000 (19:31 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Mon, 16 Sep 2002 02:31:42 +0000 (19:31 -0700)
This updates the Fusion-MPT driver to the latest stable version.
Changes affect the driver source only.

Major Changes:
Reworked the calls save_flags, cli, restore_flags to 2.5 format.
Modified DV  invocation and to handle illegal bus configuration
Negotiation settings honor NVRAM

Bug Fix: Pushing F/W onto part during driver unload.
Bug Fix: Force F/W reset for 1030 on driver load.
Bug Fix: F/W download algorithm.
Bug Fix: Found a memory leak in mptctl.c
Bug Fix: Forcing data direction for reads and writes (sg issue)
Bug Fix: Wrong mask in Inquiry data ANSI version

Minor Changes:
Modified the debug and logging statements of the driver
Upgraded the MPI include files (lsi/)

16 files changed:
drivers/message/fusion/Makefile
drivers/message/fusion/linux_compat.h
drivers/message/fusion/lsi/mpi.h
drivers/message/fusion/lsi/mpi_cnfg.h
drivers/message/fusion/lsi/mpi_fc.h
drivers/message/fusion/lsi/mpi_init.h
drivers/message/fusion/lsi/mpi_ioc.h
drivers/message/fusion/lsi/mpi_lan.h
drivers/message/fusion/lsi/mpi_raid.h
drivers/message/fusion/lsi/mpi_targ.h
drivers/message/fusion/lsi/mpi_type.h
drivers/message/fusion/mptbase.c
drivers/message/fusion/mptbase.h
drivers/message/fusion/mptctl.c
drivers/message/fusion/mptscsih.c
drivers/message/fusion/mptscsih.h

index 81a274a489f6368119fd961371d251cf65607c2d..d9cea6300a3b945ddb14ff84b242d20225f0baa7 100644 (file)
@@ -1,7 +1,14 @@
 #
 # Makefile for the LSI Logic Fusion MPT (Message Passing Technology) drivers.
 #
-# Note! If you want to turn on various debug defines for an extended period of
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definition is now inherited from the
+# parent makefile.
+#
+# Note 3! If you want to turn on various debug defines for an extended period of
 # time but don't want them lingering around in the Makefile when you pass it on 
 # to someone else, use the MPT_CFLAGS env variable (thanks Steve). -nromer
 
@@ -20,6 +27,7 @@ EXTRA_CFLAGS += -I. ${MPT_CFLAGS}
 #EXTRA_CFLAGS += -DDEBUG
 #EXTRA_CFLAGS += -DMPT_DEBUG
 #EXTRA_CFLAGS += -DMPT_DEBUG_MSG_FRAME
+#EXTRA_CFLAGS += -DMPT_DEBUG_SG
 #
 # driver/module specifics...
 #
@@ -27,11 +35,13 @@ EXTRA_CFLAGS += -I. ${MPT_CFLAGS}
 #CFLAGS_mptbase.o += -DMPT_DEBUG_HANDSHAKE
 #CFLAGS_mptbase.o += -DMPT_DEBUG_IRQ
 #
-#  For {mptscsih, mptctl}:
-#CFLAGS_mptscsih.o += -DMPT_SCSI_USE_NEW_EH
+#  For mptscsih:
 #CFLAGS_mptscsih.o += -DMPT_DEBUG_SCANDV
-#CFLAGS_mptscsih.o += -DMPT_DEBUG_SG
-#CFLAGS_mptctl.o += -DMPT_DEBUG_SG
+#CFLAGS_mptscsih.o += -DMPT_DEBUG_RESET
+#CFLAGS_mptscsih.o += -DMPT_DEBUG_NEH
+#
+#  For mptctl:
+#CFLAGS_mptctl.o += -DMPT_DEBUG_IOCTL
 #
 #  For mptlan:
 #CFLAGS_mptlan.o += -DMPT_LAN_IO_DEBUG
@@ -43,11 +53,27 @@ EXTRA_CFLAGS += -I. ${MPT_CFLAGS}
 
 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC
 
-export-objs    := mptbase.o
+O_TARGET := fusion.o
+
+export-objs    := mptbase.o mptscsih.o mptlan.o mptctl.o isense.o
+
+# ? what's list-multi for?
+#list-multi    := fusion.o mptscsih.o
 
 obj-$(CONFIG_FUSION)           += mptbase.o mptscsih.o
 obj-$(CONFIG_FUSION_ISENSE)    += isense.o
 obj-$(CONFIG_FUSION_CTL)       += mptctl.o
 obj-$(CONFIG_FUSION_LAN)       += mptlan.o
 
+O_OBJS         := $(filter-out         $(export-objs), $(obj-y))
+OX_OBJS                := $(filter             $(export-objs), $(obj-y))
+M_OBJS         := $(sort $(filter-out  $(export-objs), $(obj-m)))
+MX_OBJS                := $(sort $(filter      $(export-objs), $(obj-m)))
+
 include $(TOPDIR)/Rules.make
+
+
+#  EXP...
+## Fusion MPT extra's...
+##mptscsih.o: $(mptscsih-objs)
+##     $(LD) -r -o $@ $(mptscsih-objs)
index 3b58245d608ddf1b90a527e58b57d76970dbb904..e226d52a62e22744e19275fa2998f6a8cc3e1f19 100644 (file)
@@ -252,6 +252,27 @@ static __inline__ int __get_order(unsigned long size)
         #define MPT_SCSI_USE_NEW_EH
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,28)
+#define mptscsih_save_flags(flags) \
+({     local_save_flags(flags); \
+       local_irq_disable(); \
+})
+#else
+#define mptscsih_save_flags(flags) \
+({     save_flags(flags); \
+       cli(); \
+})
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,28)
+#define mptscsih_restore_flags(flags) \
+({     local_irq_enable(); \
+       local_irq_restore(flags); \
+})
+#else
+#define mptscsih_restore_flags(flags)  restore_flags(flags);
+#endif
+
 /*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 #endif /* _LINUX_COMPAT_H */
 
index a9f24c87fd3c3434fd9a868486cc8cd74c97f275..a20eb4ec756e02604e049b4f67c185edfa16d29e 100644 (file)
@@ -1,12 +1,12 @@
 /*
- *  Copyright (c) 2000-2001 LSI Logic Corporation.
+ *  Copyright (c) 2000-2002 LSI Logic Corporation.
  *
  *
  *           Name:  MPI.H
  *          Title:  MPI Message independent structures and definitions
  *  Creation Date:  July 27, 2000
  *
- *    MPI Version:  01.02.03
+ *    MPI.H Version:  01.02.06
  *
  *  Version History
  *  ---------------
@@ -44,6 +44,9 @@
  *                      Added define MPI_FUNCTION_TOOLBOX.
  *  09-28-01  01.02.02  New function code MPI_SCSI_ENCLOSURE_PROCESSOR.
  *  11-01-01  01.02.03  Changed name to MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR.
+ *  03-14-02  01.02.04  Added MPI_HEADER_VERSION_ defines.
+ *  05-31-02  01.02.05  Bumped MPI_HEADER_VERSION_UNIT.
+ *  07-12-02  01.02.06  Added define for MPI_FUNCTION_MAILBOX.
  *  --------------------------------------------------------------------------
  */
 
 
 #define MPI_VERSION_MAJOR                   (0x01)
 #define MPI_VERSION_MINOR                   (0x02)
-#define MPI_VERSION            ((MPI_VERSION_MAJOR << 8) | MPI_VERSION_MINOR)
-
+#define MPI_VERSION_MAJOR_MASK              (0xFF00)
+#define MPI_VERSION_MAJOR_SHIFT             (8)
+#define MPI_VERSION_MINOR_MASK              (0x00FF)
+#define MPI_VERSION_MINOR_SHIFT             (0)
+#define MPI_VERSION ((MPI_VERSION_MAJOR << MPI_VERSION_MAJOR_SHIFT) |   \
+                                      MPI_VERSION_MINOR)
+
+#define MPI_VERSION_01_00                   (0x0100)
+#define MPI_VERSION_01_01                   (0x0101)
+#define MPI_VERSION_01_02                   (0x0102)
 /* Note: The major versions of 0xe0 through 0xff are reserved */
 
+/* versioning for this MPI header set */
+#define MPI_HEADER_VERSION_UNIT             (0x07)
+#define MPI_HEADER_VERSION_DEV              (0x00)
+#define MPI_HEADER_VERSION_UNIT_MASK        (0xFF00)
+#define MPI_HEADER_VERSION_UNIT_SHIFT       (8)
+#define MPI_HEADER_VERSION_DEV_MASK         (0x00FF)
+#define MPI_HEADER_VERSION_DEV_SHIFT        (0)
+#define MPI_HEADER_VERSION ((MPI_HEADER_VERSION_UNIT << 8) | MPI_HEADER_VERSION_DEV)
+
 /*****************************************************************************
 *
 *        I O C    S t a t e    D e f i n i t i o n s
 
 #define MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR       (0x18)
 
+#define MPI_FUNCTION_MAILBOX                        (0x19)
+
 #define MPI_FUNCTION_LAN_SEND                       (0x20)
 #define MPI_FUNCTION_LAN_RECEIVE                    (0x21)
 #define MPI_FUNCTION_LAN_RESET                      (0x22)
index e7446764fe4c7dbbea76f401b846986fbb9e76c2..85fd521349878590c7c3e3970f1620680fb23723 100644 (file)
@@ -1,12 +1,12 @@
 /*
- *  Copyright (c) 2000-2001 LSI Logic Corporation.
+ *  Copyright (c) 2000-2002 LSI Logic Corporation.
  *
  *
  *           Name:  MPI_CNFG.H
  *          Title:  MPI Config message, structures, and Pages
  *  Creation Date:  July 27, 2000
  *
- *    MPI Version:  01.02.05
+ *    MPI_CNFG.H Version:  01.02.08
  *
  *  Version History
  *  ---------------
  *                      Added generic defines for hot spare pools and RAID
  *                      volume types.
  *  11-01-01 01.02.05   Added define for MPI_IOUNITPAGE1_DISABLE_IR.
+ *  03-14-02 01.02.06   Added PCISlotNum field to CONFIG_PAGE_IOC_1 along with
+ *                      related define, and bumped the page version define.
+ *  05-31-02 01.02.07   Added a Flags field to CONFIG_PAGE_IOC_2_RAID_VOL in a
+ *                      reserved byte and added a define.
+ *                      Added define for
+ *                      MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE.
+ *                      Added new config page: CONFIG_PAGE_IOC_5.
+ *                      Added MaxAliases, MaxHardAliases, and NumCurrentAliases
+ *                      fields to CONFIG_PAGE_FC_PORT_0.
+ *                      Added AltConnector and NumRequestedAliases fields to
+ *                      CONFIG_PAGE_FC_PORT_1.
+ *                      Added new config page: CONFIG_PAGE_FC_PORT_10.
+ *  07-12-02 01.02.08   Added more MPI_MANUFACTPAGE_DEVID_ defines.
+ *                      Added additional MPI_SCSIDEVPAGE0_NP_ defines.
+ *                      Added more MPI_SCSIDEVPAGE1_RP_ defines.
+ *                      Added define for
+ *                      MPI_SCSIDEVPAGE1_CONF_EXTENDED_PARAMS_ENABLE.
+ *                      Added new config page: CONFIG_PAGE_SCSI_DEVICE_3.
+ *                      Modified MPI_FCPORTPAGE5_FLAGS_ defines.
  *  --------------------------------------------------------------------------
  */
 
@@ -266,6 +285,7 @@ typedef struct _MSG_CONFIG_REPLY
 #define MPI_MANUFACTPAGE_DEVICEID_FC929             (0x0622)
 #define MPI_MANUFACTPAGE_DEVICEID_FC919X            (0x0628)
 #define MPI_MANUFACTPAGE_DEVICEID_FC929X            (0x0626)
+
 #define MPI_MANUFACTPAGE_DEVID_53C1030              (0x0030)
 #define MPI_MANUFACTPAGE_DEVID_53C1030ZC            (0x0031)
 #define MPI_MANUFACTPAGE_DEVID_1030_53C1035         (0x0032)
@@ -273,6 +293,12 @@ typedef struct _MSG_CONFIG_REPLY
 #define MPI_MANUFACTPAGE_DEVID_53C1035              (0x0040)
 #define MPI_MANUFACTPAGE_DEVID_53C1035ZC            (0x0041)
 
+#define MPI_MANUFACTPAGE_DEVID_SA2010               (0x0804)
+#define MPI_MANUFACTPAGE_DEVID_SA2010ZC             (0x0805)
+#define MPI_MANUFACTPAGE_DEVID_SA2020               (0x0806)
+#define MPI_MANUFACTPAGE_DEVID_SA2020ZC             (0x0807)
+
+
 typedef struct _CONFIG_PAGE_MANUFACTURING_0
 {
     fCONFIG_PAGE_HEADER      Header;                     /* 00h */
@@ -481,14 +507,17 @@ typedef struct _CONFIG_PAGE_IOC_1
     U32                     Flags;                      /* 04h */
     U32                     CoalescingTimeout;          /* 08h */
     U8                      CoalescingDepth;            /* 0Ch */
-    U8                      Reserved[3];                /* 0Dh */
+    U8                      PCISlotNum;                 /* 0Dh */
+    U8                      Reserved[2];                /* 0Eh */
 } fCONFIG_PAGE_IOC_1, MPI_POINTER PTR_CONFIG_PAGE_IOC_1,
   IOCPage1_t, MPI_POINTER pIOCPage1_t;
 
-#define MPI_IOCPAGE1_PAGEVERSION                        (0x00)
+#define MPI_IOCPAGE1_PAGEVERSION                        (0x01)
 
 #define MPI_IOCPAGE1_REPLY_COALESCING                   (0x00000001)
 
+#define MPI_IOCPAGE1_PCISLOTNUM_UNKNOWN                 (0xFF)
+
 
 typedef struct _CONFIG_PAGE_IOC_2_RAID_VOL
 {
@@ -497,11 +526,21 @@ typedef struct _CONFIG_PAGE_IOC_2_RAID_VOL
     U8                          VolumeIOC;              /* 02h */
     U8                          VolumePageNumber;       /* 03h */
     U8                          VolumeType;             /* 04h */
-    U8                          Reserved2;              /* 05h */
+    U8                          Flags;                  /* 05h */
     U16                         Reserved3;              /* 06h */
 } fCONFIG_PAGE_IOC_2_RAID_VOL, MPI_POINTER PTR_CONFIG_PAGE_IOC_2_RAID_VOL,
   ConfigPageIoc2RaidVol_t, MPI_POINTER pConfigPageIoc2RaidVol_t;
 
+/* IOC Page 2 Volume RAID Type values, also used in RAID Volume pages */
+
+#define MPI_RAID_VOL_TYPE_IS                        (0x00)
+#define MPI_RAID_VOL_TYPE_IME                       (0x01)
+#define MPI_RAID_VOL_TYPE_IM                        (0x02)
+
+/* IOC Page 2 Volume Flags values */
+
+#define MPI_IOCPAGE2_FLAG_VOLUME_INACTIVE           (0x08)
+
 /*
  * Host code (drivers, BIOS, utilities, etc.) should leave this define set to
  * one and check Header.PageLength at runtime.
@@ -522,7 +561,7 @@ typedef struct _CONFIG_PAGE_IOC_2
 } fCONFIG_PAGE_IOC_2, MPI_POINTER PTR_CONFIG_PAGE_IOC_2,
   IOCPage2_t, MPI_POINTER pIOCPage2_t;
 
-#define MPI_IOCPAGE2_PAGEVERSION                        (0x01)
+#define MPI_IOCPAGE2_PAGEVERSION                        (0x02)
 
 /* IOC Page 2 Capabilities flags */
 
@@ -533,12 +572,6 @@ typedef struct _CONFIG_PAGE_IOC_2
 #define MPI_IOCPAGE2_CAP_FLAGS_SAFTE_SUPPORT            (0x40000000)
 #define MPI_IOCPAGE2_CAP_FLAGS_CROSS_CHANNEL_SUPPORT    (0x80000000)
 
-/* IOC Page 2 Volume RAID Type values, also used in RAID Volume pages */
-
-#define MPI_RAID_VOL_TYPE_IS                        (0x00)
-#define MPI_RAID_VOL_TYPE_IME                       (0x01)
-#define MPI_RAID_VOL_TYPE_IM                        (0x02)
-
 
 typedef struct _IOC_3_PHYS_DISK
 {
@@ -599,6 +632,41 @@ typedef struct _CONFIG_PAGE_IOC_4
 #define MPI_IOCPAGE4_PAGEVERSION                        (0x00)
 
 
+typedef struct _IOC_5_HOT_SPARE
+{
+    U8                          PhysDiskNum;            /* 00h */
+    U8                          Reserved;               /* 01h */
+    U8                          HotSparePool;           /* 02h */
+    U8                          Flags;                   /* 03h */
+} IOC_5_HOT_SPARE, MPI_POINTER PTR_IOC_5_HOT_SPARE,
+  Ioc5HotSpare_t, MPI_POINTER pIoc5HotSpare_t;
+
+/* IOC Page 5 HotSpare Flags */
+#define MPI_IOC_PAGE_5_HOT_SPARE_ACTIVE                 (0x01)
+
+/*
+ * Host code (drivers, BIOS, utilities, etc.) should leave this define set to
+ * one and check Header.PageLength at runtime.
+ */
+#ifndef MPI_IOC_PAGE_5_HOT_SPARE_MAX
+#define MPI_IOC_PAGE_5_HOT_SPARE_MAX        (1)
+#endif
+
+typedef struct _CONFIG_PAGE_IOC_5
+{
+    fCONFIG_PAGE_HEADER         Header;                         /* 00h */
+    U32                         Reserved1;                      /* 04h */
+    U8                          NumHotSpares;                   /* 08h */
+    U8                          Reserved2;                      /* 09h */
+    U16                         Reserved3;                      /* 0Ah */
+    IOC_5_HOT_SPARE             HotSpare[MPI_IOC_PAGE_5_HOT_SPARE_MAX]; /* 0Ch */
+} fCONFIG_PAGE_IOC_5, MPI_POINTER PTR_CONFIG_PAGE_IOC_5,
+  IOCPage5_t, MPI_POINTER pIOCPage5_t;
+
+#define MPI_IOCPAGE5_PAGEVERSION                        (0x00)
+
+
+
 /****************************************************************************
 *   SCSI Port Config Pages
 ****************************************************************************/
@@ -698,11 +766,16 @@ typedef struct _CONFIG_PAGE_SCSI_DEVICE_0
 } fCONFIG_PAGE_SCSI_DEVICE_0, MPI_POINTER PTR_CONFIG_PAGE_SCSI_DEVICE_0,
   SCSIDevicePage0_t, MPI_POINTER pSCSIDevicePage0_t;
 
-#define MPI_SCSIDEVPAGE0_PAGEVERSION                    (0x02)
+#define MPI_SCSIDEVPAGE0_PAGEVERSION                    (0x03)
 
 #define MPI_SCSIDEVPAGE0_NP_IU                          (0x00000001)
 #define MPI_SCSIDEVPAGE0_NP_DT                          (0x00000002)
 #define MPI_SCSIDEVPAGE0_NP_QAS                         (0x00000004)
+#define MPI_SCSIDEVPAGE0_NP_HOLD_MCS                    (0x00000008)
+#define MPI_SCSIDEVPAGE0_NP_WR_FLOW                     (0x00000010)
+#define MPI_SCSIDEVPAGE0_NP_RD_STRM                     (0x00000020)
+#define MPI_SCSIDEVPAGE0_NP_RTI                         (0x00000040)
+#define MPI_SCSIDEVPAGE0_NP_PCOMP_EN                    (0x00000080)
 #define MPI_SCSIDEVPAGE0_NP_NEG_SYNC_PERIOD_MASK        (0x0000FF00)
 #define MPI_SCSIDEVPAGE0_NP_NEG_SYNC_OFFSET_MASK        (0x00FF0000)
 #define MPI_SCSIDEVPAGE0_NP_WIDE                        (0x20000000)
@@ -723,21 +796,24 @@ typedef struct _CONFIG_PAGE_SCSI_DEVICE_1
 } fCONFIG_PAGE_SCSI_DEVICE_1, MPI_POINTER PTR_CONFIG_PAGE_SCSI_DEVICE_1,
   SCSIDevicePage1_t, MPI_POINTER pSCSIDevicePage1_t;
 
-#define MPI_SCSIDEVPAGE1_PAGEVERSION                    (0x03)
+#define MPI_SCSIDEVPAGE1_PAGEVERSION                    (0x04)
 
 #define MPI_SCSIDEVPAGE1_RP_IU                          (0x00000001)
 #define MPI_SCSIDEVPAGE1_RP_DT                          (0x00000002)
 #define MPI_SCSIDEVPAGE1_RP_QAS                         (0x00000004)
+#define MPI_SCSIDEVPAGE1_RP_HOLD_MCS                    (0x00000008)
+#define MPI_SCSIDEVPAGE1_RP_WR_FLOW                     (0x00000010)
+#define MPI_SCSIDEVPAGE1_RP_RD_STRM                     (0x00000020)
+#define MPI_SCSIDEVPAGE1_RP_RTI                         (0x00000040)
+#define MPI_SCSIDEVPAGE1_RP_PCOMP_EN                    (0x00000080)
 #define MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK        (0x0000FF00)
 #define MPI_SCSIDEVPAGE1_RP_MAX_SYNC_OFFSET_MASK        (0x00FF0000)
 #define MPI_SCSIDEVPAGE1_RP_WIDE                        (0x20000000)
 #define MPI_SCSIDEVPAGE1_RP_AIP                         (0x80000000)
 
-#define MPI_SCSIDEVPAGE1_DV_LVD_DRIVE_STRENGTH_MASK     (0x00000003)
-#define MPI_SCSIDEVPAGE1_DV_SE_SLEW_RATE_MASK           (0x00000300)
-
 #define MPI_SCSIDEVPAGE1_CONF_WDTR_DISALLOWED           (0x00000002)
 #define MPI_SCSIDEVPAGE1_CONF_SDTR_DISALLOWED           (0x00000004)
+#define MPI_SCSIDEVPAGE1_CONF_EXTENDED_PARAMS_ENABLE    (0x00000008)
 
 
 typedef struct _CONFIG_PAGE_SCSI_DEVICE_2
@@ -749,7 +825,7 @@ typedef struct _CONFIG_PAGE_SCSI_DEVICE_2
 } fCONFIG_PAGE_SCSI_DEVICE_2, MPI_POINTER PTR_CONFIG_PAGE_SCSI_DEVICE_2,
   SCSIDevicePage2_t, MPI_POINTER pSCSIDevicePage2_t;
 
-#define MPI_SCSIDEVPAGE2_PAGEVERSION                    (0x00)
+#define MPI_SCSIDEVPAGE2_PAGEVERSION                    (0x01)
 
 #define MPI_SCSIDEVPAGE2_DV_ISI_ENABLE                  (0x00000010)
 #define MPI_SCSIDEVPAGE2_DV_SECONDARY_DRIVER_ENABLE     (0x00000020)
@@ -781,6 +857,22 @@ typedef struct _CONFIG_PAGE_SCSI_DEVICE_2
 #define MPI_SCSIDEVPAGE2_DPS_BIT_15_PL_SELECT_MASK      (0xC0000000)
 
 
+typedef struct _CONFIG_PAGE_SCSI_DEVICE_3
+{
+    fCONFIG_PAGE_HEADER      Header;                     /* 00h */
+    U16                     MsgRejectCount;             /* 04h */
+    U16                     PhaseErrorCount;            /* 06h */
+    U16                     ParityErrorCount;           /* 08h */
+    U16                     Reserved;                   /* 0Ah */
+} fCONFIG_PAGE_SCSI_DEVICE_3, MPI_POINTER PTR_CONFIG_PAGE_SCSI_DEVICE_3,
+  SCSIDevicePage3_t, MPI_POINTER pSCSIDevicePage3_t;
+
+#define MPI_SCSIDEVPAGE3_PAGEVERSION                    (0x00)
+
+#define MPI_SCSIDEVPAGE3_MAX_COUNTER                    (0xFFFE)
+#define MPI_SCSIDEVPAGE3_UNSUPPORTED_COUNTER            (0xFFFF)
+
+
 /****************************************************************************
 *   FC Port Config Pages
 ****************************************************************************/
@@ -804,10 +896,14 @@ typedef struct _CONFIG_PAGE_FC_PORT_0
     U64                     FabricWWPN;                 /* 38h */
     U32                     DiscoveredPortsCount;       /* 40h */
     U32                     MaxInitiators;              /* 44h */
+    U8                      MaxAliasesSupported;        /* 48h */
+    U8                      MaxHardAliasesSupported;    /* 49h */
+    U8                      NumCurrentAliases;          /* 4Ah */
+    U8                      Reserved1;                  /* 4Bh */
 } fCONFIG_PAGE_FC_PORT_0, MPI_POINTER PTR_CONFIG_PAGE_FC_PORT_0,
   FCPortPage0_t, MPI_POINTER pFCPortPage0_t;
 
-#define MPI_FCPORTPAGE0_PAGEVERSION                     (0x01)
+#define MPI_FCPORTPAGE0_PAGEVERSION                     (0x02)
 
 #define MPI_FCPORTPAGE0_FLAGS_PROT_MASK                 (0x0000000F)
 #define MPI_FCPORTPAGE0_FLAGS_PROT_FCP_INIT             (MPI_PORTFACTS_PROTOCOL_INITIATOR)
@@ -874,11 +970,14 @@ typedef struct _CONFIG_PAGE_FC_PORT_1
     U8                      HardALPA;                   /* 18h */
     U8                      LinkConfig;                 /* 19h */
     U8                      TopologyConfig;             /* 1Ah */
-    U8                      Reserved;                   /* 1Bh */
+    U8                      AltConnector;               /* 1Bh */
+    U8                      NumRequestedAliases;        /* 1Ch */
+    U8                      Reserved1;                  /* 1Dh */
+    U16                     Reserved2;                  /* 1Eh */
 } fCONFIG_PAGE_FC_PORT_1, MPI_POINTER PTR_CONFIG_PAGE_FC_PORT_1,
   FCPortPage1_t, MPI_POINTER pFCPortPage1_t;
 
-#define MPI_FCPORTPAGE1_PAGEVERSION                     (0x02)
+#define MPI_FCPORTPAGE1_PAGEVERSION                     (0x04)
 
 #define MPI_FCPORTPAGE1_FLAGS_EXT_FCP_STATUS_EN         (0x08000000)
 #define MPI_FCPORTPAGE1_FLAGS_IMMEDIATE_ERROR_REPLY     (0x04000000)
@@ -906,6 +1005,8 @@ typedef struct _CONFIG_PAGE_FC_PORT_1
 #define MPI_FCPORTPAGE1_TOPOLOGY_NPORT                  (0x02)
 #define MPI_FCPORTPAGE1_TOPOLOGY_AUTO                   (0x0F)
 
+#define MPI_FCPORTPAGE1_ALT_CONN_UNKNOWN                (0x00)
+
 
 typedef struct _CONFIG_PAGE_FC_PORT_2
 {
@@ -998,26 +1099,19 @@ typedef struct _CONFIG_PAGE_FC_PORT_5_ALIAS_INFO
   MPI_POINTER PTR_CONFIG_PAGE_FC_PORT_5_ALIAS_INFO,
   FcPortPage5AliasInfo_t, MPI_POINTER pFcPortPage5AliasInfo_t;
 
-/*
- * Host code (drivers, BIOS, utilities, etc.) should leave this define set to
- * one and check Header.PageLength at runtime.
- */
-#ifndef MPI_FC_PORT_PAGE_5_ALIAS_MAX
-#define MPI_FC_PORT_PAGE_5_ALIAS_MAX        (1)
-#endif
-
 typedef struct _CONFIG_PAGE_FC_PORT_5
 {
-    fCONFIG_PAGE_HEADER                  Header;                     /* 00h */
-    fCONFIG_PAGE_FC_PORT_5_ALIAS_INFO    AliasInfo[MPI_FC_PORT_PAGE_5_ALIAS_MAX];/* 04h */
+    fCONFIG_PAGE_HEADER                  Header;         /* 00h */
+    fCONFIG_PAGE_FC_PORT_5_ALIAS_INFO    AliasInfo;      /* 04h */
 } fCONFIG_PAGE_FC_PORT_5, MPI_POINTER PTR_CONFIG_PAGE_FC_PORT_5,
   FCPortPage5_t, MPI_POINTER pFCPortPage5_t;
 
-#define MPI_FCPORTPAGE5_PAGEVERSION                     (0x00)
-
-#define MPI_FCPORTPAGE5_FLAGS_ALIAS_ALPA_VALID          (0x01)
-#define MPI_FCPORTPAGE5_FLAGS_ALIAS_WWN_VALID           (0x02)
+#define MPI_FCPORTPAGE5_PAGEVERSION                     (0x01)
 
+#define MPI_FCPORTPAGE5_FLAGS_ALPA_ACQUIRED             (0x01)
+#define MPI_FCPORTPAGE5_FLAGS_HARD_ALPA                 (0x02)
+#define MPI_FCPORTPAGE5_FLAGS_HARD_WWNN                 (0x04)
+#define MPI_FCPORTPAGE5_FLAGS_HARD_WWPN                 (0x08)
 
 typedef struct _CONFIG_PAGE_FC_PORT_6
 {
@@ -1086,6 +1180,132 @@ typedef struct _CONFIG_PAGE_FC_PORT_9
 #define MPI_FCPORTPAGE9_PAGEVERSION                     (0x00)
 
 
+typedef struct _CONFIG_PAGE_FC_PORT_10_BASE_SFP_DATA
+{
+    U8                      Id;                         /* 10h */
+    U8                      ExtId;                      /* 11h */
+    U8                      Connector;                  /* 12h */
+    U8                      Transceiver[8];             /* 13h */
+    U8                      Encoding;                   /* 1Bh */
+    U8                      BitRate_100mbs;             /* 1Ch */
+    U8                      Reserved1;                  /* 1Dh */
+    U8                      Length9u_km;                /* 1Eh */
+    U8                      Length9u_100m;              /* 1Fh */
+    U8                      Length50u_10m;              /* 20h */
+    U8                      Length62p5u_10m;            /* 21h */
+    U8                      LengthCopper_m;             /* 22h */
+    U8                      Reseverved2;                /* 22h */
+    U8                      VendorName[16];             /* 24h */
+    U8                      Reserved3;                  /* 34h */
+    U8                      VendorOUI[3];               /* 35h */
+    U8                      VendorPN[16];               /* 38h */
+    U8                      VendorRev[4];               /* 48h */
+    U16                     Reserved4;                  /* 4Ch */
+    U8                      Reserved5;                  /* 4Eh */
+    U8                      CC_BASE;                    /* 4Fh */
+} fCONFIG_PAGE_FC_PORT_10_BASE_SFP_DATA,
+  MPI_POINTER PTR_CONFIG_PAGE_FC_PORT_10_BASE_SFP_DATA,
+  FCPortPage10BaseSfpData_t, MPI_POINTER pFCPortPage10BaseSfpData_t;
+
+#define MPI_FCPORT10_BASE_ID_UNKNOWN        (0x00)
+#define MPI_FCPORT10_BASE_ID_GBIC           (0x01)
+#define MPI_FCPORT10_BASE_ID_FIXED          (0x02)
+#define MPI_FCPORT10_BASE_ID_SFP            (0x03)
+#define MPI_FCPORT10_BASE_ID_SFP_MIN        (0x04)
+#define MPI_FCPORT10_BASE_ID_SFP_MAX        (0x7F)
+#define MPI_FCPORT10_BASE_ID_VEND_SPEC_MASK (0x80)
+
+#define MPI_FCPORT10_BASE_EXTID_UNKNOWN     (0x00)
+#define MPI_FCPORT10_BASE_EXTID_MODDEF1     (0x01)
+#define MPI_FCPORT10_BASE_EXTID_MODDEF2     (0x02)
+#define MPI_FCPORT10_BASE_EXTID_MODDEF3     (0x03)
+#define MPI_FCPORT10_BASE_EXTID_SEEPROM     (0x04)
+#define MPI_FCPORT10_BASE_EXTID_MODDEF5     (0x05)
+#define MPI_FCPORT10_BASE_EXTID_MODDEF6     (0x06)
+#define MPI_FCPORT10_BASE_EXTID_MODDEF7     (0x07)
+#define MPI_FCPORT10_BASE_EXTID_VNDSPC_MASK (0x80)
+
+#define MPI_FCPORT10_BASE_CONN_UNKNOWN      (0x00)
+#define MPI_FCPORT10_BASE_CONN_SC           (0x01)
+#define MPI_FCPORT10_BASE_CONN_COPPER1      (0x02)
+#define MPI_FCPORT10_BASE_CONN_COPPER2      (0x03)
+#define MPI_FCPORT10_BASE_CONN_BNC_TNC      (0x04)
+#define MPI_FCPORT10_BASE_CONN_COAXIAL      (0x05)
+#define MPI_FCPORT10_BASE_CONN_FIBERJACK    (0x06)
+#define MPI_FCPORT10_BASE_CONN_LC           (0x07)
+#define MPI_FCPORT10_BASE_CONN_MT_RJ        (0x08)
+#define MPI_FCPORT10_BASE_CONN_MU           (0x09)
+#define MPI_FCPORT10_BASE_CONN_SG           (0x0A)
+#define MPI_FCPORT10_BASE_CONN_OPT_PIGT     (0x0B)
+#define MPI_FCPORT10_BASE_CONN_RSV1_MIN     (0x0C)
+#define MPI_FCPORT10_BASE_CONN_RSV1_MAX     (0x1F)
+#define MPI_FCPORT10_BASE_CONN_HSSDC_II     (0x20)
+#define MPI_FCPORT10_BASE_CONN_CPR_PIGT     (0x21)
+#define MPI_FCPORT10_BASE_CONN_RSV2_MIN     (0x22)
+#define MPI_FCPORT10_BASE_CONN_RSV2_MAX     (0x7F)
+#define MPI_FCPORT10_BASE_CONN_VNDSPC_MASK  (0x80)
+
+#define MPI_FCPORT10_BASE_ENCODE_UNSPEC     (0x00)
+#define MPI_FCPORT10_BASE_ENCODE_8B10B      (0x01)
+#define MPI_FCPORT10_BASE_ENCODE_4B5B       (0x02)
+#define MPI_FCPORT10_BASE_ENCODE_NRZ        (0x03)
+#define MPI_FCPORT10_BASE_ENCODE_MANCHESTER (0x04)
+
+
+typedef struct _CONFIG_PAGE_FC_PORT_10_EXTENDED_SFP_DATA
+{
+    U8                      Options[2];                 /* 50h */
+    U8                      BitRateMax;                 /* 52h */
+    U8                      BitRateMin;                 /* 53h */
+    U8                      VendorSN[16];               /* 54h */
+    U8                      DateCode[8];                /* 64h */
+    U8                      Reserved5[3];               /* 6Ch */
+    U8                      CC_EXT;                     /* 6Fh */
+} fCONFIG_PAGE_FC_PORT_10_EXTENDED_SFP_DATA,
+  MPI_POINTER PTR_CONFIG_PAGE_FC_PORT_10_EXTENDED_SFP_DATA,
+  FCPortPage10ExtendedSfpData_t, MPI_POINTER pFCPortPage10ExtendedSfpData_t;
+
+#define MPI_FCPORT10_EXT_OPTION1_RATESEL    (0x20)
+#define MPI_FCPORT10_EXT_OPTION1_TX_DISABLE (0x10)
+#define MPI_FCPORT10_EXT_OPTION1_TX_FAULT   (0x08)
+#define MPI_FCPORT10_EXT_OPTION1_LOS_INVERT (0x04)
+#define MPI_FCPORT10_EXT_OPTION1_LOS        (0x02)
+
+
+typedef struct _CONFIG_PAGE_FC_PORT_10
+{
+    fCONFIG_PAGE_HEADER                          Header;             /* 00h */
+    U8                                          Flags;              /* 04h */
+    U8                                          Reserved1;          /* 05h */
+    U16                                         Reserved2;          /* 06h */
+    U32                                         HwConfig1;          /* 08h */
+    U32                                         HwConfig2;          /* 0Ch */
+    fCONFIG_PAGE_FC_PORT_10_BASE_SFP_DATA        Base;               /* 10h */
+    fCONFIG_PAGE_FC_PORT_10_EXTENDED_SFP_DATA    Extended;           /* 50h */
+    U8                                          VendorSpecific[32]; /* 70h */
+} fCONFIG_PAGE_FC_PORT_10, MPI_POINTER PTR_CONFIG_PAGE_FC_PORT_10,
+  FCPortPage10_t, MPI_POINTER pFCPortPage10_t;
+
+#define MPI_FCPORTPAGE10_PAGEVERSION                    (0x00)
+
+/* standard MODDEF pin definitions (from GBIC spec.) */
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF_MASK              (0x00000007)
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF2                  (0x00000001)
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF1                  (0x00000002)
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF0                  (0x00000004)
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF_NOGBIC            (0x00000007)
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF_CPR_IEEE_CX       (0x00000006)
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF_COPPER            (0x00000005)
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF_OPTICAL_LW        (0x00000004)
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF_SEEPROM           (0x00000003)
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF_SW_OPTICAL        (0x00000002)
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF_LX_IEEE_OPT_LW    (0x00000001)
+#define MPI_FCPORTPAGE10_FLAGS_MODDEF_SX_IEEE_OPT_SW    (0x00000000)
+
+#define MPI_FCPORTPAGE10_FLAGS_CC_BASE_OK               (0x00000010)
+#define MPI_FCPORTPAGE10_FLAGS_CC_EXT_OK                (0x00000020)
+
+
 /****************************************************************************
 *   FC Device Config Pages
 ****************************************************************************/
@@ -1155,6 +1375,7 @@ typedef struct _RAID_VOL0_STATUS
 #define MPI_RAIDVOL0_STATUS_FLAG_ENABLED                (0x01)
 #define MPI_RAIDVOL0_STATUS_FLAG_QUIESCED               (0x02)
 #define MPI_RAIDVOL0_STATUS_FLAG_RESYNC_IN_PROGRESS     (0x04)
+#define MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE        (0x08)
 
 #define MPI_RAIDVOL0_STATUS_STATE_OPTIMAL               (0x00)
 #define MPI_RAIDVOL0_STATUS_STATE_DEGRADED              (0x01)
@@ -1216,7 +1437,7 @@ typedef struct _CONFIG_PAGE_RAID_VOL_0
 } fCONFIG_PAGE_RAID_VOL_0, MPI_POINTER PTR_CONFIG_PAGE_RAID_VOL_0,
   RaidVolumePage0_t, MPI_POINTER pRaidVolumePage0_t;
 
-#define MPI_RAIDVOLPAGE0_PAGEVERSION                    (0x00)
+#define MPI_RAIDVOLPAGE0_PAGEVERSION                    (0x01)
 
 
 /****************************************************************************
index b505e70d4129460e02c61bd889a9485ad2f81272..7873657ba38c085b9071bc65ba6590450fce0787 100644 (file)
@@ -1,12 +1,12 @@
 /*
- *  Copyright (c) 2000-2001 LSI Logic Corporation.
+ *  Copyright (c) 2000-2002 LSI Logic Corporation.
  *
  *
  *           Name:  MPI_FC.H
  *          Title:  MPI Fibre Channel messages and structures
  *  Creation Date:  June 12, 2000
  *
- *    MPI Version:  01.02.02
+ *    MPI_FC.H Version:  01.02.03
  *
  *  Version History
  *  ---------------
@@ -35,6 +35,7 @@
  *  08-08-01  01.02.01  Original release for v1.2 work.
  *  09-28-01  01.02.02  Change name of reserved field in
  *                      MSG_LINK_SERVICE_RSP_REPLY.
+ *  05-31-02  01.02.03  Adding AliasIndex to FC Direct Access requests.
  *  --------------------------------------------------------------------------
  */
 
@@ -193,7 +194,7 @@ typedef struct _MSG_LINK_SERVICE_RSP_REPLY
 typedef struct _MSG_EXLINK_SERVICE_SEND_REQUEST
 {
     U8                      SendFlags;          /* 00h */
-    U8                      Reserved;           /* 01h */
+    U8                      AliasIndex;         /* 01h */
     U8                      ChainOffset;        /* 02h */
     U8                      Function;           /* 03h */
     U32                     MsgFlags_Did;       /* 04h */
@@ -212,7 +213,8 @@ typedef struct _MSG_EXLINK_SERVICE_SEND_REQUEST
 /* Extended Link Service Send Reply */
 typedef struct _MSG_EXLINK_SERVICE_SEND_REPLY
 {
-    U16                     Reserved;           /* 00h */
+    U8                      Reserved;           /* 00h */
+    U8                      AliasIndex;         /* 01h */
     U8                      MsgLength;          /* 02h */
     U8                      Function;           /* 03h */
     U16                     Reserved1;          /* 04h */
@@ -275,7 +277,7 @@ typedef struct _MSG_FC_ABORT_REPLY
 typedef struct _MSG_FC_COMMON_TRANSPORT_SEND_REQUEST
 {
     U8                      SendFlags;          /* 00h */
-    U8                      Reserved;           /* 01h */
+    U8                      AliasIndex;         /* 01h */
     U8                      ChainOffset;        /* 02h */
     U8                      Function;           /* 03h */
     U32                     MsgFlags_Did;       /* 04h */
@@ -297,7 +299,8 @@ typedef struct _MSG_FC_COMMON_TRANSPORT_SEND_REQUEST
 /* FC Common Transport Send Reply */
 typedef struct _MSG_FC_COMMON_TRANSPORT_SEND_REPLY
 {
-    U16                     Reserved;           /* 00h */
+    U8                      Reserved;           /* 00h */
+    U8                      AliasIndex;         /* 01h */
     U8                      MsgLength;          /* 02h */
     U8                      Function;           /* 03h */
     U16                     Reserved1;          /* 04h */
index c0558f1953c976cbde2eaeebe07552168736ad15..4b3256e4e7ace447d832a4c7258ff8e130edc2d2 100644 (file)
@@ -1,12 +1,12 @@
 /*
- *  Copyright (c) 2000-2001 LSI Logic Corporation.
+ *  Copyright (c) 2000-2002 LSI Logic Corporation.
  *
  *
  *           Name:  MPI_INIT.H
  *          Title:  MPI initiator mode messages and structures
  *  Creation Date:  June 8, 2000
  *
- *    MPI Version:  01.02.04
+ *    MPI_INIT.H Version:  01.02.05
  *
  *  Version History
  *  ---------------
@@ -29,6 +29,8 @@
  *  09-28-01  01.02.03  Added structures and defines for SCSI Enclosure
  *                      Processor messages.
  *  10-04-01  01.02.04  Added defines for SEP request Action field.
+ *  05-31-02  01.02.05  Added MPI_SCSIIO_MSGFLGS_CMD_DETERMINES_DATA_DIR define
+ *                      for SCSI IO requests.
  *  --------------------------------------------------------------------------
  */
 
@@ -67,16 +69,17 @@ typedef struct _MSG_SCSI_IO_REQUEST
   SCSIIORequest_t, MPI_POINTER pSCSIIORequest_t;
 
 
-/* SCSIO MsgFlags bits */
+/* SCSI IO MsgFlags bits */
 
-#define MPI_SCSIIO_MSGFLGS_SENSE_WIDTH          (0x01)
-#define MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_32       (0x00)
-#define MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_64       (0x01)
-#define MPI_SCSIIO_MSGFLGS_SENSE_LOCATION       (0x02)
-#define MPI_SCSIIO_MSGFLGS_SENSE_LOC_HOST       (0x00)
-#define MPI_SCSIIO_MSGFLGS_SENSE_LOC_IOC        (0x02)
+#define MPI_SCSIIO_MSGFLGS_SENSE_WIDTH              (0x01)
+#define MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_32           (0x00)
+#define MPI_SCSIIO_MSGFLGS_SENSE_WIDTH_64           (0x01)
+#define MPI_SCSIIO_MSGFLGS_SENSE_LOCATION           (0x02)
+#define MPI_SCSIIO_MSGFLGS_SENSE_LOC_HOST           (0x00)
+#define MPI_SCSIIO_MSGFLGS_SENSE_LOC_IOC            (0x02)
+#define MPI_SCSIIO_MSGFLGS_CMD_DETERMINES_DATA_DIR  (0x04)
 
-/* SCSIIO LUN fields */
+/* SCSI IO LUN fields */
 
 #define MPI_SCSIIO_LUN_FIRST_LEVEL_ADDRESSING   (0x0000FFFF)
 #define MPI_SCSIIO_LUN_SECOND_LEVEL_ADDRESSING  (0xFFFF0000)
@@ -85,7 +88,7 @@ typedef struct _MSG_SCSI_IO_REQUEST
 #define MPI_SCSIIO_LUN_LEVEL_1_WORD             (0xFF00)
 #define MPI_SCSIIO_LUN_LEVEL_1_DWORD            (0x0000FF00)
 
-/* SCSIO Control bits */
+/* SCSI IO Control bits */
 
 #define MPI_SCSIIO_CONTROL_DATADIRECTION_MASK   (0x03000000)
 #define MPI_SCSIIO_CONTROL_NODATATRANSFER       (0x00000000)
@@ -114,7 +117,7 @@ typedef struct _MSG_SCSI_IO_REQUEST
 #define MPI_SCSIIO_CONTROL_RESERVED2            (0x00010000)
 
 
-/* SCSIIO reply structure */
+/* SCSI IO reply structure */
 typedef struct _MSG_SCSI_IO_REPLY
 {
     U8                      TargetID;           /* 00h */
@@ -137,7 +140,7 @@ typedef struct _MSG_SCSI_IO_REPLY
   SCSIIOReply_t, MPI_POINTER pSCSIIOReply_t;
 
 
-/* SCSIIO Reply SCSIStatus values (SAM-2 status codes) */
+/* SCSI IO Reply SCSIStatus values (SAM-2 status codes) */
 
 #define MPI_SCSI_STATUS_SUCCESS                 (0x00)
 #define MPI_SCSI_STATUS_CHECK_CONDITION         (0x02)
@@ -151,7 +154,7 @@ typedef struct _MSG_SCSI_IO_REPLY
 #define MPI_SCSI_STATUS_ACA_ACTIVE              (0x30)
 
 
-/* SCSIIO Reply SCSIState values */
+/* SCSI IO Reply SCSIState values */
 
 #define MPI_SCSI_STATE_AUTOSENSE_VALID          (0x01)
 #define MPI_SCSI_STATE_AUTOSENSE_FAILED         (0x02)
@@ -160,7 +163,7 @@ typedef struct _MSG_SCSI_IO_REPLY
 #define MPI_SCSI_STATE_RESPONSE_INFO_VALID      (0x10)
 #define MPI_SCSI_STATE_QUEUE_TAG_REJECTED       (0x20)
 
-/* SCSIIO Reply ResponseInfo values */
+/* SCSI IO Reply ResponseInfo values */
 /* (FCP-1 RSP_CODE values and SPI-3 Packetized Failure codes) */
 
 #define MPI_SCSI_RSP_INFO_FUNCTION_COMPLETE     (0x00000000)
index ac117dc1da314cb359cb3c9827f57b0201f3fbdd..c58a4f4b83ca0c53f67dd8c4b9406ff0d85690e9 100644 (file)
@@ -1,12 +1,12 @@
 /*
- *  Copyright (c) 2000-2001 LSI Logic Corporation.
+ *  Copyright (c) 2000-2002 LSI Logic Corporation.
  *
  *
  *           Name:  MPI_IOC.H
  *          Title:  MPI IOC, Port, Event, FW Download, and FW Upload messages
  *  Creation Date:  August 11, 2000
  *
- *    MPI Version:  01.02.04
+ *    MPI_IOC.H Version:  01.02.06
  *
  *  Version History
  *  ---------------
  *                      MPI_FW_UPLOAD_ITYPE_NVDATA.
  *  09-28-01  01.02.03  Modified Event Data for Integrated RAID.
  *  11-01-01  01.02.04  Added defines for MPI_EXT_IMAGE_HEADER ImageType field.
+ *  03-14-02  01.02.05  Added HeaderVersion field to MSG_IOC_FACTS_REPLY.
+ *  05-31-02  01.02.06  Added define for
+ *                      MPI_IOCFACTS_EXCEPT_RAID_CONFIG_INVALID.
+ *                      Added AliasIndex to EVENT_DATA_LOGOUT structure.
  *  --------------------------------------------------------------------------
  */
 
@@ -151,7 +155,7 @@ typedef struct _MSG_IOC_FACTS_REPLY
     U16                     MsgVersion;                 /* 00h */
     U8                      MsgLength;                  /* 02h */
     U8                      Function;                   /* 03h */
-    U16                     Reserved;                   /* 04h */
+    U16                     HeaderVersion;              /* 04h */
     U8                      IOCNumber;                  /* 06h */
     U8                      MsgFlags;                   /* 07h */
     U32                     MsgContext;                 /* 08h */
@@ -183,7 +187,11 @@ typedef struct _MSG_IOC_FACTS_REPLY
 #define MPI_IOCFACTS_MSGVERSION_MAJOR_MASK          (0xFF00)
 #define MPI_IOCFACTS_MSGVERSION_MINOR_MASK          (0x00FF)
 
+#define MPI_IOCFACTS_HEADERVERSION_UNIT_MASK        (0xFF00)
+#define MPI_IOCFACTS_HEADERVERSION_DEV_MASK         (0x00FF)
+
 #define MPI_IOCFACTS_EXCEPT_CONFIG_CHECKSUM_FAIL    (0x0001)
+#define MPI_IOCFACTS_EXCEPT_RAID_CONFIG_INVALID     (0x0002)
 
 #define MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT         (0x01)
 
@@ -464,12 +472,15 @@ typedef struct _EVENT_DATA_LOOP_STATE
 typedef struct _EVENT_DATA_LOGOUT
 {
     U32                     NPortID;                    /* 00h */
-    U8                      Reserved;                   /* 04h */
+    U8                      AliasIndex;                 /* 04h */
     U8                      Port;                       /* 05h */
     U16                     Reserved1;                  /* 06h */
 } EVENT_DATA_LOGOUT, MPI_POINTER PTR_EVENT_DATA_LOGOUT,
   EventDataLogout_t, MPI_POINTER pEventDataLogout_t;
 
+#define MPI_EVENT_LOGOUT_ALL_ALIASES        (0xFF)
+
+
 /* MPI Integrated RAID Event data */
 
 typedef struct _EVENT_DATA_RAID
index 49d1d52838f7820dfa9d99abd14a29c0943e93a3..739c5cd71788531bb2830ba2428f86182bcef823 100644 (file)
@@ -1,12 +1,12 @@
 /*
- *  Copyright (c) 2000-2001 LSI Logic Corporation.
+ *  Copyright (c) 2000-2002 LSI Logic Corporation.
  *
  *
  *           Name:  MPI_LAN.H
  *          Title:  MPI LAN messages and structures
  *  Creation Date:  June 30, 2000
  *
- *    MPI Version:  01.02.01
+ *    MPI_LAN.H Version:  01.02.01
  *
  *  Version History
  *  ---------------
index a6248f2b4925dae6cb9021ed5d2c358a4a1071ed..c120cfae0f71be03b827751758b1857ae3fe961a 100644 (file)
@@ -1,12 +1,12 @@
 /*
- *  Copyright (c) 2001 LSI Logic Corporation.
+ *  Copyright (c) 2001-2002 LSI Logic Corporation.
  *
  *
  *           Name:  MPI_RAID.H
  *          Title:  MPI RAID message and structures
  *  Creation Date:  February 27, 2001
  *
- *    MPI Version:  01.02.04
+ *    MPI_RAID.H Version:  01.02.07
  *
  *  Version History
  *  ---------------
  *  10-04-01  01.02.03  Added ActionData defines for
  *                      MPI_RAID_ACTION_DELETE_VOLUME action.
  *  11-01-01  01.02.04  Added define for MPI_RAID_ACTION_ADATA_DO_NOT_SYNC.
+ *  03-14-02  01.02.05  Added define for MPI_RAID_ACTION_ADATA_LOW_LEVEL_INIT.
+ *  05-07-02  01.02.06  Added define for MPI_RAID_ACTION_ACTIVATE_VOLUME,
+ *                      MPI_RAID_ACTION_INACTIVATE_VOLUME, and
+ *                      MPI_RAID_ACTION_ADATA_INACTIVATE_ALL.
+ *  07-12-02  01.02.07  Added structures for Mailbox request and reply.
  *  --------------------------------------------------------------------------
  */
 
@@ -74,14 +79,20 @@ typedef struct _MSG_RAID_ACTION
 #define MPI_RAID_ACTION_DELETE_PHYSDISK             (0x0E)
 #define MPI_RAID_ACTION_FAIL_PHYSDISK               (0x0F)
 #define MPI_RAID_ACTION_REPLACE_PHYSDISK            (0x10)
+#define MPI_RAID_ACTION_ACTIVATE_VOLUME             (0x11)
+#define MPI_RAID_ACTION_INACTIVATE_VOLUME           (0x12)
 
 /* ActionDataWord defines for use with MPI_RAID_ACTION_CREATE_VOLUME action */
 #define MPI_RAID_ACTION_ADATA_DO_NOT_SYNC           (0x00000001)
+#define MPI_RAID_ACTION_ADATA_LOW_LEVEL_INIT        (0x00000002)
 
 /* ActionDataWord defines for use with MPI_RAID_ACTION_DELETE_VOLUME action */
 #define MPI_RAID_ACTION_ADATA_KEEP_PHYS_DISKS       (0x00000000)
 #define MPI_RAID_ACTION_ADATA_DEL_PHYS_DISKS        (0x00000001)
 
+/* ActionDataWord defines for use with MPI_RAID_ACTION_ACTIVATE_VOLUME action */
+#define MPI_RAID_ACTION_ADATA_INACTIVATE_ALL        (0x00000001)
+
 
 /* RAID Action reply message */
 
@@ -172,6 +183,42 @@ typedef struct _MSG_SCSI_IO_RAID_PT_REPLY
   SCSIIORaidPassthroughReply_t, MPI_POINTER pSCSIIORaidPassthroughReply_t;
 
 
+/****************************************************************************/
+/* Mailbox reqeust structure */
+/****************************************************************************/
+
+typedef struct _MSG_MAILBOX_REQUEST
+{
+    U16                     Reserved1;
+    U8                      ChainOffset;
+    U8                      Function;
+    U16                     Reserved2;
+    U8                      Reserved3;
+    U8                      MsgFlags;
+    U8                      Command[10];
+    U16                     Reserved4;
+    SGE_IO_UNION            SGL;
+} MSG_MAILBOX_REQUEST, MPI_POINTER PTR_MSG_MAILBOX_REQUEST,
+  MailboxRequest_t, MPI_POINTER pMailboxRequest_t;
+
+
+/* Mailbox reply structure */
+typedef struct _MSG_MAILBOX_REPLY
+{
+    U16                     Reserved1;          /* 00h */
+    U8                      MsgLength;          /* 02h */
+    U8                      Function;           /* 03h */
+    U16                     Reserved2;          /* 04h */
+    U8                      Reserved3;          /* 06h */
+    U8                      MsgFlags;           /* 07h */
+    U32                     MsgContext;         /* 08h */
+    U16                     MailboxStatus;      /* 0Ch */
+    U16                     IOCStatus;          /* 0Eh */
+    U32                     IOCLogInfo;         /* 10h */
+    U32                     Reserved4;          /* 14h */
+} MSG_MAILBOX_REPLY, MPI_POINTER PTR_MSG_MAILBOX_REPLY,
+  MailboxReply_t, MPI_POINTER pMailboxReply_t;
+
 #endif
 
 
index a009f1b075df81675ae95e03a042eb554d9ac7eb..cba82e8cf9c0790c5e44ac554c535eccf41f02a2 100644 (file)
@@ -1,12 +1,12 @@
 /*
- *  Copyright (c) 2000-2001 LSI Logic Corporation.
+ *  Copyright (c) 2000-2002 LSI Logic Corporation.
  *
  *
  *           Name:  MPI_TARG.H
  *          Title:  MPI Target mode messages and structures
  *  Creation Date:  June 22, 2000
  *
- *    MPI Version:  01.02.04
+ *    MPI_TARG.H Version:  01.02.06
  *
  *  Version History
  *  ---------------
  *                      of MPI.
  *  10-04-01  01.02.03  Added PriorityReason to MSG_TARGET_ERROR_REPLY.
  *  11-01-01  01.02.04  Added define for TARGET_STATUS_SEND_FLAGS_HIGH_PRIORITY.
+ *  03-14-02  01.02.05  Modified MPI_TARGET_FCP_RSP_BUFFER to get the proper
+ *                      byte ordering.
+ *  05-31-02  01.02.06  Modified TARGET_MODE_REPLY_ALIAS_MASK to only include
+ *                      one bit.
+ *                      Added AliasIndex field to MPI_TARGET_FCP_CMD_BUFFER.
  *  --------------------------------------------------------------------------
  */
 
@@ -161,6 +166,9 @@ typedef struct _MPI_TARGET_FCP_CMD_BUFFER
     U8      FcpCntl[4];                                 /* 08h */
     U8      FcpCdb[16];                                 /* 0Ch */
     U32     FcpDl;                                      /* 1Ch */
+    U8      AliasIndex;                                 /* 20h */
+    U8      Reserved1;                                  /* 21h */
+    U16     Reserved2;                                  /* 22h */
 } MPI_TARGET_FCP_CMD_BUFFER, MPI_POINTER PTR_MPI_TARGET_FCP_CMD_BUFFER,
   MpiTargetFcpCmdBuffer, MPI_POINTER pMpiTargetFcpCmdBuffer;
 
@@ -255,12 +263,16 @@ typedef struct _MSG_TARGET_STATUS_SEND_REQUEST
 #define TARGET_STATUS_SEND_FLAGS_HIGH_PRIORITY      (0x04)
 #define TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER  (0x80)
 
+/*
+ * NOTE: FCP_RSP data is big-endian. When used on a little-endian system, this
+ * structure properly orders the bytes.
+ */
 typedef struct _MPI_TARGET_FCP_RSP_BUFFER
 {
     U8      Reserved0[8];                               /* 00h */
-    U8      FcpStatus;                                  /* 08h */
-    U8      FcpFlags;                                   /* 09h */
-    U8      Reserved1[2];                               /* 0Ah */
+    U8      Reserved1[2];                               /* 08h */
+    U8      FcpFlags;                                   /* 0Ah */
+    U8      FcpStatus;                                  /* 0Bh */
     U32     FcpResid;                                   /* 0Ch */
     U32     FcpSenseLength;                             /* 10h */
     U32     FcpResponseLength;                          /* 14h */
@@ -269,6 +281,10 @@ typedef struct _MPI_TARGET_FCP_RSP_BUFFER
 } MPI_TARGET_FCP_RSP_BUFFER, MPI_POINTER PTR_MPI_TARGET_FCP_RSP_BUFFER,
   MpiTargetFcpRspBuffer, MPI_POINTER pMpiTargetFcpRspBuffer;
 
+/*
+ * NOTE: The SPI status IU is big-endian. When used on a little-endian system,
+ * this structure properly orders the bytes.
+ */
 typedef struct _MPI_TARGET_SCSI_SPI_STATUS_IU
 {
     U8      Reserved0;                                  /* 00h */
@@ -332,7 +348,7 @@ typedef struct _MSG_TARGET_MODE_ABORT_REPLY
 #define TARGET_MODE_REPLY_IO_INDEX_SHIFT        (0)
 #define TARGET_MODE_REPLY_INITIATOR_INDEX_MASK  (0x03FFC000)
 #define TARGET_MODE_REPLY_INITIATOR_INDEX_SHIFT (14)
-#define TARGET_MODE_REPLY_ALIAS_MASK            (0x0C000000)
+#define TARGET_MODE_REPLY_ALIAS_MASK            (0x04000000)
 #define TARGET_MODE_REPLY_ALIAS_SHIFT           (26)
 #define TARGET_MODE_REPLY_PORT_MASK             (0x10000000)
 #define TARGET_MODE_REPLY_PORT_SHIFT            (28)
index 22d454d0642737750bf3069c73ccbd6280237474..7e94ee9d3625cf87cf475aa4e0eef62995f199db 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2000-2001 LSI Logic Corporation.
+ *  Copyright (c) 2000-2002 LSI Logic Corporation.
  *
  *
  *           Name:  MPI_TYPE.H
index a92f816b716845248421fa13c7ad68f3d984a9f4..ce9b51808a144f5c4f2aad30a7f03cc75a904929 100644 (file)
@@ -49,7 +49,7 @@
  *  (mailto:sjralston1@netscape.net)
  *  (mailto:Pam.Delaney@lsil.com)
  *
- *  $Id: mptbase.c,v 1.119 2002/06/20 13:28:15 pdelaney Exp $
+ *  $Id: mptbase.c,v 1.121 2002/07/23 18:56:59 pdelaney Exp $
  */
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
@@ -437,8 +437,9 @@ mpt_interrupt(int irq, void *bus_id, struct pt_regs *r)
                        pa = 0;                                 /* No reply flush! */
                }
 
+#ifdef MPT_DEBUG_IRQ
                if ((int)ioc->chip_type > (int)FC929) {
-                       /* Verify mf, mf are reasonable.
+                       /* Verify mf, mr are reasonable.
                         */
                        if ((mf) && ((mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))
                                || (mf < ioc->req_frames)) ) {
@@ -464,6 +465,7 @@ mpt_interrupt(int irq, void *bus_id, struct pt_regs *r)
                                freeme = 0;
                        }
                }
+#endif
 
                /*  Check for (valid) IO callback!  */
                if (cb_idx) {
@@ -1602,7 +1604,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
 
        if (reason == MPT_HOSTEVENT_IOC_BRINGUP){
                if (ioc->upload_fw) {
-                       dprintk((MYIOC_s_INFO_FMT
+                       ddlprintk((MYIOC_s_INFO_FMT
                                "firmware upload required!\n", ioc->name));
 
                        r = mpt_do_upload(ioc, sleepFlag);
@@ -1788,6 +1790,16 @@ mpt_adapter_disable(MPT_ADAPTER *this, int freeup)
                                (void) KickStart(this, 1, NO_SLEEP);
                }
 
+               if (this->cached_fw != NULL) {
+                       ddlprintk((KERN_INFO MYNAM ": Pushing FW onto adapter\n"));
+
+                       if ((state = mpt_downloadboot(this, NO_SLEEP)) < 0) {
+                               printk(KERN_WARNING MYNAM 
+                                       ": firmware downloadboot failure (%d)!\n", state);
+                       }
+               }
+
+
                /* Disable adapter interrupts! */
                CHIPREG_WRITE32(&this->chip->IntMask, 0xFFFFFFFF);
                this->active = 0;
@@ -1994,8 +2006,19 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
        }
 
        /* Is it already READY? */
-       if (!statefault && (ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY)
-               return 0;
+       if (!statefault && (ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY) {
+               if ((int)ioc->chip_type <= (int)FC929)
+                       return 0;
+               else {
+                       /* Workaround from broken 1030 FW.
+                        * Force a diagnostic reset if fails.
+                        */
+                       if ((r = SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) == 0)
+                               return 0;
+                       else
+                               statefault = 4;
+               }
+       } 
 
        /*
         *      Check to see if IOC is in FAULT state.
@@ -2376,6 +2399,8 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
                else 
                        ioc->upload_fw = 1;
        }
+       ddlprintk((MYIOC_s_INFO_FMT "flags %d, upload_fw %d \n", 
+                  ioc->name, ioc_init.Flags, ioc->upload_fw));
 
        if ((int)ioc->chip_type <= (int)FC929) {
                ioc_init.MaxDevices = MPT_MAX_FC_DEVICES;
@@ -2688,7 +2713,7 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
        }
        ioc->alloc_total += alloc_sz;
 
-       dprintk((KERN_INFO MYNAM ": FW Image  @ %p, sz=%d bytes\n",
+       ddlprintk((KERN_INFO MYNAM ": FW Image  @ %p, sz=%d bytes\n",
                 (void *)(ulong)ioc->cached_fw, ioc->facts.FWImageSize));
 
        prequest = (FWUpload_t *)&request;
@@ -2748,7 +2773,7 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
                                cmdStatus = 0;
                }
        }
-       dprintk((MYIOC_s_INFO_FMT ": do_upload status %d \n",
+       ddlprintk((MYIOC_s_INFO_FMT ": do_upload status %d \n",
                        ioc->name, cmdStatus));
 
        /* Check to see if we have a copy of this image in
@@ -2766,7 +2791,7 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
         */
        if (cmdStatus || freeMem) {
 
-               dprintk((MYIOC_s_INFO_FMT ": do_upload freeing %s image \n",
+               ddlprintk((MYIOC_s_INFO_FMT ": do_upload freeing %s image \n",
                        ioc->name, cmdStatus ? "incomplete" : "duplicate"));
                mpt_free_fw_memory(ioc, NULL);
                ioc->cached_fw = NULL;
@@ -2809,20 +2834,20 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
        int                      max_idx, fw_idx, ext_idx;
        int                      left_u32s;
 
-       dprintk((MYIOC_s_INFO_FMT "DbGb0: downloadboot entered.\n",
+       ddlprintk((MYIOC_s_INFO_FMT "DbGb0: downloadboot entered.\n",
                                ioc->name));
 #ifdef MPT_DEBUG
        diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
        if (ioc->alt_ioc)
                diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic);
-       dprintk((MYIOC_s_INFO_FMT "DbGb1: diag0=%08x, diag1=%08x\n",
+       ddlprintk((MYIOC_s_INFO_FMT "DbGb1: diag0=%08x, diag1=%08x\n",
                                ioc->name, diag0val, diag1val));
 #endif
 
-       dprintk((MYIOC_s_INFO_FMT "fw size 0x%x, ioc FW Ptr %p\n",
+       ddlprintk((MYIOC_s_INFO_FMT "fw size 0x%x, ioc FW Ptr %p\n",
                                ioc->name, ioc->facts.FWImageSize, ioc->cached_fw));
        if (ioc->alt_ioc)
-               dprintk((MYIOC_s_INFO_FMT "alt ioc FW Ptr %p\n",
+               ddlprintk((MYIOC_s_INFO_FMT "alt ioc FW Ptr %p\n",
                                ioc->name, ioc->alt_ioc->cached_fw));
 
        /* Get dma_addr and data transfer size.
@@ -2831,13 +2856,13 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
                return -1;
 
        /* Get the DMA from ioc or ioc->alt_ioc */
-       if (ioc->cached_fw == NULL)
+       if (ioc->cached_fw != NULL)
                pCached = (fw_image_t **)ioc->cached_fw;
-       else if (ioc->alt_ioc && ioc->alt_ioc->cached_fw)
+       else if (ioc->alt_ioc && (ioc->alt_ioc->cached_fw != NULL))
                pCached = (fw_image_t **)ioc->alt_ioc->cached_fw;
 
-       dprintk((MYIOC_s_INFO_FMT "DbGb2: FW Image @ %p\n",
-                       ioc->name, FwHdr));
+       ddlprintk((MYIOC_s_INFO_FMT "DbGb2: FW Image @ %p\n",
+                       ioc->name, pCached));
        if (!pCached)
                return -2;
 
@@ -2872,10 +2897,10 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
 #ifdef MPT_DEBUG
                if (ioc->alt_ioc)
                        diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic);
-               dprintk((MYIOC_s_INFO_FMT "DbGb3: diag0=%08x, diag1=%08x\n",
+               ddlprintk((MYIOC_s_INFO_FMT "DbGb3: diag0=%08x, diag1=%08x\n",
                                ioc->name, diag0val, diag1val));
 #endif
-               dprintk((MYIOC_s_INFO_FMT "Wrote magic DiagWriteEn sequence (%x)\n",
+               ddlprintk((MYIOC_s_INFO_FMT "Wrote magic DiagWriteEn sequence (%x)\n",
                                ioc->name, diag0val));
        }
 
@@ -2886,18 +2911,11 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
 #ifdef MPT_DEBUG
        if (ioc->alt_ioc)
                diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic);
-       dprintk((MYIOC_s_INFO_FMT "DbGb3: diag0=%08x, diag1=%08x\n",
+
+       ddlprintk((MYIOC_s_INFO_FMT "DbGb3: diag0=%08x, diag1=%08x\n",
                        ioc->name, diag0val, diag1val));
 #endif
 
-       /* Write the LoadStartAddress to the DiagRw Address Register
-        * using Programmed IO
-        */
-       CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, FwHdr->LoadStartAddress);
-       dprintk((MYIOC_s_INFO_FMT "LoadStart addr written 0x%x \n",
-               ioc->name, FwHdr->LoadStartAddress));
-#if 1
-
        /* max_idx = 1 + maximum valid buffer index
         */
        max_idx = 0;
@@ -2910,7 +2928,14 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
        count = (FwHdr->ImageSize + 3)/4;
        nextImage = FwHdr->NextImageHeaderOffset;
 
-       dprintk((MYIOC_s_INFO_FMT "Write FW Image: 0x%x u32's @ %p\n",
+       /* Write the LoadStartAddress to the DiagRw Address Register
+        * using Programmed IO
+        */
+       CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, FwHdr->LoadStartAddress);
+       ddlprintk((MYIOC_s_INFO_FMT "LoadStart addr written 0x%x \n",
+               ioc->name, FwHdr->LoadStartAddress));
+
+       ddlprintk((MYIOC_s_INFO_FMT "Write FW Image: 0x%x u32's @ %p\n",
                                ioc->name, count, ptru32));
        left_u32s = pCached[fw_idx]->size/4;
        while (count--) {
@@ -2997,7 +3022,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
                        count = (count +3)/4;
                }
 
-               dprintk((MYIOC_s_INFO_FMT "Write Ext Image: 0x%x u32's @ %p\n",
+               ddlprintk((MYIOC_s_INFO_FMT "Write Ext Image: 0x%x u32's @ %p\n",
                                                ioc->name, count, ptru32));
                CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr);
 
@@ -3019,35 +3044,12 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
                }
        }
 
-#else
-       while (nextImage) {
-
-               /* Set the pointer to the extended image
-                */
-               ExtHdr = (MpiExtImageHeader_t *) ((char *) FwHdr + nextImage);
-
-               CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, ExtHdr->LoadStartAddress);
-
-               count = (ExtHdr->ImageSize + 3 )/4;
-
-               ptru32 = (u32 *) ExtHdr;
-               dprintk((MYIOC_s_INFO_FMT "Write Ext Image: 0x%x u32's @ %p\n",
-                               ioc->name, count, ptru32));
-               while (count-- ) {
-                       CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptru32);
-                       ptru32++;
-               }
-               nextImage = ExtHdr->NextImageHeaderOffset;
-       }
-#endif
-
-
        /* Write the IopResetVectorRegAddr */
-       dprintk((MYIOC_s_INFO_FMT "Write IopResetVector Addr! \n", ioc->name));
+       ddlprintk((MYIOC_s_INFO_FMT "Write IopResetVector Addr! \n", ioc->name));
        CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, FwHdr->IopResetRegAddr);
 
        /* Write the IopResetVectorValue */
-       dprintk((MYIOC_s_INFO_FMT "Write IopResetVector Value! \n", ioc->name));
+       ddlprintk((MYIOC_s_INFO_FMT "Write IopResetVector Value! \n", ioc->name));
        CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, FwHdr->IopResetVectorValue);
 
        /* Clear the internal flash bad bit - autoincrementing register,
@@ -3182,6 +3184,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
                        /* Write magic sequence to WriteSequence register
                         * Loop until in diagnostic mode
                         */
+                       CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF);
                        CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE);
                        CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_2ND_KEY_VALUE);
                        CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_3RD_KEY_VALUE);
@@ -3217,7 +3220,11 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
                                ioc->name, diag0val, diag1val));
 #endif
                /* Write the PreventIocBoot bit */
+#if 1
+               if ((ioc->cached_fw) || (ioc->alt_ioc && ioc->alt_ioc->cached_fw)) {
+#else
                if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) {
+#endif
                        diag0val |= MPI_DIAG_PREVENT_IOC_BOOT;
                        CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val);
                }
@@ -3263,7 +3270,11 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
                        /* FIXME?  Examine results here? */
                }
 
+#if 1
+               if ((ioc->cached_fw) || (ioc->alt_ioc && ioc->alt_ioc->cached_fw)) {
+#else
                if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) {
+#endif
                        /* If the DownloadBoot operation fails, the
                         * IOC will be left unusable. This is a fatal error
                         * case.  _diag_reset will return < 0
@@ -5274,6 +5285,9 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
                printk(KERN_WARNING MYNAM ": WARNING - (%d) Cannot recover %s\n",
                        rc, ioc->name);
        }
+       ioc->reload_fw = 0;
+       if (ioc->alt_ioc)
+               ioc->alt_ioc->reload_fw = 0;
 
        spin_lock_irqsave(&ioc->diagLock, flags);
        ioc->diagPending = 0;
@@ -5612,8 +5626,46 @@ mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info)
 static void
 mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info)
 {
-       /* FIXME! */
-       printk(MYIOC_s_INFO_FMT "LogInfo(0x%08x)\n", ioc->name, log_info);
+       u32 info = log_info & 0x00FF0000;
+       char *desc = "unknown";
+
+       switch (info) {
+       case 0x00010000:
+               desc = "bug! MID not found";
+               if (ioc->reload_fw == 0)
+                       ioc->reload_fw++;
+               break;
+
+       case 0x00020000:
+               desc = "Parity Error";
+               break;
+
+       case 0x00030000:
+               desc = "ASYNC Outbound Overrun";
+               break;
+
+       case 0x00040000:
+               desc = "SYNC Offset Error";
+               break;
+
+       case 0x00050000:
+               desc = "BM Change";
+               break;
+
+       case 0x00060000:
+               desc = "Msg In Overflow";
+               break;
+
+       case 0x00070000:
+               desc = "DMA Error";
+               break;
+
+       case 0x00080000:
+               desc = "Outbound DMA Overrun";
+               break;
+       }
+
+       printk(MYIOC_s_INFO_FMT "LogInfo(0x%08x): F/W: %s\n", ioc->name, log_info, desc);
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
index 9b5f558a5043844cae51621c46497db90c4ef4cb..ec1b82c569bda56d601cbee83c3331ca4aa580b3 100644 (file)
@@ -13,7 +13,7 @@
  *  (mailto:sjralston1@netscape.net)
  *  (mailto:Pam.Delaney@lsil.com)
  *
- *  $Id: mptbase.h,v 1.123 2002/06/20 13:28:16 pdelaney Exp $
+ *  $Id: mptbase.h,v 1.133 2002/09/05 22:30:09 pdelaney Exp $
  */
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
@@ -80,8 +80,8 @@
 #define COPYRIGHT      "Copyright (c) 1999-2002 " MODULEAUTHOR
 #endif
 
-#define MPT_LINUX_VERSION_COMMON       "2.01.06"
-#define MPT_LINUX_PACKAGE_NAME         "@(#)mptlinux-2.01.06"
+#define MPT_LINUX_VERSION_COMMON       "2.02.01.01"
+#define MPT_LINUX_PACKAGE_NAME         "@(#)mptlinux-2.02.01.01"
 #define WHAT_MAGIC_STRING              "@" "(" "#" ")"
 
 #define show_mptmod_ver(s,ver)  \
@@ -379,7 +379,11 @@ typedef struct _VirtDevice {
        u8                       maxWidth;      /* 0 if narrow, 1 if wide*/
        u8                       negoFlags;     /* bit field, 0 if WDTR/SDTR/QAS allowed */
        u8                       raidVolume;    /* set, if RAID Volume */
+#ifdef ABORT_FIX
+       u8                       numAborts;
+#else
        u8                       rsvd;
+#endif
        u16                      rsvd1raid;
        int                      npaths;
        u16                      fc_phys_lun;
@@ -422,6 +426,7 @@ typedef struct _VirtDevice {
 #define MPT_TARGET_FLAGS_VALID_INQUIRY 0x02
 #define MPT_TARGET_FLAGS_VALID_SENSE   0x04
 #define MPT_TARGET_FLAGS_Q_YES         0x08
+#define MPT_TARGET_FLAGS_VALID_56      0x10
 
 #define MPT_TARGET_NO_NEGO_WIDE                0x01
 #define MPT_TARGET_NO_NEGO_SYNC                0x02
@@ -511,7 +516,7 @@ typedef struct _mpt_ioctl_events {
 #define MPT_SCSICFG_NEGOTIATE          0x01    /* Negotiate on next IO */
 #define MPT_SCSICFG_NEED_DV            0x02    /* Schedule DV */
 #define MPT_SCSICFG_DV_PENDING         0x04    /* DV on this physical id pending */
-#define MPT_SCSICFG_DV_DONE            0x08    /* DV on this physical id complete */
+#define MPT_SCSICFG_DV_NOT_DONE                0x08    /* DV has not been performed */
 #define MPT_SCSICFG_BLK_NEGO           0x10    /* WriteSDP1 with WDTR and SDTR disabled */
 
                                                /* Args passed to writeSDP1: */
@@ -622,7 +627,8 @@ typedef struct _MPT_ADAPTER
        LANPage1_t               lan_cnfg_page1;
        u8                       FirstWhoInit;
        u8                       upload_fw;     /* If set, do a fw upload */
-       u8                       pad1[6];
+       u8                       reload_fw;     /* Force a FW Reload on next reset */
+       u8                       pad1[5];
 } MPT_ADAPTER;
 
 
@@ -707,6 +713,13 @@ typedef struct _mpt_sge {
 #define dsgprintk(x)
 #endif
 
+#if defined(MPT_DEBUG_DL) || defined(MPT_DEBUG)
+#define ddlprintk(x)  printk x
+#else
+#define ddlprintk(x)
+#endif
+
+
 #ifdef MPT_DEBUG_DV
 #define ddvprintk(x)  printk x
 #else
index 4e1b0b0f9876f42dc79a04041591874202524ae5..9323bf50f7ef9465364ce1d075a8cd52428cab7b 100644 (file)
@@ -34,7 +34,7 @@
  *  (mailto:sjralston1@netscape.net)
  *  (mailto:Pam.Delaney@lsil.com)
  *
- *  $Id: mptctl.c,v 1.55 2002/06/20 13:28:16 pdelaney Exp $
+ *  $Id: mptctl.c,v 1.59 2002/09/05 22:30:10 pdelaney Exp $
  */
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
@@ -637,8 +637,8 @@ mptctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned
        iocnumX = khdr.iocnum & 0xFF;
        if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||
            (iocp == NULL)) {
-               printk(KERN_ERR "%s::mptctl_ioctl() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnumX);
+               dtmprintk((KERN_ERR "%s::mptctl_ioctl() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnumX));
                return -ENODEV;
        }
 
@@ -708,9 +708,9 @@ static int mptctl_do_reset(unsigned long arg)
        }
 
        if (mpt_verify_adapter(krinfo.hdr.iocnum, &iocp) < 0) {
-               printk(KERN_ERR "%s@%d::mptctl_do_reset - ioc%d not found!\n",
-                               __FILE__, __LINE__, krinfo.hdr.iocnum);
-               return -ENXIO; /* (-6) No such device or address */
+               dtmprintk((KERN_ERR "%s@%d::mptctl_do_reset - ioc%d not found!\n",
+                               __FILE__, __LINE__, krinfo.hdr.iocnum));
+               return -ENODEV; /* (-6) No such device or address */
        }
 
        if (mpt_HardResetHandler(iocp, NO_SLEEP) != 0) {
@@ -816,9 +816,9 @@ mptctl_do_fw_download(int ioc, char *ufwbuf, size_t fwlen)
        dctlprintk((KERN_INFO "DbG: kfwdl.ioc   = %04xh\n", ioc));
 
        if ((ioc = mpt_verify_adapter(ioc, &iocp)) < 0) {
-               printk("%s@%d::_ioctl_fwdl - ioc%d not found!\n",
-                               __FILE__, __LINE__, ioc);
-               return -ENXIO; /* (-6) No such device or address */
+               dtmprintk(("%s@%d::_ioctl_fwdl - ioc%d not found!\n",
+                               __FILE__, __LINE__, ioc));
+               return -ENODEV; /* (-6) No such device or address */
        }
 
        /*  Valid device. Get a message frame and construct the FW download message.
@@ -1252,8 +1252,8 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
 
        if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_getiocinfo() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_getiocinfo() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -1379,8 +1379,8 @@ mptctl_gettargetinfo (unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_gettargetinfo() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_gettargetinfo() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -1510,8 +1510,8 @@ mptctl_readtest (unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_readtest() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_readtest() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -1568,8 +1568,8 @@ mptctl_eventquery (unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_eventquery() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_eventquery() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -1606,8 +1606,8 @@ mptctl_eventenable (unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_eventenable() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_eventenable() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -1654,8 +1654,8 @@ mptctl_eventreport (unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_eventreport() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_eventreport() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -1708,8 +1708,8 @@ mptctl_replace_fw (unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_replace_fw() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_replace_fw() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -1794,8 +1794,8 @@ mptctl_mpt_command (unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_mpt_command() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_mpt_command() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -1842,8 +1842,8 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
 
        if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_do_mpt_command() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_do_mpt_command() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
        if (!ioc->ioctl) {
@@ -1948,10 +1948,6 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, char *mfPtr, int local)
 
                        if (pTarget &&(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
                                qtag = MPI_SCSIIO_CONTROL_SIMPLEQ;
-                       else {
-                               rc = -EPERM;
-                               goto done_free_mem;
-                       }
 
                        /* Have the IOCTL driver set the direction based
                         * on the dataOutSize (ordering issue with Sparc).
@@ -2334,7 +2330,7 @@ done_free_mem:
                        this_sge++;     /* go to next structure */
                        this_alloc = bufOut.len;
                        pci_free_consistent(ioc->pcidev,
-                               this_alloc, (void *) &bufOut, dma_addr);
+                               this_alloc, (void *) bufOut.kptr, dma_addr);
                }
 
                if (bufIn.kptr != NULL ) {
@@ -2342,7 +2338,7 @@ done_free_mem:
                        this_alloc = bufIn.len;
 
                        pci_free_consistent(ioc->pcidev,
-                                       this_alloc, (void *) &bufIn, dma_addr);
+                                       this_alloc, (void *) bufIn.kptr, dma_addr);
                }
 
                this_alloc = sgSize * sizeof(MptSge_t);
@@ -2393,8 +2389,8 @@ mptctl_compaq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||
            (iocp == NULL)) {
-               printk(KERN_ERR "%s::mptctl_compaq_ioctl() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnumX);
+               dtmprintk((KERN_ERR "%s::mptctl_compaq_ioctl() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnumX));
                return -ENODEV;
        }
 
@@ -2466,8 +2462,8 @@ mptctl_cpq_getpciinfo(unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(iocnumX, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_pciinfo() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_pciinfo() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -2567,8 +2563,8 @@ mptctl_cpq_getdriver(unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(iocnumX, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_cpq_getdriver() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_cpq_getdriver() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -2631,8 +2627,8 @@ mptctl_cpq_ctlr_status(unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(iocnumX, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_cpq_ctlr_status() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_cpq_ctlr_status() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -2687,8 +2683,8 @@ mptctl_cpq_target_address(unsigned long arg)
 
        if (((iocnum = mpt_verify_adapter(iocnumX, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_cpq_target_address() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_cpq_target_address() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -2790,8 +2786,8 @@ mptctl_cpq_passthru(unsigned long arg)
        iocnumX = karg.lc & 0xFF;
        if (((iocnum = mpt_verify_adapter(iocnumX, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR "%s::mptctl_cpq_passthru() @%d - ioc%d not found!\n",
-                               __FILE__, __LINE__, iocnum);
+               dtmprintk((KERN_ERR "%s::mptctl_cpq_passthru() @%d - ioc%d not found!\n",
+                               __FILE__, __LINE__, iocnum));
                return -ENODEV;
        }
 
@@ -2920,12 +2916,12 @@ mptctl_compaq_scsiio(VENDOR_IOCTL_REQ *pVenReq, cpqfc_passthru_t *pPass)
 
 static struct file_operations mptctl_fops = {
        owner_THIS_MODULE
-       llseek:         no_llseek,
-       read:           mptctl_read,
-       write:          mptctl_write,
-       ioctl:          mptctl_ioctl,
-       open:           mptctl_open,
-       release:        mptctl_release,
+       .llseek =       no_llseek,
+       .read =         mptctl_read,
+       .write =        mptctl_write,
+       .ioctl =        mptctl_ioctl,
+       .open =         mptctl_open,
+       .release =      mptctl_release,
 };
 
 static struct miscdevice mptctl_miscdev = {
@@ -2975,8 +2971,8 @@ sparc32_mptfwxfer_ioctl(unsigned int fd, unsigned int cmd,
        iocnumX = kfw32.iocnum & 0xFF;
        if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||
            (iocp == NULL)) {
-               printk(KERN_ERR MYNAM "::sparc32_mptfwxfer_ioctl @%d - ioc%d not found!\n",
-                               __LINE__, iocnumX);
+               dtmprintk((KERN_ERR MYNAM "::sparc32_mptfwxfer_ioctl @%d - ioc%d not found!\n",
+                               __LINE__, iocnumX));
                return -ENODEV;
        }
 
@@ -3015,8 +3011,8 @@ sparc32_mpt_command(unsigned int fd, unsigned int cmd,
        iocnumX = karg32.hdr.iocnum & 0xFF;
        if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||
            (iocp == NULL)) {
-               printk(KERN_ERR MYNAM "::sparc32_mpt_command @%d - ioc%d not found!\n",
-                               __LINE__, iocnumX);
+               dtmprintk((KERN_ERR MYNAM "::sparc32_mpt_command @%d - ioc%d not found!\n",
+                               __LINE__, iocnumX));
                return -ENODEV;
        }
 
@@ -3072,8 +3068,8 @@ sparc32_mptctl_cpq_passthru(unsigned int fd, unsigned int cmd,
        iocnumX = karg32.lc & 0xFF;
        if (((iocnum = mpt_verify_adapter(iocnumX, &ioc)) < 0) ||
            (ioc == NULL)) {
-               printk(KERN_ERR MYNAM "::sparc32_mpt_command @%d - ioc%d not found!\n",
-                               __LINE__, iocnumX);
+               dtmprintk((KERN_ERR MYNAM "::sparc32_mpt_command @%d - ioc%d not found!\n",
+                               __LINE__, iocnumX));
                return -ENODEV;
        }
 
index 5c049fb8dfdd8ecaf24cdf91e0ae571218ba0544..bc0403f858496470af68dbc9c3a4caab4489be8e 100644 (file)
@@ -26,7 +26,7 @@
  *  (mailto:sjralston1@netscape.net)
  *  (mailto:Pam.Delaney@lsil.com)
  *
- *  $Id: mptscsih.c,v 1.95 2002/06/20 13:28:17 pdelaney Exp $
+ *  $Id: mptscsih.c,v 1.101 2002/09/05 22:30:11 pdelaney Exp $
  */
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
@@ -110,6 +110,7 @@ typedef struct _BIG_SENSE_BUF {
 #define MPT_SCANDV_SENSE               (0x00000002)
 #define MPT_SCANDV_SOME_ERROR          (0x00000004)
 #define MPT_SCANDV_SELECTION_TIMEOUT   (0x00000008)
+#define MPT_SCANDV_ISSUE_SENSE         (0x00000010)
 
 #define MPT_SCANDV_MAX_RETRIES         (10)
 
@@ -183,7 +184,7 @@ static int  mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pE
 static VirtDevice      *mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen);
 void           mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56);
 static void    clear_sense_flag(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq);
-static void    mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq, char *data);
+static void    mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq);
 static void    mptscsih_setDevicePage1Flags (u8 width, u8 factor, u8 offset, int *requestedPtr, int *configurationPtr, u8 flags);
 static void    mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id);
 static int     mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags);
@@ -198,7 +199,7 @@ static int  mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io);
 static void    mptscsih_domainValidation(void *hd);
 static int     mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id);
 static void    mptscsih_qas_check(MPT_SCSI_HOST *hd);
-static void    mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int target);
+static int     mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int target);
 static void    mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage);
 static void    mptscsih_fillbuf(char *buffer, int size, int index, int width);
 #endif
@@ -226,11 +227,11 @@ static int        ScsiScanDvCtx = -1; /* Used only for bus scan and dv */
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,28)
 static struct proc_dir_entry proc_mpt_scsihost =
 {
-       low_ino:        PROC_SCSI_MPT,
-       namelen:        8,
-       name:           "mptscsih",
-       mode:           S_IFDIR | S_IRUGO | S_IXUGO,
-       nlink:          2,
+       .low_ino =      PROC_SCSI_MPT,
+       .namelen =      8,
+       .name =         "mptscsih",
+       .mode =         S_IFDIR | S_IRUGO | S_IXUGO,
+       .nlink =        2,
 };
 #endif
 
@@ -323,8 +324,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
                return 1;
        }
 
-       dmfprintk((MYIOC_s_INFO_FMT "ScsiDone (mf=%p,mr=%p,sc=%p)\n",
-                       ioc->name, mf, mr, sc));
+       dmfprintk((MYIOC_s_INFO_FMT "ScsiDone (mf=%p,mr=%p,sc=%p,idx=%d)\n",
+                       ioc->name, mf, mr, sc, req_idx));
 
        atomic_dec(&queue_depth);
 
@@ -351,9 +352,6 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
                        }
                }
                clear_sense_flag(hd, pScsiReq);
-
-               if (hd->is_spi)
-                       mptscsih_set_dvflags(hd, pScsiReq, sc->buffer);
        } else {
                u32      xfer_cnt;
                u16      status;
@@ -484,9 +482,6 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
                                                sc->buffer,
                                                xfer_cnt);
                        }
-
-                       if (hd->is_spi)
-                               mptscsih_set_dvflags(hd, pScsiReq, sc->buffer);
                        break;
 
                case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR:        /* 0x0040 */
@@ -568,9 +563,6 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
                                                sc->buffer,
                                                xfer_cnt);
                        }
-
-                       if (hd->is_spi)
-                               mptscsih_set_dvflags(hd, pScsiReq, sc->buffer);
                        break;
 
                case MPI_IOCSTATUS_SCSI_PROTOCOL_ERROR:         /* 0x0047 */
@@ -919,11 +911,21 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
                        dmfprintk(( "flush: ScsiDone (mf=%p,sc=%p)\n",
                                        mf, SCpnt));
 
-                       /* Set status
+                       /* Set status, free OS resources (SG DMA buffers)
                         * Do OS callback
-                        * Free chain buffers
-                        * Free message frame
+                        * Free driver resources (chain, msg buffers)
                         */
+                       if (SCpnt->use_sg) {
+                               pci_unmap_sg(hd->ioc->pcidev, (struct scatterlist *) SCpnt->request_buffer,
+                                           SCpnt->use_sg, scsi_to_pci_dma_dir(SCpnt->sc_data_direction));
+                       } else if (SCpnt->request_bufflen) {
+                               scPrivate       *my_priv;
+               
+                               my_priv = (scPrivate *) &SCpnt->SCp;
+                               pci_unmap_single(hd->ioc->pcidev, (dma_addr_t)(ulong)my_priv->p1,
+                                          SCpnt->request_bufflen,
+                                          scsi_to_pci_dma_dir(SCpnt->sc_data_direction));
+                       }
                        SCpnt->result = DID_RESET << 16;
                        SCpnt->host_scribble = NULL;
                         MPT_HOST_LOCK(flags);
@@ -937,9 +939,77 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
                        mpt_free_msg_frame(ScsiDoneCtx, hd->ioc->id, mf);
                }
        }
+
        return;
 }
 
+#ifdef DROP_TEST
+/*     mptscsih_flush_drop_test - Free resources and do callback if
+ *             DROP_TEST enabled.
+ *
+ *     @hd: Pointer to a SCSI HOST structure
+ *
+ *     Returns: None.
+ *
+ *     Must be called while new I/Os are being queued.
+ */
+static void
+mptscsih_flush_drop_test (MPT_SCSI_HOST *hd)
+{
+       Scsi_Cmnd       *sc;
+       unsigned long    flags;
+       u16              req_idx;
+
+       /* Free resources for the drop test MF
+        * and chain buffers.
+        */
+       if (dropMfPtr) {
+               req_idx = le16_to_cpu(dropMfPtr->u.frame.hwhdr.msgctxu.fld.req_idx);
+               sc = hd->ScsiLookup[req_idx];
+               if (sc == NULL) {
+                       printk(MYIOC_s_ERR_FMT "Drop Test: NULL ScsiCmd ptr!\n",
+                                       ioc->name);
+               } else {
+                       /* unmap OS resources, set status, do callback
+                        * free driver resources
+                        */
+                       if (sc->use_sg) {
+                               pci_unmap_sg(ioc->pcidev, (struct scatterlist *) sc->request_buffer,
+                                           sc->use_sg, scsi_to_pci_dma_dir(sc->sc_data_direction));
+                       } else if (sc->request_bufflen) {
+                               scPrivate       *my_priv;
+
+                               my_priv = (scPrivate *) &sc->SCp;
+                               pci_unmap_single(ioc->pcidev, (dma_addr_t)(ulong)my_priv->p1,
+                                          sc->request_bufflen,
+                                          scsi_to_pci_dma_dir(sc->sc_data_direction));
+                       }
+
+                       sc->host_scribble = NULL;
+                       sc->result = DID_RESET << 16;
+                       hd->ScsiLookup[req_idx] = NULL;
+                       atomic_dec(&queue_depth);
+                       MPT_HOST_LOCK(flags);
+                       sc->scsi_done(sc);      /* Issue callback */
+                       MPT_HOST_UNLOCK(flags);
+               }
+
+               mptscsih_freeChainBuffers(hd, req_idx);
+               mpt_free_msg_frame(ScsiDoneCtx, ioc->id, dropMfPtr);
+               printk(MYIOC_s_INFO_FMT "Free'd Dropped cmd (%p)\n",
+                                       hd->ioc->name, sc);
+               printk(MYIOC_s_INFO_FMT "mf (%p) reqidx (%4x)\n",
+                                       hd->ioc->name, dropMfPtr, req_idx);
+               printk(MYIOC_s_INFO_FMT "Num Tot (%d) Good (%d) Bad (%d) \n",
+                               hd->ioc->name, dropTestNum,
+                               dropTestOK, dropTestBad);
+       }
+       dropMfPtr = NULL;
+
+       return;
+}
+#endif
+
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
  *     mptscsih_initChainBuffers - Allocate memory for and initialize
@@ -1156,8 +1226,7 @@ mptscsih_detect(Scsi_Host_Template *tpnt)
 #endif
                        sh = scsi_register(tpnt, sizeof(MPT_SCSI_HOST));
                        if (sh != NULL) {
-                               save_flags(flags);
-                               cli();
+                               mptscsih_save_flags(flags);
                                sh->io_port = 0;
                                sh->n_io_port = 0;
                                sh->irq = 0;
@@ -1221,7 +1290,7 @@ mptscsih_detect(Scsi_Host_Template *tpnt)
                                 */
                                scsi_set_pci_device(sh, this->pcidev);
 
-                               restore_flags(flags);
+                               mptscsih_restore_flags(flags);
 
                                hd = (MPT_SCSI_HOST *) sh->hostdata;
                                hd->ioc = this;
@@ -1358,7 +1427,11 @@ mptscsih_detect(Scsi_Host_Template *tpnt)
                                        hd->ioc->spi_data.forceDv = 0;
                                        for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++)
                                                hd->ioc->spi_data.dvStatus[ii] = MPT_SCSICFG_NEGOTIATE;
-
+       
+                                       if (hd->negoNvram == 0) {
+                                               for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++)
+                                                       hd->ioc->spi_data.dvStatus[ii] |= MPT_SCSICFG_DV_NOT_DONE;
+                                       }
 
                                        ddvprintk((MYIOC_s_INFO_FMT
                                                "dv %x width %x factor %x \n",
@@ -1456,6 +1529,8 @@ mptscsih_release(struct Scsi_Host *host)
 
        if (hd != NULL) {
                int sz1, sz2, sz3, sztarget=0;
+               int szr2chain = 0;
+               int szc2chain = 0;
                int szchain = 0;
                int szQ = 0;
                int scale;
@@ -1480,20 +1555,20 @@ mptscsih_release(struct Scsi_Host *host)
                }
 
                if (hd->ReqToChain != NULL) {
-                       szchain += scale * hd->ioc->req_depth * sizeof(int);
+                       szr2chain = scale * hd->ioc->req_depth * sizeof(int);
                        kfree(hd->ReqToChain);
                        hd->ReqToChain = NULL;
                }
 
                if (hd->ChainToChain != NULL) {
-                       szchain += scale * hd->ioc->req_depth * sizeof(int);
+                       szc2chain = scale * hd->ioc->req_depth * sizeof(int);
                        kfree(hd->ChainToChain);
                        hd->ChainToChain = NULL;
                }
 
                if (hd->ChainBuffer != NULL) {
                        sz2 = scale * hd->ioc->req_depth * hd->ioc->req_sz;
-                       szchain += sz2;
+                       szchain = szr2chain + szc2chain + sz2;
 
                        pci_free_consistent(hd->ioc->pcidev, sz2,
                                    hd->ChainBuffer, hd->ChainBufferDMA);
@@ -1962,17 +2037,22 @@ mptscsih_qcmd(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
                                        mod_timer(&SCpnt->eh_timeout, jiffies + 40 * HZ);
                                        issueCmd = 0;
                                }
+
+                               /* Set the DV flags.
+                                */
+                               if (dvStatus & MPT_SCSICFG_DV_NOT_DONE)
+                                       mptscsih_set_dvflags(hd, pScsiReq);
 #endif
                        }
                }
 
                if (issueCmd) {
                        mptscsih_put_msgframe(ScsiDoneCtx, hd->ioc->id, mf);
-                       dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p)\n",
-                                       hd->ioc->name, SCpnt));
+                       dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
+                                       hd->ioc->name, SCpnt, mf, my_idx));
                } else {
-                       ddvtprintk((MYIOC_s_INFO_FMT "Pending SCSI cmd (%p)\n",
-                                       hd->ioc->name, SCpnt));
+                       ddvtprintk((MYIOC_s_INFO_FMT "Pending cmd=%p idx %d\n",
+                                       hd->ioc->name, SCpnt, my_idx));
                        /* Place this command on the pendingQ if possible */
                        spin_lock_irqsave(&hd->freedoneQlock, flags);
                        if (!Q_IS_EMPTY(&hd->freeQ)) {
@@ -2453,7 +2533,7 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 target, u8 lun, int ctx2abort,
        }
 #endif
 
-       if (rc) {
+       if (rc || ioc->reload_fw || (ioc->alt_ioc && ioc->alt_ioc->reload_fw)) {
                dtmprintk((MYIOC_s_INFO_FMT "Falling through to HardReset! \n",
                         hd->ioc->name));
                rc = mpt_HardResetHandler(hd->ioc, sleepFlag);
@@ -3507,51 +3587,7 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
        }
 
 #ifdef DROP_TEST
-       {
-               Scsi_Cmnd       *sc;
-               unsigned long    flags;
-               u16              req_idx;
-
-               /* Free resources for the drop test MF and chain buffers.
-                */
-               if (dropMfPtr) {
-                       req_idx = le16_to_cpu(dropMfPtr->u.frame.hwhdr.msgctxu.fld.req_idx);
-                       sc = hd->ScsiLookup[req_idx];
-                       if (sc == NULL) {
-                               printk(MYIOC_s_ERR_FMT
-                                       "Drop Test: NULL ScsiCmd ptr!\n",
-                                       ioc->name);
-                       } else {
-                               sc->host_scribble = NULL;
-                               if (tmType == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS)
-                                       sc->result = DID_RESET << 16;
-                               else
-                                       sc->result = DID_ABORT << 16;
-
-                               hd->ScsiLookup[req_idx] = NULL;
-                               atomic_dec(&queue_depth);
-                                MPT_HOST_LOCK(flags);
-                               sc->scsi_done(sc);      /* Issue callback */
-                                MPT_HOST_UNLOCK(flags);
-
-                               mptscsih_freeChainBuffers(hd, req_idx);
-                               mpt_free_msg_frame(ScsiDoneCtx, ioc->id, dropMfPtr);
-
-                               printk(MYIOC_s_INFO_FMT
-                                               "Free'd Dropped cmd (%p)\n",
-                                               hd->ioc->name, sc);
-                               printk(MYIOC_s_INFO_FMT
-                                               "mf (%p) reqidx (%4x)\n",
-                                               hd->ioc->name, dropMfPtr,
-                                               req_idx);
-                               printk(MYIOC_s_INFO_FMT
-                                       "Num Tot (%d) Good (%d) Bad (%d) \n",
-                                       hd->ioc->name, dropTestNum,
-                                       dropTestOK, dropTestBad);
-                       }
-                       dropMfPtr = NULL;
-               }
-       }
+       mptscsih_flush_drop_test(hd);
 #endif
 
 #ifndef MPT_SCSI_USE_NEW_EH
@@ -3574,9 +3610,12 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
 /*
  *     This is anyones guess quite frankly.
  */
-
 int
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,28)
 mptscsih_bios_param(Disk * disk, struct block_device *dev, int *ip)
+#else
+mptscsih_bios_param(Disk * disk, kdev_t dev, int *ip)
+#endif
 {
        int size;
 
@@ -3648,10 +3687,25 @@ mptscsih_select_queue_depths(struct Scsi_Host *sh, Scsi_Device *sdList)
  *     0 = _DIR_NONE   changed to SCSI_DATA_NONE (3)
  *    -1 = _DATA_IN    changed to SCSI_DATA_READ (2)
  * If the direction is unknown, fall through to original code.
+ *
+ * Mid-layer bug fix(): sg interface generates the wrong data 
+ * direction in some cases. Set the direction the hard way for 
+ * the most common commands.
  */
 static int
 mptscsih_io_direction(Scsi_Cmnd *cmd)
 {
+       switch (cmd->cmnd[0]) {
+       case WRITE_6:           
+       case WRITE_10:          
+               return SCSI_DATA_WRITE;
+               break;
+       case READ_6:            
+       case READ_10:           
+               return SCSI_DATA_READ;
+               break;
+       }
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
        if (cmd->sc_data_direction != SCSI_DATA_UNKNOWN)
                return cmd->sc_data_direction;
@@ -3756,6 +3810,20 @@ copy_sense_data(Scsi_Cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply
                                sz =  SCSI_STD_SENSE_BYTES;
                        memcpy(target->sense, sense_data, sz);
                        target->tflags |= MPT_TARGET_FLAGS_VALID_SENSE;
+
+#ifdef ABORT_FIX
+                       if (sz >= SCSI_STD_SENSE_BYTES) {
+                               if ((sense_data[02] == ABORTED_COMMAND) && 
+                                       (sense_data[12] == 0x47) && (sense_data[13] == 0x00)){
+                                       target->numAborts++;
+                                       if ((target->raidVolume == 0) && (target->numAborts > 5)) {
+                                               target->numAborts = 0;
+                                               target->minSyncFactor++;
+                                               hd->ioc->spi_data.dvStatus[index] |= MPT_SCSICFG_NEGOTIATE;
+                                       }
+                               }
+                       }
+#endif
                }
 
                /* Log SMART data (asc = 0x5D, non-IM case only) if required.
@@ -3849,7 +3917,7 @@ mptscsih_search_pendingQ(MPT_SCSI_HOST *hd, int scpnt_idx)
        MPT_FRAME_HDR   *mf = NULL;
        MPT_FRAME_HDR   *cmdMfPtr = NULL;
 
-       ddvtprintk((MYIOC_s_INFO_FMT ": search_pendingQ called...", hd->ioc->name));
+       ddvtprintk((MYIOC_s_INFO_FMT ": search_pendingQ ...", hd->ioc->name));
        cmdMfPtr = MPT_INDEX_2_MFPTR(hd->ioc, scpnt_idx);
        spin_lock_irqsave(&hd->freedoneQlock, flags);
        if (!Q_IS_EMPTY(&hd->pendingQ)) {
@@ -3889,7 +3957,7 @@ post_pendingQ_commands(MPT_SCSI_HOST *hd)
 
        /* Flush the pendingQ.
         */
-       ddvtprintk((MYIOC_s_INFO_FMT ": post_pendingQ_commands called\n", hd->ioc->name));
+       ddvtprintk((MYIOC_s_INFO_FMT ": post_pendingQ_commands\n", hd->ioc->name));
        while (1) {
                spin_lock_irqsave(&hd->freedoneQlock, flags);
                if (Q_IS_EMPTY(&hd->pendingQ)) {
@@ -3917,8 +3985,15 @@ post_pendingQ_commands(MPT_SCSI_HOST *hd)
                }
 
                mptscsih_put_msgframe(ScsiDoneCtx, hd->ioc->id, mf);
-               ddvtprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (mf=%p)\n",
-                               hd->ioc->name, mf));
+
+#if defined(MPT_DEBUG_DV) || defined(MPT_DEBUG_DV_TINY)
+               {
+                       u16              req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
+                       Scsi_Cmnd       *sc = hd->ScsiLookup[req_idx];
+                       printk(MYIOC_s_INFO_FMT "Issued SCSI cmd (sc=%p) idx=%d (mf=%p)\n",
+                                       hd->ioc->name, sc, req_idx, mf);
+               }
+#endif
        }
 
        return;
@@ -3963,40 +4038,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
                /* 2a. Drop Test Command.
                 */
 #ifdef DROP_TEST
-               {
-                       Scsi_Cmnd       *sc;
-                       unsigned long    flags;
-                       u16              req_idx;
-
-                       /* Free resources for the drop test MF
-                        * and chain buffers.
-                        */
-                       if (dropMfPtr) {
-                               req_idx = le16_to_cpu(dropMfPtr->u.frame.hwhdr.msgctxu.fld.req_idx);
-                               sc = hd->ScsiLookup[req_idx];
-                               if (sc == NULL) {
-                                       printk(MYIOC_s_ERR_FMT
-                                       "Drop Test: NULL ScsiCmd ptr!\n",
-                                       ioc->name);
-                               } else {
-                                       sc->host_scribble = NULL;
-                                       sc->result = DID_RESET << 16;
-                                       hd->ScsiLookup[req_idx] = NULL;
-                                       atomic_dec(&queue_depth);
-                                        MPT_HOST_LOCK(flags);
-                                       sc->scsi_done(sc);      /* Issue callback */
-                                        MPT_HOST_UNLOCK(flags);
-                               }
-
-                               mptscsih_freeChainBuffers(hd, req_idx);
-                               mpt_free_msg_frame(ScsiDoneCtx, ioc->id, dropMfPtr);
-                               printk(MYIOC_s_INFO_FMT
-                                               "Free'd: mf (%p) reqidx (%4x)\n",
-                                               hd->ioc->name, dropMfPtr,
-                                               req_idx);
-                       }
-                       dropMfPtr = NULL;
-               }
+               mptscsih_flush_drop_test(hd);
 #endif
 
                /* 2b. Reply to OS all known outstanding I/O commands.
@@ -4161,7 +4203,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
 
                                        while (numPDisk) {
                                                if (physDiskNum == pPDisk->PhysDiskNum) {
-                                                       pSpi->dvStatus[pPDisk->PhysDiskID] = MPT_SCSICFG_NEED_DV;
+                                                       pSpi->dvStatus[pPDisk->PhysDiskID] = (MPT_SCSICFG_NEED_DV | MPT_SCSICFG_DV_NOT_DONE);
                                                        pSpi->forceDv = MPT_SCSICFG_NEED_DV;
                                                        ddvtprintk(("NEED_DV set for phys disk id %d\n", pPDisk->PhysDiskID));
                                                        break;
@@ -4596,6 +4638,26 @@ int mpt_ScsiHost_ErrorReport(IO_Info_t *ioop)
                return 0;
        }
 
+       /* Prevent the system from continually writing to the log
+        * if a medium is not found: 02 3A 00
+        * Changer issues: TUR, Read Capacity, Table of Contents continually
+        */
+       if (sk==SK_NOT_READY && asc==0x3A) {
+               if (ioop->cdbPtr == NULL) {
+                       return 0;
+               } else if ((ioop->cdbPtr[0] == CMD_TestUnitReady) ||
+                       (ioop->cdbPtr[0] == CMD_ReadCapacity) || 
+                       (ioop->cdbPtr[0] == 0x43)) {
+                       return 0;
+               }
+       }
+       if (sk==SK_UNIT_ATTENTION) {
+               if (ioop->cdbPtr == NULL)
+                       return 0;
+               else if (ioop->cdbPtr[0] == CMD_TestUnitReady)
+                       return 0;
+       }
+
        /*
         *  Protect ourselves...
         */
@@ -4715,7 +4777,8 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *
        }
 
        if (vdev && data) {
-               if (!(vdev->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY)) {
+               if ((!(vdev->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY)) || 
+               ((dlen > 56) && (!(vdev->tflags & MPT_TARGET_FLAGS_VALID_56)))) {
 
                        /* Copy the inquiry data  - if we haven't yet.
                        */
@@ -4726,10 +4789,19 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *
 
                        /* Update the target capabilities
                         */
-                       if (dlen > 56)
+                       if (dlen > 56) {
                                mptscsih_setTargetNegoParms(hd, vdev, data[56]);
-                       else
+                               vdev->tflags |= MPT_TARGET_FLAGS_VALID_56;
+                       } else
                                mptscsih_setTargetNegoParms(hd, vdev, 0);
+
+                       /* If LUN 0, tape and have not done DV, set the DV flag.
+                        */
+                       if ((lun == 0) && ((data[0] & 0x1F) == 0x01)) {
+                               ScsiCfgData *pSpi = &hd->ioc->spi_data;
+                               if (pSpi->dvStatus[target_id] & MPT_SCSICFG_DV_NOT_DONE)
+                                       pSpi->dvStatus[target_id] |= MPT_SCSICFG_NEED_DV;
+                       }
                }
 
                /* Is LUN supported? If so, upper 3 bits will be 0
@@ -4765,7 +4837,7 @@ void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byt
        /* Set flags based on Inquiry data
         */
        if (target->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) {
-               version = target->inq_data[2] & 0x03;
+               version = target->inq_data[2] & 0x07;
                if (version < 2) {
                        width = 0;
                        factor = MPT_ULTRA2;
@@ -4899,43 +4971,39 @@ static void clear_sense_flag(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq)
        return;
 }
 
-/* 
- * If DV disabled (negoNvram set to USE_NVARM) or if not LUN 0, return.
+/* If DV disabled (negoNvram set to USE_NVARM) or if not LUN 0, return.
  * Else set the NEED_DV flag after Read Capacity Issued (disks) 
- * or Mode Sense (cdroms). Tapes, key off of Inquiry command.
+ * or Mode Sense (cdroms). 
+ *
+ * Tapes, initTarget will set this flag on completion of Inquiry command.
+ * Called only if DV_NOT_DONE flag is set
  */
-static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq, char *data)
+static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq)
 {
-       u8 cmd = pReq->CDB[0];
+       u8 cmd;
        
-       if (pReq->LUN[1] != 0)
+       if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0))
                return;
 
-       if (hd->negoNvram != 0)
-               return;
+       cmd = pReq->CDB[0];
 
-       if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE) || 
-               ((cmd == INQUIRY) && ((data[0] & 0x1F) == 0x01))) {
-               u8 dvStatus = hd->ioc->spi_data.dvStatus[pReq->TargetID];
-               if (!(dvStatus & MPT_SCSICFG_DV_DONE)) {
-                       ScsiCfgData *pSpi = &hd->ioc->spi_data;
-                       if ((pSpi->isRaid & (1 << pReq->TargetID)) && pSpi->pIocPg3) {
-                               /* Set NEED_DV for all hidden disks
-                                */
-                               Ioc3PhysDisk_t *pPDisk =  pSpi->pIocPg3->PhysDisk;
-                               int             numPDisk = pSpi->pIocPg3->NumPhysDisks;
-                               
-                               while (numPDisk) {
-                                       pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV;
-                                       ddvtprintk(("NEED_DV set for phys disk id %d\n", pPDisk->PhysDiskID));
-                                       pPDisk++;
-                                       numPDisk--;
-                               }
+       if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) {
+               ScsiCfgData *pSpi = &hd->ioc->spi_data;
+               if ((pSpi->isRaid & (1 << pReq->TargetID)) && pSpi->pIocPg3) {
+                       /* Set NEED_DV for all hidden disks
+                        */
+                       Ioc3PhysDisk_t *pPDisk =  pSpi->pIocPg3->PhysDisk;
+                       int             numPDisk = pSpi->pIocPg3->NumPhysDisks;
+
+                       while (numPDisk) {
+                               pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV;
+                               ddvtprintk(("NEED_DV set for phys disk id %d\n", pPDisk->PhysDiskID));
+                               pPDisk++;
+                               numPDisk--;
                        }
-                       pSpi->dvStatus[pReq->TargetID] |= MPT_SCSICFG_NEED_DV;
-                       ddvtprintk(("NEED_DV set for visible disk id %d\n", 
-                                       pReq->TargetID));
-               };
+               }
+               pSpi->dvStatus[pReq->TargetID] |= MPT_SCSICFG_NEED_DV;
+               ddvtprintk(("NEED_DV set for visible disk id %d\n", pReq->TargetID));
        }
 }
 
@@ -5036,6 +5104,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
        u8                       offset;
        u8                       bus = 0;
        u8                       negoFlags;
+       u8                       maxwidth, maxoffset, maxfactor;
 
        if (ioc->spi_data.sdp1length == 0)
                return 0;
@@ -5049,48 +5118,54 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
        }
 
        for (; id <= maxid; id++) {
+
                if (id == ioc->pfacts[portnum].PortSCSIID)
                        continue;
 
-               if (flags & MPT_SCSICFG_USE_NVRAM) {
-                       /* Use NVRAM, adapter maximums and target settings.
-                        * Data over-riden by target structure information, if present
-                        */
-                       width = ioc->spi_data.maxBusWidth;
-                       offset = ioc->spi_data.maxSyncOffset;
-                       factor = ioc->spi_data.minSyncFactor;
-                       if (ioc->spi_data.nvram && (ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {
-                               nvram = ioc->spi_data.nvram[id];
-
-                               if (width)
-                                       width = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1;
-
-                               if (offset > 0) {
-                                       factor = (nvram & MPT_NVRAM_SYNC_MASK) >> 8;
-                                       if (factor == 0) {
-                                               /* Key for async */
-                                               factor = MPT_ASYNC;
-                                               offset = 0;
-                                       } else if (factor < ioc->spi_data.minSyncFactor) {
-                                               factor = ioc->spi_data.minSyncFactor;
-                                       }
-                               } else
-                                       factor = MPT_ASYNC;
-                       }
+               /* Use NVRAM to get adapter and target maximums
+                * Data over-riden by target structure information, if present
+                */
+               maxwidth = ioc->spi_data.maxBusWidth;
+               maxoffset = ioc->spi_data.maxSyncOffset;
+               maxfactor = ioc->spi_data.minSyncFactor;
+               if (ioc->spi_data.nvram && (ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {
+                       nvram = ioc->spi_data.nvram[id];
+
+                       if (maxwidth)
+                               maxwidth = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1;
+
+                       if (maxoffset > 0) {
+                               maxfactor = (nvram & MPT_NVRAM_SYNC_MASK) >> 8;
+                               if (maxfactor == 0) {
+                                       /* Key for async */
+                                       maxfactor = MPT_ASYNC;
+                                       maxoffset = 0;
+                               } else if (maxfactor < ioc->spi_data.minSyncFactor) {
+                                       maxfactor = ioc->spi_data.minSyncFactor;
+                               }
+                       } else
+                               maxfactor = MPT_ASYNC;
+               }
 
-                       /* Set the negotiation flags.
-                        */
-                       negoFlags = ioc->spi_data.noQas;
-                       if (!width)
-                               negoFlags |= MPT_TARGET_NO_NEGO_WIDE;
-       
-                       if (!offset)
-                               negoFlags |= MPT_TARGET_NO_NEGO_SYNC;
+               /* Set the negotiation flags.
+                */
+               negoFlags = ioc->spi_data.noQas;
+               if (!maxwidth)
+                       negoFlags |= MPT_TARGET_NO_NEGO_WIDE;
+
+               if (!maxoffset)
+                       negoFlags |= MPT_TARGET_NO_NEGO_SYNC;
+
+               if (flags & MPT_SCSICFG_USE_NVRAM) {
+                       width = maxwidth;
+                       factor = maxfactor;
+                       offset = maxoffset;
                } else {
                        width = 0;
                        factor = MPT_ASYNC;
                        offset = 0;
-                       negoFlags = MPT_TARGET_NO_NEGO_SYNC;
+                       //negoFlags = 0;
+                       //negoFlags = MPT_TARGET_NO_NEGO_SYNC;
                }
 
                /* If id is not a raid volume, get the updated
@@ -5107,15 +5182,9 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
                if (flags & MPT_SCSICFG_BLK_NEGO)
                        negoFlags = MPT_TARGET_NO_NEGO_WIDE | MPT_TARGET_NO_NEGO_SYNC;
 
-               /* REMOVE - can this be removed without problems?????
-               else if (negoFlags == (MPT_TARGET_NO_NEGO_WIDE | MPT_TARGET_NO_NEGO_SYNC))
-                       continue;
-               */
-
                mptscsih_setDevicePage1Flags(width, factor, offset,
                                        &requested, &configuration, negoFlags);
 
-
                /* Get a MF for this command.
                 */
                if ((mf = mpt_get_msg_frame(ScsiDoneCtx, ioc->id)) == NULL) {
@@ -5124,6 +5193,10 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
                        return -EAGAIN;
                }
 
+               ddvprintk((MYIOC_s_INFO_FMT "WriteSDP1 (mf=%p, id=%d, req=0x%x, cfg=0x%x)\n",
+                       hd->ioc->name, mf, id, requested, configuration));
+
+
                /* Set the request and the data pointers.
                 * Request takes: 36 bytes (32 bit SGE)
                 * SCSI Device Page 1 requires 16 bytes
@@ -5255,7 +5328,7 @@ static void mptscsih_taskmgmt_timeout(unsigned long data)
  *
  *     Remark: Sets a completion code and (possibly) saves sense data
  *     in the IOC member localReply structure.
- *     Used ONLY for bus scan, DV and other internal commands.
+ *     Used ONLY for DV and other internal commands.
  */
 static int
 mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
@@ -5280,17 +5353,18 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
        pReq = (SCSIIORequest_t *) mf;
 
        if (mf != hd->cmdPtr) {
-               printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p, cmdPtr=%p)\n",
-                               hd->ioc->name, (void *)mf, (void *) hd->cmdPtr);
+               printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p, cmdPtr=%p, idx=%d)\n",
+                               hd->ioc->name, (void *)mf, (void *) hd->cmdPtr, req_idx);
        }
        hd->cmdPtr = NULL;
 
-       ddvprintk((MYIOC_s_INFO_FMT "ScanDvComplete (mf=%p,mr=%p)\n",
-                       hd->ioc->name, mf, mr));
+       ddvprintk((MYIOC_s_INFO_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n",
+                       hd->ioc->name, mf, mr, req_idx));
 
        atomic_dec(&queue_depth);
 
        hd->pLocal = &hd->localReply;
+       hd->pLocal->scsiStatus = 0;
 
        /* If target struct exists, clear sense valid flag.
         */
@@ -5306,7 +5380,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
 
                status = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK;
 
-               ddvprintk((KERN_NOTICE "  IOCStatus=%04xh, SCSIState=%02xh, SCSIStatus=%02xh, IOCLogInfo=%08xh\n",
+               ddvtprintk((KERN_NOTICE "  IOCStatus=%04xh, SCSIState=%02xh, SCSIStatus=%02xh, IOCLogInfo=%08xh\n",
                             status, pReply->SCSIState, pReply->SCSIStatus,
                             le32_to_cpu(pReply->IOCLogInfo)));
 
@@ -5370,16 +5444,22 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
 
                                ddvprintk((KERN_NOTICE "  Check Condition, sense ptr %p\n",
                                                sense_data));
-                       } else if (pReply->SCSIState & (MPI_SCSI_STATE_AUTOSENSE_FAILED |
-                                                       MPI_SCSI_STATE_NO_SCSI_STATUS)) {
+                       } else if (pReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_FAILED) {
+                               if (pReq->CDB[0] == CMD_Inquiry)
+                                       completionCode = MPT_SCANDV_ISSUE_SENSE;
+                               else
+                                       completionCode = MPT_SCANDV_DID_RESET;
+                       }
+                       else if (pReply->SCSIState & MPI_SCSI_STATE_NO_SCSI_STATUS)
                                completionCode = MPT_SCANDV_DID_RESET;
-                       } else if (pReply->SCSIState & MPI_SCSI_STATE_TERMINATED) {
+                       else if (pReply->SCSIState & MPI_SCSI_STATE_TERMINATED)
                                completionCode = MPT_SCANDV_DID_RESET;
-                       else {
+                       else {
                                /* If no error, this will be equivalent
                                 * to MPT_SCANDV_GOOD
                                 */
-                               completionCode = (int) pReply->SCSIStatus;
+                               completionCode = MPT_SCANDV_GOOD;
+                               hd->pLocal->scsiStatus = pReply->SCSIStatus;
                        }
                        break;
 
@@ -5396,7 +5476,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
 
                }       /* switch(status) */
 
-               ddvprintk((KERN_NOTICE "  completionCode set to %08xh\n",
+               ddvtprintk((KERN_NOTICE "  completionCode set to %08xh\n",
                                completionCode));
        } /* end of address reply case */
 
@@ -5619,6 +5699,14 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
                cmdTimeout = 15;
                break;
 
+       case CMD_RequestSense:
+               cmdLen = 6;
+               CDB[0] = cmd;
+               CDB[4] = io->size;
+               dir = MPI_SCSIIO_CONTROL_READ;
+               cmdTimeout = 10;
+               break;
+
        case CMD_ReadBuffer:
                cmdLen = 10;
                dir = MPI_SCSIIO_CONTROL_READ;
@@ -5904,7 +5992,7 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum)
                /* If target Ptr NULL or if this target is NOT a disk, skip.
                 */
        //      if (pTarget && ((pTarget->inq_data[0] & 0x1F) == 0)) {
-               if (pTarget) {
+               if ((pTarget) && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)){
                        for (lun=0; lun <= MPT_LAST_LUN; lun++) {
                                /* If LUN present, issue the command
                                 */
@@ -5954,7 +6042,6 @@ mptscsih_domainValidation(void *arg)
        unsigned long            flags;
        int                      id, maxid, dvStatus, did;
        int                      ii, isPhysDisk;
-       u8                       oldQas;
 
        spin_lock_irqsave(&dvtaskQ_lock, flags);
        dvtaskQ_active = 1;
@@ -6000,7 +6087,6 @@ mptscsih_domainValidation(void *arg)
                        maxid = MIN (ioc->sh->max_id, MPT_MAX_SCSI_DEVICES);
 
                        for (id = 0; id < maxid; id++) {
-                               oldQas = hd->ioc->spi_data.noQas;
                                spin_lock_irqsave(&dvtaskQ_lock, flags);
                                if (dvtaskQ_release) {
                                        dvtaskQ_active = 0;
@@ -6011,7 +6097,7 @@ mptscsih_domainValidation(void *arg)
                                dvStatus = hd->ioc->spi_data.dvStatus[id];
 
                                if (dvStatus & MPT_SCSICFG_NEED_DV) {
-
+                                       did++;
                                        hd->ioc->spi_data.dvStatus[id] |= MPT_SCSICFG_DV_PENDING;
                                        hd->ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_NEED_DV;
 
@@ -6031,10 +6117,16 @@ mptscsih_domainValidation(void *arg)
                                                }
                                        }
 
-                                       mptscsih_doDv(hd, 0, id);
-                                       did++;
-                                       hd->ioc->spi_data.dvStatus[id] |= MPT_SCSICFG_DV_DONE;
-                                       hd->ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_DV_PENDING;
+                                       if (mptscsih_doDv(hd, 0, id) == 1) {
+                                               /* Untagged device was busy, try again
+                                                */
+                                               hd->ioc->spi_data.dvStatus[id] |= MPT_SCSICFG_NEED_DV;
+                                               hd->ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_DV_PENDING;
+                                       } else {
+                                               /* DV is complete. Clear flags.
+                                                */
+                                               hd->ioc->spi_data.dvStatus[id] &= ~(MPT_SCSICFG_DV_NOT_DONE | MPT_SCSICFG_DV_PENDING);
+                                       }
 
                                        if (isPhysDisk) {
                                                for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) {
@@ -6049,7 +6141,7 @@ mptscsih_domainValidation(void *arg)
                                         */
                                        post_pendingQ_commands(hd);
 
-                                       if ((!oldQas) && (hd->ioc->spi_data.noQas))
+                                       if (hd->ioc->spi_data.noQas)
                                                mptscsih_qas_check(hd);
                                }
                        }
@@ -6088,27 +6180,25 @@ static void mptscsih_qas_check(MPT_SCSI_HOST *hd)
 {
        VirtDevice *pTarget = NULL;
        int ii;
-       int change = 0;
 
        if (hd->Targets == NULL)
                return;
 
        for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) {
-               change = 0;
+               if ((hd->ioc->spi_data.dvStatus[ii] & MPT_SCSICFG_DV_NOT_DONE) != 0)
+                       continue;
+
                pTarget = hd->Targets[ii];
 
                if ((pTarget != NULL) && (!pTarget->raidVolume)) {
                        if ((pTarget->negoFlags & hd->ioc->spi_data.noQas) == 0) {
-                               change = 1;
                                pTarget->negoFlags |= hd->ioc->spi_data.noQas;
+                               mptscsih_writeSDP1(hd, 0, ii, 0);
                        }
                } else {
                        if (mptscsih_is_phys_disk(hd->ioc, ii) == 1)
-                               change = 1;
+                               mptscsih_writeSDP1(hd, 0, ii, MPT_SCSICFG_USE_NVRAM);
                }
-
-               if ((change) && (hd->ioc->spi_data.dvStatus[ii] & MPT_SCSICFG_DV_DONE))
-                       mptscsih_writeSDP1(hd, 0, ii, 0);
        }
        return;
 }
@@ -6135,7 +6225,7 @@ static void mptscsih_qas_check(MPT_SCSI_HOST *hd)
  *
  *     Return: None.
  */
-static void
+static int
 mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int id)
 {
        MPT_ADAPTER             *ioc = hd->ioc;
@@ -6163,6 +6253,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int id)
        int                      notDone;
        int                      patt;
        int                      repeat;
+       int                      retcode = 0;
        char                     firstPass = 1;
        char                     doFallback = 0;
        char                     readPage0;
@@ -6170,13 +6261,13 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int id)
        char                     inq0 = 0;
 
        if (ioc->spi_data.sdp1length == 0)
-               return;
+               return 0;
 
        if (ioc->spi_data.sdp0length == 0)
-               return;
+               return 0;
 
        if (id == ioc->pfacts[portnum].PortSCSIID)
-               return;
+               return 0;
 
        lun = 0;
        bus = 0;
@@ -6196,7 +6287,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int id)
        dv.cmd = MPT_GET_NVRAM_VALS;
        mptscsih_dv_parms(hd, &dv, NULL);
        if ((!dv.max.width) && (!dv.max.offset))
-               return;
+               return 0;
 
        /* Prep SCSI IO structure
         */
@@ -6207,19 +6298,29 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int id)
        iocmd.physDiskNum = -1;
        iocmd.rsvd = iocmd.rsvd2 = 0;
 
-       /* Use tagged commands if possible.
-        */
        pTarget = hd->Targets[id];
-       if (pTarget && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
-               iocmd.flags |= MPT_ICFLAG_TAGGED_CMD;
-
        if (pTarget && (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY)) {
                /* Another GEM workaround. Check peripheral device type,
                 * if PROCESSOR, quit DV.
                 */
                if (((pTarget->inq_data[0] & 0x1F) == 0x03) || ((pTarget->inq_data[0] & 0x1F) > 0x08)) {
                        pTarget->negoFlags |= (MPT_TARGET_NO_NEGO_WIDE | MPT_TARGET_NO_NEGO_SYNC);
-                       return;
+                       return 0;
+               }
+       }
+
+       /* Use tagged commands if possible.
+        */
+       if (pTarget) {
+               if (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)
+                       iocmd.flags |= MPT_ICFLAG_TAGGED_CMD;
+               else {
+                       if (hd->ioc->facts.FWVersion.Word < 0x01000600)
+                               return 0;
+
+                       if ((hd->ioc->facts.FWVersion.Word >= 0x01010000) &&
+                               (hd->ioc->facts.FWVersion.Word < 0x01010B00))
+                               return 0;
                }
        }
 
@@ -6249,7 +6350,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int id)
 
        pDvBuf = pci_alloc_consistent(ioc->pcidev, dv_alloc, &dvbuf_dma);
        if (pDvBuf == NULL)
-               return;
+               return 0;
 
        sz = 0;
        pbuf1 = (u8 *)pDvBuf;
@@ -6331,8 +6432,10 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int id)
        hd->pLocal = NULL;
        readPage0 = 0;
        sz = SCSI_STD_INQUIRY_BYTES;
+       rc = MPT_SCANDV_GOOD;
        while (1) {
                ddvprintk((MYIOC_s_NOTE_FMT "DV: Start Basic test.\n", ioc->name));
+               retcode = 0;
                dv.cmd = MPT_SET_MIN;
                mptscsih_dv_parms(hd, &dv, (void *)pcfg1Data);
 
@@ -6343,12 +6446,60 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int id)
                if (mpt_config(hd->ioc, &cfg) != 0)
                        goto target_done;
 
+               /* Wide - narrow - wide workaround case
+                */
+               if ((rc == MPT_SCANDV_ISSUE_SENSE) && dv.max.width) { 
+                       /* Send an untagged command to reset disk Qs corrupted
+                        * when a parity error occurs on a Request Sense.
+                        */
+                       if ((hd->ioc->facts.FWVersion.Word >= 0x01000600) || 
+                               ((hd->ioc->facts.FWVersion.Word >= 0x01010000) &&
+                               (hd->ioc->facts.FWVersion.Word < 0x01010B00)) ) {
+
+                               iocmd.cmd = CMD_RequestSense;
+                               iocmd.data_dma = buf1_dma;
+                               iocmd.data = pbuf1;
+                               iocmd.size = 0x12;
+                               if (mptscsih_do_cmd(hd, &iocmd) < 0)
+                                       goto target_done;
+                               else {
+                                       if (hd->pLocal == NULL)
+                                               goto target_done;
+                                       rc = hd->pLocal->completion;
+                                       if ((rc == MPT_SCANDV_GOOD) || (rc == MPT_SCANDV_SENSE)) {
+                                               dv.max.width = 0;
+                                       } else
+                                               goto target_done;
+                               }
+                       } else
+                               goto target_done;
+               }
+
                iocmd.cmd = CMD_Inquiry;
                iocmd.data_dma = buf1_dma;
                iocmd.data = pbuf1;
                iocmd.size = sz;
                if (mptscsih_do_cmd(hd, &iocmd) < 0)
                        goto target_done;
+               else {
+                       if (hd->pLocal == NULL)
+                               goto target_done;
+                       rc = hd->pLocal->completion;
+                       if (rc == MPT_SCANDV_GOOD) {
+                               if (hd->pLocal->scsiStatus == STS_BUSY) {
+                                       retcode = 1;
+                                       goto target_done;
+                               }
+                       } else if  (rc == MPT_SCANDV_SENSE) {
+                               ;
+                       } else {
+                               /* If first command doesn't complete
+                                * with a good status or with a check condition,
+                                * exit.
+                                */
+                               goto target_done;
+                       }
+               }
 
                /* Another GEM workaround. Check peripheral device type,
                 * if PROCESSOR, quit DV.
@@ -6396,6 +6547,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int id)
                                        cfg.physAddr = cfg0_dma_addr;
                                        cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
                                        cfg.dir = 0;
+
                                        if (mpt_config(hd->ioc, &cfg) != 0)
                                                goto target_done;
 
@@ -6431,7 +6583,9 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int portnum, int id)
                                }
 
 
-                       } else if ((rc == MPT_SCANDV_DID_RESET) || (rc == MPT_SCANDV_SENSE))
+                       } else if (rc == MPT_SCANDV_ISSUE_SENSE) 
+                               doFallback = 1; /* set fallback flag */
+                       else if ((rc == MPT_SCANDV_DID_RESET) || (rc == MPT_SCANDV_SENSE))
                                doFallback = 1; /* set fallback flag */
                        else
                                goto target_done;
@@ -6854,8 +7008,7 @@ target_done:
 
        /* Set if cfg1_dma_addr contents is valid
         */
-       if (cfg.hdr != NULL) {
-
+       if ((cfg.hdr != NULL) && (retcode == 0)){
                /* If disk, not U320, disable QAS
                 */
                if ((inq0 == 0) && (dv.now.factor > MPT_ULTRA320))
@@ -6889,7 +7042,7 @@ target_done:
        ddvtprintk((MYIOC_s_INFO_FMT "DV Done. IOs outstanding = %d\n",
                        ioc->name, atomic_read(&queue_depth)));
 
-       return;
+       return retcode;
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
index b0c55517d1e6254c36e3c4555133ccce1f966fd3..42f29799ce869c0816e3954fc774c0b74955a6f6 100644 (file)
@@ -201,7 +201,11 @@ extern     int              x_scsi_host_reset(Scsi_Cmnd *);
 extern int              x_scsi_old_abort(Scsi_Cmnd *);
 extern int              x_scsi_old_reset(Scsi_Cmnd *, unsigned int);
 #endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,28)
 extern int              x_scsi_bios_param(Disk *, struct block_device *, int *);
+#else
+extern int              x_scsi_bios_param(Disk *, kdev_t, int *);
+#endif
 extern void             x_scsi_select_queue_depths(struct Scsi_Host *, Scsi_Device *);
 extern void             x_scsi_taskmgmt_bh(void *);