2 * Scsi Host Layer for MPT (Message Passing Technology) based controllers
4 * Copyright (C) 2012-2014 LSI Corporation
5 * Copyright (C) 2013-2015 Avago Technologies
6 * (mailto: MPT-FusionLinux.pdl@avagotech.com)
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.
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.
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.
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
38 * You should have received a copy of the GNU General Public License
39 * along with this program.
42 #include <linux/module.h>
43 #include <linux/pci.h>
44 #include <linux/raid_class.h>
46 #include "mpt3sas_base.h"
47 #include "mpt3sas_ctl.h"
49 MODULE_AUTHOR(MPT3SAS_AUTHOR
);
50 MODULE_DESCRIPTION(MPT3SAS_DESCRIPTION
);
51 MODULE_LICENSE("GPL");
52 MODULE_VERSION(MPT3SAS_DRIVER_VERSION
);
55 static struct scsi_host_template mpt3sas_driver_template
= {
56 .module
= THIS_MODULE
,
57 .name
= "Fusion MPT SAS Host",
58 .proc_name
= MPT3SAS_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
,
75 .sg_tablesize
= MPT3SAS_SG_DEPTH
,
78 .use_clustering
= ENABLE_CLUSTERING
,
79 .shost_attrs
= mpt3sas_host_attrs
,
80 .sdev_attrs
= mpt3sas_dev_attrs
,
81 .track_queue_depth
= 1,
84 /* raid transport support */
85 static struct raid_function_template mpt3sas_raid_functions
= {
86 .cookie
= &mpt3sas_driver_template
,
87 .is_raid
= scsih_is_raid
,
88 .get_resync
= scsih_get_resync
,
89 .get_state
= scsih_get_state
,
93 * The pci device ids are defined in mpi/mpi2_cnfg.h.
95 static const struct pci_device_id mpt3sas_pci_table
[] = {
96 { MPI2_MFGPAGE_VENDORID_LSI
, MPI25_MFGPAGE_DEVID_SAS3004
,
97 PCI_ANY_ID
, PCI_ANY_ID
},
98 { MPI2_MFGPAGE_VENDORID_LSI
, MPI25_MFGPAGE_DEVID_SAS3008
,
99 PCI_ANY_ID
, PCI_ANY_ID
},
101 { MPI2_MFGPAGE_VENDORID_LSI
, MPI25_MFGPAGE_DEVID_SAS3108_1
,
102 PCI_ANY_ID
, PCI_ANY_ID
},
103 { MPI2_MFGPAGE_VENDORID_LSI
, MPI25_MFGPAGE_DEVID_SAS3108_2
,
104 PCI_ANY_ID
, PCI_ANY_ID
},
105 { MPI2_MFGPAGE_VENDORID_LSI
, MPI25_MFGPAGE_DEVID_SAS3108_5
,
106 PCI_ANY_ID
, PCI_ANY_ID
},
107 { MPI2_MFGPAGE_VENDORID_LSI
, MPI25_MFGPAGE_DEVID_SAS3108_6
,
108 PCI_ANY_ID
, PCI_ANY_ID
},
109 {0} /* Terminating entry */
111 MODULE_DEVICE_TABLE(pci
, mpt3sas_pci_table
);
113 static const struct file_operations mpt3sas_ctl_fops
= {
114 .owner
= THIS_MODULE
,
115 .unlocked_ioctl
= ctl_ioctl
,
117 .fasync
= ctl_fasync
,
119 .compat_ioctl
= ctl_ioctl_compat
,
123 static struct miscdevice mpt3sas_ctl_dev
= {
124 .minor
= MPT3SAS_MINOR
,
125 .name
= MPT3SAS_DEV_NAME
,
126 .fops
= &mpt3sas_ctl_fops
,
130 * mpt3sas_ctl_init - main entry point for ctl.
134 mpt3sas_ctl_init(void)
137 if (misc_register(&mpt3sas_ctl_dev
) < 0)
138 pr_err("%s can't register misc device [minor=%d]\n",
139 MPT3SAS_DRIVER_NAME
, MPT3SAS_MINOR
);
143 * mpt3sas_ctl_exit - exit point for ctl
147 mpt3sas_ctl_exit(void)
150 misc_deregister(&mpt3sas_ctl_dev
);
154 * _mpt3sas_probe - attach and add scsi host
155 * @pdev: PCI device struct
158 * Returns 0 success, anything else error.
161 _mpt3sas_probe(struct pci_dev
*pdev
, const struct pci_device_id
*id
)
163 struct Scsi_Host
*shost
;
166 shost
= scsi_host_alloc(&mpt3sas_driver_template
,
167 sizeof(struct MPT3SAS_ADAPTER
));
171 rv
= scsih_probe(pdev
, shost
);
175 static struct pci_error_handlers _mpt3sas_err_handler
= {
176 .error_detected
= scsih_pci_error_detected
,
177 .mmio_enabled
= scsih_pci_mmio_enabled
,
178 .slot_reset
= scsih_pci_slot_reset
,
179 .resume
= scsih_pci_resume
,
182 static struct pci_driver mpt3sas_driver
= {
183 .name
= MPT3SAS_DRIVER_NAME
,
184 .id_table
= mpt3sas_pci_table
,
185 .probe
= _mpt3sas_probe
,
186 .remove
= scsih_remove
,
187 .shutdown
= scsih_shutdown
,
188 .err_handler
= &_mpt3sas_err_handler
,
190 .suspend
= scsih_suspend
,
191 .resume
= scsih_resume
,
196 * _mpt3sas_init - main entry point for this driver.
198 * Returns 0 success, anything else error.
205 pr_info("%s version %s loaded\n", MPT3SAS_DRIVER_NAME
,
206 MPT3SAS_DRIVER_VERSION
);
208 mpt3sas_transport_template
=
209 sas_attach_transport(&mpt3sas_transport_functions
);
210 if (!mpt3sas_transport_template
)
213 mpt3sas_raid_template
= raid_class_attach(&mpt3sas_raid_functions
);
214 if (!mpt3sas_raid_template
) {
215 sas_release_transport(mpt3sas_transport_template
);
219 error
= scsih_init();
227 error
= pci_register_driver(&mpt3sas_driver
);
235 * _mpt3sas_exit - exit point for this driver (when it is a module).
241 pr_info("mpt3sas version %s unloading\n",
242 MPT3SAS_DRIVER_VERSION
);
244 pci_unregister_driver(&mpt3sas_driver
);
251 module_init(_mpt3sas_init
);
252 module_exit(_mpt3sas_exit
);