[PATCH -next] [SCSI] mpt3sas: remove unused variables

2012-12-11 Thread sreekanth.reddy
The variable 'chain_flags' and 'phy_number' are initialized but never used 
otherwise,
So remove those unused variables.

Signed-off-by: Wei Yongjun 
Acked-by: Sreekanth Reddy 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 764f3fe..157746d 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -1309,7 +1309,6 @@ _base_build_sg_scmd_ieee(struct MPT3SAS_ADAPTER *ioc,
void *sg_local, *chain;
u32 chain_offset;
u32 chain_length;
-   u32 chain_flags;
int sges_left;
u32 sges_in_segment;
u8 simple_sgl_flags;
@@ -1355,8 +1354,7 @@ _base_build_sg_scmd_ieee(struct MPT3SAS_ADAPTER *ioc,
sges_in_segment--;
}
 
-   /* initializing the chain flags and pointers */
-   chain_flags = MPI2_SGE_FLAGS_CHAIN_ELEMENT << MPI2_SGE_FLAGS_SHIFT;
+   /* initializing the pointers */
chain_req = _base_get_chain_buffer_tracker(ioc, smid);
if (!chain_req)
return -1;
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index ac9dbc2..61a1a45 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -2754,13 +2754,11 @@ _scsih_block_io_to_children_attached_directly(struct 
MPT3SAS_ADAPTER *ioc,
int i;
u16 handle;
u16 reason_code;
-   u8 phy_number;
 
for (i = 0; i < event_data->NumEntries; i++) {
handle = le16_to_cpu(event_data->PHY[i].AttachedDevHandle);
if (!handle)
continue;
-   phy_number = event_data->StartPhyNum + i;
reason_code = event_data->PHY[i].PhyStatus &
MPI2_EVENT_SAS_TOPO_RC_MASK;
if (reason_code == MPI2_EVENT_SAS_TOPO_RC_DELAY_NOT_RESPONDING)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[v2 PATCH 20/20][SCSI] mpt3sas: Adding support for MPT3SAS_MINOR(222)

2012-11-29 Thread sreekanth.reddy
Adding support for MPT3SAS_MINOR(222)

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 0549d211..9c9ba04 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -34,6 +34,7 @@
 #define MWAVE_MINOR219 /* ACP/Mwave Modem */
 #define MPT_MINOR  220
 #define MPT2SAS_MINOR  221
+#define MPT3SAS_MINOR  222
 #define UINPUT_MINOR   223
 #define HPET_MINOR 228
 #define FUSE_MINOR 229
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[v2 PATCH 19/20][SCSI] mpt3sas: Common API headers to set Diagnostic trigger for MPT based controllers

2012-11-29 Thread sreekanth.reddy
This patch provides common API headers to set Diagnostic trigger for MPT
(Message Passing Technology) based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h 
b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h
new file mode 100644
index 000..a10c309
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h
@@ -0,0 +1,193 @@
+/*
+ * This is the Fusion MPT base driver providing common API layer interface
+ * to set Diagnostic triggers for MPT (Message Passing Technology) based
+ * controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+  /* Diagnostic Trigger Configuration Data Structures */
+
+#ifndef MPT3SAS_TRIGGER_DIAG_H_INCLUDED
+#define MPT3SAS_TRIGGER_DIAG_H_INCLUDED
+
+/* limitation on number of entries */
+#define NUM_VALID_ENTRIES   (20)
+
+/* trigger types */
+#define MPT3SAS_TRIGGER_MASTER  (1)
+#define MPT3SAS_TRIGGER_EVENT   (2)
+#define MPT3SAS_TRIGGER_SCSI(3)
+#define MPT3SAS_TRIGGER_MPI (4)
+
+/* trigger names */
+#define MASTER_TRIGGER_FILE_NAME"diag_trigger_master"
+#define EVENT_TRIGGERS_FILE_NAME"diag_trigger_event"
+#define SCSI_TRIGGERS_FILE_NAME "diag_trigger_scsi"
+#define MPI_TRIGGER_FILE_NAME   "diag_trigger_mpi"
+
+/* master trigger bitmask */
+#define MASTER_TRIGGER_FW_FAULT (0x0001)
+#define MASTER_TRIGGER_ADAPTER_RESET(0x0002)
+#define MASTER_TRIGGER_TASK_MANAGMENT   (0x0004)
+#define MASTER_TRIGGER_DEVICE_REMOVAL   (0x0008)
+
+/* fake firmware event for tigger */
+#define MPI3_EVENT_DIAGNOSTIC_TRIGGER_FIRED(0x6E)
+
+/**
+ * MasterTrigger is a single U32 passed to/from sysfs.
+ *
+ * Bit Flags (enables) include:
+ * 1. FW Faults
+ * 2. Adapter Reset issued by driver
+ * 3. TMs
+ * 4. Device Remove Event sent by FW
+ */
+
+struct SL_WH_MASTER_TRIGGER_T {
+   uint32_t MasterData;
+};
+
+/**
+ * struct SL_WH_EVENT_TRIGGER_T -  Definition of an event trigger element
+ * @EventValue: Event Code to trigger on
+ * @LogEntryQualifier: Type of FW event that logged (Log Entry Added Event 
only)
+ *
+ * Defines an event that should induce a DIAG_TRIGGER driver event if observed.
+ */
+struct SL_WH_EVENT_TRIGGER_T {
+   uint16_t EventValue;
+   uint16_t LogEntryQualifier;
+};
+
+/**
+ * struct SL_WH_EVENT_TRIGGERS_T -  Structure passed to/from sysfs containing a
+ *list of Event Triggers to be monitored for.
+ * @ValidEntries: Number of _SL_WH_EVENT_TRIGGER_T structures contained in this
+ *structure.
+ * @EventTriggerEntry: List of Event trigger elements.
+ *
+ * This binary structure is transferred via sysfs to get/set Event Triggers
+ * in the Linux Driver.
+ */
+
+struct SL_WH_EVENT_TRIGGERS_T {
+   uint32_t ValidEntries;
+   struct SL_WH_EVENT_TRIGGER_T EventTriggerEntry[NUM_VALID_ENTRIES];
+};
+
+/**
+ * struct SL_WH_SC

[v2 PATCH 18/20][SCSI] mpt3sas: Common API to set Diagnostic trigger for MPT based controllers

2012-11-29 Thread sreekanth.reddy
This patch provides common API to set Diagnostic trigger for MPT
(Message Passing Technology) based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c 
b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
new file mode 100644
index 000..da6c5f2
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
@@ -0,0 +1,434 @@
+/*
+ * This module provides common API to set Diagnostic trigger for MPT
+ * (Message Passing Technology) based controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "mpt3sas_base.h"
+
+/**
+ * _mpt3sas_raise_sigio - notifiy app
+ * @ioc: per adapter object
+ * @event_data:
+ */
+static void
+_mpt3sas_raise_sigio(struct MPT3SAS_ADAPTER *ioc,
+   struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data)
+{
+   Mpi2EventNotificationReply_t *mpi_reply;
+   u16 sz, event_data_sz;
+   unsigned long flags;
+
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n",
+   ioc->name, __func__));
+
+   sz = offsetof(Mpi2EventNotificationReply_t, EventData) +
+   sizeof(struct SL_WH_TRIGGERS_EVENT_DATA_T) + 4;
+   mpi_reply = kzalloc(sz, GFP_KERNEL);
+   if (!mpi_reply)
+   goto out;
+   mpi_reply->Event = cpu_to_le16(MPI3_EVENT_DIAGNOSTIC_TRIGGER_FIRED);
+   event_data_sz = (sizeof(struct SL_WH_TRIGGERS_EVENT_DATA_T) + 4) / 4;
+   mpi_reply->EventDataLength = cpu_to_le16(event_data_sz);
+   memcpy(&mpi_reply->EventData, event_data,
+   sizeof(struct SL_WH_TRIGGERS_EVENT_DATA_T));
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT
+   "%s: add to driver event log\n",
+   ioc->name, __func__));
+   mpt3sas_ctl_add_to_event_log(ioc, mpi_reply);
+   kfree(mpi_reply);
+ out:
+
+   /* clearing the diag_trigger_active flag */
+   spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT
+   "%s: clearing diag_trigger_active flag\n",
+   ioc->name, __func__));
+   ioc->diag_trigger_active = 0;
+   spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags);
+
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT "%s: exit\n", ioc->name,
+   __func__));
+}
+
+/**
+ * mpt3sas_process_trigger_data - process the event data for the trigger
+ * @ioc: per adapter object
+ * @event_data:
+ */
+void
+mpt3sas_process_trigger_data(struct MPT3SAS_ADAPTER *ioc,
+   struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data)
+{
+   u8 issue_reset = 0;
+
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n",
+   ioc->name, __func__));
+
+   /* release the diag buffer trace */
+   if ((ioc->diag_buffer_status[MPI2_DIAG_BUF

[v2 PATCH 13/20][SCSI] mpt3sas: Logging Support for MPT based controllers

2012-11-29 Thread sreekanth.reddy
This patch provides Logging Support for MPT (Message Passing Technology)
based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_debug.h 
b/drivers/scsi/mpt3sas/mpt3sas_debug.h
new file mode 100644
index 000..ce70b87
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_debug.h
@@ -0,0 +1,219 @@
+/*
+ * Logging Support for MPT (Message Passing Technology) based controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#ifndef MPT3SAS_DEBUG_H_INCLUDED
+#define MPT3SAS_DEBUG_H_INCLUDED
+
+#define MPT_DEBUG  0x0001
+#define MPT_DEBUG_MSG_FRAME0x0002
+#define MPT_DEBUG_SG   0x0004
+#define MPT_DEBUG_EVENTS   0x0008
+#define MPT_DEBUG_EVENT_WORK_TASK  0x0010
+#define MPT_DEBUG_INIT 0x0020
+#define MPT_DEBUG_EXIT 0x0040
+#define MPT_DEBUG_FAIL 0x0080
+#define MPT_DEBUG_TM   0x0100
+#define MPT_DEBUG_REPLY0x0200
+#define MPT_DEBUG_HANDSHAKE0x0400
+#define MPT_DEBUG_CONFIG   0x0800
+#define MPT_DEBUG_DL   0x1000
+#define MPT_DEBUG_RESET0x2000
+#define MPT_DEBUG_SCSI 0x4000
+#define MPT_DEBUG_IOCTL0x8000
+#define MPT_DEBUG_SAS  0x0002
+#define MPT_DEBUG_TRANSPORT0x0004
+#define MPT_DEBUG_TASK_SET_FULL0x0008
+
+#define MPT_DEBUG_TRIGGER_DIAG 0x0020
+
+
+/*
+ * CONFIG_SCSI_MPT3SAS_LOGGING - enabled in Kconfig
+ */
+
+#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
+#define MPT_CHECK_LOGGING(IOC, CMD, BITS)  \
+{  \
+   if (IOC->logging_level & BITS)  \
+   CMD;\
+}
+#else
+#define MPT_CHECK_LOGGING(IOC, CMD, BITS)
+#endif /* CONFIG_SCSI_MPT3SAS_LOGGING */
+
+
+/*
+ * debug macros
+ */
+
+#define dprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
+
+#define dsgprintk(IOC, CMD)\
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
+
+#define devtprintk(IOC, CMD)   \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
+
+#define dewtprintk(IOC, CMD)   \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENT_WORK_TASK)
+
+#define dinitprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
+
+#define dexitprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
+
+#define dfailprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
+
+#define dtmprintk(IOC, CMD)\
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
+
+#define dreplypri

[v2 PATCH 12/20][SCSI] mpt3sas: Ioctl Module Support for MPT based controllers

2012-11-29 Thread sreekanth.reddy
This patch provides headers for ioctl Module Support for MPT (Message Passing 
Technology)
based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.h 
b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
new file mode 100644
index 000..bd89f4f
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
@@ -0,0 +1,418 @@
+/*
+ * Management Module Support for MPT (Message Passing Technology) based
+ * controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.h
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#ifndef MPT3SAS_CTL_H_INCLUDED
+#define MPT3SAS_CTL_H_INCLUDED
+
+#ifdef __KERNEL__
+#include 
+#endif
+
+
+#ifndef MPT3SAS_MINOR
+#define MPT3SAS_MINOR  (MPT_MINOR + 2)
+#endif
+#define MPT3SAS_DEV_NAME   "mpt3ctl"
+#define MPT3_MAGIC_NUMBER  'L'
+#define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
+
+/**
+ * IOCTL opcodes
+ */
+#define MPT3IOCINFO_IOWR(MPT3_MAGIC_NUMBER, 17, \
+   struct mpt3_ioctl_iocinfo)
+#define MPT3COMMAND_IOWR(MPT3_MAGIC_NUMBER, 20, \
+   struct mpt3_ioctl_command)
+#ifdef CONFIG_COMPAT
+#define MPT3COMMAND32  _IOWR(MPT3_MAGIC_NUMBER, 20, \
+   struct mpt3_ioctl_command32)
+#endif
+#define MPT3EVENTQUERY _IOWR(MPT3_MAGIC_NUMBER, 21, \
+   struct mpt3_ioctl_eventquery)
+#define MPT3EVENTENABLE_IOWR(MPT3_MAGIC_NUMBER, 22, \
+   struct mpt3_ioctl_eventenable)
+#define MPT3EVENTREPORT_IOWR(MPT3_MAGIC_NUMBER, 23, \
+   struct mpt3_ioctl_eventreport)
+#define MPT3HARDRESET  _IOWR(MPT3_MAGIC_NUMBER, 24, \
+   struct mpt3_ioctl_diag_reset)
+#define MPT3BTDHMAPPING_IOWR(MPT3_MAGIC_NUMBER, 31, \
+   struct mpt3_ioctl_btdh_mapping)
+
+/* diag buffer support */
+#define MPT3DIAGREGISTER _IOWR(MPT3_MAGIC_NUMBER, 26, \
+   struct mpt3_diag_register)
+#define MPT3DIAGRELEASE_IOWR(MPT3_MAGIC_NUMBER, 27, \
+   struct mpt3_diag_release)
+#define MPT3DIAGUNREGISTER _IOWR(MPT3_MAGIC_NUMBER, 28, \
+   struct mpt3_diag_unregister)
+#define MPT3DIAGQUERY  _IOWR(MPT3_MAGIC_NUMBER, 29, \
+   struct mpt3_diag_query)
+#define MPT3DIAGREADBUFFER _IOWR(MPT3_MAGIC_NUMBER, 30, \
+   struct mpt3_diag_read_buffer)
+
+/**
+ * struct mpt3_ioctl_header - main header structure
+ * @ioc_number -  IOC unit number
+ * @port_number - IOC port number
+ * @max_data_size - maximum number bytes to transfer on read
+ */
+struct mpt3_ioctl_header {
+   uint32_t ioc_number;
+   uint32_t port_number;
+   uint32_t max_data_size;
+};
+
+/**
+ * struct mpt3_ioctl_diag_reset - diagnostic reset
+ * @hdr - generic header
+ */
+struct mpt3_ioctl_diag_reset {
+   struct mpt3_ioctl_header hdr;
+};
+
+
+/**
+ * struct mpt3_ioctl_pci_info - pci device info
+ * @device - pci device id
+ * @function - pci function id
+ * @bus - pci bus id
+ * @segment_id - pci segment id
+ */
+struct mpt3_ioctl_pci_info {
+   union {
+   struct {
+   uint32

[v2 PATCH 10/20][SCSI] mpt3sas: Common API for accessing firmware configuration pages

2012-11-29 Thread sreekanth.reddy
This patch provides common API for accessing firmware configuration pages

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_config.c 
b/drivers/scsi/mpt3sas/mpt3sas_config.c
new file mode 100644
index 000..ce7e59b
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_config.c
@@ -0,0 +1,1650 @@
+/*
+ * This module provides common API for accessing firmware configuration pages
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.c
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mpt3sas_base.h"
+
+/* local definitions */
+
+/* Timeout for config page request (in seconds) */
+#define MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT 15
+
+/* Common sgl flags for READING a config page. */
+#define MPT3_CONFIG_COMMON_SGLFLAGS ((MPI2_SGE_FLAGS_SIMPLE_ELEMENT | \
+   MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER \
+   | MPI2_SGE_FLAGS_END_OF_LIST) << MPI2_SGE_FLAGS_SHIFT)
+
+/* Common sgl flags for WRITING a config page. */
+#define MPT3_CONFIG_COMMON_WRITE_SGLFLAGS ((MPI2_SGE_FLAGS_SIMPLE_ELEMENT | \
+   MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER \
+   | MPI2_SGE_FLAGS_END_OF_LIST | MPI2_SGE_FLAGS_HOST_TO_IOC) \
+   << MPI2_SGE_FLAGS_SHIFT)
+
+/**
+ * struct config_request - obtain dma memory via routine
+ * @sz: size
+ * @page: virt pointer
+ * @page_dma: phys pointer
+ *
+ */
+struct config_request {
+   u16 sz;
+   void*page;
+   dma_addr_t  page_dma;
+};
+
+#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
+/**
+ * _config_display_some_debug - debug routine
+ * @ioc: per adapter object
+ * @smid: system request message index
+ * @calling_function_name: string pass from calling function
+ * @mpi_reply: reply message frame
+ * Context: none.
+ *
+ * Function for displaying debug info helpful when debugging issues
+ * in this module.
+ */
+static void
+_config_display_some_debug(struct MPT3SAS_ADAPTER *ioc, u16 smid,
+   char *calling_function_name, MPI2DefaultReply_t *mpi_reply)
+{
+   Mpi2ConfigRequest_t *mpi_request;
+   char *desc = NULL;
+
+   if (!(ioc->logging_level & MPT_DEBUG_CONFIG))
+   return;
+
+   mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
+   switch (mpi_request->Header.PageType & MPI2_CONFIG_PAGETYPE_MASK) {
+   case MPI2_CONFIG_PAGETYPE_IO_UNIT:
+   desc = "io_unit";
+   break;
+   case MPI2_CONFIG_PAGETYPE_IOC:
+   desc = "ioc";
+   break;
+   case MPI2_CONFIG_PAGETYPE_BIOS:
+   desc = "bios";
+   break;
+   case MPI2_CONFIG_PAGETYPE_RAID_VOLUME:
+   desc = "raid_volume";
+   break;
+   case MPI2_CONFIG_PAGETYPE_MANUFACTURING:
+   desc = "manufaucturing";
+   break;
+   cas

[v2 PATCH 9/20][SCSI] mpt3sas: Common API layer interface headers for access to MPT firmware.

2012-11-29 Thread sreekanth.reddy
This patch contains the Fusion MPT base driver providing common API layer 
interface
headers for access to MPT (Message Passing Technology) firmware.

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
new file mode 100644
index 000..994656c
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -0,0 +1,1139 @@
+/*
+ * This is the Fusion MPT base driver providing common API layer interface
+ * for access to MPT (Message Passing Technology) firmware.
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#ifndef MPT3SAS_BASE_H_INCLUDED
+#define MPT3SAS_BASE_H_INCLUDED
+
+#include "mpi/mpi2_type.h"
+#include "mpi/mpi2.h"
+#include "mpi/mpi2_ioc.h"
+#include "mpi/mpi2_cnfg.h"
+#include "mpi/mpi2_init.h"
+#include "mpi/mpi2_raid.h"
+#include "mpi/mpi2_tool.h"
+#include "mpi/mpi2_sas.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mpt3sas_debug.h"
+#include "mpt3sas_trigger_diag.h"
+
+/* driver versioning info */
+#define MPT3SAS_DRIVER_NAME"mpt3sas"
+#define MPT3SAS_AUTHOR "LSI Corporation "
+#define MPT3SAS_DESCRIPTION"LSI MPT Fusion SAS 3.0 Device Driver"
+#define MPT3SAS_DRIVER_VERSION "01.100.01.00"
+#define MPT3SAS_MAJOR_VERSION  1
+#define MPT3SAS_MINOR_VERSION  100
+#define MPT3SAS_BUILD_VERSION  1
+#define MPT3SAS_RELEASE_VERSION00
+
+/*
+ * Set MPT3SAS_SG_DEPTH value based on user input.
+ */
+#define MPT3SAS_MAX_PHYS_SEGMENTS  SCSI_MAX_SG_SEGMENTS
+#define MPT3SAS_MIN_PHYS_SEGMENTS  16
+#ifdef CONFIG_SCSI_MPT3SAS_MAX_SGE
+#define MPT3SAS_SG_DEPTH   CONFIG_SCSI_MPT3SAS_MAX_SGE
+#else
+#define MPT3SAS_SG_DEPTH   MPT3SAS_MAX_PHYS_SEGMENTS
+#endif
+
+
+/*
+ * Generic Defines
+ */
+#define MPT3SAS_SATA_QUEUE_DEPTH   32
+#define MPT3SAS_SAS_QUEUE_DEPTH254
+#define MPT3SAS_RAID_QUEUE_DEPTH   128
+
+#define MPT_NAME_LENGTH32  /* generic length of 
strings */
+#define MPT_STRING_LENGTH  64
+
+#define MPT_MAX_CALLBACKS  32
+
+
+#define CAN_SLEEP  1
+#define  NO_SLEEP  0
+
+#define INTERNAL_CMDS_COUNT10  /* reserved cmds */
+
+#define MPI3_HIM_MASK  0x /* mask every bit*/
+
+#define MPT3SAS_INVALID_DEVICE_HANDLE  0x
+
+/*
+ * reset phases
+ */
+#define MPT3_IOC_PRE_RESET 1 /* prior to host reset */
+#define MPT3_IOC_AFTER_RESET   2 /* just after host reset */
+#define MPT3_IOC_DONE_RESET3 /* links re-initialized */
+
+/*
+ * logging format
+ */
+#define MPT3SAS_FMT"%s: "
+
+/*
+ * per target private data
+ */
+#define MPT_TARGET_FLAGS_RAID_COMPONENT0x01
+#define MPT_TARGET_FLAGS_VOLUME0x02
+#def

[v2 PATCH 6/20][SCSI] mpt3sas: Part 5 of MPI API headers

2012-11-29 Thread sreekanth.reddy
This patch contains MPI API headers
This patch is part 5 of MPI API headers.

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_raid.h 
b/drivers/scsi/mpt3sas/mpi/mpi2_raid.h
new file mode 100644
index 000..d1d9866
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_raid.h
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2000-2012 LSI Corporation.
+ *
+ *
+ *  Name:  mpi2_raid.h
+ * Title:  MPI Integrated RAID messages and structures
+ * Creation Date:  April 26, 2007
+ *
+ *   mpi2_raid.h Version:  02.00.08
+ *
+ * Version History
+ * ---
+ *
+ * Date  Version   Description
+ *     --
+ * 04-30-07  02.00.00  Corresponds to Fusion-MPT MPI Specification Rev A.
+ * 08-31-07  02.00.01  Modifications to RAID Action request and reply,
+ * including the Actions and ActionData.
+ * 02-29-08  02.00.02  Added MPI2_RAID_ACTION_ADATA_DISABL_FULL_REBUILD.
+ * 05-21-08  02.00.03  Added MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS so that
+ * the PhysDisk array in MPI2_RAID_VOLUME_CREATION_STRUCT
+ * can be sized by the build environment.
+ * 07-30-09  02.00.04  Added proper define for the Use Default Settings bit of
+ * VolumeCreationFlags and marked the old one as obsolete.
+ * 05-12-10  02.00.05  Added MPI2_RAID_VOL_FLAGS_OP_MDC define.
+ * 08-24-10  02.00.06  Added MPI2_RAID_ACTION_COMPATIBILITY_CHECK along with
+ * related structures and defines.
+ * Added product-specific range to RAID Action values.
+ * 11-18-11  02.00.07  Incorporating additions for MPI v2.5.
+ * 02-06-12  02.00.08  Added MPI2_RAID_ACTION_PHYSDISK_HIDDEN.
+ * --
+ */
+
+#ifndef MPI2_RAID_H
+#define MPI2_RAID_H
+
+/*
+*
+*  Integrated RAID Messages
+*
+*/
+
+/
+* RAID Action messages
+/
+
+/*ActionDataWord defines for use with MPI2_RAID_ACTION_DELETE_VOLUME action */
+#define MPI2_RAID_ACTION_ADATA_KEEP_LBA0(0x)
+#define MPI2_RAID_ACTION_ADATA_ZERO_LBA0(0x0001)
+
+/*use MPI2_RAIDVOL0_SETTING_ defines from mpi2_cnfg.h for
+ *MPI2_RAID_ACTION_CHANGE_VOL_WRITE_CACHE action */
+
+/*ActionDataWord defines for use with
+ *MPI2_RAID_ACTION_DISABLE_ALL_VOLUMES action */
+#define MPI2_RAID_ACTION_ADATA_DISABL_FULL_REBUILD  (0x0001)
+
+/*ActionDataWord for MPI2_RAID_ACTION_SET_RAID_FUNCTION_RATE Action */
+typedef struct _MPI2_RAID_ACTION_RATE_DATA {
+   U8 RateToChange;/*0x00 */
+   U8 RateOrMode;  /*0x01 */
+   U16 DataScrubDuration;  /*0x02 */
+} MPI2_RAID_ACTION_RATE_DATA, *PTR_MPI2_RAID_ACTION_RATE_DATA,
+   Mpi2RaidActionRateData_t, *pMpi2RaidActionRateData_t;
+
+#define MPI2_RAID_ACTION_SET_RATE_RESYNC(0x00)
+#define MPI2_RAID_ACTION_SET_RATE_DATA_SCRUB(0x01)
+#define MPI2_RAID_ACTION_SET_RATE_POWERSAVE_MODE(0x02)
+
+/*ActionDataWord for MPI2_RAID_ACTION_START_RAID_FUNCTION Action */
+typedef struct _MPI2_RAID_ACTION_START_RAID_FUNCTION {
+   U8 RAIDFunction;/*0x00 */
+   U8 Flags;   /*0x01 */
+   U16 Reserved1;  /*0x02 */
+} MPI2_RAID_ACTION_START_RAID_FUNCTION,
+   *PTR_MPI2_RAID_ACTION_START_RAID_FUNCTION,
+   Mpi2RaidActionStartRaidFunction_t,
+   *pMpi2RaidActionStartRaidFunction_t;
+
+/*defines for the RAIDFunction field */
+#define MPI2_RAID_ACTION_START_BACKGROUND_INIT  (0x00)
+#define MPI2_RAID_ACTION_START_ONLINE_CAP_EXPANSION (0x01)
+#define MPI2_RAID_ACTION_START_CONSISTENCY_CHECK(0x02)
+
+/*defines for the Flags field */
+#define MPI2_RAID_ACTION_START_NEW  (0x00)
+#define MPI2_RAID_ACTION_START_RESUME   (0x01)
+
+/*ActionDataWord for MPI2_RAID_ACTION_STOP_RAID_FUNCTION Action */
+typedef struct _MPI2_RAID_ACTION_STOP_RAID_FUNCTION {
+   U8 RAIDFunction;/*0x00 */
+   U8 Flags;   /*0x01 */
+   U16 Reserved1;  /*0x02 */
+} MPI2_RAID_ACTION_STOP_RAID_FUNCTION,
+   *PTR_MPI2_RAID_ACTION_STOP_RAID_FUNCTION,
+   Mpi2RaidActionStopRaidFunction_t,
+   *pMpi2RaidActionStopRaidFunction_t;
+
+/*defines for the RAIDFunction field */
+#define MPI2_RAID_ACTION_STOP_BACKGROUND_INIT   (0x00)
+#define MPI2_RAID_ACTION_STOP_ONLINE_CAP_EXPANSION  (0x01)
+#define MPI2_RAID_ACTION_STOP_CONSISTENCY_CHECK (0x02)
+
+/*defines for the Flags field */
+#define MPI2_RAID_ACTION_STOP_ABORT (0x00)
+#define MPI2_RAID_ACTION_STOP_PAUSE (0x01)
+
+/*Act

[v2 PATCH 2/20][SCSI] mpt3sas: Part 1 of MPI API headers

2012-11-29 Thread sreekanth.reddy
This patch contains MPI API headers
This patch is part 1 of MPI API headers.

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpi/mpi2.h b/drivers/scsi/mpt3sas/mpi/mpi2.h
new file mode 100644
index 000..03317ff
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpi/mpi2.h
@@ -0,0 +1,1164 @@
+/*
+ * Copyright (c) 2000-2012 LSI Corporation.
+ *
+ *
+ *  Name:  mpi2.h
+ * Title:  MPI Message independent structures and definitions
+ * including System Interface Register Set and
+ * scatter/gather formats.
+ * Creation Date:  June 21, 2006
+ *
+ * mpi2.h Version:  02.00.26
+ *
+ * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
+ *   prefix are for use only on MPI v2.5 products, and must not be used
+ *   with MPI v2.0 products. Unless otherwise noted, names beginning with
+ *   MPI2 or Mpi2 are for use with both MPI v2.0 and MPI v2.5 products.
+ *
+ * Version History
+ * ---
+ *
+ * Date  Version   Description
+ *     --
+ * 04-30-07  02.00.00  Corresponds to Fusion-MPT MPI Specification Rev A.
+ * 06-04-07  02.00.01  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 06-26-07  02.00.02  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 08-31-07  02.00.03  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Moved ReplyPostHostIndex register to offset 0x6C of the
+ * MPI2_SYSTEM_INTERFACE_REGS and modified the define for
+ * MPI2_REPLY_POST_HOST_INDEX_OFFSET.
+ * Added union of request descriptors.
+ * Added union of reply descriptors.
+ * 10-31-07  02.00.04  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added define for MPI2_VERSION_02_00.
+ * Fixed the size of the FunctionDependent5 field in the
+ * MPI2_DEFAULT_REPLY structure.
+ * 12-18-07  02.00.05  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Removed the MPI-defined Fault Codes and extended the
+ * product specific codes up to 0xEFFF.
+ * Added a sixth key value for the WriteSequence register
+ * and changed the flush value to 0x0.
+ * Added message function codes for Diagnostic Buffer Post
+ * and Diagnsotic Release.
+ * New IOCStatus define: MPI2_IOCSTATUS_DIAGNOSTIC_RELEASED
+ * Moved MPI2_VERSION_UNION from mpi2_ioc.h.
+ * 02-29-08  02.00.06  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 03-03-08  02.00.07  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 05-21-08  02.00.08  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added #defines for marking a reply descriptor as unused.
+ * 06-27-08  02.00.09  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 10-02-08  02.00.10  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Moved LUN field defines from mpi2_init.h.
+ * 01-19-09  02.00.11  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 05-06-09  02.00.12  Bumped MPI2_HEADER_VERSION_UNIT.
+ * In all request and reply descriptors, replaced VF_ID
+ * field with MSIxIndex field.
+ * Removed DevHandle field from
+ * MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR and made those
+ * bytes reserved.
+ * Added RAID Accelerator functionality.
+ * 07-30-09  02.00.13  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 10-28-09  02.00.14  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added MSI-x index mask and shift for Reply Post Host
+ * Index register.
+ * Added function code for Host Based Discovery Action.
+ * 02-10-10  02.00.15  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added define for MPI2_FUNCTION_PWR_MGMT_CONTROL.
+ * Added defines for product-specific range of message
+ * function codes, 0xF0 to 0xFF.
+ * 05-12-10  02.00.16  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added alternative defines for the SGE Direction bit.
+ * 08-11-10  02.00.17  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 11-10-10  02.00.18  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added MPI2_IEEE_SGE_FLAGS_SYSTEMPLBCPI_ADDR define.
+ * 02-23-11  02.00.19  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added MPI2_FUNCTION_SEND_HOST_MESSAGE.
+ * 03-09-11  02.00.20  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 05-25-11  02.00.21  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 08-24-11  02.00.22  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 11-18-11  02.00.23  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Incorporating additions for MPI v2.5.
+ * 02-06-12  02.00.24  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 03-29-12  02.00.25  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added Hard Reset delay timings.
+ * 07-10-12  02.00.26  Bump

[v2 PATCH 1/20][SCSI] mpt3sas: Makefile, Kconfig and scsi_transport_sas file changes to support new driver mpt3sas

2012-11-29 Thread sreekanth.reddy
This patch contains the Makefile, Kconfig and 
scsi_transport_sas file changes to support new driver mpt3sas

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index e955978..49244f8 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -620,6 +620,7 @@ config SCSI_ARCMSR
 
 source "drivers/scsi/megaraid/Kconfig.megaraid"
 source "drivers/scsi/mpt2sas/Kconfig"
+source "drivers/scsi/mpt3sas/Kconfig"
 source "drivers/scsi/ufs/Kconfig"
 
 config SCSI_HPTIOP
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 1a3368b..88e52bb 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -106,6 +106,7 @@ obj-$(CONFIG_MEGARAID_LEGACY)   += megaraid.o
 obj-$(CONFIG_MEGARAID_NEWGEN)  += megaraid/
 obj-$(CONFIG_MEGARAID_SAS) += megaraid/
 obj-$(CONFIG_SCSI_MPT2SAS) += mpt2sas/
+obj-$(CONFIG_SCSI_MPT3SAS) += mpt3sas/
 obj-$(CONFIG_SCSI_UFSHCD)  += ufs/
 obj-$(CONFIG_SCSI_ACARD)   += atp870u.o
 obj-$(CONFIG_SCSI_SUNESP)  += esp_scsi.o   sun_esp.o
diff --git a/drivers/scsi/mpt3sas/Kconfig b/drivers/scsi/mpt3sas/Kconfig
new file mode 100644
index 000..81471bf
--- /dev/null
+++ b/drivers/scsi/mpt3sas/Kconfig
@@ -0,0 +1,67 @@
+#
+# Kernel configuration file for the MPT3SAS
+#
+# This code is based on drivers/scsi/mpt3sas/Kconfig
+# Copyright (C) 2012  LSI Corporation
+#  (mailto:dl-mptfusionli...@lsi.com)
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# NO WARRANTY
+# THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+# LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+# solely responsible for determining the appropriateness of using and
+# distributing the Program and assumes all risks associated with its
+# exercise of rights under this Agreement, including but not limited to
+# the risks and costs of program errors, damage to or loss of data,
+# programs or equipment, and unavailability or interruption of operations.
+
+# DISCLAIMER OF LIABILITY
+# NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+# HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+# USA.
+
+config SCSI_MPT3SAS
+   tristate "LSI MPT Fusion SAS 3.0 Device Driver"
+   depends on PCI && SCSI
+   select SCSI_SAS_ATTRS
+   select RAID_ATTRS
+   ---help---
+   This driver supports PCI-Express SAS 12Gb/s Host Adapters.
+
+config SCSI_MPT3SAS_MAX_SGE
+   int "LSI MPT Fusion Max number of SG Entries (16 - 256)"
+   depends on PCI && SCSI && SCSI_MPT3SAS
+   default "128"
+   range 16 256
+   ---help---
+   This option allows you to specify the maximum number of scatter-
+   gather entries per I/O. The driver default is 128, which matches
+   MAX_PHYS_SEGMENTS in most kernels.  However in SuSE kernels this
+   can be 256. However, it may decreased down to 16.  Decreasing this
+   parameter will reduce memory requirements on a per controller instance.
+
+config SCSI_MPT3SAS_LOGGING
+   bool "LSI MPT Fusion logging facility"
+   depends on PCI && SCSI && SCSI_MPT3SAS
+   ---help---
+   This turns on a logging facility.
diff --git a/drivers/scsi/mpt3sas/Makefile b/drivers/scsi/mpt3sas/Makefile
new file mode 100644
index 000..4c1d2e7
--- /dev/null
+++ b/drivers/scsi/mpt3sas/Makefile
@@ -0,0 +1,8 @@
+# mpt3sas makefile
+obj-m += mpt3sas.o
+mpt3sas-y +=  mpt3sas_base.o \
+   mpt3sas_config.o \
+   mpt3sas_scsih.o  \
+   mpt3sas_transport.o \
+   mpt3sas_ctl.o   \
+   mpt3sas_trigger_diag.o
diff --git a/drivers/scsi/scsi_transport_sas.c 
b/drivers/scsi/scsi_transport_sas.c
index f7565fc..1b68142 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ 

[v2 PATCH 0/20][SCSI] mpt3sas: Driver submission v01.100.01.00

2012-11-29 Thread sreekanth.reddy
This is new scsi lld device driver from LSI supporting the SAS 3.0
standard.

Here is list of new 12gb host controllers:

  LSI SAS3004
  LSI SAS3008
  LSI SAS3108

Here are the changes in the 2nd posting of this patch set:

 (1) Fix compile errors when SCSI_MPT3SAS_LOGGING is not enabled.
 (2) Set the task attribute field to "Simple" if the mpt3sas driver receives 
CDB with
 untagged task attribute field.
 (3) Fix for an issue due to which the phys are not discovered when volume 
members are
 hot removed and added while performing diag reset.

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---
Here is the brief description of patches:
[PATCH 01/20] [SCSI] mpt3sas : Makefile, Kconfig and scsi_transport_sas file 
changes to support new driver mpt3sas
[PATCH 02/20] [SCSI] mpt3sas : MPI API headers. This patch is part 1 of MPI API 
headers.
[PATCH 03/20] [SCSI] mpt3sas : MPI API headers. This patch is part 2 of MPI API 
headers.
[PATCH 04/20] [SCSI] mpt3sas : MPI API headers. This patch is part 3 of MPI API 
headers.
[PATCH 05/20] [SCSI] mpt3sas : MPI API headers. This patch is part 4 of MPI API 
headers.
[PATCH 06/20] [SCSI] mpt3sas : MPI API headers. This patch is part 5 of MPI API 
headers.
[PATCH 07/20] [SCSI] mpt3sas : Fusion MPT base driver providing common API 
layer interface
for access to MPT (Message 
Passing Technology) firmware.
This patch is part 1 of 
mpt3sas_base.c
[PATCH 08/20] [SCSI] mpt3sas : This patch is part 2 of mpt3sas_base.c
[PATCH 09/20] [SCSI] mpt3sas : Fusion MPT base driver providing common API 
layer interface
headers for access to MPT 
(Message Passing Technology) firmware.
[PATCH 10/20] [SCSI] mpt3sas : Common API for accessing firmware configuration 
pages
[PATCH 11/20] [SCSI] mpt3sas : Ioctl Support for MPT (Message Passing 
Technology)
based controller
[PATCH 12/20] [SCSI] mpt3sas : Ioctl Module Support headers for MPT (Message 
Passing Technology)
based controllers
[PATCH 13/20] [SCSI] mpt3sas : Logging Support for MPT (Message Passing 
Technology)
based controllers
[PATCH 14/20] [SCSI] mpt3sas : Code related to Scsi Host Layer for
MPT (Message Passing 
Technology) based controllers
This patch is part 1 of 
mpt3sas_scsih.c
[PATCH 15/20] [SCSI] mpt3sas : This patch is part 2 of mpt3sas_scsih.c
[PATCH 16/20] [SCSI] mpt3sas : This patch is part 3 of mpt3sas_scsih.c
[PATCH 17/20] [SCSI] mpt3sas : Code related to SAS Transport Layer for
MPT (Message Passing Technology) based 
controllers
[PATCH 18/20] [SCSI] mpt3sas : Common API to set Diagnostic trigger for MPT
(Message Passing Technology) based 
controllers
[PATCH 19/20] [SCSI] mpt3sas : Common API headers to set Diagnostic trigger for 
MPT
(Message Passing Technology) based 
controllers
[PATCH 20/20] [SCSI] mpt3sas : Adding support for MPT3SAS_MINOR(222)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] MAINTAINERS : update LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI) maintainers

2012-10-09 Thread sreekanth.reddy
Updating the MAINTAINERS file for the entry LSILOGIC MPT FUSION
DRIVERS

Signed-off-by: Sreekanth Reddy 
---

diff --git a/MAINTAINERS b/MAINTAINERS
index 14bc707..de4a3a8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4282,13 +4282,16 @@ S:  Maintained
 F: fs/logfs/
 
 LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI)
-M: Eric Moore 
+M: Nagalakshmi Nandigama 
+M: Sreekanth Reddy 
 M: supp...@lsi.com
 L: dl-mptfusionli...@lsi.com
 L: linux-scsi@vger.kernel.org
 W: http://www.lsilogic.com/support
 S: Supported
 F: drivers/message/fusion/
+F: drivers/scsi/mpt2sas/
+F: drivers/scsi/mpt3sas/
 
 LSILOGIC/SYMBIOS/NCR 53C8XX and 53C1010 PCI-SCSI drivers
 M: Matthew Wilcox 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND][PATCH 20/20][SCSI] mpt3sas: Adding support for MPT3SAS_MINOR(222)

2012-09-29 Thread sreekanth.reddy
Adding support for MPT3SAS_MINOR(222)

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 0549d211..9c9ba04 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -34,6 +34,7 @@
 #define MWAVE_MINOR219 /* ACP/Mwave Modem */
 #define MPT_MINOR  220
 #define MPT2SAS_MINOR  221
+#define MPT3SAS_MINOR  222
 #define UINPUT_MINOR   223
 #define HPET_MINOR 228
 #define FUSE_MINOR 229
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND][PATCH 19/20][SCSI] mpt3sas: Common API headers to set Diagnostic trigger for MPT based controllers

2012-09-29 Thread sreekanth.reddy
This patch provides common API headers to set Diagnostic trigger for MPT
(Message Passing Technology) based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h 
b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h
new file mode 100644
index 000..a10c309
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h
@@ -0,0 +1,193 @@
+/*
+ * This is the Fusion MPT base driver providing common API layer interface
+ * to set Diagnostic triggers for MPT (Message Passing Technology) based
+ * controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+  /* Diagnostic Trigger Configuration Data Structures */
+
+#ifndef MPT3SAS_TRIGGER_DIAG_H_INCLUDED
+#define MPT3SAS_TRIGGER_DIAG_H_INCLUDED
+
+/* limitation on number of entries */
+#define NUM_VALID_ENTRIES   (20)
+
+/* trigger types */
+#define MPT3SAS_TRIGGER_MASTER  (1)
+#define MPT3SAS_TRIGGER_EVENT   (2)
+#define MPT3SAS_TRIGGER_SCSI(3)
+#define MPT3SAS_TRIGGER_MPI (4)
+
+/* trigger names */
+#define MASTER_TRIGGER_FILE_NAME"diag_trigger_master"
+#define EVENT_TRIGGERS_FILE_NAME"diag_trigger_event"
+#define SCSI_TRIGGERS_FILE_NAME "diag_trigger_scsi"
+#define MPI_TRIGGER_FILE_NAME   "diag_trigger_mpi"
+
+/* master trigger bitmask */
+#define MASTER_TRIGGER_FW_FAULT (0x0001)
+#define MASTER_TRIGGER_ADAPTER_RESET(0x0002)
+#define MASTER_TRIGGER_TASK_MANAGMENT   (0x0004)
+#define MASTER_TRIGGER_DEVICE_REMOVAL   (0x0008)
+
+/* fake firmware event for tigger */
+#define MPI3_EVENT_DIAGNOSTIC_TRIGGER_FIRED(0x6E)
+
+/**
+ * MasterTrigger is a single U32 passed to/from sysfs.
+ *
+ * Bit Flags (enables) include:
+ * 1. FW Faults
+ * 2. Adapter Reset issued by driver
+ * 3. TMs
+ * 4. Device Remove Event sent by FW
+ */
+
+struct SL_WH_MASTER_TRIGGER_T {
+   uint32_t MasterData;
+};
+
+/**
+ * struct SL_WH_EVENT_TRIGGER_T -  Definition of an event trigger element
+ * @EventValue: Event Code to trigger on
+ * @LogEntryQualifier: Type of FW event that logged (Log Entry Added Event 
only)
+ *
+ * Defines an event that should induce a DIAG_TRIGGER driver event if observed.
+ */
+struct SL_WH_EVENT_TRIGGER_T {
+   uint16_t EventValue;
+   uint16_t LogEntryQualifier;
+};
+
+/**
+ * struct SL_WH_EVENT_TRIGGERS_T -  Structure passed to/from sysfs containing a
+ *list of Event Triggers to be monitored for.
+ * @ValidEntries: Number of _SL_WH_EVENT_TRIGGER_T structures contained in this
+ *structure.
+ * @EventTriggerEntry: List of Event trigger elements.
+ *
+ * This binary structure is transferred via sysfs to get/set Event Triggers
+ * in the Linux Driver.
+ */
+
+struct SL_WH_EVENT_TRIGGERS_T {
+   uint32_t ValidEntries;
+   struct SL_WH_EVENT_TRIGGER_T EventTriggerEntry[NUM_VALID_ENTRIES];
+};
+
+/**
+ * struct SL_WH_SC

[RESEND][PATCH 18/20][SCSI] mpt3sas: Common API to set Diagnostic trigger for MPT based controllers

2012-09-29 Thread sreekanth.reddy
This patch provides common API to set Diagnostic trigger for MPT
(Message Passing Technology) based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c 
b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
new file mode 100644
index 000..da6c5f2
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
@@ -0,0 +1,434 @@
+/*
+ * This module provides common API to set Diagnostic trigger for MPT
+ * (Message Passing Technology) based controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "mpt3sas_base.h"
+
+/**
+ * _mpt3sas_raise_sigio - notifiy app
+ * @ioc: per adapter object
+ * @event_data:
+ */
+static void
+_mpt3sas_raise_sigio(struct MPT3SAS_ADAPTER *ioc,
+   struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data)
+{
+   Mpi2EventNotificationReply_t *mpi_reply;
+   u16 sz, event_data_sz;
+   unsigned long flags;
+
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n",
+   ioc->name, __func__));
+
+   sz = offsetof(Mpi2EventNotificationReply_t, EventData) +
+   sizeof(struct SL_WH_TRIGGERS_EVENT_DATA_T) + 4;
+   mpi_reply = kzalloc(sz, GFP_KERNEL);
+   if (!mpi_reply)
+   goto out;
+   mpi_reply->Event = cpu_to_le16(MPI3_EVENT_DIAGNOSTIC_TRIGGER_FIRED);
+   event_data_sz = (sizeof(struct SL_WH_TRIGGERS_EVENT_DATA_T) + 4) / 4;
+   mpi_reply->EventDataLength = cpu_to_le16(event_data_sz);
+   memcpy(&mpi_reply->EventData, event_data,
+   sizeof(struct SL_WH_TRIGGERS_EVENT_DATA_T));
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT
+   "%s: add to driver event log\n",
+   ioc->name, __func__));
+   mpt3sas_ctl_add_to_event_log(ioc, mpi_reply);
+   kfree(mpi_reply);
+ out:
+
+   /* clearing the diag_trigger_active flag */
+   spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT
+   "%s: clearing diag_trigger_active flag\n",
+   ioc->name, __func__));
+   ioc->diag_trigger_active = 0;
+   spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags);
+
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT "%s: exit\n", ioc->name,
+   __func__));
+}
+
+/**
+ * mpt3sas_process_trigger_data - process the event data for the trigger
+ * @ioc: per adapter object
+ * @event_data:
+ */
+void
+mpt3sas_process_trigger_data(struct MPT3SAS_ADAPTER *ioc,
+   struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data)
+{
+   u8 issue_reset = 0;
+
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n",
+   ioc->name, __func__));
+
+   /* release the diag buffer trace */
+   if ((ioc->diag_buffer_status[MPI2_DIAG_BUF

[RESEND][PATCH 13/20][SCSI] mpt3sas: Logging Support for MPT based controllers

2012-09-29 Thread sreekanth.reddy
This patch provides Logging Support for MPT (Message Passing Technology)
based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_debug.h 
b/drivers/scsi/mpt3sas/mpt3sas_debug.h
new file mode 100644
index 000..ce70b87
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_debug.h
@@ -0,0 +1,219 @@
+/*
+ * Logging Support for MPT (Message Passing Technology) based controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#ifndef MPT3SAS_DEBUG_H_INCLUDED
+#define MPT3SAS_DEBUG_H_INCLUDED
+
+#define MPT_DEBUG  0x0001
+#define MPT_DEBUG_MSG_FRAME0x0002
+#define MPT_DEBUG_SG   0x0004
+#define MPT_DEBUG_EVENTS   0x0008
+#define MPT_DEBUG_EVENT_WORK_TASK  0x0010
+#define MPT_DEBUG_INIT 0x0020
+#define MPT_DEBUG_EXIT 0x0040
+#define MPT_DEBUG_FAIL 0x0080
+#define MPT_DEBUG_TM   0x0100
+#define MPT_DEBUG_REPLY0x0200
+#define MPT_DEBUG_HANDSHAKE0x0400
+#define MPT_DEBUG_CONFIG   0x0800
+#define MPT_DEBUG_DL   0x1000
+#define MPT_DEBUG_RESET0x2000
+#define MPT_DEBUG_SCSI 0x4000
+#define MPT_DEBUG_IOCTL0x8000
+#define MPT_DEBUG_SAS  0x0002
+#define MPT_DEBUG_TRANSPORT0x0004
+#define MPT_DEBUG_TASK_SET_FULL0x0008
+
+#define MPT_DEBUG_TRIGGER_DIAG 0x0020
+
+
+/*
+ * CONFIG_SCSI_MPT3SAS_LOGGING - enabled in Kconfig
+ */
+
+#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
+#define MPT_CHECK_LOGGING(IOC, CMD, BITS)  \
+{  \
+   if (IOC->logging_level & BITS)  \
+   CMD;\
+}
+#else
+#define MPT_CHECK_LOGGING(IOC, CMD, BITS)
+#endif /* CONFIG_SCSI_MPT3SAS_LOGGING */
+
+
+/*
+ * debug macros
+ */
+
+#define dprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
+
+#define dsgprintk(IOC, CMD)\
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
+
+#define devtprintk(IOC, CMD)   \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
+
+#define dewtprintk(IOC, CMD)   \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENT_WORK_TASK)
+
+#define dinitprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
+
+#define dexitprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
+
+#define dfailprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
+
+#define dtmprintk(IOC, CMD)\
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
+
+#define dreplypri

[RESEND][PATCH 12/20][SCSI] mpt3sas: Ioctl Module Support for MPT based controllers

2012-09-29 Thread sreekanth.reddy
This patch provides headers for ioctl Module Support for MPT (Message Passing 
Technology)
based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.h 
b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
new file mode 100644
index 000..bd89f4f
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
@@ -0,0 +1,418 @@
+/*
+ * Management Module Support for MPT (Message Passing Technology) based
+ * controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.h
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#ifndef MPT3SAS_CTL_H_INCLUDED
+#define MPT3SAS_CTL_H_INCLUDED
+
+#ifdef __KERNEL__
+#include 
+#endif
+
+
+#ifndef MPT3SAS_MINOR
+#define MPT3SAS_MINOR  (MPT_MINOR + 2)
+#endif
+#define MPT3SAS_DEV_NAME   "mpt3ctl"
+#define MPT3_MAGIC_NUMBER  'L'
+#define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
+
+/**
+ * IOCTL opcodes
+ */
+#define MPT3IOCINFO_IOWR(MPT3_MAGIC_NUMBER, 17, \
+   struct mpt3_ioctl_iocinfo)
+#define MPT3COMMAND_IOWR(MPT3_MAGIC_NUMBER, 20, \
+   struct mpt3_ioctl_command)
+#ifdef CONFIG_COMPAT
+#define MPT3COMMAND32  _IOWR(MPT3_MAGIC_NUMBER, 20, \
+   struct mpt3_ioctl_command32)
+#endif
+#define MPT3EVENTQUERY _IOWR(MPT3_MAGIC_NUMBER, 21, \
+   struct mpt3_ioctl_eventquery)
+#define MPT3EVENTENABLE_IOWR(MPT3_MAGIC_NUMBER, 22, \
+   struct mpt3_ioctl_eventenable)
+#define MPT3EVENTREPORT_IOWR(MPT3_MAGIC_NUMBER, 23, \
+   struct mpt3_ioctl_eventreport)
+#define MPT3HARDRESET  _IOWR(MPT3_MAGIC_NUMBER, 24, \
+   struct mpt3_ioctl_diag_reset)
+#define MPT3BTDHMAPPING_IOWR(MPT3_MAGIC_NUMBER, 31, \
+   struct mpt3_ioctl_btdh_mapping)
+
+/* diag buffer support */
+#define MPT3DIAGREGISTER _IOWR(MPT3_MAGIC_NUMBER, 26, \
+   struct mpt3_diag_register)
+#define MPT3DIAGRELEASE_IOWR(MPT3_MAGIC_NUMBER, 27, \
+   struct mpt3_diag_release)
+#define MPT3DIAGUNREGISTER _IOWR(MPT3_MAGIC_NUMBER, 28, \
+   struct mpt3_diag_unregister)
+#define MPT3DIAGQUERY  _IOWR(MPT3_MAGIC_NUMBER, 29, \
+   struct mpt3_diag_query)
+#define MPT3DIAGREADBUFFER _IOWR(MPT3_MAGIC_NUMBER, 30, \
+   struct mpt3_diag_read_buffer)
+
+/**
+ * struct mpt3_ioctl_header - main header structure
+ * @ioc_number -  IOC unit number
+ * @port_number - IOC port number
+ * @max_data_size - maximum number bytes to transfer on read
+ */
+struct mpt3_ioctl_header {
+   uint32_t ioc_number;
+   uint32_t port_number;
+   uint32_t max_data_size;
+};
+
+/**
+ * struct mpt3_ioctl_diag_reset - diagnostic reset
+ * @hdr - generic header
+ */
+struct mpt3_ioctl_diag_reset {
+   struct mpt3_ioctl_header hdr;
+};
+
+
+/**
+ * struct mpt3_ioctl_pci_info - pci device info
+ * @device - pci device id
+ * @function - pci function id
+ * @bus - pci bus id
+ * @segment_id - pci segment id
+ */
+struct mpt3_ioctl_pci_info {
+   union {
+   struct {
+   uint32

[RESEND][PATCH 10/20][SCSI] mpt3sas: Common API for accessing firmware configuration pages

2012-09-29 Thread sreekanth.reddy
This patch provides common API for accessing firmware configuration pages

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_config.c 
b/drivers/scsi/mpt3sas/mpt3sas_config.c
new file mode 100644
index 000..ce7e59b
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_config.c
@@ -0,0 +1,1650 @@
+/*
+ * This module provides common API for accessing firmware configuration pages
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.c
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mpt3sas_base.h"
+
+/* local definitions */
+
+/* Timeout for config page request (in seconds) */
+#define MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT 15
+
+/* Common sgl flags for READING a config page. */
+#define MPT3_CONFIG_COMMON_SGLFLAGS ((MPI2_SGE_FLAGS_SIMPLE_ELEMENT | \
+   MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER \
+   | MPI2_SGE_FLAGS_END_OF_LIST) << MPI2_SGE_FLAGS_SHIFT)
+
+/* Common sgl flags for WRITING a config page. */
+#define MPT3_CONFIG_COMMON_WRITE_SGLFLAGS ((MPI2_SGE_FLAGS_SIMPLE_ELEMENT | \
+   MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER \
+   | MPI2_SGE_FLAGS_END_OF_LIST | MPI2_SGE_FLAGS_HOST_TO_IOC) \
+   << MPI2_SGE_FLAGS_SHIFT)
+
+/**
+ * struct config_request - obtain dma memory via routine
+ * @sz: size
+ * @page: virt pointer
+ * @page_dma: phys pointer
+ *
+ */
+struct config_request {
+   u16 sz;
+   void*page;
+   dma_addr_t  page_dma;
+};
+
+#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
+/**
+ * _config_display_some_debug - debug routine
+ * @ioc: per adapter object
+ * @smid: system request message index
+ * @calling_function_name: string pass from calling function
+ * @mpi_reply: reply message frame
+ * Context: none.
+ *
+ * Function for displaying debug info helpful when debugging issues
+ * in this module.
+ */
+static void
+_config_display_some_debug(struct MPT3SAS_ADAPTER *ioc, u16 smid,
+   char *calling_function_name, MPI2DefaultReply_t *mpi_reply)
+{
+   Mpi2ConfigRequest_t *mpi_request;
+   char *desc = NULL;
+
+   if (!(ioc->logging_level & MPT_DEBUG_CONFIG))
+   return;
+
+   mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
+   switch (mpi_request->Header.PageType & MPI2_CONFIG_PAGETYPE_MASK) {
+   case MPI2_CONFIG_PAGETYPE_IO_UNIT:
+   desc = "io_unit";
+   break;
+   case MPI2_CONFIG_PAGETYPE_IOC:
+   desc = "ioc";
+   break;
+   case MPI2_CONFIG_PAGETYPE_BIOS:
+   desc = "bios";
+   break;
+   case MPI2_CONFIG_PAGETYPE_RAID_VOLUME:
+   desc = "raid_volume";
+   break;
+   case MPI2_CONFIG_PAGETYPE_MANUFACTURING:
+   desc = "manufaucturing";
+   break;
+   cas

[RESEND][PATCH 9/20][SCSI] mpt3sas: Common API layer interface headers for access to MPT firmware.

2012-09-29 Thread sreekanth.reddy
This patch contains the Fusion MPT base driver providing common API layer 
interface
headers for access to MPT (Message Passing Technology) firmware.

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
new file mode 100644
index 000..4e08a3c
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -0,0 +1,1139 @@
+/*
+ * This is the Fusion MPT base driver providing common API layer interface
+ * for access to MPT (Message Passing Technology) firmware.
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#ifndef MPT3SAS_BASE_H_INCLUDED
+#define MPT3SAS_BASE_H_INCLUDED
+
+#include "mpi/mpi2_type.h"
+#include "mpi/mpi2.h"
+#include "mpi/mpi2_ioc.h"
+#include "mpi/mpi2_cnfg.h"
+#include "mpi/mpi2_init.h"
+#include "mpi/mpi2_raid.h"
+#include "mpi/mpi2_tool.h"
+#include "mpi/mpi2_sas.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mpt3sas_debug.h"
+#include "mpt3sas_trigger_diag.h"
+
+/* driver versioning info */
+#define MPT3SAS_DRIVER_NAME"mpt3sas"
+#define MPT3SAS_AUTHOR "LSI Corporation "
+#define MPT3SAS_DESCRIPTION"LSI MPT Fusion SAS 3.0 Device Driver"
+#define MPT3SAS_DRIVER_VERSION "01.100.00.00"
+#define MPT3SAS_MAJOR_VERSION  1
+#define MPT3SAS_MINOR_VERSION  100
+#define MPT3SAS_BUILD_VERSION  0
+#define MPT3SAS_RELEASE_VERSION00
+
+/*
+ * Set MPT3SAS_SG_DEPTH value based on user input.
+ */
+#define MPT3SAS_MAX_PHYS_SEGMENTS  SCSI_MAX_SG_SEGMENTS
+#define MPT3SAS_MIN_PHYS_SEGMENTS  16
+#ifdef CONFIG_SCSI_MPT3SAS_MAX_SGE
+#define MPT3SAS_SG_DEPTH   CONFIG_SCSI_MPT3SAS_MAX_SGE
+#else
+#define MPT3SAS_SG_DEPTH   MPT3SAS_MAX_PHYS_SEGMENTS
+#endif
+
+
+/*
+ * Generic Defines
+ */
+#define MPT3SAS_SATA_QUEUE_DEPTH   32
+#define MPT3SAS_SAS_QUEUE_DEPTH254
+#define MPT3SAS_RAID_QUEUE_DEPTH   128
+
+#define MPT_NAME_LENGTH32  /* generic length of 
strings */
+#define MPT_STRING_LENGTH  64
+
+#define MPT_MAX_CALLBACKS  32
+
+
+#define CAN_SLEEP  1
+#define  NO_SLEEP  0
+
+#define INTERNAL_CMDS_COUNT10  /* reserved cmds */
+
+#define MPI3_HIM_MASK  0x /* mask every bit*/
+
+#define MPT3SAS_INVALID_DEVICE_HANDLE  0x
+
+/*
+ * reset phases
+ */
+#define MPT3_IOC_PRE_RESET 1 /* prior to host reset */
+#define MPT3_IOC_AFTER_RESET   2 /* just after host reset */
+#define MPT3_IOC_DONE_RESET3 /* links re-initialized */
+
+/*
+ * logging format
+ */
+#define MPT3SAS_FMT"%s: "
+
+/*
+ * per target private data
+ */
+#define MPT_TARGET_FLAGS_RAID_COMPONENT0x01
+#define MPT_TARGET_FLAGS_VOLUME0x02
+#def

[RESEND][PATCH 6/20][SCSI] mpt3sas: Part 5 of MPI API headers

2012-09-29 Thread sreekanth.reddy
This patch contains MPI API headers
This patch is part 5 of MPI API headers.
Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_raid.h 
b/drivers/scsi/mpt3sas/mpi/mpi2_raid.h
new file mode 100644
index 000..d1d9866
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_raid.h
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2000-2012 LSI Corporation.
+ *
+ *
+ *  Name:  mpi2_raid.h
+ * Title:  MPI Integrated RAID messages and structures
+ * Creation Date:  April 26, 2007
+ *
+ *   mpi2_raid.h Version:  02.00.08
+ *
+ * Version History
+ * ---
+ *
+ * Date  Version   Description
+ *     --
+ * 04-30-07  02.00.00  Corresponds to Fusion-MPT MPI Specification Rev A.
+ * 08-31-07  02.00.01  Modifications to RAID Action request and reply,
+ * including the Actions and ActionData.
+ * 02-29-08  02.00.02  Added MPI2_RAID_ACTION_ADATA_DISABL_FULL_REBUILD.
+ * 05-21-08  02.00.03  Added MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS so that
+ * the PhysDisk array in MPI2_RAID_VOLUME_CREATION_STRUCT
+ * can be sized by the build environment.
+ * 07-30-09  02.00.04  Added proper define for the Use Default Settings bit of
+ * VolumeCreationFlags and marked the old one as obsolete.
+ * 05-12-10  02.00.05  Added MPI2_RAID_VOL_FLAGS_OP_MDC define.
+ * 08-24-10  02.00.06  Added MPI2_RAID_ACTION_COMPATIBILITY_CHECK along with
+ * related structures and defines.
+ * Added product-specific range to RAID Action values.
+ * 11-18-11  02.00.07  Incorporating additions for MPI v2.5.
+ * 02-06-12  02.00.08  Added MPI2_RAID_ACTION_PHYSDISK_HIDDEN.
+ * --
+ */
+
+#ifndef MPI2_RAID_H
+#define MPI2_RAID_H
+
+/*
+*
+*  Integrated RAID Messages
+*
+*/
+
+/
+* RAID Action messages
+/
+
+/*ActionDataWord defines for use with MPI2_RAID_ACTION_DELETE_VOLUME action */
+#define MPI2_RAID_ACTION_ADATA_KEEP_LBA0(0x)
+#define MPI2_RAID_ACTION_ADATA_ZERO_LBA0(0x0001)
+
+/*use MPI2_RAIDVOL0_SETTING_ defines from mpi2_cnfg.h for
+ *MPI2_RAID_ACTION_CHANGE_VOL_WRITE_CACHE action */
+
+/*ActionDataWord defines for use with
+ *MPI2_RAID_ACTION_DISABLE_ALL_VOLUMES action */
+#define MPI2_RAID_ACTION_ADATA_DISABL_FULL_REBUILD  (0x0001)
+
+/*ActionDataWord for MPI2_RAID_ACTION_SET_RAID_FUNCTION_RATE Action */
+typedef struct _MPI2_RAID_ACTION_RATE_DATA {
+   U8 RateToChange;/*0x00 */
+   U8 RateOrMode;  /*0x01 */
+   U16 DataScrubDuration;  /*0x02 */
+} MPI2_RAID_ACTION_RATE_DATA, *PTR_MPI2_RAID_ACTION_RATE_DATA,
+   Mpi2RaidActionRateData_t, *pMpi2RaidActionRateData_t;
+
+#define MPI2_RAID_ACTION_SET_RATE_RESYNC(0x00)
+#define MPI2_RAID_ACTION_SET_RATE_DATA_SCRUB(0x01)
+#define MPI2_RAID_ACTION_SET_RATE_POWERSAVE_MODE(0x02)
+
+/*ActionDataWord for MPI2_RAID_ACTION_START_RAID_FUNCTION Action */
+typedef struct _MPI2_RAID_ACTION_START_RAID_FUNCTION {
+   U8 RAIDFunction;/*0x00 */
+   U8 Flags;   /*0x01 */
+   U16 Reserved1;  /*0x02 */
+} MPI2_RAID_ACTION_START_RAID_FUNCTION,
+   *PTR_MPI2_RAID_ACTION_START_RAID_FUNCTION,
+   Mpi2RaidActionStartRaidFunction_t,
+   *pMpi2RaidActionStartRaidFunction_t;
+
+/*defines for the RAIDFunction field */
+#define MPI2_RAID_ACTION_START_BACKGROUND_INIT  (0x00)
+#define MPI2_RAID_ACTION_START_ONLINE_CAP_EXPANSION (0x01)
+#define MPI2_RAID_ACTION_START_CONSISTENCY_CHECK(0x02)
+
+/*defines for the Flags field */
+#define MPI2_RAID_ACTION_START_NEW  (0x00)
+#define MPI2_RAID_ACTION_START_RESUME   (0x01)
+
+/*ActionDataWord for MPI2_RAID_ACTION_STOP_RAID_FUNCTION Action */
+typedef struct _MPI2_RAID_ACTION_STOP_RAID_FUNCTION {
+   U8 RAIDFunction;/*0x00 */
+   U8 Flags;   /*0x01 */
+   U16 Reserved1;  /*0x02 */
+} MPI2_RAID_ACTION_STOP_RAID_FUNCTION,
+   *PTR_MPI2_RAID_ACTION_STOP_RAID_FUNCTION,
+   Mpi2RaidActionStopRaidFunction_t,
+   *pMpi2RaidActionStopRaidFunction_t;
+
+/*defines for the RAIDFunction field */
+#define MPI2_RAID_ACTION_STOP_BACKGROUND_INIT   (0x00)
+#define MPI2_RAID_ACTION_STOP_ONLINE_CAP_EXPANSION  (0x01)
+#define MPI2_RAID_ACTION_STOP_CONSISTENCY_CHECK (0x02)
+
+/*defines for the Flags field */
+#define MPI2_RAID_ACTION_STOP_ABORT (0x00)
+#define MPI2_RAID_ACTION_STOP_PAUSE (0x01)
+
+/*Acti

[RESEND][PATCH 2/20][SCSI] mpt3sas: Paer 1 of MPI API headers

2012-09-29 Thread sreekanth.reddy
This patch contains MPI API headers
This patch is part 1 of MPI API headers.
Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---


diff --git a/drivers/scsi/mpt3sas/mpi/mpi2.h b/drivers/scsi/mpt3sas/mpi/mpi2.h
new file mode 100644
index 000..03317ff
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpi/mpi2.h
@@ -0,0 +1,1164 @@
+/*
+ * Copyright (c) 2000-2012 LSI Corporation.
+ *
+ *
+ *  Name:  mpi2.h
+ * Title:  MPI Message independent structures and definitions
+ * including System Interface Register Set and
+ * scatter/gather formats.
+ * Creation Date:  June 21, 2006
+ *
+ * mpi2.h Version:  02.00.26
+ *
+ * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
+ *   prefix are for use only on MPI v2.5 products, and must not be used
+ *   with MPI v2.0 products. Unless otherwise noted, names beginning with
+ *   MPI2 or Mpi2 are for use with both MPI v2.0 and MPI v2.5 products.
+ *
+ * Version History
+ * ---
+ *
+ * Date  Version   Description
+ *     --
+ * 04-30-07  02.00.00  Corresponds to Fusion-MPT MPI Specification Rev A.
+ * 06-04-07  02.00.01  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 06-26-07  02.00.02  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 08-31-07  02.00.03  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Moved ReplyPostHostIndex register to offset 0x6C of the
+ * MPI2_SYSTEM_INTERFACE_REGS and modified the define for
+ * MPI2_REPLY_POST_HOST_INDEX_OFFSET.
+ * Added union of request descriptors.
+ * Added union of reply descriptors.
+ * 10-31-07  02.00.04  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added define for MPI2_VERSION_02_00.
+ * Fixed the size of the FunctionDependent5 field in the
+ * MPI2_DEFAULT_REPLY structure.
+ * 12-18-07  02.00.05  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Removed the MPI-defined Fault Codes and extended the
+ * product specific codes up to 0xEFFF.
+ * Added a sixth key value for the WriteSequence register
+ * and changed the flush value to 0x0.
+ * Added message function codes for Diagnostic Buffer Post
+ * and Diagnsotic Release.
+ * New IOCStatus define: MPI2_IOCSTATUS_DIAGNOSTIC_RELEASED
+ * Moved MPI2_VERSION_UNION from mpi2_ioc.h.
+ * 02-29-08  02.00.06  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 03-03-08  02.00.07  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 05-21-08  02.00.08  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added #defines for marking a reply descriptor as unused.
+ * 06-27-08  02.00.09  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 10-02-08  02.00.10  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Moved LUN field defines from mpi2_init.h.
+ * 01-19-09  02.00.11  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 05-06-09  02.00.12  Bumped MPI2_HEADER_VERSION_UNIT.
+ * In all request and reply descriptors, replaced VF_ID
+ * field with MSIxIndex field.
+ * Removed DevHandle field from
+ * MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR and made those
+ * bytes reserved.
+ * Added RAID Accelerator functionality.
+ * 07-30-09  02.00.13  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 10-28-09  02.00.14  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added MSI-x index mask and shift for Reply Post Host
+ * Index register.
+ * Added function code for Host Based Discovery Action.
+ * 02-10-10  02.00.15  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added define for MPI2_FUNCTION_PWR_MGMT_CONTROL.
+ * Added defines for product-specific range of message
+ * function codes, 0xF0 to 0xFF.
+ * 05-12-10  02.00.16  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added alternative defines for the SGE Direction bit.
+ * 08-11-10  02.00.17  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 11-10-10  02.00.18  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added MPI2_IEEE_SGE_FLAGS_SYSTEMPLBCPI_ADDR define.
+ * 02-23-11  02.00.19  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added MPI2_FUNCTION_SEND_HOST_MESSAGE.
+ * 03-09-11  02.00.20  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 05-25-11  02.00.21  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 08-24-11  02.00.22  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 11-18-11  02.00.23  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Incorporating additions for MPI v2.5.
+ * 02-06-12  02.00.24  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 03-29-12  02.00.25  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added Hard Reset delay timings.
+ * 07-10-12  02.00.26  Bump

[RESEND][PATCH 1/20][SCSI] mpt3sas: Makefile, Kconfig and scsi_transport_sas file changes to support new driver mpt3sas

2012-09-29 Thread sreekanth.reddy
This patch contains the Makefile, Kconfig and 
scsi_transport_sas file changes to support new driver mpt3sas

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index e955978..49244f8 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -620,6 +620,7 @@ config SCSI_ARCMSR
 
 source "drivers/scsi/megaraid/Kconfig.megaraid"
 source "drivers/scsi/mpt2sas/Kconfig"
+source "drivers/scsi/mpt3sas/Kconfig"
 source "drivers/scsi/ufs/Kconfig"
 
 config SCSI_HPTIOP
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 1a3368b..88e52bb 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -106,6 +106,7 @@ obj-$(CONFIG_MEGARAID_LEGACY)   += megaraid.o
 obj-$(CONFIG_MEGARAID_NEWGEN)  += megaraid/
 obj-$(CONFIG_MEGARAID_SAS) += megaraid/
 obj-$(CONFIG_SCSI_MPT2SAS) += mpt2sas/
+obj-$(CONFIG_SCSI_MPT3SAS) += mpt3sas/
 obj-$(CONFIG_SCSI_UFSHCD)  += ufs/
 obj-$(CONFIG_SCSI_ACARD)   += atp870u.o
 obj-$(CONFIG_SCSI_SUNESP)  += esp_scsi.o   sun_esp.o
diff --git a/drivers/scsi/mpt3sas/Kconfig b/drivers/scsi/mpt3sas/Kconfig
new file mode 100644
index 000..81471bf
--- /dev/null
+++ b/drivers/scsi/mpt3sas/Kconfig
@@ -0,0 +1,67 @@
+#
+# Kernel configuration file for the MPT3SAS
+#
+# This code is based on drivers/scsi/mpt3sas/Kconfig
+# Copyright (C) 2012  LSI Corporation
+#  (mailto:dl-mptfusionli...@lsi.com)
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# NO WARRANTY
+# THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+# LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+# solely responsible for determining the appropriateness of using and
+# distributing the Program and assumes all risks associated with its
+# exercise of rights under this Agreement, including but not limited to
+# the risks and costs of program errors, damage to or loss of data,
+# programs or equipment, and unavailability or interruption of operations.
+
+# DISCLAIMER OF LIABILITY
+# NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+# HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+# USA.
+
+config SCSI_MPT3SAS
+   tristate "LSI MPT Fusion SAS 3.0 Device Driver"
+   depends on PCI && SCSI
+   select SCSI_SAS_ATTRS
+   select RAID_ATTRS
+   ---help---
+   This driver supports PCI-Express SAS 12Gb/s Host Adapters.
+
+config SCSI_MPT3SAS_MAX_SGE
+   int "LSI MPT Fusion Max number of SG Entries (16 - 256)"
+   depends on PCI && SCSI && SCSI_MPT3SAS
+   default "128"
+   range 16 256
+   ---help---
+   This option allows you to specify the maximum number of scatter-
+   gather entries per I/O. The driver default is 128, which matches
+   MAX_PHYS_SEGMENTS in most kernels.  However in SuSE kernels this
+   can be 256. However, it may decreased down to 16.  Decreasing this
+   parameter will reduce memory requirements on a per controller instance.
+
+config SCSI_MPT3SAS_LOGGING
+   bool "LSI MPT Fusion logging facility"
+   depends on PCI && SCSI && SCSI_MPT3SAS
+   ---help---
+   This turns on a logging facility.
diff --git a/drivers/scsi/mpt3sas/Makefile b/drivers/scsi/mpt3sas/Makefile
new file mode 100644
index 000..4c1d2e7
--- /dev/null
+++ b/drivers/scsi/mpt3sas/Makefile
@@ -0,0 +1,8 @@
+# mpt3sas makefile
+obj-m += mpt3sas.o
+mpt3sas-y +=  mpt3sas_base.o \
+   mpt3sas_config.o \
+   mpt3sas_scsih.o  \
+   mpt3sas_transport.o \
+   mpt3sas_ctl.o   \
+   mpt3sas_trigger_diag.o
diff --git a/drivers/scsi/scsi_transport_sas.c 
b/drivers/scsi/scsi_transport_sas.c
index f7565fc..1b68142 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ 

[RESEND][PATCH 0/20][SCSI] mpt3sas: Driver submission v01.100.00.00

2012-09-29 Thread sreekanth.reddy
This is new scsi lld device driver from LSI supporting the SAS 3.0
standard.

Here is list of new 12gb host controllers:

  LSI SAS3004
  LSI SAS3008
  LSI SAS3108

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---
Here is the brief description of patches:
[PATCH 01/20] [SCSI] mpt3sas : Makefile, Kconfig and scsi_transport_sas file 
changes to support new driver mpt3sas
[PATCH 02/20] [SCSI] mpt3sas : MPI API headers. This patch is part 1 of MPI API 
headers.
[PATCH 03/20] [SCSI] mpt3sas : MPI API headers. This patch is part 2 of MPI API 
headers.
[PATCH 04/20] [SCSI] mpt3sas : MPI API headers. This patch is part 3 of MPI API 
headers.
[PATCH 05/20] [SCSI] mpt3sas : MPI API headers. This patch is part 4 of MPI API 
headers.
[PATCH 06/20] [SCSI] mpt3sas : MPI API headers. This patch is part 5 of MPI API 
headers.
[PATCH 07/20] [SCSI] mpt3sas : Fusion MPT base driver providing common API 
layer interface
for access to MPT (Message 
Passing Technology) firmware.
This patch is part 1 of 
mpt3sas_base.c
[PATCH 08/20] [SCSI] mpt3sas : This patch is part 2 of mpt3sas_base.c
[PATCH 09/20] [SCSI] mpt3sas : Fusion MPT base driver providing common API 
layer interface
headers for access to MPT 
(Message Passing Technology) firmware.
[PATCH 10/20] [SCSI] mpt3sas : Common API for accessing firmware configuration 
pages
[PATCH 11/20] [SCSI] mpt3sas : Ioctl Support for MPT (Message Passing 
Technology)
based controller
[PATCH 12/20] [SCSI] mpt3sas : Ioctl Module Support headers for MPT (Message 
Passing Technology)
based controllers
[PATCH 13/20] [SCSI] mpt3sas : Logging Support for MPT (Message Passing 
Technology)
based controllers
[PATCH 14/20] [SCSI] mpt3sas : Code related to Scsi Host Layer for
MPT (Message Passing 
Technology) based controllers
This patch is part 1 of 
mpt3sas_scsih.c
[PATCH 15/20] [SCSI] mpt3sas : This patch is part 2 of mpt3sas_scsih.c
[PATCH 16/20] [SCSI] mpt3sas : This patch is part 3 of mpt3sas_scsih.c
[PATCH 17/20] [SCSI] mpt3sas : Code related to SAS Transport Layer for
MPT (Message Passing Technology) based 
controllers
[PATCH 18/20] [SCSI] mpt3sas : Common API to set Diagnostic trigger for MPT
(Message Passing Technology) based 
controllers
[PATCH 19/20] [SCSI] mpt3sas : Common API headers to set Diagnostic trigger for 
MPT
(Message Passing Technology) based 
controllers
[PATCH 20/20] [SCSI] mpt3sas : Adding support for MPT3SAS_MINOR(222)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][SCSI] mpt3sas: Adding support for MPT3SAS_MINOR(222)

2012-09-29 Thread sreekanth.reddy
Adding support for MPT3SAS_MINOR(222)

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 0549d211..9c9ba04 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -34,6 +34,7 @@
 #define MWAVE_MINOR219 /* ACP/Mwave Modem */
 #define MPT_MINOR  220
 #define MPT2SAS_MINOR  221
+#define MPT3SAS_MINOR  222
 #define UINPUT_MINOR   223
 #define HPET_MINOR 228
 #define FUSE_MINOR 229
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][SCSI] mpt3sas: Common API headers to set Diagnostic trigger for MPT based controllers

2012-09-29 Thread sreekanth.reddy
This patch provides common API headers to set Diagnostic trigger for MPT
(Message Passing Technology) based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h 
b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h
new file mode 100644
index 000..a10c309
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.h
@@ -0,0 +1,193 @@
+/*
+ * This is the Fusion MPT base driver providing common API layer interface
+ * to set Diagnostic triggers for MPT (Message Passing Technology) based
+ * controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+  /* Diagnostic Trigger Configuration Data Structures */
+
+#ifndef MPT3SAS_TRIGGER_DIAG_H_INCLUDED
+#define MPT3SAS_TRIGGER_DIAG_H_INCLUDED
+
+/* limitation on number of entries */
+#define NUM_VALID_ENTRIES   (20)
+
+/* trigger types */
+#define MPT3SAS_TRIGGER_MASTER  (1)
+#define MPT3SAS_TRIGGER_EVENT   (2)
+#define MPT3SAS_TRIGGER_SCSI(3)
+#define MPT3SAS_TRIGGER_MPI (4)
+
+/* trigger names */
+#define MASTER_TRIGGER_FILE_NAME"diag_trigger_master"
+#define EVENT_TRIGGERS_FILE_NAME"diag_trigger_event"
+#define SCSI_TRIGGERS_FILE_NAME "diag_trigger_scsi"
+#define MPI_TRIGGER_FILE_NAME   "diag_trigger_mpi"
+
+/* master trigger bitmask */
+#define MASTER_TRIGGER_FW_FAULT (0x0001)
+#define MASTER_TRIGGER_ADAPTER_RESET(0x0002)
+#define MASTER_TRIGGER_TASK_MANAGMENT   (0x0004)
+#define MASTER_TRIGGER_DEVICE_REMOVAL   (0x0008)
+
+/* fake firmware event for tigger */
+#define MPI3_EVENT_DIAGNOSTIC_TRIGGER_FIRED(0x6E)
+
+/**
+ * MasterTrigger is a single U32 passed to/from sysfs.
+ *
+ * Bit Flags (enables) include:
+ * 1. FW Faults
+ * 2. Adapter Reset issued by driver
+ * 3. TMs
+ * 4. Device Remove Event sent by FW
+ */
+
+struct SL_WH_MASTER_TRIGGER_T {
+   uint32_t MasterData;
+};
+
+/**
+ * struct SL_WH_EVENT_TRIGGER_T -  Definition of an event trigger element
+ * @EventValue: Event Code to trigger on
+ * @LogEntryQualifier: Type of FW event that logged (Log Entry Added Event 
only)
+ *
+ * Defines an event that should induce a DIAG_TRIGGER driver event if observed.
+ */
+struct SL_WH_EVENT_TRIGGER_T {
+   uint16_t EventValue;
+   uint16_t LogEntryQualifier;
+};
+
+/**
+ * struct SL_WH_EVENT_TRIGGERS_T -  Structure passed to/from sysfs containing a
+ *list of Event Triggers to be monitored for.
+ * @ValidEntries: Number of _SL_WH_EVENT_TRIGGER_T structures contained in this
+ *structure.
+ * @EventTriggerEntry: List of Event trigger elements.
+ *
+ * This binary structure is transferred via sysfs to get/set Event Triggers
+ * in the Linux Driver.
+ */
+
+struct SL_WH_EVENT_TRIGGERS_T {
+   uint32_t ValidEntries;
+   struct SL_WH_EVENT_TRIGGER_T EventTriggerEntry[NUM_VALID_ENTRIES];
+};
+
+/**
+ * struct SL_WH_SC

[PATCH][SCSI] mpt3sas: Common API to set Diagnostic trigger for MPT based controllers

2012-09-29 Thread sreekanth.reddy
This patch provides common API to set Diagnostic trigger for MPT
(Message Passing Technology) based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c 
b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
new file mode 100644
index 000..da6c5f2
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
@@ -0,0 +1,434 @@
+/*
+ * This module provides common API to set Diagnostic trigger for MPT
+ * (Message Passing Technology) based controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "mpt3sas_base.h"
+
+/**
+ * _mpt3sas_raise_sigio - notifiy app
+ * @ioc: per adapter object
+ * @event_data:
+ */
+static void
+_mpt3sas_raise_sigio(struct MPT3SAS_ADAPTER *ioc,
+   struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data)
+{
+   Mpi2EventNotificationReply_t *mpi_reply;
+   u16 sz, event_data_sz;
+   unsigned long flags;
+
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n",
+   ioc->name, __func__));
+
+   sz = offsetof(Mpi2EventNotificationReply_t, EventData) +
+   sizeof(struct SL_WH_TRIGGERS_EVENT_DATA_T) + 4;
+   mpi_reply = kzalloc(sz, GFP_KERNEL);
+   if (!mpi_reply)
+   goto out;
+   mpi_reply->Event = cpu_to_le16(MPI3_EVENT_DIAGNOSTIC_TRIGGER_FIRED);
+   event_data_sz = (sizeof(struct SL_WH_TRIGGERS_EVENT_DATA_T) + 4) / 4;
+   mpi_reply->EventDataLength = cpu_to_le16(event_data_sz);
+   memcpy(&mpi_reply->EventData, event_data,
+   sizeof(struct SL_WH_TRIGGERS_EVENT_DATA_T));
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT
+   "%s: add to driver event log\n",
+   ioc->name, __func__));
+   mpt3sas_ctl_add_to_event_log(ioc, mpi_reply);
+   kfree(mpi_reply);
+ out:
+
+   /* clearing the diag_trigger_active flag */
+   spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT
+   "%s: clearing diag_trigger_active flag\n",
+   ioc->name, __func__));
+   ioc->diag_trigger_active = 0;
+   spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags);
+
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT "%s: exit\n", ioc->name,
+   __func__));
+}
+
+/**
+ * mpt3sas_process_trigger_data - process the event data for the trigger
+ * @ioc: per adapter object
+ * @event_data:
+ */
+void
+mpt3sas_process_trigger_data(struct MPT3SAS_ADAPTER *ioc,
+   struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data)
+{
+   u8 issue_reset = 0;
+
+   dTriggerDiagPrintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n",
+   ioc->name, __func__));
+
+   /* release the diag buffer trace */
+   if ((ioc->diag_buffer_status[MPI2_DIAG_BUF

[PATCH][SCSI] mpt3sas: Logging Support for MPT based controllers

2012-09-29 Thread sreekanth.reddy
This patch provides Logging Support for MPT (Message Passing Technology)
based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_debug.h 
b/drivers/scsi/mpt3sas/mpt3sas_debug.h
new file mode 100644
index 000..ce70b87
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_debug.h
@@ -0,0 +1,219 @@
+/*
+ * Logging Support for MPT (Message Passing Technology) based controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#ifndef MPT3SAS_DEBUG_H_INCLUDED
+#define MPT3SAS_DEBUG_H_INCLUDED
+
+#define MPT_DEBUG  0x0001
+#define MPT_DEBUG_MSG_FRAME0x0002
+#define MPT_DEBUG_SG   0x0004
+#define MPT_DEBUG_EVENTS   0x0008
+#define MPT_DEBUG_EVENT_WORK_TASK  0x0010
+#define MPT_DEBUG_INIT 0x0020
+#define MPT_DEBUG_EXIT 0x0040
+#define MPT_DEBUG_FAIL 0x0080
+#define MPT_DEBUG_TM   0x0100
+#define MPT_DEBUG_REPLY0x0200
+#define MPT_DEBUG_HANDSHAKE0x0400
+#define MPT_DEBUG_CONFIG   0x0800
+#define MPT_DEBUG_DL   0x1000
+#define MPT_DEBUG_RESET0x2000
+#define MPT_DEBUG_SCSI 0x4000
+#define MPT_DEBUG_IOCTL0x8000
+#define MPT_DEBUG_SAS  0x0002
+#define MPT_DEBUG_TRANSPORT0x0004
+#define MPT_DEBUG_TASK_SET_FULL0x0008
+
+#define MPT_DEBUG_TRIGGER_DIAG 0x0020
+
+
+/*
+ * CONFIG_SCSI_MPT3SAS_LOGGING - enabled in Kconfig
+ */
+
+#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
+#define MPT_CHECK_LOGGING(IOC, CMD, BITS)  \
+{  \
+   if (IOC->logging_level & BITS)  \
+   CMD;\
+}
+#else
+#define MPT_CHECK_LOGGING(IOC, CMD, BITS)
+#endif /* CONFIG_SCSI_MPT3SAS_LOGGING */
+
+
+/*
+ * debug macros
+ */
+
+#define dprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
+
+#define dsgprintk(IOC, CMD)\
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
+
+#define devtprintk(IOC, CMD)   \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
+
+#define dewtprintk(IOC, CMD)   \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENT_WORK_TASK)
+
+#define dinitprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
+
+#define dexitprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
+
+#define dfailprintk(IOC, CMD)  \
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
+
+#define dtmprintk(IOC, CMD)\
+   MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
+
+#define dreplypri

[PATCH][SCSI] mpt3sas: Ioctl Module Support for MPT based controllers

2012-09-29 Thread sreekanth.reddy
This patch provides headers for ioctl Module Support for MPT (Message Passing 
Technology)
based controllers

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.h 
b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
new file mode 100644
index 000..bd89f4f
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
@@ -0,0 +1,418 @@
+/*
+ * Management Module Support for MPT (Message Passing Technology) based
+ * controllers
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.h
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#ifndef MPT3SAS_CTL_H_INCLUDED
+#define MPT3SAS_CTL_H_INCLUDED
+
+#ifdef __KERNEL__
+#include 
+#endif
+
+
+#ifndef MPT3SAS_MINOR
+#define MPT3SAS_MINOR  (MPT_MINOR + 2)
+#endif
+#define MPT3SAS_DEV_NAME   "mpt3ctl"
+#define MPT3_MAGIC_NUMBER  'L'
+#define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
+
+/**
+ * IOCTL opcodes
+ */
+#define MPT3IOCINFO_IOWR(MPT3_MAGIC_NUMBER, 17, \
+   struct mpt3_ioctl_iocinfo)
+#define MPT3COMMAND_IOWR(MPT3_MAGIC_NUMBER, 20, \
+   struct mpt3_ioctl_command)
+#ifdef CONFIG_COMPAT
+#define MPT3COMMAND32  _IOWR(MPT3_MAGIC_NUMBER, 20, \
+   struct mpt3_ioctl_command32)
+#endif
+#define MPT3EVENTQUERY _IOWR(MPT3_MAGIC_NUMBER, 21, \
+   struct mpt3_ioctl_eventquery)
+#define MPT3EVENTENABLE_IOWR(MPT3_MAGIC_NUMBER, 22, \
+   struct mpt3_ioctl_eventenable)
+#define MPT3EVENTREPORT_IOWR(MPT3_MAGIC_NUMBER, 23, \
+   struct mpt3_ioctl_eventreport)
+#define MPT3HARDRESET  _IOWR(MPT3_MAGIC_NUMBER, 24, \
+   struct mpt3_ioctl_diag_reset)
+#define MPT3BTDHMAPPING_IOWR(MPT3_MAGIC_NUMBER, 31, \
+   struct mpt3_ioctl_btdh_mapping)
+
+/* diag buffer support */
+#define MPT3DIAGREGISTER _IOWR(MPT3_MAGIC_NUMBER, 26, \
+   struct mpt3_diag_register)
+#define MPT3DIAGRELEASE_IOWR(MPT3_MAGIC_NUMBER, 27, \
+   struct mpt3_diag_release)
+#define MPT3DIAGUNREGISTER _IOWR(MPT3_MAGIC_NUMBER, 28, \
+   struct mpt3_diag_unregister)
+#define MPT3DIAGQUERY  _IOWR(MPT3_MAGIC_NUMBER, 29, \
+   struct mpt3_diag_query)
+#define MPT3DIAGREADBUFFER _IOWR(MPT3_MAGIC_NUMBER, 30, \
+   struct mpt3_diag_read_buffer)
+
+/**
+ * struct mpt3_ioctl_header - main header structure
+ * @ioc_number -  IOC unit number
+ * @port_number - IOC port number
+ * @max_data_size - maximum number bytes to transfer on read
+ */
+struct mpt3_ioctl_header {
+   uint32_t ioc_number;
+   uint32_t port_number;
+   uint32_t max_data_size;
+};
+
+/**
+ * struct mpt3_ioctl_diag_reset - diagnostic reset
+ * @hdr - generic header
+ */
+struct mpt3_ioctl_diag_reset {
+   struct mpt3_ioctl_header hdr;
+};
+
+
+/**
+ * struct mpt3_ioctl_pci_info - pci device info
+ * @device - pci device id
+ * @function - pci function id
+ * @bus - pci bus id
+ * @segment_id - pci segment id
+ */
+struct mpt3_ioctl_pci_info {
+   union {
+   struct {
+   uint32

[PATCH][SCSI] mpt3sas: Common API for accessing firmware configuration pages

2012-09-29 Thread sreekanth.reddy
This patch provides common API for accessing firmware configuration pages

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_config.c 
b/drivers/scsi/mpt3sas/mpt3sas_config.c
new file mode 100644
index 000..ce7e59b
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_config.c
@@ -0,0 +1,1650 @@
+/*
+ * This module provides common API for accessing firmware configuration pages
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.c
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mpt3sas_base.h"
+
+/* local definitions */
+
+/* Timeout for config page request (in seconds) */
+#define MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT 15
+
+/* Common sgl flags for READING a config page. */
+#define MPT3_CONFIG_COMMON_SGLFLAGS ((MPI2_SGE_FLAGS_SIMPLE_ELEMENT | \
+   MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER \
+   | MPI2_SGE_FLAGS_END_OF_LIST) << MPI2_SGE_FLAGS_SHIFT)
+
+/* Common sgl flags for WRITING a config page. */
+#define MPT3_CONFIG_COMMON_WRITE_SGLFLAGS ((MPI2_SGE_FLAGS_SIMPLE_ELEMENT | \
+   MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER \
+   | MPI2_SGE_FLAGS_END_OF_LIST | MPI2_SGE_FLAGS_HOST_TO_IOC) \
+   << MPI2_SGE_FLAGS_SHIFT)
+
+/**
+ * struct config_request - obtain dma memory via routine
+ * @sz: size
+ * @page: virt pointer
+ * @page_dma: phys pointer
+ *
+ */
+struct config_request {
+   u16 sz;
+   void*page;
+   dma_addr_t  page_dma;
+};
+
+#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
+/**
+ * _config_display_some_debug - debug routine
+ * @ioc: per adapter object
+ * @smid: system request message index
+ * @calling_function_name: string pass from calling function
+ * @mpi_reply: reply message frame
+ * Context: none.
+ *
+ * Function for displaying debug info helpful when debugging issues
+ * in this module.
+ */
+static void
+_config_display_some_debug(struct MPT3SAS_ADAPTER *ioc, u16 smid,
+   char *calling_function_name, MPI2DefaultReply_t *mpi_reply)
+{
+   Mpi2ConfigRequest_t *mpi_request;
+   char *desc = NULL;
+
+   if (!(ioc->logging_level & MPT_DEBUG_CONFIG))
+   return;
+
+   mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
+   switch (mpi_request->Header.PageType & MPI2_CONFIG_PAGETYPE_MASK) {
+   case MPI2_CONFIG_PAGETYPE_IO_UNIT:
+   desc = "io_unit";
+   break;
+   case MPI2_CONFIG_PAGETYPE_IOC:
+   desc = "ioc";
+   break;
+   case MPI2_CONFIG_PAGETYPE_BIOS:
+   desc = "bios";
+   break;
+   case MPI2_CONFIG_PAGETYPE_RAID_VOLUME:
+   desc = "raid_volume";
+   break;
+   case MPI2_CONFIG_PAGETYPE_MANUFACTURING:
+   desc = "manufaucturing";
+   break;
+   cas

[PATCH][SCSI] mpt3sas: Common API layer interface headers for access to MPT firmware.

2012-09-29 Thread sreekanth.reddy
This patch contains the Fusion MPT base driver providing common API layer 
interface
headers for access to MPT (Message Passing Technology) firmware.

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
new file mode 100644
index 000..4e08a3c
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -0,0 +1,1139 @@
+/*
+ * This is the Fusion MPT base driver providing common API layer interface
+ * for access to MPT (Message Passing Technology) firmware.
+ *
+ * This code is based on drivers/scsi/mpt3sas/mpt3sas_base.h
+ * Copyright (C) 2012  LSI Corporation
+ *  (mailto:dl-mptfusionli...@lsi.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#ifndef MPT3SAS_BASE_H_INCLUDED
+#define MPT3SAS_BASE_H_INCLUDED
+
+#include "mpi/mpi2_type.h"
+#include "mpi/mpi2.h"
+#include "mpi/mpi2_ioc.h"
+#include "mpi/mpi2_cnfg.h"
+#include "mpi/mpi2_init.h"
+#include "mpi/mpi2_raid.h"
+#include "mpi/mpi2_tool.h"
+#include "mpi/mpi2_sas.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mpt3sas_debug.h"
+#include "mpt3sas_trigger_diag.h"
+
+/* driver versioning info */
+#define MPT3SAS_DRIVER_NAME"mpt3sas"
+#define MPT3SAS_AUTHOR "LSI Corporation "
+#define MPT3SAS_DESCRIPTION"LSI MPT Fusion SAS 3.0 Device Driver"
+#define MPT3SAS_DRIVER_VERSION "01.100.00.00"
+#define MPT3SAS_MAJOR_VERSION  1
+#define MPT3SAS_MINOR_VERSION  100
+#define MPT3SAS_BUILD_VERSION  0
+#define MPT3SAS_RELEASE_VERSION00
+
+/*
+ * Set MPT3SAS_SG_DEPTH value based on user input.
+ */
+#define MPT3SAS_MAX_PHYS_SEGMENTS  SCSI_MAX_SG_SEGMENTS
+#define MPT3SAS_MIN_PHYS_SEGMENTS  16
+#ifdef CONFIG_SCSI_MPT3SAS_MAX_SGE
+#define MPT3SAS_SG_DEPTH   CONFIG_SCSI_MPT3SAS_MAX_SGE
+#else
+#define MPT3SAS_SG_DEPTH   MPT3SAS_MAX_PHYS_SEGMENTS
+#endif
+
+
+/*
+ * Generic Defines
+ */
+#define MPT3SAS_SATA_QUEUE_DEPTH   32
+#define MPT3SAS_SAS_QUEUE_DEPTH254
+#define MPT3SAS_RAID_QUEUE_DEPTH   128
+
+#define MPT_NAME_LENGTH32  /* generic length of 
strings */
+#define MPT_STRING_LENGTH  64
+
+#define MPT_MAX_CALLBACKS  32
+
+
+#define CAN_SLEEP  1
+#define  NO_SLEEP  0
+
+#define INTERNAL_CMDS_COUNT10  /* reserved cmds */
+
+#define MPI3_HIM_MASK  0x /* mask every bit*/
+
+#define MPT3SAS_INVALID_DEVICE_HANDLE  0x
+
+/*
+ * reset phases
+ */
+#define MPT3_IOC_PRE_RESET 1 /* prior to host reset */
+#define MPT3_IOC_AFTER_RESET   2 /* just after host reset */
+#define MPT3_IOC_DONE_RESET3 /* links re-initialized */
+
+/*
+ * logging format
+ */
+#define MPT3SAS_FMT"%s: "
+
+/*
+ * per target private data
+ */
+#define MPT_TARGET_FLAGS_RAID_COMPONENT0x01
+#define MPT_TARGET_FLAGS_VOLUME0x02
+#def

[PATCH][SCSI] mpt3sas: Part 5 of MPI API headers

2012-09-29 Thread sreekanth.reddy
This patch contains MPI API headers
This patch is part 5 of MPI API headers.
Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_raid.h 
b/drivers/scsi/mpt3sas/mpi/mpi2_raid.h
new file mode 100644
index 000..d1d9866
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_raid.h
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2000-2012 LSI Corporation.
+ *
+ *
+ *  Name:  mpi2_raid.h
+ * Title:  MPI Integrated RAID messages and structures
+ * Creation Date:  April 26, 2007
+ *
+ *   mpi2_raid.h Version:  02.00.08
+ *
+ * Version History
+ * ---
+ *
+ * Date  Version   Description
+ *     --
+ * 04-30-07  02.00.00  Corresponds to Fusion-MPT MPI Specification Rev A.
+ * 08-31-07  02.00.01  Modifications to RAID Action request and reply,
+ * including the Actions and ActionData.
+ * 02-29-08  02.00.02  Added MPI2_RAID_ACTION_ADATA_DISABL_FULL_REBUILD.
+ * 05-21-08  02.00.03  Added MPI2_RAID_VOL_CREATION_NUM_PHYSDISKS so that
+ * the PhysDisk array in MPI2_RAID_VOLUME_CREATION_STRUCT
+ * can be sized by the build environment.
+ * 07-30-09  02.00.04  Added proper define for the Use Default Settings bit of
+ * VolumeCreationFlags and marked the old one as obsolete.
+ * 05-12-10  02.00.05  Added MPI2_RAID_VOL_FLAGS_OP_MDC define.
+ * 08-24-10  02.00.06  Added MPI2_RAID_ACTION_COMPATIBILITY_CHECK along with
+ * related structures and defines.
+ * Added product-specific range to RAID Action values.
+ * 11-18-11  02.00.07  Incorporating additions for MPI v2.5.
+ * 02-06-12  02.00.08  Added MPI2_RAID_ACTION_PHYSDISK_HIDDEN.
+ * --
+ */
+
+#ifndef MPI2_RAID_H
+#define MPI2_RAID_H
+
+/*
+*
+*  Integrated RAID Messages
+*
+*/
+
+/
+* RAID Action messages
+/
+
+/*ActionDataWord defines for use with MPI2_RAID_ACTION_DELETE_VOLUME action */
+#define MPI2_RAID_ACTION_ADATA_KEEP_LBA0(0x)
+#define MPI2_RAID_ACTION_ADATA_ZERO_LBA0(0x0001)
+
+/*use MPI2_RAIDVOL0_SETTING_ defines from mpi2_cnfg.h for
+ *MPI2_RAID_ACTION_CHANGE_VOL_WRITE_CACHE action */
+
+/*ActionDataWord defines for use with
+ *MPI2_RAID_ACTION_DISABLE_ALL_VOLUMES action */
+#define MPI2_RAID_ACTION_ADATA_DISABL_FULL_REBUILD  (0x0001)
+
+/*ActionDataWord for MPI2_RAID_ACTION_SET_RAID_FUNCTION_RATE Action */
+typedef struct _MPI2_RAID_ACTION_RATE_DATA {
+   U8 RateToChange;/*0x00 */
+   U8 RateOrMode;  /*0x01 */
+   U16 DataScrubDuration;  /*0x02 */
+} MPI2_RAID_ACTION_RATE_DATA, *PTR_MPI2_RAID_ACTION_RATE_DATA,
+   Mpi2RaidActionRateData_t, *pMpi2RaidActionRateData_t;
+
+#define MPI2_RAID_ACTION_SET_RATE_RESYNC(0x00)
+#define MPI2_RAID_ACTION_SET_RATE_DATA_SCRUB(0x01)
+#define MPI2_RAID_ACTION_SET_RATE_POWERSAVE_MODE(0x02)
+
+/*ActionDataWord for MPI2_RAID_ACTION_START_RAID_FUNCTION Action */
+typedef struct _MPI2_RAID_ACTION_START_RAID_FUNCTION {
+   U8 RAIDFunction;/*0x00 */
+   U8 Flags;   /*0x01 */
+   U16 Reserved1;  /*0x02 */
+} MPI2_RAID_ACTION_START_RAID_FUNCTION,
+   *PTR_MPI2_RAID_ACTION_START_RAID_FUNCTION,
+   Mpi2RaidActionStartRaidFunction_t,
+   *pMpi2RaidActionStartRaidFunction_t;
+
+/*defines for the RAIDFunction field */
+#define MPI2_RAID_ACTION_START_BACKGROUND_INIT  (0x00)
+#define MPI2_RAID_ACTION_START_ONLINE_CAP_EXPANSION (0x01)
+#define MPI2_RAID_ACTION_START_CONSISTENCY_CHECK(0x02)
+
+/*defines for the Flags field */
+#define MPI2_RAID_ACTION_START_NEW  (0x00)
+#define MPI2_RAID_ACTION_START_RESUME   (0x01)
+
+/*ActionDataWord for MPI2_RAID_ACTION_STOP_RAID_FUNCTION Action */
+typedef struct _MPI2_RAID_ACTION_STOP_RAID_FUNCTION {
+   U8 RAIDFunction;/*0x00 */
+   U8 Flags;   /*0x01 */
+   U16 Reserved1;  /*0x02 */
+} MPI2_RAID_ACTION_STOP_RAID_FUNCTION,
+   *PTR_MPI2_RAID_ACTION_STOP_RAID_FUNCTION,
+   Mpi2RaidActionStopRaidFunction_t,
+   *pMpi2RaidActionStopRaidFunction_t;
+
+/*defines for the RAIDFunction field */
+#define MPI2_RAID_ACTION_STOP_BACKGROUND_INIT   (0x00)
+#define MPI2_RAID_ACTION_STOP_ONLINE_CAP_EXPANSION  (0x01)
+#define MPI2_RAID_ACTION_STOP_CONSISTENCY_CHECK (0x02)
+
+/*defines for the Flags field */
+#define MPI2_RAID_ACTION_STOP_ABORT (0x00)
+#define MPI2_RAID_ACTION_STOP_PAUSE (0x01)
+
+/*Acti

[PATCH][SCSI] mpt3sas: Paer 1 of MPI API headers

2012-09-29 Thread sreekanth.reddy
This patch contains MPI API headers
This patch is part 1 of MPI API headers.
Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---


diff --git a/drivers/scsi/mpt3sas/mpi/mpi2.h b/drivers/scsi/mpt3sas/mpi/mpi2.h
new file mode 100644
index 000..03317ff
--- /dev/null
+++ b/drivers/scsi/mpt3sas/mpi/mpi2.h
@@ -0,0 +1,1164 @@
+/*
+ * Copyright (c) 2000-2012 LSI Corporation.
+ *
+ *
+ *  Name:  mpi2.h
+ * Title:  MPI Message independent structures and definitions
+ * including System Interface Register Set and
+ * scatter/gather formats.
+ * Creation Date:  June 21, 2006
+ *
+ * mpi2.h Version:  02.00.26
+ *
+ * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
+ *   prefix are for use only on MPI v2.5 products, and must not be used
+ *   with MPI v2.0 products. Unless otherwise noted, names beginning with
+ *   MPI2 or Mpi2 are for use with both MPI v2.0 and MPI v2.5 products.
+ *
+ * Version History
+ * ---
+ *
+ * Date  Version   Description
+ *     --
+ * 04-30-07  02.00.00  Corresponds to Fusion-MPT MPI Specification Rev A.
+ * 06-04-07  02.00.01  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 06-26-07  02.00.02  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 08-31-07  02.00.03  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Moved ReplyPostHostIndex register to offset 0x6C of the
+ * MPI2_SYSTEM_INTERFACE_REGS and modified the define for
+ * MPI2_REPLY_POST_HOST_INDEX_OFFSET.
+ * Added union of request descriptors.
+ * Added union of reply descriptors.
+ * 10-31-07  02.00.04  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added define for MPI2_VERSION_02_00.
+ * Fixed the size of the FunctionDependent5 field in the
+ * MPI2_DEFAULT_REPLY structure.
+ * 12-18-07  02.00.05  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Removed the MPI-defined Fault Codes and extended the
+ * product specific codes up to 0xEFFF.
+ * Added a sixth key value for the WriteSequence register
+ * and changed the flush value to 0x0.
+ * Added message function codes for Diagnostic Buffer Post
+ * and Diagnsotic Release.
+ * New IOCStatus define: MPI2_IOCSTATUS_DIAGNOSTIC_RELEASED
+ * Moved MPI2_VERSION_UNION from mpi2_ioc.h.
+ * 02-29-08  02.00.06  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 03-03-08  02.00.07  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 05-21-08  02.00.08  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added #defines for marking a reply descriptor as unused.
+ * 06-27-08  02.00.09  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 10-02-08  02.00.10  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Moved LUN field defines from mpi2_init.h.
+ * 01-19-09  02.00.11  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 05-06-09  02.00.12  Bumped MPI2_HEADER_VERSION_UNIT.
+ * In all request and reply descriptors, replaced VF_ID
+ * field with MSIxIndex field.
+ * Removed DevHandle field from
+ * MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR and made those
+ * bytes reserved.
+ * Added RAID Accelerator functionality.
+ * 07-30-09  02.00.13  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 10-28-09  02.00.14  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added MSI-x index mask and shift for Reply Post Host
+ * Index register.
+ * Added function code for Host Based Discovery Action.
+ * 02-10-10  02.00.15  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added define for MPI2_FUNCTION_PWR_MGMT_CONTROL.
+ * Added defines for product-specific range of message
+ * function codes, 0xF0 to 0xFF.
+ * 05-12-10  02.00.16  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added alternative defines for the SGE Direction bit.
+ * 08-11-10  02.00.17  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 11-10-10  02.00.18  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added MPI2_IEEE_SGE_FLAGS_SYSTEMPLBCPI_ADDR define.
+ * 02-23-11  02.00.19  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added MPI2_FUNCTION_SEND_HOST_MESSAGE.
+ * 03-09-11  02.00.20  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 05-25-11  02.00.21  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 08-24-11  02.00.22  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 11-18-11  02.00.23  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Incorporating additions for MPI v2.5.
+ * 02-06-12  02.00.24  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 03-29-12  02.00.25  Bumped MPI2_HEADER_VERSION_UNIT.
+ * Added Hard Reset delay timings.
+ * 07-10-12  02.00.26  Bump

[PATCH][SCSI] mpt3sas: Makefile, Kconfig and scsi_transport_sas file changes to support new driver mpt3sas

2012-09-29 Thread sreekanth.reddy
This patch contains the Makefile, Kconfig and 
scsi_transport_sas file changes to support new driver mpt3sas

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index e955978..49244f8 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -620,6 +620,7 @@ config SCSI_ARCMSR
 
 source "drivers/scsi/megaraid/Kconfig.megaraid"
 source "drivers/scsi/mpt2sas/Kconfig"
+source "drivers/scsi/mpt3sas/Kconfig"
 source "drivers/scsi/ufs/Kconfig"
 
 config SCSI_HPTIOP
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 1a3368b..88e52bb 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -106,6 +106,7 @@ obj-$(CONFIG_MEGARAID_LEGACY)   += megaraid.o
 obj-$(CONFIG_MEGARAID_NEWGEN)  += megaraid/
 obj-$(CONFIG_MEGARAID_SAS) += megaraid/
 obj-$(CONFIG_SCSI_MPT2SAS) += mpt2sas/
+obj-$(CONFIG_SCSI_MPT3SAS) += mpt3sas/
 obj-$(CONFIG_SCSI_UFSHCD)  += ufs/
 obj-$(CONFIG_SCSI_ACARD)   += atp870u.o
 obj-$(CONFIG_SCSI_SUNESP)  += esp_scsi.o   sun_esp.o
diff --git a/drivers/scsi/mpt3sas/Kconfig b/drivers/scsi/mpt3sas/Kconfig
new file mode 100644
index 000..81471bf
--- /dev/null
+++ b/drivers/scsi/mpt3sas/Kconfig
@@ -0,0 +1,67 @@
+#
+# Kernel configuration file for the MPT3SAS
+#
+# This code is based on drivers/scsi/mpt3sas/Kconfig
+# Copyright (C) 2012  LSI Corporation
+#  (mailto:dl-mptfusionli...@lsi.com)
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# NO WARRANTY
+# THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+# LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+# solely responsible for determining the appropriateness of using and
+# distributing the Program and assumes all risks associated with its
+# exercise of rights under this Agreement, including but not limited to
+# the risks and costs of program errors, damage to or loss of data,
+# programs or equipment, and unavailability or interruption of operations.
+
+# DISCLAIMER OF LIABILITY
+# NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+# HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+# USA.
+
+config SCSI_MPT3SAS
+   tristate "LSI MPT Fusion SAS 3.0 Device Driver"
+   depends on PCI && SCSI
+   select SCSI_SAS_ATTRS
+   select RAID_ATTRS
+   ---help---
+   This driver supports PCI-Express SAS 12Gb/s Host Adapters.
+
+config SCSI_MPT3SAS_MAX_SGE
+   int "LSI MPT Fusion Max number of SG Entries (16 - 256)"
+   depends on PCI && SCSI && SCSI_MPT3SAS
+   default "128"
+   range 16 256
+   ---help---
+   This option allows you to specify the maximum number of scatter-
+   gather entries per I/O. The driver default is 128, which matches
+   MAX_PHYS_SEGMENTS in most kernels.  However in SuSE kernels this
+   can be 256. However, it may decreased down to 16.  Decreasing this
+   parameter will reduce memory requirements on a per controller instance.
+
+config SCSI_MPT3SAS_LOGGING
+   bool "LSI MPT Fusion logging facility"
+   depends on PCI && SCSI && SCSI_MPT3SAS
+   ---help---
+   This turns on a logging facility.
diff --git a/drivers/scsi/mpt3sas/Makefile b/drivers/scsi/mpt3sas/Makefile
new file mode 100644
index 000..4c1d2e7
--- /dev/null
+++ b/drivers/scsi/mpt3sas/Makefile
@@ -0,0 +1,8 @@
+# mpt3sas makefile
+obj-m += mpt3sas.o
+mpt3sas-y +=  mpt3sas_base.o \
+   mpt3sas_config.o \
+   mpt3sas_scsih.o  \
+   mpt3sas_transport.o \
+   mpt3sas_ctl.o   \
+   mpt3sas_trigger_diag.o
diff --git a/drivers/scsi/scsi_transport_sas.c 
b/drivers/scsi/scsi_transport_sas.c
index f7565fc..1b68142 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ 

[PATCH][SCSI] mpt3sas: Driver submission v01.100.00.00

2012-09-29 Thread sreekanth.reddy
This is new scsi lld device driver from LSI supporting the SAS 3.0
standard.

Here is list of new 12gb host controllers:

  LSI SAS3004
  LSI SAS3008
  LSI SAS3108

Signed-off-by: Sreekanth Reddy 
Reviewed-by: Nagalakshmi Nandigama 
---
Here is the brief description of patches:
[PATCH 01/20] [SCSI] mpt3sas : Makefile, Kconfig and scsi_transport_sas file 
changes to support new driver mpt3sas
[PATCH 02/20] [SCSI] mpt3sas : MPI API headers. This patch is part 1 of MPI API 
headers.
[PATCH 03/20] [SCSI] mpt3sas : MPI API headers. This patch is part 2 of MPI API 
headers.
[PATCH 04/20] [SCSI] mpt3sas : MPI API headers. This patch is part 3 of MPI API 
headers.
[PATCH 05/20] [SCSI] mpt3sas : MPI API headers. This patch is part 4 of MPI API 
headers.
[PATCH 06/20] [SCSI] mpt3sas : MPI API headers. This patch is part 5 of MPI API 
headers.
[PATCH 07/20] [SCSI] mpt3sas : Fusion MPT base driver providing common API 
layer interface
for access to MPT (Message 
Passing Technology) firmware.
This patch is part 1 of 
mpt3sas_base.c
[PATCH 08/20] [SCSI] mpt3sas : This patch is part 2 of mpt3sas_base.c
[PATCH 09/20] [SCSI] mpt3sas : Fusion MPT base driver providing common API 
layer interface
headers for access to MPT 
(Message Passing Technology) firmware.
[PATCH 10/20] [SCSI] mpt3sas : Common API for accessing firmware configuration 
pages
[PATCH 11/20] [SCSI] mpt3sas : Ioctl Support for MPT (Message Passing 
Technology)
based controller
[PATCH 12/20] [SCSI] mpt3sas : Ioctl Module Support headers for MPT (Message 
Passing Technology)
based controllers
[PATCH 13/20] [SCSI] mpt3sas : Logging Support for MPT (Message Passing 
Technology)
based controllers
[PATCH 14/20] [SCSI] mpt3sas : Code related to Scsi Host Layer for
MPT (Message Passing 
Technology) based controllers
This patch is part 1 of 
mpt3sas_scsih.c
[PATCH 15/20] [SCSI] mpt3sas : This patch is part 2 of mpt3sas_scsih.c
[PATCH 16/20] [SCSI] mpt3sas : This patch is part 3 of mpt3sas_scsih.c
[PATCH 17/20] [SCSI] mpt3sas : Code related to SAS Transport Layer for
MPT (Message Passing Technology) based 
controllers
[PATCH 18/20] [SCSI] mpt3sas : Common API to set Diagnostic trigger for MPT
(Message Passing Technology) based 
controllers
[PATCH 19/20] [SCSI] mpt3sas : Common API headers to set Diagnostic trigger for 
MPT
(Message Passing Technology) based 
controllers
[PATCH 20/20] [SCSI] mpt3sas : Adding support for MPT3SAS_MINOR(222)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][SCSI] mpt3sas: linux/miscdevice.h

2012-09-24 Thread sreekanth.reddy
Adding support for MPT3SAS_MINOR(222)

Signed-off-by: Sreekanth Reddy 
---

diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 0549d211..9c9ba04 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -34,6 +34,7 @@
 #define MWAVE_MINOR219 /* ACP/Mwave Modem */
 #define MPT_MINOR  220
 #define MPT2SAS_MINOR  221
+#define MPT3SAS_MINOR  222
 #define UINPUT_MINOR   223
 #define HPET_MINOR 228
 #define FUSE_MINOR 229
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND][PATCH][SCSI] mpt2sas: Fix for issue - Unable to boot from the drive connected to HBA

2012-08-22 Thread sreekanth.reddy
Fix for issue - Unable to boot from the SAS drive connected to HBA

This patch checks whether HBA is SAS2008 B0 controller.
if it is a SAS2008 B0 controller then it use IO-APIC interrupt instead of MSIX,
as SAS2008 B0 controller doesn't support MSIX interrupts.

Signed-off-by: Sreekanth Reddy 
Cc: 
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c 
b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 2f77f39..4c66a55 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -1208,6 +1208,13 @@ _base_check_enable_msix(struct MPT2SAS_ADAPTER *ioc)
int base;
u16 message_control;
 
+   /* Check whether controller SAS2008 B0 controller,
+   if it is SAS2008 B0 controller use IO-APIC instead of MSIX */
+if (ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2008 &&
+ioc->pdev->revision == 0x01) {
+return -EINVAL;
+}
+
base = pci_find_capability(ioc->pdev, PCI_CAP_ID_MSIX);
if (!base) {
dfailprintk(ioc, printk(MPT2SAS_INFO_FMT "msix not "
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND][PATCH][SCSI] mpt2sas: Fix for issue - Unable to boot from the SAS drive connected to HBA

2012-08-21 Thread sreekanth.reddy
Fix for issue - Unable to boot from the SAS drive connected to HBA

This patch checks whether HBA is SAS2008 B0 controller.
if it is a SAS2008 B0 controller then it use IO-APIC interrupt instead of MSIX,
as SAS2008 B0 controller doesn't support MSIX interrupts.

Signed-off-by: Sreekanth Reddy 
Cc: 
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c 
b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 6102ef2..fd2f4ad 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -1207,6 +1207,15 @@ _base_check_enable_msix(struct MPT2SAS_ADAPTER *ioc)
 {
int base;
u16 message_control;
+   u8 revision;
+
+   /* Check whether controller SAS2008 B0 controller,
+  if it is a SAS2008 B0 controller use IO-APIC instead of MSIX */
+   pci_read_config_byte(ioc->pdev, PCI_CLASS_REVISION, &revision);
+   if (ioc->pdev->device == MPI2_MFGPAGE_DEVID_SAS2008 &&
+   revision == 0x01) {
+   return -EINVAL;
+   }
 
 
base = pci_find_capability(ioc->pdev, PCI_CAP_ID_MSIX);
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND] [PATCH] [SCSI] mptfusion: Fix for issue - The device is removed in blocked state

2012-07-19 Thread sreekanth.reddy
Fix for issue - The device is removed in blocked state.

The device is set to blocked state when I/Os running and the cable is pulled.
Also if the device missing delay timer is started. When the device missing
delay timer expires, the device is removed but the device state is not set to
unblocked state. This will cause problems  if there are commands in block
queue.

To fix this issue, added code to unblock the device before removing it.

Signed-off-by: Sreekanth Reddy 
Cc: 
---

diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 551262e..4d02d5d 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1088,7 +1088,13 @@ mptsas_target_reset(MPT_ADAPTER *ioc, u8 channel, u8 id)
 static void
 mptsas_block_io_sdev(struct scsi_device *sdev, void *data)
 {
-   scsi_device_set_state(sdev, SDEV_BLOCK);
+   scsi_internal_device_block(sdev);
+}
+
+static void
+mptsas_ublock_io_sdev(struct scsi_device *sdev, void *data)
+{
+   scsi_internal_device_unblock(sdev);
 }
 
 static void
@@ -1098,6 +1104,13 @@ mptsas_block_io_starget(struct scsi_target *starget)
starget_for_each_device(starget, NULL, mptsas_block_io_sdev);
 }
 
+static void
+mptsas_ublock_io_starget(struct scsi_target *starget)
+{
+   if (starget)
+   starget_for_each_device(starget, NULL, mptsas_ublock_io_sdev);
+}
+
 /**
  * mptsas_target_reset_queue
  *
@@ -1502,6 +1515,7 @@ mptsas_del_end_device(MPT_ADAPTER *ioc, struct 
mptsas_phyinfo *phy_info)
char *ds = NULL;
u8 fw_id;
u64 sas_address;
+   VirtTarget  *vtarget;
 
if (!phy_info)
return;
@@ -1545,6 +1559,13 @@ mptsas_del_end_device(MPT_ADAPTER *ioc, struct 
mptsas_phyinfo *phy_info)
phy_info->attached.id, phy_info->attached.phy_id,
(unsigned long long) sas_address);
 
+   vtarget = mptsas_find_vtarget(ioc,
+phy_info->attached.channel, phy_info->attached.id);
+   if (vtarget && vtarget->deleted == 1) {
+   mptsas_ublock_io_starget(vtarget->starget);
+   vtarget->deleted = 0; /* unblock IO */
+   }
+
port = mptsas_get_port(phy_info);
if (!port) {
dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
diff --git a/drivers/message/fusion/mptsas.h b/drivers/message/fusion/mptsas.h
index 57e86ab..1567f57 100644
--- a/drivers/message/fusion/mptsas.h
+++ b/drivers/message/fusion/mptsas.h
@@ -189,4 +189,7 @@ struct mptsas_enclosure {
 };
 
 /*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+
+extern int scsi_internal_device_block(struct scsi_device *sdev);
+extern int scsi_internal_device_unblock(struct scsi_device *sdev);
 #endif
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Fix for issue - The device is removed in blocked state

2012-07-19 Thread sreekanth.reddy
Fix for issue - The device is removed in blocked state.

The device is set to blocked state when I/Os running and the cable is pulled.
Also if the device missing delay timer is started. When the device missing
delay timer expires, the device is removed but the device state is not set to
unblocked state. This will cause problems  if there are commands in block
queue.

To fix this issue, added code to unblock the device before removing it.

Signed-off-by: Sreekanth Reddy 
Cc: 
---

diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 551262e..4d02d5d 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1088,7 +1088,13 @@ mptsas_target_reset(MPT_ADAPTER *ioc, u8 channel, u8 id)
 static void
 mptsas_block_io_sdev(struct scsi_device *sdev, void *data)
 {
-   scsi_device_set_state(sdev, SDEV_BLOCK);
+   scsi_internal_device_block(sdev);
+}
+
+static void
+mptsas_ublock_io_sdev(struct scsi_device *sdev, void *data)
+{
+   scsi_internal_device_unblock(sdev);
 }
 
 static void
@@ -1098,6 +1104,13 @@ mptsas_block_io_starget(struct scsi_target *starget)
starget_for_each_device(starget, NULL, mptsas_block_io_sdev);
 }
 
+static void
+mptsas_ublock_io_starget(struct scsi_target *starget)
+{
+   if (starget)
+   starget_for_each_device(starget, NULL, mptsas_ublock_io_sdev);
+}
+
 /**
  * mptsas_target_reset_queue
  *
@@ -1502,6 +1515,7 @@ mptsas_del_end_device(MPT_ADAPTER *ioc, struct 
mptsas_phyinfo *phy_info)
char *ds = NULL;
u8 fw_id;
u64 sas_address;
+   VirtTarget  *vtarget;
 
if (!phy_info)
return;
@@ -1545,6 +1559,13 @@ mptsas_del_end_device(MPT_ADAPTER *ioc, struct 
mptsas_phyinfo *phy_info)
phy_info->attached.id, phy_info->attached.phy_id,
(unsigned long long) sas_address);
 
+   vtarget = mptsas_find_vtarget(ioc,
+phy_info->attached.channel, phy_info->attached.id);
+   if (vtarget && vtarget->deleted == 1) {
+   mptsas_ublock_io_starget(vtarget->starget);
+   vtarget->deleted = 0; /* unblock IO */
+   }
+
port = mptsas_get_port(phy_info);
if (!port) {
dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
diff --git a/drivers/message/fusion/mptsas.h b/drivers/message/fusion/mptsas.h
index 57e86ab..1567f57 100644
--- a/drivers/message/fusion/mptsas.h
+++ b/drivers/message/fusion/mptsas.h
@@ -189,4 +189,7 @@ struct mptsas_enclosure {
 };
 
 /*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+
+extern int scsi_internal_device_block(struct scsi_device *sdev);
+extern int scsi_internal_device_unblock(struct scsi_device *sdev);
 #endif
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/09] [SCSI] mpt2sas : Fix for Driver oops, when loading driver with max_queue_depth command line option to a very small value

2012-07-17 Thread sreekanth.reddy
If the specified max_queue_depth setting is less than the expected number of
internal commands, then driver will calculate the queue depth size to a negitive
number. This negitive number is actually a very large number because variable is
unsigned 16bit integer. So, the driver will ask for a very large amount of
memory for message frames and resulting into oops as memory allocation routines
will not able to handle such a large request.

So, in order to limit this kind of oops, The driver need to set the 
max_queue_depth
to a scsi mid layer's can_queue value. Then the overall message frames required 
for
IO is minimum of either (max_queue_depth plus internal commands) or the IOC 
global
credits.

Signed-off-by: Sreekanth Reddy 
Cc: 
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c 
b/drivers/scsi/mpt2sas/mpt2sas_base.c
index ffa32ad..f7c1394 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -2424,10 +2424,13 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER 
*ioc,  int sleep_flag)
}
 
/* command line tunables  for max controller queue depth */
-   if (max_queue_depth != -1)
-   max_request_credit = (max_queue_depth < facts->RequestCredit)
-   ? max_queue_depth : facts->RequestCredit;
-   else
+   if (max_queue_depth != -1 && max_queue_depth != 0) {
+   max_request_credit = min_t(u16, max_queue_depth +
+   ioc->hi_priority_depth + ioc->internal_depth,
+   facts->RequestCredit);
+   if (max_request_credit > MAX_HBA_QUEUE_DEPTH)
+   max_request_credit =  MAX_HBA_QUEUE_DEPTH;
+   } else
max_request_credit = min_t(u16, facts->RequestCredit,
MAX_HBA_QUEUE_DEPTH);
 
@@ -2502,7 +2505,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc,  
int sleep_flag)
/* set the scsi host can_queue depth
 * with some internal commands that could be outstanding
 */
-   ioc->shost->can_queue = ioc->scsiio_depth - (2);
+   ioc->shost->can_queue = ioc->scsiio_depth;
dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host: "
"can_queue depth (%d)\n", ioc->name, ioc->shost->can_queue));
 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/09] [SCSI] mpt2sas : Bump driver vesion to 14.100.00.00

2012-07-17 Thread sreekanth.reddy
Bump driver version to 14.100.00.00

Signed-off-by: Sreekanth Reddy 
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h 
b/drivers/scsi/mpt2sas/mpt2sas_base.h
index dd05d24..e7e517a 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
@@ -69,8 +69,8 @@
 #define MPT2SAS_DRIVER_NAME"mpt2sas"
 #define MPT2SAS_AUTHOR "LSI Corporation "
 #define MPT2SAS_DESCRIPTION"LSI MPT Fusion SAS 2.0 Device Driver"
-#define MPT2SAS_DRIVER_VERSION "13.100.00.00"
-#define MPT2SAS_MAJOR_VERSION  13
+#define MPT2SAS_DRIVER_VERSION "14.100.00.00"
+#define MPT2SAS_MAJOR_VERSION  14
 #define MPT2SAS_MINOR_VERSION  100
 #define MPT2SAS_BUILD_VERSION  00
 #define MPT2SAS_RELEASE_VERSION00
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/09] [SCSI] mpt2sas : Fix for With post diag reset same set of device gets added, removed and then again gets added with new target ids

2012-07-17 Thread sreekanth.reddy
When device discovery is disabled during driver load time using module parameter
"disable_discovery=1" and when diag reset is issued then from logs, it is 
observed
that the devices get added, removed and then added with new target ids.

So, inorder to limit this turn-off the code which is deleting and devices across
host reset when the disable_discovery module parameter is turned on.

Signed-off-by: Sreekanth Reddy 
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c 
b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 7a69a5c..7efefb7 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -7264,7 +7264,8 @@ mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, 
int reset_phase)
_scsih_search_responding_sas_devices(ioc);
_scsih_search_responding_raid_devices(ioc);
_scsih_search_responding_expanders(ioc);
-   if (!ioc->is_driver_loading) {
+   if ((!ioc->is_driver_loading) && !(disable_discovery > 0 &&
+   !ioc->sas_hba.num_phys)) {
_scsih_prep_device_scan(ioc);
_scsih_search_responding_sas_devices(ioc);
_scsih_search_responding_raid_devices(ioc);
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/09] [SCSI] mpt2sas : MPI next revision header update

2012-07-17 Thread sreekanth.reddy
MPI 2.0 Rev V(2.0.14) specification

Changeset in MPI 2.0 Rev V(2.0.14) specification
1) Bumped MPI2_HEADER_VERSION_UNIT.
2) Added a product specific range to event values.
3) Added clarification to Direct-Attached SAS PHY Power condition.
4) Updated timing requirements for performing Hard Reset.

Signed-off-by: Sreekanth Reddy 
---

diff --git a/drivers/scsi/mpt2sas/mpi/mpi2.h b/drivers/scsi/mpt2sas/mpi/mpi2.h
index a80f322..e960f96 100644
--- a/drivers/scsi/mpt2sas/mpi/mpi2.h
+++ b/drivers/scsi/mpt2sas/mpi/mpi2.h
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2000-2011 LSI Corporation.
+ *  Copyright (c) 2000-2012 LSI Corporation.
  *
  *
  *   Name:  mpi2.h
@@ -8,7 +8,7 @@
  *  scatter/gather formats.
  *  Creation Date:  June 21, 2006
  *
- *  mpi2.h Version:  02.00.23
+ *  mpi2.h Version:  02.00.25
  *
  *  Version History
  *  ---
@@ -72,6 +72,9 @@
  *  05-25-11  02.00.21  Bumped MPI2_HEADER_VERSION_UNIT.
  *  08-24-11  02.00.22  Bumped MPI2_HEADER_VERSION_UNIT.
  *  11-18-11  02.00.23  Bumped MPI2_HEADER_VERSION_UNIT.
+ *  02-06-12  02.00.24  Bumped MPI2_HEADER_VERSION_UNIT.
+ *  03-29-12  02.00.25  Bumped MPI2_HEADER_VERSION_UNIT.
+ *  Added Hard Reset delay timings.
  *  --
  */
 
@@ -97,7 +100,7 @@
 #define MPI2_VERSION_02_00  (0x0200)
 
 /* versioning for this MPI header set */
-#define MPI2_HEADER_VERSION_UNIT(0x17)
+#define MPI2_HEADER_VERSION_UNIT(0x19)
 #define MPI2_HEADER_VERSION_DEV (0x00)
 #define MPI2_HEADER_VERSION_UNIT_MASK   (0xFF00)
 #define MPI2_HEADER_VERSION_UNIT_SHIFT  (8)
@@ -275,6 +278,11 @@ typedef volatile struct _MPI2_SYSTEM_INTERFACE_REGS
 #define MPI2_REQUEST_DESCRIPTOR_POST_HIGH_OFFSET(0x00C4)
 
 
+/* Hard Reset delay timings */
+#define MPI2_HARD_RESET_PCIE_FIRST_READ_DELAY_MICRO_SEC (5)
+#define MPI2_HARD_RESET_PCIE_RESET_READ_WINDOW_MICRO_SEC(255000)
+#define MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC(256000)
+
 /*
 *
 *Message Descriptors
diff --git a/drivers/scsi/mpt2sas/mpi/mpi2_init.h 
b/drivers/scsi/mpt2sas/mpi/mpi2_init.h
index de90162..38c5da3 100644
--- a/drivers/scsi/mpt2sas/mpi/mpi2_init.h
+++ b/drivers/scsi/mpt2sas/mpi/mpi2_init.h
@@ -1,12 +1,12 @@
 /*
- *  Copyright (c) 2000-2010 LSI Corporation.
+ *  Copyright (c) 2000-2012 LSI Corporation.
  *
  *
  *   Name:  mpi2_init.h
  *  Title:  MPI SCSI initiator mode messages and structures
  *  Creation Date:  June 23, 2006
  *
- *mpi2_init.h Version:  02.00.11
+ *mpi2_init.h Version:  02.00.13
  *
  *  Version History
  *  ---
@@ -34,6 +34,8 @@
  *  02-10-10  02.00.09  Removed unused structure that had "#if 0" around it.
  *  05-12-10  02.00.10  Added optional vendor-unique region to SCSI IO Request.
  *  11-10-10  02.00.11  Added MPI2_SCSIIO_NUM_SGLOFFSETS define.
+ *  02-06-12  02.00.13  Added alternate defines for Task Priority / Command
+ *  Priority to match SAM-4.
  *  --
  */
 
@@ -194,6 +196,9 @@ typedef struct _MPI2_SCSI_IO_REQUEST
 
 #define MPI2_SCSIIO_CONTROL_TASKPRI_MASK(0x7800)
 #define MPI2_SCSIIO_CONTROL_TASKPRI_SHIFT   (11)
+/* alternate name for the previous field; called Command Priority in SAM-4 */
+#define MPI2_SCSIIO_CONTROL_CMDPRI_MASK (0x7800)
+#define MPI2_SCSIIO_CONTROL_CMDPRI_SHIFT(11)
 
 #define MPI2_SCSIIO_CONTROL_TASKATTRIBUTE_MASK  (0x0700)
 #define MPI2_SCSIIO_CONTROL_SIMPLEQ (0x)
diff --git a/drivers/scsi/mpt2sas/mpi/mpi2_ioc.h 
b/drivers/scsi/mpt2sas/mpi/mpi2_ioc.h
index 9a925c0..b0d4760 100644
--- a/drivers/scsi/mpt2sas/mpi/mpi2_ioc.h
+++ b/drivers/scsi/mpt2sas/mpi/mpi2_ioc.h
@@ -1,12 +1,12 @@
 /*
- *  Copyright (c) 2000-2011 LSI Corporation.
+ *  Copyright (c) 2000-2012 LSI Corporation.
  *
  *
  *   Name:  mpi2_ioc.h
  *  Title:  MPI IOC, Port, Event, FW Download, and FW Upload messages
  *  Creation Date:  October 11, 2006
  *
- *  mpi2_ioc.h Version:  02.00.19
+ *  mpi2_ioc.h Version:  02.00.21
  *
  *  Version History
  *  ---
@@ -117,6 +117,7 @@
  *  08-24-11  02.00.19  Added PhysicalPort field to
  *  MPI2_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE structure.
  *  Marked MPI2_PM_CONTROL_FEATURE_PCIE_LINK as obsolete.
+ *  03-29-12  02.00.21  Added a product specific range to event values.
  *  --
  */
 
@@ -492,7 +493,8 @@ typedef struct _MPI2_EVENT_NOTIFICATION_REPLY
 #define MPI2_EVENT_SAS_NOTIFY_PRIMITIVE (0x0026)
 #define MPI2_EVENT_TEMP_THRESHOLD   (0x0027)
 #define MPI2_EVENT_HOST_MESSAGE   

[PATCH 07/09] [SCSI] mpt2sas : Fix for staged device discovery functionality of driver not working

2012-07-17 Thread sreekanth.reddy
This patch provides a command line option to disable "Port enable" during
the driver load.

The objective of this command line option is to load the driver and do
all the necessary initialization excluding port enable(i.e. delay
device discovery)

Signed-off-by: Sreekanth Reddy 
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c 
b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 3e231a7..7a69a5c 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -119,6 +119,10 @@ module_param(diag_buffer_enable, int, 0);
 MODULE_PARM_DESC(diag_buffer_enable, " post diag buffers "
"(TRACE=1/SNAPSHOT=2/EXTENDED=4/default=0)");
 
+static int disable_discovery = -1;
+module_param(disable_discovery, int, 0);
+MODULE_PARM_DESC(disable_discovery, " disable discovery ");
+
 /**
  * struct sense_info - common structure for obtaining sense keys
  * @skey: sense key
@@ -5973,8 +5977,14 @@ _scsih_sas_discovery_event(struct MPT2SAS_ADAPTER *ioc,
 #endif
 
if (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED &&
-   !ioc->sas_hba.num_phys)
+   !ioc->sas_hba.num_phys) {
+   if (disable_discovery > 0 && ioc->shost_recovery) {
+   /* Wait for the reset to complete */
+   while (ioc->shost_recovery)
+   ssleep(1);
+   }
_scsih_sas_host_add(ioc);
+   }
 }
 
 /**
@@ -7929,6 +7939,9 @@ _scsih_scan_start(struct Scsi_Host *shost)
if (diag_buffer_enable != -1 && diag_buffer_enable != 0)
mpt2sas_enable_diag_buffer(ioc, diag_buffer_enable);
 
+   if (disable_discovery > 0)
+   return;
+
ioc->start_scan = 1;
rc = mpt2sas_port_enable(ioc);
 
@@ -7950,6 +7963,12 @@ _scsih_scan_finished(struct Scsi_Host *shost, unsigned 
long time)
 {
struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
 
+   if (disable_discovery > 0) {
+   ioc->is_driver_loading = 0;
+   ioc->wait_for_discovery_to_complete = 0;
+   return 1;
+   }
+
if (time >= (300 * HZ)) {
ioc->base_cmds.status = MPT2_CMD_NOT_USED;
printk(MPT2SAS_INFO_FMT "port enable: FAILED with timeout "
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/09] [SCSI] mpt2sas : Fix for max_sectors warning message is stating the incorrect range

2012-07-17 Thread sreekanth.reddy
When specifying the command line option "max_sectors" less than 64, then warning
message should provide correct upper boundary value 32767 instead of 8192.

Signed-off-by: Sreekanth Reddy 
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c 
b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 0f4f971..4a09ace 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -8055,8 +8055,8 @@ _scsih_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
if (max_sectors != 0x) {
if (max_sectors < 64) {
shost->max_sectors = 64;
-   printk(MPT2SAS_WARN_FMT "Invalid value %d passed "
-   "for max_sectors, range is 64 to 8192. Assigning "
+   printk(MPT2SAS_WARN_FMT "Invalid value %d passed "\
+   "for max_sectors, range is 64 to 32767. Assigning "\
"value of 64.\n", ioc->name, max_sectors);
} else if (max_sectors > 32767) {
shost->max_sectors = 32767;
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/09] [SCSI] mpt2sas : Provide sysfs attribute to report Backup Rail Monitor Status

2012-07-17 Thread sreekanth.reddy
A new sysfs shost attribute called "BMR_status" is implemented to
report Backup Rail Monitor status.

This attribute is located in the path
/sys/class/scsi_host/host#/BMR_status

when reading this adapter attribute, then driver will output the state
of GPIO[24]. It returns "0" if BMR is healthy and it returns "1" for failure.

if it returns an empty string then it means that there was an error while
obtaining the BMR status. Then check dmesg for what error has occured.

Signed-off-by: Sreekanth Reddy 
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h 
b/drivers/scsi/mpt2sas/mpt2sas_base.h
index 401c8ac..dd05d24 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
@@ -1096,6 +1096,8 @@ int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER 
*ioc, Mpi2ConfigReply_t
 *mpi_reply, Mpi2IOUnitPage1_t *config_page);
 int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, 
Mpi2ConfigReply_t
 *mpi_reply, Mpi2IOUnitPage1_t *config_page);
+int mpt2sas_config_get_iounit_pg3(struct MPT2SAS_ADAPTER *ioc,
+   Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage3_t *config_page, u16 sz);
 int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, 
Mpi2ConfigReply_t
 *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
 int mpt2sas_config_set_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
diff --git a/drivers/scsi/mpt2sas/mpt2sas_config.c 
b/drivers/scsi/mpt2sas/mpt2sas_config.c
index 323309b..8637780 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_config.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_config.c
@@ -683,6 +683,42 @@ mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
 }
 
 /**
+ * mpt2sas_config_get_iounit_pg3 - obtain iounit page 3
+ * @ioc: per adapter object
+ * @mpi_reply: reply mf payload returned from firmware
+ * @config_page: contents of the config page
+ * @sz: size of buffer passed in config_page
+ * Context: sleep.
+ *
+ * Returns 0 for success, non-zero for failure.
+ */
+int
+mpt2sas_config_get_iounit_pg3(struct MPT2SAS_ADAPTER *ioc,
+   Mpi2ConfigReply_t *mpi_reply, Mpi2IOUnitPage3_t *config_page, u16 sz)
+{
+   Mpi2ConfigRequest_t mpi_request;
+   int r;
+
+   memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
+   mpi_request.Function = MPI2_FUNCTION_CONFIG;
+   mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
+   mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_IO_UNIT;
+   mpi_request.Header.PageNumber = 3;
+   mpi_request.Header.PageVersion = MPI2_IOUNITPAGE3_PAGEVERSION;
+   mpt2sas_base_build_zero_len_sge(ioc, &mpi_request.PageBufferSGE);
+   r = _config_request(ioc, &mpi_request, mpi_reply,
+   MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
+   if (r)
+   goto out;
+
+   mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
+   r = _config_request(ioc, &mpi_request, mpi_reply,
+   MPT2_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz);
+ out:
+   return r;
+}
+
+/**
  * mpt2sas_config_get_ioc_pg8 - obtain ioc page 8
  * @ioc: per adapter object
  * @mpi_reply: reply mf payload returned from firmware
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c 
b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
index 6da4a40..6425441 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
@@ -2690,6 +2690,75 @@ _ctl_ioc_reply_queue_count_show(struct device *cdev,
 static DEVICE_ATTR(reply_queue_count, S_IRUGO,
 _ctl_ioc_reply_queue_count_show, NULL);
 
+/**
+ * _ctl_BRM_status_show - Backup Rail Monitor Status
+ * @cdev - pointer to embedded class device
+ * @buf - the buffer returned
+ *
+ * This is number of reply queues
+ *
+ * A sysfs 'read-only' shost attribute.
+ */
+static ssize_t
+_ctl_BRM_status_show(struct device *cdev, struct device_attribute *attr,
+   char *buf)
+{
+   struct Scsi_Host *shost = class_to_shost(cdev);
+   struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
+   Mpi2IOUnitPage3_t *io_unit_pg3 = NULL;
+   Mpi2ConfigReply_t mpi_reply;
+   u16 backup_rail_monitor_status = 0;
+   u16 ioc_status;
+   int sz;
+   ssize_t rc = 0;
+
+   if (!ioc->is_warpdrive) {
+   printk(MPT2SAS_ERR_FMT "%s: BRM attribute is only for"\
+   "warpdrive\n", ioc->name, __func__);
+   goto out;
+   }
+
+   /* allocate upto GPIOVal 36 entries */
+   sz = offsetof(Mpi2IOUnitPage3_t, GPIOVal) + (sizeof(u16) * 36);
+   io_unit_pg3 = kzalloc(sz, GFP_KERNEL);
+   if (!io_unit_pg3) {
+   printk(MPT2SAS_ERR_FMT "%s: failed allocating memory"\
+   "for iounit_pg3: (%d) bytes\n", ioc->name, __func__, sz);
+   goto out;
+   }
+
+   if (mpt2sas_config_get_iounit_pg3(ioc, &mpi_reply, io_unit_pg3, sz) !=
+   0) {
+   printk(MPT2SAS_ERR_FMT
+   "%s: failed reading iounit_pg3\n", ioc->name,
+   __func__);
+   goto out;
+   }

[PATCH 02/09] [SCSI] mpt2sas : To include more Intel Branding

2012-07-17 Thread sreekanth.reddy
Updating the customer branding string for "SSD 910 Series" controller

Signed-off-by: Sreekanth Reddy 
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c 
b/drivers/scsi/mpt2sas/mpt2sas_base.c
index e68deff..ffa32ad 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -1971,9 +1971,9 @@ _base_display_intel_branding(struct MPT2SAS_ADAPTER *ioc)
printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
MPT2SAS_INTEL_RMS2LL040_BRANDING);
break;
-   case MPT2SAS_INTEL_RAMSDALE_SSDID:
+   case MPT2SAS_INTEL_SSD910_SSDID:
printk(MPT2SAS_INFO_FMT "%s\n", ioc->name,
-   MPT2SAS_INTEL_RAMSDALE_BRANDING);
+   MPT2SAS_INTEL_SSD910_BRANDING);
break;
default:
break;
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h 
b/drivers/scsi/mpt2sas/mpt2sas_base.h
index 64ac0c6..401c8ac 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
@@ -171,8 +171,8 @@
"Intel Integrated RAID Module RMS2LL040"
 #define MPT2SAS_INTEL_RS25GB008_BRANDING   \
"Intel(R) RAID Controller RS25GB008"
-#define MPT2SAS_INTEL_RAMSDALE_BRANDING\
-   "Intel 720 Series SSD"
+#define MPT2SAS_INTEL_SSD910_BRANDING  \
+   "Intel(R) SSD 910 Series"
 /*
  * Intel HBA SSDIDs
  */
@@ -183,7 +183,7 @@
 #define MPT2SAS_INTEL_RMS2LL080_SSDID  0x350E
 #define MPT2SAS_INTEL_RMS2LL040_SSDID  0x350F
 #define MPT2SAS_INTEL_RS25GB008_SSDID  0x3000
-#define MPT2SAS_INTEL_RAMSDALE_SSDID   0x3700
+#define MPT2SAS_INTEL_SSD910_SSDID 0x3700
 
 /*
  * HP HBA branding
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/09] [SCSI] mpt2sas : 2012 source code copyright

2012-07-17 Thread sreekanth.reddy
 2012 source code copyright
- The Copyright String in all the drivers sources were changed to 2012

Signed-off-by: Sreekanth Reddy 
---

diff --git a/drivers/scsi/mpt2sas/Kconfig b/drivers/scsi/mpt2sas/Kconfig
index bbb7e4b..39f08dd 100644
--- a/drivers/scsi/mpt2sas/Kconfig
+++ b/drivers/scsi/mpt2sas/Kconfig
@@ -2,7 +2,7 @@
 # Kernel configuration file for the MPT2SAS
 #
 # This code is based on drivers/scsi/mpt2sas/Kconfig
-# Copyright (C) 2007-2010  LSI Corporation
+# Copyright (C) 2007-2012  LSI Corporation
 #  (mailto:dl-mptfusionli...@lsi.com)
 
 # This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c 
b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 6102ef2..e68deff 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -3,7 +3,7 @@
  * for access to MPT (Message Passing Technology) firmware.
  *
  * This code is based on drivers/scsi/mpt2sas/mpt2_base.c
- * Copyright (C) 2007-2010  LSI Corporation
+ * Copyright (C) 2007-2012  LSI Corporation
  *  (mailto:dl-mptfusionli...@lsi.com)
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h 
b/drivers/scsi/mpt2sas/mpt2sas_base.h
index b6dd3a5..64ac0c6 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
@@ -3,7 +3,7 @@
  * for access to MPT (Message Passing Technology) firmware.
  *
  * This code is based on drivers/scsi/mpt2sas/mpt2_base.h
- * Copyright (C) 2007-2010  LSI Corporation
+ * Copyright (C) 2007-2012  LSI Corporation
  *  (mailto:dl-mptfusionli...@lsi.com)
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt2sas/mpt2sas_config.c 
b/drivers/scsi/mpt2sas/mpt2sas_config.c
index 2b4d376..323309b 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_config.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_config.c
@@ -2,7 +2,7 @@
  * This module provides common API for accessing firmware configuration pages
  *
  * This code is based on drivers/scsi/mpt2sas/mpt2_base.c
- * Copyright (C) 2007-2010  LSI Corporation
+ * Copyright (C) 2007-2012  LSI Corporation
  *  (mailto:dl-mptfusionli...@lsi.com)
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c 
b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
index 49bdd2d..6da4a40 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
@@ -3,7 +3,7 @@
  * controllers
  *
  * This code is based on drivers/scsi/mpt2sas/mpt2_ctl.c
- * Copyright (C) 2007-2010  LSI Corporation
+ * Copyright (C) 2007-2012  LSI Corporation
  *  (mailto:dl-mptfusionli...@lsi.com)
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.h 
b/drivers/scsi/mpt2sas/mpt2sas_ctl.h
index 11ff1d5..b5eb0d1 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.h
@@ -3,7 +3,7 @@
  * controllers
  *
  * This code is based on drivers/scsi/mpt2sas/mpt2_ctl.h
- * Copyright (C) 2007-2010  LSI Corporation
+ * Copyright (C) 2007-2012  LSI Corporation
  *  (mailto:dl-mptfusionli...@lsi.com)
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt2sas/mpt2sas_debug.h 
b/drivers/scsi/mpt2sas/mpt2sas_debug.h
index 9731f8e..69cc7d0 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_debug.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_debug.h
@@ -2,7 +2,7 @@
  * Logging Support for MPT (Message Passing Technology) based controllers
  *
  * This code is based on drivers/scsi/mpt2sas/mpt2_debug.c
- * Copyright (C) 2007-2010  LSI Corporation
+ * Copyright (C) 2007-2012  LSI Corporation
  *  (mailto:dl-mptfusionli...@lsi.com)
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c 
b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 76973e8..0f4f971 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -2,7 +2,7 @@
  * Scsi Host Layer for MPT (Message Passing Technology) based controllers
  *
  * This code is based on drivers/scsi/mpt2sas/mpt2_scsih.c
- * Copyright (C) 2007-2010  LSI Corporation
+ * Copyright (C) 2007-2012  LSI Corporation
  *  (mailto:dl-mptfusionli...@lsi.com)
  *
  * This program is free software; you can redistribute it and/or
diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c 
b/drivers/scsi/mpt2sas/mpt2sas_transport.c
index c6cf20f..8c2ffbe 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_transport.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c
@@ -2,7 +2,7 @@
  * SAS Transport Layer for MPT (Message Passing Technology) based controllers
  *
  * This code is based on drivers/scsi/mpt2sas/mpt2_transport.c
- * Copyright (C) 2007-2010  LSI Corporation
+ * Copyright (C) 2007-2012  LSI Corporation
  *  (mailto:dl-mptfusionli...@lsi.com)
  *
  * This program is free software; you can redistribute it and/or
--
To unsubscribe from thi

[PATCH] [scsi] mpt2sas: Description Patch

2012-07-17 Thread sreekanth.reddy
Please consider this patch set for next kernel release.

Signed-off-by: Sreekanth Reddy 
---

[PATCH 01/09] [SCSI] mpt2sas : 2012 source code copyright.
[PATCH 02/09] [SCSI] mpt2sas : To include more Intel Branding.
[PATCH 03/09] [SCSI] mpt2sas : Fix for Driver oops, when loading driver with 
max_queue_depth command line option to a very small value.
[PATCH 04/09] [SCSI] mpt2sas : Provide sysfs attribute to report Backup Rail 
Monitor Status.
[PATCH 05/09] [SCSI] mpt2sas : Fix for max_sectors warning message is stating 
the incorrect range.
[PATCH 06/09] [SCSI] mpt2sas : MPI next revision header update.
[PATCH 07/09] [SCSI] mpt2sas : Fix for staged device discovery functionality of 
driver not working.
[PATCH 08/09] [SCSI] mpt2sas : Fix for With post diag reset same set of device 
gets added, removed and then again gets added with new target ids. 
[PATCH 09/09] [SCSI] mpt2sas : Bump driver vesion to 14.100.00.00.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html