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