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/pci.h> | |
24 | #include <linux/kthread.h> | |
25 | #include <linux/interrupt.h> | |
26 | ||
91886523 | 27 | #include <scsi/scsi.h> |
dea3101e | 28 | #include <scsi/scsi_device.h> |
29 | #include <scsi/scsi_host.h> | |
30 | #include <scsi/scsi_transport_fc.h> | |
31 | ||
32 | #include "lpfc_hw.h" | |
33 | #include "lpfc_disc.h" | |
34 | #include "lpfc_sli.h" | |
35 | #include "lpfc_scsi.h" | |
36 | #include "lpfc.h" | |
37 | #include "lpfc_logmsg.h" | |
38 | #include "lpfc_crtn.h" | |
39 | ||
40 | /* AlpaArray for assignment of scsid for scan-down and bind_method */ | |
41 | static uint8_t lpfcAlpaArray[] = { | |
42 | 0xEF, 0xE8, 0xE4, 0xE2, 0xE1, 0xE0, 0xDC, 0xDA, 0xD9, 0xD6, | |
43 | 0xD5, 0xD4, 0xD3, 0xD2, 0xD1, 0xCE, 0xCD, 0xCC, 0xCB, 0xCA, | |
44 | 0xC9, 0xC7, 0xC6, 0xC5, 0xC3, 0xBC, 0xBA, 0xB9, 0xB6, 0xB5, | |
45 | 0xB4, 0xB3, 0xB2, 0xB1, 0xAE, 0xAD, 0xAC, 0xAB, 0xAA, 0xA9, | |
46 | 0xA7, 0xA6, 0xA5, 0xA3, 0x9F, 0x9E, 0x9D, 0x9B, 0x98, 0x97, | |
47 | 0x90, 0x8F, 0x88, 0x84, 0x82, 0x81, 0x80, 0x7C, 0x7A, 0x79, | |
48 | 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x6E, 0x6D, 0x6C, 0x6B, | |
49 | 0x6A, 0x69, 0x67, 0x66, 0x65, 0x63, 0x5C, 0x5A, 0x59, 0x56, | |
50 | 0x55, 0x54, 0x53, 0x52, 0x51, 0x4E, 0x4D, 0x4C, 0x4B, 0x4A, | |
51 | 0x49, 0x47, 0x46, 0x45, 0x43, 0x3C, 0x3A, 0x39, 0x36, 0x35, | |
52 | 0x34, 0x33, 0x32, 0x31, 0x2E, 0x2D, 0x2C, 0x2B, 0x2A, 0x29, | |
53 | 0x27, 0x26, 0x25, 0x23, 0x1F, 0x1E, 0x1D, 0x1B, 0x18, 0x17, | |
54 | 0x10, 0x0F, 0x08, 0x04, 0x02, 0x01 | |
55 | }; | |
56 | ||
57 | static void lpfc_disc_timeout_handler(struct lpfc_hba *); | |
58 | ||
c01f3208 JS |
59 | void |
60 | lpfc_terminate_rport_io(struct fc_rport *rport) | |
dea3101e | 61 | { |
c01f3208 JS |
62 | struct lpfc_rport_data *rdata; |
63 | struct lpfc_nodelist * ndlp; | |
64 | struct lpfc_hba *phba; | |
dea3101e | 65 | |
c01f3208 JS |
66 | rdata = rport->dd_data; |
67 | ndlp = rdata->pnode; | |
68 | ||
69 | if (!ndlp) { | |
70 | if (rport->roles & FC_RPORT_ROLE_FCP_TARGET) | |
71 | printk(KERN_ERR "Cannot find remote node" | |
72 | " to terminate I/O Data x%x\n", | |
73 | rport->port_id); | |
dea3101e | 74 | return; |
75 | } | |
76 | ||
c01f3208 JS |
77 | phba = ndlp->nlp_phba; |
78 | ||
1a169689 | 79 | spin_lock_irq(phba->host->host_lock); |
c01f3208 JS |
80 | if (ndlp->nlp_sid != NLP_NO_SID) { |
81 | lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], | |
82 | ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT); | |
83 | } | |
84 | spin_unlock_irq(phba->host->host_lock); | |
85 | ||
86 | return; | |
87 | } | |
88 | ||
89 | /* | |
90 | * This function will be called when dev_loss_tmo fire. | |
91 | */ | |
92 | void | |
93 | lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) | |
94 | { | |
95 | struct lpfc_rport_data *rdata; | |
96 | struct lpfc_nodelist * ndlp; | |
97 | uint8_t *name; | |
98 | int warn_on = 0; | |
99 | struct lpfc_hba *phba; | |
100 | ||
101 | rdata = rport->dd_data; | |
102 | ndlp = rdata->pnode; | |
1a169689 | 103 | |
c01f3208 JS |
104 | if (!ndlp) { |
105 | if (rport->roles & FC_RPORT_ROLE_FCP_TARGET) | |
106 | printk(KERN_ERR "Cannot find remote node" | |
107 | " for rport in dev_loss_tmo_callbk x%x\n", | |
108 | rport->port_id); | |
109 | return; | |
110 | } | |
111 | ||
112 | name = (uint8_t *)&ndlp->nlp_portname; | |
113 | phba = ndlp->nlp_phba; | |
114 | ||
115 | spin_lock_irq(phba->host->host_lock); | |
dea3101e | 116 | |
117 | if (ndlp->nlp_sid != NLP_NO_SID) { | |
6e8215e4 | 118 | warn_on = 1; |
dea3101e | 119 | /* flush the target */ |
120 | lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], | |
121 | ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT); | |
122 | } | |
c01f3208 JS |
123 | if (phba->fc_flag & FC_UNLOADING) |
124 | warn_on = 0; | |
125 | ||
dea3101e | 126 | spin_unlock_irq(phba->host->host_lock); |
127 | ||
6e8215e4 JSEC |
128 | if (warn_on) { |
129 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | |
c01f3208 | 130 | "%d:0203 Devloss timeout on " |
488d1469 JS |
131 | "WWPN %x:%x:%x:%x:%x:%x:%x:%x " |
132 | "NPort x%x Data: x%x x%x x%x\n", | |
133 | phba->brd_no, | |
134 | *name, *(name+1), *(name+2), *(name+3), | |
135 | *(name+4), *(name+5), *(name+6), *(name+7), | |
136 | ndlp->nlp_DID, ndlp->nlp_flag, | |
6e8215e4 JSEC |
137 | ndlp->nlp_state, ndlp->nlp_rpi); |
138 | } else { | |
139 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, | |
c01f3208 | 140 | "%d:0204 Devloss timeout on " |
488d1469 JS |
141 | "WWPN %x:%x:%x:%x:%x:%x:%x:%x " |
142 | "NPort x%x Data: x%x x%x x%x\n", | |
143 | phba->brd_no, | |
144 | *name, *(name+1), *(name+2), *(name+3), | |
145 | *(name+4), *(name+5), *(name+6), *(name+7), | |
146 | ndlp->nlp_DID, ndlp->nlp_flag, | |
6e8215e4 JSEC |
147 | ndlp->nlp_state, ndlp->nlp_rpi); |
148 | } | |
149 | ||
1dcb58e5 JS |
150 | if (!(phba->fc_flag & FC_UNLOADING) && |
151 | !(ndlp->nlp_flag & NLP_DELAY_TMO) && | |
152 | !(ndlp->nlp_flag & NLP_NPR_2B_DISC)) | |
c01f3208 | 153 | lpfc_disc_state_machine(phba, ndlp, NULL, NLP_EVT_DEVICE_RM); |
1dcb58e5 JS |
154 | else { |
155 | rdata->pnode = NULL; | |
156 | ndlp->rport = NULL; | |
157 | } | |
c01f3208 | 158 | |
dea3101e | 159 | return; |
160 | } | |
161 | ||
162 | static void | |
163 | lpfc_work_list_done(struct lpfc_hba * phba) | |
164 | { | |
165 | struct lpfc_work_evt *evtp = NULL; | |
166 | struct lpfc_nodelist *ndlp; | |
167 | int free_evt; | |
168 | ||
169 | spin_lock_irq(phba->host->host_lock); | |
170 | while(!list_empty(&phba->work_list)) { | |
171 | list_remove_head((&phba->work_list), evtp, typeof(*evtp), | |
172 | evt_listp); | |
173 | spin_unlock_irq(phba->host->host_lock); | |
174 | free_evt = 1; | |
2fe165b6 | 175 | switch (evtp->evt) { |
dea3101e | 176 | case LPFC_EVT_ELS_RETRY: |
177 | ndlp = (struct lpfc_nodelist *)(evtp->evt_arg1); | |
178 | lpfc_els_retry_delay_handler(ndlp); | |
179 | free_evt = 0; | |
180 | break; | |
181 | case LPFC_EVT_ONLINE: | |
41415862 JW |
182 | if (phba->hba_state < LPFC_LINK_DOWN) |
183 | *(int *)(evtp->evt_arg1) = lpfc_online(phba); | |
184 | else | |
185 | *(int *)(evtp->evt_arg1) = 0; | |
dea3101e | 186 | complete((struct completion *)(evtp->evt_arg2)); |
187 | break; | |
188 | case LPFC_EVT_OFFLINE: | |
41415862 JW |
189 | if (phba->hba_state >= LPFC_LINK_DOWN) |
190 | lpfc_offline(phba); | |
191 | lpfc_sli_brdrestart(phba); | |
192 | *(int *)(evtp->evt_arg1) = | |
193 | lpfc_sli_brdready(phba,HS_FFRDY | HS_MBRDY); | |
194 | complete((struct completion *)(evtp->evt_arg2)); | |
195 | break; | |
196 | case LPFC_EVT_WARM_START: | |
197 | if (phba->hba_state >= LPFC_LINK_DOWN) | |
198 | lpfc_offline(phba); | |
9290831f | 199 | lpfc_reset_barrier(phba); |
41415862 JW |
200 | lpfc_sli_brdreset(phba); |
201 | lpfc_hba_down_post(phba); | |
202 | *(int *)(evtp->evt_arg1) = | |
203 | lpfc_sli_brdready(phba, HS_MBRDY); | |
204 | complete((struct completion *)(evtp->evt_arg2)); | |
205 | break; | |
206 | case LPFC_EVT_KILL: | |
207 | if (phba->hba_state >= LPFC_LINK_DOWN) | |
208 | lpfc_offline(phba); | |
9290831f JS |
209 | *(int *)(evtp->evt_arg1) |
210 | = (phba->stopped) ? 0 : lpfc_sli_brdkill(phba); | |
dea3101e | 211 | complete((struct completion *)(evtp->evt_arg2)); |
212 | break; | |
213 | } | |
214 | if (free_evt) | |
215 | kfree(evtp); | |
216 | spin_lock_irq(phba->host->host_lock); | |
217 | } | |
218 | spin_unlock_irq(phba->host->host_lock); | |
219 | ||
220 | } | |
221 | ||
222 | static void | |
223 | lpfc_work_done(struct lpfc_hba * phba) | |
224 | { | |
225 | struct lpfc_sli_ring *pring; | |
226 | int i; | |
227 | uint32_t ha_copy; | |
228 | uint32_t control; | |
229 | uint32_t work_hba_events; | |
230 | ||
231 | spin_lock_irq(phba->host->host_lock); | |
232 | ha_copy = phba->work_ha; | |
233 | phba->work_ha = 0; | |
234 | work_hba_events=phba->work_hba_events; | |
235 | spin_unlock_irq(phba->host->host_lock); | |
236 | ||
2fe165b6 | 237 | if (ha_copy & HA_ERATT) |
dea3101e | 238 | lpfc_handle_eratt(phba); |
239 | ||
2fe165b6 | 240 | if (ha_copy & HA_MBATT) |
dea3101e | 241 | lpfc_sli_handle_mb_event(phba); |
242 | ||
2fe165b6 | 243 | if (ha_copy & HA_LATT) |
dea3101e | 244 | lpfc_handle_latt(phba); |
245 | ||
246 | if (work_hba_events & WORKER_DISC_TMO) | |
247 | lpfc_disc_timeout_handler(phba); | |
248 | ||
249 | if (work_hba_events & WORKER_ELS_TMO) | |
250 | lpfc_els_timeout_handler(phba); | |
251 | ||
252 | if (work_hba_events & WORKER_MBOX_TMO) | |
253 | lpfc_mbox_timeout_handler(phba); | |
254 | ||
255 | if (work_hba_events & WORKER_FDMI_TMO) | |
256 | lpfc_fdmi_tmo_handler(phba); | |
257 | ||
258 | spin_lock_irq(phba->host->host_lock); | |
259 | phba->work_hba_events &= ~work_hba_events; | |
260 | spin_unlock_irq(phba->host->host_lock); | |
261 | ||
262 | for (i = 0; i < phba->sli.num_rings; i++, ha_copy >>= 4) { | |
263 | pring = &phba->sli.ring[i]; | |
264 | if ((ha_copy & HA_RXATT) | |
265 | || (pring->flag & LPFC_DEFERRED_RING_EVENT)) { | |
266 | if (pring->flag & LPFC_STOP_IOCB_MASK) { | |
267 | pring->flag |= LPFC_DEFERRED_RING_EVENT; | |
268 | } else { | |
269 | lpfc_sli_handle_slow_ring_event(phba, pring, | |
270 | (ha_copy & | |
271 | HA_RXMASK)); | |
272 | pring->flag &= ~LPFC_DEFERRED_RING_EVENT; | |
273 | } | |
274 | /* | |
275 | * Turn on Ring interrupts | |
276 | */ | |
277 | spin_lock_irq(phba->host->host_lock); | |
278 | control = readl(phba->HCregaddr); | |
279 | control |= (HC_R0INT_ENA << i); | |
280 | writel(control, phba->HCregaddr); | |
281 | readl(phba->HCregaddr); /* flush */ | |
282 | spin_unlock_irq(phba->host->host_lock); | |
283 | } | |
284 | } | |
285 | ||
286 | lpfc_work_list_done (phba); | |
287 | ||
288 | } | |
289 | ||
290 | static int | |
291 | check_work_wait_done(struct lpfc_hba *phba) { | |
292 | ||
293 | spin_lock_irq(phba->host->host_lock); | |
294 | if (phba->work_ha || | |
295 | phba->work_hba_events || | |
296 | (!list_empty(&phba->work_list)) || | |
297 | kthread_should_stop()) { | |
298 | spin_unlock_irq(phba->host->host_lock); | |
299 | return 1; | |
300 | } else { | |
301 | spin_unlock_irq(phba->host->host_lock); | |
302 | return 0; | |
303 | } | |
304 | } | |
305 | ||
306 | int | |
307 | lpfc_do_work(void *p) | |
308 | { | |
309 | struct lpfc_hba *phba = p; | |
310 | int rc; | |
7259f0d0 | 311 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(work_waitq); |
dea3101e | 312 | |
313 | set_user_nice(current, -20); | |
314 | phba->work_wait = &work_waitq; | |
315 | ||
316 | while (1) { | |
317 | ||
318 | rc = wait_event_interruptible(work_waitq, | |
319 | check_work_wait_done(phba)); | |
320 | BUG_ON(rc); | |
321 | ||
322 | if (kthread_should_stop()) | |
323 | break; | |
324 | ||
325 | lpfc_work_done(phba); | |
326 | ||
327 | } | |
328 | phba->work_wait = NULL; | |
329 | return 0; | |
330 | } | |
331 | ||
332 | /* | |
333 | * This is only called to handle FC worker events. Since this a rare | |
334 | * occurance, we allocate a struct lpfc_work_evt structure here instead of | |
335 | * embedding it in the IOCB. | |
336 | */ | |
337 | int | |
338 | lpfc_workq_post_event(struct lpfc_hba * phba, void *arg1, void *arg2, | |
339 | uint32_t evt) | |
340 | { | |
341 | struct lpfc_work_evt *evtp; | |
342 | ||
343 | /* | |
344 | * All Mailbox completions and LPFC_ELS_RING rcv ring IOCB events will | |
345 | * be queued to worker thread for processing | |
346 | */ | |
347 | evtp = kmalloc(sizeof(struct lpfc_work_evt), GFP_KERNEL); | |
348 | if (!evtp) | |
349 | return 0; | |
350 | ||
351 | evtp->evt_arg1 = arg1; | |
352 | evtp->evt_arg2 = arg2; | |
353 | evtp->evt = evt; | |
354 | ||
dea3101e | 355 | spin_lock_irq(phba->host->host_lock); |
071fbd3d | 356 | list_add_tail(&evtp->evt_listp, &phba->work_list); |
dea3101e | 357 | if (phba->work_wait) |
358 | wake_up(phba->work_wait); | |
359 | spin_unlock_irq(phba->host->host_lock); | |
360 | ||
361 | return 1; | |
362 | } | |
363 | ||
364 | int | |
365 | lpfc_linkdown(struct lpfc_hba * phba) | |
366 | { | |
367 | struct lpfc_sli *psli; | |
368 | struct lpfc_nodelist *ndlp, *next_ndlp; | |
c9f8735b | 369 | struct list_head *listp, *node_list[7]; |
dea3101e | 370 | LPFC_MBOXQ_t *mb; |
371 | int rc, i; | |
372 | ||
373 | psli = &phba->sli; | |
c9f8735b | 374 | /* sysfs or selective reset may call this routine to clean up */ |
5024ab17 JW |
375 | if (phba->hba_state >= LPFC_LINK_DOWN) { |
376 | if (phba->hba_state == LPFC_LINK_DOWN) | |
377 | return 0; | |
378 | ||
c9f8735b JW |
379 | spin_lock_irq(phba->host->host_lock); |
380 | phba->hba_state = LPFC_LINK_DOWN; | |
381 | spin_unlock_irq(phba->host->host_lock); | |
382 | } | |
dea3101e | 383 | |
d2873e4c JS |
384 | fc_host_post_event(phba->host, fc_get_event_number(), |
385 | FCH_EVT_LINKDOWN, 0); | |
386 | ||
dea3101e | 387 | /* Clean up any firmware default rpi's */ |
388 | if ((mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL))) { | |
389 | lpfc_unreg_did(phba, 0xffffffff, mb); | |
390 | mb->mbox_cmpl=lpfc_sli_def_mbox_cmpl; | |
391 | if (lpfc_sli_issue_mbox(phba, mb, (MBX_NOWAIT | MBX_STOP_IOCB)) | |
392 | == MBX_NOT_FINISHED) { | |
393 | mempool_free( mb, phba->mbox_mem_pool); | |
394 | } | |
395 | } | |
396 | ||
397 | /* Cleanup any outstanding RSCN activity */ | |
398 | lpfc_els_flush_rscn(phba); | |
399 | ||
400 | /* Cleanup any outstanding ELS commands */ | |
401 | lpfc_els_flush_cmd(phba); | |
402 | ||
403 | /* Issue a LINK DOWN event to all nodes */ | |
404 | node_list[0] = &phba->fc_npr_list; /* MUST do this list first */ | |
405 | node_list[1] = &phba->fc_nlpmap_list; | |
406 | node_list[2] = &phba->fc_nlpunmap_list; | |
407 | node_list[3] = &phba->fc_prli_list; | |
408 | node_list[4] = &phba->fc_reglogin_list; | |
409 | node_list[5] = &phba->fc_adisc_list; | |
410 | node_list[6] = &phba->fc_plogi_list; | |
411 | for (i = 0; i < 7; i++) { | |
412 | listp = node_list[i]; | |
413 | if (list_empty(listp)) | |
414 | continue; | |
415 | ||
416 | list_for_each_entry_safe(ndlp, next_ndlp, listp, nlp_listp) { | |
c9f8735b JW |
417 | |
418 | rc = lpfc_disc_state_machine(phba, ndlp, NULL, | |
419 | NLP_EVT_DEVICE_RECOVERY); | |
420 | ||
dea3101e | 421 | } |
422 | } | |
423 | ||
424 | /* free any ndlp's on unused list */ | |
425 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list, | |
426 | nlp_listp) { | |
427 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | |
428 | } | |
429 | ||
430 | /* Setup myDID for link up if we are in pt2pt mode */ | |
431 | if (phba->fc_flag & FC_PT2PT) { | |
432 | phba->fc_myDID = 0; | |
433 | if ((mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL))) { | |
434 | lpfc_config_link(phba, mb); | |
435 | mb->mbox_cmpl=lpfc_sli_def_mbox_cmpl; | |
436 | if (lpfc_sli_issue_mbox | |
437 | (phba, mb, (MBX_NOWAIT | MBX_STOP_IOCB)) | |
438 | == MBX_NOT_FINISHED) { | |
439 | mempool_free( mb, phba->mbox_mem_pool); | |
440 | } | |
441 | } | |
442 | spin_lock_irq(phba->host->host_lock); | |
443 | phba->fc_flag &= ~(FC_PT2PT | FC_PT2PT_PLOGI); | |
444 | spin_unlock_irq(phba->host->host_lock); | |
445 | } | |
446 | spin_lock_irq(phba->host->host_lock); | |
447 | phba->fc_flag &= ~FC_LBIT; | |
448 | spin_unlock_irq(phba->host->host_lock); | |
449 | ||
450 | /* Turn off discovery timer if its running */ | |
451 | lpfc_can_disctmo(phba); | |
452 | ||
453 | /* Must process IOCBs on all rings to handle ABORTed I/Os */ | |
2fe165b6 | 454 | return 0; |
dea3101e | 455 | } |
456 | ||
457 | static int | |
458 | lpfc_linkup(struct lpfc_hba * phba) | |
459 | { | |
460 | struct lpfc_nodelist *ndlp, *next_ndlp; | |
c9f8735b JW |
461 | struct list_head *listp, *node_list[7]; |
462 | int i; | |
dea3101e | 463 | |
d2873e4c JS |
464 | fc_host_post_event(phba->host, fc_get_event_number(), |
465 | FCH_EVT_LINKUP, 0); | |
466 | ||
dea3101e | 467 | spin_lock_irq(phba->host->host_lock); |
468 | phba->hba_state = LPFC_LINK_UP; | |
469 | phba->fc_flag &= ~(FC_PT2PT | FC_PT2PT_PLOGI | FC_ABORT_DISCOVERY | | |
470 | FC_RSCN_MODE | FC_NLP_MORE | FC_RSCN_DISCOVERY); | |
471 | phba->fc_flag |= FC_NDISC_ACTIVE; | |
472 | phba->fc_ns_retry = 0; | |
473 | spin_unlock_irq(phba->host->host_lock); | |
474 | ||
475 | ||
c9f8735b JW |
476 | node_list[0] = &phba->fc_plogi_list; |
477 | node_list[1] = &phba->fc_adisc_list; | |
478 | node_list[2] = &phba->fc_reglogin_list; | |
479 | node_list[3] = &phba->fc_prli_list; | |
480 | node_list[4] = &phba->fc_nlpunmap_list; | |
481 | node_list[5] = &phba->fc_nlpmap_list; | |
482 | node_list[6] = &phba->fc_npr_list; | |
483 | for (i = 0; i < 7; i++) { | |
484 | listp = node_list[i]; | |
485 | if (list_empty(listp)) | |
486 | continue; | |
487 | ||
488 | list_for_each_entry_safe(ndlp, next_ndlp, listp, nlp_listp) { | |
489 | if (phba->fc_flag & FC_LBIT) { | |
490 | if (ndlp->nlp_type & NLP_FABRIC) { | |
491 | /* On Linkup its safe to clean up the | |
492 | * ndlp from Fabric connections. | |
493 | */ | |
494 | lpfc_nlp_list(phba, ndlp, | |
495 | NLP_UNUSED_LIST); | |
496 | } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { | |
497 | /* Fail outstanding IO now since device | |
498 | * is marked for PLOGI. | |
499 | */ | |
500 | lpfc_unreg_rpi(phba, ndlp); | |
501 | } | |
502 | } | |
dea3101e | 503 | } |
504 | } | |
505 | ||
506 | /* free any ndlp's on unused list */ | |
507 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list, | |
508 | nlp_listp) { | |
509 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | |
510 | } | |
511 | ||
512 | return 0; | |
513 | } | |
514 | ||
515 | /* | |
516 | * This routine handles processing a CLEAR_LA mailbox | |
517 | * command upon completion. It is setup in the LPFC_MBOXQ | |
518 | * as the completion routine when the command is | |
519 | * handed off to the SLI layer. | |
520 | */ | |
521 | void | |
522 | lpfc_mbx_cmpl_clear_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
523 | { | |
524 | struct lpfc_sli *psli; | |
525 | MAILBOX_t *mb; | |
526 | uint32_t control; | |
527 | ||
528 | psli = &phba->sli; | |
529 | mb = &pmb->mb; | |
530 | /* Since we don't do discovery right now, turn these off here */ | |
a4bc3379 | 531 | psli->ring[psli->extra_ring].flag &= ~LPFC_STOP_IOCB_EVENT; |
dea3101e | 532 | psli->ring[psli->fcp_ring].flag &= ~LPFC_STOP_IOCB_EVENT; |
533 | psli->ring[psli->next_ring].flag &= ~LPFC_STOP_IOCB_EVENT; | |
534 | ||
535 | /* Check for error */ | |
536 | if ((mb->mbxStatus) && (mb->mbxStatus != 0x1601)) { | |
537 | /* CLEAR_LA mbox error <mbxStatus> state <hba_state> */ | |
538 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, | |
539 | "%d:0320 CLEAR_LA mbxStatus error x%x hba " | |
540 | "state x%x\n", | |
541 | phba->brd_no, mb->mbxStatus, phba->hba_state); | |
542 | ||
543 | phba->hba_state = LPFC_HBA_ERROR; | |
544 | goto out; | |
545 | } | |
546 | ||
547 | if (phba->fc_flag & FC_ABORT_DISCOVERY) | |
548 | goto out; | |
549 | ||
550 | phba->num_disc_nodes = 0; | |
551 | /* go thru NPR list and issue ELS PLOGIs */ | |
552 | if (phba->fc_npr_cnt) { | |
553 | lpfc_els_disc_plogi(phba); | |
554 | } | |
555 | ||
2fe165b6 | 556 | if (!phba->num_disc_nodes) { |
dea3101e | 557 | spin_lock_irq(phba->host->host_lock); |
558 | phba->fc_flag &= ~FC_NDISC_ACTIVE; | |
559 | spin_unlock_irq(phba->host->host_lock); | |
560 | } | |
561 | ||
562 | phba->hba_state = LPFC_HBA_READY; | |
563 | ||
564 | out: | |
565 | /* Device Discovery completes */ | |
566 | lpfc_printf_log(phba, | |
567 | KERN_INFO, | |
568 | LOG_DISCOVERY, | |
569 | "%d:0225 Device Discovery completes\n", | |
570 | phba->brd_no); | |
571 | ||
572 | mempool_free( pmb, phba->mbox_mem_pool); | |
573 | ||
574 | spin_lock_irq(phba->host->host_lock); | |
575 | phba->fc_flag &= ~FC_ABORT_DISCOVERY; | |
576 | if (phba->fc_flag & FC_ESTABLISH_LINK) { | |
577 | phba->fc_flag &= ~FC_ESTABLISH_LINK; | |
578 | } | |
579 | spin_unlock_irq(phba->host->host_lock); | |
580 | ||
581 | del_timer_sync(&phba->fc_estabtmo); | |
582 | ||
583 | lpfc_can_disctmo(phba); | |
584 | ||
585 | /* turn on Link Attention interrupts */ | |
586 | spin_lock_irq(phba->host->host_lock); | |
587 | psli->sli_flag |= LPFC_PROCESS_LA; | |
588 | control = readl(phba->HCregaddr); | |
589 | control |= HC_LAINT_ENA; | |
590 | writel(control, phba->HCregaddr); | |
591 | readl(phba->HCregaddr); /* flush */ | |
592 | spin_unlock_irq(phba->host->host_lock); | |
593 | ||
594 | return; | |
595 | } | |
596 | ||
597 | static void | |
25594c6b | 598 | lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
dea3101e | 599 | { |
25594c6b JW |
600 | struct lpfc_sli *psli = &phba->sli; |
601 | int rc; | |
dea3101e | 602 | |
25594c6b | 603 | if (pmb->mb.mbxStatus) |
dea3101e | 604 | goto out; |
dea3101e | 605 | |
25594c6b JW |
606 | mempool_free(pmb, phba->mbox_mem_pool); |
607 | ||
608 | if (phba->fc_topology == TOPOLOGY_LOOP && | |
609 | phba->fc_flag & FC_PUBLIC_LOOP && | |
610 | !(phba->fc_flag & FC_LBIT)) { | |
611 | /* Need to wait for FAN - use discovery timer | |
612 | * for timeout. hba_state is identically | |
613 | * LPFC_LOCAL_CFG_LINK while waiting for FAN | |
614 | */ | |
615 | lpfc_set_disctmo(phba); | |
616 | return; | |
dea3101e | 617 | } |
618 | ||
25594c6b JW |
619 | /* Start discovery by sending a FLOGI. hba_state is identically |
620 | * LPFC_FLOGI while waiting for FLOGI cmpl | |
621 | */ | |
622 | phba->hba_state = LPFC_FLOGI; | |
623 | lpfc_set_disctmo(phba); | |
624 | lpfc_initial_flogi(phba); | |
625 | return; | |
dea3101e | 626 | |
627 | out: | |
25594c6b JW |
628 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
629 | "%d:0306 CONFIG_LINK mbxStatus error x%x " | |
630 | "HBA state x%x\n", | |
631 | phba->brd_no, pmb->mb.mbxStatus, phba->hba_state); | |
632 | ||
633 | lpfc_linkdown(phba); | |
634 | ||
635 | phba->hba_state = LPFC_HBA_ERROR; | |
636 | ||
637 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | |
dea3101e | 638 | "%d:0200 CONFIG_LINK bad hba state x%x\n", |
639 | phba->brd_no, phba->hba_state); | |
640 | ||
25594c6b JW |
641 | lpfc_clear_la(phba, pmb); |
642 | pmb->mbox_cmpl = lpfc_mbx_cmpl_clear_la; | |
643 | rc = lpfc_sli_issue_mbox(phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB)); | |
644 | if (rc == MBX_NOT_FINISHED) { | |
645 | mempool_free(pmb, phba->mbox_mem_pool); | |
646 | lpfc_disc_flush_list(phba); | |
a4bc3379 | 647 | psli->ring[(psli->extra_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; |
25594c6b JW |
648 | psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; |
649 | psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; | |
650 | phba->hba_state = LPFC_HBA_READY; | |
dea3101e | 651 | } |
652 | return; | |
653 | } | |
654 | ||
655 | static void | |
656 | lpfc_mbx_cmpl_read_sparam(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
657 | { | |
658 | struct lpfc_sli *psli = &phba->sli; | |
659 | MAILBOX_t *mb = &pmb->mb; | |
660 | struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) pmb->context1; | |
661 | ||
662 | ||
663 | /* Check for error */ | |
664 | if (mb->mbxStatus) { | |
665 | /* READ_SPARAM mbox error <mbxStatus> state <hba_state> */ | |
666 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, | |
667 | "%d:0319 READ_SPARAM mbxStatus error x%x " | |
668 | "hba state x%x>\n", | |
669 | phba->brd_no, mb->mbxStatus, phba->hba_state); | |
670 | ||
671 | lpfc_linkdown(phba); | |
672 | phba->hba_state = LPFC_HBA_ERROR; | |
673 | goto out; | |
674 | } | |
675 | ||
676 | memcpy((uint8_t *) & phba->fc_sparam, (uint8_t *) mp->virt, | |
677 | sizeof (struct serv_parm)); | |
a12e07bc JS |
678 | if (phba->cfg_soft_wwnn) |
679 | u64_to_wwn(phba->cfg_soft_wwnn, phba->fc_sparam.nodeName.u.wwn); | |
c3f28afa JS |
680 | if (phba->cfg_soft_wwpn) |
681 | u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn); | |
dea3101e | 682 | memcpy((uint8_t *) & phba->fc_nodename, |
683 | (uint8_t *) & phba->fc_sparam.nodeName, | |
684 | sizeof (struct lpfc_name)); | |
685 | memcpy((uint8_t *) & phba->fc_portname, | |
686 | (uint8_t *) & phba->fc_sparam.portName, | |
687 | sizeof (struct lpfc_name)); | |
688 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
689 | kfree(mp); | |
690 | mempool_free( pmb, phba->mbox_mem_pool); | |
691 | return; | |
692 | ||
693 | out: | |
694 | pmb->context1 = NULL; | |
695 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
696 | kfree(mp); | |
697 | if (phba->hba_state != LPFC_CLEAR_LA) { | |
698 | lpfc_clear_la(phba, pmb); | |
699 | pmb->mbox_cmpl = lpfc_mbx_cmpl_clear_la; | |
700 | if (lpfc_sli_issue_mbox(phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB)) | |
701 | == MBX_NOT_FINISHED) { | |
702 | mempool_free( pmb, phba->mbox_mem_pool); | |
703 | lpfc_disc_flush_list(phba); | |
a4bc3379 | 704 | psli->ring[(psli->extra_ring)].flag &= |
dea3101e | 705 | ~LPFC_STOP_IOCB_EVENT; |
706 | psli->ring[(psli->fcp_ring)].flag &= | |
707 | ~LPFC_STOP_IOCB_EVENT; | |
708 | psli->ring[(psli->next_ring)].flag &= | |
709 | ~LPFC_STOP_IOCB_EVENT; | |
710 | phba->hba_state = LPFC_HBA_READY; | |
711 | } | |
712 | } else { | |
713 | mempool_free( pmb, phba->mbox_mem_pool); | |
714 | } | |
715 | return; | |
716 | } | |
717 | ||
718 | static void | |
719 | lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) | |
720 | { | |
721 | int i; | |
722 | LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox; | |
14691150 JS |
723 | struct lpfc_dmabuf *mp; |
724 | int rc; | |
725 | ||
dea3101e | 726 | sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
727 | cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | |
728 | ||
729 | spin_lock_irq(phba->host->host_lock); | |
2fe165b6 | 730 | switch (la->UlnkSpeed) { |
dea3101e | 731 | case LA_1GHZ_LINK: |
732 | phba->fc_linkspeed = LA_1GHZ_LINK; | |
733 | break; | |
734 | case LA_2GHZ_LINK: | |
735 | phba->fc_linkspeed = LA_2GHZ_LINK; | |
736 | break; | |
737 | case LA_4GHZ_LINK: | |
738 | phba->fc_linkspeed = LA_4GHZ_LINK; | |
739 | break; | |
740 | default: | |
741 | phba->fc_linkspeed = LA_UNKNW_LINK; | |
742 | break; | |
743 | } | |
744 | ||
745 | phba->fc_topology = la->topology; | |
746 | ||
747 | if (phba->fc_topology == TOPOLOGY_LOOP) { | |
748 | /* Get Loop Map information */ | |
749 | ||
750 | if (la->il) | |
751 | phba->fc_flag |= FC_LBIT; | |
752 | ||
753 | phba->fc_myDID = la->granted_AL_PA; | |
754 | i = la->un.lilpBde64.tus.f.bdeSize; | |
755 | ||
756 | if (i == 0) { | |
757 | phba->alpa_map[0] = 0; | |
758 | } else { | |
759 | if (phba->cfg_log_verbose & LOG_LINK_EVENT) { | |
760 | int numalpa, j, k; | |
761 | union { | |
762 | uint8_t pamap[16]; | |
763 | struct { | |
764 | uint32_t wd1; | |
765 | uint32_t wd2; | |
766 | uint32_t wd3; | |
767 | uint32_t wd4; | |
768 | } pa; | |
769 | } un; | |
770 | numalpa = phba->alpa_map[0]; | |
771 | j = 0; | |
772 | while (j < numalpa) { | |
773 | memset(un.pamap, 0, 16); | |
774 | for (k = 1; j < numalpa; k++) { | |
775 | un.pamap[k - 1] = | |
776 | phba->alpa_map[j + 1]; | |
777 | j++; | |
778 | if (k == 16) | |
779 | break; | |
780 | } | |
781 | /* Link Up Event ALPA map */ | |
782 | lpfc_printf_log(phba, | |
783 | KERN_WARNING, | |
784 | LOG_LINK_EVENT, | |
785 | "%d:1304 Link Up Event " | |
786 | "ALPA map Data: x%x " | |
787 | "x%x x%x x%x\n", | |
788 | phba->brd_no, | |
789 | un.pa.wd1, un.pa.wd2, | |
790 | un.pa.wd3, un.pa.wd4); | |
791 | } | |
792 | } | |
793 | } | |
794 | } else { | |
795 | phba->fc_myDID = phba->fc_pref_DID; | |
796 | phba->fc_flag |= FC_LBIT; | |
797 | } | |
798 | spin_unlock_irq(phba->host->host_lock); | |
799 | ||
800 | lpfc_linkup(phba); | |
801 | if (sparam_mbox) { | |
802 | lpfc_read_sparam(phba, sparam_mbox); | |
803 | sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; | |
14691150 | 804 | rc = lpfc_sli_issue_mbox(phba, sparam_mbox, |
dea3101e | 805 | (MBX_NOWAIT | MBX_STOP_IOCB)); |
14691150 JS |
806 | if (rc == MBX_NOT_FINISHED) { |
807 | mp = (struct lpfc_dmabuf *) sparam_mbox->context1; | |
808 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
809 | kfree(mp); | |
810 | mempool_free(sparam_mbox, phba->mbox_mem_pool); | |
811 | if (cfglink_mbox) | |
812 | mempool_free(cfglink_mbox, phba->mbox_mem_pool); | |
813 | return; | |
814 | } | |
dea3101e | 815 | } |
816 | ||
817 | if (cfglink_mbox) { | |
818 | phba->hba_state = LPFC_LOCAL_CFG_LINK; | |
819 | lpfc_config_link(phba, cfglink_mbox); | |
25594c6b | 820 | cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link; |
14691150 | 821 | rc = lpfc_sli_issue_mbox(phba, cfglink_mbox, |
dea3101e | 822 | (MBX_NOWAIT | MBX_STOP_IOCB)); |
14691150 JS |
823 | if (rc == MBX_NOT_FINISHED) |
824 | mempool_free(cfglink_mbox, phba->mbox_mem_pool); | |
dea3101e | 825 | } |
826 | } | |
827 | ||
828 | static void | |
829 | lpfc_mbx_issue_link_down(struct lpfc_hba *phba) { | |
830 | uint32_t control; | |
831 | struct lpfc_sli *psli = &phba->sli; | |
832 | ||
833 | lpfc_linkdown(phba); | |
834 | ||
835 | /* turn on Link Attention interrupts - no CLEAR_LA needed */ | |
836 | spin_lock_irq(phba->host->host_lock); | |
837 | psli->sli_flag |= LPFC_PROCESS_LA; | |
838 | control = readl(phba->HCregaddr); | |
839 | control |= HC_LAINT_ENA; | |
840 | writel(control, phba->HCregaddr); | |
841 | readl(phba->HCregaddr); /* flush */ | |
842 | spin_unlock_irq(phba->host->host_lock); | |
843 | } | |
844 | ||
845 | /* | |
846 | * This routine handles processing a READ_LA mailbox | |
847 | * command upon completion. It is setup in the LPFC_MBOXQ | |
848 | * as the completion routine when the command is | |
849 | * handed off to the SLI layer. | |
850 | */ | |
851 | void | |
852 | lpfc_mbx_cmpl_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
853 | { | |
854 | READ_LA_VAR *la; | |
855 | MAILBOX_t *mb = &pmb->mb; | |
856 | struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1); | |
857 | ||
858 | /* Check for error */ | |
859 | if (mb->mbxStatus) { | |
860 | lpfc_printf_log(phba, | |
861 | KERN_INFO, | |
862 | LOG_LINK_EVENT, | |
863 | "%d:1307 READ_LA mbox error x%x state x%x\n", | |
864 | phba->brd_no, | |
865 | mb->mbxStatus, phba->hba_state); | |
866 | lpfc_mbx_issue_link_down(phba); | |
867 | phba->hba_state = LPFC_HBA_ERROR; | |
868 | goto lpfc_mbx_cmpl_read_la_free_mbuf; | |
869 | } | |
870 | ||
871 | la = (READ_LA_VAR *) & pmb->mb.un.varReadLA; | |
872 | ||
873 | memcpy(&phba->alpa_map[0], mp->virt, 128); | |
874 | ||
c9f8735b JW |
875 | spin_lock_irq(phba->host->host_lock); |
876 | if (la->pb) | |
877 | phba->fc_flag |= FC_BYPASSED_MODE; | |
878 | else | |
879 | phba->fc_flag &= ~FC_BYPASSED_MODE; | |
880 | spin_unlock_irq(phba->host->host_lock); | |
881 | ||
dea3101e | 882 | if (((phba->fc_eventTag + 1) < la->eventTag) || |
883 | (phba->fc_eventTag == la->eventTag)) { | |
884 | phba->fc_stat.LinkMultiEvent++; | |
885 | if (la->attType == AT_LINK_UP) { | |
886 | if (phba->fc_eventTag != 0) | |
887 | lpfc_linkdown(phba); | |
888 | } | |
889 | } | |
890 | ||
891 | phba->fc_eventTag = la->eventTag; | |
892 | ||
893 | if (la->attType == AT_LINK_UP) { | |
894 | phba->fc_stat.LinkUp++; | |
895 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | |
896 | "%d:1303 Link Up Event x%x received " | |
897 | "Data: x%x x%x x%x x%x\n", | |
898 | phba->brd_no, la->eventTag, phba->fc_eventTag, | |
899 | la->granted_AL_PA, la->UlnkSpeed, | |
900 | phba->alpa_map[0]); | |
901 | lpfc_mbx_process_link_up(phba, la); | |
902 | } else { | |
903 | phba->fc_stat.LinkDown++; | |
904 | lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, | |
905 | "%d:1305 Link Down Event x%x received " | |
906 | "Data: x%x x%x x%x\n", | |
907 | phba->brd_no, la->eventTag, phba->fc_eventTag, | |
908 | phba->hba_state, phba->fc_flag); | |
909 | lpfc_mbx_issue_link_down(phba); | |
910 | } | |
911 | ||
912 | lpfc_mbx_cmpl_read_la_free_mbuf: | |
913 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
914 | kfree(mp); | |
915 | mempool_free(pmb, phba->mbox_mem_pool); | |
916 | return; | |
917 | } | |
918 | ||
919 | /* | |
920 | * This routine handles processing a REG_LOGIN mailbox | |
921 | * command upon completion. It is setup in the LPFC_MBOXQ | |
922 | * as the completion routine when the command is | |
923 | * handed off to the SLI layer. | |
924 | */ | |
925 | void | |
926 | lpfc_mbx_cmpl_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
927 | { | |
928 | struct lpfc_sli *psli; | |
929 | MAILBOX_t *mb; | |
930 | struct lpfc_dmabuf *mp; | |
931 | struct lpfc_nodelist *ndlp; | |
932 | ||
933 | psli = &phba->sli; | |
934 | mb = &pmb->mb; | |
935 | ||
936 | ndlp = (struct lpfc_nodelist *) pmb->context2; | |
937 | mp = (struct lpfc_dmabuf *) (pmb->context1); | |
938 | ||
939 | pmb->context1 = NULL; | |
940 | ||
941 | /* Good status, call state machine */ | |
942 | lpfc_disc_state_machine(phba, ndlp, pmb, NLP_EVT_CMPL_REG_LOGIN); | |
943 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
944 | kfree(mp); | |
945 | mempool_free( pmb, phba->mbox_mem_pool); | |
946 | ||
947 | return; | |
948 | } | |
949 | ||
950 | /* | |
951 | * This routine handles processing a Fabric REG_LOGIN mailbox | |
952 | * command upon completion. It is setup in the LPFC_MBOXQ | |
953 | * as the completion routine when the command is | |
954 | * handed off to the SLI layer. | |
955 | */ | |
956 | void | |
957 | lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
958 | { | |
959 | struct lpfc_sli *psli; | |
960 | MAILBOX_t *mb; | |
961 | struct lpfc_dmabuf *mp; | |
962 | struct lpfc_nodelist *ndlp; | |
963 | struct lpfc_nodelist *ndlp_fdmi; | |
964 | ||
965 | ||
966 | psli = &phba->sli; | |
967 | mb = &pmb->mb; | |
968 | ||
969 | ndlp = (struct lpfc_nodelist *) pmb->context2; | |
970 | mp = (struct lpfc_dmabuf *) (pmb->context1); | |
971 | ||
972 | if (mb->mbxStatus) { | |
973 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
974 | kfree(mp); | |
975 | mempool_free( pmb, phba->mbox_mem_pool); | |
976 | mempool_free( ndlp, phba->nlp_mem_pool); | |
977 | ||
978 | /* FLOGI failed, so just use loop map to make discovery list */ | |
979 | lpfc_disc_list_loopmap(phba); | |
980 | ||
981 | /* Start discovery */ | |
982 | lpfc_disc_start(phba); | |
983 | return; | |
984 | } | |
985 | ||
986 | pmb->context1 = NULL; | |
987 | ||
dea3101e | 988 | ndlp->nlp_rpi = mb->un.varWords[0]; |
dea3101e | 989 | ndlp->nlp_type |= NLP_FABRIC; |
990 | ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; | |
991 | lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); | |
992 | ||
993 | if (phba->hba_state == LPFC_FABRIC_CFG_LINK) { | |
994 | /* This NPort has been assigned an NPort_ID by the fabric as a | |
995 | * result of the completed fabric login. Issue a State Change | |
996 | * Registration (SCR) ELS request to the fabric controller | |
997 | * (SCR_DID) so that this NPort gets RSCN events from the | |
998 | * fabric. | |
999 | */ | |
1000 | lpfc_issue_els_scr(phba, SCR_DID, 0); | |
1001 | ||
c9f8735b JW |
1002 | ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, NameServer_DID); |
1003 | if (!ndlp) { | |
1004 | /* Allocate a new node instance. If the pool is empty, | |
1005 | * start the discovery process and skip the Nameserver | |
1006 | * login process. This is attempted again later on. | |
1007 | * Otherwise, issue a Port Login (PLOGI) to NameServer. | |
1008 | */ | |
1009 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_ATOMIC); | |
1010 | if (!ndlp) { | |
1011 | lpfc_disc_start(phba); | |
1012 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
1013 | kfree(mp); | |
1014 | mempool_free( pmb, phba->mbox_mem_pool); | |
1015 | return; | |
1016 | } else { | |
1017 | lpfc_nlp_init(phba, ndlp, NameServer_DID); | |
1018 | ndlp->nlp_type |= NLP_FABRIC; | |
1019 | } | |
1020 | } | |
1021 | ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; | |
1022 | lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); | |
488d1469 | 1023 | lpfc_issue_els_plogi(phba, NameServer_DID, 0); |
c9f8735b JW |
1024 | if (phba->cfg_fdmi_on) { |
1025 | ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool, | |
1026 | GFP_KERNEL); | |
1027 | if (ndlp_fdmi) { | |
1028 | lpfc_nlp_init(phba, ndlp_fdmi, FDMI_DID); | |
1029 | ndlp_fdmi->nlp_type |= NLP_FABRIC; | |
1030 | ndlp_fdmi->nlp_state = NLP_STE_PLOGI_ISSUE; | |
488d1469 | 1031 | lpfc_issue_els_plogi(phba, FDMI_DID, 0); |
dea3101e | 1032 | } |
1033 | } | |
1034 | } | |
1035 | ||
1036 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
1037 | kfree(mp); | |
1038 | mempool_free( pmb, phba->mbox_mem_pool); | |
dea3101e | 1039 | return; |
1040 | } | |
1041 | ||
1042 | /* | |
1043 | * This routine handles processing a NameServer REG_LOGIN mailbox | |
1044 | * command upon completion. It is setup in the LPFC_MBOXQ | |
1045 | * as the completion routine when the command is | |
1046 | * handed off to the SLI layer. | |
1047 | */ | |
1048 | void | |
1049 | lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
1050 | { | |
1051 | struct lpfc_sli *psli; | |
1052 | MAILBOX_t *mb; | |
1053 | struct lpfc_dmabuf *mp; | |
1054 | struct lpfc_nodelist *ndlp; | |
1055 | ||
1056 | psli = &phba->sli; | |
1057 | mb = &pmb->mb; | |
1058 | ||
1059 | ndlp = (struct lpfc_nodelist *) pmb->context2; | |
1060 | mp = (struct lpfc_dmabuf *) (pmb->context1); | |
1061 | ||
1062 | if (mb->mbxStatus) { | |
1063 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
1064 | kfree(mp); | |
1065 | mempool_free( pmb, phba->mbox_mem_pool); | |
1066 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | |
1067 | ||
1068 | /* RegLogin failed, so just use loop map to make discovery | |
1069 | list */ | |
1070 | lpfc_disc_list_loopmap(phba); | |
1071 | ||
1072 | /* Start discovery */ | |
1073 | lpfc_disc_start(phba); | |
1074 | return; | |
1075 | } | |
1076 | ||
1077 | pmb->context1 = NULL; | |
1078 | ||
dea3101e | 1079 | ndlp->nlp_rpi = mb->un.varWords[0]; |
dea3101e | 1080 | ndlp->nlp_type |= NLP_FABRIC; |
1081 | ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; | |
1082 | lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); | |
1083 | ||
1084 | if (phba->hba_state < LPFC_HBA_READY) { | |
1085 | /* Link up discovery requires Fabrib registration. */ | |
1086 | lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RNN_ID); | |
1087 | lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RSNN_NN); | |
1088 | lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RFT_ID); | |
2fb9bd8b | 1089 | lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RFF_ID); |
dea3101e | 1090 | } |
1091 | ||
1092 | phba->fc_ns_retry = 0; | |
1093 | /* Good status, issue CT Request to NameServer */ | |
1094 | if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT)) { | |
1095 | /* Cannot issue NameServer Query, so finish up discovery */ | |
1096 | lpfc_disc_start(phba); | |
1097 | } | |
1098 | ||
1099 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
1100 | kfree(mp); | |
1101 | mempool_free( pmb, phba->mbox_mem_pool); | |
1102 | ||
1103 | return; | |
1104 | } | |
1105 | ||
1106 | static void | |
1107 | lpfc_register_remote_port(struct lpfc_hba * phba, | |
1108 | struct lpfc_nodelist * ndlp) | |
1109 | { | |
1110 | struct fc_rport *rport; | |
1111 | struct lpfc_rport_data *rdata; | |
1112 | struct fc_rport_identifiers rport_ids; | |
dea3101e | 1113 | |
1114 | /* Remote port has reappeared. Re-register w/ FC transport */ | |
68ce1eb5 AM |
1115 | rport_ids.node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn); |
1116 | rport_ids.port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn); | |
dea3101e | 1117 | rport_ids.port_id = ndlp->nlp_DID; |
1118 | rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; | |
dea3101e | 1119 | |
1120 | ndlp->rport = rport = fc_remote_port_add(phba->host, 0, &rport_ids); | |
1121 | if (!rport) { | |
1122 | dev_printk(KERN_WARNING, &phba->pcidev->dev, | |
1123 | "Warning: fc_remote_port_add failed\n"); | |
1124 | return; | |
1125 | } | |
1126 | ||
1127 | /* initialize static port data */ | |
1128 | rport->maxframe_size = ndlp->nlp_maxframe; | |
1129 | rport->supported_classes = ndlp->nlp_class_sup; | |
dea3101e | 1130 | rdata = rport->dd_data; |
1131 | rdata->pnode = ndlp; | |
23dc04f1 JSEC |
1132 | |
1133 | if (ndlp->nlp_type & NLP_FCP_TARGET) | |
1134 | rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; | |
1135 | if (ndlp->nlp_type & NLP_FCP_INITIATOR) | |
1136 | rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR; | |
1137 | ||
1138 | ||
1139 | if (rport_ids.roles != FC_RPORT_ROLE_UNKNOWN) | |
1140 | fc_remote_port_rolechg(rport, rport_ids.roles); | |
1141 | ||
071fbd3d | 1142 | if ((rport->scsi_target_id != -1) && |
e17da18e | 1143 | (rport->scsi_target_id < LPFC_MAX_TARGET)) { |
071fbd3d JS |
1144 | ndlp->nlp_sid = rport->scsi_target_id; |
1145 | } | |
19a7b4ae JSEC |
1146 | |
1147 | return; | |
1148 | } | |
1149 | ||
1150 | static void | |
1151 | lpfc_unregister_remote_port(struct lpfc_hba * phba, | |
1152 | struct lpfc_nodelist * ndlp) | |
1153 | { | |
1154 | struct fc_rport *rport = ndlp->rport; | |
1155 | struct lpfc_rport_data *rdata = rport->dd_data; | |
1156 | ||
c01f3208 JS |
1157 | if (rport->scsi_target_id == -1) { |
1158 | ndlp->rport = NULL; | |
1159 | rdata->pnode = NULL; | |
1160 | } | |
1161 | ||
19a7b4ae | 1162 | fc_remote_port_delete(rport); |
dea3101e | 1163 | |
1164 | return; | |
1165 | } | |
1166 | ||
1167 | int | |
1168 | lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list) | |
1169 | { | |
1170 | enum { none, unmapped, mapped } rport_add = none, rport_del = none; | |
1171 | struct lpfc_sli *psli; | |
1172 | ||
1173 | psli = &phba->sli; | |
1174 | /* Sanity check to ensure we are not moving to / from the same list */ | |
2fe165b6 | 1175 | if ((nlp->nlp_flag & NLP_LIST_MASK) == list) |
dea3101e | 1176 | if (list != NLP_NO_LIST) |
2fe165b6 | 1177 | return 0; |
dea3101e | 1178 | |
66a9ed66 | 1179 | spin_lock_irq(phba->host->host_lock); |
2fe165b6 | 1180 | switch (nlp->nlp_flag & NLP_LIST_MASK) { |
dea3101e | 1181 | case NLP_NO_LIST: /* Not on any list */ |
1182 | break; | |
1183 | case NLP_UNUSED_LIST: | |
1184 | phba->fc_unused_cnt--; | |
1185 | list_del(&nlp->nlp_listp); | |
1186 | break; | |
1187 | case NLP_PLOGI_LIST: | |
1188 | phba->fc_plogi_cnt--; | |
1189 | list_del(&nlp->nlp_listp); | |
1190 | break; | |
1191 | case NLP_ADISC_LIST: | |
1192 | phba->fc_adisc_cnt--; | |
1193 | list_del(&nlp->nlp_listp); | |
1194 | break; | |
1195 | case NLP_REGLOGIN_LIST: | |
1196 | phba->fc_reglogin_cnt--; | |
1197 | list_del(&nlp->nlp_listp); | |
1198 | break; | |
1199 | case NLP_PRLI_LIST: | |
1200 | phba->fc_prli_cnt--; | |
1201 | list_del(&nlp->nlp_listp); | |
1202 | break; | |
1203 | case NLP_UNMAPPED_LIST: | |
1204 | phba->fc_unmap_cnt--; | |
1205 | list_del(&nlp->nlp_listp); | |
dea3101e | 1206 | nlp->nlp_flag &= ~NLP_TGT_NO_SCSIID; |
1207 | nlp->nlp_type &= ~NLP_FC_NODE; | |
dea3101e | 1208 | phba->nport_event_cnt++; |
1209 | if (nlp->rport) | |
1210 | rport_del = unmapped; | |
1211 | break; | |
1212 | case NLP_MAPPED_LIST: | |
1213 | phba->fc_map_cnt--; | |
1214 | list_del(&nlp->nlp_listp); | |
1215 | phba->nport_event_cnt++; | |
1216 | if (nlp->rport) | |
1217 | rport_del = mapped; | |
1218 | break; | |
1219 | case NLP_NPR_LIST: | |
1220 | phba->fc_npr_cnt--; | |
1221 | list_del(&nlp->nlp_listp); | |
1222 | /* Stop delay tmo if taking node off NPR list */ | |
1223 | if ((nlp->nlp_flag & NLP_DELAY_TMO) && | |
1224 | (list != NLP_NPR_LIST)) { | |
66a9ed66 | 1225 | spin_unlock_irq(phba->host->host_lock); |
fdcebe28 | 1226 | lpfc_cancel_retry_delay_tmo(phba, nlp); |
66a9ed66 | 1227 | spin_lock_irq(phba->host->host_lock); |
dea3101e | 1228 | } |
1229 | break; | |
1230 | } | |
1231 | ||
dea3101e | 1232 | nlp->nlp_flag &= ~NLP_LIST_MASK; |
dea3101e | 1233 | |
1234 | /* Add NPort <did> to <num> list */ | |
1235 | lpfc_printf_log(phba, | |
1236 | KERN_INFO, | |
1237 | LOG_NODE, | |
1238 | "%d:0904 Add NPort x%x to %d list Data: x%x\n", | |
1239 | phba->brd_no, | |
1240 | nlp->nlp_DID, list, nlp->nlp_flag); | |
1241 | ||
2fe165b6 | 1242 | switch (list) { |
dea3101e | 1243 | case NLP_NO_LIST: /* No list, just remove it */ |
66a9ed66 | 1244 | spin_unlock_irq(phba->host->host_lock); |
dea3101e | 1245 | lpfc_nlp_remove(phba, nlp); |
66a9ed66 | 1246 | spin_lock_irq(phba->host->host_lock); |
8cbdc5ff JSEC |
1247 | /* as node removed - stop further transport calls */ |
1248 | rport_del = none; | |
dea3101e | 1249 | break; |
1250 | case NLP_UNUSED_LIST: | |
dea3101e | 1251 | nlp->nlp_flag |= list; |
dea3101e | 1252 | /* Put it at the end of the unused list */ |
1253 | list_add_tail(&nlp->nlp_listp, &phba->fc_unused_list); | |
1254 | phba->fc_unused_cnt++; | |
1255 | break; | |
1256 | case NLP_PLOGI_LIST: | |
dea3101e | 1257 | nlp->nlp_flag |= list; |
dea3101e | 1258 | /* Put it at the end of the plogi list */ |
1259 | list_add_tail(&nlp->nlp_listp, &phba->fc_plogi_list); | |
1260 | phba->fc_plogi_cnt++; | |
1261 | break; | |
1262 | case NLP_ADISC_LIST: | |
dea3101e | 1263 | nlp->nlp_flag |= list; |
dea3101e | 1264 | /* Put it at the end of the adisc list */ |
1265 | list_add_tail(&nlp->nlp_listp, &phba->fc_adisc_list); | |
1266 | phba->fc_adisc_cnt++; | |
1267 | break; | |
1268 | case NLP_REGLOGIN_LIST: | |
dea3101e | 1269 | nlp->nlp_flag |= list; |
dea3101e | 1270 | /* Put it at the end of the reglogin list */ |
1271 | list_add_tail(&nlp->nlp_listp, &phba->fc_reglogin_list); | |
1272 | phba->fc_reglogin_cnt++; | |
1273 | break; | |
1274 | case NLP_PRLI_LIST: | |
dea3101e | 1275 | nlp->nlp_flag |= list; |
dea3101e | 1276 | /* Put it at the end of the prli list */ |
1277 | list_add_tail(&nlp->nlp_listp, &phba->fc_prli_list); | |
1278 | phba->fc_prli_cnt++; | |
1279 | break; | |
1280 | case NLP_UNMAPPED_LIST: | |
1281 | rport_add = unmapped; | |
1282 | /* ensure all vestiges of "mapped" significance are gone */ | |
1283 | nlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR); | |
dea3101e | 1284 | nlp->nlp_flag |= list; |
dea3101e | 1285 | /* Put it at the end of the unmap list */ |
1286 | list_add_tail(&nlp->nlp_listp, &phba->fc_nlpunmap_list); | |
1287 | phba->fc_unmap_cnt++; | |
1288 | phba->nport_event_cnt++; | |
a0f9b48d | 1289 | nlp->nlp_flag &= ~NLP_NODEV_REMOVE; |
dea3101e | 1290 | nlp->nlp_type |= NLP_FC_NODE; |
1291 | break; | |
1292 | case NLP_MAPPED_LIST: | |
1293 | rport_add = mapped; | |
dea3101e | 1294 | nlp->nlp_flag |= list; |
dea3101e | 1295 | /* Put it at the end of the map list */ |
1296 | list_add_tail(&nlp->nlp_listp, &phba->fc_nlpmap_list); | |
1297 | phba->fc_map_cnt++; | |
1298 | phba->nport_event_cnt++; | |
a0f9b48d | 1299 | nlp->nlp_flag &= ~NLP_NODEV_REMOVE; |
dea3101e | 1300 | break; |
1301 | case NLP_NPR_LIST: | |
dea3101e | 1302 | nlp->nlp_flag |= list; |
dea3101e | 1303 | /* Put it at the end of the npr list */ |
1304 | list_add_tail(&nlp->nlp_listp, &phba->fc_npr_list); | |
1305 | phba->fc_npr_cnt++; | |
1306 | ||
dea3101e | 1307 | nlp->nlp_flag &= ~NLP_RCV_PLOGI; |
dea3101e | 1308 | break; |
1309 | case NLP_JUST_DQ: | |
1310 | break; | |
1311 | } | |
1312 | ||
66a9ed66 JW |
1313 | spin_unlock_irq(phba->host->host_lock); |
1314 | ||
dea3101e | 1315 | /* |
1316 | * We make all the calls into the transport after we have | |
1317 | * moved the node between lists. This so that we don't | |
1318 | * release the lock while in-between lists. | |
1319 | */ | |
1320 | ||
1321 | /* Don't upcall midlayer if we're unloading */ | |
1322 | if (!(phba->fc_flag & FC_UNLOADING)) { | |
1323 | /* | |
1324 | * We revalidate the rport pointer as the "add" function | |
1325 | * may have removed the remote port. | |
1326 | */ | |
1327 | if ((rport_del != none) && nlp->rport) | |
19a7b4ae | 1328 | lpfc_unregister_remote_port(phba, nlp); |
dea3101e | 1329 | |
1330 | if (rport_add != none) { | |
1331 | /* | |
1332 | * Tell the fc transport about the port, if we haven't | |
1333 | * already. If we have, and it's a scsi entity, be | |
1334 | * sure to unblock any attached scsi devices | |
1335 | */ | |
c01f3208 JS |
1336 | if ((!nlp->rport) || (nlp->rport->port_state == |
1337 | FC_PORTSTATE_BLOCKED)) | |
dea3101e | 1338 | lpfc_register_remote_port(phba, nlp); |
dea3101e | 1339 | |
1340 | /* | |
1341 | * if we added to Mapped list, but the remote port | |
1342 | * registration failed or assigned a target id outside | |
1343 | * our presentable range - move the node to the | |
1344 | * Unmapped List | |
1345 | */ | |
1346 | if ((rport_add == mapped) && | |
1347 | ((!nlp->rport) || | |
1348 | (nlp->rport->scsi_target_id == -1) || | |
e17da18e | 1349 | (nlp->rport->scsi_target_id >= LPFC_MAX_TARGET))) { |
dea3101e | 1350 | nlp->nlp_state = NLP_STE_UNMAPPED_NODE; |
1351 | spin_lock_irq(phba->host->host_lock); | |
1352 | nlp->nlp_flag |= NLP_TGT_NO_SCSIID; | |
1353 | spin_unlock_irq(phba->host->host_lock); | |
1354 | lpfc_nlp_list(phba, nlp, NLP_UNMAPPED_LIST); | |
1355 | } | |
1356 | } | |
1357 | } | |
2fe165b6 | 1358 | return 0; |
dea3101e | 1359 | } |
1360 | ||
1361 | /* | |
1362 | * Start / ReStart rescue timer for Discovery / RSCN handling | |
1363 | */ | |
1364 | void | |
1365 | lpfc_set_disctmo(struct lpfc_hba * phba) | |
1366 | { | |
1367 | uint32_t tmo; | |
1368 | ||
c9f8735b JW |
1369 | if (phba->hba_state == LPFC_LOCAL_CFG_LINK) { |
1370 | /* For FAN, timeout should be greater then edtov */ | |
1371 | tmo = (((phba->fc_edtov + 999) / 1000) + 1); | |
1372 | } else { | |
1373 | /* Normal discovery timeout should be > then ELS/CT timeout | |
1374 | * FC spec states we need 3 * ratov for CT requests | |
1375 | */ | |
1376 | tmo = ((phba->fc_ratov * 3) + 3); | |
1377 | } | |
dea3101e | 1378 | |
1379 | mod_timer(&phba->fc_disctmo, jiffies + HZ * tmo); | |
1380 | spin_lock_irq(phba->host->host_lock); | |
1381 | phba->fc_flag |= FC_DISC_TMO; | |
1382 | spin_unlock_irq(phba->host->host_lock); | |
1383 | ||
1384 | /* Start Discovery Timer state <hba_state> */ | |
1385 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, | |
1386 | "%d:0247 Start Discovery Timer state x%x " | |
1387 | "Data: x%x x%lx x%x x%x\n", | |
1388 | phba->brd_no, | |
1389 | phba->hba_state, tmo, (unsigned long)&phba->fc_disctmo, | |
1390 | phba->fc_plogi_cnt, phba->fc_adisc_cnt); | |
1391 | ||
1392 | return; | |
1393 | } | |
1394 | ||
1395 | /* | |
1396 | * Cancel rescue timer for Discovery / RSCN handling | |
1397 | */ | |
1398 | int | |
1399 | lpfc_can_disctmo(struct lpfc_hba * phba) | |
1400 | { | |
1401 | /* Turn off discovery timer if its running */ | |
1402 | if (phba->fc_flag & FC_DISC_TMO) { | |
1403 | spin_lock_irq(phba->host->host_lock); | |
1404 | phba->fc_flag &= ~FC_DISC_TMO; | |
1405 | spin_unlock_irq(phba->host->host_lock); | |
1406 | del_timer_sync(&phba->fc_disctmo); | |
1407 | phba->work_hba_events &= ~WORKER_DISC_TMO; | |
1408 | } | |
1409 | ||
1410 | /* Cancel Discovery Timer state <hba_state> */ | |
1411 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, | |
1412 | "%d:0248 Cancel Discovery Timer state x%x " | |
1413 | "Data: x%x x%x x%x\n", | |
1414 | phba->brd_no, phba->hba_state, phba->fc_flag, | |
1415 | phba->fc_plogi_cnt, phba->fc_adisc_cnt); | |
1416 | ||
2fe165b6 | 1417 | return 0; |
dea3101e | 1418 | } |
1419 | ||
1420 | /* | |
1421 | * Check specified ring for outstanding IOCB on the SLI queue | |
1422 | * Return true if iocb matches the specified nport | |
1423 | */ | |
1424 | int | |
1425 | lpfc_check_sli_ndlp(struct lpfc_hba * phba, | |
1426 | struct lpfc_sli_ring * pring, | |
1427 | struct lpfc_iocbq * iocb, struct lpfc_nodelist * ndlp) | |
1428 | { | |
1429 | struct lpfc_sli *psli; | |
1430 | IOCB_t *icmd; | |
1431 | ||
1432 | psli = &phba->sli; | |
1433 | icmd = &iocb->iocb; | |
1434 | if (pring->ringno == LPFC_ELS_RING) { | |
1435 | switch (icmd->ulpCommand) { | |
1436 | case CMD_GEN_REQUEST64_CR: | |
1437 | if (icmd->ulpContext == (volatile ushort)ndlp->nlp_rpi) | |
2fe165b6 | 1438 | return 1; |
dea3101e | 1439 | case CMD_ELS_REQUEST64_CR: |
10d4e957 JS |
1440 | if (icmd->un.elsreq64.remoteID == ndlp->nlp_DID) |
1441 | return 1; | |
dea3101e | 1442 | case CMD_XMIT_ELS_RSP64_CX: |
1443 | if (iocb->context1 == (uint8_t *) ndlp) | |
2fe165b6 | 1444 | return 1; |
dea3101e | 1445 | } |
a4bc3379 | 1446 | } else if (pring->ringno == psli->extra_ring) { |
dea3101e | 1447 | |
1448 | } else if (pring->ringno == psli->fcp_ring) { | |
1449 | /* Skip match check if waiting to relogin to FCP target */ | |
1450 | if ((ndlp->nlp_type & NLP_FCP_TARGET) && | |
1451 | (ndlp->nlp_flag & NLP_DELAY_TMO)) { | |
2fe165b6 | 1452 | return 0; |
dea3101e | 1453 | } |
1454 | if (icmd->ulpContext == (volatile ushort)ndlp->nlp_rpi) { | |
2fe165b6 | 1455 | return 1; |
dea3101e | 1456 | } |
1457 | } else if (pring->ringno == psli->next_ring) { | |
1458 | ||
1459 | } | |
2fe165b6 | 1460 | return 0; |
dea3101e | 1461 | } |
1462 | ||
1463 | /* | |
1464 | * Free resources / clean up outstanding I/Os | |
1465 | * associated with nlp_rpi in the LPFC_NODELIST entry. | |
1466 | */ | |
1467 | static int | |
1468 | lpfc_no_rpi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp) | |
1469 | { | |
1470 | struct lpfc_sli *psli; | |
1471 | struct lpfc_sli_ring *pring; | |
1472 | struct lpfc_iocbq *iocb, *next_iocb; | |
1473 | IOCB_t *icmd; | |
1474 | uint32_t rpi, i; | |
1475 | ||
1476 | /* | |
1477 | * Everything that matches on txcmplq will be returned | |
1478 | * by firmware with a no rpi error. | |
1479 | */ | |
1480 | psli = &phba->sli; | |
1481 | rpi = ndlp->nlp_rpi; | |
1482 | if (rpi) { | |
1483 | /* Now process each ring */ | |
1484 | for (i = 0; i < psli->num_rings; i++) { | |
1485 | pring = &psli->ring[i]; | |
1486 | ||
1487 | spin_lock_irq(phba->host->host_lock); | |
1488 | list_for_each_entry_safe(iocb, next_iocb, &pring->txq, | |
1489 | list) { | |
1490 | /* | |
1491 | * Check to see if iocb matches the nport we are | |
1492 | * looking for | |
1493 | */ | |
1494 | if ((lpfc_check_sli_ndlp | |
1495 | (phba, pring, iocb, ndlp))) { | |
1496 | /* It matches, so deque and call compl | |
1497 | with an error */ | |
1498 | list_del(&iocb->list); | |
1499 | pring->txq_cnt--; | |
1500 | if (iocb->iocb_cmpl) { | |
1501 | icmd = &iocb->iocb; | |
1502 | icmd->ulpStatus = | |
1503 | IOSTAT_LOCAL_REJECT; | |
1504 | icmd->un.ulpWord[4] = | |
1505 | IOERR_SLI_ABORTED; | |
1506 | spin_unlock_irq(phba->host-> | |
1507 | host_lock); | |
1508 | (iocb->iocb_cmpl) (phba, | |
1509 | iocb, iocb); | |
1510 | spin_lock_irq(phba->host-> | |
1511 | host_lock); | |
604a3e30 JB |
1512 | } else |
1513 | lpfc_sli_release_iocbq(phba, | |
1514 | iocb); | |
dea3101e | 1515 | } |
1516 | } | |
1517 | spin_unlock_irq(phba->host->host_lock); | |
1518 | ||
1519 | } | |
1520 | } | |
2fe165b6 | 1521 | return 0; |
dea3101e | 1522 | } |
1523 | ||
1524 | /* | |
1525 | * Free rpi associated with LPFC_NODELIST entry. | |
1526 | * This routine is called from lpfc_freenode(), when we are removing | |
1527 | * a LPFC_NODELIST entry. It is also called if the driver initiates a | |
1528 | * LOGO that completes successfully, and we are waiting to PLOGI back | |
1529 | * to the remote NPort. In addition, it is called after we receive | |
1530 | * and unsolicated ELS cmd, send back a rsp, the rsp completes and | |
1531 | * we are waiting to PLOGI back to the remote NPort. | |
1532 | */ | |
1533 | int | |
1534 | lpfc_unreg_rpi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp) | |
1535 | { | |
1536 | LPFC_MBOXQ_t *mbox; | |
1537 | int rc; | |
1538 | ||
1539 | if (ndlp->nlp_rpi) { | |
1540 | if ((mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL))) { | |
1541 | lpfc_unreg_login(phba, ndlp->nlp_rpi, mbox); | |
1542 | mbox->mbox_cmpl=lpfc_sli_def_mbox_cmpl; | |
1543 | rc = lpfc_sli_issue_mbox | |
1544 | (phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB)); | |
1545 | if (rc == MBX_NOT_FINISHED) | |
1546 | mempool_free( mbox, phba->mbox_mem_pool); | |
1547 | } | |
dea3101e | 1548 | lpfc_no_rpi(phba, ndlp); |
1549 | ndlp->nlp_rpi = 0; | |
1550 | return 1; | |
1551 | } | |
1552 | return 0; | |
1553 | } | |
1554 | ||
1555 | /* | |
1556 | * Free resources associated with LPFC_NODELIST entry | |
1557 | * so it can be freed. | |
1558 | */ | |
1559 | static int | |
1560 | lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp) | |
1561 | { | |
1562 | LPFC_MBOXQ_t *mb; | |
1563 | LPFC_MBOXQ_t *nextmb; | |
1564 | struct lpfc_dmabuf *mp; | |
dea3101e | 1565 | |
1566 | /* Cleanup node for NPort <nlp_DID> */ | |
1567 | lpfc_printf_log(phba, KERN_INFO, LOG_NODE, | |
1568 | "%d:0900 Cleanup node for NPort x%x " | |
1569 | "Data: x%x x%x x%x\n", | |
1570 | phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag, | |
1571 | ndlp->nlp_state, ndlp->nlp_rpi); | |
1572 | ||
1573 | lpfc_nlp_list(phba, ndlp, NLP_JUST_DQ); | |
1574 | ||
dea3101e | 1575 | /* cleanup any ndlp on mbox q waiting for reglogin cmpl */ |
1576 | if ((mb = phba->sli.mbox_active)) { | |
1577 | if ((mb->mb.mbxCommand == MBX_REG_LOGIN64) && | |
1578 | (ndlp == (struct lpfc_nodelist *) mb->context2)) { | |
1579 | mb->context2 = NULL; | |
1580 | mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | |
1581 | } | |
1582 | } | |
33ccf8d1 JS |
1583 | |
1584 | spin_lock_irq(phba->host->host_lock); | |
dea3101e | 1585 | list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { |
1586 | if ((mb->mb.mbxCommand == MBX_REG_LOGIN64) && | |
1587 | (ndlp == (struct lpfc_nodelist *) mb->context2)) { | |
1588 | mp = (struct lpfc_dmabuf *) (mb->context1); | |
1589 | if (mp) { | |
1590 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
1591 | kfree(mp); | |
1592 | } | |
1593 | list_del(&mb->list); | |
1594 | mempool_free(mb, phba->mbox_mem_pool); | |
1595 | } | |
1596 | } | |
33ccf8d1 | 1597 | spin_unlock_irq(phba->host->host_lock); |
dea3101e | 1598 | |
07951076 | 1599 | lpfc_els_abort(phba,ndlp); |
dea3101e | 1600 | spin_lock_irq(phba->host->host_lock); |
c01f3208 | 1601 | ndlp->nlp_flag &= ~NLP_DELAY_TMO; |
dea3101e | 1602 | spin_unlock_irq(phba->host->host_lock); |
dea3101e | 1603 | |
5024ab17 | 1604 | ndlp->nlp_last_elscmd = 0; |
dea3101e | 1605 | del_timer_sync(&ndlp->nlp_delayfunc); |
1606 | ||
dea3101e | 1607 | if (!list_empty(&ndlp->els_retry_evt.evt_listp)) |
1608 | list_del_init(&ndlp->els_retry_evt.evt_listp); | |
1609 | ||
1610 | lpfc_unreg_rpi(phba, ndlp); | |
1611 | ||
2fe165b6 | 1612 | return 0; |
dea3101e | 1613 | } |
1614 | ||
1615 | /* | |
1616 | * Check to see if we can free the nlp back to the freelist. | |
1617 | * If we are in the middle of using the nlp in the discovery state | |
1618 | * machine, defer the free till we reach the end of the state machine. | |
1619 | */ | |
1620 | int | |
1621 | lpfc_nlp_remove(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp) | |
1622 | { | |
1dcb58e5 | 1623 | struct lpfc_rport_data *rdata; |
dea3101e | 1624 | |
1625 | if (ndlp->nlp_flag & NLP_DELAY_TMO) { | |
fdcebe28 | 1626 | lpfc_cancel_retry_delay_tmo(phba, ndlp); |
dea3101e | 1627 | } |
1628 | ||
1629 | if (ndlp->nlp_disc_refcnt) { | |
1630 | spin_lock_irq(phba->host->host_lock); | |
1631 | ndlp->nlp_flag |= NLP_DELAY_REMOVE; | |
1632 | spin_unlock_irq(phba->host->host_lock); | |
2fe165b6 | 1633 | } else { |
dea3101e | 1634 | lpfc_freenode(phba, ndlp); |
1dcb58e5 JS |
1635 | |
1636 | if ((ndlp->rport) && !(phba->fc_flag & FC_UNLOADING)) { | |
1637 | rdata = ndlp->rport->dd_data; | |
1638 | rdata->pnode = NULL; | |
1639 | ndlp->rport = NULL; | |
1640 | } | |
1641 | ||
dea3101e | 1642 | mempool_free( ndlp, phba->nlp_mem_pool); |
1643 | } | |
2fe165b6 | 1644 | return 0; |
dea3101e | 1645 | } |
1646 | ||
1647 | static int | |
1648 | lpfc_matchdid(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, uint32_t did) | |
1649 | { | |
1650 | D_ID mydid; | |
1651 | D_ID ndlpdid; | |
1652 | D_ID matchdid; | |
1653 | ||
1654 | if (did == Bcast_DID) | |
2fe165b6 | 1655 | return 0; |
dea3101e | 1656 | |
1657 | if (ndlp->nlp_DID == 0) { | |
2fe165b6 | 1658 | return 0; |
dea3101e | 1659 | } |
1660 | ||
1661 | /* First check for Direct match */ | |
1662 | if (ndlp->nlp_DID == did) | |
2fe165b6 | 1663 | return 1; |
dea3101e | 1664 | |
1665 | /* Next check for area/domain identically equals 0 match */ | |
1666 | mydid.un.word = phba->fc_myDID; | |
1667 | if ((mydid.un.b.domain == 0) && (mydid.un.b.area == 0)) { | |
2fe165b6 | 1668 | return 0; |
dea3101e | 1669 | } |
1670 | ||
1671 | matchdid.un.word = did; | |
1672 | ndlpdid.un.word = ndlp->nlp_DID; | |
1673 | if (matchdid.un.b.id == ndlpdid.un.b.id) { | |
1674 | if ((mydid.un.b.domain == matchdid.un.b.domain) && | |
1675 | (mydid.un.b.area == matchdid.un.b.area)) { | |
1676 | if ((ndlpdid.un.b.domain == 0) && | |
1677 | (ndlpdid.un.b.area == 0)) { | |
1678 | if (ndlpdid.un.b.id) | |
2fe165b6 | 1679 | return 1; |
dea3101e | 1680 | } |
2fe165b6 | 1681 | return 0; |
dea3101e | 1682 | } |
1683 | ||
1684 | matchdid.un.word = ndlp->nlp_DID; | |
1685 | if ((mydid.un.b.domain == ndlpdid.un.b.domain) && | |
1686 | (mydid.un.b.area == ndlpdid.un.b.area)) { | |
1687 | if ((matchdid.un.b.domain == 0) && | |
1688 | (matchdid.un.b.area == 0)) { | |
1689 | if (matchdid.un.b.id) | |
2fe165b6 | 1690 | return 1; |
dea3101e | 1691 | } |
1692 | } | |
1693 | } | |
2fe165b6 | 1694 | return 0; |
dea3101e | 1695 | } |
1696 | ||
1697 | /* Search for a nodelist entry on a specific list */ | |
1698 | struct lpfc_nodelist * | |
1699 | lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did) | |
1700 | { | |
2fb9bd8b JS |
1701 | struct lpfc_nodelist *ndlp; |
1702 | struct list_head *lists[]={&phba->fc_nlpunmap_list, | |
1703 | &phba->fc_nlpmap_list, | |
1704 | &phba->fc_plogi_list, | |
1705 | &phba->fc_adisc_list, | |
1706 | &phba->fc_reglogin_list, | |
1707 | &phba->fc_prli_list, | |
1708 | &phba->fc_npr_list, | |
1709 | &phba->fc_unused_list}; | |
1710 | uint32_t search[]={NLP_SEARCH_UNMAPPED, | |
1711 | NLP_SEARCH_MAPPED, | |
1712 | NLP_SEARCH_PLOGI, | |
1713 | NLP_SEARCH_ADISC, | |
1714 | NLP_SEARCH_REGLOGIN, | |
1715 | NLP_SEARCH_PRLI, | |
1716 | NLP_SEARCH_NPR, | |
1717 | NLP_SEARCH_UNUSED}; | |
1718 | int i; | |
dea3101e | 1719 | uint32_t data1; |
1720 | ||
66a9ed66 | 1721 | spin_lock_irq(phba->host->host_lock); |
2fb9bd8b JS |
1722 | for (i = 0; i < ARRAY_SIZE(lists); i++ ) { |
1723 | if (!(order & search[i])) | |
1724 | continue; | |
1725 | list_for_each_entry(ndlp, lists[i], nlp_listp) { | |
dea3101e | 1726 | if (lpfc_matchdid(phba, ndlp, did)) { |
dea3101e | 1727 | data1 = (((uint32_t) ndlp->nlp_state << 24) | |
1728 | ((uint32_t) ndlp->nlp_xri << 16) | | |
1729 | ((uint32_t) ndlp->nlp_type << 8) | | |
1730 | ((uint32_t) ndlp->nlp_rpi & 0xff)); | |
dea3101e | 1731 | lpfc_printf_log(phba, KERN_INFO, LOG_NODE, |
2fb9bd8b | 1732 | "%d:0929 FIND node DID " |
dea3101e | 1733 | " Data: x%p x%x x%x x%x\n", |
1734 | phba->brd_no, | |
1735 | ndlp, ndlp->nlp_DID, | |
1736 | ndlp->nlp_flag, data1); | |
66a9ed66 | 1737 | spin_unlock_irq(phba->host->host_lock); |
2fe165b6 | 1738 | return ndlp; |
dea3101e | 1739 | } |
1740 | } | |
1741 | } | |
66a9ed66 JW |
1742 | spin_unlock_irq(phba->host->host_lock); |
1743 | ||
dea3101e | 1744 | /* FIND node did <did> NOT FOUND */ |
2fb9bd8b | 1745 | lpfc_printf_log(phba, KERN_INFO, LOG_NODE, |
dea3101e | 1746 | "%d:0932 FIND node did x%x NOT FOUND Data: x%x\n", |
1747 | phba->brd_no, did, order); | |
dea3101e | 1748 | return NULL; |
1749 | } | |
1750 | ||
1751 | struct lpfc_nodelist * | |
1752 | lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did) | |
1753 | { | |
1754 | struct lpfc_nodelist *ndlp; | |
1755 | uint32_t flg; | |
1756 | ||
c9f8735b JW |
1757 | ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, did); |
1758 | if (!ndlp) { | |
1759 | if ((phba->fc_flag & FC_RSCN_MODE) && | |
dea3101e | 1760 | ((lpfc_rscn_payload_check(phba, did) == 0))) |
1761 | return NULL; | |
1762 | ndlp = (struct lpfc_nodelist *) | |
1763 | mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); | |
1764 | if (!ndlp) | |
1765 | return NULL; | |
1766 | lpfc_nlp_init(phba, ndlp, did); | |
1767 | ndlp->nlp_state = NLP_STE_NPR_NODE; | |
1768 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); | |
1769 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; | |
1770 | return ndlp; | |
1771 | } | |
c9f8735b | 1772 | if (phba->fc_flag & FC_RSCN_MODE) { |
dea3101e | 1773 | if (lpfc_rscn_payload_check(phba, did)) { |
1774 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; | |
c9f8735b JW |
1775 | |
1776 | /* Since this node is marked for discovery, | |
1777 | * delay timeout is not needed. | |
1778 | */ | |
fdcebe28 JS |
1779 | if (ndlp->nlp_flag & NLP_DELAY_TMO) |
1780 | lpfc_cancel_retry_delay_tmo(phba, ndlp); | |
071fbd3d | 1781 | } else |
dea3101e | 1782 | ndlp = NULL; |
2fe165b6 | 1783 | } else { |
dea3101e | 1784 | flg = ndlp->nlp_flag & NLP_LIST_MASK; |
c9f8735b | 1785 | if ((flg == NLP_ADISC_LIST) || (flg == NLP_PLOGI_LIST)) |
dea3101e | 1786 | return NULL; |
dea3101e | 1787 | ndlp->nlp_state = NLP_STE_NPR_NODE; |
1788 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); | |
1789 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; | |
1790 | } | |
1791 | return ndlp; | |
1792 | } | |
1793 | ||
1794 | /* Build a list of nodes to discover based on the loopmap */ | |
1795 | void | |
1796 | lpfc_disc_list_loopmap(struct lpfc_hba * phba) | |
1797 | { | |
1798 | int j; | |
1799 | uint32_t alpa, index; | |
1800 | ||
1801 | if (phba->hba_state <= LPFC_LINK_DOWN) { | |
1802 | return; | |
1803 | } | |
1804 | if (phba->fc_topology != TOPOLOGY_LOOP) { | |
1805 | return; | |
1806 | } | |
1807 | ||
1808 | /* Check for loop map present or not */ | |
1809 | if (phba->alpa_map[0]) { | |
1810 | for (j = 1; j <= phba->alpa_map[0]; j++) { | |
1811 | alpa = phba->alpa_map[j]; | |
1812 | ||
1813 | if (((phba->fc_myDID & 0xff) == alpa) || (alpa == 0)) { | |
1814 | continue; | |
1815 | } | |
1816 | lpfc_setup_disc_node(phba, alpa); | |
1817 | } | |
1818 | } else { | |
1819 | /* No alpamap, so try all alpa's */ | |
1820 | for (j = 0; j < FC_MAXLOOP; j++) { | |
1821 | /* If cfg_scan_down is set, start from highest | |
1822 | * ALPA (0xef) to lowest (0x1). | |
1823 | */ | |
1824 | if (phba->cfg_scan_down) | |
1825 | index = j; | |
1826 | else | |
1827 | index = FC_MAXLOOP - j - 1; | |
1828 | alpa = lpfcAlpaArray[index]; | |
1829 | if ((phba->fc_myDID & 0xff) == alpa) { | |
1830 | continue; | |
1831 | } | |
1832 | ||
1833 | lpfc_setup_disc_node(phba, alpa); | |
1834 | } | |
1835 | } | |
1836 | return; | |
1837 | } | |
1838 | ||
1839 | /* Start Link up / RSCN discovery on NPR list */ | |
1840 | void | |
1841 | lpfc_disc_start(struct lpfc_hba * phba) | |
1842 | { | |
1843 | struct lpfc_sli *psli; | |
1844 | LPFC_MBOXQ_t *mbox; | |
1845 | struct lpfc_nodelist *ndlp, *next_ndlp; | |
1846 | uint32_t did_changed, num_sent; | |
1847 | uint32_t clear_la_pending; | |
1848 | int rc; | |
1849 | ||
1850 | psli = &phba->sli; | |
1851 | ||
1852 | if (phba->hba_state <= LPFC_LINK_DOWN) { | |
1853 | return; | |
1854 | } | |
1855 | if (phba->hba_state == LPFC_CLEAR_LA) | |
1856 | clear_la_pending = 1; | |
1857 | else | |
1858 | clear_la_pending = 0; | |
1859 | ||
1860 | if (phba->hba_state < LPFC_HBA_READY) { | |
1861 | phba->hba_state = LPFC_DISC_AUTH; | |
1862 | } | |
1863 | lpfc_set_disctmo(phba); | |
1864 | ||
1865 | if (phba->fc_prevDID == phba->fc_myDID) { | |
1866 | did_changed = 0; | |
1867 | } else { | |
1868 | did_changed = 1; | |
1869 | } | |
1870 | phba->fc_prevDID = phba->fc_myDID; | |
1871 | phba->num_disc_nodes = 0; | |
1872 | ||
1873 | /* Start Discovery state <hba_state> */ | |
1874 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, | |
1875 | "%d:0202 Start Discovery hba state x%x " | |
1876 | "Data: x%x x%x x%x\n", | |
1877 | phba->brd_no, phba->hba_state, phba->fc_flag, | |
1878 | phba->fc_plogi_cnt, phba->fc_adisc_cnt); | |
1879 | ||
1880 | /* If our did changed, we MUST do PLOGI */ | |
1881 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, | |
1882 | nlp_listp) { | |
1883 | if (ndlp->nlp_flag & NLP_NPR_2B_DISC) { | |
1884 | if (did_changed) { | |
1885 | spin_lock_irq(phba->host->host_lock); | |
1886 | ndlp->nlp_flag &= ~NLP_NPR_ADISC; | |
1887 | spin_unlock_irq(phba->host->host_lock); | |
1888 | } | |
1889 | } | |
1890 | } | |
1891 | ||
1892 | /* First do ADISCs - if any */ | |
1893 | num_sent = lpfc_els_disc_adisc(phba); | |
1894 | ||
1895 | if (num_sent) | |
1896 | return; | |
1897 | ||
1898 | if ((phba->hba_state < LPFC_HBA_READY) && (!clear_la_pending)) { | |
1899 | /* If we get here, there is nothing to ADISC */ | |
1900 | if ((mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL))) { | |
1901 | phba->hba_state = LPFC_CLEAR_LA; | |
1902 | lpfc_clear_la(phba, mbox); | |
1903 | mbox->mbox_cmpl = lpfc_mbx_cmpl_clear_la; | |
1904 | rc = lpfc_sli_issue_mbox(phba, mbox, | |
1905 | (MBX_NOWAIT | MBX_STOP_IOCB)); | |
1906 | if (rc == MBX_NOT_FINISHED) { | |
1907 | mempool_free( mbox, phba->mbox_mem_pool); | |
1908 | lpfc_disc_flush_list(phba); | |
a4bc3379 | 1909 | psli->ring[(psli->extra_ring)].flag &= |
dea3101e | 1910 | ~LPFC_STOP_IOCB_EVENT; |
1911 | psli->ring[(psli->fcp_ring)].flag &= | |
1912 | ~LPFC_STOP_IOCB_EVENT; | |
1913 | psli->ring[(psli->next_ring)].flag &= | |
1914 | ~LPFC_STOP_IOCB_EVENT; | |
1915 | phba->hba_state = LPFC_HBA_READY; | |
1916 | } | |
1917 | } | |
1918 | } else { | |
1919 | /* Next do PLOGIs - if any */ | |
1920 | num_sent = lpfc_els_disc_plogi(phba); | |
1921 | ||
1922 | if (num_sent) | |
1923 | return; | |
1924 | ||
1925 | if (phba->fc_flag & FC_RSCN_MODE) { | |
1926 | /* Check to see if more RSCNs came in while we | |
1927 | * were processing this one. | |
1928 | */ | |
1929 | if ((phba->fc_rscn_id_cnt == 0) && | |
1930 | (!(phba->fc_flag & FC_RSCN_DISCOVERY))) { | |
1931 | spin_lock_irq(phba->host->host_lock); | |
1932 | phba->fc_flag &= ~FC_RSCN_MODE; | |
1933 | spin_unlock_irq(phba->host->host_lock); | |
2fe165b6 | 1934 | } else |
dea3101e | 1935 | lpfc_els_handle_rscn(phba); |
1936 | } | |
1937 | } | |
1938 | return; | |
1939 | } | |
1940 | ||
1941 | /* | |
1942 | * Ignore completion for all IOCBs on tx and txcmpl queue for ELS | |
1943 | * ring the match the sppecified nodelist. | |
1944 | */ | |
1945 | static void | |
1946 | lpfc_free_tx(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp) | |
1947 | { | |
1948 | struct lpfc_sli *psli; | |
1949 | IOCB_t *icmd; | |
1950 | struct lpfc_iocbq *iocb, *next_iocb; | |
1951 | struct lpfc_sli_ring *pring; | |
1952 | struct lpfc_dmabuf *mp; | |
1953 | ||
1954 | psli = &phba->sli; | |
1955 | pring = &psli->ring[LPFC_ELS_RING]; | |
1956 | ||
1957 | /* Error matching iocb on txq or txcmplq | |
1958 | * First check the txq. | |
1959 | */ | |
1960 | list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) { | |
1961 | if (iocb->context1 != ndlp) { | |
1962 | continue; | |
1963 | } | |
1964 | icmd = &iocb->iocb; | |
1965 | if ((icmd->ulpCommand == CMD_ELS_REQUEST64_CR) || | |
1966 | (icmd->ulpCommand == CMD_XMIT_ELS_RSP64_CX)) { | |
1967 | ||
1968 | list_del(&iocb->list); | |
1969 | pring->txq_cnt--; | |
1970 | lpfc_els_free_iocb(phba, iocb); | |
1971 | } | |
1972 | } | |
1973 | ||
1974 | /* Next check the txcmplq */ | |
1975 | list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) { | |
1976 | if (iocb->context1 != ndlp) { | |
1977 | continue; | |
1978 | } | |
1979 | icmd = &iocb->iocb; | |
1980 | if ((icmd->ulpCommand == CMD_ELS_REQUEST64_CR) || | |
1981 | (icmd->ulpCommand == CMD_XMIT_ELS_RSP64_CX)) { | |
1982 | ||
1983 | iocb->iocb_cmpl = NULL; | |
1984 | /* context2 = cmd, context2->next = rsp, context3 = | |
1985 | bpl */ | |
1986 | if (iocb->context2) { | |
1987 | /* Free the response IOCB before handling the | |
1988 | command. */ | |
1989 | ||
1990 | mp = (struct lpfc_dmabuf *) (iocb->context2); | |
1991 | mp = list_get_first(&mp->list, | |
1992 | struct lpfc_dmabuf, | |
1993 | list); | |
1994 | if (mp) { | |
1995 | /* Delay before releasing rsp buffer to | |
1996 | * give UNREG mbox a chance to take | |
1997 | * effect. | |
1998 | */ | |
1999 | list_add(&mp->list, | |
2000 | &phba->freebufList); | |
2001 | } | |
2002 | lpfc_mbuf_free(phba, | |
2003 | ((struct lpfc_dmabuf *) | |
2004 | iocb->context2)->virt, | |
2005 | ((struct lpfc_dmabuf *) | |
2006 | iocb->context2)->phys); | |
2007 | kfree(iocb->context2); | |
2008 | } | |
2009 | ||
2010 | if (iocb->context3) { | |
2011 | lpfc_mbuf_free(phba, | |
2012 | ((struct lpfc_dmabuf *) | |
2013 | iocb->context3)->virt, | |
2014 | ((struct lpfc_dmabuf *) | |
2015 | iocb->context3)->phys); | |
2016 | kfree(iocb->context3); | |
2017 | } | |
2018 | } | |
2019 | } | |
2020 | ||
2021 | return; | |
2022 | } | |
2023 | ||
2024 | void | |
2025 | lpfc_disc_flush_list(struct lpfc_hba * phba) | |
2026 | { | |
2027 | struct lpfc_nodelist *ndlp, *next_ndlp; | |
2028 | ||
2029 | if (phba->fc_plogi_cnt) { | |
2030 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list, | |
2031 | nlp_listp) { | |
2032 | lpfc_free_tx(phba, ndlp); | |
2033 | lpfc_nlp_remove(phba, ndlp); | |
2034 | } | |
2035 | } | |
2036 | if (phba->fc_adisc_cnt) { | |
2037 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list, | |
2038 | nlp_listp) { | |
2039 | lpfc_free_tx(phba, ndlp); | |
2040 | lpfc_nlp_remove(phba, ndlp); | |
2041 | } | |
2042 | } | |
2043 | return; | |
2044 | } | |
2045 | ||
2046 | /*****************************************************************************/ | |
2047 | /* | |
2048 | * NAME: lpfc_disc_timeout | |
2049 | * | |
2050 | * FUNCTION: Fibre Channel driver discovery timeout routine. | |
2051 | * | |
2052 | * EXECUTION ENVIRONMENT: interrupt only | |
2053 | * | |
2054 | * CALLED FROM: | |
2055 | * Timer function | |
2056 | * | |
2057 | * RETURNS: | |
2058 | * none | |
2059 | */ | |
2060 | /*****************************************************************************/ | |
2061 | void | |
2062 | lpfc_disc_timeout(unsigned long ptr) | |
2063 | { | |
2064 | struct lpfc_hba *phba = (struct lpfc_hba *)ptr; | |
2065 | unsigned long flags = 0; | |
2066 | ||
2067 | if (unlikely(!phba)) | |
2068 | return; | |
2069 | ||
2070 | spin_lock_irqsave(phba->host->host_lock, flags); | |
2071 | if (!(phba->work_hba_events & WORKER_DISC_TMO)) { | |
2072 | phba->work_hba_events |= WORKER_DISC_TMO; | |
2073 | if (phba->work_wait) | |
2074 | wake_up(phba->work_wait); | |
2075 | } | |
2076 | spin_unlock_irqrestore(phba->host->host_lock, flags); | |
2077 | return; | |
2078 | } | |
2079 | ||
2080 | static void | |
2081 | lpfc_disc_timeout_handler(struct lpfc_hba *phba) | |
2082 | { | |
2083 | struct lpfc_sli *psli; | |
c9f8735b | 2084 | struct lpfc_nodelist *ndlp, *next_ndlp; |
dea3101e | 2085 | LPFC_MBOXQ_t *clearlambox, *initlinkmbox; |
2086 | int rc, clrlaerr = 0; | |
2087 | ||
2088 | if (unlikely(!phba)) | |
2089 | return; | |
2090 | ||
2091 | if (!(phba->fc_flag & FC_DISC_TMO)) | |
2092 | return; | |
2093 | ||
2094 | psli = &phba->sli; | |
2095 | ||
2096 | spin_lock_irq(phba->host->host_lock); | |
2097 | phba->fc_flag &= ~FC_DISC_TMO; | |
2098 | spin_unlock_irq(phba->host->host_lock); | |
2099 | ||
2100 | switch (phba->hba_state) { | |
2101 | ||
2102 | case LPFC_LOCAL_CFG_LINK: | |
2103 | /* hba_state is identically LPFC_LOCAL_CFG_LINK while waiting for FAN */ | |
2104 | /* FAN timeout */ | |
2105 | lpfc_printf_log(phba, | |
2106 | KERN_WARNING, | |
2107 | LOG_DISCOVERY, | |
2108 | "%d:0221 FAN timeout\n", | |
2109 | phba->brd_no); | |
2110 | ||
c9f8735b JW |
2111 | /* Start discovery by sending FLOGI, clean up old rpis */ |
2112 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, | |
2113 | nlp_listp) { | |
2114 | if (ndlp->nlp_type & NLP_FABRIC) { | |
2115 | /* Clean up the ndlp on Fabric connections */ | |
2116 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | |
2fe165b6 | 2117 | } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { |
c9f8735b JW |
2118 | /* Fail outstanding IO now since device |
2119 | * is marked for PLOGI. | |
2120 | */ | |
2121 | lpfc_unreg_rpi(phba, ndlp); | |
2122 | } | |
2123 | } | |
dea3101e | 2124 | phba->hba_state = LPFC_FLOGI; |
2125 | lpfc_set_disctmo(phba); | |
2126 | lpfc_initial_flogi(phba); | |
2127 | break; | |
2128 | ||
2129 | case LPFC_FLOGI: | |
2130 | /* hba_state is identically LPFC_FLOGI while waiting for FLOGI cmpl */ | |
2131 | /* Initial FLOGI timeout */ | |
2132 | lpfc_printf_log(phba, | |
2133 | KERN_ERR, | |
2134 | LOG_DISCOVERY, | |
2135 | "%d:0222 Initial FLOGI timeout\n", | |
2136 | phba->brd_no); | |
2137 | ||
2138 | /* Assume no Fabric and go on with discovery. | |
2139 | * Check for outstanding ELS FLOGI to abort. | |
2140 | */ | |
2141 | ||
2142 | /* FLOGI failed, so just use loop map to make discovery list */ | |
2143 | lpfc_disc_list_loopmap(phba); | |
2144 | ||
2145 | /* Start discovery */ | |
2146 | lpfc_disc_start(phba); | |
2147 | break; | |
2148 | ||
2149 | case LPFC_FABRIC_CFG_LINK: | |
2150 | /* hba_state is identically LPFC_FABRIC_CFG_LINK while waiting for | |
2151 | NameServer login */ | |
2152 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | |
2153 | "%d:0223 Timeout while waiting for NameServer " | |
2154 | "login\n", phba->brd_no); | |
2155 | ||
2156 | /* Next look for NameServer ndlp */ | |
2157 | ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, NameServer_DID); | |
2158 | if (ndlp) | |
2159 | lpfc_nlp_remove(phba, ndlp); | |
2160 | /* Start discovery */ | |
2161 | lpfc_disc_start(phba); | |
2162 | break; | |
2163 | ||
2164 | case LPFC_NS_QRY: | |
2165 | /* Check for wait for NameServer Rsp timeout */ | |
2166 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | |
2167 | "%d:0224 NameServer Query timeout " | |
2168 | "Data: x%x x%x\n", | |
2169 | phba->brd_no, | |
2170 | phba->fc_ns_retry, LPFC_MAX_NS_RETRY); | |
2171 | ||
2172 | ndlp = lpfc_findnode_did(phba, NLP_SEARCH_UNMAPPED, | |
2173 | NameServer_DID); | |
2174 | if (ndlp) { | |
2175 | if (phba->fc_ns_retry < LPFC_MAX_NS_RETRY) { | |
2176 | /* Try it one more time */ | |
2177 | rc = lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT); | |
2178 | if (rc == 0) | |
2179 | break; | |
2180 | } | |
2181 | phba->fc_ns_retry = 0; | |
2182 | } | |
2183 | ||
2184 | /* Nothing to authenticate, so CLEAR_LA right now */ | |
2185 | clearlambox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | |
2186 | if (!clearlambox) { | |
2187 | clrlaerr = 1; | |
2188 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | |
2189 | "%d:0226 Device Discovery " | |
2190 | "completion error\n", | |
2191 | phba->brd_no); | |
2192 | phba->hba_state = LPFC_HBA_ERROR; | |
2193 | break; | |
2194 | } | |
2195 | ||
2196 | phba->hba_state = LPFC_CLEAR_LA; | |
2197 | lpfc_clear_la(phba, clearlambox); | |
2198 | clearlambox->mbox_cmpl = lpfc_mbx_cmpl_clear_la; | |
2199 | rc = lpfc_sli_issue_mbox(phba, clearlambox, | |
2200 | (MBX_NOWAIT | MBX_STOP_IOCB)); | |
2201 | if (rc == MBX_NOT_FINISHED) { | |
2202 | mempool_free(clearlambox, phba->mbox_mem_pool); | |
2203 | clrlaerr = 1; | |
2204 | break; | |
2205 | } | |
2206 | ||
2207 | /* Setup and issue mailbox INITIALIZE LINK command */ | |
2208 | initlinkmbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | |
2209 | if (!initlinkmbox) { | |
2210 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | |
dca9479b | 2211 | "%d:0206 Device Discovery " |
dea3101e | 2212 | "completion error\n", |
2213 | phba->brd_no); | |
2214 | phba->hba_state = LPFC_HBA_ERROR; | |
2215 | break; | |
2216 | } | |
2217 | ||
2218 | lpfc_linkdown(phba); | |
2219 | lpfc_init_link(phba, initlinkmbox, phba->cfg_topology, | |
2220 | phba->cfg_link_speed); | |
2221 | initlinkmbox->mb.un.varInitLnk.lipsr_AL_PA = 0; | |
2222 | rc = lpfc_sli_issue_mbox(phba, initlinkmbox, | |
2223 | (MBX_NOWAIT | MBX_STOP_IOCB)); | |
2224 | if (rc == MBX_NOT_FINISHED) | |
2225 | mempool_free(initlinkmbox, phba->mbox_mem_pool); | |
2226 | ||
2227 | break; | |
2228 | ||
2229 | case LPFC_DISC_AUTH: | |
2230 | /* Node Authentication timeout */ | |
2231 | lpfc_printf_log(phba, | |
2232 | KERN_ERR, | |
2233 | LOG_DISCOVERY, | |
2234 | "%d:0227 Node Authentication timeout\n", | |
2235 | phba->brd_no); | |
2236 | lpfc_disc_flush_list(phba); | |
2237 | clearlambox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | |
2238 | if (!clearlambox) { | |
2239 | clrlaerr = 1; | |
2240 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | |
dca9479b | 2241 | "%d:0207 Device Discovery " |
dea3101e | 2242 | "completion error\n", |
2243 | phba->brd_no); | |
2244 | phba->hba_state = LPFC_HBA_ERROR; | |
2245 | break; | |
2246 | } | |
2247 | phba->hba_state = LPFC_CLEAR_LA; | |
2248 | lpfc_clear_la(phba, clearlambox); | |
2249 | clearlambox->mbox_cmpl = lpfc_mbx_cmpl_clear_la; | |
2250 | rc = lpfc_sli_issue_mbox(phba, clearlambox, | |
2251 | (MBX_NOWAIT | MBX_STOP_IOCB)); | |
2252 | if (rc == MBX_NOT_FINISHED) { | |
2253 | mempool_free(clearlambox, phba->mbox_mem_pool); | |
2254 | clrlaerr = 1; | |
2255 | } | |
2256 | break; | |
2257 | ||
2258 | case LPFC_CLEAR_LA: | |
2259 | /* CLEAR LA timeout */ | |
2260 | lpfc_printf_log(phba, | |
2261 | KERN_ERR, | |
2262 | LOG_DISCOVERY, | |
2263 | "%d:0228 CLEAR LA timeout\n", | |
2264 | phba->brd_no); | |
2265 | clrlaerr = 1; | |
2266 | break; | |
2267 | ||
2268 | case LPFC_HBA_READY: | |
2269 | if (phba->fc_flag & FC_RSCN_MODE) { | |
2270 | lpfc_printf_log(phba, | |
2271 | KERN_ERR, | |
2272 | LOG_DISCOVERY, | |
2273 | "%d:0231 RSCN timeout Data: x%x x%x\n", | |
2274 | phba->brd_no, | |
2275 | phba->fc_ns_retry, LPFC_MAX_NS_RETRY); | |
2276 | ||
2277 | /* Cleanup any outstanding ELS commands */ | |
2278 | lpfc_els_flush_cmd(phba); | |
2279 | ||
2280 | lpfc_els_flush_rscn(phba); | |
2281 | lpfc_disc_flush_list(phba); | |
2282 | } | |
2283 | break; | |
2284 | } | |
2285 | ||
2286 | if (clrlaerr) { | |
2287 | lpfc_disc_flush_list(phba); | |
a4bc3379 | 2288 | psli->ring[(psli->extra_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; |
dea3101e | 2289 | psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; |
2290 | psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; | |
2291 | phba->hba_state = LPFC_HBA_READY; | |
2292 | } | |
2293 | ||
2294 | return; | |
2295 | } | |
2296 | ||
dea3101e | 2297 | /* |
2298 | * This routine handles processing a NameServer REG_LOGIN mailbox | |
2299 | * command upon completion. It is setup in the LPFC_MBOXQ | |
2300 | * as the completion routine when the command is | |
2301 | * handed off to the SLI layer. | |
2302 | */ | |
2303 | void | |
2304 | lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |
2305 | { | |
2306 | struct lpfc_sli *psli; | |
2307 | MAILBOX_t *mb; | |
2308 | struct lpfc_dmabuf *mp; | |
2309 | struct lpfc_nodelist *ndlp; | |
2310 | ||
2311 | psli = &phba->sli; | |
2312 | mb = &pmb->mb; | |
2313 | ||
2314 | ndlp = (struct lpfc_nodelist *) pmb->context2; | |
2315 | mp = (struct lpfc_dmabuf *) (pmb->context1); | |
2316 | ||
2317 | pmb->context1 = NULL; | |
2318 | ||
dea3101e | 2319 | ndlp->nlp_rpi = mb->un.varWords[0]; |
dea3101e | 2320 | ndlp->nlp_type |= NLP_FABRIC; |
2321 | ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; | |
2322 | lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); | |
2323 | ||
2324 | /* Start issuing Fabric-Device Management Interface (FDMI) | |
2325 | * command to 0xfffffa (FDMI well known port) | |
2326 | */ | |
2327 | if (phba->cfg_fdmi_on == 1) { | |
2328 | lpfc_fdmi_cmd(phba, ndlp, SLI_MGMT_DHBA); | |
2329 | } else { | |
2330 | /* | |
2331 | * Delay issuing FDMI command if fdmi-on=2 | |
2332 | * (supporting RPA/hostnmae) | |
2333 | */ | |
2334 | mod_timer(&phba->fc_fdmitmo, jiffies + HZ * 60); | |
2335 | } | |
2336 | ||
2337 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | |
2338 | kfree(mp); | |
2339 | mempool_free( pmb, phba->mbox_mem_pool); | |
2340 | ||
2341 | return; | |
2342 | } | |
2343 | ||
2344 | /* | |
21568f53 JSEC |
2345 | * This routine looks up the ndlp lists |
2346 | * for the given RPI. If rpi found | |
dea3101e | 2347 | * it return the node list pointer |
21568f53 | 2348 | * else return NULL. |
dea3101e | 2349 | */ |
2350 | struct lpfc_nodelist * | |
2351 | lpfc_findnode_rpi(struct lpfc_hba * phba, uint16_t rpi) | |
2352 | { | |
21568f53 JSEC |
2353 | struct lpfc_nodelist *ndlp; |
2354 | struct list_head * lists[]={&phba->fc_nlpunmap_list, | |
2355 | &phba->fc_nlpmap_list, | |
2356 | &phba->fc_plogi_list, | |
2357 | &phba->fc_adisc_list, | |
2358 | &phba->fc_reglogin_list}; | |
2359 | int i; | |
dea3101e | 2360 | |
66a9ed66 | 2361 | spin_lock_irq(phba->host->host_lock); |
21568f53 JSEC |
2362 | for (i = 0; i < ARRAY_SIZE(lists); i++ ) |
2363 | list_for_each_entry(ndlp, lists[i], nlp_listp) | |
66a9ed66 JW |
2364 | if (ndlp->nlp_rpi == rpi) { |
2365 | spin_unlock_irq(phba->host->host_lock); | |
2fe165b6 | 2366 | return ndlp; |
66a9ed66 JW |
2367 | } |
2368 | spin_unlock_irq(phba->host->host_lock); | |
21568f53 | 2369 | return NULL; |
dea3101e | 2370 | } |
2371 | ||
488d1469 JS |
2372 | /* |
2373 | * This routine looks up the ndlp lists | |
2374 | * for the given WWPN. If WWPN found | |
2375 | * it return the node list pointer | |
2376 | * else return NULL. | |
2377 | */ | |
2378 | struct lpfc_nodelist * | |
2379 | lpfc_findnode_wwpn(struct lpfc_hba * phba, uint32_t order, | |
2380 | struct lpfc_name * wwpn) | |
2381 | { | |
2382 | struct lpfc_nodelist *ndlp; | |
2383 | struct list_head * lists[]={&phba->fc_nlpunmap_list, | |
2384 | &phba->fc_nlpmap_list, | |
2385 | &phba->fc_npr_list, | |
2386 | &phba->fc_plogi_list, | |
2387 | &phba->fc_adisc_list, | |
2388 | &phba->fc_reglogin_list, | |
2389 | &phba->fc_prli_list}; | |
2390 | uint32_t search[]={NLP_SEARCH_UNMAPPED, | |
2391 | NLP_SEARCH_MAPPED, | |
2392 | NLP_SEARCH_NPR, | |
2393 | NLP_SEARCH_PLOGI, | |
2394 | NLP_SEARCH_ADISC, | |
2395 | NLP_SEARCH_REGLOGIN, | |
2396 | NLP_SEARCH_PRLI}; | |
2397 | int i; | |
2398 | ||
2399 | spin_lock_irq(phba->host->host_lock); | |
2400 | for (i = 0; i < ARRAY_SIZE(lists); i++ ) { | |
2401 | if (!(order & search[i])) | |
2402 | continue; | |
2403 | list_for_each_entry(ndlp, lists[i], nlp_listp) { | |
2404 | if (memcmp(&ndlp->nlp_portname, wwpn, | |
2405 | sizeof(struct lpfc_name)) == 0) { | |
2406 | spin_unlock_irq(phba->host->host_lock); | |
2407 | return ndlp; | |
2408 | } | |
2409 | } | |
2410 | } | |
2411 | spin_unlock_irq(phba->host->host_lock); | |
2412 | return NULL; | |
2413 | } | |
2414 | ||
dea3101e | 2415 | void |
2416 | lpfc_nlp_init(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, | |
2417 | uint32_t did) | |
2418 | { | |
2419 | memset(ndlp, 0, sizeof (struct lpfc_nodelist)); | |
dea3101e | 2420 | INIT_LIST_HEAD(&ndlp->els_retry_evt.evt_listp); |
dea3101e | 2421 | init_timer(&ndlp->nlp_delayfunc); |
2422 | ndlp->nlp_delayfunc.function = lpfc_els_retry_delay; | |
2423 | ndlp->nlp_delayfunc.data = (unsigned long)ndlp; | |
2424 | ndlp->nlp_DID = did; | |
2425 | ndlp->nlp_phba = phba; | |
2426 | ndlp->nlp_sid = NLP_NO_SID; | |
2427 | return; | |
2428 | } |