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