|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1 | /******************************************************************* | 
|  | 2 | * This file is part of the Emulex Linux Device Driver for         * | 
| James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 3 | * Fibre Channel Host Bus Adapters.                                * | 
| James Smart | 9413aff | 2007-04-25 09:53:35 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2007 Emulex.  All rights reserved.           * | 
| James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 5 | * EMULEX and SLI are trademarks of Emulex.                        * | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6 | * www.emulex.com                                                  * | 
| James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig              * | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 8 | *                                                                 * | 
|  | 9 | * This program is free software; you can redistribute it and/or   * | 
| James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 10 | * modify it under the terms of version 2 of the GNU General       * | 
|  | 11 | * Public License as published by the Free Software Foundation.    * | 
|  | 12 | * This program is distributed in the hope that it will be useful. * | 
|  | 13 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          * | 
|  | 14 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  * | 
|  | 15 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      * | 
|  | 16 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * | 
|  | 17 | * TO BE LEGALLY INVALID.  See the GNU General Public License for  * | 
|  | 18 | * more details, a copy of which can be found in the file COPYING  * | 
|  | 19 | * included with this package.                                     * | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 20 | *******************************************************************/ | 
|  | 21 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 22 | #include <linux/blkdev.h> | 
|  | 23 | #include <linux/delay.h> | 
|  | 24 | #include <linux/dma-mapping.h> | 
|  | 25 | #include <linux/idr.h> | 
|  | 26 | #include <linux/interrupt.h> | 
|  | 27 | #include <linux/kthread.h> | 
|  | 28 | #include <linux/pci.h> | 
|  | 29 | #include <linux/spinlock.h> | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 30 | #include <linux/ctype.h> | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 31 |  | 
| James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 32 | #include <scsi/scsi.h> | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 33 | #include <scsi/scsi_device.h> | 
|  | 34 | #include <scsi/scsi_host.h> | 
|  | 35 | #include <scsi/scsi_transport_fc.h> | 
|  | 36 |  | 
|  | 37 | #include "lpfc_hw.h" | 
|  | 38 | #include "lpfc_sli.h" | 
|  | 39 | #include "lpfc_disc.h" | 
|  | 40 | #include "lpfc_scsi.h" | 
|  | 41 | #include "lpfc.h" | 
|  | 42 | #include "lpfc_logmsg.h" | 
|  | 43 | #include "lpfc_crtn.h" | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 44 | #include "lpfc_vport.h" | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 45 | #include "lpfc_version.h" | 
|  | 46 |  | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 47 | static int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *, int); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 48 | static void lpfc_get_hba_model_desc(struct lpfc_hba *, uint8_t *, uint8_t *); | 
|  | 49 | static int lpfc_post_rcv_buf(struct lpfc_hba *); | 
|  | 50 |  | 
|  | 51 | static struct scsi_transport_template *lpfc_transport_template = NULL; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 52 | static struct scsi_transport_template *lpfc_vport_transport_template = NULL; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 53 | static DEFINE_IDR(lpfc_hba_index); | 
|  | 54 |  | 
|  | 55 | /************************************************************************/ | 
|  | 56 | /*                                                                      */ | 
|  | 57 | /*    lpfc_config_port_prep                                             */ | 
|  | 58 | /*    This routine will do LPFC initialization prior to the             */ | 
|  | 59 | /*    CONFIG_PORT mailbox command. This will be initialized             */ | 
|  | 60 | /*    as a SLI layer callback routine.                                  */ | 
|  | 61 | /*    This routine returns 0 on success or -ERESTART if it wants        */ | 
|  | 62 | /*    the SLI layer to reset the HBA and try again. Any                 */ | 
|  | 63 | /*    other return value indicates an error.                            */ | 
|  | 64 | /*                                                                      */ | 
|  | 65 | /************************************************************************/ | 
|  | 66 | int | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 67 | lpfc_config_port_prep(struct lpfc_hba *phba) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 68 | { | 
|  | 69 | lpfc_vpd_t *vp = &phba->vpd; | 
|  | 70 | int i = 0, rc; | 
|  | 71 | LPFC_MBOXQ_t *pmb; | 
|  | 72 | MAILBOX_t *mb; | 
|  | 73 | char *lpfc_vpd_data = NULL; | 
|  | 74 | uint16_t offset = 0; | 
|  | 75 | static char licensed[56] = | 
|  | 76 | "key unlock for use with gnu public licensed code only\0"; | 
| James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 77 | static int init_key = 1; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 78 |  | 
|  | 79 | pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 
|  | 80 | if (!pmb) { | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 81 | phba->link_state = LPFC_HBA_ERROR; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 82 | return -ENOMEM; | 
|  | 83 | } | 
|  | 84 |  | 
|  | 85 | mb = &pmb->mb; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 86 | phba->link_state = LPFC_INIT_MBX_CMDS; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 87 |  | 
|  | 88 | if (lpfc_is_LC_HBA(phba->pcidev->device)) { | 
| James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 89 | if (init_key) { | 
|  | 90 | uint32_t *ptext = (uint32_t *) licensed; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 91 |  | 
| James Smart | 65a29c1 | 2006-07-06 15:50:50 -0400 | [diff] [blame] | 92 | for (i = 0; i < 56; i += sizeof (uint32_t), ptext++) | 
|  | 93 | *ptext = cpu_to_be32(*ptext); | 
|  | 94 | init_key = 0; | 
|  | 95 | } | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 96 |  | 
|  | 97 | lpfc_read_nv(phba, pmb); | 
|  | 98 | memset((char*)mb->un.varRDnvp.rsvd3, 0, | 
|  | 99 | sizeof (mb->un.varRDnvp.rsvd3)); | 
|  | 100 | memcpy((char*)mb->un.varRDnvp.rsvd3, licensed, | 
|  | 101 | sizeof (licensed)); | 
|  | 102 |  | 
|  | 103 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); | 
|  | 104 |  | 
|  | 105 | if (rc != MBX_SUCCESS) { | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 106 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 107 | "0324 Config Port initialization " | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 108 | "error, mbxCmd x%x READ_NVPARM, " | 
|  | 109 | "mbxStatus x%x\n", | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 110 | mb->mbxCommand, mb->mbxStatus); | 
|  | 111 | mempool_free(pmb, phba->mbox_mem_pool); | 
|  | 112 | return -ERESTART; | 
|  | 113 | } | 
|  | 114 | memcpy(phba->wwnn, (char *)mb->un.varRDnvp.nodename, | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 115 | sizeof(phba->wwnn)); | 
|  | 116 | memcpy(phba->wwpn, (char *)mb->un.varRDnvp.portname, | 
|  | 117 | sizeof(phba->wwpn)); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 118 | } | 
|  | 119 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 120 | phba->sli3_options = 0x0; | 
|  | 121 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 122 | /* Setup and issue mailbox READ REV command */ | 
|  | 123 | lpfc_read_rev(phba, pmb); | 
|  | 124 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); | 
|  | 125 | if (rc != MBX_SUCCESS) { | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 126 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 127 | "0439 Adapter failed to init, mbxCmd x%x " | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 128 | "READ_REV, mbxStatus x%x\n", | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 129 | mb->mbxCommand, mb->mbxStatus); | 
|  | 130 | mempool_free( pmb, phba->mbox_mem_pool); | 
|  | 131 | return -ERESTART; | 
|  | 132 | } | 
|  | 133 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 134 |  | 
| James.Smart@Emulex.Com | 1de933f | 2005-11-28 11:41:15 -0500 | [diff] [blame] | 135 | /* | 
|  | 136 | * The value of rr must be 1 since the driver set the cv field to 1. | 
|  | 137 | * This setting requires the FW to set all revision fields. | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 138 | */ | 
| James.Smart@Emulex.Com | 1de933f | 2005-11-28 11:41:15 -0500 | [diff] [blame] | 139 | if (mb->un.varRdRev.rr == 0) { | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 140 | vp->rev.rBit = 0; | 
| James.Smart@Emulex.Com | 1de933f | 2005-11-28 11:41:15 -0500 | [diff] [blame] | 141 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 142 | "0440 Adapter failed to init, READ_REV has " | 
|  | 143 | "missing revision information.\n"); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 144 | mempool_free(pmb, phba->mbox_mem_pool); | 
|  | 145 | return -ERESTART; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 146 | } | 
|  | 147 |  | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 148 | if (phba->sli_rev == 3 && !mb->un.varRdRev.v3rsp) | 
|  | 149 | return -EINVAL; | 
|  | 150 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 151 | /* Save information as VPD data */ | 
| James.Smart@Emulex.Com | 1de933f | 2005-11-28 11:41:15 -0500 | [diff] [blame] | 152 | vp->rev.rBit = 1; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 153 | memcpy(&vp->sli3Feat, &mb->un.varRdRev.sli3Feat, sizeof(uint32_t)); | 
| James.Smart@Emulex.Com | 1de933f | 2005-11-28 11:41:15 -0500 | [diff] [blame] | 154 | vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev; | 
|  | 155 | memcpy(vp->rev.sli1FwName, (char*) mb->un.varRdRev.sli1FwName, 16); | 
|  | 156 | vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev; | 
|  | 157 | memcpy(vp->rev.sli2FwName, (char *) mb->un.varRdRev.sli2FwName, 16); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 158 | vp->rev.biuRev = mb->un.varRdRev.biuRev; | 
|  | 159 | vp->rev.smRev = mb->un.varRdRev.smRev; | 
|  | 160 | vp->rev.smFwRev = mb->un.varRdRev.un.smFwRev; | 
|  | 161 | vp->rev.endecRev = mb->un.varRdRev.endecRev; | 
|  | 162 | vp->rev.fcphHigh = mb->un.varRdRev.fcphHigh; | 
|  | 163 | vp->rev.fcphLow = mb->un.varRdRev.fcphLow; | 
|  | 164 | vp->rev.feaLevelHigh = mb->un.varRdRev.feaLevelHigh; | 
|  | 165 | vp->rev.feaLevelLow = mb->un.varRdRev.feaLevelLow; | 
|  | 166 | vp->rev.postKernRev = mb->un.varRdRev.postKernRev; | 
|  | 167 | vp->rev.opFwRev = mb->un.varRdRev.opFwRev; | 
|  | 168 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 169 | /* If the sli feature level is less then 9, we must | 
|  | 170 | * tear down all RPIs and VPIs on link down if NPIV | 
|  | 171 | * is enabled. | 
|  | 172 | */ | 
|  | 173 | if (vp->rev.feaLevelHigh < 9) | 
|  | 174 | phba->sli3_options |= LPFC_SLI3_VPORT_TEARDOWN; | 
|  | 175 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 176 | if (lpfc_is_LC_HBA(phba->pcidev->device)) | 
|  | 177 | memcpy(phba->RandomData, (char *)&mb->un.varWords[24], | 
|  | 178 | sizeof (phba->RandomData)); | 
|  | 179 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 180 | /* Get adapter VPD information */ | 
|  | 181 | pmb->context2 = kmalloc(DMP_RSP_SIZE, GFP_KERNEL); | 
|  | 182 | if (!pmb->context2) | 
|  | 183 | goto out_free_mbox; | 
|  | 184 | lpfc_vpd_data = kmalloc(DMP_VPD_SIZE, GFP_KERNEL); | 
|  | 185 | if (!lpfc_vpd_data) | 
|  | 186 | goto out_free_context2; | 
|  | 187 |  | 
|  | 188 | do { | 
|  | 189 | lpfc_dump_mem(phba, pmb, offset); | 
|  | 190 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); | 
|  | 191 |  | 
|  | 192 | if (rc != MBX_SUCCESS) { | 
|  | 193 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 194 | "0441 VPD not present on adapter, " | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 195 | "mbxCmd x%x DUMP VPD, mbxStatus x%x\n", | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 196 | mb->mbxCommand, mb->mbxStatus); | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 197 | mb->un.varDmp.word_cnt = 0; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 198 | } | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 199 | if (mb->un.varDmp.word_cnt > DMP_VPD_SIZE - offset) | 
|  | 200 | mb->un.varDmp.word_cnt = DMP_VPD_SIZE - offset; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 201 | lpfc_sli_pcimem_bcopy(pmb->context2, lpfc_vpd_data + offset, | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 202 | mb->un.varDmp.word_cnt); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 203 | offset += mb->un.varDmp.word_cnt; | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 204 | } while (mb->un.varDmp.word_cnt && offset < DMP_VPD_SIZE); | 
|  | 205 | lpfc_parse_vpd(phba, lpfc_vpd_data, offset); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 206 |  | 
|  | 207 | kfree(lpfc_vpd_data); | 
|  | 208 | out_free_context2: | 
|  | 209 | kfree(pmb->context2); | 
|  | 210 | out_free_mbox: | 
|  | 211 | mempool_free(pmb, phba->mbox_mem_pool); | 
|  | 212 | return 0; | 
|  | 213 | } | 
|  | 214 |  | 
|  | 215 | /************************************************************************/ | 
|  | 216 | /*                                                                      */ | 
|  | 217 | /*    lpfc_config_port_post                                             */ | 
|  | 218 | /*    This routine will do LPFC initialization after the                */ | 
|  | 219 | /*    CONFIG_PORT mailbox command. This will be initialized             */ | 
|  | 220 | /*    as a SLI layer callback routine.                                  */ | 
|  | 221 | /*    This routine returns 0 on success. Any other return value         */ | 
|  | 222 | /*    indicates an error.                                               */ | 
|  | 223 | /*                                                                      */ | 
|  | 224 | /************************************************************************/ | 
|  | 225 | int | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 226 | lpfc_config_port_post(struct lpfc_hba *phba) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 227 | { | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 228 | struct lpfc_vport *vport = phba->pport; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 229 | LPFC_MBOXQ_t *pmb; | 
|  | 230 | MAILBOX_t *mb; | 
|  | 231 | struct lpfc_dmabuf *mp; | 
|  | 232 | struct lpfc_sli *psli = &phba->sli; | 
|  | 233 | uint32_t status, timeout; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 234 | int i, j; | 
|  | 235 | int rc; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 236 |  | 
|  | 237 | pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 
|  | 238 | if (!pmb) { | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 239 | phba->link_state = LPFC_HBA_ERROR; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 240 | return -ENOMEM; | 
|  | 241 | } | 
|  | 242 | mb = &pmb->mb; | 
|  | 243 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 244 | /* Get login parameters for NID.  */ | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 245 | lpfc_read_sparam(phba, pmb, 0); | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 246 | pmb->vport = vport; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 247 | if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 248 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 249 | "0448 Adapter failed init, mbxCmd x%x " | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 250 | "READ_SPARM mbxStatus x%x\n", | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 251 | mb->mbxCommand, mb->mbxStatus); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 252 | phba->link_state = LPFC_HBA_ERROR; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 253 | mp = (struct lpfc_dmabuf *) pmb->context1; | 
|  | 254 | mempool_free( pmb, phba->mbox_mem_pool); | 
|  | 255 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 
|  | 256 | kfree(mp); | 
|  | 257 | return -EIO; | 
|  | 258 | } | 
|  | 259 |  | 
|  | 260 | mp = (struct lpfc_dmabuf *) pmb->context1; | 
|  | 261 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 262 | memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm)); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 263 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 
|  | 264 | kfree(mp); | 
|  | 265 | pmb->context1 = NULL; | 
|  | 266 |  | 
| James Smart | a12e07b | 2006-12-02 13:35:30 -0500 | [diff] [blame] | 267 | if (phba->cfg_soft_wwnn) | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 268 | u64_to_wwn(phba->cfg_soft_wwnn, | 
|  | 269 | vport->fc_sparam.nodeName.u.wwn); | 
| James Smart | c3f28af | 2006-08-18 17:47:18 -0400 | [diff] [blame] | 270 | if (phba->cfg_soft_wwpn) | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 271 | u64_to_wwn(phba->cfg_soft_wwpn, | 
|  | 272 | vport->fc_sparam.portName.u.wwn); | 
|  | 273 | memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName, | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 274 | sizeof (struct lpfc_name)); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 275 | memcpy(&vport->fc_portname, &vport->fc_sparam.portName, | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 276 | sizeof (struct lpfc_name)); | 
|  | 277 | /* If no serial number in VPD data, use low 6 bytes of WWNN */ | 
|  | 278 | /* This should be consolidated into parse_vpd ? - mr */ | 
|  | 279 | if (phba->SerialNumber[0] == 0) { | 
|  | 280 | uint8_t *outptr; | 
|  | 281 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 282 | outptr = &vport->fc_nodename.u.s.IEEE[0]; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 283 | for (i = 0; i < 12; i++) { | 
|  | 284 | status = *outptr++; | 
|  | 285 | j = ((status & 0xf0) >> 4); | 
|  | 286 | if (j <= 9) | 
|  | 287 | phba->SerialNumber[i] = | 
|  | 288 | (char)((uint8_t) 0x30 + (uint8_t) j); | 
|  | 289 | else | 
|  | 290 | phba->SerialNumber[i] = | 
|  | 291 | (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); | 
|  | 292 | i++; | 
|  | 293 | j = (status & 0xf); | 
|  | 294 | if (j <= 9) | 
|  | 295 | phba->SerialNumber[i] = | 
|  | 296 | (char)((uint8_t) 0x30 + (uint8_t) j); | 
|  | 297 | else | 
|  | 298 | phba->SerialNumber[i] = | 
|  | 299 | (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); | 
|  | 300 | } | 
|  | 301 | } | 
|  | 302 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 303 | lpfc_read_config(phba, pmb); | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 304 | pmb->vport = vport; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 305 | if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 306 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 307 | "0453 Adapter failed to init, mbxCmd x%x " | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 308 | "READ_CONFIG, mbxStatus x%x\n", | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 309 | mb->mbxCommand, mb->mbxStatus); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 310 | phba->link_state = LPFC_HBA_ERROR; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 311 | mempool_free( pmb, phba->mbox_mem_pool); | 
|  | 312 | return -EIO; | 
|  | 313 | } | 
|  | 314 |  | 
|  | 315 | /* Reset the DFT_HBA_Q_DEPTH to the max xri  */ | 
|  | 316 | if (phba->cfg_hba_queue_depth > (mb->un.varRdConfig.max_xri+1)) | 
|  | 317 | phba->cfg_hba_queue_depth = | 
|  | 318 | mb->un.varRdConfig.max_xri + 1; | 
|  | 319 |  | 
|  | 320 | phba->lmt = mb->un.varRdConfig.lmt; | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 321 |  | 
|  | 322 | /* Get the default values for Model Name and Description */ | 
|  | 323 | lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); | 
|  | 324 |  | 
|  | 325 | if ((phba->cfg_link_speed > LINK_SPEED_10G) | 
|  | 326 | || ((phba->cfg_link_speed == LINK_SPEED_1G) | 
|  | 327 | && !(phba->lmt & LMT_1Gb)) | 
|  | 328 | || ((phba->cfg_link_speed == LINK_SPEED_2G) | 
|  | 329 | && !(phba->lmt & LMT_2Gb)) | 
|  | 330 | || ((phba->cfg_link_speed == LINK_SPEED_4G) | 
|  | 331 | && !(phba->lmt & LMT_4Gb)) | 
|  | 332 | || ((phba->cfg_link_speed == LINK_SPEED_8G) | 
|  | 333 | && !(phba->lmt & LMT_8Gb)) | 
|  | 334 | || ((phba->cfg_link_speed == LINK_SPEED_10G) | 
|  | 335 | && !(phba->lmt & LMT_10Gb))) { | 
|  | 336 | /* Reset link speed to auto */ | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 337 | lpfc_printf_log(phba, KERN_WARNING, LOG_LINK_EVENT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 338 | "1302 Invalid speed for this board: " | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 339 | "Reset link speed to auto: x%x\n", | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 340 | phba->cfg_link_speed); | 
|  | 341 | phba->cfg_link_speed = LINK_SPEED_AUTO; | 
|  | 342 | } | 
|  | 343 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 344 | phba->link_state = LPFC_LINK_DOWN; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 345 |  | 
|  | 346 | /* Only process IOCBs on ring 0 till hba_state is READY */ | 
| James Smart | a4bc337 | 2006-12-02 13:34:16 -0500 | [diff] [blame] | 347 | if (psli->ring[psli->extra_ring].cmdringaddr) | 
|  | 348 | psli->ring[psli->extra_ring].flag |= LPFC_STOP_IOCB_EVENT; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 349 | if (psli->ring[psli->fcp_ring].cmdringaddr) | 
|  | 350 | psli->ring[psli->fcp_ring].flag |= LPFC_STOP_IOCB_EVENT; | 
|  | 351 | if (psli->ring[psli->next_ring].cmdringaddr) | 
|  | 352 | psli->ring[psli->next_ring].flag |= LPFC_STOP_IOCB_EVENT; | 
|  | 353 |  | 
|  | 354 | /* Post receive buffers for desired rings */ | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 355 | if (phba->sli_rev != 3) | 
|  | 356 | lpfc_post_rcv_buf(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 357 |  | 
|  | 358 | /* Enable appropriate host interrupts */ | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 359 | spin_lock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 360 | status = readl(phba->HCregaddr); | 
|  | 361 | status |= HC_MBINT_ENA | HC_ERINT_ENA | HC_LAINT_ENA; | 
|  | 362 | if (psli->num_rings > 0) | 
|  | 363 | status |= HC_R0INT_ENA; | 
|  | 364 | if (psli->num_rings > 1) | 
|  | 365 | status |= HC_R1INT_ENA; | 
|  | 366 | if (psli->num_rings > 2) | 
|  | 367 | status |= HC_R2INT_ENA; | 
|  | 368 | if (psli->num_rings > 3) | 
|  | 369 | status |= HC_R3INT_ENA; | 
|  | 370 |  | 
| James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 371 | if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) && | 
|  | 372 | (phba->cfg_poll & DISABLE_FCP_RING_INT)) | 
|  | 373 | status &= ~(HC_R0INT_ENA << LPFC_FCP_RING); | 
|  | 374 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 375 | writel(status, phba->HCregaddr); | 
|  | 376 | readl(phba->HCregaddr); /* flush */ | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 377 | spin_unlock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 378 |  | 
|  | 379 | /* | 
|  | 380 | * Setup the ring 0 (els)  timeout handler | 
|  | 381 | */ | 
|  | 382 | timeout = phba->fc_ratov << 1; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 383 | mod_timer(&vport->els_tmofunc, jiffies + HZ * timeout); | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 384 | mod_timer(&phba->hb_tmofunc, jiffies + HZ * LPFC_HB_MBOX_INTERVAL); | 
|  | 385 | phba->hb_outstanding = 0; | 
|  | 386 | phba->last_completion_time = jiffies; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 387 |  | 
|  | 388 | lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); | 
|  | 389 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 390 | pmb->vport = vport; | 
| James Smart | 8aee918 | 2006-08-31 12:27:57 -0400 | [diff] [blame] | 391 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); | 
| James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 392 | lpfc_set_loopback_flag(phba); | 
| James Smart | 8aee918 | 2006-08-31 12:27:57 -0400 | [diff] [blame] | 393 | if (rc != MBX_SUCCESS) { | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 394 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 395 | "0454 Adapter failed to init, mbxCmd x%x " | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 396 | "INIT_LINK, mbxStatus x%x\n", | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 397 | mb->mbxCommand, mb->mbxStatus); | 
|  | 398 |  | 
|  | 399 | /* Clear all interrupt enable conditions */ | 
|  | 400 | writel(0, phba->HCregaddr); | 
|  | 401 | readl(phba->HCregaddr); /* flush */ | 
|  | 402 | /* Clear all pending interrupts */ | 
|  | 403 | writel(0xffffffff, phba->HAregaddr); | 
|  | 404 | readl(phba->HAregaddr); /* flush */ | 
|  | 405 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 406 | phba->link_state = LPFC_HBA_ERROR; | 
| James Smart | 8aee918 | 2006-08-31 12:27:57 -0400 | [diff] [blame] | 407 | if (rc != MBX_BUSY) | 
|  | 408 | mempool_free(pmb, phba->mbox_mem_pool); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 409 | return -EIO; | 
|  | 410 | } | 
|  | 411 | /* MBOX buffer will be freed in mbox compl */ | 
|  | 412 |  | 
| James Smart | ce8b3ce | 2006-07-06 15:50:36 -0400 | [diff] [blame] | 413 | return (0); | 
|  | 414 | } | 
|  | 415 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 416 | /************************************************************************/ | 
|  | 417 | /*                                                                      */ | 
|  | 418 | /*    lpfc_hba_down_prep                                                */ | 
|  | 419 | /*    This routine will do LPFC uninitialization before the             */ | 
|  | 420 | /*    HBA is reset when bringing down the SLI Layer. This will be       */ | 
|  | 421 | /*    initialized as a SLI layer callback routine.                      */ | 
|  | 422 | /*    This routine returns 0 on success. Any other return value         */ | 
|  | 423 | /*    indicates an error.                                               */ | 
|  | 424 | /*                                                                      */ | 
|  | 425 | /************************************************************************/ | 
|  | 426 | int | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 427 | lpfc_hba_down_prep(struct lpfc_hba *phba) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 428 | { | 
|  | 429 | /* Disable interrupts */ | 
|  | 430 | writel(0, phba->HCregaddr); | 
|  | 431 | readl(phba->HCregaddr); /* flush */ | 
|  | 432 |  | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 433 | lpfc_cleanup_discovery_resources(phba->pport); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 434 | return 0; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 435 | } | 
|  | 436 |  | 
|  | 437 | /************************************************************************/ | 
|  | 438 | /*                                                                      */ | 
| Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 439 | /*    lpfc_hba_down_post                                                */ | 
|  | 440 | /*    This routine will do uninitialization after the HBA is reset      */ | 
|  | 441 | /*    when bringing down the SLI Layer.                                 */ | 
|  | 442 | /*    This routine returns 0 on success. Any other return value         */ | 
|  | 443 | /*    indicates an error.                                               */ | 
|  | 444 | /*                                                                      */ | 
|  | 445 | /************************************************************************/ | 
|  | 446 | int | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 447 | lpfc_hba_down_post(struct lpfc_hba *phba) | 
| Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 448 | { | 
|  | 449 | struct lpfc_sli *psli = &phba->sli; | 
|  | 450 | struct lpfc_sli_ring *pring; | 
|  | 451 | struct lpfc_dmabuf *mp, *next_mp; | 
|  | 452 | int i; | 
|  | 453 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 454 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) | 
|  | 455 | lpfc_sli_hbqbuf_free_all(phba); | 
|  | 456 | else { | 
|  | 457 | /* Cleanup preposted buffers on the ELS ring */ | 
|  | 458 | pring = &psli->ring[LPFC_ELS_RING]; | 
|  | 459 | list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { | 
|  | 460 | list_del(&mp->list); | 
|  | 461 | pring->postbufq_cnt--; | 
|  | 462 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 
|  | 463 | kfree(mp); | 
|  | 464 | } | 
| Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 465 | } | 
|  | 466 |  | 
|  | 467 | for (i = 0; i < psli->num_rings; i++) { | 
|  | 468 | pring = &psli->ring[i]; | 
|  | 469 | lpfc_sli_abort_iocb_ring(phba, pring); | 
|  | 470 | } | 
|  | 471 |  | 
|  | 472 | return 0; | 
|  | 473 | } | 
|  | 474 |  | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 475 | /* HBA heart beat timeout handler */ | 
|  | 476 | void | 
|  | 477 | lpfc_hb_timeout(unsigned long ptr) | 
|  | 478 | { | 
|  | 479 | struct lpfc_hba *phba; | 
|  | 480 | unsigned long iflag; | 
|  | 481 |  | 
|  | 482 | phba = (struct lpfc_hba *)ptr; | 
|  | 483 | spin_lock_irqsave(&phba->pport->work_port_lock, iflag); | 
|  | 484 | if (!(phba->pport->work_port_events & WORKER_HB_TMO)) | 
|  | 485 | phba->pport->work_port_events |= WORKER_HB_TMO; | 
|  | 486 | spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); | 
|  | 487 |  | 
|  | 488 | if (phba->work_wait) | 
|  | 489 | wake_up(phba->work_wait); | 
|  | 490 | return; | 
|  | 491 | } | 
|  | 492 |  | 
|  | 493 | static void | 
|  | 494 | lpfc_hb_mbox_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq) | 
|  | 495 | { | 
|  | 496 | unsigned long drvr_flag; | 
|  | 497 |  | 
|  | 498 | spin_lock_irqsave(&phba->hbalock, drvr_flag); | 
|  | 499 | phba->hb_outstanding = 0; | 
|  | 500 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); | 
|  | 501 |  | 
|  | 502 | mempool_free(pmboxq, phba->mbox_mem_pool); | 
|  | 503 | if (!(phba->pport->fc_flag & FC_OFFLINE_MODE) && | 
|  | 504 | !(phba->link_state == LPFC_HBA_ERROR) && | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 505 | !(phba->pport->load_flag & FC_UNLOADING)) | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 506 | mod_timer(&phba->hb_tmofunc, | 
|  | 507 | jiffies + HZ * LPFC_HB_MBOX_INTERVAL); | 
|  | 508 | return; | 
|  | 509 | } | 
|  | 510 |  | 
|  | 511 | void | 
|  | 512 | lpfc_hb_timeout_handler(struct lpfc_hba *phba) | 
|  | 513 | { | 
|  | 514 | LPFC_MBOXQ_t *pmboxq; | 
|  | 515 | int retval; | 
|  | 516 | struct lpfc_sli *psli = &phba->sli; | 
|  | 517 |  | 
|  | 518 | if ((phba->link_state == LPFC_HBA_ERROR) || | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 519 | (phba->pport->load_flag & FC_UNLOADING) || | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 520 | (phba->pport->fc_flag & FC_OFFLINE_MODE)) | 
|  | 521 | return; | 
|  | 522 |  | 
|  | 523 | spin_lock_irq(&phba->pport->work_port_lock); | 
|  | 524 | /* If the timer is already canceled do nothing */ | 
|  | 525 | if (!(phba->pport->work_port_events & WORKER_HB_TMO)) { | 
|  | 526 | spin_unlock_irq(&phba->pport->work_port_lock); | 
|  | 527 | return; | 
|  | 528 | } | 
|  | 529 |  | 
|  | 530 | if (time_after(phba->last_completion_time + LPFC_HB_MBOX_INTERVAL * HZ, | 
|  | 531 | jiffies)) { | 
|  | 532 | spin_unlock_irq(&phba->pport->work_port_lock); | 
|  | 533 | if (!phba->hb_outstanding) | 
|  | 534 | mod_timer(&phba->hb_tmofunc, | 
|  | 535 | jiffies + HZ * LPFC_HB_MBOX_INTERVAL); | 
|  | 536 | else | 
|  | 537 | mod_timer(&phba->hb_tmofunc, | 
|  | 538 | jiffies + HZ * LPFC_HB_MBOX_TIMEOUT); | 
|  | 539 | return; | 
|  | 540 | } | 
|  | 541 | spin_unlock_irq(&phba->pport->work_port_lock); | 
|  | 542 |  | 
|  | 543 | /* If there is no heart beat outstanding, issue a heartbeat command */ | 
|  | 544 | if (!phba->hb_outstanding) { | 
|  | 545 | pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); | 
|  | 546 | if (!pmboxq) { | 
|  | 547 | mod_timer(&phba->hb_tmofunc, | 
|  | 548 | jiffies + HZ * LPFC_HB_MBOX_INTERVAL); | 
|  | 549 | return; | 
|  | 550 | } | 
|  | 551 |  | 
|  | 552 | lpfc_heart_beat(phba, pmboxq); | 
|  | 553 | pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl; | 
|  | 554 | pmboxq->vport = phba->pport; | 
|  | 555 | retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT); | 
|  | 556 |  | 
|  | 557 | if (retval != MBX_BUSY && retval != MBX_SUCCESS) { | 
|  | 558 | mempool_free(pmboxq, phba->mbox_mem_pool); | 
|  | 559 | mod_timer(&phba->hb_tmofunc, | 
|  | 560 | jiffies + HZ * LPFC_HB_MBOX_INTERVAL); | 
|  | 561 | return; | 
|  | 562 | } | 
|  | 563 | mod_timer(&phba->hb_tmofunc, | 
|  | 564 | jiffies + HZ * LPFC_HB_MBOX_TIMEOUT); | 
|  | 565 | phba->hb_outstanding = 1; | 
|  | 566 | return; | 
|  | 567 | } else { | 
|  | 568 | /* | 
|  | 569 | * If heart beat timeout called with hb_outstanding set we | 
|  | 570 | * need to take the HBA offline. | 
|  | 571 | */ | 
|  | 572 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 573 | "0459 Adapter heartbeat failure, taking " | 
|  | 574 | "this port offline.\n"); | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 575 |  | 
|  | 576 | spin_lock_irq(&phba->hbalock); | 
|  | 577 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; | 
|  | 578 | spin_unlock_irq(&phba->hbalock); | 
|  | 579 |  | 
|  | 580 | lpfc_offline_prep(phba); | 
|  | 581 | lpfc_offline(phba); | 
|  | 582 | lpfc_unblock_mgmt_io(phba); | 
|  | 583 | phba->link_state = LPFC_HBA_ERROR; | 
|  | 584 | lpfc_hba_down_post(phba); | 
|  | 585 | } | 
|  | 586 | } | 
|  | 587 |  | 
| Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 588 | /************************************************************************/ | 
|  | 589 | /*                                                                      */ | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 590 | /*    lpfc_handle_eratt                                                 */ | 
|  | 591 | /*    This routine will handle processing a Host Attention              */ | 
|  | 592 | /*    Error Status event. This will be initialized                      */ | 
|  | 593 | /*    as a SLI layer callback routine.                                  */ | 
|  | 594 | /*                                                                      */ | 
|  | 595 | /************************************************************************/ | 
|  | 596 | void | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 597 | lpfc_handle_eratt(struct lpfc_hba *phba) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 598 | { | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 599 | struct lpfc_vport *vport = phba->pport; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 600 | struct lpfc_sli   *psli = &phba->sli; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 601 | struct lpfc_sli_ring  *pring; | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 602 | struct lpfc_vport **vports; | 
| James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 603 | uint32_t event_data; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 604 | struct Scsi_Host  *shost; | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 605 | int i; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 606 |  | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 607 | /* If the pci channel is offline, ignore possible errors, | 
|  | 608 | * since we cannot communicate with the pci card anyway. */ | 
|  | 609 | if (pci_channel_offline(phba->pcidev)) | 
|  | 610 | return; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 611 |  | 
| James Smart | f560351 | 2006-12-02 13:35:43 -0500 | [diff] [blame] | 612 | if (phba->work_hs & HS_FFER6 || | 
|  | 613 | phba->work_hs & HS_FFER5) { | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 614 | /* Re-establishing Link */ | 
|  | 615 | lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 616 | "1301 Re-establishing Link " | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 617 | "Data: x%x x%x x%x\n", | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 618 | phba->work_hs, | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 619 | phba->work_status[0], phba->work_status[1]); | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 620 | vports = lpfc_create_vport_work_array(phba); | 
|  | 621 | if (vports != NULL) | 
|  | 622 | for(i = 0; | 
|  | 623 | i < LPFC_MAX_VPORTS && vports[i] != NULL; | 
|  | 624 | i++){ | 
|  | 625 | shost = lpfc_shost_from_vport(vports[i]); | 
|  | 626 | spin_lock_irq(shost->host_lock); | 
|  | 627 | vports[i]->fc_flag |= FC_ESTABLISH_LINK; | 
|  | 628 | spin_unlock_irq(shost->host_lock); | 
|  | 629 | } | 
|  | 630 | lpfc_destroy_vport_work_array(vports); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 631 | spin_lock_irq(&phba->hbalock); | 
| James Smart | 9290831 | 2006-03-07 15:04:13 -0500 | [diff] [blame] | 632 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 633 | spin_unlock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 634 |  | 
|  | 635 | /* | 
|  | 636 | * Firmware stops when it triggled erratt with HS_FFER6. | 
|  | 637 | * That could cause the I/Os dropped by the firmware. | 
|  | 638 | * Error iocb (I/O) on txcmplq and let the SCSI layer | 
|  | 639 | * retry it after re-establishing link. | 
|  | 640 | */ | 
|  | 641 | pring = &psli->ring[psli->fcp_ring]; | 
|  | 642 | lpfc_sli_abort_iocb_ring(phba, pring); | 
|  | 643 |  | 
|  | 644 |  | 
|  | 645 | /* | 
|  | 646 | * There was a firmware error.  Take the hba offline and then | 
|  | 647 | * attempt to restart it. | 
|  | 648 | */ | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 649 | lpfc_offline_prep(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 650 | lpfc_offline(phba); | 
| Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 651 | lpfc_sli_brdrestart(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 652 | if (lpfc_online(phba) == 0) {	/* Initialize the HBA */ | 
|  | 653 | mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60); | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 654 | lpfc_unblock_mgmt_io(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 655 | return; | 
|  | 656 | } | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 657 | lpfc_unblock_mgmt_io(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 658 | } else { | 
|  | 659 | /* The if clause above forces this code path when the status | 
|  | 660 | * failure is a value other than FFER6.  Do not call the offline | 
|  | 661 | *  twice. This is the adapter hardware error path. | 
|  | 662 | */ | 
|  | 663 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 664 | "0457 Adapter Hardware Error " | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 665 | "Data: x%x x%x x%x\n", | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 666 | phba->work_hs, | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 667 | phba->work_status[0], phba->work_status[1]); | 
|  | 668 |  | 
| James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 669 | event_data = FC_REG_DUMP_EVENT; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 670 | shost = lpfc_shost_from_vport(vport); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 671 | fc_host_post_vendor_event(shost, fc_get_event_number(), | 
| James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 672 | sizeof(event_data), (char *) &event_data, | 
|  | 673 | SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); | 
|  | 674 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 675 | spin_lock_irq(&phba->hbalock); | 
| James Smart | 9290831 | 2006-03-07 15:04:13 -0500 | [diff] [blame] | 676 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 677 | spin_unlock_irq(&phba->hbalock); | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 678 | lpfc_offline_prep(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 679 | lpfc_offline(phba); | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 680 | lpfc_unblock_mgmt_io(phba); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 681 | phba->link_state = LPFC_HBA_ERROR; | 
| Jamie Wellnitz | 4141586 | 2006-02-28 19:25:27 -0500 | [diff] [blame] | 682 | lpfc_hba_down_post(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 683 | } | 
|  | 684 | } | 
|  | 685 |  | 
|  | 686 | /************************************************************************/ | 
|  | 687 | /*                                                                      */ | 
|  | 688 | /*    lpfc_handle_latt                                                  */ | 
|  | 689 | /*    This routine will handle processing a Host Attention              */ | 
|  | 690 | /*    Link Status event. This will be initialized                       */ | 
|  | 691 | /*    as a SLI layer callback routine.                                  */ | 
|  | 692 | /*                                                                      */ | 
|  | 693 | /************************************************************************/ | 
|  | 694 | void | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 695 | lpfc_handle_latt(struct lpfc_hba *phba) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 696 | { | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 697 | struct lpfc_vport *vport = phba->pport; | 
|  | 698 | struct lpfc_sli   *psli = &phba->sli; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 699 | LPFC_MBOXQ_t *pmb; | 
|  | 700 | volatile uint32_t control; | 
|  | 701 | struct lpfc_dmabuf *mp; | 
|  | 702 | int rc = -ENOMEM; | 
|  | 703 |  | 
|  | 704 | pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 
|  | 705 | if (!pmb) | 
|  | 706 | goto lpfc_handle_latt_err_exit; | 
|  | 707 |  | 
|  | 708 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); | 
|  | 709 | if (!mp) | 
|  | 710 | goto lpfc_handle_latt_free_pmb; | 
|  | 711 |  | 
|  | 712 | mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); | 
|  | 713 | if (!mp->virt) | 
|  | 714 | goto lpfc_handle_latt_free_mp; | 
|  | 715 |  | 
|  | 716 | rc = -EIO; | 
|  | 717 |  | 
| James.Smart@Emulex.Com | 6281bfe | 2005-11-28 11:41:33 -0500 | [diff] [blame] | 718 | /* Cleanup any outstanding ELS commands */ | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 719 | lpfc_els_flush_all_cmd(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 720 |  | 
|  | 721 | psli->slistat.link_event++; | 
|  | 722 | lpfc_read_la(phba, pmb, mp); | 
|  | 723 | pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 724 | pmb->vport = vport; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 725 | rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB)); | 
|  | 726 | if (rc == MBX_NOT_FINISHED) | 
| James Smart | 1469115 | 2006-12-02 13:34:28 -0500 | [diff] [blame] | 727 | goto lpfc_handle_latt_free_mbuf; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 728 |  | 
|  | 729 | /* Clear Link Attention in HA REG */ | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 730 | spin_lock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 731 | writel(HA_LATT, phba->HAregaddr); | 
|  | 732 | readl(phba->HAregaddr); /* flush */ | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 733 | spin_unlock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 734 |  | 
|  | 735 | return; | 
|  | 736 |  | 
| James Smart | 1469115 | 2006-12-02 13:34:28 -0500 | [diff] [blame] | 737 | lpfc_handle_latt_free_mbuf: | 
|  | 738 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 739 | lpfc_handle_latt_free_mp: | 
|  | 740 | kfree(mp); | 
|  | 741 | lpfc_handle_latt_free_pmb: | 
| James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 742 | mempool_free(pmb, phba->mbox_mem_pool); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 743 | lpfc_handle_latt_err_exit: | 
|  | 744 | /* Enable Link attention interrupts */ | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 745 | spin_lock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 746 | psli->sli_flag |= LPFC_PROCESS_LA; | 
|  | 747 | control = readl(phba->HCregaddr); | 
|  | 748 | control |= HC_LAINT_ENA; | 
|  | 749 | writel(control, phba->HCregaddr); | 
|  | 750 | readl(phba->HCregaddr); /* flush */ | 
|  | 751 |  | 
|  | 752 | /* Clear Link Attention in HA REG */ | 
|  | 753 | writel(HA_LATT, phba->HAregaddr); | 
|  | 754 | readl(phba->HAregaddr); /* flush */ | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 755 | spin_unlock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 756 | lpfc_linkdown(phba); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 757 | phba->link_state = LPFC_HBA_ERROR; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 758 |  | 
|  | 759 | /* The other case is an error from issue_mbox */ | 
|  | 760 | if (rc == -ENOMEM) | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 761 | lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 762 | "0300 READ_LA: no buffers\n"); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 763 |  | 
|  | 764 | return; | 
|  | 765 | } | 
|  | 766 |  | 
|  | 767 | /************************************************************************/ | 
|  | 768 | /*                                                                      */ | 
|  | 769 | /*   lpfc_parse_vpd                                                     */ | 
|  | 770 | /*   This routine will parse the VPD data                               */ | 
|  | 771 | /*                                                                      */ | 
|  | 772 | /************************************************************************/ | 
|  | 773 | static int | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 774 | lpfc_parse_vpd(struct lpfc_hba *phba, uint8_t *vpd, int len) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 775 | { | 
|  | 776 | uint8_t lenlo, lenhi; | 
| Anton Blanchard | 07da60c1 | 2007-03-21 08:41:47 -0500 | [diff] [blame] | 777 | int Length; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 778 | int i, j; | 
|  | 779 | int finished = 0; | 
|  | 780 | int index = 0; | 
|  | 781 |  | 
|  | 782 | if (!vpd) | 
|  | 783 | return 0; | 
|  | 784 |  | 
|  | 785 | /* Vital Product */ | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 786 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 787 | "0455 Vital Product Data: x%x x%x x%x x%x\n", | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 788 | (uint32_t) vpd[0], (uint32_t) vpd[1], (uint32_t) vpd[2], | 
|  | 789 | (uint32_t) vpd[3]); | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 790 | while (!finished && (index < (len - 4))) { | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 791 | switch (vpd[index]) { | 
|  | 792 | case 0x82: | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 793 | case 0x91: | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 794 | index += 1; | 
|  | 795 | lenlo = vpd[index]; | 
|  | 796 | index += 1; | 
|  | 797 | lenhi = vpd[index]; | 
|  | 798 | index += 1; | 
|  | 799 | i = ((((unsigned short)lenhi) << 8) + lenlo); | 
|  | 800 | index += i; | 
|  | 801 | break; | 
|  | 802 | case 0x90: | 
|  | 803 | index += 1; | 
|  | 804 | lenlo = vpd[index]; | 
|  | 805 | index += 1; | 
|  | 806 | lenhi = vpd[index]; | 
|  | 807 | index += 1; | 
|  | 808 | Length = ((((unsigned short)lenhi) << 8) + lenlo); | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 809 | if (Length > len - index) | 
|  | 810 | Length = len - index; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 811 | while (Length > 0) { | 
|  | 812 | /* Look for Serial Number */ | 
|  | 813 | if ((vpd[index] == 'S') && (vpd[index+1] == 'N')) { | 
|  | 814 | index += 2; | 
|  | 815 | i = vpd[index]; | 
|  | 816 | index += 1; | 
|  | 817 | j = 0; | 
|  | 818 | Length -= (3+i); | 
|  | 819 | while(i--) { | 
|  | 820 | phba->SerialNumber[j++] = vpd[index++]; | 
|  | 821 | if (j == 31) | 
|  | 822 | break; | 
|  | 823 | } | 
|  | 824 | phba->SerialNumber[j] = 0; | 
|  | 825 | continue; | 
|  | 826 | } | 
|  | 827 | else if ((vpd[index] == 'V') && (vpd[index+1] == '1')) { | 
|  | 828 | phba->vpd_flag |= VPD_MODEL_DESC; | 
|  | 829 | index += 2; | 
|  | 830 | i = vpd[index]; | 
|  | 831 | index += 1; | 
|  | 832 | j = 0; | 
|  | 833 | Length -= (3+i); | 
|  | 834 | while(i--) { | 
|  | 835 | phba->ModelDesc[j++] = vpd[index++]; | 
|  | 836 | if (j == 255) | 
|  | 837 | break; | 
|  | 838 | } | 
|  | 839 | phba->ModelDesc[j] = 0; | 
|  | 840 | continue; | 
|  | 841 | } | 
|  | 842 | else if ((vpd[index] == 'V') && (vpd[index+1] == '2')) { | 
|  | 843 | phba->vpd_flag |= VPD_MODEL_NAME; | 
|  | 844 | index += 2; | 
|  | 845 | i = vpd[index]; | 
|  | 846 | index += 1; | 
|  | 847 | j = 0; | 
|  | 848 | Length -= (3+i); | 
|  | 849 | while(i--) { | 
|  | 850 | phba->ModelName[j++] = vpd[index++]; | 
|  | 851 | if (j == 79) | 
|  | 852 | break; | 
|  | 853 | } | 
|  | 854 | phba->ModelName[j] = 0; | 
|  | 855 | continue; | 
|  | 856 | } | 
|  | 857 | else if ((vpd[index] == 'V') && (vpd[index+1] == '3')) { | 
|  | 858 | phba->vpd_flag |= VPD_PROGRAM_TYPE; | 
|  | 859 | index += 2; | 
|  | 860 | i = vpd[index]; | 
|  | 861 | index += 1; | 
|  | 862 | j = 0; | 
|  | 863 | Length -= (3+i); | 
|  | 864 | while(i--) { | 
|  | 865 | phba->ProgramType[j++] = vpd[index++]; | 
|  | 866 | if (j == 255) | 
|  | 867 | break; | 
|  | 868 | } | 
|  | 869 | phba->ProgramType[j] = 0; | 
|  | 870 | continue; | 
|  | 871 | } | 
|  | 872 | else if ((vpd[index] == 'V') && (vpd[index+1] == '4')) { | 
|  | 873 | phba->vpd_flag |= VPD_PORT; | 
|  | 874 | index += 2; | 
|  | 875 | i = vpd[index]; | 
|  | 876 | index += 1; | 
|  | 877 | j = 0; | 
|  | 878 | Length -= (3+i); | 
|  | 879 | while(i--) { | 
|  | 880 | phba->Port[j++] = vpd[index++]; | 
|  | 881 | if (j == 19) | 
|  | 882 | break; | 
|  | 883 | } | 
|  | 884 | phba->Port[j] = 0; | 
|  | 885 | continue; | 
|  | 886 | } | 
|  | 887 | else { | 
|  | 888 | index += 2; | 
|  | 889 | i = vpd[index]; | 
|  | 890 | index += 1; | 
|  | 891 | index += i; | 
|  | 892 | Length -= (3 + i); | 
|  | 893 | } | 
|  | 894 | } | 
|  | 895 | finished = 0; | 
|  | 896 | break; | 
|  | 897 | case 0x78: | 
|  | 898 | finished = 1; | 
|  | 899 | break; | 
|  | 900 | default: | 
|  | 901 | index ++; | 
|  | 902 | break; | 
|  | 903 | } | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 904 | } | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 905 |  | 
|  | 906 | return(1); | 
|  | 907 | } | 
|  | 908 |  | 
|  | 909 | static void | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 910 | lpfc_get_hba_model_desc(struct lpfc_hba *phba, uint8_t *mdp, uint8_t *descp) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 911 | { | 
|  | 912 | lpfc_vpd_t *vp; | 
| James.Smart@Emulex.Com | fefcb2b | 2005-11-28 15:08:56 -0500 | [diff] [blame] | 913 | uint16_t dev_id = phba->pcidev->device; | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 914 | int max_speed; | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 915 | struct { | 
|  | 916 | char * name; | 
|  | 917 | int    max_speed; | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 918 | char * bus; | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 919 | } m = {"<Unknown>", 0, ""}; | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 920 |  | 
|  | 921 | if (mdp && mdp[0] != '\0' | 
|  | 922 | && descp && descp[0] != '\0') | 
|  | 923 | return; | 
|  | 924 |  | 
|  | 925 | if (phba->lmt & LMT_10Gb) | 
|  | 926 | max_speed = 10; | 
|  | 927 | else if (phba->lmt & LMT_8Gb) | 
|  | 928 | max_speed = 8; | 
|  | 929 | else if (phba->lmt & LMT_4Gb) | 
|  | 930 | max_speed = 4; | 
|  | 931 | else if (phba->lmt & LMT_2Gb) | 
|  | 932 | max_speed = 2; | 
|  | 933 | else | 
|  | 934 | max_speed = 1; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 935 |  | 
|  | 936 | vp = &phba->vpd; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 937 |  | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 938 | switch (dev_id) { | 
| James.Smart@Emulex.Com | 06325e7 | 2005-06-25 10:34:22 -0400 | [diff] [blame] | 939 | case PCI_DEVICE_ID_FIREFLY: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 940 | m = (typeof(m)){"LP6000", max_speed, "PCI"}; | 
| James.Smart@Emulex.Com | 06325e7 | 2005-06-25 10:34:22 -0400 | [diff] [blame] | 941 | break; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 942 | case PCI_DEVICE_ID_SUPERFLY: | 
|  | 943 | if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 944 | m = (typeof(m)){"LP7000", max_speed,  "PCI"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 945 | else | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 946 | m = (typeof(m)){"LP7000E", max_speed, "PCI"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 947 | break; | 
|  | 948 | case PCI_DEVICE_ID_DRAGONFLY: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 949 | m = (typeof(m)){"LP8000", max_speed, "PCI"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 950 | break; | 
|  | 951 | case PCI_DEVICE_ID_CENTAUR: | 
|  | 952 | if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 953 | m = (typeof(m)){"LP9002", max_speed, "PCI"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 954 | else | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 955 | m = (typeof(m)){"LP9000", max_speed, "PCI"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 956 | break; | 
|  | 957 | case PCI_DEVICE_ID_RFLY: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 958 | m = (typeof(m)){"LP952", max_speed, "PCI"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 959 | break; | 
|  | 960 | case PCI_DEVICE_ID_PEGASUS: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 961 | m = (typeof(m)){"LP9802", max_speed, "PCI-X"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 962 | break; | 
|  | 963 | case PCI_DEVICE_ID_THOR: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 964 | m = (typeof(m)){"LP10000", max_speed, "PCI-X"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 965 | break; | 
|  | 966 | case PCI_DEVICE_ID_VIPER: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 967 | m = (typeof(m)){"LPX1000", max_speed,  "PCI-X"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 968 | break; | 
|  | 969 | case PCI_DEVICE_ID_PFLY: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 970 | m = (typeof(m)){"LP982", max_speed, "PCI-X"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 971 | break; | 
|  | 972 | case PCI_DEVICE_ID_TFLY: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 973 | m = (typeof(m)){"LP1050", max_speed, "PCI-X"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 974 | break; | 
|  | 975 | case PCI_DEVICE_ID_HELIOS: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 976 | m = (typeof(m)){"LP11000", max_speed, "PCI-X2"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 977 | break; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 978 | case PCI_DEVICE_ID_HELIOS_SCSP: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 979 | m = (typeof(m)){"LP11000-SP", max_speed, "PCI-X2"}; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 980 | break; | 
|  | 981 | case PCI_DEVICE_ID_HELIOS_DCSP: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 982 | m = (typeof(m)){"LP11002-SP", max_speed, "PCI-X2"}; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 983 | break; | 
|  | 984 | case PCI_DEVICE_ID_NEPTUNE: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 985 | m = (typeof(m)){"LPe1000", max_speed, "PCIe"}; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 986 | break; | 
|  | 987 | case PCI_DEVICE_ID_NEPTUNE_SCSP: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 988 | m = (typeof(m)){"LPe1000-SP", max_speed, "PCIe"}; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 989 | break; | 
|  | 990 | case PCI_DEVICE_ID_NEPTUNE_DCSP: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 991 | m = (typeof(m)){"LPe1002-SP", max_speed, "PCIe"}; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 992 | break; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 993 | case PCI_DEVICE_ID_BMID: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 994 | m = (typeof(m)){"LP1150", max_speed, "PCI-X2"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 995 | break; | 
|  | 996 | case PCI_DEVICE_ID_BSMB: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 997 | m = (typeof(m)){"LP111", max_speed, "PCI-X2"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 998 | break; | 
|  | 999 | case PCI_DEVICE_ID_ZEPHYR: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 1000 | m = (typeof(m)){"LPe11000", max_speed, "PCIe"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1001 | break; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 1002 | case PCI_DEVICE_ID_ZEPHYR_SCSP: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 1003 | m = (typeof(m)){"LPe11000", max_speed, "PCIe"}; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 1004 | break; | 
|  | 1005 | case PCI_DEVICE_ID_ZEPHYR_DCSP: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 1006 | m = (typeof(m)){"LPe11002-SP", max_speed, "PCIe"}; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 1007 | break; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1008 | case PCI_DEVICE_ID_ZMID: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 1009 | m = (typeof(m)){"LPe1150", max_speed, "PCIe"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1010 | break; | 
|  | 1011 | case PCI_DEVICE_ID_ZSMB: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 1012 | m = (typeof(m)){"LPe111", max_speed, "PCIe"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1013 | break; | 
|  | 1014 | case PCI_DEVICE_ID_LP101: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 1015 | m = (typeof(m)){"LP101", max_speed, "PCI-X"}; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1016 | break; | 
|  | 1017 | case PCI_DEVICE_ID_LP10000S: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 1018 | m = (typeof(m)){"LP10000-S", max_speed, "PCI"}; | 
| James.Smart@Emulex.Com | 06325e7 | 2005-06-25 10:34:22 -0400 | [diff] [blame] | 1019 | break; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 1020 | case PCI_DEVICE_ID_LP11000S: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 1021 | m = (typeof(m)){"LP11000-S", max_speed, | 
|  | 1022 | "PCI-X2"}; | 
|  | 1023 | break; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 1024 | case PCI_DEVICE_ID_LPE11000S: | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 1025 | m = (typeof(m)){"LPe11000-S", max_speed, | 
|  | 1026 | "PCIe"}; | 
| James.Smart@Emulex.Com | 5cc36b3 | 2005-11-28 11:42:19 -0500 | [diff] [blame] | 1027 | break; | 
| James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 1028 | case PCI_DEVICE_ID_SAT: | 
|  | 1029 | m = (typeof(m)){"LPe12000", max_speed, "PCIe"}; | 
|  | 1030 | break; | 
|  | 1031 | case PCI_DEVICE_ID_SAT_MID: | 
|  | 1032 | m = (typeof(m)){"LPe1250", max_speed, "PCIe"}; | 
|  | 1033 | break; | 
|  | 1034 | case PCI_DEVICE_ID_SAT_SMB: | 
|  | 1035 | m = (typeof(m)){"LPe121", max_speed, "PCIe"}; | 
|  | 1036 | break; | 
|  | 1037 | case PCI_DEVICE_ID_SAT_DCSP: | 
|  | 1038 | m = (typeof(m)){"LPe12002-SP", max_speed, "PCIe"}; | 
|  | 1039 | break; | 
|  | 1040 | case PCI_DEVICE_ID_SAT_SCSP: | 
|  | 1041 | m = (typeof(m)){"LPe12000-SP", max_speed, "PCIe"}; | 
|  | 1042 | break; | 
|  | 1043 | case PCI_DEVICE_ID_SAT_S: | 
|  | 1044 | m = (typeof(m)){"LPe12000-S", max_speed, "PCIe"}; | 
|  | 1045 | break; | 
| James.Smart@Emulex.Com | 5cc36b3 | 2005-11-28 11:42:19 -0500 | [diff] [blame] | 1046 | default: | 
| Randy Dunlap | 041976f | 2006-06-25 01:58:51 -0700 | [diff] [blame] | 1047 | m = (typeof(m)){ NULL }; | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 1048 | break; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1049 | } | 
| Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 1050 |  | 
|  | 1051 | if (mdp && mdp[0] == '\0') | 
|  | 1052 | snprintf(mdp, 79,"%s", m.name); | 
|  | 1053 | if (descp && descp[0] == '\0') | 
|  | 1054 | snprintf(descp, 255, | 
| James Smart | 18a3b59 | 2006-12-02 13:35:08 -0500 | [diff] [blame] | 1055 | "Emulex %s %dGb %s Fibre Channel Adapter", | 
|  | 1056 | m.name, m.max_speed, m.bus); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1057 | } | 
|  | 1058 |  | 
|  | 1059 | /**************************************************/ | 
|  | 1060 | /*   lpfc_post_buffer                             */ | 
|  | 1061 | /*                                                */ | 
|  | 1062 | /*   This routine will post count buffers to the  */ | 
|  | 1063 | /*   ring with the QUE_RING_BUF_CN command. This  */ | 
|  | 1064 | /*   allows 3 buffers / command to be posted.     */ | 
|  | 1065 | /*   Returns the number of buffers NOT posted.    */ | 
|  | 1066 | /**************************************************/ | 
|  | 1067 | int | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1068 | lpfc_post_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, int cnt, | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1069 | int type) | 
|  | 1070 | { | 
|  | 1071 | IOCB_t *icmd; | 
| James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1072 | struct lpfc_iocbq *iocb; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1073 | struct lpfc_dmabuf *mp1, *mp2; | 
|  | 1074 |  | 
|  | 1075 | cnt += pring->missbufcnt; | 
|  | 1076 |  | 
|  | 1077 | /* While there are buffers to post */ | 
|  | 1078 | while (cnt > 0) { | 
|  | 1079 | /* Allocate buffer for  command iocb */ | 
| James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 1080 | iocb = lpfc_sli_get_iocbq(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1081 | if (iocb == NULL) { | 
|  | 1082 | pring->missbufcnt = cnt; | 
|  | 1083 | return cnt; | 
|  | 1084 | } | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1085 | icmd = &iocb->iocb; | 
|  | 1086 |  | 
|  | 1087 | /* 2 buffers can be posted per command */ | 
|  | 1088 | /* Allocate buffer to post */ | 
|  | 1089 | mp1 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); | 
|  | 1090 | if (mp1) | 
|  | 1091 | mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, | 
|  | 1092 | &mp1->phys); | 
|  | 1093 | if (mp1 == 0 || mp1->virt == 0) { | 
| Jesper Juhl | c9475cb | 2005-11-07 01:01:26 -0800 | [diff] [blame] | 1094 | kfree(mp1); | 
| James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 1095 | lpfc_sli_release_iocbq(phba, iocb); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1096 | pring->missbufcnt = cnt; | 
|  | 1097 | return cnt; | 
|  | 1098 | } | 
|  | 1099 |  | 
|  | 1100 | INIT_LIST_HEAD(&mp1->list); | 
|  | 1101 | /* Allocate buffer to post */ | 
|  | 1102 | if (cnt > 1) { | 
|  | 1103 | mp2 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); | 
|  | 1104 | if (mp2) | 
|  | 1105 | mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, | 
|  | 1106 | &mp2->phys); | 
|  | 1107 | if (mp2 == 0 || mp2->virt == 0) { | 
| Jesper Juhl | c9475cb | 2005-11-07 01:01:26 -0800 | [diff] [blame] | 1108 | kfree(mp2); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1109 | lpfc_mbuf_free(phba, mp1->virt, mp1->phys); | 
|  | 1110 | kfree(mp1); | 
| James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 1111 | lpfc_sli_release_iocbq(phba, iocb); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1112 | pring->missbufcnt = cnt; | 
|  | 1113 | return cnt; | 
|  | 1114 | } | 
|  | 1115 |  | 
|  | 1116 | INIT_LIST_HEAD(&mp2->list); | 
|  | 1117 | } else { | 
|  | 1118 | mp2 = NULL; | 
|  | 1119 | } | 
|  | 1120 |  | 
|  | 1121 | icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys); | 
|  | 1122 | icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys); | 
|  | 1123 | icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE; | 
|  | 1124 | icmd->ulpBdeCount = 1; | 
|  | 1125 | cnt--; | 
|  | 1126 | if (mp2) { | 
|  | 1127 | icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys); | 
|  | 1128 | icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys); | 
|  | 1129 | icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE; | 
|  | 1130 | cnt--; | 
|  | 1131 | icmd->ulpBdeCount = 2; | 
|  | 1132 | } | 
|  | 1133 |  | 
|  | 1134 | icmd->ulpCommand = CMD_QUE_RING_BUF64_CN; | 
|  | 1135 | icmd->ulpLe = 1; | 
|  | 1136 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1137 | if (lpfc_sli_issue_iocb(phba, pring, iocb, 0) == IOCB_ERROR) { | 
|  | 1138 | lpfc_mbuf_free(phba, mp1->virt, mp1->phys); | 
|  | 1139 | kfree(mp1); | 
|  | 1140 | cnt++; | 
|  | 1141 | if (mp2) { | 
|  | 1142 | lpfc_mbuf_free(phba, mp2->virt, mp2->phys); | 
|  | 1143 | kfree(mp2); | 
|  | 1144 | cnt++; | 
|  | 1145 | } | 
| James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 1146 | lpfc_sli_release_iocbq(phba, iocb); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1147 | pring->missbufcnt = cnt; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1148 | return cnt; | 
|  | 1149 | } | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1150 | lpfc_sli_ringpostbuf_put(phba, pring, mp1); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1151 | if (mp2) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1152 | lpfc_sli_ringpostbuf_put(phba, pring, mp2); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1153 | } | 
|  | 1154 | pring->missbufcnt = 0; | 
|  | 1155 | return 0; | 
|  | 1156 | } | 
|  | 1157 |  | 
|  | 1158 | /************************************************************************/ | 
|  | 1159 | /*                                                                      */ | 
|  | 1160 | /*   lpfc_post_rcv_buf                                                  */ | 
|  | 1161 | /*   This routine post initial rcv buffers to the configured rings      */ | 
|  | 1162 | /*                                                                      */ | 
|  | 1163 | /************************************************************************/ | 
|  | 1164 | static int | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1165 | lpfc_post_rcv_buf(struct lpfc_hba *phba) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1166 | { | 
|  | 1167 | struct lpfc_sli *psli = &phba->sli; | 
|  | 1168 |  | 
|  | 1169 | /* Ring 0, ELS / CT buffers */ | 
|  | 1170 | lpfc_post_buffer(phba, &psli->ring[LPFC_ELS_RING], LPFC_BUF_RING0, 1); | 
|  | 1171 | /* Ring 2 - FCP no buffers needed */ | 
|  | 1172 |  | 
|  | 1173 | return 0; | 
|  | 1174 | } | 
|  | 1175 |  | 
|  | 1176 | #define S(N,V) (((V)<<(N))|((V)>>(32-(N)))) | 
|  | 1177 |  | 
|  | 1178 | /************************************************************************/ | 
|  | 1179 | /*                                                                      */ | 
|  | 1180 | /*   lpfc_sha_init                                                      */ | 
|  | 1181 | /*                                                                      */ | 
|  | 1182 | /************************************************************************/ | 
|  | 1183 | static void | 
|  | 1184 | lpfc_sha_init(uint32_t * HashResultPointer) | 
|  | 1185 | { | 
|  | 1186 | HashResultPointer[0] = 0x67452301; | 
|  | 1187 | HashResultPointer[1] = 0xEFCDAB89; | 
|  | 1188 | HashResultPointer[2] = 0x98BADCFE; | 
|  | 1189 | HashResultPointer[3] = 0x10325476; | 
|  | 1190 | HashResultPointer[4] = 0xC3D2E1F0; | 
|  | 1191 | } | 
|  | 1192 |  | 
|  | 1193 | /************************************************************************/ | 
|  | 1194 | /*                                                                      */ | 
|  | 1195 | /*   lpfc_sha_iterate                                                   */ | 
|  | 1196 | /*                                                                      */ | 
|  | 1197 | /************************************************************************/ | 
|  | 1198 | static void | 
|  | 1199 | lpfc_sha_iterate(uint32_t * HashResultPointer, uint32_t * HashWorkingPointer) | 
|  | 1200 | { | 
|  | 1201 | int t; | 
|  | 1202 | uint32_t TEMP; | 
|  | 1203 | uint32_t A, B, C, D, E; | 
|  | 1204 | t = 16; | 
|  | 1205 | do { | 
|  | 1206 | HashWorkingPointer[t] = | 
|  | 1207 | S(1, | 
|  | 1208 | HashWorkingPointer[t - 3] ^ HashWorkingPointer[t - | 
|  | 1209 | 8] ^ | 
|  | 1210 | HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]); | 
|  | 1211 | } while (++t <= 79); | 
|  | 1212 | t = 0; | 
|  | 1213 | A = HashResultPointer[0]; | 
|  | 1214 | B = HashResultPointer[1]; | 
|  | 1215 | C = HashResultPointer[2]; | 
|  | 1216 | D = HashResultPointer[3]; | 
|  | 1217 | E = HashResultPointer[4]; | 
|  | 1218 |  | 
|  | 1219 | do { | 
|  | 1220 | if (t < 20) { | 
|  | 1221 | TEMP = ((B & C) | ((~B) & D)) + 0x5A827999; | 
|  | 1222 | } else if (t < 40) { | 
|  | 1223 | TEMP = (B ^ C ^ D) + 0x6ED9EBA1; | 
|  | 1224 | } else if (t < 60) { | 
|  | 1225 | TEMP = ((B & C) | (B & D) | (C & D)) + 0x8F1BBCDC; | 
|  | 1226 | } else { | 
|  | 1227 | TEMP = (B ^ C ^ D) + 0xCA62C1D6; | 
|  | 1228 | } | 
|  | 1229 | TEMP += S(5, A) + E + HashWorkingPointer[t]; | 
|  | 1230 | E = D; | 
|  | 1231 | D = C; | 
|  | 1232 | C = S(30, B); | 
|  | 1233 | B = A; | 
|  | 1234 | A = TEMP; | 
|  | 1235 | } while (++t <= 79); | 
|  | 1236 |  | 
|  | 1237 | HashResultPointer[0] += A; | 
|  | 1238 | HashResultPointer[1] += B; | 
|  | 1239 | HashResultPointer[2] += C; | 
|  | 1240 | HashResultPointer[3] += D; | 
|  | 1241 | HashResultPointer[4] += E; | 
|  | 1242 |  | 
|  | 1243 | } | 
|  | 1244 |  | 
|  | 1245 | /************************************************************************/ | 
|  | 1246 | /*                                                                      */ | 
|  | 1247 | /*   lpfc_challenge_key                                                 */ | 
|  | 1248 | /*                                                                      */ | 
|  | 1249 | /************************************************************************/ | 
|  | 1250 | static void | 
|  | 1251 | lpfc_challenge_key(uint32_t * RandomChallenge, uint32_t * HashWorking) | 
|  | 1252 | { | 
|  | 1253 | *HashWorking = (*RandomChallenge ^ *HashWorking); | 
|  | 1254 | } | 
|  | 1255 |  | 
|  | 1256 | /************************************************************************/ | 
|  | 1257 | /*                                                                      */ | 
|  | 1258 | /*   lpfc_hba_init                                                      */ | 
|  | 1259 | /*                                                                      */ | 
|  | 1260 | /************************************************************************/ | 
|  | 1261 | void | 
|  | 1262 | lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit) | 
|  | 1263 | { | 
|  | 1264 | int t; | 
|  | 1265 | uint32_t *HashWorking; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1266 | uint32_t *pwwnn = (uint32_t *) phba->wwnn; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1267 |  | 
| Mariusz Kozlowski | bbfbbbc | 2007-08-11 10:13:24 +0200 | [diff] [blame] | 1268 | HashWorking = kcalloc(80, sizeof(uint32_t), GFP_KERNEL); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1269 | if (!HashWorking) | 
|  | 1270 | return; | 
|  | 1271 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1272 | HashWorking[0] = HashWorking[78] = *pwwnn++; | 
|  | 1273 | HashWorking[1] = HashWorking[79] = *pwwnn; | 
|  | 1274 |  | 
|  | 1275 | for (t = 0; t < 7; t++) | 
|  | 1276 | lpfc_challenge_key(phba->RandomData + t, HashWorking + t); | 
|  | 1277 |  | 
|  | 1278 | lpfc_sha_init(hbainit); | 
|  | 1279 | lpfc_sha_iterate(hbainit, HashWorking); | 
|  | 1280 | kfree(HashWorking); | 
|  | 1281 | } | 
|  | 1282 |  | 
|  | 1283 | static void | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1284 | lpfc_cleanup(struct lpfc_vport *vport) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1285 | { | 
|  | 1286 | struct lpfc_nodelist *ndlp, *next_ndlp; | 
|  | 1287 |  | 
|  | 1288 | /* clean up phba - lpfc specific */ | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1289 | lpfc_can_disctmo(vport); | 
|  | 1290 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) | 
| James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 1291 | lpfc_nlp_put(ndlp); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1292 | return; | 
|  | 1293 | } | 
|  | 1294 |  | 
|  | 1295 | static void | 
|  | 1296 | lpfc_establish_link_tmo(unsigned long ptr) | 
|  | 1297 | { | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1298 | struct lpfc_hba   *phba = (struct lpfc_hba *) ptr; | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1299 | struct lpfc_vport **vports; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1300 | unsigned long iflag; | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1301 | int i; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1302 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1303 | /* Re-establishing Link, timer expired */ | 
|  | 1304 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1305 | "1300 Re-establishing Link, timer expired " | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1306 | "Data: x%x x%x\n", | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1307 | phba->pport->fc_flag, phba->pport->port_state); | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1308 | vports = lpfc_create_vport_work_array(phba); | 
|  | 1309 | if (vports != NULL) | 
|  | 1310 | for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) { | 
|  | 1311 | struct Scsi_Host *shost; | 
|  | 1312 | shost = lpfc_shost_from_vport(vports[i]); | 
|  | 1313 | spin_lock_irqsave(shost->host_lock, iflag); | 
|  | 1314 | vports[i]->fc_flag &= ~FC_ESTABLISH_LINK; | 
|  | 1315 | spin_unlock_irqrestore(shost->host_lock, iflag); | 
|  | 1316 | } | 
|  | 1317 | lpfc_destroy_vport_work_array(vports); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1318 | } | 
|  | 1319 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1320 | void | 
|  | 1321 | lpfc_stop_vport_timers(struct lpfc_vport *vport) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1322 | { | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1323 | del_timer_sync(&vport->els_tmofunc); | 
|  | 1324 | del_timer_sync(&vport->fc_fdmitmo); | 
|  | 1325 | lpfc_can_disctmo(vport); | 
|  | 1326 | return; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1327 | } | 
|  | 1328 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1329 | static void | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1330 | lpfc_stop_phba_timers(struct lpfc_hba *phba) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1331 | { | 
| James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1332 | del_timer_sync(&phba->fcp_poll_timer); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1333 | del_timer_sync(&phba->fc_estabtmo); | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1334 | lpfc_stop_vport_timers(phba->pport); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1335 | del_timer_sync(&phba->sli.mbox_tmo); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1336 | del_timer_sync(&phba->fabric_block_timer); | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1337 | phba->hb_outstanding = 0; | 
|  | 1338 | del_timer_sync(&phba->hb_tmofunc); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1339 | return; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1340 | } | 
|  | 1341 |  | 
|  | 1342 | int | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1343 | lpfc_online(struct lpfc_hba *phba) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1344 | { | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1345 | struct lpfc_vport *vport = phba->pport; | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1346 | struct lpfc_vport **vports; | 
|  | 1347 | int i; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1348 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1349 | if (!phba) | 
|  | 1350 | return 0; | 
|  | 1351 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1352 | if (!(vport->fc_flag & FC_OFFLINE_MODE)) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1353 | return 0; | 
|  | 1354 |  | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 1355 | lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1356 | "0458 Bring Adapter online\n"); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1357 |  | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1358 | lpfc_block_mgmt_io(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1359 |  | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1360 | if (!lpfc_sli_queue_setup(phba)) { | 
|  | 1361 | lpfc_unblock_mgmt_io(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1362 | return 1; | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1363 | } | 
|  | 1364 |  | 
|  | 1365 | if (lpfc_sli_hba_setup(phba)) {	/* Initialize the HBA */ | 
|  | 1366 | lpfc_unblock_mgmt_io(phba); | 
|  | 1367 | return 1; | 
|  | 1368 | } | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1369 |  | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1370 | vports = lpfc_create_vport_work_array(phba); | 
|  | 1371 | if (vports != NULL) | 
|  | 1372 | for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) { | 
|  | 1373 | struct Scsi_Host *shost; | 
|  | 1374 | shost = lpfc_shost_from_vport(vports[i]); | 
|  | 1375 | spin_lock_irq(shost->host_lock); | 
|  | 1376 | vports[i]->fc_flag &= ~FC_OFFLINE_MODE; | 
|  | 1377 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) | 
|  | 1378 | vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI; | 
|  | 1379 | spin_unlock_irq(shost->host_lock); | 
|  | 1380 | } | 
|  | 1381 | lpfc_destroy_vport_work_array(vports); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1382 |  | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1383 | lpfc_unblock_mgmt_io(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1384 | return 0; | 
|  | 1385 | } | 
|  | 1386 |  | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1387 | void | 
|  | 1388 | lpfc_block_mgmt_io(struct lpfc_hba * phba) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1389 | { | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1390 | unsigned long iflag; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1391 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1392 | spin_lock_irqsave(&phba->hbalock, iflag); | 
|  | 1393 | phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; | 
|  | 1394 | spin_unlock_irqrestore(&phba->hbalock, iflag); | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1395 | } | 
|  | 1396 |  | 
|  | 1397 | void | 
|  | 1398 | lpfc_unblock_mgmt_io(struct lpfc_hba * phba) | 
|  | 1399 | { | 
|  | 1400 | unsigned long iflag; | 
|  | 1401 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1402 | spin_lock_irqsave(&phba->hbalock, iflag); | 
|  | 1403 | phba->sli.sli_flag &= ~LPFC_BLOCK_MGMT_IO; | 
|  | 1404 | spin_unlock_irqrestore(&phba->hbalock, iflag); | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1405 | } | 
|  | 1406 |  | 
|  | 1407 | void | 
|  | 1408 | lpfc_offline_prep(struct lpfc_hba * phba) | 
|  | 1409 | { | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1410 | struct lpfc_vport *vport = phba->pport; | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1411 | struct lpfc_nodelist  *ndlp, *next_ndlp; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1412 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1413 | if (vport->fc_flag & FC_OFFLINE_MODE) | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1414 | return; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1415 |  | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1416 | lpfc_block_mgmt_io(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1417 |  | 
|  | 1418 | lpfc_linkdown(phba); | 
|  | 1419 |  | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1420 | /* Issue an unreg_login to all nodes */ | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1421 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) | 
| James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 1422 | if (ndlp->nlp_state != NLP_STE_UNUSED_NODE) | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1423 | lpfc_unreg_rpi(vport, ndlp); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1424 |  | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1425 | lpfc_sli_flush_mbox_queue(phba); | 
|  | 1426 | } | 
|  | 1427 |  | 
|  | 1428 | void | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1429 | lpfc_offline(struct lpfc_hba *phba) | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1430 | { | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1431 | struct Scsi_Host  *shost; | 
|  | 1432 | struct lpfc_vport **vports; | 
|  | 1433 | int i; | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1434 |  | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1435 | if (phba->pport->fc_flag & FC_OFFLINE_MODE) | 
| James Smart | 46fa311 | 2007-04-25 09:51:45 -0400 | [diff] [blame] | 1436 | return; | 
| James Smart | 688a886 | 2006-07-06 15:49:56 -0400 | [diff] [blame] | 1437 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1438 | /* stop all timers associated with this hba */ | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1439 | lpfc_stop_phba_timers(phba); | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1440 | vports = lpfc_create_vport_work_array(phba); | 
|  | 1441 | if (vports != NULL) | 
|  | 1442 | for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) | 
|  | 1443 | lpfc_stop_vport_timers(vports[i]); | 
|  | 1444 | lpfc_destroy_vport_work_array(vports); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1445 | lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1446 | "0460 Bring Adapter offline\n"); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1447 | /* Bring down the SLI Layer and cleanup.  The HBA is offline | 
|  | 1448 | now.  */ | 
|  | 1449 | lpfc_sli_hba_down(phba); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1450 | spin_lock_irq(&phba->hbalock); | 
| James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 1451 | phba->work_ha = 0; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1452 | spin_unlock_irq(&phba->hbalock); | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1453 | vports = lpfc_create_vport_work_array(phba); | 
|  | 1454 | if (vports != NULL) | 
|  | 1455 | for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) { | 
|  | 1456 | shost = lpfc_shost_from_vport(vports[i]); | 
|  | 1457 | lpfc_cleanup(vports[i]); | 
|  | 1458 | spin_lock_irq(shost->host_lock); | 
|  | 1459 | vports[i]->work_port_events = 0; | 
|  | 1460 | vports[i]->fc_flag |= FC_OFFLINE_MODE; | 
|  | 1461 | spin_unlock_irq(shost->host_lock); | 
|  | 1462 | } | 
|  | 1463 | lpfc_destroy_vport_work_array(vports); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1464 | } | 
|  | 1465 |  | 
|  | 1466 | /****************************************************************************** | 
|  | 1467 | * Function name: lpfc_scsi_free | 
|  | 1468 | * | 
|  | 1469 | * Description: Called from lpfc_pci_remove_one free internal driver resources | 
|  | 1470 | * | 
|  | 1471 | ******************************************************************************/ | 
|  | 1472 | static int | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1473 | lpfc_scsi_free(struct lpfc_hba *phba) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1474 | { | 
|  | 1475 | struct lpfc_scsi_buf *sb, *sb_next; | 
|  | 1476 | struct lpfc_iocbq *io, *io_next; | 
|  | 1477 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1478 | spin_lock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1479 | /* Release all the lpfc_scsi_bufs maintained by this host. */ | 
|  | 1480 | list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list, list) { | 
|  | 1481 | list_del(&sb->list); | 
|  | 1482 | pci_pool_free(phba->lpfc_scsi_dma_buf_pool, sb->data, | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1483 | sb->dma_handle); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1484 | kfree(sb); | 
|  | 1485 | phba->total_scsi_bufs--; | 
|  | 1486 | } | 
|  | 1487 |  | 
|  | 1488 | /* Release all the lpfc_iocbq entries maintained by this host. */ | 
|  | 1489 | list_for_each_entry_safe(io, io_next, &phba->lpfc_iocb_list, list) { | 
|  | 1490 | list_del(&io->list); | 
|  | 1491 | kfree(io); | 
|  | 1492 | phba->total_iocbq_bufs--; | 
|  | 1493 | } | 
|  | 1494 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1495 | spin_unlock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1496 |  | 
|  | 1497 | return 0; | 
|  | 1498 | } | 
|  | 1499 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1500 | struct lpfc_vport * | 
| James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1501 | lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev) | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1502 | { | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1503 | struct lpfc_vport *vport; | 
|  | 1504 | struct Scsi_Host  *shost; | 
|  | 1505 | int error = 0; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1506 |  | 
| James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1507 | if (dev != &phba->pcidev->dev) | 
|  | 1508 | shost = scsi_host_alloc(&lpfc_vport_template, | 
|  | 1509 | sizeof(struct lpfc_vport)); | 
|  | 1510 | else | 
|  | 1511 | shost = scsi_host_alloc(&lpfc_template, | 
|  | 1512 | sizeof(struct lpfc_vport)); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1513 | if (!shost) | 
|  | 1514 | goto out; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1515 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1516 | vport = (struct lpfc_vport *) shost->hostdata; | 
|  | 1517 | vport->phba = phba; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1518 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1519 | vport->load_flag |= FC_LOADING; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1520 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1521 |  | 
| James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1522 | lpfc_get_vport_cfgparam(vport); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1523 | shost->unique_id = instance; | 
|  | 1524 | shost->max_id = LPFC_MAX_TARGET; | 
| James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1525 | shost->max_lun = vport->cfg_max_luns; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1526 | shost->this_id = -1; | 
|  | 1527 | shost->max_cmd_len = 16; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1528 | /* | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1529 | * Set initial can_queue value since 0 is no longer supported and | 
|  | 1530 | * scsi_add_host will fail. This will be adjusted later based on the | 
|  | 1531 | * max xri value determined in hba setup. | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1532 | */ | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1533 | shost->can_queue = phba->cfg_hba_queue_depth - 10; | 
| James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1534 | if (dev != &phba->pcidev->dev) { | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1535 | shost->transportt = lpfc_vport_transport_template; | 
|  | 1536 | vport->port_type = LPFC_NPIV_PORT; | 
|  | 1537 | } else { | 
|  | 1538 | shost->transportt = lpfc_transport_template; | 
|  | 1539 | vport->port_type = LPFC_PHYSICAL_PORT; | 
|  | 1540 | } | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1541 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1542 | /* Initialize all internally managed lists. */ | 
|  | 1543 | INIT_LIST_HEAD(&vport->fc_nodes); | 
|  | 1544 | spin_lock_init(&vport->work_port_lock); | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1545 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1546 | init_timer(&vport->fc_disctmo); | 
|  | 1547 | vport->fc_disctmo.function = lpfc_disc_timeout; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1548 | vport->fc_disctmo.data = (unsigned long)vport; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1549 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1550 | init_timer(&vport->fc_fdmitmo); | 
|  | 1551 | vport->fc_fdmitmo.function = lpfc_fdmi_tmo; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1552 | vport->fc_fdmitmo.data = (unsigned long)vport; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1553 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1554 | init_timer(&vport->els_tmofunc); | 
|  | 1555 | vport->els_tmofunc.function = lpfc_els_timeout; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1556 | vport->els_tmofunc.data = (unsigned long)vport; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1557 |  | 
| James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1558 | error = scsi_add_host(shost, dev); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1559 | if (error) | 
|  | 1560 | goto out_put_shost; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1561 |  | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1562 | spin_lock_irq(&phba->hbalock); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1563 | list_add_tail(&vport->listentry, &phba->port_list); | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1564 | spin_unlock_irq(&phba->hbalock); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1565 | return vport; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1566 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1567 | out_put_shost: | 
|  | 1568 | scsi_host_put(shost); | 
|  | 1569 | out: | 
|  | 1570 | return NULL; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1571 | } | 
|  | 1572 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1573 | void | 
|  | 1574 | destroy_port(struct lpfc_vport *vport) | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1575 | { | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1576 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | 
|  | 1577 | struct lpfc_hba  *phba = vport->phba; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1578 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1579 | kfree(vport->vname); | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1580 |  | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1581 | lpfc_debugfs_terminate(vport); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1582 | fc_remove_host(shost); | 
|  | 1583 | scsi_remove_host(shost); | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1584 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1585 | spin_lock_irq(&phba->hbalock); | 
|  | 1586 | list_del_init(&vport->listentry); | 
|  | 1587 | spin_unlock_irq(&phba->hbalock); | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1588 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1589 | lpfc_cleanup(vport); | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1590 | return; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1591 | } | 
|  | 1592 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1593 | int | 
|  | 1594 | lpfc_get_instance(void) | 
|  | 1595 | { | 
|  | 1596 | int instance = 0; | 
|  | 1597 |  | 
|  | 1598 | /* Assign an unused number */ | 
|  | 1599 | if (!idr_pre_get(&lpfc_hba_index, GFP_KERNEL)) | 
|  | 1600 | return -1; | 
|  | 1601 | if (idr_get_new(&lpfc_hba_index, NULL, &instance)) | 
|  | 1602 | return -1; | 
|  | 1603 | return instance; | 
|  | 1604 | } | 
|  | 1605 |  | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1606 | /* | 
|  | 1607 | * Note: there is no scan_start function as adapter initialization | 
|  | 1608 | * will have asynchronously kicked off the link initialization. | 
|  | 1609 | */ | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1610 |  | 
|  | 1611 | int lpfc_scan_finished(struct Scsi_Host *shost, unsigned long time) | 
|  | 1612 | { | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1613 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 
|  | 1614 | struct lpfc_hba   *phba = vport->phba; | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1615 | int stat = 0; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1616 |  | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1617 | spin_lock_irq(shost->host_lock); | 
|  | 1618 |  | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1619 | if (vport->load_flag & FC_UNLOADING) { | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1620 | stat = 1; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1621 | goto finished; | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1622 | } | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1623 | if (time >= 30 * HZ) { | 
|  | 1624 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1625 | "0461 Scanning longer than 30 " | 
|  | 1626 | "seconds.  Continuing initialization\n"); | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1627 | stat = 1; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1628 | goto finished; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1629 | } | 
|  | 1630 | if (time >= 15 * HZ && phba->link_state <= LPFC_LINK_DOWN) { | 
|  | 1631 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1632 | "0465 Link down longer than 15 " | 
|  | 1633 | "seconds.  Continuing initialization\n"); | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1634 | stat = 1; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1635 | goto finished; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1636 | } | 
|  | 1637 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1638 | if (vport->port_state != LPFC_VPORT_READY) | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1639 | goto finished; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1640 | if (vport->num_disc_nodes || vport->fc_prli_sent) | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1641 | goto finished; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1642 | if (vport->fc_map_cnt == 0 && time < 2 * HZ) | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1643 | goto finished; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1644 | if ((phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) != 0) | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1645 | goto finished; | 
|  | 1646 |  | 
|  | 1647 | stat = 1; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1648 |  | 
|  | 1649 | finished: | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1650 | spin_unlock_irq(shost->host_lock); | 
|  | 1651 | return stat; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1652 | } | 
|  | 1653 |  | 
|  | 1654 | void lpfc_host_attrib_init(struct Scsi_Host *shost) | 
|  | 1655 | { | 
|  | 1656 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 
|  | 1657 | struct lpfc_hba   *phba = vport->phba; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1658 | /* | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1659 | * Set fixed host attributes.  Must done after lpfc_sli_hba_setup(). | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1660 | */ | 
|  | 1661 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1662 | fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); | 
|  | 1663 | fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1664 | fc_host_supported_classes(shost) = FC_COS_CLASS3; | 
|  | 1665 |  | 
|  | 1666 | memset(fc_host_supported_fc4s(shost), 0, | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1667 | sizeof(fc_host_supported_fc4s(shost))); | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1668 | fc_host_supported_fc4s(shost)[2] = 1; | 
|  | 1669 | fc_host_supported_fc4s(shost)[7] = 1; | 
|  | 1670 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1671 | lpfc_vport_symbolic_node_name(vport, fc_host_symbolic_name(shost), | 
|  | 1672 | sizeof fc_host_symbolic_name(shost)); | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1673 |  | 
|  | 1674 | fc_host_supported_speeds(shost) = 0; | 
|  | 1675 | if (phba->lmt & LMT_10Gb) | 
|  | 1676 | fc_host_supported_speeds(shost) |= FC_PORTSPEED_10GBIT; | 
|  | 1677 | if (phba->lmt & LMT_4Gb) | 
|  | 1678 | fc_host_supported_speeds(shost) |= FC_PORTSPEED_4GBIT; | 
|  | 1679 | if (phba->lmt & LMT_2Gb) | 
|  | 1680 | fc_host_supported_speeds(shost) |= FC_PORTSPEED_2GBIT; | 
|  | 1681 | if (phba->lmt & LMT_1Gb) | 
|  | 1682 | fc_host_supported_speeds(shost) |= FC_PORTSPEED_1GBIT; | 
|  | 1683 |  | 
|  | 1684 | fc_host_maxframe_size(shost) = | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1685 | (((uint32_t) vport->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) | | 
|  | 1686 | (uint32_t) vport->fc_sparam.cmn.bbRcvSizeLsb; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1687 |  | 
|  | 1688 | /* This value is also unchanging */ | 
|  | 1689 | memset(fc_host_active_fc4s(shost), 0, | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1690 | sizeof(fc_host_active_fc4s(shost))); | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1691 | fc_host_active_fc4s(shost)[2] = 1; | 
|  | 1692 | fc_host_active_fc4s(shost)[7] = 1; | 
|  | 1693 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1694 | fc_host_max_npiv_vports(shost) = phba->max_vpi; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1695 | spin_lock_irq(shost->host_lock); | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1696 | vport->load_flag &= ~FC_LOADING; | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1697 | spin_unlock_irq(shost->host_lock); | 
| James Smart | 47a8617 | 2007-04-25 09:53:22 -0400 | [diff] [blame] | 1698 | } | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1699 |  | 
|  | 1700 | static int __devinit | 
|  | 1701 | lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | 
|  | 1702 | { | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1703 | struct lpfc_vport *vport = NULL; | 
|  | 1704 | struct lpfc_hba   *phba; | 
|  | 1705 | struct lpfc_sli   *psli; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1706 | struct lpfc_iocbq *iocbq_entry = NULL, *iocbq_next = NULL; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1707 | struct Scsi_Host  *shost = NULL; | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1708 | void *ptr; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1709 | unsigned long bar0map_len, bar2map_len; | 
| James Bottomley | a578503 | 2007-07-14 18:47:04 -0500 | [diff] [blame] | 1710 | int error = -ENODEV; | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1711 | int  i, hbq_count; | 
| James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 1712 | uint16_t iotag; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1713 |  | 
|  | 1714 | if (pci_enable_device(pdev)) | 
|  | 1715 | goto out; | 
|  | 1716 | if (pci_request_regions(pdev, LPFC_DRIVER_NAME)) | 
|  | 1717 | goto out_disable_device; | 
|  | 1718 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1719 | phba = kzalloc(sizeof (struct lpfc_hba), GFP_KERNEL); | 
|  | 1720 | if (!phba) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1721 | goto out_release_regions; | 
|  | 1722 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1723 | spin_lock_init(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1724 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1725 | phba->pcidev = pdev; | 
|  | 1726 |  | 
|  | 1727 | /* Assign an unused board number */ | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1728 | if ((phba->brd_no = lpfc_get_instance()) < 0) | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1729 | goto out_free_phba; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1730 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1731 | INIT_LIST_HEAD(&phba->port_list); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1732 | /* | 
|  | 1733 | * Get all the module params for configuring this host and then | 
|  | 1734 | * establish the host. | 
|  | 1735 | */ | 
|  | 1736 | lpfc_get_cfgparam(phba); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1737 | phba->max_vpi = LPFC_MAX_VPI; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1738 |  | 
|  | 1739 | /* Initialize timers used by driver */ | 
|  | 1740 | init_timer(&phba->fc_estabtmo); | 
|  | 1741 | phba->fc_estabtmo.function = lpfc_establish_link_tmo; | 
|  | 1742 | phba->fc_estabtmo.data = (unsigned long)phba; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1743 |  | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1744 | init_timer(&phba->hb_tmofunc); | 
|  | 1745 | phba->hb_tmofunc.function = lpfc_hb_timeout; | 
|  | 1746 | phba->hb_tmofunc.data = (unsigned long)phba; | 
|  | 1747 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1748 | psli = &phba->sli; | 
|  | 1749 | init_timer(&psli->mbox_tmo); | 
|  | 1750 | psli->mbox_tmo.function = lpfc_mbox_timeout; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1751 | psli->mbox_tmo.data = (unsigned long) phba; | 
| James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1752 | init_timer(&phba->fcp_poll_timer); | 
|  | 1753 | phba->fcp_poll_timer.function = lpfc_poll_timeout; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1754 | phba->fcp_poll_timer.data = (unsigned long) phba; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1755 | init_timer(&phba->fabric_block_timer); | 
|  | 1756 | phba->fabric_block_timer.function = lpfc_fabric_block_timeout; | 
|  | 1757 | phba->fabric_block_timer.data = (unsigned long) phba; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1758 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1759 | pci_set_master(pdev); | 
| Randy Dunlap | 694625c | 2007-07-09 11:55:54 -0700 | [diff] [blame] | 1760 | pci_try_set_mwi(pdev); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1761 |  | 
|  | 1762 | if (pci_set_dma_mask(phba->pcidev, DMA_64BIT_MASK) != 0) | 
|  | 1763 | if (pci_set_dma_mask(phba->pcidev, DMA_32BIT_MASK) != 0) | 
|  | 1764 | goto out_idr_remove; | 
|  | 1765 |  | 
|  | 1766 | /* | 
|  | 1767 | * Get the bus address of Bar0 and Bar2 and the number of bytes | 
|  | 1768 | * required by each mapping. | 
|  | 1769 | */ | 
|  | 1770 | phba->pci_bar0_map = pci_resource_start(phba->pcidev, 0); | 
|  | 1771 | bar0map_len        = pci_resource_len(phba->pcidev, 0); | 
|  | 1772 |  | 
|  | 1773 | phba->pci_bar2_map = pci_resource_start(phba->pcidev, 2); | 
|  | 1774 | bar2map_len        = pci_resource_len(phba->pcidev, 2); | 
|  | 1775 |  | 
| Jamie Wellnitz | 901a920 | 2006-02-28 19:25:19 -0500 | [diff] [blame] | 1776 | /* Map HBA SLIM to a kernel virtual address. */ | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1777 | phba->slim_memmap_p      = ioremap(phba->pci_bar0_map, bar0map_len); | 
| Jamie Wellnitz | 901a920 | 2006-02-28 19:25:19 -0500 | [diff] [blame] | 1778 | if (!phba->slim_memmap_p) { | 
|  | 1779 | error = -ENODEV; | 
|  | 1780 | dev_printk(KERN_ERR, &pdev->dev, | 
|  | 1781 | "ioremap failed for SLIM memory.\n"); | 
|  | 1782 | goto out_idr_remove; | 
|  | 1783 | } | 
|  | 1784 |  | 
|  | 1785 | /* Map HBA Control Registers to a kernel virtual address. */ | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1786 | phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); | 
| Jamie Wellnitz | 901a920 | 2006-02-28 19:25:19 -0500 | [diff] [blame] | 1787 | if (!phba->ctrl_regs_memmap_p) { | 
|  | 1788 | error = -ENODEV; | 
|  | 1789 | dev_printk(KERN_ERR, &pdev->dev, | 
|  | 1790 | "ioremap failed for HBA control registers.\n"); | 
|  | 1791 | goto out_iounmap_slim; | 
|  | 1792 | } | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1793 |  | 
|  | 1794 | /* Allocate memory for SLI-2 structures */ | 
|  | 1795 | phba->slim2p = dma_alloc_coherent(&phba->pcidev->dev, SLI2_SLIM_SIZE, | 
|  | 1796 | &phba->slim2p_mapping, GFP_KERNEL); | 
|  | 1797 | if (!phba->slim2p) | 
|  | 1798 | goto out_iounmap; | 
|  | 1799 |  | 
| James.Smart@Emulex.Com | f91b392 | 2005-10-28 20:29:28 -0400 | [diff] [blame] | 1800 | memset(phba->slim2p, 0, SLI2_SLIM_SIZE); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1801 |  | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 1802 | phba->hbqslimp.virt = dma_alloc_coherent(&phba->pcidev->dev, | 
|  | 1803 | lpfc_sli_hbq_size(), | 
|  | 1804 | &phba->hbqslimp.phys, | 
|  | 1805 | GFP_KERNEL); | 
|  | 1806 | if (!phba->hbqslimp.virt) | 
|  | 1807 | goto out_free_slim; | 
|  | 1808 |  | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1809 | hbq_count = lpfc_sli_hbq_count(); | 
|  | 1810 | ptr = phba->hbqslimp.virt; | 
|  | 1811 | for (i = 0; i < hbq_count; ++i) { | 
|  | 1812 | phba->hbqs[i].hbq_virt = ptr; | 
|  | 1813 | INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list); | 
|  | 1814 | ptr += (lpfc_hbq_defs[i]->entry_count * | 
|  | 1815 | sizeof(struct lpfc_hbq_entry)); | 
|  | 1816 | } | 
|  | 1817 | phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc; | 
|  | 1818 | phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer  = lpfc_els_hbq_free; | 
|  | 1819 |  | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 1820 | memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); | 
|  | 1821 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1822 | /* Initialize the SLI Layer to run with lpfc HBAs. */ | 
|  | 1823 | lpfc_sli_setup(phba); | 
|  | 1824 | lpfc_sli_queue_setup(phba); | 
|  | 1825 |  | 
|  | 1826 | error = lpfc_mem_alloc(phba); | 
|  | 1827 | if (error) | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 1828 | goto out_free_hbqslimp; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1829 |  | 
|  | 1830 | /* Initialize and populate the iocb list per host.  */ | 
|  | 1831 | INIT_LIST_HEAD(&phba->lpfc_iocb_list); | 
|  | 1832 | for (i = 0; i < LPFC_IOCB_LIST_CNT; i++) { | 
| Yoann Padioleau | dd00cc4 | 2007-07-19 01:49:03 -0700 | [diff] [blame] | 1833 | iocbq_entry = kzalloc(sizeof(struct lpfc_iocbq), GFP_KERNEL); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1834 | if (iocbq_entry == NULL) { | 
|  | 1835 | printk(KERN_ERR "%s: only allocated %d iocbs of " | 
|  | 1836 | "expected %d count. Unloading driver.\n", | 
|  | 1837 | __FUNCTION__, i, LPFC_IOCB_LIST_CNT); | 
|  | 1838 | error = -ENOMEM; | 
|  | 1839 | goto out_free_iocbq; | 
|  | 1840 | } | 
|  | 1841 |  | 
| James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 1842 | iotag = lpfc_sli_next_iotag(phba, iocbq_entry); | 
|  | 1843 | if (iotag == 0) { | 
|  | 1844 | kfree (iocbq_entry); | 
|  | 1845 | printk(KERN_ERR "%s: failed to allocate IOTAG. " | 
|  | 1846 | "Unloading driver.\n", | 
|  | 1847 | __FUNCTION__); | 
|  | 1848 | error = -ENOMEM; | 
|  | 1849 | goto out_free_iocbq; | 
|  | 1850 | } | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1851 |  | 
|  | 1852 | spin_lock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1853 | list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); | 
|  | 1854 | phba->total_iocbq_bufs++; | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1855 | spin_unlock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1856 | } | 
|  | 1857 |  | 
|  | 1858 | /* Initialize HBA structure */ | 
|  | 1859 | phba->fc_edtov = FF_DEF_EDTOV; | 
|  | 1860 | phba->fc_ratov = FF_DEF_RATOV; | 
|  | 1861 | phba->fc_altov = FF_DEF_ALTOV; | 
|  | 1862 | phba->fc_arbtov = FF_DEF_ARBTOV; | 
|  | 1863 |  | 
|  | 1864 | INIT_LIST_HEAD(&phba->work_list); | 
|  | 1865 | phba->work_ha_mask = (HA_ERATT|HA_MBATT|HA_LATT); | 
|  | 1866 | phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); | 
|  | 1867 |  | 
|  | 1868 | /* Startup the kernel thread for this host adapter. */ | 
|  | 1869 | phba->worker_thread = kthread_run(lpfc_do_work, phba, | 
|  | 1870 | "lpfc_worker_%d", phba->brd_no); | 
|  | 1871 | if (IS_ERR(phba->worker_thread)) { | 
|  | 1872 | error = PTR_ERR(phba->worker_thread); | 
|  | 1873 | goto out_free_iocbq; | 
|  | 1874 | } | 
|  | 1875 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1876 | /* Initialize the list of scsi buffers used by driver for scsi IO. */ | 
| James.Smart@Emulex.Com | 875fbdf | 2005-11-29 16:32:13 -0500 | [diff] [blame] | 1877 | spin_lock_init(&phba->scsi_buf_list_lock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1878 | INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list); | 
|  | 1879 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1880 | /* Initialize list of fabric iocbs */ | 
|  | 1881 | INIT_LIST_HEAD(&phba->fabric_iocb_list); | 
|  | 1882 |  | 
| James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1883 | vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1884 | if (!vport) | 
|  | 1885 | goto out_kthread_stop; | 
|  | 1886 |  | 
|  | 1887 | shost = lpfc_shost_from_vport(vport); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1888 | phba->pport = vport; | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1889 | lpfc_debugfs_initialize(vport); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1890 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1891 | pci_set_drvdata(pdev, shost); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1892 |  | 
| James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 1893 | if (phba->cfg_use_msi) { | 
|  | 1894 | error = pci_enable_msi(phba->pcidev); | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1895 | if (!error) | 
|  | 1896 | phba->using_msi = 1; | 
|  | 1897 | else | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1898 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, | 
|  | 1899 | "0452 Enable MSI failed, continuing " | 
|  | 1900 | "with IRQ\n"); | 
| James Smart | 4ff4324 | 2006-12-02 13:34:56 -0500 | [diff] [blame] | 1901 | } | 
|  | 1902 |  | 
| Thomas Gleixner | 1d6f359 | 2006-07-01 19:29:42 -0700 | [diff] [blame] | 1903 | error =	request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED, | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1904 | LPFC_DRIVER_NAME, phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1905 | if (error) { | 
|  | 1906 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 
| James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1907 | "0451 Enable interrupt handler failed\n"); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1908 | goto out_disable_msi; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1909 | } | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1910 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1911 | phba->MBslimaddr = phba->slim_memmap_p; | 
|  | 1912 | phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; | 
|  | 1913 | phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; | 
|  | 1914 | phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; | 
|  | 1915 | phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; | 
|  | 1916 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1917 | if (lpfc_alloc_sysfs_attr(vport)) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1918 | goto out_free_irq; | 
|  | 1919 |  | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1920 | if (lpfc_sli_hba_setup(phba)) | 
|  | 1921 | goto out_remove_device; | 
|  | 1922 |  | 
|  | 1923 | /* | 
|  | 1924 | * hba setup may have changed the hba_queue_depth so we need to adjust | 
|  | 1925 | * the value of can_queue. | 
|  | 1926 | */ | 
|  | 1927 | shost->can_queue = phba->cfg_hba_queue_depth - 10; | 
|  | 1928 |  | 
|  | 1929 | lpfc_host_attrib_init(shost); | 
|  | 1930 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1931 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) { | 
|  | 1932 | spin_lock_irq(shost->host_lock); | 
|  | 1933 | lpfc_poll_start_timer(phba); | 
|  | 1934 | spin_unlock_irq(shost->host_lock); | 
|  | 1935 | } | 
| James Smart | 8f6d98d | 2006-08-01 07:34:00 -0400 | [diff] [blame] | 1936 |  | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1937 | scsi_scan_host(shost); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1938 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1939 | return 0; | 
|  | 1940 |  | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1941 | out_remove_device: | 
|  | 1942 | lpfc_free_sysfs_attr(vport); | 
|  | 1943 | spin_lock_irq(shost->host_lock); | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1944 | vport->load_flag |= FC_UNLOADING; | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1945 | spin_unlock_irq(shost->host_lock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1946 | out_free_irq: | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1947 | lpfc_stop_phba_timers(phba); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1948 | phba->pport->work_port_events = 0; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1949 | free_irq(phba->pcidev->irq, phba); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1950 | out_disable_msi: | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1951 | if (phba->using_msi) | 
|  | 1952 | pci_disable_msi(phba->pcidev); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1953 | destroy_port(vport); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1954 | out_kthread_stop: | 
|  | 1955 | kthread_stop(phba->worker_thread); | 
|  | 1956 | out_free_iocbq: | 
|  | 1957 | list_for_each_entry_safe(iocbq_entry, iocbq_next, | 
|  | 1958 | &phba->lpfc_iocb_list, list) { | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1959 | kfree(iocbq_entry); | 
|  | 1960 | phba->total_iocbq_bufs--; | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1961 | } | 
|  | 1962 | lpfc_mem_free(phba); | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 1963 | out_free_hbqslimp: | 
|  | 1964 | dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), phba->hbqslimp.virt, | 
|  | 1965 | phba->hbqslimp.phys); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1966 | out_free_slim: | 
|  | 1967 | dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, phba->slim2p, | 
|  | 1968 | phba->slim2p_mapping); | 
|  | 1969 | out_iounmap: | 
|  | 1970 | iounmap(phba->ctrl_regs_memmap_p); | 
| Jamie Wellnitz | 901a920 | 2006-02-28 19:25:19 -0500 | [diff] [blame] | 1971 | out_iounmap_slim: | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1972 | iounmap(phba->slim_memmap_p); | 
|  | 1973 | out_idr_remove: | 
|  | 1974 | idr_remove(&lpfc_hba_index, phba->brd_no); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1975 | out_free_phba: | 
|  | 1976 | kfree(phba); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1977 | out_release_regions: | 
|  | 1978 | pci_release_regions(pdev); | 
|  | 1979 | out_disable_device: | 
|  | 1980 | pci_disable_device(pdev); | 
|  | 1981 | out: | 
| James Smart | defbcf1 | 2006-04-16 22:26:50 -0400 | [diff] [blame] | 1982 | pci_set_drvdata(pdev, NULL); | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1983 | if (shost) | 
|  | 1984 | scsi_host_put(shost); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1985 | return error; | 
|  | 1986 | } | 
|  | 1987 |  | 
|  | 1988 | static void __devexit | 
|  | 1989 | lpfc_pci_remove_one(struct pci_dev *pdev) | 
|  | 1990 | { | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1991 | struct Scsi_Host  *shost = pci_get_drvdata(pdev); | 
|  | 1992 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | 
|  | 1993 | struct lpfc_hba   *phba = vport->phba; | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1994 | spin_lock_irq(&phba->hbalock); | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1995 | vport->load_flag |= FC_UNLOADING; | 
| James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 1996 | spin_unlock_irq(&phba->hbalock); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1997 |  | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1998 | kfree(vport->vname); | 
|  | 1999 | lpfc_free_sysfs_attr(vport); | 
|  | 2000 |  | 
|  | 2001 | fc_remove_host(shost); | 
|  | 2002 | scsi_remove_host(shost); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2003 | /* | 
|  | 2004 | * Bring down the SLI Layer. This step disable all interrupts, | 
|  | 2005 | * clears the rings, discards all mailbox commands, and resets | 
|  | 2006 | * the HBA. | 
|  | 2007 | */ | 
|  | 2008 | lpfc_sli_hba_down(phba); | 
|  | 2009 | lpfc_sli_brdrestart(phba); | 
|  | 2010 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2011 | lpfc_stop_phba_timers(phba); | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2012 | spin_lock_irq(&phba->hbalock); | 
|  | 2013 | list_del_init(&vport->listentry); | 
|  | 2014 | spin_unlock_irq(&phba->hbalock); | 
|  | 2015 |  | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2016 | lpfc_debugfs_terminate(vport); | 
|  | 2017 | lpfc_cleanup(vport); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2018 |  | 
|  | 2019 | kthread_stop(phba->worker_thread); | 
|  | 2020 |  | 
|  | 2021 | /* Release the irq reservation */ | 
|  | 2022 | free_irq(phba->pcidev->irq, phba); | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2023 | if (phba->using_msi) | 
|  | 2024 | pci_disable_msi(phba->pcidev); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2025 |  | 
|  | 2026 | pci_set_drvdata(pdev, NULL); | 
| James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2027 | scsi_host_put(shost); | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2028 |  | 
|  | 2029 | /* | 
|  | 2030 | * Call scsi_free before mem_free since scsi bufs are released to their | 
|  | 2031 | * corresponding pools here. | 
|  | 2032 | */ | 
|  | 2033 | lpfc_scsi_free(phba); | 
|  | 2034 | lpfc_mem_free(phba); | 
|  | 2035 |  | 
| James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 2036 | dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), phba->hbqslimp.virt, | 
|  | 2037 | phba->hbqslimp.phys); | 
|  | 2038 |  | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2039 | /* Free resources associated with SLI2 interface */ | 
|  | 2040 | dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, | 
|  | 2041 | phba->slim2p, phba->slim2p_mapping); | 
|  | 2042 |  | 
|  | 2043 | /* unmap adapter SLIM and Control Registers */ | 
|  | 2044 | iounmap(phba->ctrl_regs_memmap_p); | 
|  | 2045 | iounmap(phba->slim_memmap_p); | 
|  | 2046 |  | 
|  | 2047 | idr_remove(&lpfc_hba_index, phba->brd_no); | 
|  | 2048 |  | 
|  | 2049 | kfree(phba); | 
|  | 2050 |  | 
|  | 2051 | pci_release_regions(pdev); | 
|  | 2052 | pci_disable_device(pdev); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2053 | } | 
|  | 2054 |  | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 2055 | /** | 
|  | 2056 | * lpfc_io_error_detected - called when PCI error is detected | 
|  | 2057 | * @pdev: Pointer to PCI device | 
|  | 2058 | * @state: The current pci conneection state | 
|  | 2059 | * | 
|  | 2060 | * This function is called after a PCI bus error affecting | 
|  | 2061 | * this device has been detected. | 
|  | 2062 | */ | 
|  | 2063 | static pci_ers_result_t lpfc_io_error_detected(struct pci_dev *pdev, | 
|  | 2064 | pci_channel_state_t state) | 
|  | 2065 | { | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2066 | struct Scsi_Host *shost = pci_get_drvdata(pdev); | 
|  | 2067 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 2068 | struct lpfc_sli *psli = &phba->sli; | 
|  | 2069 | struct lpfc_sli_ring  *pring; | 
|  | 2070 |  | 
| Linas Vepstas | 5daa49e | 2007-03-08 16:19:11 -0600 | [diff] [blame] | 2071 | if (state == pci_channel_io_perm_failure) | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 2072 | return PCI_ERS_RESULT_DISCONNECT; | 
| Linas Vepstas | 5daa49e | 2007-03-08 16:19:11 -0600 | [diff] [blame] | 2073 |  | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 2074 | pci_disable_device(pdev); | 
|  | 2075 | /* | 
|  | 2076 | * There may be I/Os dropped by the firmware. | 
|  | 2077 | * Error iocb (I/O) on txcmplq and let the SCSI layer | 
|  | 2078 | * retry it after re-establishing link. | 
|  | 2079 | */ | 
|  | 2080 | pring = &psli->ring[psli->fcp_ring]; | 
|  | 2081 | lpfc_sli_abort_iocb_ring(phba, pring); | 
|  | 2082 |  | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2083 | /* Release the irq reservation */ | 
|  | 2084 | free_irq(phba->pcidev->irq, phba); | 
|  | 2085 | if (phba->using_msi) | 
|  | 2086 | pci_disable_msi(phba->pcidev); | 
|  | 2087 |  | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 2088 | /* Request a slot reset. */ | 
|  | 2089 | return PCI_ERS_RESULT_NEED_RESET; | 
|  | 2090 | } | 
|  | 2091 |  | 
|  | 2092 | /** | 
|  | 2093 | * lpfc_io_slot_reset - called after the pci bus has been reset. | 
|  | 2094 | * @pdev: Pointer to PCI device | 
|  | 2095 | * | 
|  | 2096 | * Restart the card from scratch, as if from a cold-boot. | 
|  | 2097 | */ | 
|  | 2098 | static pci_ers_result_t lpfc_io_slot_reset(struct pci_dev *pdev) | 
|  | 2099 | { | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2100 | struct Scsi_Host *shost = pci_get_drvdata(pdev); | 
|  | 2101 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 2102 | struct lpfc_sli *psli = &phba->sli; | 
|  | 2103 | int bars = pci_select_bars(pdev, IORESOURCE_MEM); | 
|  | 2104 |  | 
|  | 2105 | dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); | 
|  | 2106 | if (pci_enable_device_bars(pdev, bars)) { | 
|  | 2107 | printk(KERN_ERR "lpfc: Cannot re-enable " | 
|  | 2108 | "PCI device after reset.\n"); | 
|  | 2109 | return PCI_ERS_RESULT_DISCONNECT; | 
|  | 2110 | } | 
|  | 2111 |  | 
|  | 2112 | pci_set_master(pdev); | 
|  | 2113 |  | 
|  | 2114 | /* Re-establishing Link */ | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2115 | spin_lock_irq(shost->host_lock); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2116 | phba->pport->fc_flag |= FC_ESTABLISH_LINK; | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2117 | spin_unlock_irq(shost->host_lock); | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 2118 |  | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2119 | spin_lock_irq(&phba->hbalock); | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 2120 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2121 | spin_unlock_irq(&phba->hbalock); | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 2122 |  | 
|  | 2123 |  | 
|  | 2124 | /* Take device offline; this will perform cleanup */ | 
|  | 2125 | lpfc_offline(phba); | 
|  | 2126 | lpfc_sli_brdrestart(phba); | 
|  | 2127 |  | 
|  | 2128 | return PCI_ERS_RESULT_RECOVERED; | 
|  | 2129 | } | 
|  | 2130 |  | 
|  | 2131 | /** | 
|  | 2132 | * lpfc_io_resume - called when traffic can start flowing again. | 
|  | 2133 | * @pdev: Pointer to PCI device | 
|  | 2134 | * | 
|  | 2135 | * This callback is called when the error recovery driver tells us that | 
|  | 2136 | * its OK to resume normal operation. | 
|  | 2137 | */ | 
|  | 2138 | static void lpfc_io_resume(struct pci_dev *pdev) | 
|  | 2139 | { | 
| James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2140 | struct Scsi_Host *shost = pci_get_drvdata(pdev); | 
|  | 2141 | struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 2142 |  | 
|  | 2143 | if (lpfc_online(phba) == 0) { | 
|  | 2144 | mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60); | 
|  | 2145 | } | 
|  | 2146 | } | 
|  | 2147 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2148 | static struct pci_device_id lpfc_id_table[] = { | 
|  | 2149 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_VIPER, | 
|  | 2150 | PCI_ANY_ID, PCI_ANY_ID, }, | 
| James.Smart@Emulex.Com | 06325e7 | 2005-06-25 10:34:22 -0400 | [diff] [blame] | 2151 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_FIREFLY, | 
|  | 2152 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2153 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_THOR, | 
|  | 2154 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2155 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PEGASUS, | 
|  | 2156 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2157 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_CENTAUR, | 
|  | 2158 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2159 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_DRAGONFLY, | 
|  | 2160 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2161 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SUPERFLY, | 
|  | 2162 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2163 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_RFLY, | 
|  | 2164 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2165 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PFLY, | 
|  | 2166 | PCI_ANY_ID, PCI_ANY_ID, }, | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 2167 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE, | 
|  | 2168 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2169 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_SCSP, | 
|  | 2170 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2171 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_DCSP, | 
|  | 2172 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2173 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS, | 
|  | 2174 | PCI_ANY_ID, PCI_ANY_ID, }, | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 2175 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_SCSP, | 
|  | 2176 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2177 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_DCSP, | 
|  | 2178 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2179 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BMID, | 
|  | 2180 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2181 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BSMB, | 
|  | 2182 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2183 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR, | 
|  | 2184 | PCI_ANY_ID, PCI_ANY_ID, }, | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 2185 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_SCSP, | 
|  | 2186 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2187 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_DCSP, | 
|  | 2188 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2189 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZMID, | 
|  | 2190 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2191 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZSMB, | 
|  | 2192 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2193 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_TFLY, | 
|  | 2194 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2195 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP101, | 
|  | 2196 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2197 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP10000S, | 
|  | 2198 | PCI_ANY_ID, PCI_ANY_ID, }, | 
| James.Smart@Emulex.Com | e4adb20 | 2005-11-28 11:42:12 -0500 | [diff] [blame] | 2199 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP11000S, | 
|  | 2200 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2201 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LPE11000S, | 
|  | 2202 | PCI_ANY_ID, PCI_ANY_ID, }, | 
| James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 2203 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT, | 
|  | 2204 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2205 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_MID, | 
|  | 2206 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2207 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_SMB, | 
|  | 2208 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2209 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_DCSP, | 
|  | 2210 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2211 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_SCSP, | 
|  | 2212 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | 2213 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_S, | 
|  | 2214 | PCI_ANY_ID, PCI_ANY_ID, }, | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2215 | { 0 } | 
|  | 2216 | }; | 
|  | 2217 |  | 
|  | 2218 | MODULE_DEVICE_TABLE(pci, lpfc_id_table); | 
|  | 2219 |  | 
| Linas Vepstas | 8d63f37 | 2007-02-14 14:28:36 -0600 | [diff] [blame] | 2220 | static struct pci_error_handlers lpfc_err_handler = { | 
|  | 2221 | .error_detected = lpfc_io_error_detected, | 
|  | 2222 | .slot_reset = lpfc_io_slot_reset, | 
|  | 2223 | .resume = lpfc_io_resume, | 
|  | 2224 | }; | 
|  | 2225 |  | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2226 | static struct pci_driver lpfc_driver = { | 
|  | 2227 | .name		= LPFC_DRIVER_NAME, | 
|  | 2228 | .id_table	= lpfc_id_table, | 
|  | 2229 | .probe		= lpfc_pci_probe_one, | 
|  | 2230 | .remove		= __devexit_p(lpfc_pci_remove_one), | 
| James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2231 | .err_handler    = &lpfc_err_handler, | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2232 | }; | 
|  | 2233 |  | 
|  | 2234 | static int __init | 
|  | 2235 | lpfc_init(void) | 
|  | 2236 | { | 
|  | 2237 | int error = 0; | 
|  | 2238 |  | 
|  | 2239 | printk(LPFC_MODULE_DESC "\n"); | 
| James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 2240 | printk(LPFC_COPYRIGHT "\n"); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2241 |  | 
|  | 2242 | lpfc_transport_template = | 
|  | 2243 | fc_attach_transport(&lpfc_transport_functions); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2244 | lpfc_vport_transport_template = | 
|  | 2245 | fc_attach_transport(&lpfc_vport_transport_functions); | 
|  | 2246 | if (!lpfc_transport_template || !lpfc_vport_transport_template) | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2247 | return -ENOMEM; | 
|  | 2248 | error = pci_register_driver(&lpfc_driver); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2249 | if (error) { | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2250 | fc_release_transport(lpfc_transport_template); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2251 | fc_release_transport(lpfc_vport_transport_template); | 
|  | 2252 | } | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2253 |  | 
|  | 2254 | return error; | 
|  | 2255 | } | 
|  | 2256 |  | 
|  | 2257 | static void __exit | 
|  | 2258 | lpfc_exit(void) | 
|  | 2259 | { | 
|  | 2260 | pci_unregister_driver(&lpfc_driver); | 
|  | 2261 | fc_release_transport(lpfc_transport_template); | 
| James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2262 | fc_release_transport(lpfc_vport_transport_template); | 
|  | dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2263 | } | 
|  | 2264 |  | 
|  | 2265 | module_init(lpfc_init); | 
|  | 2266 | module_exit(lpfc_exit); | 
|  | 2267 | MODULE_LICENSE("GPL"); | 
|  | 2268 | MODULE_DESCRIPTION(LPFC_MODULE_DESC); | 
|  | 2269 | MODULE_AUTHOR("Emulex Corporation - tech.support@emulex.com"); | 
|  | 2270 | MODULE_VERSION("0:" LPFC_DRIVER_VERSION); |