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