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