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