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