Commit | Line | Data |
---|---|---|
dea3101e | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | |
c44ce173 | 3 | * Fibre Channel Host Bus Adapters. * |
41415862 | 4 | * Copyright (C) 2004-2006 Emulex. All rights reserved. * |
c44ce173 | 5 | * EMULEX and SLI are trademarks of Emulex. * |
dea3101e | 6 | * www.emulex.com * |
c44ce173 | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
dea3101e | 8 | * * |
9 | * This program is free software; you can redistribute it and/or * | |
c44ce173 JSEC |
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. * | |
dea3101e | 20 | *******************************************************************/ |
21 | ||
dea3101e | 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> | |
30 | ||
91886523 | 31 | #include <scsi/scsi.h> |
dea3101e | 32 | #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 | ||
74b72a59 | 45 | static int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *, int); |
dea3101e | 46 | static void lpfc_get_hba_model_desc(struct lpfc_hba *, uint8_t *, uint8_t *); |
47 | static int lpfc_post_rcv_buf(struct lpfc_hba *); | |
48 | ||
49 | static struct scsi_transport_template *lpfc_transport_template = NULL; | |
50 | static 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 | /************************************************************************/ | |
63 | int | |
64 | lpfc_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"; | |
65a29c16 | 74 | static int init_key = 1; |
dea3101e | 75 | |
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)) { | |
65a29c16 JS |
86 | if (init_key) { |
87 | uint32_t *ptext = (uint32_t *) licensed; | |
dea3101e | 88 | |
65a29c16 JS |
89 | for (i = 0; i < 56; i += sizeof (uint32_t), ptext++) |
90 | *ptext = cpu_to_be32(*ptext); | |
91 | init_key = 0; | |
92 | } | |
dea3101e | 93 | |
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 | ||
1de933f3 JSEC |
133 | /* |
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. | |
dea3101e | 136 | */ |
1de933f3 | 137 | if (mb->un.varRdRev.rr == 0) { |
dea3101e | 138 | vp->rev.rBit = 0; |
1de933f3 JSEC |
139 | 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); | |
dea3101e | 143 | mempool_free(pmb, phba->mbox_mem_pool); |
144 | return -ERESTART; | |
dea3101e | 145 | } |
146 | ||
147 | /* Save information as VPD data */ | |
1de933f3 JSEC |
148 | 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); | |
dea3101e | 153 | 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 | ||
dea3101e | 168 | /* 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); | |
74b72a59 | 186 | mb->un.varDmp.word_cnt = 0; |
dea3101e | 187 | } |
74b72a59 JW |
188 | if (mb->un.varDmp.word_cnt > DMP_VPD_SIZE - offset) |
189 | mb->un.varDmp.word_cnt = DMP_VPD_SIZE - offset; | |
dea3101e | 190 | lpfc_sli_pcimem_bcopy(pmb->context2, lpfc_vpd_data + offset, |
191 | mb->un.varDmp.word_cnt); | |
192 | offset += mb->un.varDmp.word_cnt; | |
74b72a59 JW |
193 | } while (mb->un.varDmp.word_cnt && offset < DMP_VPD_SIZE); |
194 | lpfc_parse_vpd(phba, lpfc_vpd_data, offset); | |
dea3101e | 195 | |
196 | kfree(lpfc_vpd_data); | |
197 | out_free_context2: | |
198 | kfree(pmb->context2); | |
199 | out_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 | /************************************************************************/ | |
214 | int | |
215 | lpfc_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 | ||
a12e07bc JS |
271 | if (phba->cfg_soft_wwnn) |
272 | u64_to_wwn(phba->cfg_soft_wwnn, phba->fc_sparam.nodeName.u.wwn); | |
c3f28afa JS |
273 | if (phba->cfg_soft_wwpn) |
274 | u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn); | |
dea3101e | 275 | 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 | ||
68ce1eb5 | 284 | outptr = &phba->fc_nodename.u.s.IEEE[0]; |
dea3101e | 285 | 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 | ||
dea3101e | 305 | 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; | |
74b72a59 JW |
325 | |
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 */ | |
dea3101e | 341 | 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 */ | |
a4bc3379 JS |
354 | if (psli->ring[psli->extra_ring].cmdringaddr) |
355 | psli->ring[psli->extra_ring].flag |= LPFC_STOP_IOCB_EVENT; | |
dea3101e | 356 | 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 | ||
875fbdfe JSEC |
377 | 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 | ||
dea3101e | 381 | 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; | |
1dcb58e5 | 389 | mod_timer(&phba->els_tmofunc, jiffies + HZ * timeout); |
dea3101e | 390 | |
391 | lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); | |
392 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | |
8aee918a JS |
393 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); |
394 | if (rc != MBX_SUCCESS) { | |
dea3101e | 395 | 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; | |
8aee918a JS |
411 | if (rc != MBX_BUSY) |
412 | mempool_free(pmb, phba->mbox_mem_pool); | |
dea3101e | 413 | return -EIO; |
414 | } | |
415 | /* MBOX buffer will be freed in mbox compl */ | |
416 | ||
ce8b3ce5 JS |
417 | return (0); |
418 | } | |
419 | ||
420 | static int | |
421 | lpfc_discovery_wait(struct lpfc_hba *phba) | |
422 | { | |
423 | int i = 0; | |
424 | ||
dea3101e | 425 | while ((phba->hba_state != LPFC_HBA_READY) || |
426 | (phba->num_disc_nodes) || (phba->fc_prli_sent) || | |
427 | ((phba->fc_map_cnt == 0) && (i<2)) || | |
ce8b3ce5 | 428 | (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE)) { |
dea3101e | 429 | /* Check every second for 30 retries. */ |
430 | i++; | |
431 | if (i > 30) { | |
ce8b3ce5 | 432 | return -ETIMEDOUT; |
dea3101e | 433 | } |
434 | if ((i >= 15) && (phba->hba_state <= LPFC_LINK_DOWN)) { | |
435 | /* The link is down. Set linkdown timeout */ | |
ce8b3ce5 | 436 | return -ETIMEDOUT; |
dea3101e | 437 | } |
438 | ||
439 | /* Delay for 1 second to give discovery time to complete. */ | |
440 | msleep(1000); | |
441 | ||
442 | } | |
443 | ||
ce8b3ce5 | 444 | return 0; |
dea3101e | 445 | } |
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 | /************************************************************************/ | |
457 | int | |
458 | lpfc_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 | ||
41415862 JW |
472 | /************************************************************************/ |
473 | /* */ | |
474 | /* 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 | /************************************************************************/ | |
481 | int | |
482 | lpfc_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 | ||
dea3101e | 506 | /************************************************************************/ |
507 | /* */ | |
508 | /* 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 | /************************************************************************/ | |
514 | void | |
515 | lpfc_handle_eratt(struct lpfc_hba * phba) | |
516 | { | |
517 | struct lpfc_sli *psli = &phba->sli; | |
518 | struct lpfc_sli_ring *pring; | |
d2873e4c | 519 | uint32_t event_data; |
8d63f375 LV |
520 | /* 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; | |
dea3101e | 524 | |
f5603511 JS |
525 | if (phba->work_hs & HS_FFER6 || |
526 | phba->work_hs & HS_FFER5) { | |
dea3101e | 527 | /* 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; | |
9290831f | 535 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; |
dea3101e | 536 | 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 | */ | |
46fa311e | 552 | lpfc_offline_prep(phba); |
dea3101e | 553 | lpfc_offline(phba); |
41415862 | 554 | lpfc_sli_brdrestart(phba); |
dea3101e | 555 | if (lpfc_online(phba) == 0) { /* Initialize the HBA */ |
556 | mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60); | |
46fa311e | 557 | lpfc_unblock_mgmt_io(phba); |
dea3101e | 558 | return; |
559 | } | |
46fa311e | 560 | lpfc_unblock_mgmt_io(phba); |
dea3101e | 561 | } else { |
562 | /* The if clause above forces this code path when the status | |
563 | * failure is a value other than FFER6. Do not call the offline | |
564 | * twice. This is the adapter hardware error path. | |
565 | */ | |
566 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
567 | "%d:0457 Adapter Hardware Error " | |
568 | "Data: x%x x%x x%x\n", | |
569 | phba->brd_no, phba->work_hs, | |
570 | phba->work_status[0], phba->work_status[1]); | |
571 | ||
d2873e4c JS |
572 | event_data = FC_REG_DUMP_EVENT; |
573 | fc_host_post_vendor_event(phba->host, fc_get_event_number(), | |
574 | sizeof(event_data), (char *) &event_data, | |
575 | SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); | |
576 | ||
9290831f | 577 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; |
46fa311e | 578 | lpfc_offline_prep(phba); |
dea3101e | 579 | lpfc_offline(phba); |
46fa311e | 580 | lpfc_unblock_mgmt_io(phba); |
41415862 JW |
581 | phba->hba_state = LPFC_HBA_ERROR; |
582 | lpfc_hba_down_post(phba); | |
dea3101e | 583 | } |
584 | } | |
585 | ||
586 | /************************************************************************/ | |
587 | /* */ | |
588 | /* lpfc_handle_latt */ | |
589 | /* This routine will handle processing a Host Attention */ | |
590 | /* Link Status event. This will be initialized */ | |
591 | /* as a SLI layer callback routine. */ | |
592 | /* */ | |
593 | /************************************************************************/ | |
594 | void | |
595 | lpfc_handle_latt(struct lpfc_hba * phba) | |
596 | { | |
597 | struct lpfc_sli *psli = &phba->sli; | |
598 | LPFC_MBOXQ_t *pmb; | |
599 | volatile uint32_t control; | |
600 | struct lpfc_dmabuf *mp; | |
601 | int rc = -ENOMEM; | |
602 | ||
603 | pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | |
604 | if (!pmb) | |
605 | goto lpfc_handle_latt_err_exit; | |
606 | ||
607 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); | |
608 | if (!mp) | |
609 | goto lpfc_handle_latt_free_pmb; | |
610 | ||
611 | mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); | |
612 | if (!mp->virt) | |
613 | goto lpfc_handle_latt_free_mp; | |
614 | ||
615 | rc = -EIO; | |
616 | ||
6281bfe0 JSEC |
617 | /* Cleanup any outstanding ELS commands */ |
618 | lpfc_els_flush_cmd(phba); | |
dea3101e | 619 | |
620 | psli->slistat.link_event++; | |
621 | lpfc_read_la(phba, pmb, mp); | |
622 | pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la; | |
623 | rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB)); | |
624 | if (rc == MBX_NOT_FINISHED) | |
14691150 | 625 | goto lpfc_handle_latt_free_mbuf; |
dea3101e | 626 | |
627 | /* Clear Link Attention in HA REG */ | |
628 | spin_lock_irq(phba->host->host_lock); | |
629 | writel(HA_LATT, phba->HAregaddr); | |
630 | readl(phba->HAregaddr); /* flush */ | |
631 | spin_unlock_irq(phba->host->host_lock); | |
632 | ||
633 | return; | |
634 | ||
14691150 JS |
635 | lpfc_handle_latt_free_mbuf: |
636 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
dea3101e | 637 | lpfc_handle_latt_free_mp: |
638 | kfree(mp); | |
639 | lpfc_handle_latt_free_pmb: | |
1dcb58e5 | 640 | mempool_free(pmb, phba->mbox_mem_pool); |
dea3101e | 641 | lpfc_handle_latt_err_exit: |
642 | /* Enable Link attention interrupts */ | |
643 | spin_lock_irq(phba->host->host_lock); | |
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 */ | |
653 | spin_unlock_irq(phba->host->host_lock); | |
654 | lpfc_linkdown(phba); | |
655 | phba->hba_state = LPFC_HBA_ERROR; | |
656 | ||
657 | /* The other case is an error from issue_mbox */ | |
658 | if (rc == -ENOMEM) | |
659 | lpfc_printf_log(phba, | |
660 | KERN_WARNING, | |
661 | LOG_MBOX, | |
662 | "%d:0300 READ_LA: no buffers\n", | |
663 | phba->brd_no); | |
664 | ||
665 | return; | |
666 | } | |
667 | ||
668 | /************************************************************************/ | |
669 | /* */ | |
670 | /* lpfc_parse_vpd */ | |
671 | /* This routine will parse the VPD data */ | |
672 | /* */ | |
673 | /************************************************************************/ | |
674 | static int | |
74b72a59 | 675 | lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len) |
dea3101e | 676 | { |
677 | uint8_t lenlo, lenhi; | |
07da60c1 | 678 | int Length; |
dea3101e | 679 | int i, j; |
680 | int finished = 0; | |
681 | int index = 0; | |
682 | ||
683 | if (!vpd) | |
684 | return 0; | |
685 | ||
686 | /* Vital Product */ | |
687 | lpfc_printf_log(phba, | |
688 | KERN_INFO, | |
689 | LOG_INIT, | |
690 | "%d:0455 Vital Product Data: x%x x%x x%x x%x\n", | |
691 | phba->brd_no, | |
692 | (uint32_t) vpd[0], (uint32_t) vpd[1], (uint32_t) vpd[2], | |
693 | (uint32_t) vpd[3]); | |
74b72a59 | 694 | while (!finished && (index < (len - 4))) { |
dea3101e | 695 | switch (vpd[index]) { |
696 | case 0x82: | |
74b72a59 | 697 | case 0x91: |
dea3101e | 698 | index += 1; |
699 | lenlo = vpd[index]; | |
700 | index += 1; | |
701 | lenhi = vpd[index]; | |
702 | index += 1; | |
703 | i = ((((unsigned short)lenhi) << 8) + lenlo); | |
704 | index += i; | |
705 | break; | |
706 | case 0x90: | |
707 | index += 1; | |
708 | lenlo = vpd[index]; | |
709 | index += 1; | |
710 | lenhi = vpd[index]; | |
711 | index += 1; | |
712 | Length = ((((unsigned short)lenhi) << 8) + lenlo); | |
74b72a59 JW |
713 | if (Length > len - index) |
714 | Length = len - index; | |
dea3101e | 715 | while (Length > 0) { |
716 | /* Look for Serial Number */ | |
717 | if ((vpd[index] == 'S') && (vpd[index+1] == 'N')) { | |
718 | index += 2; | |
719 | i = vpd[index]; | |
720 | index += 1; | |
721 | j = 0; | |
722 | Length -= (3+i); | |
723 | while(i--) { | |
724 | phba->SerialNumber[j++] = vpd[index++]; | |
725 | if (j == 31) | |
726 | break; | |
727 | } | |
728 | phba->SerialNumber[j] = 0; | |
729 | continue; | |
730 | } | |
731 | else if ((vpd[index] == 'V') && (vpd[index+1] == '1')) { | |
732 | phba->vpd_flag |= VPD_MODEL_DESC; | |
733 | index += 2; | |
734 | i = vpd[index]; | |
735 | index += 1; | |
736 | j = 0; | |
737 | Length -= (3+i); | |
738 | while(i--) { | |
739 | phba->ModelDesc[j++] = vpd[index++]; | |
740 | if (j == 255) | |
741 | break; | |
742 | } | |
743 | phba->ModelDesc[j] = 0; | |
744 | continue; | |
745 | } | |
746 | else if ((vpd[index] == 'V') && (vpd[index+1] == '2')) { | |
747 | phba->vpd_flag |= VPD_MODEL_NAME; | |
748 | index += 2; | |
749 | i = vpd[index]; | |
750 | index += 1; | |
751 | j = 0; | |
752 | Length -= (3+i); | |
753 | while(i--) { | |
754 | phba->ModelName[j++] = vpd[index++]; | |
755 | if (j == 79) | |
756 | break; | |
757 | } | |
758 | phba->ModelName[j] = 0; | |
759 | continue; | |
760 | } | |
761 | else if ((vpd[index] == 'V') && (vpd[index+1] == '3')) { | |
762 | phba->vpd_flag |= VPD_PROGRAM_TYPE; | |
763 | index += 2; | |
764 | i = vpd[index]; | |
765 | index += 1; | |
766 | j = 0; | |
767 | Length -= (3+i); | |
768 | while(i--) { | |
769 | phba->ProgramType[j++] = vpd[index++]; | |
770 | if (j == 255) | |
771 | break; | |
772 | } | |
773 | phba->ProgramType[j] = 0; | |
774 | continue; | |
775 | } | |
776 | else if ((vpd[index] == 'V') && (vpd[index+1] == '4')) { | |
777 | phba->vpd_flag |= VPD_PORT; | |
778 | index += 2; | |
779 | i = vpd[index]; | |
780 | index += 1; | |
781 | j = 0; | |
782 | Length -= (3+i); | |
783 | while(i--) { | |
784 | phba->Port[j++] = vpd[index++]; | |
785 | if (j == 19) | |
786 | break; | |
787 | } | |
788 | phba->Port[j] = 0; | |
789 | continue; | |
790 | } | |
791 | else { | |
792 | index += 2; | |
793 | i = vpd[index]; | |
794 | index += 1; | |
795 | index += i; | |
796 | Length -= (3 + i); | |
797 | } | |
798 | } | |
799 | finished = 0; | |
800 | break; | |
801 | case 0x78: | |
802 | finished = 1; | |
803 | break; | |
804 | default: | |
805 | index ++; | |
806 | break; | |
807 | } | |
74b72a59 | 808 | } |
dea3101e | 809 | |
810 | return(1); | |
811 | } | |
812 | ||
813 | static void | |
814 | lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) | |
815 | { | |
816 | lpfc_vpd_t *vp; | |
fefcb2b6 | 817 | uint16_t dev_id = phba->pcidev->device; |
74b72a59 | 818 | int max_speed; |
74b72a59 JW |
819 | struct { |
820 | char * name; | |
821 | int max_speed; | |
74b72a59 | 822 | char * bus; |
18a3b596 | 823 | } m = {"<Unknown>", 0, ""}; |
74b72a59 JW |
824 | |
825 | if (mdp && mdp[0] != '\0' | |
826 | && descp && descp[0] != '\0') | |
827 | return; | |
828 | ||
829 | if (phba->lmt & LMT_10Gb) | |
830 | max_speed = 10; | |
831 | else if (phba->lmt & LMT_8Gb) | |
832 | max_speed = 8; | |
833 | else if (phba->lmt & LMT_4Gb) | |
834 | max_speed = 4; | |
835 | else if (phba->lmt & LMT_2Gb) | |
836 | max_speed = 2; | |
837 | else | |
838 | max_speed = 1; | |
dea3101e | 839 | |
840 | vp = &phba->vpd; | |
dea3101e | 841 | |
e4adb204 | 842 | switch (dev_id) { |
06325e74 | 843 | case PCI_DEVICE_ID_FIREFLY: |
18a3b596 | 844 | m = (typeof(m)){"LP6000", max_speed, "PCI"}; |
06325e74 | 845 | break; |
dea3101e | 846 | case PCI_DEVICE_ID_SUPERFLY: |
847 | if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) | |
18a3b596 | 848 | m = (typeof(m)){"LP7000", max_speed, "PCI"}; |
dea3101e | 849 | else |
18a3b596 | 850 | m = (typeof(m)){"LP7000E", max_speed, "PCI"}; |
dea3101e | 851 | break; |
852 | case PCI_DEVICE_ID_DRAGONFLY: | |
18a3b596 | 853 | m = (typeof(m)){"LP8000", max_speed, "PCI"}; |
dea3101e | 854 | break; |
855 | case PCI_DEVICE_ID_CENTAUR: | |
856 | if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) | |
18a3b596 | 857 | m = (typeof(m)){"LP9002", max_speed, "PCI"}; |
dea3101e | 858 | else |
18a3b596 | 859 | m = (typeof(m)){"LP9000", max_speed, "PCI"}; |
dea3101e | 860 | break; |
861 | case PCI_DEVICE_ID_RFLY: | |
18a3b596 | 862 | m = (typeof(m)){"LP952", max_speed, "PCI"}; |
dea3101e | 863 | break; |
864 | case PCI_DEVICE_ID_PEGASUS: | |
18a3b596 | 865 | m = (typeof(m)){"LP9802", max_speed, "PCI-X"}; |
dea3101e | 866 | break; |
867 | case PCI_DEVICE_ID_THOR: | |
18a3b596 | 868 | m = (typeof(m)){"LP10000", max_speed, "PCI-X"}; |
dea3101e | 869 | break; |
870 | case PCI_DEVICE_ID_VIPER: | |
18a3b596 | 871 | m = (typeof(m)){"LPX1000", max_speed, "PCI-X"}; |
dea3101e | 872 | break; |
873 | case PCI_DEVICE_ID_PFLY: | |
18a3b596 | 874 | m = (typeof(m)){"LP982", max_speed, "PCI-X"}; |
dea3101e | 875 | break; |
876 | case PCI_DEVICE_ID_TFLY: | |
18a3b596 | 877 | m = (typeof(m)){"LP1050", max_speed, "PCI-X"}; |
dea3101e | 878 | break; |
879 | case PCI_DEVICE_ID_HELIOS: | |
18a3b596 | 880 | m = (typeof(m)){"LP11000", max_speed, "PCI-X2"}; |
dea3101e | 881 | break; |
e4adb204 | 882 | case PCI_DEVICE_ID_HELIOS_SCSP: |
18a3b596 | 883 | m = (typeof(m)){"LP11000-SP", max_speed, "PCI-X2"}; |
e4adb204 JSEC |
884 | break; |
885 | case PCI_DEVICE_ID_HELIOS_DCSP: | |
18a3b596 | 886 | m = (typeof(m)){"LP11002-SP", max_speed, "PCI-X2"}; |
e4adb204 JSEC |
887 | break; |
888 | case PCI_DEVICE_ID_NEPTUNE: | |
18a3b596 | 889 | m = (typeof(m)){"LPe1000", max_speed, "PCIe"}; |
e4adb204 JSEC |
890 | break; |
891 | case PCI_DEVICE_ID_NEPTUNE_SCSP: | |
18a3b596 | 892 | m = (typeof(m)){"LPe1000-SP", max_speed, "PCIe"}; |
e4adb204 JSEC |
893 | break; |
894 | case PCI_DEVICE_ID_NEPTUNE_DCSP: | |
18a3b596 | 895 | m = (typeof(m)){"LPe1002-SP", max_speed, "PCIe"}; |
e4adb204 | 896 | break; |
dea3101e | 897 | case PCI_DEVICE_ID_BMID: |
18a3b596 | 898 | m = (typeof(m)){"LP1150", max_speed, "PCI-X2"}; |
dea3101e | 899 | break; |
900 | case PCI_DEVICE_ID_BSMB: | |
18a3b596 | 901 | m = (typeof(m)){"LP111", max_speed, "PCI-X2"}; |
dea3101e | 902 | break; |
903 | case PCI_DEVICE_ID_ZEPHYR: | |
18a3b596 | 904 | m = (typeof(m)){"LPe11000", max_speed, "PCIe"}; |
dea3101e | 905 | break; |
e4adb204 | 906 | case PCI_DEVICE_ID_ZEPHYR_SCSP: |
18a3b596 | 907 | m = (typeof(m)){"LPe11000", max_speed, "PCIe"}; |
e4adb204 JSEC |
908 | break; |
909 | case PCI_DEVICE_ID_ZEPHYR_DCSP: | |
18a3b596 | 910 | m = (typeof(m)){"LPe11002-SP", max_speed, "PCIe"}; |
e4adb204 | 911 | break; |
dea3101e | 912 | case PCI_DEVICE_ID_ZMID: |
18a3b596 | 913 | m = (typeof(m)){"LPe1150", max_speed, "PCIe"}; |
dea3101e | 914 | break; |
915 | case PCI_DEVICE_ID_ZSMB: | |
18a3b596 | 916 | m = (typeof(m)){"LPe111", max_speed, "PCIe"}; |
dea3101e | 917 | break; |
918 | case PCI_DEVICE_ID_LP101: | |
18a3b596 | 919 | m = (typeof(m)){"LP101", max_speed, "PCI-X"}; |
dea3101e | 920 | break; |
921 | case PCI_DEVICE_ID_LP10000S: | |
18a3b596 | 922 | m = (typeof(m)){"LP10000-S", max_speed, "PCI"}; |
06325e74 | 923 | break; |
e4adb204 | 924 | case PCI_DEVICE_ID_LP11000S: |
18a3b596 JS |
925 | m = (typeof(m)){"LP11000-S", max_speed, |
926 | "PCI-X2"}; | |
927 | break; | |
e4adb204 | 928 | case PCI_DEVICE_ID_LPE11000S: |
18a3b596 JS |
929 | m = (typeof(m)){"LPe11000-S", max_speed, |
930 | "PCIe"}; | |
5cc36b3c JSEC |
931 | break; |
932 | default: | |
041976fb | 933 | m = (typeof(m)){ NULL }; |
e4adb204 | 934 | break; |
dea3101e | 935 | } |
74b72a59 JW |
936 | |
937 | if (mdp && mdp[0] == '\0') | |
938 | snprintf(mdp, 79,"%s", m.name); | |
939 | if (descp && descp[0] == '\0') | |
940 | snprintf(descp, 255, | |
18a3b596 JS |
941 | "Emulex %s %dGb %s Fibre Channel Adapter", |
942 | m.name, m.max_speed, m.bus); | |
dea3101e | 943 | } |
944 | ||
945 | /**************************************************/ | |
946 | /* lpfc_post_buffer */ | |
947 | /* */ | |
948 | /* This routine will post count buffers to the */ | |
949 | /* ring with the QUE_RING_BUF_CN command. This */ | |
950 | /* allows 3 buffers / command to be posted. */ | |
951 | /* Returns the number of buffers NOT posted. */ | |
952 | /**************************************************/ | |
953 | int | |
954 | lpfc_post_buffer(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, int cnt, | |
955 | int type) | |
956 | { | |
957 | IOCB_t *icmd; | |
0bd4ca25 | 958 | struct lpfc_iocbq *iocb; |
dea3101e | 959 | struct lpfc_dmabuf *mp1, *mp2; |
960 | ||
961 | cnt += pring->missbufcnt; | |
962 | ||
963 | /* While there are buffers to post */ | |
964 | while (cnt > 0) { | |
965 | /* Allocate buffer for command iocb */ | |
966 | spin_lock_irq(phba->host->host_lock); | |
0bd4ca25 | 967 | iocb = lpfc_sli_get_iocbq(phba); |
dea3101e | 968 | spin_unlock_irq(phba->host->host_lock); |
969 | if (iocb == NULL) { | |
970 | pring->missbufcnt = cnt; | |
971 | return cnt; | |
972 | } | |
dea3101e | 973 | icmd = &iocb->iocb; |
974 | ||
975 | /* 2 buffers can be posted per command */ | |
976 | /* Allocate buffer to post */ | |
977 | mp1 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); | |
978 | if (mp1) | |
979 | mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, | |
980 | &mp1->phys); | |
981 | if (mp1 == 0 || mp1->virt == 0) { | |
c9475cb0 | 982 | kfree(mp1); |
dea3101e | 983 | spin_lock_irq(phba->host->host_lock); |
604a3e30 | 984 | lpfc_sli_release_iocbq(phba, iocb); |
dea3101e | 985 | spin_unlock_irq(phba->host->host_lock); |
986 | pring->missbufcnt = cnt; | |
987 | return cnt; | |
988 | } | |
989 | ||
990 | INIT_LIST_HEAD(&mp1->list); | |
991 | /* Allocate buffer to post */ | |
992 | if (cnt > 1) { | |
993 | mp2 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); | |
994 | if (mp2) | |
995 | mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, | |
996 | &mp2->phys); | |
997 | if (mp2 == 0 || mp2->virt == 0) { | |
c9475cb0 | 998 | kfree(mp2); |
dea3101e | 999 | lpfc_mbuf_free(phba, mp1->virt, mp1->phys); |
1000 | kfree(mp1); | |
1001 | spin_lock_irq(phba->host->host_lock); | |
604a3e30 | 1002 | lpfc_sli_release_iocbq(phba, iocb); |
dea3101e | 1003 | spin_unlock_irq(phba->host->host_lock); |
1004 | pring->missbufcnt = cnt; | |
1005 | return cnt; | |
1006 | } | |
1007 | ||
1008 | INIT_LIST_HEAD(&mp2->list); | |
1009 | } else { | |
1010 | mp2 = NULL; | |
1011 | } | |
1012 | ||
1013 | icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys); | |
1014 | icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys); | |
1015 | icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE; | |
1016 | icmd->ulpBdeCount = 1; | |
1017 | cnt--; | |
1018 | if (mp2) { | |
1019 | icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys); | |
1020 | icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys); | |
1021 | icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE; | |
1022 | cnt--; | |
1023 | icmd->ulpBdeCount = 2; | |
1024 | } | |
1025 | ||
1026 | icmd->ulpCommand = CMD_QUE_RING_BUF64_CN; | |
1027 | icmd->ulpLe = 1; | |
1028 | ||
1029 | spin_lock_irq(phba->host->host_lock); | |
1030 | if (lpfc_sli_issue_iocb(phba, pring, iocb, 0) == IOCB_ERROR) { | |
1031 | lpfc_mbuf_free(phba, mp1->virt, mp1->phys); | |
1032 | kfree(mp1); | |
1033 | cnt++; | |
1034 | if (mp2) { | |
1035 | lpfc_mbuf_free(phba, mp2->virt, mp2->phys); | |
1036 | kfree(mp2); | |
1037 | cnt++; | |
1038 | } | |
604a3e30 | 1039 | lpfc_sli_release_iocbq(phba, iocb); |
dea3101e | 1040 | pring->missbufcnt = cnt; |
1041 | spin_unlock_irq(phba->host->host_lock); | |
1042 | return cnt; | |
1043 | } | |
1044 | spin_unlock_irq(phba->host->host_lock); | |
1045 | lpfc_sli_ringpostbuf_put(phba, pring, mp1); | |
1046 | if (mp2) { | |
1047 | lpfc_sli_ringpostbuf_put(phba, pring, mp2); | |
1048 | } | |
1049 | } | |
1050 | pring->missbufcnt = 0; | |
1051 | return 0; | |
1052 | } | |
1053 | ||
1054 | /************************************************************************/ | |
1055 | /* */ | |
1056 | /* lpfc_post_rcv_buf */ | |
1057 | /* This routine post initial rcv buffers to the configured rings */ | |
1058 | /* */ | |
1059 | /************************************************************************/ | |
1060 | static int | |
1061 | lpfc_post_rcv_buf(struct lpfc_hba * phba) | |
1062 | { | |
1063 | struct lpfc_sli *psli = &phba->sli; | |
1064 | ||
1065 | /* Ring 0, ELS / CT buffers */ | |
1066 | lpfc_post_buffer(phba, &psli->ring[LPFC_ELS_RING], LPFC_BUF_RING0, 1); | |
1067 | /* Ring 2 - FCP no buffers needed */ | |
1068 | ||
1069 | return 0; | |
1070 | } | |
1071 | ||
1072 | #define S(N,V) (((V)<<(N))|((V)>>(32-(N)))) | |
1073 | ||
1074 | /************************************************************************/ | |
1075 | /* */ | |
1076 | /* lpfc_sha_init */ | |
1077 | /* */ | |
1078 | /************************************************************************/ | |
1079 | static void | |
1080 | lpfc_sha_init(uint32_t * HashResultPointer) | |
1081 | { | |
1082 | HashResultPointer[0] = 0x67452301; | |
1083 | HashResultPointer[1] = 0xEFCDAB89; | |
1084 | HashResultPointer[2] = 0x98BADCFE; | |
1085 | HashResultPointer[3] = 0x10325476; | |
1086 | HashResultPointer[4] = 0xC3D2E1F0; | |
1087 | } | |
1088 | ||
1089 | /************************************************************************/ | |
1090 | /* */ | |
1091 | /* lpfc_sha_iterate */ | |
1092 | /* */ | |
1093 | /************************************************************************/ | |
1094 | static void | |
1095 | lpfc_sha_iterate(uint32_t * HashResultPointer, uint32_t * HashWorkingPointer) | |
1096 | { | |
1097 | int t; | |
1098 | uint32_t TEMP; | |
1099 | uint32_t A, B, C, D, E; | |
1100 | t = 16; | |
1101 | do { | |
1102 | HashWorkingPointer[t] = | |
1103 | S(1, | |
1104 | HashWorkingPointer[t - 3] ^ HashWorkingPointer[t - | |
1105 | 8] ^ | |
1106 | HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]); | |
1107 | } while (++t <= 79); | |
1108 | t = 0; | |
1109 | A = HashResultPointer[0]; | |
1110 | B = HashResultPointer[1]; | |
1111 | C = HashResultPointer[2]; | |
1112 | D = HashResultPointer[3]; | |
1113 | E = HashResultPointer[4]; | |
1114 | ||
1115 | do { | |
1116 | if (t < 20) { | |
1117 | TEMP = ((B & C) | ((~B) & D)) + 0x5A827999; | |
1118 | } else if (t < 40) { | |
1119 | TEMP = (B ^ C ^ D) + 0x6ED9EBA1; | |
1120 | } else if (t < 60) { | |
1121 | TEMP = ((B & C) | (B & D) | (C & D)) + 0x8F1BBCDC; | |
1122 | } else { | |
1123 | TEMP = (B ^ C ^ D) + 0xCA62C1D6; | |
1124 | } | |
1125 | TEMP += S(5, A) + E + HashWorkingPointer[t]; | |
1126 | E = D; | |
1127 | D = C; | |
1128 | C = S(30, B); | |
1129 | B = A; | |
1130 | A = TEMP; | |
1131 | } while (++t <= 79); | |
1132 | ||
1133 | HashResultPointer[0] += A; | |
1134 | HashResultPointer[1] += B; | |
1135 | HashResultPointer[2] += C; | |
1136 | HashResultPointer[3] += D; | |
1137 | HashResultPointer[4] += E; | |
1138 | ||
1139 | } | |
1140 | ||
1141 | /************************************************************************/ | |
1142 | /* */ | |
1143 | /* lpfc_challenge_key */ | |
1144 | /* */ | |
1145 | /************************************************************************/ | |
1146 | static void | |
1147 | lpfc_challenge_key(uint32_t * RandomChallenge, uint32_t * HashWorking) | |
1148 | { | |
1149 | *HashWorking = (*RandomChallenge ^ *HashWorking); | |
1150 | } | |
1151 | ||
1152 | /************************************************************************/ | |
1153 | /* */ | |
1154 | /* lpfc_hba_init */ | |
1155 | /* */ | |
1156 | /************************************************************************/ | |
1157 | void | |
1158 | lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit) | |
1159 | { | |
1160 | int t; | |
1161 | uint32_t *HashWorking; | |
1162 | uint32_t *pwwnn = phba->wwnn; | |
1163 | ||
1164 | HashWorking = kmalloc(80 * sizeof(uint32_t), GFP_KERNEL); | |
1165 | if (!HashWorking) | |
1166 | return; | |
1167 | ||
1168 | memset(HashWorking, 0, (80 * sizeof(uint32_t))); | |
1169 | HashWorking[0] = HashWorking[78] = *pwwnn++; | |
1170 | HashWorking[1] = HashWorking[79] = *pwwnn; | |
1171 | ||
1172 | for (t = 0; t < 7; t++) | |
1173 | lpfc_challenge_key(phba->RandomData + t, HashWorking + t); | |
1174 | ||
1175 | lpfc_sha_init(hbainit); | |
1176 | lpfc_sha_iterate(hbainit, HashWorking); | |
1177 | kfree(HashWorking); | |
1178 | } | |
1179 | ||
1180 | static void | |
1dcb58e5 | 1181 | lpfc_cleanup(struct lpfc_hba * phba) |
dea3101e | 1182 | { |
1183 | struct lpfc_nodelist *ndlp, *next_ndlp; | |
1184 | ||
1185 | /* clean up phba - lpfc specific */ | |
1186 | lpfc_can_disctmo(phba); | |
1187 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpunmap_list, | |
1188 | nlp_listp) { | |
1189 | lpfc_nlp_remove(phba, ndlp); | |
1190 | } | |
1191 | ||
1192 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpmap_list, | |
1193 | nlp_listp) { | |
1194 | lpfc_nlp_remove(phba, ndlp); | |
1195 | } | |
1196 | ||
1197 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list, | |
1198 | nlp_listp) { | |
de0c5b32 | 1199 | lpfc_drop_node(phba, ndlp); |
dea3101e | 1200 | } |
1201 | ||
1202 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list, | |
1203 | nlp_listp) { | |
1204 | lpfc_nlp_remove(phba, ndlp); | |
1205 | } | |
1206 | ||
1207 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list, | |
1208 | nlp_listp) { | |
1209 | lpfc_nlp_remove(phba, ndlp); | |
1210 | } | |
1211 | ||
1212 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_reglogin_list, | |
1213 | nlp_listp) { | |
1214 | lpfc_nlp_remove(phba, ndlp); | |
1215 | } | |
1216 | ||
1217 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_prli_list, | |
1218 | nlp_listp) { | |
1219 | lpfc_nlp_remove(phba, ndlp); | |
1220 | } | |
1221 | ||
1222 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, | |
1223 | nlp_listp) { | |
1224 | lpfc_nlp_remove(phba, ndlp); | |
1225 | } | |
1226 | ||
1227 | INIT_LIST_HEAD(&phba->fc_nlpmap_list); | |
1228 | INIT_LIST_HEAD(&phba->fc_nlpunmap_list); | |
1229 | INIT_LIST_HEAD(&phba->fc_unused_list); | |
1230 | INIT_LIST_HEAD(&phba->fc_plogi_list); | |
1231 | INIT_LIST_HEAD(&phba->fc_adisc_list); | |
1232 | INIT_LIST_HEAD(&phba->fc_reglogin_list); | |
1233 | INIT_LIST_HEAD(&phba->fc_prli_list); | |
1234 | INIT_LIST_HEAD(&phba->fc_npr_list); | |
1235 | ||
1236 | phba->fc_map_cnt = 0; | |
1237 | phba->fc_unmap_cnt = 0; | |
1238 | phba->fc_plogi_cnt = 0; | |
1239 | phba->fc_adisc_cnt = 0; | |
1240 | phba->fc_reglogin_cnt = 0; | |
1241 | phba->fc_prli_cnt = 0; | |
1242 | phba->fc_npr_cnt = 0; | |
1243 | phba->fc_unused_cnt= 0; | |
1244 | return; | |
1245 | } | |
1246 | ||
1247 | static void | |
1248 | lpfc_establish_link_tmo(unsigned long ptr) | |
1249 | { | |
1250 | struct lpfc_hba *phba = (struct lpfc_hba *)ptr; | |
1251 | unsigned long iflag; | |
1252 | ||
1253 | ||
1254 | /* Re-establishing Link, timer expired */ | |
1255 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | |
1256 | "%d:1300 Re-establishing Link, timer expired " | |
1257 | "Data: x%x x%x\n", | |
1258 | phba->brd_no, phba->fc_flag, phba->hba_state); | |
1259 | spin_lock_irqsave(phba->host->host_lock, iflag); | |
1260 | phba->fc_flag &= ~FC_ESTABLISH_LINK; | |
1261 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | |
1262 | } | |
1263 | ||
1264 | static int | |
1265 | lpfc_stop_timer(struct lpfc_hba * phba) | |
1266 | { | |
1267 | struct lpfc_sli *psli = &phba->sli; | |
1268 | ||
875fbdfe | 1269 | del_timer_sync(&phba->fcp_poll_timer); |
dea3101e | 1270 | del_timer_sync(&phba->fc_estabtmo); |
1271 | del_timer_sync(&phba->fc_disctmo); | |
1272 | del_timer_sync(&phba->fc_fdmitmo); | |
1273 | del_timer_sync(&phba->els_tmofunc); | |
1274 | psli = &phba->sli; | |
1275 | del_timer_sync(&psli->mbox_tmo); | |
1276 | return(1); | |
1277 | } | |
1278 | ||
1279 | int | |
1280 | lpfc_online(struct lpfc_hba * phba) | |
1281 | { | |
1282 | if (!phba) | |
1283 | return 0; | |
1284 | ||
1285 | if (!(phba->fc_flag & FC_OFFLINE_MODE)) | |
1286 | return 0; | |
1287 | ||
1288 | lpfc_printf_log(phba, | |
1289 | KERN_WARNING, | |
1290 | LOG_INIT, | |
1291 | "%d:0458 Bring Adapter online\n", | |
1292 | phba->brd_no); | |
1293 | ||
46fa311e JS |
1294 | lpfc_block_mgmt_io(phba); |
1295 | ||
1296 | if (!lpfc_sli_queue_setup(phba)) { | |
1297 | lpfc_unblock_mgmt_io(phba); | |
dea3101e | 1298 | return 1; |
46fa311e | 1299 | } |
dea3101e | 1300 | |
46fa311e JS |
1301 | if (lpfc_sli_hba_setup(phba)) { /* Initialize the HBA */ |
1302 | lpfc_unblock_mgmt_io(phba); | |
dea3101e | 1303 | return 1; |
46fa311e | 1304 | } |
dea3101e | 1305 | |
1306 | spin_lock_irq(phba->host->host_lock); | |
1307 | phba->fc_flag &= ~FC_OFFLINE_MODE; | |
1308 | spin_unlock_irq(phba->host->host_lock); | |
1309 | ||
46fa311e | 1310 | lpfc_unblock_mgmt_io(phba); |
dea3101e | 1311 | return 0; |
1312 | } | |
1313 | ||
46fa311e JS |
1314 | void |
1315 | lpfc_block_mgmt_io(struct lpfc_hba * phba) | |
dea3101e | 1316 | { |
dea3101e | 1317 | unsigned long iflag; |
dea3101e | 1318 | |
46fa311e JS |
1319 | spin_lock_irqsave(phba->host->host_lock, iflag); |
1320 | phba->fc_flag |= FC_BLOCK_MGMT_IO; | |
1321 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | |
1322 | } | |
1323 | ||
1324 | void | |
1325 | lpfc_unblock_mgmt_io(struct lpfc_hba * phba) | |
1326 | { | |
1327 | unsigned long iflag; | |
1328 | ||
1329 | spin_lock_irqsave(phba->host->host_lock, iflag); | |
1330 | phba->fc_flag &= ~FC_BLOCK_MGMT_IO; | |
1331 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | |
1332 | } | |
1333 | ||
1334 | void | |
1335 | lpfc_offline_prep(struct lpfc_hba * phba) | |
1336 | { | |
1337 | struct lpfc_nodelist *ndlp, *next_ndlp; | |
1338 | struct list_head *listp, *node_list[7]; | |
1339 | int i; | |
dea3101e | 1340 | |
1341 | if (phba->fc_flag & FC_OFFLINE_MODE) | |
46fa311e | 1342 | return; |
dea3101e | 1343 | |
46fa311e | 1344 | lpfc_block_mgmt_io(phba); |
dea3101e | 1345 | |
1346 | lpfc_linkdown(phba); | |
1347 | ||
46fa311e JS |
1348 | /* Issue an unreg_login to all nodes */ |
1349 | node_list[0] = &phba->fc_npr_list; /* MUST do this list first */ | |
1350 | node_list[1] = &phba->fc_nlpmap_list; | |
1351 | node_list[2] = &phba->fc_nlpunmap_list; | |
1352 | node_list[3] = &phba->fc_prli_list; | |
1353 | node_list[4] = &phba->fc_reglogin_list; | |
1354 | node_list[5] = &phba->fc_adisc_list; | |
1355 | node_list[6] = &phba->fc_plogi_list; | |
1356 | for (i = 0; i < 7; i++) { | |
1357 | listp = node_list[i]; | |
1358 | if (list_empty(listp)) | |
1359 | continue; | |
1360 | ||
1361 | list_for_each_entry_safe(ndlp, next_ndlp, listp, nlp_listp) | |
1362 | lpfc_unreg_rpi(phba, ndlp); | |
dea3101e | 1363 | } |
1364 | ||
46fa311e JS |
1365 | lpfc_sli_flush_mbox_queue(phba); |
1366 | } | |
1367 | ||
1368 | void | |
1369 | lpfc_offline(struct lpfc_hba * phba) | |
1370 | { | |
1371 | unsigned long iflag; | |
1372 | ||
1373 | if (phba->fc_flag & FC_OFFLINE_MODE) | |
1374 | return; | |
688a8863 | 1375 | |
dea3101e | 1376 | /* stop all timers associated with this hba */ |
1377 | lpfc_stop_timer(phba); | |
1378 | phba->work_hba_events = 0; | |
33ccf8d1 | 1379 | phba->work_ha = 0; |
dea3101e | 1380 | |
1381 | lpfc_printf_log(phba, | |
1382 | KERN_WARNING, | |
1383 | LOG_INIT, | |
1384 | "%d:0460 Bring Adapter offline\n", | |
1385 | phba->brd_no); | |
1386 | ||
1387 | /* Bring down the SLI Layer and cleanup. The HBA is offline | |
1388 | now. */ | |
1389 | lpfc_sli_hba_down(phba); | |
1dcb58e5 | 1390 | lpfc_cleanup(phba); |
dea3101e | 1391 | spin_lock_irqsave(phba->host->host_lock, iflag); |
1392 | phba->fc_flag |= FC_OFFLINE_MODE; | |
1393 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | |
dea3101e | 1394 | } |
1395 | ||
1396 | /****************************************************************************** | |
1397 | * Function name: lpfc_scsi_free | |
1398 | * | |
1399 | * Description: Called from lpfc_pci_remove_one free internal driver resources | |
1400 | * | |
1401 | ******************************************************************************/ | |
1402 | static int | |
1403 | lpfc_scsi_free(struct lpfc_hba * phba) | |
1404 | { | |
1405 | struct lpfc_scsi_buf *sb, *sb_next; | |
1406 | struct lpfc_iocbq *io, *io_next; | |
1407 | ||
1408 | spin_lock_irq(phba->host->host_lock); | |
1409 | /* Release all the lpfc_scsi_bufs maintained by this host. */ | |
1410 | list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list, list) { | |
1411 | list_del(&sb->list); | |
1412 | pci_pool_free(phba->lpfc_scsi_dma_buf_pool, sb->data, | |
1413 | sb->dma_handle); | |
1414 | kfree(sb); | |
1415 | phba->total_scsi_bufs--; | |
1416 | } | |
1417 | ||
1418 | /* Release all the lpfc_iocbq entries maintained by this host. */ | |
1419 | list_for_each_entry_safe(io, io_next, &phba->lpfc_iocb_list, list) { | |
1420 | list_del(&io->list); | |
1421 | kfree(io); | |
1422 | phba->total_iocbq_bufs--; | |
1423 | } | |
1424 | ||
1425 | spin_unlock_irq(phba->host->host_lock); | |
1426 | ||
1427 | return 0; | |
1428 | } | |
1429 | ||
1430 | ||
1431 | static int __devinit | |
1432 | lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |
1433 | { | |
1434 | struct Scsi_Host *host; | |
1435 | struct lpfc_hba *phba; | |
1436 | struct lpfc_sli *psli; | |
1437 | struct lpfc_iocbq *iocbq_entry = NULL, *iocbq_next = NULL; | |
1438 | unsigned long bar0map_len, bar2map_len; | |
1439 | int error = -ENODEV, retval; | |
1440 | int i; | |
604a3e30 | 1441 | uint16_t iotag; |
dea3101e | 1442 | |
1443 | if (pci_enable_device(pdev)) | |
1444 | goto out; | |
1445 | if (pci_request_regions(pdev, LPFC_DRIVER_NAME)) | |
1446 | goto out_disable_device; | |
1447 | ||
f888ba3c | 1448 | host = scsi_host_alloc(&lpfc_template, sizeof (struct lpfc_hba)); |
dea3101e | 1449 | if (!host) |
1450 | goto out_release_regions; | |
1451 | ||
1452 | phba = (struct lpfc_hba*)host->hostdata; | |
1453 | memset(phba, 0, sizeof (struct lpfc_hba)); | |
dea3101e | 1454 | phba->host = host; |
1455 | ||
1456 | phba->fc_flag |= FC_LOADING; | |
1457 | phba->pcidev = pdev; | |
1458 | ||
1459 | /* Assign an unused board number */ | |
1460 | if (!idr_pre_get(&lpfc_hba_index, GFP_KERNEL)) | |
1461 | goto out_put_host; | |
1462 | ||
1463 | error = idr_get_new(&lpfc_hba_index, NULL, &phba->brd_no); | |
1464 | if (error) | |
1465 | goto out_put_host; | |
1466 | ||
1467 | host->unique_id = phba->brd_no; | |
dea3101e | 1468 | |
1469 | /* Initialize timers used by driver */ | |
1470 | init_timer(&phba->fc_estabtmo); | |
1471 | phba->fc_estabtmo.function = lpfc_establish_link_tmo; | |
1472 | phba->fc_estabtmo.data = (unsigned long)phba; | |
1473 | init_timer(&phba->fc_disctmo); | |
1474 | phba->fc_disctmo.function = lpfc_disc_timeout; | |
1475 | phba->fc_disctmo.data = (unsigned long)phba; | |
1476 | ||
1477 | init_timer(&phba->fc_fdmitmo); | |
1478 | phba->fc_fdmitmo.function = lpfc_fdmi_tmo; | |
1479 | phba->fc_fdmitmo.data = (unsigned long)phba; | |
1480 | init_timer(&phba->els_tmofunc); | |
1481 | phba->els_tmofunc.function = lpfc_els_timeout; | |
1482 | phba->els_tmofunc.data = (unsigned long)phba; | |
1483 | psli = &phba->sli; | |
1484 | init_timer(&psli->mbox_tmo); | |
1485 | psli->mbox_tmo.function = lpfc_mbox_timeout; | |
1486 | psli->mbox_tmo.data = (unsigned long)phba; | |
1487 | ||
875fbdfe JSEC |
1488 | init_timer(&phba->fcp_poll_timer); |
1489 | phba->fcp_poll_timer.function = lpfc_poll_timeout; | |
1490 | phba->fcp_poll_timer.data = (unsigned long)phba; | |
1491 | ||
dea3101e | 1492 | /* |
1493 | * Get all the module params for configuring this host and then | |
1494 | * establish the host parameters. | |
1495 | */ | |
1496 | lpfc_get_cfgparam(phba); | |
1497 | ||
1498 | host->max_id = LPFC_MAX_TARGET; | |
1499 | host->max_lun = phba->cfg_max_luns; | |
1500 | host->this_id = -1; | |
1501 | ||
1502 | /* Initialize all internally managed lists. */ | |
1503 | INIT_LIST_HEAD(&phba->fc_nlpmap_list); | |
1504 | INIT_LIST_HEAD(&phba->fc_nlpunmap_list); | |
1505 | INIT_LIST_HEAD(&phba->fc_unused_list); | |
1506 | INIT_LIST_HEAD(&phba->fc_plogi_list); | |
1507 | INIT_LIST_HEAD(&phba->fc_adisc_list); | |
1508 | INIT_LIST_HEAD(&phba->fc_reglogin_list); | |
1509 | INIT_LIST_HEAD(&phba->fc_prli_list); | |
1510 | INIT_LIST_HEAD(&phba->fc_npr_list); | |
1511 | ||
1512 | ||
1513 | pci_set_master(pdev); | |
1514 | retval = pci_set_mwi(pdev); | |
1515 | if (retval) | |
1516 | dev_printk(KERN_WARNING, &pdev->dev, | |
1517 | "Warning: pci_set_mwi returned %d\n", retval); | |
1518 | ||
1519 | if (pci_set_dma_mask(phba->pcidev, DMA_64BIT_MASK) != 0) | |
1520 | if (pci_set_dma_mask(phba->pcidev, DMA_32BIT_MASK) != 0) | |
1521 | goto out_idr_remove; | |
1522 | ||
1523 | /* | |
1524 | * Get the bus address of Bar0 and Bar2 and the number of bytes | |
1525 | * required by each mapping. | |
1526 | */ | |
1527 | phba->pci_bar0_map = pci_resource_start(phba->pcidev, 0); | |
1528 | bar0map_len = pci_resource_len(phba->pcidev, 0); | |
1529 | ||
1530 | phba->pci_bar2_map = pci_resource_start(phba->pcidev, 2); | |
1531 | bar2map_len = pci_resource_len(phba->pcidev, 2); | |
1532 | ||
901a920f | 1533 | /* Map HBA SLIM to a kernel virtual address. */ |
dea3101e | 1534 | phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); |
901a920f JW |
1535 | if (!phba->slim_memmap_p) { |
1536 | error = -ENODEV; | |
1537 | dev_printk(KERN_ERR, &pdev->dev, | |
1538 | "ioremap failed for SLIM memory.\n"); | |
1539 | goto out_idr_remove; | |
1540 | } | |
1541 | ||
1542 | /* Map HBA Control Registers to a kernel virtual address. */ | |
dea3101e | 1543 | phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); |
901a920f JW |
1544 | if (!phba->ctrl_regs_memmap_p) { |
1545 | error = -ENODEV; | |
1546 | dev_printk(KERN_ERR, &pdev->dev, | |
1547 | "ioremap failed for HBA control registers.\n"); | |
1548 | goto out_iounmap_slim; | |
1549 | } | |
dea3101e | 1550 | |
1551 | /* Allocate memory for SLI-2 structures */ | |
1552 | phba->slim2p = dma_alloc_coherent(&phba->pcidev->dev, SLI2_SLIM_SIZE, | |
1553 | &phba->slim2p_mapping, GFP_KERNEL); | |
1554 | if (!phba->slim2p) | |
1555 | goto out_iounmap; | |
1556 | ||
f91b392c | 1557 | memset(phba->slim2p, 0, SLI2_SLIM_SIZE); |
dea3101e | 1558 | |
1559 | /* Initialize the SLI Layer to run with lpfc HBAs. */ | |
1560 | lpfc_sli_setup(phba); | |
1561 | lpfc_sli_queue_setup(phba); | |
1562 | ||
1563 | error = lpfc_mem_alloc(phba); | |
1564 | if (error) | |
1565 | goto out_free_slim; | |
1566 | ||
1567 | /* Initialize and populate the iocb list per host. */ | |
1568 | INIT_LIST_HEAD(&phba->lpfc_iocb_list); | |
1569 | for (i = 0; i < LPFC_IOCB_LIST_CNT; i++) { | |
1570 | iocbq_entry = kmalloc(sizeof(struct lpfc_iocbq), GFP_KERNEL); | |
1571 | if (iocbq_entry == NULL) { | |
1572 | printk(KERN_ERR "%s: only allocated %d iocbs of " | |
1573 | "expected %d count. Unloading driver.\n", | |
1574 | __FUNCTION__, i, LPFC_IOCB_LIST_CNT); | |
1575 | error = -ENOMEM; | |
1576 | goto out_free_iocbq; | |
1577 | } | |
1578 | ||
1579 | memset(iocbq_entry, 0, sizeof(struct lpfc_iocbq)); | |
604a3e30 JB |
1580 | iotag = lpfc_sli_next_iotag(phba, iocbq_entry); |
1581 | if (iotag == 0) { | |
1582 | kfree (iocbq_entry); | |
1583 | printk(KERN_ERR "%s: failed to allocate IOTAG. " | |
1584 | "Unloading driver.\n", | |
1585 | __FUNCTION__); | |
1586 | error = -ENOMEM; | |
1587 | goto out_free_iocbq; | |
1588 | } | |
dea3101e | 1589 | spin_lock_irq(phba->host->host_lock); |
1590 | list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); | |
1591 | phba->total_iocbq_bufs++; | |
1592 | spin_unlock_irq(phba->host->host_lock); | |
1593 | } | |
1594 | ||
1595 | /* Initialize HBA structure */ | |
1596 | phba->fc_edtov = FF_DEF_EDTOV; | |
1597 | phba->fc_ratov = FF_DEF_RATOV; | |
1598 | phba->fc_altov = FF_DEF_ALTOV; | |
1599 | phba->fc_arbtov = FF_DEF_ARBTOV; | |
1600 | ||
1601 | INIT_LIST_HEAD(&phba->work_list); | |
1602 | phba->work_ha_mask = (HA_ERATT|HA_MBATT|HA_LATT); | |
1603 | phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); | |
1604 | ||
1605 | /* Startup the kernel thread for this host adapter. */ | |
1606 | phba->worker_thread = kthread_run(lpfc_do_work, phba, | |
1607 | "lpfc_worker_%d", phba->brd_no); | |
1608 | if (IS_ERR(phba->worker_thread)) { | |
1609 | error = PTR_ERR(phba->worker_thread); | |
1610 | goto out_free_iocbq; | |
1611 | } | |
1612 | ||
8f6d98d2 JS |
1613 | /* |
1614 | * Set initial can_queue value since 0 is no longer supported and | |
1615 | * scsi_add_host will fail. This will be adjusted later based on the | |
1616 | * max xri value determined in hba setup. | |
1617 | */ | |
dea3101e | 1618 | host->can_queue = phba->cfg_hba_queue_depth - 10; |
1619 | ||
1620 | /* Tell the midlayer we support 16 byte commands */ | |
1621 | host->max_cmd_len = 16; | |
1622 | ||
1623 | /* Initialize the list of scsi buffers used by driver for scsi IO. */ | |
875fbdfe | 1624 | spin_lock_init(&phba->scsi_buf_list_lock); |
dea3101e | 1625 | INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list); |
1626 | ||
1627 | host->transportt = lpfc_transport_template; | |
dea3101e | 1628 | pci_set_drvdata(pdev, host); |
1629 | error = scsi_add_host(host, &pdev->dev); | |
1630 | if (error) | |
1631 | goto out_kthread_stop; | |
1632 | ||
1633 | error = lpfc_alloc_sysfs_attr(phba); | |
1634 | if (error) | |
defbcf11 | 1635 | goto out_remove_host; |
dea3101e | 1636 | |
4ff43246 JS |
1637 | if (phba->cfg_use_msi) { |
1638 | error = pci_enable_msi(phba->pcidev); | |
1639 | if (error) | |
1640 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "%d:0452 " | |
1641 | "Enable MSI failed, continuing with " | |
1642 | "IRQ\n", phba->brd_no); | |
1643 | } | |
1644 | ||
1d6f359a | 1645 | error = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED, |
dea3101e | 1646 | LPFC_DRIVER_NAME, phba); |
1647 | if (error) { | |
1648 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
1649 | "%d:0451 Enable interrupt handler failed\n", | |
1650 | phba->brd_no); | |
1651 | goto out_free_sysfs_attr; | |
1652 | } | |
1653 | phba->MBslimaddr = phba->slim_memmap_p; | |
1654 | phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; | |
1655 | phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; | |
1656 | phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; | |
1657 | phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; | |
1658 | ||
1659 | error = lpfc_sli_hba_setup(phba); | |
defbcf11 JS |
1660 | if (error) { |
1661 | error = -ENODEV; | |
dea3101e | 1662 | goto out_free_irq; |
defbcf11 | 1663 | } |
dea3101e | 1664 | |
8f6d98d2 JS |
1665 | /* |
1666 | * hba setup may have changed the hba_queue_depth so we need to adjust | |
1667 | * the value of can_queue. | |
1668 | */ | |
1669 | host->can_queue = phba->cfg_hba_queue_depth - 10; | |
1670 | ||
ce8b3ce5 JS |
1671 | lpfc_discovery_wait(phba); |
1672 | ||
875fbdfe JSEC |
1673 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) { |
1674 | spin_lock_irq(phba->host->host_lock); | |
1675 | lpfc_poll_start_timer(phba); | |
1676 | spin_unlock_irq(phba->host->host_lock); | |
1677 | } | |
1678 | ||
dea3101e | 1679 | /* |
1680 | * set fixed host attributes | |
1681 | * Must done after lpfc_sli_hba_setup() | |
1682 | */ | |
1683 | ||
68ce1eb5 AM |
1684 | fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.u.wwn); |
1685 | fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.u.wwn); | |
dea3101e | 1686 | fc_host_supported_classes(host) = FC_COS_CLASS3; |
1687 | ||
1688 | memset(fc_host_supported_fc4s(host), 0, | |
1689 | sizeof(fc_host_supported_fc4s(host))); | |
1690 | fc_host_supported_fc4s(host)[2] = 1; | |
1691 | fc_host_supported_fc4s(host)[7] = 1; | |
1692 | ||
1693 | lpfc_get_hba_sym_node_name(phba, fc_host_symbolic_name(host)); | |
1694 | ||
1695 | fc_host_supported_speeds(host) = 0; | |
74b72a59 | 1696 | if (phba->lmt & LMT_10Gb) |
dea3101e | 1697 | fc_host_supported_speeds(host) |= FC_PORTSPEED_10GBIT; |
74b72a59 | 1698 | if (phba->lmt & LMT_4Gb) |
dea3101e | 1699 | fc_host_supported_speeds(host) |= FC_PORTSPEED_4GBIT; |
74b72a59 | 1700 | if (phba->lmt & LMT_2Gb) |
dea3101e | 1701 | fc_host_supported_speeds(host) |= FC_PORTSPEED_2GBIT; |
74b72a59 JW |
1702 | if (phba->lmt & LMT_1Gb) |
1703 | fc_host_supported_speeds(host) |= FC_PORTSPEED_1GBIT; | |
dea3101e | 1704 | |
1705 | fc_host_maxframe_size(host) = | |
1706 | ((((uint32_t) phba->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) | | |
1707 | (uint32_t) phba->fc_sparam.cmn.bbRcvSizeLsb); | |
1708 | ||
1709 | /* This value is also unchanging */ | |
1710 | memset(fc_host_active_fc4s(host), 0, | |
1711 | sizeof(fc_host_active_fc4s(host))); | |
1712 | fc_host_active_fc4s(host)[2] = 1; | |
1713 | fc_host_active_fc4s(host)[7] = 1; | |
1714 | ||
1715 | spin_lock_irq(phba->host->host_lock); | |
1716 | phba->fc_flag &= ~FC_LOADING; | |
1717 | spin_unlock_irq(phba->host->host_lock); | |
1718 | return 0; | |
1719 | ||
1720 | out_free_irq: | |
1721 | lpfc_stop_timer(phba); | |
1722 | phba->work_hba_events = 0; | |
1723 | free_irq(phba->pcidev->irq, phba); | |
4ff43246 | 1724 | pci_disable_msi(phba->pcidev); |
dea3101e | 1725 | out_free_sysfs_attr: |
1726 | lpfc_free_sysfs_attr(phba); | |
defbcf11 JS |
1727 | out_remove_host: |
1728 | fc_remove_host(phba->host); | |
1729 | scsi_remove_host(phba->host); | |
dea3101e | 1730 | out_kthread_stop: |
1731 | kthread_stop(phba->worker_thread); | |
1732 | out_free_iocbq: | |
1733 | list_for_each_entry_safe(iocbq_entry, iocbq_next, | |
1734 | &phba->lpfc_iocb_list, list) { | |
1735 | spin_lock_irq(phba->host->host_lock); | |
1736 | kfree(iocbq_entry); | |
1737 | phba->total_iocbq_bufs--; | |
1738 | spin_unlock_irq(phba->host->host_lock); | |
1739 | } | |
1740 | lpfc_mem_free(phba); | |
1741 | out_free_slim: | |
1742 | dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, phba->slim2p, | |
1743 | phba->slim2p_mapping); | |
1744 | out_iounmap: | |
1745 | iounmap(phba->ctrl_regs_memmap_p); | |
901a920f | 1746 | out_iounmap_slim: |
dea3101e | 1747 | iounmap(phba->slim_memmap_p); |
1748 | out_idr_remove: | |
1749 | idr_remove(&lpfc_hba_index, phba->brd_no); | |
1750 | out_put_host: | |
defbcf11 | 1751 | phba->host = NULL; |
dea3101e | 1752 | scsi_host_put(host); |
1753 | out_release_regions: | |
1754 | pci_release_regions(pdev); | |
1755 | out_disable_device: | |
1756 | pci_disable_device(pdev); | |
1757 | out: | |
defbcf11 | 1758 | pci_set_drvdata(pdev, NULL); |
dea3101e | 1759 | return error; |
1760 | } | |
1761 | ||
1762 | static void __devexit | |
1763 | lpfc_pci_remove_one(struct pci_dev *pdev) | |
1764 | { | |
1765 | struct Scsi_Host *host = pci_get_drvdata(pdev); | |
7f0b5b19 | 1766 | struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; |
dea3101e | 1767 | unsigned long iflag; |
1768 | ||
1769 | lpfc_free_sysfs_attr(phba); | |
1770 | ||
1771 | spin_lock_irqsave(phba->host->host_lock, iflag); | |
1772 | phba->fc_flag |= FC_UNLOADING; | |
1773 | ||
1774 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | |
1775 | ||
1776 | fc_remove_host(phba->host); | |
1777 | scsi_remove_host(phba->host); | |
1778 | ||
1779 | kthread_stop(phba->worker_thread); | |
1780 | ||
1781 | /* | |
1782 | * Bring down the SLI Layer. This step disable all interrupts, | |
1783 | * clears the rings, discards all mailbox commands, and resets | |
1784 | * the HBA. | |
1785 | */ | |
1786 | lpfc_sli_hba_down(phba); | |
41415862 | 1787 | lpfc_sli_brdrestart(phba); |
dea3101e | 1788 | |
1789 | /* Release the irq reservation */ | |
1790 | free_irq(phba->pcidev->irq, phba); | |
4ff43246 | 1791 | pci_disable_msi(phba->pcidev); |
dea3101e | 1792 | |
1dcb58e5 | 1793 | lpfc_cleanup(phba); |
dea3101e | 1794 | lpfc_stop_timer(phba); |
1795 | phba->work_hba_events = 0; | |
1796 | ||
1797 | /* | |
1798 | * Call scsi_free before mem_free since scsi bufs are released to their | |
1799 | * corresponding pools here. | |
1800 | */ | |
1801 | lpfc_scsi_free(phba); | |
1802 | lpfc_mem_free(phba); | |
1803 | ||
1804 | /* Free resources associated with SLI2 interface */ | |
1805 | dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, | |
1806 | phba->slim2p, phba->slim2p_mapping); | |
1807 | ||
1808 | /* unmap adapter SLIM and Control Registers */ | |
1809 | iounmap(phba->ctrl_regs_memmap_p); | |
1810 | iounmap(phba->slim_memmap_p); | |
1811 | ||
1812 | pci_release_regions(phba->pcidev); | |
1813 | pci_disable_device(phba->pcidev); | |
1814 | ||
1815 | idr_remove(&lpfc_hba_index, phba->brd_no); | |
1816 | scsi_host_put(phba->host); | |
1817 | ||
1818 | pci_set_drvdata(pdev, NULL); | |
1819 | } | |
1820 | ||
8d63f375 LV |
1821 | /** |
1822 | * lpfc_io_error_detected - called when PCI error is detected | |
1823 | * @pdev: Pointer to PCI device | |
1824 | * @state: The current pci conneection state | |
1825 | * | |
1826 | * This function is called after a PCI bus error affecting | |
1827 | * this device has been detected. | |
1828 | */ | |
1829 | static pci_ers_result_t lpfc_io_error_detected(struct pci_dev *pdev, | |
1830 | pci_channel_state_t state) | |
1831 | { | |
1832 | struct Scsi_Host *host = pci_get_drvdata(pdev); | |
1833 | struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; | |
1834 | struct lpfc_sli *psli = &phba->sli; | |
1835 | struct lpfc_sli_ring *pring; | |
1836 | ||
5daa49ef | 1837 | if (state == pci_channel_io_perm_failure) |
8d63f375 | 1838 | return PCI_ERS_RESULT_DISCONNECT; |
5daa49ef | 1839 | |
8d63f375 LV |
1840 | pci_disable_device(pdev); |
1841 | /* | |
1842 | * There may be I/Os dropped by the firmware. | |
1843 | * Error iocb (I/O) on txcmplq and let the SCSI layer | |
1844 | * retry it after re-establishing link. | |
1845 | */ | |
1846 | pring = &psli->ring[psli->fcp_ring]; | |
1847 | lpfc_sli_abort_iocb_ring(phba, pring); | |
1848 | ||
1849 | /* Request a slot reset. */ | |
1850 | return PCI_ERS_RESULT_NEED_RESET; | |
1851 | } | |
1852 | ||
1853 | /** | |
1854 | * lpfc_io_slot_reset - called after the pci bus has been reset. | |
1855 | * @pdev: Pointer to PCI device | |
1856 | * | |
1857 | * Restart the card from scratch, as if from a cold-boot. | |
1858 | */ | |
1859 | static pci_ers_result_t lpfc_io_slot_reset(struct pci_dev *pdev) | |
1860 | { | |
1861 | struct Scsi_Host *host = pci_get_drvdata(pdev); | |
1862 | struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; | |
1863 | struct lpfc_sli *psli = &phba->sli; | |
1864 | int bars = pci_select_bars(pdev, IORESOURCE_MEM); | |
1865 | ||
1866 | dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); | |
1867 | if (pci_enable_device_bars(pdev, bars)) { | |
1868 | printk(KERN_ERR "lpfc: Cannot re-enable " | |
1869 | "PCI device after reset.\n"); | |
1870 | return PCI_ERS_RESULT_DISCONNECT; | |
1871 | } | |
1872 | ||
1873 | pci_set_master(pdev); | |
1874 | ||
1875 | /* Re-establishing Link */ | |
1876 | spin_lock_irq(phba->host->host_lock); | |
1877 | phba->fc_flag |= FC_ESTABLISH_LINK; | |
1878 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; | |
1879 | spin_unlock_irq(phba->host->host_lock); | |
1880 | ||
1881 | ||
1882 | /* Take device offline; this will perform cleanup */ | |
1883 | lpfc_offline(phba); | |
1884 | lpfc_sli_brdrestart(phba); | |
1885 | ||
1886 | return PCI_ERS_RESULT_RECOVERED; | |
1887 | } | |
1888 | ||
1889 | /** | |
1890 | * lpfc_io_resume - called when traffic can start flowing again. | |
1891 | * @pdev: Pointer to PCI device | |
1892 | * | |
1893 | * This callback is called when the error recovery driver tells us that | |
1894 | * its OK to resume normal operation. | |
1895 | */ | |
1896 | static void lpfc_io_resume(struct pci_dev *pdev) | |
1897 | { | |
1898 | struct Scsi_Host *host = pci_get_drvdata(pdev); | |
1899 | struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; | |
1900 | ||
1901 | if (lpfc_online(phba) == 0) { | |
1902 | mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60); | |
1903 | } | |
1904 | } | |
1905 | ||
dea3101e | 1906 | static struct pci_device_id lpfc_id_table[] = { |
1907 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_VIPER, | |
1908 | PCI_ANY_ID, PCI_ANY_ID, }, | |
06325e74 JSEC |
1909 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_FIREFLY, |
1910 | PCI_ANY_ID, PCI_ANY_ID, }, | |
dea3101e | 1911 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_THOR, |
1912 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1913 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PEGASUS, | |
1914 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1915 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_CENTAUR, | |
1916 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1917 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_DRAGONFLY, | |
1918 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1919 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SUPERFLY, | |
1920 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1921 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_RFLY, | |
1922 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1923 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PFLY, | |
1924 | PCI_ANY_ID, PCI_ANY_ID, }, | |
e4adb204 JSEC |
1925 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE, |
1926 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1927 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_SCSP, | |
1928 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1929 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_DCSP, | |
1930 | PCI_ANY_ID, PCI_ANY_ID, }, | |
dea3101e | 1931 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS, |
1932 | PCI_ANY_ID, PCI_ANY_ID, }, | |
e4adb204 JSEC |
1933 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_SCSP, |
1934 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1935 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_DCSP, | |
1936 | PCI_ANY_ID, PCI_ANY_ID, }, | |
dea3101e | 1937 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BMID, |
1938 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1939 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BSMB, | |
1940 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1941 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR, | |
1942 | PCI_ANY_ID, PCI_ANY_ID, }, | |
e4adb204 JSEC |
1943 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_SCSP, |
1944 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1945 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_DCSP, | |
1946 | PCI_ANY_ID, PCI_ANY_ID, }, | |
dea3101e | 1947 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZMID, |
1948 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1949 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZSMB, | |
1950 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1951 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_TFLY, | |
1952 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1953 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP101, | |
1954 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1955 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP10000S, | |
1956 | PCI_ANY_ID, PCI_ANY_ID, }, | |
e4adb204 JSEC |
1957 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP11000S, |
1958 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1959 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LPE11000S, | |
1960 | PCI_ANY_ID, PCI_ANY_ID, }, | |
dea3101e | 1961 | { 0 } |
1962 | }; | |
1963 | ||
1964 | MODULE_DEVICE_TABLE(pci, lpfc_id_table); | |
1965 | ||
8d63f375 LV |
1966 | static struct pci_error_handlers lpfc_err_handler = { |
1967 | .error_detected = lpfc_io_error_detected, | |
1968 | .slot_reset = lpfc_io_slot_reset, | |
1969 | .resume = lpfc_io_resume, | |
1970 | }; | |
1971 | ||
dea3101e | 1972 | static struct pci_driver lpfc_driver = { |
1973 | .name = LPFC_DRIVER_NAME, | |
1974 | .id_table = lpfc_id_table, | |
1975 | .probe = lpfc_pci_probe_one, | |
1976 | .remove = __devexit_p(lpfc_pci_remove_one), | |
8d63f375 | 1977 | .err_handler = &lpfc_err_handler, |
dea3101e | 1978 | }; |
1979 | ||
1980 | static int __init | |
1981 | lpfc_init(void) | |
1982 | { | |
1983 | int error = 0; | |
1984 | ||
1985 | printk(LPFC_MODULE_DESC "\n"); | |
c44ce173 | 1986 | printk(LPFC_COPYRIGHT "\n"); |
dea3101e | 1987 | |
1988 | lpfc_transport_template = | |
1989 | fc_attach_transport(&lpfc_transport_functions); | |
1990 | if (!lpfc_transport_template) | |
1991 | return -ENOMEM; | |
1992 | error = pci_register_driver(&lpfc_driver); | |
1993 | if (error) | |
1994 | fc_release_transport(lpfc_transport_template); | |
1995 | ||
1996 | return error; | |
1997 | } | |
1998 | ||
1999 | static void __exit | |
2000 | lpfc_exit(void) | |
2001 | { | |
2002 | pci_unregister_driver(&lpfc_driver); | |
2003 | fc_release_transport(lpfc_transport_template); | |
2004 | } | |
2005 | ||
2006 | module_init(lpfc_init); | |
2007 | module_exit(lpfc_exit); | |
2008 | MODULE_LICENSE("GPL"); | |
2009 | MODULE_DESCRIPTION(LPFC_MODULE_DESC); | |
2010 | MODULE_AUTHOR("Emulex Corporation - tech.support@emulex.com"); | |
2011 | MODULE_VERSION("0:" LPFC_DRIVER_VERSION); |