Commit | Line | Data |
---|---|---|
128bddac | 1 | /******************************************************************* |
dea3101e | 2 | * This file is part of the Emulex Linux Device Driver for * |
c44ce173 | 3 | * Fibre Channel Host Bus Adapters. * |
ea4044e4 | 4 | * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * |
4ae2ebde | 5 | * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * |
50611577 | 6 | * Copyright (C) 2004-2016 Emulex. All rights reserved. * |
c44ce173 | 7 | * EMULEX and SLI are trademarks of Emulex. * |
d080abe0 | 8 | * www.broadcom.com * |
c44ce173 | 9 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
dea3101e | 10 | * * |
11 | * This program is free software; you can redistribute it and/or * | |
c44ce173 JSEC |
12 | * modify it under the terms of version 2 of the GNU General * |
13 | * Public License as published by the Free Software Foundation. * | |
14 | * This program is distributed in the hope that it will be useful. * | |
15 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * | |
16 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * | |
18 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * | |
19 | * TO BE LEGALLY INVALID. See the GNU General Public License for * | |
20 | * more details, a copy of which can be found in the file COPYING * | |
21 | * included with this package. * | |
dea3101e | 22 | *******************************************************************/ |
23 | ||
dea3101e | 24 | #include <linux/blkdev.h> |
25 | #include <linux/pci.h> | |
5a0e3ad6 | 26 | #include <linux/slab.h> |
dea3101e | 27 | #include <linux/interrupt.h> |
28 | ||
91886523 | 29 | #include <scsi/scsi.h> |
dea3101e | 30 | #include <scsi/scsi_device.h> |
31 | #include <scsi/scsi_host.h> | |
32 | #include <scsi/scsi_transport_fc.h> | |
a0f2d3ef JS |
33 | #include <scsi/fc/fc_fs.h> |
34 | ||
da0436e9 | 35 | #include "lpfc_hw4.h" |
dea3101e | 36 | #include "lpfc_hw.h" |
37 | #include "lpfc_sli.h" | |
da0436e9 | 38 | #include "lpfc_sli4.h" |
ea2151b4 | 39 | #include "lpfc_nl.h" |
dea3101e | 40 | #include "lpfc_disc.h" |
dea3101e | 41 | #include "lpfc.h" |
a0f2d3ef JS |
42 | #include "lpfc_scsi.h" |
43 | #include "lpfc_nvme.h" | |
dea3101e | 44 | #include "lpfc_logmsg.h" |
45 | #include "lpfc_crtn.h" | |
92d7f7b0 | 46 | #include "lpfc_vport.h" |
858c9f6c | 47 | #include "lpfc_debugfs.h" |
dea3101e | 48 | |
49 | ||
bf81e9cd JT |
50 | /* Called to clear RSCN discovery flags when driver is unloading. */ |
51 | static bool | |
52 | lpfc_check_unload_and_clr_rscn(unsigned long *fc_flag) | |
53 | { | |
54 | /* If unloading, then clear the FC_RSCN_DEFERRED flag */ | |
55 | if (test_bit(FC_UNLOADING, fc_flag)) { | |
56 | clear_bit(FC_RSCN_DEFERRED, fc_flag); | |
57 | return false; | |
58 | } | |
59 | return test_bit(FC_RSCN_DEFERRED, fc_flag); | |
60 | } | |
61 | ||
dea3101e | 62 | /* Called to verify a rcv'ed ADISC was intended for us. */ |
63 | static int | |
2e0fef85 JS |
64 | lpfc_check_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
65 | struct lpfc_name *nn, struct lpfc_name *pn) | |
dea3101e | 66 | { |
6b5151fd | 67 | |
dea3101e | 68 | /* Compare the ADISC rsp WWNN / WWPN matches our internal node |
69 | * table entry for that node. | |
70 | */ | |
2e0fef85 | 71 | if (memcmp(nn, &ndlp->nlp_nodename, sizeof (struct lpfc_name))) |
c9f8735b | 72 | return 0; |
dea3101e | 73 | |
2e0fef85 | 74 | if (memcmp(pn, &ndlp->nlp_portname, sizeof (struct lpfc_name))) |
c9f8735b | 75 | return 0; |
dea3101e | 76 | |
77 | /* we match, return success */ | |
c9f8735b | 78 | return 1; |
dea3101e | 79 | } |
80 | ||
dea3101e | 81 | int |
2e0fef85 | 82 | lpfc_check_sparm(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
341af102 | 83 | struct serv_parm *sp, uint32_t class, int flogi) |
dea3101e | 84 | { |
2e0fef85 | 85 | volatile struct serv_parm *hsp = &vport->fc_sparam; |
2fb70f79 JSEC |
86 | uint16_t hsp_value, ssp_value = 0; |
87 | ||
88 | /* | |
89 | * The receive data field size and buffer-to-buffer receive data field | |
90 | * size entries are 16 bits but are represented as two 8-bit fields in | |
91 | * the driver data structure to account for rsvd bits and other control | |
92 | * bits. Reconstruct and compare the fields as a 16-bit values before | |
93 | * correcting the byte values. | |
94 | */ | |
dea3101e | 95 | if (sp->cls1.classValid) { |
341af102 JS |
96 | if (!flogi) { |
97 | hsp_value = ((hsp->cls1.rcvDataSizeMsb << 8) | | |
98 | hsp->cls1.rcvDataSizeLsb); | |
99 | ssp_value = ((sp->cls1.rcvDataSizeMsb << 8) | | |
100 | sp->cls1.rcvDataSizeLsb); | |
101 | if (!ssp_value) | |
102 | goto bad_service_param; | |
103 | if (ssp_value > hsp_value) { | |
104 | sp->cls1.rcvDataSizeLsb = | |
105 | hsp->cls1.rcvDataSizeLsb; | |
106 | sp->cls1.rcvDataSizeMsb = | |
107 | hsp->cls1.rcvDataSizeMsb; | |
108 | } | |
2fb70f79 | 109 | } |
341af102 | 110 | } else if (class == CLASS1) |
92d7f7b0 | 111 | goto bad_service_param; |
dea3101e | 112 | if (sp->cls2.classValid) { |
341af102 JS |
113 | if (!flogi) { |
114 | hsp_value = ((hsp->cls2.rcvDataSizeMsb << 8) | | |
115 | hsp->cls2.rcvDataSizeLsb); | |
116 | ssp_value = ((sp->cls2.rcvDataSizeMsb << 8) | | |
117 | sp->cls2.rcvDataSizeLsb); | |
118 | if (!ssp_value) | |
119 | goto bad_service_param; | |
120 | if (ssp_value > hsp_value) { | |
121 | sp->cls2.rcvDataSizeLsb = | |
122 | hsp->cls2.rcvDataSizeLsb; | |
123 | sp->cls2.rcvDataSizeMsb = | |
124 | hsp->cls2.rcvDataSizeMsb; | |
125 | } | |
2fb70f79 | 126 | } |
341af102 | 127 | } else if (class == CLASS2) |
92d7f7b0 | 128 | goto bad_service_param; |
dea3101e | 129 | if (sp->cls3.classValid) { |
341af102 JS |
130 | if (!flogi) { |
131 | hsp_value = ((hsp->cls3.rcvDataSizeMsb << 8) | | |
132 | hsp->cls3.rcvDataSizeLsb); | |
133 | ssp_value = ((sp->cls3.rcvDataSizeMsb << 8) | | |
134 | sp->cls3.rcvDataSizeLsb); | |
135 | if (!ssp_value) | |
136 | goto bad_service_param; | |
137 | if (ssp_value > hsp_value) { | |
138 | sp->cls3.rcvDataSizeLsb = | |
139 | hsp->cls3.rcvDataSizeLsb; | |
140 | sp->cls3.rcvDataSizeMsb = | |
141 | hsp->cls3.rcvDataSizeMsb; | |
142 | } | |
2fb70f79 | 143 | } |
341af102 | 144 | } else if (class == CLASS3) |
92d7f7b0 | 145 | goto bad_service_param; |
dea3101e | 146 | |
2fb70f79 JSEC |
147 | /* |
148 | * Preserve the upper four bits of the MSB from the PLOGI response. | |
149 | * These bits contain the Buffer-to-Buffer State Change Number | |
150 | * from the target and need to be passed to the FW. | |
151 | */ | |
152 | hsp_value = (hsp->cmn.bbRcvSizeMsb << 8) | hsp->cmn.bbRcvSizeLsb; | |
153 | ssp_value = (sp->cmn.bbRcvSizeMsb << 8) | sp->cmn.bbRcvSizeLsb; | |
154 | if (ssp_value > hsp_value) { | |
dea3101e | 155 | sp->cmn.bbRcvSizeLsb = hsp->cmn.bbRcvSizeLsb; |
2fb70f79 JSEC |
156 | sp->cmn.bbRcvSizeMsb = (sp->cmn.bbRcvSizeMsb & 0xF0) | |
157 | (hsp->cmn.bbRcvSizeMsb & 0x0F); | |
158 | } | |
dea3101e | 159 | |
dea3101e | 160 | memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof (struct lpfc_name)); |
161 | memcpy(&ndlp->nlp_portname, &sp->portName, sizeof (struct lpfc_name)); | |
2fb70f79 | 162 | return 1; |
92d7f7b0 | 163 | bad_service_param: |
372c187b | 164 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
e8b62011 JS |
165 | "0207 Device %x " |
166 | "(%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x) sent " | |
167 | "invalid service parameters. Ignoring device.\n", | |
168 | ndlp->nlp_DID, | |
169 | sp->nodeName.u.wwn[0], sp->nodeName.u.wwn[1], | |
170 | sp->nodeName.u.wwn[2], sp->nodeName.u.wwn[3], | |
171 | sp->nodeName.u.wwn[4], sp->nodeName.u.wwn[5], | |
172 | sp->nodeName.u.wwn[6], sp->nodeName.u.wwn[7]); | |
92d7f7b0 | 173 | return 0; |
dea3101e | 174 | } |
175 | ||
176 | static void * | |
2e0fef85 | 177 | lpfc_check_elscmpl_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
92d7f7b0 | 178 | struct lpfc_iocbq *rspiocb) |
dea3101e | 179 | { |
180 | struct lpfc_dmabuf *pcmd, *prsp; | |
181 | uint32_t *lp; | |
182 | void *ptr = NULL; | |
2d1928c5 | 183 | u32 ulp_status = get_job_ulpstatus(phba, rspiocb); |
dea3101e | 184 | |
d51cf5bd | 185 | pcmd = cmdiocb->cmd_dmabuf; |
dea3101e | 186 | |
d51cf5bd | 187 | /* For lpfc_els_abort, cmd_dmabuf could be zero'ed to delay |
dea3101e | 188 | * freeing associated memory till after ABTS completes. |
189 | */ | |
190 | if (pcmd) { | |
191 | prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, | |
192 | list); | |
193 | if (prsp) { | |
194 | lp = (uint32_t *) prsp->virt; | |
195 | ptr = (void *)((uint8_t *)lp + sizeof(uint32_t)); | |
196 | } | |
2fe165b6 | 197 | } else { |
2d1928c5 JS |
198 | /* Force ulp_status error since we are returning NULL ptr */ |
199 | if (!(ulp_status)) { | |
200 | if (phba->sli_rev == LPFC_SLI_REV4) { | |
201 | bf_set(lpfc_wcqe_c_status, &rspiocb->wcqe_cmpl, | |
202 | IOSTAT_LOCAL_REJECT); | |
203 | rspiocb->wcqe_cmpl.parameter = IOERR_SLI_ABORTED; | |
204 | } else { | |
205 | rspiocb->iocb.ulpStatus = IOSTAT_LOCAL_REJECT; | |
206 | rspiocb->iocb.un.ulpWord[4] = IOERR_SLI_ABORTED; | |
207 | } | |
dea3101e | 208 | } |
209 | ptr = NULL; | |
210 | } | |
c9f8735b | 211 | return ptr; |
dea3101e | 212 | } |
213 | ||
214 | ||
2a9bf3d0 | 215 | |
dea3101e | 216 | /* |
217 | * Free resources / clean up outstanding I/Os | |
218 | * associated with a LPFC_NODELIST entry. This | |
219 | * routine effectively results in a "software abort". | |
220 | */ | |
7c9fdfb7 | 221 | void |
2e0fef85 | 222 | lpfc_els_abort(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) |
dea3101e | 223 | { |
2a9bf3d0 | 224 | LIST_HEAD(abort_list); |
bf81e9cd | 225 | LIST_HEAD(drv_cmpl_list); |
895427bd | 226 | struct lpfc_sli_ring *pring; |
dea3101e | 227 | struct lpfc_iocbq *iocb, *next_iocb; |
bf81e9cd | 228 | int retval = 0; |
dea3101e | 229 | |
895427bd JS |
230 | pring = lpfc_phba_elsring(phba); |
231 | ||
7c9fdfb7 | 232 | /* In case of error recovery path, we might have a NULL pring here */ |
1234a6d5 | 233 | if (unlikely(!pring)) |
7c9fdfb7 GP |
234 | return; |
235 | ||
dea3101e | 236 | /* Abort outstanding I/O on NPort <nlp_DID> */ |
e8b62011 | 237 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_DISCOVERY, |
2a9bf3d0 | 238 | "2819 Abort outstanding I/O on NPort x%x " |
92b99f1a | 239 | "Data: x%lx x%x x%x\n", |
e8b62011 JS |
240 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
241 | ndlp->nlp_rpi); | |
0976e1a6 | 242 | /* Clean up all fabric IOs first.*/ |
92d7f7b0 | 243 | lpfc_fabric_abort_nport(ndlp); |
dea3101e | 244 | |
0976e1a6 JS |
245 | /* |
246 | * Lock the ELS ring txcmplq for SLI3/SLI4 and build a local list | |
247 | * of all ELS IOs that need an ABTS. The IOs need to stay on the | |
248 | * txcmplq so that the abort operation completes them successfully. | |
249 | */ | |
2e0fef85 | 250 | spin_lock_irq(&phba->hbalock); |
0976e1a6 JS |
251 | if (phba->sli_rev == LPFC_SLI_REV4) |
252 | spin_lock(&pring->ring_lock); | |
253 | list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) { | |
254 | /* Add to abort_list on on NDLP match. */ | |
2a9bf3d0 JS |
255 | if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp)) |
256 | list_add_tail(&iocb->dlist, &abort_list); | |
07951076 | 257 | } |
0976e1a6 JS |
258 | if (phba->sli_rev == LPFC_SLI_REV4) |
259 | spin_unlock(&pring->ring_lock); | |
2e0fef85 | 260 | spin_unlock_irq(&phba->hbalock); |
dea3101e | 261 | |
0976e1a6 | 262 | /* Abort the targeted IOs and remove them from the abort list. */ |
2a9bf3d0 | 263 | list_for_each_entry_safe(iocb, next_iocb, &abort_list, dlist) { |
bf81e9cd JT |
264 | spin_lock_irq(&phba->hbalock); |
265 | list_del_init(&iocb->dlist); | |
266 | retval = lpfc_sli_issue_abort_iotag(phba, pring, iocb, NULL); | |
267 | spin_unlock_irq(&phba->hbalock); | |
268 | ||
269 | if (retval && test_bit(FC_UNLOADING, &phba->pport->load_flag)) { | |
270 | list_del_init(&iocb->list); | |
271 | list_add_tail(&iocb->list, &drv_cmpl_list); | |
272 | } | |
2a9bf3d0 | 273 | } |
bf81e9cd JT |
274 | |
275 | lpfc_sli_cancel_iocbs(phba, &drv_cmpl_list, IOSTAT_LOCAL_REJECT, | |
276 | IOERR_SLI_ABORTED); | |
277 | ||
a22d73b6 JS |
278 | /* Make sure HBA is alive */ |
279 | lpfc_issue_hb_tmo(phba); | |
2a9bf3d0 | 280 | |
0976e1a6 JS |
281 | INIT_LIST_HEAD(&abort_list); |
282 | ||
283 | /* Now process the txq */ | |
284 | spin_lock_irq(&phba->hbalock); | |
285 | if (phba->sli_rev == LPFC_SLI_REV4) | |
286 | spin_lock(&pring->ring_lock); | |
287 | ||
288 | list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) { | |
289 | /* Check to see if iocb matches the nport we are looking for */ | |
290 | if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp)) { | |
291 | list_del_init(&iocb->list); | |
292 | list_add_tail(&iocb->list, &abort_list); | |
293 | } | |
294 | } | |
295 | ||
296 | if (phba->sli_rev == LPFC_SLI_REV4) | |
297 | spin_unlock(&pring->ring_lock); | |
298 | spin_unlock_irq(&phba->hbalock); | |
299 | ||
a257bf90 | 300 | /* Cancel all the IOCBs from the completions list */ |
0976e1a6 JS |
301 | lpfc_sli_cancel_iocbs(phba, &abort_list, |
302 | IOSTAT_LOCAL_REJECT, IOERR_SLI_ABORTED); | |
2534ba75 | 303 | |
0d2b6b83 | 304 | lpfc_cancel_retry_delay_tmo(phba->pport, ndlp); |
dea3101e | 305 | } |
306 | ||
14375305 | 307 | /* lpfc_defer_plogi_acc - Issue PLOGI ACC after reg_login completes |
359e10f0 | 308 | * @phba: pointer to lpfc hba data structure. |
14375305 | 309 | * @login_mbox: pointer to REG_RPI mailbox object |
359e10f0 | 310 | * |
14375305 | 311 | * The ACC for a rcv'ed PLOGI is deferred until AFTER the REG_RPI completes |
359e10f0 | 312 | */ |
f7cb0d09 | 313 | static void |
14375305 | 314 | lpfc_defer_plogi_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *login_mbox) |
359e10f0 | 315 | { |
359e10f0 JS |
316 | struct lpfc_iocbq *save_iocb; |
317 | struct lpfc_nodelist *ndlp; | |
14375305 JS |
318 | MAILBOX_t *mb = &login_mbox->u.mb; |
319 | ||
359e10f0 JS |
320 | int rc; |
321 | ||
14375305 | 322 | ndlp = login_mbox->ctx_ndlp; |
85d77f91 | 323 | save_iocb = login_mbox->ctx_u.save_iocb; |
359e10f0 | 324 | |
14375305 JS |
325 | if (mb->mbxStatus == MBX_SUCCESS) { |
326 | /* Now that REG_RPI completed successfully, | |
327 | * we can now proceed with sending the PLOGI ACC. | |
328 | */ | |
329 | rc = lpfc_els_rsp_acc(login_mbox->vport, ELS_CMD_PLOGI, | |
330 | save_iocb, ndlp, NULL); | |
331 | if (rc) { | |
332 | lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, | |
333 | "4576 PLOGI ACC fails pt2pt discovery: " | |
334 | "DID %x Data: %x\n", ndlp->nlp_DID, rc); | |
335 | } | |
359e10f0 JS |
336 | } |
337 | ||
14375305 JS |
338 | /* Now process the REG_RPI cmpl */ |
339 | lpfc_mbx_cmpl_reg_login(phba, login_mbox); | |
92b99f1a | 340 | clear_bit(NLP_ACC_REGLOGIN, &ndlp->nlp_flag); |
be0709e4 JS |
341 | kfree(save_iocb); |
342 | } | |
343 | ||
dea3101e | 344 | static int |
2e0fef85 | 345 | lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
92d7f7b0 | 346 | struct lpfc_iocbq *cmdiocb) |
dea3101e | 347 | { |
2e0fef85 | 348 | struct lpfc_hba *phba = vport->phba; |
dea3101e | 349 | struct lpfc_dmabuf *pcmd; |
ed4afe74 | 350 | uint64_t nlp_portwwn = 0; |
dea3101e | 351 | uint32_t *lp; |
2d1928c5 | 352 | union lpfc_wqe128 *wqe; |
dea3101e | 353 | IOCB_t *icmd; |
354 | struct serv_parm *sp; | |
d6de08cc | 355 | uint32_t ed_tov; |
359e10f0 JS |
356 | LPFC_MBOXQ_t *link_mbox; |
357 | LPFC_MBOXQ_t *login_mbox; | |
358 | struct lpfc_iocbq *save_iocb; | |
dea3101e | 359 | struct ls_rjt stat; |
8c258641 | 360 | uint32_t vid, flag; |
14375305 | 361 | int rc; |
2d1928c5 | 362 | u32 remote_did; |
dea3101e | 363 | |
364 | memset(&stat, 0, sizeof (struct ls_rjt)); | |
d51cf5bd | 365 | pcmd = cmdiocb->cmd_dmabuf; |
dea3101e | 366 | lp = (uint32_t *) pcmd->virt; |
367 | sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t)); | |
a8adb832 | 368 | if (wwn_to_u64(sp->portName.u.wwn) == 0) { |
372c187b | 369 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
3bfab8a0 | 370 | "0140 PLOGI Reject: invalid pname\n"); |
a8adb832 JS |
371 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
372 | stat.un.b.lsRjtRsnCodeExp = LSEXP_INVALID_PNAME; | |
373 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, | |
374 | NULL); | |
375 | return 0; | |
376 | } | |
377 | if (wwn_to_u64(sp->nodeName.u.wwn) == 0) { | |
372c187b | 378 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
3bfab8a0 | 379 | "0141 PLOGI Reject: invalid nname\n"); |
a8adb832 JS |
380 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
381 | stat.un.b.lsRjtRsnCodeExp = LSEXP_INVALID_NNAME; | |
382 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, | |
383 | NULL); | |
384 | return 0; | |
385 | } | |
ed4afe74 JS |
386 | |
387 | nlp_portwwn = wwn_to_u64(ndlp->nlp_portname.u.wwn); | |
341af102 | 388 | if ((lpfc_check_sparm(vport, ndlp, sp, CLASS3, 0) == 0)) { |
dea3101e | 389 | /* Reject this request because invalid parameters */ |
390 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; | |
391 | stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; | |
858c9f6c JS |
392 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
393 | NULL); | |
c9f8735b | 394 | return 0; |
dea3101e | 395 | } |
2d1928c5 JS |
396 | |
397 | if (phba->sli_rev == LPFC_SLI_REV4) | |
398 | wqe = &cmdiocb->wqe; | |
399 | else | |
400 | icmd = &cmdiocb->iocb; | |
dea3101e | 401 | |
402 | /* PLOGI chkparm OK */ | |
e8b62011 | 403 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
92b99f1a | 404 | "0114 PLOGI chkparm OK Data: x%x x%x x%lx " |
a645b8c1 | 405 | "x%x x%x x%lx\n", |
e8b62011 | 406 | ndlp->nlp_DID, ndlp->nlp_state, ndlp->nlp_flag, |
e74c03c8 JS |
407 | ndlp->nlp_rpi, vport->port_state, |
408 | vport->fc_flag); | |
dea3101e | 409 | |
3de2a653 | 410 | if (vport->cfg_fcp_class == 2 && sp->cls2.classValid) |
dea3101e | 411 | ndlp->nlp_fcp_info |= CLASS2; |
ed957684 | 412 | else |
dea3101e | 413 | ndlp->nlp_fcp_info |= CLASS3; |
2e0fef85 | 414 | |
dea3101e | 415 | ndlp->nlp_class_sup = 0; |
416 | if (sp->cls1.classValid) | |
417 | ndlp->nlp_class_sup |= FC_COS_CLASS1; | |
418 | if (sp->cls2.classValid) | |
419 | ndlp->nlp_class_sup |= FC_COS_CLASS2; | |
420 | if (sp->cls3.classValid) | |
421 | ndlp->nlp_class_sup |= FC_COS_CLASS3; | |
422 | if (sp->cls4.classValid) | |
423 | ndlp->nlp_class_sup |= FC_COS_CLASS4; | |
424 | ndlp->nlp_maxframe = | |
425 | ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb; | |
ed4afe74 | 426 | /* if already logged in, do implicit logout */ |
2fe165b6 | 427 | switch (ndlp->nlp_state) { |
dea3101e | 428 | case NLP_STE_NPR_NODE: |
92b99f1a | 429 | if (!test_bit(NLP_NPR_ADISC, &ndlp->nlp_flag)) |
dea3101e | 430 | break; |
df561f66 | 431 | fallthrough; |
dea3101e | 432 | case NLP_STE_REG_LOGIN_ISSUE: |
433 | case NLP_STE_PRLI_ISSUE: | |
434 | case NLP_STE_UNMAPPED_NODE: | |
435 | case NLP_STE_MAPPED_NODE: | |
1c5b12f7 JS |
436 | /* For initiators, lpfc_plogi_confirm_nport skips fabric did. |
437 | * For target mode, execute implicit logo. | |
438 | * Fabric nodes go into NPR. | |
439 | */ | |
440 | if (!(ndlp->nlp_type & NLP_FABRIC) && | |
441 | !(phba->nvmet_support)) { | |
ecf041fe JS |
442 | /* Clear ndlp info, since follow up PRLI may have |
443 | * updated ndlp information | |
444 | */ | |
445 | ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR); | |
446 | ndlp->nlp_type &= ~(NLP_NVME_TARGET | NLP_NVME_INITIATOR); | |
447 | ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE; | |
448 | ndlp->nlp_nvme_info &= ~NLP_NVME_NSLER; | |
92b99f1a | 449 | clear_bit(NLP_FIRSTBURST, &ndlp->nlp_flag); |
ecf041fe | 450 | |
ed4afe74 JS |
451 | lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, |
452 | ndlp, NULL); | |
453 | return 1; | |
454 | } | |
455 | if (nlp_portwwn != 0 && | |
456 | nlp_portwwn != wwn_to_u64(sp->portName.u.wwn)) | |
b76beac1 | 457 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
ed4afe74 JS |
458 | "0143 PLOGI recv'd from DID: x%x " |
459 | "WWPN changed: old %llx new %llx\n", | |
460 | ndlp->nlp_DID, | |
461 | (unsigned long long)nlp_portwwn, | |
462 | (unsigned long long) | |
463 | wwn_to_u64(sp->portName.u.wwn)); | |
464 | ||
4c2805aa JS |
465 | /* Notify transport of connectivity loss to trigger cleanup. */ |
466 | if (phba->nvmet_support && | |
467 | ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) | |
468 | lpfc_nvmet_invalidate_host(phba, ndlp); | |
469 | ||
ed4afe74 JS |
470 | ndlp->nlp_prev_state = ndlp->nlp_state; |
471 | /* rport needs to be unregistered first */ | |
472 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); | |
473 | break; | |
dea3101e | 474 | } |
475 | ||
9de416ac JS |
476 | ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR); |
477 | ndlp->nlp_type &= ~(NLP_NVME_TARGET | NLP_NVME_INITIATOR); | |
478 | ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE; | |
ecf041fe | 479 | ndlp->nlp_nvme_info &= ~NLP_NVME_NSLER; |
92b99f1a | 480 | clear_bit(NLP_FIRSTBURST, &ndlp->nlp_flag); |
9de416ac | 481 | |
359e10f0 JS |
482 | login_mbox = NULL; |
483 | link_mbox = NULL; | |
484 | save_iocb = NULL; | |
485 | ||
939723a4 | 486 | /* Check for Nport to NPort pt2pt protocol */ |
a645b8c1 JT |
487 | if (test_bit(FC_PT2PT, &vport->fc_flag) && |
488 | !test_bit(FC_PT2PT_PLOGI, &vport->fc_flag)) { | |
dea3101e | 489 | /* rcv'ed PLOGI decides what our NPortId will be */ |
2d1928c5 JS |
490 | if (phba->sli_rev == LPFC_SLI_REV4) { |
491 | vport->fc_myDID = bf_get(els_rsp64_sid, | |
492 | &cmdiocb->wqe.xmit_els_rsp); | |
493 | } else { | |
494 | vport->fc_myDID = icmd->un.rcvels.parmRo; | |
495 | } | |
d6de08cc | 496 | |
9dd83f75 JS |
497 | /* If there is an outstanding FLOGI, abort it now. |
498 | * The remote NPort is not going to ACC our FLOGI | |
499 | * if its already issuing a PLOGI for pt2pt mode. | |
500 | * This indicates our FLOGI was dropped; however, we | |
501 | * must have ACCed the remote NPorts FLOGI to us | |
502 | * to make it here. | |
503 | */ | |
e780c942 | 504 | if (test_bit(HBA_FLOGI_OUTSTANDING, &phba->hba_flag)) |
9dd83f75 JS |
505 | lpfc_els_abort_flogi(phba); |
506 | ||
d6de08cc JS |
507 | ed_tov = be32_to_cpu(sp->cmn.e_d_tov); |
508 | if (sp->cmn.edtovResolution) { | |
509 | /* E_D_TOV ticks are in nanoseconds */ | |
510 | ed_tov = (phba->fc_edtov + 999999) / 1000000; | |
dea3101e | 511 | } |
d6de08cc | 512 | |
939723a4 | 513 | /* |
d6de08cc JS |
514 | * For pt-to-pt, use the larger EDTOV |
515 | * RATOV = 2 * EDTOV | |
939723a4 | 516 | */ |
d6de08cc JS |
517 | if (ed_tov > phba->fc_edtov) |
518 | phba->fc_edtov = ed_tov; | |
519 | phba->fc_ratov = (2 * phba->fc_edtov) / 1000; | |
520 | ||
521 | memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm)); | |
522 | ||
14375305 JS |
523 | /* Issue CONFIG_LINK for SLI3 or REG_VFI for SLI4, |
524 | * to account for updated TOV's / parameters | |
525 | */ | |
939723a4 JS |
526 | if (phba->sli_rev == LPFC_SLI_REV4) |
527 | lpfc_issue_reg_vfi(vport); | |
d6de08cc | 528 | else { |
359e10f0 JS |
529 | link_mbox = mempool_alloc(phba->mbox_mem_pool, |
530 | GFP_KERNEL); | |
531 | if (!link_mbox) | |
d6de08cc | 532 | goto out; |
359e10f0 | 533 | lpfc_config_link(phba, link_mbox); |
14375305 | 534 | link_mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
359e10f0 | 535 | link_mbox->vport = vport; |
ba3d58a1 JS |
536 | |
537 | /* The default completion handling for CONFIG_LINK | |
538 | * does not require the ndlp so no reference is needed. | |
539 | */ | |
359e10f0 JS |
540 | link_mbox->ctx_ndlp = ndlp; |
541 | ||
14375305 JS |
542 | rc = lpfc_sli_issue_mbox(phba, link_mbox, MBX_NOWAIT); |
543 | if (rc == MBX_NOT_FINISHED) { | |
544 | mempool_free(link_mbox, phba->mbox_mem_pool); | |
d6de08cc | 545 | goto out; |
14375305 | 546 | } |
d6de08cc | 547 | } |
dea3101e | 548 | |
2e0fef85 | 549 | lpfc_can_disctmo(vport); |
dea3101e | 550 | } |
d6de08cc | 551 | |
92b99f1a | 552 | clear_bit(NLP_SUPPRESS_RSP, &ndlp->nlp_flag); |
8c258641 JS |
553 | if ((phba->sli.sli_flag & LPFC_SLI_SUPPRESS_RSP) && |
554 | sp->cmn.valid_vendor_ver_level) { | |
555 | vid = be32_to_cpu(sp->un.vv.vid); | |
556 | flag = be32_to_cpu(sp->un.vv.flags); | |
557 | if ((vid == LPFC_VV_EMLX_ID) && (flag & LPFC_VV_SUPPRESS_RSP)) | |
92b99f1a | 558 | set_bit(NLP_SUPPRESS_RSP, &ndlp->nlp_flag); |
8c258641 JS |
559 | } |
560 | ||
359e10f0 JS |
561 | login_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
562 | if (!login_mbox) | |
dea3101e | 563 | goto out; |
564 | ||
14375305 JS |
565 | save_iocb = kzalloc(sizeof(*save_iocb), GFP_KERNEL); |
566 | if (!save_iocb) | |
567 | goto out; | |
568 | ||
569 | /* Save info from cmd IOCB to be used in rsp after all mbox completes */ | |
570 | memcpy((uint8_t *)save_iocb, (uint8_t *)cmdiocb, | |
571 | sizeof(struct lpfc_iocbq)); | |
572 | ||
6b5151fd | 573 | /* Registering an existing RPI behaves differently for SLI3 vs SLI4 */ |
14375305 | 574 | if (phba->sli_rev == LPFC_SLI_REV4) |
6b5151fd JS |
575 | lpfc_unreg_rpi(vport, ndlp); |
576 | ||
14375305 JS |
577 | /* Issue REG_LOGIN first, before ACCing the PLOGI, thus we will |
578 | * always be deferring the ACC. | |
579 | */ | |
2d1928c5 JS |
580 | if (phba->sli_rev == LPFC_SLI_REV4) |
581 | remote_did = bf_get(wqe_els_did, &wqe->xmit_els_rsp.wqe_dest); | |
582 | else | |
583 | remote_did = icmd->un.rcvels.remoteID; | |
584 | rc = lpfc_reg_rpi(phba, vport->vpi, remote_did, | |
359e10f0 JS |
585 | (uint8_t *)sp, login_mbox, ndlp->nlp_rpi); |
586 | if (rc) | |
dea3101e | 587 | goto out; |
dea3101e | 588 | |
359e10f0 | 589 | login_mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; |
359e10f0 | 590 | login_mbox->vport = vport; |
dea3101e | 591 | |
33ccf8d1 JS |
592 | /* |
593 | * If there is an outstanding PLOGI issued, abort it before | |
594 | * sending ACC rsp for received PLOGI. If pending plogi | |
595 | * is not canceled here, the plogi will be rejected by | |
596 | * remote port and will be retried. On a configuration with | |
597 | * single discovery thread, this will cause a huge delay in | |
598 | * discovery. Also this will cause multiple state machines | |
599 | * running in parallel for this node. | |
feff8b3d | 600 | * This only applies to a fabric environment. |
33ccf8d1 | 601 | */ |
feff8b3d | 602 | if ((ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) && |
a645b8c1 | 603 | test_bit(FC_FABRIC, &vport->fc_flag)) { |
33ccf8d1 | 604 | /* software abort outstanding PLOGI */ |
07951076 | 605 | lpfc_els_abort(phba, ndlp); |
33ccf8d1 JS |
606 | } |
607 | ||
858c9f6c | 608 | if ((vport->port_type == LPFC_NPIV_PORT && |
3de2a653 | 609 | vport->cfg_restrict_login)) { |
858c9f6c | 610 | |
be0709e4 JS |
611 | /* no deferred ACC */ |
612 | kfree(save_iocb); | |
613 | ||
01131e7a JS |
614 | /* This is an NPIV SLI4 instance that does not need to register |
615 | * a default RPI. | |
858c9f6c | 616 | */ |
01131e7a | 617 | if (phba->sli_rev == LPFC_SLI_REV4) { |
ef47575f JS |
618 | lpfc_mbox_rsrc_cleanup(phba, login_mbox, |
619 | MBOX_THD_UNLOCKED); | |
01131e7a JS |
620 | login_mbox = NULL; |
621 | } else { | |
622 | /* In order to preserve RPIs, we want to cleanup | |
623 | * the default RPI the firmware created to rcv | |
624 | * this ELS request. The only way to do this is | |
625 | * to register, then unregister the RPI. | |
626 | */ | |
92b99f1a JT |
627 | set_bit(NLP_RM_DFLT_RPI, &ndlp->nlp_flag); |
628 | set_bit(NLP_ACC_REGLOGIN, &ndlp->nlp_flag); | |
629 | set_bit(NLP_RCV_PLOGI, &ndlp->nlp_flag); | |
01131e7a JS |
630 | } |
631 | ||
858c9f6c JS |
632 | stat.un.b.lsRjtRsnCode = LSRJT_INVALID_CMD; |
633 | stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; | |
0a8a86fa | 634 | rc = lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, |
672d1cb4 | 635 | ndlp, login_mbox); |
ef47575f JS |
636 | if (rc && login_mbox) |
637 | lpfc_mbox_rsrc_cleanup(phba, login_mbox, | |
638 | MBOX_THD_UNLOCKED); | |
359e10f0 JS |
639 | return 1; |
640 | } | |
359e10f0 | 641 | |
14375305 JS |
642 | /* So the order here should be: |
643 | * SLI3 pt2pt | |
644 | * Issue CONFIG_LINK mbox | |
645 | * CONFIG_LINK cmpl | |
646 | * SLI4 pt2pt | |
647 | * Issue REG_VFI mbox | |
648 | * REG_VFI cmpl | |
649 | * SLI4 | |
650 | * Issue UNREG RPI mbx | |
651 | * UNREG RPI cmpl | |
652 | * Issue REG_RPI mbox | |
653 | * REG RPI cmpl | |
654 | * Issue PLOGI ACC | |
655 | * PLOGI ACC cmpl | |
656 | */ | |
657 | login_mbox->mbox_cmpl = lpfc_defer_plogi_acc; | |
658 | login_mbox->ctx_ndlp = lpfc_nlp_get(ndlp); | |
ba3d58a1 JS |
659 | if (!login_mbox->ctx_ndlp) |
660 | goto out; | |
661 | ||
85d77f91 | 662 | login_mbox->ctx_u.save_iocb = save_iocb; /* For PLOGI ACC */ |
359e10f0 | 663 | |
92b99f1a JT |
664 | set_bit(NLP_ACC_REGLOGIN, &ndlp->nlp_flag); |
665 | set_bit(NLP_RCV_PLOGI, &ndlp->nlp_flag); | |
14375305 JS |
666 | |
667 | /* Start the ball rolling by issuing REG_LOGIN here */ | |
668 | rc = lpfc_sli_issue_mbox(phba, login_mbox, MBX_NOWAIT); | |
ba3d58a1 JS |
669 | if (rc == MBX_NOT_FINISHED) { |
670 | lpfc_nlp_put(ndlp); | |
14375305 | 671 | goto out; |
ba3d58a1 | 672 | } |
14375305 | 673 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE); |
359e10f0 | 674 | |
c9f8735b | 675 | return 1; |
dea3101e | 676 | out: |
be0709e4 | 677 | kfree(save_iocb); |
359e10f0 JS |
678 | if (login_mbox) |
679 | mempool_free(login_mbox, phba->mbox_mem_pool); | |
680 | ||
dea3101e | 681 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
682 | stat.un.b.lsRjtRsnCodeExp = LSEXP_OUT_OF_RESOURCE; | |
858c9f6c | 683 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
c9f8735b | 684 | return 0; |
dea3101e | 685 | } |
686 | ||
6b5151fd JS |
687 | /** |
688 | * lpfc_mbx_cmpl_resume_rpi - Resume RPI completion routine | |
689 | * @phba: pointer to lpfc hba data structure. | |
690 | * @mboxq: pointer to mailbox object | |
691 | * | |
692 | * This routine is invoked to issue a completion to a rcv'ed | |
693 | * ADISC or PDISC after the paused RPI has been resumed. | |
694 | **/ | |
695 | static void | |
696 | lpfc_mbx_cmpl_resume_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |
697 | { | |
698 | struct lpfc_vport *vport; | |
699 | struct lpfc_iocbq *elsiocb; | |
700 | struct lpfc_nodelist *ndlp; | |
701 | uint32_t cmd; | |
702 | ||
85d77f91 | 703 | elsiocb = mboxq->ctx_u.save_iocb; |
18f7fe44 | 704 | ndlp = mboxq->ctx_ndlp; |
6b5151fd JS |
705 | vport = mboxq->vport; |
706 | cmd = elsiocb->drvrTimeout; | |
707 | ||
708 | if (cmd == ELS_CMD_ADISC) { | |
709 | lpfc_els_rsp_adisc_acc(vport, elsiocb, ndlp); | |
710 | } else { | |
711 | lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, elsiocb, | |
712 | ndlp, NULL); | |
713 | } | |
1037e4b4 JS |
714 | |
715 | /* This nlp_put pairs with lpfc_sli4_resume_rpi */ | |
716 | lpfc_nlp_put(ndlp); | |
717 | ||
6b5151fd | 718 | kfree(elsiocb); |
72859909 | 719 | mempool_free(mboxq, phba->mbox_mem_pool); |
6b5151fd JS |
720 | } |
721 | ||
dea3101e | 722 | static int |
2e0fef85 | 723 | lpfc_rcv_padisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
dea3101e | 724 | struct lpfc_iocbq *cmdiocb) |
725 | { | |
cad93a08 | 726 | struct lpfc_hba *phba = vport->phba; |
6b5151fd | 727 | struct lpfc_iocbq *elsiocb; |
dea3101e | 728 | struct lpfc_dmabuf *pcmd; |
2e0fef85 JS |
729 | struct serv_parm *sp; |
730 | struct lpfc_name *pnn, *ppn; | |
dea3101e | 731 | struct ls_rjt stat; |
732 | ADISC *ap; | |
dea3101e | 733 | uint32_t *lp; |
734 | uint32_t cmd; | |
ee80d8c2 | 735 | int rc; |
dea3101e | 736 | |
d51cf5bd | 737 | pcmd = cmdiocb->cmd_dmabuf; |
dea3101e | 738 | lp = (uint32_t *) pcmd->virt; |
739 | ||
740 | cmd = *lp++; | |
741 | if (cmd == ELS_CMD_ADISC) { | |
742 | ap = (ADISC *) lp; | |
743 | pnn = (struct lpfc_name *) & ap->nodeName; | |
744 | ppn = (struct lpfc_name *) & ap->portName; | |
745 | } else { | |
746 | sp = (struct serv_parm *) lp; | |
747 | pnn = (struct lpfc_name *) & sp->nodeName; | |
748 | ppn = (struct lpfc_name *) & sp->portName; | |
749 | } | |
750 | ||
cad93a08 JS |
751 | if (get_job_ulpstatus(phba, cmdiocb) == 0 && |
752 | lpfc_check_adisc(vport, ndlp, pnn, ppn)) { | |
6b5151fd JS |
753 | |
754 | /* | |
755 | * As soon as we send ACC, the remote NPort can | |
756 | * start sending us data. Thus, for SLI4 we must | |
757 | * resume the RPI before the ACC goes out. | |
758 | */ | |
759 | if (vport->phba->sli_rev == LPFC_SLI_REV4) { | |
ee80d8c2 JT |
760 | /* Don't resume an unregistered RPI - unnecessary |
761 | * mailbox. Just send the ACC when the RPI is not | |
762 | * registered. | |
763 | */ | |
764 | if (test_bit(NLP_RPI_REGISTERED, &ndlp->nlp_flag)) { | |
765 | elsiocb = kmalloc(sizeof(*elsiocb), GFP_KERNEL); | |
766 | if (elsiocb) { | |
767 | /* Save info from cmd IOCB used in | |
768 | * rsp | |
769 | */ | |
770 | memcpy(elsiocb, cmdiocb, | |
771 | sizeof(*elsiocb)); | |
772 | ||
773 | elsiocb->drvrTimeout = cmd; | |
774 | ||
775 | rc = lpfc_sli4_resume_rpi(ndlp, | |
776 | lpfc_mbx_cmpl_resume_rpi, | |
777 | elsiocb); | |
778 | if (rc) | |
779 | kfree(elsiocb); | |
780 | ||
781 | goto out; | |
782 | } | |
6b5151fd JS |
783 | } |
784 | } | |
785 | ||
dea3101e | 786 | if (cmd == ELS_CMD_ADISC) { |
2e0fef85 | 787 | lpfc_els_rsp_adisc_acc(vport, cmdiocb, ndlp); |
2fe165b6 | 788 | } else { |
6b5151fd JS |
789 | lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, |
790 | ndlp, NULL); | |
dea3101e | 791 | } |
6b5151fd | 792 | out: |
9806c984 DK |
793 | /* If we are authenticated, move to the proper state. |
794 | * It is possible an ADISC arrived and the remote nport | |
795 | * is already in MAPPED or UNMAPPED state. Catch this | |
796 | * condition and don't set the nlp_state again because | |
797 | * it causes an unnecessary transport unregister/register. | |
ab803860 JS |
798 | * |
799 | * Nodes marked for ADISC will move MAPPED or UNMAPPED state | |
800 | * after issuing ADISC | |
9806c984 DK |
801 | */ |
802 | if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET)) { | |
ab803860 | 803 | if ((ndlp->nlp_state != NLP_STE_MAPPED_NODE) && |
92b99f1a | 804 | !test_bit(NLP_NPR_ADISC, &ndlp->nlp_flag)) |
9806c984 DK |
805 | lpfc_nlp_set_state(vport, ndlp, |
806 | NLP_STE_MAPPED_NODE); | |
807 | } | |
6b5151fd | 808 | |
c9f8735b | 809 | return 1; |
dea3101e | 810 | } |
811 | /* Reject this request because invalid parameters */ | |
812 | stat.un.b.lsRjtRsvd0 = 0; | |
813 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; | |
814 | stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; | |
815 | stat.un.b.vendorUnique = 0; | |
858c9f6c | 816 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
dea3101e | 817 | |
dea3101e | 818 | /* 1 sec timeout */ |
256ec0d0 | 819 | mod_timer(&ndlp->nlp_delayfunc, jiffies + msecs_to_jiffies(1000)); |
dea3101e | 820 | |
92b99f1a | 821 | set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag); |
5024ab17 JW |
822 | ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; |
823 | ndlp->nlp_prev_state = ndlp->nlp_state; | |
c9f8735b | 824 | return 0; |
dea3101e | 825 | } |
826 | ||
827 | static int | |
2e0fef85 JS |
828 | lpfc_rcv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
829 | struct lpfc_iocbq *cmdiocb, uint32_t els_cmd) | |
dea3101e | 830 | { |
4b40c59e JS |
831 | struct lpfc_hba *phba = vport->phba; |
832 | struct lpfc_vport **vports; | |
833 | int i, active_vlink_present = 0 ; | |
2e0fef85 JS |
834 | |
835 | /* Put ndlp in NPR state with 1 sec timeout for plogi, ACC logo */ | |
dea3101e | 836 | /* Only call LOGO ACC for first LOGO, this avoids sending unnecessary |
837 | * PLOGIs during LOGO storms from a device. | |
838 | */ | |
92b99f1a | 839 | set_bit(NLP_LOGO_ACC, &ndlp->nlp_flag); |
82d9a2a2 | 840 | if (els_cmd == ELS_CMD_PRLO) |
51ef4c26 | 841 | lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL); |
82d9a2a2 | 842 | else |
51ef4c26 | 843 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
4c2805aa | 844 | |
fe83e3b9 JS |
845 | /* This clause allows the initiator to ACC the LOGO back to the |
846 | * Fabric Domain Controller. It does deliberately skip all other | |
847 | * steps because some fabrics send RDP requests after logging out | |
848 | * from the initiator. | |
849 | */ | |
850 | if (ndlp->nlp_type & NLP_FABRIC && | |
851 | ((ndlp->nlp_DID & WELL_KNOWN_DID_MASK) != WELL_KNOWN_DID_MASK)) | |
852 | return 0; | |
853 | ||
4c2805aa JS |
854 | /* Notify transport of connectivity loss to trigger cleanup. */ |
855 | if (phba->nvmet_support && | |
856 | ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) | |
857 | lpfc_nvmet_invalidate_host(phba, ndlp); | |
858 | ||
4b40c59e | 859 | if (ndlp->nlp_DID == Fabric_DID) { |
336d6361 | 860 | if (vport->port_state <= LPFC_FDISC || |
a645b8c1 | 861 | test_bit(FC_PT2PT, &vport->fc_flag)) |
4b40c59e | 862 | goto out; |
6fb120a7 | 863 | lpfc_linkdown_port(vport); |
a645b8c1 | 864 | set_bit(FC_VPORT_LOGO_RCVD, &vport->fc_flag); |
4b40c59e JS |
865 | vports = lpfc_create_vport_work_array(phba); |
866 | if (vports) { | |
867 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; | |
868 | i++) { | |
a645b8c1 JT |
869 | if (!test_bit(FC_VPORT_LOGO_RCVD, |
870 | &vports[i]->fc_flag) && | |
871 | vports[i]->port_state > LPFC_FDISC) { | |
4b40c59e JS |
872 | active_vlink_present = 1; |
873 | break; | |
874 | } | |
875 | } | |
876 | lpfc_destroy_vport_work_array(phba, vports); | |
877 | } | |
dea3101e | 878 | |
cc82355a JS |
879 | /* |
880 | * Don't re-instantiate if vport is marked for deletion. | |
881 | * If we are here first then vport_delete is going to wait | |
882 | * for discovery to complete. | |
883 | */ | |
e39811be JT |
884 | if (!test_bit(FC_UNLOADING, &vport->load_flag) && |
885 | active_vlink_present) { | |
4b40c59e JS |
886 | /* |
887 | * If there are other active VLinks present, | |
888 | * re-instantiate the Vlink using FDISC. | |
889 | */ | |
256ec0d0 JS |
890 | mod_timer(&ndlp->nlp_delayfunc, |
891 | jiffies + msecs_to_jiffies(1000)); | |
92b99f1a | 892 | set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag); |
4b40c59e JS |
893 | ndlp->nlp_last_elscmd = ELS_CMD_FDISC; |
894 | vport->port_state = LPFC_FDISC; | |
895 | } else { | |
a645b8c1 | 896 | clear_bit(FC_LOGO_RCVD_DID_CHNG, &phba->pport->fc_flag); |
4b40c59e JS |
897 | lpfc_retry_pport_discovery(phba); |
898 | } | |
9388da30 JT |
899 | } else { |
900 | lpfc_printf_vlog(vport, KERN_INFO, | |
901 | LOG_NODE | LOG_ELS | LOG_DISCOVERY, | |
902 | "3203 LOGO recover nport x%06x state x%x " | |
a645b8c1 | 903 | "ntype x%x fc_flag x%lx\n", |
9388da30 JT |
904 | ndlp->nlp_DID, ndlp->nlp_state, |
905 | ndlp->nlp_type, vport->fc_flag); | |
906 | ||
907 | /* Special cases for rports that recover post LOGO. */ | |
908 | if ((!(ndlp->nlp_type == NLP_FABRIC) && | |
909 | (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET) || | |
a645b8c1 | 910 | test_bit(FC_PT2PT, &vport->fc_flag))) || |
9388da30 JT |
911 | (ndlp->nlp_state >= NLP_STE_ADISC_ISSUE || |
912 | ndlp->nlp_state <= NLP_STE_PRLI_ISSUE)) { | |
913 | mod_timer(&ndlp->nlp_delayfunc, | |
84bbaeb0 | 914 | jiffies + secs_to_jiffies(1)); |
92b99f1a | 915 | set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag); |
9388da30 JT |
916 | ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; |
917 | lpfc_printf_vlog(vport, KERN_INFO, | |
918 | LOG_NODE | LOG_ELS | LOG_DISCOVERY, | |
919 | "3204 Start nlpdelay on DID x%06x " | |
92b99f1a | 920 | "nflag x%lx lastels x%x ref cnt %u", |
9388da30 JT |
921 | ndlp->nlp_DID, ndlp->nlp_flag, |
922 | ndlp->nlp_last_elscmd, | |
923 | kref_read(&ndlp->kref)); | |
924 | } | |
c9f8735b | 925 | } |
4b40c59e | 926 | out: |
06145683 JS |
927 | /* Unregister from backend, could have been skipped due to ADISC */ |
928 | lpfc_nlp_unreg_node(vport, ndlp); | |
929 | ||
87af33fe JS |
930 | ndlp->nlp_prev_state = ndlp->nlp_state; |
931 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); | |
dea3101e | 932 | |
92b99f1a | 933 | clear_bit(NLP_NPR_ADISC, &ndlp->nlp_flag); |
dea3101e | 934 | /* The driver has to wait until the ACC completes before it continues |
935 | * processing the LOGO. The action will resume in | |
936 | * lpfc_cmpl_els_logo_acc routine. Since part of processing includes an | |
937 | * unreg_login, the driver waits so the ACC does not get aborted. | |
938 | */ | |
c9f8735b | 939 | return 0; |
dea3101e | 940 | } |
941 | ||
b95e29b7 JS |
942 | static uint32_t |
943 | lpfc_rcv_prli_support_check(struct lpfc_vport *vport, | |
944 | struct lpfc_nodelist *ndlp, | |
945 | struct lpfc_iocbq *cmdiocb) | |
946 | { | |
947 | struct ls_rjt stat; | |
948 | uint32_t *payload; | |
949 | uint32_t cmd; | |
12e896c7 | 950 | PRLI *npr; |
b95e29b7 | 951 | |
d51cf5bd | 952 | payload = cmdiocb->cmd_dmabuf->virt; |
b95e29b7 | 953 | cmd = *payload; |
12e896c7 JT |
954 | npr = (PRLI *)((uint8_t *)payload + sizeof(uint32_t)); |
955 | ||
b95e29b7 JS |
956 | if (vport->phba->nvmet_support) { |
957 | /* Must be a NVME PRLI */ | |
12e896c7 | 958 | if (cmd == ELS_CMD_PRLI) |
b95e29b7 JS |
959 | goto out; |
960 | } else { | |
961 | /* Initiator mode. */ | |
962 | if (!vport->nvmei_support && (cmd == ELS_CMD_NVMEPRLI)) | |
963 | goto out; | |
12e896c7 JT |
964 | |
965 | /* NPIV ports will RJT initiator only functions */ | |
966 | if (vport->port_type == LPFC_NPIV_PORT && | |
967 | npr->initiatorFunc && !npr->targetFunc) | |
968 | goto out; | |
b95e29b7 JS |
969 | } |
970 | return 1; | |
971 | out: | |
12e896c7 | 972 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_DISCOVERY, |
b95e29b7 | 973 | "6115 Rcv PRLI (%x) check failed: ndlp rpi %d " |
92b99f1a | 974 | "state x%x flags x%lx port_type: x%x " |
12e896c7 | 975 | "npr->initfcn: x%x npr->tgtfcn: x%x\n", |
b95e29b7 | 976 | cmd, ndlp->nlp_rpi, ndlp->nlp_state, |
12e896c7 JT |
977 | ndlp->nlp_flag, vport->port_type, |
978 | npr->initiatorFunc, npr->targetFunc); | |
b95e29b7 JS |
979 | memset(&stat, 0, sizeof(struct ls_rjt)); |
980 | stat.un.b.lsRjtRsnCode = LSRJT_CMD_UNSUPPORTED; | |
981 | stat.un.b.lsRjtRsnCodeExp = LSEXP_REQ_UNSUPPORTED; | |
982 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, | |
983 | ndlp, NULL); | |
984 | return 0; | |
985 | } | |
986 | ||
dea3101e | 987 | static void |
2e0fef85 JS |
988 | lpfc_rcv_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
989 | struct lpfc_iocbq *cmdiocb) | |
dea3101e | 990 | { |
a0f2d3ef | 991 | struct lpfc_hba *phba = vport->phba; |
dea3101e | 992 | struct lpfc_dmabuf *pcmd; |
993 | uint32_t *lp; | |
994 | PRLI *npr; | |
995 | struct fc_rport *rport = ndlp->rport; | |
996 | u32 roles; | |
997 | ||
d51cf5bd JS |
998 | pcmd = cmdiocb->cmd_dmabuf; |
999 | lp = (uint32_t *)pcmd->virt; | |
1000 | npr = (PRLI *)((uint8_t *)lp + sizeof(uint32_t)); | |
dea3101e | 1001 | |
a0f2d3ef JS |
1002 | if ((npr->prliType == PRLI_FCP_TYPE) || |
1003 | (npr->prliType == PRLI_NVME_TYPE)) { | |
1004 | if (npr->initiatorFunc) { | |
1005 | if (npr->prliType == PRLI_FCP_TYPE) | |
1006 | ndlp->nlp_type |= NLP_FCP_INITIATOR; | |
1007 | if (npr->prliType == PRLI_NVME_TYPE) | |
1008 | ndlp->nlp_type |= NLP_NVME_INITIATOR; | |
1009 | } | |
3cb01c57 | 1010 | if (npr->targetFunc) { |
a0f2d3ef JS |
1011 | if (npr->prliType == PRLI_FCP_TYPE) |
1012 | ndlp->nlp_type |= NLP_FCP_TARGET; | |
1013 | if (npr->prliType == PRLI_NVME_TYPE) | |
1014 | ndlp->nlp_type |= NLP_NVME_TARGET; | |
3cb01c57 | 1015 | if (npr->writeXferRdyDis) |
92b99f1a | 1016 | set_bit(NLP_FIRSTBURST, &ndlp->nlp_flag); |
3cb01c57 | 1017 | } |
0d8af096 JS |
1018 | if (npr->Retry && ndlp->nlp_type & |
1019 | (NLP_FCP_INITIATOR | NLP_FCP_TARGET)) | |
dea3101e | 1020 | ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE; |
8c258641 | 1021 | |
0d8af096 JS |
1022 | if (npr->Retry && phba->nsler && |
1023 | ndlp->nlp_type & (NLP_NVME_INITIATOR | NLP_NVME_TARGET)) | |
1024 | ndlp->nlp_nvme_info |= NLP_NVME_NSLER; | |
1025 | ||
1026 | ||
8c258641 JS |
1027 | /* If this driver is in nvme target mode, set the ndlp's fc4 |
1028 | * type to NVME provided the PRLI response claims NVME FC4 | |
1029 | * type. Target mode does not issue gft_id so doesn't get | |
1030 | * the fc4 type set until now. | |
1031 | */ | |
9de416ac | 1032 | if (phba->nvmet_support && (npr->prliType == PRLI_NVME_TYPE)) { |
8c258641 | 1033 | ndlp->nlp_fc4_type |= NLP_FC4_NVME; |
9de416ac JS |
1034 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); |
1035 | } | |
07aaefdf JS |
1036 | |
1037 | /* Fabric Controllers send FCP PRLI as an initiator but should | |
1038 | * not get recognized as FCP type and registered with transport. | |
1039 | */ | |
1040 | if (npr->prliType == PRLI_FCP_TYPE && | |
1041 | !(ndlp->nlp_type & NLP_FABRIC)) | |
9de416ac | 1042 | ndlp->nlp_fc4_type |= NLP_FC4_FCP; |
dea3101e | 1043 | } |
1044 | if (rport) { | |
1045 | /* We need to update the rport role values */ | |
1046 | roles = FC_RPORT_ROLE_UNKNOWN; | |
1047 | if (ndlp->nlp_type & NLP_FCP_INITIATOR) | |
1048 | roles |= FC_RPORT_ROLE_FCP_INITIATOR; | |
1049 | if (ndlp->nlp_type & NLP_FCP_TARGET) | |
1050 | roles |= FC_RPORT_ROLE_FCP_TARGET; | |
858c9f6c JS |
1051 | |
1052 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT, | |
92b99f1a | 1053 | "rport rolechg: role:x%x did:x%x flg:x%lx", |
858c9f6c JS |
1054 | roles, ndlp->nlp_DID, ndlp->nlp_flag); |
1055 | ||
f6e84790 | 1056 | if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME) |
a0f2d3ef | 1057 | fc_remote_port_rolechg(rport, roles); |
dea3101e | 1058 | } |
1059 | } | |
1060 | ||
1061 | static uint32_t | |
2e0fef85 | 1062 | lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) |
dea3101e | 1063 | { |
92b99f1a JT |
1064 | if (!test_bit(NLP_RPI_REGISTERED, &ndlp->nlp_flag)) { |
1065 | clear_bit(NLP_NPR_ADISC, &ndlp->nlp_flag); | |
51ef4c26 JS |
1066 | return 0; |
1067 | } | |
1068 | ||
a645b8c1 | 1069 | if (!test_bit(FC_PT2PT, &vport->fc_flag)) { |
1b32f6aa | 1070 | /* Check config parameter use-adisc or FCP-2 */ |
a645b8c1 JT |
1071 | if (vport->cfg_use_adisc && |
1072 | (test_bit(FC_RSCN_MODE, &vport->fc_flag) || | |
ffc95493 | 1073 | ((ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) && |
0fd103cc | 1074 | (ndlp->nlp_type & NLP_FCP_TARGET)))) { |
92b99f1a | 1075 | set_bit(NLP_NPR_ADISC, &ndlp->nlp_flag); |
1b32f6aa JS |
1076 | return 1; |
1077 | } | |
92d7f7b0 | 1078 | } |
30e196ca | 1079 | |
92b99f1a | 1080 | clear_bit(NLP_NPR_ADISC, &ndlp->nlp_flag); |
92d7f7b0 JS |
1081 | lpfc_unreg_rpi(vport, ndlp); |
1082 | return 0; | |
dea3101e | 1083 | } |
6d368e53 | 1084 | |
78730cfe | 1085 | /** |
25985edc | 1086 | * lpfc_release_rpi - Release a RPI by issuing unreg_login mailbox cmd. |
78730cfe JS |
1087 | * @phba : Pointer to lpfc_hba structure. |
1088 | * @vport: Pointer to lpfc_vport structure. | |
22f8c077 | 1089 | * @ndlp: Pointer to lpfc_nodelist structure. |
78730cfe JS |
1090 | * @rpi : rpi to be release. |
1091 | * | |
1092 | * This function will send a unreg_login mailbox command to the firmware | |
1093 | * to release a rpi. | |
1094 | **/ | |
3999df75 | 1095 | static void |
dea16bda JS |
1096 | lpfc_release_rpi(struct lpfc_hba *phba, struct lpfc_vport *vport, |
1097 | struct lpfc_nodelist *ndlp, uint16_t rpi) | |
78730cfe JS |
1098 | { |
1099 | LPFC_MBOXQ_t *pmb; | |
1100 | int rc; | |
1101 | ||
dea16bda JS |
1102 | /* If there is already an UNREG in progress for this ndlp, |
1103 | * no need to queue up another one. | |
1104 | */ | |
92b99f1a | 1105 | if (test_bit(NLP_UNREG_INP, &ndlp->nlp_flag)) { |
dea16bda JS |
1106 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
1107 | "1435 release_rpi SKIP UNREG x%x on " | |
92b99f1a | 1108 | "NPort x%x deferred x%x flg x%lx " |
32350664 | 1109 | "Data: x%px\n", |
dea16bda JS |
1110 | ndlp->nlp_rpi, ndlp->nlp_DID, |
1111 | ndlp->nlp_defer_did, | |
1112 | ndlp->nlp_flag, ndlp); | |
1113 | return; | |
1114 | } | |
1115 | ||
78730cfe JS |
1116 | pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, |
1117 | GFP_KERNEL); | |
1118 | if (!pmb) | |
372c187b DK |
1119 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
1120 | "2796 mailbox memory allocation failed \n"); | |
78730cfe JS |
1121 | else { |
1122 | lpfc_unreg_login(phba, vport->vpi, rpi, pmb); | |
1123 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | |
dea16bda | 1124 | pmb->vport = vport; |
4430f7fd JS |
1125 | pmb->ctx_ndlp = lpfc_nlp_get(ndlp); |
1126 | if (!pmb->ctx_ndlp) { | |
1127 | mempool_free(pmb, phba->mbox_mem_pool); | |
1128 | return; | |
1129 | } | |
dea16bda JS |
1130 | |
1131 | if (((ndlp->nlp_DID & Fabric_DID_MASK) != Fabric_DID_MASK) && | |
a645b8c1 | 1132 | (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag))) |
92b99f1a | 1133 | set_bit(NLP_UNREG_INP, &ndlp->nlp_flag); |
dea16bda JS |
1134 | |
1135 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | |
1136 | "1437 release_rpi UNREG x%x " | |
92b99f1a | 1137 | "on NPort x%x flg x%lx\n", |
dea16bda JS |
1138 | ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag); |
1139 | ||
78730cfe | 1140 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); |
ba3d58a1 JS |
1141 | if (rc == MBX_NOT_FINISHED) { |
1142 | lpfc_nlp_put(ndlp); | |
78730cfe | 1143 | mempool_free(pmb, phba->mbox_mem_pool); |
ba3d58a1 | 1144 | } |
78730cfe JS |
1145 | } |
1146 | } | |
dea3101e | 1147 | |
1148 | static uint32_t | |
2e0fef85 JS |
1149 | lpfc_disc_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1150 | void *arg, uint32_t evt) | |
dea3101e | 1151 | { |
78730cfe JS |
1152 | struct lpfc_hba *phba; |
1153 | LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg; | |
78730cfe JS |
1154 | uint16_t rpi; |
1155 | ||
1156 | phba = vport->phba; | |
1157 | /* Release the RPI if reglogin completing */ | |
e39811be JT |
1158 | if (!test_bit(FC_UNLOADING, &phba->pport->load_flag) && |
1159 | evt == NLP_EVT_CMPL_REG_LOGIN && !pmb->u.mb.mbxStatus) { | |
78730cfe | 1160 | rpi = pmb->u.mb.un.varWords[0]; |
dea16bda | 1161 | lpfc_release_rpi(phba, vport, ndlp, rpi); |
78730cfe | 1162 | } |
372c187b | 1163 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
e47c9093 | 1164 | "0271 Illegal State Transition: node x%x " |
92b99f1a | 1165 | "event x%x, state x%x Data: x%x x%lx\n", |
e8b62011 JS |
1166 | ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi, |
1167 | ndlp->nlp_flag); | |
c9f8735b | 1168 | return ndlp->nlp_state; |
dea3101e | 1169 | } |
1170 | ||
87af33fe JS |
1171 | static uint32_t |
1172 | lpfc_cmpl_plogi_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
1173 | void *arg, uint32_t evt) | |
1174 | { | |
1175 | /* This transition is only legal if we previously | |
1176 | * rcv'ed a PLOGI. Since we don't want 2 discovery threads | |
1177 | * working on the same NPortID, do nothing for this thread | |
1178 | * to stop it. | |
1179 | */ | |
92b99f1a | 1180 | if (!test_bit(NLP_RCV_PLOGI, &ndlp->nlp_flag)) |
372c187b DK |
1181 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
1182 | "0272 Illegal State Transition: node x%x " | |
92b99f1a | 1183 | "event x%x, state x%x Data: x%x x%lx\n", |
372c187b DK |
1184 | ndlp->nlp_DID, evt, ndlp->nlp_state, |
1185 | ndlp->nlp_rpi, ndlp->nlp_flag); | |
87af33fe JS |
1186 | return ndlp->nlp_state; |
1187 | } | |
1188 | ||
dea3101e | 1189 | /* Start of Discovery State Machine routines */ |
1190 | ||
1191 | static uint32_t | |
2e0fef85 JS |
1192 | lpfc_rcv_plogi_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1193 | void *arg, uint32_t evt) | |
dea3101e | 1194 | { |
1195 | struct lpfc_iocbq *cmdiocb; | |
1196 | ||
1197 | cmdiocb = (struct lpfc_iocbq *) arg; | |
1198 | ||
2e0fef85 | 1199 | if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) { |
c9f8735b | 1200 | return ndlp->nlp_state; |
dea3101e | 1201 | } |
c9f8735b | 1202 | return NLP_STE_FREED_NODE; |
dea3101e | 1203 | } |
1204 | ||
1205 | static uint32_t | |
2e0fef85 JS |
1206 | lpfc_rcv_els_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1207 | void *arg, uint32_t evt) | |
dea3101e | 1208 | { |
2e0fef85 | 1209 | lpfc_issue_els_logo(vport, ndlp, 0); |
c9f8735b | 1210 | return ndlp->nlp_state; |
dea3101e | 1211 | } |
1212 | ||
1213 | static uint32_t | |
2e0fef85 JS |
1214 | lpfc_rcv_logo_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1215 | void *arg, uint32_t evt) | |
dea3101e | 1216 | { |
2e0fef85 | 1217 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 1218 | |
92b99f1a | 1219 | set_bit(NLP_LOGO_ACC, &ndlp->nlp_flag); |
51ef4c26 | 1220 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
dea3101e | 1221 | |
c9f8735b | 1222 | return ndlp->nlp_state; |
dea3101e | 1223 | } |
1224 | ||
1225 | static uint32_t | |
2e0fef85 JS |
1226 | lpfc_cmpl_logo_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1227 | void *arg, uint32_t evt) | |
dea3101e | 1228 | { |
c9f8735b | 1229 | return NLP_STE_FREED_NODE; |
dea3101e | 1230 | } |
1231 | ||
1232 | static uint32_t | |
2e0fef85 JS |
1233 | lpfc_device_rm_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1234 | void *arg, uint32_t evt) | |
dea3101e | 1235 | { |
c9f8735b | 1236 | return NLP_STE_FREED_NODE; |
dea3101e | 1237 | } |
1238 | ||
df9e1b59 JS |
1239 | static uint32_t |
1240 | lpfc_device_recov_unused_node(struct lpfc_vport *vport, | |
1241 | struct lpfc_nodelist *ndlp, | |
1242 | void *arg, uint32_t evt) | |
1243 | { | |
1244 | return ndlp->nlp_state; | |
1245 | } | |
1246 | ||
dea3101e | 1247 | static uint32_t |
2e0fef85 | 1248 | lpfc_rcv_plogi_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
dea3101e | 1249 | void *arg, uint32_t evt) |
1250 | { | |
2e0fef85 | 1251 | struct lpfc_hba *phba = vport->phba; |
dea3101e | 1252 | struct lpfc_iocbq *cmdiocb = arg; |
d51cf5bd | 1253 | struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf; |
2e0fef85 JS |
1254 | uint32_t *lp = (uint32_t *) pcmd->virt; |
1255 | struct serv_parm *sp = (struct serv_parm *) (lp + 1); | |
dea3101e | 1256 | struct ls_rjt stat; |
1257 | int port_cmp; | |
1258 | ||
dea3101e | 1259 | memset(&stat, 0, sizeof (struct ls_rjt)); |
1260 | ||
1261 | /* For a PLOGI, we only accept if our portname is less | |
1262 | * than the remote portname. | |
1263 | */ | |
1264 | phba->fc_stat.elsLogiCol++; | |
2e0fef85 | 1265 | port_cmp = memcmp(&vport->fc_portname, &sp->portName, |
92d7f7b0 | 1266 | sizeof(struct lpfc_name)); |
dea3101e | 1267 | |
1268 | if (port_cmp >= 0) { | |
1269 | /* Reject this request because the remote node will accept | |
1270 | ours */ | |
1271 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; | |
1272 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CMD_IN_PROGRESS; | |
858c9f6c JS |
1273 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
1274 | NULL); | |
2fe165b6 | 1275 | } else { |
0d2b6b83 | 1276 | if (lpfc_rcv_plogi(vport, ndlp, cmdiocb) && |
92b99f1a JT |
1277 | test_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag) && |
1278 | vport->num_disc_nodes) { | |
1279 | clear_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag); | |
0d2b6b83 JS |
1280 | /* Check if there are more PLOGIs to be sent */ |
1281 | lpfc_more_plogi(vport); | |
1282 | if (vport->num_disc_nodes == 0) { | |
a645b8c1 | 1283 | clear_bit(FC_NDISC_ACTIVE, &vport->fc_flag); |
0d2b6b83 JS |
1284 | lpfc_can_disctmo(vport); |
1285 | lpfc_end_rscn(vport); | |
1286 | } | |
1287 | } | |
2e0fef85 | 1288 | } /* If our portname was less */ |
dea3101e | 1289 | |
c9f8735b JW |
1290 | return ndlp->nlp_state; |
1291 | } | |
1292 | ||
92d7f7b0 JS |
1293 | static uint32_t |
1294 | lpfc_rcv_prli_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
1295 | void *arg, uint32_t evt) | |
1296 | { | |
1297 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; | |
1298 | struct ls_rjt stat; | |
1299 | ||
1300 | memset(&stat, 0, sizeof (struct ls_rjt)); | |
1301 | stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY; | |
1302 | stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; | |
858c9f6c | 1303 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
92d7f7b0 JS |
1304 | return ndlp->nlp_state; |
1305 | } | |
1306 | ||
c9f8735b | 1307 | static uint32_t |
2e0fef85 JS |
1308 | lpfc_rcv_logo_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1309 | void *arg, uint32_t evt) | |
c9f8735b | 1310 | { |
2e0fef85 | 1311 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
c9f8735b | 1312 | |
faa832e9 JS |
1313 | /* Retrieve RPI from LOGO IOCB. RPI is used for CMD_ABORT_XRI_CN */ |
1314 | if (vport->phba->sli_rev == LPFC_SLI_REV3) | |
1315 | ndlp->nlp_rpi = cmdiocb->iocb.ulpIoTag; | |
92d7f7b0 | 1316 | /* software abort outstanding PLOGI */ |
2e0fef85 | 1317 | lpfc_els_abort(vport->phba, ndlp); |
c9f8735b | 1318 | |
2e0fef85 | 1319 | lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO); |
c9f8735b | 1320 | return ndlp->nlp_state; |
dea3101e | 1321 | } |
1322 | ||
1323 | static uint32_t | |
2e0fef85 JS |
1324 | lpfc_rcv_els_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1325 | void *arg, uint32_t evt) | |
dea3101e | 1326 | { |
2e0fef85 JS |
1327 | struct lpfc_hba *phba = vport->phba; |
1328 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; | |
dea3101e | 1329 | |
1330 | /* software abort outstanding PLOGI */ | |
07951076 | 1331 | lpfc_els_abort(phba, ndlp); |
dea3101e | 1332 | |
1333 | if (evt == NLP_EVT_RCV_LOGO) { | |
51ef4c26 | 1334 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
2fe165b6 | 1335 | } else { |
2e0fef85 | 1336 | lpfc_issue_els_logo(vport, ndlp, 0); |
dea3101e | 1337 | } |
1338 | ||
2e0fef85 | 1339 | /* Put ndlp in npr state set plogi timer for 1 sec */ |
84bbaeb0 | 1340 | mod_timer(&ndlp->nlp_delayfunc, jiffies + secs_to_jiffies(1)); |
92b99f1a | 1341 | set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag); |
5024ab17 JW |
1342 | ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; |
1343 | ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE; | |
2e0fef85 | 1344 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
dea3101e | 1345 | |
c9f8735b | 1346 | return ndlp->nlp_state; |
dea3101e | 1347 | } |
1348 | ||
1349 | static uint32_t | |
2e0fef85 JS |
1350 | lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, |
1351 | struct lpfc_nodelist *ndlp, | |
1352 | void *arg, | |
dea3101e | 1353 | uint32_t evt) |
1354 | { | |
2e0fef85 JS |
1355 | struct lpfc_hba *phba = vport->phba; |
1356 | struct lpfc_iocbq *cmdiocb, *rspiocb; | |
ef47575f | 1357 | struct lpfc_dmabuf *pcmd, *prsp; |
dea3101e | 1358 | uint32_t *lp; |
8c258641 | 1359 | uint32_t vid, flag; |
dea3101e | 1360 | struct serv_parm *sp; |
d6de08cc | 1361 | uint32_t ed_tov; |
dea3101e | 1362 | LPFC_MBOXQ_t *mbox; |
d6de08cc | 1363 | int rc; |
cad93a08 JS |
1364 | u32 ulp_status; |
1365 | u32 did; | |
dea3101e | 1366 | |
1367 | cmdiocb = (struct lpfc_iocbq *) arg; | |
d51cf5bd | 1368 | rspiocb = cmdiocb->rsp_iocb; |
dea3101e | 1369 | |
cad93a08 JS |
1370 | ulp_status = get_job_ulpstatus(phba, rspiocb); |
1371 | ||
92b99f1a | 1372 | if (test_bit(NLP_ACC_REGLOGIN, &ndlp->nlp_flag)) { |
5024ab17 | 1373 | /* Recovery from PLOGI collision logic */ |
c9f8735b | 1374 | return ndlp->nlp_state; |
dea3101e | 1375 | } |
1376 | ||
cad93a08 | 1377 | if (ulp_status) |
dea3101e | 1378 | goto out; |
1379 | ||
d51cf5bd | 1380 | pcmd = cmdiocb->cmd_dmabuf; |
dea3101e | 1381 | |
2e0fef85 | 1382 | prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list); |
a2fc4aef JS |
1383 | if (!prsp) |
1384 | goto out; | |
dea3101e | 1385 | |
2e0fef85 | 1386 | lp = (uint32_t *) prsp->virt; |
dea3101e | 1387 | sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t)); |
58da1ffb JS |
1388 | |
1389 | /* Some switches have FDMI servers returning 0 for WWN */ | |
1390 | if ((ndlp->nlp_DID != FDMI_DID) && | |
1391 | (wwn_to_u64(sp->portName.u.wwn) == 0 || | |
1392 | wwn_to_u64(sp->nodeName.u.wwn) == 0)) { | |
372c187b | 1393 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
a8adb832 JS |
1394 | "0142 PLOGI RSP: Invalid WWN.\n"); |
1395 | goto out; | |
1396 | } | |
341af102 | 1397 | if (!lpfc_check_sparm(vport, ndlp, sp, CLASS3, 0)) |
dea3101e | 1398 | goto out; |
dea3101e | 1399 | /* PLOGI chkparm OK */ |
e8b62011 | 1400 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
92b99f1a | 1401 | "0121 PLOGI chkparm OK Data: x%x x%x x%lx x%x\n", |
e8b62011 JS |
1402 | ndlp->nlp_DID, ndlp->nlp_state, |
1403 | ndlp->nlp_flag, ndlp->nlp_rpi); | |
3de2a653 | 1404 | if (vport->cfg_fcp_class == 2 && (sp->cls2.classValid)) |
dea3101e | 1405 | ndlp->nlp_fcp_info |= CLASS2; |
2e0fef85 | 1406 | else |
dea3101e | 1407 | ndlp->nlp_fcp_info |= CLASS3; |
2e0fef85 | 1408 | |
dea3101e | 1409 | ndlp->nlp_class_sup = 0; |
1410 | if (sp->cls1.classValid) | |
1411 | ndlp->nlp_class_sup |= FC_COS_CLASS1; | |
1412 | if (sp->cls2.classValid) | |
1413 | ndlp->nlp_class_sup |= FC_COS_CLASS2; | |
1414 | if (sp->cls3.classValid) | |
1415 | ndlp->nlp_class_sup |= FC_COS_CLASS3; | |
1416 | if (sp->cls4.classValid) | |
1417 | ndlp->nlp_class_sup |= FC_COS_CLASS4; | |
1418 | ndlp->nlp_maxframe = | |
2e0fef85 | 1419 | ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb; |
dea3101e | 1420 | |
a645b8c1 JT |
1421 | if (test_bit(FC_PT2PT, &vport->fc_flag) && |
1422 | test_bit(FC_PT2PT_PLOGI, &vport->fc_flag)) { | |
d6de08cc JS |
1423 | ed_tov = be32_to_cpu(sp->cmn.e_d_tov); |
1424 | if (sp->cmn.edtovResolution) { | |
1425 | /* E_D_TOV ticks are in nanoseconds */ | |
1426 | ed_tov = (phba->fc_edtov + 999999) / 1000000; | |
1427 | } | |
1428 | ||
92b99f1a | 1429 | clear_bit(NLP_SUPPRESS_RSP, &ndlp->nlp_flag); |
8c258641 JS |
1430 | if ((phba->sli.sli_flag & LPFC_SLI_SUPPRESS_RSP) && |
1431 | sp->cmn.valid_vendor_ver_level) { | |
1432 | vid = be32_to_cpu(sp->un.vv.vid); | |
1433 | flag = be32_to_cpu(sp->un.vv.flags); | |
1434 | if ((vid == LPFC_VV_EMLX_ID) && | |
1435 | (flag & LPFC_VV_SUPPRESS_RSP)) | |
92b99f1a | 1436 | set_bit(NLP_SUPPRESS_RSP, &ndlp->nlp_flag); |
8c258641 JS |
1437 | } |
1438 | ||
d6de08cc JS |
1439 | /* |
1440 | * Use the larger EDTOV | |
1441 | * RATOV = 2 * EDTOV for pt-to-pt | |
1442 | */ | |
1443 | if (ed_tov > phba->fc_edtov) | |
1444 | phba->fc_edtov = ed_tov; | |
1445 | phba->fc_ratov = (2 * phba->fc_edtov) / 1000; | |
1446 | ||
1447 | memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm)); | |
1448 | ||
1449 | /* Issue config_link / reg_vfi to account for updated TOV's */ | |
1450 | if (phba->sli_rev == LPFC_SLI_REV4) { | |
1451 | lpfc_issue_reg_vfi(vport); | |
1452 | } else { | |
01c73bbc JS |
1453 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
1454 | if (!mbox) { | |
372c187b DK |
1455 | lpfc_printf_vlog(vport, KERN_ERR, |
1456 | LOG_TRACE_EVENT, | |
01c73bbc JS |
1457 | "0133 PLOGI: no memory " |
1458 | "for config_link " | |
92b99f1a | 1459 | "Data: x%x x%x x%lx x%x\n", |
01c73bbc JS |
1460 | ndlp->nlp_DID, ndlp->nlp_state, |
1461 | ndlp->nlp_flag, ndlp->nlp_rpi); | |
1462 | goto out; | |
1463 | } | |
1464 | ||
d6de08cc JS |
1465 | lpfc_config_link(phba, mbox); |
1466 | ||
1467 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | |
1468 | mbox->vport = vport; | |
1469 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); | |
1470 | if (rc == MBX_NOT_FINISHED) { | |
1471 | mempool_free(mbox, phba->mbox_mem_pool); | |
1472 | goto out; | |
1473 | } | |
1474 | } | |
92d7f7b0 | 1475 | } |
dea3101e | 1476 | |
2e0fef85 JS |
1477 | lpfc_unreg_rpi(vport, ndlp); |
1478 | ||
01c73bbc JS |
1479 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
1480 | if (!mbox) { | |
372c187b | 1481 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
01c73bbc | 1482 | "0018 PLOGI: no memory for reg_login " |
92b99f1a | 1483 | "Data: x%x x%x x%lx x%x\n", |
01c73bbc JS |
1484 | ndlp->nlp_DID, ndlp->nlp_state, |
1485 | ndlp->nlp_flag, ndlp->nlp_rpi); | |
1486 | goto out; | |
1487 | } | |
1488 | ||
cad93a08 JS |
1489 | did = get_job_els_rsp64_did(phba, cmdiocb); |
1490 | ||
1491 | if (lpfc_reg_rpi(phba, vport->vpi, did, | |
4042629e | 1492 | (uint8_t *) sp, mbox, ndlp->nlp_rpi) == 0) { |
2fe165b6 | 1493 | switch (ndlp->nlp_DID) { |
dea3101e | 1494 | case NameServer_DID: |
de0c5b32 | 1495 | mbox->mbox_cmpl = lpfc_mbx_cmpl_ns_reg_login; |
fe83e3b9 JS |
1496 | /* Fabric Controller Node needs these parameters. */ |
1497 | memcpy(&ndlp->fc_sparam, sp, sizeof(struct serv_parm)); | |
dea3101e | 1498 | break; |
1499 | case FDMI_DID: | |
de0c5b32 | 1500 | mbox->mbox_cmpl = lpfc_mbx_cmpl_fdmi_reg_login; |
dea3101e | 1501 | break; |
1502 | default: | |
92b99f1a | 1503 | set_bit(NLP_REG_LOGIN_SEND, &ndlp->nlp_flag); |
de0c5b32 | 1504 | mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; |
dea3101e | 1505 | } |
4430f7fd | 1506 | |
3e1f0718 | 1507 | mbox->ctx_ndlp = lpfc_nlp_get(ndlp); |
4430f7fd JS |
1508 | if (!mbox->ctx_ndlp) |
1509 | goto out; | |
1510 | ||
2e0fef85 | 1511 | mbox->vport = vport; |
0b727fea | 1512 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
dea3101e | 1513 | != MBX_NOT_FINISHED) { |
2e0fef85 JS |
1514 | lpfc_nlp_set_state(vport, ndlp, |
1515 | NLP_STE_REG_LOGIN_ISSUE); | |
c9f8735b | 1516 | return ndlp->nlp_state; |
dea3101e | 1517 | } |
92b99f1a | 1518 | clear_bit(NLP_REG_LOGIN_SEND, &ndlp->nlp_flag); |
fa4066b6 JS |
1519 | /* decrement node reference count to the failed mbox |
1520 | * command | |
1521 | */ | |
329f9bc7 | 1522 | lpfc_nlp_put(ndlp); |
ef47575f | 1523 | lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); |
372c187b | 1524 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
e8b62011 | 1525 | "0134 PLOGI: cannot issue reg_login " |
92b99f1a | 1526 | "Data: x%x x%x x%lx x%x\n", |
e8b62011 JS |
1527 | ndlp->nlp_DID, ndlp->nlp_state, |
1528 | ndlp->nlp_flag, ndlp->nlp_rpi); | |
dea3101e | 1529 | } else { |
1530 | mempool_free(mbox, phba->mbox_mem_pool); | |
92d7f7b0 | 1531 | |
372c187b | 1532 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
e8b62011 | 1533 | "0135 PLOGI: cannot format reg_login " |
92b99f1a | 1534 | "Data: x%x x%x x%lx x%x\n", |
e8b62011 JS |
1535 | ndlp->nlp_DID, ndlp->nlp_state, |
1536 | ndlp->nlp_flag, ndlp->nlp_rpi); | |
dea3101e | 1537 | } |
1538 | ||
1539 | ||
92d7f7b0 JS |
1540 | out: |
1541 | if (ndlp->nlp_DID == NameServer_DID) { | |
1542 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); | |
372c187b | 1543 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
e8b62011 | 1544 | "0261 Cannot Register NameServer login\n"); |
92d7f7b0 JS |
1545 | } |
1546 | ||
8b455cf3 JS |
1547 | /* |
1548 | ** In case the node reference counter does not go to zero, ensure that | |
1549 | ** the stale state for the node is not processed. | |
1550 | */ | |
1551 | ||
1552 | ndlp->nlp_prev_state = ndlp->nlp_state; | |
1553 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); | |
c9f8735b | 1554 | return NLP_STE_FREED_NODE; |
dea3101e | 1555 | } |
1556 | ||
0ff10d46 JS |
1557 | static uint32_t |
1558 | lpfc_cmpl_logo_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
1559 | void *arg, uint32_t evt) | |
1560 | { | |
1561 | return ndlp->nlp_state; | |
1562 | } | |
1563 | ||
1564 | static uint32_t | |
1565 | lpfc_cmpl_reglogin_plogi_issue(struct lpfc_vport *vport, | |
1566 | struct lpfc_nodelist *ndlp, void *arg, uint32_t evt) | |
1567 | { | |
78730cfe JS |
1568 | struct lpfc_hba *phba; |
1569 | LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg; | |
1570 | MAILBOX_t *mb = &pmb->u.mb; | |
1571 | uint16_t rpi; | |
1572 | ||
1573 | phba = vport->phba; | |
1574 | /* Release the RPI */ | |
e39811be JT |
1575 | if (!test_bit(FC_UNLOADING, &phba->pport->load_flag) && |
1576 | !mb->mbxStatus) { | |
78730cfe | 1577 | rpi = pmb->u.mb.un.varWords[0]; |
dea16bda | 1578 | lpfc_release_rpi(phba, vport, ndlp, rpi); |
78730cfe | 1579 | } |
0ff10d46 JS |
1580 | return ndlp->nlp_state; |
1581 | } | |
1582 | ||
dea3101e | 1583 | static uint32_t |
2e0fef85 JS |
1584 | lpfc_device_rm_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1585 | void *arg, uint32_t evt) | |
dea3101e | 1586 | { |
92b99f1a JT |
1587 | if (test_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag)) { |
1588 | set_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); | |
a0f9b48d | 1589 | return ndlp->nlp_state; |
a0f9b48d | 1590 | } |
92b99f1a JT |
1591 | /* software abort outstanding PLOGI */ |
1592 | lpfc_els_abort(vport->phba, ndlp); | |
1593 | ||
1594 | lpfc_drop_node(vport, ndlp); | |
1595 | return NLP_STE_FREED_NODE; | |
dea3101e | 1596 | } |
1597 | ||
1598 | static uint32_t | |
2e0fef85 JS |
1599 | lpfc_device_recov_plogi_issue(struct lpfc_vport *vport, |
1600 | struct lpfc_nodelist *ndlp, | |
1601 | void *arg, | |
1602 | uint32_t evt) | |
dea3101e | 1603 | { |
2e0fef85 JS |
1604 | struct lpfc_hba *phba = vport->phba; |
1605 | ||
bf81e9cd JT |
1606 | /* Don't do anything that disrupts the RSCN unless lpfc is unloading. */ |
1607 | if (lpfc_check_unload_and_clr_rscn(&vport->fc_flag)) | |
92d7f7b0 JS |
1608 | return ndlp->nlp_state; |
1609 | ||
dea3101e | 1610 | /* software abort outstanding PLOGI */ |
07951076 | 1611 | lpfc_els_abort(phba, ndlp); |
dea3101e | 1612 | |
5024ab17 | 1613 | ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE; |
2e0fef85 | 1614 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
92b99f1a JT |
1615 | clear_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); |
1616 | clear_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag); | |
dea3101e | 1617 | |
c9f8735b | 1618 | return ndlp->nlp_state; |
dea3101e | 1619 | } |
1620 | ||
1621 | static uint32_t | |
2e0fef85 JS |
1622 | lpfc_rcv_plogi_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1623 | void *arg, uint32_t evt) | |
dea3101e | 1624 | { |
2e0fef85 | 1625 | struct lpfc_hba *phba = vport->phba; |
dea3101e | 1626 | struct lpfc_iocbq *cmdiocb; |
1627 | ||
1628 | /* software abort outstanding ADISC */ | |
07951076 | 1629 | lpfc_els_abort(phba, ndlp); |
dea3101e | 1630 | |
1631 | cmdiocb = (struct lpfc_iocbq *) arg; | |
1632 | ||
0d2b6b83 | 1633 | if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) { |
92b99f1a | 1634 | if (test_and_clear_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag)) { |
90160e01 | 1635 | if (vport->num_disc_nodes) |
0d2b6b83 | 1636 | lpfc_more_adisc(vport); |
0d2b6b83 JS |
1637 | } |
1638 | return ndlp->nlp_state; | |
1639 | } | |
5024ab17 | 1640 | ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; |
2e0fef85 JS |
1641 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); |
1642 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); | |
dea3101e | 1643 | |
c9f8735b | 1644 | return ndlp->nlp_state; |
dea3101e | 1645 | } |
1646 | ||
1647 | static uint32_t | |
2e0fef85 JS |
1648 | lpfc_rcv_prli_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1649 | void *arg, uint32_t evt) | |
dea3101e | 1650 | { |
2e0fef85 | 1651 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 1652 | |
b95e29b7 JS |
1653 | if (lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb)) |
1654 | lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp); | |
c9f8735b | 1655 | return ndlp->nlp_state; |
dea3101e | 1656 | } |
1657 | ||
1658 | static uint32_t | |
2e0fef85 JS |
1659 | lpfc_rcv_logo_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1660 | void *arg, uint32_t evt) | |
dea3101e | 1661 | { |
2e0fef85 | 1662 | struct lpfc_hba *phba = vport->phba; |
dea3101e | 1663 | struct lpfc_iocbq *cmdiocb; |
1664 | ||
1665 | cmdiocb = (struct lpfc_iocbq *) arg; | |
1666 | ||
1667 | /* software abort outstanding ADISC */ | |
07951076 | 1668 | lpfc_els_abort(phba, ndlp); |
dea3101e | 1669 | |
2e0fef85 | 1670 | lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO); |
c9f8735b | 1671 | return ndlp->nlp_state; |
dea3101e | 1672 | } |
1673 | ||
1674 | static uint32_t | |
2e0fef85 JS |
1675 | lpfc_rcv_padisc_adisc_issue(struct lpfc_vport *vport, |
1676 | struct lpfc_nodelist *ndlp, | |
1677 | void *arg, uint32_t evt) | |
dea3101e | 1678 | { |
1679 | struct lpfc_iocbq *cmdiocb; | |
1680 | ||
1681 | cmdiocb = (struct lpfc_iocbq *) arg; | |
1682 | ||
2e0fef85 | 1683 | lpfc_rcv_padisc(vport, ndlp, cmdiocb); |
c9f8735b | 1684 | return ndlp->nlp_state; |
dea3101e | 1685 | } |
1686 | ||
1687 | static uint32_t | |
2e0fef85 JS |
1688 | lpfc_rcv_prlo_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1689 | void *arg, uint32_t evt) | |
dea3101e | 1690 | { |
1691 | struct lpfc_iocbq *cmdiocb; | |
1692 | ||
1693 | cmdiocb = (struct lpfc_iocbq *) arg; | |
1694 | ||
1695 | /* Treat like rcv logo */ | |
2e0fef85 | 1696 | lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO); |
c9f8735b | 1697 | return ndlp->nlp_state; |
dea3101e | 1698 | } |
1699 | ||
1700 | static uint32_t | |
2e0fef85 JS |
1701 | lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport *vport, |
1702 | struct lpfc_nodelist *ndlp, | |
1703 | void *arg, uint32_t evt) | |
dea3101e | 1704 | { |
2e0fef85 | 1705 | struct lpfc_hba *phba = vport->phba; |
dea3101e | 1706 | struct lpfc_iocbq *cmdiocb, *rspiocb; |
dea3101e | 1707 | ADISC *ap; |
6fb120a7 | 1708 | int rc; |
cad93a08 | 1709 | u32 ulp_status; |
dea3101e | 1710 | |
1711 | cmdiocb = (struct lpfc_iocbq *) arg; | |
d51cf5bd | 1712 | rspiocb = cmdiocb->rsp_iocb; |
dea3101e | 1713 | |
cad93a08 JS |
1714 | ulp_status = get_job_ulpstatus(phba, rspiocb); |
1715 | ||
dea3101e | 1716 | ap = (ADISC *)lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb); |
dea3101e | 1717 | |
cad93a08 | 1718 | if ((ulp_status) || |
92d7f7b0 | 1719 | (!lpfc_check_adisc(vport, ndlp, &ap->nodeName, &ap->portName))) { |
dea3101e | 1720 | /* 1 sec timeout */ |
256ec0d0 JS |
1721 | mod_timer(&ndlp->nlp_delayfunc, |
1722 | jiffies + msecs_to_jiffies(1000)); | |
92b99f1a | 1723 | set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag); |
5024ab17 | 1724 | ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; |
dea3101e | 1725 | |
5024ab17 | 1726 | ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; |
2e0fef85 JS |
1727 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
1728 | lpfc_unreg_rpi(vport, ndlp); | |
c9f8735b | 1729 | return ndlp->nlp_state; |
dea3101e | 1730 | } |
5024ab17 | 1731 | |
6fb120a7 | 1732 | if (phba->sli_rev == LPFC_SLI_REV4) { |
6b5151fd | 1733 | rc = lpfc_sli4_resume_rpi(ndlp, NULL, NULL); |
6fb120a7 JS |
1734 | if (rc) { |
1735 | /* Stay in state and retry. */ | |
1736 | ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; | |
1737 | return ndlp->nlp_state; | |
1738 | } | |
1739 | } | |
1740 | ||
00081c5c DK |
1741 | if (ndlp->nlp_type & NLP_FCP_TARGET) |
1742 | ndlp->nlp_fc4_type |= NLP_FC4_FCP; | |
1743 | ||
1744 | if (ndlp->nlp_type & NLP_NVME_TARGET) | |
1745 | ndlp->nlp_fc4_type |= NLP_FC4_NVME; | |
1746 | ||
1747 | if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET)) { | |
5024ab17 | 1748 | ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; |
2e0fef85 | 1749 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE); |
2501322e | 1750 | } else { |
5024ab17 | 1751 | ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; |
2e0fef85 | 1752 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); |
2501322e | 1753 | } |
6fb120a7 | 1754 | |
c9f8735b | 1755 | return ndlp->nlp_state; |
dea3101e | 1756 | } |
1757 | ||
1758 | static uint32_t | |
2e0fef85 JS |
1759 | lpfc_device_rm_adisc_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
1760 | void *arg, uint32_t evt) | |
dea3101e | 1761 | { |
92b99f1a JT |
1762 | if (test_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag)) { |
1763 | set_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); | |
a0f9b48d | 1764 | return ndlp->nlp_state; |
a0f9b48d | 1765 | } |
92b99f1a JT |
1766 | /* software abort outstanding ADISC */ |
1767 | lpfc_els_abort(vport->phba, ndlp); | |
1768 | ||
1769 | lpfc_drop_node(vport, ndlp); | |
1770 | return NLP_STE_FREED_NODE; | |
dea3101e | 1771 | } |
1772 | ||
1773 | static uint32_t | |
2e0fef85 JS |
1774 | lpfc_device_recov_adisc_issue(struct lpfc_vport *vport, |
1775 | struct lpfc_nodelist *ndlp, | |
1776 | void *arg, | |
1777 | uint32_t evt) | |
dea3101e | 1778 | { |
2e0fef85 JS |
1779 | struct lpfc_hba *phba = vport->phba; |
1780 | ||
bf81e9cd JT |
1781 | /* Don't do anything that disrupts the RSCN unless lpfc is unloading. */ |
1782 | if (lpfc_check_unload_and_clr_rscn(&vport->fc_flag)) | |
92d7f7b0 JS |
1783 | return ndlp->nlp_state; |
1784 | ||
dea3101e | 1785 | /* software abort outstanding ADISC */ |
07951076 | 1786 | lpfc_els_abort(phba, ndlp); |
dea3101e | 1787 | |
5024ab17 | 1788 | ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; |
2e0fef85 | 1789 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
92b99f1a JT |
1790 | clear_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); |
1791 | clear_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag); | |
92d7f7b0 | 1792 | lpfc_disc_set_adisc(vport, ndlp); |
c9f8735b | 1793 | return ndlp->nlp_state; |
dea3101e | 1794 | } |
1795 | ||
1796 | static uint32_t | |
2e0fef85 JS |
1797 | lpfc_rcv_plogi_reglogin_issue(struct lpfc_vport *vport, |
1798 | struct lpfc_nodelist *ndlp, | |
1799 | void *arg, | |
dea3101e | 1800 | uint32_t evt) |
1801 | { | |
2e0fef85 | 1802 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 1803 | |
2e0fef85 | 1804 | lpfc_rcv_plogi(vport, ndlp, cmdiocb); |
c9f8735b | 1805 | return ndlp->nlp_state; |
dea3101e | 1806 | } |
1807 | ||
1808 | static uint32_t | |
2e0fef85 JS |
1809 | lpfc_rcv_prli_reglogin_issue(struct lpfc_vport *vport, |
1810 | struct lpfc_nodelist *ndlp, | |
1811 | void *arg, | |
dea3101e | 1812 | uint32_t evt) |
1813 | { | |
2e0fef85 | 1814 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
8c258641 | 1815 | struct ls_rjt stat; |
dea3101e | 1816 | |
b95e29b7 JS |
1817 | if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb)) { |
1818 | return ndlp->nlp_state; | |
1819 | } | |
8c258641 JS |
1820 | if (vport->phba->nvmet_support) { |
1821 | /* NVME Target mode. Handle and respond to the PRLI and | |
1822 | * transition to UNMAPPED provided the RPI has completed | |
1823 | * registration. | |
1824 | */ | |
92b99f1a | 1825 | if (test_bit(NLP_RPI_REGISTERED, &ndlp->nlp_flag)) { |
8c258641 JS |
1826 | lpfc_rcv_prli(vport, ndlp, cmdiocb); |
1827 | lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp); | |
8c258641 JS |
1828 | } else { |
1829 | /* RPI registration has not completed. Reject the PRLI | |
1830 | * to prevent an illegal state transition when the | |
1831 | * rpi registration does complete. | |
1832 | */ | |
8c258641 | 1833 | memset(&stat, 0, sizeof(struct ls_rjt)); |
e06351a0 JS |
1834 | stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY; |
1835 | stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; | |
8c258641 JS |
1836 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, |
1837 | ndlp, NULL); | |
9de416ac | 1838 | return ndlp->nlp_state; |
8c258641 JS |
1839 | } |
1840 | } else { | |
1841 | /* Initiator mode. */ | |
1842 | lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp); | |
1843 | } | |
c9f8735b | 1844 | return ndlp->nlp_state; |
dea3101e | 1845 | } |
1846 | ||
1847 | static uint32_t | |
2e0fef85 JS |
1848 | lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport, |
1849 | struct lpfc_nodelist *ndlp, | |
1850 | void *arg, | |
dea3101e | 1851 | uint32_t evt) |
1852 | { | |
2e0fef85 JS |
1853 | struct lpfc_hba *phba = vport->phba; |
1854 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; | |
7054a606 JS |
1855 | LPFC_MBOXQ_t *mb; |
1856 | LPFC_MBOXQ_t *nextmb; | |
dea3101e | 1857 | |
1858 | cmdiocb = (struct lpfc_iocbq *) arg; | |
1859 | ||
7054a606 JS |
1860 | /* cleanup any ndlp on mbox q waiting for reglogin cmpl */ |
1861 | if ((mb = phba->sli.mbox_active)) { | |
04c68496 | 1862 | if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) && |
18f7fe44 | 1863 | (ndlp == mb->ctx_ndlp)) { |
92b99f1a | 1864 | clear_bit(NLP_REG_LOGIN_SEND, &ndlp->nlp_flag); |
92d7f7b0 | 1865 | lpfc_nlp_put(ndlp); |
3e1f0718 | 1866 | mb->ctx_ndlp = NULL; |
7054a606 JS |
1867 | mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
1868 | } | |
1869 | } | |
1870 | ||
2e0fef85 | 1871 | spin_lock_irq(&phba->hbalock); |
7054a606 | 1872 | list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { |
04c68496 | 1873 | if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) && |
18f7fe44 | 1874 | (ndlp == mb->ctx_ndlp)) { |
92b99f1a | 1875 | clear_bit(NLP_REG_LOGIN_SEND, &ndlp->nlp_flag); |
92d7f7b0 | 1876 | lpfc_nlp_put(ndlp); |
7054a606 | 1877 | list_del(&mb->list); |
5ffc266e | 1878 | phba->sli.mboxq_cnt--; |
ef47575f | 1879 | lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_LOCKED); |
7054a606 JS |
1880 | } |
1881 | } | |
2e0fef85 | 1882 | spin_unlock_irq(&phba->hbalock); |
7054a606 | 1883 | |
2e0fef85 | 1884 | lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO); |
c9f8735b | 1885 | return ndlp->nlp_state; |
dea3101e | 1886 | } |
1887 | ||
1888 | static uint32_t | |
2e0fef85 JS |
1889 | lpfc_rcv_padisc_reglogin_issue(struct lpfc_vport *vport, |
1890 | struct lpfc_nodelist *ndlp, | |
1891 | void *arg, | |
dea3101e | 1892 | uint32_t evt) |
1893 | { | |
2e0fef85 | 1894 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 1895 | |
2e0fef85 | 1896 | lpfc_rcv_padisc(vport, ndlp, cmdiocb); |
c9f8735b | 1897 | return ndlp->nlp_state; |
dea3101e | 1898 | } |
1899 | ||
1900 | static uint32_t | |
2e0fef85 JS |
1901 | lpfc_rcv_prlo_reglogin_issue(struct lpfc_vport *vport, |
1902 | struct lpfc_nodelist *ndlp, | |
1903 | void *arg, | |
dea3101e | 1904 | uint32_t evt) |
1905 | { | |
1906 | struct lpfc_iocbq *cmdiocb; | |
1907 | ||
1908 | cmdiocb = (struct lpfc_iocbq *) arg; | |
51ef4c26 | 1909 | lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL); |
c9f8735b | 1910 | return ndlp->nlp_state; |
dea3101e | 1911 | } |
1912 | ||
1913 | static uint32_t | |
2e0fef85 JS |
1914 | lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport, |
1915 | struct lpfc_nodelist *ndlp, | |
1916 | void *arg, | |
1917 | uint32_t evt) | |
dea3101e | 1918 | { |
a0f2d3ef | 1919 | struct lpfc_hba *phba = vport->phba; |
2e0fef85 | 1920 | LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg; |
04c68496 | 1921 | MAILBOX_t *mb = &pmb->u.mb; |
2e0fef85 | 1922 | uint32_t did = mb->un.varWords[1]; |
dea3101e | 1923 | |
dea3101e | 1924 | if (mb->mbxStatus) { |
1925 | /* RegLogin failed */ | |
372c187b DK |
1926 | lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, |
1927 | "0246 RegLogin failed Data: x%x x%x x%x x%x " | |
6d368e53 JS |
1928 | "x%x\n", |
1929 | did, mb->mbxStatus, vport->port_state, | |
1930 | mb->un.varRegLogin.vpi, | |
1931 | mb->un.varRegLogin.rpi); | |
d0e56dad JS |
1932 | /* |
1933 | * If RegLogin failed due to lack of HBA resources do not | |
1934 | * retry discovery. | |
1935 | */ | |
1936 | if (mb->mbxStatus == MBXERR_RPI_FULL) { | |
87af33fe JS |
1937 | ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; |
1938 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); | |
d0e56dad JS |
1939 | return ndlp->nlp_state; |
1940 | } | |
1941 | ||
2e0fef85 | 1942 | /* Put ndlp in npr state set plogi timer for 1 sec */ |
256ec0d0 | 1943 | mod_timer(&ndlp->nlp_delayfunc, |
84bbaeb0 | 1944 | jiffies + secs_to_jiffies(1)); |
92b99f1a | 1945 | set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag); |
5024ab17 | 1946 | ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; |
dea3101e | 1947 | |
2e0fef85 | 1948 | lpfc_issue_els_logo(vport, ndlp, 0); |
c9f8735b | 1949 | return ndlp->nlp_state; |
dea3101e | 1950 | } |
1951 | ||
6d368e53 | 1952 | /* SLI4 ports have preallocated logical rpis. */ |
a0f2d3ef | 1953 | if (phba->sli_rev < LPFC_SLI_REV4) |
6d368e53 JS |
1954 | ndlp->nlp_rpi = mb->un.varWords[0]; |
1955 | ||
92b99f1a | 1956 | set_bit(NLP_RPI_REGISTERED, &ndlp->nlp_flag); |
dea3101e | 1957 | |
1958 | /* Only if we are not a fabric nport do we issue PRLI */ | |
a0f2d3ef JS |
1959 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
1960 | "3066 RegLogin Complete on x%x x%x x%x\n", | |
1961 | did, ndlp->nlp_type, ndlp->nlp_fc4_type); | |
1962 | if (!(ndlp->nlp_type & NLP_FABRIC) && | |
1963 | (phba->nvmet_support == 0)) { | |
1964 | /* The driver supports FCP and NVME concurrently. If the | |
1965 | * ndlp's nlp_fc4_type is still zero, the driver doesn't | |
1966 | * know what PRLI to send yet. Figure that out now and | |
1967 | * call PRLI depending on the outcome. | |
1968 | */ | |
a645b8c1 | 1969 | if (test_bit(FC_PT2PT, &vport->fc_flag)) { |
a0f2d3ef JS |
1970 | /* If we are pt2pt, there is no Fabric to determine |
1971 | * the FC4 type of the remote nport. So if NVME | |
1972 | * is configured try it. | |
1973 | */ | |
1974 | ndlp->nlp_fc4_type |= NLP_FC4_FCP; | |
a645b8c1 | 1975 | if ((!test_bit(FC_PT2PT_NO_NVME, &vport->fc_flag)) && |
7f4c5a26 JS |
1976 | (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH || |
1977 | vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) { | |
a0f2d3ef JS |
1978 | ndlp->nlp_fc4_type |= NLP_FC4_NVME; |
1979 | /* We need to update the localport also */ | |
01649561 | 1980 | lpfc_nvme_update_localport(vport); |
a0f2d3ef JS |
1981 | } |
1982 | ||
2877cbff DK |
1983 | } else if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
1984 | ndlp->nlp_fc4_type |= NLP_FC4_FCP; | |
1985 | ||
a0f2d3ef | 1986 | } else if (ndlp->nlp_fc4_type == 0) { |
7ea92eb4 JS |
1987 | /* If we are only configured for FCP, the driver |
1988 | * should just issue PRLI for FCP. Otherwise issue | |
1989 | * GFT_ID to determine if remote port supports NVME. | |
1990 | */ | |
f6e84790 | 1991 | if (vport->cfg_enable_fc4_type != LPFC_ENABLE_FCP) { |
b27cbd55 BVA |
1992 | lpfc_ns_cmd(vport, SLI_CTNS_GFT_ID, 0, |
1993 | ndlp->nlp_DID); | |
7ea92eb4 JS |
1994 | return ndlp->nlp_state; |
1995 | } | |
1996 | ndlp->nlp_fc4_type = NLP_FC4_FCP; | |
a0f2d3ef JS |
1997 | } |
1998 | ||
5024ab17 | 1999 | ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; |
2e0fef85 | 2000 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE); |
7f20c1cb JS |
2001 | if (lpfc_issue_els_prli(vport, ndlp, 0)) { |
2002 | lpfc_issue_els_logo(vport, ndlp, 0); | |
2003 | ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; | |
2004 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); | |
2005 | } | |
dea3101e | 2006 | } else { |
a645b8c1 | 2007 | if (test_bit(FC_PT2PT, &vport->fc_flag) && phba->nvmet_support) |
8c258641 JS |
2008 | phba->targetport->port_id = vport->fc_myDID; |
2009 | ||
2010 | /* Only Fabric ports should transition. NVME target | |
2011 | * must complete PRLI. | |
2012 | */ | |
a0f2d3ef | 2013 | if (ndlp->nlp_type & NLP_FABRIC) { |
07aaefdf | 2014 | ndlp->nlp_fc4_type &= ~NLP_FC4_FCP; |
a0f2d3ef JS |
2015 | ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; |
2016 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); | |
2017 | } | |
dea3101e | 2018 | } |
c9f8735b | 2019 | return ndlp->nlp_state; |
dea3101e | 2020 | } |
2021 | ||
2022 | static uint32_t | |
2e0fef85 JS |
2023 | lpfc_device_rm_reglogin_issue(struct lpfc_vport *vport, |
2024 | struct lpfc_nodelist *ndlp, | |
2025 | void *arg, | |
dea3101e | 2026 | uint32_t evt) |
2027 | { | |
92b99f1a JT |
2028 | if (test_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag)) { |
2029 | set_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); | |
a0f9b48d | 2030 | return ndlp->nlp_state; |
a0f9b48d | 2031 | } |
92b99f1a JT |
2032 | lpfc_drop_node(vport, ndlp); |
2033 | return NLP_STE_FREED_NODE; | |
dea3101e | 2034 | } |
2035 | ||
2036 | static uint32_t | |
2e0fef85 JS |
2037 | lpfc_device_recov_reglogin_issue(struct lpfc_vport *vport, |
2038 | struct lpfc_nodelist *ndlp, | |
2039 | void *arg, | |
2040 | uint32_t evt) | |
dea3101e | 2041 | { |
bf81e9cd JT |
2042 | /* Don't do anything that disrupts the RSCN unless lpfc is unloading. */ |
2043 | if (lpfc_check_unload_and_clr_rscn(&vport->fc_flag)) | |
92d7f7b0 JS |
2044 | return ndlp->nlp_state; |
2045 | ||
5024ab17 | 2046 | ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; |
2e0fef85 | 2047 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
a0f2d3ef | 2048 | |
8c258641 JS |
2049 | /* If we are a target we won't immediately transition into PRLI, |
2050 | * so if REG_LOGIN already completed we don't need to ignore it. | |
2051 | */ | |
92b99f1a | 2052 | if (!test_bit(NLP_RPI_REGISTERED, &ndlp->nlp_flag) || |
8c258641 | 2053 | !vport->phba->nvmet_support) |
92b99f1a | 2054 | set_bit(NLP_IGNR_REG_CMPL, &ndlp->nlp_flag); |
8c258641 | 2055 | |
92b99f1a JT |
2056 | clear_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); |
2057 | clear_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag); | |
92d7f7b0 | 2058 | lpfc_disc_set_adisc(vport, ndlp); |
c9f8735b | 2059 | return ndlp->nlp_state; |
dea3101e | 2060 | } |
2061 | ||
2062 | static uint32_t | |
2e0fef85 JS |
2063 | lpfc_rcv_plogi_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2064 | void *arg, uint32_t evt) | |
dea3101e | 2065 | { |
2066 | struct lpfc_iocbq *cmdiocb; | |
2067 | ||
2068 | cmdiocb = (struct lpfc_iocbq *) arg; | |
2069 | ||
2e0fef85 | 2070 | lpfc_rcv_plogi(vport, ndlp, cmdiocb); |
c9f8735b | 2071 | return ndlp->nlp_state; |
dea3101e | 2072 | } |
2073 | ||
2074 | static uint32_t | |
2e0fef85 JS |
2075 | lpfc_rcv_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2076 | void *arg, uint32_t evt) | |
dea3101e | 2077 | { |
2e0fef85 | 2078 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2079 | |
b95e29b7 JS |
2080 | if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb)) |
2081 | return ndlp->nlp_state; | |
ecf041fe | 2082 | lpfc_rcv_prli(vport, ndlp, cmdiocb); |
2e0fef85 | 2083 | lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp); |
c9f8735b | 2084 | return ndlp->nlp_state; |
dea3101e | 2085 | } |
2086 | ||
2087 | static uint32_t | |
2e0fef85 JS |
2088 | lpfc_rcv_logo_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2089 | void *arg, uint32_t evt) | |
dea3101e | 2090 | { |
2e0fef85 | 2091 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2092 | |
2093 | /* Software abort outstanding PRLI before sending acc */ | |
2e0fef85 | 2094 | lpfc_els_abort(vport->phba, ndlp); |
dea3101e | 2095 | |
2e0fef85 | 2096 | lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO); |
c9f8735b | 2097 | return ndlp->nlp_state; |
dea3101e | 2098 | } |
2099 | ||
2100 | static uint32_t | |
2e0fef85 JS |
2101 | lpfc_rcv_padisc_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2102 | void *arg, uint32_t evt) | |
dea3101e | 2103 | { |
2e0fef85 | 2104 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2105 | |
2e0fef85 | 2106 | lpfc_rcv_padisc(vport, ndlp, cmdiocb); |
c9f8735b | 2107 | return ndlp->nlp_state; |
dea3101e | 2108 | } |
2109 | ||
2110 | /* This routine is envoked when we rcv a PRLO request from a nport | |
2111 | * we are logged into. We should send back a PRLO rsp setting the | |
2112 | * appropriate bits. | |
2113 | * NEXT STATE = PRLI_ISSUE | |
2114 | */ | |
2115 | static uint32_t | |
2e0fef85 JS |
2116 | lpfc_rcv_prlo_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2117 | void *arg, uint32_t evt) | |
dea3101e | 2118 | { |
2e0fef85 | 2119 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2120 | |
51ef4c26 | 2121 | lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL); |
c9f8735b | 2122 | return ndlp->nlp_state; |
dea3101e | 2123 | } |
2124 | ||
2125 | static uint32_t | |
2e0fef85 JS |
2126 | lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2127 | void *arg, uint32_t evt) | |
dea3101e | 2128 | { |
2129 | struct lpfc_iocbq *cmdiocb, *rspiocb; | |
2e0fef85 | 2130 | struct lpfc_hba *phba = vport->phba; |
dea3101e | 2131 | PRLI *npr; |
a0f2d3ef JS |
2132 | struct lpfc_nvme_prli *nvpr; |
2133 | void *temp_ptr; | |
cad93a08 | 2134 | u32 ulp_status; |
04c32001 | 2135 | bool acc_imode_sps = false; |
dea3101e | 2136 | |
2137 | cmdiocb = (struct lpfc_iocbq *) arg; | |
d51cf5bd | 2138 | rspiocb = cmdiocb->rsp_iocb; |
a0f2d3ef | 2139 | |
cad93a08 JS |
2140 | ulp_status = get_job_ulpstatus(phba, rspiocb); |
2141 | ||
a0f2d3ef JS |
2142 | /* A solicited PRLI is either FCP or NVME. The PRLI cmd/rsp |
2143 | * format is different so NULL the two PRLI types so that the | |
2144 | * driver correctly gets the correct context. | |
2145 | */ | |
2146 | npr = NULL; | |
2147 | nvpr = NULL; | |
2148 | temp_ptr = lpfc_check_elscmpl_iocb(phba, cmdiocb, rspiocb); | |
a680a929 | 2149 | if (cmdiocb->cmd_flag & LPFC_PRLI_FCP_REQ) |
a0f2d3ef | 2150 | npr = (PRLI *) temp_ptr; |
a680a929 | 2151 | else if (cmdiocb->cmd_flag & LPFC_PRLI_NVME_REQ) |
a0f2d3ef | 2152 | nvpr = (struct lpfc_nvme_prli *) temp_ptr; |
dea3101e | 2153 | |
cad93a08 | 2154 | if (ulp_status) { |
858c9f6c | 2155 | if ((vport->port_type == LPFC_NPIV_PORT) && |
3de2a653 | 2156 | vport->cfg_restrict_login) { |
858c9f6c JS |
2157 | goto out; |
2158 | } | |
a0f2d3ef | 2159 | |
118c0415 JS |
2160 | /* Adjust the nlp_type accordingly if the PRLI failed */ |
2161 | if (npr) | |
8db1c2b3 | 2162 | ndlp->nlp_fc4_type &= ~NLP_FC4_FCP; |
118c0415 JS |
2163 | if (nvpr) |
2164 | ndlp->nlp_fc4_type &= ~NLP_FC4_NVME; | |
8db1c2b3 | 2165 | |
118c0415 JS |
2166 | /* We can't set the DSM state till BOTH PRLIs complete */ |
2167 | goto out_err; | |
dea3101e | 2168 | } |
2169 | ||
04c32001 JT |
2170 | if (npr && npr->prliType == PRLI_FCP_TYPE) { |
2171 | lpfc_printf_vlog(vport, KERN_INFO, | |
2172 | LOG_ELS | LOG_NODE | LOG_DISCOVERY, | |
2173 | "6028 FCP NPR PRLI Cmpl Init %d Target %d " | |
2174 | "EIP %d AccCode x%x\n", | |
2175 | npr->initiatorFunc, npr->targetFunc, | |
2176 | npr->estabImagePair, npr->acceptRspCode); | |
2177 | ||
2178 | if (npr->acceptRspCode == PRLI_INV_SRV_PARM) { | |
2179 | /* Strict initiators don't establish an image pair. */ | |
2180 | if (npr->initiatorFunc && !npr->targetFunc && | |
2181 | !npr->estabImagePair) | |
2182 | acc_imode_sps = true; | |
3cb01c57 | 2183 | } |
a0f2d3ef | 2184 | |
04c32001 JT |
2185 | if (npr->acceptRspCode == PRLI_REQ_EXECUTED || acc_imode_sps) { |
2186 | if (npr->initiatorFunc) | |
2187 | ndlp->nlp_type |= NLP_FCP_INITIATOR; | |
2188 | if (npr->targetFunc) { | |
2189 | ndlp->nlp_type |= NLP_FCP_TARGET; | |
2190 | if (npr->writeXferRdyDis) | |
92b99f1a JT |
2191 | set_bit(NLP_FIRSTBURST, |
2192 | &ndlp->nlp_flag); | |
04c32001 JT |
2193 | } |
2194 | if (npr->Retry) | |
2195 | ndlp->nlp_fcp_info |= NLP_FCP_2_DEVICE; | |
2196 | } | |
a0f2d3ef JS |
2197 | } else if (nvpr && |
2198 | (bf_get_be32(prli_acc_rsp_code, nvpr) == | |
2199 | PRLI_REQ_EXECUTED) && | |
2200 | (bf_get_be32(prli_type_code, nvpr) == | |
2201 | PRLI_NVME_TYPE)) { | |
2202 | ||
2203 | /* Complete setting up the remote ndlp personality. */ | |
2204 | if (bf_get_be32(prli_init, nvpr)) | |
2205 | ndlp->nlp_type |= NLP_NVME_INITIATOR; | |
2206 | ||
69641627 JS |
2207 | if (phba->nsler && bf_get_be32(prli_nsler, nvpr) && |
2208 | bf_get_be32(prli_conf, nvpr)) | |
2209 | ||
0d8af096 JS |
2210 | ndlp->nlp_nvme_info |= NLP_NVME_NSLER; |
2211 | else | |
2212 | ndlp->nlp_nvme_info &= ~NLP_NVME_NSLER; | |
2213 | ||
a0f2d3ef JS |
2214 | /* Target driver cannot solicit NVME FB. */ |
2215 | if (bf_get_be32(prli_tgt, nvpr)) { | |
dc53a618 JS |
2216 | /* Complete the nvme target roles. The transport |
2217 | * needs to know if the rport is capable of | |
2218 | * discovery in addition to its role. | |
2219 | */ | |
a0f2d3ef | 2220 | ndlp->nlp_type |= NLP_NVME_TARGET; |
dc53a618 JS |
2221 | if (bf_get_be32(prli_disc, nvpr)) |
2222 | ndlp->nlp_type |= NLP_NVME_DISCOVERY; | |
0709263a JS |
2223 | |
2224 | /* | |
2225 | * If prli_fba is set, the Target supports FirstBurst. | |
2226 | * If prli_fb_sz is 0, the FirstBurst size is unlimited, | |
2227 | * otherwise it defines the actual size supported by | |
2228 | * the NVME Target. | |
2229 | */ | |
a0f2d3ef | 2230 | if ((bf_get_be32(prli_fba, nvpr) == 1) && |
a0f2d3ef JS |
2231 | (phba->cfg_nvme_enable_fb) && |
2232 | (!phba->nvmet_support)) { | |
2233 | /* Both sides support FB. The target's first | |
2234 | * burst size is a 512 byte encoded value. | |
2235 | */ | |
92b99f1a | 2236 | set_bit(NLP_FIRSTBURST, &ndlp->nlp_flag); |
a0f2d3ef JS |
2237 | ndlp->nvme_fb_size = bf_get_be32(prli_fb_sz, |
2238 | nvpr); | |
0709263a JS |
2239 | |
2240 | /* Expressed in units of 512 bytes */ | |
2241 | if (ndlp->nvme_fb_size) | |
2242 | ndlp->nvme_fb_size <<= | |
2243 | LPFC_NVME_FB_SHIFT; | |
2244 | else | |
2245 | ndlp->nvme_fb_size = LPFC_NVME_MAX_FB; | |
a0f2d3ef JS |
2246 | } |
2247 | } | |
2248 | ||
a0f2d3ef JS |
2249 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC, |
2250 | "6029 NVME PRLI Cmpl w1 x%08x " | |
92b99f1a | 2251 | "w4 x%08x w5 x%08x flag x%lx, " |
a0f2d3ef JS |
2252 | "fcp_info x%x nlp_type x%x\n", |
2253 | be32_to_cpu(nvpr->word1), | |
2254 | be32_to_cpu(nvpr->word4), | |
2255 | be32_to_cpu(nvpr->word5), | |
2256 | ndlp->nlp_flag, ndlp->nlp_fcp_info, | |
2257 | ndlp->nlp_type); | |
dea3101e | 2258 | } |
92d7f7b0 JS |
2259 | if (!(ndlp->nlp_type & NLP_FCP_TARGET) && |
2260 | (vport->port_type == LPFC_NPIV_PORT) && | |
3de2a653 | 2261 | vport->cfg_restrict_login) { |
858c9f6c | 2262 | out: |
bb33b07a JT |
2263 | lpfc_printf_vlog(vport, KERN_INFO, |
2264 | LOG_ELS | LOG_DISCOVERY | LOG_NODE, | |
2265 | "6228 Sending LOGO, determined nlp_type " | |
2266 | "0x%x nlp_flag x%lx refcnt %u\n", | |
2267 | ndlp->nlp_type, ndlp->nlp_flag, | |
2268 | kref_read(&ndlp->kref)); | |
92d7f7b0 | 2269 | lpfc_issue_els_logo(vport, ndlp, 0); |
92d7f7b0 JS |
2270 | return ndlp->nlp_state; |
2271 | } | |
dea3101e | 2272 | |
a0f2d3ef JS |
2273 | out_err: |
2274 | /* The ndlp state cannot move to MAPPED or UNMAPPED before all PRLIs | |
2275 | * are complete. | |
2276 | */ | |
2277 | if (ndlp->fc4_prli_sent == 0) { | |
2278 | ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; | |
2279 | if (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET)) | |
2280 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_MAPPED_NODE); | |
9de416ac JS |
2281 | else if (ndlp->nlp_type & |
2282 | (NLP_FCP_INITIATOR | NLP_NVME_INITIATOR)) | |
a0f2d3ef JS |
2283 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); |
2284 | } else | |
2285 | lpfc_printf_vlog(vport, | |
2286 | KERN_INFO, LOG_ELS, | |
2287 | "3067 PRLI's still outstanding " | |
2288 | "on x%06x - count %d, Pend Node Mode " | |
2289 | "transition...\n", | |
2290 | ndlp->nlp_DID, ndlp->fc4_prli_sent); | |
2291 | ||
c9f8735b | 2292 | return ndlp->nlp_state; |
dea3101e | 2293 | } |
2294 | ||
2295 | /*! lpfc_device_rm_prli_issue | |
92d7f7b0 JS |
2296 | * |
2297 | * \pre | |
2298 | * \post | |
2299 | * \param phba | |
2300 | * \param ndlp | |
2301 | * \param arg | |
2302 | * \param evt | |
2303 | * \return uint32_t | |
2304 | * | |
2305 | * \b Description: | |
2306 | * This routine is envoked when we a request to remove a nport we are in the | |
2307 | * process of PRLIing. We should software abort outstanding prli, unreg | |
2308 | * login, send a logout. We will change node state to UNUSED_NODE, put it | |
2309 | * on plogi list so it can be freed when LOGO completes. | |
2310 | * | |
2311 | */ | |
2312 | ||
dea3101e | 2313 | static uint32_t |
2e0fef85 JS |
2314 | lpfc_device_rm_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2315 | void *arg, uint32_t evt) | |
dea3101e | 2316 | { |
92b99f1a JT |
2317 | if (test_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag)) { |
2318 | set_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); | |
a0f9b48d | 2319 | return ndlp->nlp_state; |
a0f9b48d | 2320 | } |
92b99f1a JT |
2321 | /* software abort outstanding PLOGI */ |
2322 | lpfc_els_abort(vport->phba, ndlp); | |
2323 | ||
2324 | lpfc_drop_node(vport, ndlp); | |
2325 | return NLP_STE_FREED_NODE; | |
dea3101e | 2326 | } |
2327 | ||
2328 | ||
2329 | /*! lpfc_device_recov_prli_issue | |
92d7f7b0 JS |
2330 | * |
2331 | * \pre | |
2332 | * \post | |
2333 | * \param phba | |
2334 | * \param ndlp | |
2335 | * \param arg | |
2336 | * \param evt | |
2337 | * \return uint32_t | |
2338 | * | |
2339 | * \b Description: | |
2340 | * The routine is envoked when the state of a device is unknown, like | |
2341 | * during a link down. We should remove the nodelist entry from the | |
2342 | * unmapped list, issue a UNREG_LOGIN, do a software abort of the | |
2343 | * outstanding PRLI command, then free the node entry. | |
2344 | */ | |
dea3101e | 2345 | static uint32_t |
2e0fef85 JS |
2346 | lpfc_device_recov_prli_issue(struct lpfc_vport *vport, |
2347 | struct lpfc_nodelist *ndlp, | |
2348 | void *arg, | |
2349 | uint32_t evt) | |
dea3101e | 2350 | { |
2e0fef85 JS |
2351 | struct lpfc_hba *phba = vport->phba; |
2352 | ||
bf81e9cd JT |
2353 | /* Don't do anything that disrupts the RSCN unless lpfc is unloading. */ |
2354 | if (lpfc_check_unload_and_clr_rscn(&vport->fc_flag)) | |
92d7f7b0 JS |
2355 | return ndlp->nlp_state; |
2356 | ||
dea3101e | 2357 | /* software abort outstanding PRLI */ |
07951076 | 2358 | lpfc_els_abort(phba, ndlp); |
dea3101e | 2359 | |
5024ab17 | 2360 | ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; |
2e0fef85 | 2361 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
92b99f1a JT |
2362 | clear_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); |
2363 | clear_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag); | |
92d7f7b0 | 2364 | lpfc_disc_set_adisc(vport, ndlp); |
c9f8735b | 2365 | return ndlp->nlp_state; |
dea3101e | 2366 | } |
2367 | ||
086a345f JS |
2368 | static uint32_t |
2369 | lpfc_rcv_plogi_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
2370 | void *arg, uint32_t evt) | |
2371 | { | |
2372 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg; | |
2373 | struct ls_rjt stat; | |
2374 | ||
2375 | memset(&stat, 0, sizeof(struct ls_rjt)); | |
2376 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; | |
2377 | stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; | |
2378 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); | |
2379 | return ndlp->nlp_state; | |
2380 | } | |
2381 | ||
2382 | static uint32_t | |
2383 | lpfc_rcv_prli_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
2384 | void *arg, uint32_t evt) | |
2385 | { | |
2386 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg; | |
2387 | struct ls_rjt stat; | |
2388 | ||
2389 | memset(&stat, 0, sizeof(struct ls_rjt)); | |
2390 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; | |
2391 | stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; | |
2392 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); | |
2393 | return ndlp->nlp_state; | |
2394 | } | |
2395 | ||
2396 | static uint32_t | |
2397 | lpfc_rcv_logo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
2398 | void *arg, uint32_t evt) | |
2399 | { | |
086a345f JS |
2400 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg; |
2401 | ||
92b99f1a | 2402 | set_bit(NLP_LOGO_ACC, &ndlp->nlp_flag); |
086a345f JS |
2403 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
2404 | return ndlp->nlp_state; | |
2405 | } | |
2406 | ||
2407 | static uint32_t | |
2408 | lpfc_rcv_padisc_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
2409 | void *arg, uint32_t evt) | |
2410 | { | |
2411 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg; | |
2412 | struct ls_rjt stat; | |
2413 | ||
2414 | memset(&stat, 0, sizeof(struct ls_rjt)); | |
2415 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; | |
2416 | stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; | |
2417 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); | |
2418 | return ndlp->nlp_state; | |
2419 | } | |
2420 | ||
2421 | static uint32_t | |
2422 | lpfc_rcv_prlo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
2423 | void *arg, uint32_t evt) | |
2424 | { | |
2425 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *)arg; | |
2426 | struct ls_rjt stat; | |
2427 | ||
2428 | memset(&stat, 0, sizeof(struct ls_rjt)); | |
2429 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; | |
2430 | stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; | |
2431 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); | |
2432 | return ndlp->nlp_state; | |
2433 | } | |
2434 | ||
2435 | static uint32_t | |
2436 | lpfc_cmpl_logo_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
2437 | void *arg, uint32_t evt) | |
2438 | { | |
086a345f JS |
2439 | ndlp->nlp_prev_state = NLP_STE_LOGO_ISSUE; |
2440 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); | |
92b99f1a JT |
2441 | clear_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); |
2442 | clear_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag); | |
086a345f JS |
2443 | lpfc_disc_set_adisc(vport, ndlp); |
2444 | return ndlp->nlp_state; | |
2445 | } | |
2446 | ||
2447 | static uint32_t | |
2448 | lpfc_device_rm_logo_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |
2449 | void *arg, uint32_t evt) | |
2450 | { | |
2451 | /* | |
d2aa4876 DK |
2452 | * DevLoss has timed out and is calling for Device Remove. |
2453 | * In this case, abort the LOGO and cleanup the ndlp | |
086a345f | 2454 | */ |
d2aa4876 DK |
2455 | |
2456 | lpfc_unreg_rpi(vport, ndlp); | |
2457 | /* software abort outstanding PLOGI */ | |
2458 | lpfc_els_abort(vport->phba, ndlp); | |
2459 | lpfc_drop_node(vport, ndlp); | |
2460 | return NLP_STE_FREED_NODE; | |
086a345f JS |
2461 | } |
2462 | ||
2463 | static uint32_t | |
2464 | lpfc_device_recov_logo_issue(struct lpfc_vport *vport, | |
2465 | struct lpfc_nodelist *ndlp, | |
2466 | void *arg, uint32_t evt) | |
2467 | { | |
2468 | /* | |
2469 | * Device Recovery events have no meaning for a node with a LOGO | |
2470 | * outstanding. The LOGO has to complete first and handle the | |
2471 | * node from that point. | |
2472 | */ | |
2473 | return ndlp->nlp_state; | |
2474 | } | |
2475 | ||
dea3101e | 2476 | static uint32_t |
2e0fef85 JS |
2477 | lpfc_rcv_plogi_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2478 | void *arg, uint32_t evt) | |
dea3101e | 2479 | { |
2e0fef85 | 2480 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2481 | |
2e0fef85 | 2482 | lpfc_rcv_plogi(vport, ndlp, cmdiocb); |
c9f8735b | 2483 | return ndlp->nlp_state; |
dea3101e | 2484 | } |
2485 | ||
2486 | static uint32_t | |
2e0fef85 JS |
2487 | lpfc_rcv_prli_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2488 | void *arg, uint32_t evt) | |
dea3101e | 2489 | { |
2e0fef85 | 2490 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2491 | |
b95e29b7 JS |
2492 | if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb)) |
2493 | return ndlp->nlp_state; | |
2494 | ||
2e0fef85 JS |
2495 | lpfc_rcv_prli(vport, ndlp, cmdiocb); |
2496 | lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp); | |
c9f8735b | 2497 | return ndlp->nlp_state; |
dea3101e | 2498 | } |
2499 | ||
2500 | static uint32_t | |
2e0fef85 JS |
2501 | lpfc_rcv_logo_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2502 | void *arg, uint32_t evt) | |
dea3101e | 2503 | { |
2e0fef85 | 2504 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2505 | |
2e0fef85 | 2506 | lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO); |
c9f8735b | 2507 | return ndlp->nlp_state; |
dea3101e | 2508 | } |
2509 | ||
2510 | static uint32_t | |
2e0fef85 JS |
2511 | lpfc_rcv_padisc_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2512 | void *arg, uint32_t evt) | |
dea3101e | 2513 | { |
2e0fef85 | 2514 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2515 | |
2e0fef85 | 2516 | lpfc_rcv_padisc(vport, ndlp, cmdiocb); |
c9f8735b | 2517 | return ndlp->nlp_state; |
dea3101e | 2518 | } |
2519 | ||
2520 | static uint32_t | |
2e0fef85 JS |
2521 | lpfc_rcv_prlo_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2522 | void *arg, uint32_t evt) | |
dea3101e | 2523 | { |
2e0fef85 | 2524 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2525 | |
51ef4c26 | 2526 | lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL); |
c9f8735b | 2527 | return ndlp->nlp_state; |
dea3101e | 2528 | } |
2529 | ||
debbc1e2 JS |
2530 | static uint32_t |
2531 | lpfc_device_rm_unmap_node(struct lpfc_vport *vport, | |
2532 | struct lpfc_nodelist *ndlp, | |
2533 | void *arg, | |
2534 | uint32_t evt) | |
2535 | { | |
2536 | lpfc_drop_node(vport, ndlp); | |
2537 | return NLP_STE_FREED_NODE; | |
2538 | } | |
2539 | ||
dea3101e | 2540 | static uint32_t |
2e0fef85 JS |
2541 | lpfc_device_recov_unmap_node(struct lpfc_vport *vport, |
2542 | struct lpfc_nodelist *ndlp, | |
2543 | void *arg, | |
2544 | uint32_t evt) | |
dea3101e | 2545 | { |
5024ab17 | 2546 | ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE; |
2e0fef85 | 2547 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
92b99f1a JT |
2548 | clear_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); |
2549 | clear_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag); | |
c6adba15 | 2550 | spin_lock_irq(&ndlp->lock); |
01a8aed6 | 2551 | ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME); |
c6adba15 | 2552 | spin_unlock_irq(&ndlp->lock); |
2e0fef85 | 2553 | lpfc_disc_set_adisc(vport, ndlp); |
dea3101e | 2554 | |
c9f8735b | 2555 | return ndlp->nlp_state; |
dea3101e | 2556 | } |
2557 | ||
2558 | static uint32_t | |
2e0fef85 JS |
2559 | lpfc_rcv_plogi_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2560 | void *arg, uint32_t evt) | |
dea3101e | 2561 | { |
2e0fef85 | 2562 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2563 | |
2e0fef85 | 2564 | lpfc_rcv_plogi(vport, ndlp, cmdiocb); |
c9f8735b | 2565 | return ndlp->nlp_state; |
dea3101e | 2566 | } |
2567 | ||
2568 | static uint32_t | |
2e0fef85 JS |
2569 | lpfc_rcv_prli_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2570 | void *arg, uint32_t evt) | |
dea3101e | 2571 | { |
2e0fef85 | 2572 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2573 | |
b95e29b7 JS |
2574 | if (!lpfc_rcv_prli_support_check(vport, ndlp, cmdiocb)) |
2575 | return ndlp->nlp_state; | |
2e0fef85 | 2576 | lpfc_els_rsp_prli_acc(vport, cmdiocb, ndlp); |
c9f8735b | 2577 | return ndlp->nlp_state; |
dea3101e | 2578 | } |
2579 | ||
2580 | static uint32_t | |
2e0fef85 JS |
2581 | lpfc_rcv_logo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2582 | void *arg, uint32_t evt) | |
dea3101e | 2583 | { |
2e0fef85 | 2584 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2585 | |
2e0fef85 | 2586 | lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO); |
c9f8735b | 2587 | return ndlp->nlp_state; |
dea3101e | 2588 | } |
2589 | ||
2590 | static uint32_t | |
2e0fef85 JS |
2591 | lpfc_rcv_padisc_mapped_node(struct lpfc_vport *vport, |
2592 | struct lpfc_nodelist *ndlp, | |
2593 | void *arg, uint32_t evt) | |
dea3101e | 2594 | { |
2e0fef85 | 2595 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2596 | |
2e0fef85 | 2597 | lpfc_rcv_padisc(vport, ndlp, cmdiocb); |
c9f8735b | 2598 | return ndlp->nlp_state; |
dea3101e | 2599 | } |
2600 | ||
2601 | static uint32_t | |
2e0fef85 JS |
2602 | lpfc_rcv_prlo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2603 | void *arg, uint32_t evt) | |
dea3101e | 2604 | { |
2e0fef85 | 2605 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2606 | |
2607 | /* flush the target */ | |
078c68b8 | 2608 | lpfc_sli_abort_iocb(vport, ndlp->nlp_sid, 0, LPFC_CTX_TGT); |
dea3101e | 2609 | |
1f0f7679 | 2610 | /* Send PRLO_ACC */ |
92b99f1a | 2611 | set_bit(NLP_LOGO_ACC, &ndlp->nlp_flag); |
1f0f7679 JT |
2612 | lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL); |
2613 | ||
2614 | /* Save ELS_CMD_PRLO as the last elscmd and then set to NPR. | |
2615 | * lpfc_cmpl_els_logo_acc is expected to restart discovery. | |
2616 | */ | |
2617 | ndlp->nlp_last_elscmd = ELS_CMD_PRLO; | |
2618 | ndlp->nlp_prev_state = ndlp->nlp_state; | |
2619 | ||
2620 | lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE | LOG_ELS | LOG_DISCOVERY, | |
92b99f1a | 2621 | "3422 DID x%06x nflag x%lx lastels x%x ref cnt %u\n", |
1f0f7679 JT |
2622 | ndlp->nlp_DID, ndlp->nlp_flag, |
2623 | ndlp->nlp_last_elscmd, | |
2624 | kref_read(&ndlp->kref)); | |
2625 | ||
2626 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); | |
2627 | ||
c9f8735b | 2628 | return ndlp->nlp_state; |
dea3101e | 2629 | } |
2630 | ||
2631 | static uint32_t | |
2e0fef85 JS |
2632 | lpfc_device_recov_mapped_node(struct lpfc_vport *vport, |
2633 | struct lpfc_nodelist *ndlp, | |
2634 | void *arg, | |
2635 | uint32_t evt) | |
dea3101e | 2636 | { |
06145683 JS |
2637 | lpfc_disc_set_adisc(vport, ndlp); |
2638 | ||
5024ab17 | 2639 | ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE; |
2e0fef85 | 2640 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
92b99f1a JT |
2641 | clear_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); |
2642 | clear_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag); | |
c6adba15 | 2643 | spin_lock_irq(&ndlp->lock); |
01a8aed6 | 2644 | ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME); |
c6adba15 | 2645 | spin_unlock_irq(&ndlp->lock); |
c9f8735b | 2646 | return ndlp->nlp_state; |
dea3101e | 2647 | } |
2648 | ||
2649 | static uint32_t | |
2e0fef85 JS |
2650 | lpfc_rcv_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2651 | void *arg, uint32_t evt) | |
dea3101e | 2652 | { |
2e0fef85 | 2653 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2654 | |
2655 | /* Ignore PLOGI if we have an outstanding LOGO */ | |
92b99f1a JT |
2656 | if (test_bit(NLP_LOGO_SND, &ndlp->nlp_flag) || |
2657 | test_bit(NLP_LOGO_ACC, &ndlp->nlp_flag)) | |
c9f8735b | 2658 | return ndlp->nlp_state; |
2e0fef85 | 2659 | if (lpfc_rcv_plogi(vport, ndlp, cmdiocb)) { |
0d2b6b83 | 2660 | lpfc_cancel_retry_delay_tmo(vport, ndlp); |
92b99f1a JT |
2661 | clear_bit(NLP_NPR_ADISC, &ndlp->nlp_flag); |
2662 | clear_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag); | |
2663 | } else if (!test_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag)) { | |
0d2b6b83 | 2664 | /* send PLOGI immediately, move to PLOGI issue state */ |
92b99f1a | 2665 | if (!test_bit(NLP_DELAY_TMO, &ndlp->nlp_flag)) { |
0d2b6b83 JS |
2666 | ndlp->nlp_prev_state = NLP_STE_NPR_NODE; |
2667 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); | |
2668 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); | |
2669 | } | |
dea3101e | 2670 | } |
c9f8735b | 2671 | return ndlp->nlp_state; |
dea3101e | 2672 | } |
2673 | ||
2674 | static uint32_t | |
2e0fef85 JS |
2675 | lpfc_rcv_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2676 | void *arg, uint32_t evt) | |
dea3101e | 2677 | { |
2e0fef85 JS |
2678 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
2679 | struct ls_rjt stat; | |
dea3101e | 2680 | |
2681 | memset(&stat, 0, sizeof (struct ls_rjt)); | |
2682 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; | |
2683 | stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; | |
858c9f6c | 2684 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
dea3101e | 2685 | |
92b99f1a | 2686 | if (!test_bit(NLP_DELAY_TMO, &ndlp->nlp_flag)) { |
ab803860 JS |
2687 | /* |
2688 | * ADISC nodes will be handled in regular discovery path after | |
2689 | * receiving response from NS. | |
2690 | * | |
2691 | * For other nodes, Send PLOGI to trigger an implicit LOGO. | |
2692 | */ | |
92b99f1a | 2693 | if (!test_bit(NLP_NPR_ADISC, &ndlp->nlp_flag)) { |
5024ab17 | 2694 | ndlp->nlp_prev_state = NLP_STE_NPR_NODE; |
2e0fef85 JS |
2695 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
2696 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); | |
dea3101e | 2697 | } |
2698 | } | |
c9f8735b | 2699 | return ndlp->nlp_state; |
dea3101e | 2700 | } |
2701 | ||
2702 | static uint32_t | |
2e0fef85 JS |
2703 | lpfc_rcv_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2704 | void *arg, uint32_t evt) | |
dea3101e | 2705 | { |
2e0fef85 | 2706 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2707 | |
2e0fef85 | 2708 | lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_LOGO); |
c9f8735b | 2709 | return ndlp->nlp_state; |
dea3101e | 2710 | } |
2711 | ||
2712 | static uint32_t | |
2e0fef85 JS |
2713 | lpfc_rcv_padisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2714 | void *arg, uint32_t evt) | |
dea3101e | 2715 | { |
2e0fef85 | 2716 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2717 | |
2e0fef85 | 2718 | lpfc_rcv_padisc(vport, ndlp, cmdiocb); |
33ccf8d1 JS |
2719 | /* |
2720 | * Do not start discovery if discovery is about to start | |
2721 | * or discovery in progress for this node. Starting discovery | |
2722 | * here will affect the counting of discovery threads. | |
2723 | */ | |
92b99f1a JT |
2724 | if (!test_bit(NLP_DELAY_TMO, &ndlp->nlp_flag) && |
2725 | !test_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag)) { | |
ab803860 JS |
2726 | /* |
2727 | * ADISC nodes will be handled in regular discovery path after | |
2728 | * receiving response from NS. | |
2729 | * | |
2730 | * For other nodes, Send PLOGI to trigger an implicit LOGO. | |
2731 | */ | |
92b99f1a | 2732 | if (!test_bit(NLP_NPR_ADISC, &ndlp->nlp_flag)) { |
5024ab17 | 2733 | ndlp->nlp_prev_state = NLP_STE_NPR_NODE; |
2e0fef85 JS |
2734 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
2735 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); | |
dea3101e | 2736 | } |
2737 | } | |
c9f8735b | 2738 | return ndlp->nlp_state; |
dea3101e | 2739 | } |
2740 | ||
2741 | static uint32_t | |
2e0fef85 JS |
2742 | lpfc_rcv_prlo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2743 | void *arg, uint32_t evt) | |
dea3101e | 2744 | { |
2e0fef85 | 2745 | struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; |
dea3101e | 2746 | |
92b99f1a | 2747 | set_bit(NLP_LOGO_ACC, &ndlp->nlp_flag); |
c9f8735b | 2748 | |
51ef4c26 | 2749 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
dea3101e | 2750 | |
92b99f1a | 2751 | if (!test_bit(NLP_DELAY_TMO, &ndlp->nlp_flag)) { |
256ec0d0 | 2752 | mod_timer(&ndlp->nlp_delayfunc, |
84bbaeb0 | 2753 | jiffies + secs_to_jiffies(1)); |
92b99f1a JT |
2754 | set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag); |
2755 | clear_bit(NLP_NPR_ADISC, &ndlp->nlp_flag); | |
5024ab17 | 2756 | ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; |
c9f8735b | 2757 | } else { |
92b99f1a | 2758 | clear_bit(NLP_NPR_ADISC, &ndlp->nlp_flag); |
dea3101e | 2759 | } |
c9f8735b JW |
2760 | return ndlp->nlp_state; |
2761 | } | |
dea3101e | 2762 | |
c9f8735b | 2763 | static uint32_t |
2e0fef85 JS |
2764 | lpfc_cmpl_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2765 | void *arg, uint32_t evt) | |
c9f8735b | 2766 | { |
cad93a08 | 2767 | struct lpfc_hba *phba = vport->phba; |
c9f8735b | 2768 | struct lpfc_iocbq *cmdiocb, *rspiocb; |
cad93a08 | 2769 | u32 ulp_status; |
c9f8735b JW |
2770 | |
2771 | cmdiocb = (struct lpfc_iocbq *) arg; | |
d51cf5bd | 2772 | rspiocb = cmdiocb->rsp_iocb; |
a0f9b48d | 2773 | |
cad93a08 JS |
2774 | ulp_status = get_job_ulpstatus(phba, rspiocb); |
2775 | ||
2776 | if (ulp_status) | |
a0f9b48d | 2777 | return NLP_STE_FREED_NODE; |
cad93a08 | 2778 | |
c9f8735b JW |
2779 | return ndlp->nlp_state; |
2780 | } | |
2781 | ||
2782 | static uint32_t | |
2e0fef85 JS |
2783 | lpfc_cmpl_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2784 | void *arg, uint32_t evt) | |
c9f8735b | 2785 | { |
cad93a08 | 2786 | struct lpfc_hba *phba = vport->phba; |
c9f8735b | 2787 | struct lpfc_iocbq *cmdiocb, *rspiocb; |
cad93a08 | 2788 | u32 ulp_status; |
c9f8735b JW |
2789 | |
2790 | cmdiocb = (struct lpfc_iocbq *) arg; | |
d51cf5bd | 2791 | rspiocb = cmdiocb->rsp_iocb; |
a0f9b48d | 2792 | |
cad93a08 JS |
2793 | ulp_status = get_job_ulpstatus(phba, rspiocb); |
2794 | ||
92b99f1a | 2795 | if (ulp_status && test_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag)) { |
2e0fef85 | 2796 | lpfc_drop_node(vport, ndlp); |
a0f9b48d JS |
2797 | return NLP_STE_FREED_NODE; |
2798 | } | |
c9f8735b | 2799 | return ndlp->nlp_state; |
dea3101e | 2800 | } |
2801 | ||
2802 | static uint32_t | |
2e0fef85 JS |
2803 | lpfc_cmpl_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2804 | void *arg, uint32_t evt) | |
dea3101e | 2805 | { |
086a345f | 2806 | /* For the fabric port just clear the fc flags. */ |
d7c255b2 | 2807 | if (ndlp->nlp_DID == Fabric_DID) { |
a645b8c1 JT |
2808 | clear_bit(FC_FABRIC, &vport->fc_flag); |
2809 | clear_bit(FC_PUBLIC_LOOP, &vport->fc_flag); | |
d7c255b2 | 2810 | } |
2e0fef85 | 2811 | lpfc_unreg_rpi(vport, ndlp); |
c9f8735b JW |
2812 | return ndlp->nlp_state; |
2813 | } | |
2814 | ||
2815 | static uint32_t | |
2e0fef85 JS |
2816 | lpfc_cmpl_adisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2817 | void *arg, uint32_t evt) | |
c9f8735b | 2818 | { |
cad93a08 | 2819 | struct lpfc_hba *phba = vport->phba; |
c9f8735b | 2820 | struct lpfc_iocbq *cmdiocb, *rspiocb; |
cad93a08 | 2821 | u32 ulp_status; |
c9f8735b JW |
2822 | |
2823 | cmdiocb = (struct lpfc_iocbq *) arg; | |
d51cf5bd | 2824 | rspiocb = cmdiocb->rsp_iocb; |
a0f9b48d | 2825 | |
cad93a08 JS |
2826 | ulp_status = get_job_ulpstatus(phba, rspiocb); |
2827 | ||
92b99f1a | 2828 | if (ulp_status && test_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag)) { |
2e0fef85 | 2829 | lpfc_drop_node(vport, ndlp); |
a0f9b48d JS |
2830 | return NLP_STE_FREED_NODE; |
2831 | } | |
c9f8735b | 2832 | return ndlp->nlp_state; |
dea3101e | 2833 | } |
2834 | ||
2835 | static uint32_t | |
2e0fef85 JS |
2836 | lpfc_cmpl_reglogin_npr_node(struct lpfc_vport *vport, |
2837 | struct lpfc_nodelist *ndlp, | |
2838 | void *arg, uint32_t evt) | |
dea3101e | 2839 | { |
2e0fef85 | 2840 | LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg; |
04c68496 | 2841 | MAILBOX_t *mb = &pmb->u.mb; |
dea3101e | 2842 | |
04c68496 | 2843 | if (!mb->mbxStatus) { |
6d368e53 JS |
2844 | /* SLI4 ports have preallocated logical rpis. */ |
2845 | if (vport->phba->sli_rev < LPFC_SLI_REV4) | |
2846 | ndlp->nlp_rpi = mb->un.varWords[0]; | |
92b99f1a JT |
2847 | set_bit(NLP_RPI_REGISTERED, &ndlp->nlp_flag); |
2848 | if (test_bit(NLP_LOGO_ACC, &ndlp->nlp_flag)) | |
4b7789b7 | 2849 | lpfc_unreg_rpi(vport, ndlp); |
04c68496 | 2850 | } else { |
92b99f1a | 2851 | if (test_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag)) { |
2e0fef85 | 2852 | lpfc_drop_node(vport, ndlp); |
a0f9b48d JS |
2853 | return NLP_STE_FREED_NODE; |
2854 | } | |
2855 | } | |
c9f8735b | 2856 | return ndlp->nlp_state; |
dea3101e | 2857 | } |
2858 | ||
2859 | static uint32_t | |
2e0fef85 JS |
2860 | lpfc_device_rm_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2861 | void *arg, uint32_t evt) | |
dea3101e | 2862 | { |
92b99f1a JT |
2863 | if (test_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag)) { |
2864 | set_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); | |
a0f9b48d JS |
2865 | return ndlp->nlp_state; |
2866 | } | |
2e0fef85 | 2867 | lpfc_drop_node(vport, ndlp); |
c9f8735b | 2868 | return NLP_STE_FREED_NODE; |
dea3101e | 2869 | } |
2870 | ||
2871 | static uint32_t | |
2e0fef85 JS |
2872 | lpfc_device_recov_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
2873 | void *arg, uint32_t evt) | |
dea3101e | 2874 | { |
bf81e9cd JT |
2875 | /* Don't do anything that disrupts the RSCN unless lpfc is unloading. */ |
2876 | if (lpfc_check_unload_and_clr_rscn(&vport->fc_flag)) | |
92d7f7b0 JS |
2877 | return ndlp->nlp_state; |
2878 | ||
eaf15d5b | 2879 | lpfc_cancel_retry_delay_tmo(vport, ndlp); |
92b99f1a JT |
2880 | clear_bit(NLP_NODEV_REMOVE, &ndlp->nlp_flag); |
2881 | clear_bit(NLP_NPR_2B_DISC, &ndlp->nlp_flag); | |
c6adba15 | 2882 | spin_lock_irq(&ndlp->lock); |
01a8aed6 | 2883 | ndlp->nlp_fc4_type &= ~(NLP_FC4_FCP | NLP_FC4_NVME); |
c6adba15 | 2884 | spin_unlock_irq(&ndlp->lock); |
c9f8735b | 2885 | return ndlp->nlp_state; |
dea3101e | 2886 | } |
2887 | ||
2888 | ||
2889 | /* This next section defines the NPort Discovery State Machine */ | |
2890 | ||
2891 | /* There are 4 different double linked lists nodelist entries can reside on. | |
2892 | * The plogi list and adisc list are used when Link Up discovery or RSCN | |
2893 | * processing is needed. Each list holds the nodes that we will send PLOGI | |
2894 | * or ADISC on. These lists will keep track of what nodes will be effected | |
2895 | * by an RSCN, or a Link Up (Typically, all nodes are effected on Link Up). | |
2896 | * The unmapped_list will contain all nodes that we have successfully logged | |
2897 | * into at the Fibre Channel level. The mapped_list will contain all nodes | |
2898 | * that are mapped FCP targets. | |
2899 | */ | |
2900 | /* | |
2901 | * The bind list is a list of undiscovered (potentially non-existent) nodes | |
2902 | * that we have saved binding information on. This information is used when | |
2903 | * nodes transition from the unmapped to the mapped list. | |
2904 | */ | |
2905 | /* For UNUSED_NODE state, the node has just been allocated . | |
2906 | * For PLOGI_ISSUE and REG_LOGIN_ISSUE, the node is on | |
2907 | * the PLOGI list. For REG_LOGIN_COMPL, the node is taken off the PLOGI list | |
2908 | * and put on the unmapped list. For ADISC processing, the node is taken off | |
2909 | * the ADISC list and placed on either the mapped or unmapped list (depending | |
2910 | * on its previous state). Once on the unmapped list, a PRLI is issued and the | |
2911 | * state changed to PRLI_ISSUE. When the PRLI completion occurs, the state is | |
2912 | * changed to UNMAPPED_NODE. If the completion indicates a mapped | |
2913 | * node, the node is taken off the unmapped list. The binding list is checked | |
2914 | * for a valid binding, or a binding is automatically assigned. If binding | |
2915 | * assignment is unsuccessful, the node is left on the unmapped list. If | |
2916 | * binding assignment is successful, the associated binding list entry (if | |
2917 | * any) is removed, and the node is placed on the mapped list. | |
2918 | */ | |
2919 | /* | |
2920 | * For a Link Down, all nodes on the ADISC, PLOGI, unmapped or mapped | |
c01f3208 | 2921 | * lists will receive a DEVICE_RECOVERY event. If the linkdown or devloss timers |
dea3101e | 2922 | * expire, all effected nodes will receive a DEVICE_RM event. |
2923 | */ | |
2924 | /* | |
2925 | * For a Link Up or RSCN, all nodes will move from the mapped / unmapped lists | |
2926 | * to either the ADISC or PLOGI list. After a Nameserver query or ALPA loopmap | |
2927 | * check, additional nodes may be added or removed (via DEVICE_RM) to / from | |
2928 | * the PLOGI or ADISC lists. Once the PLOGI and ADISC lists are populated, | |
2929 | * we will first process the ADISC list. 32 entries are processed initially and | |
2930 | * ADISC is initited for each one. Completions / Events for each node are | |
2931 | * funnelled thru the state machine. As each node finishes ADISC processing, it | |
2932 | * starts ADISC for any nodes waiting for ADISC processing. If no nodes are | |
2933 | * waiting, and the ADISC list count is identically 0, then we are done. For | |
2934 | * Link Up discovery, since all nodes on the PLOGI list are UNREG_LOGIN'ed, we | |
2935 | * can issue a CLEAR_LA and reenable Link Events. Next we will process the PLOGI | |
2936 | * list. 32 entries are processed initially and PLOGI is initited for each one. | |
2937 | * Completions / Events for each node are funnelled thru the state machine. As | |
2938 | * each node finishes PLOGI processing, it starts PLOGI for any nodes waiting | |
2939 | * for PLOGI processing. If no nodes are waiting, and the PLOGI list count is | |
2940 | * indentically 0, then we are done. We have now completed discovery / RSCN | |
2941 | * handling. Upon completion, ALL nodes should be on either the mapped or | |
2942 | * unmapped lists. | |
2943 | */ | |
2944 | ||
2945 | static uint32_t (*lpfc_disc_action[NLP_STE_MAX_STATE * NLP_EVT_MAX_EVENT]) | |
2e0fef85 | 2946 | (struct lpfc_vport *, struct lpfc_nodelist *, void *, uint32_t) = { |
dea3101e | 2947 | /* Action routine Event Current State */ |
2948 | lpfc_rcv_plogi_unused_node, /* RCV_PLOGI UNUSED_NODE */ | |
2949 | lpfc_rcv_els_unused_node, /* RCV_PRLI */ | |
2950 | lpfc_rcv_logo_unused_node, /* RCV_LOGO */ | |
2951 | lpfc_rcv_els_unused_node, /* RCV_ADISC */ | |
2952 | lpfc_rcv_els_unused_node, /* RCV_PDISC */ | |
2953 | lpfc_rcv_els_unused_node, /* RCV_PRLO */ | |
2954 | lpfc_disc_illegal, /* CMPL_PLOGI */ | |
2955 | lpfc_disc_illegal, /* CMPL_PRLI */ | |
2956 | lpfc_cmpl_logo_unused_node, /* CMPL_LOGO */ | |
2957 | lpfc_disc_illegal, /* CMPL_ADISC */ | |
2958 | lpfc_disc_illegal, /* CMPL_REG_LOGIN */ | |
2959 | lpfc_device_rm_unused_node, /* DEVICE_RM */ | |
df9e1b59 | 2960 | lpfc_device_recov_unused_node, /* DEVICE_RECOVERY */ |
dea3101e | 2961 | |
2962 | lpfc_rcv_plogi_plogi_issue, /* RCV_PLOGI PLOGI_ISSUE */ | |
92d7f7b0 | 2963 | lpfc_rcv_prli_plogi_issue, /* RCV_PRLI */ |
c9f8735b | 2964 | lpfc_rcv_logo_plogi_issue, /* RCV_LOGO */ |
dea3101e | 2965 | lpfc_rcv_els_plogi_issue, /* RCV_ADISC */ |
2966 | lpfc_rcv_els_plogi_issue, /* RCV_PDISC */ | |
2967 | lpfc_rcv_els_plogi_issue, /* RCV_PRLO */ | |
2968 | lpfc_cmpl_plogi_plogi_issue, /* CMPL_PLOGI */ | |
2969 | lpfc_disc_illegal, /* CMPL_PRLI */ | |
0ff10d46 | 2970 | lpfc_cmpl_logo_plogi_issue, /* CMPL_LOGO */ |
dea3101e | 2971 | lpfc_disc_illegal, /* CMPL_ADISC */ |
0ff10d46 | 2972 | lpfc_cmpl_reglogin_plogi_issue,/* CMPL_REG_LOGIN */ |
dea3101e | 2973 | lpfc_device_rm_plogi_issue, /* DEVICE_RM */ |
2974 | lpfc_device_recov_plogi_issue, /* DEVICE_RECOVERY */ | |
2975 | ||
2976 | lpfc_rcv_plogi_adisc_issue, /* RCV_PLOGI ADISC_ISSUE */ | |
2977 | lpfc_rcv_prli_adisc_issue, /* RCV_PRLI */ | |
2978 | lpfc_rcv_logo_adisc_issue, /* RCV_LOGO */ | |
2979 | lpfc_rcv_padisc_adisc_issue, /* RCV_ADISC */ | |
2980 | lpfc_rcv_padisc_adisc_issue, /* RCV_PDISC */ | |
2981 | lpfc_rcv_prlo_adisc_issue, /* RCV_PRLO */ | |
2982 | lpfc_disc_illegal, /* CMPL_PLOGI */ | |
2983 | lpfc_disc_illegal, /* CMPL_PRLI */ | |
2984 | lpfc_disc_illegal, /* CMPL_LOGO */ | |
2985 | lpfc_cmpl_adisc_adisc_issue, /* CMPL_ADISC */ | |
2986 | lpfc_disc_illegal, /* CMPL_REG_LOGIN */ | |
2987 | lpfc_device_rm_adisc_issue, /* DEVICE_RM */ | |
2988 | lpfc_device_recov_adisc_issue, /* DEVICE_RECOVERY */ | |
2989 | ||
2990 | lpfc_rcv_plogi_reglogin_issue, /* RCV_PLOGI REG_LOGIN_ISSUE */ | |
2991 | lpfc_rcv_prli_reglogin_issue, /* RCV_PLOGI */ | |
2992 | lpfc_rcv_logo_reglogin_issue, /* RCV_LOGO */ | |
2993 | lpfc_rcv_padisc_reglogin_issue, /* RCV_ADISC */ | |
2994 | lpfc_rcv_padisc_reglogin_issue, /* RCV_PDISC */ | |
2995 | lpfc_rcv_prlo_reglogin_issue, /* RCV_PRLO */ | |
87af33fe | 2996 | lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */ |
dea3101e | 2997 | lpfc_disc_illegal, /* CMPL_PRLI */ |
2998 | lpfc_disc_illegal, /* CMPL_LOGO */ | |
2999 | lpfc_disc_illegal, /* CMPL_ADISC */ | |
3000 | lpfc_cmpl_reglogin_reglogin_issue,/* CMPL_REG_LOGIN */ | |
3001 | lpfc_device_rm_reglogin_issue, /* DEVICE_RM */ | |
3002 | lpfc_device_recov_reglogin_issue,/* DEVICE_RECOVERY */ | |
3003 | ||
3004 | lpfc_rcv_plogi_prli_issue, /* RCV_PLOGI PRLI_ISSUE */ | |
3005 | lpfc_rcv_prli_prli_issue, /* RCV_PRLI */ | |
3006 | lpfc_rcv_logo_prli_issue, /* RCV_LOGO */ | |
3007 | lpfc_rcv_padisc_prli_issue, /* RCV_ADISC */ | |
3008 | lpfc_rcv_padisc_prli_issue, /* RCV_PDISC */ | |
3009 | lpfc_rcv_prlo_prli_issue, /* RCV_PRLO */ | |
87af33fe | 3010 | lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */ |
dea3101e | 3011 | lpfc_cmpl_prli_prli_issue, /* CMPL_PRLI */ |
3012 | lpfc_disc_illegal, /* CMPL_LOGO */ | |
3013 | lpfc_disc_illegal, /* CMPL_ADISC */ | |
3014 | lpfc_disc_illegal, /* CMPL_REG_LOGIN */ | |
3015 | lpfc_device_rm_prli_issue, /* DEVICE_RM */ | |
3016 | lpfc_device_recov_prli_issue, /* DEVICE_RECOVERY */ | |
3017 | ||
086a345f JS |
3018 | lpfc_rcv_plogi_logo_issue, /* RCV_PLOGI LOGO_ISSUE */ |
3019 | lpfc_rcv_prli_logo_issue, /* RCV_PRLI */ | |
3020 | lpfc_rcv_logo_logo_issue, /* RCV_LOGO */ | |
3021 | lpfc_rcv_padisc_logo_issue, /* RCV_ADISC */ | |
3022 | lpfc_rcv_padisc_logo_issue, /* RCV_PDISC */ | |
3023 | lpfc_rcv_prlo_logo_issue, /* RCV_PRLO */ | |
3024 | lpfc_cmpl_plogi_illegal, /* CMPL_PLOGI */ | |
3025 | lpfc_disc_illegal, /* CMPL_PRLI */ | |
3026 | lpfc_cmpl_logo_logo_issue, /* CMPL_LOGO */ | |
3027 | lpfc_disc_illegal, /* CMPL_ADISC */ | |
3028 | lpfc_disc_illegal, /* CMPL_REG_LOGIN */ | |
3029 | lpfc_device_rm_logo_issue, /* DEVICE_RM */ | |
3030 | lpfc_device_recov_logo_issue, /* DEVICE_RECOVERY */ | |
3031 | ||
dea3101e | 3032 | lpfc_rcv_plogi_unmap_node, /* RCV_PLOGI UNMAPPED_NODE */ |
3033 | lpfc_rcv_prli_unmap_node, /* RCV_PRLI */ | |
3034 | lpfc_rcv_logo_unmap_node, /* RCV_LOGO */ | |
3035 | lpfc_rcv_padisc_unmap_node, /* RCV_ADISC */ | |
3036 | lpfc_rcv_padisc_unmap_node, /* RCV_PDISC */ | |
3037 | lpfc_rcv_prlo_unmap_node, /* RCV_PRLO */ | |
3038 | lpfc_disc_illegal, /* CMPL_PLOGI */ | |
3039 | lpfc_disc_illegal, /* CMPL_PRLI */ | |
3040 | lpfc_disc_illegal, /* CMPL_LOGO */ | |
3041 | lpfc_disc_illegal, /* CMPL_ADISC */ | |
3042 | lpfc_disc_illegal, /* CMPL_REG_LOGIN */ | |
debbc1e2 | 3043 | lpfc_device_rm_unmap_node, /* DEVICE_RM */ |
dea3101e | 3044 | lpfc_device_recov_unmap_node, /* DEVICE_RECOVERY */ |
3045 | ||
3046 | lpfc_rcv_plogi_mapped_node, /* RCV_PLOGI MAPPED_NODE */ | |
3047 | lpfc_rcv_prli_mapped_node, /* RCV_PRLI */ | |
3048 | lpfc_rcv_logo_mapped_node, /* RCV_LOGO */ | |
3049 | lpfc_rcv_padisc_mapped_node, /* RCV_ADISC */ | |
3050 | lpfc_rcv_padisc_mapped_node, /* RCV_PDISC */ | |
3051 | lpfc_rcv_prlo_mapped_node, /* RCV_PRLO */ | |
3052 | lpfc_disc_illegal, /* CMPL_PLOGI */ | |
3053 | lpfc_disc_illegal, /* CMPL_PRLI */ | |
3054 | lpfc_disc_illegal, /* CMPL_LOGO */ | |
3055 | lpfc_disc_illegal, /* CMPL_ADISC */ | |
3056 | lpfc_disc_illegal, /* CMPL_REG_LOGIN */ | |
3057 | lpfc_disc_illegal, /* DEVICE_RM */ | |
3058 | lpfc_device_recov_mapped_node, /* DEVICE_RECOVERY */ | |
3059 | ||
3060 | lpfc_rcv_plogi_npr_node, /* RCV_PLOGI NPR_NODE */ | |
3061 | lpfc_rcv_prli_npr_node, /* RCV_PRLI */ | |
3062 | lpfc_rcv_logo_npr_node, /* RCV_LOGO */ | |
3063 | lpfc_rcv_padisc_npr_node, /* RCV_ADISC */ | |
3064 | lpfc_rcv_padisc_npr_node, /* RCV_PDISC */ | |
3065 | lpfc_rcv_prlo_npr_node, /* RCV_PRLO */ | |
c9f8735b JW |
3066 | lpfc_cmpl_plogi_npr_node, /* CMPL_PLOGI */ |
3067 | lpfc_cmpl_prli_npr_node, /* CMPL_PRLI */ | |
dea3101e | 3068 | lpfc_cmpl_logo_npr_node, /* CMPL_LOGO */ |
c9f8735b | 3069 | lpfc_cmpl_adisc_npr_node, /* CMPL_ADISC */ |
dea3101e | 3070 | lpfc_cmpl_reglogin_npr_node, /* CMPL_REG_LOGIN */ |
3071 | lpfc_device_rm_npr_node, /* DEVICE_RM */ | |
3072 | lpfc_device_recov_npr_node, /* DEVICE_RECOVERY */ | |
3073 | }; | |
3074 | ||
3075 | int | |
2e0fef85 JS |
3076 | lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
3077 | void *arg, uint32_t evt) | |
dea3101e | 3078 | { |
3079 | uint32_t cur_state, rc; | |
2e0fef85 | 3080 | uint32_t(*func) (struct lpfc_vport *, struct lpfc_nodelist *, void *, |
dea3101e | 3081 | uint32_t); |
e47c9093 | 3082 | uint32_t got_ndlp = 0; |
26d824ca | 3083 | uint32_t data1; |
e47c9093 JS |
3084 | |
3085 | if (lpfc_nlp_get(ndlp)) | |
3086 | got_ndlp = 1; | |
dea3101e | 3087 | |
dea3101e | 3088 | cur_state = ndlp->nlp_state; |
3089 | ||
26d824ca JS |
3090 | data1 = (((uint32_t)ndlp->nlp_fc4_type << 16) | |
3091 | ((uint32_t)ndlp->nlp_type)); | |
dea3101e | 3092 | /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */ |
e8b62011 JS |
3093 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
3094 | "0211 DSM in event x%x on NPort x%x in " | |
92b99f1a | 3095 | "state %d rpi x%x Data: x%lx x%x\n", |
dea16bda | 3096 | evt, ndlp->nlp_DID, cur_state, ndlp->nlp_rpi, |
26d824ca | 3097 | ndlp->nlp_flag, data1); |
dea3101e | 3098 | |
858c9f6c JS |
3099 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, |
3100 | "DSM in: evt:%d ste:%d did:x%x", | |
3101 | evt, cur_state, ndlp->nlp_DID); | |
3102 | ||
dea3101e | 3103 | func = lpfc_disc_action[(cur_state * NLP_EVT_MAX_EVENT) + evt]; |
2e0fef85 | 3104 | rc = (func) (vport, ndlp, arg, evt); |
dea3101e | 3105 | |
3106 | /* DSM out state <rc> on NPort <nlp_DID> */ | |
e47c9093 | 3107 | if (got_ndlp) { |
26d824ca JS |
3108 | data1 = (((uint32_t)ndlp->nlp_fc4_type << 16) | |
3109 | ((uint32_t)ndlp->nlp_type)); | |
e47c9093 | 3110 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
dea16bda | 3111 | "0212 DSM out state %d on NPort x%x " |
92b99f1a | 3112 | "rpi x%x Data: x%lx x%x\n", |
26d824ca JS |
3113 | rc, ndlp->nlp_DID, ndlp->nlp_rpi, ndlp->nlp_flag, |
3114 | data1); | |
dea3101e | 3115 | |
e47c9093 | 3116 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, |
92b99f1a | 3117 | "DSM out: ste:%d did:x%x flg:x%lx", |
e47c9093 JS |
3118 | rc, ndlp->nlp_DID, ndlp->nlp_flag); |
3119 | /* Decrement the ndlp reference count held for this function */ | |
3120 | lpfc_nlp_put(ndlp); | |
3121 | } else { | |
3122 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, | |
d7c255b2 | 3123 | "0213 DSM out state %d on NPort free\n", rc); |
858c9f6c | 3124 | |
e47c9093 JS |
3125 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, |
3126 | "DSM out: ste:%d did:x%x flg:x%x", | |
3127 | rc, 0, 0); | |
3128 | } | |
dea3101e | 3129 | |
c9f8735b | 3130 | return rc; |
dea3101e | 3131 | } |