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 | ||
c3f28afa JS |
271 | if (phba->cfg_soft_wwpn) |
272 | u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn); | |
dea3101e | 273 | memcpy(&phba->fc_nodename, &phba->fc_sparam.nodeName, |
274 | sizeof (struct lpfc_name)); | |
275 | memcpy(&phba->fc_portname, &phba->fc_sparam.portName, | |
276 | sizeof (struct lpfc_name)); | |
277 | /* If no serial number in VPD data, use low 6 bytes of WWNN */ | |
278 | /* This should be consolidated into parse_vpd ? - mr */ | |
279 | if (phba->SerialNumber[0] == 0) { | |
280 | uint8_t *outptr; | |
281 | ||
68ce1eb5 | 282 | outptr = &phba->fc_nodename.u.s.IEEE[0]; |
dea3101e | 283 | for (i = 0; i < 12; i++) { |
284 | status = *outptr++; | |
285 | j = ((status & 0xf0) >> 4); | |
286 | if (j <= 9) | |
287 | phba->SerialNumber[i] = | |
288 | (char)((uint8_t) 0x30 + (uint8_t) j); | |
289 | else | |
290 | phba->SerialNumber[i] = | |
291 | (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); | |
292 | i++; | |
293 | j = (status & 0xf); | |
294 | if (j <= 9) | |
295 | phba->SerialNumber[i] = | |
296 | (char)((uint8_t) 0x30 + (uint8_t) j); | |
297 | else | |
298 | phba->SerialNumber[i] = | |
299 | (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); | |
300 | } | |
301 | } | |
302 | ||
dea3101e | 303 | lpfc_read_config(phba, pmb); |
304 | if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { | |
305 | lpfc_printf_log(phba, | |
306 | KERN_ERR, | |
307 | LOG_INIT, | |
308 | "%d:0453 Adapter failed to init, mbxCmd x%x " | |
309 | "READ_CONFIG, mbxStatus x%x\n", | |
310 | phba->brd_no, | |
311 | mb->mbxCommand, mb->mbxStatus); | |
312 | phba->hba_state = LPFC_HBA_ERROR; | |
313 | mempool_free( pmb, phba->mbox_mem_pool); | |
314 | return -EIO; | |
315 | } | |
316 | ||
317 | /* Reset the DFT_HBA_Q_DEPTH to the max xri */ | |
318 | if (phba->cfg_hba_queue_depth > (mb->un.varRdConfig.max_xri+1)) | |
319 | phba->cfg_hba_queue_depth = | |
320 | mb->un.varRdConfig.max_xri + 1; | |
321 | ||
322 | phba->lmt = mb->un.varRdConfig.lmt; | |
74b72a59 JW |
323 | |
324 | /* Get the default values for Model Name and Description */ | |
325 | lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); | |
326 | ||
327 | if ((phba->cfg_link_speed > LINK_SPEED_10G) | |
328 | || ((phba->cfg_link_speed == LINK_SPEED_1G) | |
329 | && !(phba->lmt & LMT_1Gb)) | |
330 | || ((phba->cfg_link_speed == LINK_SPEED_2G) | |
331 | && !(phba->lmt & LMT_2Gb)) | |
332 | || ((phba->cfg_link_speed == LINK_SPEED_4G) | |
333 | && !(phba->lmt & LMT_4Gb)) | |
334 | || ((phba->cfg_link_speed == LINK_SPEED_8G) | |
335 | && !(phba->lmt & LMT_8Gb)) | |
336 | || ((phba->cfg_link_speed == LINK_SPEED_10G) | |
337 | && !(phba->lmt & LMT_10Gb))) { | |
338 | /* Reset link speed to auto */ | |
dea3101e | 339 | lpfc_printf_log(phba, |
340 | KERN_WARNING, | |
341 | LOG_LINK_EVENT, | |
342 | "%d:1302 Invalid speed for this board: " | |
343 | "Reset link speed to auto: x%x\n", | |
344 | phba->brd_no, | |
345 | phba->cfg_link_speed); | |
346 | phba->cfg_link_speed = LINK_SPEED_AUTO; | |
347 | } | |
348 | ||
349 | phba->hba_state = LPFC_LINK_DOWN; | |
350 | ||
351 | /* Only process IOCBs on ring 0 till hba_state is READY */ | |
a4bc3379 JS |
352 | if (psli->ring[psli->extra_ring].cmdringaddr) |
353 | psli->ring[psli->extra_ring].flag |= LPFC_STOP_IOCB_EVENT; | |
dea3101e | 354 | if (psli->ring[psli->fcp_ring].cmdringaddr) |
355 | psli->ring[psli->fcp_ring].flag |= LPFC_STOP_IOCB_EVENT; | |
356 | if (psli->ring[psli->next_ring].cmdringaddr) | |
357 | psli->ring[psli->next_ring].flag |= LPFC_STOP_IOCB_EVENT; | |
358 | ||
359 | /* Post receive buffers for desired rings */ | |
360 | lpfc_post_rcv_buf(phba); | |
361 | ||
362 | /* Enable appropriate host interrupts */ | |
363 | spin_lock_irq(phba->host->host_lock); | |
364 | status = readl(phba->HCregaddr); | |
365 | status |= HC_MBINT_ENA | HC_ERINT_ENA | HC_LAINT_ENA; | |
366 | if (psli->num_rings > 0) | |
367 | status |= HC_R0INT_ENA; | |
368 | if (psli->num_rings > 1) | |
369 | status |= HC_R1INT_ENA; | |
370 | if (psli->num_rings > 2) | |
371 | status |= HC_R2INT_ENA; | |
372 | if (psli->num_rings > 3) | |
373 | status |= HC_R3INT_ENA; | |
374 | ||
875fbdfe JSEC |
375 | if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) && |
376 | (phba->cfg_poll & DISABLE_FCP_RING_INT)) | |
377 | status &= ~(HC_R0INT_ENA << LPFC_FCP_RING); | |
378 | ||
dea3101e | 379 | writel(status, phba->HCregaddr); |
380 | readl(phba->HCregaddr); /* flush */ | |
381 | spin_unlock_irq(phba->host->host_lock); | |
382 | ||
383 | /* | |
384 | * Setup the ring 0 (els) timeout handler | |
385 | */ | |
386 | timeout = phba->fc_ratov << 1; | |
387 | phba->els_tmofunc.expires = jiffies + HZ * timeout; | |
388 | add_timer(&phba->els_tmofunc); | |
389 | ||
390 | lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); | |
391 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | |
8aee918a JS |
392 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); |
393 | if (rc != MBX_SUCCESS) { | |
dea3101e | 394 | lpfc_printf_log(phba, |
395 | KERN_ERR, | |
396 | LOG_INIT, | |
397 | "%d:0454 Adapter failed to init, mbxCmd x%x " | |
398 | "INIT_LINK, mbxStatus x%x\n", | |
399 | phba->brd_no, | |
400 | mb->mbxCommand, mb->mbxStatus); | |
401 | ||
402 | /* Clear all interrupt enable conditions */ | |
403 | writel(0, phba->HCregaddr); | |
404 | readl(phba->HCregaddr); /* flush */ | |
405 | /* Clear all pending interrupts */ | |
406 | writel(0xffffffff, phba->HAregaddr); | |
407 | readl(phba->HAregaddr); /* flush */ | |
408 | ||
409 | phba->hba_state = LPFC_HBA_ERROR; | |
8aee918a JS |
410 | if (rc != MBX_BUSY) |
411 | mempool_free(pmb, phba->mbox_mem_pool); | |
dea3101e | 412 | return -EIO; |
413 | } | |
414 | /* MBOX buffer will be freed in mbox compl */ | |
415 | ||
ce8b3ce5 JS |
416 | return (0); |
417 | } | |
418 | ||
419 | static int | |
420 | lpfc_discovery_wait(struct lpfc_hba *phba) | |
421 | { | |
422 | int i = 0; | |
423 | ||
dea3101e | 424 | while ((phba->hba_state != LPFC_HBA_READY) || |
425 | (phba->num_disc_nodes) || (phba->fc_prli_sent) || | |
426 | ((phba->fc_map_cnt == 0) && (i<2)) || | |
ce8b3ce5 | 427 | (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE)) { |
dea3101e | 428 | /* Check every second for 30 retries. */ |
429 | i++; | |
430 | if (i > 30) { | |
ce8b3ce5 | 431 | return -ETIMEDOUT; |
dea3101e | 432 | } |
433 | if ((i >= 15) && (phba->hba_state <= LPFC_LINK_DOWN)) { | |
434 | /* The link is down. Set linkdown timeout */ | |
ce8b3ce5 | 435 | return -ETIMEDOUT; |
dea3101e | 436 | } |
437 | ||
438 | /* Delay for 1 second to give discovery time to complete. */ | |
439 | msleep(1000); | |
440 | ||
441 | } | |
442 | ||
ce8b3ce5 | 443 | return 0; |
dea3101e | 444 | } |
445 | ||
446 | /************************************************************************/ | |
447 | /* */ | |
448 | /* lpfc_hba_down_prep */ | |
449 | /* This routine will do LPFC uninitialization before the */ | |
450 | /* HBA is reset when bringing down the SLI Layer. This will be */ | |
451 | /* initialized as a SLI layer callback routine. */ | |
452 | /* This routine returns 0 on success. Any other return value */ | |
453 | /* indicates an error. */ | |
454 | /* */ | |
455 | /************************************************************************/ | |
456 | int | |
457 | lpfc_hba_down_prep(struct lpfc_hba * phba) | |
458 | { | |
459 | /* Disable interrupts */ | |
460 | writel(0, phba->HCregaddr); | |
461 | readl(phba->HCregaddr); /* flush */ | |
462 | ||
463 | /* Cleanup potential discovery resources */ | |
464 | lpfc_els_flush_rscn(phba); | |
465 | lpfc_els_flush_cmd(phba); | |
466 | lpfc_disc_flush_list(phba); | |
467 | ||
468 | return (0); | |
469 | } | |
470 | ||
41415862 JW |
471 | /************************************************************************/ |
472 | /* */ | |
473 | /* lpfc_hba_down_post */ | |
474 | /* This routine will do uninitialization after the HBA is reset */ | |
475 | /* when bringing down the SLI Layer. */ | |
476 | /* This routine returns 0 on success. Any other return value */ | |
477 | /* indicates an error. */ | |
478 | /* */ | |
479 | /************************************************************************/ | |
480 | int | |
481 | lpfc_hba_down_post(struct lpfc_hba * phba) | |
482 | { | |
483 | struct lpfc_sli *psli = &phba->sli; | |
484 | struct lpfc_sli_ring *pring; | |
485 | struct lpfc_dmabuf *mp, *next_mp; | |
486 | int i; | |
487 | ||
488 | /* Cleanup preposted buffers on the ELS ring */ | |
489 | pring = &psli->ring[LPFC_ELS_RING]; | |
490 | list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { | |
491 | list_del(&mp->list); | |
492 | pring->postbufq_cnt--; | |
493 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
494 | kfree(mp); | |
495 | } | |
496 | ||
497 | for (i = 0; i < psli->num_rings; i++) { | |
498 | pring = &psli->ring[i]; | |
499 | lpfc_sli_abort_iocb_ring(phba, pring); | |
500 | } | |
501 | ||
502 | return 0; | |
503 | } | |
504 | ||
dea3101e | 505 | /************************************************************************/ |
506 | /* */ | |
507 | /* lpfc_handle_eratt */ | |
508 | /* This routine will handle processing a Host Attention */ | |
509 | /* Error Status event. This will be initialized */ | |
510 | /* as a SLI layer callback routine. */ | |
511 | /* */ | |
512 | /************************************************************************/ | |
513 | void | |
514 | lpfc_handle_eratt(struct lpfc_hba * phba) | |
515 | { | |
516 | struct lpfc_sli *psli = &phba->sli; | |
517 | struct lpfc_sli_ring *pring; | |
d2873e4c | 518 | uint32_t event_data; |
dea3101e | 519 | |
dea3101e | 520 | if (phba->work_hs & HS_FFER6) { |
521 | /* Re-establishing Link */ | |
522 | lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, | |
523 | "%d:1301 Re-establishing Link " | |
524 | "Data: x%x x%x x%x\n", | |
525 | phba->brd_no, phba->work_hs, | |
526 | phba->work_status[0], phba->work_status[1]); | |
527 | spin_lock_irq(phba->host->host_lock); | |
528 | phba->fc_flag |= FC_ESTABLISH_LINK; | |
9290831f | 529 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; |
dea3101e | 530 | spin_unlock_irq(phba->host->host_lock); |
531 | ||
532 | /* | |
533 | * Firmware stops when it triggled erratt with HS_FFER6. | |
534 | * That could cause the I/Os dropped by the firmware. | |
535 | * Error iocb (I/O) on txcmplq and let the SCSI layer | |
536 | * retry it after re-establishing link. | |
537 | */ | |
538 | pring = &psli->ring[psli->fcp_ring]; | |
539 | lpfc_sli_abort_iocb_ring(phba, pring); | |
540 | ||
541 | ||
542 | /* | |
543 | * There was a firmware error. Take the hba offline and then | |
544 | * attempt to restart it. | |
545 | */ | |
546 | lpfc_offline(phba); | |
41415862 | 547 | lpfc_sli_brdrestart(phba); |
dea3101e | 548 | if (lpfc_online(phba) == 0) { /* Initialize the HBA */ |
549 | mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60); | |
550 | return; | |
551 | } | |
552 | } else { | |
553 | /* The if clause above forces this code path when the status | |
554 | * failure is a value other than FFER6. Do not call the offline | |
555 | * twice. This is the adapter hardware error path. | |
556 | */ | |
557 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
558 | "%d:0457 Adapter Hardware Error " | |
559 | "Data: x%x x%x x%x\n", | |
560 | phba->brd_no, phba->work_hs, | |
561 | phba->work_status[0], phba->work_status[1]); | |
562 | ||
d2873e4c JS |
563 | event_data = FC_REG_DUMP_EVENT; |
564 | fc_host_post_vendor_event(phba->host, fc_get_event_number(), | |
565 | sizeof(event_data), (char *) &event_data, | |
566 | SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); | |
567 | ||
9290831f | 568 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; |
dea3101e | 569 | lpfc_offline(phba); |
41415862 JW |
570 | phba->hba_state = LPFC_HBA_ERROR; |
571 | lpfc_hba_down_post(phba); | |
dea3101e | 572 | } |
573 | } | |
574 | ||
575 | /************************************************************************/ | |
576 | /* */ | |
577 | /* lpfc_handle_latt */ | |
578 | /* This routine will handle processing a Host Attention */ | |
579 | /* Link Status event. This will be initialized */ | |
580 | /* as a SLI layer callback routine. */ | |
581 | /* */ | |
582 | /************************************************************************/ | |
583 | void | |
584 | lpfc_handle_latt(struct lpfc_hba * phba) | |
585 | { | |
586 | struct lpfc_sli *psli = &phba->sli; | |
587 | LPFC_MBOXQ_t *pmb; | |
588 | volatile uint32_t control; | |
589 | struct lpfc_dmabuf *mp; | |
590 | int rc = -ENOMEM; | |
591 | ||
592 | pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | |
593 | if (!pmb) | |
594 | goto lpfc_handle_latt_err_exit; | |
595 | ||
596 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); | |
597 | if (!mp) | |
598 | goto lpfc_handle_latt_free_pmb; | |
599 | ||
600 | mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); | |
601 | if (!mp->virt) | |
602 | goto lpfc_handle_latt_free_mp; | |
603 | ||
604 | rc = -EIO; | |
605 | ||
6281bfe0 JSEC |
606 | /* Cleanup any outstanding ELS commands */ |
607 | lpfc_els_flush_cmd(phba); | |
dea3101e | 608 | |
609 | psli->slistat.link_event++; | |
610 | lpfc_read_la(phba, pmb, mp); | |
611 | pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la; | |
612 | rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB)); | |
613 | if (rc == MBX_NOT_FINISHED) | |
14691150 | 614 | goto lpfc_handle_latt_free_mbuf; |
dea3101e | 615 | |
616 | /* Clear Link Attention in HA REG */ | |
617 | spin_lock_irq(phba->host->host_lock); | |
618 | writel(HA_LATT, phba->HAregaddr); | |
619 | readl(phba->HAregaddr); /* flush */ | |
620 | spin_unlock_irq(phba->host->host_lock); | |
621 | ||
622 | return; | |
623 | ||
14691150 JS |
624 | lpfc_handle_latt_free_mbuf: |
625 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
dea3101e | 626 | lpfc_handle_latt_free_mp: |
627 | kfree(mp); | |
628 | lpfc_handle_latt_free_pmb: | |
629 | kfree(pmb); | |
630 | lpfc_handle_latt_err_exit: | |
631 | /* Enable Link attention interrupts */ | |
632 | spin_lock_irq(phba->host->host_lock); | |
633 | psli->sli_flag |= LPFC_PROCESS_LA; | |
634 | control = readl(phba->HCregaddr); | |
635 | control |= HC_LAINT_ENA; | |
636 | writel(control, phba->HCregaddr); | |
637 | readl(phba->HCregaddr); /* flush */ | |
638 | ||
639 | /* Clear Link Attention in HA REG */ | |
640 | writel(HA_LATT, phba->HAregaddr); | |
641 | readl(phba->HAregaddr); /* flush */ | |
642 | spin_unlock_irq(phba->host->host_lock); | |
643 | lpfc_linkdown(phba); | |
644 | phba->hba_state = LPFC_HBA_ERROR; | |
645 | ||
646 | /* The other case is an error from issue_mbox */ | |
647 | if (rc == -ENOMEM) | |
648 | lpfc_printf_log(phba, | |
649 | KERN_WARNING, | |
650 | LOG_MBOX, | |
651 | "%d:0300 READ_LA: no buffers\n", | |
652 | phba->brd_no); | |
653 | ||
654 | return; | |
655 | } | |
656 | ||
657 | /************************************************************************/ | |
658 | /* */ | |
659 | /* lpfc_parse_vpd */ | |
660 | /* This routine will parse the VPD data */ | |
661 | /* */ | |
662 | /************************************************************************/ | |
663 | static int | |
74b72a59 | 664 | lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd, int len) |
dea3101e | 665 | { |
666 | uint8_t lenlo, lenhi; | |
667 | uint32_t Length; | |
668 | int i, j; | |
669 | int finished = 0; | |
670 | int index = 0; | |
671 | ||
672 | if (!vpd) | |
673 | return 0; | |
674 | ||
675 | /* Vital Product */ | |
676 | lpfc_printf_log(phba, | |
677 | KERN_INFO, | |
678 | LOG_INIT, | |
679 | "%d:0455 Vital Product Data: x%x x%x x%x x%x\n", | |
680 | phba->brd_no, | |
681 | (uint32_t) vpd[0], (uint32_t) vpd[1], (uint32_t) vpd[2], | |
682 | (uint32_t) vpd[3]); | |
74b72a59 | 683 | while (!finished && (index < (len - 4))) { |
dea3101e | 684 | switch (vpd[index]) { |
685 | case 0x82: | |
74b72a59 | 686 | case 0x91: |
dea3101e | 687 | index += 1; |
688 | lenlo = vpd[index]; | |
689 | index += 1; | |
690 | lenhi = vpd[index]; | |
691 | index += 1; | |
692 | i = ((((unsigned short)lenhi) << 8) + lenlo); | |
693 | index += i; | |
694 | break; | |
695 | case 0x90: | |
696 | index += 1; | |
697 | lenlo = vpd[index]; | |
698 | index += 1; | |
699 | lenhi = vpd[index]; | |
700 | index += 1; | |
701 | Length = ((((unsigned short)lenhi) << 8) + lenlo); | |
74b72a59 JW |
702 | if (Length > len - index) |
703 | Length = len - index; | |
dea3101e | 704 | while (Length > 0) { |
705 | /* Look for Serial Number */ | |
706 | if ((vpd[index] == 'S') && (vpd[index+1] == 'N')) { | |
707 | index += 2; | |
708 | i = vpd[index]; | |
709 | index += 1; | |
710 | j = 0; | |
711 | Length -= (3+i); | |
712 | while(i--) { | |
713 | phba->SerialNumber[j++] = vpd[index++]; | |
714 | if (j == 31) | |
715 | break; | |
716 | } | |
717 | phba->SerialNumber[j] = 0; | |
718 | continue; | |
719 | } | |
720 | else if ((vpd[index] == 'V') && (vpd[index+1] == '1')) { | |
721 | phba->vpd_flag |= VPD_MODEL_DESC; | |
722 | index += 2; | |
723 | i = vpd[index]; | |
724 | index += 1; | |
725 | j = 0; | |
726 | Length -= (3+i); | |
727 | while(i--) { | |
728 | phba->ModelDesc[j++] = vpd[index++]; | |
729 | if (j == 255) | |
730 | break; | |
731 | } | |
732 | phba->ModelDesc[j] = 0; | |
733 | continue; | |
734 | } | |
735 | else if ((vpd[index] == 'V') && (vpd[index+1] == '2')) { | |
736 | phba->vpd_flag |= VPD_MODEL_NAME; | |
737 | index += 2; | |
738 | i = vpd[index]; | |
739 | index += 1; | |
740 | j = 0; | |
741 | Length -= (3+i); | |
742 | while(i--) { | |
743 | phba->ModelName[j++] = vpd[index++]; | |
744 | if (j == 79) | |
745 | break; | |
746 | } | |
747 | phba->ModelName[j] = 0; | |
748 | continue; | |
749 | } | |
750 | else if ((vpd[index] == 'V') && (vpd[index+1] == '3')) { | |
751 | phba->vpd_flag |= VPD_PROGRAM_TYPE; | |
752 | index += 2; | |
753 | i = vpd[index]; | |
754 | index += 1; | |
755 | j = 0; | |
756 | Length -= (3+i); | |
757 | while(i--) { | |
758 | phba->ProgramType[j++] = vpd[index++]; | |
759 | if (j == 255) | |
760 | break; | |
761 | } | |
762 | phba->ProgramType[j] = 0; | |
763 | continue; | |
764 | } | |
765 | else if ((vpd[index] == 'V') && (vpd[index+1] == '4')) { | |
766 | phba->vpd_flag |= VPD_PORT; | |
767 | index += 2; | |
768 | i = vpd[index]; | |
769 | index += 1; | |
770 | j = 0; | |
771 | Length -= (3+i); | |
772 | while(i--) { | |
773 | phba->Port[j++] = vpd[index++]; | |
774 | if (j == 19) | |
775 | break; | |
776 | } | |
777 | phba->Port[j] = 0; | |
778 | continue; | |
779 | } | |
780 | else { | |
781 | index += 2; | |
782 | i = vpd[index]; | |
783 | index += 1; | |
784 | index += i; | |
785 | Length -= (3 + i); | |
786 | } | |
787 | } | |
788 | finished = 0; | |
789 | break; | |
790 | case 0x78: | |
791 | finished = 1; | |
792 | break; | |
793 | default: | |
794 | index ++; | |
795 | break; | |
796 | } | |
74b72a59 | 797 | } |
dea3101e | 798 | |
799 | return(1); | |
800 | } | |
801 | ||
802 | static void | |
803 | lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) | |
804 | { | |
805 | lpfc_vpd_t *vp; | |
fefcb2b6 | 806 | uint16_t dev_id = phba->pcidev->device; |
74b72a59 | 807 | int max_speed; |
74b72a59 JW |
808 | struct { |
809 | char * name; | |
810 | int max_speed; | |
74b72a59 | 811 | char * bus; |
18a3b596 | 812 | } m = {"<Unknown>", 0, ""}; |
74b72a59 JW |
813 | |
814 | if (mdp && mdp[0] != '\0' | |
815 | && descp && descp[0] != '\0') | |
816 | return; | |
817 | ||
818 | if (phba->lmt & LMT_10Gb) | |
819 | max_speed = 10; | |
820 | else if (phba->lmt & LMT_8Gb) | |
821 | max_speed = 8; | |
822 | else if (phba->lmt & LMT_4Gb) | |
823 | max_speed = 4; | |
824 | else if (phba->lmt & LMT_2Gb) | |
825 | max_speed = 2; | |
826 | else | |
827 | max_speed = 1; | |
dea3101e | 828 | |
829 | vp = &phba->vpd; | |
dea3101e | 830 | |
e4adb204 | 831 | switch (dev_id) { |
06325e74 | 832 | case PCI_DEVICE_ID_FIREFLY: |
18a3b596 | 833 | m = (typeof(m)){"LP6000", max_speed, "PCI"}; |
06325e74 | 834 | break; |
dea3101e | 835 | case PCI_DEVICE_ID_SUPERFLY: |
836 | if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) | |
18a3b596 | 837 | m = (typeof(m)){"LP7000", max_speed, "PCI"}; |
dea3101e | 838 | else |
18a3b596 | 839 | m = (typeof(m)){"LP7000E", max_speed, "PCI"}; |
dea3101e | 840 | break; |
841 | case PCI_DEVICE_ID_DRAGONFLY: | |
18a3b596 | 842 | m = (typeof(m)){"LP8000", max_speed, "PCI"}; |
dea3101e | 843 | break; |
844 | case PCI_DEVICE_ID_CENTAUR: | |
845 | if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) | |
18a3b596 | 846 | m = (typeof(m)){"LP9002", max_speed, "PCI"}; |
dea3101e | 847 | else |
18a3b596 | 848 | m = (typeof(m)){"LP9000", max_speed, "PCI"}; |
dea3101e | 849 | break; |
850 | case PCI_DEVICE_ID_RFLY: | |
18a3b596 | 851 | m = (typeof(m)){"LP952", max_speed, "PCI"}; |
dea3101e | 852 | break; |
853 | case PCI_DEVICE_ID_PEGASUS: | |
18a3b596 | 854 | m = (typeof(m)){"LP9802", max_speed, "PCI-X"}; |
dea3101e | 855 | break; |
856 | case PCI_DEVICE_ID_THOR: | |
18a3b596 | 857 | m = (typeof(m)){"LP10000", max_speed, "PCI-X"}; |
dea3101e | 858 | break; |
859 | case PCI_DEVICE_ID_VIPER: | |
18a3b596 | 860 | m = (typeof(m)){"LPX1000", max_speed, "PCI-X"}; |
dea3101e | 861 | break; |
862 | case PCI_DEVICE_ID_PFLY: | |
18a3b596 | 863 | m = (typeof(m)){"LP982", max_speed, "PCI-X"}; |
dea3101e | 864 | break; |
865 | case PCI_DEVICE_ID_TFLY: | |
18a3b596 | 866 | m = (typeof(m)){"LP1050", max_speed, "PCI-X"}; |
dea3101e | 867 | break; |
868 | case PCI_DEVICE_ID_HELIOS: | |
18a3b596 | 869 | m = (typeof(m)){"LP11000", max_speed, "PCI-X2"}; |
dea3101e | 870 | break; |
e4adb204 | 871 | case PCI_DEVICE_ID_HELIOS_SCSP: |
18a3b596 | 872 | m = (typeof(m)){"LP11000-SP", max_speed, "PCI-X2"}; |
e4adb204 JSEC |
873 | break; |
874 | case PCI_DEVICE_ID_HELIOS_DCSP: | |
18a3b596 | 875 | m = (typeof(m)){"LP11002-SP", max_speed, "PCI-X2"}; |
e4adb204 JSEC |
876 | break; |
877 | case PCI_DEVICE_ID_NEPTUNE: | |
18a3b596 | 878 | m = (typeof(m)){"LPe1000", max_speed, "PCIe"}; |
e4adb204 JSEC |
879 | break; |
880 | case PCI_DEVICE_ID_NEPTUNE_SCSP: | |
18a3b596 | 881 | m = (typeof(m)){"LPe1000-SP", max_speed, "PCIe"}; |
e4adb204 JSEC |
882 | break; |
883 | case PCI_DEVICE_ID_NEPTUNE_DCSP: | |
18a3b596 | 884 | m = (typeof(m)){"LPe1002-SP", max_speed, "PCIe"}; |
e4adb204 | 885 | break; |
dea3101e | 886 | case PCI_DEVICE_ID_BMID: |
18a3b596 | 887 | m = (typeof(m)){"LP1150", max_speed, "PCI-X2"}; |
dea3101e | 888 | break; |
889 | case PCI_DEVICE_ID_BSMB: | |
18a3b596 | 890 | m = (typeof(m)){"LP111", max_speed, "PCI-X2"}; |
dea3101e | 891 | break; |
892 | case PCI_DEVICE_ID_ZEPHYR: | |
18a3b596 | 893 | m = (typeof(m)){"LPe11000", max_speed, "PCIe"}; |
dea3101e | 894 | break; |
e4adb204 | 895 | case PCI_DEVICE_ID_ZEPHYR_SCSP: |
18a3b596 | 896 | m = (typeof(m)){"LPe11000", max_speed, "PCIe"}; |
e4adb204 JSEC |
897 | break; |
898 | case PCI_DEVICE_ID_ZEPHYR_DCSP: | |
18a3b596 | 899 | m = (typeof(m)){"LPe11002-SP", max_speed, "PCIe"}; |
e4adb204 | 900 | break; |
dea3101e | 901 | case PCI_DEVICE_ID_ZMID: |
18a3b596 | 902 | m = (typeof(m)){"LPe1150", max_speed, "PCIe"}; |
dea3101e | 903 | break; |
904 | case PCI_DEVICE_ID_ZSMB: | |
18a3b596 | 905 | m = (typeof(m)){"LPe111", max_speed, "PCIe"}; |
dea3101e | 906 | break; |
907 | case PCI_DEVICE_ID_LP101: | |
18a3b596 | 908 | m = (typeof(m)){"LP101", max_speed, "PCI-X"}; |
dea3101e | 909 | break; |
910 | case PCI_DEVICE_ID_LP10000S: | |
18a3b596 | 911 | m = (typeof(m)){"LP10000-S", max_speed, "PCI"}; |
06325e74 | 912 | break; |
e4adb204 | 913 | case PCI_DEVICE_ID_LP11000S: |
18a3b596 JS |
914 | m = (typeof(m)){"LP11000-S", max_speed, |
915 | "PCI-X2"}; | |
916 | break; | |
e4adb204 | 917 | case PCI_DEVICE_ID_LPE11000S: |
18a3b596 JS |
918 | m = (typeof(m)){"LPe11000-S", max_speed, |
919 | "PCIe"}; | |
5cc36b3c JSEC |
920 | break; |
921 | default: | |
041976fb | 922 | m = (typeof(m)){ NULL }; |
e4adb204 | 923 | break; |
dea3101e | 924 | } |
74b72a59 JW |
925 | |
926 | if (mdp && mdp[0] == '\0') | |
927 | snprintf(mdp, 79,"%s", m.name); | |
928 | if (descp && descp[0] == '\0') | |
929 | snprintf(descp, 255, | |
18a3b596 JS |
930 | "Emulex %s %dGb %s Fibre Channel Adapter", |
931 | m.name, m.max_speed, m.bus); | |
dea3101e | 932 | } |
933 | ||
934 | /**************************************************/ | |
935 | /* lpfc_post_buffer */ | |
936 | /* */ | |
937 | /* This routine will post count buffers to the */ | |
938 | /* ring with the QUE_RING_BUF_CN command. This */ | |
939 | /* allows 3 buffers / command to be posted. */ | |
940 | /* Returns the number of buffers NOT posted. */ | |
941 | /**************************************************/ | |
942 | int | |
943 | lpfc_post_buffer(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, int cnt, | |
944 | int type) | |
945 | { | |
946 | IOCB_t *icmd; | |
0bd4ca25 | 947 | struct lpfc_iocbq *iocb; |
dea3101e | 948 | struct lpfc_dmabuf *mp1, *mp2; |
949 | ||
950 | cnt += pring->missbufcnt; | |
951 | ||
952 | /* While there are buffers to post */ | |
953 | while (cnt > 0) { | |
954 | /* Allocate buffer for command iocb */ | |
955 | spin_lock_irq(phba->host->host_lock); | |
0bd4ca25 | 956 | iocb = lpfc_sli_get_iocbq(phba); |
dea3101e | 957 | spin_unlock_irq(phba->host->host_lock); |
958 | if (iocb == NULL) { | |
959 | pring->missbufcnt = cnt; | |
960 | return cnt; | |
961 | } | |
dea3101e | 962 | icmd = &iocb->iocb; |
963 | ||
964 | /* 2 buffers can be posted per command */ | |
965 | /* Allocate buffer to post */ | |
966 | mp1 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); | |
967 | if (mp1) | |
968 | mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, | |
969 | &mp1->phys); | |
970 | if (mp1 == 0 || mp1->virt == 0) { | |
c9475cb0 | 971 | kfree(mp1); |
dea3101e | 972 | spin_lock_irq(phba->host->host_lock); |
604a3e30 | 973 | lpfc_sli_release_iocbq(phba, iocb); |
dea3101e | 974 | spin_unlock_irq(phba->host->host_lock); |
975 | pring->missbufcnt = cnt; | |
976 | return cnt; | |
977 | } | |
978 | ||
979 | INIT_LIST_HEAD(&mp1->list); | |
980 | /* Allocate buffer to post */ | |
981 | if (cnt > 1) { | |
982 | mp2 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); | |
983 | if (mp2) | |
984 | mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, | |
985 | &mp2->phys); | |
986 | if (mp2 == 0 || mp2->virt == 0) { | |
c9475cb0 | 987 | kfree(mp2); |
dea3101e | 988 | lpfc_mbuf_free(phba, mp1->virt, mp1->phys); |
989 | kfree(mp1); | |
990 | spin_lock_irq(phba->host->host_lock); | |
604a3e30 | 991 | lpfc_sli_release_iocbq(phba, iocb); |
dea3101e | 992 | spin_unlock_irq(phba->host->host_lock); |
993 | pring->missbufcnt = cnt; | |
994 | return cnt; | |
995 | } | |
996 | ||
997 | INIT_LIST_HEAD(&mp2->list); | |
998 | } else { | |
999 | mp2 = NULL; | |
1000 | } | |
1001 | ||
1002 | icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys); | |
1003 | icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys); | |
1004 | icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE; | |
1005 | icmd->ulpBdeCount = 1; | |
1006 | cnt--; | |
1007 | if (mp2) { | |
1008 | icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys); | |
1009 | icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys); | |
1010 | icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE; | |
1011 | cnt--; | |
1012 | icmd->ulpBdeCount = 2; | |
1013 | } | |
1014 | ||
1015 | icmd->ulpCommand = CMD_QUE_RING_BUF64_CN; | |
1016 | icmd->ulpLe = 1; | |
1017 | ||
1018 | spin_lock_irq(phba->host->host_lock); | |
1019 | if (lpfc_sli_issue_iocb(phba, pring, iocb, 0) == IOCB_ERROR) { | |
1020 | lpfc_mbuf_free(phba, mp1->virt, mp1->phys); | |
1021 | kfree(mp1); | |
1022 | cnt++; | |
1023 | if (mp2) { | |
1024 | lpfc_mbuf_free(phba, mp2->virt, mp2->phys); | |
1025 | kfree(mp2); | |
1026 | cnt++; | |
1027 | } | |
604a3e30 | 1028 | lpfc_sli_release_iocbq(phba, iocb); |
dea3101e | 1029 | pring->missbufcnt = cnt; |
1030 | spin_unlock_irq(phba->host->host_lock); | |
1031 | return cnt; | |
1032 | } | |
1033 | spin_unlock_irq(phba->host->host_lock); | |
1034 | lpfc_sli_ringpostbuf_put(phba, pring, mp1); | |
1035 | if (mp2) { | |
1036 | lpfc_sli_ringpostbuf_put(phba, pring, mp2); | |
1037 | } | |
1038 | } | |
1039 | pring->missbufcnt = 0; | |
1040 | return 0; | |
1041 | } | |
1042 | ||
1043 | /************************************************************************/ | |
1044 | /* */ | |
1045 | /* lpfc_post_rcv_buf */ | |
1046 | /* This routine post initial rcv buffers to the configured rings */ | |
1047 | /* */ | |
1048 | /************************************************************************/ | |
1049 | static int | |
1050 | lpfc_post_rcv_buf(struct lpfc_hba * phba) | |
1051 | { | |
1052 | struct lpfc_sli *psli = &phba->sli; | |
1053 | ||
1054 | /* Ring 0, ELS / CT buffers */ | |
1055 | lpfc_post_buffer(phba, &psli->ring[LPFC_ELS_RING], LPFC_BUF_RING0, 1); | |
1056 | /* Ring 2 - FCP no buffers needed */ | |
1057 | ||
1058 | return 0; | |
1059 | } | |
1060 | ||
1061 | #define S(N,V) (((V)<<(N))|((V)>>(32-(N)))) | |
1062 | ||
1063 | /************************************************************************/ | |
1064 | /* */ | |
1065 | /* lpfc_sha_init */ | |
1066 | /* */ | |
1067 | /************************************************************************/ | |
1068 | static void | |
1069 | lpfc_sha_init(uint32_t * HashResultPointer) | |
1070 | { | |
1071 | HashResultPointer[0] = 0x67452301; | |
1072 | HashResultPointer[1] = 0xEFCDAB89; | |
1073 | HashResultPointer[2] = 0x98BADCFE; | |
1074 | HashResultPointer[3] = 0x10325476; | |
1075 | HashResultPointer[4] = 0xC3D2E1F0; | |
1076 | } | |
1077 | ||
1078 | /************************************************************************/ | |
1079 | /* */ | |
1080 | /* lpfc_sha_iterate */ | |
1081 | /* */ | |
1082 | /************************************************************************/ | |
1083 | static void | |
1084 | lpfc_sha_iterate(uint32_t * HashResultPointer, uint32_t * HashWorkingPointer) | |
1085 | { | |
1086 | int t; | |
1087 | uint32_t TEMP; | |
1088 | uint32_t A, B, C, D, E; | |
1089 | t = 16; | |
1090 | do { | |
1091 | HashWorkingPointer[t] = | |
1092 | S(1, | |
1093 | HashWorkingPointer[t - 3] ^ HashWorkingPointer[t - | |
1094 | 8] ^ | |
1095 | HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]); | |
1096 | } while (++t <= 79); | |
1097 | t = 0; | |
1098 | A = HashResultPointer[0]; | |
1099 | B = HashResultPointer[1]; | |
1100 | C = HashResultPointer[2]; | |
1101 | D = HashResultPointer[3]; | |
1102 | E = HashResultPointer[4]; | |
1103 | ||
1104 | do { | |
1105 | if (t < 20) { | |
1106 | TEMP = ((B & C) | ((~B) & D)) + 0x5A827999; | |
1107 | } else if (t < 40) { | |
1108 | TEMP = (B ^ C ^ D) + 0x6ED9EBA1; | |
1109 | } else if (t < 60) { | |
1110 | TEMP = ((B & C) | (B & D) | (C & D)) + 0x8F1BBCDC; | |
1111 | } else { | |
1112 | TEMP = (B ^ C ^ D) + 0xCA62C1D6; | |
1113 | } | |
1114 | TEMP += S(5, A) + E + HashWorkingPointer[t]; | |
1115 | E = D; | |
1116 | D = C; | |
1117 | C = S(30, B); | |
1118 | B = A; | |
1119 | A = TEMP; | |
1120 | } while (++t <= 79); | |
1121 | ||
1122 | HashResultPointer[0] += A; | |
1123 | HashResultPointer[1] += B; | |
1124 | HashResultPointer[2] += C; | |
1125 | HashResultPointer[3] += D; | |
1126 | HashResultPointer[4] += E; | |
1127 | ||
1128 | } | |
1129 | ||
1130 | /************************************************************************/ | |
1131 | /* */ | |
1132 | /* lpfc_challenge_key */ | |
1133 | /* */ | |
1134 | /************************************************************************/ | |
1135 | static void | |
1136 | lpfc_challenge_key(uint32_t * RandomChallenge, uint32_t * HashWorking) | |
1137 | { | |
1138 | *HashWorking = (*RandomChallenge ^ *HashWorking); | |
1139 | } | |
1140 | ||
1141 | /************************************************************************/ | |
1142 | /* */ | |
1143 | /* lpfc_hba_init */ | |
1144 | /* */ | |
1145 | /************************************************************************/ | |
1146 | void | |
1147 | lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit) | |
1148 | { | |
1149 | int t; | |
1150 | uint32_t *HashWorking; | |
1151 | uint32_t *pwwnn = phba->wwnn; | |
1152 | ||
1153 | HashWorking = kmalloc(80 * sizeof(uint32_t), GFP_KERNEL); | |
1154 | if (!HashWorking) | |
1155 | return; | |
1156 | ||
1157 | memset(HashWorking, 0, (80 * sizeof(uint32_t))); | |
1158 | HashWorking[0] = HashWorking[78] = *pwwnn++; | |
1159 | HashWorking[1] = HashWorking[79] = *pwwnn; | |
1160 | ||
1161 | for (t = 0; t < 7; t++) | |
1162 | lpfc_challenge_key(phba->RandomData + t, HashWorking + t); | |
1163 | ||
1164 | lpfc_sha_init(hbainit); | |
1165 | lpfc_sha_iterate(hbainit, HashWorking); | |
1166 | kfree(HashWorking); | |
1167 | } | |
1168 | ||
1169 | static void | |
1170 | lpfc_cleanup(struct lpfc_hba * phba, uint32_t save_bind) | |
1171 | { | |
1172 | struct lpfc_nodelist *ndlp, *next_ndlp; | |
1173 | ||
1174 | /* clean up phba - lpfc specific */ | |
1175 | lpfc_can_disctmo(phba); | |
1176 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpunmap_list, | |
1177 | nlp_listp) { | |
1178 | lpfc_nlp_remove(phba, ndlp); | |
1179 | } | |
1180 | ||
1181 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpmap_list, | |
1182 | nlp_listp) { | |
1183 | lpfc_nlp_remove(phba, ndlp); | |
1184 | } | |
1185 | ||
1186 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list, | |
1187 | nlp_listp) { | |
1188 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | |
1189 | } | |
1190 | ||
1191 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list, | |
1192 | nlp_listp) { | |
1193 | lpfc_nlp_remove(phba, ndlp); | |
1194 | } | |
1195 | ||
1196 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list, | |
1197 | nlp_listp) { | |
1198 | lpfc_nlp_remove(phba, ndlp); | |
1199 | } | |
1200 | ||
1201 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_reglogin_list, | |
1202 | nlp_listp) { | |
1203 | lpfc_nlp_remove(phba, ndlp); | |
1204 | } | |
1205 | ||
1206 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_prli_list, | |
1207 | nlp_listp) { | |
1208 | lpfc_nlp_remove(phba, ndlp); | |
1209 | } | |
1210 | ||
1211 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, | |
1212 | nlp_listp) { | |
1213 | lpfc_nlp_remove(phba, ndlp); | |
1214 | } | |
1215 | ||
1216 | INIT_LIST_HEAD(&phba->fc_nlpmap_list); | |
1217 | INIT_LIST_HEAD(&phba->fc_nlpunmap_list); | |
1218 | INIT_LIST_HEAD(&phba->fc_unused_list); | |
1219 | INIT_LIST_HEAD(&phba->fc_plogi_list); | |
1220 | INIT_LIST_HEAD(&phba->fc_adisc_list); | |
1221 | INIT_LIST_HEAD(&phba->fc_reglogin_list); | |
1222 | INIT_LIST_HEAD(&phba->fc_prli_list); | |
1223 | INIT_LIST_HEAD(&phba->fc_npr_list); | |
1224 | ||
1225 | phba->fc_map_cnt = 0; | |
1226 | phba->fc_unmap_cnt = 0; | |
1227 | phba->fc_plogi_cnt = 0; | |
1228 | phba->fc_adisc_cnt = 0; | |
1229 | phba->fc_reglogin_cnt = 0; | |
1230 | phba->fc_prli_cnt = 0; | |
1231 | phba->fc_npr_cnt = 0; | |
1232 | phba->fc_unused_cnt= 0; | |
1233 | return; | |
1234 | } | |
1235 | ||
1236 | static void | |
1237 | lpfc_establish_link_tmo(unsigned long ptr) | |
1238 | { | |
1239 | struct lpfc_hba *phba = (struct lpfc_hba *)ptr; | |
1240 | unsigned long iflag; | |
1241 | ||
1242 | ||
1243 | /* Re-establishing Link, timer expired */ | |
1244 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | |
1245 | "%d:1300 Re-establishing Link, timer expired " | |
1246 | "Data: x%x x%x\n", | |
1247 | phba->brd_no, phba->fc_flag, phba->hba_state); | |
1248 | spin_lock_irqsave(phba->host->host_lock, iflag); | |
1249 | phba->fc_flag &= ~FC_ESTABLISH_LINK; | |
1250 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | |
1251 | } | |
1252 | ||
1253 | static int | |
1254 | lpfc_stop_timer(struct lpfc_hba * phba) | |
1255 | { | |
1256 | struct lpfc_sli *psli = &phba->sli; | |
1257 | ||
1258 | /* Instead of a timer, this has been converted to a | |
1259 | * deferred procedding list. | |
1260 | */ | |
1261 | while (!list_empty(&phba->freebufList)) { | |
1262 | ||
1263 | struct lpfc_dmabuf *mp = NULL; | |
1264 | ||
1265 | list_remove_head((&phba->freebufList), mp, | |
1266 | struct lpfc_dmabuf, list); | |
1267 | if (mp) { | |
1268 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
1269 | kfree(mp); | |
1270 | } | |
1271 | } | |
1272 | ||
875fbdfe | 1273 | del_timer_sync(&phba->fcp_poll_timer); |
dea3101e | 1274 | del_timer_sync(&phba->fc_estabtmo); |
1275 | del_timer_sync(&phba->fc_disctmo); | |
1276 | del_timer_sync(&phba->fc_fdmitmo); | |
1277 | del_timer_sync(&phba->els_tmofunc); | |
1278 | psli = &phba->sli; | |
1279 | del_timer_sync(&psli->mbox_tmo); | |
1280 | return(1); | |
1281 | } | |
1282 | ||
1283 | int | |
1284 | lpfc_online(struct lpfc_hba * phba) | |
1285 | { | |
1286 | if (!phba) | |
1287 | return 0; | |
1288 | ||
1289 | if (!(phba->fc_flag & FC_OFFLINE_MODE)) | |
1290 | return 0; | |
1291 | ||
1292 | lpfc_printf_log(phba, | |
1293 | KERN_WARNING, | |
1294 | LOG_INIT, | |
1295 | "%d:0458 Bring Adapter online\n", | |
1296 | phba->brd_no); | |
1297 | ||
1298 | if (!lpfc_sli_queue_setup(phba)) | |
1299 | return 1; | |
1300 | ||
1301 | if (lpfc_sli_hba_setup(phba)) /* Initialize the HBA */ | |
1302 | return 1; | |
1303 | ||
1304 | spin_lock_irq(phba->host->host_lock); | |
1305 | phba->fc_flag &= ~FC_OFFLINE_MODE; | |
1306 | spin_unlock_irq(phba->host->host_lock); | |
1307 | ||
dea3101e | 1308 | return 0; |
1309 | } | |
1310 | ||
1311 | int | |
1312 | lpfc_offline(struct lpfc_hba * phba) | |
1313 | { | |
1314 | struct lpfc_sli_ring *pring; | |
1315 | struct lpfc_sli *psli; | |
1316 | unsigned long iflag; | |
688a8863 JS |
1317 | int i; |
1318 | int cnt = 0; | |
dea3101e | 1319 | |
1320 | if (!phba) | |
1321 | return 0; | |
1322 | ||
1323 | if (phba->fc_flag & FC_OFFLINE_MODE) | |
1324 | return 0; | |
1325 | ||
dea3101e | 1326 | psli = &phba->sli; |
dea3101e | 1327 | |
1328 | lpfc_linkdown(phba); | |
b4c02652 | 1329 | lpfc_sli_flush_mbox_queue(phba); |
dea3101e | 1330 | |
688a8863 JS |
1331 | for (i = 0; i < psli->num_rings; i++) { |
1332 | pring = &psli->ring[i]; | |
1333 | /* The linkdown event takes 30 seconds to timeout. */ | |
1334 | while (pring->txcmplq_cnt) { | |
1335 | mdelay(10); | |
1336 | if (cnt++ > 3000) { | |
1337 | lpfc_printf_log(phba, | |
1338 | KERN_WARNING, LOG_INIT, | |
1339 | "%d:0466 Outstanding IO when " | |
1340 | "bringing Adapter offline\n", | |
1341 | phba->brd_no); | |
1342 | break; | |
1343 | } | |
1344 | } | |
dea3101e | 1345 | } |
1346 | ||
688a8863 | 1347 | |
dea3101e | 1348 | /* stop all timers associated with this hba */ |
1349 | lpfc_stop_timer(phba); | |
1350 | phba->work_hba_events = 0; | |
33ccf8d1 | 1351 | phba->work_ha = 0; |
dea3101e | 1352 | |
1353 | lpfc_printf_log(phba, | |
1354 | KERN_WARNING, | |
1355 | LOG_INIT, | |
1356 | "%d:0460 Bring Adapter offline\n", | |
1357 | phba->brd_no); | |
1358 | ||
1359 | /* Bring down the SLI Layer and cleanup. The HBA is offline | |
1360 | now. */ | |
1361 | lpfc_sli_hba_down(phba); | |
1362 | lpfc_cleanup(phba, 1); | |
1363 | spin_lock_irqsave(phba->host->host_lock, iflag); | |
1364 | phba->fc_flag |= FC_OFFLINE_MODE; | |
1365 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | |
1366 | return 0; | |
1367 | } | |
1368 | ||
1369 | /****************************************************************************** | |
1370 | * Function name: lpfc_scsi_free | |
1371 | * | |
1372 | * Description: Called from lpfc_pci_remove_one free internal driver resources | |
1373 | * | |
1374 | ******************************************************************************/ | |
1375 | static int | |
1376 | lpfc_scsi_free(struct lpfc_hba * phba) | |
1377 | { | |
1378 | struct lpfc_scsi_buf *sb, *sb_next; | |
1379 | struct lpfc_iocbq *io, *io_next; | |
1380 | ||
1381 | spin_lock_irq(phba->host->host_lock); | |
1382 | /* Release all the lpfc_scsi_bufs maintained by this host. */ | |
1383 | list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list, list) { | |
1384 | list_del(&sb->list); | |
1385 | pci_pool_free(phba->lpfc_scsi_dma_buf_pool, sb->data, | |
1386 | sb->dma_handle); | |
1387 | kfree(sb); | |
1388 | phba->total_scsi_bufs--; | |
1389 | } | |
1390 | ||
1391 | /* Release all the lpfc_iocbq entries maintained by this host. */ | |
1392 | list_for_each_entry_safe(io, io_next, &phba->lpfc_iocb_list, list) { | |
1393 | list_del(&io->list); | |
1394 | kfree(io); | |
1395 | phba->total_iocbq_bufs--; | |
1396 | } | |
1397 | ||
1398 | spin_unlock_irq(phba->host->host_lock); | |
1399 | ||
1400 | return 0; | |
1401 | } | |
1402 | ||
1403 | ||
1404 | static int __devinit | |
1405 | lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |
1406 | { | |
1407 | struct Scsi_Host *host; | |
1408 | struct lpfc_hba *phba; | |
1409 | struct lpfc_sli *psli; | |
1410 | struct lpfc_iocbq *iocbq_entry = NULL, *iocbq_next = NULL; | |
1411 | unsigned long bar0map_len, bar2map_len; | |
1412 | int error = -ENODEV, retval; | |
1413 | int i; | |
604a3e30 | 1414 | uint16_t iotag; |
dea3101e | 1415 | |
1416 | if (pci_enable_device(pdev)) | |
1417 | goto out; | |
1418 | if (pci_request_regions(pdev, LPFC_DRIVER_NAME)) | |
1419 | goto out_disable_device; | |
1420 | ||
f888ba3c | 1421 | host = scsi_host_alloc(&lpfc_template, sizeof (struct lpfc_hba)); |
dea3101e | 1422 | if (!host) |
1423 | goto out_release_regions; | |
1424 | ||
1425 | phba = (struct lpfc_hba*)host->hostdata; | |
1426 | memset(phba, 0, sizeof (struct lpfc_hba)); | |
dea3101e | 1427 | phba->host = host; |
1428 | ||
1429 | phba->fc_flag |= FC_LOADING; | |
1430 | phba->pcidev = pdev; | |
1431 | ||
1432 | /* Assign an unused board number */ | |
1433 | if (!idr_pre_get(&lpfc_hba_index, GFP_KERNEL)) | |
1434 | goto out_put_host; | |
1435 | ||
1436 | error = idr_get_new(&lpfc_hba_index, NULL, &phba->brd_no); | |
1437 | if (error) | |
1438 | goto out_put_host; | |
1439 | ||
1440 | host->unique_id = phba->brd_no; | |
dea3101e | 1441 | INIT_LIST_HEAD(&phba->ctrspbuflist); |
1442 | INIT_LIST_HEAD(&phba->rnidrspbuflist); | |
1443 | INIT_LIST_HEAD(&phba->freebufList); | |
1444 | ||
1445 | /* Initialize timers used by driver */ | |
1446 | init_timer(&phba->fc_estabtmo); | |
1447 | phba->fc_estabtmo.function = lpfc_establish_link_tmo; | |
1448 | phba->fc_estabtmo.data = (unsigned long)phba; | |
1449 | init_timer(&phba->fc_disctmo); | |
1450 | phba->fc_disctmo.function = lpfc_disc_timeout; | |
1451 | phba->fc_disctmo.data = (unsigned long)phba; | |
1452 | ||
1453 | init_timer(&phba->fc_fdmitmo); | |
1454 | phba->fc_fdmitmo.function = lpfc_fdmi_tmo; | |
1455 | phba->fc_fdmitmo.data = (unsigned long)phba; | |
1456 | init_timer(&phba->els_tmofunc); | |
1457 | phba->els_tmofunc.function = lpfc_els_timeout; | |
1458 | phba->els_tmofunc.data = (unsigned long)phba; | |
1459 | psli = &phba->sli; | |
1460 | init_timer(&psli->mbox_tmo); | |
1461 | psli->mbox_tmo.function = lpfc_mbox_timeout; | |
1462 | psli->mbox_tmo.data = (unsigned long)phba; | |
1463 | ||
875fbdfe JSEC |
1464 | init_timer(&phba->fcp_poll_timer); |
1465 | phba->fcp_poll_timer.function = lpfc_poll_timeout; | |
1466 | phba->fcp_poll_timer.data = (unsigned long)phba; | |
1467 | ||
dea3101e | 1468 | /* |
1469 | * Get all the module params for configuring this host and then | |
1470 | * establish the host parameters. | |
1471 | */ | |
1472 | lpfc_get_cfgparam(phba); | |
1473 | ||
1474 | host->max_id = LPFC_MAX_TARGET; | |
1475 | host->max_lun = phba->cfg_max_luns; | |
1476 | host->this_id = -1; | |
1477 | ||
1478 | /* Initialize all internally managed lists. */ | |
1479 | INIT_LIST_HEAD(&phba->fc_nlpmap_list); | |
1480 | INIT_LIST_HEAD(&phba->fc_nlpunmap_list); | |
1481 | INIT_LIST_HEAD(&phba->fc_unused_list); | |
1482 | INIT_LIST_HEAD(&phba->fc_plogi_list); | |
1483 | INIT_LIST_HEAD(&phba->fc_adisc_list); | |
1484 | INIT_LIST_HEAD(&phba->fc_reglogin_list); | |
1485 | INIT_LIST_HEAD(&phba->fc_prli_list); | |
1486 | INIT_LIST_HEAD(&phba->fc_npr_list); | |
1487 | ||
1488 | ||
1489 | pci_set_master(pdev); | |
1490 | retval = pci_set_mwi(pdev); | |
1491 | if (retval) | |
1492 | dev_printk(KERN_WARNING, &pdev->dev, | |
1493 | "Warning: pci_set_mwi returned %d\n", retval); | |
1494 | ||
1495 | if (pci_set_dma_mask(phba->pcidev, DMA_64BIT_MASK) != 0) | |
1496 | if (pci_set_dma_mask(phba->pcidev, DMA_32BIT_MASK) != 0) | |
1497 | goto out_idr_remove; | |
1498 | ||
1499 | /* | |
1500 | * Get the bus address of Bar0 and Bar2 and the number of bytes | |
1501 | * required by each mapping. | |
1502 | */ | |
1503 | phba->pci_bar0_map = pci_resource_start(phba->pcidev, 0); | |
1504 | bar0map_len = pci_resource_len(phba->pcidev, 0); | |
1505 | ||
1506 | phba->pci_bar2_map = pci_resource_start(phba->pcidev, 2); | |
1507 | bar2map_len = pci_resource_len(phba->pcidev, 2); | |
1508 | ||
901a920f | 1509 | /* Map HBA SLIM to a kernel virtual address. */ |
dea3101e | 1510 | phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); |
901a920f JW |
1511 | if (!phba->slim_memmap_p) { |
1512 | error = -ENODEV; | |
1513 | dev_printk(KERN_ERR, &pdev->dev, | |
1514 | "ioremap failed for SLIM memory.\n"); | |
1515 | goto out_idr_remove; | |
1516 | } | |
1517 | ||
1518 | /* Map HBA Control Registers to a kernel virtual address. */ | |
dea3101e | 1519 | phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); |
901a920f JW |
1520 | if (!phba->ctrl_regs_memmap_p) { |
1521 | error = -ENODEV; | |
1522 | dev_printk(KERN_ERR, &pdev->dev, | |
1523 | "ioremap failed for HBA control registers.\n"); | |
1524 | goto out_iounmap_slim; | |
1525 | } | |
dea3101e | 1526 | |
1527 | /* Allocate memory for SLI-2 structures */ | |
1528 | phba->slim2p = dma_alloc_coherent(&phba->pcidev->dev, SLI2_SLIM_SIZE, | |
1529 | &phba->slim2p_mapping, GFP_KERNEL); | |
1530 | if (!phba->slim2p) | |
1531 | goto out_iounmap; | |
1532 | ||
f91b392c | 1533 | memset(phba->slim2p, 0, SLI2_SLIM_SIZE); |
dea3101e | 1534 | |
1535 | /* Initialize the SLI Layer to run with lpfc HBAs. */ | |
1536 | lpfc_sli_setup(phba); | |
1537 | lpfc_sli_queue_setup(phba); | |
1538 | ||
1539 | error = lpfc_mem_alloc(phba); | |
1540 | if (error) | |
1541 | goto out_free_slim; | |
1542 | ||
1543 | /* Initialize and populate the iocb list per host. */ | |
1544 | INIT_LIST_HEAD(&phba->lpfc_iocb_list); | |
1545 | for (i = 0; i < LPFC_IOCB_LIST_CNT; i++) { | |
1546 | iocbq_entry = kmalloc(sizeof(struct lpfc_iocbq), GFP_KERNEL); | |
1547 | if (iocbq_entry == NULL) { | |
1548 | printk(KERN_ERR "%s: only allocated %d iocbs of " | |
1549 | "expected %d count. Unloading driver.\n", | |
1550 | __FUNCTION__, i, LPFC_IOCB_LIST_CNT); | |
1551 | error = -ENOMEM; | |
1552 | goto out_free_iocbq; | |
1553 | } | |
1554 | ||
1555 | memset(iocbq_entry, 0, sizeof(struct lpfc_iocbq)); | |
604a3e30 JB |
1556 | iotag = lpfc_sli_next_iotag(phba, iocbq_entry); |
1557 | if (iotag == 0) { | |
1558 | kfree (iocbq_entry); | |
1559 | printk(KERN_ERR "%s: failed to allocate IOTAG. " | |
1560 | "Unloading driver.\n", | |
1561 | __FUNCTION__); | |
1562 | error = -ENOMEM; | |
1563 | goto out_free_iocbq; | |
1564 | } | |
dea3101e | 1565 | spin_lock_irq(phba->host->host_lock); |
1566 | list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); | |
1567 | phba->total_iocbq_bufs++; | |
1568 | spin_unlock_irq(phba->host->host_lock); | |
1569 | } | |
1570 | ||
1571 | /* Initialize HBA structure */ | |
1572 | phba->fc_edtov = FF_DEF_EDTOV; | |
1573 | phba->fc_ratov = FF_DEF_RATOV; | |
1574 | phba->fc_altov = FF_DEF_ALTOV; | |
1575 | phba->fc_arbtov = FF_DEF_ARBTOV; | |
1576 | ||
1577 | INIT_LIST_HEAD(&phba->work_list); | |
1578 | phba->work_ha_mask = (HA_ERATT|HA_MBATT|HA_LATT); | |
1579 | phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); | |
1580 | ||
1581 | /* Startup the kernel thread for this host adapter. */ | |
1582 | phba->worker_thread = kthread_run(lpfc_do_work, phba, | |
1583 | "lpfc_worker_%d", phba->brd_no); | |
1584 | if (IS_ERR(phba->worker_thread)) { | |
1585 | error = PTR_ERR(phba->worker_thread); | |
1586 | goto out_free_iocbq; | |
1587 | } | |
1588 | ||
8f6d98d2 JS |
1589 | /* |
1590 | * Set initial can_queue value since 0 is no longer supported and | |
1591 | * scsi_add_host will fail. This will be adjusted later based on the | |
1592 | * max xri value determined in hba setup. | |
1593 | */ | |
dea3101e | 1594 | host->can_queue = phba->cfg_hba_queue_depth - 10; |
1595 | ||
1596 | /* Tell the midlayer we support 16 byte commands */ | |
1597 | host->max_cmd_len = 16; | |
1598 | ||
1599 | /* Initialize the list of scsi buffers used by driver for scsi IO. */ | |
875fbdfe | 1600 | spin_lock_init(&phba->scsi_buf_list_lock); |
dea3101e | 1601 | INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list); |
1602 | ||
1603 | host->transportt = lpfc_transport_template; | |
dea3101e | 1604 | pci_set_drvdata(pdev, host); |
1605 | error = scsi_add_host(host, &pdev->dev); | |
1606 | if (error) | |
1607 | goto out_kthread_stop; | |
1608 | ||
1609 | error = lpfc_alloc_sysfs_attr(phba); | |
1610 | if (error) | |
defbcf11 | 1611 | goto out_remove_host; |
dea3101e | 1612 | |
4ff43246 JS |
1613 | if (phba->cfg_use_msi) { |
1614 | error = pci_enable_msi(phba->pcidev); | |
1615 | if (error) | |
1616 | lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "%d:0452 " | |
1617 | "Enable MSI failed, continuing with " | |
1618 | "IRQ\n", phba->brd_no); | |
1619 | } | |
1620 | ||
1d6f359a | 1621 | error = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED, |
dea3101e | 1622 | LPFC_DRIVER_NAME, phba); |
1623 | if (error) { | |
1624 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | |
1625 | "%d:0451 Enable interrupt handler failed\n", | |
1626 | phba->brd_no); | |
1627 | goto out_free_sysfs_attr; | |
1628 | } | |
1629 | phba->MBslimaddr = phba->slim_memmap_p; | |
1630 | phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; | |
1631 | phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; | |
1632 | phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; | |
1633 | phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; | |
1634 | ||
1635 | error = lpfc_sli_hba_setup(phba); | |
defbcf11 JS |
1636 | if (error) { |
1637 | error = -ENODEV; | |
dea3101e | 1638 | goto out_free_irq; |
defbcf11 | 1639 | } |
dea3101e | 1640 | |
8f6d98d2 JS |
1641 | /* |
1642 | * hba setup may have changed the hba_queue_depth so we need to adjust | |
1643 | * the value of can_queue. | |
1644 | */ | |
1645 | host->can_queue = phba->cfg_hba_queue_depth - 10; | |
1646 | ||
ce8b3ce5 JS |
1647 | lpfc_discovery_wait(phba); |
1648 | ||
875fbdfe JSEC |
1649 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) { |
1650 | spin_lock_irq(phba->host->host_lock); | |
1651 | lpfc_poll_start_timer(phba); | |
1652 | spin_unlock_irq(phba->host->host_lock); | |
1653 | } | |
1654 | ||
dea3101e | 1655 | /* |
1656 | * set fixed host attributes | |
1657 | * Must done after lpfc_sli_hba_setup() | |
1658 | */ | |
1659 | ||
68ce1eb5 AM |
1660 | fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.u.wwn); |
1661 | fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.u.wwn); | |
dea3101e | 1662 | fc_host_supported_classes(host) = FC_COS_CLASS3; |
1663 | ||
1664 | memset(fc_host_supported_fc4s(host), 0, | |
1665 | sizeof(fc_host_supported_fc4s(host))); | |
1666 | fc_host_supported_fc4s(host)[2] = 1; | |
1667 | fc_host_supported_fc4s(host)[7] = 1; | |
1668 | ||
1669 | lpfc_get_hba_sym_node_name(phba, fc_host_symbolic_name(host)); | |
1670 | ||
1671 | fc_host_supported_speeds(host) = 0; | |
74b72a59 | 1672 | if (phba->lmt & LMT_10Gb) |
dea3101e | 1673 | fc_host_supported_speeds(host) |= FC_PORTSPEED_10GBIT; |
74b72a59 | 1674 | if (phba->lmt & LMT_4Gb) |
dea3101e | 1675 | fc_host_supported_speeds(host) |= FC_PORTSPEED_4GBIT; |
74b72a59 | 1676 | if (phba->lmt & LMT_2Gb) |
dea3101e | 1677 | fc_host_supported_speeds(host) |= FC_PORTSPEED_2GBIT; |
74b72a59 JW |
1678 | if (phba->lmt & LMT_1Gb) |
1679 | fc_host_supported_speeds(host) |= FC_PORTSPEED_1GBIT; | |
dea3101e | 1680 | |
1681 | fc_host_maxframe_size(host) = | |
1682 | ((((uint32_t) phba->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) | | |
1683 | (uint32_t) phba->fc_sparam.cmn.bbRcvSizeLsb); | |
1684 | ||
1685 | /* This value is also unchanging */ | |
1686 | memset(fc_host_active_fc4s(host), 0, | |
1687 | sizeof(fc_host_active_fc4s(host))); | |
1688 | fc_host_active_fc4s(host)[2] = 1; | |
1689 | fc_host_active_fc4s(host)[7] = 1; | |
1690 | ||
1691 | spin_lock_irq(phba->host->host_lock); | |
1692 | phba->fc_flag &= ~FC_LOADING; | |
1693 | spin_unlock_irq(phba->host->host_lock); | |
1694 | return 0; | |
1695 | ||
1696 | out_free_irq: | |
1697 | lpfc_stop_timer(phba); | |
1698 | phba->work_hba_events = 0; | |
1699 | free_irq(phba->pcidev->irq, phba); | |
4ff43246 | 1700 | pci_disable_msi(phba->pcidev); |
dea3101e | 1701 | out_free_sysfs_attr: |
1702 | lpfc_free_sysfs_attr(phba); | |
defbcf11 JS |
1703 | out_remove_host: |
1704 | fc_remove_host(phba->host); | |
1705 | scsi_remove_host(phba->host); | |
dea3101e | 1706 | out_kthread_stop: |
1707 | kthread_stop(phba->worker_thread); | |
1708 | out_free_iocbq: | |
1709 | list_for_each_entry_safe(iocbq_entry, iocbq_next, | |
1710 | &phba->lpfc_iocb_list, list) { | |
1711 | spin_lock_irq(phba->host->host_lock); | |
1712 | kfree(iocbq_entry); | |
1713 | phba->total_iocbq_bufs--; | |
1714 | spin_unlock_irq(phba->host->host_lock); | |
1715 | } | |
1716 | lpfc_mem_free(phba); | |
1717 | out_free_slim: | |
1718 | dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, phba->slim2p, | |
1719 | phba->slim2p_mapping); | |
1720 | out_iounmap: | |
1721 | iounmap(phba->ctrl_regs_memmap_p); | |
901a920f | 1722 | out_iounmap_slim: |
dea3101e | 1723 | iounmap(phba->slim_memmap_p); |
1724 | out_idr_remove: | |
1725 | idr_remove(&lpfc_hba_index, phba->brd_no); | |
1726 | out_put_host: | |
defbcf11 | 1727 | phba->host = NULL; |
dea3101e | 1728 | scsi_host_put(host); |
1729 | out_release_regions: | |
1730 | pci_release_regions(pdev); | |
1731 | out_disable_device: | |
1732 | pci_disable_device(pdev); | |
1733 | out: | |
defbcf11 | 1734 | pci_set_drvdata(pdev, NULL); |
dea3101e | 1735 | return error; |
1736 | } | |
1737 | ||
1738 | static void __devexit | |
1739 | lpfc_pci_remove_one(struct pci_dev *pdev) | |
1740 | { | |
1741 | struct Scsi_Host *host = pci_get_drvdata(pdev); | |
7f0b5b19 | 1742 | struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; |
dea3101e | 1743 | unsigned long iflag; |
1744 | ||
1745 | lpfc_free_sysfs_attr(phba); | |
1746 | ||
1747 | spin_lock_irqsave(phba->host->host_lock, iflag); | |
1748 | phba->fc_flag |= FC_UNLOADING; | |
1749 | ||
1750 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | |
1751 | ||
1752 | fc_remove_host(phba->host); | |
1753 | scsi_remove_host(phba->host); | |
1754 | ||
1755 | kthread_stop(phba->worker_thread); | |
1756 | ||
1757 | /* | |
1758 | * Bring down the SLI Layer. This step disable all interrupts, | |
1759 | * clears the rings, discards all mailbox commands, and resets | |
1760 | * the HBA. | |
1761 | */ | |
1762 | lpfc_sli_hba_down(phba); | |
41415862 | 1763 | lpfc_sli_brdrestart(phba); |
dea3101e | 1764 | |
1765 | /* Release the irq reservation */ | |
1766 | free_irq(phba->pcidev->irq, phba); | |
4ff43246 | 1767 | pci_disable_msi(phba->pcidev); |
dea3101e | 1768 | |
1769 | lpfc_cleanup(phba, 0); | |
1770 | lpfc_stop_timer(phba); | |
1771 | phba->work_hba_events = 0; | |
1772 | ||
1773 | /* | |
1774 | * Call scsi_free before mem_free since scsi bufs are released to their | |
1775 | * corresponding pools here. | |
1776 | */ | |
1777 | lpfc_scsi_free(phba); | |
1778 | lpfc_mem_free(phba); | |
1779 | ||
1780 | /* Free resources associated with SLI2 interface */ | |
1781 | dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, | |
1782 | phba->slim2p, phba->slim2p_mapping); | |
1783 | ||
1784 | /* unmap adapter SLIM and Control Registers */ | |
1785 | iounmap(phba->ctrl_regs_memmap_p); | |
1786 | iounmap(phba->slim_memmap_p); | |
1787 | ||
1788 | pci_release_regions(phba->pcidev); | |
1789 | pci_disable_device(phba->pcidev); | |
1790 | ||
1791 | idr_remove(&lpfc_hba_index, phba->brd_no); | |
1792 | scsi_host_put(phba->host); | |
1793 | ||
1794 | pci_set_drvdata(pdev, NULL); | |
1795 | } | |
1796 | ||
1797 | static struct pci_device_id lpfc_id_table[] = { | |
1798 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_VIPER, | |
1799 | PCI_ANY_ID, PCI_ANY_ID, }, | |
06325e74 JSEC |
1800 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_FIREFLY, |
1801 | PCI_ANY_ID, PCI_ANY_ID, }, | |
dea3101e | 1802 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_THOR, |
1803 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1804 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PEGASUS, | |
1805 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1806 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_CENTAUR, | |
1807 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1808 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_DRAGONFLY, | |
1809 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1810 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SUPERFLY, | |
1811 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1812 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_RFLY, | |
1813 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1814 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PFLY, | |
1815 | PCI_ANY_ID, PCI_ANY_ID, }, | |
e4adb204 JSEC |
1816 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE, |
1817 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1818 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_SCSP, | |
1819 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1820 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_DCSP, | |
1821 | PCI_ANY_ID, PCI_ANY_ID, }, | |
dea3101e | 1822 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS, |
1823 | PCI_ANY_ID, PCI_ANY_ID, }, | |
e4adb204 JSEC |
1824 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_SCSP, |
1825 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1826 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_DCSP, | |
1827 | PCI_ANY_ID, PCI_ANY_ID, }, | |
dea3101e | 1828 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BMID, |
1829 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1830 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BSMB, | |
1831 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1832 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR, | |
1833 | PCI_ANY_ID, PCI_ANY_ID, }, | |
e4adb204 JSEC |
1834 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_SCSP, |
1835 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1836 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_DCSP, | |
1837 | PCI_ANY_ID, PCI_ANY_ID, }, | |
dea3101e | 1838 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZMID, |
1839 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1840 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZSMB, | |
1841 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1842 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_TFLY, | |
1843 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1844 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP101, | |
1845 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1846 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP10000S, | |
1847 | PCI_ANY_ID, PCI_ANY_ID, }, | |
e4adb204 JSEC |
1848 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP11000S, |
1849 | PCI_ANY_ID, PCI_ANY_ID, }, | |
1850 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LPE11000S, | |
1851 | PCI_ANY_ID, PCI_ANY_ID, }, | |
dea3101e | 1852 | { 0 } |
1853 | }; | |
1854 | ||
1855 | MODULE_DEVICE_TABLE(pci, lpfc_id_table); | |
1856 | ||
1857 | static struct pci_driver lpfc_driver = { | |
1858 | .name = LPFC_DRIVER_NAME, | |
1859 | .id_table = lpfc_id_table, | |
1860 | .probe = lpfc_pci_probe_one, | |
1861 | .remove = __devexit_p(lpfc_pci_remove_one), | |
1862 | }; | |
1863 | ||
1864 | static int __init | |
1865 | lpfc_init(void) | |
1866 | { | |
1867 | int error = 0; | |
1868 | ||
1869 | printk(LPFC_MODULE_DESC "\n"); | |
c44ce173 | 1870 | printk(LPFC_COPYRIGHT "\n"); |
dea3101e | 1871 | |
1872 | lpfc_transport_template = | |
1873 | fc_attach_transport(&lpfc_transport_functions); | |
1874 | if (!lpfc_transport_template) | |
1875 | return -ENOMEM; | |
1876 | error = pci_register_driver(&lpfc_driver); | |
1877 | if (error) | |
1878 | fc_release_transport(lpfc_transport_template); | |
1879 | ||
1880 | return error; | |
1881 | } | |
1882 | ||
1883 | static void __exit | |
1884 | lpfc_exit(void) | |
1885 | { | |
1886 | pci_unregister_driver(&lpfc_driver); | |
1887 | fc_release_transport(lpfc_transport_template); | |
1888 | } | |
1889 | ||
1890 | module_init(lpfc_init); | |
1891 | module_exit(lpfc_exit); | |
1892 | MODULE_LICENSE("GPL"); | |
1893 | MODULE_DESCRIPTION(LPFC_MODULE_DESC); | |
1894 | MODULE_AUTHOR("Emulex Corporation - tech.support@emulex.com"); | |
1895 | MODULE_VERSION("0:" LPFC_DRIVER_VERSION); |