| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1 | /******************************************************************* |
| 2 | * This file is part of the Emulex Linux Device Driver for * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 3 | * Fibre Channel Host Bus Adapters. * |
James Smart | 92c13f2 | 2013-05-31 17:05:45 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2013 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 | *******************************************************************/ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 21 | /* See Fibre Channel protocol T11 FC-LS for details */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 22 | #include <linux/blkdev.h> |
| 23 | #include <linux/pci.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 24 | #include <linux/slab.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 25 | #include <linux/interrupt.h> |
| 26 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 27 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 28 | #include <scsi/scsi_device.h> |
| 29 | #include <scsi/scsi_host.h> |
| 30 | #include <scsi/scsi_transport_fc.h> |
| 31 | |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 32 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 33 | #include "lpfc_hw4.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 34 | #include "lpfc_hw.h" |
| 35 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 36 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 37 | #include "lpfc_nl.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 38 | #include "lpfc_disc.h" |
| 39 | #include "lpfc_scsi.h" |
| 40 | #include "lpfc.h" |
| 41 | #include "lpfc_logmsg.h" |
| 42 | #include "lpfc_crtn.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 43 | #include "lpfc_vport.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 44 | #include "lpfc_debugfs.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 45 | |
| 46 | static int lpfc_els_retry(struct lpfc_hba *, struct lpfc_iocbq *, |
| 47 | struct lpfc_iocbq *); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 48 | static void lpfc_cmpl_fabric_iocb(struct lpfc_hba *, struct lpfc_iocbq *, |
| 49 | struct lpfc_iocbq *); |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 50 | static void lpfc_fabric_abort_vport(struct lpfc_vport *vport); |
| 51 | static int lpfc_issue_els_fdisc(struct lpfc_vport *vport, |
| 52 | struct lpfc_nodelist *ndlp, uint8_t retry); |
| 53 | static int lpfc_issue_fabric_iocb(struct lpfc_hba *phba, |
| 54 | struct lpfc_iocbq *iocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 55 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 56 | static int lpfc_max_els_tries = 3; |
| 57 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 58 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 59 | * lpfc_els_chk_latt - Check host link attention event for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 60 | * @vport: pointer to a host virtual N_Port data structure. |
| 61 | * |
| 62 | * This routine checks whether there is an outstanding host link |
| 63 | * attention event during the discovery process with the @vport. It is done |
| 64 | * by reading the HBA's Host Attention (HA) register. If there is any host |
| 65 | * link attention events during this @vport's discovery process, the @vport |
| 66 | * shall be marked as FC_ABORT_DISCOVERY, a host link attention clear shall |
| 67 | * be issued if the link state is not already in host link cleared state, |
| 68 | * and a return code shall indicate whether the host link attention event |
| 69 | * had happened. |
| 70 | * |
| 71 | * Note that, if either the host link is in state LPFC_LINK_DOWN or @vport |
| 72 | * state in LPFC_VPORT_READY, the request for checking host link attention |
| 73 | * event will be ignored and a return code shall indicate no host link |
| 74 | * attention event had happened. |
| 75 | * |
| 76 | * Return codes |
| 77 | * 0 - no host link attention event happened |
| 78 | * 1 - host link attention event happened |
| 79 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 80 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 81 | lpfc_els_chk_latt(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 82 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 83 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 84 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 85 | uint32_t ha_copy; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 86 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 87 | if (vport->port_state >= LPFC_VPORT_READY || |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 88 | phba->link_state == LPFC_LINK_DOWN || |
| 89 | phba->sli_rev > LPFC_SLI_REV3) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 90 | return 0; |
| 91 | |
| 92 | /* Read the HBA Host Attention Register */ |
James Smart | 9940b97 | 2011-03-11 16:06:12 -0500 | [diff] [blame] | 93 | if (lpfc_readl(phba->HAregaddr, &ha_copy)) |
| 94 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 95 | |
| 96 | if (!(ha_copy & HA_LATT)) |
| 97 | return 0; |
| 98 | |
| 99 | /* Pending Link Event during Discovery */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 100 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 101 | "0237 Pending Link Event during " |
| 102 | "Discovery: State x%x\n", |
| 103 | phba->pport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 104 | |
| 105 | /* CLEAR_LA should re-enable link attention events and |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 106 | * we should then immediately take a LATT event. The |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 107 | * LATT processing should call lpfc_linkdown() which |
| 108 | * will cleanup any left over in-progress discovery |
| 109 | * events. |
| 110 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 111 | spin_lock_irq(shost->host_lock); |
| 112 | vport->fc_flag |= FC_ABORT_DISCOVERY; |
| 113 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 114 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 115 | if (phba->link_state != LPFC_CLEAR_LA) |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 116 | lpfc_issue_clear_la(phba, vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 117 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 118 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 119 | } |
| 120 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 121 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 122 | * lpfc_prep_els_iocb - Allocate and prepare a lpfc iocb data structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 123 | * @vport: pointer to a host virtual N_Port data structure. |
| 124 | * @expectRsp: flag indicating whether response is expected. |
| 125 | * @cmdSize: size of the ELS command. |
| 126 | * @retry: number of retries to the command IOCB when it fails. |
| 127 | * @ndlp: pointer to a node-list data structure. |
| 128 | * @did: destination identifier. |
| 129 | * @elscmd: the ELS command code. |
| 130 | * |
| 131 | * This routine is used for allocating a lpfc-IOCB data structure from |
| 132 | * the driver lpfc-IOCB free-list and prepare the IOCB with the parameters |
| 133 | * passed into the routine for discovery state machine to issue an Extended |
| 134 | * Link Service (ELS) commands. It is a generic lpfc-IOCB allocation |
| 135 | * and preparation routine that is used by all the discovery state machine |
| 136 | * routines and the ELS command-specific fields will be later set up by |
| 137 | * the individual discovery machine routines after calling this routine |
| 138 | * allocating and preparing a generic IOCB data structure. It fills in the |
| 139 | * Buffer Descriptor Entries (BDEs), allocates buffers for both command |
| 140 | * payload and response payload (if expected). The reference count on the |
| 141 | * ndlp is incremented by 1 and the reference to the ndlp is put into |
| 142 | * context1 of the IOCB data structure for this IOCB to hold the ndlp |
| 143 | * reference for the command's callback function to access later. |
| 144 | * |
| 145 | * Return code |
| 146 | * Pointer to the newly allocated/prepared els iocb data structure |
| 147 | * NULL - when els iocb data structure allocation/preparation failed |
| 148 | **/ |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 149 | struct lpfc_iocbq * |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 150 | lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, |
| 151 | uint16_t cmdSize, uint8_t retry, |
| 152 | struct lpfc_nodelist *ndlp, uint32_t did, |
| 153 | uint32_t elscmd) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 154 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 155 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 156 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 157 | struct lpfc_dmabuf *pcmd, *prsp, *pbuflist; |
| 158 | struct ulp_bde64 *bpl; |
| 159 | IOCB_t *icmd; |
| 160 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 161 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 162 | if (!lpfc_is_link_up(phba)) |
| 163 | return NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 164 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 165 | /* Allocate buffer for command iocb */ |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 166 | elsiocb = lpfc_sli_get_iocbq(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 167 | |
| 168 | if (elsiocb == NULL) |
| 169 | return NULL; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 170 | |
James Smart | 0c28758 | 2009-06-10 17:22:56 -0400 | [diff] [blame] | 171 | /* |
| 172 | * If this command is for fabric controller and HBA running |
| 173 | * in FIP mode send FLOGI, FDISC and LOGO as FIP frames. |
| 174 | */ |
| 175 | if ((did == Fabric_DID) && |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 176 | (phba->hba_flag & HBA_FIP_SUPPORT) && |
James Smart | 0c28758 | 2009-06-10 17:22:56 -0400 | [diff] [blame] | 177 | ((elscmd == ELS_CMD_FLOGI) || |
| 178 | (elscmd == ELS_CMD_FDISC) || |
| 179 | (elscmd == ELS_CMD_LOGO))) |
James Smart | c868595 | 2009-11-18 15:39:16 -0500 | [diff] [blame] | 180 | switch (elscmd) { |
| 181 | case ELS_CMD_FLOGI: |
James Smart | f0d9bcc | 2010-10-22 11:07:09 -0400 | [diff] [blame] | 182 | elsiocb->iocb_flag |= |
| 183 | ((LPFC_ELS_ID_FLOGI << LPFC_FIP_ELS_ID_SHIFT) |
James Smart | c868595 | 2009-11-18 15:39:16 -0500 | [diff] [blame] | 184 | & LPFC_FIP_ELS_ID_MASK); |
| 185 | break; |
| 186 | case ELS_CMD_FDISC: |
James Smart | f0d9bcc | 2010-10-22 11:07:09 -0400 | [diff] [blame] | 187 | elsiocb->iocb_flag |= |
| 188 | ((LPFC_ELS_ID_FDISC << LPFC_FIP_ELS_ID_SHIFT) |
James Smart | c868595 | 2009-11-18 15:39:16 -0500 | [diff] [blame] | 189 | & LPFC_FIP_ELS_ID_MASK); |
| 190 | break; |
| 191 | case ELS_CMD_LOGO: |
James Smart | f0d9bcc | 2010-10-22 11:07:09 -0400 | [diff] [blame] | 192 | elsiocb->iocb_flag |= |
| 193 | ((LPFC_ELS_ID_LOGO << LPFC_FIP_ELS_ID_SHIFT) |
James Smart | c868595 | 2009-11-18 15:39:16 -0500 | [diff] [blame] | 194 | & LPFC_FIP_ELS_ID_MASK); |
| 195 | break; |
| 196 | } |
James Smart | 0c28758 | 2009-06-10 17:22:56 -0400 | [diff] [blame] | 197 | else |
James Smart | c868595 | 2009-11-18 15:39:16 -0500 | [diff] [blame] | 198 | elsiocb->iocb_flag &= ~LPFC_FIP_ELS_ID_MASK; |
James Smart | 0c28758 | 2009-06-10 17:22:56 -0400 | [diff] [blame] | 199 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 200 | icmd = &elsiocb->iocb; |
| 201 | |
| 202 | /* fill in BDEs for command */ |
| 203 | /* Allocate buffer for command payload */ |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 204 | pcmd = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| 205 | if (pcmd) |
| 206 | pcmd->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &pcmd->phys); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 207 | if (!pcmd || !pcmd->virt) |
| 208 | goto els_iocb_free_pcmb_exit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 209 | |
| 210 | INIT_LIST_HEAD(&pcmd->list); |
| 211 | |
| 212 | /* Allocate buffer for response payload */ |
| 213 | if (expectRsp) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 214 | prsp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 215 | if (prsp) |
| 216 | prsp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, |
| 217 | &prsp->phys); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 218 | if (!prsp || !prsp->virt) |
| 219 | goto els_iocb_free_prsp_exit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 220 | INIT_LIST_HEAD(&prsp->list); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 221 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 222 | prsp = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 223 | |
| 224 | /* Allocate buffer for Buffer ptr list */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 225 | pbuflist = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 226 | if (pbuflist) |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 227 | pbuflist->virt = lpfc_mbuf_alloc(phba, MEM_PRI, |
| 228 | &pbuflist->phys); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 229 | if (!pbuflist || !pbuflist->virt) |
| 230 | goto els_iocb_free_pbuf_exit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 231 | |
| 232 | INIT_LIST_HEAD(&pbuflist->list); |
| 233 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 234 | if (expectRsp) { |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 235 | icmd->un.elsreq64.bdl.addrHigh = putPaddrHigh(pbuflist->phys); |
| 236 | icmd->un.elsreq64.bdl.addrLow = putPaddrLow(pbuflist->phys); |
| 237 | icmd->un.elsreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 238 | icmd->un.elsreq64.bdl.bdeSize = (2 * sizeof(struct ulp_bde64)); |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 239 | |
| 240 | icmd->un.elsreq64.remoteID = did; /* DID */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 241 | icmd->ulpCommand = CMD_ELS_REQUEST64_CR; |
James Smart | 88f43a0 | 2013-04-17 20:19:44 -0400 | [diff] [blame] | 242 | if (elscmd == ELS_CMD_FLOGI) |
| 243 | icmd->ulpTimeout = FF_DEF_RATOV * 2; |
| 244 | else |
| 245 | icmd->ulpTimeout = phba->fc_ratov * 2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 246 | } else { |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 247 | icmd->un.xseq64.bdl.addrHigh = putPaddrHigh(pbuflist->phys); |
| 248 | icmd->un.xseq64.bdl.addrLow = putPaddrLow(pbuflist->phys); |
| 249 | icmd->un.xseq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; |
| 250 | icmd->un.xseq64.bdl.bdeSize = sizeof(struct ulp_bde64); |
| 251 | icmd->un.xseq64.xmit_els_remoteID = did; /* DID */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 252 | icmd->ulpCommand = CMD_XMIT_ELS_RSP64_CX; |
| 253 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 254 | icmd->ulpBdeCount = 1; |
| 255 | icmd->ulpLe = 1; |
| 256 | icmd->ulpClass = CLASS3; |
| 257 | |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 258 | /* |
| 259 | * If we have NPIV enabled, we want to send ELS traffic by VPI. |
| 260 | * For SLI4, since the driver controls VPIs we also want to include |
| 261 | * all ELS pt2pt protocol traffic as well. |
| 262 | */ |
| 263 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) || |
| 264 | ((phba->sli_rev == LPFC_SLI_REV4) && |
| 265 | (vport->fc_flag & FC_PT2PT))) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 266 | |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 267 | if (expectRsp) { |
| 268 | icmd->un.elsreq64.myID = vport->fc_myDID; |
| 269 | |
| 270 | /* For ELS_REQUEST64_CR, use the VPI by default */ |
| 271 | icmd->ulpContext = phba->vpi_ids[vport->vpi]; |
| 272 | } |
| 273 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 274 | icmd->ulpCt_h = 0; |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 275 | /* The CT field must be 0=INVALID_RPI for the ECHO cmd */ |
| 276 | if (elscmd == ELS_CMD_ECHO) |
| 277 | icmd->ulpCt_l = 0; /* context = invalid RPI */ |
| 278 | else |
| 279 | icmd->ulpCt_l = 1; /* context = VPI */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 280 | } |
| 281 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 282 | bpl = (struct ulp_bde64 *) pbuflist->virt; |
| 283 | bpl->addrLow = le32_to_cpu(putPaddrLow(pcmd->phys)); |
| 284 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(pcmd->phys)); |
| 285 | bpl->tus.f.bdeSize = cmdSize; |
| 286 | bpl->tus.f.bdeFlags = 0; |
| 287 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 288 | |
| 289 | if (expectRsp) { |
| 290 | bpl++; |
| 291 | bpl->addrLow = le32_to_cpu(putPaddrLow(prsp->phys)); |
| 292 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(prsp->phys)); |
| 293 | bpl->tus.f.bdeSize = FCELSSIZE; |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 294 | bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 295 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 296 | } |
| 297 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 298 | /* prevent preparing iocb with NULL ndlp reference */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 299 | elsiocb->context1 = lpfc_nlp_get(ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 300 | if (!elsiocb->context1) |
| 301 | goto els_iocb_free_pbuf_exit; |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 302 | elsiocb->context2 = pcmd; |
| 303 | elsiocb->context3 = pbuflist; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 304 | elsiocb->retry = retry; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 305 | elsiocb->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 306 | elsiocb->drvrTimeout = (phba->fc_ratov << 1) + LPFC_DRVR_TIMEOUT; |
| 307 | |
| 308 | if (prsp) { |
| 309 | list_add(&prsp->list, &pcmd->list); |
| 310 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 311 | if (expectRsp) { |
| 312 | /* Xmit ELS command <elsCmd> to remote NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 313 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 314 | "0116 Xmit ELS command x%x to remote " |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 315 | "NPORT x%x I/O tag: x%x, port state:x%x" |
| 316 | " fc_flag:x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 317 | elscmd, did, elsiocb->iotag, |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 318 | vport->port_state, |
| 319 | vport->fc_flag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 320 | } else { |
| 321 | /* Xmit ELS response <elsCmd> to remote NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 322 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 323 | "0117 Xmit ELS response x%x to remote " |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 324 | "NPORT x%x I/O tag: x%x, size: x%x " |
| 325 | "port_state x%x fc_flag x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 326 | elscmd, ndlp->nlp_DID, elsiocb->iotag, |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 327 | cmdSize, vport->port_state, |
| 328 | vport->fc_flag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 329 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 330 | return elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 331 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 332 | els_iocb_free_pbuf_exit: |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 333 | if (expectRsp) |
| 334 | lpfc_mbuf_free(phba, prsp->virt, prsp->phys); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 335 | kfree(pbuflist); |
| 336 | |
| 337 | els_iocb_free_prsp_exit: |
| 338 | lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys); |
| 339 | kfree(prsp); |
| 340 | |
| 341 | els_iocb_free_pcmb_exit: |
| 342 | kfree(pcmd); |
| 343 | lpfc_sli_release_iocbq(phba, elsiocb); |
| 344 | return NULL; |
| 345 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 346 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 347 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 348 | * lpfc_issue_fabric_reglogin - Issue fabric registration login for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 349 | * @vport: pointer to a host virtual N_Port data structure. |
| 350 | * |
| 351 | * This routine issues a fabric registration login for a @vport. An |
| 352 | * active ndlp node with Fabric_DID must already exist for this @vport. |
| 353 | * The routine invokes two mailbox commands to carry out fabric registration |
| 354 | * login through the HBA firmware: the first mailbox command requests the |
| 355 | * HBA to perform link configuration for the @vport; and the second mailbox |
| 356 | * command requests the HBA to perform the actual fabric registration login |
| 357 | * with the @vport. |
| 358 | * |
| 359 | * Return code |
| 360 | * 0 - successfully issued fabric registration login for @vport |
| 361 | * -ENXIO -- failed to issue fabric registration login for @vport |
| 362 | **/ |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 363 | int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 364 | lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) |
| 365 | { |
| 366 | struct lpfc_hba *phba = vport->phba; |
| 367 | LPFC_MBOXQ_t *mbox; |
| 368 | struct lpfc_dmabuf *mp; |
| 369 | struct lpfc_nodelist *ndlp; |
| 370 | struct serv_parm *sp; |
| 371 | int rc; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 372 | int err = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 373 | |
| 374 | sp = &phba->fc_fabparam; |
| 375 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 376 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 377 | err = 1; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 378 | goto fail; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 379 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 380 | |
| 381 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 382 | if (!mbox) { |
| 383 | err = 2; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 384 | goto fail; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 385 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 386 | |
| 387 | vport->port_state = LPFC_FABRIC_CFG_LINK; |
| 388 | lpfc_config_link(phba, mbox); |
| 389 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
| 390 | mbox->vport = vport; |
| 391 | |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 392 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 393 | if (rc == MBX_NOT_FINISHED) { |
| 394 | err = 3; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 395 | goto fail_free_mbox; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 396 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 397 | |
| 398 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 399 | if (!mbox) { |
| 400 | err = 4; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 401 | goto fail; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 402 | } |
James Smart | 4042629 | 2010-12-15 17:58:10 -0500 | [diff] [blame] | 403 | rc = lpfc_reg_rpi(phba, vport->vpi, Fabric_DID, (uint8_t *)sp, mbox, |
| 404 | ndlp->nlp_rpi); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 405 | if (rc) { |
| 406 | err = 5; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 407 | goto fail_free_mbox; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 408 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 409 | |
| 410 | mbox->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login; |
| 411 | mbox->vport = vport; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 412 | /* increment the reference count on ndlp to hold reference |
| 413 | * for the callback routine. |
| 414 | */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 415 | mbox->context2 = lpfc_nlp_get(ndlp); |
| 416 | |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 417 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 418 | if (rc == MBX_NOT_FINISHED) { |
| 419 | err = 6; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 420 | goto fail_issue_reg_login; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 421 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 422 | |
| 423 | return 0; |
| 424 | |
| 425 | fail_issue_reg_login: |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 426 | /* decrement the reference count on ndlp just incremented |
| 427 | * for the failed mbox command. |
| 428 | */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 429 | lpfc_nlp_put(ndlp); |
| 430 | mp = (struct lpfc_dmabuf *) mbox->context1; |
| 431 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 432 | kfree(mp); |
| 433 | fail_free_mbox: |
| 434 | mempool_free(mbox, phba->mbox_mem_pool); |
| 435 | |
| 436 | fail: |
| 437 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 438 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 439 | "0249 Cannot issue Register Fabric login: Err %d\n", err); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 440 | return -ENXIO; |
| 441 | } |
| 442 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 443 | /** |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 444 | * lpfc_issue_reg_vfi - Register VFI for this vport's fabric login |
| 445 | * @vport: pointer to a host virtual N_Port data structure. |
| 446 | * |
| 447 | * This routine issues a REG_VFI mailbox for the vfi, vpi, fcfi triplet for |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 448 | * the @vport. This mailbox command is necessary for SLI4 port only. |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 449 | * |
| 450 | * Return code |
| 451 | * 0 - successfully issued REG_VFI for @vport |
| 452 | * A failure code otherwise. |
| 453 | **/ |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 454 | int |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 455 | lpfc_issue_reg_vfi(struct lpfc_vport *vport) |
| 456 | { |
| 457 | struct lpfc_hba *phba = vport->phba; |
| 458 | LPFC_MBOXQ_t *mboxq; |
| 459 | struct lpfc_nodelist *ndlp; |
| 460 | struct serv_parm *sp; |
| 461 | struct lpfc_dmabuf *dmabuf; |
| 462 | int rc = 0; |
| 463 | |
| 464 | sp = &phba->fc_fabparam; |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 465 | /* move forward in case of SLI4 FC port loopback test and pt2pt mode */ |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 466 | if ((phba->sli_rev == LPFC_SLI_REV4) && |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 467 | !(phba->link_flag & LS_LOOPBACK_MODE) && |
| 468 | !(vport->fc_flag & FC_PT2PT)) { |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 469 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
| 470 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
| 471 | rc = -ENODEV; |
| 472 | goto fail; |
| 473 | } |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| 477 | if (!dmabuf) { |
| 478 | rc = -ENOMEM; |
| 479 | goto fail; |
| 480 | } |
| 481 | dmabuf->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &dmabuf->phys); |
| 482 | if (!dmabuf->virt) { |
| 483 | rc = -ENOMEM; |
| 484 | goto fail_free_dmabuf; |
| 485 | } |
James Smart | 6d368e5 | 2011-05-24 11:44:12 -0400 | [diff] [blame] | 486 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 487 | mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 488 | if (!mboxq) { |
| 489 | rc = -ENOMEM; |
| 490 | goto fail_free_coherent; |
| 491 | } |
| 492 | vport->port_state = LPFC_FABRIC_CFG_LINK; |
| 493 | memcpy(dmabuf->virt, &phba->fc_fabparam, sizeof(vport->fc_sparam)); |
| 494 | lpfc_reg_vfi(mboxq, vport, dmabuf->phys); |
James Smart | ae05ebe | 2013-03-01 16:35:38 -0500 | [diff] [blame] | 495 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 496 | mboxq->mbox_cmpl = lpfc_mbx_cmpl_reg_vfi; |
| 497 | mboxq->vport = vport; |
| 498 | mboxq->context1 = dmabuf; |
| 499 | rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); |
| 500 | if (rc == MBX_NOT_FINISHED) { |
| 501 | rc = -ENXIO; |
| 502 | goto fail_free_mbox; |
| 503 | } |
| 504 | return 0; |
| 505 | |
| 506 | fail_free_mbox: |
| 507 | mempool_free(mboxq, phba->mbox_mem_pool); |
| 508 | fail_free_coherent: |
| 509 | lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys); |
| 510 | fail_free_dmabuf: |
| 511 | kfree(dmabuf); |
| 512 | fail: |
| 513 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 514 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 515 | "0289 Issue Register VFI failed: Err %d\n", rc); |
| 516 | return rc; |
| 517 | } |
| 518 | |
| 519 | /** |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 520 | * lpfc_issue_unreg_vfi - Unregister VFI for this vport's fabric login |
| 521 | * @vport: pointer to a host virtual N_Port data structure. |
| 522 | * |
| 523 | * This routine issues a UNREG_VFI mailbox with the vfi, vpi, fcfi triplet for |
| 524 | * the @vport. This mailbox command is necessary for SLI4 port only. |
| 525 | * |
| 526 | * Return code |
| 527 | * 0 - successfully issued REG_VFI for @vport |
| 528 | * A failure code otherwise. |
| 529 | **/ |
| 530 | int |
| 531 | lpfc_issue_unreg_vfi(struct lpfc_vport *vport) |
| 532 | { |
| 533 | struct lpfc_hba *phba = vport->phba; |
| 534 | struct Scsi_Host *shost; |
| 535 | LPFC_MBOXQ_t *mboxq; |
| 536 | int rc; |
| 537 | |
| 538 | mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 539 | if (!mboxq) { |
| 540 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, |
| 541 | "2556 UNREG_VFI mbox allocation failed" |
| 542 | "HBA state x%x\n", phba->pport->port_state); |
| 543 | return -ENOMEM; |
| 544 | } |
| 545 | |
| 546 | lpfc_unreg_vfi(mboxq, vport); |
| 547 | mboxq->vport = vport; |
| 548 | mboxq->mbox_cmpl = lpfc_unregister_vfi_cmpl; |
| 549 | |
| 550 | rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); |
| 551 | if (rc == MBX_NOT_FINISHED) { |
| 552 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, |
| 553 | "2557 UNREG_VFI issue mbox failed rc x%x " |
| 554 | "HBA state x%x\n", |
| 555 | rc, phba->pport->port_state); |
| 556 | mempool_free(mboxq, phba->mbox_mem_pool); |
| 557 | return -EIO; |
| 558 | } |
| 559 | |
| 560 | shost = lpfc_shost_from_vport(vport); |
| 561 | spin_lock_irq(shost->host_lock); |
| 562 | vport->fc_flag &= ~FC_VFI_REGISTERED; |
| 563 | spin_unlock_irq(shost->host_lock); |
| 564 | return 0; |
| 565 | } |
| 566 | |
| 567 | /** |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 568 | * lpfc_check_clean_addr_bit - Check whether assigned FCID is clean. |
| 569 | * @vport: pointer to a host virtual N_Port data structure. |
| 570 | * @sp: pointer to service parameter data structure. |
| 571 | * |
| 572 | * This routine is called from FLOGI/FDISC completion handler functions. |
| 573 | * lpfc_check_clean_addr_bit return 1 when FCID/Fabric portname/ Fabric |
| 574 | * node nodename is changed in the completion service parameter else return |
| 575 | * 0. This function also set flag in the vport data structure to delay |
| 576 | * NP_Port discovery after the FLOGI/FDISC completion if Clean address bit |
| 577 | * in FLOGI/FDISC response is cleared and FCID/Fabric portname/ Fabric |
| 578 | * node nodename is changed in the completion service parameter. |
| 579 | * |
| 580 | * Return code |
| 581 | * 0 - FCID and Fabric Nodename and Fabric portname is not changed. |
| 582 | * 1 - FCID or Fabric Nodename or Fabric portname is changed. |
| 583 | * |
| 584 | **/ |
| 585 | static uint8_t |
| 586 | lpfc_check_clean_addr_bit(struct lpfc_vport *vport, |
| 587 | struct serv_parm *sp) |
| 588 | { |
| 589 | uint8_t fabric_param_changed = 0; |
| 590 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 591 | |
| 592 | if ((vport->fc_prevDID != vport->fc_myDID) || |
| 593 | memcmp(&vport->fabric_portname, &sp->portName, |
| 594 | sizeof(struct lpfc_name)) || |
| 595 | memcmp(&vport->fabric_nodename, &sp->nodeName, |
| 596 | sizeof(struct lpfc_name))) |
| 597 | fabric_param_changed = 1; |
| 598 | |
| 599 | /* |
| 600 | * Word 1 Bit 31 in common service parameter is overloaded. |
| 601 | * Word 1 Bit 31 in FLOGI request is multiple NPort request |
| 602 | * Word 1 Bit 31 in FLOGI response is clean address bit |
| 603 | * |
| 604 | * If fabric parameter is changed and clean address bit is |
| 605 | * cleared delay nport discovery if |
| 606 | * - vport->fc_prevDID != 0 (not initial discovery) OR |
| 607 | * - lpfc_delay_discovery module parameter is set. |
| 608 | */ |
| 609 | if (fabric_param_changed && !sp->cmn.clean_address_bit && |
| 610 | (vport->fc_prevDID || lpfc_delay_discovery)) { |
| 611 | spin_lock_irq(shost->host_lock); |
| 612 | vport->fc_flag |= FC_DISC_DELAYED; |
| 613 | spin_unlock_irq(shost->host_lock); |
| 614 | } |
| 615 | |
| 616 | return fabric_param_changed; |
| 617 | } |
| 618 | |
| 619 | |
| 620 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 621 | * lpfc_cmpl_els_flogi_fabric - Completion function for flogi to a fabric port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 622 | * @vport: pointer to a host virtual N_Port data structure. |
| 623 | * @ndlp: pointer to a node-list data structure. |
| 624 | * @sp: pointer to service parameter data structure. |
| 625 | * @irsp: pointer to the IOCB within the lpfc response IOCB. |
| 626 | * |
| 627 | * This routine is invoked by the lpfc_cmpl_els_flogi() completion callback |
| 628 | * function to handle the completion of a Fabric Login (FLOGI) into a fabric |
| 629 | * port in a fabric topology. It properly sets up the parameters to the @ndlp |
| 630 | * from the IOCB response. It also check the newly assigned N_Port ID to the |
| 631 | * @vport against the previously assigned N_Port ID. If it is different from |
| 632 | * the previously assigned Destination ID (DID), the lpfc_unreg_rpi() routine |
| 633 | * is invoked on all the remaining nodes with the @vport to unregister the |
| 634 | * Remote Port Indicators (RPIs). Finally, the lpfc_issue_fabric_reglogin() |
| 635 | * is invoked to register login to the fabric. |
| 636 | * |
| 637 | * Return code |
| 638 | * 0 - Success (currently, always return 0) |
| 639 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 640 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 641 | lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 642 | struct serv_parm *sp, IOCB_t *irsp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 643 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 644 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 645 | struct lpfc_hba *phba = vport->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 646 | struct lpfc_nodelist *np; |
| 647 | struct lpfc_nodelist *next_np; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 648 | uint8_t fabric_param_changed; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 649 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 650 | spin_lock_irq(shost->host_lock); |
| 651 | vport->fc_flag |= FC_FABRIC; |
| 652 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 653 | |
| 654 | phba->fc_edtov = be32_to_cpu(sp->cmn.e_d_tov); |
| 655 | if (sp->cmn.edtovResolution) /* E_D_TOV ticks are in nanoseconds */ |
| 656 | phba->fc_edtov = (phba->fc_edtov + 999999) / 1000000; |
| 657 | |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 658 | phba->fc_edtovResol = sp->cmn.edtovResolution; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 659 | phba->fc_ratov = (be32_to_cpu(sp->cmn.w2.r_a_tov) + 999) / 1000; |
| 660 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 661 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 662 | spin_lock_irq(shost->host_lock); |
| 663 | vport->fc_flag |= FC_PUBLIC_LOOP; |
| 664 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 665 | } |
| 666 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 667 | vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 668 | memcpy(&ndlp->nlp_portname, &sp->portName, sizeof(struct lpfc_name)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 669 | memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 670 | ndlp->nlp_class_sup = 0; |
| 671 | if (sp->cls1.classValid) |
| 672 | ndlp->nlp_class_sup |= FC_COS_CLASS1; |
| 673 | if (sp->cls2.classValid) |
| 674 | ndlp->nlp_class_sup |= FC_COS_CLASS2; |
| 675 | if (sp->cls3.classValid) |
| 676 | ndlp->nlp_class_sup |= FC_COS_CLASS3; |
| 677 | if (sp->cls4.classValid) |
| 678 | ndlp->nlp_class_sup |= FC_COS_CLASS4; |
| 679 | ndlp->nlp_maxframe = ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | |
| 680 | sp->cmn.bbRcvSizeLsb; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 681 | |
| 682 | fabric_param_changed = lpfc_check_clean_addr_bit(vport, sp); |
| 683 | memcpy(&vport->fabric_portname, &sp->portName, |
| 684 | sizeof(struct lpfc_name)); |
| 685 | memcpy(&vport->fabric_nodename, &sp->nodeName, |
| 686 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 687 | memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm)); |
| 688 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 689 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
| 690 | if (sp->cmn.response_multiple_NPort) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 691 | lpfc_printf_vlog(vport, KERN_WARNING, |
| 692 | LOG_ELS | LOG_VPORT, |
| 693 | "1816 FLOGI NPIV supported, " |
| 694 | "response data 0x%x\n", |
| 695 | sp->cmn.response_multiple_NPort); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 696 | spin_lock_irq(&phba->hbalock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 697 | phba->link_flag |= LS_NPIV_FAB_SUPPORTED; |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 698 | spin_unlock_irq(&phba->hbalock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 699 | } else { |
| 700 | /* Because we asked f/w for NPIV it still expects us |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 701 | to call reg_vnpid atleast for the physcial host */ |
| 702 | lpfc_printf_vlog(vport, KERN_WARNING, |
| 703 | LOG_ELS | LOG_VPORT, |
| 704 | "1817 Fabric does not support NPIV " |
| 705 | "- configuring single port mode.\n"); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 706 | spin_lock_irq(&phba->hbalock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 707 | phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED; |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 708 | spin_unlock_irq(&phba->hbalock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 709 | } |
| 710 | } |
| 711 | |
James Smart | ae05ebe | 2013-03-01 16:35:38 -0500 | [diff] [blame] | 712 | /* |
| 713 | * For FC we need to do some special processing because of the SLI |
| 714 | * Port's default settings of the Common Service Parameters. |
| 715 | */ |
| 716 | if (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) { |
| 717 | /* If physical FC port changed, unreg VFI and ALL VPIs / RPIs */ |
| 718 | if ((phba->sli_rev == LPFC_SLI_REV4) && fabric_param_changed) |
| 719 | lpfc_unregister_fcf_prep(phba); |
| 720 | |
| 721 | /* This should just update the VFI CSPs*/ |
| 722 | if (vport->fc_flag & FC_VFI_REGISTERED) |
| 723 | lpfc_issue_reg_vfi(vport); |
| 724 | } |
| 725 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 726 | if (fabric_param_changed && |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 727 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 728 | |
| 729 | /* If our NportID changed, we need to ensure all |
| 730 | * remaining NPORTs get unreg_login'ed. |
| 731 | */ |
| 732 | list_for_each_entry_safe(np, next_np, |
| 733 | &vport->fc_nodes, nlp_listp) { |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 734 | if (!NLP_CHK_NODE_ACT(np)) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 735 | continue; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 736 | if ((np->nlp_state != NLP_STE_NPR_NODE) || |
| 737 | !(np->nlp_flag & NLP_NPR_ADISC)) |
| 738 | continue; |
| 739 | spin_lock_irq(shost->host_lock); |
| 740 | np->nlp_flag &= ~NLP_NPR_ADISC; |
| 741 | spin_unlock_irq(shost->host_lock); |
| 742 | lpfc_unreg_rpi(vport, np); |
| 743 | } |
James Smart | 78730cf | 2010-04-06 15:06:30 -0400 | [diff] [blame] | 744 | lpfc_cleanup_pending_mbox(vport); |
James Smart | 5af5eee | 2010-10-22 11:06:38 -0400 | [diff] [blame] | 745 | |
James Smart | 5248a74 | 2011-07-22 18:37:06 -0400 | [diff] [blame] | 746 | if (phba->sli_rev == LPFC_SLI_REV4) { |
James Smart | 5af5eee | 2010-10-22 11:06:38 -0400 | [diff] [blame] | 747 | lpfc_sli4_unreg_all_rpis(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 748 | lpfc_mbx_unreg_vpi(vport); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 749 | spin_lock_irq(shost->host_lock); |
James Smart | ecfd03c | 2010-02-12 14:41:27 -0500 | [diff] [blame] | 750 | vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; |
| 751 | spin_unlock_irq(shost->host_lock); |
| 752 | } |
James Smart | 27aa1b7 | 2012-05-09 21:18:49 -0400 | [diff] [blame] | 753 | |
| 754 | /* |
| 755 | * For SLI3 and SLI4, the VPI needs to be reregistered in |
| 756 | * response to this fabric parameter change event. |
| 757 | */ |
| 758 | spin_lock_irq(shost->host_lock); |
| 759 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
| 760 | spin_unlock_irq(shost->host_lock); |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 761 | } else if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 762 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 763 | /* |
| 764 | * Driver needs to re-reg VPI in order for f/w |
| 765 | * to update the MAC address. |
| 766 | */ |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 767 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 768 | lpfc_register_new_vport(phba, vport, ndlp); |
| 769 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 770 | } |
| 771 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 772 | if (phba->sli_rev < LPFC_SLI_REV4) { |
| 773 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE); |
| 774 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED && |
| 775 | vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) |
| 776 | lpfc_register_new_vport(phba, vport, ndlp); |
| 777 | else |
| 778 | lpfc_issue_fabric_reglogin(vport); |
| 779 | } else { |
| 780 | ndlp->nlp_type |= NLP_FABRIC; |
| 781 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 782 | if ((!(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) && |
| 783 | (vport->vpi_state & LPFC_VPI_REGISTERED)) { |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 784 | lpfc_start_fdiscs(phba); |
| 785 | lpfc_do_scr_ns_plogi(phba, vport); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 786 | } else if (vport->fc_flag & FC_VFI_REGISTERED) |
James Smart | ecfd03c | 2010-02-12 14:41:27 -0500 | [diff] [blame] | 787 | lpfc_issue_init_vpi(vport); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 788 | else { |
| 789 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 790 | "3135 Need register VFI: (x%x/%x)\n", |
| 791 | vport->fc_prevDID, vport->fc_myDID); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 792 | lpfc_issue_reg_vfi(vport); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 793 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 794 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 795 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 796 | } |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 797 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 798 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 799 | * lpfc_cmpl_els_flogi_nport - Completion function for flogi to an N_Port |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 800 | * @vport: pointer to a host virtual N_Port data structure. |
| 801 | * @ndlp: pointer to a node-list data structure. |
| 802 | * @sp: pointer to service parameter data structure. |
| 803 | * |
| 804 | * This routine is invoked by the lpfc_cmpl_els_flogi() completion callback |
| 805 | * function to handle the completion of a Fabric Login (FLOGI) into an N_Port |
| 806 | * in a point-to-point topology. First, the @vport's N_Port Name is compared |
| 807 | * with the received N_Port Name: if the @vport's N_Port Name is greater than |
| 808 | * the received N_Port Name lexicographically, this node shall assign local |
| 809 | * N_Port ID (PT2PT_LocalID: 1) and remote N_Port ID (PT2PT_RemoteID: 2) and |
| 810 | * will send out Port Login (PLOGI) with the N_Port IDs assigned. Otherwise, |
| 811 | * this node shall just wait for the remote node to issue PLOGI and assign |
| 812 | * N_Port IDs. |
| 813 | * |
| 814 | * Return code |
| 815 | * 0 - Success |
| 816 | * -ENXIO - Fail |
| 817 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 818 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 819 | lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 820 | struct serv_parm *sp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 821 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 822 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 823 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 824 | LPFC_MBOXQ_t *mbox; |
| 825 | int rc; |
| 826 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 827 | spin_lock_irq(shost->host_lock); |
| 828 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
| 829 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 830 | |
| 831 | phba->fc_edtov = FF_DEF_EDTOV; |
| 832 | phba->fc_ratov = FF_DEF_RATOV; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 833 | rc = memcmp(&vport->fc_portname, &sp->portName, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 834 | sizeof(vport->fc_portname)); |
James Smart | 2eb6862 | 2012-09-29 11:32:27 -0400 | [diff] [blame] | 835 | memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm)); |
| 836 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 837 | if (rc >= 0) { |
| 838 | /* This side will initiate the PLOGI */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 839 | spin_lock_irq(shost->host_lock); |
| 840 | vport->fc_flag |= FC_PT2PT_PLOGI; |
| 841 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 842 | |
| 843 | /* |
| 844 | * N_Port ID cannot be 0, set our to LocalID the other |
| 845 | * side will be RemoteID. |
| 846 | */ |
| 847 | |
| 848 | /* not equal */ |
| 849 | if (rc) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 850 | vport->fc_myDID = PT2PT_LocalID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 851 | |
| 852 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 853 | if (!mbox) |
| 854 | goto fail; |
| 855 | |
| 856 | lpfc_config_link(phba, mbox); |
| 857 | |
| 858 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 859 | mbox->vport = vport; |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 860 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 861 | if (rc == MBX_NOT_FINISHED) { |
| 862 | mempool_free(mbox, phba->mbox_mem_pool); |
| 863 | goto fail; |
| 864 | } |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 865 | |
| 866 | /* |
| 867 | * For SLI4, the VFI/VPI are registered AFTER the |
| 868 | * Nport with the higher WWPN sends the PLOGI with |
| 869 | * an assigned NPortId. |
| 870 | */ |
| 871 | |
| 872 | /* not equal */ |
| 873 | if ((phba->sli_rev == LPFC_SLI_REV4) && rc) |
| 874 | lpfc_issue_reg_vfi(vport); |
| 875 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 876 | /* Decrement ndlp reference count indicating that ndlp can be |
| 877 | * safely released when other references to it are done. |
| 878 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 879 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 880 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 881 | ndlp = lpfc_findnode_did(vport, PT2PT_RemoteID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 882 | if (!ndlp) { |
| 883 | /* |
| 884 | * Cannot find existing Fabric ndlp, so allocate a |
| 885 | * new one |
| 886 | */ |
| 887 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 888 | if (!ndlp) |
| 889 | goto fail; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 890 | lpfc_nlp_init(vport, ndlp, PT2PT_RemoteID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 891 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 892 | ndlp = lpfc_enable_node(vport, ndlp, |
| 893 | NLP_STE_UNUSED_NODE); |
| 894 | if(!ndlp) |
| 895 | goto fail; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | memcpy(&ndlp->nlp_portname, &sp->portName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 899 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 900 | memcpy(&ndlp->nlp_nodename, &sp->nodeName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 901 | sizeof(struct lpfc_name)); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 902 | /* Set state will put ndlp onto node list if not already done */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 903 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 904 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 905 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 906 | spin_unlock_irq(shost->host_lock); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 907 | } else |
| 908 | /* This side will wait for the PLOGI, decrement ndlp reference |
| 909 | * count indicating that ndlp can be released when other |
| 910 | * references to it are done. |
| 911 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 912 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 913 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 914 | /* If we are pt2pt with another NPort, force NPIV off! */ |
| 915 | phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; |
| 916 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 917 | spin_lock_irq(shost->host_lock); |
| 918 | vport->fc_flag |= FC_PT2PT; |
| 919 | spin_unlock_irq(shost->host_lock); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 920 | /* If physical FC port changed, unreg VFI and ALL VPIs / RPIs */ |
| 921 | if ((phba->sli_rev == LPFC_SLI_REV4) && phba->fc_topology_changed) { |
| 922 | lpfc_unregister_fcf_prep(phba); |
| 923 | |
| 924 | /* The FC_VFI_REGISTERED flag will get clear in the cmpl |
| 925 | * handler for unreg_vfi, but if we don't force the |
| 926 | * FC_VFI_REGISTERED flag then the reg_vfi mailbox could be |
| 927 | * built with the update bit set instead of just the vp bit to |
| 928 | * change the Nport ID. We need to have the vp set and the |
| 929 | * Upd cleared on topology changes. |
| 930 | */ |
| 931 | spin_lock_irq(shost->host_lock); |
| 932 | vport->fc_flag &= ~FC_VFI_REGISTERED; |
| 933 | spin_unlock_irq(shost->host_lock); |
| 934 | phba->fc_topology_changed = 0; |
| 935 | lpfc_issue_reg_vfi(vport); |
| 936 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 937 | |
| 938 | /* Start discovery - this should just do CLEAR_LA */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 939 | lpfc_disc_start(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 940 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 941 | fail: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 942 | return -ENXIO; |
| 943 | } |
| 944 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 945 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 946 | * lpfc_cmpl_els_flogi - Completion callback function for flogi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 947 | * @phba: pointer to lpfc hba data structure. |
| 948 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 949 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 950 | * |
| 951 | * This routine is the top-level completion callback function for issuing |
| 952 | * a Fabric Login (FLOGI) command. If the response IOCB reported error, |
| 953 | * the lpfc_els_retry() routine shall be invoked to retry the FLOGI. If |
| 954 | * retry has been made (either immediately or delayed with lpfc_els_retry() |
| 955 | * returning 1), the command IOCB will be released and function returned. |
| 956 | * If the retry attempt has been given up (possibly reach the maximum |
| 957 | * number of retries), one additional decrement of ndlp reference shall be |
| 958 | * invoked before going out after releasing the command IOCB. This will |
| 959 | * actually release the remote node (Note, lpfc_els_free_iocb() will also |
| 960 | * invoke one decrement of ndlp reference count). If no error reported in |
| 961 | * the IOCB status, the command Port ID field is used to determine whether |
| 962 | * this is a point-to-point topology or a fabric topology: if the Port ID |
| 963 | * field is assigned, it is a fabric topology; otherwise, it is a |
| 964 | * point-to-point topology. The routine lpfc_cmpl_els_flogi_fabric() or |
| 965 | * lpfc_cmpl_els_flogi_nport() shall be invoked accordingly to handle the |
| 966 | * specific topology completion conditions. |
| 967 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 968 | static void |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 969 | lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 970 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 971 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 972 | struct lpfc_vport *vport = cmdiocb->vport; |
| 973 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 974 | IOCB_t *irsp = &rspiocb->iocb; |
| 975 | struct lpfc_nodelist *ndlp = cmdiocb->context1; |
| 976 | struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp; |
| 977 | struct serv_parm *sp; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 978 | uint16_t fcf_index; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 979 | int rc; |
| 980 | |
| 981 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 982 | if (lpfc_els_chk_latt(vport)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 983 | /* One additional decrement on node reference count to |
| 984 | * trigger the release of the node |
| 985 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 986 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 987 | goto out; |
| 988 | } |
| 989 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 990 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 991 | "FLOGI cmpl: status:x%x/x%x state:x%x", |
| 992 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 993 | vport->port_state); |
| 994 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 995 | if (irsp->ulpStatus) { |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 996 | /* |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 997 | * In case of FIP mode, perform roundrobin FCF failover |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 998 | * due to new FCF discovery |
| 999 | */ |
| 1000 | if ((phba->hba_flag & HBA_FIP_SUPPORT) && |
James Smart | 80c1784 | 2012-03-01 22:35:45 -0500 | [diff] [blame] | 1001 | (phba->fcf.fcf_flag & FCF_DISCOVERY)) { |
| 1002 | if (phba->link_state < LPFC_LINK_UP) |
| 1003 | goto stop_rr_fcf_flogi; |
| 1004 | if ((phba->fcoe_cvl_eventtag_attn == |
| 1005 | phba->fcoe_cvl_eventtag) && |
| 1006 | (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 1007 | ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) == |
| 1008 | IOERR_SLI_ABORTED)) |
James Smart | 80c1784 | 2012-03-01 22:35:45 -0500 | [diff] [blame] | 1009 | goto stop_rr_fcf_flogi; |
| 1010 | else |
| 1011 | phba->fcoe_cvl_eventtag_attn = |
| 1012 | phba->fcoe_cvl_eventtag; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1013 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP | LOG_ELS, |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 1014 | "2611 FLOGI failed on FCF (x%x), " |
| 1015 | "status:x%x/x%x, tmo:x%x, perform " |
| 1016 | "roundrobin FCF failover\n", |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1017 | phba->fcf.current_rec.fcf_indx, |
| 1018 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1019 | irsp->ulpTimeout); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 1020 | lpfc_sli4_set_fcf_flogi_fail(phba, |
| 1021 | phba->fcf.current_rec.fcf_indx); |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1022 | fcf_index = lpfc_sli4_fcf_rr_next_index_get(phba); |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 1023 | rc = lpfc_sli4_fcf_rr_next_proc(vport, fcf_index); |
| 1024 | if (rc) |
| 1025 | goto out; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1026 | } |
| 1027 | |
James Smart | 80c1784 | 2012-03-01 22:35:45 -0500 | [diff] [blame] | 1028 | stop_rr_fcf_flogi: |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1029 | /* FLOGI failure */ |
| 1030 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1031 | "2858 FLOGI failure Status:x%x/x%x TMO:x%x\n", |
| 1032 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1033 | irsp->ulpTimeout); |
| 1034 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1035 | /* Check for retry */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1036 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1037 | goto out; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1038 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1039 | /* FLOGI failure */ |
| 1040 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1041 | "0100 FLOGI failure Status:x%x/x%x TMO:x%x\n", |
| 1042 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1043 | irsp->ulpTimeout); |
| 1044 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1045 | /* FLOGI failed, so there is no fabric */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1046 | spin_lock_irq(shost->host_lock); |
| 1047 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
| 1048 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1049 | |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 1050 | /* If private loop, then allow max outstanding els to be |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1051 | * LPFC_MAX_DISC_THREADS (32). Scanning in the case of no |
| 1052 | * alpa map would take too long otherwise. |
| 1053 | */ |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 1054 | if (phba->alpa_map[0] == 0) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1055 | vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 1056 | if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 1057 | (!(vport->fc_flag & FC_VFI_REGISTERED) || |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 1058 | (vport->fc_prevDID != vport->fc_myDID) || |
| 1059 | phba->fc_topology_changed)) { |
| 1060 | if (vport->fc_flag & FC_VFI_REGISTERED) { |
| 1061 | if (phba->fc_topology_changed) { |
| 1062 | lpfc_unregister_fcf_prep(phba); |
| 1063 | spin_lock_irq(shost->host_lock); |
| 1064 | vport->fc_flag &= ~FC_VFI_REGISTERED; |
| 1065 | spin_unlock_irq(shost->host_lock); |
| 1066 | phba->fc_topology_changed = 0; |
| 1067 | } else { |
| 1068 | lpfc_sli4_unreg_all_rpis(vport); |
| 1069 | } |
| 1070 | } |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 1071 | lpfc_issue_reg_vfi(vport); |
| 1072 | lpfc_nlp_put(ndlp); |
| 1073 | goto out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1074 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1075 | goto flogifail; |
| 1076 | } |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 1077 | spin_lock_irq(shost->host_lock); |
| 1078 | vport->fc_flag &= ~FC_VPORT_CVL_RCVD; |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 1079 | vport->fc_flag &= ~FC_VPORT_LOGO_RCVD; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 1080 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1081 | |
| 1082 | /* |
| 1083 | * The FLogI succeeded. Sync the data for the CPU before |
| 1084 | * accessing it. |
| 1085 | */ |
| 1086 | prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list); |
| 1087 | |
| 1088 | sp = prsp->virt + sizeof(uint32_t); |
| 1089 | |
| 1090 | /* FLOGI completes successfully */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1091 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
James Smart | 88f43a0 | 2013-04-17 20:19:44 -0400 | [diff] [blame] | 1092 | "0101 FLOGI completes successfully, I/O tag:x%x, " |
| 1093 | "Data: x%x x%x x%x x%x x%x x%x\n", cmdiocb->iotag, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1094 | irsp->un.ulpWord[4], sp->cmn.e_d_tov, |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 1095 | sp->cmn.w2.r_a_tov, sp->cmn.edtovResolution, |
| 1096 | vport->port_state, vport->fc_flag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1097 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1098 | if (vport->port_state == LPFC_FLOGI) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1099 | /* |
| 1100 | * If Common Service Parameters indicate Nport |
| 1101 | * we are point to point, if Fport we are Fabric. |
| 1102 | */ |
| 1103 | if (sp->cmn.fPort) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1104 | rc = lpfc_cmpl_els_flogi_fabric(vport, ndlp, sp, irsp); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1105 | else if (!(phba->hba_flag & HBA_FCOE_MODE)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1106 | rc = lpfc_cmpl_els_flogi_nport(vport, ndlp, sp); |
James Smart | dbb6b3a | 2010-06-08 18:31:37 -0400 | [diff] [blame] | 1107 | else { |
| 1108 | lpfc_printf_vlog(vport, KERN_ERR, |
| 1109 | LOG_FIP | LOG_ELS, |
| 1110 | "2831 FLOGI response with cleared Fabric " |
| 1111 | "bit fcf_index 0x%x " |
| 1112 | "Switch Name %02x%02x%02x%02x%02x%02x%02x%02x " |
| 1113 | "Fabric Name " |
| 1114 | "%02x%02x%02x%02x%02x%02x%02x%02x\n", |
| 1115 | phba->fcf.current_rec.fcf_indx, |
| 1116 | phba->fcf.current_rec.switch_name[0], |
| 1117 | phba->fcf.current_rec.switch_name[1], |
| 1118 | phba->fcf.current_rec.switch_name[2], |
| 1119 | phba->fcf.current_rec.switch_name[3], |
| 1120 | phba->fcf.current_rec.switch_name[4], |
| 1121 | phba->fcf.current_rec.switch_name[5], |
| 1122 | phba->fcf.current_rec.switch_name[6], |
| 1123 | phba->fcf.current_rec.switch_name[7], |
| 1124 | phba->fcf.current_rec.fabric_name[0], |
| 1125 | phba->fcf.current_rec.fabric_name[1], |
| 1126 | phba->fcf.current_rec.fabric_name[2], |
| 1127 | phba->fcf.current_rec.fabric_name[3], |
| 1128 | phba->fcf.current_rec.fabric_name[4], |
| 1129 | phba->fcf.current_rec.fabric_name[5], |
| 1130 | phba->fcf.current_rec.fabric_name[6], |
| 1131 | phba->fcf.current_rec.fabric_name[7]); |
| 1132 | lpfc_nlp_put(ndlp); |
| 1133 | spin_lock_irq(&phba->hbalock); |
| 1134 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 1135 | phba->hba_flag &= ~(FCF_RR_INPROG | HBA_DEVLOSS_TMO); |
James Smart | dbb6b3a | 2010-06-08 18:31:37 -0400 | [diff] [blame] | 1136 | spin_unlock_irq(&phba->hbalock); |
| 1137 | goto out; |
| 1138 | } |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1139 | if (!rc) { |
| 1140 | /* Mark the FCF discovery process done */ |
James Smart | 999d813 | 2010-03-15 11:24:56 -0400 | [diff] [blame] | 1141 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 1142 | lpfc_printf_vlog(vport, KERN_INFO, LOG_FIP | |
| 1143 | LOG_ELS, |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 1144 | "2769 FLOGI to FCF (x%x) " |
| 1145 | "completed successfully\n", |
James Smart | 999d813 | 2010-03-15 11:24:56 -0400 | [diff] [blame] | 1146 | phba->fcf.current_rec.fcf_indx); |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1147 | spin_lock_irq(&phba->hbalock); |
| 1148 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 1149 | phba->hba_flag &= ~(FCF_RR_INPROG | HBA_DEVLOSS_TMO); |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1150 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1151 | goto out; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1152 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | flogifail: |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 1156 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1157 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1158 | if (!lpfc_error_lost_link(irsp)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1159 | /* FLOGI failed, so just use loop map to make discovery list */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1160 | lpfc_disc_list_loopmap(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1161 | |
| 1162 | /* Start discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1163 | lpfc_disc_start(vport); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1164 | } else if (((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 1165 | (((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) != |
| 1166 | IOERR_SLI_ABORTED) && |
| 1167 | ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) != |
| 1168 | IOERR_SLI_DOWN))) && |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1169 | (phba->link_state != LPFC_CLEAR_LA)) { |
| 1170 | /* If FLOGI failed enable link interrupt. */ |
| 1171 | lpfc_issue_clear_la(phba, vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1172 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1173 | out: |
| 1174 | lpfc_els_free_iocb(phba, cmdiocb); |
| 1175 | } |
| 1176 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1177 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1178 | * lpfc_issue_els_flogi - Issue an flogi iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1179 | * @vport: pointer to a host virtual N_Port data structure. |
| 1180 | * @ndlp: pointer to a node-list data structure. |
| 1181 | * @retry: number of retries to the command IOCB. |
| 1182 | * |
| 1183 | * This routine issues a Fabric Login (FLOGI) Request ELS command |
| 1184 | * for a @vport. The initiator service parameters are put into the payload |
| 1185 | * of the FLOGI Request IOCB and the top-level callback function pointer |
| 1186 | * to lpfc_cmpl_els_flogi() routine is put to the IOCB completion callback |
| 1187 | * function field. The lpfc_issue_fabric_iocb routine is invoked to send |
| 1188 | * out FLOGI ELS command with one outstanding fabric IOCB at a time. |
| 1189 | * |
| 1190 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 1191 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 1192 | * will be stored into the context1 field of the IOCB for the completion |
| 1193 | * callback function to the FLOGI ELS command. |
| 1194 | * |
| 1195 | * Return code |
| 1196 | * 0 - successfully issued flogi iocb for @vport |
| 1197 | * 1 - failed to issue flogi iocb for @vport |
| 1198 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1199 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1200 | lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1201 | uint8_t retry) |
| 1202 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1203 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1204 | struct serv_parm *sp; |
| 1205 | IOCB_t *icmd; |
| 1206 | struct lpfc_iocbq *elsiocb; |
| 1207 | struct lpfc_sli_ring *pring; |
| 1208 | uint8_t *pcmd; |
| 1209 | uint16_t cmdsize; |
| 1210 | uint32_t tmo; |
| 1211 | int rc; |
| 1212 | |
| 1213 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
| 1214 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1215 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1216 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 1217 | ndlp->nlp_DID, ELS_CMD_FLOGI); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1218 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1219 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1220 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1221 | |
| 1222 | icmd = &elsiocb->iocb; |
| 1223 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 1224 | |
| 1225 | /* For FLOGI request, remainder of payload is service parameters */ |
| 1226 | *((uint32_t *) (pcmd)) = ELS_CMD_FLOGI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1227 | pcmd += sizeof(uint32_t); |
| 1228 | memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1229 | sp = (struct serv_parm *) pcmd; |
| 1230 | |
| 1231 | /* Setup CSPs accordingly for Fabric */ |
| 1232 | sp->cmn.e_d_tov = 0; |
| 1233 | sp->cmn.w2.r_a_tov = 0; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 1234 | sp->cmn.virtual_fabric_support = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1235 | sp->cls1.classValid = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1236 | if (sp->cmn.fcphLow < FC_PH3) |
| 1237 | sp->cmn.fcphLow = FC_PH3; |
| 1238 | if (sp->cmn.fcphHigh < FC_PH3) |
| 1239 | sp->cmn.fcphHigh = FC_PH3; |
| 1240 | |
James Smart | c31098c | 2011-04-16 11:03:33 -0400 | [diff] [blame] | 1241 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1242 | if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == |
| 1243 | LPFC_SLI_INTF_IF_TYPE_0) { |
| 1244 | elsiocb->iocb.ulpCt_h = ((SLI4_CT_FCFI >> 1) & 1); |
| 1245 | elsiocb->iocb.ulpCt_l = (SLI4_CT_FCFI & 1); |
| 1246 | /* FLOGI needs to be 3 for WQE FCFI */ |
| 1247 | /* Set the fcfi to the fcfi we registered with */ |
| 1248 | elsiocb->iocb.ulpContext = phba->fcf.fcfi; |
| 1249 | } |
James Smart | 0f37887 | 2012-10-31 14:45:01 -0400 | [diff] [blame] | 1250 | /* Can't do SLI4 class2 without support sequence coalescing */ |
| 1251 | sp->cls2.classValid = 0; |
| 1252 | sp->cls2.seqDelivery = 0; |
James Smart | 5248a74 | 2011-07-22 18:37:06 -0400 | [diff] [blame] | 1253 | } else { |
James Smart | 0f37887 | 2012-10-31 14:45:01 -0400 | [diff] [blame] | 1254 | /* Historical, setting sequential-delivery bit for SLI3 */ |
| 1255 | sp->cls2.seqDelivery = (sp->cls2.classValid) ? 1 : 0; |
| 1256 | sp->cls3.seqDelivery = (sp->cls3.classValid) ? 1 : 0; |
James Smart | 5248a74 | 2011-07-22 18:37:06 -0400 | [diff] [blame] | 1257 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
| 1258 | sp->cmn.request_multiple_Nport = 1; |
| 1259 | /* For FLOGI, Let FLOGI rsp set the NPortID for VPI 0 */ |
| 1260 | icmd->ulpCt_h = 1; |
| 1261 | icmd->ulpCt_l = 0; |
| 1262 | } else |
| 1263 | sp->cmn.request_multiple_Nport = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1264 | } |
| 1265 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1266 | if (phba->fc_topology != LPFC_TOPOLOGY_LOOP) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1267 | icmd->un.elsreq64.myID = 0; |
| 1268 | icmd->un.elsreq64.fl = 1; |
| 1269 | } |
| 1270 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1271 | tmo = phba->fc_ratov; |
| 1272 | phba->fc_ratov = LPFC_DISC_FLOGI_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1273 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1274 | phba->fc_ratov = tmo; |
| 1275 | |
| 1276 | phba->fc_stat.elsXmitFLOGI++; |
| 1277 | elsiocb->iocb_cmpl = lpfc_cmpl_els_flogi; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1278 | |
| 1279 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1280 | "Issue FLOGI: opt:x%x", |
| 1281 | phba->sli3_options, 0, 0); |
| 1282 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1283 | rc = lpfc_issue_fabric_iocb(phba, elsiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1284 | if (rc == IOCB_ERROR) { |
| 1285 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1286 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1287 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1288 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1289 | } |
| 1290 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1291 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1292 | * lpfc_els_abort_flogi - Abort all outstanding flogi iocbs |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1293 | * @phba: pointer to lpfc hba data structure. |
| 1294 | * |
| 1295 | * This routine aborts all the outstanding Fabric Login (FLOGI) IOCBs |
| 1296 | * with a @phba. This routine walks all the outstanding IOCBs on the txcmplq |
| 1297 | * list and issues an abort IOCB commond on each outstanding IOCB that |
| 1298 | * contains a active Fabric_DID ndlp. Note that this function is to issue |
| 1299 | * the abort IOCB command on all the outstanding IOCBs, thus when this |
| 1300 | * function returns, it does not guarantee all the IOCBs are actually aborted. |
| 1301 | * |
| 1302 | * Return code |
Daniel Mack | 3ad2f3f | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 1303 | * 0 - Successfully issued abort iocb on all outstanding flogis (Always 0) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1304 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1305 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1306 | lpfc_els_abort_flogi(struct lpfc_hba *phba) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1307 | { |
| 1308 | struct lpfc_sli_ring *pring; |
| 1309 | struct lpfc_iocbq *iocb, *next_iocb; |
| 1310 | struct lpfc_nodelist *ndlp; |
| 1311 | IOCB_t *icmd; |
| 1312 | |
| 1313 | /* Abort outstanding I/O on NPort <nlp_DID> */ |
| 1314 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1315 | "0201 Abort outstanding I/O on NPort x%x\n", |
| 1316 | Fabric_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1317 | |
| 1318 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
| 1319 | |
| 1320 | /* |
| 1321 | * Check the txcmplq for an iocb that matches the nport the driver is |
| 1322 | * searching for. |
| 1323 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1324 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1325 | list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) { |
| 1326 | icmd = &iocb->iocb; |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 1327 | if (icmd->ulpCommand == CMD_ELS_REQUEST64_CR) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1328 | ndlp = (struct lpfc_nodelist *)(iocb->context1); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1329 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 1330 | (ndlp->nlp_DID == Fabric_DID)) |
James Smart | 0795107 | 2007-04-25 09:51:38 -0400 | [diff] [blame] | 1331 | lpfc_sli_issue_abort_iotag(phba, pring, iocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1332 | } |
| 1333 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1334 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1335 | |
| 1336 | return 0; |
| 1337 | } |
| 1338 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1339 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1340 | * lpfc_initial_flogi - Issue an initial fabric login for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1341 | * @vport: pointer to a host virtual N_Port data structure. |
| 1342 | * |
| 1343 | * This routine issues an initial Fabric Login (FLOGI) for the @vport |
| 1344 | * specified. It first searches the ndlp with the Fabric_DID (0xfffffe) from |
| 1345 | * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and |
| 1346 | * put it into the @vport's ndlp list. If an inactive ndlp found on the list, |
| 1347 | * it will just be enabled and made active. The lpfc_issue_els_flogi() routine |
| 1348 | * is then invoked with the @vport and the ndlp to perform the FLOGI for the |
| 1349 | * @vport. |
| 1350 | * |
| 1351 | * Return code |
| 1352 | * 0 - failed to issue initial flogi for @vport |
| 1353 | * 1 - successfully issued initial flogi for @vport |
| 1354 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1355 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1356 | lpfc_initial_flogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1357 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1358 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1359 | struct lpfc_nodelist *ndlp; |
| 1360 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1361 | vport->port_state = LPFC_FLOGI; |
| 1362 | lpfc_set_disctmo(vport); |
| 1363 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1364 | /* First look for the Fabric ndlp */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1365 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1366 | if (!ndlp) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1367 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1368 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 1369 | if (!ndlp) |
| 1370 | return 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1371 | lpfc_nlp_init(vport, ndlp, Fabric_DID); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 1372 | /* Set the node type */ |
| 1373 | ndlp->nlp_type |= NLP_FABRIC; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1374 | /* Put ndlp onto node list */ |
| 1375 | lpfc_enqueue_node(vport, ndlp); |
| 1376 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 1377 | /* re-setup ndlp without removing from node list */ |
| 1378 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 1379 | if (!ndlp) |
| 1380 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1381 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1382 | |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 1383 | if (lpfc_issue_els_flogi(vport, ndlp, 0)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1384 | /* This decrement of reference count to node shall kick off |
| 1385 | * the release of the node. |
| 1386 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 1387 | lpfc_nlp_put(ndlp); |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 1388 | return 0; |
| 1389 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1390 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1391 | } |
| 1392 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1393 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1394 | * lpfc_initial_fdisc - Issue an initial fabric discovery for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1395 | * @vport: pointer to a host virtual N_Port data structure. |
| 1396 | * |
| 1397 | * This routine issues an initial Fabric Discover (FDISC) for the @vport |
| 1398 | * specified. It first searches the ndlp with the Fabric_DID (0xfffffe) from |
| 1399 | * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and |
| 1400 | * put it into the @vport's ndlp list. If an inactive ndlp found on the list, |
| 1401 | * it will just be enabled and made active. The lpfc_issue_els_fdisc() routine |
| 1402 | * is then invoked with the @vport and the ndlp to perform the FDISC for the |
| 1403 | * @vport. |
| 1404 | * |
| 1405 | * Return code |
| 1406 | * 0 - failed to issue initial fdisc for @vport |
| 1407 | * 1 - successfully issued initial fdisc for @vport |
| 1408 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1409 | int |
| 1410 | lpfc_initial_fdisc(struct lpfc_vport *vport) |
| 1411 | { |
| 1412 | struct lpfc_hba *phba = vport->phba; |
| 1413 | struct lpfc_nodelist *ndlp; |
| 1414 | |
| 1415 | /* First look for the Fabric ndlp */ |
| 1416 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
| 1417 | if (!ndlp) { |
| 1418 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
| 1419 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 1420 | if (!ndlp) |
| 1421 | return 0; |
| 1422 | lpfc_nlp_init(vport, ndlp, Fabric_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1423 | /* Put ndlp onto node list */ |
| 1424 | lpfc_enqueue_node(vport, ndlp); |
| 1425 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 1426 | /* re-setup ndlp without removing from node list */ |
| 1427 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 1428 | if (!ndlp) |
| 1429 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1430 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1431 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1432 | if (lpfc_issue_els_fdisc(vport, ndlp, 0)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1433 | /* decrement node reference count to trigger the release of |
| 1434 | * the node. |
| 1435 | */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1436 | lpfc_nlp_put(ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1437 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1438 | } |
| 1439 | return 1; |
| 1440 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1441 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1442 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1443 | * lpfc_more_plogi - Check and issue remaining plogis for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1444 | * @vport: pointer to a host virtual N_Port data structure. |
| 1445 | * |
| 1446 | * This routine checks whether there are more remaining Port Logins |
| 1447 | * (PLOGI) to be issued for the @vport. If so, it will invoke the routine |
| 1448 | * lpfc_els_disc_plogi() to go through the Node Port Recovery (NPR) nodes |
| 1449 | * to issue ELS PLOGIs up to the configured discover threads with the |
| 1450 | * @vport (@vport->cfg_discovery_threads). The function also decrement |
| 1451 | * the @vport's num_disc_node by 1 if it is not already 0. |
| 1452 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1453 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1454 | lpfc_more_plogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1455 | { |
| 1456 | int sentplogi; |
| 1457 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1458 | if (vport->num_disc_nodes) |
| 1459 | vport->num_disc_nodes--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1460 | |
| 1461 | /* Continue discovery with <num_disc_nodes> PLOGIs to go */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1462 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1463 | "0232 Continue discovery with %d PLOGIs to go " |
| 1464 | "Data: x%x x%x x%x\n", |
| 1465 | vport->num_disc_nodes, vport->fc_plogi_cnt, |
| 1466 | vport->fc_flag, vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1467 | /* Check to see if there are more PLOGIs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1468 | if (vport->fc_flag & FC_NLP_MORE) |
| 1469 | /* go thru NPR nodes and issue any remaining ELS PLOGIs */ |
| 1470 | sentplogi = lpfc_els_disc_plogi(vport); |
| 1471 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1472 | return; |
| 1473 | } |
| 1474 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1475 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1476 | * lpfc_plogi_confirm_nport - Confirm pologi wwpn matches stored ndlp |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1477 | * @phba: pointer to lpfc hba data structure. |
| 1478 | * @prsp: pointer to response IOCB payload. |
| 1479 | * @ndlp: pointer to a node-list data structure. |
| 1480 | * |
| 1481 | * This routine checks and indicates whether the WWPN of an N_Port, retrieved |
| 1482 | * from a PLOGI, matches the WWPN that is stored in the @ndlp for that N_POrt. |
| 1483 | * The following cases are considered N_Port confirmed: |
| 1484 | * 1) The N_Port is a Fabric ndlp; 2) The @ndlp is on vport list and matches |
| 1485 | * the WWPN of the N_Port logged into; 3) The @ndlp is not on vport list but |
| 1486 | * it does not have WWPN assigned either. If the WWPN is confirmed, the |
| 1487 | * pointer to the @ndlp will be returned. If the WWPN is not confirmed: |
| 1488 | * 1) if there is a node on vport list other than the @ndlp with the same |
| 1489 | * WWPN of the N_Port PLOGI logged into, the lpfc_unreg_rpi() will be invoked |
| 1490 | * on that node to release the RPI associated with the node; 2) if there is |
| 1491 | * no node found on vport list with the same WWPN of the N_Port PLOGI logged |
| 1492 | * into, a new node shall be allocated (or activated). In either case, the |
| 1493 | * parameters of the @ndlp shall be copied to the new_ndlp, the @ndlp shall |
| 1494 | * be released and the new_ndlp shall be put on to the vport node list and |
| 1495 | * its pointer returned as the confirmed node. |
| 1496 | * |
| 1497 | * Note that before the @ndlp got "released", the keepDID from not-matching |
| 1498 | * or inactive "new_ndlp" on the vport node list is assigned to the nlp_DID |
| 1499 | * of the @ndlp. This is because the release of @ndlp is actually to put it |
| 1500 | * into an inactive state on the vport node list and the vport node list |
| 1501 | * management algorithm does not allow two node with a same DID. |
| 1502 | * |
| 1503 | * Return code |
| 1504 | * pointer to the PLOGI N_Port @ndlp |
| 1505 | **/ |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1506 | static struct lpfc_nodelist * |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1507 | lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1508 | struct lpfc_nodelist *ndlp) |
| 1509 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1510 | struct lpfc_vport *vport = ndlp->vport; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1511 | struct lpfc_nodelist *new_ndlp; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1512 | struct lpfc_rport_data *rdata; |
| 1513 | struct fc_rport *rport; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1514 | struct serv_parm *sp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1515 | uint8_t name[sizeof(struct lpfc_name)]; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1516 | uint32_t rc, keepDID = 0; |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1517 | int put_node; |
| 1518 | int put_rport; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1519 | unsigned long *active_rrqs_xri_bitmap = NULL; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1520 | |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1521 | /* Fabric nodes can have the same WWPN so we don't bother searching |
| 1522 | * by WWPN. Just return the ndlp that was given to us. |
| 1523 | */ |
| 1524 | if (ndlp->nlp_type & NLP_FABRIC) |
| 1525 | return ndlp; |
| 1526 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1527 | sp = (struct serv_parm *) ((uint8_t *) prsp + sizeof(uint32_t)); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 1528 | memset(name, 0, sizeof(struct lpfc_name)); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1529 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 1530 | /* Now we find out if the NPort we are logging into, matches the WWPN |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1531 | * we have for that ndlp. If not, we have some work to do. |
| 1532 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1533 | new_ndlp = lpfc_findnode_wwpn(vport, &sp->portName); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1534 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1535 | if (new_ndlp == ndlp && NLP_CHK_NODE_ACT(new_ndlp)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1536 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1537 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1538 | active_rrqs_xri_bitmap = mempool_alloc(phba->active_rrq_pool, |
| 1539 | GFP_KERNEL); |
| 1540 | if (active_rrqs_xri_bitmap) |
| 1541 | memset(active_rrqs_xri_bitmap, 0, |
| 1542 | phba->cfg_rrq_xri_bitmap_sz); |
| 1543 | } |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1544 | |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1545 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1546 | "3178 PLOGI confirm: ndlp %p x%x: new_ndlp %p\n", |
| 1547 | ndlp, ndlp->nlp_DID, new_ndlp); |
| 1548 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1549 | if (!new_ndlp) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1550 | rc = memcmp(&ndlp->nlp_portname, name, |
| 1551 | sizeof(struct lpfc_name)); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1552 | if (!rc) { |
| 1553 | if (active_rrqs_xri_bitmap) |
| 1554 | mempool_free(active_rrqs_xri_bitmap, |
| 1555 | phba->active_rrq_pool); |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1556 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1557 | } |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1558 | new_ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_ATOMIC); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1559 | if (!new_ndlp) { |
| 1560 | if (active_rrqs_xri_bitmap) |
| 1561 | mempool_free(active_rrqs_xri_bitmap, |
| 1562 | phba->active_rrq_pool); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1563 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1564 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1565 | lpfc_nlp_init(vport, new_ndlp, ndlp->nlp_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1566 | } else if (!NLP_CHK_NODE_ACT(new_ndlp)) { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1567 | rc = memcmp(&ndlp->nlp_portname, name, |
| 1568 | sizeof(struct lpfc_name)); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1569 | if (!rc) { |
| 1570 | if (active_rrqs_xri_bitmap) |
| 1571 | mempool_free(active_rrqs_xri_bitmap, |
| 1572 | phba->active_rrq_pool); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1573 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1574 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1575 | new_ndlp = lpfc_enable_node(vport, new_ndlp, |
| 1576 | NLP_STE_UNUSED_NODE); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1577 | if (!new_ndlp) { |
| 1578 | if (active_rrqs_xri_bitmap) |
| 1579 | mempool_free(active_rrqs_xri_bitmap, |
| 1580 | phba->active_rrq_pool); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1581 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1582 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1583 | keepDID = new_ndlp->nlp_DID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1584 | if ((phba->sli_rev == LPFC_SLI_REV4) && active_rrqs_xri_bitmap) |
| 1585 | memcpy(active_rrqs_xri_bitmap, |
| 1586 | new_ndlp->active_rrqs_xri_bitmap, |
| 1587 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1588 | } else { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1589 | keepDID = new_ndlp->nlp_DID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1590 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1591 | active_rrqs_xri_bitmap) |
| 1592 | memcpy(active_rrqs_xri_bitmap, |
| 1593 | new_ndlp->active_rrqs_xri_bitmap, |
| 1594 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1595 | } |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1596 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1597 | lpfc_unreg_rpi(vport, new_ndlp); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1598 | new_ndlp->nlp_DID = ndlp->nlp_DID; |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1599 | new_ndlp->nlp_prev_state = ndlp->nlp_prev_state; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1600 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1601 | memcpy(new_ndlp->active_rrqs_xri_bitmap, |
| 1602 | ndlp->active_rrqs_xri_bitmap, |
| 1603 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1604 | |
| 1605 | if (ndlp->nlp_flag & NLP_NPR_2B_DISC) |
| 1606 | new_ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
| 1607 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
| 1608 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1609 | /* Set state will put new_ndlp on to node list if not already done */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1610 | lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1611 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1612 | /* Move this back to NPR state */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1613 | if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0) { |
| 1614 | /* The new_ndlp is replacing ndlp totally, so we need |
| 1615 | * to put ndlp on UNUSED list and try to free it. |
| 1616 | */ |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1617 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1618 | "3179 PLOGI confirm NEW: %x %x\n", |
| 1619 | new_ndlp->nlp_DID, keepDID); |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1620 | |
| 1621 | /* Fix up the rport accordingly */ |
| 1622 | rport = ndlp->rport; |
| 1623 | if (rport) { |
| 1624 | rdata = rport->dd_data; |
| 1625 | if (rdata->pnode == ndlp) { |
| 1626 | lpfc_nlp_put(ndlp); |
| 1627 | ndlp->rport = NULL; |
| 1628 | rdata->pnode = lpfc_nlp_get(new_ndlp); |
| 1629 | new_ndlp->rport = rport; |
| 1630 | } |
| 1631 | new_ndlp->nlp_type = ndlp->nlp_type; |
| 1632 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1633 | /* We shall actually free the ndlp with both nlp_DID and |
| 1634 | * nlp_portname fields equals 0 to avoid any ndlp on the |
| 1635 | * nodelist never to be used. |
| 1636 | */ |
| 1637 | if (ndlp->nlp_DID == 0) { |
| 1638 | spin_lock_irq(&phba->ndlp_lock); |
| 1639 | NLP_SET_FREE_REQ(ndlp); |
| 1640 | spin_unlock_irq(&phba->ndlp_lock); |
| 1641 | } |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1642 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1643 | /* Two ndlps cannot have the same did on the nodelist */ |
| 1644 | ndlp->nlp_DID = keepDID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1645 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1646 | active_rrqs_xri_bitmap) |
| 1647 | memcpy(ndlp->active_rrqs_xri_bitmap, |
| 1648 | active_rrqs_xri_bitmap, |
| 1649 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1650 | lpfc_drop_node(vport, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1651 | } |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1652 | else { |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1653 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1654 | "3180 PLOGI confirm SWAP: %x %x\n", |
| 1655 | new_ndlp->nlp_DID, keepDID); |
| 1656 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1657 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1658 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1659 | /* Two ndlps cannot have the same did */ |
| 1660 | ndlp->nlp_DID = keepDID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1661 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1662 | active_rrqs_xri_bitmap) |
| 1663 | memcpy(ndlp->active_rrqs_xri_bitmap, |
| 1664 | active_rrqs_xri_bitmap, |
| 1665 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1666 | |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1667 | /* Since we are swapping the ndlp passed in with the new one |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1668 | * and the did has already been swapped, copy over state. |
| 1669 | * The new WWNs are already in new_ndlp since thats what |
| 1670 | * we looked it up by in the begining of this routine. |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1671 | */ |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1672 | new_ndlp->nlp_state = ndlp->nlp_state; |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1673 | |
| 1674 | /* Since we are switching over to the new_ndlp, the old |
| 1675 | * ndlp should be put in the NPR state, unless we have |
| 1676 | * already started re-discovery on it. |
| 1677 | */ |
| 1678 | if ((ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) || |
| 1679 | (ndlp->nlp_state == NLP_STE_MAPPED_NODE)) |
| 1680 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 1681 | |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1682 | /* Fix up the rport accordingly */ |
| 1683 | rport = ndlp->rport; |
| 1684 | if (rport) { |
| 1685 | rdata = rport->dd_data; |
| 1686 | put_node = rdata->pnode != NULL; |
| 1687 | put_rport = ndlp->rport != NULL; |
| 1688 | rdata->pnode = NULL; |
| 1689 | ndlp->rport = NULL; |
| 1690 | if (put_node) |
| 1691 | lpfc_nlp_put(ndlp); |
| 1692 | if (put_rport) |
| 1693 | put_device(&rport->dev); |
| 1694 | } |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1695 | } |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1696 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1697 | active_rrqs_xri_bitmap) |
| 1698 | mempool_free(active_rrqs_xri_bitmap, |
| 1699 | phba->active_rrq_pool); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1700 | return new_ndlp; |
| 1701 | } |
| 1702 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1703 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1704 | * lpfc_end_rscn - Check and handle more rscn for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1705 | * @vport: pointer to a host virtual N_Port data structure. |
| 1706 | * |
| 1707 | * This routine checks whether more Registration State Change |
| 1708 | * Notifications (RSCNs) came in while the discovery state machine was in |
| 1709 | * the FC_RSCN_MODE. If so, the lpfc_els_handle_rscn() routine will be |
| 1710 | * invoked to handle the additional RSCNs for the @vport. Otherwise, the |
| 1711 | * FC_RSCN_MODE bit will be cleared with the @vport to mark as the end of |
| 1712 | * handling the RSCNs. |
| 1713 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1714 | void |
| 1715 | lpfc_end_rscn(struct lpfc_vport *vport) |
| 1716 | { |
| 1717 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 1718 | |
| 1719 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 1720 | /* |
| 1721 | * Check to see if more RSCNs came in while we were |
| 1722 | * processing this one. |
| 1723 | */ |
| 1724 | if (vport->fc_rscn_id_cnt || |
| 1725 | (vport->fc_flag & FC_RSCN_DISCOVERY) != 0) |
| 1726 | lpfc_els_handle_rscn(vport); |
| 1727 | else { |
| 1728 | spin_lock_irq(shost->host_lock); |
| 1729 | vport->fc_flag &= ~FC_RSCN_MODE; |
| 1730 | spin_unlock_irq(shost->host_lock); |
| 1731 | } |
| 1732 | } |
| 1733 | } |
| 1734 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1735 | /** |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1736 | * lpfc_cmpl_els_rrq - Completion handled for els RRQs. |
| 1737 | * @phba: pointer to lpfc hba data structure. |
| 1738 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 1739 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 1740 | * |
| 1741 | * This routine will call the clear rrq function to free the rrq and |
| 1742 | * clear the xri's bit in the ndlp's xri_bitmap. If the ndlp does not |
| 1743 | * exist then the clear_rrq is still called because the rrq needs to |
| 1744 | * be freed. |
| 1745 | **/ |
| 1746 | |
| 1747 | static void |
| 1748 | lpfc_cmpl_els_rrq(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1749 | struct lpfc_iocbq *rspiocb) |
| 1750 | { |
| 1751 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1752 | IOCB_t *irsp; |
| 1753 | struct lpfc_nodelist *ndlp; |
| 1754 | struct lpfc_node_rrq *rrq; |
| 1755 | |
| 1756 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 1757 | rrq = cmdiocb->context_un.rrq; |
| 1758 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 1759 | |
| 1760 | irsp = &rspiocb->iocb; |
| 1761 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1762 | "RRQ cmpl: status:x%x/x%x did:x%x", |
| 1763 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1764 | irsp->un.elsreq64.remoteID); |
| 1765 | |
| 1766 | ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); |
| 1767 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) || ndlp != rrq->ndlp) { |
| 1768 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1769 | "2882 RRQ completes to NPort x%x " |
| 1770 | "with no ndlp. Data: x%x x%x x%x\n", |
| 1771 | irsp->un.elsreq64.remoteID, |
| 1772 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1773 | irsp->ulpIoTag); |
| 1774 | goto out; |
| 1775 | } |
| 1776 | |
| 1777 | /* rrq completes to NPort <nlp_DID> */ |
| 1778 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1779 | "2880 RRQ completes to NPort x%x " |
| 1780 | "Data: x%x x%x x%x x%x x%x\n", |
| 1781 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1782 | irsp->ulpTimeout, rrq->xritag, rrq->rxid); |
| 1783 | |
| 1784 | if (irsp->ulpStatus) { |
| 1785 | /* Check for retry */ |
| 1786 | /* RRQ failed Don't print the vport to vport rjts */ |
| 1787 | if (irsp->ulpStatus != IOSTAT_LS_RJT || |
| 1788 | (((irsp->un.ulpWord[4]) >> 16 != LSRJT_INVALID_CMD) && |
| 1789 | ((irsp->un.ulpWord[4]) >> 16 != LSRJT_UNABLE_TPC)) || |
| 1790 | (phba)->pport->cfg_log_verbose & LOG_ELS) |
| 1791 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1792 | "2881 RRQ failure DID:%06X Status:x%x/x%x\n", |
| 1793 | ndlp->nlp_DID, irsp->ulpStatus, |
| 1794 | irsp->un.ulpWord[4]); |
| 1795 | } |
| 1796 | out: |
| 1797 | if (rrq) |
| 1798 | lpfc_clr_rrq_active(phba, rrq->xritag, rrq); |
| 1799 | lpfc_els_free_iocb(phba, cmdiocb); |
| 1800 | return; |
| 1801 | } |
| 1802 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1803 | * lpfc_cmpl_els_plogi - Completion callback function for plogi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1804 | * @phba: pointer to lpfc hba data structure. |
| 1805 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 1806 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 1807 | * |
| 1808 | * This routine is the completion callback function for issuing the Port |
| 1809 | * Login (PLOGI) command. For PLOGI completion, there must be an active |
| 1810 | * ndlp on the vport node list that matches the remote node ID from the |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 1811 | * PLOGI response IOCB. If such ndlp does not exist, the PLOGI is simply |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1812 | * ignored and command IOCB released. The PLOGI response IOCB status is |
| 1813 | * checked for error conditons. If there is error status reported, PLOGI |
| 1814 | * retry shall be attempted by invoking the lpfc_els_retry() routine. |
| 1815 | * Otherwise, the lpfc_plogi_confirm_nport() routine shall be invoked on |
| 1816 | * the ndlp and the NLP_EVT_CMPL_PLOGI state to the Discover State Machine |
| 1817 | * (DSM) is set for this PLOGI completion. Finally, it checks whether |
| 1818 | * there are additional N_Port nodes with the vport that need to perform |
| 1819 | * PLOGI. If so, the lpfc_more_plogi() routine is invoked to issue addition |
| 1820 | * PLOGIs. |
| 1821 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1822 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1823 | lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1824 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1825 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1826 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1827 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1828 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1829 | struct lpfc_nodelist *ndlp; |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1830 | struct lpfc_dmabuf *prsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1831 | int disc, rc, did, type; |
| 1832 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1833 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 1834 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 1835 | |
| 1836 | irsp = &rspiocb->iocb; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1837 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1838 | "PLOGI cmpl: status:x%x/x%x did:x%x", |
| 1839 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1840 | irsp->un.elsreq64.remoteID); |
| 1841 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1842 | ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1843 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1844 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1845 | "0136 PLOGI completes to NPort x%x " |
| 1846 | "with no ndlp. Data: x%x x%x x%x\n", |
| 1847 | irsp->un.elsreq64.remoteID, |
| 1848 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1849 | irsp->ulpIoTag); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1850 | goto out; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 1851 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1852 | |
| 1853 | /* Since ndlp can be freed in the disc state machine, note if this node |
| 1854 | * is being used during discovery. |
| 1855 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1856 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1857 | disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1858 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1859 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1860 | rc = 0; |
| 1861 | |
| 1862 | /* PLOGI completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1863 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1864 | "0102 PLOGI completes to NPort x%x " |
| 1865 | "Data: x%x x%x x%x x%x x%x\n", |
| 1866 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1867 | irsp->ulpTimeout, disc, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1868 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1869 | if (lpfc_els_chk_latt(vport)) { |
| 1870 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1871 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1872 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1873 | goto out; |
| 1874 | } |
| 1875 | |
| 1876 | /* ndlp could be freed in DSM, save these values now */ |
| 1877 | type = ndlp->nlp_type; |
| 1878 | did = ndlp->nlp_DID; |
| 1879 | |
| 1880 | if (irsp->ulpStatus) { |
| 1881 | /* Check for retry */ |
| 1882 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 1883 | /* ELS command is being retried */ |
| 1884 | if (disc) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1885 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1886 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1887 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1888 | } |
| 1889 | goto out; |
| 1890 | } |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 1891 | /* PLOGI failed Don't print the vport to vport rjts */ |
| 1892 | if (irsp->ulpStatus != IOSTAT_LS_RJT || |
| 1893 | (((irsp->un.ulpWord[4]) >> 16 != LSRJT_INVALID_CMD) && |
| 1894 | ((irsp->un.ulpWord[4]) >> 16 != LSRJT_UNABLE_TPC)) || |
| 1895 | (phba)->pport->cfg_log_verbose & LOG_ELS) |
| 1896 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 1897 | "2753 PLOGI failure DID:%06X Status:x%x/x%x\n", |
| 1898 | ndlp->nlp_DID, irsp->ulpStatus, |
| 1899 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1900 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1901 | if (lpfc_error_lost_link(irsp)) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1902 | rc = NLP_STE_FREED_NODE; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1903 | else |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1904 | rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1905 | NLP_EVT_CMPL_PLOGI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1906 | } else { |
| 1907 | /* Good status, call state machine */ |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1908 | prsp = list_entry(((struct lpfc_dmabuf *) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1909 | cmdiocb->context2)->list.next, |
| 1910 | struct lpfc_dmabuf, list); |
| 1911 | ndlp = lpfc_plogi_confirm_nport(phba, prsp->virt, ndlp); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1912 | rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1913 | NLP_EVT_CMPL_PLOGI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1914 | } |
| 1915 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1916 | if (disc && vport->num_disc_nodes) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1917 | /* Check to see if there are more PLOGIs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1918 | lpfc_more_plogi(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1919 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1920 | if (vport->num_disc_nodes == 0) { |
| 1921 | spin_lock_irq(shost->host_lock); |
| 1922 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 1923 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1924 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1925 | lpfc_can_disctmo(vport); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1926 | lpfc_end_rscn(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1927 | } |
| 1928 | } |
| 1929 | |
| 1930 | out: |
| 1931 | lpfc_els_free_iocb(phba, cmdiocb); |
| 1932 | return; |
| 1933 | } |
| 1934 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1935 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1936 | * lpfc_issue_els_plogi - Issue an plogi iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1937 | * @vport: pointer to a host virtual N_Port data structure. |
| 1938 | * @did: destination port identifier. |
| 1939 | * @retry: number of retries to the command IOCB. |
| 1940 | * |
| 1941 | * This routine issues a Port Login (PLOGI) command to a remote N_Port |
| 1942 | * (with the @did) for a @vport. Before issuing a PLOGI to a remote N_Port, |
| 1943 | * the ndlp with the remote N_Port DID must exist on the @vport's ndlp list. |
| 1944 | * This routine constructs the proper feilds of the PLOGI IOCB and invokes |
| 1945 | * the lpfc_sli_issue_iocb() routine to send out PLOGI ELS command. |
| 1946 | * |
| 1947 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 1948 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 1949 | * will be stored into the context1 field of the IOCB for the completion |
| 1950 | * callback function to the PLOGI ELS command. |
| 1951 | * |
| 1952 | * Return code |
| 1953 | * 0 - Successfully issued a plogi for @vport |
| 1954 | * 1 - failed to issue a plogi for @vport |
| 1955 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1956 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1957 | lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1958 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1959 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1960 | struct serv_parm *sp; |
| 1961 | IOCB_t *icmd; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1962 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1963 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1964 | struct lpfc_sli *psli; |
| 1965 | uint8_t *pcmd; |
| 1966 | uint16_t cmdsize; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1967 | int ret; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1968 | |
| 1969 | psli = &phba->sli; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1970 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1971 | ndlp = lpfc_findnode_did(vport, did); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1972 | if (ndlp && !NLP_CHK_NODE_ACT(ndlp)) |
| 1973 | ndlp = NULL; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1974 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1975 | /* If ndlp is not NULL, we will bump the reference count on it */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1976 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1977 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1978 | ELS_CMD_PLOGI); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1979 | if (!elsiocb) |
| 1980 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1981 | |
| 1982 | icmd = &elsiocb->iocb; |
| 1983 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 1984 | |
| 1985 | /* For PLOGI request, remainder of payload is service parameters */ |
| 1986 | *((uint32_t *) (pcmd)) = ELS_CMD_PLOGI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1987 | pcmd += sizeof(uint32_t); |
| 1988 | memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1989 | sp = (struct serv_parm *) pcmd; |
| 1990 | |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 1991 | /* |
| 1992 | * If we are a N-port connected to a Fabric, fix-up paramm's so logins |
| 1993 | * to device on remote loops work. |
| 1994 | */ |
| 1995 | if ((vport->fc_flag & FC_FABRIC) && !(vport->fc_flag & FC_PUBLIC_LOOP)) |
| 1996 | sp->cmn.altBbCredit = 1; |
| 1997 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1998 | if (sp->cmn.fcphLow < FC_PH_4_3) |
| 1999 | sp->cmn.fcphLow = FC_PH_4_3; |
| 2000 | |
| 2001 | if (sp->cmn.fcphHigh < FC_PH3) |
| 2002 | sp->cmn.fcphHigh = FC_PH3; |
| 2003 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2004 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2005 | "Issue PLOGI: did:x%x", |
| 2006 | did, 0, 0); |
| 2007 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2008 | phba->fc_stat.elsXmitPLOGI++; |
| 2009 | elsiocb->iocb_cmpl = lpfc_cmpl_els_plogi; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2010 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2011 | |
| 2012 | if (ret == IOCB_ERROR) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2013 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2014 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2015 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2016 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2017 | } |
| 2018 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2019 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2020 | * lpfc_cmpl_els_prli - Completion callback function for prli |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2021 | * @phba: pointer to lpfc hba data structure. |
| 2022 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2023 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2024 | * |
| 2025 | * This routine is the completion callback function for a Process Login |
| 2026 | * (PRLI) ELS command. The PRLI response IOCB status is checked for error |
| 2027 | * status. If there is error status reported, PRLI retry shall be attempted |
| 2028 | * by invoking the lpfc_els_retry() routine. Otherwise, the state |
| 2029 | * NLP_EVT_CMPL_PRLI is sent to the Discover State Machine (DSM) for this |
| 2030 | * ndlp to mark the PRLI completion. |
| 2031 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2032 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2033 | lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2034 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2035 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2036 | struct lpfc_vport *vport = cmdiocb->vport; |
| 2037 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2038 | IOCB_t *irsp; |
| 2039 | struct lpfc_sli *psli; |
| 2040 | struct lpfc_nodelist *ndlp; |
| 2041 | |
| 2042 | psli = &phba->sli; |
| 2043 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 2044 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 2045 | |
| 2046 | irsp = &(rspiocb->iocb); |
| 2047 | ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2048 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2049 | ndlp->nlp_flag &= ~NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2050 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2051 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2052 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2053 | "PRLI cmpl: status:x%x/x%x did:x%x", |
| 2054 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2055 | ndlp->nlp_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2056 | /* PRLI completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2057 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2058 | "0103 PRLI completes to NPort x%x " |
| 2059 | "Data: x%x x%x x%x x%x\n", |
| 2060 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2061 | irsp->ulpTimeout, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2062 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2063 | vport->fc_prli_sent--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2064 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2065 | if (lpfc_els_chk_latt(vport)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2066 | goto out; |
| 2067 | |
| 2068 | if (irsp->ulpStatus) { |
| 2069 | /* Check for retry */ |
| 2070 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 2071 | /* ELS command is being retried */ |
| 2072 | goto out; |
| 2073 | } |
| 2074 | /* PRLI failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2075 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2076 | "2754 PRLI failure DID:%06X Status:x%x/x%x\n", |
| 2077 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2078 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2079 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2080 | if (lpfc_error_lost_link(irsp)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2081 | goto out; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2082 | else |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2083 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2084 | NLP_EVT_CMPL_PRLI); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2085 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2086 | /* Good status, call state machine */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2087 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2088 | NLP_EVT_CMPL_PRLI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2089 | out: |
| 2090 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2091 | return; |
| 2092 | } |
| 2093 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2094 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2095 | * lpfc_issue_els_prli - Issue a prli iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2096 | * @vport: pointer to a host virtual N_Port data structure. |
| 2097 | * @ndlp: pointer to a node-list data structure. |
| 2098 | * @retry: number of retries to the command IOCB. |
| 2099 | * |
| 2100 | * This routine issues a Process Login (PRLI) ELS command for the |
| 2101 | * @vport. The PRLI service parameters are set up in the payload of the |
| 2102 | * PRLI Request command and the pointer to lpfc_cmpl_els_prli() routine |
| 2103 | * is put to the IOCB completion callback func field before invoking the |
| 2104 | * routine lpfc_sli_issue_iocb() to send out PRLI command. |
| 2105 | * |
| 2106 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2107 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2108 | * will be stored into the context1 field of the IOCB for the completion |
| 2109 | * callback function to the PRLI ELS command. |
| 2110 | * |
| 2111 | * Return code |
| 2112 | * 0 - successfully issued prli iocb command for @vport |
| 2113 | * 1 - failed to issue prli iocb command for @vport |
| 2114 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2115 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2116 | lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2117 | uint8_t retry) |
| 2118 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2119 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2120 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2121 | PRLI *npr; |
| 2122 | IOCB_t *icmd; |
| 2123 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2124 | uint8_t *pcmd; |
| 2125 | uint16_t cmdsize; |
| 2126 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2127 | cmdsize = (sizeof(uint32_t) + sizeof(PRLI)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2128 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2129 | ndlp->nlp_DID, ELS_CMD_PRLI); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2130 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2131 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2132 | |
| 2133 | icmd = &elsiocb->iocb; |
| 2134 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2135 | |
| 2136 | /* For PRLI request, remainder of payload is service parameters */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2137 | memset(pcmd, 0, (sizeof(PRLI) + sizeof(uint32_t))); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2138 | *((uint32_t *) (pcmd)) = ELS_CMD_PRLI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2139 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2140 | |
| 2141 | /* For PRLI, remainder of payload is PRLI parameter page */ |
| 2142 | npr = (PRLI *) pcmd; |
| 2143 | /* |
| 2144 | * If our firmware version is 3.20 or later, |
| 2145 | * set the following bits for FC-TAPE support. |
| 2146 | */ |
| 2147 | if (phba->vpd.rev.feaLevelHigh >= 0x02) { |
| 2148 | npr->ConfmComplAllowed = 1; |
| 2149 | npr->Retry = 1; |
| 2150 | npr->TaskRetryIdReq = 1; |
| 2151 | } |
| 2152 | npr->estabImagePair = 1; |
| 2153 | npr->readXferRdyDis = 1; |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 2154 | if (vport->cfg_first_burst_size) |
| 2155 | npr->writeXferRdyDis = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2156 | |
| 2157 | /* For FCP support */ |
| 2158 | npr->prliType = PRLI_FCP_TYPE; |
| 2159 | npr->initiatorFunc = 1; |
| 2160 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2161 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2162 | "Issue PRLI: did:x%x", |
| 2163 | ndlp->nlp_DID, 0, 0); |
| 2164 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2165 | phba->fc_stat.elsXmitPRLI++; |
| 2166 | elsiocb->iocb_cmpl = lpfc_cmpl_els_prli; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2167 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2168 | ndlp->nlp_flag |= NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2169 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2170 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2171 | IOCB_ERROR) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2172 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2173 | ndlp->nlp_flag &= ~NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2174 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2175 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2176 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2177 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2178 | vport->fc_prli_sent++; |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2179 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2180 | } |
| 2181 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2182 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2183 | * lpfc_rscn_disc - Perform rscn discovery for a vport |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2184 | * @vport: pointer to a host virtual N_Port data structure. |
| 2185 | * |
| 2186 | * This routine performs Registration State Change Notification (RSCN) |
| 2187 | * discovery for a @vport. If the @vport's node port recovery count is not |
| 2188 | * zero, it will invoke the lpfc_els_disc_plogi() to perform PLOGI for all |
| 2189 | * the nodes that need recovery. If none of the PLOGI were needed through |
| 2190 | * the lpfc_els_disc_plogi() routine, the lpfc_end_rscn() routine shall be |
| 2191 | * invoked to check and handle possible more RSCN came in during the period |
| 2192 | * of processing the current ones. |
| 2193 | **/ |
| 2194 | static void |
| 2195 | lpfc_rscn_disc(struct lpfc_vport *vport) |
| 2196 | { |
| 2197 | lpfc_can_disctmo(vport); |
| 2198 | |
| 2199 | /* RSCN discovery */ |
| 2200 | /* go thru NPR nodes and issue ELS PLOGIs */ |
| 2201 | if (vport->fc_npr_cnt) |
| 2202 | if (lpfc_els_disc_plogi(vport)) |
| 2203 | return; |
| 2204 | |
| 2205 | lpfc_end_rscn(vport); |
| 2206 | } |
| 2207 | |
| 2208 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2209 | * lpfc_adisc_done - Complete the adisc phase of discovery |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2210 | * @vport: pointer to lpfc_vport hba data structure that finished all ADISCs. |
| 2211 | * |
| 2212 | * This function is called when the final ADISC is completed during discovery. |
| 2213 | * This function handles clearing link attention or issuing reg_vpi depending |
| 2214 | * on whether npiv is enabled. This function also kicks off the PLOGI phase of |
| 2215 | * discovery. |
| 2216 | * This function is called with no locks held. |
| 2217 | **/ |
| 2218 | static void |
| 2219 | lpfc_adisc_done(struct lpfc_vport *vport) |
| 2220 | { |
| 2221 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2222 | struct lpfc_hba *phba = vport->phba; |
| 2223 | |
| 2224 | /* |
| 2225 | * For NPIV, cmpl_reg_vpi will set port_state to READY, |
| 2226 | * and continue discovery. |
| 2227 | */ |
| 2228 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 2229 | !(vport->fc_flag & FC_RSCN_MODE) && |
| 2230 | (phba->sli_rev < LPFC_SLI_REV4)) { |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2231 | lpfc_issue_reg_vpi(phba, vport); |
| 2232 | return; |
| 2233 | } |
| 2234 | /* |
| 2235 | * For SLI2, we need to set port_state to READY |
| 2236 | * and continue discovery. |
| 2237 | */ |
| 2238 | if (vport->port_state < LPFC_VPORT_READY) { |
| 2239 | /* If we get here, there is nothing to ADISC */ |
| 2240 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 2241 | lpfc_issue_clear_la(phba, vport); |
| 2242 | if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) { |
| 2243 | vport->num_disc_nodes = 0; |
| 2244 | /* go thru NPR list, issue ELS PLOGIs */ |
| 2245 | if (vport->fc_npr_cnt) |
| 2246 | lpfc_els_disc_plogi(vport); |
| 2247 | if (!vport->num_disc_nodes) { |
| 2248 | spin_lock_irq(shost->host_lock); |
| 2249 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 2250 | spin_unlock_irq(shost->host_lock); |
| 2251 | lpfc_can_disctmo(vport); |
| 2252 | lpfc_end_rscn(vport); |
| 2253 | } |
| 2254 | } |
| 2255 | vport->port_state = LPFC_VPORT_READY; |
| 2256 | } else |
| 2257 | lpfc_rscn_disc(vport); |
| 2258 | } |
| 2259 | |
| 2260 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2261 | * lpfc_more_adisc - Issue more adisc as needed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2262 | * @vport: pointer to a host virtual N_Port data structure. |
| 2263 | * |
| 2264 | * This routine determines whether there are more ndlps on a @vport |
| 2265 | * node list need to have Address Discover (ADISC) issued. If so, it will |
| 2266 | * invoke the lpfc_els_disc_adisc() routine to issue ADISC on the @vport's |
| 2267 | * remaining nodes which need to have ADISC sent. |
| 2268 | **/ |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 2269 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2270 | lpfc_more_adisc(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2271 | { |
| 2272 | int sentadisc; |
| 2273 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2274 | if (vport->num_disc_nodes) |
| 2275 | vport->num_disc_nodes--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2276 | /* Continue discovery with <num_disc_nodes> ADISCs to go */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2277 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 2278 | "0210 Continue discovery with %d ADISCs to go " |
| 2279 | "Data: x%x x%x x%x\n", |
| 2280 | vport->num_disc_nodes, vport->fc_adisc_cnt, |
| 2281 | vport->fc_flag, vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2282 | /* Check to see if there are more ADISCs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2283 | if (vport->fc_flag & FC_NLP_MORE) { |
| 2284 | lpfc_set_disctmo(vport); |
| 2285 | /* go thru NPR nodes and issue any remaining ELS ADISCs */ |
| 2286 | sentadisc = lpfc_els_disc_adisc(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2287 | } |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2288 | if (!vport->num_disc_nodes) |
| 2289 | lpfc_adisc_done(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2290 | return; |
| 2291 | } |
| 2292 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2293 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2294 | * lpfc_cmpl_els_adisc - Completion callback function for adisc |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2295 | * @phba: pointer to lpfc hba data structure. |
| 2296 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2297 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2298 | * |
| 2299 | * This routine is the completion function for issuing the Address Discover |
| 2300 | * (ADISC) command. It first checks to see whether link went down during |
| 2301 | * the discovery process. If so, the node will be marked as node port |
| 2302 | * recovery for issuing discover IOCB by the link attention handler and |
| 2303 | * exit. Otherwise, the response status is checked. If error was reported |
| 2304 | * in the response status, the ADISC command shall be retried by invoking |
| 2305 | * the lpfc_els_retry() routine. Otherwise, if no error was reported in |
| 2306 | * the response status, the state machine is invoked to set transition |
| 2307 | * with respect to NLP_EVT_CMPL_ADISC event. |
| 2308 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2309 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2310 | lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2311 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2312 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2313 | struct lpfc_vport *vport = cmdiocb->vport; |
| 2314 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2315 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2316 | struct lpfc_nodelist *ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2317 | int disc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2318 | |
| 2319 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 2320 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 2321 | |
| 2322 | irsp = &(rspiocb->iocb); |
| 2323 | ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2324 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2325 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2326 | "ADISC cmpl: status:x%x/x%x did:x%x", |
| 2327 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2328 | ndlp->nlp_DID); |
| 2329 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2330 | /* Since ndlp can be freed in the disc state machine, note if this node |
| 2331 | * is being used during discovery. |
| 2332 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2333 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2334 | disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2335 | ndlp->nlp_flag &= ~(NLP_ADISC_SND | NLP_NPR_2B_DISC); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2336 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2337 | /* ADISC completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2338 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2339 | "0104 ADISC completes to NPort x%x " |
| 2340 | "Data: x%x x%x x%x x%x x%x\n", |
| 2341 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2342 | irsp->ulpTimeout, disc, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2343 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2344 | if (lpfc_els_chk_latt(vport)) { |
| 2345 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2346 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2347 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2348 | goto out; |
| 2349 | } |
| 2350 | |
| 2351 | if (irsp->ulpStatus) { |
| 2352 | /* Check for retry */ |
| 2353 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 2354 | /* ELS command is being retried */ |
| 2355 | if (disc) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2356 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2357 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2358 | spin_unlock_irq(shost->host_lock); |
| 2359 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2360 | } |
| 2361 | goto out; |
| 2362 | } |
| 2363 | /* ADISC failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2364 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2365 | "2755 ADISC failure DID:%06X Status:x%x/x%x\n", |
| 2366 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2367 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2368 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2369 | if (!lpfc_error_lost_link(irsp)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2370 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2371 | NLP_EVT_CMPL_ADISC); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2372 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2373 | /* Good status, call state machine */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2374 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2375 | NLP_EVT_CMPL_ADISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2376 | |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2377 | /* Check to see if there are more ADISCs to be sent */ |
| 2378 | if (disc && vport->num_disc_nodes) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2379 | lpfc_more_adisc(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2380 | out: |
| 2381 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2382 | return; |
| 2383 | } |
| 2384 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2385 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2386 | * lpfc_issue_els_adisc - Issue an address discover iocb to an node on a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2387 | * @vport: pointer to a virtual N_Port data structure. |
| 2388 | * @ndlp: pointer to a node-list data structure. |
| 2389 | * @retry: number of retries to the command IOCB. |
| 2390 | * |
| 2391 | * This routine issues an Address Discover (ADISC) for an @ndlp on a |
| 2392 | * @vport. It prepares the payload of the ADISC ELS command, updates the |
| 2393 | * and states of the ndlp, and invokes the lpfc_sli_issue_iocb() routine |
| 2394 | * to issue the ADISC ELS command. |
| 2395 | * |
| 2396 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2397 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2398 | * will be stored into the context1 field of the IOCB for the completion |
| 2399 | * callback function to the ADISC ELS command. |
| 2400 | * |
| 2401 | * Return code |
| 2402 | * 0 - successfully issued adisc |
| 2403 | * 1 - failed to issue adisc |
| 2404 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2405 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2406 | lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2407 | uint8_t retry) |
| 2408 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2409 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2410 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2411 | ADISC *ap; |
| 2412 | IOCB_t *icmd; |
| 2413 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2414 | uint8_t *pcmd; |
| 2415 | uint16_t cmdsize; |
| 2416 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2417 | cmdsize = (sizeof(uint32_t) + sizeof(ADISC)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2418 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2419 | ndlp->nlp_DID, ELS_CMD_ADISC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2420 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2421 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2422 | |
| 2423 | icmd = &elsiocb->iocb; |
| 2424 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2425 | |
| 2426 | /* For ADISC request, remainder of payload is service parameters */ |
| 2427 | *((uint32_t *) (pcmd)) = ELS_CMD_ADISC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2428 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2429 | |
| 2430 | /* Fill in ADISC payload */ |
| 2431 | ap = (ADISC *) pcmd; |
| 2432 | ap->hardAL_PA = phba->fc_pref_ALPA; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2433 | memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 2434 | memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2435 | ap->DID = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2436 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2437 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2438 | "Issue ADISC: did:x%x", |
| 2439 | ndlp->nlp_DID, 0, 0); |
| 2440 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2441 | phba->fc_stat.elsXmitADISC++; |
| 2442 | elsiocb->iocb_cmpl = lpfc_cmpl_els_adisc; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2443 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2444 | ndlp->nlp_flag |= NLP_ADISC_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2445 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2446 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2447 | IOCB_ERROR) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2448 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2449 | ndlp->nlp_flag &= ~NLP_ADISC_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2450 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2451 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2452 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2453 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2454 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2455 | } |
| 2456 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2457 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2458 | * lpfc_cmpl_els_logo - Completion callback function for logo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2459 | * @phba: pointer to lpfc hba data structure. |
| 2460 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2461 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2462 | * |
| 2463 | * This routine is the completion function for issuing the ELS Logout (LOGO) |
| 2464 | * command. If no error status was reported from the LOGO response, the |
| 2465 | * state machine of the associated ndlp shall be invoked for transition with |
| 2466 | * respect to NLP_EVT_CMPL_LOGO event. Otherwise, if error status was reported, |
| 2467 | * the lpfc_els_retry() routine will be invoked to retry the LOGO command. |
| 2468 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2469 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2470 | lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2471 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2472 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2473 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 2474 | struct lpfc_vport *vport = ndlp->vport; |
| 2475 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2476 | IOCB_t *irsp; |
| 2477 | struct lpfc_sli *psli; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 2478 | struct lpfcMboxq *mbox; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2479 | unsigned long flags; |
| 2480 | uint32_t skip_recovery = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2481 | |
| 2482 | psli = &phba->sli; |
| 2483 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 2484 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 2485 | |
| 2486 | irsp = &(rspiocb->iocb); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2487 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2488 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2489 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2490 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2491 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2492 | "LOGO cmpl: status:x%x/x%x did:x%x", |
| 2493 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2494 | ndlp->nlp_DID); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2495 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2496 | /* LOGO completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2497 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2498 | "0105 LOGO completes to NPort x%x " |
| 2499 | "Data: x%x x%x x%x x%x\n", |
| 2500 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2501 | irsp->ulpTimeout, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2502 | |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2503 | if (lpfc_els_chk_latt(vport)) { |
| 2504 | skip_recovery = 1; |
| 2505 | goto out; |
| 2506 | } |
| 2507 | |
| 2508 | /* Check to see if link went down during discovery */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2509 | if (ndlp->nlp_flag & NLP_TARGET_REMOVE) { |
| 2510 | /* NLP_EVT_DEVICE_RM should unregister the RPI |
| 2511 | * which should abort all outstanding IOs. |
| 2512 | */ |
| 2513 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
| 2514 | NLP_EVT_DEVICE_RM); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2515 | skip_recovery = 1; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2516 | goto out; |
| 2517 | } |
| 2518 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2519 | if (irsp->ulpStatus) { |
| 2520 | /* Check for retry */ |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2521 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2522 | /* ELS command is being retried */ |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2523 | skip_recovery = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2524 | goto out; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2525 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2526 | /* LOGO failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2527 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2528 | "2756 LOGO failure DID:%06X Status:x%x/x%x\n", |
| 2529 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2530 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2531 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2532 | if (lpfc_error_lost_link(irsp)) { |
| 2533 | skip_recovery = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2534 | goto out; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2535 | } |
| 2536 | } |
| 2537 | |
| 2538 | /* Call state machine. This will unregister the rpi if needed. */ |
| 2539 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_CMPL_LOGO); |
| 2540 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2541 | out: |
| 2542 | lpfc_els_free_iocb(phba, cmdiocb); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 2543 | /* If we are in pt2pt mode, we could rcv new S_ID on PLOGI */ |
| 2544 | if ((vport->fc_flag & FC_PT2PT) && |
| 2545 | !(vport->fc_flag & FC_PT2PT_PLOGI)) { |
| 2546 | phba->pport->fc_myDID = 0; |
| 2547 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 2548 | if (mbox) { |
| 2549 | lpfc_config_link(phba, mbox); |
| 2550 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
| 2551 | mbox->vport = vport; |
| 2552 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) == |
| 2553 | MBX_NOT_FINISHED) { |
| 2554 | mempool_free(mbox, phba->mbox_mem_pool); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2555 | skip_recovery = 1; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 2556 | } |
| 2557 | } |
| 2558 | } |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2559 | |
| 2560 | /* |
| 2561 | * If the node is a target, the handling attempts to recover the port. |
| 2562 | * For any other port type, the rpi is unregistered as an implicit |
| 2563 | * LOGO. |
| 2564 | */ |
| 2565 | if ((ndlp->nlp_type & NLP_FCP_TARGET) && (skip_recovery == 0)) { |
| 2566 | lpfc_cancel_retry_delay_tmo(vport, ndlp); |
| 2567 | spin_lock_irqsave(shost->host_lock, flags); |
| 2568 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
| 2569 | spin_unlock_irqrestore(shost->host_lock, flags); |
| 2570 | |
| 2571 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2572 | "3187 LOGO completes to NPort x%x: Start " |
| 2573 | "Recovery Data: x%x x%x x%x x%x\n", |
| 2574 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2575 | irsp->un.ulpWord[4], irsp->ulpTimeout, |
| 2576 | vport->num_disc_nodes); |
| 2577 | lpfc_disc_start(vport); |
| 2578 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2579 | return; |
| 2580 | } |
| 2581 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2582 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2583 | * lpfc_issue_els_logo - Issue a logo to an node on a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2584 | * @vport: pointer to a virtual N_Port data structure. |
| 2585 | * @ndlp: pointer to a node-list data structure. |
| 2586 | * @retry: number of retries to the command IOCB. |
| 2587 | * |
| 2588 | * This routine constructs and issues an ELS Logout (LOGO) iocb command |
| 2589 | * to a remote node, referred by an @ndlp on a @vport. It constructs the |
| 2590 | * payload of the IOCB, properly sets up the @ndlp state, and invokes the |
| 2591 | * lpfc_sli_issue_iocb() routine to send out the LOGO ELS command. |
| 2592 | * |
| 2593 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2594 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2595 | * will be stored into the context1 field of the IOCB for the completion |
| 2596 | * callback function to the LOGO ELS command. |
| 2597 | * |
| 2598 | * Return code |
| 2599 | * 0 - successfully issued logo |
| 2600 | * 1 - failed to issue logo |
| 2601 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2602 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2603 | lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2604 | uint8_t retry) |
| 2605 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2606 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2607 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2608 | IOCB_t *icmd; |
| 2609 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2610 | uint8_t *pcmd; |
| 2611 | uint16_t cmdsize; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2612 | int rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2613 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 2614 | spin_lock_irq(shost->host_lock); |
| 2615 | if (ndlp->nlp_flag & NLP_LOGO_SND) { |
| 2616 | spin_unlock_irq(shost->host_lock); |
| 2617 | return 0; |
| 2618 | } |
| 2619 | spin_unlock_irq(shost->host_lock); |
| 2620 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2621 | cmdsize = (2 * sizeof(uint32_t)) + sizeof(struct lpfc_name); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2622 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2623 | ndlp->nlp_DID, ELS_CMD_LOGO); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2624 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2625 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2626 | |
| 2627 | icmd = &elsiocb->iocb; |
| 2628 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2629 | *((uint32_t *) (pcmd)) = ELS_CMD_LOGO; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2630 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2631 | |
| 2632 | /* Fill in LOGO payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2633 | *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2634 | pcmd += sizeof(uint32_t); |
| 2635 | memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2636 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2637 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2638 | "Issue LOGO: did:x%x", |
| 2639 | ndlp->nlp_DID, 0, 0); |
| 2640 | |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2641 | /* |
| 2642 | * If we are issuing a LOGO, we may try to recover the remote NPort |
| 2643 | * by issuing a PLOGI later. Even though we issue ELS cmds by the |
| 2644 | * VPI, if we have a valid RPI, and that RPI gets unreg'ed while |
| 2645 | * that ELS command is in-flight, the HBA returns a IOERR_INVALID_RPI |
| 2646 | * for that ELS cmd. To avoid this situation, lets get rid of the |
| 2647 | * RPI right now, before any ELS cmds are sent. |
| 2648 | */ |
| 2649 | spin_lock_irq(shost->host_lock); |
| 2650 | ndlp->nlp_flag |= NLP_ISSUE_LOGO; |
| 2651 | spin_unlock_irq(shost->host_lock); |
| 2652 | if (lpfc_unreg_rpi(vport, ndlp)) { |
| 2653 | lpfc_els_free_iocb(phba, elsiocb); |
| 2654 | return 0; |
| 2655 | } |
| 2656 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2657 | phba->fc_stat.elsXmitLOGO++; |
| 2658 | elsiocb->iocb_cmpl = lpfc_cmpl_els_logo; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2659 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2660 | ndlp->nlp_flag |= NLP_LOGO_SND; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2661 | ndlp->nlp_flag &= ~NLP_ISSUE_LOGO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2662 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2663 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2664 | |
| 2665 | if (rc == IOCB_ERROR) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2666 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2667 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2668 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2669 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2670 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2671 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2672 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2673 | } |
| 2674 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2675 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2676 | * lpfc_cmpl_els_cmd - Completion callback function for generic els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2677 | * @phba: pointer to lpfc hba data structure. |
| 2678 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2679 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2680 | * |
| 2681 | * This routine is a generic completion callback function for ELS commands. |
| 2682 | * Specifically, it is the callback function which does not need to perform |
| 2683 | * any command specific operations. It is currently used by the ELS command |
| 2684 | * issuing routines for the ELS State Change Request (SCR), |
| 2685 | * lpfc_issue_els_scr(), and the ELS Fibre Channel Address Resolution |
| 2686 | * Protocol Response (FARPR) routine, lpfc_issue_els_farpr(). Other than |
| 2687 | * certain debug loggings, this callback function simply invokes the |
| 2688 | * lpfc_els_chk_latt() routine to check whether link went down during the |
| 2689 | * discovery process. |
| 2690 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2691 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2692 | lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2693 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2694 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2695 | struct lpfc_vport *vport = cmdiocb->vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2696 | IOCB_t *irsp; |
| 2697 | |
| 2698 | irsp = &rspiocb->iocb; |
| 2699 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2700 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2701 | "ELS cmd cmpl: status:x%x/x%x did:x%x", |
| 2702 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2703 | irsp->un.elsreq64.remoteID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2704 | /* ELS cmd tag <ulpIoTag> completes */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2705 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2706 | "0106 ELS cmd tag x%x completes Data: x%x x%x x%x\n", |
| 2707 | irsp->ulpIoTag, irsp->ulpStatus, |
| 2708 | irsp->un.ulpWord[4], irsp->ulpTimeout); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2709 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2710 | lpfc_els_chk_latt(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2711 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2712 | return; |
| 2713 | } |
| 2714 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2715 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2716 | * lpfc_issue_els_scr - Issue a scr to an node on a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2717 | * @vport: pointer to a host virtual N_Port data structure. |
| 2718 | * @nportid: N_Port identifier to the remote node. |
| 2719 | * @retry: number of retries to the command IOCB. |
| 2720 | * |
| 2721 | * This routine issues a State Change Request (SCR) to a fabric node |
| 2722 | * on a @vport. The remote node @nportid is passed into the function. It |
| 2723 | * first search the @vport node list to find the matching ndlp. If no such |
| 2724 | * ndlp is found, a new ndlp shall be created for this (SCR) purpose. An |
| 2725 | * IOCB is allocated, payload prepared, and the lpfc_sli_issue_iocb() |
| 2726 | * routine is invoked to send the SCR IOCB. |
| 2727 | * |
| 2728 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2729 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2730 | * will be stored into the context1 field of the IOCB for the completion |
| 2731 | * callback function to the SCR ELS command. |
| 2732 | * |
| 2733 | * Return code |
| 2734 | * 0 - Successfully issued scr command |
| 2735 | * 1 - Failed to issue scr command |
| 2736 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2737 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2738 | lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2739 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2740 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2741 | IOCB_t *icmd; |
| 2742 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2743 | struct lpfc_sli *psli; |
| 2744 | uint8_t *pcmd; |
| 2745 | uint16_t cmdsize; |
| 2746 | struct lpfc_nodelist *ndlp; |
| 2747 | |
| 2748 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2749 | cmdsize = (sizeof(uint32_t) + sizeof(SCR)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2750 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2751 | ndlp = lpfc_findnode_did(vport, nportid); |
| 2752 | if (!ndlp) { |
| 2753 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 2754 | if (!ndlp) |
| 2755 | return 1; |
| 2756 | lpfc_nlp_init(vport, ndlp, nportid); |
| 2757 | lpfc_enqueue_node(vport, ndlp); |
| 2758 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 2759 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 2760 | if (!ndlp) |
| 2761 | return 1; |
| 2762 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2763 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2764 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2765 | ndlp->nlp_DID, ELS_CMD_SCR); |
| 2766 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2767 | if (!elsiocb) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2768 | /* This will trigger the release of the node just |
| 2769 | * allocated |
| 2770 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2771 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2772 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2773 | } |
| 2774 | |
| 2775 | icmd = &elsiocb->iocb; |
| 2776 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2777 | |
| 2778 | *((uint32_t *) (pcmd)) = ELS_CMD_SCR; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2779 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2780 | |
| 2781 | /* For SCR, remainder of payload is SCR parameter page */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2782 | memset(pcmd, 0, sizeof(SCR)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2783 | ((SCR *) pcmd)->Function = SCR_FUNC_FULL; |
| 2784 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2785 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2786 | "Issue SCR: did:x%x", |
| 2787 | ndlp->nlp_DID, 0, 0); |
| 2788 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2789 | phba->fc_stat.elsXmitSCR++; |
| 2790 | elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2791 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2792 | IOCB_ERROR) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2793 | /* The additional lpfc_nlp_put will cause the following |
| 2794 | * lpfc_els_free_iocb routine to trigger the rlease of |
| 2795 | * the node. |
| 2796 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2797 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2798 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2799 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2800 | } |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2801 | /* This will cause the callback-function lpfc_cmpl_els_cmd to |
| 2802 | * trigger the release of node. |
| 2803 | */ |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 2804 | |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2805 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2806 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2807 | } |
| 2808 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2809 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2810 | * lpfc_issue_els_farpr - Issue a farp to an node on a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2811 | * @vport: pointer to a host virtual N_Port data structure. |
| 2812 | * @nportid: N_Port identifier to the remote node. |
| 2813 | * @retry: number of retries to the command IOCB. |
| 2814 | * |
| 2815 | * This routine issues a Fibre Channel Address Resolution Response |
| 2816 | * (FARPR) to a node on a vport. The remote node N_Port identifier (@nportid) |
| 2817 | * is passed into the function. It first search the @vport node list to find |
| 2818 | * the matching ndlp. If no such ndlp is found, a new ndlp shall be created |
| 2819 | * for this (FARPR) purpose. An IOCB is allocated, payload prepared, and the |
| 2820 | * lpfc_sli_issue_iocb() routine is invoked to send the FARPR ELS command. |
| 2821 | * |
| 2822 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2823 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2824 | * will be stored into the context1 field of the IOCB for the completion |
| 2825 | * callback function to the PARPR ELS command. |
| 2826 | * |
| 2827 | * Return code |
| 2828 | * 0 - Successfully issued farpr command |
| 2829 | * 1 - Failed to issue farpr command |
| 2830 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2831 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2832 | lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2833 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2834 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2835 | IOCB_t *icmd; |
| 2836 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2837 | struct lpfc_sli *psli; |
| 2838 | FARP *fp; |
| 2839 | uint8_t *pcmd; |
| 2840 | uint32_t *lp; |
| 2841 | uint16_t cmdsize; |
| 2842 | struct lpfc_nodelist *ondlp; |
| 2843 | struct lpfc_nodelist *ndlp; |
| 2844 | |
| 2845 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2846 | cmdsize = (sizeof(uint32_t) + sizeof(FARP)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2847 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2848 | ndlp = lpfc_findnode_did(vport, nportid); |
| 2849 | if (!ndlp) { |
| 2850 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 2851 | if (!ndlp) |
| 2852 | return 1; |
| 2853 | lpfc_nlp_init(vport, ndlp, nportid); |
| 2854 | lpfc_enqueue_node(vport, ndlp); |
| 2855 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 2856 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 2857 | if (!ndlp) |
| 2858 | return 1; |
| 2859 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2860 | |
| 2861 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2862 | ndlp->nlp_DID, ELS_CMD_RNID); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2863 | if (!elsiocb) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2864 | /* This will trigger the release of the node just |
| 2865 | * allocated |
| 2866 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2867 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2868 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2869 | } |
| 2870 | |
| 2871 | icmd = &elsiocb->iocb; |
| 2872 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2873 | |
| 2874 | *((uint32_t *) (pcmd)) = ELS_CMD_FARPR; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2875 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2876 | |
| 2877 | /* Fill in FARPR payload */ |
| 2878 | fp = (FARP *) (pcmd); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2879 | memset(fp, 0, sizeof(FARP)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2880 | lp = (uint32_t *) pcmd; |
| 2881 | *lp++ = be32_to_cpu(nportid); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2882 | *lp++ = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2883 | fp->Rflags = 0; |
| 2884 | fp->Mflags = (FARP_MATCH_PORT | FARP_MATCH_NODE); |
| 2885 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2886 | memcpy(&fp->RportName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 2887 | memcpy(&fp->RnodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2888 | ondlp = lpfc_findnode_did(vport, nportid); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2889 | if (ondlp && NLP_CHK_NODE_ACT(ondlp)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2890 | memcpy(&fp->OportName, &ondlp->nlp_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2891 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2892 | memcpy(&fp->OnodeName, &ondlp->nlp_nodename, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2893 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2894 | } |
| 2895 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2896 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2897 | "Issue FARPR: did:x%x", |
| 2898 | ndlp->nlp_DID, 0, 0); |
| 2899 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2900 | phba->fc_stat.elsXmitFARPR++; |
| 2901 | elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2902 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2903 | IOCB_ERROR) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2904 | /* The additional lpfc_nlp_put will cause the following |
| 2905 | * lpfc_els_free_iocb routine to trigger the release of |
| 2906 | * the node. |
| 2907 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2908 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2909 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2910 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2911 | } |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2912 | /* This will cause the callback-function lpfc_cmpl_els_cmd to |
| 2913 | * trigger the release of the node. |
| 2914 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2915 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2916 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2917 | } |
| 2918 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2919 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2920 | * lpfc_cancel_retry_delay_tmo - Cancel the timer with delayed iocb-cmd retry |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2921 | * @vport: pointer to a host virtual N_Port data structure. |
| 2922 | * @nlp: pointer to a node-list data structure. |
| 2923 | * |
| 2924 | * This routine cancels the timer with a delayed IOCB-command retry for |
| 2925 | * a @vport's @ndlp. It stops the timer for the delayed function retrial and |
| 2926 | * removes the ELS retry event if it presents. In addition, if the |
| 2927 | * NLP_NPR_2B_DISC bit is set in the @nlp's nlp_flag bitmap, ADISC IOCB |
| 2928 | * commands are sent for the @vport's nodes that require issuing discovery |
| 2929 | * ADISC. |
| 2930 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2931 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2932 | lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp) |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2933 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2934 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2935 | struct lpfc_work_evt *evtp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2936 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2937 | if (!(nlp->nlp_flag & NLP_DELAY_TMO)) |
| 2938 | return; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2939 | spin_lock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2940 | nlp->nlp_flag &= ~NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2941 | spin_unlock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2942 | del_timer_sync(&nlp->nlp_delayfunc); |
| 2943 | nlp->nlp_last_elscmd = 0; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2944 | if (!list_empty(&nlp->els_retry_evt.evt_listp)) { |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2945 | list_del_init(&nlp->els_retry_evt.evt_listp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2946 | /* Decrement nlp reference count held for the delayed retry */ |
| 2947 | evtp = &nlp->els_retry_evt; |
| 2948 | lpfc_nlp_put((struct lpfc_nodelist *)evtp->evt_arg1); |
| 2949 | } |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2950 | if (nlp->nlp_flag & NLP_NPR_2B_DISC) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2951 | spin_lock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2952 | nlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2953 | spin_unlock_irq(shost->host_lock); |
| 2954 | if (vport->num_disc_nodes) { |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2955 | if (vport->port_state < LPFC_VPORT_READY) { |
| 2956 | /* Check if there are more ADISCs to be sent */ |
| 2957 | lpfc_more_adisc(vport); |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2958 | } else { |
| 2959 | /* Check if there are more PLOGIs to be sent */ |
| 2960 | lpfc_more_plogi(vport); |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2961 | if (vport->num_disc_nodes == 0) { |
| 2962 | spin_lock_irq(shost->host_lock); |
| 2963 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 2964 | spin_unlock_irq(shost->host_lock); |
| 2965 | lpfc_can_disctmo(vport); |
| 2966 | lpfc_end_rscn(vport); |
| 2967 | } |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2968 | } |
| 2969 | } |
| 2970 | } |
| 2971 | return; |
| 2972 | } |
| 2973 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2974 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2975 | * lpfc_els_retry_delay - Timer function with a ndlp delayed function timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2976 | * @ptr: holder for the pointer to the timer function associated data (ndlp). |
| 2977 | * |
| 2978 | * This routine is invoked by the ndlp delayed-function timer to check |
| 2979 | * whether there is any pending ELS retry event(s) with the node. If not, it |
| 2980 | * simply returns. Otherwise, if there is at least one ELS delayed event, it |
| 2981 | * adds the delayed events to the HBA work list and invokes the |
| 2982 | * lpfc_worker_wake_up() routine to wake up worker thread to process the |
| 2983 | * event. Note that lpfc_nlp_get() is called before posting the event to |
| 2984 | * the work list to hold reference count of ndlp so that it guarantees the |
| 2985 | * reference to ndlp will still be available when the worker thread gets |
| 2986 | * to the event associated with the ndlp. |
| 2987 | **/ |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2988 | void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2989 | lpfc_els_retry_delay(unsigned long ptr) |
| 2990 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2991 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) ptr; |
| 2992 | struct lpfc_vport *vport = ndlp->vport; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2993 | struct lpfc_hba *phba = vport->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2994 | unsigned long flags; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2995 | struct lpfc_work_evt *evtp = &ndlp->els_retry_evt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2996 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2997 | spin_lock_irqsave(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2998 | if (!list_empty(&evtp->evt_listp)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2999 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3000 | return; |
| 3001 | } |
| 3002 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3003 | /* We need to hold the node by incrementing the reference |
| 3004 | * count until the queued work is done |
| 3005 | */ |
| 3006 | evtp->evt_arg1 = lpfc_nlp_get(ndlp); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 3007 | if (evtp->evt_arg1) { |
| 3008 | evtp->evt = LPFC_EVT_ELS_RETRY; |
| 3009 | list_add_tail(&evtp->evt_listp, &phba->work_list); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3010 | lpfc_worker_wake_up(phba); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 3011 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3012 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3013 | return; |
| 3014 | } |
| 3015 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3016 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3017 | * lpfc_els_retry_delay_handler - Work thread handler for ndlp delayed function |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3018 | * @ndlp: pointer to a node-list data structure. |
| 3019 | * |
| 3020 | * This routine is the worker-thread handler for processing the @ndlp delayed |
| 3021 | * event(s), posted by the lpfc_els_retry_delay() routine. It simply retrieves |
| 3022 | * the last ELS command from the associated ndlp and invokes the proper ELS |
| 3023 | * function according to the delayed ELS command to retry the command. |
| 3024 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3025 | void |
| 3026 | lpfc_els_retry_delay_handler(struct lpfc_nodelist *ndlp) |
| 3027 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3028 | struct lpfc_vport *vport = ndlp->vport; |
| 3029 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3030 | uint32_t cmd, did, retry; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3031 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3032 | spin_lock_irq(shost->host_lock); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3033 | did = ndlp->nlp_DID; |
| 3034 | cmd = ndlp->nlp_last_elscmd; |
| 3035 | ndlp->nlp_last_elscmd = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3036 | |
| 3037 | if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3038 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3039 | return; |
| 3040 | } |
| 3041 | |
| 3042 | ndlp->nlp_flag &= ~NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3043 | spin_unlock_irq(shost->host_lock); |
James Smart | 1a16968 | 2006-03-07 15:04:06 -0500 | [diff] [blame] | 3044 | /* |
| 3045 | * If a discovery event readded nlp_delayfunc after timer |
| 3046 | * firing and before processing the timer, cancel the |
| 3047 | * nlp_delayfunc. |
| 3048 | */ |
| 3049 | del_timer_sync(&ndlp->nlp_delayfunc); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3050 | retry = ndlp->nlp_retry; |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 3051 | ndlp->nlp_retry = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3052 | |
| 3053 | switch (cmd) { |
| 3054 | case ELS_CMD_FLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3055 | lpfc_issue_els_flogi(vport, ndlp, retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3056 | break; |
| 3057 | case ELS_CMD_PLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3058 | if (!lpfc_issue_els_plogi(vport, ndlp->nlp_DID, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3059 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3060 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 3061 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3062 | break; |
| 3063 | case ELS_CMD_ADISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3064 | if (!lpfc_issue_els_adisc(vport, ndlp, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3065 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3066 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 3067 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3068 | break; |
| 3069 | case ELS_CMD_PRLI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3070 | if (!lpfc_issue_els_prli(vport, ndlp, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3071 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3072 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 3073 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3074 | break; |
| 3075 | case ELS_CMD_LOGO: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3076 | if (!lpfc_issue_els_logo(vport, ndlp, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3077 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 3078 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 3079 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3080 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3081 | case ELS_CMD_FDISC: |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 3082 | if (!(vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI)) |
| 3083 | lpfc_issue_els_fdisc(vport, ndlp, retry); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3084 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3085 | } |
| 3086 | return; |
| 3087 | } |
| 3088 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3089 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3090 | * lpfc_els_retry - Make retry decision on an els command iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3091 | * @phba: pointer to lpfc hba data structure. |
| 3092 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 3093 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 3094 | * |
| 3095 | * This routine makes a retry decision on an ELS command IOCB, which has |
| 3096 | * failed. The following ELS IOCBs use this function for retrying the command |
| 3097 | * when previously issued command responsed with error status: FLOGI, PLOGI, |
| 3098 | * PRLI, ADISC, LOGO, and FDISC. Based on the ELS command type and the |
| 3099 | * returned error status, it makes the decision whether a retry shall be |
| 3100 | * issued for the command, and whether a retry shall be made immediately or |
| 3101 | * delayed. In the former case, the corresponding ELS command issuing-function |
| 3102 | * is called to retry the command. In the later case, the ELS command shall |
| 3103 | * be posted to the ndlp delayed event and delayed function timer set to the |
| 3104 | * ndlp for the delayed command issusing. |
| 3105 | * |
| 3106 | * Return code |
| 3107 | * 0 - No retry of els command is made |
| 3108 | * 1 - Immediate or delayed retry of els command is made |
| 3109 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3110 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3111 | lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 3112 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3113 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3114 | struct lpfc_vport *vport = cmdiocb->vport; |
| 3115 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3116 | IOCB_t *irsp = &rspiocb->iocb; |
| 3117 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 3118 | struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3119 | uint32_t *elscmd; |
| 3120 | struct ls_rjt stat; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3121 | int retry = 0, maxretry = lpfc_max_els_tries, delay = 0; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3122 | int logerr = 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3123 | uint32_t cmd = 0; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3124 | uint32_t did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3125 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3126 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3127 | /* Note: context2 may be 0 for internal driver abort |
| 3128 | * of delays ELS command. |
| 3129 | */ |
| 3130 | |
| 3131 | if (pcmd && pcmd->virt) { |
| 3132 | elscmd = (uint32_t *) (pcmd->virt); |
| 3133 | cmd = *elscmd++; |
| 3134 | } |
| 3135 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3136 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3137 | did = ndlp->nlp_DID; |
| 3138 | else { |
| 3139 | /* We should only hit this case for retrying PLOGI */ |
| 3140 | did = irsp->un.elsreq64.remoteID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3141 | ndlp = lpfc_findnode_did(vport, did); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3142 | if ((!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 3143 | && (cmd != ELS_CMD_PLOGI)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3144 | return 1; |
| 3145 | } |
| 3146 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3147 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 3148 | "Retry ELS: wd7:x%x wd4:x%x did:x%x", |
| 3149 | *(((uint32_t *) irsp) + 7), irsp->un.ulpWord[4], ndlp->nlp_DID); |
| 3150 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3151 | switch (irsp->ulpStatus) { |
| 3152 | case IOSTAT_FCP_RSP_ERROR: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3153 | break; |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 3154 | case IOSTAT_REMOTE_STOP: |
| 3155 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 3156 | /* This IO was aborted by the target, we don't |
| 3157 | * know the rxid and because we did not send the |
| 3158 | * ABTS we cannot generate and RRQ. |
| 3159 | */ |
| 3160 | lpfc_set_rrq_active(phba, ndlp, |
James Smart | ee0f4fe | 2012-05-09 21:19:14 -0400 | [diff] [blame] | 3161 | cmdiocb->sli4_lxritag, 0, 0); |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 3162 | } |
| 3163 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3164 | case IOSTAT_LOCAL_REJECT: |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 3165 | switch ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3166 | case IOERR_LOOP_OPEN_FAILURE: |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 3167 | if (cmd == ELS_CMD_FLOGI) { |
| 3168 | if (PCI_DEVICE_ID_HORNET == |
| 3169 | phba->pcidev->device) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3170 | phba->fc_topology = LPFC_TOPOLOGY_LOOP; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 3171 | phba->pport->fc_myDID = 0; |
| 3172 | phba->alpa_map[0] = 0; |
| 3173 | phba->alpa_map[1] = 0; |
| 3174 | } |
| 3175 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3176 | if (cmd == ELS_CMD_PLOGI && cmdiocb->retry == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3177 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3178 | retry = 1; |
| 3179 | break; |
| 3180 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3181 | case IOERR_ILLEGAL_COMMAND: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 3182 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3183 | "0124 Retry illegal cmd x%x " |
| 3184 | "retry:x%x delay:x%x\n", |
| 3185 | cmd, cmdiocb->retry, delay); |
| 3186 | retry = 1; |
| 3187 | /* All command's retry policy */ |
| 3188 | maxretry = 8; |
| 3189 | if (cmdiocb->retry > 2) |
| 3190 | delay = 1000; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3191 | break; |
| 3192 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3193 | case IOERR_NO_RESOURCES: |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3194 | logerr = 1; /* HBA out of resources */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3195 | retry = 1; |
| 3196 | if (cmdiocb->retry > 100) |
| 3197 | delay = 100; |
| 3198 | maxretry = 250; |
| 3199 | break; |
| 3200 | |
| 3201 | case IOERR_ILLEGAL_FRAME: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3202 | delay = 100; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3203 | retry = 1; |
| 3204 | break; |
| 3205 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3206 | case IOERR_SEQUENCE_TIMEOUT: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3207 | case IOERR_INVALID_RPI: |
James Smart | 5b5b36a | 2013-01-03 15:43:19 -0500 | [diff] [blame] | 3208 | if (cmd == ELS_CMD_PLOGI && |
| 3209 | did == NameServer_DID) { |
| 3210 | /* Continue forever if plogi to */ |
| 3211 | /* the nameserver fails */ |
| 3212 | maxretry = 0; |
| 3213 | delay = 100; |
| 3214 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3215 | retry = 1; |
| 3216 | break; |
| 3217 | } |
| 3218 | break; |
| 3219 | |
| 3220 | case IOSTAT_NPORT_RJT: |
| 3221 | case IOSTAT_FABRIC_RJT: |
| 3222 | if (irsp->un.ulpWord[4] & RJT_UNAVAIL_TEMP) { |
| 3223 | retry = 1; |
| 3224 | break; |
| 3225 | } |
| 3226 | break; |
| 3227 | |
| 3228 | case IOSTAT_NPORT_BSY: |
| 3229 | case IOSTAT_FABRIC_BSY: |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3230 | logerr = 1; /* Fabric / Remote NPort out of resources */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3231 | retry = 1; |
| 3232 | break; |
| 3233 | |
| 3234 | case IOSTAT_LS_RJT: |
| 3235 | stat.un.lsRjtError = be32_to_cpu(irsp->un.ulpWord[4]); |
| 3236 | /* Added for Vendor specifc support |
| 3237 | * Just keep retrying for these Rsn / Exp codes |
| 3238 | */ |
| 3239 | switch (stat.un.b.lsRjtRsnCode) { |
| 3240 | case LSRJT_UNABLE_TPC: |
| 3241 | if (stat.un.b.lsRjtRsnCodeExp == |
| 3242 | LSEXP_CMD_IN_PROGRESS) { |
| 3243 | if (cmd == ELS_CMD_PLOGI) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3244 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3245 | maxretry = 48; |
| 3246 | } |
| 3247 | retry = 1; |
| 3248 | break; |
| 3249 | } |
James Smart | ffc9549 | 2010-06-07 15:23:17 -0400 | [diff] [blame] | 3250 | if (stat.un.b.lsRjtRsnCodeExp == |
| 3251 | LSEXP_CANT_GIVE_DATA) { |
| 3252 | if (cmd == ELS_CMD_PLOGI) { |
| 3253 | delay = 1000; |
| 3254 | maxretry = 48; |
| 3255 | } |
| 3256 | retry = 1; |
| 3257 | break; |
| 3258 | } |
James Smart | 4c1b64b | 2012-09-29 11:31:11 -0400 | [diff] [blame] | 3259 | if ((cmd == ELS_CMD_PLOGI) || |
| 3260 | (cmd == ELS_CMD_PRLI)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3261 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3262 | maxretry = lpfc_max_els_tries + 1; |
| 3263 | retry = 1; |
| 3264 | break; |
| 3265 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3266 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
| 3267 | (cmd == ELS_CMD_FDISC) && |
| 3268 | (stat.un.b.lsRjtRsnCodeExp == LSEXP_OUT_OF_RESOURCE)){ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3269 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3270 | "0125 FDISC Failed (x%x). " |
| 3271 | "Fabric out of resources\n", |
| 3272 | stat.un.lsRjtError); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3273 | lpfc_vport_set_state(vport, |
| 3274 | FC_VPORT_NO_FABRIC_RSCS); |
| 3275 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3276 | break; |
| 3277 | |
| 3278 | case LSRJT_LOGICAL_BSY: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3279 | if ((cmd == ELS_CMD_PLOGI) || |
| 3280 | (cmd == ELS_CMD_PRLI)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3281 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3282 | maxretry = 48; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3283 | } else if (cmd == ELS_CMD_FDISC) { |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3284 | /* FDISC retry policy */ |
| 3285 | maxretry = 48; |
| 3286 | if (cmdiocb->retry >= 32) |
| 3287 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3288 | } |
| 3289 | retry = 1; |
| 3290 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3291 | |
| 3292 | case LSRJT_LOGICAL_ERR: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 3293 | /* There are some cases where switches return this |
| 3294 | * error when they are not ready and should be returning |
| 3295 | * Logical Busy. We should delay every time. |
| 3296 | */ |
| 3297 | if (cmd == ELS_CMD_FDISC && |
| 3298 | stat.un.b.lsRjtRsnCodeExp == LSEXP_PORT_LOGIN_REQ) { |
| 3299 | maxretry = 3; |
| 3300 | delay = 1000; |
| 3301 | retry = 1; |
| 3302 | break; |
| 3303 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3304 | case LSRJT_PROTOCOL_ERR: |
| 3305 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
| 3306 | (cmd == ELS_CMD_FDISC) && |
| 3307 | ((stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_PNAME) || |
| 3308 | (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID)) |
| 3309 | ) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3310 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3311 | "0122 FDISC Failed (x%x). " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3312 | "Fabric Detected Bad WWN\n", |
| 3313 | stat.un.lsRjtError); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3314 | lpfc_vport_set_state(vport, |
| 3315 | FC_VPORT_FABRIC_REJ_WWN); |
| 3316 | } |
| 3317 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3318 | } |
| 3319 | break; |
| 3320 | |
| 3321 | case IOSTAT_INTERMED_RSP: |
| 3322 | case IOSTAT_BA_RJT: |
| 3323 | break; |
| 3324 | |
| 3325 | default: |
| 3326 | break; |
| 3327 | } |
| 3328 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3329 | if (did == FDMI_DID) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3330 | retry = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3331 | |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3332 | if ((cmd == ELS_CMD_FLOGI) && |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3333 | (phba->fc_topology != LPFC_TOPOLOGY_LOOP) && |
James Smart | 1b32f6a | 2008-02-08 18:49:39 -0500 | [diff] [blame] | 3334 | !lpfc_error_lost_link(irsp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3335 | /* FLOGI retry policy */ |
| 3336 | retry = 1; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3337 | /* retry FLOGI forever */ |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 3338 | maxretry = 0; |
| 3339 | if (cmdiocb->retry >= 100) |
| 3340 | delay = 5000; |
| 3341 | else if (cmdiocb->retry >= 32) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3342 | delay = 1000; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3343 | } else if ((cmd == ELS_CMD_FDISC) && !lpfc_error_lost_link(irsp)) { |
| 3344 | /* retry FDISCs every second up to devloss */ |
| 3345 | retry = 1; |
| 3346 | maxretry = vport->cfg_devloss_tmo; |
| 3347 | delay = 1000; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3348 | } |
| 3349 | |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 3350 | cmdiocb->retry++; |
| 3351 | if (maxretry && (cmdiocb->retry >= maxretry)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3352 | phba->fc_stat.elsRetryExceeded++; |
| 3353 | retry = 0; |
| 3354 | } |
| 3355 | |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 3356 | if ((vport->load_flag & FC_UNLOADING) != 0) |
| 3357 | retry = 0; |
| 3358 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3359 | if (retry) { |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 3360 | if ((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_FDISC)) { |
| 3361 | /* Stop retrying PLOGI and FDISC if in FCF discovery */ |
| 3362 | if (phba->fcf.fcf_flag & FCF_DISCOVERY) { |
| 3363 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3364 | "2849 Stop retry ELS command " |
| 3365 | "x%x to remote NPORT x%x, " |
| 3366 | "Data: x%x x%x\n", cmd, did, |
| 3367 | cmdiocb->retry, delay); |
| 3368 | return 0; |
| 3369 | } |
| 3370 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3371 | |
| 3372 | /* Retry ELS command <elsCmd> to remote NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3373 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3374 | "0107 Retry ELS command x%x to remote " |
| 3375 | "NPORT x%x Data: x%x x%x\n", |
| 3376 | cmd, did, cmdiocb->retry, delay); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3377 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3378 | if (((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_ADISC)) && |
| 3379 | ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 3380 | ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) != |
| 3381 | IOERR_NO_RESOURCES))) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3382 | /* Don't reset timer for no resources */ |
| 3383 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3384 | /* If discovery / RSCN timer is running, reset it */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3385 | if (timer_pending(&vport->fc_disctmo) || |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3386 | (vport->fc_flag & FC_RSCN_MODE)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3387 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3388 | } |
| 3389 | |
| 3390 | phba->fc_stat.elsXmitRetry++; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3391 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && delay) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3392 | phba->fc_stat.elsDelayRetry++; |
| 3393 | ndlp->nlp_retry = cmdiocb->retry; |
| 3394 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3395 | /* delay is specified in milliseconds */ |
| 3396 | mod_timer(&ndlp->nlp_delayfunc, |
| 3397 | jiffies + msecs_to_jiffies(delay)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3398 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3399 | ndlp->nlp_flag |= NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3400 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3401 | |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3402 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3403 | if (cmd == ELS_CMD_PRLI) |
| 3404 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | 4c1b64b | 2012-09-29 11:31:11 -0400 | [diff] [blame] | 3405 | NLP_STE_PRLI_ISSUE); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3406 | else |
| 3407 | lpfc_nlp_set_state(vport, ndlp, |
| 3408 | NLP_STE_NPR_NODE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3409 | ndlp->nlp_last_elscmd = cmd; |
| 3410 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3411 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3412 | } |
| 3413 | switch (cmd) { |
| 3414 | case ELS_CMD_FLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3415 | lpfc_issue_els_flogi(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3416 | return 1; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3417 | case ELS_CMD_FDISC: |
| 3418 | lpfc_issue_els_fdisc(vport, ndlp, cmdiocb->retry); |
| 3419 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3420 | case ELS_CMD_PLOGI: |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3421 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3422 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3423 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | de0c5b3 | 2007-04-25 09:52:27 -0400 | [diff] [blame] | 3424 | NLP_STE_PLOGI_ISSUE); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3425 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3426 | lpfc_issue_els_plogi(vport, did, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3427 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3428 | case ELS_CMD_ADISC: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3429 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3430 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE); |
| 3431 | lpfc_issue_els_adisc(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3432 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3433 | case ELS_CMD_PRLI: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3434 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3435 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE); |
| 3436 | lpfc_issue_els_prli(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3437 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3438 | case ELS_CMD_LOGO: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3439 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 3440 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3441 | lpfc_issue_els_logo(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3442 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3443 | } |
| 3444 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3445 | /* No retry ELS command <elsCmd> to remote NPORT <did> */ |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3446 | if (logerr) { |
| 3447 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3448 | "0137 No retry ELS command x%x to remote " |
| 3449 | "NPORT x%x: Out of Resources: Error:x%x/%x\n", |
| 3450 | cmd, did, irsp->ulpStatus, |
| 3451 | irsp->un.ulpWord[4]); |
| 3452 | } |
| 3453 | else { |
| 3454 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3455 | "0108 No retry ELS command x%x to remote " |
| 3456 | "NPORT x%x Retried:%d Error:x%x/%x\n", |
| 3457 | cmd, did, cmdiocb->retry, irsp->ulpStatus, |
| 3458 | irsp->un.ulpWord[4]); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3459 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3460 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3461 | } |
| 3462 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3463 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3464 | * lpfc_els_free_data - Free lpfc dma buffer and data structure with an iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3465 | * @phba: pointer to lpfc hba data structure. |
| 3466 | * @buf_ptr1: pointer to the lpfc DMA buffer data structure. |
| 3467 | * |
| 3468 | * This routine releases the lpfc DMA (Direct Memory Access) buffer(s) |
| 3469 | * associated with a command IOCB back to the lpfc DMA buffer pool. It first |
| 3470 | * checks to see whether there is a lpfc DMA buffer associated with the |
| 3471 | * response of the command IOCB. If so, it will be released before releasing |
| 3472 | * the lpfc DMA buffer associated with the IOCB itself. |
| 3473 | * |
| 3474 | * Return code |
| 3475 | * 0 - Successfully released lpfc DMA buffer (currently, always return 0) |
| 3476 | **/ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3477 | static int |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3478 | lpfc_els_free_data(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr1) |
| 3479 | { |
| 3480 | struct lpfc_dmabuf *buf_ptr; |
| 3481 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3482 | /* Free the response before processing the command. */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3483 | if (!list_empty(&buf_ptr1->list)) { |
| 3484 | list_remove_head(&buf_ptr1->list, buf_ptr, |
| 3485 | struct lpfc_dmabuf, |
| 3486 | list); |
| 3487 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 3488 | kfree(buf_ptr); |
| 3489 | } |
| 3490 | lpfc_mbuf_free(phba, buf_ptr1->virt, buf_ptr1->phys); |
| 3491 | kfree(buf_ptr1); |
| 3492 | return 0; |
| 3493 | } |
| 3494 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3495 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3496 | * lpfc_els_free_bpl - Free lpfc dma buffer and data structure with bpl |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3497 | * @phba: pointer to lpfc hba data structure. |
| 3498 | * @buf_ptr: pointer to the lpfc dma buffer data structure. |
| 3499 | * |
| 3500 | * This routine releases the lpfc Direct Memory Access (DMA) buffer |
| 3501 | * associated with a Buffer Pointer List (BPL) back to the lpfc DMA buffer |
| 3502 | * pool. |
| 3503 | * |
| 3504 | * Return code |
| 3505 | * 0 - Successfully released lpfc DMA buffer (currently, always return 0) |
| 3506 | **/ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3507 | static int |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3508 | lpfc_els_free_bpl(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr) |
| 3509 | { |
| 3510 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 3511 | kfree(buf_ptr); |
| 3512 | return 0; |
| 3513 | } |
| 3514 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3515 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3516 | * lpfc_els_free_iocb - Free a command iocb and its associated resources |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3517 | * @phba: pointer to lpfc hba data structure. |
| 3518 | * @elsiocb: pointer to lpfc els command iocb data structure. |
| 3519 | * |
| 3520 | * This routine frees a command IOCB and its associated resources. The |
| 3521 | * command IOCB data structure contains the reference to various associated |
| 3522 | * resources, these fields must be set to NULL if the associated reference |
| 3523 | * not present: |
| 3524 | * context1 - reference to ndlp |
| 3525 | * context2 - reference to cmd |
| 3526 | * context2->next - reference to rsp |
| 3527 | * context3 - reference to bpl |
| 3528 | * |
| 3529 | * It first properly decrements the reference count held on ndlp for the |
| 3530 | * IOCB completion callback function. If LPFC_DELAY_MEM_FREE flag is not |
| 3531 | * set, it invokes the lpfc_els_free_data() routine to release the Direct |
| 3532 | * Memory Access (DMA) buffers associated with the IOCB. Otherwise, it |
| 3533 | * adds the DMA buffer the @phba data structure for the delayed release. |
| 3534 | * If reference to the Buffer Pointer List (BPL) is present, the |
| 3535 | * lpfc_els_free_bpl() routine is invoked to release the DMA memory |
| 3536 | * associated with BPL. Finally, the lpfc_sli_release_iocbq() routine is |
| 3537 | * invoked to release the IOCB data structure back to @phba IOCBQ list. |
| 3538 | * |
| 3539 | * Return code |
| 3540 | * 0 - Success (currently, always return 0) |
| 3541 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3542 | int |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3543 | lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3544 | { |
| 3545 | struct lpfc_dmabuf *buf_ptr, *buf_ptr1; |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3546 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3547 | |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3548 | ndlp = (struct lpfc_nodelist *)elsiocb->context1; |
| 3549 | if (ndlp) { |
| 3550 | if (ndlp->nlp_flag & NLP_DEFER_RM) { |
| 3551 | lpfc_nlp_put(ndlp); |
| 3552 | |
| 3553 | /* If the ndlp is not being used by another discovery |
| 3554 | * thread, free it. |
| 3555 | */ |
| 3556 | if (!lpfc_nlp_not_used(ndlp)) { |
| 3557 | /* If ndlp is being used by another discovery |
| 3558 | * thread, just clear NLP_DEFER_RM |
| 3559 | */ |
| 3560 | ndlp->nlp_flag &= ~NLP_DEFER_RM; |
| 3561 | } |
| 3562 | } |
| 3563 | else |
| 3564 | lpfc_nlp_put(ndlp); |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3565 | elsiocb->context1 = NULL; |
| 3566 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3567 | /* context2 = cmd, context2->next = rsp, context3 = bpl */ |
| 3568 | if (elsiocb->context2) { |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 3569 | if (elsiocb->iocb_flag & LPFC_DELAY_MEM_FREE) { |
| 3570 | /* Firmware could still be in progress of DMAing |
| 3571 | * payload, so don't free data buffer till after |
| 3572 | * a hbeat. |
| 3573 | */ |
| 3574 | elsiocb->iocb_flag &= ~LPFC_DELAY_MEM_FREE; |
| 3575 | buf_ptr = elsiocb->context2; |
| 3576 | elsiocb->context2 = NULL; |
| 3577 | if (buf_ptr) { |
| 3578 | buf_ptr1 = NULL; |
| 3579 | spin_lock_irq(&phba->hbalock); |
| 3580 | if (!list_empty(&buf_ptr->list)) { |
| 3581 | list_remove_head(&buf_ptr->list, |
| 3582 | buf_ptr1, struct lpfc_dmabuf, |
| 3583 | list); |
| 3584 | INIT_LIST_HEAD(&buf_ptr1->list); |
| 3585 | list_add_tail(&buf_ptr1->list, |
| 3586 | &phba->elsbuf); |
| 3587 | phba->elsbuf_cnt++; |
| 3588 | } |
| 3589 | INIT_LIST_HEAD(&buf_ptr->list); |
| 3590 | list_add_tail(&buf_ptr->list, &phba->elsbuf); |
| 3591 | phba->elsbuf_cnt++; |
| 3592 | spin_unlock_irq(&phba->hbalock); |
| 3593 | } |
| 3594 | } else { |
| 3595 | buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2; |
| 3596 | lpfc_els_free_data(phba, buf_ptr1); |
| 3597 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3598 | } |
| 3599 | |
| 3600 | if (elsiocb->context3) { |
| 3601 | buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3602 | lpfc_els_free_bpl(phba, buf_ptr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3603 | } |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 3604 | lpfc_sli_release_iocbq(phba, elsiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3605 | return 0; |
| 3606 | } |
| 3607 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3608 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3609 | * lpfc_cmpl_els_logo_acc - Completion callback function to logo acc response |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3610 | * @phba: pointer to lpfc hba data structure. |
| 3611 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 3612 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 3613 | * |
| 3614 | * This routine is the completion callback function to the Logout (LOGO) |
| 3615 | * Accept (ACC) Response ELS command. This routine is invoked to indicate |
| 3616 | * the completion of the LOGO process. It invokes the lpfc_nlp_not_used() to |
| 3617 | * release the ndlp if it has the last reference remaining (reference count |
| 3618 | * is 1). If succeeded (meaning ndlp released), it sets the IOCB context1 |
| 3619 | * field to NULL to inform the following lpfc_els_free_iocb() routine no |
| 3620 | * ndlp reference count needs to be decremented. Otherwise, the ndlp |
| 3621 | * reference use-count shall be decremented by the lpfc_els_free_iocb() |
| 3622 | * routine. Finally, the lpfc_els_free_iocb() is invoked to release the |
| 3623 | * IOCB data structure. |
| 3624 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3625 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3626 | lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 3627 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3628 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3629 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 3630 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3631 | IOCB_t *irsp; |
| 3632 | |
| 3633 | irsp = &rspiocb->iocb; |
| 3634 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3635 | "ACC LOGO cmpl: status:x%x/x%x did:x%x", |
| 3636 | irsp->ulpStatus, irsp->un.ulpWord[4], ndlp->nlp_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3637 | /* ACC to LOGO completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3638 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3639 | "0109 ACC to LOGO completes to NPort x%x " |
| 3640 | "Data: x%x x%x x%x\n", |
| 3641 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3642 | ndlp->nlp_rpi); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3643 | |
| 3644 | if (ndlp->nlp_state == NLP_STE_NPR_NODE) { |
| 3645 | /* NPort Recovery mode or node is just allocated */ |
| 3646 | if (!lpfc_nlp_not_used(ndlp)) { |
| 3647 | /* If the ndlp is being used by another discovery |
| 3648 | * thread, just unregister the RPI. |
| 3649 | */ |
| 3650 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3651 | } else { |
| 3652 | /* Indicate the node has already released, should |
| 3653 | * not reference to it from within lpfc_els_free_iocb. |
| 3654 | */ |
| 3655 | cmdiocb->context1 = NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3656 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3657 | } |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 3658 | |
| 3659 | /* |
| 3660 | * The driver received a LOGO from the rport and has ACK'd it. |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3661 | * At this point, the driver is done so release the IOCB |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 3662 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3663 | lpfc_els_free_iocb(phba, cmdiocb); |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3664 | |
| 3665 | /* |
| 3666 | * Remove the ndlp reference if it's a fabric node that has |
| 3667 | * sent us an unsolicted LOGO. |
| 3668 | */ |
| 3669 | if (ndlp->nlp_type & NLP_FABRIC) |
| 3670 | lpfc_nlp_put(ndlp); |
| 3671 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3672 | return; |
| 3673 | } |
| 3674 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3675 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3676 | * lpfc_mbx_cmpl_dflt_rpi - Completion callbk func for unreg dflt rpi mbox cmd |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3677 | * @phba: pointer to lpfc hba data structure. |
| 3678 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 3679 | * |
| 3680 | * This routine is the completion callback function for unregister default |
| 3681 | * RPI (Remote Port Index) mailbox command to the @phba. It simply releases |
| 3682 | * the associated lpfc Direct Memory Access (DMA) buffer back to the pool and |
| 3683 | * decrements the ndlp reference count held for this completion callback |
| 3684 | * function. After that, it invokes the lpfc_nlp_not_used() to check |
| 3685 | * whether there is only one reference left on the ndlp. If so, it will |
| 3686 | * perform one more decrement and trigger the release of the ndlp. |
| 3687 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3688 | void |
| 3689 | lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
| 3690 | { |
| 3691 | struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1); |
| 3692 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2; |
| 3693 | |
| 3694 | pmb->context1 = NULL; |
James Smart | d439d28 | 2010-09-29 11:18:45 -0400 | [diff] [blame] | 3695 | pmb->context2 = NULL; |
| 3696 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3697 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3698 | kfree(mp); |
| 3699 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 3700 | if (ndlp) { |
| 3701 | if (NLP_CHK_NODE_ACT(ndlp)) { |
| 3702 | lpfc_nlp_put(ndlp); |
| 3703 | /* This is the end of the default RPI cleanup logic for |
| 3704 | * this ndlp. If no other discovery threads are using |
| 3705 | * this ndlp, free all resources associated with it. |
| 3706 | */ |
| 3707 | lpfc_nlp_not_used(ndlp); |
| 3708 | } else { |
| 3709 | lpfc_drop_node(ndlp->vport, ndlp); |
| 3710 | } |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3711 | } |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 3712 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3713 | return; |
| 3714 | } |
| 3715 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3716 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3717 | * lpfc_cmpl_els_rsp - Completion callback function for els response iocb cmd |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3718 | * @phba: pointer to lpfc hba data structure. |
| 3719 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 3720 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 3721 | * |
| 3722 | * This routine is the completion callback function for ELS Response IOCB |
| 3723 | * command. In normal case, this callback function just properly sets the |
| 3724 | * nlp_flag bitmap in the ndlp data structure, if the mbox command reference |
| 3725 | * field in the command IOCB is not NULL, the referred mailbox command will |
| 3726 | * be send out, and then invokes the lpfc_els_free_iocb() routine to release |
| 3727 | * the IOCB. Under error conditions, such as when a LS_RJT is returned or a |
| 3728 | * link down event occurred during the discovery, the lpfc_nlp_not_used() |
| 3729 | * routine shall be invoked trying to release the ndlp if no other threads |
| 3730 | * are currently referring it. |
| 3731 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3732 | static void |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3733 | lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3734 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3735 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3736 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 3737 | struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL; |
| 3738 | struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3739 | IOCB_t *irsp; |
| 3740 | uint8_t *pcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3741 | LPFC_MBOXQ_t *mbox = NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3742 | struct lpfc_dmabuf *mp = NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3743 | uint32_t ls_rjt = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3744 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 3745 | irsp = &rspiocb->iocb; |
| 3746 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3747 | if (cmdiocb->context_un.mbox) |
| 3748 | mbox = cmdiocb->context_un.mbox; |
| 3749 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3750 | /* First determine if this is a LS_RJT cmpl. Note, this callback |
| 3751 | * function can have cmdiocb->contest1 (ndlp) field set to NULL. |
| 3752 | */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3753 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3754 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 3755 | (*((uint32_t *) (pcmd)) == ELS_CMD_LS_RJT)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3756 | /* A LS_RJT associated with Default RPI cleanup has its own |
Daniel Mack | 3ad2f3f | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 3757 | * separate code path. |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3758 | */ |
| 3759 | if (!(ndlp->nlp_flag & NLP_RM_DFLT_RPI)) |
| 3760 | ls_rjt = 1; |
| 3761 | } |
| 3762 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3763 | /* Check to see if link went down during discovery */ |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3764 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) || lpfc_els_chk_latt(vport)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3765 | if (mbox) { |
James Smart | 1469115 | 2006-12-02 13:34:28 -0500 | [diff] [blame] | 3766 | mp = (struct lpfc_dmabuf *) mbox->context1; |
| 3767 | if (mp) { |
| 3768 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3769 | kfree(mp); |
| 3770 | } |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3771 | mempool_free(mbox, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3772 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3773 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 3774 | (ndlp->nlp_flag & NLP_RM_DFLT_RPI)) |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3775 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3776 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3777 | /* Indicate the node has already released, |
| 3778 | * should not reference to it from within |
| 3779 | * the routine lpfc_els_free_iocb. |
| 3780 | */ |
| 3781 | cmdiocb->context1 = NULL; |
| 3782 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3783 | goto out; |
| 3784 | } |
| 3785 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3786 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3787 | "ELS rsp cmpl: status:x%x/x%x did:x%x", |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3788 | irsp->ulpStatus, irsp->un.ulpWord[4], |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3789 | cmdiocb->iocb.un.elsreq64.remoteID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3790 | /* ELS response tag <ulpIoTag> completes */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3791 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3792 | "0110 ELS response tag x%x completes " |
| 3793 | "Data: x%x x%x x%x x%x x%x x%x x%x\n", |
| 3794 | cmdiocb->iocb.ulpIoTag, rspiocb->iocb.ulpStatus, |
| 3795 | rspiocb->iocb.un.ulpWord[4], rspiocb->iocb.ulpTimeout, |
| 3796 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3797 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3798 | if (mbox) { |
| 3799 | if ((rspiocb->iocb.ulpStatus == 0) |
| 3800 | && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3801 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3802 | /* Increment reference count to ndlp to hold the |
| 3803 | * reference to ndlp for the callback function. |
| 3804 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3805 | mbox->context2 = lpfc_nlp_get(ndlp); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3806 | mbox->vport = vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3807 | if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) { |
| 3808 | mbox->mbox_flag |= LPFC_MBX_IMED_UNREG; |
| 3809 | mbox->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi; |
| 3810 | } |
| 3811 | else { |
| 3812 | mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; |
| 3813 | ndlp->nlp_prev_state = ndlp->nlp_state; |
| 3814 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3815 | NLP_STE_REG_LOGIN_ISSUE); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3816 | } |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 3817 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3818 | != MBX_NOT_FINISHED) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3819 | goto out; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3820 | else |
| 3821 | /* Decrement the ndlp reference count we |
| 3822 | * set for this failed mailbox command. |
| 3823 | */ |
| 3824 | lpfc_nlp_put(ndlp); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3825 | |
| 3826 | /* ELS rsp: Cannot issue reg_login for <NPortid> */ |
| 3827 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3828 | "0138 ELS rsp: Cannot issue reg_login for x%x " |
| 3829 | "Data: x%x x%x x%x\n", |
| 3830 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3831 | ndlp->nlp_rpi); |
| 3832 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3833 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3834 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3835 | /* Indicate node has already been released, |
| 3836 | * should not reference to it from within |
| 3837 | * the routine lpfc_els_free_iocb. |
| 3838 | */ |
| 3839 | cmdiocb->context1 = NULL; |
| 3840 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3841 | } else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3842 | /* Do not drop node for lpfc_els_abort'ed ELS cmds */ |
| 3843 | if (!lpfc_error_lost_link(irsp) && |
| 3844 | ndlp->nlp_flag & NLP_ACC_REGLOGIN) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3845 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3846 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3847 | /* Indicate node has already been |
| 3848 | * released, should not reference |
| 3849 | * to it from within the routine |
| 3850 | * lpfc_els_free_iocb. |
| 3851 | */ |
| 3852 | cmdiocb->context1 = NULL; |
| 3853 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3854 | } |
| 3855 | } |
James Smart | 1469115 | 2006-12-02 13:34:28 -0500 | [diff] [blame] | 3856 | mp = (struct lpfc_dmabuf *) mbox->context1; |
| 3857 | if (mp) { |
| 3858 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3859 | kfree(mp); |
| 3860 | } |
| 3861 | mempool_free(mbox, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3862 | } |
| 3863 | out: |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3864 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3865 | spin_lock_irq(shost->host_lock); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3866 | ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3867 | spin_unlock_irq(shost->host_lock); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3868 | |
| 3869 | /* If the node is not being used by another discovery thread, |
| 3870 | * and we are sending a reject, we are done with it. |
| 3871 | * Release driver reference count here and free associated |
| 3872 | * resources. |
| 3873 | */ |
| 3874 | if (ls_rjt) |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3875 | if (lpfc_nlp_not_used(ndlp)) |
| 3876 | /* Indicate node has already been released, |
| 3877 | * should not reference to it from within |
| 3878 | * the routine lpfc_els_free_iocb. |
| 3879 | */ |
| 3880 | cmdiocb->context1 = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3881 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3882 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3883 | lpfc_els_free_iocb(phba, cmdiocb); |
| 3884 | return; |
| 3885 | } |
| 3886 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3887 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3888 | * lpfc_els_rsp_acc - Prepare and issue an acc response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3889 | * @vport: pointer to a host virtual N_Port data structure. |
| 3890 | * @flag: the els command code to be accepted. |
| 3891 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 3892 | * @ndlp: pointer to a node-list data structure. |
| 3893 | * @mbox: pointer to the driver internal queue element for mailbox command. |
| 3894 | * |
| 3895 | * This routine prepares and issues an Accept (ACC) response IOCB |
| 3896 | * command. It uses the @flag to properly set up the IOCB field for the |
| 3897 | * specific ACC response command to be issued and invokes the |
| 3898 | * lpfc_sli_issue_iocb() routine to send out ACC response IOCB. If a |
| 3899 | * @mbox pointer is passed in, it will be put into the context_un.mbox |
| 3900 | * field of the IOCB for the completion callback function to issue the |
| 3901 | * mailbox command to the HBA later when callback is invoked. |
| 3902 | * |
| 3903 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 3904 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 3905 | * will be stored into the context1 field of the IOCB for the completion |
| 3906 | * callback function to the corresponding response ELS IOCB command. |
| 3907 | * |
| 3908 | * Return code |
| 3909 | * 0 - Successfully issued acc response |
| 3910 | * 1 - Failed to issue acc response |
| 3911 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3912 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3913 | lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, |
| 3914 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3915 | LPFC_MBOXQ_t *mbox) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3916 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3917 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3918 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3919 | IOCB_t *icmd; |
| 3920 | IOCB_t *oldcmd; |
| 3921 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3922 | struct lpfc_sli *psli; |
| 3923 | uint8_t *pcmd; |
| 3924 | uint16_t cmdsize; |
| 3925 | int rc; |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3926 | ELS_PKT *els_pkt_ptr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3927 | |
| 3928 | psli = &phba->sli; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3929 | oldcmd = &oldiocb->iocb; |
| 3930 | |
| 3931 | switch (flag) { |
| 3932 | case ELS_CMD_ACC: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3933 | cmdsize = sizeof(uint32_t); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3934 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
| 3935 | ndlp, ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3936 | if (!elsiocb) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3937 | spin_lock_irq(shost->host_lock); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3938 | ndlp->nlp_flag &= ~NLP_LOGO_ACC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3939 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3940 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3941 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3942 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3943 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 3944 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 3945 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3946 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3947 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3948 | pcmd += sizeof(uint32_t); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3949 | |
| 3950 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3951 | "Issue ACC: did:x%x flg:x%x", |
| 3952 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3953 | break; |
| 3954 | case ELS_CMD_PLOGI: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3955 | cmdsize = (sizeof(struct serv_parm) + sizeof(uint32_t)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3956 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
| 3957 | ndlp, ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3958 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3959 | return 1; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3960 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3961 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 3962 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 3963 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3964 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3965 | |
| 3966 | if (mbox) |
| 3967 | elsiocb->context_un.mbox = mbox; |
| 3968 | |
| 3969 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3970 | pcmd += sizeof(uint32_t); |
| 3971 | memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3972 | |
| 3973 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3974 | "Issue ACC PLOGI: did:x%x flg:x%x", |
| 3975 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3976 | break; |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3977 | case ELS_CMD_PRLO: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3978 | cmdsize = sizeof(uint32_t) + sizeof(PRLO); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3979 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3980 | ndlp, ndlp->nlp_DID, ELS_CMD_PRLO); |
| 3981 | if (!elsiocb) |
| 3982 | return 1; |
| 3983 | |
| 3984 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 3985 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 3986 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3987 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3988 | |
| 3989 | memcpy(pcmd, ((struct lpfc_dmabuf *) oldiocb->context2)->virt, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3990 | sizeof(uint32_t) + sizeof(PRLO)); |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3991 | *((uint32_t *) (pcmd)) = ELS_CMD_PRLO_ACC; |
| 3992 | els_pkt_ptr = (ELS_PKT *) pcmd; |
| 3993 | els_pkt_ptr->un.prlo.acceptRspCode = PRLO_REQ_EXECUTED; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3994 | |
| 3995 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3996 | "Issue ACC PRLO: did:x%x flg:x%x", |
| 3997 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3998 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3999 | default: |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4000 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4001 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4002 | /* Xmit ELS ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4003 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4004 | "0128 Xmit ELS ACC response tag x%x, XRI: x%x, " |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 4005 | "DID: x%x, nlp_flag: x%x nlp_state: x%x RPI: x%x " |
| 4006 | "fc_flag x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4007 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 4008 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 4009 | ndlp->nlp_rpi, vport->fc_flag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4010 | if (ndlp->nlp_flag & NLP_LOGO_ACC) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4011 | spin_lock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4012 | ndlp->nlp_flag &= ~NLP_LOGO_ACC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4013 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4014 | elsiocb->iocb_cmpl = lpfc_cmpl_els_logo_acc; |
| 4015 | } else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4016 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4017 | } |
| 4018 | |
| 4019 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4020 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4021 | if (rc == IOCB_ERROR) { |
| 4022 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4023 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4024 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4025 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4026 | } |
| 4027 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4028 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4029 | * lpfc_els_rsp_reject - Propare and issue a rjt response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4030 | * @vport: pointer to a virtual N_Port data structure. |
| 4031 | * @rejectError: |
| 4032 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4033 | * @ndlp: pointer to a node-list data structure. |
| 4034 | * @mbox: pointer to the driver internal queue element for mailbox command. |
| 4035 | * |
| 4036 | * This routine prepares and issue an Reject (RJT) response IOCB |
| 4037 | * command. If a @mbox pointer is passed in, it will be put into the |
| 4038 | * context_un.mbox field of the IOCB for the completion callback function |
| 4039 | * to issue to the HBA later. |
| 4040 | * |
| 4041 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4042 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4043 | * will be stored into the context1 field of the IOCB for the completion |
| 4044 | * callback function to the reject response ELS IOCB command. |
| 4045 | * |
| 4046 | * Return code |
| 4047 | * 0 - Successfully issued reject response |
| 4048 | * 1 - Failed to issue reject response |
| 4049 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4050 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4051 | lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4052 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, |
| 4053 | LPFC_MBOXQ_t *mbox) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4054 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4055 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4056 | IOCB_t *icmd; |
| 4057 | IOCB_t *oldcmd; |
| 4058 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4059 | struct lpfc_sli *psli; |
| 4060 | uint8_t *pcmd; |
| 4061 | uint16_t cmdsize; |
| 4062 | int rc; |
| 4063 | |
| 4064 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4065 | cmdsize = 2 * sizeof(uint32_t); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4066 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4067 | ndlp->nlp_DID, ELS_CMD_LS_RJT); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 4068 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4069 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4070 | |
| 4071 | icmd = &elsiocb->iocb; |
| 4072 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4073 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4074 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4075 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4076 | |
| 4077 | *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4078 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4079 | *((uint32_t *) (pcmd)) = rejectError; |
| 4080 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4081 | if (mbox) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4082 | elsiocb->context_un.mbox = mbox; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4083 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4084 | /* Xmit ELS RJT <err> response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4085 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4086 | "0129 Xmit ELS RJT x%x response tag x%x " |
| 4087 | "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " |
| 4088 | "rpi x%x\n", |
| 4089 | rejectError, elsiocb->iotag, |
| 4090 | elsiocb->iocb.ulpContext, ndlp->nlp_DID, |
| 4091 | ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4092 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4093 | "Issue LS_RJT: did:x%x flg:x%x err:x%x", |
| 4094 | ndlp->nlp_DID, ndlp->nlp_flag, rejectError); |
| 4095 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4096 | phba->fc_stat.elsXmitLSRJT++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4097 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4098 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4099 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4100 | if (rc == IOCB_ERROR) { |
| 4101 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4102 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4103 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4104 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4105 | } |
| 4106 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4107 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4108 | * lpfc_els_rsp_adisc_acc - Prepare and issue acc response to adisc iocb cmd |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4109 | * @vport: pointer to a virtual N_Port data structure. |
| 4110 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4111 | * @ndlp: pointer to a node-list data structure. |
| 4112 | * |
| 4113 | * This routine prepares and issues an Accept (ACC) response to Address |
| 4114 | * Discover (ADISC) ELS command. It simply prepares the payload of the IOCB |
| 4115 | * and invokes the lpfc_sli_issue_iocb() routine to send out the command. |
| 4116 | * |
| 4117 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4118 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4119 | * will be stored into the context1 field of the IOCB for the completion |
| 4120 | * callback function to the ADISC Accept response ELS IOCB command. |
| 4121 | * |
| 4122 | * Return code |
| 4123 | * 0 - Successfully issued acc adisc response |
| 4124 | * 1 - Failed to issue adisc acc response |
| 4125 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4126 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4127 | lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, |
| 4128 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4129 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4130 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4131 | ADISC *ap; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4132 | IOCB_t *icmd, *oldcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4133 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4134 | uint8_t *pcmd; |
| 4135 | uint16_t cmdsize; |
| 4136 | int rc; |
| 4137 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4138 | cmdsize = sizeof(uint32_t) + sizeof(ADISC); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4139 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4140 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 4141 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4142 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4143 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4144 | icmd = &elsiocb->iocb; |
| 4145 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4146 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4147 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 4148 | |
| 4149 | /* Xmit ADISC ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4150 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4151 | "0130 Xmit ADISC ACC response iotag x%x xri: " |
| 4152 | "x%x, did x%x, nlp_flag x%x, nlp_state x%x rpi x%x\n", |
| 4153 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 4154 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 4155 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4156 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4157 | |
| 4158 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4159 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4160 | |
| 4161 | ap = (ADISC *) (pcmd); |
| 4162 | ap->hardAL_PA = phba->fc_pref_ALPA; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4163 | memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 4164 | memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4165 | ap->DID = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4166 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4167 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4168 | "Issue ACC ADISC: did:x%x flg:x%x", |
| 4169 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4170 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4171 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4172 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4173 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4174 | if (rc == IOCB_ERROR) { |
| 4175 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4176 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4177 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4178 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4179 | } |
| 4180 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4181 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4182 | * lpfc_els_rsp_prli_acc - Prepare and issue acc response to prli iocb cmd |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4183 | * @vport: pointer to a virtual N_Port data structure. |
| 4184 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4185 | * @ndlp: pointer to a node-list data structure. |
| 4186 | * |
| 4187 | * This routine prepares and issues an Accept (ACC) response to Process |
| 4188 | * Login (PRLI) ELS command. It simply prepares the payload of the IOCB |
| 4189 | * and invokes the lpfc_sli_issue_iocb() routine to send out the command. |
| 4190 | * |
| 4191 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4192 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4193 | * will be stored into the context1 field of the IOCB for the completion |
| 4194 | * callback function to the PRLI Accept response ELS IOCB command. |
| 4195 | * |
| 4196 | * Return code |
| 4197 | * 0 - Successfully issued acc prli response |
| 4198 | * 1 - Failed to issue acc prli response |
| 4199 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4200 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4201 | lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 4202 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4203 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4204 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4205 | PRLI *npr; |
| 4206 | lpfc_vpd_t *vpd; |
| 4207 | IOCB_t *icmd; |
| 4208 | IOCB_t *oldcmd; |
| 4209 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4210 | struct lpfc_sli *psli; |
| 4211 | uint8_t *pcmd; |
| 4212 | uint16_t cmdsize; |
| 4213 | int rc; |
| 4214 | |
| 4215 | psli = &phba->sli; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4216 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4217 | cmdsize = sizeof(uint32_t) + sizeof(PRLI); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4218 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4219 | ndlp->nlp_DID, (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK))); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4220 | if (!elsiocb) |
| 4221 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4222 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4223 | icmd = &elsiocb->iocb; |
| 4224 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4225 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4226 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| 4227 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 4228 | /* Xmit PRLI ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4229 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4230 | "0131 Xmit PRLI ACC response tag x%x xri x%x, " |
| 4231 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", |
| 4232 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 4233 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 4234 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4235 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4236 | |
| 4237 | *((uint32_t *) (pcmd)) = (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4238 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4239 | |
| 4240 | /* For PRLI, remainder of payload is PRLI parameter page */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4241 | memset(pcmd, 0, sizeof(PRLI)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4242 | |
| 4243 | npr = (PRLI *) pcmd; |
| 4244 | vpd = &phba->vpd; |
| 4245 | /* |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4246 | * If the remote port is a target and our firmware version is 3.20 or |
| 4247 | * later, set the following bits for FC-TAPE support. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4248 | */ |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4249 | if ((ndlp->nlp_type & NLP_FCP_TARGET) && |
| 4250 | (vpd->rev.feaLevelHigh >= 0x02)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4251 | npr->ConfmComplAllowed = 1; |
| 4252 | npr->Retry = 1; |
| 4253 | npr->TaskRetryIdReq = 1; |
| 4254 | } |
| 4255 | |
| 4256 | npr->acceptRspCode = PRLI_REQ_EXECUTED; |
| 4257 | npr->estabImagePair = 1; |
| 4258 | npr->readXferRdyDis = 1; |
| 4259 | npr->ConfmComplAllowed = 1; |
| 4260 | |
| 4261 | npr->prliType = PRLI_FCP_TYPE; |
| 4262 | npr->initiatorFunc = 1; |
| 4263 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4264 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4265 | "Issue ACC PRLI: did:x%x flg:x%x", |
| 4266 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4267 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4268 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4269 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4270 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4271 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4272 | if (rc == IOCB_ERROR) { |
| 4273 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4274 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4275 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4276 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4277 | } |
| 4278 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4279 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4280 | * lpfc_els_rsp_rnid_acc - Issue rnid acc response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4281 | * @vport: pointer to a virtual N_Port data structure. |
| 4282 | * @format: rnid command format. |
| 4283 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4284 | * @ndlp: pointer to a node-list data structure. |
| 4285 | * |
| 4286 | * This routine issues a Request Node Identification Data (RNID) Accept |
| 4287 | * (ACC) response. It constructs the RNID ACC response command according to |
| 4288 | * the proper @format and then calls the lpfc_sli_issue_iocb() routine to |
| 4289 | * issue the response. Note that this command does not need to hold the ndlp |
| 4290 | * reference count for the callback. So, the ndlp reference count taken by |
| 4291 | * the lpfc_prep_els_iocb() routine is put back and the context1 field of |
| 4292 | * IOCB is set to NULL to indicate to the lpfc_els_free_iocb() routine that |
| 4293 | * there is no ndlp reference available. |
| 4294 | * |
| 4295 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4296 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4297 | * will be stored into the context1 field of the IOCB for the completion |
| 4298 | * callback function. However, for the RNID Accept Response ELS command, |
| 4299 | * this is undone later by this routine after the IOCB is allocated. |
| 4300 | * |
| 4301 | * Return code |
| 4302 | * 0 - Successfully issued acc rnid response |
| 4303 | * 1 - Failed to issue acc rnid response |
| 4304 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4305 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4306 | lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 4307 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4308 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4309 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4310 | RNID *rn; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4311 | IOCB_t *icmd, *oldcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4312 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4313 | struct lpfc_sli *psli; |
| 4314 | uint8_t *pcmd; |
| 4315 | uint16_t cmdsize; |
| 4316 | int rc; |
| 4317 | |
| 4318 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4319 | cmdsize = sizeof(uint32_t) + sizeof(uint32_t) |
| 4320 | + (2 * sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4321 | if (format) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4322 | cmdsize += sizeof(RNID_TOP_DISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4323 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4324 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4325 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 4326 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4327 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4328 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4329 | icmd = &elsiocb->iocb; |
| 4330 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4331 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4332 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| 4333 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 4334 | /* Xmit RNID ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4335 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4336 | "0132 Xmit RNID ACC response tag x%x xri x%x\n", |
| 4337 | elsiocb->iotag, elsiocb->iocb.ulpContext); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4338 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4339 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4340 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4341 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4342 | memset(pcmd, 0, sizeof(RNID)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4343 | rn = (RNID *) (pcmd); |
| 4344 | rn->Format = format; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4345 | rn->CommonLen = (2 * sizeof(struct lpfc_name)); |
| 4346 | memcpy(&rn->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 4347 | memcpy(&rn->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4348 | switch (format) { |
| 4349 | case 0: |
| 4350 | rn->SpecificLen = 0; |
| 4351 | break; |
| 4352 | case RNID_TOPOLOGY_DISC: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4353 | rn->SpecificLen = sizeof(RNID_TOP_DISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4354 | memcpy(&rn->un.topologyDisc.portName, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4355 | &vport->fc_portname, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4356 | rn->un.topologyDisc.unitType = RNID_HBA; |
| 4357 | rn->un.topologyDisc.physPort = 0; |
| 4358 | rn->un.topologyDisc.attachedNodes = 0; |
| 4359 | break; |
| 4360 | default: |
| 4361 | rn->CommonLen = 0; |
| 4362 | rn->SpecificLen = 0; |
| 4363 | break; |
| 4364 | } |
| 4365 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4366 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4367 | "Issue ACC RNID: did:x%x flg:x%x", |
| 4368 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4369 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4370 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4371 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4372 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4373 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4374 | if (rc == IOCB_ERROR) { |
| 4375 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4376 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4377 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4378 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4379 | } |
| 4380 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4381 | /** |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4382 | * lpfc_els_clear_rrq - Clear the rq that this rrq describes. |
| 4383 | * @vport: pointer to a virtual N_Port data structure. |
| 4384 | * @iocb: pointer to the lpfc command iocb data structure. |
| 4385 | * @ndlp: pointer to a node-list data structure. |
| 4386 | * |
| 4387 | * Return |
| 4388 | **/ |
| 4389 | static void |
| 4390 | lpfc_els_clear_rrq(struct lpfc_vport *vport, |
| 4391 | struct lpfc_iocbq *iocb, struct lpfc_nodelist *ndlp) |
| 4392 | { |
| 4393 | struct lpfc_hba *phba = vport->phba; |
| 4394 | uint8_t *pcmd; |
| 4395 | struct RRQ *rrq; |
| 4396 | uint16_t rxid; |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4397 | uint16_t xri; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4398 | struct lpfc_node_rrq *prrq; |
| 4399 | |
| 4400 | |
| 4401 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) iocb->context2)->virt); |
| 4402 | pcmd += sizeof(uint32_t); |
| 4403 | rrq = (struct RRQ *)pcmd; |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4404 | rrq->rrq_exchg = be32_to_cpu(rrq->rrq_exchg); |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 4405 | rxid = bf_get(rrq_rxid, rrq); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4406 | |
| 4407 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4408 | "2883 Clear RRQ for SID:x%x OXID:x%x RXID:x%x" |
| 4409 | " x%x x%x\n", |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4410 | be32_to_cpu(bf_get(rrq_did, rrq)), |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 4411 | bf_get(rrq_oxid, rrq), |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4412 | rxid, |
| 4413 | iocb->iotag, iocb->iocb.ulpContext); |
| 4414 | |
| 4415 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4416 | "Clear RRQ: did:x%x flg:x%x exchg:x%.08x", |
| 4417 | ndlp->nlp_DID, ndlp->nlp_flag, rrq->rrq_exchg); |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4418 | if (vport->fc_myDID == be32_to_cpu(bf_get(rrq_did, rrq))) |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 4419 | xri = bf_get(rrq_oxid, rrq); |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4420 | else |
| 4421 | xri = rxid; |
| 4422 | prrq = lpfc_get_active_rrq(vport, xri, ndlp->nlp_DID); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4423 | if (prrq) |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4424 | lpfc_clr_rrq_active(phba, xri, prrq); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4425 | return; |
| 4426 | } |
| 4427 | |
| 4428 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4429 | * lpfc_els_rsp_echo_acc - Issue echo acc response |
| 4430 | * @vport: pointer to a virtual N_Port data structure. |
| 4431 | * @data: pointer to echo data to return in the accept. |
| 4432 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4433 | * @ndlp: pointer to a node-list data structure. |
| 4434 | * |
| 4435 | * Return code |
| 4436 | * 0 - Successfully issued acc echo response |
| 4437 | * 1 - Failed to issue acc echo response |
| 4438 | **/ |
| 4439 | static int |
| 4440 | lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data, |
| 4441 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) |
| 4442 | { |
| 4443 | struct lpfc_hba *phba = vport->phba; |
| 4444 | struct lpfc_iocbq *elsiocb; |
| 4445 | struct lpfc_sli *psli; |
| 4446 | uint8_t *pcmd; |
| 4447 | uint16_t cmdsize; |
| 4448 | int rc; |
| 4449 | |
| 4450 | psli = &phba->sli; |
| 4451 | cmdsize = oldiocb->iocb.unsli3.rcvsli3.acc_len; |
| 4452 | |
James Smart | bf08611 | 2011-08-21 21:48:13 -0400 | [diff] [blame] | 4453 | /* The accumulated length can exceed the BPL_SIZE. For |
| 4454 | * now, use this as the limit |
| 4455 | */ |
| 4456 | if (cmdsize > LPFC_BPL_SIZE) |
| 4457 | cmdsize = LPFC_BPL_SIZE; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4458 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4459 | ndlp->nlp_DID, ELS_CMD_ACC); |
| 4460 | if (!elsiocb) |
| 4461 | return 1; |
| 4462 | |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4463 | elsiocb->iocb.ulpContext = oldiocb->iocb.ulpContext; /* Xri / rx_id */ |
| 4464 | elsiocb->iocb.unsli3.rcvsli3.ox_id = oldiocb->iocb.unsli3.rcvsli3.ox_id; |
| 4465 | |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4466 | /* Xmit ECHO ACC response tag <ulpIoTag> */ |
| 4467 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4468 | "2876 Xmit ECHO ACC response tag x%x xri x%x\n", |
| 4469 | elsiocb->iotag, elsiocb->iocb.ulpContext); |
| 4470 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4471 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
| 4472 | pcmd += sizeof(uint32_t); |
| 4473 | memcpy(pcmd, data, cmdsize - sizeof(uint32_t)); |
| 4474 | |
| 4475 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4476 | "Issue ACC ECHO: did:x%x flg:x%x", |
| 4477 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4478 | |
| 4479 | phba->fc_stat.elsXmitACC++; |
| 4480 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4481 | |
| 4482 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| 4483 | if (rc == IOCB_ERROR) { |
| 4484 | lpfc_els_free_iocb(phba, elsiocb); |
| 4485 | return 1; |
| 4486 | } |
| 4487 | return 0; |
| 4488 | } |
| 4489 | |
| 4490 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4491 | * lpfc_els_disc_adisc - Issue remaining adisc iocbs to npr nodes of a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4492 | * @vport: pointer to a host virtual N_Port data structure. |
| 4493 | * |
| 4494 | * This routine issues Address Discover (ADISC) ELS commands to those |
| 4495 | * N_Ports which are in node port recovery state and ADISC has not been issued |
| 4496 | * for the @vport. Each time an ELS ADISC IOCB is issued by invoking the |
| 4497 | * lpfc_issue_els_adisc() routine, the per @vport number of discover count |
| 4498 | * (num_disc_nodes) shall be incremented. If the num_disc_nodes reaches a |
| 4499 | * pre-configured threshold (cfg_discovery_threads), the @vport fc_flag will |
| 4500 | * be marked with FC_NLP_MORE bit and the process of issuing remaining ADISC |
| 4501 | * IOCBs quit for later pick up. On the other hand, after walking through |
| 4502 | * all the ndlps with the @vport and there is none ADISC IOCB issued, the |
| 4503 | * @vport fc_flag shall be cleared with FC_NLP_MORE bit indicating there is |
| 4504 | * no more ADISC need to be sent. |
| 4505 | * |
| 4506 | * Return code |
| 4507 | * The number of N_Ports with adisc issued. |
| 4508 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4509 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4510 | lpfc_els_disc_adisc(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4511 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4512 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4513 | struct lpfc_nodelist *ndlp, *next_ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4514 | int sentadisc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4515 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4516 | /* go thru NPR nodes and issue any remaining ELS ADISCs */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4517 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4518 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4519 | continue; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4520 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && |
| 4521 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && |
| 4522 | (ndlp->nlp_flag & NLP_NPR_ADISC) != 0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4523 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4524 | ndlp->nlp_flag &= ~NLP_NPR_ADISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4525 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4526 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4527 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE); |
| 4528 | lpfc_issue_els_adisc(vport, ndlp, 0); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4529 | sentadisc++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4530 | vport->num_disc_nodes++; |
| 4531 | if (vport->num_disc_nodes >= |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4532 | vport->cfg_discovery_threads) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4533 | spin_lock_irq(shost->host_lock); |
| 4534 | vport->fc_flag |= FC_NLP_MORE; |
| 4535 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4536 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4537 | } |
| 4538 | } |
| 4539 | } |
| 4540 | if (sentadisc == 0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4541 | spin_lock_irq(shost->host_lock); |
| 4542 | vport->fc_flag &= ~FC_NLP_MORE; |
| 4543 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4544 | } |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 4545 | return sentadisc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4546 | } |
| 4547 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4548 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4549 | * lpfc_els_disc_plogi - Issue plogi for all npr nodes of a vport before adisc |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4550 | * @vport: pointer to a host virtual N_Port data structure. |
| 4551 | * |
| 4552 | * This routine issues Port Login (PLOGI) ELS commands to all the N_Ports |
| 4553 | * which are in node port recovery state, with a @vport. Each time an ELS |
| 4554 | * ADISC PLOGI IOCB is issued by invoking the lpfc_issue_els_plogi() routine, |
| 4555 | * the per @vport number of discover count (num_disc_nodes) shall be |
| 4556 | * incremented. If the num_disc_nodes reaches a pre-configured threshold |
| 4557 | * (cfg_discovery_threads), the @vport fc_flag will be marked with FC_NLP_MORE |
| 4558 | * bit set and quit the process of issuing remaining ADISC PLOGIN IOCBs for |
| 4559 | * later pick up. On the other hand, after walking through all the ndlps with |
| 4560 | * the @vport and there is none ADISC PLOGI IOCB issued, the @vport fc_flag |
| 4561 | * shall be cleared with the FC_NLP_MORE bit indicating there is no more ADISC |
| 4562 | * PLOGI need to be sent. |
| 4563 | * |
| 4564 | * Return code |
| 4565 | * The number of N_Ports with plogi issued. |
| 4566 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4567 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4568 | lpfc_els_disc_plogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4569 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4570 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4571 | struct lpfc_nodelist *ndlp, *next_ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4572 | int sentplogi = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4573 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4574 | /* go thru NPR nodes and issue any remaining ELS PLOGIs */ |
| 4575 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4576 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4577 | continue; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4578 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && |
| 4579 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && |
| 4580 | (ndlp->nlp_flag & NLP_DELAY_TMO) == 0 && |
| 4581 | (ndlp->nlp_flag & NLP_NPR_ADISC) == 0) { |
| 4582 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4583 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
| 4584 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4585 | sentplogi++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4586 | vport->num_disc_nodes++; |
| 4587 | if (vport->num_disc_nodes >= |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4588 | vport->cfg_discovery_threads) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4589 | spin_lock_irq(shost->host_lock); |
| 4590 | vport->fc_flag |= FC_NLP_MORE; |
| 4591 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4592 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4593 | } |
| 4594 | } |
| 4595 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 4596 | if (sentplogi) { |
| 4597 | lpfc_set_disctmo(vport); |
| 4598 | } |
| 4599 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4600 | spin_lock_irq(shost->host_lock); |
| 4601 | vport->fc_flag &= ~FC_NLP_MORE; |
| 4602 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4603 | } |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 4604 | return sentplogi; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4605 | } |
| 4606 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4607 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4608 | * lpfc_els_flush_rscn - Clean up any rscn activities with a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4609 | * @vport: pointer to a host virtual N_Port data structure. |
| 4610 | * |
| 4611 | * This routine cleans up any Registration State Change Notification |
| 4612 | * (RSCN) activity with a @vport. Note that the fc_rscn_flush flag of the |
| 4613 | * @vport together with the host_lock is used to prevent multiple thread |
| 4614 | * trying to access the RSCN array on a same @vport at the same time. |
| 4615 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4616 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4617 | lpfc_els_flush_rscn(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4618 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4619 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4620 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4621 | int i; |
| 4622 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4623 | spin_lock_irq(shost->host_lock); |
| 4624 | if (vport->fc_rscn_flush) { |
| 4625 | /* Another thread is walking fc_rscn_id_list on this vport */ |
| 4626 | spin_unlock_irq(shost->host_lock); |
| 4627 | return; |
| 4628 | } |
| 4629 | /* Indicate we are walking lpfc_els_flush_rscn on this vport */ |
| 4630 | vport->fc_rscn_flush = 1; |
| 4631 | spin_unlock_irq(shost->host_lock); |
| 4632 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4633 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4634 | lpfc_in_buf_free(phba, vport->fc_rscn_id_list[i]); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4635 | vport->fc_rscn_id_list[i] = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4636 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4637 | spin_lock_irq(shost->host_lock); |
| 4638 | vport->fc_rscn_id_cnt = 0; |
| 4639 | vport->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY); |
| 4640 | spin_unlock_irq(shost->host_lock); |
| 4641 | lpfc_can_disctmo(vport); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4642 | /* Indicate we are done walking this fc_rscn_id_list */ |
| 4643 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4644 | } |
| 4645 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4646 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4647 | * lpfc_rscn_payload_check - Check whether there is a pending rscn to a did |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4648 | * @vport: pointer to a host virtual N_Port data structure. |
| 4649 | * @did: remote destination port identifier. |
| 4650 | * |
| 4651 | * This routine checks whether there is any pending Registration State |
| 4652 | * Configuration Notification (RSCN) to a @did on @vport. |
| 4653 | * |
| 4654 | * Return code |
| 4655 | * None zero - The @did matched with a pending rscn |
| 4656 | * 0 - not able to match @did with a pending rscn |
| 4657 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4658 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4659 | lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4660 | { |
| 4661 | D_ID ns_did; |
| 4662 | D_ID rscn_did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4663 | uint32_t *lp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4664 | uint32_t payload_len, i; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4665 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4666 | |
| 4667 | ns_did.un.word = did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4668 | |
| 4669 | /* Never match fabric nodes for RSCNs */ |
| 4670 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4671 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4672 | |
| 4673 | /* If we are doing a FULL RSCN rediscovery, match everything */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4674 | if (vport->fc_flag & FC_RSCN_DISCOVERY) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4675 | return did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4676 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4677 | spin_lock_irq(shost->host_lock); |
| 4678 | if (vport->fc_rscn_flush) { |
| 4679 | /* Another thread is walking fc_rscn_id_list on this vport */ |
| 4680 | spin_unlock_irq(shost->host_lock); |
| 4681 | return 0; |
| 4682 | } |
| 4683 | /* Indicate we are walking fc_rscn_id_list on this vport */ |
| 4684 | vport->fc_rscn_flush = 1; |
| 4685 | spin_unlock_irq(shost->host_lock); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4686 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4687 | lp = vport->fc_rscn_id_list[i]->virt; |
| 4688 | payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); |
| 4689 | payload_len -= sizeof(uint32_t); /* take off word 0 */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4690 | while (payload_len) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4691 | rscn_did.un.word = be32_to_cpu(*lp++); |
| 4692 | payload_len -= sizeof(uint32_t); |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4693 | switch (rscn_did.un.b.resv & RSCN_ADDRESS_FORMAT_MASK) { |
| 4694 | case RSCN_ADDRESS_FORMAT_PORT: |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 4695 | if ((ns_did.un.b.domain == rscn_did.un.b.domain) |
| 4696 | && (ns_did.un.b.area == rscn_did.un.b.area) |
| 4697 | && (ns_did.un.b.id == rscn_did.un.b.id)) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4698 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4699 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4700 | case RSCN_ADDRESS_FORMAT_AREA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4701 | if ((ns_did.un.b.domain == rscn_did.un.b.domain) |
| 4702 | && (ns_did.un.b.area == rscn_did.un.b.area)) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4703 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4704 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4705 | case RSCN_ADDRESS_FORMAT_DOMAIN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4706 | if (ns_did.un.b.domain == rscn_did.un.b.domain) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4707 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4708 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4709 | case RSCN_ADDRESS_FORMAT_FABRIC: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4710 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4711 | } |
| 4712 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4713 | } |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4714 | /* Indicate we are done with walking fc_rscn_id_list on this vport */ |
| 4715 | vport->fc_rscn_flush = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4716 | return 0; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4717 | return_did_out: |
| 4718 | /* Indicate we are done with walking fc_rscn_id_list on this vport */ |
| 4719 | vport->fc_rscn_flush = 0; |
| 4720 | return did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4721 | } |
| 4722 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4723 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4724 | * lpfc_rscn_recovery_check - Send recovery event to vport nodes matching rscn |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4725 | * @vport: pointer to a host virtual N_Port data structure. |
| 4726 | * |
| 4727 | * This routine sends recovery (NLP_EVT_DEVICE_RECOVERY) event to the |
| 4728 | * state machine for a @vport's nodes that are with pending RSCN (Registration |
| 4729 | * State Change Notification). |
| 4730 | * |
| 4731 | * Return code |
| 4732 | * 0 - Successful (currently alway return 0) |
| 4733 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4734 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4735 | lpfc_rscn_recovery_check(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4736 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4737 | struct lpfc_nodelist *ndlp = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4738 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4739 | /* Move all affected nodes by pending RSCNs to NPR state. */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4740 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4741 | if (!NLP_CHK_NODE_ACT(ndlp) || |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4742 | (ndlp->nlp_state == NLP_STE_UNUSED_NODE) || |
| 4743 | !lpfc_rscn_payload_check(vport, ndlp->nlp_DID)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4744 | continue; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4745 | lpfc_disc_state_machine(vport, ndlp, NULL, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4746 | NLP_EVT_DEVICE_RECOVERY); |
| 4747 | lpfc_cancel_retry_delay_tmo(vport, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4748 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4749 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4750 | } |
| 4751 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4752 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4753 | * lpfc_send_rscn_event - Send an RSCN event to management application |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 4754 | * @vport: pointer to a host virtual N_Port data structure. |
| 4755 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4756 | * |
| 4757 | * lpfc_send_rscn_event sends an RSCN netlink event to management |
| 4758 | * applications. |
| 4759 | */ |
| 4760 | static void |
| 4761 | lpfc_send_rscn_event(struct lpfc_vport *vport, |
| 4762 | struct lpfc_iocbq *cmdiocb) |
| 4763 | { |
| 4764 | struct lpfc_dmabuf *pcmd; |
| 4765 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4766 | uint32_t *payload_ptr; |
| 4767 | uint32_t payload_len; |
| 4768 | struct lpfc_rscn_event_header *rscn_event_data; |
| 4769 | |
| 4770 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 4771 | payload_ptr = (uint32_t *) pcmd->virt; |
| 4772 | payload_len = be32_to_cpu(*payload_ptr & ~ELS_CMD_MASK); |
| 4773 | |
| 4774 | rscn_event_data = kmalloc(sizeof(struct lpfc_rscn_event_header) + |
| 4775 | payload_len, GFP_KERNEL); |
| 4776 | if (!rscn_event_data) { |
| 4777 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 4778 | "0147 Failed to allocate memory for RSCN event\n"); |
| 4779 | return; |
| 4780 | } |
| 4781 | rscn_event_data->event_type = FC_REG_RSCN_EVENT; |
| 4782 | rscn_event_data->payload_length = payload_len; |
| 4783 | memcpy(rscn_event_data->rscn_payload, payload_ptr, |
| 4784 | payload_len); |
| 4785 | |
| 4786 | fc_host_post_vendor_event(shost, |
| 4787 | fc_get_event_number(), |
| 4788 | sizeof(struct lpfc_els_event_header) + payload_len, |
| 4789 | (char *)rscn_event_data, |
| 4790 | LPFC_NL_VENDOR_ID); |
| 4791 | |
| 4792 | kfree(rscn_event_data); |
| 4793 | } |
| 4794 | |
| 4795 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4796 | * lpfc_els_rcv_rscn - Process an unsolicited rscn iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4797 | * @vport: pointer to a host virtual N_Port data structure. |
| 4798 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4799 | * @ndlp: pointer to a node-list data structure. |
| 4800 | * |
| 4801 | * This routine processes an unsolicited RSCN (Registration State Change |
| 4802 | * Notification) IOCB. First, the payload of the unsolicited RSCN is walked |
| 4803 | * to invoke fc_host_post_event() routine to the FC transport layer. If the |
| 4804 | * discover state machine is about to begin discovery, it just accepts the |
| 4805 | * RSCN and the discovery process will satisfy the RSCN. If this RSCN only |
| 4806 | * contains N_Port IDs for other vports on this HBA, it just accepts the |
| 4807 | * RSCN and ignore processing it. If the state machine is in the recovery |
| 4808 | * state, the fc_rscn_id_list of this @vport is walked and the |
| 4809 | * lpfc_rscn_recovery_check() routine is invoked to send recovery event for |
| 4810 | * all nodes that match RSCN payload. Otherwise, the lpfc_els_handle_rscn() |
| 4811 | * routine is invoked to handle the RSCN event. |
| 4812 | * |
| 4813 | * Return code |
| 4814 | * 0 - Just sent the acc response |
| 4815 | * 1 - Sent the acc response and waited for name server completion |
| 4816 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4817 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4818 | lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4819 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4820 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4821 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4822 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4823 | struct lpfc_dmabuf *pcmd; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4824 | uint32_t *lp, *datap; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4825 | IOCB_t *icmd; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4826 | uint32_t payload_len, length, nportid, *cmd; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4827 | int rscn_cnt; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4828 | int rscn_id = 0, hba_id = 0; |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 4829 | int i; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4830 | |
| 4831 | icmd = &cmdiocb->iocb; |
| 4832 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 4833 | lp = (uint32_t *) pcmd->virt; |
| 4834 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4835 | payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); |
| 4836 | payload_len -= sizeof(uint32_t); /* take off word 0 */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4837 | /* RSCN received */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4838 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 4839 | "0214 RSCN received Data: x%x x%x x%x x%x\n", |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4840 | vport->fc_flag, payload_len, *lp, |
| 4841 | vport->fc_rscn_id_cnt); |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 4842 | |
| 4843 | /* Send an RSCN event to the management application */ |
| 4844 | lpfc_send_rscn_event(vport, cmdiocb); |
| 4845 | |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 4846 | for (i = 0; i < payload_len/sizeof(uint32_t); i++) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4847 | fc_host_post_event(shost, fc_get_event_number(), |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 4848 | FCH_EVT_RSCN, lp[i]); |
| 4849 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4850 | /* If we are about to begin discovery, just ACC the RSCN. |
| 4851 | * Discovery processing will satisfy it. |
| 4852 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4853 | if (vport->port_state <= LPFC_NS_QRY) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4854 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4855 | "RCV RSCN ignore: did:x%x/ste:x%x flg:x%x", |
| 4856 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 4857 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4858 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4859 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4860 | } |
| 4861 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4862 | /* If this RSCN just contains NPortIDs for other vports on this HBA, |
| 4863 | * just ACC and ignore it. |
| 4864 | */ |
| 4865 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4866 | !(vport->cfg_peer_port_login)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4867 | i = payload_len; |
| 4868 | datap = lp; |
| 4869 | while (i > 0) { |
| 4870 | nportid = *datap++; |
| 4871 | nportid = ((be32_to_cpu(nportid)) & Mask_DID); |
| 4872 | i -= sizeof(uint32_t); |
| 4873 | rscn_id++; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 4874 | if (lpfc_find_vport_by_did(phba, nportid)) |
| 4875 | hba_id++; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4876 | } |
| 4877 | if (rscn_id == hba_id) { |
| 4878 | /* ALL NPortIDs in RSCN are on HBA */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4879 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4880 | "0219 Ignore RSCN " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4881 | "Data: x%x x%x x%x x%x\n", |
| 4882 | vport->fc_flag, payload_len, |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4883 | *lp, vport->fc_rscn_id_cnt); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4884 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4885 | "RCV RSCN vport: did:x%x/ste:x%x flg:x%x", |
| 4886 | ndlp->nlp_DID, vport->port_state, |
| 4887 | ndlp->nlp_flag); |
| 4888 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4889 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4890 | ndlp, NULL); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4891 | return 0; |
| 4892 | } |
| 4893 | } |
| 4894 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4895 | spin_lock_irq(shost->host_lock); |
| 4896 | if (vport->fc_rscn_flush) { |
| 4897 | /* Another thread is walking fc_rscn_id_list on this vport */ |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4898 | vport->fc_flag |= FC_RSCN_DISCOVERY; |
James Smart | 9795724 | 2009-12-21 17:03:15 -0500 | [diff] [blame] | 4899 | spin_unlock_irq(shost->host_lock); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 4900 | /* Send back ACC */ |
| 4901 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4902 | return 0; |
| 4903 | } |
| 4904 | /* Indicate we are walking fc_rscn_id_list on this vport */ |
| 4905 | vport->fc_rscn_flush = 1; |
| 4906 | spin_unlock_irq(shost->host_lock); |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 4907 | /* Get the array count after successfully have the token */ |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4908 | rscn_cnt = vport->fc_rscn_id_cnt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4909 | /* If we are already processing an RSCN, save the received |
| 4910 | * RSCN payload buffer, cmdiocb->context2 to process later. |
| 4911 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4912 | if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4913 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4914 | "RCV RSCN defer: did:x%x/ste:x%x flg:x%x", |
| 4915 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 4916 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4917 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4918 | vport->fc_flag |= FC_RSCN_DEFERRED; |
| 4919 | if ((rscn_cnt < FC_MAX_HOLD_RSCN) && |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4920 | !(vport->fc_flag & FC_RSCN_DISCOVERY)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4921 | vport->fc_flag |= FC_RSCN_MODE; |
| 4922 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4923 | if (rscn_cnt) { |
| 4924 | cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt; |
| 4925 | length = be32_to_cpu(*cmd & ~ELS_CMD_MASK); |
| 4926 | } |
| 4927 | if ((rscn_cnt) && |
| 4928 | (payload_len + length <= LPFC_BPL_SIZE)) { |
| 4929 | *cmd &= ELS_CMD_MASK; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4930 | *cmd |= cpu_to_be32(payload_len + length); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4931 | memcpy(((uint8_t *)cmd) + length, lp, |
| 4932 | payload_len); |
| 4933 | } else { |
| 4934 | vport->fc_rscn_id_list[rscn_cnt] = pcmd; |
| 4935 | vport->fc_rscn_id_cnt++; |
| 4936 | /* If we zero, cmdiocb->context2, the calling |
| 4937 | * routine will not try to free it. |
| 4938 | */ |
| 4939 | cmdiocb->context2 = NULL; |
| 4940 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4941 | /* Deferred RSCN */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4942 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 4943 | "0235 Deferred RSCN " |
| 4944 | "Data: x%x x%x x%x\n", |
| 4945 | vport->fc_rscn_id_cnt, vport->fc_flag, |
| 4946 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4947 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4948 | vport->fc_flag |= FC_RSCN_DISCOVERY; |
| 4949 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4950 | /* ReDiscovery RSCN */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4951 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 4952 | "0234 ReDiscovery RSCN " |
| 4953 | "Data: x%x x%x x%x\n", |
| 4954 | vport->fc_rscn_id_cnt, vport->fc_flag, |
| 4955 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4956 | } |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4957 | /* Indicate we are done walking fc_rscn_id_list on this vport */ |
| 4958 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4959 | /* Send back ACC */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4960 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4961 | /* send RECOVERY event for ALL nodes that match RSCN payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4962 | lpfc_rscn_recovery_check(vport); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4963 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4964 | vport->fc_flag &= ~FC_RSCN_DEFERRED; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4965 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4966 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4967 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4968 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4969 | "RCV RSCN: did:x%x/ste:x%x flg:x%x", |
| 4970 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 4971 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4972 | spin_lock_irq(shost->host_lock); |
| 4973 | vport->fc_flag |= FC_RSCN_MODE; |
| 4974 | spin_unlock_irq(shost->host_lock); |
| 4975 | vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4976 | /* Indicate we are done walking fc_rscn_id_list on this vport */ |
| 4977 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4978 | /* |
| 4979 | * If we zero, cmdiocb->context2, the calling routine will |
| 4980 | * not try to free it. |
| 4981 | */ |
| 4982 | cmdiocb->context2 = NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4983 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4984 | /* Send back ACC */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4985 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4986 | /* send RECOVERY event for ALL nodes that match RSCN payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4987 | lpfc_rscn_recovery_check(vport); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4988 | return lpfc_els_handle_rscn(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4989 | } |
| 4990 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4991 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4992 | * lpfc_els_handle_rscn - Handle rscn for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4993 | * @vport: pointer to a host virtual N_Port data structure. |
| 4994 | * |
| 4995 | * This routine handles the Registration State Configuration Notification |
| 4996 | * (RSCN) for a @vport. If login to NameServer does not exist, a new ndlp shall |
| 4997 | * be created and a Port Login (PLOGI) to the NameServer is issued. Otherwise, |
| 4998 | * if the ndlp to NameServer exists, a Common Transport (CT) command to the |
| 4999 | * NameServer shall be issued. If CT command to the NameServer fails to be |
| 5000 | * issued, the lpfc_els_flush_rscn() routine shall be invoked to clean up any |
| 5001 | * RSCN activities with the @vport. |
| 5002 | * |
| 5003 | * Return code |
| 5004 | * 0 - Cleaned up rscn on the @vport |
| 5005 | * 1 - Wait for plogi to name server before proceed |
| 5006 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5007 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5008 | lpfc_els_handle_rscn(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5009 | { |
| 5010 | struct lpfc_nodelist *ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5011 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5012 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5013 | /* Ignore RSCN if the port is being torn down. */ |
| 5014 | if (vport->load_flag & FC_UNLOADING) { |
| 5015 | lpfc_els_flush_rscn(vport); |
| 5016 | return 0; |
| 5017 | } |
| 5018 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5019 | /* Start timer for RSCN processing */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5020 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5021 | |
| 5022 | /* RSCN processed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5023 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 5024 | "0215 RSCN processed Data: x%x x%x x%x x%x\n", |
| 5025 | vport->fc_flag, 0, vport->fc_rscn_id_cnt, |
| 5026 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5027 | |
| 5028 | /* To process RSCN, first compare RSCN data with NameServer */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5029 | vport->fc_ns_retry = 0; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 5030 | vport->num_disc_nodes = 0; |
| 5031 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5032 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5033 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) |
| 5034 | && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5035 | /* Good ndlp, issue CT Request to NameServer */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5036 | if (lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 0, 0) == 0) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5037 | /* Wait for NameServer query cmpl before we can |
| 5038 | continue */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5039 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5040 | } else { |
| 5041 | /* If login to NameServer does not exist, issue one */ |
| 5042 | /* Good status, issue PLOGI to NameServer */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5043 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5044 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5045 | /* Wait for NameServer login cmpl before we can |
| 5046 | continue */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5047 | return 1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5048 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5049 | if (ndlp) { |
| 5050 | ndlp = lpfc_enable_node(vport, ndlp, |
| 5051 | NLP_STE_PLOGI_ISSUE); |
| 5052 | if (!ndlp) { |
| 5053 | lpfc_els_flush_rscn(vport); |
| 5054 | return 0; |
| 5055 | } |
| 5056 | ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5057 | } else { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5058 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 5059 | if (!ndlp) { |
| 5060 | lpfc_els_flush_rscn(vport); |
| 5061 | return 0; |
| 5062 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5063 | lpfc_nlp_init(vport, ndlp, NameServer_DID); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 5064 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5065 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5066 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5067 | ndlp->nlp_type |= NLP_FABRIC; |
| 5068 | lpfc_issue_els_plogi(vport, NameServer_DID, 0); |
| 5069 | /* Wait for NameServer login cmpl before we can |
| 5070 | * continue |
| 5071 | */ |
| 5072 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5073 | } |
| 5074 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5075 | lpfc_els_flush_rscn(vport); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5076 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5077 | } |
| 5078 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5079 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5080 | * lpfc_els_rcv_flogi - Process an unsolicited flogi iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5081 | * @vport: pointer to a host virtual N_Port data structure. |
| 5082 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5083 | * @ndlp: pointer to a node-list data structure. |
| 5084 | * |
| 5085 | * This routine processes Fabric Login (FLOGI) IOCB received as an ELS |
| 5086 | * unsolicited event. An unsolicited FLOGI can be received in a point-to- |
| 5087 | * point topology. As an unsolicited FLOGI should not be received in a loop |
| 5088 | * mode, any unsolicited FLOGI received in loop mode shall be ignored. The |
| 5089 | * lpfc_check_sparm() routine is invoked to check the parameters in the |
| 5090 | * unsolicited FLOGI. If parameters validation failed, the routine |
| 5091 | * lpfc_els_rsp_reject() shall be called with reject reason code set to |
| 5092 | * LSEXP_SPARM_OPTIONS to reject the FLOGI. Otherwise, the Port WWN in the |
| 5093 | * FLOGI shall be compared with the Port WWN of the @vport to determine who |
| 5094 | * will initiate PLOGI. The higher lexicographical value party shall has |
| 5095 | * higher priority (as the winning port) and will initiate PLOGI and |
| 5096 | * communicate Port_IDs (Addresses) for both nodes in PLOGI. The result |
| 5097 | * of this will be marked in the @vport fc_flag field with FC_PT2PT_PLOGI |
| 5098 | * and then the lpfc_els_rsp_acc() routine is invoked to accept the FLOGI. |
| 5099 | * |
| 5100 | * Return code |
| 5101 | * 0 - Successfully processed the unsolicited flogi |
| 5102 | * 1 - Failed to process the unsolicited flogi |
| 5103 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5104 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5105 | lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5106 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5107 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5108 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5109 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5110 | struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5111 | uint32_t *lp = (uint32_t *) pcmd->virt; |
| 5112 | IOCB_t *icmd = &cmdiocb->iocb; |
| 5113 | struct serv_parm *sp; |
| 5114 | LPFC_MBOXQ_t *mbox; |
| 5115 | struct ls_rjt stat; |
| 5116 | uint32_t cmd, did; |
| 5117 | int rc; |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 5118 | uint32_t fc_flag = 0; |
| 5119 | uint32_t port_state = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5120 | |
| 5121 | cmd = *lp++; |
| 5122 | sp = (struct serv_parm *) lp; |
| 5123 | |
| 5124 | /* FLOGI received */ |
| 5125 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5126 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5127 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5128 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5129 | /* We should never receive a FLOGI in loop mode, ignore it */ |
| 5130 | did = icmd->un.elsreq64.remoteID; |
| 5131 | |
| 5132 | /* An FLOGI ELS command <elsCmd> was received from DID <did> in |
| 5133 | Loop Mode */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5134 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 5135 | "0113 An FLOGI ELS command x%x was " |
| 5136 | "received from DID x%x in Loop Mode\n", |
| 5137 | cmd, did); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5138 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5139 | } |
| 5140 | |
James Smart | 341af10 | 2010-01-26 23:07:37 -0500 | [diff] [blame] | 5141 | if ((lpfc_check_sparm(vport, ndlp, sp, CLASS3, 1))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5142 | /* For a FLOGI we accept, then if our portname is greater |
| 5143 | * then the remote portname we initiate Nport login. |
| 5144 | */ |
| 5145 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5146 | rc = memcmp(&vport->fc_portname, &sp->portName, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5147 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5148 | |
| 5149 | if (!rc) { |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 5150 | if (phba->sli_rev < LPFC_SLI_REV4) { |
| 5151 | mbox = mempool_alloc(phba->mbox_mem_pool, |
| 5152 | GFP_KERNEL); |
| 5153 | if (!mbox) |
| 5154 | return 1; |
| 5155 | lpfc_linkdown(phba); |
| 5156 | lpfc_init_link(phba, mbox, |
| 5157 | phba->cfg_topology, |
| 5158 | phba->cfg_link_speed); |
| 5159 | mbox->u.mb.un.varInitLnk.lipsr_AL_PA = 0; |
| 5160 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
| 5161 | mbox->vport = vport; |
| 5162 | rc = lpfc_sli_issue_mbox(phba, mbox, |
| 5163 | MBX_NOWAIT); |
| 5164 | lpfc_set_loopback_flag(phba); |
| 5165 | if (rc == MBX_NOT_FINISHED) |
| 5166 | mempool_free(mbox, phba->mbox_mem_pool); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5167 | return 1; |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 5168 | } else { |
| 5169 | /* abort the flogi coming back to ourselves |
| 5170 | * due to external loopback on the port. |
| 5171 | */ |
| 5172 | lpfc_els_abort_flogi(phba); |
| 5173 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5174 | } |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 5175 | } else if (rc > 0) { /* greater than */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5176 | spin_lock_irq(shost->host_lock); |
| 5177 | vport->fc_flag |= FC_PT2PT_PLOGI; |
| 5178 | spin_unlock_irq(shost->host_lock); |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5179 | |
| 5180 | /* If we have the high WWPN we can assign our own |
| 5181 | * myDID; otherwise, we have to WAIT for a PLOGI |
| 5182 | * from the remote NPort to find out what it |
| 5183 | * will be. |
| 5184 | */ |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 5185 | vport->fc_myDID = PT2PT_LocalID; |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 5186 | } else |
| 5187 | vport->fc_myDID = PT2PT_RemoteID; |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5188 | |
| 5189 | /* |
| 5190 | * The vport state should go to LPFC_FLOGI only |
| 5191 | * AFTER we issue a FLOGI, not receive one. |
| 5192 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5193 | spin_lock_irq(shost->host_lock); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 5194 | fc_flag = vport->fc_flag; |
| 5195 | port_state = vport->port_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5196 | vport->fc_flag |= FC_PT2PT; |
| 5197 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 5198 | vport->port_state = LPFC_FLOGI; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5199 | spin_unlock_irq(shost->host_lock); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 5200 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 5201 | "3311 Rcv Flogi PS x%x new PS x%x " |
| 5202 | "fc_flag x%x new fc_flag x%x\n", |
| 5203 | port_state, vport->port_state, |
| 5204 | fc_flag, vport->fc_flag); |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5205 | |
| 5206 | /* |
| 5207 | * We temporarily set fc_myDID to make it look like we are |
| 5208 | * a Fabric. This is done just so we end up with the right |
| 5209 | * did / sid on the FLOGI ACC rsp. |
| 5210 | */ |
| 5211 | did = vport->fc_myDID; |
| 5212 | vport->fc_myDID = Fabric_DID; |
| 5213 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5214 | } else { |
| 5215 | /* Reject this request because invalid parameters */ |
| 5216 | stat.un.b.lsRjtRsvd0 = 0; |
| 5217 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5218 | stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; |
| 5219 | stat.un.b.vendorUnique = 0; |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5220 | |
| 5221 | /* |
| 5222 | * We temporarily set fc_myDID to make it look like we are |
| 5223 | * a Fabric. This is done just so we end up with the right |
| 5224 | * did / sid on the FLOGI LS_RJT rsp. |
| 5225 | */ |
| 5226 | did = vport->fc_myDID; |
| 5227 | vport->fc_myDID = Fabric_DID; |
| 5228 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5229 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
| 5230 | NULL); |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5231 | |
| 5232 | /* Now lets put fc_myDID back to what its supposed to be */ |
| 5233 | vport->fc_myDID = did; |
| 5234 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5235 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5236 | } |
| 5237 | |
| 5238 | /* Send back ACC */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5239 | lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5240 | |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5241 | /* Now lets put fc_myDID back to what its supposed to be */ |
| 5242 | vport->fc_myDID = did; |
| 5243 | |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 5244 | if (!(vport->fc_flag & FC_PT2PT_PLOGI)) { |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5245 | |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 5246 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5247 | if (!mbox) |
| 5248 | goto fail; |
| 5249 | |
| 5250 | lpfc_config_link(phba, mbox); |
| 5251 | |
| 5252 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
| 5253 | mbox->vport = vport; |
| 5254 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
| 5255 | if (rc == MBX_NOT_FINISHED) { |
| 5256 | mempool_free(mbox, phba->mbox_mem_pool); |
| 5257 | goto fail; |
| 5258 | } |
| 5259 | } |
| 5260 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5261 | return 0; |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 5262 | fail: |
| 5263 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5264 | } |
| 5265 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5266 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5267 | * lpfc_els_rcv_rnid - Process an unsolicited rnid iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5268 | * @vport: pointer to a host virtual N_Port data structure. |
| 5269 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5270 | * @ndlp: pointer to a node-list data structure. |
| 5271 | * |
| 5272 | * This routine processes Request Node Identification Data (RNID) IOCB |
| 5273 | * received as an ELS unsolicited event. Only when the RNID specified format |
| 5274 | * 0x0 or 0xDF (Topology Discovery Specific Node Identification Data) |
| 5275 | * present, this routine will invoke the lpfc_els_rsp_rnid_acc() routine to |
| 5276 | * Accept (ACC) the RNID ELS command. All the other RNID formats are |
| 5277 | * rejected by invoking the lpfc_els_rsp_reject() routine. |
| 5278 | * |
| 5279 | * Return code |
| 5280 | * 0 - Successfully processed rnid iocb (currently always return 0) |
| 5281 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5282 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5283 | lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5284 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5285 | { |
| 5286 | struct lpfc_dmabuf *pcmd; |
| 5287 | uint32_t *lp; |
| 5288 | IOCB_t *icmd; |
| 5289 | RNID *rn; |
| 5290 | struct ls_rjt stat; |
| 5291 | uint32_t cmd, did; |
| 5292 | |
| 5293 | icmd = &cmdiocb->iocb; |
| 5294 | did = icmd->un.elsreq64.remoteID; |
| 5295 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5296 | lp = (uint32_t *) pcmd->virt; |
| 5297 | |
| 5298 | cmd = *lp++; |
| 5299 | rn = (RNID *) lp; |
| 5300 | |
| 5301 | /* RNID received */ |
| 5302 | |
| 5303 | switch (rn->Format) { |
| 5304 | case 0: |
| 5305 | case RNID_TOPOLOGY_DISC: |
| 5306 | /* Send back ACC */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5307 | lpfc_els_rsp_rnid_acc(vport, rn->Format, cmdiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5308 | break; |
| 5309 | default: |
| 5310 | /* Reject this request because format not supported */ |
| 5311 | stat.un.b.lsRjtRsvd0 = 0; |
| 5312 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5313 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5314 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5315 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
| 5316 | NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5317 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5318 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5319 | } |
| 5320 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5321 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5322 | * lpfc_els_rcv_echo - Process an unsolicited echo iocb |
| 5323 | * @vport: pointer to a host virtual N_Port data structure. |
| 5324 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5325 | * @ndlp: pointer to a node-list data structure. |
| 5326 | * |
| 5327 | * Return code |
| 5328 | * 0 - Successfully processed echo iocb (currently always return 0) |
| 5329 | **/ |
| 5330 | static int |
| 5331 | lpfc_els_rcv_echo(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5332 | struct lpfc_nodelist *ndlp) |
| 5333 | { |
| 5334 | uint8_t *pcmd; |
| 5335 | |
| 5336 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt); |
| 5337 | |
| 5338 | /* skip over first word of echo command to find echo data */ |
| 5339 | pcmd += sizeof(uint32_t); |
| 5340 | |
| 5341 | lpfc_els_rsp_echo_acc(vport, pcmd, cmdiocb, ndlp); |
| 5342 | return 0; |
| 5343 | } |
| 5344 | |
| 5345 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5346 | * lpfc_els_rcv_lirr - Process an unsolicited lirr iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5347 | * @vport: pointer to a host virtual N_Port data structure. |
| 5348 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5349 | * @ndlp: pointer to a node-list data structure. |
| 5350 | * |
| 5351 | * This routine processes a Link Incident Report Registration(LIRR) IOCB |
| 5352 | * received as an ELS unsolicited event. Currently, this function just invokes |
| 5353 | * the lpfc_els_rsp_reject() routine to reject the LIRR IOCB unconditionally. |
| 5354 | * |
| 5355 | * Return code |
| 5356 | * 0 - Successfully processed lirr iocb (currently always return 0) |
| 5357 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5358 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5359 | lpfc_els_rcv_lirr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5360 | struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5361 | { |
| 5362 | struct ls_rjt stat; |
| 5363 | |
| 5364 | /* For now, unconditionally reject this command */ |
| 5365 | stat.un.b.lsRjtRsvd0 = 0; |
| 5366 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5367 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5368 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5369 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5370 | return 0; |
| 5371 | } |
| 5372 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5373 | /** |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 5374 | * lpfc_els_rcv_rrq - Process an unsolicited rrq iocb |
| 5375 | * @vport: pointer to a host virtual N_Port data structure. |
| 5376 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5377 | * @ndlp: pointer to a node-list data structure. |
| 5378 | * |
| 5379 | * This routine processes a Reinstate Recovery Qualifier (RRQ) IOCB |
| 5380 | * received as an ELS unsolicited event. A request to RRQ shall only |
| 5381 | * be accepted if the Originator Nx_Port N_Port_ID or the Responder |
| 5382 | * Nx_Port N_Port_ID of the target Exchange is the same as the |
| 5383 | * N_Port_ID of the Nx_Port that makes the request. If the RRQ is |
| 5384 | * not accepted, an LS_RJT with reason code "Unable to perform |
| 5385 | * command request" and reason code explanation "Invalid Originator |
| 5386 | * S_ID" shall be returned. For now, we just unconditionally accept |
| 5387 | * RRQ from the target. |
| 5388 | **/ |
| 5389 | static void |
| 5390 | lpfc_els_rcv_rrq(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5391 | struct lpfc_nodelist *ndlp) |
| 5392 | { |
| 5393 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5394 | if (vport->phba->sli_rev == LPFC_SLI_REV4) |
| 5395 | lpfc_els_clear_rrq(vport, cmdiocb, ndlp); |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 5396 | } |
| 5397 | |
| 5398 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5399 | * lpfc_els_rsp_rls_acc - Completion callbk func for MBX_READ_LNK_STAT mbox cmd |
| 5400 | * @phba: pointer to lpfc hba data structure. |
| 5401 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 5402 | * |
| 5403 | * This routine is the completion callback function for the MBX_READ_LNK_STAT |
| 5404 | * mailbox command. This callback function is to actually send the Accept |
| 5405 | * (ACC) response to a Read Port Status (RPS) unsolicited IOCB event. It |
| 5406 | * collects the link statistics from the completion of the MBX_READ_LNK_STAT |
| 5407 | * mailbox command, constructs the RPS response with the link statistics |
| 5408 | * collected, and then invokes the lpfc_sli_issue_iocb() routine to send ACC |
| 5409 | * response to the RPS. |
| 5410 | * |
| 5411 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 5412 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 5413 | * will be stored into the context1 field of the IOCB for the completion |
| 5414 | * callback function to the RPS Accept Response ELS IOCB command. |
| 5415 | * |
| 5416 | **/ |
| 5417 | static void |
| 5418 | lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
| 5419 | { |
| 5420 | MAILBOX_t *mb; |
| 5421 | IOCB_t *icmd; |
| 5422 | struct RLS_RSP *rls_rsp; |
| 5423 | uint8_t *pcmd; |
| 5424 | struct lpfc_iocbq *elsiocb; |
| 5425 | struct lpfc_nodelist *ndlp; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5426 | uint16_t oxid; |
| 5427 | uint16_t rxid; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5428 | uint32_t cmdsize; |
| 5429 | |
| 5430 | mb = &pmb->u.mb; |
| 5431 | |
| 5432 | ndlp = (struct lpfc_nodelist *) pmb->context2; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5433 | rxid = (uint16_t) ((unsigned long)(pmb->context1) & 0xffff); |
| 5434 | oxid = (uint16_t) (((unsigned long)(pmb->context1) >> 16) & 0xffff); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5435 | pmb->context1 = NULL; |
| 5436 | pmb->context2 = NULL; |
| 5437 | |
| 5438 | if (mb->mbxStatus) { |
| 5439 | mempool_free(pmb, phba->mbox_mem_pool); |
| 5440 | return; |
| 5441 | } |
| 5442 | |
| 5443 | cmdsize = sizeof(struct RLS_RSP) + sizeof(uint32_t); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5444 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 5445 | lpfc_max_els_tries, ndlp, |
| 5446 | ndlp->nlp_DID, ELS_CMD_ACC); |
| 5447 | |
| 5448 | /* Decrement the ndlp reference count from previous mbox command */ |
| 5449 | lpfc_nlp_put(ndlp); |
| 5450 | |
James Smart | 37db57e | 2012-05-09 21:17:16 -0400 | [diff] [blame] | 5451 | if (!elsiocb) { |
| 5452 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5453 | return; |
James Smart | 37db57e | 2012-05-09 21:17:16 -0400 | [diff] [blame] | 5454 | } |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5455 | |
| 5456 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5457 | icmd->ulpContext = rxid; |
| 5458 | icmd->unsli3.rcvsli3.ox_id = oxid; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5459 | |
| 5460 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 5461 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
| 5462 | pcmd += sizeof(uint32_t); /* Skip past command */ |
| 5463 | rls_rsp = (struct RLS_RSP *)pcmd; |
| 5464 | |
| 5465 | rls_rsp->linkFailureCnt = cpu_to_be32(mb->un.varRdLnk.linkFailureCnt); |
| 5466 | rls_rsp->lossSyncCnt = cpu_to_be32(mb->un.varRdLnk.lossSyncCnt); |
| 5467 | rls_rsp->lossSignalCnt = cpu_to_be32(mb->un.varRdLnk.lossSignalCnt); |
| 5468 | rls_rsp->primSeqErrCnt = cpu_to_be32(mb->un.varRdLnk.primSeqErrCnt); |
| 5469 | rls_rsp->invalidXmitWord = cpu_to_be32(mb->un.varRdLnk.invalidXmitWord); |
| 5470 | rls_rsp->crcCnt = cpu_to_be32(mb->un.varRdLnk.crcCnt); |
James Smart | 37db57e | 2012-05-09 21:17:16 -0400 | [diff] [blame] | 5471 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5472 | /* Xmit ELS RLS ACC response tag <ulpIoTag> */ |
| 5473 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS, |
| 5474 | "2874 Xmit ELS RLS ACC response tag x%x xri x%x, " |
| 5475 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", |
| 5476 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 5477 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 5478 | ndlp->nlp_rpi); |
| 5479 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| 5480 | phba->fc_stat.elsXmitACC++; |
| 5481 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == IOCB_ERROR) |
| 5482 | lpfc_els_free_iocb(phba, elsiocb); |
| 5483 | } |
| 5484 | |
| 5485 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5486 | * lpfc_els_rsp_rps_acc - Completion callbk func for MBX_READ_LNK_STAT mbox cmd |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5487 | * @phba: pointer to lpfc hba data structure. |
| 5488 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 5489 | * |
| 5490 | * This routine is the completion callback function for the MBX_READ_LNK_STAT |
| 5491 | * mailbox command. This callback function is to actually send the Accept |
| 5492 | * (ACC) response to a Read Port Status (RPS) unsolicited IOCB event. It |
| 5493 | * collects the link statistics from the completion of the MBX_READ_LNK_STAT |
| 5494 | * mailbox command, constructs the RPS response with the link statistics |
| 5495 | * collected, and then invokes the lpfc_sli_issue_iocb() routine to send ACC |
| 5496 | * response to the RPS. |
| 5497 | * |
| 5498 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 5499 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 5500 | * will be stored into the context1 field of the IOCB for the completion |
| 5501 | * callback function to the RPS Accept Response ELS IOCB command. |
| 5502 | * |
| 5503 | **/ |
Jamie Wellnitz | 082c026 | 2006-02-28 19:25:30 -0500 | [diff] [blame] | 5504 | static void |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5505 | lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5506 | { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5507 | MAILBOX_t *mb; |
| 5508 | IOCB_t *icmd; |
| 5509 | RPS_RSP *rps_rsp; |
| 5510 | uint8_t *pcmd; |
| 5511 | struct lpfc_iocbq *elsiocb; |
| 5512 | struct lpfc_nodelist *ndlp; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5513 | uint16_t status; |
| 5514 | uint16_t oxid; |
| 5515 | uint16_t rxid; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5516 | uint32_t cmdsize; |
| 5517 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5518 | mb = &pmb->u.mb; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5519 | |
| 5520 | ndlp = (struct lpfc_nodelist *) pmb->context2; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5521 | rxid = (uint16_t) ((unsigned long)(pmb->context1) & 0xffff); |
| 5522 | oxid = (uint16_t) (((unsigned long)(pmb->context1) >> 16) & 0xffff); |
Randy Dunlap | 041976f | 2006-06-25 01:58:51 -0700 | [diff] [blame] | 5523 | pmb->context1 = NULL; |
| 5524 | pmb->context2 = NULL; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5525 | |
| 5526 | if (mb->mbxStatus) { |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5527 | mempool_free(pmb, phba->mbox_mem_pool); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5528 | return; |
| 5529 | } |
| 5530 | |
| 5531 | cmdsize = sizeof(RPS_RSP) + sizeof(uint32_t); |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5532 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5533 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 5534 | lpfc_max_els_tries, ndlp, |
| 5535 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 5536 | |
| 5537 | /* Decrement the ndlp reference count from previous mbox command */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5538 | lpfc_nlp_put(ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 5539 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5540 | if (!elsiocb) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5541 | return; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5542 | |
| 5543 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5544 | icmd->ulpContext = rxid; |
| 5545 | icmd->unsli3.rcvsli3.ox_id = oxid; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5546 | |
| 5547 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 5548 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5549 | pcmd += sizeof(uint32_t); /* Skip past command */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5550 | rps_rsp = (RPS_RSP *)pcmd; |
| 5551 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5552 | if (phba->fc_topology != LPFC_TOPOLOGY_LOOP) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5553 | status = 0x10; |
| 5554 | else |
| 5555 | status = 0x8; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5556 | if (phba->pport->fc_flag & FC_FABRIC) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5557 | status |= 0x4; |
| 5558 | |
| 5559 | rps_rsp->rsvd1 = 0; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5560 | rps_rsp->portStatus = cpu_to_be16(status); |
| 5561 | rps_rsp->linkFailureCnt = cpu_to_be32(mb->un.varRdLnk.linkFailureCnt); |
| 5562 | rps_rsp->lossSyncCnt = cpu_to_be32(mb->un.varRdLnk.lossSyncCnt); |
| 5563 | rps_rsp->lossSignalCnt = cpu_to_be32(mb->un.varRdLnk.lossSignalCnt); |
| 5564 | rps_rsp->primSeqErrCnt = cpu_to_be32(mb->un.varRdLnk.primSeqErrCnt); |
| 5565 | rps_rsp->invalidXmitWord = cpu_to_be32(mb->un.varRdLnk.invalidXmitWord); |
| 5566 | rps_rsp->crcCnt = cpu_to_be32(mb->un.varRdLnk.crcCnt); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5567 | /* Xmit ELS RPS ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5568 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS, |
| 5569 | "0118 Xmit ELS RPS ACC response tag x%x xri x%x, " |
| 5570 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", |
| 5571 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 5572 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 5573 | ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5574 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5575 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 5576 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == IOCB_ERROR) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5577 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5578 | return; |
| 5579 | } |
| 5580 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5581 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5582 | * lpfc_els_rcv_rls - Process an unsolicited rls iocb |
| 5583 | * @vport: pointer to a host virtual N_Port data structure. |
| 5584 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5585 | * @ndlp: pointer to a node-list data structure. |
| 5586 | * |
| 5587 | * This routine processes Read Port Status (RPL) IOCB received as an |
| 5588 | * ELS unsolicited event. It first checks the remote port state. If the |
| 5589 | * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE |
| 5590 | * state, it invokes the lpfc_els_rsl_reject() routine to send the reject |
| 5591 | * response. Otherwise, it issue the MBX_READ_LNK_STAT mailbox command |
| 5592 | * for reading the HBA link statistics. It is for the callback function, |
| 5593 | * lpfc_els_rsp_rls_acc(), set to the MBX_READ_LNK_STAT mailbox command |
| 5594 | * to actually sending out RPL Accept (ACC) response. |
| 5595 | * |
| 5596 | * Return codes |
| 5597 | * 0 - Successfully processed rls iocb (currently always return 0) |
| 5598 | **/ |
| 5599 | static int |
| 5600 | lpfc_els_rcv_rls(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5601 | struct lpfc_nodelist *ndlp) |
| 5602 | { |
| 5603 | struct lpfc_hba *phba = vport->phba; |
| 5604 | LPFC_MBOXQ_t *mbox; |
| 5605 | struct lpfc_dmabuf *pcmd; |
| 5606 | struct ls_rjt stat; |
| 5607 | |
| 5608 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
| 5609 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) |
| 5610 | /* reject the unsolicited RPS request and done with it */ |
| 5611 | goto reject_out; |
| 5612 | |
| 5613 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5614 | |
| 5615 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC); |
| 5616 | if (mbox) { |
| 5617 | lpfc_read_lnk_stat(phba, mbox); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5618 | mbox->context1 = (void *)((unsigned long) |
| 5619 | ((cmdiocb->iocb.unsli3.rcvsli3.ox_id << 16) | |
| 5620 | cmdiocb->iocb.ulpContext)); /* rx_id */ |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5621 | mbox->context2 = lpfc_nlp_get(ndlp); |
| 5622 | mbox->vport = vport; |
| 5623 | mbox->mbox_cmpl = lpfc_els_rsp_rls_acc; |
| 5624 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
| 5625 | != MBX_NOT_FINISHED) |
| 5626 | /* Mbox completion will send ELS Response */ |
| 5627 | return 0; |
| 5628 | /* Decrement reference count used for the failed mbox |
| 5629 | * command. |
| 5630 | */ |
| 5631 | lpfc_nlp_put(ndlp); |
| 5632 | mempool_free(mbox, phba->mbox_mem_pool); |
| 5633 | } |
| 5634 | reject_out: |
| 5635 | /* issue rejection response */ |
| 5636 | stat.un.b.lsRjtRsvd0 = 0; |
| 5637 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5638 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5639 | stat.un.b.vendorUnique = 0; |
| 5640 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
| 5641 | return 0; |
| 5642 | } |
| 5643 | |
| 5644 | /** |
| 5645 | * lpfc_els_rcv_rtv - Process an unsolicited rtv iocb |
| 5646 | * @vport: pointer to a host virtual N_Port data structure. |
| 5647 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5648 | * @ndlp: pointer to a node-list data structure. |
| 5649 | * |
| 5650 | * This routine processes Read Timout Value (RTV) IOCB received as an |
| 5651 | * ELS unsolicited event. It first checks the remote port state. If the |
| 5652 | * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE |
| 5653 | * state, it invokes the lpfc_els_rsl_reject() routine to send the reject |
| 5654 | * response. Otherwise, it sends the Accept(ACC) response to a Read Timeout |
| 5655 | * Value (RTV) unsolicited IOCB event. |
| 5656 | * |
| 5657 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 5658 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 5659 | * will be stored into the context1 field of the IOCB for the completion |
| 5660 | * callback function to the RPS Accept Response ELS IOCB command. |
| 5661 | * |
| 5662 | * Return codes |
| 5663 | * 0 - Successfully processed rtv iocb (currently always return 0) |
| 5664 | **/ |
| 5665 | static int |
| 5666 | lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5667 | struct lpfc_nodelist *ndlp) |
| 5668 | { |
| 5669 | struct lpfc_hba *phba = vport->phba; |
| 5670 | struct ls_rjt stat; |
| 5671 | struct RTV_RSP *rtv_rsp; |
| 5672 | uint8_t *pcmd; |
| 5673 | struct lpfc_iocbq *elsiocb; |
| 5674 | uint32_t cmdsize; |
| 5675 | |
| 5676 | |
| 5677 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
| 5678 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) |
| 5679 | /* reject the unsolicited RPS request and done with it */ |
| 5680 | goto reject_out; |
| 5681 | |
| 5682 | cmdsize = sizeof(struct RTV_RSP) + sizeof(uint32_t); |
| 5683 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 5684 | lpfc_max_els_tries, ndlp, |
| 5685 | ndlp->nlp_DID, ELS_CMD_ACC); |
| 5686 | |
| 5687 | if (!elsiocb) |
| 5688 | return 1; |
| 5689 | |
| 5690 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 5691 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
| 5692 | pcmd += sizeof(uint32_t); /* Skip past command */ |
| 5693 | |
| 5694 | /* use the command's xri in the response */ |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5695 | elsiocb->iocb.ulpContext = cmdiocb->iocb.ulpContext; /* Xri / rx_id */ |
| 5696 | elsiocb->iocb.unsli3.rcvsli3.ox_id = cmdiocb->iocb.unsli3.rcvsli3.ox_id; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5697 | |
| 5698 | rtv_rsp = (struct RTV_RSP *)pcmd; |
| 5699 | |
| 5700 | /* populate RTV payload */ |
| 5701 | rtv_rsp->ratov = cpu_to_be32(phba->fc_ratov * 1000); /* report msecs */ |
| 5702 | rtv_rsp->edtov = cpu_to_be32(phba->fc_edtov); |
| 5703 | bf_set(qtov_edtovres, rtv_rsp, phba->fc_edtovResol ? 1 : 0); |
| 5704 | bf_set(qtov_rttov, rtv_rsp, 0); /* Field is for FC ONLY */ |
| 5705 | rtv_rsp->qtov = cpu_to_be32(rtv_rsp->qtov); |
| 5706 | |
| 5707 | /* Xmit ELS RLS ACC response tag <ulpIoTag> */ |
| 5708 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS, |
| 5709 | "2875 Xmit ELS RTV ACC response tag x%x xri x%x, " |
| 5710 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x, " |
| 5711 | "Data: x%x x%x x%x\n", |
| 5712 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 5713 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 5714 | ndlp->nlp_rpi, |
| 5715 | rtv_rsp->ratov, rtv_rsp->edtov, rtv_rsp->qtov); |
| 5716 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| 5717 | phba->fc_stat.elsXmitACC++; |
| 5718 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == IOCB_ERROR) |
| 5719 | lpfc_els_free_iocb(phba, elsiocb); |
| 5720 | return 0; |
| 5721 | |
| 5722 | reject_out: |
| 5723 | /* issue rejection response */ |
| 5724 | stat.un.b.lsRjtRsvd0 = 0; |
| 5725 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5726 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5727 | stat.un.b.vendorUnique = 0; |
| 5728 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
| 5729 | return 0; |
| 5730 | } |
| 5731 | |
| 5732 | /* lpfc_els_rcv_rps - Process an unsolicited rps iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5733 | * @vport: pointer to a host virtual N_Port data structure. |
| 5734 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5735 | * @ndlp: pointer to a node-list data structure. |
| 5736 | * |
| 5737 | * This routine processes Read Port Status (RPS) IOCB received as an |
| 5738 | * ELS unsolicited event. It first checks the remote port state. If the |
| 5739 | * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE |
| 5740 | * state, it invokes the lpfc_els_rsp_reject() routine to send the reject |
| 5741 | * response. Otherwise, it issue the MBX_READ_LNK_STAT mailbox command |
| 5742 | * for reading the HBA link statistics. It is for the callback function, |
| 5743 | * lpfc_els_rsp_rps_acc(), set to the MBX_READ_LNK_STAT mailbox command |
| 5744 | * to actually sending out RPS Accept (ACC) response. |
| 5745 | * |
| 5746 | * Return codes |
| 5747 | * 0 - Successfully processed rps iocb (currently always return 0) |
| 5748 | **/ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5749 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5750 | lpfc_els_rcv_rps(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5751 | struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5752 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5753 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5754 | uint32_t *lp; |
| 5755 | uint8_t flag; |
| 5756 | LPFC_MBOXQ_t *mbox; |
| 5757 | struct lpfc_dmabuf *pcmd; |
| 5758 | RPS *rps; |
| 5759 | struct ls_rjt stat; |
| 5760 | |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 5761 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 5762 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) |
| 5763 | /* reject the unsolicited RPS request and done with it */ |
| 5764 | goto reject_out; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5765 | |
| 5766 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5767 | lp = (uint32_t *) pcmd->virt; |
| 5768 | flag = (be32_to_cpu(*lp++) & 0xf); |
| 5769 | rps = (RPS *) lp; |
| 5770 | |
| 5771 | if ((flag == 0) || |
| 5772 | ((flag == 1) && (be32_to_cpu(rps->un.portNum) == 0)) || |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5773 | ((flag == 2) && (memcmp(&rps->un.portName, &vport->fc_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5774 | sizeof(struct lpfc_name)) == 0))) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5775 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5776 | printk("Fix me....\n"); |
| 5777 | dump_stack(); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5778 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC); |
| 5779 | if (mbox) { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5780 | lpfc_read_lnk_stat(phba, mbox); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5781 | mbox->context1 = (void *)((unsigned long) |
| 5782 | ((cmdiocb->iocb.unsli3.rcvsli3.ox_id << 16) | |
| 5783 | cmdiocb->iocb.ulpContext)); /* rx_id */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5784 | mbox->context2 = lpfc_nlp_get(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5785 | mbox->vport = vport; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5786 | mbox->mbox_cmpl = lpfc_els_rsp_rps_acc; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 5787 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 5788 | != MBX_NOT_FINISHED) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5789 | /* Mbox completion will send ELS Response */ |
| 5790 | return 0; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 5791 | /* Decrement reference count used for the failed mbox |
| 5792 | * command. |
| 5793 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5794 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5795 | mempool_free(mbox, phba->mbox_mem_pool); |
| 5796 | } |
| 5797 | } |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 5798 | |
| 5799 | reject_out: |
| 5800 | /* issue rejection response */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5801 | stat.un.b.lsRjtRsvd0 = 0; |
| 5802 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5803 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5804 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5805 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5806 | return 0; |
| 5807 | } |
| 5808 | |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5809 | /* lpfc_issue_els_rrq - Process an unsolicited rps iocb |
| 5810 | * @vport: pointer to a host virtual N_Port data structure. |
| 5811 | * @ndlp: pointer to a node-list data structure. |
| 5812 | * @did: DID of the target. |
| 5813 | * @rrq: Pointer to the rrq struct. |
| 5814 | * |
| 5815 | * Build a ELS RRQ command and send it to the target. If the issue_iocb is |
| 5816 | * Successful the the completion handler will clear the RRQ. |
| 5817 | * |
| 5818 | * Return codes |
| 5819 | * 0 - Successfully sent rrq els iocb. |
| 5820 | * 1 - Failed to send rrq els iocb. |
| 5821 | **/ |
| 5822 | static int |
| 5823 | lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 5824 | uint32_t did, struct lpfc_node_rrq *rrq) |
| 5825 | { |
| 5826 | struct lpfc_hba *phba = vport->phba; |
| 5827 | struct RRQ *els_rrq; |
| 5828 | IOCB_t *icmd; |
| 5829 | struct lpfc_iocbq *elsiocb; |
| 5830 | uint8_t *pcmd; |
| 5831 | uint16_t cmdsize; |
| 5832 | int ret; |
| 5833 | |
| 5834 | |
| 5835 | if (ndlp != rrq->ndlp) |
| 5836 | ndlp = rrq->ndlp; |
| 5837 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 5838 | return 1; |
| 5839 | |
| 5840 | /* If ndlp is not NULL, we will bump the reference count on it */ |
| 5841 | cmdsize = (sizeof(uint32_t) + sizeof(struct RRQ)); |
| 5842 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, did, |
| 5843 | ELS_CMD_RRQ); |
| 5844 | if (!elsiocb) |
| 5845 | return 1; |
| 5846 | |
| 5847 | icmd = &elsiocb->iocb; |
| 5848 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 5849 | |
| 5850 | /* For RRQ request, remainder of payload is Exchange IDs */ |
| 5851 | *((uint32_t *) (pcmd)) = ELS_CMD_RRQ; |
| 5852 | pcmd += sizeof(uint32_t); |
| 5853 | els_rrq = (struct RRQ *) pcmd; |
| 5854 | |
James Smart | ee0f4fe | 2012-05-09 21:19:14 -0400 | [diff] [blame] | 5855 | bf_set(rrq_oxid, els_rrq, phba->sli4_hba.xri_ids[rrq->xritag]); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5856 | bf_set(rrq_rxid, els_rrq, rrq->rxid); |
| 5857 | bf_set(rrq_did, els_rrq, vport->fc_myDID); |
| 5858 | els_rrq->rrq = cpu_to_be32(els_rrq->rrq); |
| 5859 | els_rrq->rrq_exchg = cpu_to_be32(els_rrq->rrq_exchg); |
| 5860 | |
| 5861 | |
| 5862 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 5863 | "Issue RRQ: did:x%x", |
| 5864 | did, rrq->xritag, rrq->rxid); |
| 5865 | elsiocb->context_un.rrq = rrq; |
| 5866 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rrq; |
| 5867 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| 5868 | |
| 5869 | if (ret == IOCB_ERROR) { |
| 5870 | lpfc_els_free_iocb(phba, elsiocb); |
| 5871 | return 1; |
| 5872 | } |
| 5873 | return 0; |
| 5874 | } |
| 5875 | |
| 5876 | /** |
| 5877 | * lpfc_send_rrq - Sends ELS RRQ if needed. |
| 5878 | * @phba: pointer to lpfc hba data structure. |
| 5879 | * @rrq: pointer to the active rrq. |
| 5880 | * |
| 5881 | * This routine will call the lpfc_issue_els_rrq if the rrq is |
| 5882 | * still active for the xri. If this function returns a failure then |
| 5883 | * the caller needs to clean up the RRQ by calling lpfc_clr_active_rrq. |
| 5884 | * |
| 5885 | * Returns 0 Success. |
| 5886 | * 1 Failure. |
| 5887 | **/ |
| 5888 | int |
| 5889 | lpfc_send_rrq(struct lpfc_hba *phba, struct lpfc_node_rrq *rrq) |
| 5890 | { |
| 5891 | struct lpfc_nodelist *ndlp = lpfc_findnode_did(rrq->vport, |
| 5892 | rrq->nlp_DID); |
| 5893 | if (lpfc_test_rrq_active(phba, ndlp, rrq->xritag)) |
| 5894 | return lpfc_issue_els_rrq(rrq->vport, ndlp, |
| 5895 | rrq->nlp_DID, rrq); |
| 5896 | else |
| 5897 | return 1; |
| 5898 | } |
| 5899 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5900 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5901 | * lpfc_els_rsp_rpl_acc - Issue an accept rpl els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5902 | * @vport: pointer to a host virtual N_Port data structure. |
| 5903 | * @cmdsize: size of the ELS command. |
| 5904 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 5905 | * @ndlp: pointer to a node-list data structure. |
| 5906 | * |
| 5907 | * This routine issuees an Accept (ACC) Read Port List (RPL) ELS command. |
| 5908 | * It is to be called by the lpfc_els_rcv_rpl() routine to accept the RPL. |
| 5909 | * |
| 5910 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 5911 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 5912 | * will be stored into the context1 field of the IOCB for the completion |
| 5913 | * callback function to the RPL Accept Response ELS command. |
| 5914 | * |
| 5915 | * Return code |
| 5916 | * 0 - Successfully issued ACC RPL ELS command |
| 5917 | * 1 - Failed to issue ACC RPL ELS command |
| 5918 | **/ |
Jamie Wellnitz | 082c026 | 2006-02-28 19:25:30 -0500 | [diff] [blame] | 5919 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5920 | lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, |
| 5921 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5922 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5923 | struct lpfc_hba *phba = vport->phba; |
| 5924 | IOCB_t *icmd, *oldcmd; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5925 | RPL_RSP rpl_rsp; |
| 5926 | struct lpfc_iocbq *elsiocb; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5927 | uint8_t *pcmd; |
| 5928 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5929 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 5930 | ndlp->nlp_DID, ELS_CMD_ACC); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5931 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 5932 | if (!elsiocb) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5933 | return 1; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 5934 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5935 | icmd = &elsiocb->iocb; |
| 5936 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5937 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 5938 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5939 | |
| 5940 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 5941 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5942 | pcmd += sizeof(uint16_t); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5943 | *((uint16_t *)(pcmd)) = be16_to_cpu(cmdsize); |
| 5944 | pcmd += sizeof(uint16_t); |
| 5945 | |
| 5946 | /* Setup the RPL ACC payload */ |
| 5947 | rpl_rsp.listLen = be32_to_cpu(1); |
| 5948 | rpl_rsp.index = 0; |
| 5949 | rpl_rsp.port_num_blk.portNum = 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5950 | rpl_rsp.port_num_blk.portID = be32_to_cpu(vport->fc_myDID); |
| 5951 | memcpy(&rpl_rsp.port_num_blk.portName, &vport->fc_portname, |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5952 | sizeof(struct lpfc_name)); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5953 | memcpy(pcmd, &rpl_rsp, cmdsize - sizeof(uint32_t)); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5954 | /* Xmit ELS RPL ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5955 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 5956 | "0120 Xmit ELS RPL ACC response tag x%x " |
| 5957 | "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " |
| 5958 | "rpi x%x\n", |
| 5959 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 5960 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 5961 | ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5962 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5963 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 5964 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 5965 | IOCB_ERROR) { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5966 | lpfc_els_free_iocb(phba, elsiocb); |
| 5967 | return 1; |
| 5968 | } |
| 5969 | return 0; |
| 5970 | } |
| 5971 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5972 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5973 | * lpfc_els_rcv_rpl - Process an unsolicited rpl iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5974 | * @vport: pointer to a host virtual N_Port data structure. |
| 5975 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5976 | * @ndlp: pointer to a node-list data structure. |
| 5977 | * |
| 5978 | * This routine processes Read Port List (RPL) IOCB received as an ELS |
| 5979 | * unsolicited event. It first checks the remote port state. If the remote |
| 5980 | * port is not in NLP_STE_UNMAPPED_NODE and NLP_STE_MAPPED_NODE states, it |
| 5981 | * invokes the lpfc_els_rsp_reject() routine to send reject response. |
| 5982 | * Otherwise, this routine then invokes the lpfc_els_rsp_rpl_acc() routine |
| 5983 | * to accept the RPL. |
| 5984 | * |
| 5985 | * Return code |
| 5986 | * 0 - Successfully processed rpl iocb (currently always return 0) |
| 5987 | **/ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5988 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5989 | lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5990 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5991 | { |
| 5992 | struct lpfc_dmabuf *pcmd; |
| 5993 | uint32_t *lp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5994 | uint32_t maxsize; |
| 5995 | uint16_t cmdsize; |
| 5996 | RPL *rpl; |
| 5997 | struct ls_rjt stat; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5998 | |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 5999 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
| 6000 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) { |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 6001 | /* issue rejection response */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6002 | stat.un.b.lsRjtRsvd0 = 0; |
| 6003 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 6004 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 6005 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6006 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
| 6007 | NULL); |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 6008 | /* rejected the unsolicited RPL request and done with it */ |
| 6009 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6010 | } |
| 6011 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6012 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 6013 | lp = (uint32_t *) pcmd->virt; |
| 6014 | rpl = (RPL *) (lp + 1); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6015 | maxsize = be32_to_cpu(rpl->maxsize); |
| 6016 | |
| 6017 | /* We support only one port */ |
| 6018 | if ((rpl->index == 0) && |
| 6019 | ((maxsize == 0) || |
| 6020 | ((maxsize * sizeof(uint32_t)) >= sizeof(RPL_RSP)))) { |
| 6021 | cmdsize = sizeof(uint32_t) + sizeof(RPL_RSP); |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 6022 | } else { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6023 | cmdsize = sizeof(uint32_t) + maxsize * sizeof(uint32_t); |
| 6024 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6025 | lpfc_els_rsp_rpl_acc(vport, cmdsize, cmdiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6026 | |
| 6027 | return 0; |
| 6028 | } |
| 6029 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6030 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6031 | * lpfc_els_rcv_farp - Process an unsolicited farp request els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6032 | * @vport: pointer to a virtual N_Port data structure. |
| 6033 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6034 | * @ndlp: pointer to a node-list data structure. |
| 6035 | * |
| 6036 | * This routine processes Fibre Channel Address Resolution Protocol |
| 6037 | * (FARP) Request IOCB received as an ELS unsolicited event. Currently, |
| 6038 | * the lpfc driver only supports matching on WWPN or WWNN for FARP. As such, |
| 6039 | * FARP_MATCH_PORT flag and FARP_MATCH_NODE flag are checked against the |
| 6040 | * Match Flag in the FARP request IOCB: if FARP_MATCH_PORT flag is set, the |
| 6041 | * remote PortName is compared against the FC PortName stored in the @vport |
| 6042 | * data structure; if FARP_MATCH_NODE flag is set, the remote NodeName is |
| 6043 | * compared against the FC NodeName stored in the @vport data structure. |
| 6044 | * If any of these matches and the FARP_REQUEST_FARPR flag is set in the |
| 6045 | * FARP request IOCB Response Flag, the lpfc_issue_els_farpr() routine is |
| 6046 | * invoked to send out FARP Response to the remote node. Before sending the |
| 6047 | * FARP Response, however, the FARP_REQUEST_PLOGI flag is check in the FARP |
| 6048 | * request IOCB Response Flag and, if it is set, the lpfc_issue_els_plogi() |
| 6049 | * routine is invoked to log into the remote port first. |
| 6050 | * |
| 6051 | * Return code |
| 6052 | * 0 - Either the FARP Match Mode not supported or successfully processed |
| 6053 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6054 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6055 | lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6056 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6057 | { |
| 6058 | struct lpfc_dmabuf *pcmd; |
| 6059 | uint32_t *lp; |
| 6060 | IOCB_t *icmd; |
| 6061 | FARP *fp; |
| 6062 | uint32_t cmd, cnt, did; |
| 6063 | |
| 6064 | icmd = &cmdiocb->iocb; |
| 6065 | did = icmd->un.elsreq64.remoteID; |
| 6066 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 6067 | lp = (uint32_t *) pcmd->virt; |
| 6068 | |
| 6069 | cmd = *lp++; |
| 6070 | fp = (FARP *) lp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6071 | /* FARP-REQ received from DID <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6072 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6073 | "0601 FARP-REQ received from DID x%x\n", did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6074 | /* We will only support match on WWPN or WWNN */ |
| 6075 | if (fp->Mflags & ~(FARP_MATCH_NODE | FARP_MATCH_PORT)) { |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6076 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6077 | } |
| 6078 | |
| 6079 | cnt = 0; |
| 6080 | /* If this FARP command is searching for my portname */ |
| 6081 | if (fp->Mflags & FARP_MATCH_PORT) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6082 | if (memcmp(&fp->RportName, &vport->fc_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6083 | sizeof(struct lpfc_name)) == 0) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6084 | cnt = 1; |
| 6085 | } |
| 6086 | |
| 6087 | /* If this FARP command is searching for my nodename */ |
| 6088 | if (fp->Mflags & FARP_MATCH_NODE) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6089 | if (memcmp(&fp->RnodeName, &vport->fc_nodename, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6090 | sizeof(struct lpfc_name)) == 0) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6091 | cnt = 1; |
| 6092 | } |
| 6093 | |
| 6094 | if (cnt) { |
| 6095 | if ((ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) || |
| 6096 | (ndlp->nlp_state == NLP_STE_MAPPED_NODE)) { |
| 6097 | /* Log back into the node before sending the FARP. */ |
| 6098 | if (fp->Rflags & FARP_REQUEST_PLOGI) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6099 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6100 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | de0c5b3 | 2007-04-25 09:52:27 -0400 | [diff] [blame] | 6101 | NLP_STE_PLOGI_ISSUE); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6102 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6103 | } |
| 6104 | |
| 6105 | /* Send a FARP response to that node */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6106 | if (fp->Rflags & FARP_REQUEST_FARPR) |
| 6107 | lpfc_issue_els_farpr(vport, did, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6108 | } |
| 6109 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6110 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6111 | } |
| 6112 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6113 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6114 | * lpfc_els_rcv_farpr - Process an unsolicited farp response iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6115 | * @vport: pointer to a host virtual N_Port data structure. |
| 6116 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6117 | * @ndlp: pointer to a node-list data structure. |
| 6118 | * |
| 6119 | * This routine processes Fibre Channel Address Resolution Protocol |
| 6120 | * Response (FARPR) IOCB received as an ELS unsolicited event. It simply |
| 6121 | * invokes the lpfc_els_rsp_acc() routine to the remote node to accept |
| 6122 | * the FARP response request. |
| 6123 | * |
| 6124 | * Return code |
| 6125 | * 0 - Successfully processed FARPR IOCB (currently always return 0) |
| 6126 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6127 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6128 | lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6129 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6130 | { |
| 6131 | struct lpfc_dmabuf *pcmd; |
| 6132 | uint32_t *lp; |
| 6133 | IOCB_t *icmd; |
| 6134 | uint32_t cmd, did; |
| 6135 | |
| 6136 | icmd = &cmdiocb->iocb; |
| 6137 | did = icmd->un.elsreq64.remoteID; |
| 6138 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 6139 | lp = (uint32_t *) pcmd->virt; |
| 6140 | |
| 6141 | cmd = *lp++; |
| 6142 | /* FARP-RSP received from DID <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6143 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6144 | "0600 FARP-RSP received from DID x%x\n", did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6145 | /* ACCEPT the Farp resp request */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 6146 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6147 | |
| 6148 | return 0; |
| 6149 | } |
| 6150 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6151 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6152 | * lpfc_els_rcv_fan - Process an unsolicited fan iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6153 | * @vport: pointer to a host virtual N_Port data structure. |
| 6154 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6155 | * @fan_ndlp: pointer to a node-list data structure. |
| 6156 | * |
| 6157 | * This routine processes a Fabric Address Notification (FAN) IOCB |
| 6158 | * command received as an ELS unsolicited event. The FAN ELS command will |
| 6159 | * only be processed on a physical port (i.e., the @vport represents the |
| 6160 | * physical port). The fabric NodeName and PortName from the FAN IOCB are |
| 6161 | * compared against those in the phba data structure. If any of those is |
| 6162 | * different, the lpfc_initial_flogi() routine is invoked to initialize |
| 6163 | * Fabric Login (FLOGI) to the fabric to start the discover over. Otherwise, |
| 6164 | * if both of those are identical, the lpfc_issue_fabric_reglogin() routine |
| 6165 | * is invoked to register login to the fabric. |
| 6166 | * |
| 6167 | * Return code |
| 6168 | * 0 - Successfully processed fan iocb (currently always return 0). |
| 6169 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6170 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6171 | lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6172 | struct lpfc_nodelist *fan_ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6173 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6174 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6175 | uint32_t *lp; |
| 6176 | FAN *fp; |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6177 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6178 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0265 FAN received\n"); |
| 6179 | lp = (uint32_t *)((struct lpfc_dmabuf *)cmdiocb->context2)->virt; |
| 6180 | fp = (FAN *) ++lp; |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6181 | /* FAN received; Fan does not have a reply sequence */ |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6182 | if ((vport == phba->pport) && |
| 6183 | (vport->port_state == LPFC_LOCAL_CFG_LINK)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6184 | if ((memcmp(&phba->fc_fabparam.nodeName, &fp->FnodeName, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6185 | sizeof(struct lpfc_name))) || |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6186 | (memcmp(&phba->fc_fabparam.portName, &fp->FportName, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6187 | sizeof(struct lpfc_name)))) { |
| 6188 | /* This port has switched fabrics. FLOGI is required */ |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6189 | lpfc_issue_init_vfi(vport); |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6190 | } else { |
| 6191 | /* FAN verified - skip FLOGI */ |
| 6192 | vport->fc_myDID = vport->fc_prevDID; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6193 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 6194 | lpfc_issue_fabric_reglogin(vport); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 6195 | else { |
| 6196 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6197 | "3138 Need register VFI: (x%x/%x)\n", |
| 6198 | vport->fc_prevDID, vport->fc_myDID); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6199 | lpfc_issue_reg_vfi(vport); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 6200 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6201 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6202 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6203 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6204 | } |
| 6205 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6206 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6207 | * lpfc_els_timeout - Handler funciton to the els timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6208 | * @ptr: holder for the timer function associated data. |
| 6209 | * |
| 6210 | * This routine is invoked by the ELS timer after timeout. It posts the ELS |
| 6211 | * timer timeout event by setting the WORKER_ELS_TMO bit to the work port |
| 6212 | * event bitmap and then invokes the lpfc_worker_wake_up() routine to wake |
| 6213 | * up the worker thread. It is for the worker thread to invoke the routine |
| 6214 | * lpfc_els_timeout_handler() to work on the posted event WORKER_ELS_TMO. |
| 6215 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6216 | void |
| 6217 | lpfc_els_timeout(unsigned long ptr) |
| 6218 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6219 | struct lpfc_vport *vport = (struct lpfc_vport *) ptr; |
| 6220 | struct lpfc_hba *phba = vport->phba; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6221 | uint32_t tmo_posted; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6222 | unsigned long iflag; |
| 6223 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6224 | spin_lock_irqsave(&vport->work_port_lock, iflag); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6225 | tmo_posted = vport->work_port_events & WORKER_ELS_TMO; |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6226 | if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING))) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6227 | vport->work_port_events |= WORKER_ELS_TMO; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6228 | spin_unlock_irqrestore(&vport->work_port_lock, iflag); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6229 | |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6230 | if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING))) |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6231 | lpfc_worker_wake_up(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6232 | return; |
| 6233 | } |
| 6234 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6235 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6236 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6237 | * lpfc_els_timeout_handler - Process an els timeout event |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6238 | * @vport: pointer to a virtual N_Port data structure. |
| 6239 | * |
| 6240 | * This routine is the actual handler function that processes an ELS timeout |
| 6241 | * event. It walks the ELS ring to get and abort all the IOCBs (except the |
| 6242 | * ABORT/CLOSE/FARP/FARPR/FDISC), which are associated with the @vport by |
| 6243 | * invoking the lpfc_sli_issue_abort_iotag() routine. |
| 6244 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6245 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6246 | lpfc_els_timeout_handler(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6247 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6248 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6249 | struct lpfc_sli_ring *pring; |
| 6250 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 6251 | IOCB_t *cmd = NULL; |
| 6252 | struct lpfc_dmabuf *pcmd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6253 | uint32_t els_command = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6254 | uint32_t timeout; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6255 | uint32_t remote_ID = 0xffffffff; |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6256 | LIST_HEAD(abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6257 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6258 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6259 | timeout = (uint32_t)(phba->fc_ratov << 1); |
| 6260 | |
| 6261 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6262 | if ((phba->pport->load_flag & FC_UNLOADING)) |
| 6263 | return; |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6264 | spin_lock_irq(&phba->hbalock); |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6265 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6266 | spin_lock(&pring->ring_lock); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6267 | |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6268 | if ((phba->pport->load_flag & FC_UNLOADING)) { |
| 6269 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6270 | spin_unlock(&pring->ring_lock); |
| 6271 | spin_unlock_irq(&phba->hbalock); |
| 6272 | return; |
| 6273 | } |
| 6274 | |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6275 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6276 | cmd = &piocb->iocb; |
| 6277 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6278 | if ((piocb->iocb_flag & LPFC_IO_LIBDFC) != 0 || |
| 6279 | piocb->iocb.ulpCommand == CMD_ABORT_XRI_CN || |
| 6280 | piocb->iocb.ulpCommand == CMD_CLOSE_XRI_CN) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6281 | continue; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6282 | |
| 6283 | if (piocb->vport != vport) |
| 6284 | continue; |
| 6285 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6286 | pcmd = (struct lpfc_dmabuf *) piocb->context2; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6287 | if (pcmd) |
| 6288 | els_command = *(uint32_t *) (pcmd->virt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6289 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6290 | if (els_command == ELS_CMD_FARP || |
| 6291 | els_command == ELS_CMD_FARPR || |
| 6292 | els_command == ELS_CMD_FDISC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6293 | continue; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6294 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6295 | if (piocb->drvrTimeout > 0) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6296 | if (piocb->drvrTimeout >= timeout) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6297 | piocb->drvrTimeout -= timeout; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6298 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6299 | piocb->drvrTimeout = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6300 | continue; |
| 6301 | } |
| 6302 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6303 | remote_ID = 0xffffffff; |
| 6304 | if (cmd->ulpCommand != CMD_GEN_REQUEST64_CR) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6305 | remote_ID = cmd->un.elsreq64.remoteID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6306 | else { |
| 6307 | struct lpfc_nodelist *ndlp; |
| 6308 | ndlp = __lpfc_findnode_rpi(vport, cmd->ulpContext); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 6309 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6310 | remote_ID = ndlp->nlp_DID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6311 | } |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6312 | list_add_tail(&piocb->dlist, &abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6313 | } |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6314 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6315 | spin_unlock(&pring->ring_lock); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6316 | spin_unlock_irq(&phba->hbalock); |
James Smart | 5a0e326 | 2006-07-06 15:49:16 -0400 | [diff] [blame] | 6317 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6318 | list_for_each_entry_safe(piocb, tmp_iocb, &abort_list, dlist) { |
James Smart | 15026c9 | 2013-12-17 20:30:09 -0500 | [diff] [blame] | 6319 | cmd = &piocb->iocb; |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6320 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6321 | "0127 ELS timeout Data: x%x x%x x%x " |
| 6322 | "x%x\n", els_command, |
| 6323 | remote_ID, cmd->ulpCommand, cmd->ulpIoTag); |
| 6324 | spin_lock_irq(&phba->hbalock); |
| 6325 | list_del_init(&piocb->dlist); |
| 6326 | lpfc_sli_issue_abort_iotag(phba, pring, piocb); |
| 6327 | spin_unlock_irq(&phba->hbalock); |
| 6328 | } |
| 6329 | |
James Smart | 0e9bb8d | 2013-03-01 16:35:12 -0500 | [diff] [blame] | 6330 | if (!list_empty(&phba->sli.ring[LPFC_ELS_RING].txcmplq)) |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6331 | if (!(phba->pport->load_flag & FC_UNLOADING)) |
| 6332 | mod_timer(&vport->els_tmofunc, |
| 6333 | jiffies + msecs_to_jiffies(1000 * timeout)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6334 | } |
| 6335 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6336 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6337 | * lpfc_els_flush_cmd - Clean up the outstanding els commands to a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6338 | * @vport: pointer to a host virtual N_Port data structure. |
| 6339 | * |
| 6340 | * This routine is used to clean up all the outstanding ELS commands on a |
| 6341 | * @vport. It first aborts the @vport by invoking lpfc_fabric_abort_vport() |
| 6342 | * routine. After that, it walks the ELS transmit queue to remove all the |
| 6343 | * IOCBs with the @vport other than the QUE_RING and ABORT/CLOSE IOCBs. For |
| 6344 | * the IOCBs with a non-NULL completion callback function, the callback |
| 6345 | * function will be invoked with the status set to IOSTAT_LOCAL_REJECT and |
| 6346 | * un.ulpWord[4] set to IOERR_SLI_ABORTED. For IOCBs with a NULL completion |
| 6347 | * callback function, the IOCB will simply be released. Finally, it walks |
| 6348 | * the ELS transmit completion queue to issue an abort IOCB to any transmit |
| 6349 | * completion queue IOCB that is associated with the @vport and is not |
| 6350 | * an IOCB from libdfc (i.e., the management plane IOCBs that are not |
| 6351 | * part of the discovery state machine) out to HBA by invoking the |
| 6352 | * lpfc_sli_issue_abort_iotag() routine. Note that this function issues the |
| 6353 | * abort IOCB to any transmit completion queueed IOCB, it does not guarantee |
| 6354 | * the IOCBs are aborted when this function returns. |
| 6355 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6356 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6357 | lpfc_els_flush_cmd(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6358 | { |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6359 | LIST_HEAD(abort_list); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6360 | struct lpfc_hba *phba = vport->phba; |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6361 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6362 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 6363 | IOCB_t *cmd = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6364 | |
| 6365 | lpfc_fabric_abort_vport(vport); |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6366 | /* |
| 6367 | * For SLI3, only the hbalock is required. But SLI4 needs to coordinate |
| 6368 | * with the ring insert operation. Because lpfc_sli_issue_abort_iotag |
| 6369 | * ultimately grabs the ring_lock, the driver must splice the list into |
| 6370 | * a working list and release the locks before calling the abort. |
| 6371 | */ |
| 6372 | spin_lock_irq(&phba->hbalock); |
| 6373 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6374 | spin_lock(&pring->ring_lock); |
| 6375 | |
| 6376 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) { |
| 6377 | if (piocb->iocb_flag & LPFC_IO_LIBDFC) |
| 6378 | continue; |
| 6379 | |
| 6380 | if (piocb->vport != vport) |
| 6381 | continue; |
| 6382 | list_add_tail(&piocb->dlist, &abort_list); |
| 6383 | } |
| 6384 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6385 | spin_unlock(&pring->ring_lock); |
| 6386 | spin_unlock_irq(&phba->hbalock); |
| 6387 | /* Abort each iocb on the aborted list and remove the dlist links. */ |
| 6388 | list_for_each_entry_safe(piocb, tmp_iocb, &abort_list, dlist) { |
| 6389 | spin_lock_irq(&phba->hbalock); |
| 6390 | list_del_init(&piocb->dlist); |
| 6391 | lpfc_sli_issue_abort_iotag(phba, pring, piocb); |
| 6392 | spin_unlock_irq(&phba->hbalock); |
| 6393 | } |
| 6394 | if (!list_empty(&abort_list)) |
| 6395 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6396 | "3387 abort list for txq not empty\n"); |
| 6397 | INIT_LIST_HEAD(&abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6398 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6399 | spin_lock_irq(&phba->hbalock); |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6400 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6401 | spin_lock(&pring->ring_lock); |
| 6402 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6403 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txq, list) { |
| 6404 | cmd = &piocb->iocb; |
| 6405 | |
| 6406 | if (piocb->iocb_flag & LPFC_IO_LIBDFC) { |
| 6407 | continue; |
| 6408 | } |
| 6409 | |
| 6410 | /* Do not flush out the QUE_RING and ABORT/CLOSE iocbs */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6411 | if (cmd->ulpCommand == CMD_QUE_RING_BUF_CN || |
| 6412 | cmd->ulpCommand == CMD_QUE_RING_BUF64_CN || |
| 6413 | cmd->ulpCommand == CMD_CLOSE_XRI_CN || |
| 6414 | cmd->ulpCommand == CMD_ABORT_XRI_CN) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6415 | continue; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6416 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6417 | if (piocb->vport != vport) |
| 6418 | continue; |
| 6419 | |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6420 | list_del_init(&piocb->list); |
| 6421 | list_add_tail(&piocb->list, &abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6422 | } |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6423 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6424 | spin_unlock(&pring->ring_lock); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6425 | spin_unlock_irq(&phba->hbalock); |
James Smart | 2534ba7 | 2007-04-25 09:52:20 -0400 | [diff] [blame] | 6426 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 6427 | /* Cancell all the IOCBs from the completions list */ |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6428 | lpfc_sli_cancel_iocbs(phba, &abort_list, |
| 6429 | IOSTAT_LOCAL_REJECT, IOERR_SLI_ABORTED); |
James Smart | 2534ba7 | 2007-04-25 09:52:20 -0400 | [diff] [blame] | 6430 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6431 | return; |
| 6432 | } |
| 6433 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6434 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6435 | * lpfc_els_flush_all_cmd - Clean up all the outstanding els commands to a HBA |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6436 | * @phba: pointer to lpfc hba data structure. |
| 6437 | * |
| 6438 | * This routine is used to clean up all the outstanding ELS commands on a |
| 6439 | * @phba. It first aborts the @phba by invoking the lpfc_fabric_abort_hba() |
| 6440 | * routine. After that, it walks the ELS transmit queue to remove all the |
| 6441 | * IOCBs to the @phba other than the QUE_RING and ABORT/CLOSE IOCBs. For |
| 6442 | * the IOCBs with the completion callback function associated, the callback |
| 6443 | * function will be invoked with the status set to IOSTAT_LOCAL_REJECT and |
| 6444 | * un.ulpWord[4] set to IOERR_SLI_ABORTED. For IOCBs without the completion |
| 6445 | * callback function associated, the IOCB will simply be released. Finally, |
| 6446 | * it walks the ELS transmit completion queue to issue an abort IOCB to any |
| 6447 | * transmit completion queue IOCB that is not an IOCB from libdfc (i.e., the |
| 6448 | * management plane IOCBs that are not part of the discovery state machine) |
| 6449 | * out to HBA by invoking the lpfc_sli_issue_abort_iotag() routine. |
| 6450 | **/ |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 6451 | void |
| 6452 | lpfc_els_flush_all_cmd(struct lpfc_hba *phba) |
| 6453 | { |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6454 | struct lpfc_vport *vport; |
| 6455 | list_for_each_entry(vport, &phba->port_list, listentry) |
| 6456 | lpfc_els_flush_cmd(vport); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 6457 | |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 6458 | return; |
| 6459 | } |
| 6460 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6461 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6462 | * lpfc_send_els_failure_event - Posts an ELS command failure event |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6463 | * @phba: Pointer to hba context object. |
| 6464 | * @cmdiocbp: Pointer to command iocb which reported error. |
| 6465 | * @rspiocbp: Pointer to response iocb which reported error. |
| 6466 | * |
| 6467 | * This function sends an event when there is an ELS command |
| 6468 | * failure. |
| 6469 | **/ |
| 6470 | void |
| 6471 | lpfc_send_els_failure_event(struct lpfc_hba *phba, |
| 6472 | struct lpfc_iocbq *cmdiocbp, |
| 6473 | struct lpfc_iocbq *rspiocbp) |
| 6474 | { |
| 6475 | struct lpfc_vport *vport = cmdiocbp->vport; |
| 6476 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 6477 | struct lpfc_lsrjt_event lsrjt_event; |
| 6478 | struct lpfc_fabric_event_header fabric_event; |
| 6479 | struct ls_rjt stat; |
| 6480 | struct lpfc_nodelist *ndlp; |
| 6481 | uint32_t *pcmd; |
| 6482 | |
| 6483 | ndlp = cmdiocbp->context1; |
| 6484 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 6485 | return; |
| 6486 | |
| 6487 | if (rspiocbp->iocb.ulpStatus == IOSTAT_LS_RJT) { |
| 6488 | lsrjt_event.header.event_type = FC_REG_ELS_EVENT; |
| 6489 | lsrjt_event.header.subcategory = LPFC_EVENT_LSRJT_RCV; |
| 6490 | memcpy(lsrjt_event.header.wwpn, &ndlp->nlp_portname, |
| 6491 | sizeof(struct lpfc_name)); |
| 6492 | memcpy(lsrjt_event.header.wwnn, &ndlp->nlp_nodename, |
| 6493 | sizeof(struct lpfc_name)); |
| 6494 | pcmd = (uint32_t *) (((struct lpfc_dmabuf *) |
| 6495 | cmdiocbp->context2)->virt); |
James Smart | 49198b3 | 2010-04-06 15:04:33 -0400 | [diff] [blame] | 6496 | lsrjt_event.command = (pcmd != NULL) ? *pcmd : 0; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6497 | stat.un.lsRjtError = be32_to_cpu(rspiocbp->iocb.un.ulpWord[4]); |
| 6498 | lsrjt_event.reason_code = stat.un.b.lsRjtRsnCode; |
| 6499 | lsrjt_event.explanation = stat.un.b.lsRjtRsnCodeExp; |
| 6500 | fc_host_post_vendor_event(shost, |
| 6501 | fc_get_event_number(), |
| 6502 | sizeof(lsrjt_event), |
| 6503 | (char *)&lsrjt_event, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6504 | LPFC_NL_VENDOR_ID); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6505 | return; |
| 6506 | } |
| 6507 | if ((rspiocbp->iocb.ulpStatus == IOSTAT_NPORT_BSY) || |
| 6508 | (rspiocbp->iocb.ulpStatus == IOSTAT_FABRIC_BSY)) { |
| 6509 | fabric_event.event_type = FC_REG_FABRIC_EVENT; |
| 6510 | if (rspiocbp->iocb.ulpStatus == IOSTAT_NPORT_BSY) |
| 6511 | fabric_event.subcategory = LPFC_EVENT_PORT_BUSY; |
| 6512 | else |
| 6513 | fabric_event.subcategory = LPFC_EVENT_FABRIC_BUSY; |
| 6514 | memcpy(fabric_event.wwpn, &ndlp->nlp_portname, |
| 6515 | sizeof(struct lpfc_name)); |
| 6516 | memcpy(fabric_event.wwnn, &ndlp->nlp_nodename, |
| 6517 | sizeof(struct lpfc_name)); |
| 6518 | fc_host_post_vendor_event(shost, |
| 6519 | fc_get_event_number(), |
| 6520 | sizeof(fabric_event), |
| 6521 | (char *)&fabric_event, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6522 | LPFC_NL_VENDOR_ID); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6523 | return; |
| 6524 | } |
| 6525 | |
| 6526 | } |
| 6527 | |
| 6528 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6529 | * lpfc_send_els_event - Posts unsolicited els event |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6530 | * @vport: Pointer to vport object. |
| 6531 | * @ndlp: Pointer FC node object. |
| 6532 | * @cmd: ELS command code. |
| 6533 | * |
| 6534 | * This function posts an event when there is an incoming |
| 6535 | * unsolicited ELS command. |
| 6536 | **/ |
| 6537 | static void |
| 6538 | lpfc_send_els_event(struct lpfc_vport *vport, |
| 6539 | struct lpfc_nodelist *ndlp, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6540 | uint32_t *payload) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6541 | { |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6542 | struct lpfc_els_event_header *els_data = NULL; |
| 6543 | struct lpfc_logo_event *logo_data = NULL; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6544 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 6545 | |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6546 | if (*payload == ELS_CMD_LOGO) { |
| 6547 | logo_data = kmalloc(sizeof(struct lpfc_logo_event), GFP_KERNEL); |
| 6548 | if (!logo_data) { |
| 6549 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6550 | "0148 Failed to allocate memory " |
| 6551 | "for LOGO event\n"); |
| 6552 | return; |
| 6553 | } |
| 6554 | els_data = &logo_data->header; |
| 6555 | } else { |
| 6556 | els_data = kmalloc(sizeof(struct lpfc_els_event_header), |
| 6557 | GFP_KERNEL); |
| 6558 | if (!els_data) { |
| 6559 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6560 | "0149 Failed to allocate memory " |
| 6561 | "for ELS event\n"); |
| 6562 | return; |
| 6563 | } |
| 6564 | } |
| 6565 | els_data->event_type = FC_REG_ELS_EVENT; |
| 6566 | switch (*payload) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6567 | case ELS_CMD_PLOGI: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6568 | els_data->subcategory = LPFC_EVENT_PLOGI_RCV; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6569 | break; |
| 6570 | case ELS_CMD_PRLO: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6571 | els_data->subcategory = LPFC_EVENT_PRLO_RCV; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6572 | break; |
| 6573 | case ELS_CMD_ADISC: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6574 | els_data->subcategory = LPFC_EVENT_ADISC_RCV; |
| 6575 | break; |
| 6576 | case ELS_CMD_LOGO: |
| 6577 | els_data->subcategory = LPFC_EVENT_LOGO_RCV; |
| 6578 | /* Copy the WWPN in the LOGO payload */ |
| 6579 | memcpy(logo_data->logo_wwpn, &payload[2], |
| 6580 | sizeof(struct lpfc_name)); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6581 | break; |
| 6582 | default: |
Julia Lawall | e916141 | 2009-02-08 22:43:19 +0100 | [diff] [blame] | 6583 | kfree(els_data); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6584 | return; |
| 6585 | } |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6586 | memcpy(els_data->wwpn, &ndlp->nlp_portname, sizeof(struct lpfc_name)); |
| 6587 | memcpy(els_data->wwnn, &ndlp->nlp_nodename, sizeof(struct lpfc_name)); |
| 6588 | if (*payload == ELS_CMD_LOGO) { |
| 6589 | fc_host_post_vendor_event(shost, |
| 6590 | fc_get_event_number(), |
| 6591 | sizeof(struct lpfc_logo_event), |
| 6592 | (char *)logo_data, |
| 6593 | LPFC_NL_VENDOR_ID); |
| 6594 | kfree(logo_data); |
| 6595 | } else { |
| 6596 | fc_host_post_vendor_event(shost, |
| 6597 | fc_get_event_number(), |
| 6598 | sizeof(struct lpfc_els_event_header), |
| 6599 | (char *)els_data, |
| 6600 | LPFC_NL_VENDOR_ID); |
| 6601 | kfree(els_data); |
| 6602 | } |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6603 | |
| 6604 | return; |
| 6605 | } |
| 6606 | |
| 6607 | |
| 6608 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6609 | * lpfc_els_unsol_buffer - Process an unsolicited event data buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6610 | * @phba: pointer to lpfc hba data structure. |
| 6611 | * @pring: pointer to a SLI ring. |
| 6612 | * @vport: pointer to a host virtual N_Port data structure. |
| 6613 | * @elsiocb: pointer to lpfc els command iocb data structure. |
| 6614 | * |
| 6615 | * This routine is used for processing the IOCB associated with a unsolicited |
| 6616 | * event. It first determines whether there is an existing ndlp that matches |
| 6617 | * the DID from the unsolicited IOCB. If not, it will create a new one with |
| 6618 | * the DID from the unsolicited IOCB. The ELS command from the unsolicited |
| 6619 | * IOCB is then used to invoke the proper routine and to set up proper state |
| 6620 | * of the discovery state machine. |
| 6621 | **/ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6622 | static void |
| 6623 | lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6624 | struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6625 | { |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6626 | struct Scsi_Host *shost; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6627 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6628 | struct ls_rjt stat; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6629 | uint32_t *payload; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6630 | uint32_t cmd, did, newnode; |
| 6631 | uint8_t rjt_exp, rjt_err = 0; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6632 | IOCB_t *icmd = &elsiocb->iocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6633 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6634 | if (!vport || !(elsiocb->context2)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6635 | goto dropit; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6636 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6637 | newnode = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6638 | payload = ((struct lpfc_dmabuf *)elsiocb->context2)->virt; |
| 6639 | cmd = *payload; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6640 | if ((phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) == 0) |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 6641 | lpfc_post_buffer(phba, pring, 1); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6642 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6643 | did = icmd->un.rcvels.remoteID; |
| 6644 | if (icmd->ulpStatus) { |
| 6645 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6646 | "RCV Unsol ELS: status:x%x/x%x did:x%x", |
| 6647 | icmd->ulpStatus, icmd->un.ulpWord[4], did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6648 | goto dropit; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6649 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6650 | |
| 6651 | /* Check to see if link went down during discovery */ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6652 | if (lpfc_els_chk_latt(vport)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6653 | goto dropit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6654 | |
James Smart | c868595 | 2009-11-18 15:39:16 -0500 | [diff] [blame] | 6655 | /* Ignore traffic received during vport shutdown. */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6656 | if (vport->load_flag & FC_UNLOADING) |
| 6657 | goto dropit; |
| 6658 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 6659 | /* If NPort discovery is delayed drop incoming ELS */ |
| 6660 | if ((vport->fc_flag & FC_DISC_DELAYED) && |
| 6661 | (cmd != ELS_CMD_PLOGI)) |
| 6662 | goto dropit; |
| 6663 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6664 | ndlp = lpfc_findnode_did(vport, did); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6665 | if (!ndlp) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6666 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6667 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6668 | if (!ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6669 | goto dropit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6670 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6671 | lpfc_nlp_init(vport, ndlp, did); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6672 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6673 | newnode = 1; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6674 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6675 | ndlp->nlp_type |= NLP_FABRIC; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 6676 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 6677 | ndlp = lpfc_enable_node(vport, ndlp, |
| 6678 | NLP_STE_UNUSED_NODE); |
| 6679 | if (!ndlp) |
| 6680 | goto dropit; |
| 6681 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 6682 | newnode = 1; |
| 6683 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
| 6684 | ndlp->nlp_type |= NLP_FABRIC; |
| 6685 | } else if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) { |
| 6686 | /* This is similar to the new node path */ |
| 6687 | ndlp = lpfc_nlp_get(ndlp); |
| 6688 | if (!ndlp) |
| 6689 | goto dropit; |
| 6690 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 6691 | newnode = 1; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6692 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6693 | |
| 6694 | phba->fc_stat.elsRcvFrame++; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6695 | |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6696 | elsiocb->context1 = lpfc_nlp_get(ndlp); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6697 | elsiocb->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6698 | |
| 6699 | if ((cmd & ELS_CMD_MASK) == ELS_CMD_RSCN) { |
| 6700 | cmd &= ELS_CMD_MASK; |
| 6701 | } |
| 6702 | /* ELS command <elsCmd> received from NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6703 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6704 | "0112 ELS command x%x received from NPORT x%x " |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 6705 | "Data: x%x x%x x%x x%x\n", |
| 6706 | cmd, did, vport->port_state, vport->fc_flag, |
| 6707 | vport->fc_myDID, vport->fc_prevDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6708 | switch (cmd) { |
| 6709 | case ELS_CMD_PLOGI: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6710 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6711 | "RCV PLOGI: did:x%x/ste:x%x flg:x%x", |
| 6712 | did, vport->port_state, ndlp->nlp_flag); |
| 6713 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6714 | phba->fc_stat.elsRcvPLOGI++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6715 | ndlp = lpfc_plogi_confirm_nport(phba, payload, ndlp); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 6716 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 6717 | (phba->pport->fc_flag & FC_PT2PT)) { |
| 6718 | vport->fc_prevDID = vport->fc_myDID; |
| 6719 | /* Our DID needs to be updated before registering |
| 6720 | * the vfi. This is done in lpfc_rcv_plogi but |
| 6721 | * that is called after the reg_vfi. |
| 6722 | */ |
| 6723 | vport->fc_myDID = elsiocb->iocb.un.rcvels.parmRo; |
| 6724 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6725 | "3312 Remote port assigned DID x%x " |
| 6726 | "%x\n", vport->fc_myDID, |
| 6727 | vport->fc_prevDID); |
| 6728 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6729 | |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6730 | lpfc_send_els_event(vport, ndlp, payload); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 6731 | |
| 6732 | /* If Nport discovery is delayed, reject PLOGIs */ |
| 6733 | if (vport->fc_flag & FC_DISC_DELAYED) { |
| 6734 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6735 | rjt_exp = LSEXP_NOTHING_MORE; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 6736 | break; |
| 6737 | } |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 6738 | shost = lpfc_shost_from_vport(vport); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6739 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 1b32f6a | 2008-02-08 18:49:39 -0500 | [diff] [blame] | 6740 | if (!(phba->pport->fc_flag & FC_PT2PT) || |
| 6741 | (phba->pport->fc_flag & FC_PT2PT_PLOGI)) { |
| 6742 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6743 | rjt_exp = LSEXP_NOTHING_MORE; |
James Smart | 1b32f6a | 2008-02-08 18:49:39 -0500 | [diff] [blame] | 6744 | break; |
| 6745 | } |
| 6746 | /* We get here, and drop thru, if we are PT2PT with |
| 6747 | * another NPort and the other side has initiated |
| 6748 | * the PLOGI before responding to our FLOGI. |
| 6749 | */ |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 6750 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 6751 | (phba->fc_topology_changed || |
| 6752 | vport->fc_myDID != vport->fc_prevDID)) { |
| 6753 | lpfc_unregister_fcf_prep(phba); |
| 6754 | spin_lock_irq(shost->host_lock); |
| 6755 | vport->fc_flag &= ~FC_VFI_REGISTERED; |
| 6756 | spin_unlock_irq(shost->host_lock); |
| 6757 | phba->fc_topology_changed = 0; |
| 6758 | lpfc_issue_reg_vfi(vport); |
| 6759 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6760 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6761 | |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6762 | spin_lock_irq(shost->host_lock); |
| 6763 | ndlp->nlp_flag &= ~NLP_TARGET_REMOVE; |
| 6764 | spin_unlock_irq(shost->host_lock); |
| 6765 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6766 | lpfc_disc_state_machine(vport, ndlp, elsiocb, |
| 6767 | NLP_EVT_RCV_PLOGI); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6768 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6769 | break; |
| 6770 | case ELS_CMD_FLOGI: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6771 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6772 | "RCV FLOGI: did:x%x/ste:x%x flg:x%x", |
| 6773 | did, vport->port_state, ndlp->nlp_flag); |
| 6774 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6775 | phba->fc_stat.elsRcvFLOGI++; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 6776 | lpfc_els_rcv_flogi(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6777 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6778 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6779 | break; |
| 6780 | case ELS_CMD_LOGO: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6781 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6782 | "RCV LOGO: did:x%x/ste:x%x flg:x%x", |
| 6783 | did, vport->port_state, ndlp->nlp_flag); |
| 6784 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6785 | phba->fc_stat.elsRcvLOGO++; |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6786 | lpfc_send_els_event(vport, ndlp, payload); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6787 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6788 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6789 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6790 | break; |
| 6791 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6792 | lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_LOGO); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6793 | break; |
| 6794 | case ELS_CMD_PRLO: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6795 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6796 | "RCV PRLO: did:x%x/ste:x%x flg:x%x", |
| 6797 | did, vport->port_state, ndlp->nlp_flag); |
| 6798 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6799 | phba->fc_stat.elsRcvPRLO++; |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6800 | lpfc_send_els_event(vport, ndlp, payload); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6801 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6802 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6803 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6804 | break; |
| 6805 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6806 | lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLO); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6807 | break; |
| 6808 | case ELS_CMD_RSCN: |
| 6809 | phba->fc_stat.elsRcvRSCN++; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 6810 | lpfc_els_rcv_rscn(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6811 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6812 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6813 | break; |
| 6814 | case ELS_CMD_ADISC: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6815 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6816 | "RCV ADISC: did:x%x/ste:x%x flg:x%x", |
| 6817 | did, vport->port_state, ndlp->nlp_flag); |
| 6818 | |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6819 | lpfc_send_els_event(vport, ndlp, payload); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6820 | phba->fc_stat.elsRcvADISC++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6821 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6822 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6823 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6824 | break; |
| 6825 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6826 | lpfc_disc_state_machine(vport, ndlp, elsiocb, |
| 6827 | NLP_EVT_RCV_ADISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6828 | break; |
| 6829 | case ELS_CMD_PDISC: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6830 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6831 | "RCV PDISC: did:x%x/ste:x%x flg:x%x", |
| 6832 | did, vport->port_state, ndlp->nlp_flag); |
| 6833 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6834 | phba->fc_stat.elsRcvPDISC++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6835 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6836 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6837 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6838 | break; |
| 6839 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6840 | lpfc_disc_state_machine(vport, ndlp, elsiocb, |
| 6841 | NLP_EVT_RCV_PDISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6842 | break; |
| 6843 | case ELS_CMD_FARPR: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6844 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6845 | "RCV FARPR: did:x%x/ste:x%x flg:x%x", |
| 6846 | did, vport->port_state, ndlp->nlp_flag); |
| 6847 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6848 | phba->fc_stat.elsRcvFARPR++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6849 | lpfc_els_rcv_farpr(vport, elsiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6850 | break; |
| 6851 | case ELS_CMD_FARP: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6852 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6853 | "RCV FARP: did:x%x/ste:x%x flg:x%x", |
| 6854 | did, vport->port_state, ndlp->nlp_flag); |
| 6855 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6856 | phba->fc_stat.elsRcvFARP++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6857 | lpfc_els_rcv_farp(vport, elsiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6858 | break; |
| 6859 | case ELS_CMD_FAN: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6860 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6861 | "RCV FAN: did:x%x/ste:x%x flg:x%x", |
| 6862 | did, vport->port_state, ndlp->nlp_flag); |
| 6863 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6864 | phba->fc_stat.elsRcvFAN++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6865 | lpfc_els_rcv_fan(vport, elsiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6866 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6867 | case ELS_CMD_PRLI: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6868 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6869 | "RCV PRLI: did:x%x/ste:x%x flg:x%x", |
| 6870 | did, vport->port_state, ndlp->nlp_flag); |
| 6871 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6872 | phba->fc_stat.elsRcvPRLI++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6873 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6874 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6875 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6876 | break; |
| 6877 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6878 | lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6879 | break; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6880 | case ELS_CMD_LIRR: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6881 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6882 | "RCV LIRR: did:x%x/ste:x%x flg:x%x", |
| 6883 | did, vport->port_state, ndlp->nlp_flag); |
| 6884 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6885 | phba->fc_stat.elsRcvLIRR++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6886 | lpfc_els_rcv_lirr(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6887 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6888 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6889 | break; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6890 | case ELS_CMD_RLS: |
| 6891 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6892 | "RCV RLS: did:x%x/ste:x%x flg:x%x", |
| 6893 | did, vport->port_state, ndlp->nlp_flag); |
| 6894 | |
| 6895 | phba->fc_stat.elsRcvRLS++; |
| 6896 | lpfc_els_rcv_rls(vport, elsiocb, ndlp); |
| 6897 | if (newnode) |
| 6898 | lpfc_nlp_put(ndlp); |
| 6899 | break; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6900 | case ELS_CMD_RPS: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6901 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6902 | "RCV RPS: did:x%x/ste:x%x flg:x%x", |
| 6903 | did, vport->port_state, ndlp->nlp_flag); |
| 6904 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6905 | phba->fc_stat.elsRcvRPS++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6906 | lpfc_els_rcv_rps(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6907 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6908 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6909 | break; |
| 6910 | case ELS_CMD_RPL: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6911 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6912 | "RCV RPL: did:x%x/ste:x%x flg:x%x", |
| 6913 | did, vport->port_state, ndlp->nlp_flag); |
| 6914 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6915 | phba->fc_stat.elsRcvRPL++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6916 | lpfc_els_rcv_rpl(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6917 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6918 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6919 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6920 | case ELS_CMD_RNID: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6921 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6922 | "RCV RNID: did:x%x/ste:x%x flg:x%x", |
| 6923 | did, vport->port_state, ndlp->nlp_flag); |
| 6924 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6925 | phba->fc_stat.elsRcvRNID++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6926 | lpfc_els_rcv_rnid(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6927 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6928 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6929 | break; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6930 | case ELS_CMD_RTV: |
| 6931 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6932 | "RCV RTV: did:x%x/ste:x%x flg:x%x", |
| 6933 | did, vport->port_state, ndlp->nlp_flag); |
| 6934 | phba->fc_stat.elsRcvRTV++; |
| 6935 | lpfc_els_rcv_rtv(vport, elsiocb, ndlp); |
| 6936 | if (newnode) |
| 6937 | lpfc_nlp_put(ndlp); |
| 6938 | break; |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 6939 | case ELS_CMD_RRQ: |
| 6940 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6941 | "RCV RRQ: did:x%x/ste:x%x flg:x%x", |
| 6942 | did, vport->port_state, ndlp->nlp_flag); |
| 6943 | |
| 6944 | phba->fc_stat.elsRcvRRQ++; |
| 6945 | lpfc_els_rcv_rrq(vport, elsiocb, ndlp); |
| 6946 | if (newnode) |
| 6947 | lpfc_nlp_put(ndlp); |
| 6948 | break; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6949 | case ELS_CMD_ECHO: |
| 6950 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6951 | "RCV ECHO: did:x%x/ste:x%x flg:x%x", |
| 6952 | did, vport->port_state, ndlp->nlp_flag); |
| 6953 | |
| 6954 | phba->fc_stat.elsRcvECHO++; |
| 6955 | lpfc_els_rcv_echo(vport, elsiocb, ndlp); |
| 6956 | if (newnode) |
| 6957 | lpfc_nlp_put(ndlp); |
| 6958 | break; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6959 | case ELS_CMD_REC: |
| 6960 | /* receive this due to exchange closed */ |
| 6961 | rjt_err = LSRJT_UNABLE_TPC; |
| 6962 | rjt_exp = LSEXP_INVALID_OX_RX; |
| 6963 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6964 | default: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6965 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6966 | "RCV ELS cmd: cmd:x%x did:x%x/ste:x%x", |
| 6967 | cmd, did, vport->port_state); |
| 6968 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6969 | /* Unsupported ELS command, reject */ |
James Smart | 63e801c | 2010-11-20 23:14:19 -0500 | [diff] [blame] | 6970 | rjt_err = LSRJT_CMD_UNSUPPORTED; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6971 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6972 | |
| 6973 | /* Unknown ELS command <elsCmd> received from NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6974 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6975 | "0115 Unknown ELS command x%x " |
| 6976 | "received from NPORT x%x\n", cmd, did); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6977 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6978 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6979 | break; |
| 6980 | } |
| 6981 | |
| 6982 | /* check if need to LS_RJT received ELS cmd */ |
| 6983 | if (rjt_err) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6984 | memset(&stat, 0, sizeof(stat)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6985 | stat.un.b.lsRjtRsnCode = rjt_err; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6986 | stat.un.b.lsRjtRsnCodeExp = rjt_exp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6987 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp, |
| 6988 | NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6989 | } |
| 6990 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6991 | lpfc_nlp_put(elsiocb->context1); |
| 6992 | elsiocb->context1 = NULL; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6993 | return; |
| 6994 | |
| 6995 | dropit: |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6996 | if (vport && !(vport->load_flag & FC_UNLOADING)) |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6997 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6998 | "0111 Dropping received ELS cmd " |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6999 | "Data: x%x x%x x%x\n", |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7000 | icmd->ulpStatus, icmd->un.ulpWord[4], icmd->ulpTimeout); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7001 | phba->fc_stat.elsRcvDrop++; |
| 7002 | } |
| 7003 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7004 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7005 | * lpfc_els_unsol_event - Process an unsolicited event from an els sli ring |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7006 | * @phba: pointer to lpfc hba data structure. |
| 7007 | * @pring: pointer to a SLI ring. |
| 7008 | * @elsiocb: pointer to lpfc els iocb data structure. |
| 7009 | * |
| 7010 | * This routine is used to process an unsolicited event received from a SLI |
| 7011 | * (Service Level Interface) ring. The actual processing of the data buffer |
| 7012 | * associated with the unsolicited event is done by invoking the routine |
| 7013 | * lpfc_els_unsol_buffer() after properly set up the iocb buffer from the |
| 7014 | * SLI ring on which the unsolicited event was received. |
| 7015 | **/ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7016 | void |
| 7017 | lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
| 7018 | struct lpfc_iocbq *elsiocb) |
| 7019 | { |
| 7020 | struct lpfc_vport *vport = phba->pport; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7021 | IOCB_t *icmd = &elsiocb->iocb; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7022 | dma_addr_t paddr; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7023 | struct lpfc_dmabuf *bdeBuf1 = elsiocb->context2; |
| 7024 | struct lpfc_dmabuf *bdeBuf2 = elsiocb->context3; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7025 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7026 | elsiocb->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7027 | elsiocb->context2 = NULL; |
| 7028 | elsiocb->context3 = NULL; |
| 7029 | |
| 7030 | if (icmd->ulpStatus == IOSTAT_NEED_BUFFER) { |
| 7031 | lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ); |
| 7032 | } else if (icmd->ulpStatus == IOSTAT_LOCAL_REJECT && |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 7033 | (icmd->un.ulpWord[4] & IOERR_PARAM_MASK) == |
| 7034 | IOERR_RCV_BUFFER_WAITING) { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7035 | phba->fc_stat.NoRcvBuf++; |
| 7036 | /* Not enough posted buffers; Try posting more buffers */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7037 | if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)) |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 7038 | lpfc_post_buffer(phba, pring, 0); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7039 | return; |
| 7040 | } |
| 7041 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7042 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
| 7043 | (icmd->ulpCommand == CMD_IOCB_RCV_ELS64_CX || |
| 7044 | icmd->ulpCommand == CMD_IOCB_RCV_SEQ64_CX)) { |
| 7045 | if (icmd->unsli3.rcvsli3.vpi == 0xffff) |
| 7046 | vport = phba->pport; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7047 | else |
| 7048 | vport = lpfc_find_vport_by_vpid(phba, |
James Smart | 6d368e5 | 2011-05-24 11:44:12 -0400 | [diff] [blame] | 7049 | icmd->unsli3.rcvsli3.vpi); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7050 | } |
James Smart | 6d368e5 | 2011-05-24 11:44:12 -0400 | [diff] [blame] | 7051 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7052 | /* If there are no BDEs associated |
| 7053 | * with this IOCB, there is nothing to do. |
| 7054 | */ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7055 | if (icmd->ulpBdeCount == 0) |
| 7056 | return; |
| 7057 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7058 | /* type of ELS cmd is first 32bit word |
| 7059 | * in packet |
| 7060 | */ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7061 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7062 | elsiocb->context2 = bdeBuf1; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7063 | } else { |
| 7064 | paddr = getPaddr(icmd->un.cont64[0].addrHigh, |
| 7065 | icmd->un.cont64[0].addrLow); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7066 | elsiocb->context2 = lpfc_sli_ringpostbuf_get(phba, pring, |
| 7067 | paddr); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7068 | } |
| 7069 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7070 | lpfc_els_unsol_buffer(phba, pring, vport, elsiocb); |
| 7071 | /* |
| 7072 | * The different unsolicited event handlers would tell us |
| 7073 | * if they are done with "mp" by setting context2 to NULL. |
| 7074 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7075 | if (elsiocb->context2) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7076 | lpfc_in_buf_free(phba, (struct lpfc_dmabuf *)elsiocb->context2); |
| 7077 | elsiocb->context2 = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7078 | } |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7079 | |
| 7080 | /* RCV_ELS64_CX provide for 2 BDEs - process 2nd if included */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7081 | if ((phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) && |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7082 | icmd->ulpBdeCount == 2) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7083 | elsiocb->context2 = bdeBuf2; |
| 7084 | lpfc_els_unsol_buffer(phba, pring, vport, elsiocb); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7085 | /* free mp if we are done with it */ |
| 7086 | if (elsiocb->context2) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7087 | lpfc_in_buf_free(phba, elsiocb->context2); |
| 7088 | elsiocb->context2 = NULL; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7089 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7090 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7091 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7092 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7093 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7094 | * lpfc_do_scr_ns_plogi - Issue a plogi to the name server for scr |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7095 | * @phba: pointer to lpfc hba data structure. |
| 7096 | * @vport: pointer to a virtual N_Port data structure. |
| 7097 | * |
| 7098 | * This routine issues a Port Login (PLOGI) to the Name Server with |
| 7099 | * State Change Request (SCR) for a @vport. This routine will create an |
| 7100 | * ndlp for the Name Server associated to the @vport if such node does |
| 7101 | * not already exist. The PLOGI to Name Server is issued by invoking the |
| 7102 | * lpfc_issue_els_plogi() routine. If Fabric-Device Management Interface |
| 7103 | * (FDMI) is configured to the @vport, a FDMI node will be created and |
| 7104 | * the PLOGI to FDMI is issued by invoking lpfc_issue_els_plogi() routine. |
| 7105 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7106 | void |
| 7107 | lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport) |
| 7108 | { |
| 7109 | struct lpfc_nodelist *ndlp, *ndlp_fdmi; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7110 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 7111 | |
| 7112 | /* |
| 7113 | * If lpfc_delay_discovery parameter is set and the clean address |
| 7114 | * bit is cleared and fc fabric parameters chenged, delay FC NPort |
| 7115 | * discovery. |
| 7116 | */ |
| 7117 | spin_lock_irq(shost->host_lock); |
| 7118 | if (vport->fc_flag & FC_DISC_DELAYED) { |
| 7119 | spin_unlock_irq(shost->host_lock); |
James Smart | 1877570 | 2013-04-17 20:19:25 -0400 | [diff] [blame] | 7120 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, |
| 7121 | "3334 Delay fc port discovery for %d seconds\n", |
| 7122 | phba->fc_ratov); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7123 | mod_timer(&vport->delayed_disc_tmo, |
James Smart | 256ec0d | 2013-04-17 20:14:58 -0400 | [diff] [blame] | 7124 | jiffies + msecs_to_jiffies(1000 * phba->fc_ratov)); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7125 | return; |
| 7126 | } |
| 7127 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7128 | |
| 7129 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
| 7130 | if (!ndlp) { |
| 7131 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 7132 | if (!ndlp) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 7133 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7134 | lpfc_disc_start(vport); |
| 7135 | return; |
| 7136 | } |
| 7137 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7138 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7139 | "0251 NameServer login: no memory\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7140 | return; |
| 7141 | } |
| 7142 | lpfc_nlp_init(vport, ndlp, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 7143 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 7144 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 7145 | if (!ndlp) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 7146 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 7147 | lpfc_disc_start(vport); |
| 7148 | return; |
| 7149 | } |
| 7150 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 7151 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7152 | "0348 NameServer login: node freed\n"); |
| 7153 | return; |
| 7154 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7155 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 7156 | ndlp->nlp_type |= NLP_FABRIC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7157 | |
| 7158 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
| 7159 | |
| 7160 | if (lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0)) { |
| 7161 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7162 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7163 | "0252 Cannot issue NameServer login\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7164 | return; |
| 7165 | } |
| 7166 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 7167 | if (vport->cfg_fdmi_on) { |
James Smart | 63e801c | 2010-11-20 23:14:19 -0500 | [diff] [blame] | 7168 | /* If this is the first time, allocate an ndlp and initialize |
| 7169 | * it. Otherwise, make sure the node is enabled and then do the |
| 7170 | * login. |
| 7171 | */ |
| 7172 | ndlp_fdmi = lpfc_findnode_did(vport, FDMI_DID); |
| 7173 | if (!ndlp_fdmi) { |
| 7174 | ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool, |
| 7175 | GFP_KERNEL); |
| 7176 | if (ndlp_fdmi) { |
| 7177 | lpfc_nlp_init(vport, ndlp_fdmi, FDMI_DID); |
| 7178 | ndlp_fdmi->nlp_type |= NLP_FABRIC; |
| 7179 | } else |
| 7180 | return; |
| 7181 | } |
| 7182 | if (!NLP_CHK_NODE_ACT(ndlp_fdmi)) |
| 7183 | ndlp_fdmi = lpfc_enable_node(vport, |
| 7184 | ndlp_fdmi, |
| 7185 | NLP_STE_NPR_NODE); |
| 7186 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7187 | if (ndlp_fdmi) { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 7188 | lpfc_nlp_set_state(vport, ndlp_fdmi, |
James Smart | 63e801c | 2010-11-20 23:14:19 -0500 | [diff] [blame] | 7189 | NLP_STE_PLOGI_ISSUE); |
| 7190 | lpfc_issue_els_plogi(vport, ndlp_fdmi->nlp_DID, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7191 | } |
| 7192 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7193 | } |
| 7194 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7195 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7196 | * lpfc_cmpl_reg_new_vport - Completion callback function to register new vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7197 | * @phba: pointer to lpfc hba data structure. |
| 7198 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 7199 | * |
| 7200 | * This routine is the completion callback function to register new vport |
| 7201 | * mailbox command. If the new vport mailbox command completes successfully, |
| 7202 | * the fabric registration login shall be performed on physical port (the |
| 7203 | * new vport created is actually a physical port, with VPI 0) or the port |
| 7204 | * login to Name Server for State Change Request (SCR) will be performed |
| 7205 | * on virtual port (real virtual port, with VPI greater than 0). |
| 7206 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7207 | static void |
| 7208 | lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
| 7209 | { |
| 7210 | struct lpfc_vport *vport = pmb->vport; |
| 7211 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 7212 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2; |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 7213 | MAILBOX_t *mb = &pmb->u.mb; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7214 | int rc; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7215 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7216 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7217 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7218 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7219 | |
| 7220 | if (mb->mbxStatus) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7221 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 7222 | "0915 Register VPI failed : Status: x%x" |
| 7223 | " upd bit: x%x \n", mb->mbxStatus, |
| 7224 | mb->un.varRegVpi.upd); |
| 7225 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 7226 | mb->un.varRegVpi.upd) |
| 7227 | goto mbox_err_exit ; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7228 | |
| 7229 | switch (mb->mbxStatus) { |
| 7230 | case 0x11: /* unsupported feature */ |
| 7231 | case 0x9603: /* max_vpi exceeded */ |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7232 | case 0x9602: /* Link event since CLEAR_LA */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7233 | /* giving up on vport registration */ |
| 7234 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 7235 | spin_lock_irq(shost->host_lock); |
| 7236 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
| 7237 | spin_unlock_irq(shost->host_lock); |
| 7238 | lpfc_can_disctmo(vport); |
| 7239 | break; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7240 | /* If reg_vpi fail with invalid VPI status, re-init VPI */ |
| 7241 | case 0x20: |
| 7242 | spin_lock_irq(shost->host_lock); |
| 7243 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
| 7244 | spin_unlock_irq(shost->host_lock); |
| 7245 | lpfc_init_vpi(phba, pmb, vport->vpi); |
| 7246 | pmb->vport = vport; |
| 7247 | pmb->mbox_cmpl = lpfc_init_vpi_cmpl; |
| 7248 | rc = lpfc_sli_issue_mbox(phba, pmb, |
| 7249 | MBX_NOWAIT); |
| 7250 | if (rc == MBX_NOT_FINISHED) { |
| 7251 | lpfc_printf_vlog(vport, |
| 7252 | KERN_ERR, LOG_MBOX, |
| 7253 | "2732 Failed to issue INIT_VPI" |
| 7254 | " mailbox command\n"); |
| 7255 | } else { |
| 7256 | lpfc_nlp_put(ndlp); |
| 7257 | return; |
| 7258 | } |
| 7259 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7260 | default: |
| 7261 | /* Try to recover from this error */ |
James Smart | 5af5eee | 2010-10-22 11:06:38 -0400 | [diff] [blame] | 7262 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 7263 | lpfc_sli4_unreg_all_rpis(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7264 | lpfc_mbx_unreg_vpi(vport); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7265 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7266 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7267 | spin_unlock_irq(shost->host_lock); |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 7268 | if (vport->port_type == LPFC_PHYSICAL_PORT |
| 7269 | && !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 7270 | lpfc_issue_init_vfi(vport); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7271 | else |
| 7272 | lpfc_initial_fdisc(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7273 | break; |
| 7274 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7275 | } else { |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7276 | spin_lock_irq(shost->host_lock); |
James Smart | 1987807 | 2009-12-21 17:02:00 -0500 | [diff] [blame] | 7277 | vport->vpi_state |= LPFC_VPI_REGISTERED; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7278 | spin_unlock_irq(shost->host_lock); |
| 7279 | if (vport == phba->pport) { |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7280 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 7281 | lpfc_issue_fabric_reglogin(vport); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7282 | else { |
James Smart | fc2b989 | 2010-02-26 14:15:29 -0500 | [diff] [blame] | 7283 | /* |
| 7284 | * If the physical port is instantiated using |
| 7285 | * FDISC, do not start vport discovery. |
| 7286 | */ |
| 7287 | if (vport->port_state != LPFC_FDISC) |
| 7288 | lpfc_start_fdiscs(phba); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7289 | lpfc_do_scr_ns_plogi(phba, vport); |
| 7290 | } |
| 7291 | } else |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7292 | lpfc_do_scr_ns_plogi(phba, vport); |
| 7293 | } |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 7294 | mbox_err_exit: |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 7295 | /* Now, we decrement the ndlp reference count held for this |
| 7296 | * callback function |
| 7297 | */ |
| 7298 | lpfc_nlp_put(ndlp); |
| 7299 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7300 | mempool_free(pmb, phba->mbox_mem_pool); |
| 7301 | return; |
| 7302 | } |
| 7303 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7304 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7305 | * lpfc_register_new_vport - Register a new vport with a HBA |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7306 | * @phba: pointer to lpfc hba data structure. |
| 7307 | * @vport: pointer to a host virtual N_Port data structure. |
| 7308 | * @ndlp: pointer to a node-list data structure. |
| 7309 | * |
| 7310 | * This routine registers the @vport as a new virtual port with a HBA. |
| 7311 | * It is done through a registering vpi mailbox command. |
| 7312 | **/ |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7313 | void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7314 | lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport, |
| 7315 | struct lpfc_nodelist *ndlp) |
| 7316 | { |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7317 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7318 | LPFC_MBOXQ_t *mbox; |
| 7319 | |
| 7320 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 7321 | if (mbox) { |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7322 | lpfc_reg_vpi(vport, mbox); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7323 | mbox->vport = vport; |
| 7324 | mbox->context2 = lpfc_nlp_get(ndlp); |
| 7325 | mbox->mbox_cmpl = lpfc_cmpl_reg_new_vport; |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 7326 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7327 | == MBX_NOT_FINISHED) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 7328 | /* mailbox command not success, decrement ndlp |
| 7329 | * reference count for this command |
| 7330 | */ |
| 7331 | lpfc_nlp_put(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7332 | mempool_free(mbox, phba->mbox_mem_pool); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7333 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7334 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
| 7335 | "0253 Register VPI: Can't send mbox\n"); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 7336 | goto mbox_err_exit; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7337 | } |
| 7338 | } else { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7339 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
| 7340 | "0254 Register VPI: no memory\n"); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 7341 | goto mbox_err_exit; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7342 | } |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 7343 | return; |
| 7344 | |
| 7345 | mbox_err_exit: |
| 7346 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 7347 | spin_lock_irq(shost->host_lock); |
| 7348 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; |
| 7349 | spin_unlock_irq(shost->host_lock); |
| 7350 | return; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7351 | } |
| 7352 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7353 | /** |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 7354 | * lpfc_cancel_all_vport_retry_delay_timer - Cancel all vport retry delay timer |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7355 | * @phba: pointer to lpfc hba data structure. |
| 7356 | * |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 7357 | * This routine cancels the retry delay timers to all the vports. |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7358 | **/ |
| 7359 | void |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 7360 | lpfc_cancel_all_vport_retry_delay_timer(struct lpfc_hba *phba) |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7361 | { |
| 7362 | struct lpfc_vport **vports; |
| 7363 | struct lpfc_nodelist *ndlp; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7364 | uint32_t link_state; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 7365 | int i; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7366 | |
| 7367 | /* Treat this failure as linkdown for all vports */ |
| 7368 | link_state = phba->link_state; |
| 7369 | lpfc_linkdown(phba); |
| 7370 | phba->link_state = link_state; |
| 7371 | |
| 7372 | vports = lpfc_create_vport_work_array(phba); |
| 7373 | |
| 7374 | if (vports) { |
| 7375 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
| 7376 | ndlp = lpfc_findnode_did(vports[i], Fabric_DID); |
| 7377 | if (ndlp) |
| 7378 | lpfc_cancel_retry_delay_tmo(vports[i], ndlp); |
| 7379 | lpfc_els_flush_cmd(vports[i]); |
| 7380 | } |
| 7381 | lpfc_destroy_vport_work_array(phba, vports); |
| 7382 | } |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 7383 | } |
| 7384 | |
| 7385 | /** |
| 7386 | * lpfc_retry_pport_discovery - Start timer to retry FLOGI. |
| 7387 | * @phba: pointer to lpfc hba data structure. |
| 7388 | * |
| 7389 | * This routine abort all pending discovery commands and |
| 7390 | * start a timer to retry FLOGI for the physical port |
| 7391 | * discovery. |
| 7392 | **/ |
| 7393 | void |
| 7394 | lpfc_retry_pport_discovery(struct lpfc_hba *phba) |
| 7395 | { |
| 7396 | struct lpfc_nodelist *ndlp; |
| 7397 | struct Scsi_Host *shost; |
| 7398 | |
| 7399 | /* Cancel the all vports retry delay retry timers */ |
| 7400 | lpfc_cancel_all_vport_retry_delay_timer(phba); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7401 | |
| 7402 | /* If fabric require FLOGI, then re-instantiate physical login */ |
| 7403 | ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); |
| 7404 | if (!ndlp) |
| 7405 | return; |
| 7406 | |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7407 | shost = lpfc_shost_from_vport(phba->pport); |
James Smart | 256ec0d | 2013-04-17 20:14:58 -0400 | [diff] [blame] | 7408 | mod_timer(&ndlp->nlp_delayfunc, jiffies + msecs_to_jiffies(1000)); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7409 | spin_lock_irq(shost->host_lock); |
| 7410 | ndlp->nlp_flag |= NLP_DELAY_TMO; |
| 7411 | spin_unlock_irq(shost->host_lock); |
| 7412 | ndlp->nlp_last_elscmd = ELS_CMD_FLOGI; |
| 7413 | phba->pport->port_state = LPFC_FLOGI; |
| 7414 | return; |
| 7415 | } |
| 7416 | |
| 7417 | /** |
| 7418 | * lpfc_fabric_login_reqd - Check if FLOGI required. |
| 7419 | * @phba: pointer to lpfc hba data structure. |
| 7420 | * @cmdiocb: pointer to FDISC command iocb. |
| 7421 | * @rspiocb: pointer to FDISC response iocb. |
| 7422 | * |
| 7423 | * This routine checks if a FLOGI is reguired for FDISC |
| 7424 | * to succeed. |
| 7425 | **/ |
| 7426 | static int |
| 7427 | lpfc_fabric_login_reqd(struct lpfc_hba *phba, |
| 7428 | struct lpfc_iocbq *cmdiocb, |
| 7429 | struct lpfc_iocbq *rspiocb) |
| 7430 | { |
| 7431 | |
| 7432 | if ((rspiocb->iocb.ulpStatus != IOSTAT_FABRIC_RJT) || |
| 7433 | (rspiocb->iocb.un.ulpWord[4] != RJT_LOGIN_REQUIRED)) |
| 7434 | return 0; |
| 7435 | else |
| 7436 | return 1; |
| 7437 | } |
| 7438 | |
| 7439 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7440 | * lpfc_cmpl_els_fdisc - Completion function for fdisc iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7441 | * @phba: pointer to lpfc hba data structure. |
| 7442 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 7443 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 7444 | * |
| 7445 | * This routine is the completion callback function to a Fabric Discover |
| 7446 | * (FDISC) ELS command. Since all the FDISC ELS commands are issued |
| 7447 | * single threaded, each FDISC completion callback function will reset |
| 7448 | * the discovery timer for all vports such that the timers will not get |
| 7449 | * unnecessary timeout. The function checks the FDISC IOCB status. If error |
| 7450 | * detected, the vport will be set to FC_VPORT_FAILED state. Otherwise,the |
| 7451 | * vport will set to FC_VPORT_ACTIVE state. It then checks whether the DID |
| 7452 | * assigned to the vport has been changed with the completion of the FDISC |
| 7453 | * command. If so, both RPI (Remote Port Index) and VPI (Virtual Port Index) |
| 7454 | * are unregistered from the HBA, and then the lpfc_register_new_vport() |
| 7455 | * routine is invoked to register new vport with the HBA. Otherwise, the |
| 7456 | * lpfc_do_scr_ns_plogi() routine is invoked to issue a PLOGI to the Name |
| 7457 | * Server for State Change Request (SCR). |
| 7458 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7459 | static void |
| 7460 | lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 7461 | struct lpfc_iocbq *rspiocb) |
| 7462 | { |
| 7463 | struct lpfc_vport *vport = cmdiocb->vport; |
| 7464 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 7465 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 7466 | struct lpfc_nodelist *np; |
| 7467 | struct lpfc_nodelist *next_np; |
| 7468 | IOCB_t *irsp = &rspiocb->iocb; |
| 7469 | struct lpfc_iocbq *piocb; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7470 | struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp; |
| 7471 | struct serv_parm *sp; |
| 7472 | uint8_t fabric_param_changed; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7473 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7474 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 7475 | "0123 FDISC completes. x%x/x%x prevDID: x%x\n", |
| 7476 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 7477 | vport->fc_prevDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7478 | /* Since all FDISCs are being single threaded, we |
| 7479 | * must reset the discovery timer for ALL vports |
| 7480 | * waiting to send FDISC when one completes. |
| 7481 | */ |
| 7482 | list_for_each_entry(piocb, &phba->fabric_iocb_list, list) { |
| 7483 | lpfc_set_disctmo(piocb->vport); |
| 7484 | } |
| 7485 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7486 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 7487 | "FDISC cmpl: status:x%x/x%x prevdid:x%x", |
| 7488 | irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_prevDID); |
| 7489 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7490 | if (irsp->ulpStatus) { |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7491 | |
| 7492 | if (lpfc_fabric_login_reqd(phba, cmdiocb, rspiocb)) { |
| 7493 | lpfc_retry_pport_discovery(phba); |
| 7494 | goto out; |
| 7495 | } |
| 7496 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7497 | /* Check for retry */ |
| 7498 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) |
| 7499 | goto out; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7500 | /* FDISC failed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7501 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 7502 | "0126 FDISC failed. (x%x/x%x)\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7503 | irsp->ulpStatus, irsp->un.ulpWord[4]); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7504 | goto fdisc_failed; |
| 7505 | } |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7506 | spin_lock_irq(shost->host_lock); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7507 | vport->fc_flag &= ~FC_VPORT_CVL_RCVD; |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 7508 | vport->fc_flag &= ~FC_VPORT_LOGO_RCVD; |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7509 | vport->fc_flag |= FC_FABRIC; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 7510 | if (vport->phba->fc_topology == LPFC_TOPOLOGY_LOOP) |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7511 | vport->fc_flag |= FC_PUBLIC_LOOP; |
| 7512 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7513 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7514 | vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID; |
| 7515 | lpfc_vport_set_state(vport, FC_VPORT_ACTIVE); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7516 | prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list); |
| 7517 | sp = prsp->virt + sizeof(uint32_t); |
| 7518 | fabric_param_changed = lpfc_check_clean_addr_bit(vport, sp); |
| 7519 | memcpy(&vport->fabric_portname, &sp->portName, |
| 7520 | sizeof(struct lpfc_name)); |
| 7521 | memcpy(&vport->fabric_nodename, &sp->nodeName, |
| 7522 | sizeof(struct lpfc_name)); |
| 7523 | if (fabric_param_changed && |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7524 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 7525 | /* If our NportID changed, we need to ensure all |
| 7526 | * remaining NPORTs get unreg_login'ed so we can |
| 7527 | * issue unreg_vpi. |
| 7528 | */ |
| 7529 | list_for_each_entry_safe(np, next_np, |
| 7530 | &vport->fc_nodes, nlp_listp) { |
| 7531 | if (!NLP_CHK_NODE_ACT(ndlp) || |
| 7532 | (np->nlp_state != NLP_STE_NPR_NODE) || |
| 7533 | !(np->nlp_flag & NLP_NPR_ADISC)) |
| 7534 | continue; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7535 | spin_lock_irq(shost->host_lock); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7536 | np->nlp_flag &= ~NLP_NPR_ADISC; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7537 | spin_unlock_irq(shost->host_lock); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7538 | lpfc_unreg_rpi(vport, np); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7539 | } |
James Smart | 78730cf | 2010-04-06 15:06:30 -0400 | [diff] [blame] | 7540 | lpfc_cleanup_pending_mbox(vport); |
James Smart | 5af5eee | 2010-10-22 11:06:38 -0400 | [diff] [blame] | 7541 | |
| 7542 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 7543 | lpfc_sli4_unreg_all_rpis(vport); |
| 7544 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7545 | lpfc_mbx_unreg_vpi(vport); |
| 7546 | spin_lock_irq(shost->host_lock); |
| 7547 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 7548 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 7549 | vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 7550 | else |
| 7551 | vport->fc_flag |= FC_LOGO_RCVD_DID_CHNG; |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7552 | spin_unlock_irq(shost->host_lock); |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 7553 | } else if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 7554 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 7555 | /* |
| 7556 | * Driver needs to re-reg VPI in order for f/w |
| 7557 | * to update the MAC address. |
| 7558 | */ |
| 7559 | lpfc_register_new_vport(phba, vport, ndlp); |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 7560 | goto out; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7561 | } |
| 7562 | |
James Smart | ecfd03c | 2010-02-12 14:41:27 -0500 | [diff] [blame] | 7563 | if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI) |
| 7564 | lpfc_issue_init_vpi(vport); |
| 7565 | else if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7566 | lpfc_register_new_vport(phba, vport, ndlp); |
| 7567 | else |
| 7568 | lpfc_do_scr_ns_plogi(phba, vport); |
| 7569 | goto out; |
| 7570 | fdisc_failed: |
| 7571 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 7572 | /* Cancel discovery timer */ |
| 7573 | lpfc_can_disctmo(vport); |
| 7574 | lpfc_nlp_put(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7575 | out: |
| 7576 | lpfc_els_free_iocb(phba, cmdiocb); |
| 7577 | } |
| 7578 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7579 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7580 | * lpfc_issue_els_fdisc - Issue a fdisc iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7581 | * @vport: pointer to a virtual N_Port data structure. |
| 7582 | * @ndlp: pointer to a node-list data structure. |
| 7583 | * @retry: number of retries to the command IOCB. |
| 7584 | * |
| 7585 | * This routine prepares and issues a Fabric Discover (FDISC) IOCB to |
| 7586 | * a remote node (@ndlp) off a @vport. It uses the lpfc_issue_fabric_iocb() |
| 7587 | * routine to issue the IOCB, which makes sure only one outstanding fabric |
| 7588 | * IOCB will be sent off HBA at any given time. |
| 7589 | * |
| 7590 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 7591 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 7592 | * will be stored into the context1 field of the IOCB for the completion |
| 7593 | * callback function to the FDISC ELS command. |
| 7594 | * |
| 7595 | * Return code |
| 7596 | * 0 - Successfully issued fdisc iocb command |
| 7597 | * 1 - Failed to issue fdisc iocb command |
| 7598 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 7599 | static int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7600 | lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 7601 | uint8_t retry) |
| 7602 | { |
| 7603 | struct lpfc_hba *phba = vport->phba; |
| 7604 | IOCB_t *icmd; |
| 7605 | struct lpfc_iocbq *elsiocb; |
| 7606 | struct serv_parm *sp; |
| 7607 | uint8_t *pcmd; |
| 7608 | uint16_t cmdsize; |
| 7609 | int did = ndlp->nlp_DID; |
| 7610 | int rc; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7611 | |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 7612 | vport->port_state = LPFC_FDISC; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 7613 | vport->fc_myDID = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7614 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
| 7615 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did, |
| 7616 | ELS_CMD_FDISC); |
| 7617 | if (!elsiocb) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7618 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7619 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7620 | "0255 Issue FDISC: no IOCB\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7621 | return 1; |
| 7622 | } |
| 7623 | |
| 7624 | icmd = &elsiocb->iocb; |
| 7625 | icmd->un.elsreq64.myID = 0; |
| 7626 | icmd->un.elsreq64.fl = 1; |
| 7627 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 7628 | /* |
| 7629 | * SLI3 ports require a different context type value than SLI4. |
| 7630 | * Catch SLI3 ports here and override the prep. |
| 7631 | */ |
| 7632 | if (phba->sli_rev == LPFC_SLI_REV3) { |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 7633 | icmd->ulpCt_h = 1; |
| 7634 | icmd->ulpCt_l = 0; |
| 7635 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7636 | |
| 7637 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 7638 | *((uint32_t *) (pcmd)) = ELS_CMD_FDISC; |
| 7639 | pcmd += sizeof(uint32_t); /* CSP Word 1 */ |
| 7640 | memcpy(pcmd, &vport->phba->pport->fc_sparam, sizeof(struct serv_parm)); |
| 7641 | sp = (struct serv_parm *) pcmd; |
| 7642 | /* Setup CSPs accordingly for Fabric */ |
| 7643 | sp->cmn.e_d_tov = 0; |
| 7644 | sp->cmn.w2.r_a_tov = 0; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 7645 | sp->cmn.virtual_fabric_support = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7646 | sp->cls1.classValid = 0; |
| 7647 | sp->cls2.seqDelivery = 1; |
| 7648 | sp->cls3.seqDelivery = 1; |
| 7649 | |
| 7650 | pcmd += sizeof(uint32_t); /* CSP Word 2 */ |
| 7651 | pcmd += sizeof(uint32_t); /* CSP Word 3 */ |
| 7652 | pcmd += sizeof(uint32_t); /* CSP Word 4 */ |
| 7653 | pcmd += sizeof(uint32_t); /* Port Name */ |
| 7654 | memcpy(pcmd, &vport->fc_portname, 8); |
| 7655 | pcmd += sizeof(uint32_t); /* Node Name */ |
| 7656 | pcmd += sizeof(uint32_t); /* Node Name */ |
| 7657 | memcpy(pcmd, &vport->fc_nodename, 8); |
| 7658 | |
| 7659 | lpfc_set_disctmo(vport); |
| 7660 | |
| 7661 | phba->fc_stat.elsXmitFDISC++; |
| 7662 | elsiocb->iocb_cmpl = lpfc_cmpl_els_fdisc; |
| 7663 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7664 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 7665 | "Issue FDISC: did:x%x", |
| 7666 | did, 0, 0); |
| 7667 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7668 | rc = lpfc_issue_fabric_iocb(phba, elsiocb); |
| 7669 | if (rc == IOCB_ERROR) { |
| 7670 | lpfc_els_free_iocb(phba, elsiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7671 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7672 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7673 | "0256 Issue FDISC: Cannot send IOCB\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7674 | return 1; |
| 7675 | } |
| 7676 | lpfc_vport_set_state(vport, FC_VPORT_INITIALIZING); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7677 | return 0; |
| 7678 | } |
| 7679 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7680 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7681 | * lpfc_cmpl_els_npiv_logo - Completion function with vport logo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7682 | * @phba: pointer to lpfc hba data structure. |
| 7683 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 7684 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 7685 | * |
| 7686 | * This routine is the completion callback function to the issuing of a LOGO |
| 7687 | * ELS command off a vport. It frees the command IOCB and then decrement the |
| 7688 | * reference count held on ndlp for this completion function, indicating that |
| 7689 | * the reference to the ndlp is no long needed. Note that the |
| 7690 | * lpfc_els_free_iocb() routine decrements the ndlp reference held for this |
| 7691 | * callback function and an additional explicit ndlp reference decrementation |
| 7692 | * will trigger the actual release of the ndlp. |
| 7693 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7694 | static void |
| 7695 | lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 7696 | struct lpfc_iocbq *rspiocb) |
| 7697 | { |
| 7698 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7699 | IOCB_t *irsp; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 7700 | struct lpfc_nodelist *ndlp; |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 7701 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7702 | |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 7703 | ndlp = (struct lpfc_nodelist *)cmdiocb->context1; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7704 | irsp = &rspiocb->iocb; |
| 7705 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 7706 | "LOGO npiv cmpl: status:x%x/x%x did:x%x", |
| 7707 | irsp->ulpStatus, irsp->un.ulpWord[4], irsp->un.rcvels.remoteID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7708 | |
| 7709 | lpfc_els_free_iocb(phba, cmdiocb); |
| 7710 | vport->unreg_vpi_cmpl = VPORT_ERROR; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 7711 | |
| 7712 | /* Trigger the release of the ndlp after logo */ |
| 7713 | lpfc_nlp_put(ndlp); |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 7714 | |
| 7715 | /* NPIV LOGO completes to NPort <nlp_DID> */ |
| 7716 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 7717 | "2928 NPIV LOGO completes to NPort x%x " |
| 7718 | "Data: x%x x%x x%x x%x\n", |
| 7719 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 7720 | irsp->ulpTimeout, vport->num_disc_nodes); |
| 7721 | |
| 7722 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 7723 | spin_lock_irq(shost->host_lock); |
| 7724 | vport->fc_flag &= ~FC_FABRIC; |
| 7725 | spin_unlock_irq(shost->host_lock); |
| 7726 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7727 | } |
| 7728 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7729 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7730 | * lpfc_issue_els_npiv_logo - Issue a logo off a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7731 | * @vport: pointer to a virtual N_Port data structure. |
| 7732 | * @ndlp: pointer to a node-list data structure. |
| 7733 | * |
| 7734 | * This routine issues a LOGO ELS command to an @ndlp off a @vport. |
| 7735 | * |
| 7736 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 7737 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 7738 | * will be stored into the context1 field of the IOCB for the completion |
| 7739 | * callback function to the LOGO ELS command. |
| 7740 | * |
| 7741 | * Return codes |
| 7742 | * 0 - Successfully issued logo off the @vport |
| 7743 | * 1 - Failed to issue logo off the @vport |
| 7744 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7745 | int |
| 7746 | lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) |
| 7747 | { |
| 7748 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 7749 | struct lpfc_hba *phba = vport->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7750 | IOCB_t *icmd; |
| 7751 | struct lpfc_iocbq *elsiocb; |
| 7752 | uint8_t *pcmd; |
| 7753 | uint16_t cmdsize; |
| 7754 | |
| 7755 | cmdsize = 2 * sizeof(uint32_t) + sizeof(struct lpfc_name); |
| 7756 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, ndlp->nlp_DID, |
| 7757 | ELS_CMD_LOGO); |
| 7758 | if (!elsiocb) |
| 7759 | return 1; |
| 7760 | |
| 7761 | icmd = &elsiocb->iocb; |
| 7762 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 7763 | *((uint32_t *) (pcmd)) = ELS_CMD_LOGO; |
| 7764 | pcmd += sizeof(uint32_t); |
| 7765 | |
| 7766 | /* Fill in LOGO payload */ |
| 7767 | *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID); |
| 7768 | pcmd += sizeof(uint32_t); |
| 7769 | memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 7770 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7771 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 7772 | "Issue LOGO npiv did:x%x flg:x%x", |
| 7773 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 7774 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7775 | elsiocb->iocb_cmpl = lpfc_cmpl_els_npiv_logo; |
| 7776 | spin_lock_irq(shost->host_lock); |
| 7777 | ndlp->nlp_flag |= NLP_LOGO_SND; |
| 7778 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 7779 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 7780 | IOCB_ERROR) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7781 | spin_lock_irq(shost->host_lock); |
| 7782 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
| 7783 | spin_unlock_irq(shost->host_lock); |
| 7784 | lpfc_els_free_iocb(phba, elsiocb); |
| 7785 | return 1; |
| 7786 | } |
| 7787 | return 0; |
| 7788 | } |
| 7789 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7790 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7791 | * lpfc_fabric_block_timeout - Handler function to the fabric block timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7792 | * @ptr: holder for the timer function associated data. |
| 7793 | * |
| 7794 | * This routine is invoked by the fabric iocb block timer after |
| 7795 | * timeout. It posts the fabric iocb block timeout event by setting the |
| 7796 | * WORKER_FABRIC_BLOCK_TMO bit to work port event bitmap and then invokes |
| 7797 | * lpfc_worker_wake_up() routine to wake up the worker thread. It is for |
| 7798 | * the worker thread to invoke the lpfc_unblock_fabric_iocbs() on the |
| 7799 | * posted event WORKER_FABRIC_BLOCK_TMO. |
| 7800 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7801 | void |
| 7802 | lpfc_fabric_block_timeout(unsigned long ptr) |
| 7803 | { |
| 7804 | struct lpfc_hba *phba = (struct lpfc_hba *) ptr; |
| 7805 | unsigned long iflags; |
| 7806 | uint32_t tmo_posted; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 7807 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7808 | spin_lock_irqsave(&phba->pport->work_port_lock, iflags); |
| 7809 | tmo_posted = phba->pport->work_port_events & WORKER_FABRIC_BLOCK_TMO; |
| 7810 | if (!tmo_posted) |
| 7811 | phba->pport->work_port_events |= WORKER_FABRIC_BLOCK_TMO; |
| 7812 | spin_unlock_irqrestore(&phba->pport->work_port_lock, iflags); |
| 7813 | |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 7814 | if (!tmo_posted) |
| 7815 | lpfc_worker_wake_up(phba); |
| 7816 | return; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7817 | } |
| 7818 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7819 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7820 | * lpfc_resume_fabric_iocbs - Issue a fabric iocb from driver internal list |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7821 | * @phba: pointer to lpfc hba data structure. |
| 7822 | * |
| 7823 | * This routine issues one fabric iocb from the driver internal list to |
| 7824 | * the HBA. It first checks whether it's ready to issue one fabric iocb to |
| 7825 | * the HBA (whether there is no outstanding fabric iocb). If so, it shall |
| 7826 | * remove one pending fabric iocb from the driver internal list and invokes |
| 7827 | * lpfc_sli_issue_iocb() routine to send the fabric iocb to the HBA. |
| 7828 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7829 | static void |
| 7830 | lpfc_resume_fabric_iocbs(struct lpfc_hba *phba) |
| 7831 | { |
| 7832 | struct lpfc_iocbq *iocb; |
| 7833 | unsigned long iflags; |
| 7834 | int ret; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7835 | IOCB_t *cmd; |
| 7836 | |
| 7837 | repeat: |
| 7838 | iocb = NULL; |
| 7839 | spin_lock_irqsave(&phba->hbalock, iflags); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7840 | /* Post any pending iocb to the SLI layer */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7841 | if (atomic_read(&phba->fabric_iocb_count) == 0) { |
| 7842 | list_remove_head(&phba->fabric_iocb_list, iocb, typeof(*iocb), |
| 7843 | list); |
| 7844 | if (iocb) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7845 | /* Increment fabric iocb count to hold the position */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7846 | atomic_inc(&phba->fabric_iocb_count); |
| 7847 | } |
| 7848 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 7849 | if (iocb) { |
| 7850 | iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; |
| 7851 | iocb->iocb_cmpl = lpfc_cmpl_fabric_iocb; |
| 7852 | iocb->iocb_flag |= LPFC_IO_FABRIC; |
| 7853 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7854 | lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD, |
| 7855 | "Fabric sched1: ste:x%x", |
| 7856 | iocb->vport->port_state, 0, 0); |
| 7857 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 7858 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, iocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7859 | |
| 7860 | if (ret == IOCB_ERROR) { |
| 7861 | iocb->iocb_cmpl = iocb->fabric_iocb_cmpl; |
| 7862 | iocb->fabric_iocb_cmpl = NULL; |
| 7863 | iocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 7864 | cmd = &iocb->iocb; |
| 7865 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; |
| 7866 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; |
| 7867 | iocb->iocb_cmpl(phba, iocb, iocb); |
| 7868 | |
| 7869 | atomic_dec(&phba->fabric_iocb_count); |
| 7870 | goto repeat; |
| 7871 | } |
| 7872 | } |
| 7873 | |
| 7874 | return; |
| 7875 | } |
| 7876 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7877 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7878 | * lpfc_unblock_fabric_iocbs - Unblock issuing fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7879 | * @phba: pointer to lpfc hba data structure. |
| 7880 | * |
| 7881 | * This routine unblocks the issuing fabric iocb command. The function |
| 7882 | * will clear the fabric iocb block bit and then invoke the routine |
| 7883 | * lpfc_resume_fabric_iocbs() to issue one of the pending fabric iocb |
| 7884 | * from the driver internal fabric iocb list. |
| 7885 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7886 | void |
| 7887 | lpfc_unblock_fabric_iocbs(struct lpfc_hba *phba) |
| 7888 | { |
| 7889 | clear_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
| 7890 | |
| 7891 | lpfc_resume_fabric_iocbs(phba); |
| 7892 | return; |
| 7893 | } |
| 7894 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7895 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7896 | * lpfc_block_fabric_iocbs - Block issuing fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7897 | * @phba: pointer to lpfc hba data structure. |
| 7898 | * |
| 7899 | * This routine blocks the issuing fabric iocb for a specified amount of |
| 7900 | * time (currently 100 ms). This is done by set the fabric iocb block bit |
| 7901 | * and set up a timeout timer for 100ms. When the block bit is set, no more |
| 7902 | * fabric iocb will be issued out of the HBA. |
| 7903 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7904 | static void |
| 7905 | lpfc_block_fabric_iocbs(struct lpfc_hba *phba) |
| 7906 | { |
| 7907 | int blocked; |
| 7908 | |
| 7909 | blocked = test_and_set_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7910 | /* Start a timer to unblock fabric iocbs after 100ms */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7911 | if (!blocked) |
James Smart | 256ec0d | 2013-04-17 20:14:58 -0400 | [diff] [blame] | 7912 | mod_timer(&phba->fabric_block_timer, |
| 7913 | jiffies + msecs_to_jiffies(100)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7914 | |
| 7915 | return; |
| 7916 | } |
| 7917 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7918 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7919 | * lpfc_cmpl_fabric_iocb - Completion callback function for fabric iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7920 | * @phba: pointer to lpfc hba data structure. |
| 7921 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 7922 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 7923 | * |
| 7924 | * This routine is the callback function that is put to the fabric iocb's |
| 7925 | * callback function pointer (iocb->iocb_cmpl). The original iocb's callback |
| 7926 | * function pointer has been stored in iocb->fabric_iocb_cmpl. This callback |
| 7927 | * function first restores and invokes the original iocb's callback function |
| 7928 | * and then invokes the lpfc_resume_fabric_iocbs() routine to issue the next |
| 7929 | * fabric bound iocb from the driver internal fabric iocb list onto the wire. |
| 7930 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7931 | static void |
| 7932 | lpfc_cmpl_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 7933 | struct lpfc_iocbq *rspiocb) |
| 7934 | { |
| 7935 | struct ls_rjt stat; |
| 7936 | |
| 7937 | if ((cmdiocb->iocb_flag & LPFC_IO_FABRIC) != LPFC_IO_FABRIC) |
| 7938 | BUG(); |
| 7939 | |
| 7940 | switch (rspiocb->iocb.ulpStatus) { |
| 7941 | case IOSTAT_NPORT_RJT: |
| 7942 | case IOSTAT_FABRIC_RJT: |
| 7943 | if (rspiocb->iocb.un.ulpWord[4] & RJT_UNAVAIL_TEMP) { |
| 7944 | lpfc_block_fabric_iocbs(phba); |
| 7945 | } |
| 7946 | break; |
| 7947 | |
| 7948 | case IOSTAT_NPORT_BSY: |
| 7949 | case IOSTAT_FABRIC_BSY: |
| 7950 | lpfc_block_fabric_iocbs(phba); |
| 7951 | break; |
| 7952 | |
| 7953 | case IOSTAT_LS_RJT: |
| 7954 | stat.un.lsRjtError = |
| 7955 | be32_to_cpu(rspiocb->iocb.un.ulpWord[4]); |
| 7956 | if ((stat.un.b.lsRjtRsnCode == LSRJT_UNABLE_TPC) || |
| 7957 | (stat.un.b.lsRjtRsnCode == LSRJT_LOGICAL_BSY)) |
| 7958 | lpfc_block_fabric_iocbs(phba); |
| 7959 | break; |
| 7960 | } |
| 7961 | |
| 7962 | if (atomic_read(&phba->fabric_iocb_count) == 0) |
| 7963 | BUG(); |
| 7964 | |
| 7965 | cmdiocb->iocb_cmpl = cmdiocb->fabric_iocb_cmpl; |
| 7966 | cmdiocb->fabric_iocb_cmpl = NULL; |
| 7967 | cmdiocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 7968 | cmdiocb->iocb_cmpl(phba, cmdiocb, rspiocb); |
| 7969 | |
| 7970 | atomic_dec(&phba->fabric_iocb_count); |
| 7971 | if (!test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags)) { |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7972 | /* Post any pending iocbs to HBA */ |
| 7973 | lpfc_resume_fabric_iocbs(phba); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7974 | } |
| 7975 | } |
| 7976 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7977 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7978 | * lpfc_issue_fabric_iocb - Issue a fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7979 | * @phba: pointer to lpfc hba data structure. |
| 7980 | * @iocb: pointer to lpfc command iocb data structure. |
| 7981 | * |
| 7982 | * This routine is used as the top-level API for issuing a fabric iocb command |
| 7983 | * such as FLOGI and FDISC. To accommodate certain switch fabric, this driver |
| 7984 | * function makes sure that only one fabric bound iocb will be outstanding at |
| 7985 | * any given time. As such, this function will first check to see whether there |
| 7986 | * is already an outstanding fabric iocb on the wire. If so, it will put the |
| 7987 | * newly issued iocb onto the driver internal fabric iocb list, waiting to be |
| 7988 | * issued later. Otherwise, it will issue the iocb on the wire and update the |
| 7989 | * fabric iocb count it indicate that there is one fabric iocb on the wire. |
| 7990 | * |
| 7991 | * Note, this implementation has a potential sending out fabric IOCBs out of |
| 7992 | * order. The problem is caused by the construction of the "ready" boolen does |
| 7993 | * not include the condition that the internal fabric IOCB list is empty. As |
| 7994 | * such, it is possible a fabric IOCB issued by this routine might be "jump" |
| 7995 | * ahead of the fabric IOCBs in the internal list. |
| 7996 | * |
| 7997 | * Return code |
| 7998 | * IOCB_SUCCESS - either fabric iocb put on the list or issued successfully |
| 7999 | * IOCB_ERROR - failed to issue fabric iocb |
| 8000 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 8001 | static int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8002 | lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb) |
| 8003 | { |
| 8004 | unsigned long iflags; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8005 | int ready; |
| 8006 | int ret; |
| 8007 | |
| 8008 | if (atomic_read(&phba->fabric_iocb_count) > 1) |
| 8009 | BUG(); |
| 8010 | |
| 8011 | spin_lock_irqsave(&phba->hbalock, iflags); |
| 8012 | ready = atomic_read(&phba->fabric_iocb_count) == 0 && |
| 8013 | !test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
| 8014 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 8015 | if (ready) |
| 8016 | /* Increment fabric iocb count to hold the position */ |
| 8017 | atomic_inc(&phba->fabric_iocb_count); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8018 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 8019 | if (ready) { |
| 8020 | iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; |
| 8021 | iocb->iocb_cmpl = lpfc_cmpl_fabric_iocb; |
| 8022 | iocb->iocb_flag |= LPFC_IO_FABRIC; |
| 8023 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 8024 | lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD, |
| 8025 | "Fabric sched2: ste:x%x", |
| 8026 | iocb->vport->port_state, 0, 0); |
| 8027 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 8028 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, iocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8029 | |
| 8030 | if (ret == IOCB_ERROR) { |
| 8031 | iocb->iocb_cmpl = iocb->fabric_iocb_cmpl; |
| 8032 | iocb->fabric_iocb_cmpl = NULL; |
| 8033 | iocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 8034 | atomic_dec(&phba->fabric_iocb_count); |
| 8035 | } |
| 8036 | } else { |
| 8037 | spin_lock_irqsave(&phba->hbalock, iflags); |
| 8038 | list_add_tail(&iocb->list, &phba->fabric_iocb_list); |
| 8039 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 8040 | ret = IOCB_SUCCESS; |
| 8041 | } |
| 8042 | return ret; |
| 8043 | } |
| 8044 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8045 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8046 | * lpfc_fabric_abort_vport - Abort a vport's iocbs from driver fabric iocb list |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8047 | * @vport: pointer to a virtual N_Port data structure. |
| 8048 | * |
| 8049 | * This routine aborts all the IOCBs associated with a @vport from the |
| 8050 | * driver internal fabric IOCB list. The list contains fabric IOCBs to be |
| 8051 | * issued to the ELS IOCB ring. This abort function walks the fabric IOCB |
| 8052 | * list, removes each IOCB associated with the @vport off the list, set the |
| 8053 | * status feild to IOSTAT_LOCAL_REJECT, and invokes the callback function |
| 8054 | * associated with the IOCB. |
| 8055 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 8056 | static void lpfc_fabric_abort_vport(struct lpfc_vport *vport) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8057 | { |
| 8058 | LIST_HEAD(completions); |
| 8059 | struct lpfc_hba *phba = vport->phba; |
| 8060 | struct lpfc_iocbq *tmp_iocb, *piocb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8061 | |
| 8062 | spin_lock_irq(&phba->hbalock); |
| 8063 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, |
| 8064 | list) { |
| 8065 | |
| 8066 | if (piocb->vport != vport) |
| 8067 | continue; |
| 8068 | |
| 8069 | list_move_tail(&piocb->list, &completions); |
| 8070 | } |
| 8071 | spin_unlock_irq(&phba->hbalock); |
| 8072 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8073 | /* Cancel all the IOCBs from the completions list */ |
| 8074 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 8075 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8076 | } |
| 8077 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8078 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8079 | * lpfc_fabric_abort_nport - Abort a ndlp's iocbs from driver fabric iocb list |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8080 | * @ndlp: pointer to a node-list data structure. |
| 8081 | * |
| 8082 | * This routine aborts all the IOCBs associated with an @ndlp from the |
| 8083 | * driver internal fabric IOCB list. The list contains fabric IOCBs to be |
| 8084 | * issued to the ELS IOCB ring. This abort function walks the fabric IOCB |
| 8085 | * list, removes each IOCB associated with the @ndlp off the list, set the |
| 8086 | * status feild to IOSTAT_LOCAL_REJECT, and invokes the callback function |
| 8087 | * associated with the IOCB. |
| 8088 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8089 | void lpfc_fabric_abort_nport(struct lpfc_nodelist *ndlp) |
| 8090 | { |
| 8091 | LIST_HEAD(completions); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8092 | struct lpfc_hba *phba = ndlp->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8093 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 8094 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8095 | |
| 8096 | spin_lock_irq(&phba->hbalock); |
| 8097 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, |
| 8098 | list) { |
| 8099 | if ((lpfc_check_sli_ndlp(phba, pring, piocb, ndlp))) { |
| 8100 | |
| 8101 | list_move_tail(&piocb->list, &completions); |
| 8102 | } |
| 8103 | } |
| 8104 | spin_unlock_irq(&phba->hbalock); |
| 8105 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8106 | /* Cancel all the IOCBs from the completions list */ |
| 8107 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 8108 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8109 | } |
| 8110 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8111 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8112 | * lpfc_fabric_abort_hba - Abort all iocbs on driver fabric iocb list |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8113 | * @phba: pointer to lpfc hba data structure. |
| 8114 | * |
| 8115 | * This routine aborts all the IOCBs currently on the driver internal |
| 8116 | * fabric IOCB list. The list contains fabric IOCBs to be issued to the ELS |
| 8117 | * IOCB ring. This function takes the entire IOCB list off the fabric IOCB |
| 8118 | * list, removes IOCBs off the list, set the status feild to |
| 8119 | * IOSTAT_LOCAL_REJECT, and invokes the callback function associated with |
| 8120 | * the IOCB. |
| 8121 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8122 | void lpfc_fabric_abort_hba(struct lpfc_hba *phba) |
| 8123 | { |
| 8124 | LIST_HEAD(completions); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8125 | |
| 8126 | spin_lock_irq(&phba->hbalock); |
| 8127 | list_splice_init(&phba->fabric_iocb_list, &completions); |
| 8128 | spin_unlock_irq(&phba->hbalock); |
| 8129 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8130 | /* Cancel all the IOCBs from the completions list */ |
| 8131 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 8132 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8133 | } |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8134 | |
| 8135 | /** |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 8136 | * lpfc_sli4_vport_delete_els_xri_aborted -Remove all ndlp references for vport |
| 8137 | * @vport: pointer to lpfc vport data structure. |
| 8138 | * |
| 8139 | * This routine is invoked by the vport cleanup for deletions and the cleanup |
| 8140 | * for an ndlp on removal. |
| 8141 | **/ |
| 8142 | void |
| 8143 | lpfc_sli4_vport_delete_els_xri_aborted(struct lpfc_vport *vport) |
| 8144 | { |
| 8145 | struct lpfc_hba *phba = vport->phba; |
| 8146 | struct lpfc_sglq *sglq_entry = NULL, *sglq_next = NULL; |
| 8147 | unsigned long iflag = 0; |
| 8148 | |
| 8149 | spin_lock_irqsave(&phba->hbalock, iflag); |
| 8150 | spin_lock(&phba->sli4_hba.abts_sgl_list_lock); |
| 8151 | list_for_each_entry_safe(sglq_entry, sglq_next, |
| 8152 | &phba->sli4_hba.lpfc_abts_els_sgl_list, list) { |
| 8153 | if (sglq_entry->ndlp && sglq_entry->ndlp->vport == vport) |
| 8154 | sglq_entry->ndlp = NULL; |
| 8155 | } |
| 8156 | spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); |
| 8157 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8158 | return; |
| 8159 | } |
| 8160 | |
| 8161 | /** |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8162 | * lpfc_sli4_els_xri_aborted - Slow-path process of els xri abort |
| 8163 | * @phba: pointer to lpfc hba data structure. |
| 8164 | * @axri: pointer to the els xri abort wcqe structure. |
| 8165 | * |
| 8166 | * This routine is invoked by the worker thread to process a SLI4 slow-path |
| 8167 | * ELS aborted xri. |
| 8168 | **/ |
| 8169 | void |
| 8170 | lpfc_sli4_els_xri_aborted(struct lpfc_hba *phba, |
| 8171 | struct sli4_wcqe_xri_aborted *axri) |
| 8172 | { |
| 8173 | uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8174 | uint16_t rxid = bf_get(lpfc_wcqe_xa_remote_xid, axri); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 8175 | uint16_t lxri = 0; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8176 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8177 | struct lpfc_sglq *sglq_entry = NULL, *sglq_next = NULL; |
| 8178 | unsigned long iflag = 0; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8179 | struct lpfc_nodelist *ndlp; |
James Smart | 589a52d | 2010-07-14 15:30:54 -0400 | [diff] [blame] | 8180 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8181 | |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8182 | spin_lock_irqsave(&phba->hbalock, iflag); |
| 8183 | spin_lock(&phba->sli4_hba.abts_sgl_list_lock); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8184 | list_for_each_entry_safe(sglq_entry, sglq_next, |
| 8185 | &phba->sli4_hba.lpfc_abts_els_sgl_list, list) { |
| 8186 | if (sglq_entry->sli4_xritag == xri) { |
| 8187 | list_del(&sglq_entry->list); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8188 | ndlp = sglq_entry->ndlp; |
| 8189 | sglq_entry->ndlp = NULL; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8190 | list_add_tail(&sglq_entry->list, |
| 8191 | &phba->sli4_hba.lpfc_sgl_list); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8192 | sglq_entry->state = SGL_FREED; |
| 8193 | spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8194 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
James Smart | ee0f4fe | 2012-05-09 21:19:14 -0400 | [diff] [blame] | 8195 | lpfc_set_rrq_active(phba, ndlp, |
| 8196 | sglq_entry->sli4_lxritag, |
| 8197 | rxid, 1); |
James Smart | 589a52d | 2010-07-14 15:30:54 -0400 | [diff] [blame] | 8198 | |
| 8199 | /* Check if TXQ queue needs to be serviced */ |
James Smart | 0e9bb8d | 2013-03-01 16:35:12 -0500 | [diff] [blame] | 8200 | if (!(list_empty(&pring->txq))) |
James Smart | 589a52d | 2010-07-14 15:30:54 -0400 | [diff] [blame] | 8201 | lpfc_worker_wake_up(phba); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8202 | return; |
| 8203 | } |
| 8204 | } |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8205 | spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 8206 | lxri = lpfc_sli4_xri_inrange(phba, xri); |
| 8207 | if (lxri == NO_XRI) { |
| 8208 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8209 | return; |
| 8210 | } |
| 8211 | sglq_entry = __lpfc_get_active_sglq(phba, lxri); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8212 | if (!sglq_entry || (sglq_entry->sli4_xritag != xri)) { |
| 8213 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8214 | return; |
| 8215 | } |
| 8216 | sglq_entry->state = SGL_XRI_ABORTED; |
| 8217 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8218 | return; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8219 | } |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 8220 | |
| 8221 | /* lpfc_sli_abts_recover_port - Recover a port that failed a BLS_ABORT req. |
| 8222 | * @vport: pointer to virtual port object. |
| 8223 | * @ndlp: nodelist pointer for the impacted node. |
| 8224 | * |
| 8225 | * The driver calls this routine in response to an SLI4 XRI ABORT CQE |
| 8226 | * or an SLI3 ASYNC_STATUS_CN event from the port. For either event, |
| 8227 | * the driver is required to send a LOGO to the remote node before it |
| 8228 | * attempts to recover its login to the remote node. |
| 8229 | */ |
| 8230 | void |
| 8231 | lpfc_sli_abts_recover_port(struct lpfc_vport *vport, |
| 8232 | struct lpfc_nodelist *ndlp) |
| 8233 | { |
| 8234 | struct Scsi_Host *shost; |
| 8235 | struct lpfc_hba *phba; |
| 8236 | unsigned long flags = 0; |
| 8237 | |
| 8238 | shost = lpfc_shost_from_vport(vport); |
| 8239 | phba = vport->phba; |
| 8240 | if (ndlp->nlp_state != NLP_STE_MAPPED_NODE) { |
| 8241 | lpfc_printf_log(phba, KERN_INFO, |
| 8242 | LOG_SLI, "3093 No rport recovery needed. " |
| 8243 | "rport in state 0x%x\n", ndlp->nlp_state); |
| 8244 | return; |
| 8245 | } |
| 8246 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, |
| 8247 | "3094 Start rport recovery on shost id 0x%x " |
| 8248 | "fc_id 0x%06x vpi 0x%x rpi 0x%x state 0x%x " |
| 8249 | "flags 0x%x\n", |
| 8250 | shost->host_no, ndlp->nlp_DID, |
| 8251 | vport->vpi, ndlp->nlp_rpi, ndlp->nlp_state, |
| 8252 | ndlp->nlp_flag); |
| 8253 | /* |
| 8254 | * The rport is not responding. Remove the FCP-2 flag to prevent |
| 8255 | * an ADISC in the follow-up recovery code. |
| 8256 | */ |
| 8257 | spin_lock_irqsave(shost->host_lock, flags); |
| 8258 | ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE; |
| 8259 | spin_unlock_irqrestore(shost->host_lock, flags); |
| 8260 | lpfc_issue_els_logo(vport, ndlp, 0); |
| 8261 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE); |
| 8262 | } |
| 8263 | |