From: Sreekanth Reddy <sreekanth.reddy@avagotech.com>
To: jejb@kernel.org, hch@infradead.org
Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
JBottomley@Parallels.com, Sathya.Prakash@avagotech.com,
chaitra.basappa@avagotech.com,
suganath-prabu.subramani@avagotech.com,
linux-kernel@vger.kernel.org,
Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Subject: [PATCH 04/18] mpt2sas: Created mpt2sas_module.c file in which Gen2 HBA's are registers with PCI, SML and IOCTLs
Date: Wed, 30 Sep 2015 21:17:04 +0530 [thread overview]
Message-ID: <1443628038-13552-5-git-send-email-Sreekanth.Reddy@avagotech.com> (raw)
In-Reply-To: <1443628038-13552-1-git-send-email-Sreekanth.Reddy@avagotech.com>
1. Create a mpt2sas_module.c file for mpt2sas driver module
where GEN2 HBA devices registers with PCI, SML, IOCTL subsytems.
2. Updated the Makefile to use the object files from mpt3sas folder
3. Defined a compilation defination flag SCSI_MPT2SAS which can be used to
not include those sections of code from mpt3sas driver which are not
required for mpt2sas driver.
4. Inherited Automatic diag buffer feature from mpt3sas driver.
Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
---
drivers/scsi/mpt2sas/Makefile | 14 +-
drivers/scsi/mpt2sas/mpt2sas_module.c | 280 ++++++++++++++++++++++++++++++++++
drivers/scsi/mpt3sas/mpt3sas_ctl.h | 5 +-
3 files changed, 293 insertions(+), 6 deletions(-)
create mode 100644 drivers/scsi/mpt2sas/mpt2sas_module.c
diff --git a/drivers/scsi/mpt2sas/Makefile b/drivers/scsi/mpt2sas/Makefile
index 2ac2fc3..3771616 100644
--- a/drivers/scsi/mpt2sas/Makefile
+++ b/drivers/scsi/mpt2sas/Makefile
@@ -2,10 +2,14 @@
# share the official mpi headers from the mpt3sas driver
ccflags-y += -I$(src)/../mpt3sas
+ccflags-y += -DSCSI_MPT2SAS
+# use the common object files from mpt3sas driver
obj-$(CONFIG_SCSI_MPT2SAS) += mpt2sas.o
-mpt2sas-y += mpt2sas_base.o \
- mpt2sas_config.o \
- mpt2sas_scsih.o \
- mpt2sas_transport.o \
- mpt2sas_ctl.o
+mpt2sas-y += ../mpt3sas/mpt3sas_base.o \
+ ../mpt3sas/mpt3sas_config.o \
+ ../mpt3sas/mpt3sas_scsih.o \
+ ../mpt3sas/mpt3sas_transport.o \
+ ../mpt3sas/mpt3sas_ctl.o \
+ ../mpt3sas/mpt3sas_trigger_diag.o \
+ mpt2sas_module.o
diff --git a/drivers/scsi/mpt2sas/mpt2sas_module.c b/drivers/scsi/mpt2sas/mpt2sas_module.c
new file mode 100644
index 0000000..2b70693
--- /dev/null
+++ b/drivers/scsi/mpt2sas/mpt2sas_module.c
@@ -0,0 +1,280 @@
+/*
+ * Scsi Host Layer for MPT (Message Passing Technology) based controllers
+ *
+ * Copyright (C) 2012-2014 LSI Corporation
+ * Copyright (C) 2013-2015 Avago Technologies
+ * (mailto: MPT-FusionLinux.pdl@avagotech.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.
+ */
+
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/raid_class.h>
+
+#include "mpt3sas_base.h"
+#include "mpt3sas_ctl.h"
+
+MODULE_AUTHOR(MPT3SAS_AUTHOR);
+MODULE_DESCRIPTION(MPT2SAS_DESCRIPTION);
+MODULE_LICENSE("GPL");
+MODULE_VERSION(MPT2SAS_DRIVER_VERSION);
+
+/* shost template */
+static struct scsi_host_template mpt2sas_driver_template = {
+ .module = THIS_MODULE,
+ .name = "Fusion MPT SAS Host",
+ .proc_name = MPT2SAS_DRIVER_NAME,
+ .queuecommand = scsih_qcmd,
+ .target_alloc = scsih_target_alloc,
+ .slave_alloc = scsih_slave_alloc,
+ .slave_configure = scsih_slave_configure,
+ .target_destroy = scsih_target_destroy,
+ .slave_destroy = scsih_slave_destroy,
+ .scan_finished = scsih_scan_finished,
+ .scan_start = scsih_scan_start,
+ .change_queue_depth = scsih_change_queue_depth,
+ .eh_abort_handler = scsih_abort,
+ .eh_device_reset_handler = scsih_dev_reset,
+ .eh_target_reset_handler = scsih_target_reset,
+ .eh_host_reset_handler = scsih_host_reset,
+ .bios_param = scsih_bios_param,
+ .can_queue = 1,
+ .this_id = -1,
+ .sg_tablesize = MPT2SAS_SG_DEPTH,
+ .max_sectors = 32767,
+ .cmd_per_lun = 7,
+ .use_clustering = ENABLE_CLUSTERING,
+ .shost_attrs = mpt3sas_host_attrs,
+ .sdev_attrs = mpt3sas_dev_attrs,
+ .track_queue_depth = 1,
+};
+
+/* raid transport support */
+static struct raid_function_template mpt2sas_raid_functions = {
+ .cookie = &mpt2sas_driver_template,
+ .is_raid = scsih_is_raid,
+ .get_resync = scsih_get_resync,
+ .get_state = scsih_get_state,
+};
+
+/*
+ * The pci device ids are defined in mpi/mpi2_cnfg.h.
+ */
+static const struct pci_device_id mpt2sas_pci_table[] = {
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2004,
+ PCI_ANY_ID, PCI_ANY_ID },
+ /* Falcon ~ 2008*/
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2008,
+ PCI_ANY_ID, PCI_ANY_ID },
+ /* Liberator ~ 2108 */
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_1,
+ PCI_ANY_ID, PCI_ANY_ID },
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_2,
+ PCI_ANY_ID, PCI_ANY_ID },
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_3,
+ PCI_ANY_ID, PCI_ANY_ID },
+ /* Meteor ~ 2116 */
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2116_1,
+ PCI_ANY_ID, PCI_ANY_ID },
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2116_2,
+ PCI_ANY_ID, PCI_ANY_ID },
+ /* Thunderbolt ~ 2208 */
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_1,
+ PCI_ANY_ID, PCI_ANY_ID },
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_2,
+ PCI_ANY_ID, PCI_ANY_ID },
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_3,
+ PCI_ANY_ID, PCI_ANY_ID },
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_4,
+ PCI_ANY_ID, PCI_ANY_ID },
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_5,
+ PCI_ANY_ID, PCI_ANY_ID },
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_6,
+ PCI_ANY_ID, PCI_ANY_ID },
+ /* Mustang ~ 2308 */
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_1,
+ PCI_ANY_ID, PCI_ANY_ID },
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_2,
+ PCI_ANY_ID, PCI_ANY_ID },
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_3,
+ PCI_ANY_ID, PCI_ANY_ID },
+ /* SSS6200 */
+ { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SSS6200,
+ PCI_ANY_ID, PCI_ANY_ID },
+ {0} /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(pci, mpt2sas_pci_table);
+
+static const struct file_operations mpt2sas_ctl_fops = {
+ .owner = THIS_MODULE,
+ .unlocked_ioctl = ctl_ioctl,
+ .poll = ctl_poll,
+ .fasync = ctl_fasync,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = ctl_ioctl_compat,
+#endif
+ .llseek = noop_llseek,
+};
+
+static struct miscdevice mpt2sas_ctl_dev = {
+ .minor = MPT2SAS_MINOR,
+ .name = MPT2SAS_DEV_NAME,
+ .fops = &mpt2sas_ctl_fops,
+};
+
+/**
+ * mpt2sas_ctl_init - main entry point for ctl.
+ *
+ */
+void
+mpt2sas_ctl_init(void)
+{
+ ctl_init();
+ if (misc_register(&mpt2sas_ctl_dev) < 0)
+ pr_err("%s can't register misc device [minor=%d]\n",
+ MPT2SAS_DRIVER_NAME, MPT2SAS_MINOR);
+}
+
+/**
+ * mpt2sas_ctl_exit - exit point for ctl
+ *
+ */
+void
+mpt2sas_ctl_exit(void)
+{
+ ctl_exit();
+ misc_deregister(&mpt2sas_ctl_dev);
+}
+
+/**
+ * _mpt2sas_probe - attach and add scsi host
+ * @pdev: PCI device struct
+ * @id: pci device id
+ *
+ * Returns 0 success, anything else error.
+ */
+static int
+_mpt2sas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+ struct Scsi_Host *shost;
+ int rv;
+
+ shost = scsi_host_alloc(&mpt2sas_driver_template,
+ sizeof(struct MPT3SAS_ADAPTER));
+ if (!shost)
+ return -ENODEV;
+
+ rv = scsih_probe(pdev, shost);
+ return rv;
+}
+
+static struct pci_error_handlers _mpt2sas_err_handler = {
+ .error_detected = scsih_pci_error_detected,
+ .mmio_enabled = scsih_pci_mmio_enabled,
+ .slot_reset = scsih_pci_slot_reset,
+ .resume = scsih_pci_resume,
+};
+
+static struct pci_driver mpt2sas_driver = {
+ .name = MPT2SAS_DRIVER_NAME,
+ .id_table = mpt2sas_pci_table,
+ .probe = _mpt2sas_probe,
+ .remove = scsih_remove,
+ .shutdown = scsih_shutdown,
+ .err_handler = &_mpt2sas_err_handler,
+#ifdef CONFIG_PM
+ .suspend = scsih_suspend,
+ .resume = scsih_resume,
+#endif
+};
+
+/**
+ * _mpt2sas_init - main entry point for this driver.
+ *
+ * Returns 0 success, anything else error.
+ */
+static int __init
+_mpt2sas_init(void)
+{
+ int error;
+
+ pr_info("%s version %s loaded\n", MPT2SAS_DRIVER_NAME,
+ MPT2SAS_DRIVER_VERSION);
+
+ mpt3sas_transport_template =
+ sas_attach_transport(&mpt3sas_transport_functions);
+ if (!mpt3sas_transport_template)
+ return -ENODEV;
+
+ mpt3sas_raid_template = raid_class_attach(&mpt2sas_raid_functions);
+ if (!mpt3sas_raid_template) {
+ sas_release_transport(mpt3sas_transport_template);
+ return -ENODEV;
+ }
+
+ error = scsih_init();
+ if (error) {
+ scsih_exit();
+ return error;
+ }
+
+ mpt2sas_ctl_init();
+
+ error = pci_register_driver(&mpt2sas_driver);
+ if (error)
+ scsih_exit();
+
+ return error;
+}
+
+/**
+ * _mpt2sas_exit - exit point for this driver (when it is a module).
+ *
+ */
+static void __exit
+_mpt2sas_exit(void)
+{
+ pr_info("mpt2sas version %s unloading\n",
+ MPT2SAS_DRIVER_VERSION);
+
+ pci_unregister_driver(&mpt2sas_driver);
+
+ mpt2sas_ctl_exit();
+
+ scsih_exit();
+}
+
+module_init(_mpt2sas_init);
+module_exit(_mpt2sas_exit);
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.h b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
index aee99ce..f43e3c2 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
@@ -50,10 +50,13 @@
#include <linux/miscdevice.h>
#endif
-
+#ifndef MPT2SAS_MINOR
+#define MPT2SAS_MINOR (MPT_MINOR + 1)
+#endif
#ifndef MPT3SAS_MINOR
#define MPT3SAS_MINOR (MPT_MINOR + 2)
#endif
+#define MPT2SAS_DEV_NAME "mpt2ctl"
#define MPT3SAS_DEV_NAME "mpt3ctl"
#define MPT3_MAGIC_NUMBER 'L'
#define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
--
2.0.2
next prev parent reply other threads:[~2015-09-30 15:48 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-30 15:47 [PATCH 00/18] mpt2sas, mpt3sas: Combine mpt2sas and mpt3sas driver code base Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 01/18] mpt2sas: Use mpi headers from mpt3sas Sreekanth Reddy
2015-10-04 7:51 ` Christoph Hellwig
2015-09-30 15:47 ` [PATCH 02/18] mpt3sas : Added mpt2sas driver definitions Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 03/18] mpt3sas: Move Gen3 HBA's device registration with PCI, SML and IOCTL related API's to a separate file Sreekanth Reddy
2015-09-30 15:47 ` Sreekanth Reddy [this message]
2015-09-30 15:47 ` [PATCH 06/18] mpt3sas: Define 'hba_mpi_version_belonged' IOC variable Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 07/18] mpt2sas, mpt3sas : Removed SCSI_MPTXSAS_LOGGING entry from Kconfig Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 08/18] mpt3sas: For an IO, build MPI SGL LIST on GEN2 HBA's and build IEEE SGL LIST on GEN3 HBA's Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 09/18] mpt3as: Don't send PHYDISK_HIDDEN Raid Action request on SAS2 HBA's Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 10/18] mpt3sas: Manage MSIX vectors according to HBA device type Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 11/18] mpt3sas: fix for driver fails EEH, recovery from injected pci bus error Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 12/18] mpt3sas : Ported WarpDrive product SSS6200 support Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 13/18] mpt3sas: Ported the providing sysfs attribute to report Backup Rail Monitor Status Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 14/18] mpt3sas: Refcount sas_device objects and fix unsafe list usage Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 15/18] mpt3sas: Refcount fw_events " Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 16/18] mpt3sas: Added OEMs Gen2 PnP ID Branding names Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 17/18] mpt3sas: setpci reset kernel oops fix Sreekanth Reddy
2015-09-30 15:47 ` [PATCH 18/18] mpt2sas, mpt3sas: Update the driver versions Sreekanth Reddy
2015-10-06 9:46 ` [PATCH 00/18] mpt2sas, mpt3sas: Combine mpt2sas and mpt3sas driver code base Christoph Hellwig
2015-10-06 10:29 ` Sreekanth Reddy
2015-10-06 17:13 ` James Bottomley
2015-10-07 9:18 ` Sreekanth Reddy
2015-10-08 14:00 ` Sreekanth Reddy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443628038-13552-5-git-send-email-Sreekanth.Reddy@avagotech.com \
--to=sreekanth.reddy@avagotech.com \
--cc=JBottomley@Parallels.com \
--cc=Sathya.Prakash@avagotech.com \
--cc=chaitra.basappa@avagotech.com \
--cc=hch@infradead.org \
--cc=jejb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=suganath-prabu.subramani@avagotech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®