aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSreekanth Reddy <sreekanth.reddy@avagotech.com>2015-11-11 07:00:20 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2015-11-11 18:22:27 -0500
commit78f97c8f612d0e7d7d08d741549e89e8c951920a (patch)
tree4a00edc5aa64bfb13a8c99e4da64ff9395db6d62
parent7497392a1193ea5b32d8a8a2b8d77888e7fe8221 (diff)
mpt2sas: Move Gen2 HBA's device registration to a separate file
1. Create a mpt2sas_module.c file for mpt2sas where GEN2 HBA devices register with PCI, SML, IOCTL subsystems. 2. Updated the Makefile to use the object files from mpt3sas folder. 3. Defined a compilation 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> Acked-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/mpt2sas/Makefile14
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_module.c280
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_ctl.h5
3 files changed, 293 insertions, 6 deletions
diff --git a/drivers/scsi/mpt2sas/Makefile b/drivers/scsi/mpt2sas/Makefile
index 2ac2fc30a00d..37716169b91a 100644
--- a/drivers/scsi/mpt2sas/Makefile
+++ b/drivers/scsi/mpt2sas/Makefile
@@ -2,10 +2,14 @@
2 2
3# share the official mpi headers from the mpt3sas driver 3# share the official mpi headers from the mpt3sas driver
4ccflags-y += -I$(src)/../mpt3sas 4ccflags-y += -I$(src)/../mpt3sas
5ccflags-y += -DSCSI_MPT2SAS
5 6
7# use the common object files from mpt3sas driver
6obj-$(CONFIG_SCSI_MPT2SAS) += mpt2sas.o 8obj-$(CONFIG_SCSI_MPT2SAS) += mpt2sas.o
7mpt2sas-y += mpt2sas_base.o \ 9mpt2sas-y += ../mpt3sas/mpt3sas_base.o \
8 mpt2sas_config.o \ 10 ../mpt3sas/mpt3sas_config.o \
9 mpt2sas_scsih.o \ 11 ../mpt3sas/mpt3sas_scsih.o \
10 mpt2sas_transport.o \ 12 ../mpt3sas/mpt3sas_transport.o \
11 mpt2sas_ctl.o 13 ../mpt3sas/mpt3sas_ctl.o \
14 ../mpt3sas/mpt3sas_trigger_diag.o \
15 mpt2sas_module.o
diff --git a/drivers/scsi/mpt2sas/mpt2sas_module.c b/drivers/scsi/mpt2sas/mpt2sas_module.c
new file mode 100644
index 000000000000..2b7069329612
--- /dev/null
+++ b/drivers/scsi/mpt2sas/mpt2sas_module.c
@@ -0,0 +1,280 @@
1/*
2 * Scsi Host Layer for MPT (Message Passing Technology) based controllers
3 *
4 * Copyright (C) 2012-2014 LSI Corporation
5 * Copyright (C) 2013-2015 Avago Technologies
6 * (mailto: MPT-FusionLinux.pdl@avagotech.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * NO WARRANTY
19 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
20 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
21 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
22 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
23 * solely responsible for determining the appropriateness of using and
24 * distributing the Program and assumes all risks associated with its
25 * exercise of rights under this Agreement, including but not limited to
26 * the risks and costs of program errors, damage to or loss of data,
27 * programs or equipment, and unavailability or interruption of operations.
28
29 * DISCLAIMER OF LIABILITY
30 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
31 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
33 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
35 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
36 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
37
38 * You should have received a copy of the GNU General Public License
39 * along with this program.
40 */
41
42#include <linux/module.h>
43#include <linux/pci.h>
44#include <linux/raid_class.h>
45
46#include "mpt3sas_base.h"
47#include "mpt3sas_ctl.h"
48
49MODULE_AUTHOR(MPT3SAS_AUTHOR);
50MODULE_DESCRIPTION(MPT2SAS_DESCRIPTION);
51MODULE_LICENSE("GPL");
52MODULE_VERSION(MPT2SAS_DRIVER_VERSION);
53
54/* shost template */
55static struct scsi_host_template mpt2sas_driver_template = {
56 .module = THIS_MODULE,
57 .name = "Fusion MPT SAS Host",
58 .proc_name = MPT2SAS_DRIVER_NAME,
59 .queuecommand = scsih_qcmd,
60 .target_alloc = scsih_target_alloc,
61 .slave_alloc = scsih_slave_alloc,
62 .slave_configure = scsih_slave_configure,
63 .target_destroy = scsih_target_destroy,
64 .slave_destroy = scsih_slave_destroy,
65 .scan_finished = scsih_scan_finished,
66 .scan_start = scsih_scan_start,
67 .change_queue_depth = scsih_change_queue_depth,
68 .eh_abort_handler = scsih_abort,
69 .eh_device_reset_handler = scsih_dev_reset,
70 .eh_target_reset_handler = scsih_target_reset,
71 .eh_host_reset_handler = scsih_host_reset,
72 .bios_param = scsih_bios_param,
73 .can_queue = 1,
74 .this_id = -1,
75 .sg_tablesize = MPT2SAS_SG_DEPTH,
76 .max_sectors = 32767,
77 .cmd_per_lun = 7,
78 .use_clustering = ENABLE_CLUSTERING,
79 .shost_attrs = mpt3sas_host_attrs,
80 .sdev_attrs = mpt3sas_dev_attrs,
81 .track_queue_depth = 1,
82};
83
84/* raid transport support */
85static struct raid_function_template mpt2sas_raid_functions = {
86 .cookie = &mpt2sas_driver_template,
87 .is_raid = scsih_is_raid,
88 .get_resync = scsih_get_resync,
89 .get_state = scsih_get_state,
90};
91
92/*
93 * The pci device ids are defined in mpi/mpi2_cnfg.h.
94 */
95static const struct pci_device_id mpt2sas_pci_table[] = {
96 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2004,
97 PCI_ANY_ID, PCI_ANY_ID },
98 /* Falcon ~ 2008*/
99 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2008,
100 PCI_ANY_ID, PCI_ANY_ID },
101 /* Liberator ~ 2108 */
102 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_1,
103 PCI_ANY_ID, PCI_ANY_ID },
104 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_2,
105 PCI_ANY_ID, PCI_ANY_ID },
106 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2108_3,
107 PCI_ANY_ID, PCI_ANY_ID },
108 /* Meteor ~ 2116 */
109 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2116_1,
110 PCI_ANY_ID, PCI_ANY_ID },
111 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2116_2,
112 PCI_ANY_ID, PCI_ANY_ID },
113 /* Thunderbolt ~ 2208 */
114 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_1,
115 PCI_ANY_ID, PCI_ANY_ID },
116 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_2,
117 PCI_ANY_ID, PCI_ANY_ID },
118 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_3,
119 PCI_ANY_ID, PCI_ANY_ID },
120 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_4,
121 PCI_ANY_ID, PCI_ANY_ID },
122 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_5,
123 PCI_ANY_ID, PCI_ANY_ID },
124 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2208_6,
125 PCI_ANY_ID, PCI_ANY_ID },
126 /* Mustang ~ 2308 */
127 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_1,
128 PCI_ANY_ID, PCI_ANY_ID },
129 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_2,
130 PCI_ANY_ID, PCI_ANY_ID },
131 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SAS2308_3,
132 PCI_ANY_ID, PCI_ANY_ID },
133 /* SSS6200 */
134 { MPI2_MFGPAGE_VENDORID_LSI, MPI2_MFGPAGE_DEVID_SSS6200,
135 PCI_ANY_ID, PCI_ANY_ID },
136 {0} /* Terminating entry */
137};
138MODULE_DEVICE_TABLE(pci, mpt2sas_pci_table);
139
140static const struct file_operations mpt2sas_ctl_fops = {
141 .owner = THIS_MODULE,
142 .unlocked_ioctl = ctl_ioctl,
143 .poll = ctl_poll,
144 .fasync = ctl_fasync,
145#ifdef CONFIG_COMPAT
146 .compat_ioctl = ctl_ioctl_compat,
147#endif
148 .llseek = noop_llseek,
149};
150
151static struct miscdevice mpt2sas_ctl_dev = {
152 .minor = MPT2SAS_MINOR,
153 .name = MPT2SAS_DEV_NAME,
154 .fops = &mpt2sas_ctl_fops,
155};
156
157/**
158 * mpt2sas_ctl_init - main entry point for ctl.
159 *
160 */
161void
162mpt2sas_ctl_init(void)
163{
164 ctl_init();
165 if (misc_register(&mpt2sas_ctl_dev) < 0)
166 pr_err("%s can't register misc device [minor=%d]\n",
167 MPT2SAS_DRIVER_NAME, MPT2SAS_MINOR);
168}
169
170/**
171 * mpt2sas_ctl_exit - exit point for ctl
172 *
173 */
174void
175mpt2sas_ctl_exit(void)
176{
177 ctl_exit();
178 misc_deregister(&mpt2sas_ctl_dev);
179}
180
181/**
182 * _mpt2sas_probe - attach and add scsi host
183 * @pdev: PCI device struct
184 * @id: pci device id
185 *
186 * Returns 0 success, anything else error.
187 */
188static int
189_mpt2sas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
190{
191 struct Scsi_Host *shost;
192 int rv;
193
194 shost = scsi_host_alloc(&mpt2sas_driver_template,
195 sizeof(struct MPT3SAS_ADAPTER));
196 if (!shost)
197 return -ENODEV;
198
199 rv = scsih_probe(pdev, shost);
200 return rv;
201}
202
203static struct pci_error_handlers _mpt2sas_err_handler = {
204 .error_detected = scsih_pci_error_detected,
205 .mmio_enabled = scsih_pci_mmio_enabled,
206 .slot_reset = scsih_pci_slot_reset,
207 .resume = scsih_pci_resume,
208};
209
210static struct pci_driver mpt2sas_driver = {
211 .name = MPT2SAS_DRIVER_NAME,
212 .id_table = mpt2sas_pci_table,
213 .probe = _mpt2sas_probe,
214 .remove = scsih_remove,
215 .shutdown = scsih_shutdown,
216 .err_handler = &_mpt2sas_err_handler,
217#ifdef CONFIG_PM
218 .suspend = scsih_suspend,
219 .resume = scsih_resume,
220#endif
221};
222
223/**
224 * _mpt2sas_init - main entry point for this driver.
225 *
226 * Returns 0 success, anything else error.
227 */
228static int __init
229_mpt2sas_init(void)
230{
231 int error;
232
233 pr_info("%s version %s loaded\n", MPT2SAS_DRIVER_NAME,
234 MPT2SAS_DRIVER_VERSION);
235
236 mpt3sas_transport_template =
237 sas_attach_transport(&mpt3sas_transport_functions);
238 if (!mpt3sas_transport_template)
239 return -ENODEV;
240
241 mpt3sas_raid_template = raid_class_attach(&mpt2sas_raid_functions);
242 if (!mpt3sas_raid_template) {
243 sas_release_transport(mpt3sas_transport_template);
244 return -ENODEV;
245 }
246
247 error = scsih_init();
248 if (error) {
249 scsih_exit();
250 return error;
251 }
252
253 mpt2sas_ctl_init();
254
255 error = pci_register_driver(&mpt2sas_driver);
256 if (error)
257 scsih_exit();
258
259 return error;
260}
261
262/**
263 * _mpt2sas_exit - exit point for this driver (when it is a module).
264 *
265 */
266static void __exit
267_mpt2sas_exit(void)
268{
269 pr_info("mpt2sas version %s unloading\n",
270 MPT2SAS_DRIVER_VERSION);
271
272 pci_unregister_driver(&mpt2sas_driver);
273
274 mpt2sas_ctl_exit();
275
276 scsih_exit();
277}
278
279module_init(_mpt2sas_init);
280module_exit(_mpt2sas_exit);
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.h b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
index aee99ce67e54..f43e3c2c3353 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
@@ -50,10 +50,13 @@
50#include <linux/miscdevice.h> 50#include <linux/miscdevice.h>
51#endif 51#endif
52 52
53 53#ifndef MPT2SAS_MINOR
54#define MPT2SAS_MINOR (MPT_MINOR + 1)
55#endif
54#ifndef MPT3SAS_MINOR 56#ifndef MPT3SAS_MINOR
55#define MPT3SAS_MINOR (MPT_MINOR + 2) 57#define MPT3SAS_MINOR (MPT_MINOR + 2)
56#endif 58#endif
59#define MPT2SAS_DEV_NAME "mpt2ctl"
57#define MPT3SAS_DEV_NAME "mpt3ctl" 60#define MPT3SAS_DEV_NAME "mpt3ctl"
58#define MPT3_MAGIC_NUMBER 'L' 61#define MPT3_MAGIC_NUMBER 'L'
59#define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */ 62#define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */