blob: 62677da28c9d77f33b801afa06f775346013b120 [file] [log] [blame]
dea31012005-04-17 16:05:31 -05001/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -04003 * Fibre Channel Host Bus Adapters. *
Jamie Wellnitz41415862006-02-28 19:25:27 -05004 * Copyright (C) 2004-2006 Emulex. All rights reserved. *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -04005 * EMULEX and SLI are trademarks of Emulex. *
dea31012005-04-17 16:05:31 -05006 * www.emulex.com *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -04007 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
dea31012005-04-17 16:05:31 -05008 * *
9 * This program is free software; you can redistribute it and/or *
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -040010 * 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. *
dea31012005-04-17 16:05:31 -050020 *******************************************************************/
21
dea31012005-04-17 16:05:31 -050022#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>
30
James.Smart@Emulex.Com91886522005-08-10 15:03:09 -040031#include <scsi/scsi.h>
dea31012005-04-17 16:05:31 -050032#include <scsi/scsi_device.h>
33#include <scsi/scsi_host.h>
34#include <scsi/scsi_transport_fc.h>
35
36#include "lpfc_hw.h"
37#include "lpfc_sli.h"
38#include "lpfc_disc.h"
39#include "lpfc_scsi.h"
40#include "lpfc.h"
41#include "lpfc_logmsg.h"
42#include "lpfc_crtn.h"
43#include "lpfc_version.h"
44
Jamie Wellnitz74b72a52006-02-28 22:33:04 -050045static int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *, int);
dea31012005-04-17 16:05:31 -050046static void lpfc_get_hba_model_desc(struct lpfc_hba *, uint8_t *, uint8_t *);
47static int lpfc_post_rcv_buf(struct lpfc_hba *);
48
49static struct scsi_transport_template *lpfc_transport_template = NULL;
50static DEFINE_IDR(lpfc_hba_index);
51
52/************************************************************************/
53/* */
54/* lpfc_config_port_prep */
55/* This routine will do LPFC initialization prior to the */
56/* CONFIG_PORT mailbox command. This will be initialized */
57/* as a SLI layer callback routine. */
58/* This routine returns 0 on success or -ERESTART if it wants */
59/* the SLI layer to reset the HBA and try again. Any */
60/* other return value indicates an error. */
61/* */
62/************************************************************************/
63int
64lpfc_config_port_prep(struct lpfc_hba * phba)
65{
66 lpfc_vpd_t *vp = &phba->vpd;
67 int i = 0, rc;
68 LPFC_MBOXQ_t *pmb;
69 MAILBOX_t *mb;
70 char *lpfc_vpd_data = NULL;
71 uint16_t offset = 0;
72 static char licensed[56] =
73 "key unlock for use with gnu public licensed code only\0";
James Smart65a29c12006-07-06 15:50:50 -040074 static int init_key = 1;
dea31012005-04-17 16:05:31 -050075
76 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
77 if (!pmb) {
78 phba->hba_state = LPFC_HBA_ERROR;
79 return -ENOMEM;
80 }
81
82 mb = &pmb->mb;
83 phba->hba_state = LPFC_INIT_MBX_CMDS;
84
85 if (lpfc_is_LC_HBA(phba->pcidev->device)) {
James Smart65a29c12006-07-06 15:50:50 -040086 if (init_key) {
87 uint32_t *ptext = (uint32_t *) licensed;
dea31012005-04-17 16:05:31 -050088
James Smart65a29c12006-07-06 15:50:50 -040089 for (i = 0; i < 56; i += sizeof (uint32_t), ptext++)
90 *ptext = cpu_to_be32(*ptext);
91 init_key = 0;
92 }
dea31012005-04-17 16:05:31 -050093
94 lpfc_read_nv(phba, pmb);
95 memset((char*)mb->un.varRDnvp.rsvd3, 0,
96 sizeof (mb->un.varRDnvp.rsvd3));
97 memcpy((char*)mb->un.varRDnvp.rsvd3, licensed,
98 sizeof (licensed));
99
100 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
101
102 if (rc != MBX_SUCCESS) {
103 lpfc_printf_log(phba,
104 KERN_ERR,
105 LOG_MBOX,
106 "%d:0324 Config Port initialization "
107 "error, mbxCmd x%x READ_NVPARM, "
108 "mbxStatus x%x\n",
109 phba->brd_no,
110 mb->mbxCommand, mb->mbxStatus);
111 mempool_free(pmb, phba->mbox_mem_pool);
112 return -ERESTART;
113 }
114 memcpy(phba->wwnn, (char *)mb->un.varRDnvp.nodename,
115 sizeof (mb->un.varRDnvp.nodename));
116 }
117
118 /* Setup and issue mailbox READ REV command */
119 lpfc_read_rev(phba, pmb);
120 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
121 if (rc != MBX_SUCCESS) {
122 lpfc_printf_log(phba,
123 KERN_ERR,
124 LOG_INIT,
125 "%d:0439 Adapter failed to init, mbxCmd x%x "
126 "READ_REV, mbxStatus x%x\n",
127 phba->brd_no,
128 mb->mbxCommand, mb->mbxStatus);
129 mempool_free( pmb, phba->mbox_mem_pool);
130 return -ERESTART;
131 }
132
James.Smart@Emulex.Com1de933f2005-11-28 11:41:15 -0500133 /*
134 * The value of rr must be 1 since the driver set the cv field to 1.
135 * This setting requires the FW to set all revision fields.
dea31012005-04-17 16:05:31 -0500136 */
James.Smart@Emulex.Com1de933f2005-11-28 11:41:15 -0500137 if (mb->un.varRdRev.rr == 0) {
dea31012005-04-17 16:05:31 -0500138 vp->rev.rBit = 0;
James.Smart@Emulex.Com1de933f2005-11-28 11:41:15 -0500139 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
140 "%d:0440 Adapter failed to init, READ_REV has "
141 "missing revision information.\n",
142 phba->brd_no);
dea31012005-04-17 16:05:31 -0500143 mempool_free(pmb, phba->mbox_mem_pool);
144 return -ERESTART;
dea31012005-04-17 16:05:31 -0500145 }
146
147 /* Save information as VPD data */
James.Smart@Emulex.Com1de933f2005-11-28 11:41:15 -0500148 vp->rev.rBit = 1;
149 vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev;
150 memcpy(vp->rev.sli1FwName, (char*) mb->un.varRdRev.sli1FwName, 16);
151 vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev;
152 memcpy(vp->rev.sli2FwName, (char *) mb->un.varRdRev.sli2FwName, 16);
dea31012005-04-17 16:05:31 -0500153 vp->rev.biuRev = mb->un.varRdRev.biuRev;
154 vp->rev.smRev = mb->un.varRdRev.smRev;
155 vp->rev.smFwRev = mb->un.varRdRev.un.smFwRev;
156 vp->rev.endecRev = mb->un.varRdRev.endecRev;
157 vp->rev.fcphHigh = mb->un.varRdRev.fcphHigh;
158 vp->rev.fcphLow = mb->un.varRdRev.fcphLow;
159 vp->rev.feaLevelHigh = mb->un.varRdRev.feaLevelHigh;
160 vp->rev.feaLevelLow = mb->un.varRdRev.feaLevelLow;
161 vp->rev.postKernRev = mb->un.varRdRev.postKernRev;
162 vp->rev.opFwRev = mb->un.varRdRev.opFwRev;
163
164 if (lpfc_is_LC_HBA(phba->pcidev->device))
165 memcpy(phba->RandomData, (char *)&mb->un.varWords[24],
166 sizeof (phba->RandomData));
167
dea31012005-04-17 16:05:31 -0500168 /* Get adapter VPD information */
169 pmb->context2 = kmalloc(DMP_RSP_SIZE, GFP_KERNEL);
170 if (!pmb->context2)
171 goto out_free_mbox;
172 lpfc_vpd_data = kmalloc(DMP_VPD_SIZE, GFP_KERNEL);
173 if (!lpfc_vpd_data)
174 goto out_free_context2;
175
176 do {
177 lpfc_dump_mem(phba, pmb, offset);
178 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
179
180 if (rc != MBX_SUCCESS) {
181 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
182 "%d:0441 VPD not present on adapter, "
183 "mbxCmd x%x DUMP VPD, mbxStatus x%x\n",
184 phba->brd_no,
185 mb->mbxCommand, mb->mbxStatus);
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500186 mb->un.varDmp.word_cnt = 0;
dea31012005-04-17 16:05:31 -0500187 }
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500188 if (mb->un.varDmp.word_cnt > DMP_VPD_SIZE - offset)
189 mb->un.varDmp.word_cnt = DMP_VPD_SIZE - offset;
dea31012005-04-17 16:05:31 -0500190 lpfc_sli_pcimem_bcopy(pmb->context2, lpfc_vpd_data + offset,
191 mb->un.varDmp.word_cnt);
192 offset += mb->un.varDmp.word_cnt;
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500193 } while (mb->un.varDmp.word_cnt && offset < DMP_VPD_SIZE);
194 lpfc_parse_vpd(phba, lpfc_vpd_data, offset);
dea31012005-04-17 16:05:31 -0500195
196 kfree(lpfc_vpd_data);
197out_free_context2:
198 kfree(pmb->context2);
199out_free_mbox:
200 mempool_free(pmb, phba->mbox_mem_pool);
201 return 0;
202}
203
204/************************************************************************/
205/* */
206/* lpfc_config_port_post */
207/* This routine will do LPFC initialization after the */
208/* CONFIG_PORT mailbox command. This will be initialized */
209/* as a SLI layer callback routine. */
210/* This routine returns 0 on success. Any other return value */
211/* indicates an error. */
212/* */
213/************************************************************************/
214int
215lpfc_config_port_post(struct lpfc_hba * phba)
216{
217 LPFC_MBOXQ_t *pmb;
218 MAILBOX_t *mb;
219 struct lpfc_dmabuf *mp;
220 struct lpfc_sli *psli = &phba->sli;
221 uint32_t status, timeout;
222 int i, j, rc;
223
224 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
225 if (!pmb) {
226 phba->hba_state = LPFC_HBA_ERROR;
227 return -ENOMEM;
228 }
229 mb = &pmb->mb;
230
231 lpfc_config_link(phba, pmb);
232 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
233 if (rc != MBX_SUCCESS) {
234 lpfc_printf_log(phba,
235 KERN_ERR,
236 LOG_INIT,
237 "%d:0447 Adapter failed init, mbxCmd x%x "
238 "CONFIG_LINK mbxStatus x%x\n",
239 phba->brd_no,
240 mb->mbxCommand, mb->mbxStatus);
241 phba->hba_state = LPFC_HBA_ERROR;
242 mempool_free( pmb, phba->mbox_mem_pool);
243 return -EIO;
244 }
245
246 /* Get login parameters for NID. */
247 lpfc_read_sparam(phba, pmb);
248 if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
249 lpfc_printf_log(phba,
250 KERN_ERR,
251 LOG_INIT,
252 "%d:0448 Adapter failed init, mbxCmd x%x "
253 "READ_SPARM mbxStatus x%x\n",
254 phba->brd_no,
255 mb->mbxCommand, mb->mbxStatus);
256 phba->hba_state = LPFC_HBA_ERROR;
257 mp = (struct lpfc_dmabuf *) pmb->context1;
258 mempool_free( pmb, phba->mbox_mem_pool);
259 lpfc_mbuf_free(phba, mp->virt, mp->phys);
260 kfree(mp);
261 return -EIO;
262 }
263
264 mp = (struct lpfc_dmabuf *) pmb->context1;
265
266 memcpy(&phba->fc_sparam, mp->virt, sizeof (struct serv_parm));
267 lpfc_mbuf_free(phba, mp->virt, mp->phys);
268 kfree(mp);
269 pmb->context1 = NULL;
270
James Smarta12e07b2006-12-02 13:35:30 -0500271 if (phba->cfg_soft_wwnn)
272 u64_to_wwn(phba->cfg_soft_wwnn, phba->fc_sparam.nodeName.u.wwn);
James Smartc3f28af2006-08-18 17:47:18 -0400273 if (phba->cfg_soft_wwpn)
274 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn);
dea31012005-04-17 16:05:31 -0500275 memcpy(&phba->fc_nodename, &phba->fc_sparam.nodeName,
276 sizeof (struct lpfc_name));
277 memcpy(&phba->fc_portname, &phba->fc_sparam.portName,
278 sizeof (struct lpfc_name));
279 /* If no serial number in VPD data, use low 6 bytes of WWNN */
280 /* This should be consolidated into parse_vpd ? - mr */
281 if (phba->SerialNumber[0] == 0) {
282 uint8_t *outptr;
283
Andrew Morton68ce1eb2005-09-21 09:46:54 -0700284 outptr = &phba->fc_nodename.u.s.IEEE[0];
dea31012005-04-17 16:05:31 -0500285 for (i = 0; i < 12; i++) {
286 status = *outptr++;
287 j = ((status & 0xf0) >> 4);
288 if (j <= 9)
289 phba->SerialNumber[i] =
290 (char)((uint8_t) 0x30 + (uint8_t) j);
291 else
292 phba->SerialNumber[i] =
293 (char)((uint8_t) 0x61 + (uint8_t) (j - 10));
294 i++;
295 j = (status & 0xf);
296 if (j <= 9)
297 phba->SerialNumber[i] =
298 (char)((uint8_t) 0x30 + (uint8_t) j);
299 else
300 phba->SerialNumber[i] =
301 (char)((uint8_t) 0x61 + (uint8_t) (j - 10));
302 }
303 }
304
dea31012005-04-17 16:05:31 -0500305 lpfc_read_config(phba, pmb);
306 if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
307 lpfc_printf_log(phba,
308 KERN_ERR,
309 LOG_INIT,
310 "%d:0453 Adapter failed to init, mbxCmd x%x "
311 "READ_CONFIG, mbxStatus x%x\n",
312 phba->brd_no,
313 mb->mbxCommand, mb->mbxStatus);
314 phba->hba_state = LPFC_HBA_ERROR;
315 mempool_free( pmb, phba->mbox_mem_pool);
316 return -EIO;
317 }
318
319 /* Reset the DFT_HBA_Q_DEPTH to the max xri */
320 if (phba->cfg_hba_queue_depth > (mb->un.varRdConfig.max_xri+1))
321 phba->cfg_hba_queue_depth =
322 mb->un.varRdConfig.max_xri + 1;
323
324 phba->lmt = mb->un.varRdConfig.lmt;
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500325
326 /* Get the default values for Model Name and Description */
327 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc);
328
329 if ((phba->cfg_link_speed > LINK_SPEED_10G)
330 || ((phba->cfg_link_speed == LINK_SPEED_1G)
331 && !(phba->lmt & LMT_1Gb))
332 || ((phba->cfg_link_speed == LINK_SPEED_2G)
333 && !(phba->lmt & LMT_2Gb))
334 || ((phba->cfg_link_speed == LINK_SPEED_4G)
335 && !(phba->lmt & LMT_4Gb))
336 || ((phba->cfg_link_speed == LINK_SPEED_8G)
337 && !(phba->lmt & LMT_8Gb))
338 || ((phba->cfg_link_speed == LINK_SPEED_10G)
339 && !(phba->lmt & LMT_10Gb))) {
340 /* Reset link speed to auto */
dea31012005-04-17 16:05:31 -0500341 lpfc_printf_log(phba,
342 KERN_WARNING,
343 LOG_LINK_EVENT,
344 "%d:1302 Invalid speed for this board: "
345 "Reset link speed to auto: x%x\n",
346 phba->brd_no,
347 phba->cfg_link_speed);
348 phba->cfg_link_speed = LINK_SPEED_AUTO;
349 }
350
351 phba->hba_state = LPFC_LINK_DOWN;
352
353 /* Only process IOCBs on ring 0 till hba_state is READY */
James Smarta4bc3372006-12-02 13:34:16 -0500354 if (psli->ring[psli->extra_ring].cmdringaddr)
355 psli->ring[psli->extra_ring].flag |= LPFC_STOP_IOCB_EVENT;
dea31012005-04-17 16:05:31 -0500356 if (psli->ring[psli->fcp_ring].cmdringaddr)
357 psli->ring[psli->fcp_ring].flag |= LPFC_STOP_IOCB_EVENT;
358 if (psli->ring[psli->next_ring].cmdringaddr)
359 psli->ring[psli->next_ring].flag |= LPFC_STOP_IOCB_EVENT;
360
361 /* Post receive buffers for desired rings */
362 lpfc_post_rcv_buf(phba);
363
364 /* Enable appropriate host interrupts */
365 spin_lock_irq(phba->host->host_lock);
366 status = readl(phba->HCregaddr);
367 status |= HC_MBINT_ENA | HC_ERINT_ENA | HC_LAINT_ENA;
368 if (psli->num_rings > 0)
369 status |= HC_R0INT_ENA;
370 if (psli->num_rings > 1)
371 status |= HC_R1INT_ENA;
372 if (psli->num_rings > 2)
373 status |= HC_R2INT_ENA;
374 if (psli->num_rings > 3)
375 status |= HC_R3INT_ENA;
376
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -0500377 if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) &&
378 (phba->cfg_poll & DISABLE_FCP_RING_INT))
379 status &= ~(HC_R0INT_ENA << LPFC_FCP_RING);
380
dea31012005-04-17 16:05:31 -0500381 writel(status, phba->HCregaddr);
382 readl(phba->HCregaddr); /* flush */
383 spin_unlock_irq(phba->host->host_lock);
384
385 /*
386 * Setup the ring 0 (els) timeout handler
387 */
388 timeout = phba->fc_ratov << 1;
James Smart1dcb58e2007-04-25 09:51:30 -0400389 mod_timer(&phba->els_tmofunc, jiffies + HZ * timeout);
dea31012005-04-17 16:05:31 -0500390
391 lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed);
392 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
James Smart8aee9182006-08-31 12:27:57 -0400393 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
394 if (rc != MBX_SUCCESS) {
dea31012005-04-17 16:05:31 -0500395 lpfc_printf_log(phba,
396 KERN_ERR,
397 LOG_INIT,
398 "%d:0454 Adapter failed to init, mbxCmd x%x "
399 "INIT_LINK, mbxStatus x%x\n",
400 phba->brd_no,
401 mb->mbxCommand, mb->mbxStatus);
402
403 /* Clear all interrupt enable conditions */
404 writel(0, phba->HCregaddr);
405 readl(phba->HCregaddr); /* flush */
406 /* Clear all pending interrupts */
407 writel(0xffffffff, phba->HAregaddr);
408 readl(phba->HAregaddr); /* flush */
409
410 phba->hba_state = LPFC_HBA_ERROR;
James Smart8aee9182006-08-31 12:27:57 -0400411 if (rc != MBX_BUSY)
412 mempool_free(pmb, phba->mbox_mem_pool);
dea31012005-04-17 16:05:31 -0500413 return -EIO;
414 }
415 /* MBOX buffer will be freed in mbox compl */
416
James Smartce8b3ce2006-07-06 15:50:36 -0400417 return (0);
418}
419
420static int
421lpfc_discovery_wait(struct lpfc_hba *phba)
422{
423 int i = 0;
424
dea31012005-04-17 16:05:31 -0500425 while ((phba->hba_state != LPFC_HBA_READY) ||
426 (phba->num_disc_nodes) || (phba->fc_prli_sent) ||
427 ((phba->fc_map_cnt == 0) && (i<2)) ||
James Smartce8b3ce2006-07-06 15:50:36 -0400428 (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE)) {
dea31012005-04-17 16:05:31 -0500429 /* Check every second for 30 retries. */
430 i++;
431 if (i > 30) {
James Smartce8b3ce2006-07-06 15:50:36 -0400432 return -ETIMEDOUT;
dea31012005-04-17 16:05:31 -0500433 }
434 if ((i >= 15) && (phba->hba_state <= LPFC_LINK_DOWN)) {
435 /* The link is down. Set linkdown timeout */
James Smartce8b3ce2006-07-06 15:50:36 -0400436 return -ETIMEDOUT;
dea31012005-04-17 16:05:31 -0500437 }
438
439 /* Delay for 1 second to give discovery time to complete. */
440 msleep(1000);
441
442 }
443
James Smartce8b3ce2006-07-06 15:50:36 -0400444 return 0;
dea31012005-04-17 16:05:31 -0500445}
446
447/************************************************************************/
448/* */
449/* lpfc_hba_down_prep */
450/* This routine will do LPFC uninitialization before the */
451/* HBA is reset when bringing down the SLI Layer. This will be */
452/* initialized as a SLI layer callback routine. */
453/* This routine returns 0 on success. Any other return value */
454/* indicates an error. */
455/* */
456/************************************************************************/
457int
458lpfc_hba_down_prep(struct lpfc_hba * phba)
459{
460 /* Disable interrupts */
461 writel(0, phba->HCregaddr);
462 readl(phba->HCregaddr); /* flush */
463
464 /* Cleanup potential discovery resources */
465 lpfc_els_flush_rscn(phba);
466 lpfc_els_flush_cmd(phba);
467 lpfc_disc_flush_list(phba);
468
469 return (0);
470}
471
472/************************************************************************/
473/* */
Jamie Wellnitz41415862006-02-28 19:25:27 -0500474/* lpfc_hba_down_post */
475/* This routine will do uninitialization after the HBA is reset */
476/* when bringing down the SLI Layer. */
477/* This routine returns 0 on success. Any other return value */
478/* indicates an error. */
479/* */
480/************************************************************************/
481int
482lpfc_hba_down_post(struct lpfc_hba * phba)
483{
484 struct lpfc_sli *psli = &phba->sli;
485 struct lpfc_sli_ring *pring;
486 struct lpfc_dmabuf *mp, *next_mp;
487 int i;
488
489 /* Cleanup preposted buffers on the ELS ring */
490 pring = &psli->ring[LPFC_ELS_RING];
491 list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) {
492 list_del(&mp->list);
493 pring->postbufq_cnt--;
494 lpfc_mbuf_free(phba, mp->virt, mp->phys);
495 kfree(mp);
496 }
497
498 for (i = 0; i < psli->num_rings; i++) {
499 pring = &psli->ring[i];
500 lpfc_sli_abort_iocb_ring(phba, pring);
501 }
502
503 return 0;
504}
505
506/************************************************************************/
507/* */
dea31012005-04-17 16:05:31 -0500508/* lpfc_handle_eratt */
509/* This routine will handle processing a Host Attention */
510/* Error Status event. This will be initialized */
511/* as a SLI layer callback routine. */
512/* */
513/************************************************************************/
514void
515lpfc_handle_eratt(struct lpfc_hba * phba)
516{
517 struct lpfc_sli *psli = &phba->sli;
518 struct lpfc_sli_ring *pring;
James Smartd2873e42006-08-18 17:46:43 -0400519 uint32_t event_data;
Linas Vepstas8d63f372007-02-14 14:28:36 -0600520 /* If the pci channel is offline, ignore possible errors,
521 * since we cannot communicate with the pci card anyway. */
522 if (pci_channel_offline(phba->pcidev))
523 return;
dea31012005-04-17 16:05:31 -0500524
James Smartf5603512006-12-02 13:35:43 -0500525 if (phba->work_hs & HS_FFER6 ||
526 phba->work_hs & HS_FFER5) {
dea31012005-04-17 16:05:31 -0500527 /* Re-establishing Link */
528 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
529 "%d:1301 Re-establishing Link "
530 "Data: x%x x%x x%x\n",
531 phba->brd_no, phba->work_hs,
532 phba->work_status[0], phba->work_status[1]);
533 spin_lock_irq(phba->host->host_lock);
534 phba->fc_flag |= FC_ESTABLISH_LINK;
James Smart92908312006-03-07 15:04:13 -0500535 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
dea31012005-04-17 16:05:31 -0500536 spin_unlock_irq(phba->host->host_lock);
537
538 /*
539 * Firmware stops when it triggled erratt with HS_FFER6.
540 * That could cause the I/Os dropped by the firmware.
541 * Error iocb (I/O) on txcmplq and let the SCSI layer
542 * retry it after re-establishing link.
543 */
544 pring = &psli->ring[psli->fcp_ring];
545 lpfc_sli_abort_iocb_ring(phba, pring);
546
547
548 /*
549 * There was a firmware error. Take the hba offline and then
550 * attempt to restart it.
551 */
552 lpfc_offline(phba);
Jamie Wellnitz41415862006-02-28 19:25:27 -0500553 lpfc_sli_brdrestart(phba);
dea31012005-04-17 16:05:31 -0500554 if (lpfc_online(phba) == 0) { /* Initialize the HBA */
555 mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60);
556 return;
557 }
558 } else {
559 /* The if clause above forces this code path when the status
560 * failure is a value other than FFER6. Do not call the offline
561 * twice. This is the adapter hardware error path.
562 */
563 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
564 "%d:0457 Adapter Hardware Error "
565 "Data: x%x x%x x%x\n",
566 phba->brd_no, phba->work_hs,
567 phba->work_status[0], phba->work_status[1]);
568
James Smartd2873e42006-08-18 17:46:43 -0400569 event_data = FC_REG_DUMP_EVENT;
570 fc_host_post_vendor_event(phba->host, fc_get_event_number(),
571 sizeof(event_data), (char *) &event_data,
572 SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX);
573
James Smart92908312006-03-07 15:04:13 -0500574 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
dea31012005-04-17 16:05:31 -0500575 lpfc_offline(phba);
Jamie Wellnitz41415862006-02-28 19:25:27 -0500576 phba->hba_state = LPFC_HBA_ERROR;
577 lpfc_hba_down_post(phba);
dea31012005-04-17 16:05:31 -0500578 }
579}
580
581/************************************************************************/
582/* */
583/* lpfc_handle_latt */
584/* This routine will handle processing a Host Attention */
585/* Link Status event. This will be initialized */
586/* as a SLI layer callback routine. */
587/* */
588/************************************************************************/
589void
590lpfc_handle_latt(struct lpfc_hba * phba)
591{
592 struct lpfc_sli *psli = &phba->sli;
593 LPFC_MBOXQ_t *pmb;
594 volatile uint32_t control;
595 struct lpfc_dmabuf *mp;
596 int rc = -ENOMEM;
597
598 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
599 if (!pmb)
600 goto lpfc_handle_latt_err_exit;
601
602 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
603 if (!mp)
604 goto lpfc_handle_latt_free_pmb;
605
606 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
607 if (!mp->virt)
608 goto lpfc_handle_latt_free_mp;
609
610 rc = -EIO;
611
James.Smart@Emulex.Com6281bfe2005-11-28 11:41:33 -0500612 /* Cleanup any outstanding ELS commands */
613 lpfc_els_flush_cmd(phba);
dea31012005-04-17 16:05:31 -0500614
615 psli->slistat.link_event++;
616 lpfc_read_la(phba, pmb, mp);
617 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la;
618 rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB));
619 if (rc == MBX_NOT_FINISHED)
James Smart14691152006-12-02 13:34:28 -0500620 goto lpfc_handle_latt_free_mbuf;
dea31012005-04-17 16:05:31 -0500621
622 /* Clear Link Attention in HA REG */
623 spin_lock_irq(phba->host->host_lock);
624 writel(HA_LATT, phba->HAregaddr);
625 readl(phba->HAregaddr); /* flush */
626 spin_unlock_irq(phba->host->host_lock);
627
628 return;
629
James Smart14691152006-12-02 13:34:28 -0500630lpfc_handle_latt_free_mbuf:
631 lpfc_mbuf_free(phba, mp->virt, mp->phys);
dea31012005-04-17 16:05:31 -0500632lpfc_handle_latt_free_mp:
633 kfree(mp);
634lpfc_handle_latt_free_pmb:
James Smart1dcb58e2007-04-25 09:51:30 -0400635 mempool_free(pmb, phba->mbox_mem_pool);
dea31012005-04-17 16:05:31 -0500636lpfc_handle_latt_err_exit:
637 /* Enable Link attention interrupts */
638 spin_lock_irq(phba->host->host_lock);
639 psli->sli_flag |= LPFC_PROCESS_LA;
640 control = readl(phba->HCregaddr);
641 control |= HC_LAINT_ENA;
642 writel(control, phba->HCregaddr);
643 readl(phba->HCregaddr); /* flush */
644
645 /* Clear Link Attention in HA REG */
646 writel(HA_LATT, phba->HAregaddr);
647 readl(phba->HAregaddr); /* flush */
648 spin_unlock_irq(phba->host->host_lock);
649 lpfc_linkdown(phba);
650 phba->hba_state = LPFC_HBA_ERROR;
651
652 /* The other case is an error from issue_mbox */
653 if (rc == -ENOMEM)
654 lpfc_printf_log(phba,
655 KERN_WARNING,
656 LOG_MBOX,
657 "%d:0300 READ_LA: no buffers\n",
658 phba->brd_no);
659
660 return;
661}
662
663/************************************************************************/
664/* */
665/* lpfc_parse_vpd */
666/* This routine will parse the VPD data */
667/* */
668/************************************************************************/
669static int
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500670lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len)
dea31012005-04-17 16:05:31 -0500671{
672 uint8_t lenlo, lenhi;
Anton Blanchard07da60c2007-03-21 08:41:47 -0500673 int Length;
dea31012005-04-17 16:05:31 -0500674 int i, j;
675 int finished = 0;
676 int index = 0;
677
678 if (!vpd)
679 return 0;
680
681 /* Vital Product */
682 lpfc_printf_log(phba,
683 KERN_INFO,
684 LOG_INIT,
685 "%d:0455 Vital Product Data: x%x x%x x%x x%x\n",
686 phba->brd_no,
687 (uint32_t) vpd[0], (uint32_t) vpd[1], (uint32_t) vpd[2],
688 (uint32_t) vpd[3]);
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500689 while (!finished && (index < (len - 4))) {
dea31012005-04-17 16:05:31 -0500690 switch (vpd[index]) {
691 case 0x82:
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500692 case 0x91:
dea31012005-04-17 16:05:31 -0500693 index += 1;
694 lenlo = vpd[index];
695 index += 1;
696 lenhi = vpd[index];
697 index += 1;
698 i = ((((unsigned short)lenhi) << 8) + lenlo);
699 index += i;
700 break;
701 case 0x90:
702 index += 1;
703 lenlo = vpd[index];
704 index += 1;
705 lenhi = vpd[index];
706 index += 1;
707 Length = ((((unsigned short)lenhi) << 8) + lenlo);
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500708 if (Length > len - index)
709 Length = len - index;
dea31012005-04-17 16:05:31 -0500710 while (Length > 0) {
711 /* Look for Serial Number */
712 if ((vpd[index] == 'S') && (vpd[index+1] == 'N')) {
713 index += 2;
714 i = vpd[index];
715 index += 1;
716 j = 0;
717 Length -= (3+i);
718 while(i--) {
719 phba->SerialNumber[j++] = vpd[index++];
720 if (j == 31)
721 break;
722 }
723 phba->SerialNumber[j] = 0;
724 continue;
725 }
726 else if ((vpd[index] == 'V') && (vpd[index+1] == '1')) {
727 phba->vpd_flag |= VPD_MODEL_DESC;
728 index += 2;
729 i = vpd[index];
730 index += 1;
731 j = 0;
732 Length -= (3+i);
733 while(i--) {
734 phba->ModelDesc[j++] = vpd[index++];
735 if (j == 255)
736 break;
737 }
738 phba->ModelDesc[j] = 0;
739 continue;
740 }
741 else if ((vpd[index] == 'V') && (vpd[index+1] == '2')) {
742 phba->vpd_flag |= VPD_MODEL_NAME;
743 index += 2;
744 i = vpd[index];
745 index += 1;
746 j = 0;
747 Length -= (3+i);
748 while(i--) {
749 phba->ModelName[j++] = vpd[index++];
750 if (j == 79)
751 break;
752 }
753 phba->ModelName[j] = 0;
754 continue;
755 }
756 else if ((vpd[index] == 'V') && (vpd[index+1] == '3')) {
757 phba->vpd_flag |= VPD_PROGRAM_TYPE;
758 index += 2;
759 i = vpd[index];
760 index += 1;
761 j = 0;
762 Length -= (3+i);
763 while(i--) {
764 phba->ProgramType[j++] = vpd[index++];
765 if (j == 255)
766 break;
767 }
768 phba->ProgramType[j] = 0;
769 continue;
770 }
771 else if ((vpd[index] == 'V') && (vpd[index+1] == '4')) {
772 phba->vpd_flag |= VPD_PORT;
773 index += 2;
774 i = vpd[index];
775 index += 1;
776 j = 0;
777 Length -= (3+i);
778 while(i--) {
779 phba->Port[j++] = vpd[index++];
780 if (j == 19)
781 break;
782 }
783 phba->Port[j] = 0;
784 continue;
785 }
786 else {
787 index += 2;
788 i = vpd[index];
789 index += 1;
790 index += i;
791 Length -= (3 + i);
792 }
793 }
794 finished = 0;
795 break;
796 case 0x78:
797 finished = 1;
798 break;
799 default:
800 index ++;
801 break;
802 }
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500803 }
dea31012005-04-17 16:05:31 -0500804
805 return(1);
806}
807
808static void
809lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
810{
811 lpfc_vpd_t *vp;
James.Smart@Emulex.Comfefcb2b2005-11-28 15:08:56 -0500812 uint16_t dev_id = phba->pcidev->device;
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500813 int max_speed;
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500814 struct {
815 char * name;
816 int max_speed;
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500817 char * bus;
James Smart18a3b592006-12-02 13:35:08 -0500818 } m = {"<Unknown>", 0, ""};
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500819
820 if (mdp && mdp[0] != '\0'
821 && descp && descp[0] != '\0')
822 return;
823
824 if (phba->lmt & LMT_10Gb)
825 max_speed = 10;
826 else if (phba->lmt & LMT_8Gb)
827 max_speed = 8;
828 else if (phba->lmt & LMT_4Gb)
829 max_speed = 4;
830 else if (phba->lmt & LMT_2Gb)
831 max_speed = 2;
832 else
833 max_speed = 1;
dea31012005-04-17 16:05:31 -0500834
835 vp = &phba->vpd;
dea31012005-04-17 16:05:31 -0500836
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500837 switch (dev_id) {
James.Smart@Emulex.Com06325e72005-06-25 10:34:22 -0400838 case PCI_DEVICE_ID_FIREFLY:
James Smart18a3b592006-12-02 13:35:08 -0500839 m = (typeof(m)){"LP6000", max_speed, "PCI"};
James.Smart@Emulex.Com06325e72005-06-25 10:34:22 -0400840 break;
dea31012005-04-17 16:05:31 -0500841 case PCI_DEVICE_ID_SUPERFLY:
842 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3)
James Smart18a3b592006-12-02 13:35:08 -0500843 m = (typeof(m)){"LP7000", max_speed, "PCI"};
dea31012005-04-17 16:05:31 -0500844 else
James Smart18a3b592006-12-02 13:35:08 -0500845 m = (typeof(m)){"LP7000E", max_speed, "PCI"};
dea31012005-04-17 16:05:31 -0500846 break;
847 case PCI_DEVICE_ID_DRAGONFLY:
James Smart18a3b592006-12-02 13:35:08 -0500848 m = (typeof(m)){"LP8000", max_speed, "PCI"};
dea31012005-04-17 16:05:31 -0500849 break;
850 case PCI_DEVICE_ID_CENTAUR:
851 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID)
James Smart18a3b592006-12-02 13:35:08 -0500852 m = (typeof(m)){"LP9002", max_speed, "PCI"};
dea31012005-04-17 16:05:31 -0500853 else
James Smart18a3b592006-12-02 13:35:08 -0500854 m = (typeof(m)){"LP9000", max_speed, "PCI"};
dea31012005-04-17 16:05:31 -0500855 break;
856 case PCI_DEVICE_ID_RFLY:
James Smart18a3b592006-12-02 13:35:08 -0500857 m = (typeof(m)){"LP952", max_speed, "PCI"};
dea31012005-04-17 16:05:31 -0500858 break;
859 case PCI_DEVICE_ID_PEGASUS:
James Smart18a3b592006-12-02 13:35:08 -0500860 m = (typeof(m)){"LP9802", max_speed, "PCI-X"};
dea31012005-04-17 16:05:31 -0500861 break;
862 case PCI_DEVICE_ID_THOR:
James Smart18a3b592006-12-02 13:35:08 -0500863 m = (typeof(m)){"LP10000", max_speed, "PCI-X"};
dea31012005-04-17 16:05:31 -0500864 break;
865 case PCI_DEVICE_ID_VIPER:
James Smart18a3b592006-12-02 13:35:08 -0500866 m = (typeof(m)){"LPX1000", max_speed, "PCI-X"};
dea31012005-04-17 16:05:31 -0500867 break;
868 case PCI_DEVICE_ID_PFLY:
James Smart18a3b592006-12-02 13:35:08 -0500869 m = (typeof(m)){"LP982", max_speed, "PCI-X"};
dea31012005-04-17 16:05:31 -0500870 break;
871 case PCI_DEVICE_ID_TFLY:
James Smart18a3b592006-12-02 13:35:08 -0500872 m = (typeof(m)){"LP1050", max_speed, "PCI-X"};
dea31012005-04-17 16:05:31 -0500873 break;
874 case PCI_DEVICE_ID_HELIOS:
James Smart18a3b592006-12-02 13:35:08 -0500875 m = (typeof(m)){"LP11000", max_speed, "PCI-X2"};
dea31012005-04-17 16:05:31 -0500876 break;
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500877 case PCI_DEVICE_ID_HELIOS_SCSP:
James Smart18a3b592006-12-02 13:35:08 -0500878 m = (typeof(m)){"LP11000-SP", max_speed, "PCI-X2"};
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500879 break;
880 case PCI_DEVICE_ID_HELIOS_DCSP:
James Smart18a3b592006-12-02 13:35:08 -0500881 m = (typeof(m)){"LP11002-SP", max_speed, "PCI-X2"};
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500882 break;
883 case PCI_DEVICE_ID_NEPTUNE:
James Smart18a3b592006-12-02 13:35:08 -0500884 m = (typeof(m)){"LPe1000", max_speed, "PCIe"};
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500885 break;
886 case PCI_DEVICE_ID_NEPTUNE_SCSP:
James Smart18a3b592006-12-02 13:35:08 -0500887 m = (typeof(m)){"LPe1000-SP", max_speed, "PCIe"};
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500888 break;
889 case PCI_DEVICE_ID_NEPTUNE_DCSP:
James Smart18a3b592006-12-02 13:35:08 -0500890 m = (typeof(m)){"LPe1002-SP", max_speed, "PCIe"};
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500891 break;
dea31012005-04-17 16:05:31 -0500892 case PCI_DEVICE_ID_BMID:
James Smart18a3b592006-12-02 13:35:08 -0500893 m = (typeof(m)){"LP1150", max_speed, "PCI-X2"};
dea31012005-04-17 16:05:31 -0500894 break;
895 case PCI_DEVICE_ID_BSMB:
James Smart18a3b592006-12-02 13:35:08 -0500896 m = (typeof(m)){"LP111", max_speed, "PCI-X2"};
dea31012005-04-17 16:05:31 -0500897 break;
898 case PCI_DEVICE_ID_ZEPHYR:
James Smart18a3b592006-12-02 13:35:08 -0500899 m = (typeof(m)){"LPe11000", max_speed, "PCIe"};
dea31012005-04-17 16:05:31 -0500900 break;
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500901 case PCI_DEVICE_ID_ZEPHYR_SCSP:
James Smart18a3b592006-12-02 13:35:08 -0500902 m = (typeof(m)){"LPe11000", max_speed, "PCIe"};
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500903 break;
904 case PCI_DEVICE_ID_ZEPHYR_DCSP:
James Smart18a3b592006-12-02 13:35:08 -0500905 m = (typeof(m)){"LPe11002-SP", max_speed, "PCIe"};
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500906 break;
dea31012005-04-17 16:05:31 -0500907 case PCI_DEVICE_ID_ZMID:
James Smart18a3b592006-12-02 13:35:08 -0500908 m = (typeof(m)){"LPe1150", max_speed, "PCIe"};
dea31012005-04-17 16:05:31 -0500909 break;
910 case PCI_DEVICE_ID_ZSMB:
James Smart18a3b592006-12-02 13:35:08 -0500911 m = (typeof(m)){"LPe111", max_speed, "PCIe"};
dea31012005-04-17 16:05:31 -0500912 break;
913 case PCI_DEVICE_ID_LP101:
James Smart18a3b592006-12-02 13:35:08 -0500914 m = (typeof(m)){"LP101", max_speed, "PCI-X"};
dea31012005-04-17 16:05:31 -0500915 break;
916 case PCI_DEVICE_ID_LP10000S:
James Smart18a3b592006-12-02 13:35:08 -0500917 m = (typeof(m)){"LP10000-S", max_speed, "PCI"};
James.Smart@Emulex.Com06325e72005-06-25 10:34:22 -0400918 break;
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500919 case PCI_DEVICE_ID_LP11000S:
James Smart18a3b592006-12-02 13:35:08 -0500920 m = (typeof(m)){"LP11000-S", max_speed,
921 "PCI-X2"};
922 break;
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500923 case PCI_DEVICE_ID_LPE11000S:
James Smart18a3b592006-12-02 13:35:08 -0500924 m = (typeof(m)){"LPe11000-S", max_speed,
925 "PCIe"};
James.Smart@Emulex.Com5cc36b32005-11-28 11:42:19 -0500926 break;
927 default:
Randy Dunlap041976f2006-06-25 01:58:51 -0700928 m = (typeof(m)){ NULL };
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -0500929 break;
dea31012005-04-17 16:05:31 -0500930 }
Jamie Wellnitz74b72a52006-02-28 22:33:04 -0500931
932 if (mdp && mdp[0] == '\0')
933 snprintf(mdp, 79,"%s", m.name);
934 if (descp && descp[0] == '\0')
935 snprintf(descp, 255,
James Smart18a3b592006-12-02 13:35:08 -0500936 "Emulex %s %dGb %s Fibre Channel Adapter",
937 m.name, m.max_speed, m.bus);
dea31012005-04-17 16:05:31 -0500938}
939
940/**************************************************/
941/* lpfc_post_buffer */
942/* */
943/* This routine will post count buffers to the */
944/* ring with the QUE_RING_BUF_CN command. This */
945/* allows 3 buffers / command to be posted. */
946/* Returns the number of buffers NOT posted. */
947/**************************************************/
948int
949lpfc_post_buffer(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, int cnt,
950 int type)
951{
952 IOCB_t *icmd;
James.Smart@Emulex.Com0bd4ca22005-10-28 20:30:02 -0400953 struct lpfc_iocbq *iocb;
dea31012005-04-17 16:05:31 -0500954 struct lpfc_dmabuf *mp1, *mp2;
955
956 cnt += pring->missbufcnt;
957
958 /* While there are buffers to post */
959 while (cnt > 0) {
960 /* Allocate buffer for command iocb */
961 spin_lock_irq(phba->host->host_lock);
James.Smart@Emulex.Com0bd4ca22005-10-28 20:30:02 -0400962 iocb = lpfc_sli_get_iocbq(phba);
dea31012005-04-17 16:05:31 -0500963 spin_unlock_irq(phba->host->host_lock);
964 if (iocb == NULL) {
965 pring->missbufcnt = cnt;
966 return cnt;
967 }
dea31012005-04-17 16:05:31 -0500968 icmd = &iocb->iocb;
969
970 /* 2 buffers can be posted per command */
971 /* Allocate buffer to post */
972 mp1 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
973 if (mp1)
974 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
975 &mp1->phys);
976 if (mp1 == 0 || mp1->virt == 0) {
Jesper Juhlc9475cb2005-11-07 01:01:26 -0800977 kfree(mp1);
dea31012005-04-17 16:05:31 -0500978 spin_lock_irq(phba->host->host_lock);
James Bottomley604a3e32005-10-29 10:28:33 -0500979 lpfc_sli_release_iocbq(phba, iocb);
dea31012005-04-17 16:05:31 -0500980 spin_unlock_irq(phba->host->host_lock);
981 pring->missbufcnt = cnt;
982 return cnt;
983 }
984
985 INIT_LIST_HEAD(&mp1->list);
986 /* Allocate buffer to post */
987 if (cnt > 1) {
988 mp2 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
989 if (mp2)
990 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
991 &mp2->phys);
992 if (mp2 == 0 || mp2->virt == 0) {
Jesper Juhlc9475cb2005-11-07 01:01:26 -0800993 kfree(mp2);
dea31012005-04-17 16:05:31 -0500994 lpfc_mbuf_free(phba, mp1->virt, mp1->phys);
995 kfree(mp1);
996 spin_lock_irq(phba->host->host_lock);
James Bottomley604a3e32005-10-29 10:28:33 -0500997 lpfc_sli_release_iocbq(phba, iocb);
dea31012005-04-17 16:05:31 -0500998 spin_unlock_irq(phba->host->host_lock);
999 pring->missbufcnt = cnt;
1000 return cnt;
1001 }
1002
1003 INIT_LIST_HEAD(&mp2->list);
1004 } else {
1005 mp2 = NULL;
1006 }
1007
1008 icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys);
1009 icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys);
1010 icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE;
1011 icmd->ulpBdeCount = 1;
1012 cnt--;
1013 if (mp2) {
1014 icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys);
1015 icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys);
1016 icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE;
1017 cnt--;
1018 icmd->ulpBdeCount = 2;
1019 }
1020
1021 icmd->ulpCommand = CMD_QUE_RING_BUF64_CN;
1022 icmd->ulpLe = 1;
1023
1024 spin_lock_irq(phba->host->host_lock);
1025 if (lpfc_sli_issue_iocb(phba, pring, iocb, 0) == IOCB_ERROR) {
1026 lpfc_mbuf_free(phba, mp1->virt, mp1->phys);
1027 kfree(mp1);
1028 cnt++;
1029 if (mp2) {
1030 lpfc_mbuf_free(phba, mp2->virt, mp2->phys);
1031 kfree(mp2);
1032 cnt++;
1033 }
James Bottomley604a3e32005-10-29 10:28:33 -05001034 lpfc_sli_release_iocbq(phba, iocb);
dea31012005-04-17 16:05:31 -05001035 pring->missbufcnt = cnt;
1036 spin_unlock_irq(phba->host->host_lock);
1037 return cnt;
1038 }
1039 spin_unlock_irq(phba->host->host_lock);
1040 lpfc_sli_ringpostbuf_put(phba, pring, mp1);
1041 if (mp2) {
1042 lpfc_sli_ringpostbuf_put(phba, pring, mp2);
1043 }
1044 }
1045 pring->missbufcnt = 0;
1046 return 0;
1047}
1048
1049/************************************************************************/
1050/* */
1051/* lpfc_post_rcv_buf */
1052/* This routine post initial rcv buffers to the configured rings */
1053/* */
1054/************************************************************************/
1055static int
1056lpfc_post_rcv_buf(struct lpfc_hba * phba)
1057{
1058 struct lpfc_sli *psli = &phba->sli;
1059
1060 /* Ring 0, ELS / CT buffers */
1061 lpfc_post_buffer(phba, &psli->ring[LPFC_ELS_RING], LPFC_BUF_RING0, 1);
1062 /* Ring 2 - FCP no buffers needed */
1063
1064 return 0;
1065}
1066
1067#define S(N,V) (((V)<<(N))|((V)>>(32-(N))))
1068
1069/************************************************************************/
1070/* */
1071/* lpfc_sha_init */
1072/* */
1073/************************************************************************/
1074static void
1075lpfc_sha_init(uint32_t * HashResultPointer)
1076{
1077 HashResultPointer[0] = 0x67452301;
1078 HashResultPointer[1] = 0xEFCDAB89;
1079 HashResultPointer[2] = 0x98BADCFE;
1080 HashResultPointer[3] = 0x10325476;
1081 HashResultPointer[4] = 0xC3D2E1F0;
1082}
1083
1084/************************************************************************/
1085/* */
1086/* lpfc_sha_iterate */
1087/* */
1088/************************************************************************/
1089static void
1090lpfc_sha_iterate(uint32_t * HashResultPointer, uint32_t * HashWorkingPointer)
1091{
1092 int t;
1093 uint32_t TEMP;
1094 uint32_t A, B, C, D, E;
1095 t = 16;
1096 do {
1097 HashWorkingPointer[t] =
1098 S(1,
1099 HashWorkingPointer[t - 3] ^ HashWorkingPointer[t -
1100 8] ^
1101 HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]);
1102 } while (++t <= 79);
1103 t = 0;
1104 A = HashResultPointer[0];
1105 B = HashResultPointer[1];
1106 C = HashResultPointer[2];
1107 D = HashResultPointer[3];
1108 E = HashResultPointer[4];
1109
1110 do {
1111 if (t < 20) {
1112 TEMP = ((B & C) | ((~B) & D)) + 0x5A827999;
1113 } else if (t < 40) {
1114 TEMP = (B ^ C ^ D) + 0x6ED9EBA1;
1115 } else if (t < 60) {
1116 TEMP = ((B & C) | (B & D) | (C & D)) + 0x8F1BBCDC;
1117 } else {
1118 TEMP = (B ^ C ^ D) + 0xCA62C1D6;
1119 }
1120 TEMP += S(5, A) + E + HashWorkingPointer[t];
1121 E = D;
1122 D = C;
1123 C = S(30, B);
1124 B = A;
1125 A = TEMP;
1126 } while (++t <= 79);
1127
1128 HashResultPointer[0] += A;
1129 HashResultPointer[1] += B;
1130 HashResultPointer[2] += C;
1131 HashResultPointer[3] += D;
1132 HashResultPointer[4] += E;
1133
1134}
1135
1136/************************************************************************/
1137/* */
1138/* lpfc_challenge_key */
1139/* */
1140/************************************************************************/
1141static void
1142lpfc_challenge_key(uint32_t * RandomChallenge, uint32_t * HashWorking)
1143{
1144 *HashWorking = (*RandomChallenge ^ *HashWorking);
1145}
1146
1147/************************************************************************/
1148/* */
1149/* lpfc_hba_init */
1150/* */
1151/************************************************************************/
1152void
1153lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit)
1154{
1155 int t;
1156 uint32_t *HashWorking;
1157 uint32_t *pwwnn = phba->wwnn;
1158
1159 HashWorking = kmalloc(80 * sizeof(uint32_t), GFP_KERNEL);
1160 if (!HashWorking)
1161 return;
1162
1163 memset(HashWorking, 0, (80 * sizeof(uint32_t)));
1164 HashWorking[0] = HashWorking[78] = *pwwnn++;
1165 HashWorking[1] = HashWorking[79] = *pwwnn;
1166
1167 for (t = 0; t < 7; t++)
1168 lpfc_challenge_key(phba->RandomData + t, HashWorking + t);
1169
1170 lpfc_sha_init(hbainit);
1171 lpfc_sha_iterate(hbainit, HashWorking);
1172 kfree(HashWorking);
1173}
1174
1175static void
James Smart1dcb58e2007-04-25 09:51:30 -04001176lpfc_cleanup(struct lpfc_hba * phba)
dea31012005-04-17 16:05:31 -05001177{
1178 struct lpfc_nodelist *ndlp, *next_ndlp;
1179
1180 /* clean up phba - lpfc specific */
1181 lpfc_can_disctmo(phba);
1182 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpunmap_list,
1183 nlp_listp) {
1184 lpfc_nlp_remove(phba, ndlp);
1185 }
1186
1187 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpmap_list,
1188 nlp_listp) {
1189 lpfc_nlp_remove(phba, ndlp);
1190 }
1191
1192 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list,
1193 nlp_listp) {
1194 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
1195 }
1196
1197 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list,
1198 nlp_listp) {
1199 lpfc_nlp_remove(phba, ndlp);
1200 }
1201
1202 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list,
1203 nlp_listp) {
1204 lpfc_nlp_remove(phba, ndlp);
1205 }
1206
1207 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_reglogin_list,
1208 nlp_listp) {
1209 lpfc_nlp_remove(phba, ndlp);
1210 }
1211
1212 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_prli_list,
1213 nlp_listp) {
1214 lpfc_nlp_remove(phba, ndlp);
1215 }
1216
1217 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list,
1218 nlp_listp) {
1219 lpfc_nlp_remove(phba, ndlp);
1220 }
1221
1222 INIT_LIST_HEAD(&phba->fc_nlpmap_list);
1223 INIT_LIST_HEAD(&phba->fc_nlpunmap_list);
1224 INIT_LIST_HEAD(&phba->fc_unused_list);
1225 INIT_LIST_HEAD(&phba->fc_plogi_list);
1226 INIT_LIST_HEAD(&phba->fc_adisc_list);
1227 INIT_LIST_HEAD(&phba->fc_reglogin_list);
1228 INIT_LIST_HEAD(&phba->fc_prli_list);
1229 INIT_LIST_HEAD(&phba->fc_npr_list);
1230
1231 phba->fc_map_cnt = 0;
1232 phba->fc_unmap_cnt = 0;
1233 phba->fc_plogi_cnt = 0;
1234 phba->fc_adisc_cnt = 0;
1235 phba->fc_reglogin_cnt = 0;
1236 phba->fc_prli_cnt = 0;
1237 phba->fc_npr_cnt = 0;
1238 phba->fc_unused_cnt= 0;
1239 return;
1240}
1241
1242static void
1243lpfc_establish_link_tmo(unsigned long ptr)
1244{
1245 struct lpfc_hba *phba = (struct lpfc_hba *)ptr;
1246 unsigned long iflag;
1247
1248
1249 /* Re-establishing Link, timer expired */
1250 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
1251 "%d:1300 Re-establishing Link, timer expired "
1252 "Data: x%x x%x\n",
1253 phba->brd_no, phba->fc_flag, phba->hba_state);
1254 spin_lock_irqsave(phba->host->host_lock, iflag);
1255 phba->fc_flag &= ~FC_ESTABLISH_LINK;
1256 spin_unlock_irqrestore(phba->host->host_lock, iflag);
1257}
1258
1259static int
1260lpfc_stop_timer(struct lpfc_hba * phba)
1261{
1262 struct lpfc_sli *psli = &phba->sli;
1263
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05001264 del_timer_sync(&phba->fcp_poll_timer);
dea31012005-04-17 16:05:31 -05001265 del_timer_sync(&phba->fc_estabtmo);
1266 del_timer_sync(&phba->fc_disctmo);
1267 del_timer_sync(&phba->fc_fdmitmo);
1268 del_timer_sync(&phba->els_tmofunc);
1269 psli = &phba->sli;
1270 del_timer_sync(&psli->mbox_tmo);
1271 return(1);
1272}
1273
1274int
1275lpfc_online(struct lpfc_hba * phba)
1276{
1277 if (!phba)
1278 return 0;
1279
1280 if (!(phba->fc_flag & FC_OFFLINE_MODE))
1281 return 0;
1282
1283 lpfc_printf_log(phba,
1284 KERN_WARNING,
1285 LOG_INIT,
1286 "%d:0458 Bring Adapter online\n",
1287 phba->brd_no);
1288
1289 if (!lpfc_sli_queue_setup(phba))
1290 return 1;
1291
1292 if (lpfc_sli_hba_setup(phba)) /* Initialize the HBA */
1293 return 1;
1294
1295 spin_lock_irq(phba->host->host_lock);
1296 phba->fc_flag &= ~FC_OFFLINE_MODE;
1297 spin_unlock_irq(phba->host->host_lock);
1298
dea31012005-04-17 16:05:31 -05001299 return 0;
1300}
1301
1302int
1303lpfc_offline(struct lpfc_hba * phba)
1304{
1305 struct lpfc_sli_ring *pring;
1306 struct lpfc_sli *psli;
1307 unsigned long iflag;
James Smart688a8862006-07-06 15:49:56 -04001308 int i;
1309 int cnt = 0;
dea31012005-04-17 16:05:31 -05001310
1311 if (!phba)
1312 return 0;
1313
1314 if (phba->fc_flag & FC_OFFLINE_MODE)
1315 return 0;
1316
dea31012005-04-17 16:05:31 -05001317 psli = &phba->sli;
dea31012005-04-17 16:05:31 -05001318
1319 lpfc_linkdown(phba);
James Smartb4c02652006-07-06 15:50:43 -04001320 lpfc_sli_flush_mbox_queue(phba);
dea31012005-04-17 16:05:31 -05001321
James Smart688a8862006-07-06 15:49:56 -04001322 for (i = 0; i < psli->num_rings; i++) {
1323 pring = &psli->ring[i];
1324 /* The linkdown event takes 30 seconds to timeout. */
1325 while (pring->txcmplq_cnt) {
James Smart1dcb58e2007-04-25 09:51:30 -04001326 msleep(10);
James Smart688a8862006-07-06 15:49:56 -04001327 if (cnt++ > 3000) {
1328 lpfc_printf_log(phba,
1329 KERN_WARNING, LOG_INIT,
1330 "%d:0466 Outstanding IO when "
1331 "bringing Adapter offline\n",
1332 phba->brd_no);
1333 break;
1334 }
1335 }
dea31012005-04-17 16:05:31 -05001336 }
1337
James Smart688a8862006-07-06 15:49:56 -04001338
dea31012005-04-17 16:05:31 -05001339 /* stop all timers associated with this hba */
1340 lpfc_stop_timer(phba);
1341 phba->work_hba_events = 0;
James Smart33ccf8d2006-08-17 11:57:58 -04001342 phba->work_ha = 0;
dea31012005-04-17 16:05:31 -05001343
1344 lpfc_printf_log(phba,
1345 KERN_WARNING,
1346 LOG_INIT,
1347 "%d:0460 Bring Adapter offline\n",
1348 phba->brd_no);
1349
1350 /* Bring down the SLI Layer and cleanup. The HBA is offline
1351 now. */
1352 lpfc_sli_hba_down(phba);
James Smart1dcb58e2007-04-25 09:51:30 -04001353 lpfc_cleanup(phba);
dea31012005-04-17 16:05:31 -05001354 spin_lock_irqsave(phba->host->host_lock, iflag);
1355 phba->fc_flag |= FC_OFFLINE_MODE;
1356 spin_unlock_irqrestore(phba->host->host_lock, iflag);
1357 return 0;
1358}
1359
1360/******************************************************************************
1361* Function name: lpfc_scsi_free
1362*
1363* Description: Called from lpfc_pci_remove_one free internal driver resources
1364*
1365******************************************************************************/
1366static int
1367lpfc_scsi_free(struct lpfc_hba * phba)
1368{
1369 struct lpfc_scsi_buf *sb, *sb_next;
1370 struct lpfc_iocbq *io, *io_next;
1371
1372 spin_lock_irq(phba->host->host_lock);
1373 /* Release all the lpfc_scsi_bufs maintained by this host. */
1374 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list, list) {
1375 list_del(&sb->list);
1376 pci_pool_free(phba->lpfc_scsi_dma_buf_pool, sb->data,
1377 sb->dma_handle);
1378 kfree(sb);
1379 phba->total_scsi_bufs--;
1380 }
1381
1382 /* Release all the lpfc_iocbq entries maintained by this host. */
1383 list_for_each_entry_safe(io, io_next, &phba->lpfc_iocb_list, list) {
1384 list_del(&io->list);
1385 kfree(io);
1386 phba->total_iocbq_bufs--;
1387 }
1388
1389 spin_unlock_irq(phba->host->host_lock);
1390
1391 return 0;
1392}
1393
1394
1395static int __devinit
1396lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1397{
1398 struct Scsi_Host *host;
1399 struct lpfc_hba *phba;
1400 struct lpfc_sli *psli;
1401 struct lpfc_iocbq *iocbq_entry = NULL, *iocbq_next = NULL;
1402 unsigned long bar0map_len, bar2map_len;
1403 int error = -ENODEV, retval;
1404 int i;
James Bottomley604a3e32005-10-29 10:28:33 -05001405 uint16_t iotag;
dea31012005-04-17 16:05:31 -05001406
1407 if (pci_enable_device(pdev))
1408 goto out;
1409 if (pci_request_regions(pdev, LPFC_DRIVER_NAME))
1410 goto out_disable_device;
1411
James.Smart@Emulex.Comf888ba32005-08-10 15:03:01 -04001412 host = scsi_host_alloc(&lpfc_template, sizeof (struct lpfc_hba));
dea31012005-04-17 16:05:31 -05001413 if (!host)
1414 goto out_release_regions;
1415
1416 phba = (struct lpfc_hba*)host->hostdata;
1417 memset(phba, 0, sizeof (struct lpfc_hba));
dea31012005-04-17 16:05:31 -05001418 phba->host = host;
1419
1420 phba->fc_flag |= FC_LOADING;
1421 phba->pcidev = pdev;
1422
1423 /* Assign an unused board number */
1424 if (!idr_pre_get(&lpfc_hba_index, GFP_KERNEL))
1425 goto out_put_host;
1426
1427 error = idr_get_new(&lpfc_hba_index, NULL, &phba->brd_no);
1428 if (error)
1429 goto out_put_host;
1430
1431 host->unique_id = phba->brd_no;
dea31012005-04-17 16:05:31 -05001432
1433 /* Initialize timers used by driver */
1434 init_timer(&phba->fc_estabtmo);
1435 phba->fc_estabtmo.function = lpfc_establish_link_tmo;
1436 phba->fc_estabtmo.data = (unsigned long)phba;
1437 init_timer(&phba->fc_disctmo);
1438 phba->fc_disctmo.function = lpfc_disc_timeout;
1439 phba->fc_disctmo.data = (unsigned long)phba;
1440
1441 init_timer(&phba->fc_fdmitmo);
1442 phba->fc_fdmitmo.function = lpfc_fdmi_tmo;
1443 phba->fc_fdmitmo.data = (unsigned long)phba;
1444 init_timer(&phba->els_tmofunc);
1445 phba->els_tmofunc.function = lpfc_els_timeout;
1446 phba->els_tmofunc.data = (unsigned long)phba;
1447 psli = &phba->sli;
1448 init_timer(&psli->mbox_tmo);
1449 psli->mbox_tmo.function = lpfc_mbox_timeout;
1450 psli->mbox_tmo.data = (unsigned long)phba;
1451
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05001452 init_timer(&phba->fcp_poll_timer);
1453 phba->fcp_poll_timer.function = lpfc_poll_timeout;
1454 phba->fcp_poll_timer.data = (unsigned long)phba;
1455
dea31012005-04-17 16:05:31 -05001456 /*
1457 * Get all the module params for configuring this host and then
1458 * establish the host parameters.
1459 */
1460 lpfc_get_cfgparam(phba);
1461
1462 host->max_id = LPFC_MAX_TARGET;
1463 host->max_lun = phba->cfg_max_luns;
1464 host->this_id = -1;
1465
1466 /* Initialize all internally managed lists. */
1467 INIT_LIST_HEAD(&phba->fc_nlpmap_list);
1468 INIT_LIST_HEAD(&phba->fc_nlpunmap_list);
1469 INIT_LIST_HEAD(&phba->fc_unused_list);
1470 INIT_LIST_HEAD(&phba->fc_plogi_list);
1471 INIT_LIST_HEAD(&phba->fc_adisc_list);
1472 INIT_LIST_HEAD(&phba->fc_reglogin_list);
1473 INIT_LIST_HEAD(&phba->fc_prli_list);
1474 INIT_LIST_HEAD(&phba->fc_npr_list);
1475
1476
1477 pci_set_master(pdev);
1478 retval = pci_set_mwi(pdev);
1479 if (retval)
1480 dev_printk(KERN_WARNING, &pdev->dev,
1481 "Warning: pci_set_mwi returned %d\n", retval);
1482
1483 if (pci_set_dma_mask(phba->pcidev, DMA_64BIT_MASK) != 0)
1484 if (pci_set_dma_mask(phba->pcidev, DMA_32BIT_MASK) != 0)
1485 goto out_idr_remove;
1486
1487 /*
1488 * Get the bus address of Bar0 and Bar2 and the number of bytes
1489 * required by each mapping.
1490 */
1491 phba->pci_bar0_map = pci_resource_start(phba->pcidev, 0);
1492 bar0map_len = pci_resource_len(phba->pcidev, 0);
1493
1494 phba->pci_bar2_map = pci_resource_start(phba->pcidev, 2);
1495 bar2map_len = pci_resource_len(phba->pcidev, 2);
1496
Jamie Wellnitz901a9202006-02-28 19:25:19 -05001497 /* Map HBA SLIM to a kernel virtual address. */
dea31012005-04-17 16:05:31 -05001498 phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len);
Jamie Wellnitz901a9202006-02-28 19:25:19 -05001499 if (!phba->slim_memmap_p) {
1500 error = -ENODEV;
1501 dev_printk(KERN_ERR, &pdev->dev,
1502 "ioremap failed for SLIM memory.\n");
1503 goto out_idr_remove;
1504 }
1505
1506 /* Map HBA Control Registers to a kernel virtual address. */
dea31012005-04-17 16:05:31 -05001507 phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len);
Jamie Wellnitz901a9202006-02-28 19:25:19 -05001508 if (!phba->ctrl_regs_memmap_p) {
1509 error = -ENODEV;
1510 dev_printk(KERN_ERR, &pdev->dev,
1511 "ioremap failed for HBA control registers.\n");
1512 goto out_iounmap_slim;
1513 }
dea31012005-04-17 16:05:31 -05001514
1515 /* Allocate memory for SLI-2 structures */
1516 phba->slim2p = dma_alloc_coherent(&phba->pcidev->dev, SLI2_SLIM_SIZE,
1517 &phba->slim2p_mapping, GFP_KERNEL);
1518 if (!phba->slim2p)
1519 goto out_iounmap;
1520
James.Smart@Emulex.Comf91b3922005-10-28 20:29:28 -04001521 memset(phba->slim2p, 0, SLI2_SLIM_SIZE);
dea31012005-04-17 16:05:31 -05001522
1523 /* Initialize the SLI Layer to run with lpfc HBAs. */
1524 lpfc_sli_setup(phba);
1525 lpfc_sli_queue_setup(phba);
1526
1527 error = lpfc_mem_alloc(phba);
1528 if (error)
1529 goto out_free_slim;
1530
1531 /* Initialize and populate the iocb list per host. */
1532 INIT_LIST_HEAD(&phba->lpfc_iocb_list);
1533 for (i = 0; i < LPFC_IOCB_LIST_CNT; i++) {
1534 iocbq_entry = kmalloc(sizeof(struct lpfc_iocbq), GFP_KERNEL);
1535 if (iocbq_entry == NULL) {
1536 printk(KERN_ERR "%s: only allocated %d iocbs of "
1537 "expected %d count. Unloading driver.\n",
1538 __FUNCTION__, i, LPFC_IOCB_LIST_CNT);
1539 error = -ENOMEM;
1540 goto out_free_iocbq;
1541 }
1542
1543 memset(iocbq_entry, 0, sizeof(struct lpfc_iocbq));
James Bottomley604a3e32005-10-29 10:28:33 -05001544 iotag = lpfc_sli_next_iotag(phba, iocbq_entry);
1545 if (iotag == 0) {
1546 kfree (iocbq_entry);
1547 printk(KERN_ERR "%s: failed to allocate IOTAG. "
1548 "Unloading driver.\n",
1549 __FUNCTION__);
1550 error = -ENOMEM;
1551 goto out_free_iocbq;
1552 }
dea31012005-04-17 16:05:31 -05001553 spin_lock_irq(phba->host->host_lock);
1554 list_add(&iocbq_entry->list, &phba->lpfc_iocb_list);
1555 phba->total_iocbq_bufs++;
1556 spin_unlock_irq(phba->host->host_lock);
1557 }
1558
1559 /* Initialize HBA structure */
1560 phba->fc_edtov = FF_DEF_EDTOV;
1561 phba->fc_ratov = FF_DEF_RATOV;
1562 phba->fc_altov = FF_DEF_ALTOV;
1563 phba->fc_arbtov = FF_DEF_ARBTOV;
1564
1565 INIT_LIST_HEAD(&phba->work_list);
1566 phba->work_ha_mask = (HA_ERATT|HA_MBATT|HA_LATT);
1567 phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4));
1568
1569 /* Startup the kernel thread for this host adapter. */
1570 phba->worker_thread = kthread_run(lpfc_do_work, phba,
1571 "lpfc_worker_%d", phba->brd_no);
1572 if (IS_ERR(phba->worker_thread)) {
1573 error = PTR_ERR(phba->worker_thread);
1574 goto out_free_iocbq;
1575 }
1576
James Smart8f6d98d2006-08-01 07:34:00 -04001577 /*
1578 * Set initial can_queue value since 0 is no longer supported and
1579 * scsi_add_host will fail. This will be adjusted later based on the
1580 * max xri value determined in hba setup.
1581 */
dea31012005-04-17 16:05:31 -05001582 host->can_queue = phba->cfg_hba_queue_depth - 10;
1583
1584 /* Tell the midlayer we support 16 byte commands */
1585 host->max_cmd_len = 16;
1586
1587 /* Initialize the list of scsi buffers used by driver for scsi IO. */
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05001588 spin_lock_init(&phba->scsi_buf_list_lock);
dea31012005-04-17 16:05:31 -05001589 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list);
1590
1591 host->transportt = lpfc_transport_template;
dea31012005-04-17 16:05:31 -05001592 pci_set_drvdata(pdev, host);
1593 error = scsi_add_host(host, &pdev->dev);
1594 if (error)
1595 goto out_kthread_stop;
1596
1597 error = lpfc_alloc_sysfs_attr(phba);
1598 if (error)
James Smartdefbcf12006-04-16 22:26:50 -04001599 goto out_remove_host;
dea31012005-04-17 16:05:31 -05001600
James Smart4ff43242006-12-02 13:34:56 -05001601 if (phba->cfg_use_msi) {
1602 error = pci_enable_msi(phba->pcidev);
1603 if (error)
1604 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "%d:0452 "
1605 "Enable MSI failed, continuing with "
1606 "IRQ\n", phba->brd_no);
1607 }
1608
Thomas Gleixner1d6f3592006-07-01 19:29:42 -07001609 error = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED,
dea31012005-04-17 16:05:31 -05001610 LPFC_DRIVER_NAME, phba);
1611 if (error) {
1612 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1613 "%d:0451 Enable interrupt handler failed\n",
1614 phba->brd_no);
1615 goto out_free_sysfs_attr;
1616 }
1617 phba->MBslimaddr = phba->slim_memmap_p;
1618 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET;
1619 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET;
1620 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET;
1621 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET;
1622
1623 error = lpfc_sli_hba_setup(phba);
James Smartdefbcf12006-04-16 22:26:50 -04001624 if (error) {
1625 error = -ENODEV;
dea31012005-04-17 16:05:31 -05001626 goto out_free_irq;
James Smartdefbcf12006-04-16 22:26:50 -04001627 }
dea31012005-04-17 16:05:31 -05001628
James Smart8f6d98d2006-08-01 07:34:00 -04001629 /*
1630 * hba setup may have changed the hba_queue_depth so we need to adjust
1631 * the value of can_queue.
1632 */
1633 host->can_queue = phba->cfg_hba_queue_depth - 10;
1634
James Smartce8b3ce2006-07-06 15:50:36 -04001635 lpfc_discovery_wait(phba);
1636
James.Smart@Emulex.Com875fbdf2005-11-29 16:32:13 -05001637 if (phba->cfg_poll & DISABLE_FCP_RING_INT) {
1638 spin_lock_irq(phba->host->host_lock);
1639 lpfc_poll_start_timer(phba);
1640 spin_unlock_irq(phba->host->host_lock);
1641 }
1642
dea31012005-04-17 16:05:31 -05001643 /*
1644 * set fixed host attributes
1645 * Must done after lpfc_sli_hba_setup()
1646 */
1647
Andrew Morton68ce1eb2005-09-21 09:46:54 -07001648 fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.u.wwn);
1649 fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.u.wwn);
dea31012005-04-17 16:05:31 -05001650 fc_host_supported_classes(host) = FC_COS_CLASS3;
1651
1652 memset(fc_host_supported_fc4s(host), 0,
1653 sizeof(fc_host_supported_fc4s(host)));
1654 fc_host_supported_fc4s(host)[2] = 1;
1655 fc_host_supported_fc4s(host)[7] = 1;
1656
1657 lpfc_get_hba_sym_node_name(phba, fc_host_symbolic_name(host));
1658
1659 fc_host_supported_speeds(host) = 0;
Jamie Wellnitz74b72a52006-02-28 22:33:04 -05001660 if (phba->lmt & LMT_10Gb)
dea31012005-04-17 16:05:31 -05001661 fc_host_supported_speeds(host) |= FC_PORTSPEED_10GBIT;
Jamie Wellnitz74b72a52006-02-28 22:33:04 -05001662 if (phba->lmt & LMT_4Gb)
dea31012005-04-17 16:05:31 -05001663 fc_host_supported_speeds(host) |= FC_PORTSPEED_4GBIT;
Jamie Wellnitz74b72a52006-02-28 22:33:04 -05001664 if (phba->lmt & LMT_2Gb)
dea31012005-04-17 16:05:31 -05001665 fc_host_supported_speeds(host) |= FC_PORTSPEED_2GBIT;
Jamie Wellnitz74b72a52006-02-28 22:33:04 -05001666 if (phba->lmt & LMT_1Gb)
1667 fc_host_supported_speeds(host) |= FC_PORTSPEED_1GBIT;
dea31012005-04-17 16:05:31 -05001668
1669 fc_host_maxframe_size(host) =
1670 ((((uint32_t) phba->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) |
1671 (uint32_t) phba->fc_sparam.cmn.bbRcvSizeLsb);
1672
1673 /* This value is also unchanging */
1674 memset(fc_host_active_fc4s(host), 0,
1675 sizeof(fc_host_active_fc4s(host)));
1676 fc_host_active_fc4s(host)[2] = 1;
1677 fc_host_active_fc4s(host)[7] = 1;
1678
1679 spin_lock_irq(phba->host->host_lock);
1680 phba->fc_flag &= ~FC_LOADING;
1681 spin_unlock_irq(phba->host->host_lock);
1682 return 0;
1683
1684out_free_irq:
1685 lpfc_stop_timer(phba);
1686 phba->work_hba_events = 0;
1687 free_irq(phba->pcidev->irq, phba);
James Smart4ff43242006-12-02 13:34:56 -05001688 pci_disable_msi(phba->pcidev);
dea31012005-04-17 16:05:31 -05001689out_free_sysfs_attr:
1690 lpfc_free_sysfs_attr(phba);
James Smartdefbcf12006-04-16 22:26:50 -04001691out_remove_host:
1692 fc_remove_host(phba->host);
1693 scsi_remove_host(phba->host);
dea31012005-04-17 16:05:31 -05001694out_kthread_stop:
1695 kthread_stop(phba->worker_thread);
1696out_free_iocbq:
1697 list_for_each_entry_safe(iocbq_entry, iocbq_next,
1698 &phba->lpfc_iocb_list, list) {
1699 spin_lock_irq(phba->host->host_lock);
1700 kfree(iocbq_entry);
1701 phba->total_iocbq_bufs--;
1702 spin_unlock_irq(phba->host->host_lock);
1703 }
1704 lpfc_mem_free(phba);
1705out_free_slim:
1706 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, phba->slim2p,
1707 phba->slim2p_mapping);
1708out_iounmap:
1709 iounmap(phba->ctrl_regs_memmap_p);
Jamie Wellnitz901a9202006-02-28 19:25:19 -05001710out_iounmap_slim:
dea31012005-04-17 16:05:31 -05001711 iounmap(phba->slim_memmap_p);
1712out_idr_remove:
1713 idr_remove(&lpfc_hba_index, phba->brd_no);
1714out_put_host:
James Smartdefbcf12006-04-16 22:26:50 -04001715 phba->host = NULL;
dea31012005-04-17 16:05:31 -05001716 scsi_host_put(host);
1717out_release_regions:
1718 pci_release_regions(pdev);
1719out_disable_device:
1720 pci_disable_device(pdev);
1721out:
James Smartdefbcf12006-04-16 22:26:50 -04001722 pci_set_drvdata(pdev, NULL);
dea31012005-04-17 16:05:31 -05001723 return error;
1724}
1725
1726static void __devexit
1727lpfc_pci_remove_one(struct pci_dev *pdev)
1728{
1729 struct Scsi_Host *host = pci_get_drvdata(pdev);
Jamie Wellnitz7f0b5b12006-02-28 19:25:24 -05001730 struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata;
dea31012005-04-17 16:05:31 -05001731 unsigned long iflag;
1732
1733 lpfc_free_sysfs_attr(phba);
1734
1735 spin_lock_irqsave(phba->host->host_lock, iflag);
1736 phba->fc_flag |= FC_UNLOADING;
1737
1738 spin_unlock_irqrestore(phba->host->host_lock, iflag);
1739
1740 fc_remove_host(phba->host);
1741 scsi_remove_host(phba->host);
1742
1743 kthread_stop(phba->worker_thread);
1744
1745 /*
1746 * Bring down the SLI Layer. This step disable all interrupts,
1747 * clears the rings, discards all mailbox commands, and resets
1748 * the HBA.
1749 */
1750 lpfc_sli_hba_down(phba);
Jamie Wellnitz41415862006-02-28 19:25:27 -05001751 lpfc_sli_brdrestart(phba);
dea31012005-04-17 16:05:31 -05001752
1753 /* Release the irq reservation */
1754 free_irq(phba->pcidev->irq, phba);
James Smart4ff43242006-12-02 13:34:56 -05001755 pci_disable_msi(phba->pcidev);
dea31012005-04-17 16:05:31 -05001756
James Smart1dcb58e2007-04-25 09:51:30 -04001757 lpfc_cleanup(phba);
dea31012005-04-17 16:05:31 -05001758 lpfc_stop_timer(phba);
1759 phba->work_hba_events = 0;
1760
1761 /*
1762 * Call scsi_free before mem_free since scsi bufs are released to their
1763 * corresponding pools here.
1764 */
1765 lpfc_scsi_free(phba);
1766 lpfc_mem_free(phba);
1767
1768 /* Free resources associated with SLI2 interface */
1769 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE,
1770 phba->slim2p, phba->slim2p_mapping);
1771
1772 /* unmap adapter SLIM and Control Registers */
1773 iounmap(phba->ctrl_regs_memmap_p);
1774 iounmap(phba->slim_memmap_p);
1775
1776 pci_release_regions(phba->pcidev);
1777 pci_disable_device(phba->pcidev);
1778
1779 idr_remove(&lpfc_hba_index, phba->brd_no);
1780 scsi_host_put(phba->host);
1781
1782 pci_set_drvdata(pdev, NULL);
1783}
1784
Linas Vepstas8d63f372007-02-14 14:28:36 -06001785/**
1786 * lpfc_io_error_detected - called when PCI error is detected
1787 * @pdev: Pointer to PCI device
1788 * @state: The current pci conneection state
1789 *
1790 * This function is called after a PCI bus error affecting
1791 * this device has been detected.
1792 */
1793static pci_ers_result_t lpfc_io_error_detected(struct pci_dev *pdev,
1794 pci_channel_state_t state)
1795{
1796 struct Scsi_Host *host = pci_get_drvdata(pdev);
1797 struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata;
1798 struct lpfc_sli *psli = &phba->sli;
1799 struct lpfc_sli_ring *pring;
1800
Linas Vepstas5daa49e2007-03-08 16:19:11 -06001801 if (state == pci_channel_io_perm_failure)
Linas Vepstas8d63f372007-02-14 14:28:36 -06001802 return PCI_ERS_RESULT_DISCONNECT;
Linas Vepstas5daa49e2007-03-08 16:19:11 -06001803
Linas Vepstas8d63f372007-02-14 14:28:36 -06001804 pci_disable_device(pdev);
1805 /*
1806 * There may be I/Os dropped by the firmware.
1807 * Error iocb (I/O) on txcmplq and let the SCSI layer
1808 * retry it after re-establishing link.
1809 */
1810 pring = &psli->ring[psli->fcp_ring];
1811 lpfc_sli_abort_iocb_ring(phba, pring);
1812
1813 /* Request a slot reset. */
1814 return PCI_ERS_RESULT_NEED_RESET;
1815}
1816
1817/**
1818 * lpfc_io_slot_reset - called after the pci bus has been reset.
1819 * @pdev: Pointer to PCI device
1820 *
1821 * Restart the card from scratch, as if from a cold-boot.
1822 */
1823static pci_ers_result_t lpfc_io_slot_reset(struct pci_dev *pdev)
1824{
1825 struct Scsi_Host *host = pci_get_drvdata(pdev);
1826 struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata;
1827 struct lpfc_sli *psli = &phba->sli;
1828 int bars = pci_select_bars(pdev, IORESOURCE_MEM);
1829
1830 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n");
1831 if (pci_enable_device_bars(pdev, bars)) {
1832 printk(KERN_ERR "lpfc: Cannot re-enable "
1833 "PCI device after reset.\n");
1834 return PCI_ERS_RESULT_DISCONNECT;
1835 }
1836
1837 pci_set_master(pdev);
1838
1839 /* Re-establishing Link */
1840 spin_lock_irq(phba->host->host_lock);
1841 phba->fc_flag |= FC_ESTABLISH_LINK;
1842 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
1843 spin_unlock_irq(phba->host->host_lock);
1844
1845
1846 /* Take device offline; this will perform cleanup */
1847 lpfc_offline(phba);
1848 lpfc_sli_brdrestart(phba);
1849
1850 return PCI_ERS_RESULT_RECOVERED;
1851}
1852
1853/**
1854 * lpfc_io_resume - called when traffic can start flowing again.
1855 * @pdev: Pointer to PCI device
1856 *
1857 * This callback is called when the error recovery driver tells us that
1858 * its OK to resume normal operation.
1859 */
1860static void lpfc_io_resume(struct pci_dev *pdev)
1861{
1862 struct Scsi_Host *host = pci_get_drvdata(pdev);
1863 struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata;
1864
1865 if (lpfc_online(phba) == 0) {
1866 mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60);
1867 }
1868}
1869
dea31012005-04-17 16:05:31 -05001870static struct pci_device_id lpfc_id_table[] = {
1871 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_VIPER,
1872 PCI_ANY_ID, PCI_ANY_ID, },
James.Smart@Emulex.Com06325e72005-06-25 10:34:22 -04001873 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_FIREFLY,
1874 PCI_ANY_ID, PCI_ANY_ID, },
dea31012005-04-17 16:05:31 -05001875 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_THOR,
1876 PCI_ANY_ID, PCI_ANY_ID, },
1877 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PEGASUS,
1878 PCI_ANY_ID, PCI_ANY_ID, },
1879 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_CENTAUR,
1880 PCI_ANY_ID, PCI_ANY_ID, },
1881 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_DRAGONFLY,
1882 PCI_ANY_ID, PCI_ANY_ID, },
1883 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SUPERFLY,
1884 PCI_ANY_ID, PCI_ANY_ID, },
1885 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_RFLY,
1886 PCI_ANY_ID, PCI_ANY_ID, },
1887 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PFLY,
1888 PCI_ANY_ID, PCI_ANY_ID, },
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -05001889 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE,
1890 PCI_ANY_ID, PCI_ANY_ID, },
1891 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_SCSP,
1892 PCI_ANY_ID, PCI_ANY_ID, },
1893 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_DCSP,
1894 PCI_ANY_ID, PCI_ANY_ID, },
dea31012005-04-17 16:05:31 -05001895 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS,
1896 PCI_ANY_ID, PCI_ANY_ID, },
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -05001897 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_SCSP,
1898 PCI_ANY_ID, PCI_ANY_ID, },
1899 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_DCSP,
1900 PCI_ANY_ID, PCI_ANY_ID, },
dea31012005-04-17 16:05:31 -05001901 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BMID,
1902 PCI_ANY_ID, PCI_ANY_ID, },
1903 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BSMB,
1904 PCI_ANY_ID, PCI_ANY_ID, },
1905 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR,
1906 PCI_ANY_ID, PCI_ANY_ID, },
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -05001907 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_SCSP,
1908 PCI_ANY_ID, PCI_ANY_ID, },
1909 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_DCSP,
1910 PCI_ANY_ID, PCI_ANY_ID, },
dea31012005-04-17 16:05:31 -05001911 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZMID,
1912 PCI_ANY_ID, PCI_ANY_ID, },
1913 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZSMB,
1914 PCI_ANY_ID, PCI_ANY_ID, },
1915 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_TFLY,
1916 PCI_ANY_ID, PCI_ANY_ID, },
1917 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP101,
1918 PCI_ANY_ID, PCI_ANY_ID, },
1919 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP10000S,
1920 PCI_ANY_ID, PCI_ANY_ID, },
James.Smart@Emulex.Come4adb202005-11-28 11:42:12 -05001921 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP11000S,
1922 PCI_ANY_ID, PCI_ANY_ID, },
1923 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LPE11000S,
1924 PCI_ANY_ID, PCI_ANY_ID, },
dea31012005-04-17 16:05:31 -05001925 { 0 }
1926};
1927
1928MODULE_DEVICE_TABLE(pci, lpfc_id_table);
1929
Linas Vepstas8d63f372007-02-14 14:28:36 -06001930static struct pci_error_handlers lpfc_err_handler = {
1931 .error_detected = lpfc_io_error_detected,
1932 .slot_reset = lpfc_io_slot_reset,
1933 .resume = lpfc_io_resume,
1934};
1935
dea31012005-04-17 16:05:31 -05001936static struct pci_driver lpfc_driver = {
1937 .name = LPFC_DRIVER_NAME,
1938 .id_table = lpfc_id_table,
1939 .probe = lpfc_pci_probe_one,
1940 .remove = __devexit_p(lpfc_pci_remove_one),
Linas Vepstas8d63f372007-02-14 14:28:36 -06001941 .err_handler = &lpfc_err_handler,
dea31012005-04-17 16:05:31 -05001942};
1943
1944static int __init
1945lpfc_init(void)
1946{
1947 int error = 0;
1948
1949 printk(LPFC_MODULE_DESC "\n");
James.Smart@Emulex.Comc44ce172005-06-25 10:34:39 -04001950 printk(LPFC_COPYRIGHT "\n");
dea31012005-04-17 16:05:31 -05001951
1952 lpfc_transport_template =
1953 fc_attach_transport(&lpfc_transport_functions);
1954 if (!lpfc_transport_template)
1955 return -ENOMEM;
1956 error = pci_register_driver(&lpfc_driver);
1957 if (error)
1958 fc_release_transport(lpfc_transport_template);
1959
1960 return error;
1961}
1962
1963static void __exit
1964lpfc_exit(void)
1965{
1966 pci_unregister_driver(&lpfc_driver);
1967 fc_release_transport(lpfc_transport_template);
1968}
1969
1970module_init(lpfc_init);
1971module_exit(lpfc_exit);
1972MODULE_LICENSE("GPL");
1973MODULE_DESCRIPTION(LPFC_MODULE_DESC);
1974MODULE_AUTHOR("Emulex Corporation - tech.support@emulex.com");
1975MODULE_VERSION("0:" LPFC_DRIVER_VERSION);