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 34505e8ec17SMichael Reed return 0; 34605e8ec17SMichael Reed } 34705e8ec17SMichael Reed 34805e8ec17SMichael Reed static void 34905e8ec17SMichael Reed mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0) 35005e8ec17SMichael Reed { 35105e8ec17SMichael Reed struct fc_rport_identifiers rport_ids; 35205e8ec17SMichael Reed struct fc_rport *rport; 35305e8ec17SMichael Reed struct mptfc_rport_info *ri; 3543bc7bf1dSMichael Reed int new_ri = 1; 35565207fedSMoore, Eric u64 pn, nn; 3563bc7bf1dSMichael Reed VirtTarget *vtarget; 357*6dd727daSmdr@sgi.com u32 roles = FC_RPORT_ROLE_UNKNOWN; 35805e8ec17SMichael Reed 35905e8ec17SMichael Reed if (mptfc_generate_rport_ids(pg0, &rport_ids) < 0) 36005e8ec17SMichael Reed return; 36105e8ec17SMichael Reed 362*6dd727daSmdr@sgi.com roles |= FC_RPORT_ROLE_FCP_TARGET; 363*6dd727daSmdr@sgi.com if (pg0->Protocol & MPI_FC_DEVICE_PAGE0_PROT_FCP_INITIATOR) 364*6dd727daSmdr@sgi.com roles |= FC_RPORT_ROLE_FCP_INITIATOR; 365*6dd727daSmdr@sgi.com 36605e8ec17SMichael Reed /* scan list looking for a match */ 36705e8ec17SMichael Reed list_for_each_entry(ri, &ioc->fc_rports, list) { 3683bc7bf1dSMichael Reed pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; 3693bc7bf1dSMichael Reed if (pn == rport_ids.port_name) { /* match */ 37005e8ec17SMichael Reed list_move_tail(&ri->list, &ioc->fc_rports); 3713bc7bf1dSMichael Reed new_ri = 0; 37205e8ec17SMichael Reed break; 37305e8ec17SMichael Reed } 37405e8ec17SMichael Reed } 3753bc7bf1dSMichael Reed if (new_ri) { /* allocate one */ 37605e8ec17SMichael Reed ri = kzalloc(sizeof(struct mptfc_rport_info), GFP_KERNEL); 37705e8ec17SMichael Reed if (!ri) 37805e8ec17SMichael Reed return; 37905e8ec17SMichael Reed list_add_tail(&ri->list, &ioc->fc_rports); 38005e8ec17SMichael Reed } 38105e8ec17SMichael Reed 38205e8ec17SMichael Reed ri->pg0 = *pg0; /* add/update pg0 data */ 38305e8ec17SMichael Reed ri->flags &= ~MPT_RPORT_INFO_FLAGS_MISSING; 38405e8ec17SMichael Reed 3853bc7bf1dSMichael Reed /* MPT_RPORT_INFO_FLAGS_REGISTERED - rport not previously deleted */ 38605e8ec17SMichael Reed if (!(ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED)) { 38705e8ec17SMichael Reed ri->flags |= MPT_RPORT_INFO_FLAGS_REGISTERED; 38805e8ec17SMichael Reed rport = fc_remote_port_add(ioc->sh, channel, &rport_ids); 38905e8ec17SMichael Reed if (rport) { 39005e8ec17SMichael Reed ri->rport = rport; 3913bc7bf1dSMichael Reed if (new_ri) /* may have been reset by user */ 39205e8ec17SMichael Reed rport->dev_loss_tmo = mptfc_dev_loss_tmo; 39305e8ec17SMichael Reed /* 39405e8ec17SMichael Reed * if already mapped, remap here. If not mapped, 3953bc7bf1dSMichael Reed * target_alloc will allocate vtarget and map, 3963bc7bf1dSMichael Reed * slave_alloc will fill in vdev from vtarget. 39705e8ec17SMichael Reed */ 3983bc7bf1dSMichael Reed if (ri->starget) { 3993bc7bf1dSMichael Reed vtarget = ri->starget->hostdata; 4003bc7bf1dSMichael Reed if (vtarget) { 4013bc7bf1dSMichael Reed vtarget->target_id = pg0->CurrentTargetID; 4023bc7bf1dSMichael Reed vtarget->bus_id = pg0->CurrentBus; 40305e8ec17SMichael Reed } 4043bc7bf1dSMichael Reed } 40565207fedSMoore, Eric *((struct mptfc_rport_info **)rport->dd_data) = ri; 406*6dd727daSmdr@sgi.com /* scan will be scheduled once rport becomes a target */ 407*6dd727daSmdr@sgi.com fc_remote_port_rolechg(rport,roles); 40865207fedSMoore, Eric 40965207fedSMoore, Eric pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; 41065207fedSMoore, Eric nn = (u64)ri->pg0.WWNN.High << 32 | (u64)ri->pg0.WWNN.Low; 4113bc7bf1dSMichael Reed dfcprintk ((MYIOC_s_INFO_FMT 4123bc7bf1dSMichael Reed "mptfc_reg_dev.%d: %x, %llx / %llx, tid %d, " 41305e8ec17SMichael Reed "rport tid %d, tmo %d\n", 4143bc7bf1dSMichael Reed ioc->name, 415914c2d8eSMoore, Eric ioc->sh->host_no, 41605e8ec17SMichael Reed pg0->PortIdentifier, 41765207fedSMoore, Eric (unsigned long long)nn, 41865207fedSMoore, Eric (unsigned long long)pn, 41905e8ec17SMichael Reed pg0->CurrentTargetID, 42005e8ec17SMichael Reed ri->rport->scsi_target_id, 4213bc7bf1dSMichael Reed ri->rport->dev_loss_tmo)); 42205e8ec17SMichael Reed } else { 42305e8ec17SMichael Reed list_del(&ri->list); 42405e8ec17SMichael Reed kfree(ri); 42505e8ec17SMichael Reed ri = NULL; 42605e8ec17SMichael Reed } 42705e8ec17SMichael Reed } 42805e8ec17SMichael Reed } 42905e8ec17SMichael Reed 43005e8ec17SMichael Reed /* 4313bc7bf1dSMichael Reed * OS entry point to allow for host driver to free allocated memory 4323bc7bf1dSMichael Reed * Called if no device present or device being unloaded 4333bc7bf1dSMichael Reed */ 4343bc7bf1dSMichael Reed static void 4353bc7bf1dSMichael Reed mptfc_target_destroy(struct scsi_target *starget) 4363bc7bf1dSMichael Reed { 4373bc7bf1dSMichael Reed struct fc_rport *rport; 4383bc7bf1dSMichael Reed struct mptfc_rport_info *ri; 4393bc7bf1dSMichael Reed 4403bc7bf1dSMichael Reed rport = starget_to_rport(starget); 4413bc7bf1dSMichael Reed if (rport) { 4423bc7bf1dSMichael Reed ri = *((struct mptfc_rport_info **)rport->dd_data); 4433bc7bf1dSMichael Reed if (ri) /* better be! */ 4443bc7bf1dSMichael Reed ri->starget = NULL; 4453bc7bf1dSMichael Reed } 4463bc7bf1dSMichael Reed if (starget->hostdata) 4473bc7bf1dSMichael Reed kfree(starget->hostdata); 4483bc7bf1dSMichael Reed starget->hostdata = NULL; 4493bc7bf1dSMichael Reed } 4503bc7bf1dSMichael Reed 4513bc7bf1dSMichael Reed /* 4523bc7bf1dSMichael Reed * OS entry point to allow host driver to alloc memory 4533bc7bf1dSMichael Reed * for each scsi target. Called once per device the bus scan. 4543bc7bf1dSMichael Reed * Return non-zero if allocation fails. 4553bc7bf1dSMichael Reed */ 4563bc7bf1dSMichael Reed static int 4573bc7bf1dSMichael Reed mptfc_target_alloc(struct scsi_target *starget) 4583bc7bf1dSMichael Reed { 4593bc7bf1dSMichael Reed VirtTarget *vtarget; 4603bc7bf1dSMichael Reed struct fc_rport *rport; 4613bc7bf1dSMichael Reed struct mptfc_rport_info *ri; 4623bc7bf1dSMichael Reed int rc; 4633bc7bf1dSMichael Reed 4643bc7bf1dSMichael Reed vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); 4653bc7bf1dSMichael Reed if (!vtarget) 4663bc7bf1dSMichael Reed return -ENOMEM; 4673bc7bf1dSMichael Reed starget->hostdata = vtarget; 4683bc7bf1dSMichael Reed 4693bc7bf1dSMichael Reed rc = -ENODEV; 4703bc7bf1dSMichael Reed rport = starget_to_rport(starget); 4713bc7bf1dSMichael Reed if (rport) { 4723bc7bf1dSMichael Reed ri = *((struct mptfc_rport_info **)rport->dd_data); 4733bc7bf1dSMichael Reed if (ri) { /* better be! */ 4743bc7bf1dSMichael Reed vtarget->target_id = ri->pg0.CurrentTargetID; 4753bc7bf1dSMichael Reed vtarget->bus_id = ri->pg0.CurrentBus; 4763bc7bf1dSMichael Reed ri->starget = starget; 4773bc7bf1dSMichael Reed rc = 0; 4783bc7bf1dSMichael Reed } 4793bc7bf1dSMichael Reed } 4803bc7bf1dSMichael Reed if (rc != 0) { 4813bc7bf1dSMichael Reed kfree(vtarget); 4823bc7bf1dSMichael Reed starget->hostdata = NULL; 4833bc7bf1dSMichael Reed } 4843bc7bf1dSMichael Reed 4853bc7bf1dSMichael Reed return rc; 4863bc7bf1dSMichael Reed } 4873bc7bf1dSMichael Reed 4883bc7bf1dSMichael Reed /* 48905e8ec17SMichael Reed * OS entry point to allow host driver to alloc memory 49005e8ec17SMichael Reed * for each scsi device. Called once per device the bus scan. 49105e8ec17SMichael Reed * Return non-zero if allocation fails. 49205e8ec17SMichael Reed * Init memory once per LUN. 49305e8ec17SMichael Reed */ 49403fbcbcdSAdrian Bunk static int 49505e8ec17SMichael Reed mptfc_slave_alloc(struct scsi_device *sdev) 49605e8ec17SMichael Reed { 49705e8ec17SMichael Reed MPT_SCSI_HOST *hd; 49805e8ec17SMichael Reed VirtTarget *vtarget; 49905e8ec17SMichael Reed VirtDevice *vdev; 50005e8ec17SMichael Reed struct scsi_target *starget; 50105e8ec17SMichael Reed struct fc_rport *rport; 50205e8ec17SMichael Reed 50305e8ec17SMichael Reed 50465207fedSMoore, Eric starget = scsi_target(sdev); 50565207fedSMoore, Eric rport = starget_to_rport(starget); 50605e8ec17SMichael Reed 50705e8ec17SMichael Reed if (!rport || fc_remote_port_chkready(rport)) 50805e8ec17SMichael Reed return -ENXIO; 50905e8ec17SMichael Reed 51005e8ec17SMichael Reed hd = (MPT_SCSI_HOST *)sdev->host->hostdata; 51105e8ec17SMichael Reed 5123bc7bf1dSMichael Reed vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL); 51305e8ec17SMichael Reed if (!vdev) { 51405e8ec17SMichael Reed printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", 51505e8ec17SMichael Reed hd->ioc->name, sizeof(VirtDevice)); 51605e8ec17SMichael Reed return -ENOMEM; 51705e8ec17SMichael Reed } 51805e8ec17SMichael Reed 51905e8ec17SMichael Reed 52005e8ec17SMichael Reed sdev->hostdata = vdev; 52105e8ec17SMichael Reed vtarget = starget->hostdata; 5223bc7bf1dSMichael Reed 52305e8ec17SMichael Reed if (vtarget->num_luns == 0) { 5243bc7bf1dSMichael Reed vtarget->ioc_id = hd->ioc->id; 52505e8ec17SMichael Reed vtarget->tflags = MPT_TARGET_FLAGS_Q_YES | 52605e8ec17SMichael Reed MPT_TARGET_FLAGS_VALID_INQUIRY; 52705e8ec17SMichael Reed hd->Targets[sdev->id] = vtarget; 52805e8ec17SMichael Reed } 52905e8ec17SMichael Reed 53005e8ec17SMichael Reed vdev->vtarget = vtarget; 53105e8ec17SMichael Reed vdev->lun = sdev->lun; 53205e8ec17SMichael Reed 53305e8ec17SMichael Reed vtarget->num_luns++; 53405e8ec17SMichael Reed 53565207fedSMoore, Eric 536914c2d8eSMoore, Eric #ifdef DMPT_DEBUG_FC 537914c2d8eSMoore, Eric { 53865207fedSMoore, Eric u64 nn, pn; 539914c2d8eSMoore, Eric struct mptfc_rport_info *ri; 540914c2d8eSMoore, Eric ri = *((struct mptfc_rport_info **)rport->dd_data); 54165207fedSMoore, Eric pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; 54265207fedSMoore, Eric nn = (u64)ri->pg0.WWNN.High << 32 | (u64)ri->pg0.WWNN.Low; 5433bc7bf1dSMichael Reed dfcprintk ((MYIOC_s_INFO_FMT 5443bc7bf1dSMichael Reed "mptfc_slv_alloc.%d: num_luns %d, sdev.id %d, " 54505e8ec17SMichael Reed "CurrentTargetID %d, %x %llx %llx\n", 546914c2d8eSMoore, Eric hd->ioc->name, 54705e8ec17SMichael Reed sdev->host->host_no, 54805e8ec17SMichael Reed vtarget->num_luns, 54905e8ec17SMichael Reed sdev->id, ri->pg0.CurrentTargetID, 55065207fedSMoore, Eric ri->pg0.PortIdentifier, 55165207fedSMoore, Eric (unsigned long long)pn, 55265207fedSMoore, Eric (unsigned long long)nn)); 553914c2d8eSMoore, Eric } 554914c2d8eSMoore, Eric #endif 55505e8ec17SMichael Reed 55605e8ec17SMichael Reed return 0; 55705e8ec17SMichael Reed } 55805e8ec17SMichael Reed 55905e8ec17SMichael Reed static int 56005e8ec17SMichael Reed mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 56105e8ec17SMichael Reed { 5623bc7bf1dSMichael Reed struct mptfc_rport_info *ri; 56305e8ec17SMichael Reed struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device)); 56405e8ec17SMichael Reed int err; 56505e8ec17SMichael Reed 56605e8ec17SMichael Reed err = fc_remote_port_chkready(rport); 56705e8ec17SMichael Reed if (unlikely(err)) { 56805e8ec17SMichael Reed SCpnt->result = err; 56905e8ec17SMichael Reed done(SCpnt); 57005e8ec17SMichael Reed return 0; 57105e8ec17SMichael Reed } 5723bc7bf1dSMichael Reed 57365207fedSMoore, Eric /* dd_data is null until finished adding target */ 57465207fedSMoore, Eric ri = *((struct mptfc_rport_info **)rport->dd_data); 57565207fedSMoore, Eric if (unlikely(!ri)) { 57665207fedSMoore, Eric dfcprintk ((MYIOC_s_INFO_FMT 57765207fedSMoore, Eric "mptfc_qcmd.%d: %d:%d, dd_data is null.\n", 57865207fedSMoore, Eric ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->name, 57965207fedSMoore, Eric ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->sh->host_no, 58065207fedSMoore, Eric SCpnt->device->id,SCpnt->device->lun)); 58165207fedSMoore, Eric SCpnt->result = DID_IMM_RETRY << 16; 58265207fedSMoore, Eric done(SCpnt); 58365207fedSMoore, Eric return 0; 58465207fedSMoore, Eric } 58565207fedSMoore, Eric 58665207fedSMoore, Eric err = mptscsih_qcmd(SCpnt,done); 58765207fedSMoore, Eric #ifdef DMPT_DEBUG_FC 58865207fedSMoore, Eric if (unlikely(err)) { 58965207fedSMoore, Eric dfcprintk ((MYIOC_s_INFO_FMT 59065207fedSMoore, Eric "mptfc_qcmd.%d: %d:%d, mptscsih_qcmd returns non-zero.\n", 59165207fedSMoore, Eric ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->name, 59265207fedSMoore, Eric ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->sh->host_no, 59365207fedSMoore, Eric SCpnt->device->id,SCpnt->device->lun)); 59465207fedSMoore, Eric } 59565207fedSMoore, Eric #endif 59665207fedSMoore, Eric return err; 59705e8ec17SMichael Reed } 59805e8ec17SMichael Reed 59905e8ec17SMichael Reed static void 60005e8ec17SMichael Reed mptfc_init_host_attr(MPT_ADAPTER *ioc,int portnum) 60105e8ec17SMichael Reed { 60205e8ec17SMichael Reed unsigned class = 0, cos = 0; 60305e8ec17SMichael Reed 60405e8ec17SMichael Reed /* don't know what to do as only one scsi (fc) host was allocated */ 60505e8ec17SMichael Reed if (portnum != 0) 60605e8ec17SMichael Reed return; 60705e8ec17SMichael Reed 60805e8ec17SMichael Reed class = ioc->fc_port_page0[portnum].SupportedServiceClass; 60905e8ec17SMichael Reed if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_1) 61005e8ec17SMichael Reed cos |= FC_COS_CLASS1; 61105e8ec17SMichael Reed if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_2) 61205e8ec17SMichael Reed cos |= FC_COS_CLASS2; 61305e8ec17SMichael Reed if (class & MPI_FCPORTPAGE0_SUPPORT_CLASS_3) 61405e8ec17SMichael Reed cos |= FC_COS_CLASS3; 61505e8ec17SMichael Reed 61605e8ec17SMichael Reed fc_host_node_name(ioc->sh) = 61705e8ec17SMichael Reed (u64)ioc->fc_port_page0[portnum].WWNN.High << 32 61805e8ec17SMichael Reed | (u64)ioc->fc_port_page0[portnum].WWNN.Low; 61905e8ec17SMichael Reed 62005e8ec17SMichael Reed fc_host_port_name(ioc->sh) = 62105e8ec17SMichael Reed (u64)ioc->fc_port_page0[portnum].WWPN.High << 32 62205e8ec17SMichael Reed | (u64)ioc->fc_port_page0[portnum].WWPN.Low; 62305e8ec17SMichael Reed 62405e8ec17SMichael Reed fc_host_port_id(ioc->sh) = ioc->fc_port_page0[portnum].PortIdentifier; 62505e8ec17SMichael Reed 62605e8ec17SMichael Reed fc_host_supported_classes(ioc->sh) = cos; 62705e8ec17SMichael Reed 62805e8ec17SMichael Reed fc_host_tgtid_bind_type(ioc->sh) = FC_TGTID_BIND_BY_WWPN; 62905e8ec17SMichael Reed } 63005e8ec17SMichael Reed 63105e8ec17SMichael Reed static void 63205e8ec17SMichael Reed mptfc_rescan_devices(void *arg) 63305e8ec17SMichael Reed { 63405e8ec17SMichael Reed MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 63505e8ec17SMichael Reed int ii; 63605e8ec17SMichael Reed int work_to_do; 63765207fedSMoore, Eric u64 pn; 63805e8ec17SMichael Reed unsigned long flags; 63905e8ec17SMichael Reed struct mptfc_rport_info *ri; 64005e8ec17SMichael Reed 64105e8ec17SMichael Reed do { 64205e8ec17SMichael Reed /* start by tagging all ports as missing */ 64305e8ec17SMichael Reed list_for_each_entry(ri, &ioc->fc_rports, list) { 64405e8ec17SMichael Reed if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) { 64505e8ec17SMichael Reed ri->flags |= MPT_RPORT_INFO_FLAGS_MISSING; 64605e8ec17SMichael Reed } 64705e8ec17SMichael Reed } 64805e8ec17SMichael Reed 64905e8ec17SMichael Reed /* 65005e8ec17SMichael Reed * now rescan devices known to adapter, 65105e8ec17SMichael Reed * will reregister existing rports 65205e8ec17SMichael Reed */ 65305e8ec17SMichael Reed for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) { 65405e8ec17SMichael Reed (void) mptbase_GetFcPortPage0(ioc, ii); 65505e8ec17SMichael Reed mptfc_init_host_attr(ioc,ii); /* refresh */ 65605e8ec17SMichael Reed mptfc_GetFcDevPage0(ioc,ii,mptfc_register_dev); 65705e8ec17SMichael Reed } 65805e8ec17SMichael Reed 65905e8ec17SMichael Reed /* delete devices still missing */ 66005e8ec17SMichael Reed list_for_each_entry(ri, &ioc->fc_rports, list) { 66105e8ec17SMichael Reed /* if newly missing, delete it */ 66265207fedSMoore, Eric if (ri->flags & MPT_RPORT_INFO_FLAGS_MISSING) { 66305e8ec17SMichael Reed 66405e8ec17SMichael Reed ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED| 66505e8ec17SMichael Reed MPT_RPORT_INFO_FLAGS_MISSING); 66665207fedSMoore, Eric fc_remote_port_delete(ri->rport); /* won't sleep */ 6673bc7bf1dSMichael Reed ri->rport = NULL; 66865207fedSMoore, Eric 66965207fedSMoore, Eric pn = (u64)ri->pg0.WWPN.High << 32 | 67065207fedSMoore, Eric (u64)ri->pg0.WWPN.Low; 6713bc7bf1dSMichael Reed dfcprintk ((MYIOC_s_INFO_FMT 6723bc7bf1dSMichael Reed "mptfc_rescan.%d: %llx deleted\n", 6733bc7bf1dSMichael Reed ioc->name, 6743bc7bf1dSMichael Reed ioc->sh->host_no, 67565207fedSMoore, Eric (unsigned long long)pn)); 67605e8ec17SMichael Reed } 67705e8ec17SMichael Reed } 67805e8ec17SMichael Reed 67905e8ec17SMichael Reed /* 68005e8ec17SMichael Reed * allow multiple passes as target state 68105e8ec17SMichael Reed * might have changed during scan 68205e8ec17SMichael Reed */ 68305e8ec17SMichael Reed spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); 68405e8ec17SMichael Reed if (ioc->fc_rescan_work_count > 2) /* only need one more */ 68505e8ec17SMichael Reed ioc->fc_rescan_work_count = 2; 68605e8ec17SMichael Reed work_to_do = --ioc->fc_rescan_work_count; 68705e8ec17SMichael Reed spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); 68805e8ec17SMichael Reed } while (work_to_do); 68905e8ec17SMichael Reed } 69005e8ec17SMichael Reed 6912496af39SMoore, Eric Dean static int 6922496af39SMoore, Eric Dean mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) 6932496af39SMoore, Eric Dean { 6942496af39SMoore, Eric Dean struct Scsi_Host *sh; 6952496af39SMoore, Eric Dean MPT_SCSI_HOST *hd; 6962496af39SMoore, Eric Dean MPT_ADAPTER *ioc; 6972496af39SMoore, Eric Dean unsigned long flags; 6981ca00bb7SChristoph Hellwig int ii; 6992496af39SMoore, Eric Dean int numSGE = 0; 7002496af39SMoore, Eric Dean int scale; 7012496af39SMoore, Eric Dean int ioc_cap; 7022496af39SMoore, Eric Dean int error=0; 7032496af39SMoore, Eric Dean int r; 7042496af39SMoore, Eric Dean 7052496af39SMoore, Eric Dean if ((r = mpt_attach(pdev,id)) != 0) 7062496af39SMoore, Eric Dean return r; 7072496af39SMoore, Eric Dean 7082496af39SMoore, Eric Dean ioc = pci_get_drvdata(pdev); 709d335cc38SMoore, Eric Dean ioc->DoneCtx = mptfcDoneCtx; 710d335cc38SMoore, Eric Dean ioc->TaskCtx = mptfcTaskCtx; 711d335cc38SMoore, Eric Dean ioc->InternalCtx = mptfcInternalCtx; 7122496af39SMoore, Eric Dean 7132496af39SMoore, Eric Dean /* Added sanity check on readiness of the MPT adapter. 7142496af39SMoore, Eric Dean */ 7152496af39SMoore, Eric Dean if (ioc->last_state != MPI_IOC_STATE_OPERATIONAL) { 7162496af39SMoore, Eric Dean printk(MYIOC_s_WARN_FMT 7172496af39SMoore, Eric Dean "Skipping because it's not operational!\n", 7182496af39SMoore, Eric Dean ioc->name); 7197acec1e7SMoore, Eric Dean error = -ENODEV; 7207acec1e7SMoore, Eric Dean goto out_mptfc_probe; 7212496af39SMoore, Eric Dean } 7222496af39SMoore, Eric Dean 7232496af39SMoore, Eric Dean if (!ioc->active) { 7242496af39SMoore, Eric Dean printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", 7252496af39SMoore, Eric Dean ioc->name); 7267acec1e7SMoore, Eric Dean error = -ENODEV; 7277acec1e7SMoore, Eric Dean goto out_mptfc_probe; 7282496af39SMoore, Eric Dean } 7292496af39SMoore, Eric Dean 7302496af39SMoore, Eric Dean /* Sanity check - ensure at least 1 port is INITIATOR capable 7312496af39SMoore, Eric Dean */ 7322496af39SMoore, Eric Dean ioc_cap = 0; 7332496af39SMoore, Eric Dean for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) { 7342496af39SMoore, Eric Dean if (ioc->pfacts[ii].ProtocolFlags & 7352496af39SMoore, Eric Dean MPI_PORTFACTS_PROTOCOL_INITIATOR) 7362496af39SMoore, Eric Dean ioc_cap ++; 7372496af39SMoore, Eric Dean } 7382496af39SMoore, Eric Dean 7392496af39SMoore, Eric Dean if (!ioc_cap) { 7402496af39SMoore, Eric Dean printk(MYIOC_s_WARN_FMT 7412496af39SMoore, Eric Dean "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n", 7422496af39SMoore, Eric Dean ioc->name, ioc); 74305e8ec17SMichael Reed return -ENODEV; 7442496af39SMoore, Eric Dean } 7452496af39SMoore, Eric Dean 7462496af39SMoore, Eric Dean sh = scsi_host_alloc(&mptfc_driver_template, sizeof(MPT_SCSI_HOST)); 7472496af39SMoore, Eric Dean 7482496af39SMoore, Eric Dean if (!sh) { 7492496af39SMoore, Eric Dean printk(MYIOC_s_WARN_FMT 7502496af39SMoore, Eric Dean "Unable to register controller with SCSI subsystem\n", 7512496af39SMoore, Eric Dean ioc->name); 7527acec1e7SMoore, Eric Dean error = -1; 7537acec1e7SMoore, Eric Dean goto out_mptfc_probe; 7542496af39SMoore, Eric Dean } 7552496af39SMoore, Eric Dean 75605e8ec17SMichael Reed INIT_WORK(&ioc->fc_rescan_work, mptfc_rescan_devices,(void *)ioc); 75705e8ec17SMichael Reed 7582496af39SMoore, Eric Dean spin_lock_irqsave(&ioc->FreeQlock, flags); 7592496af39SMoore, Eric Dean 7602496af39SMoore, Eric Dean /* Attach the SCSI Host to the IOC structure 7612496af39SMoore, Eric Dean */ 7622496af39SMoore, Eric Dean ioc->sh = sh; 7632496af39SMoore, Eric Dean 7642496af39SMoore, Eric Dean sh->io_port = 0; 7652496af39SMoore, Eric Dean sh->n_io_port = 0; 7662496af39SMoore, Eric Dean sh->irq = 0; 7672496af39SMoore, Eric Dean 7682496af39SMoore, Eric Dean /* set 16 byte cdb's */ 7692496af39SMoore, Eric Dean sh->max_cmd_len = 16; 7702496af39SMoore, Eric Dean 7712496af39SMoore, Eric Dean sh->max_id = MPT_MAX_FC_DEVICES<256 ? MPT_MAX_FC_DEVICES : 255; 7722496af39SMoore, Eric Dean 7732496af39SMoore, Eric Dean sh->max_lun = MPT_LAST_LUN + 1; 7742496af39SMoore, Eric Dean sh->max_channel = 0; 7752496af39SMoore, Eric Dean sh->this_id = ioc->pfacts[0].PortSCSIID; 7762496af39SMoore, Eric Dean 7772496af39SMoore, Eric Dean /* Required entry. 7782496af39SMoore, Eric Dean */ 7792496af39SMoore, Eric Dean sh->unique_id = ioc->id; 7802496af39SMoore, Eric Dean 7812496af39SMoore, Eric Dean /* Verify that we won't exceed the maximum 7822496af39SMoore, Eric Dean * number of chain buffers 7832496af39SMoore, Eric Dean * We can optimize: ZZ = req_sz/sizeof(SGE) 7842496af39SMoore, Eric Dean * For 32bit SGE's: 7852496af39SMoore, Eric Dean * numSGE = 1 + (ZZ-1)*(maxChain -1) + ZZ 7862496af39SMoore, Eric Dean * + (req_sz - 64)/sizeof(SGE) 7872496af39SMoore, Eric Dean * A slightly different algorithm is required for 7882496af39SMoore, Eric Dean * 64bit SGEs. 7892496af39SMoore, Eric Dean */ 7902496af39SMoore, Eric Dean scale = ioc->req_sz/(sizeof(dma_addr_t) + sizeof(u32)); 7912496af39SMoore, Eric Dean if (sizeof(dma_addr_t) == sizeof(u64)) { 7922496af39SMoore, Eric Dean numSGE = (scale - 1) * 7932496af39SMoore, Eric Dean (ioc->facts.MaxChainDepth-1) + scale + 7942496af39SMoore, Eric Dean (ioc->req_sz - 60) / (sizeof(dma_addr_t) + 7952496af39SMoore, Eric Dean sizeof(u32)); 7962496af39SMoore, Eric Dean } else { 7972496af39SMoore, Eric Dean numSGE = 1 + (scale - 1) * 7982496af39SMoore, Eric Dean (ioc->facts.MaxChainDepth-1) + scale + 7992496af39SMoore, Eric Dean (ioc->req_sz - 64) / (sizeof(dma_addr_t) + 8002496af39SMoore, Eric Dean sizeof(u32)); 8012496af39SMoore, Eric Dean } 8022496af39SMoore, Eric Dean 8032496af39SMoore, Eric Dean if (numSGE < sh->sg_tablesize) { 8042496af39SMoore, Eric Dean /* Reset this value */ 8052496af39SMoore, Eric Dean dprintk((MYIOC_s_INFO_FMT 8062496af39SMoore, Eric Dean "Resetting sg_tablesize to %d from %d\n", 8072496af39SMoore, Eric Dean ioc->name, numSGE, sh->sg_tablesize)); 8082496af39SMoore, Eric Dean sh->sg_tablesize = numSGE; 8092496af39SMoore, Eric Dean } 8102496af39SMoore, Eric Dean 8112496af39SMoore, Eric Dean spin_unlock_irqrestore(&ioc->FreeQlock, flags); 8122496af39SMoore, Eric Dean 8132496af39SMoore, Eric Dean hd = (MPT_SCSI_HOST *) sh->hostdata; 8142496af39SMoore, Eric Dean hd->ioc = ioc; 8152496af39SMoore, Eric Dean 8162496af39SMoore, Eric Dean /* SCSI needs scsi_cmnd lookup table! 8172496af39SMoore, Eric Dean * (with size equal to req_depth*PtrSz!) 8182496af39SMoore, Eric Dean */ 8191ca00bb7SChristoph Hellwig hd->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); 8201ca00bb7SChristoph Hellwig if (!hd->ScsiLookup) { 8212496af39SMoore, Eric Dean error = -ENOMEM; 8227acec1e7SMoore, Eric Dean goto out_mptfc_probe; 8232496af39SMoore, Eric Dean } 8242496af39SMoore, Eric Dean 8251ca00bb7SChristoph Hellwig dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n", 8261ca00bb7SChristoph Hellwig ioc->name, hd->ScsiLookup)); 8272496af39SMoore, Eric Dean 8282496af39SMoore, Eric Dean /* Allocate memory for the device structures. 8292496af39SMoore, Eric Dean * A non-Null pointer at an offset 8302496af39SMoore, Eric Dean * indicates a device exists. 8312496af39SMoore, Eric Dean * max_id = 1 + maximum id (hosts.h) 8322496af39SMoore, Eric Dean */ 8331ca00bb7SChristoph Hellwig hd->Targets = kcalloc(sh->max_id, sizeof(void *), GFP_ATOMIC); 8341ca00bb7SChristoph Hellwig if (!hd->Targets) { 8352496af39SMoore, Eric Dean error = -ENOMEM; 8367acec1e7SMoore, Eric Dean goto out_mptfc_probe; 8372496af39SMoore, Eric Dean } 8382496af39SMoore, Eric Dean 8391ca00bb7SChristoph Hellwig dprintk((KERN_INFO " vdev @ %p\n", hd->Targets)); 8402496af39SMoore, Eric Dean 8412496af39SMoore, Eric Dean /* Clear the TM flags 8422496af39SMoore, Eric Dean */ 8432496af39SMoore, Eric Dean hd->tmPending = 0; 8442496af39SMoore, Eric Dean hd->tmState = TM_STATE_NONE; 8452496af39SMoore, Eric Dean hd->resetPending = 0; 8462496af39SMoore, Eric Dean hd->abortSCpnt = NULL; 8472496af39SMoore, Eric Dean 8482496af39SMoore, Eric Dean /* Clear the pointer used to store 8492496af39SMoore, Eric Dean * single-threaded commands, i.e., those 8502496af39SMoore, Eric Dean * issued during a bus scan, dv and 8512496af39SMoore, Eric Dean * configuration pages. 8522496af39SMoore, Eric Dean */ 8532496af39SMoore, Eric Dean hd->cmdPtr = NULL; 8542496af39SMoore, Eric Dean 8552496af39SMoore, Eric Dean /* Initialize this SCSI Hosts' timers 8562496af39SMoore, Eric Dean * To use, set the timer expires field 8572496af39SMoore, Eric Dean * and add_timer 8582496af39SMoore, Eric Dean */ 8592496af39SMoore, Eric Dean init_timer(&hd->timer); 8602496af39SMoore, Eric Dean hd->timer.data = (unsigned long) hd; 8612496af39SMoore, Eric Dean hd->timer.function = mptscsih_timer_expired; 8622496af39SMoore, Eric Dean 8632496af39SMoore, Eric Dean hd->mpt_pq_filter = mpt_pq_filter; 8642496af39SMoore, Eric Dean 8652496af39SMoore, Eric Dean ddvprintk((MYIOC_s_INFO_FMT 8662496af39SMoore, Eric Dean "mpt_pq_filter %x\n", 8672496af39SMoore, Eric Dean ioc->name, 8682496af39SMoore, Eric Dean mpt_pq_filter)); 8692496af39SMoore, Eric Dean 8702496af39SMoore, Eric Dean init_waitqueue_head(&hd->scandv_waitq); 8712496af39SMoore, Eric Dean hd->scandv_wait_done = 0; 8722496af39SMoore, Eric Dean hd->last_queue_full = 0; 8732496af39SMoore, Eric Dean 87405e8ec17SMichael Reed sh->transportt = mptfc_transport_template; 8752496af39SMoore, Eric Dean error = scsi_add_host (sh, &ioc->pcidev->dev); 8762496af39SMoore, Eric Dean if(error) { 8772496af39SMoore, Eric Dean dprintk((KERN_ERR MYNAM 8782496af39SMoore, Eric Dean "scsi_add_host failed\n")); 8797acec1e7SMoore, Eric Dean goto out_mptfc_probe; 8802496af39SMoore, Eric Dean } 8812496af39SMoore, Eric Dean 88265207fedSMoore, Eric /* initialize workqueue */ 88365207fedSMoore, Eric 88465207fedSMoore, Eric snprintf(ioc->fc_rescan_work_q_name, KOBJ_NAME_LEN, "mptfc_wq_%d", 88565207fedSMoore, Eric sh->host_no); 88665207fedSMoore, Eric ioc->fc_rescan_work_q = 88765207fedSMoore, Eric create_singlethread_workqueue(ioc->fc_rescan_work_q_name); 88865207fedSMoore, Eric if (!ioc->fc_rescan_work_q) 88965207fedSMoore, Eric goto out_mptfc_probe; 89065207fedSMoore, Eric 89165207fedSMoore, Eric /* 89265207fedSMoore, Eric * scan for rports - 89365207fedSMoore, Eric * by doing it via the workqueue, some locking is eliminated 89465207fedSMoore, Eric */ 89565207fedSMoore, Eric 89665207fedSMoore, Eric ioc->fc_rescan_work_count = 1; 89765207fedSMoore, Eric queue_work(ioc->fc_rescan_work_q, &ioc->fc_rescan_work); 89865207fedSMoore, Eric flush_workqueue(ioc->fc_rescan_work_q); 89905e8ec17SMichael Reed 9002496af39SMoore, Eric Dean return 0; 9012496af39SMoore, Eric Dean 9027acec1e7SMoore, Eric Dean out_mptfc_probe: 9032496af39SMoore, Eric Dean 9042496af39SMoore, Eric Dean mptscsih_remove(pdev); 9052496af39SMoore, Eric Dean return error; 9062496af39SMoore, Eric Dean } 9072496af39SMoore, Eric Dean 9082496af39SMoore, Eric Dean static struct pci_driver mptfc_driver = { 9092496af39SMoore, Eric Dean .name = "mptfc", 9102496af39SMoore, Eric Dean .id_table = mptfc_pci_table, 9112496af39SMoore, Eric Dean .probe = mptfc_probe, 91205e8ec17SMichael Reed .remove = __devexit_p(mptfc_remove), 9132496af39SMoore, Eric Dean .shutdown = mptscsih_shutdown, 9142496af39SMoore, Eric Dean #ifdef CONFIG_PM 9152496af39SMoore, Eric Dean .suspend = mptscsih_suspend, 9162496af39SMoore, Eric Dean .resume = mptscsih_resume, 9172496af39SMoore, Eric Dean #endif 9182496af39SMoore, Eric Dean }; 9192496af39SMoore, Eric Dean 9202496af39SMoore, Eric Dean /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 9212496af39SMoore, Eric Dean /** 9222496af39SMoore, Eric Dean * mptfc_init - Register MPT adapter(s) as SCSI host(s) with 9232496af39SMoore, Eric Dean * linux scsi mid-layer. 9242496af39SMoore, Eric Dean * 9252496af39SMoore, Eric Dean * Returns 0 for success, non-zero for failure. 9262496af39SMoore, Eric Dean */ 9272496af39SMoore, Eric Dean static int __init 9282496af39SMoore, Eric Dean mptfc_init(void) 9292496af39SMoore, Eric Dean { 93005e8ec17SMichael Reed int error; 9312496af39SMoore, Eric Dean 9322496af39SMoore, Eric Dean show_mptmod_ver(my_NAME, my_VERSION); 9332496af39SMoore, Eric Dean 93405e8ec17SMichael Reed /* sanity check module parameter */ 93505e8ec17SMichael Reed if (mptfc_dev_loss_tmo == 0) 93605e8ec17SMichael Reed mptfc_dev_loss_tmo = MPTFC_DEV_LOSS_TMO; 93705e8ec17SMichael Reed 93805e8ec17SMichael Reed mptfc_transport_template = 93905e8ec17SMichael Reed fc_attach_transport(&mptfc_transport_functions); 94005e8ec17SMichael Reed 94105e8ec17SMichael Reed if (!mptfc_transport_template) 94205e8ec17SMichael Reed return -ENODEV; 94305e8ec17SMichael Reed 9442496af39SMoore, Eric Dean mptfcDoneCtx = mpt_register(mptscsih_io_done, MPTFC_DRIVER); 9452496af39SMoore, Eric Dean mptfcTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTFC_DRIVER); 9462496af39SMoore, Eric Dean mptfcInternalCtx = mpt_register(mptscsih_scandv_complete, MPTFC_DRIVER); 9472496af39SMoore, Eric Dean 9482496af39SMoore, Eric Dean if (mpt_event_register(mptfcDoneCtx, mptscsih_event_process) == 0) { 9493a892befSMoore, Eric devtverboseprintk((KERN_INFO MYNAM 9502496af39SMoore, Eric Dean ": Registered for IOC event notifications\n")); 9512496af39SMoore, Eric Dean } 9522496af39SMoore, Eric Dean 9532496af39SMoore, Eric Dean if (mpt_reset_register(mptfcDoneCtx, mptscsih_ioc_reset) == 0) { 9542496af39SMoore, Eric Dean dprintk((KERN_INFO MYNAM 9552496af39SMoore, Eric Dean ": Registered for IOC reset notifications\n")); 9562496af39SMoore, Eric Dean } 9572496af39SMoore, Eric Dean 95805e8ec17SMichael Reed error = pci_register_driver(&mptfc_driver); 9593bc7bf1dSMichael Reed if (error) 96005e8ec17SMichael Reed fc_release_transport(mptfc_transport_template); 96105e8ec17SMichael Reed 96205e8ec17SMichael Reed return error; 96305e8ec17SMichael Reed } 96405e8ec17SMichael Reed 96505e8ec17SMichael Reed /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 96605e8ec17SMichael Reed /** 96705e8ec17SMichael Reed * mptfc_remove - Removed fc infrastructure for devices 96805e8ec17SMichael Reed * @pdev: Pointer to pci_dev structure 96905e8ec17SMichael Reed * 97005e8ec17SMichael Reed */ 9713bc7bf1dSMichael Reed static void __devexit 9723bc7bf1dSMichael Reed mptfc_remove(struct pci_dev *pdev) 97305e8ec17SMichael Reed { 97405e8ec17SMichael Reed MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 97505e8ec17SMichael Reed struct mptfc_rport_info *p, *n; 97665207fedSMoore, Eric struct workqueue_struct *work_q; 97765207fedSMoore, Eric unsigned long flags; 97865207fedSMoore, Eric 97965207fedSMoore, Eric /* destroy workqueue */ 98065207fedSMoore, Eric if ((work_q=ioc->fc_rescan_work_q)) { 98165207fedSMoore, Eric spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); 98265207fedSMoore, Eric ioc->fc_rescan_work_q = NULL; 98365207fedSMoore, Eric spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); 98465207fedSMoore, Eric destroy_workqueue(work_q); 98565207fedSMoore, Eric } 98605e8ec17SMichael Reed 98705e8ec17SMichael Reed fc_remove_host(ioc->sh); 98805e8ec17SMichael Reed 98905e8ec17SMichael Reed list_for_each_entry_safe(p, n, &ioc->fc_rports, list) { 99005e8ec17SMichael Reed list_del(&p->list); 99105e8ec17SMichael Reed kfree(p); 99205e8ec17SMichael Reed } 99305e8ec17SMichael Reed 99405e8ec17SMichael Reed mptscsih_remove(pdev); 9952496af39SMoore, Eric Dean } 9962496af39SMoore, Eric Dean 9972496af39SMoore, Eric Dean /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 9982496af39SMoore, Eric Dean /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 9992496af39SMoore, Eric Dean /** 10002496af39SMoore, Eric Dean * mptfc_exit - Unregisters MPT adapter(s) 10012496af39SMoore, Eric Dean * 10022496af39SMoore, Eric Dean */ 10032496af39SMoore, Eric Dean static void __exit 10042496af39SMoore, Eric Dean mptfc_exit(void) 10052496af39SMoore, Eric Dean { 10062496af39SMoore, Eric Dean pci_unregister_driver(&mptfc_driver); 100705e8ec17SMichael Reed fc_release_transport(mptfc_transport_template); 10082496af39SMoore, Eric Dean 10092496af39SMoore, Eric Dean mpt_reset_deregister(mptfcDoneCtx); 10102496af39SMoore, Eric Dean dprintk((KERN_INFO MYNAM 10112496af39SMoore, Eric Dean ": Deregistered for IOC reset notifications\n")); 10122496af39SMoore, Eric Dean 10132496af39SMoore, Eric Dean mpt_event_deregister(mptfcDoneCtx); 10142496af39SMoore, Eric Dean dprintk((KERN_INFO MYNAM 10152496af39SMoore, Eric Dean ": Deregistered for IOC event notifications\n")); 10162496af39SMoore, Eric Dean 10172496af39SMoore, Eric Dean mpt_deregister(mptfcInternalCtx); 10182496af39SMoore, Eric Dean mpt_deregister(mptfcTaskCtx); 10192496af39SMoore, Eric Dean mpt_deregister(mptfcDoneCtx); 10202496af39SMoore, Eric Dean } 10212496af39SMoore, Eric Dean 10222496af39SMoore, Eric Dean module_init(mptfc_init); 10232496af39SMoore, Eric Dean module_exit(mptfc_exit); 1024