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