12496af39SMoore, Eric Dean /* 22496af39SMoore, Eric Dean * linux/drivers/message/fusion/mptfc.c 32496af39SMoore, Eric Dean * For use with LSI Logic PCI chip/adapter(s) 42496af39SMoore, Eric Dean * running LSI Logic Fusion MPT (Message Passing Technology) firmware. 52496af39SMoore, Eric Dean * 62496af39SMoore, Eric Dean * Copyright (c) 1999-2005 LSI Logic Corporation 72496af39SMoore, Eric Dean * (mailto:mpt_linux_developer@lsil.com) 82496af39SMoore, Eric Dean * 92496af39SMoore, Eric Dean */ 102496af39SMoore, Eric Dean /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 112496af39SMoore, Eric Dean /* 122496af39SMoore, Eric Dean This program is free software; you can redistribute it and/or modify 132496af39SMoore, Eric Dean it under the terms of the GNU General Public License as published by 142496af39SMoore, Eric Dean the Free Software Foundation; version 2 of the License. 152496af39SMoore, Eric Dean 162496af39SMoore, Eric Dean This program is distributed in the hope that it will be useful, 172496af39SMoore, Eric Dean but WITHOUT ANY WARRANTY; without even the implied warranty of 182496af39SMoore, Eric Dean MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 192496af39SMoore, Eric Dean GNU General Public License for more details. 202496af39SMoore, Eric Dean 212496af39SMoore, Eric Dean NO WARRANTY 222496af39SMoore, Eric Dean THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR 232496af39SMoore, Eric Dean CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT 242496af39SMoore, Eric Dean LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 252496af39SMoore, Eric Dean MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is 262496af39SMoore, Eric Dean solely responsible for determining the appropriateness of using and 272496af39SMoore, Eric Dean distributing the Program and assumes all risks associated with its 282496af39SMoore, Eric Dean exercise of rights under this Agreement, including but not limited to 292496af39SMoore, Eric Dean the risks and costs of program errors, damage to or loss of data, 302496af39SMoore, Eric Dean programs or equipment, and unavailability or interruption of operations. 312496af39SMoore, Eric Dean 322496af39SMoore, Eric Dean DISCLAIMER OF LIABILITY 332496af39SMoore, Eric Dean NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY 342496af39SMoore, Eric Dean DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 352496af39SMoore, Eric Dean DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND 362496af39SMoore, Eric Dean ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 372496af39SMoore, Eric Dean TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 382496af39SMoore, Eric Dean USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 392496af39SMoore, Eric Dean HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 402496af39SMoore, Eric Dean 412496af39SMoore, Eric Dean You should have received a copy of the GNU General Public License 422496af39SMoore, Eric Dean along with this program; if not, write to the Free Software 432496af39SMoore, Eric Dean Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 442496af39SMoore, Eric Dean */ 452496af39SMoore, Eric Dean /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 462496af39SMoore, Eric Dean #include "linux_compat.h" /* linux-2.6 tweaks */ 472496af39SMoore, Eric Dean #include <linux/module.h> 482496af39SMoore, Eric Dean #include <linux/kernel.h> 492496af39SMoore, Eric Dean #include <linux/init.h> 502496af39SMoore, Eric Dean #include <linux/errno.h> 512496af39SMoore, Eric Dean #include <linux/kdev_t.h> 522496af39SMoore, Eric Dean #include <linux/blkdev.h> 532496af39SMoore, Eric Dean #include <linux/delay.h> /* for mdelay */ 542496af39SMoore, Eric Dean #include <linux/interrupt.h> /* needed for in_interrupt() proto */ 552496af39SMoore, Eric Dean #include <linux/reboot.h> /* notifier code */ 562496af39SMoore, Eric Dean #include <linux/sched.h> 572496af39SMoore, Eric Dean #include <linux/workqueue.h> 5805e8ec17SMichael Reed #include <linux/sort.h> 592496af39SMoore, Eric Dean 602496af39SMoore, Eric Dean #include <scsi/scsi.h> 612496af39SMoore, Eric Dean #include <scsi/scsi_cmnd.h> 622496af39SMoore, Eric Dean #include <scsi/scsi_device.h> 632496af39SMoore, Eric Dean #include <scsi/scsi_host.h> 642496af39SMoore, Eric Dean #include <scsi/scsi_tcq.h> 6505e8ec17SMichael Reed #include <scsi/scsi_transport_fc.h> 662496af39SMoore, Eric Dean 672496af39SMoore, Eric Dean #include "mptbase.h" 682496af39SMoore, Eric Dean #include "mptscsih.h" 692496af39SMoore, Eric Dean 702496af39SMoore, Eric Dean /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 712496af39SMoore, Eric Dean #define my_NAME "Fusion MPT FC Host driver" 722496af39SMoore, Eric Dean #define my_VERSION MPT_LINUX_VERSION_COMMON 732496af39SMoore, Eric Dean #define MYNAM "mptfc" 742496af39SMoore, Eric Dean 752496af39SMoore, Eric Dean MODULE_AUTHOR(MODULEAUTHOR); 762496af39SMoore, Eric Dean MODULE_DESCRIPTION(my_NAME); 772496af39SMoore, Eric Dean MODULE_LICENSE("GPL"); 782496af39SMoore, Eric Dean 792496af39SMoore, Eric Dean /* Command line args */ 802496af39SMoore, Eric Dean static int mpt_pq_filter = 0; 812496af39SMoore, Eric Dean module_param(mpt_pq_filter, int, 0); 822496af39SMoore, Eric Dean MODULE_PARM_DESC(mpt_pq_filter, " Enable peripheral qualifier filter: enable=1 (default=0)"); 832496af39SMoore, Eric Dean 8405e8ec17SMichael Reed #define MPTFC_DEV_LOSS_TMO (60) 8505e8ec17SMichael Reed static int mptfc_dev_loss_tmo = MPTFC_DEV_LOSS_TMO; /* reasonable default */ 8605e8ec17SMichael Reed module_param(mptfc_dev_loss_tmo, int, 0); 8705e8ec17SMichael Reed MODULE_PARM_DESC(mptfc_dev_loss_tmo, " Initial time the driver programs the " 8805e8ec17SMichael Reed " transport to wait for an rport to " 8905e8ec17SMichael Reed " return following a device loss event." 9005e8ec17SMichael Reed " Default=60."); 9105e8ec17SMichael Reed 922496af39SMoore, Eric Dean static int mptfcDoneCtx = -1; 932496af39SMoore, Eric Dean static int mptfcTaskCtx = -1; 942496af39SMoore, Eric Dean static int mptfcInternalCtx = -1; /* Used only for internal commands */ 952496af39SMoore, Eric Dean 963bc7bf1dSMichael Reed static int mptfc_target_alloc(struct scsi_target *starget); 973bc7bf1dSMichael Reed static int mptfc_slave_alloc(struct scsi_device *sdev); 9805e8ec17SMichael Reed static int mptfc_qcmd(struct scsi_cmnd *SCpnt, 9905e8ec17SMichael Reed void (*done)(struct scsi_cmnd *)); 1003bc7bf1dSMichael Reed static void mptfc_target_destroy(struct scsi_target *starget); 10105e8ec17SMichael Reed static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout); 10205e8ec17SMichael Reed static void __devexit mptfc_remove(struct pci_dev *pdev); 10305e8ec17SMichael Reed 1042496af39SMoore, Eric Dean static struct scsi_host_template mptfc_driver_template = { 105f78496daSMoore, Eric Dean .module = THIS_MODULE, 1062496af39SMoore, Eric Dean .proc_name = "mptfc", 1072496af39SMoore, Eric Dean .proc_info = mptscsih_proc_info, 1082496af39SMoore, Eric Dean .name = "MPT FC Host", 1092496af39SMoore, Eric Dean .info = mptscsih_info, 11005e8ec17SMichael Reed .queuecommand = mptfc_qcmd, 1113bc7bf1dSMichael Reed .target_alloc = mptfc_target_alloc, 11205e8ec17SMichael Reed .slave_alloc = mptfc_slave_alloc, 1132496af39SMoore, Eric Dean .slave_configure = mptscsih_slave_configure, 1143bc7bf1dSMichael Reed .target_destroy = mptfc_target_destroy, 1152496af39SMoore, Eric Dean .slave_destroy = mptscsih_slave_destroy, 1166e3815baSMoore, Eric Dean .change_queue_depth = mptscsih_change_queue_depth, 1172496af39SMoore, Eric Dean .eh_abort_handler = mptscsih_abort, 1182496af39SMoore, Eric Dean .eh_device_reset_handler = mptscsih_dev_reset, 1192496af39SMoore, Eric Dean .eh_bus_reset_handler = mptscsih_bus_reset, 1202496af39SMoore, Eric Dean .eh_host_reset_handler = mptscsih_host_reset, 1212496af39SMoore, Eric Dean .bios_param = mptscsih_bios_param, 1222496af39SMoore, Eric Dean .can_queue = MPT_FC_CAN_QUEUE, 1232496af39SMoore, Eric Dean .this_id = -1, 1242496af39SMoore, Eric Dean .sg_tablesize = MPT_SCSI_SG_DEPTH, 1252496af39SMoore, Eric Dean .max_sectors = 8192, 1262496af39SMoore, Eric Dean .cmd_per_lun = 7, 1272496af39SMoore, Eric Dean .use_clustering = ENABLE_CLUSTERING, 1282496af39SMoore, Eric Dean }; 1292496af39SMoore, Eric Dean 1302496af39SMoore, Eric Dean /**************************************************************************** 1312496af39SMoore, Eric Dean * Supported hardware 1322496af39SMoore, Eric Dean */ 1332496af39SMoore, Eric Dean 1342496af39SMoore, Eric Dean static struct pci_device_id mptfc_pci_table[] = { 1352496af39SMoore, Eric Dean { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC909, 1362496af39SMoore, Eric Dean PCI_ANY_ID, PCI_ANY_ID }, 1372496af39SMoore, Eric Dean { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC919, 1382496af39SMoore, Eric Dean PCI_ANY_ID, PCI_ANY_ID }, 1392496af39SMoore, Eric Dean { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC929, 1402496af39SMoore, Eric Dean PCI_ANY_ID, PCI_ANY_ID }, 1412496af39SMoore, Eric Dean { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC919X, 1422496af39SMoore, Eric Dean PCI_ANY_ID, PCI_ANY_ID }, 1432496af39SMoore, Eric Dean { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC929X, 1442496af39SMoore, Eric Dean PCI_ANY_ID, PCI_ANY_ID }, 1453fadc59dSMoore, Eric Dean { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC939X, 1463fadc59dSMoore, Eric Dean PCI_ANY_ID, PCI_ANY_ID }, 1473fadc59dSMoore, Eric Dean { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC949X, 1483fadc59dSMoore, Eric Dean PCI_ANY_ID, PCI_ANY_ID }, 1496d5b0c31SMoore, Eric { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FC949ES, 1506d5b0c31SMoore, Eric PCI_ANY_ID, PCI_ANY_ID }, 1512496af39SMoore, Eric Dean {0} /* Terminating entry */ 1522496af39SMoore, Eric Dean }; 1532496af39SMoore, Eric Dean MODULE_DEVICE_TABLE(pci, mptfc_pci_table); 1542496af39SMoore, Eric Dean 15505e8ec17SMichael Reed static struct scsi_transport_template *mptfc_transport_template = NULL; 15605e8ec17SMichael Reed 15703fbcbcdSAdrian Bunk static struct fc_function_template mptfc_transport_functions = { 15805e8ec17SMichael Reed .dd_fcrport_size = 8, 15905e8ec17SMichael Reed .show_host_node_name = 1, 16005e8ec17SMichael Reed .show_host_port_name = 1, 16105e8ec17SMichael Reed .show_host_supported_classes = 1, 16205e8ec17SMichael Reed .show_host_port_id = 1, 16305e8ec17SMichael Reed .show_rport_supported_classes = 1, 16405e8ec17SMichael Reed .show_starget_node_name = 1, 16505e8ec17SMichael Reed .show_starget_port_name = 1, 16605e8ec17SMichael Reed .show_starget_port_id = 1, 16705e8ec17SMichael Reed .set_rport_dev_loss_tmo = mptfc_set_rport_loss_tmo, 16805e8ec17SMichael Reed .show_rport_dev_loss_tmo = 1, 16905e8ec17SMichael Reed 17005e8ec17SMichael Reed }; 17105e8ec17SMichael Reed 17205e8ec17SMichael Reed /* FIXME! values controlling firmware RESCAN event 17305e8ec17SMichael Reed * need to be set low to allow dev_loss_tmo to 17405e8ec17SMichael Reed * work as expected. Currently, firmware doesn't 17505e8ec17SMichael Reed * notify driver of RESCAN event until some number 17605e8ec17SMichael Reed * of seconds elapse. This value can be set via 17705e8ec17SMichael Reed * lsiutil. 1782496af39SMoore, Eric Dean */ 17905e8ec17SMichael Reed static void 18005e8ec17SMichael Reed mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) 18105e8ec17SMichael Reed { 18205e8ec17SMichael Reed if (timeout > 0) 18305e8ec17SMichael Reed rport->dev_loss_tmo = timeout; 18405e8ec17SMichael Reed else 18505e8ec17SMichael Reed rport->dev_loss_tmo = mptfc_dev_loss_tmo; 18605e8ec17SMichael Reed } 18705e8ec17SMichael Reed 18805e8ec17SMichael Reed static int 18905e8ec17SMichael Reed mptfc_FcDevPage0_cmp_func(const void *a, const void *b) 19005e8ec17SMichael Reed { 19105e8ec17SMichael Reed FCDevicePage0_t **aa = (FCDevicePage0_t **)a; 19205e8ec17SMichael Reed FCDevicePage0_t **bb = (FCDevicePage0_t **)b; 19305e8ec17SMichael Reed 19405e8ec17SMichael Reed if ((*aa)->CurrentBus == (*bb)->CurrentBus) { 19505e8ec17SMichael Reed if ((*aa)->CurrentTargetID == (*bb)->CurrentTargetID) 19605e8ec17SMichael Reed return 0; 19705e8ec17SMichael Reed if ((*aa)->CurrentTargetID < (*bb)->CurrentTargetID) 19805e8ec17SMichael Reed return -1; 19905e8ec17SMichael Reed return 1; 20005e8ec17SMichael Reed } 20105e8ec17SMichael Reed if ((*aa)->CurrentBus < (*bb)->CurrentBus) 20205e8ec17SMichael Reed return -1; 20305e8ec17SMichael Reed return 1; 20405e8ec17SMichael Reed } 20505e8ec17SMichael Reed 20605e8ec17SMichael Reed static int 20705e8ec17SMichael Reed mptfc_GetFcDevPage0(MPT_ADAPTER *ioc, int ioc_port, 20805e8ec17SMichael Reed void(*func)(MPT_ADAPTER *ioc,int channel, FCDevicePage0_t *arg)) 20905e8ec17SMichael Reed { 21005e8ec17SMichael Reed ConfigPageHeader_t hdr; 21105e8ec17SMichael Reed CONFIGPARMS cfg; 21205e8ec17SMichael Reed FCDevicePage0_t *ppage0_alloc, *fc; 21305e8ec17SMichael Reed dma_addr_t page0_dma; 21405e8ec17SMichael Reed int data_sz; 21505e8ec17SMichael Reed int ii; 21605e8ec17SMichael Reed 21705e8ec17SMichael Reed FCDevicePage0_t *p0_array=NULL, *p_p0; 21805e8ec17SMichael Reed FCDevicePage0_t **pp0_array=NULL, **p_pp0; 21905e8ec17SMichael Reed 22005e8ec17SMichael Reed int rc = -ENOMEM; 22105e8ec17SMichael Reed U32 port_id = 0xffffff; 22205e8ec17SMichael Reed int num_targ = 0; 22305e8ec17SMichael Reed int max_bus = ioc->facts.MaxBuses; 22405e8ec17SMichael Reed int max_targ = ioc->facts.MaxDevices; 22505e8ec17SMichael Reed 22605e8ec17SMichael Reed if (max_bus == 0 || max_targ == 0) 22705e8ec17SMichael Reed goto out; 22805e8ec17SMichael Reed 22905e8ec17SMichael Reed data_sz = sizeof(FCDevicePage0_t) * max_bus * max_targ; 23005e8ec17SMichael Reed p_p0 = p0_array = kzalloc(data_sz, GFP_KERNEL); 23105e8ec17SMichael Reed if (!p0_array) 23205e8ec17SMichael Reed goto out; 23305e8ec17SMichael Reed 23405e8ec17SMichael Reed data_sz = sizeof(FCDevicePage0_t *) * max_bus * max_targ; 23505e8ec17SMichael Reed p_pp0 = pp0_array = kzalloc(data_sz, GFP_KERNEL); 23605e8ec17SMichael Reed if (!pp0_array) 23705e8ec17SMichael Reed goto out; 23805e8ec17SMichael Reed 23905e8ec17SMichael Reed do { 24005e8ec17SMichael Reed /* Get FC Device Page 0 header */ 24105e8ec17SMichael Reed hdr.PageVersion = 0; 24205e8ec17SMichael Reed hdr.PageLength = 0; 24305e8ec17SMichael Reed hdr.PageNumber = 0; 24405e8ec17SMichael Reed hdr.PageType = MPI_CONFIG_PAGETYPE_FC_DEVICE; 24505e8ec17SMichael Reed cfg.cfghdr.hdr = &hdr; 24605e8ec17SMichael Reed cfg.physAddr = -1; 24705e8ec17SMichael Reed cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER; 24805e8ec17SMichael Reed cfg.dir = 0; 24905e8ec17SMichael Reed cfg.pageAddr = port_id; 25005e8ec17SMichael Reed cfg.timeout = 0; 25105e8ec17SMichael Reed 25205e8ec17SMichael Reed if ((rc = mpt_config(ioc, &cfg)) != 0) 25305e8ec17SMichael Reed break; 25405e8ec17SMichael Reed 25505e8ec17SMichael Reed if (hdr.PageLength <= 0) 25605e8ec17SMichael Reed break; 25705e8ec17SMichael Reed 25805e8ec17SMichael Reed data_sz = hdr.PageLength * 4; 25905e8ec17SMichael Reed ppage0_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, 26005e8ec17SMichael Reed &page0_dma); 26105e8ec17SMichael Reed rc = -ENOMEM; 26205e8ec17SMichael Reed if (!ppage0_alloc) 26305e8ec17SMichael Reed break; 26405e8ec17SMichael Reed 26505e8ec17SMichael Reed cfg.physAddr = page0_dma; 26605e8ec17SMichael Reed cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; 26705e8ec17SMichael Reed 26805e8ec17SMichael Reed if ((rc = mpt_config(ioc, &cfg)) == 0) { 26905e8ec17SMichael Reed ppage0_alloc->PortIdentifier = 27005e8ec17SMichael Reed le32_to_cpu(ppage0_alloc->PortIdentifier); 27105e8ec17SMichael Reed 27205e8ec17SMichael Reed ppage0_alloc->WWNN.Low = 27305e8ec17SMichael Reed le32_to_cpu(ppage0_alloc->WWNN.Low); 27405e8ec17SMichael Reed 27505e8ec17SMichael Reed ppage0_alloc->WWNN.High = 27605e8ec17SMichael Reed le32_to_cpu(ppage0_alloc->WWNN.High); 27705e8ec17SMichael Reed 27805e8ec17SMichael Reed ppage0_alloc->WWPN.Low = 27905e8ec17SMichael Reed le32_to_cpu(ppage0_alloc->WWPN.Low); 28005e8ec17SMichael Reed 28105e8ec17SMichael Reed ppage0_alloc->WWPN.High = 28205e8ec17SMichael Reed le32_to_cpu(ppage0_alloc->WWPN.High); 28305e8ec17SMichael Reed 28405e8ec17SMichael Reed ppage0_alloc->BBCredit = 28505e8ec17SMichael Reed le16_to_cpu(ppage0_alloc->BBCredit); 28605e8ec17SMichael Reed 28705e8ec17SMichael Reed ppage0_alloc->MaxRxFrameSize = 28805e8ec17SMichael Reed le16_to_cpu(ppage0_alloc->MaxRxFrameSize); 28905e8ec17SMichael Reed 29005e8ec17SMichael Reed port_id = ppage0_alloc->PortIdentifier; 29105e8ec17SMichael Reed num_targ++; 29205e8ec17SMichael Reed *p_p0 = *ppage0_alloc; /* save data */ 29305e8ec17SMichael Reed *p_pp0++ = p_p0++; /* save addr */ 29405e8ec17SMichael Reed } 29505e8ec17SMichael Reed pci_free_consistent(ioc->pcidev, data_sz, 29605e8ec17SMichael Reed (u8 *) ppage0_alloc, page0_dma); 29705e8ec17SMichael Reed if (rc != 0) 29805e8ec17SMichael Reed break; 29905e8ec17SMichael Reed 30005e8ec17SMichael Reed } while (port_id <= 0xff0000); 30105e8ec17SMichael Reed 30205e8ec17SMichael Reed if (num_targ) { 30305e8ec17SMichael Reed /* sort array */ 30405e8ec17SMichael Reed if (num_targ > 1) 30505e8ec17SMichael Reed sort (pp0_array, num_targ, sizeof(FCDevicePage0_t *), 30605e8ec17SMichael Reed mptfc_FcDevPage0_cmp_func, NULL); 30705e8ec17SMichael Reed /* call caller's func for each targ */ 30805e8ec17SMichael Reed for (ii = 0; ii < num_targ; ii++) { 30905e8ec17SMichael Reed fc = *(pp0_array+ii); 31005e8ec17SMichael Reed func(ioc, ioc_port, fc); 31105e8ec17SMichael Reed } 31205e8ec17SMichael Reed } 31305e8ec17SMichael Reed 31405e8ec17SMichael Reed out: 31505e8ec17SMichael Reed if (pp0_array) 31605e8ec17SMichael Reed kfree(pp0_array); 31705e8ec17SMichael Reed if (p0_array) 31805e8ec17SMichael Reed kfree(p0_array); 31905e8ec17SMichael Reed return rc; 32005e8ec17SMichael Reed } 32105e8ec17SMichael Reed 32205e8ec17SMichael Reed static int 32305e8ec17SMichael Reed mptfc_generate_rport_ids(FCDevicePage0_t *pg0, struct fc_rport_identifiers *rid) 32405e8ec17SMichael Reed { 32505e8ec17SMichael Reed /* not currently usable */ 32605e8ec17SMichael Reed if (pg0->Flags & (MPI_FC_DEVICE_PAGE0_FLAGS_PLOGI_INVALID | 32705e8ec17SMichael Reed MPI_FC_DEVICE_PAGE0_FLAGS_PRLI_INVALID)) 32805e8ec17SMichael Reed return -1; 32905e8ec17SMichael Reed 33005e8ec17SMichael Reed if (!(pg0->Flags & MPI_FC_DEVICE_PAGE0_FLAGS_TARGETID_BUS_VALID)) 33105e8ec17SMichael Reed return -1; 33205e8ec17SMichael Reed 33305e8ec17SMichael Reed if (!(pg0->Protocol & MPI_FC_DEVICE_PAGE0_PROT_FCP_TARGET)) 33405e8ec17SMichael Reed return -1; 33505e8ec17SMichael Reed 33605e8ec17SMichael Reed /* 33705e8ec17SMichael Reed * board data structure already normalized to platform endianness 33805e8ec17SMichael Reed * shifted to avoid unaligned access on 64 bit architecture 33905e8ec17SMichael Reed */ 34005e8ec17SMichael Reed rid->node_name = ((u64)pg0->WWNN.High) << 32 | (u64)pg0->WWNN.Low; 34105e8ec17SMichael Reed rid->port_name = ((u64)pg0->WWPN.High) << 32 | (u64)pg0->WWPN.Low; 34205e8ec17SMichael Reed rid->port_id = pg0->PortIdentifier; 34305e8ec17SMichael Reed rid->roles = FC_RPORT_ROLE_UNKNOWN; 34405e8ec17SMichael Reed rid->roles |= FC_RPORT_ROLE_FCP_TARGET; 34505e8ec17SMichael Reed if (pg0->Protocol & MPI_FC_DEVICE_PAGE0_PROT_FCP_INITIATOR) 34605e8ec17SMichael Reed rid->roles |= FC_RPORT_ROLE_FCP_INITIATOR; 34705e8ec17SMichael Reed 34805e8ec17SMichael Reed return 0; 34905e8ec17SMichael Reed } 35005e8ec17SMichael Reed 35105e8ec17SMichael Reed static void 35205e8ec17SMichael Reed mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0) 35305e8ec17SMichael Reed { 35405e8ec17SMichael Reed struct fc_rport_identifiers rport_ids; 35505e8ec17SMichael Reed struct fc_rport *rport; 35605e8ec17SMichael Reed struct mptfc_rport_info *ri; 3573bc7bf1dSMichael Reed int new_ri = 1; 358*65207fedSMoore, Eric u64 pn, nn; 3593bc7bf1dSMichael Reed VirtTarget *vtarget; 36005e8ec17SMichael Reed 36105e8ec17SMichael Reed if (mptfc_generate_rport_ids(pg0, &rport_ids) < 0) 36205e8ec17SMichael Reed return; 36305e8ec17SMichael Reed 36405e8ec17SMichael Reed /* scan list looking for a match */ 36505e8ec17SMichael Reed list_for_each_entry(ri, &ioc->fc_rports, list) { 3663bc7bf1dSMichael Reed pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; 3673bc7bf1dSMichael Reed if (pn == rport_ids.port_name) { /* match */ 36805e8ec17SMichael Reed list_move_tail(&ri->list, &ioc->fc_rports); 3693bc7bf1dSMichael Reed new_ri = 0; 37005e8ec17SMichael Reed break; 37105e8ec17SMichael Reed } 37205e8ec17SMichael Reed } 3733bc7bf1dSMichael Reed if (new_ri) { /* allocate one */ 37405e8ec17SMichael Reed ri = kzalloc(sizeof(struct mptfc_rport_info), GFP_KERNEL); 37505e8ec17SMichael Reed if (!ri) 37605e8ec17SMichael Reed return; 37705e8ec17SMichael Reed list_add_tail(&ri->list, &ioc->fc_rports); 37805e8ec17SMichael Reed } 37905e8ec17SMichael Reed 38005e8ec17SMichael Reed ri->pg0 = *pg0; /* add/update pg0 data */ 38105e8ec17SMichael Reed ri->flags &= ~MPT_RPORT_INFO_FLAGS_MISSING; 38205e8ec17SMichael Reed 3833bc7bf1dSMichael Reed /* MPT_RPORT_INFO_FLAGS_REGISTERED - rport not previously deleted */ 38405e8ec17SMichael Reed if (!(ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED)) { 38505e8ec17SMichael Reed ri->flags |= MPT_RPORT_INFO_FLAGS_REGISTERED; 38605e8ec17SMichael Reed rport = fc_remote_port_add(ioc->sh, channel, &rport_ids); 38705e8ec17SMichael Reed if (rport) { 38805e8ec17SMichael Reed ri->rport = rport; 3893bc7bf1dSMichael Reed if (new_ri) /* may have been reset by user */ 39005e8ec17SMichael Reed rport->dev_loss_tmo = mptfc_dev_loss_tmo; 39105e8ec17SMichael Reed /* 39205e8ec17SMichael Reed * if already mapped, remap here. If not mapped, 3933bc7bf1dSMichael Reed * target_alloc will allocate vtarget and map, 3943bc7bf1dSMichael Reed * slave_alloc will fill in vdev from vtarget. 39505e8ec17SMichael Reed */ 3963bc7bf1dSMichael Reed if (ri->starget) { 3973bc7bf1dSMichael Reed vtarget = ri->starget->hostdata; 3983bc7bf1dSMichael Reed if (vtarget) { 3993bc7bf1dSMichael Reed vtarget->target_id = pg0->CurrentTargetID; 4003bc7bf1dSMichael Reed vtarget->bus_id = pg0->CurrentBus; 40105e8ec17SMichael Reed } 4023bc7bf1dSMichael Reed } 403*65207fedSMoore, Eric /* once dd_data is filled in, commands will issue to hardware */ 404*65207fedSMoore, Eric *((struct mptfc_rport_info **)rport->dd_data) = ri; 405*65207fedSMoore, Eric 406*65207fedSMoore, Eric pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; 407*65207fedSMoore, Eric nn = (u64)ri->pg0.WWNN.High << 32 | (u64)ri->pg0.WWNN.Low; 4083bc7bf1dSMichael Reed dfcprintk ((MYIOC_s_INFO_FMT 4093bc7bf1dSMichael Reed "mptfc_reg_dev.%d: %x, %llx / %llx, tid %d, " 41005e8ec17SMichael Reed "rport tid %d, tmo %d\n", 4113bc7bf1dSMichael Reed ioc->name, 412914c2d8eSMoore, Eric ioc->sh->host_no, 41305e8ec17SMichael Reed pg0->PortIdentifier, 414*65207fedSMoore, Eric (unsigned long long)nn, 415*65207fedSMoore, Eric (unsigned long long)pn, 41605e8ec17SMichael Reed pg0->CurrentTargetID, 41705e8ec17SMichael Reed ri->rport->scsi_target_id, 4183bc7bf1dSMichael Reed ri->rport->dev_loss_tmo)); 41905e8ec17SMichael Reed } else { 42005e8ec17SMichael Reed list_del(&ri->list); 42105e8ec17SMichael Reed kfree(ri); 42205e8ec17SMichael Reed ri = NULL; 42305e8ec17SMichael Reed } 42405e8ec17SMichael Reed } 42505e8ec17SMichael Reed } 42605e8ec17SMichael Reed 42705e8ec17SMichael Reed /* 4283bc7bf1dSMichael Reed * OS entry point to allow for host driver to free allocated memory 4293bc7bf1dSMichael Reed * Called if no device present or device being unloaded 4303bc7bf1dSMichael Reed */ 4313bc7bf1dSMichael Reed static void 4323bc7bf1dSMichael Reed mptfc_target_destroy(struct scsi_target *starget) 4333bc7bf1dSMichael Reed { 4343bc7bf1dSMichael Reed struct fc_rport *rport; 4353bc7bf1dSMichael Reed struct mptfc_rport_info *ri; 4363bc7bf1dSMichael Reed 4373bc7bf1dSMichael Reed rport = starget_to_rport(starget); 4383bc7bf1dSMichael Reed if (rport) { 4393bc7bf1dSMichael Reed ri = *((struct mptfc_rport_info **)rport->dd_data); 4403bc7bf1dSMichael Reed if (ri) /* better be! */ 4413bc7bf1dSMichael Reed ri->starget = NULL; 4423bc7bf1dSMichael Reed } 4433bc7bf1dSMichael Reed if (starget->hostdata) 4443bc7bf1dSMichael Reed kfree(starget->hostdata); 4453bc7bf1dSMichael Reed starget->hostdata = NULL; 4463bc7bf1dSMichael Reed } 4473bc7bf1dSMichael Reed 4483bc7bf1dSMichael Reed /* 4493bc7bf1dSMichael Reed * OS entry point to allow host driver to alloc memory 4503bc7bf1dSMichael Reed * for each scsi target. Called once per device the bus scan. 4513bc7bf1dSMichael Reed * Return non-zero if allocation fails. 4523bc7bf1dSMichael Reed */ 4533bc7bf1dSMichael Reed static int 4543bc7bf1dSMichael Reed mptfc_target_alloc(struct scsi_target *starget) 4553bc7bf1dSMichael Reed { 4563bc7bf1dSMichael Reed VirtTarget *vtarget; 4573bc7bf1dSMichael Reed struct fc_rport *rport; 4583bc7bf1dSMichael Reed struct mptfc_rport_info *ri; 4593bc7bf1dSMichael Reed int rc; 4603bc7bf1dSMichael Reed 4613bc7bf1dSMichael Reed vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); 4623bc7bf1dSMichael Reed if (!vtarget) 4633bc7bf1dSMichael Reed return -ENOMEM; 4643bc7bf1dSMichael Reed starget->hostdata = vtarget; 4653bc7bf1dSMichael Reed 4663bc7bf1dSMichael Reed rc = -ENODEV; 4673bc7bf1dSMichael Reed rport = starget_to_rport(starget); 4683bc7bf1dSMichael Reed if (rport) { 4693bc7bf1dSMichael Reed ri = *((struct mptfc_rport_info **)rport->dd_data); 4703bc7bf1dSMichael Reed if (ri) { /* better be! */ 4713bc7bf1dSMichael Reed vtarget->target_id = ri->pg0.CurrentTargetID; 4723bc7bf1dSMichael Reed vtarget->bus_id = ri->pg0.CurrentBus; 4733bc7bf1dSMichael Reed ri->starget = starget; 4743bc7bf1dSMichael Reed rc = 0; 4753bc7bf1dSMichael Reed } 4763bc7bf1dSMichael Reed } 4773bc7bf1dSMichael Reed if (rc != 0) { 4783bc7bf1dSMichael Reed kfree(vtarget); 4793bc7bf1dSMichael Reed starget->hostdata = NULL; 4803bc7bf1dSMichael Reed } 4813bc7bf1dSMichael Reed 4823bc7bf1dSMichael Reed return rc; 4833bc7bf1dSMichael Reed } 4843bc7bf1dSMichael Reed 4853bc7bf1dSMichael Reed /* 48605e8ec17SMichael Reed * OS entry point to allow host driver to alloc memory 48705e8ec17SMichael Reed * for each scsi device. Called once per device the bus scan. 48805e8ec17SMichael Reed * Return non-zero if allocation fails. 48905e8ec17SMichael Reed * Init memory once per LUN. 49005e8ec17SMichael Reed */ 49103fbcbcdSAdrian Bunk static int 49205e8ec17SMichael Reed mptfc_slave_alloc(struct scsi_device *sdev) 49305e8ec17SMichael Reed { 49405e8ec17SMichael Reed MPT_SCSI_HOST *hd; 49505e8ec17SMichael Reed VirtTarget *vtarget; 49605e8ec17SMichael Reed VirtDevice *vdev; 49705e8ec17SMichael Reed struct scsi_target *starget; 49805e8ec17SMichael Reed struct fc_rport *rport; 49905e8ec17SMichael Reed 50005e8ec17SMichael Reed 501*65207fedSMoore, Eric starget = scsi_target(sdev); 502*65207fedSMoore, Eric rport = starget_to_rport(starget); 50305e8ec17SMichael Reed 50405e8ec17SMichael Reed if (!rport || fc_remote_port_chkready(rport)) 50505e8ec17SMichael Reed return -ENXIO; 50605e8ec17SMichael Reed 50705e8ec17SMichael Reed hd = (MPT_SCSI_HOST *)sdev->host->hostdata; 50805e8ec17SMichael Reed 5093bc7bf1dSMichael Reed vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL); 51005e8ec17SMichael Reed if (!vdev) { 51105e8ec17SMichael Reed printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", 51205e8ec17SMichael Reed hd->ioc->name, sizeof(VirtDevice)); 51305e8ec17SMichael Reed return -ENOMEM; 51405e8ec17SMichael Reed } 51505e8ec17SMichael Reed 51605e8ec17SMichael Reed 51705e8ec17SMichael Reed sdev->hostdata = vdev; 51805e8ec17SMichael Reed vtarget = starget->hostdata; 5193bc7bf1dSMichael Reed 52005e8ec17SMichael Reed if (vtarget->num_luns == 0) { 5213bc7bf1dSMichael Reed vtarget->ioc_id = hd->ioc->id; 52205e8ec17SMichael Reed vtarget->tflags = MPT_TARGET_FLAGS_Q_YES | 52305e8ec17SMichael Reed MPT_TARGET_FLAGS_VALID_INQUIRY; 52405e8ec17SMichael Reed hd->Targets[sdev->id] = vtarget; 52505e8ec17SMichael Reed } 52605e8ec17SMichael Reed 52705e8ec17SMichael Reed vdev->vtarget = vtarget; 52805e8ec17SMichael Reed vdev->lun = sdev->lun; 52905e8ec17SMichael Reed 53005e8ec17SMichael Reed vtarget->num_luns++; 53105e8ec17SMichael Reed 532*65207fedSMoore, Eric 533914c2d8eSMoore, Eric #ifdef DMPT_DEBUG_FC 534914c2d8eSMoore, Eric { 535*65207fedSMoore, Eric u64 nn, pn; 536914c2d8eSMoore, Eric struct mptfc_rport_info *ri; 537914c2d8eSMoore, Eric ri = *((struct mptfc_rport_info **)rport->dd_data); 538*65207fedSMoore, Eric pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; 539*65207fedSMoore, Eric nn = (u64)ri->pg0.WWNN.High << 32 | (u64)ri->pg0.WWNN.Low; 5403bc7bf1dSMichael Reed dfcprintk ((MYIOC_s_INFO_FMT 5413bc7bf1dSMichael Reed "mptfc_slv_alloc.%d: num_luns %d, sdev.id %d, " 54205e8ec17SMichael Reed "CurrentTargetID %d, %x %llx %llx\n", 543914c2d8eSMoore, Eric hd->ioc->name, 54405e8ec17SMichael Reed sdev->host->host_no, 54505e8ec17SMichael Reed vtarget->num_luns, 54605e8ec17SMichael Reed sdev->id, ri->pg0.CurrentTargetID, 547*65207fedSMoore, Eric ri->pg0.PortIdentifier, 548*65207fedSMoore, Eric (unsigned long long)pn, 549*65207fedSMoore, Eric (unsigned long long)nn)); 550914c2d8eSMoore, Eric } 551914c2d8eSMoore, Eric #endif 55205e8ec17SMichael Reed 55305e8ec17SMichael Reed return 0; 55405e8ec17SMichael Reed } 55505e8ec17SMichael Reed 55605e8ec17SMichael Reed static int 55705e8ec17SMichael Reed mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 55805e8ec17SMichael Reed { 5593bc7bf1dSMichael Reed struct mptfc_rport_info *ri; 56005e8ec17SMichael Reed struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device)); 56105e8ec17SMichael Reed int err; 56205e8ec17SMichael Reed 56305e8ec17SMichael Reed err = fc_remote_port_chkready(rport); 56405e8ec17SMichael Reed if (unlikely(err)) { 56505e8ec17SMichael Reed SCpnt->result = err; 56605e8ec17SMichael Reed done(SCpnt); 56705e8ec17SMichael Reed return 0; 56805e8ec17SMichael Reed } 5693bc7bf1dSMichael Reed 570*65207fedSMoore, Eric /* dd_data is null until finished adding target */ 571*65207fedSMoore, Eric ri = *((struct mptfc_rport_info **)rport->dd_data); 572*65207fedSMoore, Eric if (unlikely(!ri)) { 573*65207fedSMoore, Eric dfcprintk ((MYIOC_s_INFO_FMT 574*65207fedSMoore, Eric "mptfc_qcmd.%d: %d:%d, dd_data is null.\n", 575*65207fedSMoore, Eric ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->name, 576*65207fedSMoore, Eric ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->sh->host_no, 577*65207fedSMoore, Eric SCpnt->device->id,SCpnt->device->lun)); 578*65207fedSMoore, Eric SCpnt->result = DID_IMM_RETRY << 16; 579*65207fedSMoore, Eric done(SCpnt); 580*65207fedSMoore, Eric return 0; 581*65207fedSMoore, Eric } 582*65207fedSMoore, Eric 583*65207fedSMoore, Eric err = mptscsih_qcmd(SCpnt,done); 584*65207fedSMoore, Eric #ifdef DMPT_DEBUG_FC 585*65207fedSMoore, Eric if (unlikely(err)) { 586*65207fedSMoore, Eric dfcprintk ((MYIOC_s_INFO_FMT 587*65207fedSMoore, Eric "mptfc_qcmd.%d: %d:%d, mptscsih_qcmd returns non-zero.\n", 588*65207fedSMoore, Eric ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->name, 589*65207fedSMoore, Eric ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->sh->host_no, 590*65207fedSMoore, Eric SCpnt->device->id,SCpnt->device->lun)); 591*65207fedSMoore, Eric } 592*65207fedSMoore, Eric #endif 593*65207fedSMoore, Eric return err; 59405e8ec17SMichael Reed } 59505e8ec17SMichael Reed 59605e8ec17SMichael Reed static void 59705e8ec17SMichael Reed mptfc_init_host_attr(MPT_ADAPTER *ioc,int portnum) 59805e8ec17SMichael Reed { 59905e8ec17SMichael Reed unsigned class = 0, cos = 0; 60005e8ec17SMichael Reed 60105e8ec17SMichael Reed /* don't know what to do as only one scsi (fc) host was allocated */ 60205e8ec17SMichael Reed if (portnum != 0) 60305e8ec17SMichael Reed return; 60405e8ec17SMichael Reed 60505e8ec17SMichael Reed class = ioc->fc_port_page0[portnum].SupportedServiceClass; 60605e8ec17SMichael Reed if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_1) 60705e8ec17SMichael Reed cos |= FC_COS_CLASS1; 60805e8ec17SMichael Reed if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_2) 60905e8ec17SMichael Reed cos |= FC_COS_CLASS2; 61005e8ec17SMichael Reed if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_3) 61105e8ec17SMichael Reed cos |= FC_COS_CLASS3; 61205e8ec17SMichael Reed 61305e8ec17SMichael Reed fc_host_node_name(ioc->sh) = 61405e8ec17SMichael Reed (u64)ioc->fc_port_page0[portnum].WWNN.High << 32 61505e8ec17SMichael Reed | (u64)ioc->fc_port_page0[portnum].WWNN.Low; 61605e8ec17SMichael Reed 61705e8ec17SMichael Reed fc_host_port_name(ioc->sh) = 61805e8ec17SMichael Reed (u64)ioc->fc_port_page0[portnum].WWPN.High << 32 61905e8ec17SMichael Reed | (u64)ioc->fc_port_page0[portnum].WWPN.Low; 62005e8ec17SMichael Reed 62105e8ec17SMichael Reed fc_host_port_id(ioc->sh) = ioc->fc_port_page0[portnum].PortIdentifier; 62205e8ec17SMichael Reed 62305e8ec17SMichael Reed fc_host_supported_classes(ioc->sh) = cos; 62405e8ec17SMichael Reed 62505e8ec17SMichael Reed fc_host_tgtid_bind_type(ioc->sh) = FC_TGTID_BIND_BY_WWPN; 62605e8ec17SMichael Reed } 62705e8ec17SMichael Reed 62805e8ec17SMichael Reed static void 62905e8ec17SMichael Reed mptfc_rescan_devices(void *arg) 63005e8ec17SMichael Reed { 63105e8ec17SMichael Reed MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 63205e8ec17SMichael Reed int ii; 63305e8ec17SMichael Reed int work_to_do; 634*65207fedSMoore, Eric u64 pn; 63505e8ec17SMichael Reed unsigned long flags; 63605e8ec17SMichael Reed struct mptfc_rport_info *ri; 63705e8ec17SMichael Reed 63805e8ec17SMichael Reed do { 63905e8ec17SMichael Reed /* start by tagging all ports as missing */ 64005e8ec17SMichael Reed list_for_each_entry(ri, &ioc->fc_rports, list) { 64105e8ec17SMichael Reed if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) { 64205e8ec17SMichael Reed ri->flags |= MPT_RPORT_INFO_FLAGS_MISSING; 64305e8ec17SMichael Reed } 64405e8ec17SMichael Reed } 64505e8ec17SMichael Reed 64605e8ec17SMichael Reed /* 64705e8ec17SMichael Reed * now rescan devices known to adapter, 64805e8ec17SMichael Reed * will reregister existing rports 64905e8ec17SMichael Reed */ 65005e8ec17SMichael Reed for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) { 65105e8ec17SMichael Reed (void) mptbase_GetFcPortPage0(ioc, ii); 65205e8ec17SMichael Reed mptfc_init_host_attr(ioc,ii); /* refresh */ 65305e8ec17SMichael Reed mptfc_GetFcDevPage0(ioc,ii,mptfc_register_dev); 65405e8ec17SMichael Reed } 65505e8ec17SMichael Reed 65605e8ec17SMichael Reed /* delete devices still missing */ 65705e8ec17SMichael Reed list_for_each_entry(ri, &ioc->fc_rports, list) { 65805e8ec17SMichael Reed /* if newly missing, delete it */ 659*65207fedSMoore, Eric if (ri->flags & MPT_RPORT_INFO_FLAGS_MISSING) { 66005e8ec17SMichael Reed 66105e8ec17SMichael Reed ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED| 66205e8ec17SMichael Reed MPT_RPORT_INFO_FLAGS_MISSING); 663*65207fedSMoore, Eric fc_remote_port_delete(ri->rport); /* won't sleep */ 6643bc7bf1dSMichael Reed ri->rport = NULL; 665*65207fedSMoore, Eric 666*65207fedSMoore, Eric pn = (u64)ri->pg0.WWPN.High << 32 | 667*65207fedSMoore, Eric (u64)ri->pg0.WWPN.Low; 6683bc7bf1dSMichael Reed dfcprintk ((MYIOC_s_INFO_FMT 6693bc7bf1dSMichael Reed "mptfc_rescan.%d: %llx deleted\n", 6703bc7bf1dSMichael Reed ioc->name, 6713bc7bf1dSMichael Reed ioc->sh->host_no, 672*65207fedSMoore, Eric (unsigned long long)pn)); 67305e8ec17SMichael Reed } 67405e8ec17SMichael Reed } 67505e8ec17SMichael Reed 67605e8ec17SMichael Reed /* 67705e8ec17SMichael Reed * allow multiple passes as target state 67805e8ec17SMichael Reed * might have changed during scan 67905e8ec17SMichael Reed */ 68005e8ec17SMichael Reed spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); 68105e8ec17SMichael Reed if (ioc->fc_rescan_work_count > 2) /* only need one more */ 68205e8ec17SMichael Reed ioc->fc_rescan_work_count = 2; 68305e8ec17SMichael Reed work_to_do = --ioc->fc_rescan_work_count; 68405e8ec17SMichael Reed spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); 68505e8ec17SMichael Reed } while (work_to_do); 68605e8ec17SMichael Reed } 68705e8ec17SMichael Reed 6882496af39SMoore, Eric Dean static int 6892496af39SMoore, Eric Dean mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) 6902496af39SMoore, Eric Dean { 6912496af39SMoore, Eric Dean struct Scsi_Host *sh; 6922496af39SMoore, Eric Dean MPT_SCSI_HOST *hd; 6932496af39SMoore, Eric Dean MPT_ADAPTER *ioc; 6942496af39SMoore, Eric Dean unsigned long flags; 6951ca00bb7SChristoph Hellwig int ii; 6962496af39SMoore, Eric Dean int numSGE = 0; 6972496af39SMoore, Eric Dean int scale; 6982496af39SMoore, Eric Dean int ioc_cap; 6992496af39SMoore, Eric Dean int error=0; 7002496af39SMoore, Eric Dean int r; 7012496af39SMoore, Eric Dean 7022496af39SMoore, Eric Dean if ((r = mpt_attach(pdev,id)) != 0) 7032496af39SMoore, Eric Dean return r; 7042496af39SMoore, Eric Dean 7052496af39SMoore, Eric Dean ioc = pci_get_drvdata(pdev); 706d335cc38SMoore, Eric Dean ioc->DoneCtx = mptfcDoneCtx; 707d335cc38SMoore, Eric Dean ioc->TaskCtx = mptfcTaskCtx; 708d335cc38SMoore, Eric Dean ioc->InternalCtx = mptfcInternalCtx; 7092496af39SMoore, Eric Dean 7102496af39SMoore, Eric Dean /* Added sanity check on readiness of the MPT adapter. 7112496af39SMoore, Eric Dean */ 7122496af39SMoore, Eric Dean if (ioc->last_state != MPI_IOC_STATE_OPERATIONAL) { 7132496af39SMoore, Eric Dean printk(MYIOC_s_WARN_FMT 7142496af39SMoore, Eric Dean "Skipping because it's not operational!\n", 7152496af39SMoore, Eric Dean ioc->name); 7167acec1e7SMoore, Eric Dean error = -ENODEV; 7177acec1e7SMoore, Eric Dean goto out_mptfc_probe; 7182496af39SMoore, Eric Dean } 7192496af39SMoore, Eric Dean 7202496af39SMoore, Eric Dean if (!ioc->active) { 7212496af39SMoore, Eric Dean printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", 7222496af39SMoore, Eric Dean ioc->name); 7237acec1e7SMoore, Eric Dean error = -ENODEV; 7247acec1e7SMoore, Eric Dean goto out_mptfc_probe; 7252496af39SMoore, Eric Dean } 7262496af39SMoore, Eric Dean 7272496af39SMoore, Eric Dean /* Sanity check - ensure at least 1 port is INITIATOR capable 7282496af39SMoore, Eric Dean */ 7292496af39SMoore, Eric Dean ioc_cap = 0; 7302496af39SMoore, Eric Dean for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) { 7312496af39SMoore, Eric Dean if (ioc->pfacts[ii].ProtocolFlags & 7322496af39SMoore, Eric Dean MPI_PORTFACTS_PROTOCOL_INITIATOR) 7332496af39SMoore, Eric Dean ioc_cap ++; 7342496af39SMoore, Eric Dean } 7352496af39SMoore, Eric Dean 7362496af39SMoore, Eric Dean if (!ioc_cap) { 7372496af39SMoore, Eric Dean printk(MYIOC_s_WARN_FMT 7382496af39SMoore, Eric Dean "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n", 7392496af39SMoore, Eric Dean ioc->name, ioc); 74005e8ec17SMichael Reed return -ENODEV; 7412496af39SMoore, Eric Dean } 7422496af39SMoore, Eric Dean 7432496af39SMoore, Eric Dean sh = scsi_host_alloc(&mptfc_driver_template, sizeof(MPT_SCSI_HOST)); 7442496af39SMoore, Eric Dean 7452496af39SMoore, Eric Dean if (!sh) { 7462496af39SMoore, Eric Dean printk(MYIOC_s_WARN_FMT 7472496af39SMoore, Eric Dean "Unable to register controller with SCSI subsystem\n", 7482496af39SMoore, Eric Dean ioc->name); 7497acec1e7SMoore, Eric Dean error = -1; 7507acec1e7SMoore, Eric Dean goto out_mptfc_probe; 7512496af39SMoore, Eric Dean } 7522496af39SMoore, Eric Dean 75305e8ec17SMichael Reed INIT_WORK(&ioc->fc_rescan_work, mptfc_rescan_devices,(void *)ioc); 75405e8ec17SMichael Reed 7552496af39SMoore, Eric Dean spin_lock_irqsave(&ioc->FreeQlock, flags); 7562496af39SMoore, Eric Dean 7572496af39SMoore, Eric Dean /* Attach the SCSI Host to the IOC structure 7582496af39SMoore, Eric Dean */ 7592496af39SMoore, Eric Dean ioc->sh = sh; 7602496af39SMoore, Eric Dean 7612496af39SMoore, Eric Dean sh->io_port = 0; 7622496af39SMoore, Eric Dean sh->n_io_port = 0; 7632496af39SMoore, Eric Dean sh->irq = 0; 7642496af39SMoore, Eric Dean 7652496af39SMoore, Eric Dean /* set 16 byte cdb's */ 7662496af39SMoore, Eric Dean sh->max_cmd_len = 16; 7672496af39SMoore, Eric Dean 7682496af39SMoore, Eric Dean sh->max_id = MPT_MAX_FC_DEVICES<256 ? MPT_MAX_FC_DEVICES : 255; 7692496af39SMoore, Eric Dean 7702496af39SMoore, Eric Dean sh->max_lun = MPT_LAST_LUN + 1; 7712496af39SMoore, Eric Dean sh->max_channel = 0; 7722496af39SMoore, Eric Dean sh->this_id = ioc->pfacts[0].PortSCSIID; 7732496af39SMoore, Eric Dean 7742496af39SMoore, Eric Dean /* Required entry. 7752496af39SMoore, Eric Dean */ 7762496af39SMoore, Eric Dean sh->unique_id = ioc->id; 7772496af39SMoore, Eric Dean 7782496af39SMoore, Eric Dean /* Verify that we won't exceed the maximum 7792496af39SMoore, Eric Dean * number of chain buffers 7802496af39SMoore, Eric Dean * We can optimize: ZZ = req_sz/sizeof(SGE) 7812496af39SMoore, Eric Dean * For 32bit SGE's: 7822496af39SMoore, Eric Dean * numSGE = 1 + (ZZ-1)*(maxChain -1) + ZZ 7832496af39SMoore, Eric Dean * + (req_sz - 64)/sizeof(SGE) 7842496af39SMoore, Eric Dean * A slightly different algorithm is required for 7852496af39SMoore, Eric Dean * 64bit SGEs. 7862496af39SMoore, Eric Dean */ 7872496af39SMoore, Eric Dean scale = ioc->req_sz/(sizeof(dma_addr_t) + sizeof(u32)); 7882496af39SMoore, Eric Dean if (sizeof(dma_addr_t) == sizeof(u64)) { 7892496af39SMoore, Eric Dean numSGE = (scale - 1) * 7902496af39SMoore, Eric Dean (ioc->facts.MaxChainDepth-1) + scale + 7912496af39SMoore, Eric Dean (ioc->req_sz - 60) / (sizeof(dma_addr_t) + 7922496af39SMoore, Eric Dean sizeof(u32)); 7932496af39SMoore, Eric Dean } else { 7942496af39SMoore, Eric Dean numSGE = 1 + (scale - 1) * 7952496af39SMoore, Eric Dean (ioc->facts.MaxChainDepth-1) + scale + 7962496af39SMoore, Eric Dean (ioc->req_sz - 64) / (sizeof(dma_addr_t) + 7972496af39SMoore, Eric Dean sizeof(u32)); 7982496af39SMoore, Eric Dean } 7992496af39SMoore, Eric Dean 8002496af39SMoore, Eric Dean if (numSGE < sh->sg_tablesize) { 8012496af39SMoore, Eric Dean /* Reset this value */ 8022496af39SMoore, Eric Dean dprintk((MYIOC_s_INFO_FMT 8032496af39SMoore, Eric Dean "Resetting sg_tablesize to %d from %d\n", 8042496af39SMoore, Eric Dean ioc->name, numSGE, sh->sg_tablesize)); 8052496af39SMoore, Eric Dean sh->sg_tablesize = numSGE; 8062496af39SMoore, Eric Dean } 8072496af39SMoore, Eric Dean 8082496af39SMoore, Eric Dean spin_unlock_irqrestore(&ioc->FreeQlock, flags); 8092496af39SMoore, Eric Dean 8102496af39SMoore, Eric Dean hd = (MPT_SCSI_HOST *) sh->hostdata; 8112496af39SMoore, Eric Dean hd->ioc = ioc; 8122496af39SMoore, Eric Dean 8132496af39SMoore, Eric Dean /* SCSI needs scsi_cmnd lookup table! 8142496af39SMoore, Eric Dean * (with size equal to req_depth*PtrSz!) 8152496af39SMoore, Eric Dean */ 8161ca00bb7SChristoph Hellwig hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); 8171ca00bb7SChristoph Hellwig if (!hd->ScsiLookup) { 8182496af39SMoore, Eric Dean error = -ENOMEM; 8197acec1e7SMoore, Eric Dean goto out_mptfc_probe; 8202496af39SMoore, Eric Dean } 8212496af39SMoore, Eric Dean 8221ca00bb7SChristoph Hellwig dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n", 8231ca00bb7SChristoph Hellwig ioc->name, hd->ScsiLookup)); 8242496af39SMoore, Eric Dean 8252496af39SMoore, Eric Dean /* Allocate memory for the device structures. 8262496af39SMoore, Eric Dean * A non-Null pointer at an offset 8272496af39SMoore, Eric Dean * indicates a device exists. 8282496af39SMoore, Eric Dean * max_id = 1 + maximum id (hosts.h) 8292496af39SMoore, Eric Dean */ 8301ca00bb7SChristoph Hellwig hd->Targets = kcalloc(sh->max_id, sizeof(void *), GFP_ATOMIC); 8311ca00bb7SChristoph Hellwig if (!hd->Targets) { 8322496af39SMoore, Eric Dean error = -ENOMEM; 8337acec1e7SMoore, Eric Dean goto out_mptfc_probe; 8342496af39SMoore, Eric Dean } 8352496af39SMoore, Eric Dean 8361ca00bb7SChristoph Hellwig dprintk((KERN_INFO " vdev @ %p\n", hd->Targets)); 8372496af39SMoore, Eric Dean 8382496af39SMoore, Eric Dean /* Clear the TM flags 8392496af39SMoore, Eric Dean */ 8402496af39SMoore, Eric Dean hd->tmPending = 0; 8412496af39SMoore, Eric Dean hd->tmState = TM_STATE_NONE; 8422496af39SMoore, Eric Dean hd->resetPending = 0; 8432496af39SMoore, Eric Dean hd->abortSCpnt = NULL; 8442496af39SMoore, Eric Dean 8452496af39SMoore, Eric Dean /* Clear the pointer used to store 8462496af39SMoore, Eric Dean * single-threaded commands, i.e., those 8472496af39SMoore, Eric Dean * issued during a bus scan, dv and 8482496af39SMoore, Eric Dean * configuration pages. 8492496af39SMoore, Eric Dean */ 8502496af39SMoore, Eric Dean hd->cmdPtr = NULL; 8512496af39SMoore, Eric Dean 8522496af39SMoore, Eric Dean /* Initialize this SCSI Hosts' timers 8532496af39SMoore, Eric Dean * To use, set the timer expires field 8542496af39SMoore, Eric Dean * and add_timer 8552496af39SMoore, Eric Dean */ 8562496af39SMoore, Eric Dean init_timer(&hd->timer); 8572496af39SMoore, Eric Dean hd->timer.data = (unsigned long) hd; 8582496af39SMoore, Eric Dean hd->timer.function = mptscsih_timer_expired; 8592496af39SMoore, Eric Dean 8602496af39SMoore, Eric Dean hd->mpt_pq_filter = mpt_pq_filter; 8612496af39SMoore, Eric Dean 8622496af39SMoore, Eric Dean ddvprintk((MYIOC_s_INFO_FMT 8632496af39SMoore, Eric Dean "mpt_pq_filter %x\n", 8642496af39SMoore, Eric Dean ioc->name, 8652496af39SMoore, Eric Dean mpt_pq_filter)); 8662496af39SMoore, Eric Dean 8672496af39SMoore, Eric Dean init_waitqueue_head(&hd->scandv_waitq); 8682496af39SMoore, Eric Dean hd->scandv_wait_done = 0; 8692496af39SMoore, Eric Dean hd->last_queue_full = 0; 8702496af39SMoore, Eric Dean 87105e8ec17SMichael Reed sh->transportt = mptfc_transport_template; 8722496af39SMoore, Eric Dean error = scsi_add_host (sh, &ioc->pcidev->dev); 8732496af39SMoore, Eric Dean if(error) { 8742496af39SMoore, Eric Dean dprintk((KERN_ERR MYNAM 8752496af39SMoore, Eric Dean "scsi_add_host failed\n")); 8767acec1e7SMoore, Eric Dean goto out_mptfc_probe; 8772496af39SMoore, Eric Dean } 8782496af39SMoore, Eric Dean 879*65207fedSMoore, Eric /* initialize workqueue */ 880*65207fedSMoore, Eric 881*65207fedSMoore, Eric snprintf(ioc->fc_rescan_work_q_name, KOBJ_NAME_LEN, "mptfc_wq_%d", 882*65207fedSMoore, Eric sh->host_no); 883*65207fedSMoore, Eric ioc->fc_rescan_work_q = 884*65207fedSMoore, Eric create_singlethread_workqueue(ioc->fc_rescan_work_q_name); 885*65207fedSMoore, Eric if (!ioc->fc_rescan_work_q) 886*65207fedSMoore, Eric goto out_mptfc_probe; 887*65207fedSMoore, Eric 888*65207fedSMoore, Eric /* 889*65207fedSMoore, Eric * scan for rports - 890*65207fedSMoore, Eric * by doing it via the workqueue, some locking is eliminated 891*65207fedSMoore, Eric */ 892*65207fedSMoore, Eric 893*65207fedSMoore, Eric ioc->fc_rescan_work_count = 1; 894*65207fedSMoore, Eric queue_work(ioc->fc_rescan_work_q, &ioc->fc_rescan_work); 895*65207fedSMoore, Eric flush_workqueue(ioc->fc_rescan_work_q); 89605e8ec17SMichael Reed 8972496af39SMoore, Eric Dean return 0; 8982496af39SMoore, Eric Dean 8997acec1e7SMoore, Eric Dean out_mptfc_probe: 9002496af39SMoore, Eric Dean 9012496af39SMoore, Eric Dean mptscsih_remove(pdev); 9022496af39SMoore, Eric Dean return error; 9032496af39SMoore, Eric Dean } 9042496af39SMoore, Eric Dean 9052496af39SMoore, Eric Dean static struct pci_driver mptfc_driver = { 9062496af39SMoore, Eric Dean .name = "mptfc", 9072496af39SMoore, Eric Dean .id_table = mptfc_pci_table, 9082496af39SMoore, Eric Dean .probe = mptfc_probe, 90905e8ec17SMichael Reed .remove = __devexit_p(mptfc_remove), 9102496af39SMoore, Eric Dean .shutdown = mptscsih_shutdown, 9112496af39SMoore, Eric Dean #ifdef CONFIG_PM 9122496af39SMoore, Eric Dean .suspend = mptscsih_suspend, 9132496af39SMoore, Eric Dean .resume = mptscsih_resume, 9142496af39SMoore, Eric Dean #endif 9152496af39SMoore, Eric Dean }; 9162496af39SMoore, Eric Dean 9172496af39SMoore, Eric Dean /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 9182496af39SMoore, Eric Dean /** 9192496af39SMoore, Eric Dean * mptfc_init - Register MPT adapter(s) as SCSI host(s) with 9202496af39SMoore, Eric Dean * linux scsi mid-layer. 9212496af39SMoore, Eric Dean * 9222496af39SMoore, Eric Dean * Returns 0 for success, non-zero for failure. 9232496af39SMoore, Eric Dean */ 9242496af39SMoore, Eric Dean static int __init 9252496af39SMoore, Eric Dean mptfc_init(void) 9262496af39SMoore, Eric Dean { 92705e8ec17SMichael Reed int error; 9282496af39SMoore, Eric Dean 9292496af39SMoore, Eric Dean show_mptmod_ver(my_NAME, my_VERSION); 9302496af39SMoore, Eric Dean 93105e8ec17SMichael Reed /* sanity check module parameter */ 93205e8ec17SMichael Reed if (mptfc_dev_loss_tmo == 0) 93305e8ec17SMichael Reed mptfc_dev_loss_tmo = MPTFC_DEV_LOSS_TMO; 93405e8ec17SMichael Reed 93505e8ec17SMichael Reed mptfc_transport_template = 93605e8ec17SMichael Reed fc_attach_transport(&mptfc_transport_functions); 93705e8ec17SMichael Reed 93805e8ec17SMichael Reed if (!mptfc_transport_template) 93905e8ec17SMichael Reed return -ENODEV; 94005e8ec17SMichael Reed 9412496af39SMoore, Eric Dean mptfcDoneCtx = mpt_register(mptscsih_io_done, MPTFC_DRIVER); 9422496af39SMoore, Eric Dean mptfcTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTFC_DRIVER); 9432496af39SMoore, Eric Dean mptfcInternalCtx = mpt_register(mptscsih_scandv_complete, MPTFC_DRIVER); 9442496af39SMoore, Eric Dean 9452496af39SMoore, Eric Dean if (mpt_event_register(mptfcDoneCtx, mptscsih_event_process) == 0) { 9463a892befSMoore, Eric devtverboseprintk((KERN_INFO MYNAM 9472496af39SMoore, Eric Dean ": Registered for IOC event notifications\n")); 9482496af39SMoore, Eric Dean } 9492496af39SMoore, Eric Dean 9502496af39SMoore, Eric Dean if (mpt_reset_register(mptfcDoneCtx, mptscsih_ioc_reset) == 0) { 9512496af39SMoore, Eric Dean dprintk((KERN_INFO MYNAM 9522496af39SMoore, Eric Dean ": Registered for IOC reset notifications\n")); 9532496af39SMoore, Eric Dean } 9542496af39SMoore, Eric Dean 95505e8ec17SMichael Reed error = pci_register_driver(&mptfc_driver); 9563bc7bf1dSMichael Reed if (error) 95705e8ec17SMichael Reed fc_release_transport(mptfc_transport_template); 95805e8ec17SMichael Reed 95905e8ec17SMichael Reed return error; 96005e8ec17SMichael Reed } 96105e8ec17SMichael Reed 96205e8ec17SMichael Reed /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 96305e8ec17SMichael Reed /** 96405e8ec17SMichael Reed * mptfc_remove - Removed fc infrastructure for devices 96505e8ec17SMichael Reed * @pdev: Pointer to pci_dev structure 96605e8ec17SMichael Reed * 96705e8ec17SMichael Reed */ 9683bc7bf1dSMichael Reed static void __devexit 9693bc7bf1dSMichael Reed mptfc_remove(struct pci_dev *pdev) 97005e8ec17SMichael Reed { 97105e8ec17SMichael Reed MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 97205e8ec17SMichael Reed struct mptfc_rport_info *p, *n; 973*65207fedSMoore, Eric struct workqueue_struct *work_q; 974*65207fedSMoore, Eric unsigned long flags; 975*65207fedSMoore, Eric 976*65207fedSMoore, Eric /* destroy workqueue */ 977*65207fedSMoore, Eric if ((work_q=ioc->fc_rescan_work_q)) { 978*65207fedSMoore, Eric spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); 979*65207fedSMoore, Eric ioc->fc_rescan_work_q = NULL; 980*65207fedSMoore, Eric spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); 981*65207fedSMoore, Eric destroy_workqueue(work_q); 982*65207fedSMoore, Eric } 98305e8ec17SMichael Reed 98405e8ec17SMichael Reed fc_remove_host(ioc->sh); 98505e8ec17SMichael Reed 98605e8ec17SMichael Reed list_for_each_entry_safe(p, n, &ioc->fc_rports, list) { 98705e8ec17SMichael Reed list_del(&p->list); 98805e8ec17SMichael Reed kfree(p); 98905e8ec17SMichael Reed } 99005e8ec17SMichael Reed 99105e8ec17SMichael Reed mptscsih_remove(pdev); 9922496af39SMoore, Eric Dean } 9932496af39SMoore, Eric Dean 9942496af39SMoore, Eric Dean /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 9952496af39SMoore, Eric Dean /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 9962496af39SMoore, Eric Dean /** 9972496af39SMoore, Eric Dean * mptfc_exit - Unregisters MPT adapter(s) 9982496af39SMoore, Eric Dean * 9992496af39SMoore, Eric Dean */ 10002496af39SMoore, Eric Dean static void __exit 10012496af39SMoore, Eric Dean mptfc_exit(void) 10022496af39SMoore, Eric Dean { 10032496af39SMoore, Eric Dean pci_unregister_driver(&mptfc_driver); 100405e8ec17SMichael Reed fc_release_transport(mptfc_transport_template); 10052496af39SMoore, Eric Dean 10062496af39SMoore, Eric Dean mpt_reset_deregister(mptfcDoneCtx); 10072496af39SMoore, Eric Dean dprintk((KERN_INFO MYNAM 10082496af39SMoore, Eric Dean ": Deregistered for IOC reset notifications\n")); 10092496af39SMoore, Eric Dean 10102496af39SMoore, Eric Dean mpt_event_deregister(mptfcDoneCtx); 10112496af39SMoore, Eric Dean dprintk((KERN_INFO MYNAM 10122496af39SMoore, Eric Dean ": Deregistered for IOC event notifications\n")); 10132496af39SMoore, Eric Dean 10142496af39SMoore, Eric Dean mpt_deregister(mptfcInternalCtx); 10152496af39SMoore, Eric Dean mpt_deregister(mptfcTaskCtx); 10162496af39SMoore, Eric Dean mpt_deregister(mptfcDoneCtx); 10172496af39SMoore, Eric Dean } 10182496af39SMoore, Eric Dean 10192496af39SMoore, Eric Dean module_init(mptfc_init); 10202496af39SMoore, Eric Dean module_exit(mptfc_exit); 1021