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