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