| 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 | 16a59fb | 2014-04-04 13:52:41 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2014 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); |
James Smart | a2fc4aef | 2014-09-03 12:57:55 -0400 | [diff] [blame] | 1087 | if (!prsp) |
| 1088 | goto out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1089 | sp = prsp->virt + sizeof(uint32_t); |
| 1090 | |
| 1091 | /* FLOGI completes successfully */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1092 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
James Smart | 88f43a0 | 2013-04-17 20:19:44 -0400 | [diff] [blame] | 1093 | "0101 FLOGI completes successfully, I/O tag:x%x, " |
| 1094 | "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] | 1095 | irsp->un.ulpWord[4], sp->cmn.e_d_tov, |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 1096 | sp->cmn.w2.r_a_tov, sp->cmn.edtovResolution, |
| 1097 | vport->port_state, vport->fc_flag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1098 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1099 | if (vport->port_state == LPFC_FLOGI) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1100 | /* |
| 1101 | * If Common Service Parameters indicate Nport |
| 1102 | * we are point to point, if Fport we are Fabric. |
| 1103 | */ |
| 1104 | if (sp->cmn.fPort) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1105 | rc = lpfc_cmpl_els_flogi_fabric(vport, ndlp, sp, irsp); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1106 | else if (!(phba->hba_flag & HBA_FCOE_MODE)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1107 | rc = lpfc_cmpl_els_flogi_nport(vport, ndlp, sp); |
James Smart | dbb6b3a | 2010-06-08 18:31:37 -0400 | [diff] [blame] | 1108 | else { |
| 1109 | lpfc_printf_vlog(vport, KERN_ERR, |
| 1110 | LOG_FIP | LOG_ELS, |
| 1111 | "2831 FLOGI response with cleared Fabric " |
| 1112 | "bit fcf_index 0x%x " |
| 1113 | "Switch Name %02x%02x%02x%02x%02x%02x%02x%02x " |
| 1114 | "Fabric Name " |
| 1115 | "%02x%02x%02x%02x%02x%02x%02x%02x\n", |
| 1116 | phba->fcf.current_rec.fcf_indx, |
| 1117 | phba->fcf.current_rec.switch_name[0], |
| 1118 | phba->fcf.current_rec.switch_name[1], |
| 1119 | phba->fcf.current_rec.switch_name[2], |
| 1120 | phba->fcf.current_rec.switch_name[3], |
| 1121 | phba->fcf.current_rec.switch_name[4], |
| 1122 | phba->fcf.current_rec.switch_name[5], |
| 1123 | phba->fcf.current_rec.switch_name[6], |
| 1124 | phba->fcf.current_rec.switch_name[7], |
| 1125 | phba->fcf.current_rec.fabric_name[0], |
| 1126 | phba->fcf.current_rec.fabric_name[1], |
| 1127 | phba->fcf.current_rec.fabric_name[2], |
| 1128 | phba->fcf.current_rec.fabric_name[3], |
| 1129 | phba->fcf.current_rec.fabric_name[4], |
| 1130 | phba->fcf.current_rec.fabric_name[5], |
| 1131 | phba->fcf.current_rec.fabric_name[6], |
| 1132 | phba->fcf.current_rec.fabric_name[7]); |
| 1133 | lpfc_nlp_put(ndlp); |
| 1134 | spin_lock_irq(&phba->hbalock); |
| 1135 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 1136 | phba->hba_flag &= ~(FCF_RR_INPROG | HBA_DEVLOSS_TMO); |
James Smart | dbb6b3a | 2010-06-08 18:31:37 -0400 | [diff] [blame] | 1137 | spin_unlock_irq(&phba->hbalock); |
| 1138 | goto out; |
| 1139 | } |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1140 | if (!rc) { |
| 1141 | /* Mark the FCF discovery process done */ |
James Smart | 999d813 | 2010-03-15 11:24:56 -0400 | [diff] [blame] | 1142 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 1143 | lpfc_printf_vlog(vport, KERN_INFO, LOG_FIP | |
| 1144 | LOG_ELS, |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 1145 | "2769 FLOGI to FCF (x%x) " |
| 1146 | "completed successfully\n", |
James Smart | 999d813 | 2010-03-15 11:24:56 -0400 | [diff] [blame] | 1147 | phba->fcf.current_rec.fcf_indx); |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1148 | spin_lock_irq(&phba->hbalock); |
| 1149 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 1150 | phba->hba_flag &= ~(FCF_RR_INPROG | HBA_DEVLOSS_TMO); |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1151 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1152 | goto out; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1153 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1154 | } |
| 1155 | |
| 1156 | flogifail: |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 1157 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1158 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1159 | if (!lpfc_error_lost_link(irsp)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1160 | /* FLOGI failed, so just use loop map to make discovery list */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1161 | lpfc_disc_list_loopmap(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1162 | |
| 1163 | /* Start discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1164 | lpfc_disc_start(vport); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1165 | } else if (((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 1166 | (((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) != |
| 1167 | IOERR_SLI_ABORTED) && |
| 1168 | ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) != |
| 1169 | IOERR_SLI_DOWN))) && |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1170 | (phba->link_state != LPFC_CLEAR_LA)) { |
| 1171 | /* If FLOGI failed enable link interrupt. */ |
| 1172 | lpfc_issue_clear_la(phba, vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1173 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1174 | out: |
| 1175 | lpfc_els_free_iocb(phba, cmdiocb); |
| 1176 | } |
| 1177 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1178 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1179 | * lpfc_issue_els_flogi - Issue an flogi iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1180 | * @vport: pointer to a host virtual N_Port data structure. |
| 1181 | * @ndlp: pointer to a node-list data structure. |
| 1182 | * @retry: number of retries to the command IOCB. |
| 1183 | * |
| 1184 | * This routine issues a Fabric Login (FLOGI) Request ELS command |
| 1185 | * for a @vport. The initiator service parameters are put into the payload |
| 1186 | * of the FLOGI Request IOCB and the top-level callback function pointer |
| 1187 | * to lpfc_cmpl_els_flogi() routine is put to the IOCB completion callback |
| 1188 | * function field. The lpfc_issue_fabric_iocb routine is invoked to send |
| 1189 | * out FLOGI ELS command with one outstanding fabric IOCB at a time. |
| 1190 | * |
| 1191 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 1192 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 1193 | * will be stored into the context1 field of the IOCB for the completion |
| 1194 | * callback function to the FLOGI ELS command. |
| 1195 | * |
| 1196 | * Return code |
| 1197 | * 0 - successfully issued flogi iocb for @vport |
| 1198 | * 1 - failed to issue flogi iocb for @vport |
| 1199 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1200 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1201 | lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1202 | uint8_t retry) |
| 1203 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1204 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1205 | struct serv_parm *sp; |
| 1206 | IOCB_t *icmd; |
| 1207 | struct lpfc_iocbq *elsiocb; |
| 1208 | struct lpfc_sli_ring *pring; |
| 1209 | uint8_t *pcmd; |
| 1210 | uint16_t cmdsize; |
| 1211 | uint32_t tmo; |
| 1212 | int rc; |
| 1213 | |
| 1214 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
| 1215 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1216 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1217 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 1218 | ndlp->nlp_DID, ELS_CMD_FLOGI); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1219 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1220 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1221 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1222 | |
| 1223 | icmd = &elsiocb->iocb; |
| 1224 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 1225 | |
| 1226 | /* For FLOGI request, remainder of payload is service parameters */ |
| 1227 | *((uint32_t *) (pcmd)) = ELS_CMD_FLOGI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1228 | pcmd += sizeof(uint32_t); |
| 1229 | memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1230 | sp = (struct serv_parm *) pcmd; |
| 1231 | |
| 1232 | /* Setup CSPs accordingly for Fabric */ |
| 1233 | sp->cmn.e_d_tov = 0; |
| 1234 | sp->cmn.w2.r_a_tov = 0; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 1235 | sp->cmn.virtual_fabric_support = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1236 | sp->cls1.classValid = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1237 | if (sp->cmn.fcphLow < FC_PH3) |
| 1238 | sp->cmn.fcphLow = FC_PH3; |
| 1239 | if (sp->cmn.fcphHigh < FC_PH3) |
| 1240 | sp->cmn.fcphHigh = FC_PH3; |
| 1241 | |
James Smart | c31098c | 2011-04-16 11:03:33 -0400 | [diff] [blame] | 1242 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1243 | if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == |
| 1244 | LPFC_SLI_INTF_IF_TYPE_0) { |
| 1245 | elsiocb->iocb.ulpCt_h = ((SLI4_CT_FCFI >> 1) & 1); |
| 1246 | elsiocb->iocb.ulpCt_l = (SLI4_CT_FCFI & 1); |
| 1247 | /* FLOGI needs to be 3 for WQE FCFI */ |
| 1248 | /* Set the fcfi to the fcfi we registered with */ |
| 1249 | elsiocb->iocb.ulpContext = phba->fcf.fcfi; |
| 1250 | } |
James Smart | 0f37887 | 2012-10-31 14:45:01 -0400 | [diff] [blame] | 1251 | /* Can't do SLI4 class2 without support sequence coalescing */ |
| 1252 | sp->cls2.classValid = 0; |
| 1253 | sp->cls2.seqDelivery = 0; |
James Smart | 5248a74 | 2011-07-22 18:37:06 -0400 | [diff] [blame] | 1254 | } else { |
James Smart | 0f37887 | 2012-10-31 14:45:01 -0400 | [diff] [blame] | 1255 | /* Historical, setting sequential-delivery bit for SLI3 */ |
| 1256 | sp->cls2.seqDelivery = (sp->cls2.classValid) ? 1 : 0; |
| 1257 | sp->cls3.seqDelivery = (sp->cls3.classValid) ? 1 : 0; |
James Smart | 5248a74 | 2011-07-22 18:37:06 -0400 | [diff] [blame] | 1258 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
| 1259 | sp->cmn.request_multiple_Nport = 1; |
| 1260 | /* For FLOGI, Let FLOGI rsp set the NPortID for VPI 0 */ |
| 1261 | icmd->ulpCt_h = 1; |
| 1262 | icmd->ulpCt_l = 0; |
| 1263 | } else |
| 1264 | sp->cmn.request_multiple_Nport = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1265 | } |
| 1266 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1267 | if (phba->fc_topology != LPFC_TOPOLOGY_LOOP) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1268 | icmd->un.elsreq64.myID = 0; |
| 1269 | icmd->un.elsreq64.fl = 1; |
| 1270 | } |
| 1271 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1272 | tmo = phba->fc_ratov; |
| 1273 | phba->fc_ratov = LPFC_DISC_FLOGI_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1274 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1275 | phba->fc_ratov = tmo; |
| 1276 | |
| 1277 | phba->fc_stat.elsXmitFLOGI++; |
| 1278 | elsiocb->iocb_cmpl = lpfc_cmpl_els_flogi; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1279 | |
| 1280 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1281 | "Issue FLOGI: opt:x%x", |
| 1282 | phba->sli3_options, 0, 0); |
| 1283 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1284 | rc = lpfc_issue_fabric_iocb(phba, elsiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1285 | if (rc == IOCB_ERROR) { |
| 1286 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1287 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1288 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1289 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1290 | } |
| 1291 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1292 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1293 | * lpfc_els_abort_flogi - Abort all outstanding flogi iocbs |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1294 | * @phba: pointer to lpfc hba data structure. |
| 1295 | * |
| 1296 | * This routine aborts all the outstanding Fabric Login (FLOGI) IOCBs |
| 1297 | * with a @phba. This routine walks all the outstanding IOCBs on the txcmplq |
| 1298 | * list and issues an abort IOCB commond on each outstanding IOCB that |
| 1299 | * contains a active Fabric_DID ndlp. Note that this function is to issue |
| 1300 | * the abort IOCB command on all the outstanding IOCBs, thus when this |
| 1301 | * function returns, it does not guarantee all the IOCBs are actually aborted. |
| 1302 | * |
| 1303 | * Return code |
Daniel Mack | 3ad2f3f | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 1304 | * 0 - Successfully issued abort iocb on all outstanding flogis (Always 0) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1305 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1306 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1307 | lpfc_els_abort_flogi(struct lpfc_hba *phba) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1308 | { |
| 1309 | struct lpfc_sli_ring *pring; |
| 1310 | struct lpfc_iocbq *iocb, *next_iocb; |
| 1311 | struct lpfc_nodelist *ndlp; |
| 1312 | IOCB_t *icmd; |
| 1313 | |
| 1314 | /* Abort outstanding I/O on NPort <nlp_DID> */ |
| 1315 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1316 | "0201 Abort outstanding I/O on NPort x%x\n", |
| 1317 | Fabric_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1318 | |
| 1319 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
| 1320 | |
| 1321 | /* |
| 1322 | * Check the txcmplq for an iocb that matches the nport the driver is |
| 1323 | * searching for. |
| 1324 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1325 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1326 | list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) { |
| 1327 | icmd = &iocb->iocb; |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 1328 | if (icmd->ulpCommand == CMD_ELS_REQUEST64_CR) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1329 | ndlp = (struct lpfc_nodelist *)(iocb->context1); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1330 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 1331 | (ndlp->nlp_DID == Fabric_DID)) |
James Smart | 0795107 | 2007-04-25 09:51:38 -0400 | [diff] [blame] | 1332 | lpfc_sli_issue_abort_iotag(phba, pring, iocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1333 | } |
| 1334 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1335 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1336 | |
| 1337 | return 0; |
| 1338 | } |
| 1339 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1340 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1341 | * lpfc_initial_flogi - Issue an initial fabric login for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1342 | * @vport: pointer to a host virtual N_Port data structure. |
| 1343 | * |
| 1344 | * This routine issues an initial Fabric Login (FLOGI) for the @vport |
| 1345 | * specified. It first searches the ndlp with the Fabric_DID (0xfffffe) from |
| 1346 | * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and |
| 1347 | * put it into the @vport's ndlp list. If an inactive ndlp found on the list, |
| 1348 | * it will just be enabled and made active. The lpfc_issue_els_flogi() routine |
| 1349 | * is then invoked with the @vport and the ndlp to perform the FLOGI for the |
| 1350 | * @vport. |
| 1351 | * |
| 1352 | * Return code |
| 1353 | * 0 - failed to issue initial flogi for @vport |
| 1354 | * 1 - successfully issued initial flogi for @vport |
| 1355 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1356 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1357 | lpfc_initial_flogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1358 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1359 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1360 | struct lpfc_nodelist *ndlp; |
| 1361 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1362 | vport->port_state = LPFC_FLOGI; |
| 1363 | lpfc_set_disctmo(vport); |
| 1364 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1365 | /* First look for the Fabric ndlp */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1366 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1367 | if (!ndlp) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1368 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1369 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 1370 | if (!ndlp) |
| 1371 | return 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1372 | lpfc_nlp_init(vport, ndlp, Fabric_DID); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 1373 | /* Set the node type */ |
| 1374 | ndlp->nlp_type |= NLP_FABRIC; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1375 | /* Put ndlp onto node list */ |
| 1376 | lpfc_enqueue_node(vport, ndlp); |
| 1377 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 1378 | /* re-setup ndlp without removing from node list */ |
| 1379 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 1380 | if (!ndlp) |
| 1381 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1382 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1383 | |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 1384 | if (lpfc_issue_els_flogi(vport, ndlp, 0)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1385 | /* This decrement of reference count to node shall kick off |
| 1386 | * the release of the node. |
| 1387 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 1388 | lpfc_nlp_put(ndlp); |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 1389 | return 0; |
| 1390 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1391 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1392 | } |
| 1393 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1394 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1395 | * lpfc_initial_fdisc - Issue an initial fabric discovery for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1396 | * @vport: pointer to a host virtual N_Port data structure. |
| 1397 | * |
| 1398 | * This routine issues an initial Fabric Discover (FDISC) for the @vport |
| 1399 | * specified. It first searches the ndlp with the Fabric_DID (0xfffffe) from |
| 1400 | * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and |
| 1401 | * put it into the @vport's ndlp list. If an inactive ndlp found on the list, |
| 1402 | * it will just be enabled and made active. The lpfc_issue_els_fdisc() routine |
| 1403 | * is then invoked with the @vport and the ndlp to perform the FDISC for the |
| 1404 | * @vport. |
| 1405 | * |
| 1406 | * Return code |
| 1407 | * 0 - failed to issue initial fdisc for @vport |
| 1408 | * 1 - successfully issued initial fdisc for @vport |
| 1409 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1410 | int |
| 1411 | lpfc_initial_fdisc(struct lpfc_vport *vport) |
| 1412 | { |
| 1413 | struct lpfc_hba *phba = vport->phba; |
| 1414 | struct lpfc_nodelist *ndlp; |
| 1415 | |
| 1416 | /* First look for the Fabric ndlp */ |
| 1417 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
| 1418 | if (!ndlp) { |
| 1419 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
| 1420 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 1421 | if (!ndlp) |
| 1422 | return 0; |
| 1423 | lpfc_nlp_init(vport, ndlp, Fabric_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1424 | /* Put ndlp onto node list */ |
| 1425 | lpfc_enqueue_node(vport, ndlp); |
| 1426 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 1427 | /* re-setup ndlp without removing from node list */ |
| 1428 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 1429 | if (!ndlp) |
| 1430 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1431 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1432 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1433 | if (lpfc_issue_els_fdisc(vport, ndlp, 0)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1434 | /* decrement node reference count to trigger the release of |
| 1435 | * the node. |
| 1436 | */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1437 | lpfc_nlp_put(ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1438 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1439 | } |
| 1440 | return 1; |
| 1441 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1442 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1443 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1444 | * lpfc_more_plogi - Check and issue remaining plogis for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1445 | * @vport: pointer to a host virtual N_Port data structure. |
| 1446 | * |
| 1447 | * This routine checks whether there are more remaining Port Logins |
| 1448 | * (PLOGI) to be issued for the @vport. If so, it will invoke the routine |
| 1449 | * lpfc_els_disc_plogi() to go through the Node Port Recovery (NPR) nodes |
| 1450 | * to issue ELS PLOGIs up to the configured discover threads with the |
| 1451 | * @vport (@vport->cfg_discovery_threads). The function also decrement |
| 1452 | * the @vport's num_disc_node by 1 if it is not already 0. |
| 1453 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1454 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1455 | lpfc_more_plogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1456 | { |
| 1457 | int sentplogi; |
| 1458 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1459 | if (vport->num_disc_nodes) |
| 1460 | vport->num_disc_nodes--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1461 | |
| 1462 | /* Continue discovery with <num_disc_nodes> PLOGIs to go */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1463 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1464 | "0232 Continue discovery with %d PLOGIs to go " |
| 1465 | "Data: x%x x%x x%x\n", |
| 1466 | vport->num_disc_nodes, vport->fc_plogi_cnt, |
| 1467 | vport->fc_flag, vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1468 | /* Check to see if there are more PLOGIs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1469 | if (vport->fc_flag & FC_NLP_MORE) |
| 1470 | /* go thru NPR nodes and issue any remaining ELS PLOGIs */ |
| 1471 | sentplogi = lpfc_els_disc_plogi(vport); |
| 1472 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1473 | return; |
| 1474 | } |
| 1475 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1476 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1477 | * lpfc_plogi_confirm_nport - Confirm pologi wwpn matches stored ndlp |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1478 | * @phba: pointer to lpfc hba data structure. |
| 1479 | * @prsp: pointer to response IOCB payload. |
| 1480 | * @ndlp: pointer to a node-list data structure. |
| 1481 | * |
| 1482 | * This routine checks and indicates whether the WWPN of an N_Port, retrieved |
| 1483 | * from a PLOGI, matches the WWPN that is stored in the @ndlp for that N_POrt. |
| 1484 | * The following cases are considered N_Port confirmed: |
| 1485 | * 1) The N_Port is a Fabric ndlp; 2) The @ndlp is on vport list and matches |
| 1486 | * the WWPN of the N_Port logged into; 3) The @ndlp is not on vport list but |
| 1487 | * it does not have WWPN assigned either. If the WWPN is confirmed, the |
| 1488 | * pointer to the @ndlp will be returned. If the WWPN is not confirmed: |
| 1489 | * 1) if there is a node on vport list other than the @ndlp with the same |
| 1490 | * WWPN of the N_Port PLOGI logged into, the lpfc_unreg_rpi() will be invoked |
| 1491 | * on that node to release the RPI associated with the node; 2) if there is |
| 1492 | * no node found on vport list with the same WWPN of the N_Port PLOGI logged |
| 1493 | * into, a new node shall be allocated (or activated). In either case, the |
| 1494 | * parameters of the @ndlp shall be copied to the new_ndlp, the @ndlp shall |
| 1495 | * be released and the new_ndlp shall be put on to the vport node list and |
| 1496 | * its pointer returned as the confirmed node. |
| 1497 | * |
| 1498 | * Note that before the @ndlp got "released", the keepDID from not-matching |
| 1499 | * or inactive "new_ndlp" on the vport node list is assigned to the nlp_DID |
| 1500 | * of the @ndlp. This is because the release of @ndlp is actually to put it |
| 1501 | * into an inactive state on the vport node list and the vport node list |
| 1502 | * management algorithm does not allow two node with a same DID. |
| 1503 | * |
| 1504 | * Return code |
| 1505 | * pointer to the PLOGI N_Port @ndlp |
| 1506 | **/ |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1507 | static struct lpfc_nodelist * |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1508 | lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1509 | struct lpfc_nodelist *ndlp) |
| 1510 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1511 | struct lpfc_vport *vport = ndlp->vport; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1512 | struct lpfc_nodelist *new_ndlp; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1513 | struct lpfc_rport_data *rdata; |
| 1514 | struct fc_rport *rport; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1515 | struct serv_parm *sp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1516 | uint8_t name[sizeof(struct lpfc_name)]; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1517 | uint32_t rc, keepDID = 0; |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1518 | int put_node; |
| 1519 | int put_rport; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1520 | unsigned long *active_rrqs_xri_bitmap = NULL; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1521 | |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1522 | /* Fabric nodes can have the same WWPN so we don't bother searching |
| 1523 | * by WWPN. Just return the ndlp that was given to us. |
| 1524 | */ |
| 1525 | if (ndlp->nlp_type & NLP_FABRIC) |
| 1526 | return ndlp; |
| 1527 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1528 | sp = (struct serv_parm *) ((uint8_t *) prsp + sizeof(uint32_t)); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 1529 | memset(name, 0, sizeof(struct lpfc_name)); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1530 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 1531 | /* 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] | 1532 | * we have for that ndlp. If not, we have some work to do. |
| 1533 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1534 | new_ndlp = lpfc_findnode_wwpn(vport, &sp->portName); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1535 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1536 | if (new_ndlp == ndlp && NLP_CHK_NODE_ACT(new_ndlp)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1537 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1538 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1539 | active_rrqs_xri_bitmap = mempool_alloc(phba->active_rrq_pool, |
| 1540 | GFP_KERNEL); |
| 1541 | if (active_rrqs_xri_bitmap) |
| 1542 | memset(active_rrqs_xri_bitmap, 0, |
| 1543 | phba->cfg_rrq_xri_bitmap_sz); |
| 1544 | } |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1545 | |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1546 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1547 | "3178 PLOGI confirm: ndlp %p x%x: new_ndlp %p\n", |
| 1548 | ndlp, ndlp->nlp_DID, new_ndlp); |
| 1549 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1550 | if (!new_ndlp) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1551 | rc = memcmp(&ndlp->nlp_portname, name, |
| 1552 | sizeof(struct lpfc_name)); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1553 | if (!rc) { |
| 1554 | if (active_rrqs_xri_bitmap) |
| 1555 | mempool_free(active_rrqs_xri_bitmap, |
| 1556 | phba->active_rrq_pool); |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1557 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1558 | } |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1559 | new_ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_ATOMIC); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1560 | if (!new_ndlp) { |
| 1561 | if (active_rrqs_xri_bitmap) |
| 1562 | mempool_free(active_rrqs_xri_bitmap, |
| 1563 | phba->active_rrq_pool); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1564 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1565 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1566 | lpfc_nlp_init(vport, new_ndlp, ndlp->nlp_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1567 | } else if (!NLP_CHK_NODE_ACT(new_ndlp)) { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1568 | rc = memcmp(&ndlp->nlp_portname, name, |
| 1569 | sizeof(struct lpfc_name)); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1570 | if (!rc) { |
| 1571 | if (active_rrqs_xri_bitmap) |
| 1572 | mempool_free(active_rrqs_xri_bitmap, |
| 1573 | phba->active_rrq_pool); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1574 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1575 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1576 | new_ndlp = lpfc_enable_node(vport, new_ndlp, |
| 1577 | NLP_STE_UNUSED_NODE); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1578 | if (!new_ndlp) { |
| 1579 | if (active_rrqs_xri_bitmap) |
| 1580 | mempool_free(active_rrqs_xri_bitmap, |
| 1581 | phba->active_rrq_pool); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1582 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1583 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1584 | keepDID = new_ndlp->nlp_DID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1585 | if ((phba->sli_rev == LPFC_SLI_REV4) && active_rrqs_xri_bitmap) |
| 1586 | memcpy(active_rrqs_xri_bitmap, |
| 1587 | new_ndlp->active_rrqs_xri_bitmap, |
| 1588 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1589 | } else { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1590 | keepDID = new_ndlp->nlp_DID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1591 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1592 | active_rrqs_xri_bitmap) |
| 1593 | memcpy(active_rrqs_xri_bitmap, |
| 1594 | new_ndlp->active_rrqs_xri_bitmap, |
| 1595 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1596 | } |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1597 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1598 | lpfc_unreg_rpi(vport, new_ndlp); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1599 | new_ndlp->nlp_DID = ndlp->nlp_DID; |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1600 | new_ndlp->nlp_prev_state = ndlp->nlp_prev_state; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1601 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1602 | memcpy(new_ndlp->active_rrqs_xri_bitmap, |
| 1603 | ndlp->active_rrqs_xri_bitmap, |
| 1604 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1605 | |
| 1606 | if (ndlp->nlp_flag & NLP_NPR_2B_DISC) |
| 1607 | new_ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
| 1608 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
| 1609 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1610 | /* 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] | 1611 | lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1612 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1613 | /* Move this back to NPR state */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1614 | if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0) { |
| 1615 | /* The new_ndlp is replacing ndlp totally, so we need |
| 1616 | * to put ndlp on UNUSED list and try to free it. |
| 1617 | */ |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1618 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1619 | "3179 PLOGI confirm NEW: %x %x\n", |
| 1620 | new_ndlp->nlp_DID, keepDID); |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1621 | |
| 1622 | /* Fix up the rport accordingly */ |
| 1623 | rport = ndlp->rport; |
| 1624 | if (rport) { |
| 1625 | rdata = rport->dd_data; |
| 1626 | if (rdata->pnode == ndlp) { |
| 1627 | lpfc_nlp_put(ndlp); |
| 1628 | ndlp->rport = NULL; |
| 1629 | rdata->pnode = lpfc_nlp_get(new_ndlp); |
| 1630 | new_ndlp->rport = rport; |
| 1631 | } |
| 1632 | new_ndlp->nlp_type = ndlp->nlp_type; |
| 1633 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1634 | /* We shall actually free the ndlp with both nlp_DID and |
| 1635 | * nlp_portname fields equals 0 to avoid any ndlp on the |
| 1636 | * nodelist never to be used. |
| 1637 | */ |
| 1638 | if (ndlp->nlp_DID == 0) { |
| 1639 | spin_lock_irq(&phba->ndlp_lock); |
| 1640 | NLP_SET_FREE_REQ(ndlp); |
| 1641 | spin_unlock_irq(&phba->ndlp_lock); |
| 1642 | } |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1643 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1644 | /* Two ndlps cannot have the same did on the nodelist */ |
| 1645 | ndlp->nlp_DID = keepDID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1646 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1647 | active_rrqs_xri_bitmap) |
| 1648 | memcpy(ndlp->active_rrqs_xri_bitmap, |
| 1649 | active_rrqs_xri_bitmap, |
| 1650 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1651 | lpfc_drop_node(vport, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1652 | } |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1653 | else { |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1654 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1655 | "3180 PLOGI confirm SWAP: %x %x\n", |
| 1656 | new_ndlp->nlp_DID, keepDID); |
| 1657 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1658 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1659 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1660 | /* Two ndlps cannot have the same did */ |
| 1661 | ndlp->nlp_DID = keepDID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1662 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1663 | active_rrqs_xri_bitmap) |
| 1664 | memcpy(ndlp->active_rrqs_xri_bitmap, |
| 1665 | active_rrqs_xri_bitmap, |
| 1666 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1667 | |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1668 | /* Since we are swapping the ndlp passed in with the new one |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1669 | * and the did has already been swapped, copy over state. |
| 1670 | * The new WWNs are already in new_ndlp since thats what |
| 1671 | * we looked it up by in the begining of this routine. |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1672 | */ |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1673 | new_ndlp->nlp_state = ndlp->nlp_state; |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1674 | |
| 1675 | /* Since we are switching over to the new_ndlp, the old |
| 1676 | * ndlp should be put in the NPR state, unless we have |
| 1677 | * already started re-discovery on it. |
| 1678 | */ |
| 1679 | if ((ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) || |
| 1680 | (ndlp->nlp_state == NLP_STE_MAPPED_NODE)) |
| 1681 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 1682 | |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1683 | /* Fix up the rport accordingly */ |
| 1684 | rport = ndlp->rport; |
| 1685 | if (rport) { |
| 1686 | rdata = rport->dd_data; |
| 1687 | put_node = rdata->pnode != NULL; |
| 1688 | put_rport = ndlp->rport != NULL; |
| 1689 | rdata->pnode = NULL; |
| 1690 | ndlp->rport = NULL; |
| 1691 | if (put_node) |
| 1692 | lpfc_nlp_put(ndlp); |
| 1693 | if (put_rport) |
| 1694 | put_device(&rport->dev); |
| 1695 | } |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1696 | } |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1697 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1698 | active_rrqs_xri_bitmap) |
| 1699 | mempool_free(active_rrqs_xri_bitmap, |
| 1700 | phba->active_rrq_pool); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1701 | return new_ndlp; |
| 1702 | } |
| 1703 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1704 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1705 | * lpfc_end_rscn - Check and handle more rscn for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1706 | * @vport: pointer to a host virtual N_Port data structure. |
| 1707 | * |
| 1708 | * This routine checks whether more Registration State Change |
| 1709 | * Notifications (RSCNs) came in while the discovery state machine was in |
| 1710 | * the FC_RSCN_MODE. If so, the lpfc_els_handle_rscn() routine will be |
| 1711 | * invoked to handle the additional RSCNs for the @vport. Otherwise, the |
| 1712 | * FC_RSCN_MODE bit will be cleared with the @vport to mark as the end of |
| 1713 | * handling the RSCNs. |
| 1714 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1715 | void |
| 1716 | lpfc_end_rscn(struct lpfc_vport *vport) |
| 1717 | { |
| 1718 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 1719 | |
| 1720 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 1721 | /* |
| 1722 | * Check to see if more RSCNs came in while we were |
| 1723 | * processing this one. |
| 1724 | */ |
| 1725 | if (vport->fc_rscn_id_cnt || |
| 1726 | (vport->fc_flag & FC_RSCN_DISCOVERY) != 0) |
| 1727 | lpfc_els_handle_rscn(vport); |
| 1728 | else { |
| 1729 | spin_lock_irq(shost->host_lock); |
| 1730 | vport->fc_flag &= ~FC_RSCN_MODE; |
| 1731 | spin_unlock_irq(shost->host_lock); |
| 1732 | } |
| 1733 | } |
| 1734 | } |
| 1735 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1736 | /** |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1737 | * lpfc_cmpl_els_rrq - Completion handled for els RRQs. |
| 1738 | * @phba: pointer to lpfc hba data structure. |
| 1739 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 1740 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 1741 | * |
| 1742 | * This routine will call the clear rrq function to free the rrq and |
| 1743 | * clear the xri's bit in the ndlp's xri_bitmap. If the ndlp does not |
| 1744 | * exist then the clear_rrq is still called because the rrq needs to |
| 1745 | * be freed. |
| 1746 | **/ |
| 1747 | |
| 1748 | static void |
| 1749 | lpfc_cmpl_els_rrq(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1750 | struct lpfc_iocbq *rspiocb) |
| 1751 | { |
| 1752 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1753 | IOCB_t *irsp; |
| 1754 | struct lpfc_nodelist *ndlp; |
| 1755 | struct lpfc_node_rrq *rrq; |
| 1756 | |
| 1757 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 1758 | rrq = cmdiocb->context_un.rrq; |
| 1759 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 1760 | |
| 1761 | irsp = &rspiocb->iocb; |
| 1762 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1763 | "RRQ cmpl: status:x%x/x%x did:x%x", |
| 1764 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1765 | irsp->un.elsreq64.remoteID); |
| 1766 | |
| 1767 | ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); |
| 1768 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) || ndlp != rrq->ndlp) { |
| 1769 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1770 | "2882 RRQ completes to NPort x%x " |
| 1771 | "with no ndlp. Data: x%x x%x x%x\n", |
| 1772 | irsp->un.elsreq64.remoteID, |
| 1773 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1774 | irsp->ulpIoTag); |
| 1775 | goto out; |
| 1776 | } |
| 1777 | |
| 1778 | /* rrq completes to NPort <nlp_DID> */ |
| 1779 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1780 | "2880 RRQ completes to NPort x%x " |
| 1781 | "Data: x%x x%x x%x x%x x%x\n", |
| 1782 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1783 | irsp->ulpTimeout, rrq->xritag, rrq->rxid); |
| 1784 | |
| 1785 | if (irsp->ulpStatus) { |
| 1786 | /* Check for retry */ |
| 1787 | /* RRQ failed Don't print the vport to vport rjts */ |
| 1788 | if (irsp->ulpStatus != IOSTAT_LS_RJT || |
| 1789 | (((irsp->un.ulpWord[4]) >> 16 != LSRJT_INVALID_CMD) && |
| 1790 | ((irsp->un.ulpWord[4]) >> 16 != LSRJT_UNABLE_TPC)) || |
| 1791 | (phba)->pport->cfg_log_verbose & LOG_ELS) |
| 1792 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1793 | "2881 RRQ failure DID:%06X Status:x%x/x%x\n", |
| 1794 | ndlp->nlp_DID, irsp->ulpStatus, |
| 1795 | irsp->un.ulpWord[4]); |
| 1796 | } |
| 1797 | out: |
| 1798 | if (rrq) |
| 1799 | lpfc_clr_rrq_active(phba, rrq->xritag, rrq); |
| 1800 | lpfc_els_free_iocb(phba, cmdiocb); |
| 1801 | return; |
| 1802 | } |
| 1803 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1804 | * lpfc_cmpl_els_plogi - Completion callback function for plogi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1805 | * @phba: pointer to lpfc hba data structure. |
| 1806 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 1807 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 1808 | * |
| 1809 | * This routine is the completion callback function for issuing the Port |
| 1810 | * Login (PLOGI) command. For PLOGI completion, there must be an active |
| 1811 | * 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] | 1812 | * 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] | 1813 | * ignored and command IOCB released. The PLOGI response IOCB status is |
| 1814 | * checked for error conditons. If there is error status reported, PLOGI |
| 1815 | * retry shall be attempted by invoking the lpfc_els_retry() routine. |
| 1816 | * Otherwise, the lpfc_plogi_confirm_nport() routine shall be invoked on |
| 1817 | * the ndlp and the NLP_EVT_CMPL_PLOGI state to the Discover State Machine |
| 1818 | * (DSM) is set for this PLOGI completion. Finally, it checks whether |
| 1819 | * there are additional N_Port nodes with the vport that need to perform |
| 1820 | * PLOGI. If so, the lpfc_more_plogi() routine is invoked to issue addition |
| 1821 | * PLOGIs. |
| 1822 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1823 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1824 | lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1825 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1826 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1827 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1828 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1829 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1830 | struct lpfc_nodelist *ndlp; |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1831 | struct lpfc_dmabuf *prsp; |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame^] | 1832 | int disc, rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1833 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1834 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 1835 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 1836 | |
| 1837 | irsp = &rspiocb->iocb; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1838 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1839 | "PLOGI cmpl: status:x%x/x%x did:x%x", |
| 1840 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1841 | irsp->un.elsreq64.remoteID); |
| 1842 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1843 | ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1844 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1845 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1846 | "0136 PLOGI completes to NPort x%x " |
| 1847 | "with no ndlp. Data: x%x x%x x%x\n", |
| 1848 | irsp->un.elsreq64.remoteID, |
| 1849 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1850 | irsp->ulpIoTag); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1851 | goto out; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 1852 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1853 | |
| 1854 | /* Since ndlp can be freed in the disc state machine, note if this node |
| 1855 | * is being used during discovery. |
| 1856 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1857 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1858 | disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1859 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1860 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1861 | rc = 0; |
| 1862 | |
| 1863 | /* PLOGI completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1864 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1865 | "0102 PLOGI completes to NPort x%x " |
| 1866 | "Data: x%x x%x x%x x%x x%x\n", |
| 1867 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1868 | irsp->ulpTimeout, disc, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1869 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1870 | if (lpfc_els_chk_latt(vport)) { |
| 1871 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1872 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1873 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1874 | goto out; |
| 1875 | } |
| 1876 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1877 | if (irsp->ulpStatus) { |
| 1878 | /* Check for retry */ |
| 1879 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 1880 | /* ELS command is being retried */ |
| 1881 | if (disc) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1882 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1883 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1884 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1885 | } |
| 1886 | goto out; |
| 1887 | } |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 1888 | /* PLOGI failed Don't print the vport to vport rjts */ |
| 1889 | if (irsp->ulpStatus != IOSTAT_LS_RJT || |
| 1890 | (((irsp->un.ulpWord[4]) >> 16 != LSRJT_INVALID_CMD) && |
| 1891 | ((irsp->un.ulpWord[4]) >> 16 != LSRJT_UNABLE_TPC)) || |
| 1892 | (phba)->pport->cfg_log_verbose & LOG_ELS) |
| 1893 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 1894 | "2753 PLOGI failure DID:%06X Status:x%x/x%x\n", |
| 1895 | ndlp->nlp_DID, irsp->ulpStatus, |
| 1896 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1897 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1898 | if (lpfc_error_lost_link(irsp)) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1899 | rc = NLP_STE_FREED_NODE; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1900 | else |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1901 | rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1902 | NLP_EVT_CMPL_PLOGI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1903 | } else { |
| 1904 | /* Good status, call state machine */ |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1905 | prsp = list_entry(((struct lpfc_dmabuf *) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1906 | cmdiocb->context2)->list.next, |
| 1907 | struct lpfc_dmabuf, list); |
| 1908 | ndlp = lpfc_plogi_confirm_nport(phba, prsp->virt, ndlp); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1909 | rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1910 | NLP_EVT_CMPL_PLOGI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1911 | } |
| 1912 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1913 | if (disc && vport->num_disc_nodes) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1914 | /* Check to see if there are more PLOGIs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1915 | lpfc_more_plogi(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1916 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1917 | if (vport->num_disc_nodes == 0) { |
| 1918 | spin_lock_irq(shost->host_lock); |
| 1919 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 1920 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1921 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1922 | lpfc_can_disctmo(vport); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1923 | lpfc_end_rscn(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1924 | } |
| 1925 | } |
| 1926 | |
| 1927 | out: |
| 1928 | lpfc_els_free_iocb(phba, cmdiocb); |
| 1929 | return; |
| 1930 | } |
| 1931 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1932 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1933 | * lpfc_issue_els_plogi - Issue an plogi iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1934 | * @vport: pointer to a host virtual N_Port data structure. |
| 1935 | * @did: destination port identifier. |
| 1936 | * @retry: number of retries to the command IOCB. |
| 1937 | * |
| 1938 | * This routine issues a Port Login (PLOGI) command to a remote N_Port |
| 1939 | * (with the @did) for a @vport. Before issuing a PLOGI to a remote N_Port, |
| 1940 | * the ndlp with the remote N_Port DID must exist on the @vport's ndlp list. |
| 1941 | * This routine constructs the proper feilds of the PLOGI IOCB and invokes |
| 1942 | * the lpfc_sli_issue_iocb() routine to send out PLOGI ELS command. |
| 1943 | * |
| 1944 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 1945 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 1946 | * will be stored into the context1 field of the IOCB for the completion |
| 1947 | * callback function to the PLOGI ELS command. |
| 1948 | * |
| 1949 | * Return code |
| 1950 | * 0 - Successfully issued a plogi for @vport |
| 1951 | * 1 - failed to issue a plogi for @vport |
| 1952 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1953 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1954 | lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1955 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1956 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1957 | struct serv_parm *sp; |
| 1958 | IOCB_t *icmd; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1959 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1960 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1961 | struct lpfc_sli *psli; |
| 1962 | uint8_t *pcmd; |
| 1963 | uint16_t cmdsize; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1964 | int ret; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1965 | |
| 1966 | psli = &phba->sli; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1967 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1968 | ndlp = lpfc_findnode_did(vport, did); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1969 | if (ndlp && !NLP_CHK_NODE_ACT(ndlp)) |
| 1970 | ndlp = NULL; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1971 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1972 | /* 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] | 1973 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1974 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1975 | ELS_CMD_PLOGI); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1976 | if (!elsiocb) |
| 1977 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1978 | |
| 1979 | icmd = &elsiocb->iocb; |
| 1980 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 1981 | |
| 1982 | /* For PLOGI request, remainder of payload is service parameters */ |
| 1983 | *((uint32_t *) (pcmd)) = ELS_CMD_PLOGI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1984 | pcmd += sizeof(uint32_t); |
| 1985 | memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1986 | sp = (struct serv_parm *) pcmd; |
| 1987 | |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 1988 | /* |
| 1989 | * If we are a N-port connected to a Fabric, fix-up paramm's so logins |
| 1990 | * to device on remote loops work. |
| 1991 | */ |
| 1992 | if ((vport->fc_flag & FC_FABRIC) && !(vport->fc_flag & FC_PUBLIC_LOOP)) |
| 1993 | sp->cmn.altBbCredit = 1; |
| 1994 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1995 | if (sp->cmn.fcphLow < FC_PH_4_3) |
| 1996 | sp->cmn.fcphLow = FC_PH_4_3; |
| 1997 | |
| 1998 | if (sp->cmn.fcphHigh < FC_PH3) |
| 1999 | sp->cmn.fcphHigh = FC_PH3; |
| 2000 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2001 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2002 | "Issue PLOGI: did:x%x", |
| 2003 | did, 0, 0); |
| 2004 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2005 | phba->fc_stat.elsXmitPLOGI++; |
| 2006 | elsiocb->iocb_cmpl = lpfc_cmpl_els_plogi; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2007 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2008 | |
| 2009 | if (ret == IOCB_ERROR) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2010 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2011 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2012 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2013 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2014 | } |
| 2015 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2016 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2017 | * lpfc_cmpl_els_prli - Completion callback function for prli |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2018 | * @phba: pointer to lpfc hba data structure. |
| 2019 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2020 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2021 | * |
| 2022 | * This routine is the completion callback function for a Process Login |
| 2023 | * (PRLI) ELS command. The PRLI response IOCB status is checked for error |
| 2024 | * status. If there is error status reported, PRLI retry shall be attempted |
| 2025 | * by invoking the lpfc_els_retry() routine. Otherwise, the state |
| 2026 | * NLP_EVT_CMPL_PRLI is sent to the Discover State Machine (DSM) for this |
| 2027 | * ndlp to mark the PRLI completion. |
| 2028 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2029 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2030 | lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2031 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2032 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2033 | struct lpfc_vport *vport = cmdiocb->vport; |
| 2034 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2035 | IOCB_t *irsp; |
| 2036 | struct lpfc_sli *psli; |
| 2037 | struct lpfc_nodelist *ndlp; |
| 2038 | |
| 2039 | psli = &phba->sli; |
| 2040 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 2041 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 2042 | |
| 2043 | irsp = &(rspiocb->iocb); |
| 2044 | ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2045 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2046 | ndlp->nlp_flag &= ~NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2047 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2048 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2049 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2050 | "PRLI cmpl: status:x%x/x%x did:x%x", |
| 2051 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2052 | ndlp->nlp_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2053 | /* PRLI completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2054 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2055 | "0103 PRLI completes to NPort x%x " |
| 2056 | "Data: x%x x%x x%x x%x\n", |
| 2057 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2058 | irsp->ulpTimeout, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2059 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2060 | vport->fc_prli_sent--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2061 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2062 | if (lpfc_els_chk_latt(vport)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2063 | goto out; |
| 2064 | |
| 2065 | if (irsp->ulpStatus) { |
| 2066 | /* Check for retry */ |
| 2067 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 2068 | /* ELS command is being retried */ |
| 2069 | goto out; |
| 2070 | } |
| 2071 | /* PRLI failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2072 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2073 | "2754 PRLI failure DID:%06X Status:x%x/x%x\n", |
| 2074 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2075 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2076 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2077 | if (lpfc_error_lost_link(irsp)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2078 | goto out; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2079 | else |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2080 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2081 | NLP_EVT_CMPL_PRLI); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2082 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2083 | /* Good status, call state machine */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2084 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2085 | NLP_EVT_CMPL_PRLI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2086 | out: |
| 2087 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2088 | return; |
| 2089 | } |
| 2090 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2091 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2092 | * lpfc_issue_els_prli - Issue a prli iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2093 | * @vport: pointer to a host virtual N_Port data structure. |
| 2094 | * @ndlp: pointer to a node-list data structure. |
| 2095 | * @retry: number of retries to the command IOCB. |
| 2096 | * |
| 2097 | * This routine issues a Process Login (PRLI) ELS command for the |
| 2098 | * @vport. The PRLI service parameters are set up in the payload of the |
| 2099 | * PRLI Request command and the pointer to lpfc_cmpl_els_prli() routine |
| 2100 | * is put to the IOCB completion callback func field before invoking the |
| 2101 | * routine lpfc_sli_issue_iocb() to send out PRLI command. |
| 2102 | * |
| 2103 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2104 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2105 | * will be stored into the context1 field of the IOCB for the completion |
| 2106 | * callback function to the PRLI ELS command. |
| 2107 | * |
| 2108 | * Return code |
| 2109 | * 0 - successfully issued prli iocb command for @vport |
| 2110 | * 1 - failed to issue prli iocb command for @vport |
| 2111 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2112 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2113 | lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2114 | uint8_t retry) |
| 2115 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2116 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2117 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2118 | PRLI *npr; |
| 2119 | IOCB_t *icmd; |
| 2120 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2121 | uint8_t *pcmd; |
| 2122 | uint16_t cmdsize; |
| 2123 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2124 | cmdsize = (sizeof(uint32_t) + sizeof(PRLI)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2125 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2126 | ndlp->nlp_DID, ELS_CMD_PRLI); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2127 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2128 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2129 | |
| 2130 | icmd = &elsiocb->iocb; |
| 2131 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2132 | |
| 2133 | /* For PRLI request, remainder of payload is service parameters */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2134 | memset(pcmd, 0, (sizeof(PRLI) + sizeof(uint32_t))); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2135 | *((uint32_t *) (pcmd)) = ELS_CMD_PRLI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2136 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2137 | |
| 2138 | /* For PRLI, remainder of payload is PRLI parameter page */ |
| 2139 | npr = (PRLI *) pcmd; |
| 2140 | /* |
| 2141 | * If our firmware version is 3.20 or later, |
| 2142 | * set the following bits for FC-TAPE support. |
| 2143 | */ |
| 2144 | if (phba->vpd.rev.feaLevelHigh >= 0x02) { |
| 2145 | npr->ConfmComplAllowed = 1; |
| 2146 | npr->Retry = 1; |
| 2147 | npr->TaskRetryIdReq = 1; |
| 2148 | } |
| 2149 | npr->estabImagePair = 1; |
| 2150 | npr->readXferRdyDis = 1; |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 2151 | if (vport->cfg_first_burst_size) |
| 2152 | npr->writeXferRdyDis = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2153 | |
| 2154 | /* For FCP support */ |
| 2155 | npr->prliType = PRLI_FCP_TYPE; |
| 2156 | npr->initiatorFunc = 1; |
| 2157 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2158 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2159 | "Issue PRLI: did:x%x", |
| 2160 | ndlp->nlp_DID, 0, 0); |
| 2161 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2162 | phba->fc_stat.elsXmitPRLI++; |
| 2163 | elsiocb->iocb_cmpl = lpfc_cmpl_els_prli; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2164 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2165 | ndlp->nlp_flag |= NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2166 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2167 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2168 | IOCB_ERROR) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2169 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2170 | ndlp->nlp_flag &= ~NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2171 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2172 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2173 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2174 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2175 | vport->fc_prli_sent++; |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2176 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2177 | } |
| 2178 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2179 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2180 | * lpfc_rscn_disc - Perform rscn discovery for a vport |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2181 | * @vport: pointer to a host virtual N_Port data structure. |
| 2182 | * |
| 2183 | * This routine performs Registration State Change Notification (RSCN) |
| 2184 | * discovery for a @vport. If the @vport's node port recovery count is not |
| 2185 | * zero, it will invoke the lpfc_els_disc_plogi() to perform PLOGI for all |
| 2186 | * the nodes that need recovery. If none of the PLOGI were needed through |
| 2187 | * the lpfc_els_disc_plogi() routine, the lpfc_end_rscn() routine shall be |
| 2188 | * invoked to check and handle possible more RSCN came in during the period |
| 2189 | * of processing the current ones. |
| 2190 | **/ |
| 2191 | static void |
| 2192 | lpfc_rscn_disc(struct lpfc_vport *vport) |
| 2193 | { |
| 2194 | lpfc_can_disctmo(vport); |
| 2195 | |
| 2196 | /* RSCN discovery */ |
| 2197 | /* go thru NPR nodes and issue ELS PLOGIs */ |
| 2198 | if (vport->fc_npr_cnt) |
| 2199 | if (lpfc_els_disc_plogi(vport)) |
| 2200 | return; |
| 2201 | |
| 2202 | lpfc_end_rscn(vport); |
| 2203 | } |
| 2204 | |
| 2205 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2206 | * lpfc_adisc_done - Complete the adisc phase of discovery |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2207 | * @vport: pointer to lpfc_vport hba data structure that finished all ADISCs. |
| 2208 | * |
| 2209 | * This function is called when the final ADISC is completed during discovery. |
| 2210 | * This function handles clearing link attention or issuing reg_vpi depending |
| 2211 | * on whether npiv is enabled. This function also kicks off the PLOGI phase of |
| 2212 | * discovery. |
| 2213 | * This function is called with no locks held. |
| 2214 | **/ |
| 2215 | static void |
| 2216 | lpfc_adisc_done(struct lpfc_vport *vport) |
| 2217 | { |
| 2218 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2219 | struct lpfc_hba *phba = vport->phba; |
| 2220 | |
| 2221 | /* |
| 2222 | * For NPIV, cmpl_reg_vpi will set port_state to READY, |
| 2223 | * and continue discovery. |
| 2224 | */ |
| 2225 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 2226 | !(vport->fc_flag & FC_RSCN_MODE) && |
| 2227 | (phba->sli_rev < LPFC_SLI_REV4)) { |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2228 | lpfc_issue_reg_vpi(phba, vport); |
| 2229 | return; |
| 2230 | } |
| 2231 | /* |
| 2232 | * For SLI2, we need to set port_state to READY |
| 2233 | * and continue discovery. |
| 2234 | */ |
| 2235 | if (vport->port_state < LPFC_VPORT_READY) { |
| 2236 | /* If we get here, there is nothing to ADISC */ |
| 2237 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 2238 | lpfc_issue_clear_la(phba, vport); |
| 2239 | if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) { |
| 2240 | vport->num_disc_nodes = 0; |
| 2241 | /* go thru NPR list, issue ELS PLOGIs */ |
| 2242 | if (vport->fc_npr_cnt) |
| 2243 | lpfc_els_disc_plogi(vport); |
| 2244 | if (!vport->num_disc_nodes) { |
| 2245 | spin_lock_irq(shost->host_lock); |
| 2246 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 2247 | spin_unlock_irq(shost->host_lock); |
| 2248 | lpfc_can_disctmo(vport); |
| 2249 | lpfc_end_rscn(vport); |
| 2250 | } |
| 2251 | } |
| 2252 | vport->port_state = LPFC_VPORT_READY; |
| 2253 | } else |
| 2254 | lpfc_rscn_disc(vport); |
| 2255 | } |
| 2256 | |
| 2257 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2258 | * lpfc_more_adisc - Issue more adisc as needed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2259 | * @vport: pointer to a host virtual N_Port data structure. |
| 2260 | * |
| 2261 | * This routine determines whether there are more ndlps on a @vport |
| 2262 | * node list need to have Address Discover (ADISC) issued. If so, it will |
| 2263 | * invoke the lpfc_els_disc_adisc() routine to issue ADISC on the @vport's |
| 2264 | * remaining nodes which need to have ADISC sent. |
| 2265 | **/ |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 2266 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2267 | lpfc_more_adisc(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2268 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2269 | if (vport->num_disc_nodes) |
| 2270 | vport->num_disc_nodes--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2271 | /* Continue discovery with <num_disc_nodes> ADISCs to go */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2272 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 2273 | "0210 Continue discovery with %d ADISCs to go " |
| 2274 | "Data: x%x x%x x%x\n", |
| 2275 | vport->num_disc_nodes, vport->fc_adisc_cnt, |
| 2276 | vport->fc_flag, vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2277 | /* Check to see if there are more ADISCs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2278 | if (vport->fc_flag & FC_NLP_MORE) { |
| 2279 | lpfc_set_disctmo(vport); |
| 2280 | /* go thru NPR nodes and issue any remaining ELS ADISCs */ |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame^] | 2281 | lpfc_els_disc_adisc(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2282 | } |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2283 | if (!vport->num_disc_nodes) |
| 2284 | lpfc_adisc_done(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2285 | return; |
| 2286 | } |
| 2287 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2288 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2289 | * lpfc_cmpl_els_adisc - Completion callback function for adisc |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2290 | * @phba: pointer to lpfc hba data structure. |
| 2291 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2292 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2293 | * |
| 2294 | * This routine is the completion function for issuing the Address Discover |
| 2295 | * (ADISC) command. It first checks to see whether link went down during |
| 2296 | * the discovery process. If so, the node will be marked as node port |
| 2297 | * recovery for issuing discover IOCB by the link attention handler and |
| 2298 | * exit. Otherwise, the response status is checked. If error was reported |
| 2299 | * in the response status, the ADISC command shall be retried by invoking |
| 2300 | * the lpfc_els_retry() routine. Otherwise, if no error was reported in |
| 2301 | * the response status, the state machine is invoked to set transition |
| 2302 | * with respect to NLP_EVT_CMPL_ADISC event. |
| 2303 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2304 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2305 | lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2306 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2307 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2308 | struct lpfc_vport *vport = cmdiocb->vport; |
| 2309 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2310 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2311 | struct lpfc_nodelist *ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2312 | int disc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2313 | |
| 2314 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 2315 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 2316 | |
| 2317 | irsp = &(rspiocb->iocb); |
| 2318 | ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2319 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2320 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2321 | "ADISC cmpl: status:x%x/x%x did:x%x", |
| 2322 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2323 | ndlp->nlp_DID); |
| 2324 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2325 | /* Since ndlp can be freed in the disc state machine, note if this node |
| 2326 | * is being used during discovery. |
| 2327 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2328 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2329 | disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2330 | ndlp->nlp_flag &= ~(NLP_ADISC_SND | NLP_NPR_2B_DISC); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2331 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2332 | /* ADISC completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2333 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2334 | "0104 ADISC completes to NPort x%x " |
| 2335 | "Data: x%x x%x x%x x%x x%x\n", |
| 2336 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2337 | irsp->ulpTimeout, disc, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2338 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2339 | if (lpfc_els_chk_latt(vport)) { |
| 2340 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2341 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2342 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2343 | goto out; |
| 2344 | } |
| 2345 | |
| 2346 | if (irsp->ulpStatus) { |
| 2347 | /* Check for retry */ |
| 2348 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 2349 | /* ELS command is being retried */ |
| 2350 | if (disc) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2351 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2352 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2353 | spin_unlock_irq(shost->host_lock); |
| 2354 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2355 | } |
| 2356 | goto out; |
| 2357 | } |
| 2358 | /* ADISC failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2359 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2360 | "2755 ADISC failure DID:%06X Status:x%x/x%x\n", |
| 2361 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2362 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2363 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2364 | if (!lpfc_error_lost_link(irsp)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2365 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2366 | NLP_EVT_CMPL_ADISC); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2367 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2368 | /* Good status, call state machine */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2369 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2370 | NLP_EVT_CMPL_ADISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2371 | |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2372 | /* Check to see if there are more ADISCs to be sent */ |
| 2373 | if (disc && vport->num_disc_nodes) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2374 | lpfc_more_adisc(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2375 | out: |
| 2376 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2377 | return; |
| 2378 | } |
| 2379 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2380 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2381 | * 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] | 2382 | * @vport: pointer to a virtual N_Port data structure. |
| 2383 | * @ndlp: pointer to a node-list data structure. |
| 2384 | * @retry: number of retries to the command IOCB. |
| 2385 | * |
| 2386 | * This routine issues an Address Discover (ADISC) for an @ndlp on a |
| 2387 | * @vport. It prepares the payload of the ADISC ELS command, updates the |
| 2388 | * and states of the ndlp, and invokes the lpfc_sli_issue_iocb() routine |
| 2389 | * to issue the ADISC ELS command. |
| 2390 | * |
| 2391 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2392 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2393 | * will be stored into the context1 field of the IOCB for the completion |
| 2394 | * callback function to the ADISC ELS command. |
| 2395 | * |
| 2396 | * Return code |
| 2397 | * 0 - successfully issued adisc |
| 2398 | * 1 - failed to issue adisc |
| 2399 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2400 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2401 | lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2402 | uint8_t retry) |
| 2403 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2404 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2405 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2406 | ADISC *ap; |
| 2407 | IOCB_t *icmd; |
| 2408 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2409 | uint8_t *pcmd; |
| 2410 | uint16_t cmdsize; |
| 2411 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2412 | cmdsize = (sizeof(uint32_t) + sizeof(ADISC)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2413 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2414 | ndlp->nlp_DID, ELS_CMD_ADISC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2415 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2416 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2417 | |
| 2418 | icmd = &elsiocb->iocb; |
| 2419 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2420 | |
| 2421 | /* For ADISC request, remainder of payload is service parameters */ |
| 2422 | *((uint32_t *) (pcmd)) = ELS_CMD_ADISC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2423 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2424 | |
| 2425 | /* Fill in ADISC payload */ |
| 2426 | ap = (ADISC *) pcmd; |
| 2427 | ap->hardAL_PA = phba->fc_pref_ALPA; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2428 | memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 2429 | memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2430 | ap->DID = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2431 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2432 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2433 | "Issue ADISC: did:x%x", |
| 2434 | ndlp->nlp_DID, 0, 0); |
| 2435 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2436 | phba->fc_stat.elsXmitADISC++; |
| 2437 | elsiocb->iocb_cmpl = lpfc_cmpl_els_adisc; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2438 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2439 | ndlp->nlp_flag |= NLP_ADISC_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2440 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2441 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2442 | IOCB_ERROR) { |
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); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2446 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2447 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2448 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2449 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2450 | } |
| 2451 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2452 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2453 | * lpfc_cmpl_els_logo - Completion callback function for logo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2454 | * @phba: pointer to lpfc hba data structure. |
| 2455 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2456 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2457 | * |
| 2458 | * This routine is the completion function for issuing the ELS Logout (LOGO) |
| 2459 | * command. If no error status was reported from the LOGO response, the |
| 2460 | * state machine of the associated ndlp shall be invoked for transition with |
| 2461 | * respect to NLP_EVT_CMPL_LOGO event. Otherwise, if error status was reported, |
| 2462 | * the lpfc_els_retry() routine will be invoked to retry the LOGO command. |
| 2463 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2464 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2465 | lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2466 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2467 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2468 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 2469 | struct lpfc_vport *vport = ndlp->vport; |
| 2470 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2471 | IOCB_t *irsp; |
| 2472 | struct lpfc_sli *psli; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 2473 | struct lpfcMboxq *mbox; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2474 | unsigned long flags; |
| 2475 | uint32_t skip_recovery = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2476 | |
| 2477 | psli = &phba->sli; |
| 2478 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 2479 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 2480 | |
| 2481 | irsp = &(rspiocb->iocb); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2482 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2483 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2484 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2485 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2486 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2487 | "LOGO cmpl: status:x%x/x%x did:x%x", |
| 2488 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2489 | ndlp->nlp_DID); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2490 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2491 | /* LOGO completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2492 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2493 | "0105 LOGO completes to NPort x%x " |
| 2494 | "Data: x%x x%x x%x x%x\n", |
| 2495 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2496 | irsp->ulpTimeout, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2497 | |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2498 | if (lpfc_els_chk_latt(vport)) { |
| 2499 | skip_recovery = 1; |
| 2500 | goto out; |
| 2501 | } |
| 2502 | |
| 2503 | /* Check to see if link went down during discovery */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2504 | if (ndlp->nlp_flag & NLP_TARGET_REMOVE) { |
| 2505 | /* NLP_EVT_DEVICE_RM should unregister the RPI |
| 2506 | * which should abort all outstanding IOs. |
| 2507 | */ |
| 2508 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
| 2509 | NLP_EVT_DEVICE_RM); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2510 | skip_recovery = 1; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2511 | goto out; |
| 2512 | } |
| 2513 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2514 | if (irsp->ulpStatus) { |
| 2515 | /* Check for retry */ |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2516 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2517 | /* ELS command is being retried */ |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2518 | skip_recovery = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2519 | goto out; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2520 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2521 | /* LOGO failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2522 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2523 | "2756 LOGO failure DID:%06X Status:x%x/x%x\n", |
| 2524 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2525 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2526 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2527 | if (lpfc_error_lost_link(irsp)) { |
| 2528 | skip_recovery = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2529 | goto out; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2530 | } |
| 2531 | } |
| 2532 | |
| 2533 | /* Call state machine. This will unregister the rpi if needed. */ |
| 2534 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_CMPL_LOGO); |
| 2535 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2536 | out: |
| 2537 | lpfc_els_free_iocb(phba, cmdiocb); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 2538 | /* If we are in pt2pt mode, we could rcv new S_ID on PLOGI */ |
| 2539 | if ((vport->fc_flag & FC_PT2PT) && |
| 2540 | !(vport->fc_flag & FC_PT2PT_PLOGI)) { |
| 2541 | phba->pport->fc_myDID = 0; |
| 2542 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 2543 | if (mbox) { |
| 2544 | lpfc_config_link(phba, mbox); |
| 2545 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
| 2546 | mbox->vport = vport; |
| 2547 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) == |
| 2548 | MBX_NOT_FINISHED) { |
| 2549 | mempool_free(mbox, phba->mbox_mem_pool); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2550 | skip_recovery = 1; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 2551 | } |
| 2552 | } |
| 2553 | } |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2554 | |
| 2555 | /* |
| 2556 | * If the node is a target, the handling attempts to recover the port. |
| 2557 | * For any other port type, the rpi is unregistered as an implicit |
| 2558 | * LOGO. |
| 2559 | */ |
| 2560 | if ((ndlp->nlp_type & NLP_FCP_TARGET) && (skip_recovery == 0)) { |
| 2561 | lpfc_cancel_retry_delay_tmo(vport, ndlp); |
| 2562 | spin_lock_irqsave(shost->host_lock, flags); |
| 2563 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
| 2564 | spin_unlock_irqrestore(shost->host_lock, flags); |
| 2565 | |
| 2566 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2567 | "3187 LOGO completes to NPort x%x: Start " |
| 2568 | "Recovery Data: x%x x%x x%x x%x\n", |
| 2569 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2570 | irsp->un.ulpWord[4], irsp->ulpTimeout, |
| 2571 | vport->num_disc_nodes); |
| 2572 | lpfc_disc_start(vport); |
| 2573 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2574 | return; |
| 2575 | } |
| 2576 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2577 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2578 | * 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] | 2579 | * @vport: pointer to a virtual N_Port data structure. |
| 2580 | * @ndlp: pointer to a node-list data structure. |
| 2581 | * @retry: number of retries to the command IOCB. |
| 2582 | * |
| 2583 | * This routine constructs and issues an ELS Logout (LOGO) iocb command |
| 2584 | * to a remote node, referred by an @ndlp on a @vport. It constructs the |
| 2585 | * payload of the IOCB, properly sets up the @ndlp state, and invokes the |
| 2586 | * lpfc_sli_issue_iocb() routine to send out the LOGO ELS command. |
| 2587 | * |
| 2588 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2589 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2590 | * will be stored into the context1 field of the IOCB for the completion |
| 2591 | * callback function to the LOGO ELS command. |
| 2592 | * |
| 2593 | * Return code |
| 2594 | * 0 - successfully issued logo |
| 2595 | * 1 - failed to issue logo |
| 2596 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2597 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2598 | lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2599 | uint8_t retry) |
| 2600 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2601 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2602 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2603 | IOCB_t *icmd; |
| 2604 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2605 | uint8_t *pcmd; |
| 2606 | uint16_t cmdsize; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2607 | int rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2608 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 2609 | spin_lock_irq(shost->host_lock); |
| 2610 | if (ndlp->nlp_flag & NLP_LOGO_SND) { |
| 2611 | spin_unlock_irq(shost->host_lock); |
| 2612 | return 0; |
| 2613 | } |
| 2614 | spin_unlock_irq(shost->host_lock); |
| 2615 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2616 | cmdsize = (2 * sizeof(uint32_t)) + sizeof(struct lpfc_name); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2617 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2618 | ndlp->nlp_DID, ELS_CMD_LOGO); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2619 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2620 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2621 | |
| 2622 | icmd = &elsiocb->iocb; |
| 2623 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2624 | *((uint32_t *) (pcmd)) = ELS_CMD_LOGO; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2625 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2626 | |
| 2627 | /* Fill in LOGO payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2628 | *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2629 | pcmd += sizeof(uint32_t); |
| 2630 | memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2631 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2632 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2633 | "Issue LOGO: did:x%x", |
| 2634 | ndlp->nlp_DID, 0, 0); |
| 2635 | |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2636 | /* |
| 2637 | * If we are issuing a LOGO, we may try to recover the remote NPort |
| 2638 | * by issuing a PLOGI later. Even though we issue ELS cmds by the |
| 2639 | * VPI, if we have a valid RPI, and that RPI gets unreg'ed while |
| 2640 | * that ELS command is in-flight, the HBA returns a IOERR_INVALID_RPI |
| 2641 | * for that ELS cmd. To avoid this situation, lets get rid of the |
| 2642 | * RPI right now, before any ELS cmds are sent. |
| 2643 | */ |
| 2644 | spin_lock_irq(shost->host_lock); |
| 2645 | ndlp->nlp_flag |= NLP_ISSUE_LOGO; |
| 2646 | spin_unlock_irq(shost->host_lock); |
| 2647 | if (lpfc_unreg_rpi(vport, ndlp)) { |
| 2648 | lpfc_els_free_iocb(phba, elsiocb); |
| 2649 | return 0; |
| 2650 | } |
| 2651 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2652 | phba->fc_stat.elsXmitLOGO++; |
| 2653 | elsiocb->iocb_cmpl = lpfc_cmpl_els_logo; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2654 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2655 | ndlp->nlp_flag |= NLP_LOGO_SND; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2656 | ndlp->nlp_flag &= ~NLP_ISSUE_LOGO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2657 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2658 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2659 | |
| 2660 | if (rc == IOCB_ERROR) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2661 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2662 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2663 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2664 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2665 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2666 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2667 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2668 | } |
| 2669 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2670 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2671 | * lpfc_cmpl_els_cmd - Completion callback function for generic els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2672 | * @phba: pointer to lpfc hba data structure. |
| 2673 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2674 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2675 | * |
| 2676 | * This routine is a generic completion callback function for ELS commands. |
| 2677 | * Specifically, it is the callback function which does not need to perform |
| 2678 | * any command specific operations. It is currently used by the ELS command |
| 2679 | * issuing routines for the ELS State Change Request (SCR), |
| 2680 | * lpfc_issue_els_scr(), and the ELS Fibre Channel Address Resolution |
| 2681 | * Protocol Response (FARPR) routine, lpfc_issue_els_farpr(). Other than |
| 2682 | * certain debug loggings, this callback function simply invokes the |
| 2683 | * lpfc_els_chk_latt() routine to check whether link went down during the |
| 2684 | * discovery process. |
| 2685 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2686 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2687 | lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2688 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2689 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2690 | struct lpfc_vport *vport = cmdiocb->vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2691 | IOCB_t *irsp; |
| 2692 | |
| 2693 | irsp = &rspiocb->iocb; |
| 2694 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2695 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2696 | "ELS cmd cmpl: status:x%x/x%x did:x%x", |
| 2697 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2698 | irsp->un.elsreq64.remoteID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2699 | /* ELS cmd tag <ulpIoTag> completes */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2700 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2701 | "0106 ELS cmd tag x%x completes Data: x%x x%x x%x\n", |
| 2702 | irsp->ulpIoTag, irsp->ulpStatus, |
| 2703 | irsp->un.ulpWord[4], irsp->ulpTimeout); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2704 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2705 | lpfc_els_chk_latt(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2706 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2707 | return; |
| 2708 | } |
| 2709 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2710 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2711 | * 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] | 2712 | * @vport: pointer to a host virtual N_Port data structure. |
| 2713 | * @nportid: N_Port identifier to the remote node. |
| 2714 | * @retry: number of retries to the command IOCB. |
| 2715 | * |
| 2716 | * This routine issues a State Change Request (SCR) to a fabric node |
| 2717 | * on a @vport. The remote node @nportid is passed into the function. It |
| 2718 | * first search the @vport node list to find the matching ndlp. If no such |
| 2719 | * ndlp is found, a new ndlp shall be created for this (SCR) purpose. An |
| 2720 | * IOCB is allocated, payload prepared, and the lpfc_sli_issue_iocb() |
| 2721 | * routine is invoked to send the SCR IOCB. |
| 2722 | * |
| 2723 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2724 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2725 | * will be stored into the context1 field of the IOCB for the completion |
| 2726 | * callback function to the SCR ELS command. |
| 2727 | * |
| 2728 | * Return code |
| 2729 | * 0 - Successfully issued scr command |
| 2730 | * 1 - Failed to issue scr command |
| 2731 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2732 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2733 | lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2734 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2735 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2736 | IOCB_t *icmd; |
| 2737 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2738 | struct lpfc_sli *psli; |
| 2739 | uint8_t *pcmd; |
| 2740 | uint16_t cmdsize; |
| 2741 | struct lpfc_nodelist *ndlp; |
| 2742 | |
| 2743 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2744 | cmdsize = (sizeof(uint32_t) + sizeof(SCR)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2745 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2746 | ndlp = lpfc_findnode_did(vport, nportid); |
| 2747 | if (!ndlp) { |
| 2748 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 2749 | if (!ndlp) |
| 2750 | return 1; |
| 2751 | lpfc_nlp_init(vport, ndlp, nportid); |
| 2752 | lpfc_enqueue_node(vport, ndlp); |
| 2753 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 2754 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 2755 | if (!ndlp) |
| 2756 | return 1; |
| 2757 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2758 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2759 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2760 | ndlp->nlp_DID, ELS_CMD_SCR); |
| 2761 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2762 | if (!elsiocb) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2763 | /* This will trigger the release of the node just |
| 2764 | * allocated |
| 2765 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2766 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2767 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2768 | } |
| 2769 | |
| 2770 | icmd = &elsiocb->iocb; |
| 2771 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2772 | |
| 2773 | *((uint32_t *) (pcmd)) = ELS_CMD_SCR; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2774 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2775 | |
| 2776 | /* For SCR, remainder of payload is SCR parameter page */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2777 | memset(pcmd, 0, sizeof(SCR)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2778 | ((SCR *) pcmd)->Function = SCR_FUNC_FULL; |
| 2779 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2780 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2781 | "Issue SCR: did:x%x", |
| 2782 | ndlp->nlp_DID, 0, 0); |
| 2783 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2784 | phba->fc_stat.elsXmitSCR++; |
| 2785 | elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2786 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2787 | IOCB_ERROR) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2788 | /* The additional lpfc_nlp_put will cause the following |
| 2789 | * lpfc_els_free_iocb routine to trigger the rlease of |
| 2790 | * the node. |
| 2791 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2792 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2793 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2794 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2795 | } |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2796 | /* This will cause the callback-function lpfc_cmpl_els_cmd to |
| 2797 | * trigger the release of node. |
| 2798 | */ |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 2799 | |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2800 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2801 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2802 | } |
| 2803 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2804 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2805 | * 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] | 2806 | * @vport: pointer to a host virtual N_Port data structure. |
| 2807 | * @nportid: N_Port identifier to the remote node. |
| 2808 | * @retry: number of retries to the command IOCB. |
| 2809 | * |
| 2810 | * This routine issues a Fibre Channel Address Resolution Response |
| 2811 | * (FARPR) to a node on a vport. The remote node N_Port identifier (@nportid) |
| 2812 | * is passed into the function. It first search the @vport node list to find |
| 2813 | * the matching ndlp. If no such ndlp is found, a new ndlp shall be created |
| 2814 | * for this (FARPR) purpose. An IOCB is allocated, payload prepared, and the |
| 2815 | * lpfc_sli_issue_iocb() routine is invoked to send the FARPR ELS command. |
| 2816 | * |
| 2817 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2818 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2819 | * will be stored into the context1 field of the IOCB for the completion |
| 2820 | * callback function to the PARPR ELS command. |
| 2821 | * |
| 2822 | * Return code |
| 2823 | * 0 - Successfully issued farpr command |
| 2824 | * 1 - Failed to issue farpr command |
| 2825 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2826 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2827 | lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2828 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2829 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2830 | IOCB_t *icmd; |
| 2831 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2832 | struct lpfc_sli *psli; |
| 2833 | FARP *fp; |
| 2834 | uint8_t *pcmd; |
| 2835 | uint32_t *lp; |
| 2836 | uint16_t cmdsize; |
| 2837 | struct lpfc_nodelist *ondlp; |
| 2838 | struct lpfc_nodelist *ndlp; |
| 2839 | |
| 2840 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2841 | cmdsize = (sizeof(uint32_t) + sizeof(FARP)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2842 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2843 | ndlp = lpfc_findnode_did(vport, nportid); |
| 2844 | if (!ndlp) { |
| 2845 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 2846 | if (!ndlp) |
| 2847 | return 1; |
| 2848 | lpfc_nlp_init(vport, ndlp, nportid); |
| 2849 | lpfc_enqueue_node(vport, ndlp); |
| 2850 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 2851 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 2852 | if (!ndlp) |
| 2853 | return 1; |
| 2854 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2855 | |
| 2856 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2857 | ndlp->nlp_DID, ELS_CMD_RNID); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2858 | if (!elsiocb) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2859 | /* This will trigger the release of the node just |
| 2860 | * allocated |
| 2861 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2862 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2863 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2864 | } |
| 2865 | |
| 2866 | icmd = &elsiocb->iocb; |
| 2867 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2868 | |
| 2869 | *((uint32_t *) (pcmd)) = ELS_CMD_FARPR; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2870 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2871 | |
| 2872 | /* Fill in FARPR payload */ |
| 2873 | fp = (FARP *) (pcmd); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2874 | memset(fp, 0, sizeof(FARP)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2875 | lp = (uint32_t *) pcmd; |
| 2876 | *lp++ = be32_to_cpu(nportid); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2877 | *lp++ = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2878 | fp->Rflags = 0; |
| 2879 | fp->Mflags = (FARP_MATCH_PORT | FARP_MATCH_NODE); |
| 2880 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2881 | memcpy(&fp->RportName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 2882 | memcpy(&fp->RnodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2883 | ondlp = lpfc_findnode_did(vport, nportid); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2884 | if (ondlp && NLP_CHK_NODE_ACT(ondlp)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2885 | memcpy(&fp->OportName, &ondlp->nlp_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2886 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2887 | memcpy(&fp->OnodeName, &ondlp->nlp_nodename, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2888 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2889 | } |
| 2890 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2891 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2892 | "Issue FARPR: did:x%x", |
| 2893 | ndlp->nlp_DID, 0, 0); |
| 2894 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2895 | phba->fc_stat.elsXmitFARPR++; |
| 2896 | elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2897 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2898 | IOCB_ERROR) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2899 | /* The additional lpfc_nlp_put will cause the following |
| 2900 | * lpfc_els_free_iocb routine to trigger the release of |
| 2901 | * the node. |
| 2902 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2903 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2904 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2905 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2906 | } |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2907 | /* This will cause the callback-function lpfc_cmpl_els_cmd to |
| 2908 | * trigger the release of the node. |
| 2909 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2910 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2911 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2912 | } |
| 2913 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2914 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2915 | * 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] | 2916 | * @vport: pointer to a host virtual N_Port data structure. |
| 2917 | * @nlp: pointer to a node-list data structure. |
| 2918 | * |
| 2919 | * This routine cancels the timer with a delayed IOCB-command retry for |
| 2920 | * a @vport's @ndlp. It stops the timer for the delayed function retrial and |
| 2921 | * removes the ELS retry event if it presents. In addition, if the |
| 2922 | * NLP_NPR_2B_DISC bit is set in the @nlp's nlp_flag bitmap, ADISC IOCB |
| 2923 | * commands are sent for the @vport's nodes that require issuing discovery |
| 2924 | * ADISC. |
| 2925 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2926 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2927 | 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] | 2928 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2929 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2930 | struct lpfc_work_evt *evtp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2931 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2932 | if (!(nlp->nlp_flag & NLP_DELAY_TMO)) |
| 2933 | return; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2934 | spin_lock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2935 | nlp->nlp_flag &= ~NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2936 | spin_unlock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2937 | del_timer_sync(&nlp->nlp_delayfunc); |
| 2938 | nlp->nlp_last_elscmd = 0; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2939 | if (!list_empty(&nlp->els_retry_evt.evt_listp)) { |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2940 | list_del_init(&nlp->els_retry_evt.evt_listp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2941 | /* Decrement nlp reference count held for the delayed retry */ |
| 2942 | evtp = &nlp->els_retry_evt; |
| 2943 | lpfc_nlp_put((struct lpfc_nodelist *)evtp->evt_arg1); |
| 2944 | } |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2945 | if (nlp->nlp_flag & NLP_NPR_2B_DISC) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2946 | spin_lock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2947 | nlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2948 | spin_unlock_irq(shost->host_lock); |
| 2949 | if (vport->num_disc_nodes) { |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2950 | if (vport->port_state < LPFC_VPORT_READY) { |
| 2951 | /* Check if there are more ADISCs to be sent */ |
| 2952 | lpfc_more_adisc(vport); |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2953 | } else { |
| 2954 | /* Check if there are more PLOGIs to be sent */ |
| 2955 | lpfc_more_plogi(vport); |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2956 | if (vport->num_disc_nodes == 0) { |
| 2957 | spin_lock_irq(shost->host_lock); |
| 2958 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 2959 | spin_unlock_irq(shost->host_lock); |
| 2960 | lpfc_can_disctmo(vport); |
| 2961 | lpfc_end_rscn(vport); |
| 2962 | } |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2963 | } |
| 2964 | } |
| 2965 | } |
| 2966 | return; |
| 2967 | } |
| 2968 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2969 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2970 | * lpfc_els_retry_delay - Timer function with a ndlp delayed function timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2971 | * @ptr: holder for the pointer to the timer function associated data (ndlp). |
| 2972 | * |
| 2973 | * This routine is invoked by the ndlp delayed-function timer to check |
| 2974 | * whether there is any pending ELS retry event(s) with the node. If not, it |
| 2975 | * simply returns. Otherwise, if there is at least one ELS delayed event, it |
| 2976 | * adds the delayed events to the HBA work list and invokes the |
| 2977 | * lpfc_worker_wake_up() routine to wake up worker thread to process the |
| 2978 | * event. Note that lpfc_nlp_get() is called before posting the event to |
| 2979 | * the work list to hold reference count of ndlp so that it guarantees the |
| 2980 | * reference to ndlp will still be available when the worker thread gets |
| 2981 | * to the event associated with the ndlp. |
| 2982 | **/ |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2983 | void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2984 | lpfc_els_retry_delay(unsigned long ptr) |
| 2985 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2986 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) ptr; |
| 2987 | struct lpfc_vport *vport = ndlp->vport; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2988 | struct lpfc_hba *phba = vport->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2989 | unsigned long flags; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2990 | struct lpfc_work_evt *evtp = &ndlp->els_retry_evt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2991 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2992 | spin_lock_irqsave(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2993 | if (!list_empty(&evtp->evt_listp)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2994 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2995 | return; |
| 2996 | } |
| 2997 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2998 | /* We need to hold the node by incrementing the reference |
| 2999 | * count until the queued work is done |
| 3000 | */ |
| 3001 | evtp->evt_arg1 = lpfc_nlp_get(ndlp); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 3002 | if (evtp->evt_arg1) { |
| 3003 | evtp->evt = LPFC_EVT_ELS_RETRY; |
| 3004 | list_add_tail(&evtp->evt_listp, &phba->work_list); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3005 | lpfc_worker_wake_up(phba); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 3006 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3007 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3008 | return; |
| 3009 | } |
| 3010 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3011 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3012 | * lpfc_els_retry_delay_handler - Work thread handler for ndlp delayed function |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3013 | * @ndlp: pointer to a node-list data structure. |
| 3014 | * |
| 3015 | * This routine is the worker-thread handler for processing the @ndlp delayed |
| 3016 | * event(s), posted by the lpfc_els_retry_delay() routine. It simply retrieves |
| 3017 | * the last ELS command from the associated ndlp and invokes the proper ELS |
| 3018 | * function according to the delayed ELS command to retry the command. |
| 3019 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3020 | void |
| 3021 | lpfc_els_retry_delay_handler(struct lpfc_nodelist *ndlp) |
| 3022 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3023 | struct lpfc_vport *vport = ndlp->vport; |
| 3024 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame^] | 3025 | uint32_t cmd, retry; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3026 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3027 | spin_lock_irq(shost->host_lock); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3028 | cmd = ndlp->nlp_last_elscmd; |
| 3029 | ndlp->nlp_last_elscmd = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3030 | |
| 3031 | if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3032 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3033 | return; |
| 3034 | } |
| 3035 | |
| 3036 | ndlp->nlp_flag &= ~NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3037 | spin_unlock_irq(shost->host_lock); |
James Smart | 1a16968 | 2006-03-07 15:04:06 -0500 | [diff] [blame] | 3038 | /* |
| 3039 | * If a discovery event readded nlp_delayfunc after timer |
| 3040 | * firing and before processing the timer, cancel the |
| 3041 | * nlp_delayfunc. |
| 3042 | */ |
| 3043 | del_timer_sync(&ndlp->nlp_delayfunc); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3044 | retry = ndlp->nlp_retry; |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 3045 | ndlp->nlp_retry = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3046 | |
| 3047 | switch (cmd) { |
| 3048 | case ELS_CMD_FLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3049 | lpfc_issue_els_flogi(vport, ndlp, retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3050 | break; |
| 3051 | case ELS_CMD_PLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3052 | if (!lpfc_issue_els_plogi(vport, ndlp->nlp_DID, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3053 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3054 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 3055 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3056 | break; |
| 3057 | case ELS_CMD_ADISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3058 | if (!lpfc_issue_els_adisc(vport, ndlp, 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_ADISC_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_PRLI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3064 | if (!lpfc_issue_els_prli(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_PRLI_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_LOGO: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3070 | if (!lpfc_issue_els_logo(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 | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 3072 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_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; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3075 | case ELS_CMD_FDISC: |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 3076 | if (!(vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI)) |
| 3077 | lpfc_issue_els_fdisc(vport, ndlp, retry); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3078 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3079 | } |
| 3080 | return; |
| 3081 | } |
| 3082 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3083 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3084 | * lpfc_els_retry - Make retry decision on an els command iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3085 | * @phba: pointer to lpfc hba data structure. |
| 3086 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 3087 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 3088 | * |
| 3089 | * This routine makes a retry decision on an ELS command IOCB, which has |
| 3090 | * failed. The following ELS IOCBs use this function for retrying the command |
| 3091 | * when previously issued command responsed with error status: FLOGI, PLOGI, |
| 3092 | * PRLI, ADISC, LOGO, and FDISC. Based on the ELS command type and the |
| 3093 | * returned error status, it makes the decision whether a retry shall be |
| 3094 | * issued for the command, and whether a retry shall be made immediately or |
| 3095 | * delayed. In the former case, the corresponding ELS command issuing-function |
| 3096 | * is called to retry the command. In the later case, the ELS command shall |
| 3097 | * be posted to the ndlp delayed event and delayed function timer set to the |
| 3098 | * ndlp for the delayed command issusing. |
| 3099 | * |
| 3100 | * Return code |
| 3101 | * 0 - No retry of els command is made |
| 3102 | * 1 - Immediate or delayed retry of els command is made |
| 3103 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3104 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3105 | lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 3106 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3107 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3108 | struct lpfc_vport *vport = cmdiocb->vport; |
| 3109 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3110 | IOCB_t *irsp = &rspiocb->iocb; |
| 3111 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 3112 | struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3113 | uint32_t *elscmd; |
| 3114 | struct ls_rjt stat; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3115 | int retry = 0, maxretry = lpfc_max_els_tries, delay = 0; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3116 | int logerr = 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3117 | uint32_t cmd = 0; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3118 | uint32_t did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3119 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3120 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3121 | /* Note: context2 may be 0 for internal driver abort |
| 3122 | * of delays ELS command. |
| 3123 | */ |
| 3124 | |
| 3125 | if (pcmd && pcmd->virt) { |
| 3126 | elscmd = (uint32_t *) (pcmd->virt); |
| 3127 | cmd = *elscmd++; |
| 3128 | } |
| 3129 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3130 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3131 | did = ndlp->nlp_DID; |
| 3132 | else { |
| 3133 | /* We should only hit this case for retrying PLOGI */ |
| 3134 | did = irsp->un.elsreq64.remoteID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3135 | ndlp = lpfc_findnode_did(vport, did); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3136 | if ((!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 3137 | && (cmd != ELS_CMD_PLOGI)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3138 | return 1; |
| 3139 | } |
| 3140 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3141 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 3142 | "Retry ELS: wd7:x%x wd4:x%x did:x%x", |
| 3143 | *(((uint32_t *) irsp) + 7), irsp->un.ulpWord[4], ndlp->nlp_DID); |
| 3144 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3145 | switch (irsp->ulpStatus) { |
| 3146 | case IOSTAT_FCP_RSP_ERROR: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3147 | break; |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 3148 | case IOSTAT_REMOTE_STOP: |
| 3149 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 3150 | /* This IO was aborted by the target, we don't |
| 3151 | * know the rxid and because we did not send the |
| 3152 | * ABTS we cannot generate and RRQ. |
| 3153 | */ |
| 3154 | lpfc_set_rrq_active(phba, ndlp, |
James Smart | ee0f4fe | 2012-05-09 21:19:14 -0400 | [diff] [blame] | 3155 | cmdiocb->sli4_lxritag, 0, 0); |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 3156 | } |
| 3157 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3158 | case IOSTAT_LOCAL_REJECT: |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 3159 | switch ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3160 | case IOERR_LOOP_OPEN_FAILURE: |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 3161 | if (cmd == ELS_CMD_FLOGI) { |
| 3162 | if (PCI_DEVICE_ID_HORNET == |
| 3163 | phba->pcidev->device) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3164 | phba->fc_topology = LPFC_TOPOLOGY_LOOP; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 3165 | phba->pport->fc_myDID = 0; |
| 3166 | phba->alpa_map[0] = 0; |
| 3167 | phba->alpa_map[1] = 0; |
| 3168 | } |
| 3169 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3170 | if (cmd == ELS_CMD_PLOGI && cmdiocb->retry == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3171 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3172 | retry = 1; |
| 3173 | break; |
| 3174 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3175 | case IOERR_ILLEGAL_COMMAND: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 3176 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3177 | "0124 Retry illegal cmd x%x " |
| 3178 | "retry:x%x delay:x%x\n", |
| 3179 | cmd, cmdiocb->retry, delay); |
| 3180 | retry = 1; |
| 3181 | /* All command's retry policy */ |
| 3182 | maxretry = 8; |
| 3183 | if (cmdiocb->retry > 2) |
| 3184 | delay = 1000; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3185 | break; |
| 3186 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3187 | case IOERR_NO_RESOURCES: |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3188 | logerr = 1; /* HBA out of resources */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3189 | retry = 1; |
| 3190 | if (cmdiocb->retry > 100) |
| 3191 | delay = 100; |
| 3192 | maxretry = 250; |
| 3193 | break; |
| 3194 | |
| 3195 | case IOERR_ILLEGAL_FRAME: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3196 | delay = 100; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3197 | retry = 1; |
| 3198 | break; |
| 3199 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3200 | case IOERR_SEQUENCE_TIMEOUT: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3201 | case IOERR_INVALID_RPI: |
James Smart | 5b5b36a | 2013-01-03 15:43:19 -0500 | [diff] [blame] | 3202 | if (cmd == ELS_CMD_PLOGI && |
| 3203 | did == NameServer_DID) { |
| 3204 | /* Continue forever if plogi to */ |
| 3205 | /* the nameserver fails */ |
| 3206 | maxretry = 0; |
| 3207 | delay = 100; |
| 3208 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3209 | retry = 1; |
| 3210 | break; |
| 3211 | } |
| 3212 | break; |
| 3213 | |
| 3214 | case IOSTAT_NPORT_RJT: |
| 3215 | case IOSTAT_FABRIC_RJT: |
| 3216 | if (irsp->un.ulpWord[4] & RJT_UNAVAIL_TEMP) { |
| 3217 | retry = 1; |
| 3218 | break; |
| 3219 | } |
| 3220 | break; |
| 3221 | |
| 3222 | case IOSTAT_NPORT_BSY: |
| 3223 | case IOSTAT_FABRIC_BSY: |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3224 | logerr = 1; /* Fabric / Remote NPort out of resources */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3225 | retry = 1; |
| 3226 | break; |
| 3227 | |
| 3228 | case IOSTAT_LS_RJT: |
| 3229 | stat.un.lsRjtError = be32_to_cpu(irsp->un.ulpWord[4]); |
| 3230 | /* Added for Vendor specifc support |
| 3231 | * Just keep retrying for these Rsn / Exp codes |
| 3232 | */ |
| 3233 | switch (stat.un.b.lsRjtRsnCode) { |
| 3234 | case LSRJT_UNABLE_TPC: |
| 3235 | if (stat.un.b.lsRjtRsnCodeExp == |
| 3236 | LSEXP_CMD_IN_PROGRESS) { |
| 3237 | if (cmd == ELS_CMD_PLOGI) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3238 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3239 | maxretry = 48; |
| 3240 | } |
| 3241 | retry = 1; |
| 3242 | break; |
| 3243 | } |
James Smart | ffc9549 | 2010-06-07 15:23:17 -0400 | [diff] [blame] | 3244 | if (stat.un.b.lsRjtRsnCodeExp == |
| 3245 | LSEXP_CANT_GIVE_DATA) { |
| 3246 | if (cmd == ELS_CMD_PLOGI) { |
| 3247 | delay = 1000; |
| 3248 | maxretry = 48; |
| 3249 | } |
| 3250 | retry = 1; |
| 3251 | break; |
| 3252 | } |
James Smart | 4c1b64b | 2012-09-29 11:31:11 -0400 | [diff] [blame] | 3253 | if ((cmd == ELS_CMD_PLOGI) || |
| 3254 | (cmd == ELS_CMD_PRLI)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3255 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3256 | maxretry = lpfc_max_els_tries + 1; |
| 3257 | retry = 1; |
| 3258 | break; |
| 3259 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3260 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
| 3261 | (cmd == ELS_CMD_FDISC) && |
| 3262 | (stat.un.b.lsRjtRsnCodeExp == LSEXP_OUT_OF_RESOURCE)){ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3263 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3264 | "0125 FDISC Failed (x%x). " |
| 3265 | "Fabric out of resources\n", |
| 3266 | stat.un.lsRjtError); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3267 | lpfc_vport_set_state(vport, |
| 3268 | FC_VPORT_NO_FABRIC_RSCS); |
| 3269 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3270 | break; |
| 3271 | |
| 3272 | case LSRJT_LOGICAL_BSY: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3273 | if ((cmd == ELS_CMD_PLOGI) || |
| 3274 | (cmd == ELS_CMD_PRLI)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3275 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3276 | maxretry = 48; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3277 | } else if (cmd == ELS_CMD_FDISC) { |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3278 | /* FDISC retry policy */ |
| 3279 | maxretry = 48; |
| 3280 | if (cmdiocb->retry >= 32) |
| 3281 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3282 | } |
| 3283 | retry = 1; |
| 3284 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3285 | |
| 3286 | case LSRJT_LOGICAL_ERR: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 3287 | /* There are some cases where switches return this |
| 3288 | * error when they are not ready and should be returning |
| 3289 | * Logical Busy. We should delay every time. |
| 3290 | */ |
| 3291 | if (cmd == ELS_CMD_FDISC && |
| 3292 | stat.un.b.lsRjtRsnCodeExp == LSEXP_PORT_LOGIN_REQ) { |
| 3293 | maxretry = 3; |
| 3294 | delay = 1000; |
| 3295 | retry = 1; |
| 3296 | break; |
| 3297 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3298 | case LSRJT_PROTOCOL_ERR: |
| 3299 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
| 3300 | (cmd == ELS_CMD_FDISC) && |
| 3301 | ((stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_PNAME) || |
| 3302 | (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID)) |
| 3303 | ) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3304 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3305 | "0122 FDISC Failed (x%x). " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3306 | "Fabric Detected Bad WWN\n", |
| 3307 | stat.un.lsRjtError); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3308 | lpfc_vport_set_state(vport, |
| 3309 | FC_VPORT_FABRIC_REJ_WWN); |
| 3310 | } |
| 3311 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3312 | } |
| 3313 | break; |
| 3314 | |
| 3315 | case IOSTAT_INTERMED_RSP: |
| 3316 | case IOSTAT_BA_RJT: |
| 3317 | break; |
| 3318 | |
| 3319 | default: |
| 3320 | break; |
| 3321 | } |
| 3322 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3323 | if (did == FDMI_DID) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3324 | retry = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3325 | |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3326 | if ((cmd == ELS_CMD_FLOGI) && |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3327 | (phba->fc_topology != LPFC_TOPOLOGY_LOOP) && |
James Smart | 1b32f6a | 2008-02-08 18:49:39 -0500 | [diff] [blame] | 3328 | !lpfc_error_lost_link(irsp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3329 | /* FLOGI retry policy */ |
| 3330 | retry = 1; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3331 | /* retry FLOGI forever */ |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 3332 | maxretry = 0; |
| 3333 | if (cmdiocb->retry >= 100) |
| 3334 | delay = 5000; |
| 3335 | else if (cmdiocb->retry >= 32) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3336 | delay = 1000; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3337 | } else if ((cmd == ELS_CMD_FDISC) && !lpfc_error_lost_link(irsp)) { |
| 3338 | /* retry FDISCs every second up to devloss */ |
| 3339 | retry = 1; |
| 3340 | maxretry = vport->cfg_devloss_tmo; |
| 3341 | delay = 1000; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3342 | } |
| 3343 | |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 3344 | cmdiocb->retry++; |
| 3345 | if (maxretry && (cmdiocb->retry >= maxretry)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3346 | phba->fc_stat.elsRetryExceeded++; |
| 3347 | retry = 0; |
| 3348 | } |
| 3349 | |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 3350 | if ((vport->load_flag & FC_UNLOADING) != 0) |
| 3351 | retry = 0; |
| 3352 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3353 | if (retry) { |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 3354 | if ((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_FDISC)) { |
| 3355 | /* Stop retrying PLOGI and FDISC if in FCF discovery */ |
| 3356 | if (phba->fcf.fcf_flag & FCF_DISCOVERY) { |
| 3357 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3358 | "2849 Stop retry ELS command " |
| 3359 | "x%x to remote NPORT x%x, " |
| 3360 | "Data: x%x x%x\n", cmd, did, |
| 3361 | cmdiocb->retry, delay); |
| 3362 | return 0; |
| 3363 | } |
| 3364 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3365 | |
| 3366 | /* Retry ELS command <elsCmd> to remote NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3367 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3368 | "0107 Retry ELS command x%x to remote " |
| 3369 | "NPORT x%x Data: x%x x%x\n", |
| 3370 | cmd, did, cmdiocb->retry, delay); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3371 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3372 | if (((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_ADISC)) && |
| 3373 | ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 3374 | ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) != |
| 3375 | IOERR_NO_RESOURCES))) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3376 | /* Don't reset timer for no resources */ |
| 3377 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3378 | /* If discovery / RSCN timer is running, reset it */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3379 | if (timer_pending(&vport->fc_disctmo) || |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3380 | (vport->fc_flag & FC_RSCN_MODE)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3381 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3382 | } |
| 3383 | |
| 3384 | phba->fc_stat.elsXmitRetry++; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3385 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && delay) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3386 | phba->fc_stat.elsDelayRetry++; |
| 3387 | ndlp->nlp_retry = cmdiocb->retry; |
| 3388 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3389 | /* delay is specified in milliseconds */ |
| 3390 | mod_timer(&ndlp->nlp_delayfunc, |
| 3391 | jiffies + msecs_to_jiffies(delay)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3392 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3393 | ndlp->nlp_flag |= NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3394 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3395 | |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3396 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3397 | if (cmd == ELS_CMD_PRLI) |
| 3398 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | 4c1b64b | 2012-09-29 11:31:11 -0400 | [diff] [blame] | 3399 | NLP_STE_PRLI_ISSUE); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3400 | else |
| 3401 | lpfc_nlp_set_state(vport, ndlp, |
| 3402 | NLP_STE_NPR_NODE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3403 | ndlp->nlp_last_elscmd = cmd; |
| 3404 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3405 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3406 | } |
| 3407 | switch (cmd) { |
| 3408 | case ELS_CMD_FLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3409 | lpfc_issue_els_flogi(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3410 | return 1; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3411 | case ELS_CMD_FDISC: |
| 3412 | lpfc_issue_els_fdisc(vport, ndlp, cmdiocb->retry); |
| 3413 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3414 | case ELS_CMD_PLOGI: |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3415 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3416 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3417 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | de0c5b3 | 2007-04-25 09:52:27 -0400 | [diff] [blame] | 3418 | NLP_STE_PLOGI_ISSUE); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3419 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3420 | lpfc_issue_els_plogi(vport, did, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3421 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3422 | case ELS_CMD_ADISC: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3423 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3424 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE); |
| 3425 | lpfc_issue_els_adisc(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3426 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3427 | case ELS_CMD_PRLI: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3428 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3429 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE); |
| 3430 | lpfc_issue_els_prli(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3431 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3432 | case ELS_CMD_LOGO: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3433 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 3434 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3435 | lpfc_issue_els_logo(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3436 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3437 | } |
| 3438 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3439 | /* No retry ELS command <elsCmd> to remote NPORT <did> */ |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3440 | if (logerr) { |
| 3441 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3442 | "0137 No retry ELS command x%x to remote " |
| 3443 | "NPORT x%x: Out of Resources: Error:x%x/%x\n", |
| 3444 | cmd, did, irsp->ulpStatus, |
| 3445 | irsp->un.ulpWord[4]); |
| 3446 | } |
| 3447 | else { |
| 3448 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3449 | "0108 No retry ELS command x%x to remote " |
| 3450 | "NPORT x%x Retried:%d Error:x%x/%x\n", |
| 3451 | cmd, did, cmdiocb->retry, irsp->ulpStatus, |
| 3452 | irsp->un.ulpWord[4]); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3453 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3454 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3455 | } |
| 3456 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3457 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3458 | * 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] | 3459 | * @phba: pointer to lpfc hba data structure. |
| 3460 | * @buf_ptr1: pointer to the lpfc DMA buffer data structure. |
| 3461 | * |
| 3462 | * This routine releases the lpfc DMA (Direct Memory Access) buffer(s) |
| 3463 | * associated with a command IOCB back to the lpfc DMA buffer pool. It first |
| 3464 | * checks to see whether there is a lpfc DMA buffer associated with the |
| 3465 | * response of the command IOCB. If so, it will be released before releasing |
| 3466 | * the lpfc DMA buffer associated with the IOCB itself. |
| 3467 | * |
| 3468 | * Return code |
| 3469 | * 0 - Successfully released lpfc DMA buffer (currently, always return 0) |
| 3470 | **/ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3471 | static int |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3472 | lpfc_els_free_data(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr1) |
| 3473 | { |
| 3474 | struct lpfc_dmabuf *buf_ptr; |
| 3475 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3476 | /* Free the response before processing the command. */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3477 | if (!list_empty(&buf_ptr1->list)) { |
| 3478 | list_remove_head(&buf_ptr1->list, buf_ptr, |
| 3479 | struct lpfc_dmabuf, |
| 3480 | list); |
| 3481 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 3482 | kfree(buf_ptr); |
| 3483 | } |
| 3484 | lpfc_mbuf_free(phba, buf_ptr1->virt, buf_ptr1->phys); |
| 3485 | kfree(buf_ptr1); |
| 3486 | return 0; |
| 3487 | } |
| 3488 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3489 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3490 | * 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] | 3491 | * @phba: pointer to lpfc hba data structure. |
| 3492 | * @buf_ptr: pointer to the lpfc dma buffer data structure. |
| 3493 | * |
| 3494 | * This routine releases the lpfc Direct Memory Access (DMA) buffer |
| 3495 | * associated with a Buffer Pointer List (BPL) back to the lpfc DMA buffer |
| 3496 | * pool. |
| 3497 | * |
| 3498 | * Return code |
| 3499 | * 0 - Successfully released lpfc DMA buffer (currently, always return 0) |
| 3500 | **/ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3501 | static int |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3502 | lpfc_els_free_bpl(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr) |
| 3503 | { |
| 3504 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 3505 | kfree(buf_ptr); |
| 3506 | return 0; |
| 3507 | } |
| 3508 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3509 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3510 | * lpfc_els_free_iocb - Free a command iocb and its associated resources |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3511 | * @phba: pointer to lpfc hba data structure. |
| 3512 | * @elsiocb: pointer to lpfc els command iocb data structure. |
| 3513 | * |
| 3514 | * This routine frees a command IOCB and its associated resources. The |
| 3515 | * command IOCB data structure contains the reference to various associated |
| 3516 | * resources, these fields must be set to NULL if the associated reference |
| 3517 | * not present: |
| 3518 | * context1 - reference to ndlp |
| 3519 | * context2 - reference to cmd |
| 3520 | * context2->next - reference to rsp |
| 3521 | * context3 - reference to bpl |
| 3522 | * |
| 3523 | * It first properly decrements the reference count held on ndlp for the |
| 3524 | * IOCB completion callback function. If LPFC_DELAY_MEM_FREE flag is not |
| 3525 | * set, it invokes the lpfc_els_free_data() routine to release the Direct |
| 3526 | * Memory Access (DMA) buffers associated with the IOCB. Otherwise, it |
| 3527 | * adds the DMA buffer the @phba data structure for the delayed release. |
| 3528 | * If reference to the Buffer Pointer List (BPL) is present, the |
| 3529 | * lpfc_els_free_bpl() routine is invoked to release the DMA memory |
| 3530 | * associated with BPL. Finally, the lpfc_sli_release_iocbq() routine is |
| 3531 | * invoked to release the IOCB data structure back to @phba IOCBQ list. |
| 3532 | * |
| 3533 | * Return code |
| 3534 | * 0 - Success (currently, always return 0) |
| 3535 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3536 | int |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3537 | lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3538 | { |
| 3539 | struct lpfc_dmabuf *buf_ptr, *buf_ptr1; |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3540 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3541 | |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3542 | ndlp = (struct lpfc_nodelist *)elsiocb->context1; |
| 3543 | if (ndlp) { |
| 3544 | if (ndlp->nlp_flag & NLP_DEFER_RM) { |
| 3545 | lpfc_nlp_put(ndlp); |
| 3546 | |
| 3547 | /* If the ndlp is not being used by another discovery |
| 3548 | * thread, free it. |
| 3549 | */ |
| 3550 | if (!lpfc_nlp_not_used(ndlp)) { |
| 3551 | /* If ndlp is being used by another discovery |
| 3552 | * thread, just clear NLP_DEFER_RM |
| 3553 | */ |
| 3554 | ndlp->nlp_flag &= ~NLP_DEFER_RM; |
| 3555 | } |
| 3556 | } |
| 3557 | else |
| 3558 | lpfc_nlp_put(ndlp); |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3559 | elsiocb->context1 = NULL; |
| 3560 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3561 | /* context2 = cmd, context2->next = rsp, context3 = bpl */ |
| 3562 | if (elsiocb->context2) { |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 3563 | if (elsiocb->iocb_flag & LPFC_DELAY_MEM_FREE) { |
| 3564 | /* Firmware could still be in progress of DMAing |
| 3565 | * payload, so don't free data buffer till after |
| 3566 | * a hbeat. |
| 3567 | */ |
| 3568 | elsiocb->iocb_flag &= ~LPFC_DELAY_MEM_FREE; |
| 3569 | buf_ptr = elsiocb->context2; |
| 3570 | elsiocb->context2 = NULL; |
| 3571 | if (buf_ptr) { |
| 3572 | buf_ptr1 = NULL; |
| 3573 | spin_lock_irq(&phba->hbalock); |
| 3574 | if (!list_empty(&buf_ptr->list)) { |
| 3575 | list_remove_head(&buf_ptr->list, |
| 3576 | buf_ptr1, struct lpfc_dmabuf, |
| 3577 | list); |
| 3578 | INIT_LIST_HEAD(&buf_ptr1->list); |
| 3579 | list_add_tail(&buf_ptr1->list, |
| 3580 | &phba->elsbuf); |
| 3581 | phba->elsbuf_cnt++; |
| 3582 | } |
| 3583 | INIT_LIST_HEAD(&buf_ptr->list); |
| 3584 | list_add_tail(&buf_ptr->list, &phba->elsbuf); |
| 3585 | phba->elsbuf_cnt++; |
| 3586 | spin_unlock_irq(&phba->hbalock); |
| 3587 | } |
| 3588 | } else { |
| 3589 | buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2; |
| 3590 | lpfc_els_free_data(phba, buf_ptr1); |
| 3591 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3592 | } |
| 3593 | |
| 3594 | if (elsiocb->context3) { |
| 3595 | buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3596 | lpfc_els_free_bpl(phba, buf_ptr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3597 | } |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 3598 | lpfc_sli_release_iocbq(phba, elsiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3599 | return 0; |
| 3600 | } |
| 3601 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3602 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3603 | * lpfc_cmpl_els_logo_acc - Completion callback function to logo acc response |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3604 | * @phba: pointer to lpfc hba data structure. |
| 3605 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 3606 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 3607 | * |
| 3608 | * This routine is the completion callback function to the Logout (LOGO) |
| 3609 | * Accept (ACC) Response ELS command. This routine is invoked to indicate |
| 3610 | * the completion of the LOGO process. It invokes the lpfc_nlp_not_used() to |
| 3611 | * release the ndlp if it has the last reference remaining (reference count |
| 3612 | * is 1). If succeeded (meaning ndlp released), it sets the IOCB context1 |
| 3613 | * field to NULL to inform the following lpfc_els_free_iocb() routine no |
| 3614 | * ndlp reference count needs to be decremented. Otherwise, the ndlp |
| 3615 | * reference use-count shall be decremented by the lpfc_els_free_iocb() |
| 3616 | * routine. Finally, the lpfc_els_free_iocb() is invoked to release the |
| 3617 | * IOCB data structure. |
| 3618 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3619 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3620 | lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 3621 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3622 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3623 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 3624 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3625 | IOCB_t *irsp; |
| 3626 | |
| 3627 | irsp = &rspiocb->iocb; |
| 3628 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3629 | "ACC LOGO cmpl: status:x%x/x%x did:x%x", |
| 3630 | irsp->ulpStatus, irsp->un.ulpWord[4], ndlp->nlp_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3631 | /* ACC to LOGO completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3632 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3633 | "0109 ACC to LOGO completes to NPort x%x " |
| 3634 | "Data: x%x x%x x%x\n", |
| 3635 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3636 | ndlp->nlp_rpi); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3637 | |
| 3638 | if (ndlp->nlp_state == NLP_STE_NPR_NODE) { |
| 3639 | /* NPort Recovery mode or node is just allocated */ |
| 3640 | if (!lpfc_nlp_not_used(ndlp)) { |
| 3641 | /* If the ndlp is being used by another discovery |
| 3642 | * thread, just unregister the RPI. |
| 3643 | */ |
| 3644 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3645 | } else { |
| 3646 | /* Indicate the node has already released, should |
| 3647 | * not reference to it from within lpfc_els_free_iocb. |
| 3648 | */ |
| 3649 | cmdiocb->context1 = NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3650 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3651 | } |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 3652 | |
| 3653 | /* |
| 3654 | * 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] | 3655 | * At this point, the driver is done so release the IOCB |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 3656 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3657 | lpfc_els_free_iocb(phba, cmdiocb); |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3658 | |
| 3659 | /* |
| 3660 | * Remove the ndlp reference if it's a fabric node that has |
| 3661 | * sent us an unsolicted LOGO. |
| 3662 | */ |
| 3663 | if (ndlp->nlp_type & NLP_FABRIC) |
| 3664 | lpfc_nlp_put(ndlp); |
| 3665 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3666 | return; |
| 3667 | } |
| 3668 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3669 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3670 | * 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] | 3671 | * @phba: pointer to lpfc hba data structure. |
| 3672 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 3673 | * |
| 3674 | * This routine is the completion callback function for unregister default |
| 3675 | * RPI (Remote Port Index) mailbox command to the @phba. It simply releases |
| 3676 | * the associated lpfc Direct Memory Access (DMA) buffer back to the pool and |
| 3677 | * decrements the ndlp reference count held for this completion callback |
| 3678 | * function. After that, it invokes the lpfc_nlp_not_used() to check |
| 3679 | * whether there is only one reference left on the ndlp. If so, it will |
| 3680 | * perform one more decrement and trigger the release of the ndlp. |
| 3681 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3682 | void |
| 3683 | lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
| 3684 | { |
| 3685 | struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1); |
| 3686 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2; |
| 3687 | |
| 3688 | pmb->context1 = NULL; |
James Smart | d439d28 | 2010-09-29 11:18:45 -0400 | [diff] [blame] | 3689 | pmb->context2 = NULL; |
| 3690 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3691 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3692 | kfree(mp); |
| 3693 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 3694 | if (ndlp) { |
| 3695 | if (NLP_CHK_NODE_ACT(ndlp)) { |
| 3696 | lpfc_nlp_put(ndlp); |
| 3697 | /* This is the end of the default RPI cleanup logic for |
| 3698 | * this ndlp. If no other discovery threads are using |
| 3699 | * this ndlp, free all resources associated with it. |
| 3700 | */ |
| 3701 | lpfc_nlp_not_used(ndlp); |
| 3702 | } else { |
| 3703 | lpfc_drop_node(ndlp->vport, ndlp); |
| 3704 | } |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3705 | } |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 3706 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3707 | return; |
| 3708 | } |
| 3709 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3710 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3711 | * lpfc_cmpl_els_rsp - Completion callback function for els response iocb cmd |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3712 | * @phba: pointer to lpfc hba data structure. |
| 3713 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 3714 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 3715 | * |
| 3716 | * This routine is the completion callback function for ELS Response IOCB |
| 3717 | * command. In normal case, this callback function just properly sets the |
| 3718 | * nlp_flag bitmap in the ndlp data structure, if the mbox command reference |
| 3719 | * field in the command IOCB is not NULL, the referred mailbox command will |
| 3720 | * be send out, and then invokes the lpfc_els_free_iocb() routine to release |
| 3721 | * the IOCB. Under error conditions, such as when a LS_RJT is returned or a |
| 3722 | * link down event occurred during the discovery, the lpfc_nlp_not_used() |
| 3723 | * routine shall be invoked trying to release the ndlp if no other threads |
| 3724 | * are currently referring it. |
| 3725 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3726 | static void |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3727 | lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3728 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3729 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3730 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 3731 | struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL; |
| 3732 | struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3733 | IOCB_t *irsp; |
| 3734 | uint8_t *pcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3735 | LPFC_MBOXQ_t *mbox = NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3736 | struct lpfc_dmabuf *mp = NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3737 | uint32_t ls_rjt = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3738 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 3739 | irsp = &rspiocb->iocb; |
| 3740 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3741 | if (cmdiocb->context_un.mbox) |
| 3742 | mbox = cmdiocb->context_un.mbox; |
| 3743 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3744 | /* First determine if this is a LS_RJT cmpl. Note, this callback |
| 3745 | * function can have cmdiocb->contest1 (ndlp) field set to NULL. |
| 3746 | */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3747 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3748 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 3749 | (*((uint32_t *) (pcmd)) == ELS_CMD_LS_RJT)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3750 | /* A LS_RJT associated with Default RPI cleanup has its own |
Daniel Mack | 3ad2f3f | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 3751 | * separate code path. |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3752 | */ |
| 3753 | if (!(ndlp->nlp_flag & NLP_RM_DFLT_RPI)) |
| 3754 | ls_rjt = 1; |
| 3755 | } |
| 3756 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3757 | /* Check to see if link went down during discovery */ |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3758 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) || lpfc_els_chk_latt(vport)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3759 | if (mbox) { |
James Smart | 1469115 | 2006-12-02 13:34:28 -0500 | [diff] [blame] | 3760 | mp = (struct lpfc_dmabuf *) mbox->context1; |
| 3761 | if (mp) { |
| 3762 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3763 | kfree(mp); |
| 3764 | } |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3765 | mempool_free(mbox, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3766 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3767 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 3768 | (ndlp->nlp_flag & NLP_RM_DFLT_RPI)) |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3769 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3770 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3771 | /* Indicate the node has already released, |
| 3772 | * should not reference to it from within |
| 3773 | * the routine lpfc_els_free_iocb. |
| 3774 | */ |
| 3775 | cmdiocb->context1 = NULL; |
| 3776 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3777 | goto out; |
| 3778 | } |
| 3779 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3780 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3781 | "ELS rsp cmpl: status:x%x/x%x did:x%x", |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3782 | irsp->ulpStatus, irsp->un.ulpWord[4], |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3783 | cmdiocb->iocb.un.elsreq64.remoteID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3784 | /* ELS response tag <ulpIoTag> completes */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3785 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3786 | "0110 ELS response tag x%x completes " |
| 3787 | "Data: x%x x%x x%x x%x x%x x%x x%x\n", |
| 3788 | cmdiocb->iocb.ulpIoTag, rspiocb->iocb.ulpStatus, |
| 3789 | rspiocb->iocb.un.ulpWord[4], rspiocb->iocb.ulpTimeout, |
| 3790 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3791 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3792 | if (mbox) { |
| 3793 | if ((rspiocb->iocb.ulpStatus == 0) |
| 3794 | && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3795 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3796 | /* Increment reference count to ndlp to hold the |
| 3797 | * reference to ndlp for the callback function. |
| 3798 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3799 | mbox->context2 = lpfc_nlp_get(ndlp); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3800 | mbox->vport = vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3801 | if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) { |
| 3802 | mbox->mbox_flag |= LPFC_MBX_IMED_UNREG; |
| 3803 | mbox->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi; |
| 3804 | } |
| 3805 | else { |
| 3806 | mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; |
| 3807 | ndlp->nlp_prev_state = ndlp->nlp_state; |
| 3808 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3809 | NLP_STE_REG_LOGIN_ISSUE); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3810 | } |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 3811 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3812 | != MBX_NOT_FINISHED) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3813 | goto out; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3814 | else |
| 3815 | /* Decrement the ndlp reference count we |
| 3816 | * set for this failed mailbox command. |
| 3817 | */ |
| 3818 | lpfc_nlp_put(ndlp); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3819 | |
| 3820 | /* ELS rsp: Cannot issue reg_login for <NPortid> */ |
| 3821 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3822 | "0138 ELS rsp: Cannot issue reg_login for x%x " |
| 3823 | "Data: x%x x%x x%x\n", |
| 3824 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3825 | ndlp->nlp_rpi); |
| 3826 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3827 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3828 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3829 | /* Indicate node has already been released, |
| 3830 | * should not reference to it from within |
| 3831 | * the routine lpfc_els_free_iocb. |
| 3832 | */ |
| 3833 | cmdiocb->context1 = NULL; |
| 3834 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3835 | } else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3836 | /* Do not drop node for lpfc_els_abort'ed ELS cmds */ |
| 3837 | if (!lpfc_error_lost_link(irsp) && |
| 3838 | ndlp->nlp_flag & NLP_ACC_REGLOGIN) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3839 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3840 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3841 | /* Indicate node has already been |
| 3842 | * released, should not reference |
| 3843 | * to it from within the routine |
| 3844 | * lpfc_els_free_iocb. |
| 3845 | */ |
| 3846 | cmdiocb->context1 = NULL; |
| 3847 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3848 | } |
| 3849 | } |
James Smart | 1469115 | 2006-12-02 13:34:28 -0500 | [diff] [blame] | 3850 | mp = (struct lpfc_dmabuf *) mbox->context1; |
| 3851 | if (mp) { |
| 3852 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3853 | kfree(mp); |
| 3854 | } |
| 3855 | mempool_free(mbox, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3856 | } |
| 3857 | out: |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3858 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3859 | spin_lock_irq(shost->host_lock); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3860 | ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3861 | spin_unlock_irq(shost->host_lock); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3862 | |
| 3863 | /* If the node is not being used by another discovery thread, |
| 3864 | * and we are sending a reject, we are done with it. |
| 3865 | * Release driver reference count here and free associated |
| 3866 | * resources. |
| 3867 | */ |
| 3868 | if (ls_rjt) |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3869 | if (lpfc_nlp_not_used(ndlp)) |
| 3870 | /* Indicate node has already been released, |
| 3871 | * should not reference to it from within |
| 3872 | * the routine lpfc_els_free_iocb. |
| 3873 | */ |
| 3874 | cmdiocb->context1 = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3875 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3876 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3877 | lpfc_els_free_iocb(phba, cmdiocb); |
| 3878 | return; |
| 3879 | } |
| 3880 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3881 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3882 | * lpfc_els_rsp_acc - Prepare and issue an acc response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3883 | * @vport: pointer to a host virtual N_Port data structure. |
| 3884 | * @flag: the els command code to be accepted. |
| 3885 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 3886 | * @ndlp: pointer to a node-list data structure. |
| 3887 | * @mbox: pointer to the driver internal queue element for mailbox command. |
| 3888 | * |
| 3889 | * This routine prepares and issues an Accept (ACC) response IOCB |
| 3890 | * command. It uses the @flag to properly set up the IOCB field for the |
| 3891 | * specific ACC response command to be issued and invokes the |
| 3892 | * lpfc_sli_issue_iocb() routine to send out ACC response IOCB. If a |
| 3893 | * @mbox pointer is passed in, it will be put into the context_un.mbox |
| 3894 | * field of the IOCB for the completion callback function to issue the |
| 3895 | * mailbox command to the HBA later when callback is invoked. |
| 3896 | * |
| 3897 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 3898 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 3899 | * will be stored into the context1 field of the IOCB for the completion |
| 3900 | * callback function to the corresponding response ELS IOCB command. |
| 3901 | * |
| 3902 | * Return code |
| 3903 | * 0 - Successfully issued acc response |
| 3904 | * 1 - Failed to issue acc response |
| 3905 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3906 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3907 | lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, |
| 3908 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3909 | LPFC_MBOXQ_t *mbox) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3910 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3911 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3912 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3913 | IOCB_t *icmd; |
| 3914 | IOCB_t *oldcmd; |
| 3915 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3916 | struct lpfc_sli *psli; |
| 3917 | uint8_t *pcmd; |
| 3918 | uint16_t cmdsize; |
| 3919 | int rc; |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3920 | ELS_PKT *els_pkt_ptr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3921 | |
| 3922 | psli = &phba->sli; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3923 | oldcmd = &oldiocb->iocb; |
| 3924 | |
| 3925 | switch (flag) { |
| 3926 | case ELS_CMD_ACC: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3927 | cmdsize = sizeof(uint32_t); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3928 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
| 3929 | ndlp, ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3930 | if (!elsiocb) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3931 | spin_lock_irq(shost->host_lock); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3932 | ndlp->nlp_flag &= ~NLP_LOGO_ACC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3933 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3934 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3935 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3936 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3937 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 3938 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 3939 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3940 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3941 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3942 | pcmd += sizeof(uint32_t); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3943 | |
| 3944 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3945 | "Issue ACC: did:x%x flg:x%x", |
| 3946 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3947 | break; |
| 3948 | case ELS_CMD_PLOGI: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3949 | cmdsize = (sizeof(struct serv_parm) + sizeof(uint32_t)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3950 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
| 3951 | ndlp, ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3952 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3953 | return 1; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3954 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3955 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 3956 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 3957 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3958 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3959 | |
| 3960 | if (mbox) |
| 3961 | elsiocb->context_un.mbox = mbox; |
| 3962 | |
| 3963 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3964 | pcmd += sizeof(uint32_t); |
| 3965 | memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3966 | |
| 3967 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3968 | "Issue ACC PLOGI: did:x%x flg:x%x", |
| 3969 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3970 | break; |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3971 | case ELS_CMD_PRLO: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3972 | cmdsize = sizeof(uint32_t) + sizeof(PRLO); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3973 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3974 | ndlp, ndlp->nlp_DID, ELS_CMD_PRLO); |
| 3975 | if (!elsiocb) |
| 3976 | return 1; |
| 3977 | |
| 3978 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 3979 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 3980 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3981 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3982 | |
| 3983 | memcpy(pcmd, ((struct lpfc_dmabuf *) oldiocb->context2)->virt, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3984 | sizeof(uint32_t) + sizeof(PRLO)); |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3985 | *((uint32_t *) (pcmd)) = ELS_CMD_PRLO_ACC; |
| 3986 | els_pkt_ptr = (ELS_PKT *) pcmd; |
| 3987 | els_pkt_ptr->un.prlo.acceptRspCode = PRLO_REQ_EXECUTED; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3988 | |
| 3989 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3990 | "Issue ACC PRLO: did:x%x flg:x%x", |
| 3991 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3992 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3993 | default: |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3994 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3995 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3996 | /* Xmit ELS ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3997 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3998 | "0128 Xmit ELS ACC response tag x%x, XRI: x%x, " |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 3999 | "DID: x%x, nlp_flag: x%x nlp_state: x%x RPI: x%x " |
| 4000 | "fc_flag x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4001 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 4002 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 4003 | ndlp->nlp_rpi, vport->fc_flag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4004 | if (ndlp->nlp_flag & NLP_LOGO_ACC) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4005 | spin_lock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4006 | ndlp->nlp_flag &= ~NLP_LOGO_ACC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4007 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4008 | elsiocb->iocb_cmpl = lpfc_cmpl_els_logo_acc; |
| 4009 | } else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4010 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4011 | } |
| 4012 | |
| 4013 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4014 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4015 | if (rc == IOCB_ERROR) { |
| 4016 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4017 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4018 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4019 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4020 | } |
| 4021 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4022 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4023 | * lpfc_els_rsp_reject - Propare and issue a rjt response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4024 | * @vport: pointer to a virtual N_Port data structure. |
| 4025 | * @rejectError: |
| 4026 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4027 | * @ndlp: pointer to a node-list data structure. |
| 4028 | * @mbox: pointer to the driver internal queue element for mailbox command. |
| 4029 | * |
| 4030 | * This routine prepares and issue an Reject (RJT) response IOCB |
| 4031 | * command. If a @mbox pointer is passed in, it will be put into the |
| 4032 | * context_un.mbox field of the IOCB for the completion callback function |
| 4033 | * to issue to the HBA later. |
| 4034 | * |
| 4035 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4036 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4037 | * will be stored into the context1 field of the IOCB for the completion |
| 4038 | * callback function to the reject response ELS IOCB command. |
| 4039 | * |
| 4040 | * Return code |
| 4041 | * 0 - Successfully issued reject response |
| 4042 | * 1 - Failed to issue reject response |
| 4043 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4044 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4045 | lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4046 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, |
| 4047 | LPFC_MBOXQ_t *mbox) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4048 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4049 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4050 | IOCB_t *icmd; |
| 4051 | IOCB_t *oldcmd; |
| 4052 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4053 | struct lpfc_sli *psli; |
| 4054 | uint8_t *pcmd; |
| 4055 | uint16_t cmdsize; |
| 4056 | int rc; |
| 4057 | |
| 4058 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4059 | cmdsize = 2 * sizeof(uint32_t); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4060 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4061 | ndlp->nlp_DID, ELS_CMD_LS_RJT); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 4062 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4063 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4064 | |
| 4065 | icmd = &elsiocb->iocb; |
| 4066 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4067 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4068 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4069 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4070 | |
| 4071 | *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4072 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4073 | *((uint32_t *) (pcmd)) = rejectError; |
| 4074 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4075 | if (mbox) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4076 | elsiocb->context_un.mbox = mbox; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4077 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4078 | /* Xmit ELS RJT <err> response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4079 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4080 | "0129 Xmit ELS RJT x%x response tag x%x " |
| 4081 | "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " |
| 4082 | "rpi x%x\n", |
| 4083 | rejectError, elsiocb->iotag, |
| 4084 | elsiocb->iocb.ulpContext, ndlp->nlp_DID, |
| 4085 | ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4086 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4087 | "Issue LS_RJT: did:x%x flg:x%x err:x%x", |
| 4088 | ndlp->nlp_DID, ndlp->nlp_flag, rejectError); |
| 4089 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4090 | phba->fc_stat.elsXmitLSRJT++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4091 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4092 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4093 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4094 | if (rc == IOCB_ERROR) { |
| 4095 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4096 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4097 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4098 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4099 | } |
| 4100 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4101 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4102 | * 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] | 4103 | * @vport: pointer to a virtual N_Port data structure. |
| 4104 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4105 | * @ndlp: pointer to a node-list data structure. |
| 4106 | * |
| 4107 | * This routine prepares and issues an Accept (ACC) response to Address |
| 4108 | * Discover (ADISC) ELS command. It simply prepares the payload of the IOCB |
| 4109 | * and invokes the lpfc_sli_issue_iocb() routine to send out the command. |
| 4110 | * |
| 4111 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4112 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4113 | * will be stored into the context1 field of the IOCB for the completion |
| 4114 | * callback function to the ADISC Accept response ELS IOCB command. |
| 4115 | * |
| 4116 | * Return code |
| 4117 | * 0 - Successfully issued acc adisc response |
| 4118 | * 1 - Failed to issue adisc acc response |
| 4119 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4120 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4121 | lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, |
| 4122 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4123 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4124 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4125 | ADISC *ap; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4126 | IOCB_t *icmd, *oldcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4127 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4128 | uint8_t *pcmd; |
| 4129 | uint16_t cmdsize; |
| 4130 | int rc; |
| 4131 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4132 | cmdsize = sizeof(uint32_t) + sizeof(ADISC); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4133 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4134 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 4135 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4136 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4137 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4138 | icmd = &elsiocb->iocb; |
| 4139 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4140 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4141 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 4142 | |
| 4143 | /* Xmit ADISC ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4144 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4145 | "0130 Xmit ADISC ACC response iotag x%x xri: " |
| 4146 | "x%x, did x%x, nlp_flag x%x, nlp_state x%x rpi x%x\n", |
| 4147 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 4148 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 4149 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4150 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4151 | |
| 4152 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4153 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4154 | |
| 4155 | ap = (ADISC *) (pcmd); |
| 4156 | ap->hardAL_PA = phba->fc_pref_ALPA; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4157 | memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 4158 | memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4159 | ap->DID = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4160 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4161 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4162 | "Issue ACC ADISC: did:x%x flg:x%x", |
| 4163 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4164 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4165 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4166 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4167 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4168 | if (rc == IOCB_ERROR) { |
| 4169 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4170 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4171 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4172 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4173 | } |
| 4174 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4175 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4176 | * 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] | 4177 | * @vport: pointer to a virtual N_Port data structure. |
| 4178 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4179 | * @ndlp: pointer to a node-list data structure. |
| 4180 | * |
| 4181 | * This routine prepares and issues an Accept (ACC) response to Process |
| 4182 | * Login (PRLI) ELS command. It simply prepares the payload of the IOCB |
| 4183 | * and invokes the lpfc_sli_issue_iocb() routine to send out the command. |
| 4184 | * |
| 4185 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4186 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4187 | * will be stored into the context1 field of the IOCB for the completion |
| 4188 | * callback function to the PRLI Accept response ELS IOCB command. |
| 4189 | * |
| 4190 | * Return code |
| 4191 | * 0 - Successfully issued acc prli response |
| 4192 | * 1 - Failed to issue acc prli response |
| 4193 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4194 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4195 | 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] | 4196 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4197 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4198 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4199 | PRLI *npr; |
| 4200 | lpfc_vpd_t *vpd; |
| 4201 | IOCB_t *icmd; |
| 4202 | IOCB_t *oldcmd; |
| 4203 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4204 | struct lpfc_sli *psli; |
| 4205 | uint8_t *pcmd; |
| 4206 | uint16_t cmdsize; |
| 4207 | int rc; |
| 4208 | |
| 4209 | psli = &phba->sli; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4210 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4211 | cmdsize = sizeof(uint32_t) + sizeof(PRLI); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4212 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4213 | ndlp->nlp_DID, (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK))); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4214 | if (!elsiocb) |
| 4215 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4216 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4217 | icmd = &elsiocb->iocb; |
| 4218 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4219 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4220 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| 4221 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 4222 | /* Xmit PRLI ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4223 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4224 | "0131 Xmit PRLI ACC response tag x%x xri x%x, " |
| 4225 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", |
| 4226 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 4227 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 4228 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4229 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4230 | |
| 4231 | *((uint32_t *) (pcmd)) = (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4232 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4233 | |
| 4234 | /* For PRLI, remainder of payload is PRLI parameter page */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4235 | memset(pcmd, 0, sizeof(PRLI)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4236 | |
| 4237 | npr = (PRLI *) pcmd; |
| 4238 | vpd = &phba->vpd; |
| 4239 | /* |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4240 | * If the remote port is a target and our firmware version is 3.20 or |
| 4241 | * later, set the following bits for FC-TAPE support. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4242 | */ |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4243 | if ((ndlp->nlp_type & NLP_FCP_TARGET) && |
| 4244 | (vpd->rev.feaLevelHigh >= 0x02)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4245 | npr->ConfmComplAllowed = 1; |
| 4246 | npr->Retry = 1; |
| 4247 | npr->TaskRetryIdReq = 1; |
| 4248 | } |
| 4249 | |
| 4250 | npr->acceptRspCode = PRLI_REQ_EXECUTED; |
| 4251 | npr->estabImagePair = 1; |
| 4252 | npr->readXferRdyDis = 1; |
| 4253 | npr->ConfmComplAllowed = 1; |
| 4254 | |
| 4255 | npr->prliType = PRLI_FCP_TYPE; |
| 4256 | npr->initiatorFunc = 1; |
| 4257 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4258 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4259 | "Issue ACC PRLI: did:x%x flg:x%x", |
| 4260 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4261 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4262 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4263 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4264 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4265 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4266 | if (rc == IOCB_ERROR) { |
| 4267 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4268 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4269 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4270 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4271 | } |
| 4272 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4273 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4274 | * lpfc_els_rsp_rnid_acc - Issue rnid acc response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4275 | * @vport: pointer to a virtual N_Port data structure. |
| 4276 | * @format: rnid command format. |
| 4277 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4278 | * @ndlp: pointer to a node-list data structure. |
| 4279 | * |
| 4280 | * This routine issues a Request Node Identification Data (RNID) Accept |
| 4281 | * (ACC) response. It constructs the RNID ACC response command according to |
| 4282 | * the proper @format and then calls the lpfc_sli_issue_iocb() routine to |
| 4283 | * issue the response. Note that this command does not need to hold the ndlp |
| 4284 | * reference count for the callback. So, the ndlp reference count taken by |
| 4285 | * the lpfc_prep_els_iocb() routine is put back and the context1 field of |
| 4286 | * IOCB is set to NULL to indicate to the lpfc_els_free_iocb() routine that |
| 4287 | * there is no ndlp reference available. |
| 4288 | * |
| 4289 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4290 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4291 | * will be stored into the context1 field of the IOCB for the completion |
| 4292 | * callback function. However, for the RNID Accept Response ELS command, |
| 4293 | * this is undone later by this routine after the IOCB is allocated. |
| 4294 | * |
| 4295 | * Return code |
| 4296 | * 0 - Successfully issued acc rnid response |
| 4297 | * 1 - Failed to issue acc rnid response |
| 4298 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4299 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4300 | lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 4301 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4302 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4303 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4304 | RNID *rn; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4305 | IOCB_t *icmd, *oldcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4306 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4307 | struct lpfc_sli *psli; |
| 4308 | uint8_t *pcmd; |
| 4309 | uint16_t cmdsize; |
| 4310 | int rc; |
| 4311 | |
| 4312 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4313 | cmdsize = sizeof(uint32_t) + sizeof(uint32_t) |
| 4314 | + (2 * sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4315 | if (format) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4316 | cmdsize += sizeof(RNID_TOP_DISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4317 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4318 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4319 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 4320 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4321 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4322 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4323 | icmd = &elsiocb->iocb; |
| 4324 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4325 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4326 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| 4327 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 4328 | /* Xmit RNID ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4329 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4330 | "0132 Xmit RNID ACC response tag x%x xri x%x\n", |
| 4331 | elsiocb->iotag, elsiocb->iocb.ulpContext); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4332 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4333 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4334 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4335 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4336 | memset(pcmd, 0, sizeof(RNID)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4337 | rn = (RNID *) (pcmd); |
| 4338 | rn->Format = format; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4339 | rn->CommonLen = (2 * sizeof(struct lpfc_name)); |
| 4340 | memcpy(&rn->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 4341 | memcpy(&rn->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4342 | switch (format) { |
| 4343 | case 0: |
| 4344 | rn->SpecificLen = 0; |
| 4345 | break; |
| 4346 | case RNID_TOPOLOGY_DISC: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4347 | rn->SpecificLen = sizeof(RNID_TOP_DISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4348 | memcpy(&rn->un.topologyDisc.portName, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4349 | &vport->fc_portname, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4350 | rn->un.topologyDisc.unitType = RNID_HBA; |
| 4351 | rn->un.topologyDisc.physPort = 0; |
| 4352 | rn->un.topologyDisc.attachedNodes = 0; |
| 4353 | break; |
| 4354 | default: |
| 4355 | rn->CommonLen = 0; |
| 4356 | rn->SpecificLen = 0; |
| 4357 | break; |
| 4358 | } |
| 4359 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4360 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4361 | "Issue ACC RNID: did:x%x flg:x%x", |
| 4362 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4363 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4364 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4365 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4366 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4367 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4368 | if (rc == IOCB_ERROR) { |
| 4369 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4370 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4371 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4372 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4373 | } |
| 4374 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4375 | /** |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4376 | * lpfc_els_clear_rrq - Clear the rq that this rrq describes. |
| 4377 | * @vport: pointer to a virtual N_Port data structure. |
| 4378 | * @iocb: pointer to the lpfc command iocb data structure. |
| 4379 | * @ndlp: pointer to a node-list data structure. |
| 4380 | * |
| 4381 | * Return |
| 4382 | **/ |
| 4383 | static void |
| 4384 | lpfc_els_clear_rrq(struct lpfc_vport *vport, |
| 4385 | struct lpfc_iocbq *iocb, struct lpfc_nodelist *ndlp) |
| 4386 | { |
| 4387 | struct lpfc_hba *phba = vport->phba; |
| 4388 | uint8_t *pcmd; |
| 4389 | struct RRQ *rrq; |
| 4390 | uint16_t rxid; |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4391 | uint16_t xri; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4392 | struct lpfc_node_rrq *prrq; |
| 4393 | |
| 4394 | |
| 4395 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) iocb->context2)->virt); |
| 4396 | pcmd += sizeof(uint32_t); |
| 4397 | rrq = (struct RRQ *)pcmd; |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4398 | rrq->rrq_exchg = be32_to_cpu(rrq->rrq_exchg); |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 4399 | rxid = bf_get(rrq_rxid, rrq); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4400 | |
| 4401 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4402 | "2883 Clear RRQ for SID:x%x OXID:x%x RXID:x%x" |
| 4403 | " x%x x%x\n", |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4404 | be32_to_cpu(bf_get(rrq_did, rrq)), |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 4405 | bf_get(rrq_oxid, rrq), |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4406 | rxid, |
| 4407 | iocb->iotag, iocb->iocb.ulpContext); |
| 4408 | |
| 4409 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4410 | "Clear RRQ: did:x%x flg:x%x exchg:x%.08x", |
| 4411 | ndlp->nlp_DID, ndlp->nlp_flag, rrq->rrq_exchg); |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4412 | if (vport->fc_myDID == be32_to_cpu(bf_get(rrq_did, rrq))) |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 4413 | xri = bf_get(rrq_oxid, rrq); |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4414 | else |
| 4415 | xri = rxid; |
| 4416 | prrq = lpfc_get_active_rrq(vport, xri, ndlp->nlp_DID); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4417 | if (prrq) |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4418 | lpfc_clr_rrq_active(phba, xri, prrq); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4419 | return; |
| 4420 | } |
| 4421 | |
| 4422 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4423 | * lpfc_els_rsp_echo_acc - Issue echo acc response |
| 4424 | * @vport: pointer to a virtual N_Port data structure. |
| 4425 | * @data: pointer to echo data to return in the accept. |
| 4426 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4427 | * @ndlp: pointer to a node-list data structure. |
| 4428 | * |
| 4429 | * Return code |
| 4430 | * 0 - Successfully issued acc echo response |
| 4431 | * 1 - Failed to issue acc echo response |
| 4432 | **/ |
| 4433 | static int |
| 4434 | lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data, |
| 4435 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) |
| 4436 | { |
| 4437 | struct lpfc_hba *phba = vport->phba; |
| 4438 | struct lpfc_iocbq *elsiocb; |
| 4439 | struct lpfc_sli *psli; |
| 4440 | uint8_t *pcmd; |
| 4441 | uint16_t cmdsize; |
| 4442 | int rc; |
| 4443 | |
| 4444 | psli = &phba->sli; |
| 4445 | cmdsize = oldiocb->iocb.unsli3.rcvsli3.acc_len; |
| 4446 | |
James Smart | bf08611 | 2011-08-21 21:48:13 -0400 | [diff] [blame] | 4447 | /* The accumulated length can exceed the BPL_SIZE. For |
| 4448 | * now, use this as the limit |
| 4449 | */ |
| 4450 | if (cmdsize > LPFC_BPL_SIZE) |
| 4451 | cmdsize = LPFC_BPL_SIZE; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4452 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4453 | ndlp->nlp_DID, ELS_CMD_ACC); |
| 4454 | if (!elsiocb) |
| 4455 | return 1; |
| 4456 | |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4457 | elsiocb->iocb.ulpContext = oldiocb->iocb.ulpContext; /* Xri / rx_id */ |
| 4458 | elsiocb->iocb.unsli3.rcvsli3.ox_id = oldiocb->iocb.unsli3.rcvsli3.ox_id; |
| 4459 | |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4460 | /* Xmit ECHO ACC response tag <ulpIoTag> */ |
| 4461 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4462 | "2876 Xmit ECHO ACC response tag x%x xri x%x\n", |
| 4463 | elsiocb->iotag, elsiocb->iocb.ulpContext); |
| 4464 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4465 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
| 4466 | pcmd += sizeof(uint32_t); |
| 4467 | memcpy(pcmd, data, cmdsize - sizeof(uint32_t)); |
| 4468 | |
| 4469 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4470 | "Issue ACC ECHO: did:x%x flg:x%x", |
| 4471 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4472 | |
| 4473 | phba->fc_stat.elsXmitACC++; |
| 4474 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4475 | |
| 4476 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| 4477 | if (rc == IOCB_ERROR) { |
| 4478 | lpfc_els_free_iocb(phba, elsiocb); |
| 4479 | return 1; |
| 4480 | } |
| 4481 | return 0; |
| 4482 | } |
| 4483 | |
| 4484 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4485 | * 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] | 4486 | * @vport: pointer to a host virtual N_Port data structure. |
| 4487 | * |
| 4488 | * This routine issues Address Discover (ADISC) ELS commands to those |
| 4489 | * N_Ports which are in node port recovery state and ADISC has not been issued |
| 4490 | * for the @vport. Each time an ELS ADISC IOCB is issued by invoking the |
| 4491 | * lpfc_issue_els_adisc() routine, the per @vport number of discover count |
| 4492 | * (num_disc_nodes) shall be incremented. If the num_disc_nodes reaches a |
| 4493 | * pre-configured threshold (cfg_discovery_threads), the @vport fc_flag will |
| 4494 | * be marked with FC_NLP_MORE bit and the process of issuing remaining ADISC |
| 4495 | * IOCBs quit for later pick up. On the other hand, after walking through |
| 4496 | * all the ndlps with the @vport and there is none ADISC IOCB issued, the |
| 4497 | * @vport fc_flag shall be cleared with FC_NLP_MORE bit indicating there is |
| 4498 | * no more ADISC need to be sent. |
| 4499 | * |
| 4500 | * Return code |
| 4501 | * The number of N_Ports with adisc issued. |
| 4502 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4503 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4504 | lpfc_els_disc_adisc(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4505 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4506 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4507 | struct lpfc_nodelist *ndlp, *next_ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4508 | int sentadisc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4509 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4510 | /* go thru NPR nodes and issue any remaining ELS ADISCs */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4511 | 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] | 4512 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4513 | continue; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4514 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && |
| 4515 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && |
| 4516 | (ndlp->nlp_flag & NLP_NPR_ADISC) != 0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4517 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4518 | ndlp->nlp_flag &= ~NLP_NPR_ADISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4519 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4520 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4521 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE); |
| 4522 | lpfc_issue_els_adisc(vport, ndlp, 0); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4523 | sentadisc++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4524 | vport->num_disc_nodes++; |
| 4525 | if (vport->num_disc_nodes >= |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4526 | vport->cfg_discovery_threads) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4527 | spin_lock_irq(shost->host_lock); |
| 4528 | vport->fc_flag |= FC_NLP_MORE; |
| 4529 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4530 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4531 | } |
| 4532 | } |
| 4533 | } |
| 4534 | if (sentadisc == 0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4535 | spin_lock_irq(shost->host_lock); |
| 4536 | vport->fc_flag &= ~FC_NLP_MORE; |
| 4537 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4538 | } |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 4539 | return sentadisc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4540 | } |
| 4541 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4542 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4543 | * 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] | 4544 | * @vport: pointer to a host virtual N_Port data structure. |
| 4545 | * |
| 4546 | * This routine issues Port Login (PLOGI) ELS commands to all the N_Ports |
| 4547 | * which are in node port recovery state, with a @vport. Each time an ELS |
| 4548 | * ADISC PLOGI IOCB is issued by invoking the lpfc_issue_els_plogi() routine, |
| 4549 | * the per @vport number of discover count (num_disc_nodes) shall be |
| 4550 | * incremented. If the num_disc_nodes reaches a pre-configured threshold |
| 4551 | * (cfg_discovery_threads), the @vport fc_flag will be marked with FC_NLP_MORE |
| 4552 | * bit set and quit the process of issuing remaining ADISC PLOGIN IOCBs for |
| 4553 | * later pick up. On the other hand, after walking through all the ndlps with |
| 4554 | * the @vport and there is none ADISC PLOGI IOCB issued, the @vport fc_flag |
| 4555 | * shall be cleared with the FC_NLP_MORE bit indicating there is no more ADISC |
| 4556 | * PLOGI need to be sent. |
| 4557 | * |
| 4558 | * Return code |
| 4559 | * The number of N_Ports with plogi issued. |
| 4560 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4561 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4562 | lpfc_els_disc_plogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4563 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4564 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4565 | struct lpfc_nodelist *ndlp, *next_ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4566 | int sentplogi = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4567 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4568 | /* go thru NPR nodes and issue any remaining ELS PLOGIs */ |
| 4569 | 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] | 4570 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4571 | continue; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4572 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && |
| 4573 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && |
| 4574 | (ndlp->nlp_flag & NLP_DELAY_TMO) == 0 && |
| 4575 | (ndlp->nlp_flag & NLP_NPR_ADISC) == 0) { |
| 4576 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4577 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
| 4578 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4579 | sentplogi++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4580 | vport->num_disc_nodes++; |
| 4581 | if (vport->num_disc_nodes >= |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4582 | vport->cfg_discovery_threads) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4583 | spin_lock_irq(shost->host_lock); |
| 4584 | vport->fc_flag |= FC_NLP_MORE; |
| 4585 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4586 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4587 | } |
| 4588 | } |
| 4589 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 4590 | if (sentplogi) { |
| 4591 | lpfc_set_disctmo(vport); |
| 4592 | } |
| 4593 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4594 | spin_lock_irq(shost->host_lock); |
| 4595 | vport->fc_flag &= ~FC_NLP_MORE; |
| 4596 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4597 | } |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 4598 | return sentplogi; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4599 | } |
| 4600 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4601 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4602 | * lpfc_els_flush_rscn - Clean up any rscn activities with a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4603 | * @vport: pointer to a host virtual N_Port data structure. |
| 4604 | * |
| 4605 | * This routine cleans up any Registration State Change Notification |
| 4606 | * (RSCN) activity with a @vport. Note that the fc_rscn_flush flag of the |
| 4607 | * @vport together with the host_lock is used to prevent multiple thread |
| 4608 | * trying to access the RSCN array on a same @vport at the same time. |
| 4609 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4610 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4611 | lpfc_els_flush_rscn(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4612 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4613 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4614 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4615 | int i; |
| 4616 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4617 | spin_lock_irq(shost->host_lock); |
| 4618 | if (vport->fc_rscn_flush) { |
| 4619 | /* Another thread is walking fc_rscn_id_list on this vport */ |
| 4620 | spin_unlock_irq(shost->host_lock); |
| 4621 | return; |
| 4622 | } |
| 4623 | /* Indicate we are walking lpfc_els_flush_rscn on this vport */ |
| 4624 | vport->fc_rscn_flush = 1; |
| 4625 | spin_unlock_irq(shost->host_lock); |
| 4626 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4627 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4628 | lpfc_in_buf_free(phba, vport->fc_rscn_id_list[i]); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4629 | vport->fc_rscn_id_list[i] = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4630 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4631 | spin_lock_irq(shost->host_lock); |
| 4632 | vport->fc_rscn_id_cnt = 0; |
| 4633 | vport->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY); |
| 4634 | spin_unlock_irq(shost->host_lock); |
| 4635 | lpfc_can_disctmo(vport); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4636 | /* Indicate we are done walking this fc_rscn_id_list */ |
| 4637 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4638 | } |
| 4639 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4640 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4641 | * 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] | 4642 | * @vport: pointer to a host virtual N_Port data structure. |
| 4643 | * @did: remote destination port identifier. |
| 4644 | * |
| 4645 | * This routine checks whether there is any pending Registration State |
| 4646 | * Configuration Notification (RSCN) to a @did on @vport. |
| 4647 | * |
| 4648 | * Return code |
| 4649 | * None zero - The @did matched with a pending rscn |
| 4650 | * 0 - not able to match @did with a pending rscn |
| 4651 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4652 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4653 | lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4654 | { |
| 4655 | D_ID ns_did; |
| 4656 | D_ID rscn_did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4657 | uint32_t *lp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4658 | uint32_t payload_len, i; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4659 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4660 | |
| 4661 | ns_did.un.word = did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4662 | |
| 4663 | /* Never match fabric nodes for RSCNs */ |
| 4664 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4665 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4666 | |
| 4667 | /* If we are doing a FULL RSCN rediscovery, match everything */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4668 | if (vport->fc_flag & FC_RSCN_DISCOVERY) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4669 | return did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4670 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4671 | spin_lock_irq(shost->host_lock); |
| 4672 | if (vport->fc_rscn_flush) { |
| 4673 | /* Another thread is walking fc_rscn_id_list on this vport */ |
| 4674 | spin_unlock_irq(shost->host_lock); |
| 4675 | return 0; |
| 4676 | } |
| 4677 | /* Indicate we are walking fc_rscn_id_list on this vport */ |
| 4678 | vport->fc_rscn_flush = 1; |
| 4679 | spin_unlock_irq(shost->host_lock); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4680 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4681 | lp = vport->fc_rscn_id_list[i]->virt; |
| 4682 | payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); |
| 4683 | payload_len -= sizeof(uint32_t); /* take off word 0 */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4684 | while (payload_len) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4685 | rscn_did.un.word = be32_to_cpu(*lp++); |
| 4686 | payload_len -= sizeof(uint32_t); |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4687 | switch (rscn_did.un.b.resv & RSCN_ADDRESS_FORMAT_MASK) { |
| 4688 | case RSCN_ADDRESS_FORMAT_PORT: |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 4689 | if ((ns_did.un.b.domain == rscn_did.un.b.domain) |
| 4690 | && (ns_did.un.b.area == rscn_did.un.b.area) |
| 4691 | && (ns_did.un.b.id == rscn_did.un.b.id)) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4692 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4693 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4694 | case RSCN_ADDRESS_FORMAT_AREA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [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)) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4697 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4698 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4699 | case RSCN_ADDRESS_FORMAT_DOMAIN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4700 | if (ns_did.un.b.domain == rscn_did.un.b.domain) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4701 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4702 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4703 | case RSCN_ADDRESS_FORMAT_FABRIC: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4704 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4705 | } |
| 4706 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4707 | } |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4708 | /* Indicate we are done with walking fc_rscn_id_list on this vport */ |
| 4709 | vport->fc_rscn_flush = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4710 | return 0; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4711 | return_did_out: |
| 4712 | /* Indicate we are done with walking fc_rscn_id_list on this vport */ |
| 4713 | vport->fc_rscn_flush = 0; |
| 4714 | return did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4715 | } |
| 4716 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4717 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4718 | * lpfc_rscn_recovery_check - Send recovery event to vport nodes matching rscn |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4719 | * @vport: pointer to a host virtual N_Port data structure. |
| 4720 | * |
| 4721 | * This routine sends recovery (NLP_EVT_DEVICE_RECOVERY) event to the |
| 4722 | * state machine for a @vport's nodes that are with pending RSCN (Registration |
| 4723 | * State Change Notification). |
| 4724 | * |
| 4725 | * Return code |
| 4726 | * 0 - Successful (currently alway return 0) |
| 4727 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4728 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4729 | lpfc_rscn_recovery_check(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4730 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4731 | struct lpfc_nodelist *ndlp = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4732 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4733 | /* Move all affected nodes by pending RSCNs to NPR state. */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4734 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4735 | if (!NLP_CHK_NODE_ACT(ndlp) || |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4736 | (ndlp->nlp_state == NLP_STE_UNUSED_NODE) || |
| 4737 | !lpfc_rscn_payload_check(vport, ndlp->nlp_DID)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4738 | continue; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4739 | lpfc_disc_state_machine(vport, ndlp, NULL, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4740 | NLP_EVT_DEVICE_RECOVERY); |
| 4741 | lpfc_cancel_retry_delay_tmo(vport, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4742 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4743 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4744 | } |
| 4745 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4746 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4747 | * lpfc_send_rscn_event - Send an RSCN event to management application |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 4748 | * @vport: pointer to a host virtual N_Port data structure. |
| 4749 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4750 | * |
| 4751 | * lpfc_send_rscn_event sends an RSCN netlink event to management |
| 4752 | * applications. |
| 4753 | */ |
| 4754 | static void |
| 4755 | lpfc_send_rscn_event(struct lpfc_vport *vport, |
| 4756 | struct lpfc_iocbq *cmdiocb) |
| 4757 | { |
| 4758 | struct lpfc_dmabuf *pcmd; |
| 4759 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4760 | uint32_t *payload_ptr; |
| 4761 | uint32_t payload_len; |
| 4762 | struct lpfc_rscn_event_header *rscn_event_data; |
| 4763 | |
| 4764 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 4765 | payload_ptr = (uint32_t *) pcmd->virt; |
| 4766 | payload_len = be32_to_cpu(*payload_ptr & ~ELS_CMD_MASK); |
| 4767 | |
| 4768 | rscn_event_data = kmalloc(sizeof(struct lpfc_rscn_event_header) + |
| 4769 | payload_len, GFP_KERNEL); |
| 4770 | if (!rscn_event_data) { |
| 4771 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 4772 | "0147 Failed to allocate memory for RSCN event\n"); |
| 4773 | return; |
| 4774 | } |
| 4775 | rscn_event_data->event_type = FC_REG_RSCN_EVENT; |
| 4776 | rscn_event_data->payload_length = payload_len; |
| 4777 | memcpy(rscn_event_data->rscn_payload, payload_ptr, |
| 4778 | payload_len); |
| 4779 | |
| 4780 | fc_host_post_vendor_event(shost, |
| 4781 | fc_get_event_number(), |
| 4782 | sizeof(struct lpfc_els_event_header) + payload_len, |
| 4783 | (char *)rscn_event_data, |
| 4784 | LPFC_NL_VENDOR_ID); |
| 4785 | |
| 4786 | kfree(rscn_event_data); |
| 4787 | } |
| 4788 | |
| 4789 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4790 | * lpfc_els_rcv_rscn - Process an unsolicited rscn iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4791 | * @vport: pointer to a host virtual N_Port data structure. |
| 4792 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4793 | * @ndlp: pointer to a node-list data structure. |
| 4794 | * |
| 4795 | * This routine processes an unsolicited RSCN (Registration State Change |
| 4796 | * Notification) IOCB. First, the payload of the unsolicited RSCN is walked |
| 4797 | * to invoke fc_host_post_event() routine to the FC transport layer. If the |
| 4798 | * discover state machine is about to begin discovery, it just accepts the |
| 4799 | * RSCN and the discovery process will satisfy the RSCN. If this RSCN only |
| 4800 | * contains N_Port IDs for other vports on this HBA, it just accepts the |
| 4801 | * RSCN and ignore processing it. If the state machine is in the recovery |
| 4802 | * state, the fc_rscn_id_list of this @vport is walked and the |
| 4803 | * lpfc_rscn_recovery_check() routine is invoked to send recovery event for |
| 4804 | * all nodes that match RSCN payload. Otherwise, the lpfc_els_handle_rscn() |
| 4805 | * routine is invoked to handle the RSCN event. |
| 4806 | * |
| 4807 | * Return code |
| 4808 | * 0 - Just sent the acc response |
| 4809 | * 1 - Sent the acc response and waited for name server completion |
| 4810 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4811 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4812 | lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4813 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4814 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4815 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4816 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4817 | struct lpfc_dmabuf *pcmd; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4818 | uint32_t *lp, *datap; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4819 | IOCB_t *icmd; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4820 | uint32_t payload_len, length, nportid, *cmd; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4821 | int rscn_cnt; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4822 | int rscn_id = 0, hba_id = 0; |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 4823 | int i; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4824 | |
| 4825 | icmd = &cmdiocb->iocb; |
| 4826 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 4827 | lp = (uint32_t *) pcmd->virt; |
| 4828 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4829 | payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); |
| 4830 | payload_len -= sizeof(uint32_t); /* take off word 0 */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4831 | /* RSCN received */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4832 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 4833 | "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] | 4834 | vport->fc_flag, payload_len, *lp, |
| 4835 | vport->fc_rscn_id_cnt); |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 4836 | |
| 4837 | /* Send an RSCN event to the management application */ |
| 4838 | lpfc_send_rscn_event(vport, cmdiocb); |
| 4839 | |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 4840 | for (i = 0; i < payload_len/sizeof(uint32_t); i++) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4841 | fc_host_post_event(shost, fc_get_event_number(), |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 4842 | FCH_EVT_RSCN, lp[i]); |
| 4843 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4844 | /* If we are about to begin discovery, just ACC the RSCN. |
| 4845 | * Discovery processing will satisfy it. |
| 4846 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4847 | if (vport->port_state <= LPFC_NS_QRY) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4848 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4849 | "RCV RSCN ignore: did:x%x/ste:x%x flg:x%x", |
| 4850 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 4851 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4852 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4853 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4854 | } |
| 4855 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4856 | /* If this RSCN just contains NPortIDs for other vports on this HBA, |
| 4857 | * just ACC and ignore it. |
| 4858 | */ |
| 4859 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4860 | !(vport->cfg_peer_port_login)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4861 | i = payload_len; |
| 4862 | datap = lp; |
| 4863 | while (i > 0) { |
| 4864 | nportid = *datap++; |
| 4865 | nportid = ((be32_to_cpu(nportid)) & Mask_DID); |
| 4866 | i -= sizeof(uint32_t); |
| 4867 | rscn_id++; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 4868 | if (lpfc_find_vport_by_did(phba, nportid)) |
| 4869 | hba_id++; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4870 | } |
| 4871 | if (rscn_id == hba_id) { |
| 4872 | /* ALL NPortIDs in RSCN are on HBA */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4873 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4874 | "0219 Ignore RSCN " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4875 | "Data: x%x x%x x%x x%x\n", |
| 4876 | vport->fc_flag, payload_len, |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4877 | *lp, vport->fc_rscn_id_cnt); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4878 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4879 | "RCV RSCN vport: did:x%x/ste:x%x flg:x%x", |
| 4880 | ndlp->nlp_DID, vport->port_state, |
| 4881 | ndlp->nlp_flag); |
| 4882 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4883 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4884 | ndlp, NULL); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4885 | return 0; |
| 4886 | } |
| 4887 | } |
| 4888 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4889 | spin_lock_irq(shost->host_lock); |
| 4890 | if (vport->fc_rscn_flush) { |
| 4891 | /* Another thread is walking fc_rscn_id_list on this vport */ |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4892 | vport->fc_flag |= FC_RSCN_DISCOVERY; |
James Smart | 9795724 | 2009-12-21 17:03:15 -0500 | [diff] [blame] | 4893 | spin_unlock_irq(shost->host_lock); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 4894 | /* Send back ACC */ |
| 4895 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4896 | return 0; |
| 4897 | } |
| 4898 | /* Indicate we are walking fc_rscn_id_list on this vport */ |
| 4899 | vport->fc_rscn_flush = 1; |
| 4900 | spin_unlock_irq(shost->host_lock); |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 4901 | /* Get the array count after successfully have the token */ |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4902 | rscn_cnt = vport->fc_rscn_id_cnt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4903 | /* If we are already processing an RSCN, save the received |
| 4904 | * RSCN payload buffer, cmdiocb->context2 to process later. |
| 4905 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4906 | if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4907 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4908 | "RCV RSCN defer: did:x%x/ste:x%x flg:x%x", |
| 4909 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 4910 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4911 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4912 | vport->fc_flag |= FC_RSCN_DEFERRED; |
| 4913 | if ((rscn_cnt < FC_MAX_HOLD_RSCN) && |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4914 | !(vport->fc_flag & FC_RSCN_DISCOVERY)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4915 | vport->fc_flag |= FC_RSCN_MODE; |
| 4916 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4917 | if (rscn_cnt) { |
| 4918 | cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt; |
| 4919 | length = be32_to_cpu(*cmd & ~ELS_CMD_MASK); |
| 4920 | } |
| 4921 | if ((rscn_cnt) && |
| 4922 | (payload_len + length <= LPFC_BPL_SIZE)) { |
| 4923 | *cmd &= ELS_CMD_MASK; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4924 | *cmd |= cpu_to_be32(payload_len + length); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4925 | memcpy(((uint8_t *)cmd) + length, lp, |
| 4926 | payload_len); |
| 4927 | } else { |
| 4928 | vport->fc_rscn_id_list[rscn_cnt] = pcmd; |
| 4929 | vport->fc_rscn_id_cnt++; |
| 4930 | /* If we zero, cmdiocb->context2, the calling |
| 4931 | * routine will not try to free it. |
| 4932 | */ |
| 4933 | cmdiocb->context2 = NULL; |
| 4934 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4935 | /* Deferred RSCN */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4936 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 4937 | "0235 Deferred RSCN " |
| 4938 | "Data: x%x x%x x%x\n", |
| 4939 | vport->fc_rscn_id_cnt, vport->fc_flag, |
| 4940 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4941 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4942 | vport->fc_flag |= FC_RSCN_DISCOVERY; |
| 4943 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4944 | /* ReDiscovery RSCN */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4945 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 4946 | "0234 ReDiscovery RSCN " |
| 4947 | "Data: x%x x%x x%x\n", |
| 4948 | vport->fc_rscn_id_cnt, vport->fc_flag, |
| 4949 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4950 | } |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4951 | /* Indicate we are done walking fc_rscn_id_list on this vport */ |
| 4952 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4953 | /* Send back ACC */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4954 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4955 | /* send RECOVERY event for ALL nodes that match RSCN payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4956 | lpfc_rscn_recovery_check(vport); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4957 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4958 | vport->fc_flag &= ~FC_RSCN_DEFERRED; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4959 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4960 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4961 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4962 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4963 | "RCV RSCN: did:x%x/ste:x%x flg:x%x", |
| 4964 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 4965 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4966 | spin_lock_irq(shost->host_lock); |
| 4967 | vport->fc_flag |= FC_RSCN_MODE; |
| 4968 | spin_unlock_irq(shost->host_lock); |
| 4969 | vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4970 | /* Indicate we are done walking fc_rscn_id_list on this vport */ |
| 4971 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4972 | /* |
| 4973 | * If we zero, cmdiocb->context2, the calling routine will |
| 4974 | * not try to free it. |
| 4975 | */ |
| 4976 | cmdiocb->context2 = NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4977 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4978 | /* Send back ACC */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4979 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4980 | /* send RECOVERY event for ALL nodes that match RSCN payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4981 | lpfc_rscn_recovery_check(vport); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4982 | return lpfc_els_handle_rscn(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4983 | } |
| 4984 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4985 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4986 | * lpfc_els_handle_rscn - Handle rscn for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4987 | * @vport: pointer to a host virtual N_Port data structure. |
| 4988 | * |
| 4989 | * This routine handles the Registration State Configuration Notification |
| 4990 | * (RSCN) for a @vport. If login to NameServer does not exist, a new ndlp shall |
| 4991 | * be created and a Port Login (PLOGI) to the NameServer is issued. Otherwise, |
| 4992 | * if the ndlp to NameServer exists, a Common Transport (CT) command to the |
| 4993 | * NameServer shall be issued. If CT command to the NameServer fails to be |
| 4994 | * issued, the lpfc_els_flush_rscn() routine shall be invoked to clean up any |
| 4995 | * RSCN activities with the @vport. |
| 4996 | * |
| 4997 | * Return code |
| 4998 | * 0 - Cleaned up rscn on the @vport |
| 4999 | * 1 - Wait for plogi to name server before proceed |
| 5000 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5001 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5002 | lpfc_els_handle_rscn(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5003 | { |
| 5004 | struct lpfc_nodelist *ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5005 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5006 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5007 | /* Ignore RSCN if the port is being torn down. */ |
| 5008 | if (vport->load_flag & FC_UNLOADING) { |
| 5009 | lpfc_els_flush_rscn(vport); |
| 5010 | return 0; |
| 5011 | } |
| 5012 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5013 | /* Start timer for RSCN processing */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5014 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5015 | |
| 5016 | /* RSCN processed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5017 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 5018 | "0215 RSCN processed Data: x%x x%x x%x x%x\n", |
| 5019 | vport->fc_flag, 0, vport->fc_rscn_id_cnt, |
| 5020 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5021 | |
| 5022 | /* To process RSCN, first compare RSCN data with NameServer */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5023 | vport->fc_ns_retry = 0; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 5024 | vport->num_disc_nodes = 0; |
| 5025 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5026 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5027 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) |
| 5028 | && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5029 | /* Good ndlp, issue CT Request to NameServer */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5030 | if (lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 0, 0) == 0) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5031 | /* Wait for NameServer query cmpl before we can |
| 5032 | continue */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5033 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5034 | } else { |
| 5035 | /* If login to NameServer does not exist, issue one */ |
| 5036 | /* Good status, issue PLOGI to NameServer */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5037 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5038 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5039 | /* Wait for NameServer login cmpl before we can |
| 5040 | continue */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5041 | return 1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5042 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5043 | if (ndlp) { |
| 5044 | ndlp = lpfc_enable_node(vport, ndlp, |
| 5045 | NLP_STE_PLOGI_ISSUE); |
| 5046 | if (!ndlp) { |
| 5047 | lpfc_els_flush_rscn(vport); |
| 5048 | return 0; |
| 5049 | } |
| 5050 | ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5051 | } else { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5052 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 5053 | if (!ndlp) { |
| 5054 | lpfc_els_flush_rscn(vport); |
| 5055 | return 0; |
| 5056 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5057 | lpfc_nlp_init(vport, ndlp, NameServer_DID); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 5058 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5059 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5060 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5061 | ndlp->nlp_type |= NLP_FABRIC; |
| 5062 | lpfc_issue_els_plogi(vport, NameServer_DID, 0); |
| 5063 | /* Wait for NameServer login cmpl before we can |
| 5064 | * continue |
| 5065 | */ |
| 5066 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5067 | } |
| 5068 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5069 | lpfc_els_flush_rscn(vport); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5070 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5071 | } |
| 5072 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5073 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5074 | * lpfc_els_rcv_flogi - Process an unsolicited flogi iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5075 | * @vport: pointer to a host virtual N_Port data structure. |
| 5076 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5077 | * @ndlp: pointer to a node-list data structure. |
| 5078 | * |
| 5079 | * This routine processes Fabric Login (FLOGI) IOCB received as an ELS |
| 5080 | * unsolicited event. An unsolicited FLOGI can be received in a point-to- |
| 5081 | * point topology. As an unsolicited FLOGI should not be received in a loop |
| 5082 | * mode, any unsolicited FLOGI received in loop mode shall be ignored. The |
| 5083 | * lpfc_check_sparm() routine is invoked to check the parameters in the |
| 5084 | * unsolicited FLOGI. If parameters validation failed, the routine |
| 5085 | * lpfc_els_rsp_reject() shall be called with reject reason code set to |
| 5086 | * LSEXP_SPARM_OPTIONS to reject the FLOGI. Otherwise, the Port WWN in the |
| 5087 | * FLOGI shall be compared with the Port WWN of the @vport to determine who |
| 5088 | * will initiate PLOGI. The higher lexicographical value party shall has |
| 5089 | * higher priority (as the winning port) and will initiate PLOGI and |
| 5090 | * communicate Port_IDs (Addresses) for both nodes in PLOGI. The result |
| 5091 | * of this will be marked in the @vport fc_flag field with FC_PT2PT_PLOGI |
| 5092 | * and then the lpfc_els_rsp_acc() routine is invoked to accept the FLOGI. |
| 5093 | * |
| 5094 | * Return code |
| 5095 | * 0 - Successfully processed the unsolicited flogi |
| 5096 | * 1 - Failed to process the unsolicited flogi |
| 5097 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5098 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5099 | lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5100 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5101 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5102 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5103 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5104 | struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5105 | uint32_t *lp = (uint32_t *) pcmd->virt; |
| 5106 | IOCB_t *icmd = &cmdiocb->iocb; |
| 5107 | struct serv_parm *sp; |
| 5108 | LPFC_MBOXQ_t *mbox; |
| 5109 | struct ls_rjt stat; |
| 5110 | uint32_t cmd, did; |
| 5111 | int rc; |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 5112 | uint32_t fc_flag = 0; |
| 5113 | uint32_t port_state = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5114 | |
| 5115 | cmd = *lp++; |
| 5116 | sp = (struct serv_parm *) lp; |
| 5117 | |
| 5118 | /* FLOGI received */ |
| 5119 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5120 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5121 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5122 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5123 | /* We should never receive a FLOGI in loop mode, ignore it */ |
| 5124 | did = icmd->un.elsreq64.remoteID; |
| 5125 | |
| 5126 | /* An FLOGI ELS command <elsCmd> was received from DID <did> in |
| 5127 | Loop Mode */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5128 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 5129 | "0113 An FLOGI ELS command x%x was " |
| 5130 | "received from DID x%x in Loop Mode\n", |
| 5131 | cmd, did); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5132 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5133 | } |
| 5134 | |
James Smart | 341af10 | 2010-01-26 23:07:37 -0500 | [diff] [blame] | 5135 | if ((lpfc_check_sparm(vport, ndlp, sp, CLASS3, 1))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5136 | /* For a FLOGI we accept, then if our portname is greater |
| 5137 | * then the remote portname we initiate Nport login. |
| 5138 | */ |
| 5139 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5140 | rc = memcmp(&vport->fc_portname, &sp->portName, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5141 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5142 | |
| 5143 | if (!rc) { |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 5144 | if (phba->sli_rev < LPFC_SLI_REV4) { |
| 5145 | mbox = mempool_alloc(phba->mbox_mem_pool, |
| 5146 | GFP_KERNEL); |
| 5147 | if (!mbox) |
| 5148 | return 1; |
| 5149 | lpfc_linkdown(phba); |
| 5150 | lpfc_init_link(phba, mbox, |
| 5151 | phba->cfg_topology, |
| 5152 | phba->cfg_link_speed); |
| 5153 | mbox->u.mb.un.varInitLnk.lipsr_AL_PA = 0; |
| 5154 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
| 5155 | mbox->vport = vport; |
| 5156 | rc = lpfc_sli_issue_mbox(phba, mbox, |
| 5157 | MBX_NOWAIT); |
| 5158 | lpfc_set_loopback_flag(phba); |
| 5159 | if (rc == MBX_NOT_FINISHED) |
| 5160 | mempool_free(mbox, phba->mbox_mem_pool); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5161 | return 1; |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 5162 | } else { |
| 5163 | /* abort the flogi coming back to ourselves |
| 5164 | * due to external loopback on the port. |
| 5165 | */ |
| 5166 | lpfc_els_abort_flogi(phba); |
| 5167 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5168 | } |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 5169 | } else if (rc > 0) { /* greater than */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5170 | spin_lock_irq(shost->host_lock); |
| 5171 | vport->fc_flag |= FC_PT2PT_PLOGI; |
| 5172 | spin_unlock_irq(shost->host_lock); |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5173 | |
| 5174 | /* If we have the high WWPN we can assign our own |
| 5175 | * myDID; otherwise, we have to WAIT for a PLOGI |
| 5176 | * from the remote NPort to find out what it |
| 5177 | * will be. |
| 5178 | */ |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 5179 | vport->fc_myDID = PT2PT_LocalID; |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 5180 | } else |
| 5181 | vport->fc_myDID = PT2PT_RemoteID; |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5182 | |
| 5183 | /* |
| 5184 | * The vport state should go to LPFC_FLOGI only |
| 5185 | * AFTER we issue a FLOGI, not receive one. |
| 5186 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5187 | spin_lock_irq(shost->host_lock); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 5188 | fc_flag = vport->fc_flag; |
| 5189 | port_state = vport->port_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5190 | vport->fc_flag |= FC_PT2PT; |
| 5191 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 5192 | vport->port_state = LPFC_FLOGI; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5193 | spin_unlock_irq(shost->host_lock); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 5194 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 5195 | "3311 Rcv Flogi PS x%x new PS x%x " |
| 5196 | "fc_flag x%x new fc_flag x%x\n", |
| 5197 | port_state, vport->port_state, |
| 5198 | fc_flag, vport->fc_flag); |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5199 | |
| 5200 | /* |
| 5201 | * We temporarily set fc_myDID to make it look like we are |
| 5202 | * a Fabric. This is done just so we end up with the right |
| 5203 | * did / sid on the FLOGI ACC rsp. |
| 5204 | */ |
| 5205 | did = vport->fc_myDID; |
| 5206 | vport->fc_myDID = Fabric_DID; |
| 5207 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5208 | } else { |
| 5209 | /* Reject this request because invalid parameters */ |
| 5210 | stat.un.b.lsRjtRsvd0 = 0; |
| 5211 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5212 | stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; |
| 5213 | stat.un.b.vendorUnique = 0; |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5214 | |
| 5215 | /* |
| 5216 | * We temporarily set fc_myDID to make it look like we are |
| 5217 | * a Fabric. This is done just so we end up with the right |
| 5218 | * did / sid on the FLOGI LS_RJT rsp. |
| 5219 | */ |
| 5220 | did = vport->fc_myDID; |
| 5221 | vport->fc_myDID = Fabric_DID; |
| 5222 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5223 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
| 5224 | NULL); |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5225 | |
| 5226 | /* Now lets put fc_myDID back to what its supposed to be */ |
| 5227 | vport->fc_myDID = did; |
| 5228 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5229 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5230 | } |
| 5231 | |
| 5232 | /* Send back ACC */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5233 | lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5234 | |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5235 | /* Now lets put fc_myDID back to what its supposed to be */ |
| 5236 | vport->fc_myDID = did; |
| 5237 | |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 5238 | if (!(vport->fc_flag & FC_PT2PT_PLOGI)) { |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5239 | |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 5240 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5241 | if (!mbox) |
| 5242 | goto fail; |
| 5243 | |
| 5244 | lpfc_config_link(phba, mbox); |
| 5245 | |
| 5246 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
| 5247 | mbox->vport = vport; |
| 5248 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
| 5249 | if (rc == MBX_NOT_FINISHED) { |
| 5250 | mempool_free(mbox, phba->mbox_mem_pool); |
| 5251 | goto fail; |
| 5252 | } |
| 5253 | } |
| 5254 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5255 | return 0; |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 5256 | fail: |
| 5257 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5258 | } |
| 5259 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5260 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5261 | * lpfc_els_rcv_rnid - Process an unsolicited rnid iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5262 | * @vport: pointer to a host virtual N_Port data structure. |
| 5263 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5264 | * @ndlp: pointer to a node-list data structure. |
| 5265 | * |
| 5266 | * This routine processes Request Node Identification Data (RNID) IOCB |
| 5267 | * received as an ELS unsolicited event. Only when the RNID specified format |
| 5268 | * 0x0 or 0xDF (Topology Discovery Specific Node Identification Data) |
| 5269 | * present, this routine will invoke the lpfc_els_rsp_rnid_acc() routine to |
| 5270 | * Accept (ACC) the RNID ELS command. All the other RNID formats are |
| 5271 | * rejected by invoking the lpfc_els_rsp_reject() routine. |
| 5272 | * |
| 5273 | * Return code |
| 5274 | * 0 - Successfully processed rnid iocb (currently always return 0) |
| 5275 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5276 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5277 | lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5278 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5279 | { |
| 5280 | struct lpfc_dmabuf *pcmd; |
| 5281 | uint32_t *lp; |
| 5282 | IOCB_t *icmd; |
| 5283 | RNID *rn; |
| 5284 | struct ls_rjt stat; |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame^] | 5285 | uint32_t cmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5286 | |
| 5287 | icmd = &cmdiocb->iocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5288 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5289 | lp = (uint32_t *) pcmd->virt; |
| 5290 | |
| 5291 | cmd = *lp++; |
| 5292 | rn = (RNID *) lp; |
| 5293 | |
| 5294 | /* RNID received */ |
| 5295 | |
| 5296 | switch (rn->Format) { |
| 5297 | case 0: |
| 5298 | case RNID_TOPOLOGY_DISC: |
| 5299 | /* Send back ACC */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5300 | lpfc_els_rsp_rnid_acc(vport, rn->Format, cmdiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5301 | break; |
| 5302 | default: |
| 5303 | /* Reject this request because format not supported */ |
| 5304 | stat.un.b.lsRjtRsvd0 = 0; |
| 5305 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5306 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5307 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5308 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
| 5309 | NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5310 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5311 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5312 | } |
| 5313 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5314 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5315 | * lpfc_els_rcv_echo - Process an unsolicited echo iocb |
| 5316 | * @vport: pointer to a host virtual N_Port data structure. |
| 5317 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5318 | * @ndlp: pointer to a node-list data structure. |
| 5319 | * |
| 5320 | * Return code |
| 5321 | * 0 - Successfully processed echo iocb (currently always return 0) |
| 5322 | **/ |
| 5323 | static int |
| 5324 | lpfc_els_rcv_echo(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5325 | struct lpfc_nodelist *ndlp) |
| 5326 | { |
| 5327 | uint8_t *pcmd; |
| 5328 | |
| 5329 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt); |
| 5330 | |
| 5331 | /* skip over first word of echo command to find echo data */ |
| 5332 | pcmd += sizeof(uint32_t); |
| 5333 | |
| 5334 | lpfc_els_rsp_echo_acc(vport, pcmd, cmdiocb, ndlp); |
| 5335 | return 0; |
| 5336 | } |
| 5337 | |
| 5338 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5339 | * lpfc_els_rcv_lirr - Process an unsolicited lirr iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5340 | * @vport: pointer to a host virtual N_Port data structure. |
| 5341 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5342 | * @ndlp: pointer to a node-list data structure. |
| 5343 | * |
| 5344 | * This routine processes a Link Incident Report Registration(LIRR) IOCB |
| 5345 | * received as an ELS unsolicited event. Currently, this function just invokes |
| 5346 | * the lpfc_els_rsp_reject() routine to reject the LIRR IOCB unconditionally. |
| 5347 | * |
| 5348 | * Return code |
| 5349 | * 0 - Successfully processed lirr iocb (currently always return 0) |
| 5350 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5351 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5352 | lpfc_els_rcv_lirr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5353 | struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5354 | { |
| 5355 | struct ls_rjt stat; |
| 5356 | |
| 5357 | /* For now, unconditionally reject this command */ |
| 5358 | stat.un.b.lsRjtRsvd0 = 0; |
| 5359 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5360 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5361 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5362 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5363 | return 0; |
| 5364 | } |
| 5365 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5366 | /** |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 5367 | * lpfc_els_rcv_rrq - Process an unsolicited rrq iocb |
| 5368 | * @vport: pointer to a host virtual N_Port data structure. |
| 5369 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5370 | * @ndlp: pointer to a node-list data structure. |
| 5371 | * |
| 5372 | * This routine processes a Reinstate Recovery Qualifier (RRQ) IOCB |
| 5373 | * received as an ELS unsolicited event. A request to RRQ shall only |
| 5374 | * be accepted if the Originator Nx_Port N_Port_ID or the Responder |
| 5375 | * Nx_Port N_Port_ID of the target Exchange is the same as the |
| 5376 | * N_Port_ID of the Nx_Port that makes the request. If the RRQ is |
| 5377 | * not accepted, an LS_RJT with reason code "Unable to perform |
| 5378 | * command request" and reason code explanation "Invalid Originator |
| 5379 | * S_ID" shall be returned. For now, we just unconditionally accept |
| 5380 | * RRQ from the target. |
| 5381 | **/ |
| 5382 | static void |
| 5383 | lpfc_els_rcv_rrq(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5384 | struct lpfc_nodelist *ndlp) |
| 5385 | { |
| 5386 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5387 | if (vport->phba->sli_rev == LPFC_SLI_REV4) |
| 5388 | lpfc_els_clear_rrq(vport, cmdiocb, ndlp); |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 5389 | } |
| 5390 | |
| 5391 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5392 | * lpfc_els_rsp_rls_acc - Completion callbk func for MBX_READ_LNK_STAT mbox cmd |
| 5393 | * @phba: pointer to lpfc hba data structure. |
| 5394 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 5395 | * |
| 5396 | * This routine is the completion callback function for the MBX_READ_LNK_STAT |
| 5397 | * mailbox command. This callback function is to actually send the Accept |
| 5398 | * (ACC) response to a Read Port Status (RPS) unsolicited IOCB event. It |
| 5399 | * collects the link statistics from the completion of the MBX_READ_LNK_STAT |
| 5400 | * mailbox command, constructs the RPS response with the link statistics |
| 5401 | * collected, and then invokes the lpfc_sli_issue_iocb() routine to send ACC |
| 5402 | * response to the RPS. |
| 5403 | * |
| 5404 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 5405 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 5406 | * will be stored into the context1 field of the IOCB for the completion |
| 5407 | * callback function to the RPS Accept Response ELS IOCB command. |
| 5408 | * |
| 5409 | **/ |
| 5410 | static void |
| 5411 | lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
| 5412 | { |
| 5413 | MAILBOX_t *mb; |
| 5414 | IOCB_t *icmd; |
| 5415 | struct RLS_RSP *rls_rsp; |
| 5416 | uint8_t *pcmd; |
| 5417 | struct lpfc_iocbq *elsiocb; |
| 5418 | struct lpfc_nodelist *ndlp; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5419 | uint16_t oxid; |
| 5420 | uint16_t rxid; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5421 | uint32_t cmdsize; |
| 5422 | |
| 5423 | mb = &pmb->u.mb; |
| 5424 | |
| 5425 | ndlp = (struct lpfc_nodelist *) pmb->context2; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5426 | rxid = (uint16_t) ((unsigned long)(pmb->context1) & 0xffff); |
| 5427 | oxid = (uint16_t) (((unsigned long)(pmb->context1) >> 16) & 0xffff); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5428 | pmb->context1 = NULL; |
| 5429 | pmb->context2 = NULL; |
| 5430 | |
| 5431 | if (mb->mbxStatus) { |
| 5432 | mempool_free(pmb, phba->mbox_mem_pool); |
| 5433 | return; |
| 5434 | } |
| 5435 | |
| 5436 | cmdsize = sizeof(struct RLS_RSP) + sizeof(uint32_t); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5437 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 5438 | lpfc_max_els_tries, ndlp, |
| 5439 | ndlp->nlp_DID, ELS_CMD_ACC); |
| 5440 | |
| 5441 | /* Decrement the ndlp reference count from previous mbox command */ |
| 5442 | lpfc_nlp_put(ndlp); |
| 5443 | |
James Smart | 37db57e | 2012-05-09 21:17:16 -0400 | [diff] [blame] | 5444 | if (!elsiocb) { |
| 5445 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5446 | return; |
James Smart | 37db57e | 2012-05-09 21:17:16 -0400 | [diff] [blame] | 5447 | } |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5448 | |
| 5449 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5450 | icmd->ulpContext = rxid; |
| 5451 | icmd->unsli3.rcvsli3.ox_id = oxid; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5452 | |
| 5453 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 5454 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
| 5455 | pcmd += sizeof(uint32_t); /* Skip past command */ |
| 5456 | rls_rsp = (struct RLS_RSP *)pcmd; |
| 5457 | |
| 5458 | rls_rsp->linkFailureCnt = cpu_to_be32(mb->un.varRdLnk.linkFailureCnt); |
| 5459 | rls_rsp->lossSyncCnt = cpu_to_be32(mb->un.varRdLnk.lossSyncCnt); |
| 5460 | rls_rsp->lossSignalCnt = cpu_to_be32(mb->un.varRdLnk.lossSignalCnt); |
| 5461 | rls_rsp->primSeqErrCnt = cpu_to_be32(mb->un.varRdLnk.primSeqErrCnt); |
| 5462 | rls_rsp->invalidXmitWord = cpu_to_be32(mb->un.varRdLnk.invalidXmitWord); |
| 5463 | rls_rsp->crcCnt = cpu_to_be32(mb->un.varRdLnk.crcCnt); |
James Smart | 37db57e | 2012-05-09 21:17:16 -0400 | [diff] [blame] | 5464 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5465 | /* Xmit ELS RLS ACC response tag <ulpIoTag> */ |
| 5466 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS, |
| 5467 | "2874 Xmit ELS RLS ACC response tag x%x xri x%x, " |
| 5468 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", |
| 5469 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 5470 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 5471 | ndlp->nlp_rpi); |
| 5472 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| 5473 | phba->fc_stat.elsXmitACC++; |
| 5474 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == IOCB_ERROR) |
| 5475 | lpfc_els_free_iocb(phba, elsiocb); |
| 5476 | } |
| 5477 | |
| 5478 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5479 | * 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] | 5480 | * @phba: pointer to lpfc hba data structure. |
| 5481 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 5482 | * |
| 5483 | * This routine is the completion callback function for the MBX_READ_LNK_STAT |
| 5484 | * mailbox command. This callback function is to actually send the Accept |
| 5485 | * (ACC) response to a Read Port Status (RPS) unsolicited IOCB event. It |
| 5486 | * collects the link statistics from the completion of the MBX_READ_LNK_STAT |
| 5487 | * mailbox command, constructs the RPS response with the link statistics |
| 5488 | * collected, and then invokes the lpfc_sli_issue_iocb() routine to send ACC |
| 5489 | * response to the RPS. |
| 5490 | * |
| 5491 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 5492 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 5493 | * will be stored into the context1 field of the IOCB for the completion |
| 5494 | * callback function to the RPS Accept Response ELS IOCB command. |
| 5495 | * |
| 5496 | **/ |
Jamie Wellnitz | 082c026 | 2006-02-28 19:25:30 -0500 | [diff] [blame] | 5497 | static void |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5498 | 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] | 5499 | { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5500 | MAILBOX_t *mb; |
| 5501 | IOCB_t *icmd; |
| 5502 | RPS_RSP *rps_rsp; |
| 5503 | uint8_t *pcmd; |
| 5504 | struct lpfc_iocbq *elsiocb; |
| 5505 | struct lpfc_nodelist *ndlp; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5506 | uint16_t status; |
| 5507 | uint16_t oxid; |
| 5508 | uint16_t rxid; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5509 | uint32_t cmdsize; |
| 5510 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 5511 | mb = &pmb->u.mb; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5512 | |
| 5513 | ndlp = (struct lpfc_nodelist *) pmb->context2; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5514 | rxid = (uint16_t) ((unsigned long)(pmb->context1) & 0xffff); |
| 5515 | oxid = (uint16_t) (((unsigned long)(pmb->context1) >> 16) & 0xffff); |
Randy Dunlap | 041976f | 2006-06-25 01:58:51 -0700 | [diff] [blame] | 5516 | pmb->context1 = NULL; |
| 5517 | pmb->context2 = NULL; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5518 | |
| 5519 | if (mb->mbxStatus) { |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5520 | mempool_free(pmb, phba->mbox_mem_pool); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5521 | return; |
| 5522 | } |
| 5523 | |
| 5524 | cmdsize = sizeof(RPS_RSP) + sizeof(uint32_t); |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5525 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5526 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 5527 | lpfc_max_els_tries, ndlp, |
| 5528 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 5529 | |
| 5530 | /* Decrement the ndlp reference count from previous mbox command */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5531 | lpfc_nlp_put(ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 5532 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5533 | if (!elsiocb) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5534 | return; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5535 | |
| 5536 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5537 | icmd->ulpContext = rxid; |
| 5538 | icmd->unsli3.rcvsli3.ox_id = oxid; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5539 | |
| 5540 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 5541 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5542 | pcmd += sizeof(uint32_t); /* Skip past command */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5543 | rps_rsp = (RPS_RSP *)pcmd; |
| 5544 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5545 | if (phba->fc_topology != LPFC_TOPOLOGY_LOOP) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5546 | status = 0x10; |
| 5547 | else |
| 5548 | status = 0x8; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5549 | if (phba->pport->fc_flag & FC_FABRIC) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5550 | status |= 0x4; |
| 5551 | |
| 5552 | rps_rsp->rsvd1 = 0; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5553 | rps_rsp->portStatus = cpu_to_be16(status); |
| 5554 | rps_rsp->linkFailureCnt = cpu_to_be32(mb->un.varRdLnk.linkFailureCnt); |
| 5555 | rps_rsp->lossSyncCnt = cpu_to_be32(mb->un.varRdLnk.lossSyncCnt); |
| 5556 | rps_rsp->lossSignalCnt = cpu_to_be32(mb->un.varRdLnk.lossSignalCnt); |
| 5557 | rps_rsp->primSeqErrCnt = cpu_to_be32(mb->un.varRdLnk.primSeqErrCnt); |
| 5558 | rps_rsp->invalidXmitWord = cpu_to_be32(mb->un.varRdLnk.invalidXmitWord); |
| 5559 | rps_rsp->crcCnt = cpu_to_be32(mb->un.varRdLnk.crcCnt); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5560 | /* Xmit ELS RPS ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5561 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS, |
| 5562 | "0118 Xmit ELS RPS ACC response tag x%x xri x%x, " |
| 5563 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", |
| 5564 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 5565 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 5566 | ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5567 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5568 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 5569 | 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] | 5570 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5571 | return; |
| 5572 | } |
| 5573 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5574 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5575 | * lpfc_els_rcv_rls - Process an unsolicited rls iocb |
| 5576 | * @vport: pointer to a host virtual N_Port data structure. |
| 5577 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5578 | * @ndlp: pointer to a node-list data structure. |
| 5579 | * |
| 5580 | * This routine processes Read Port Status (RPL) IOCB received as an |
| 5581 | * ELS unsolicited event. It first checks the remote port state. If the |
| 5582 | * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE |
| 5583 | * state, it invokes the lpfc_els_rsl_reject() routine to send the reject |
| 5584 | * response. Otherwise, it issue the MBX_READ_LNK_STAT mailbox command |
| 5585 | * for reading the HBA link statistics. It is for the callback function, |
| 5586 | * lpfc_els_rsp_rls_acc(), set to the MBX_READ_LNK_STAT mailbox command |
| 5587 | * to actually sending out RPL Accept (ACC) response. |
| 5588 | * |
| 5589 | * Return codes |
| 5590 | * 0 - Successfully processed rls iocb (currently always return 0) |
| 5591 | **/ |
| 5592 | static int |
| 5593 | lpfc_els_rcv_rls(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5594 | struct lpfc_nodelist *ndlp) |
| 5595 | { |
| 5596 | struct lpfc_hba *phba = vport->phba; |
| 5597 | LPFC_MBOXQ_t *mbox; |
| 5598 | struct lpfc_dmabuf *pcmd; |
| 5599 | struct ls_rjt stat; |
| 5600 | |
| 5601 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
| 5602 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) |
| 5603 | /* reject the unsolicited RPS request and done with it */ |
| 5604 | goto reject_out; |
| 5605 | |
| 5606 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5607 | |
| 5608 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC); |
| 5609 | if (mbox) { |
| 5610 | lpfc_read_lnk_stat(phba, mbox); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5611 | mbox->context1 = (void *)((unsigned long) |
| 5612 | ((cmdiocb->iocb.unsli3.rcvsli3.ox_id << 16) | |
| 5613 | cmdiocb->iocb.ulpContext)); /* rx_id */ |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5614 | mbox->context2 = lpfc_nlp_get(ndlp); |
| 5615 | mbox->vport = vport; |
| 5616 | mbox->mbox_cmpl = lpfc_els_rsp_rls_acc; |
| 5617 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
| 5618 | != MBX_NOT_FINISHED) |
| 5619 | /* Mbox completion will send ELS Response */ |
| 5620 | return 0; |
| 5621 | /* Decrement reference count used for the failed mbox |
| 5622 | * command. |
| 5623 | */ |
| 5624 | lpfc_nlp_put(ndlp); |
| 5625 | mempool_free(mbox, phba->mbox_mem_pool); |
| 5626 | } |
| 5627 | reject_out: |
| 5628 | /* issue rejection response */ |
| 5629 | stat.un.b.lsRjtRsvd0 = 0; |
| 5630 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5631 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5632 | stat.un.b.vendorUnique = 0; |
| 5633 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
| 5634 | return 0; |
| 5635 | } |
| 5636 | |
| 5637 | /** |
| 5638 | * lpfc_els_rcv_rtv - Process an unsolicited rtv iocb |
| 5639 | * @vport: pointer to a host virtual N_Port data structure. |
| 5640 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5641 | * @ndlp: pointer to a node-list data structure. |
| 5642 | * |
| 5643 | * This routine processes Read Timout Value (RTV) IOCB received as an |
| 5644 | * ELS unsolicited event. It first checks the remote port state. If the |
| 5645 | * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE |
| 5646 | * state, it invokes the lpfc_els_rsl_reject() routine to send the reject |
| 5647 | * response. Otherwise, it sends the Accept(ACC) response to a Read Timeout |
| 5648 | * Value (RTV) unsolicited IOCB event. |
| 5649 | * |
| 5650 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 5651 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 5652 | * will be stored into the context1 field of the IOCB for the completion |
| 5653 | * callback function to the RPS Accept Response ELS IOCB command. |
| 5654 | * |
| 5655 | * Return codes |
| 5656 | * 0 - Successfully processed rtv iocb (currently always return 0) |
| 5657 | **/ |
| 5658 | static int |
| 5659 | lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5660 | struct lpfc_nodelist *ndlp) |
| 5661 | { |
| 5662 | struct lpfc_hba *phba = vport->phba; |
| 5663 | struct ls_rjt stat; |
| 5664 | struct RTV_RSP *rtv_rsp; |
| 5665 | uint8_t *pcmd; |
| 5666 | struct lpfc_iocbq *elsiocb; |
| 5667 | uint32_t cmdsize; |
| 5668 | |
| 5669 | |
| 5670 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
| 5671 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) |
| 5672 | /* reject the unsolicited RPS request and done with it */ |
| 5673 | goto reject_out; |
| 5674 | |
| 5675 | cmdsize = sizeof(struct RTV_RSP) + sizeof(uint32_t); |
| 5676 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 5677 | lpfc_max_els_tries, ndlp, |
| 5678 | ndlp->nlp_DID, ELS_CMD_ACC); |
| 5679 | |
| 5680 | if (!elsiocb) |
| 5681 | return 1; |
| 5682 | |
| 5683 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 5684 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
| 5685 | pcmd += sizeof(uint32_t); /* Skip past command */ |
| 5686 | |
| 5687 | /* use the command's xri in the response */ |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5688 | elsiocb->iocb.ulpContext = cmdiocb->iocb.ulpContext; /* Xri / rx_id */ |
| 5689 | elsiocb->iocb.unsli3.rcvsli3.ox_id = cmdiocb->iocb.unsli3.rcvsli3.ox_id; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5690 | |
| 5691 | rtv_rsp = (struct RTV_RSP *)pcmd; |
| 5692 | |
| 5693 | /* populate RTV payload */ |
| 5694 | rtv_rsp->ratov = cpu_to_be32(phba->fc_ratov * 1000); /* report msecs */ |
| 5695 | rtv_rsp->edtov = cpu_to_be32(phba->fc_edtov); |
| 5696 | bf_set(qtov_edtovres, rtv_rsp, phba->fc_edtovResol ? 1 : 0); |
| 5697 | bf_set(qtov_rttov, rtv_rsp, 0); /* Field is for FC ONLY */ |
| 5698 | rtv_rsp->qtov = cpu_to_be32(rtv_rsp->qtov); |
| 5699 | |
| 5700 | /* Xmit ELS RLS ACC response tag <ulpIoTag> */ |
| 5701 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS, |
| 5702 | "2875 Xmit ELS RTV ACC response tag x%x xri x%x, " |
| 5703 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x, " |
| 5704 | "Data: x%x x%x x%x\n", |
| 5705 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 5706 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 5707 | ndlp->nlp_rpi, |
| 5708 | rtv_rsp->ratov, rtv_rsp->edtov, rtv_rsp->qtov); |
| 5709 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| 5710 | phba->fc_stat.elsXmitACC++; |
| 5711 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == IOCB_ERROR) |
| 5712 | lpfc_els_free_iocb(phba, elsiocb); |
| 5713 | return 0; |
| 5714 | |
| 5715 | reject_out: |
| 5716 | /* issue rejection response */ |
| 5717 | stat.un.b.lsRjtRsvd0 = 0; |
| 5718 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5719 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5720 | stat.un.b.vendorUnique = 0; |
| 5721 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
| 5722 | return 0; |
| 5723 | } |
| 5724 | |
| 5725 | /* lpfc_els_rcv_rps - Process an unsolicited rps iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5726 | * @vport: pointer to a host virtual N_Port data structure. |
| 5727 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5728 | * @ndlp: pointer to a node-list data structure. |
| 5729 | * |
| 5730 | * This routine processes Read Port Status (RPS) IOCB received as an |
| 5731 | * ELS unsolicited event. It first checks the remote port state. If the |
| 5732 | * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE |
| 5733 | * state, it invokes the lpfc_els_rsp_reject() routine to send the reject |
| 5734 | * response. Otherwise, it issue the MBX_READ_LNK_STAT mailbox command |
| 5735 | * for reading the HBA link statistics. It is for the callback function, |
| 5736 | * lpfc_els_rsp_rps_acc(), set to the MBX_READ_LNK_STAT mailbox command |
| 5737 | * to actually sending out RPS Accept (ACC) response. |
| 5738 | * |
| 5739 | * Return codes |
| 5740 | * 0 - Successfully processed rps iocb (currently always return 0) |
| 5741 | **/ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5742 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5743 | lpfc_els_rcv_rps(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5744 | struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5745 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5746 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5747 | uint32_t *lp; |
| 5748 | uint8_t flag; |
| 5749 | LPFC_MBOXQ_t *mbox; |
| 5750 | struct lpfc_dmabuf *pcmd; |
| 5751 | RPS *rps; |
| 5752 | struct ls_rjt stat; |
| 5753 | |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 5754 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 5755 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) |
| 5756 | /* reject the unsolicited RPS request and done with it */ |
| 5757 | goto reject_out; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5758 | |
| 5759 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5760 | lp = (uint32_t *) pcmd->virt; |
| 5761 | flag = (be32_to_cpu(*lp++) & 0xf); |
| 5762 | rps = (RPS *) lp; |
| 5763 | |
| 5764 | if ((flag == 0) || |
| 5765 | ((flag == 1) && (be32_to_cpu(rps->un.portNum) == 0)) || |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5766 | ((flag == 2) && (memcmp(&rps->un.portName, &vport->fc_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5767 | sizeof(struct lpfc_name)) == 0))) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5768 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5769 | printk("Fix me....\n"); |
| 5770 | dump_stack(); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5771 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC); |
| 5772 | if (mbox) { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5773 | lpfc_read_lnk_stat(phba, mbox); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5774 | mbox->context1 = (void *)((unsigned long) |
| 5775 | ((cmdiocb->iocb.unsli3.rcvsli3.ox_id << 16) | |
| 5776 | cmdiocb->iocb.ulpContext)); /* rx_id */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5777 | mbox->context2 = lpfc_nlp_get(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5778 | mbox->vport = vport; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5779 | mbox->mbox_cmpl = lpfc_els_rsp_rps_acc; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 5780 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 5781 | != MBX_NOT_FINISHED) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5782 | /* Mbox completion will send ELS Response */ |
| 5783 | return 0; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 5784 | /* Decrement reference count used for the failed mbox |
| 5785 | * command. |
| 5786 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5787 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5788 | mempool_free(mbox, phba->mbox_mem_pool); |
| 5789 | } |
| 5790 | } |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 5791 | |
| 5792 | reject_out: |
| 5793 | /* issue rejection response */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5794 | stat.un.b.lsRjtRsvd0 = 0; |
| 5795 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5796 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5797 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5798 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5799 | return 0; |
| 5800 | } |
| 5801 | |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5802 | /* lpfc_issue_els_rrq - Process an unsolicited rps iocb |
| 5803 | * @vport: pointer to a host virtual N_Port data structure. |
| 5804 | * @ndlp: pointer to a node-list data structure. |
| 5805 | * @did: DID of the target. |
| 5806 | * @rrq: Pointer to the rrq struct. |
| 5807 | * |
| 5808 | * Build a ELS RRQ command and send it to the target. If the issue_iocb is |
| 5809 | * Successful the the completion handler will clear the RRQ. |
| 5810 | * |
| 5811 | * Return codes |
| 5812 | * 0 - Successfully sent rrq els iocb. |
| 5813 | * 1 - Failed to send rrq els iocb. |
| 5814 | **/ |
| 5815 | static int |
| 5816 | lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 5817 | uint32_t did, struct lpfc_node_rrq *rrq) |
| 5818 | { |
| 5819 | struct lpfc_hba *phba = vport->phba; |
| 5820 | struct RRQ *els_rrq; |
| 5821 | IOCB_t *icmd; |
| 5822 | struct lpfc_iocbq *elsiocb; |
| 5823 | uint8_t *pcmd; |
| 5824 | uint16_t cmdsize; |
| 5825 | int ret; |
| 5826 | |
| 5827 | |
| 5828 | if (ndlp != rrq->ndlp) |
| 5829 | ndlp = rrq->ndlp; |
| 5830 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 5831 | return 1; |
| 5832 | |
| 5833 | /* If ndlp is not NULL, we will bump the reference count on it */ |
| 5834 | cmdsize = (sizeof(uint32_t) + sizeof(struct RRQ)); |
| 5835 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, did, |
| 5836 | ELS_CMD_RRQ); |
| 5837 | if (!elsiocb) |
| 5838 | return 1; |
| 5839 | |
| 5840 | icmd = &elsiocb->iocb; |
| 5841 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 5842 | |
| 5843 | /* For RRQ request, remainder of payload is Exchange IDs */ |
| 5844 | *((uint32_t *) (pcmd)) = ELS_CMD_RRQ; |
| 5845 | pcmd += sizeof(uint32_t); |
| 5846 | els_rrq = (struct RRQ *) pcmd; |
| 5847 | |
James Smart | ee0f4fe | 2012-05-09 21:19:14 -0400 | [diff] [blame] | 5848 | 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] | 5849 | bf_set(rrq_rxid, els_rrq, rrq->rxid); |
| 5850 | bf_set(rrq_did, els_rrq, vport->fc_myDID); |
| 5851 | els_rrq->rrq = cpu_to_be32(els_rrq->rrq); |
| 5852 | els_rrq->rrq_exchg = cpu_to_be32(els_rrq->rrq_exchg); |
| 5853 | |
| 5854 | |
| 5855 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 5856 | "Issue RRQ: did:x%x", |
| 5857 | did, rrq->xritag, rrq->rxid); |
| 5858 | elsiocb->context_un.rrq = rrq; |
| 5859 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rrq; |
| 5860 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| 5861 | |
| 5862 | if (ret == IOCB_ERROR) { |
| 5863 | lpfc_els_free_iocb(phba, elsiocb); |
| 5864 | return 1; |
| 5865 | } |
| 5866 | return 0; |
| 5867 | } |
| 5868 | |
| 5869 | /** |
| 5870 | * lpfc_send_rrq - Sends ELS RRQ if needed. |
| 5871 | * @phba: pointer to lpfc hba data structure. |
| 5872 | * @rrq: pointer to the active rrq. |
| 5873 | * |
| 5874 | * This routine will call the lpfc_issue_els_rrq if the rrq is |
| 5875 | * still active for the xri. If this function returns a failure then |
| 5876 | * the caller needs to clean up the RRQ by calling lpfc_clr_active_rrq. |
| 5877 | * |
| 5878 | * Returns 0 Success. |
| 5879 | * 1 Failure. |
| 5880 | **/ |
| 5881 | int |
| 5882 | lpfc_send_rrq(struct lpfc_hba *phba, struct lpfc_node_rrq *rrq) |
| 5883 | { |
| 5884 | struct lpfc_nodelist *ndlp = lpfc_findnode_did(rrq->vport, |
| 5885 | rrq->nlp_DID); |
| 5886 | if (lpfc_test_rrq_active(phba, ndlp, rrq->xritag)) |
| 5887 | return lpfc_issue_els_rrq(rrq->vport, ndlp, |
| 5888 | rrq->nlp_DID, rrq); |
| 5889 | else |
| 5890 | return 1; |
| 5891 | } |
| 5892 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5893 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5894 | * lpfc_els_rsp_rpl_acc - Issue an accept rpl els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5895 | * @vport: pointer to a host virtual N_Port data structure. |
| 5896 | * @cmdsize: size of the ELS command. |
| 5897 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 5898 | * @ndlp: pointer to a node-list data structure. |
| 5899 | * |
| 5900 | * This routine issuees an Accept (ACC) Read Port List (RPL) ELS command. |
| 5901 | * It is to be called by the lpfc_els_rcv_rpl() routine to accept the RPL. |
| 5902 | * |
| 5903 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 5904 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 5905 | * will be stored into the context1 field of the IOCB for the completion |
| 5906 | * callback function to the RPL Accept Response ELS command. |
| 5907 | * |
| 5908 | * Return code |
| 5909 | * 0 - Successfully issued ACC RPL ELS command |
| 5910 | * 1 - Failed to issue ACC RPL ELS command |
| 5911 | **/ |
Jamie Wellnitz | 082c026 | 2006-02-28 19:25:30 -0500 | [diff] [blame] | 5912 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5913 | lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, |
| 5914 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5915 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5916 | struct lpfc_hba *phba = vport->phba; |
| 5917 | IOCB_t *icmd, *oldcmd; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5918 | RPL_RSP rpl_rsp; |
| 5919 | struct lpfc_iocbq *elsiocb; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5920 | uint8_t *pcmd; |
| 5921 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5922 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 5923 | ndlp->nlp_DID, ELS_CMD_ACC); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5924 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 5925 | if (!elsiocb) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5926 | return 1; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 5927 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5928 | icmd = &elsiocb->iocb; |
| 5929 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 5930 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 5931 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5932 | |
| 5933 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 5934 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5935 | pcmd += sizeof(uint16_t); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5936 | *((uint16_t *)(pcmd)) = be16_to_cpu(cmdsize); |
| 5937 | pcmd += sizeof(uint16_t); |
| 5938 | |
| 5939 | /* Setup the RPL ACC payload */ |
| 5940 | rpl_rsp.listLen = be32_to_cpu(1); |
| 5941 | rpl_rsp.index = 0; |
| 5942 | rpl_rsp.port_num_blk.portNum = 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5943 | rpl_rsp.port_num_blk.portID = be32_to_cpu(vport->fc_myDID); |
| 5944 | memcpy(&rpl_rsp.port_num_blk.portName, &vport->fc_portname, |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5945 | sizeof(struct lpfc_name)); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5946 | memcpy(pcmd, &rpl_rsp, cmdsize - sizeof(uint32_t)); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5947 | /* Xmit ELS RPL ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5948 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 5949 | "0120 Xmit ELS RPL ACC response tag x%x " |
| 5950 | "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " |
| 5951 | "rpi x%x\n", |
| 5952 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 5953 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 5954 | ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5955 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5956 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 5957 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 5958 | IOCB_ERROR) { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5959 | lpfc_els_free_iocb(phba, elsiocb); |
| 5960 | return 1; |
| 5961 | } |
| 5962 | return 0; |
| 5963 | } |
| 5964 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5965 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5966 | * lpfc_els_rcv_rpl - Process an unsolicited rpl iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5967 | * @vport: pointer to a host virtual N_Port data structure. |
| 5968 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5969 | * @ndlp: pointer to a node-list data structure. |
| 5970 | * |
| 5971 | * This routine processes Read Port List (RPL) IOCB received as an ELS |
| 5972 | * unsolicited event. It first checks the remote port state. If the remote |
| 5973 | * port is not in NLP_STE_UNMAPPED_NODE and NLP_STE_MAPPED_NODE states, it |
| 5974 | * invokes the lpfc_els_rsp_reject() routine to send reject response. |
| 5975 | * Otherwise, this routine then invokes the lpfc_els_rsp_rpl_acc() routine |
| 5976 | * to accept the RPL. |
| 5977 | * |
| 5978 | * Return code |
| 5979 | * 0 - Successfully processed rpl iocb (currently always return 0) |
| 5980 | **/ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5981 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5982 | lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5983 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5984 | { |
| 5985 | struct lpfc_dmabuf *pcmd; |
| 5986 | uint32_t *lp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5987 | uint32_t maxsize; |
| 5988 | uint16_t cmdsize; |
| 5989 | RPL *rpl; |
| 5990 | struct ls_rjt stat; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5991 | |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 5992 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
| 5993 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) { |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 5994 | /* issue rejection response */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5995 | stat.un.b.lsRjtRsvd0 = 0; |
| 5996 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5997 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5998 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5999 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
| 6000 | NULL); |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 6001 | /* rejected the unsolicited RPL request and done with it */ |
| 6002 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6003 | } |
| 6004 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6005 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 6006 | lp = (uint32_t *) pcmd->virt; |
| 6007 | rpl = (RPL *) (lp + 1); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6008 | maxsize = be32_to_cpu(rpl->maxsize); |
| 6009 | |
| 6010 | /* We support only one port */ |
| 6011 | if ((rpl->index == 0) && |
| 6012 | ((maxsize == 0) || |
| 6013 | ((maxsize * sizeof(uint32_t)) >= sizeof(RPL_RSP)))) { |
| 6014 | cmdsize = sizeof(uint32_t) + sizeof(RPL_RSP); |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 6015 | } else { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6016 | cmdsize = sizeof(uint32_t) + maxsize * sizeof(uint32_t); |
| 6017 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6018 | lpfc_els_rsp_rpl_acc(vport, cmdsize, cmdiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6019 | |
| 6020 | return 0; |
| 6021 | } |
| 6022 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6023 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6024 | * lpfc_els_rcv_farp - Process an unsolicited farp request els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6025 | * @vport: pointer to a virtual N_Port data structure. |
| 6026 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6027 | * @ndlp: pointer to a node-list data structure. |
| 6028 | * |
| 6029 | * This routine processes Fibre Channel Address Resolution Protocol |
| 6030 | * (FARP) Request IOCB received as an ELS unsolicited event. Currently, |
| 6031 | * the lpfc driver only supports matching on WWPN or WWNN for FARP. As such, |
| 6032 | * FARP_MATCH_PORT flag and FARP_MATCH_NODE flag are checked against the |
| 6033 | * Match Flag in the FARP request IOCB: if FARP_MATCH_PORT flag is set, the |
| 6034 | * remote PortName is compared against the FC PortName stored in the @vport |
| 6035 | * data structure; if FARP_MATCH_NODE flag is set, the remote NodeName is |
| 6036 | * compared against the FC NodeName stored in the @vport data structure. |
| 6037 | * If any of these matches and the FARP_REQUEST_FARPR flag is set in the |
| 6038 | * FARP request IOCB Response Flag, the lpfc_issue_els_farpr() routine is |
| 6039 | * invoked to send out FARP Response to the remote node. Before sending the |
| 6040 | * FARP Response, however, the FARP_REQUEST_PLOGI flag is check in the FARP |
| 6041 | * request IOCB Response Flag and, if it is set, the lpfc_issue_els_plogi() |
| 6042 | * routine is invoked to log into the remote port first. |
| 6043 | * |
| 6044 | * Return code |
| 6045 | * 0 - Either the FARP Match Mode not supported or successfully processed |
| 6046 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6047 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6048 | lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6049 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6050 | { |
| 6051 | struct lpfc_dmabuf *pcmd; |
| 6052 | uint32_t *lp; |
| 6053 | IOCB_t *icmd; |
| 6054 | FARP *fp; |
| 6055 | uint32_t cmd, cnt, did; |
| 6056 | |
| 6057 | icmd = &cmdiocb->iocb; |
| 6058 | did = icmd->un.elsreq64.remoteID; |
| 6059 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 6060 | lp = (uint32_t *) pcmd->virt; |
| 6061 | |
| 6062 | cmd = *lp++; |
| 6063 | fp = (FARP *) lp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6064 | /* FARP-REQ received from DID <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6065 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6066 | "0601 FARP-REQ received from DID x%x\n", did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6067 | /* We will only support match on WWPN or WWNN */ |
| 6068 | if (fp->Mflags & ~(FARP_MATCH_NODE | FARP_MATCH_PORT)) { |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6069 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6070 | } |
| 6071 | |
| 6072 | cnt = 0; |
| 6073 | /* If this FARP command is searching for my portname */ |
| 6074 | if (fp->Mflags & FARP_MATCH_PORT) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6075 | if (memcmp(&fp->RportName, &vport->fc_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6076 | sizeof(struct lpfc_name)) == 0) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6077 | cnt = 1; |
| 6078 | } |
| 6079 | |
| 6080 | /* If this FARP command is searching for my nodename */ |
| 6081 | if (fp->Mflags & FARP_MATCH_NODE) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6082 | if (memcmp(&fp->RnodeName, &vport->fc_nodename, |
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 (cnt) { |
| 6088 | if ((ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) || |
| 6089 | (ndlp->nlp_state == NLP_STE_MAPPED_NODE)) { |
| 6090 | /* Log back into the node before sending the FARP. */ |
| 6091 | if (fp->Rflags & FARP_REQUEST_PLOGI) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6092 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6093 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | de0c5b3 | 2007-04-25 09:52:27 -0400 | [diff] [blame] | 6094 | NLP_STE_PLOGI_ISSUE); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6095 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6096 | } |
| 6097 | |
| 6098 | /* Send a FARP response to that node */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6099 | if (fp->Rflags & FARP_REQUEST_FARPR) |
| 6100 | lpfc_issue_els_farpr(vport, did, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6101 | } |
| 6102 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6103 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6104 | } |
| 6105 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6106 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6107 | * lpfc_els_rcv_farpr - Process an unsolicited farp response iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6108 | * @vport: pointer to a host virtual N_Port data structure. |
| 6109 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6110 | * @ndlp: pointer to a node-list data structure. |
| 6111 | * |
| 6112 | * This routine processes Fibre Channel Address Resolution Protocol |
| 6113 | * Response (FARPR) IOCB received as an ELS unsolicited event. It simply |
| 6114 | * invokes the lpfc_els_rsp_acc() routine to the remote node to accept |
| 6115 | * the FARP response request. |
| 6116 | * |
| 6117 | * Return code |
| 6118 | * 0 - Successfully processed FARPR IOCB (currently always return 0) |
| 6119 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6120 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6121 | lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6122 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6123 | { |
| 6124 | struct lpfc_dmabuf *pcmd; |
| 6125 | uint32_t *lp; |
| 6126 | IOCB_t *icmd; |
| 6127 | uint32_t cmd, did; |
| 6128 | |
| 6129 | icmd = &cmdiocb->iocb; |
| 6130 | did = icmd->un.elsreq64.remoteID; |
| 6131 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 6132 | lp = (uint32_t *) pcmd->virt; |
| 6133 | |
| 6134 | cmd = *lp++; |
| 6135 | /* FARP-RSP received from DID <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6136 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6137 | "0600 FARP-RSP received from DID x%x\n", did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6138 | /* ACCEPT the Farp resp request */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 6139 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6140 | |
| 6141 | return 0; |
| 6142 | } |
| 6143 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6144 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6145 | * lpfc_els_rcv_fan - Process an unsolicited fan iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6146 | * @vport: pointer to a host virtual N_Port data structure. |
| 6147 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6148 | * @fan_ndlp: pointer to a node-list data structure. |
| 6149 | * |
| 6150 | * This routine processes a Fabric Address Notification (FAN) IOCB |
| 6151 | * command received as an ELS unsolicited event. The FAN ELS command will |
| 6152 | * only be processed on a physical port (i.e., the @vport represents the |
| 6153 | * physical port). The fabric NodeName and PortName from the FAN IOCB are |
| 6154 | * compared against those in the phba data structure. If any of those is |
| 6155 | * different, the lpfc_initial_flogi() routine is invoked to initialize |
| 6156 | * Fabric Login (FLOGI) to the fabric to start the discover over. Otherwise, |
| 6157 | * if both of those are identical, the lpfc_issue_fabric_reglogin() routine |
| 6158 | * is invoked to register login to the fabric. |
| 6159 | * |
| 6160 | * Return code |
| 6161 | * 0 - Successfully processed fan iocb (currently always return 0). |
| 6162 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6163 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6164 | lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6165 | struct lpfc_nodelist *fan_ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6166 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6167 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6168 | uint32_t *lp; |
| 6169 | FAN *fp; |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6170 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6171 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0265 FAN received\n"); |
| 6172 | lp = (uint32_t *)((struct lpfc_dmabuf *)cmdiocb->context2)->virt; |
| 6173 | fp = (FAN *) ++lp; |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6174 | /* FAN received; Fan does not have a reply sequence */ |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6175 | if ((vport == phba->pport) && |
| 6176 | (vport->port_state == LPFC_LOCAL_CFG_LINK)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6177 | if ((memcmp(&phba->fc_fabparam.nodeName, &fp->FnodeName, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6178 | sizeof(struct lpfc_name))) || |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6179 | (memcmp(&phba->fc_fabparam.portName, &fp->FportName, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6180 | sizeof(struct lpfc_name)))) { |
| 6181 | /* This port has switched fabrics. FLOGI is required */ |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6182 | lpfc_issue_init_vfi(vport); |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6183 | } else { |
| 6184 | /* FAN verified - skip FLOGI */ |
| 6185 | vport->fc_myDID = vport->fc_prevDID; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6186 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 6187 | lpfc_issue_fabric_reglogin(vport); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 6188 | else { |
| 6189 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6190 | "3138 Need register VFI: (x%x/%x)\n", |
| 6191 | vport->fc_prevDID, vport->fc_myDID); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6192 | lpfc_issue_reg_vfi(vport); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 6193 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6194 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6195 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6196 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6197 | } |
| 6198 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6199 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6200 | * lpfc_els_timeout - Handler funciton to the els timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6201 | * @ptr: holder for the timer function associated data. |
| 6202 | * |
| 6203 | * This routine is invoked by the ELS timer after timeout. It posts the ELS |
| 6204 | * timer timeout event by setting the WORKER_ELS_TMO bit to the work port |
| 6205 | * event bitmap and then invokes the lpfc_worker_wake_up() routine to wake |
| 6206 | * up the worker thread. It is for the worker thread to invoke the routine |
| 6207 | * lpfc_els_timeout_handler() to work on the posted event WORKER_ELS_TMO. |
| 6208 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6209 | void |
| 6210 | lpfc_els_timeout(unsigned long ptr) |
| 6211 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6212 | struct lpfc_vport *vport = (struct lpfc_vport *) ptr; |
| 6213 | struct lpfc_hba *phba = vport->phba; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6214 | uint32_t tmo_posted; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6215 | unsigned long iflag; |
| 6216 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6217 | spin_lock_irqsave(&vport->work_port_lock, iflag); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6218 | tmo_posted = vport->work_port_events & WORKER_ELS_TMO; |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6219 | if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING))) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6220 | vport->work_port_events |= WORKER_ELS_TMO; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6221 | spin_unlock_irqrestore(&vport->work_port_lock, iflag); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6222 | |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6223 | if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING))) |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6224 | lpfc_worker_wake_up(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6225 | return; |
| 6226 | } |
| 6227 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6228 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6229 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6230 | * lpfc_els_timeout_handler - Process an els timeout event |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6231 | * @vport: pointer to a virtual N_Port data structure. |
| 6232 | * |
| 6233 | * This routine is the actual handler function that processes an ELS timeout |
| 6234 | * event. It walks the ELS ring to get and abort all the IOCBs (except the |
| 6235 | * ABORT/CLOSE/FARP/FARPR/FDISC), which are associated with the @vport by |
| 6236 | * invoking the lpfc_sli_issue_abort_iotag() routine. |
| 6237 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6238 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6239 | lpfc_els_timeout_handler(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6240 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6241 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6242 | struct lpfc_sli_ring *pring; |
| 6243 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 6244 | IOCB_t *cmd = NULL; |
| 6245 | struct lpfc_dmabuf *pcmd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6246 | uint32_t els_command = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6247 | uint32_t timeout; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6248 | uint32_t remote_ID = 0xffffffff; |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6249 | LIST_HEAD(abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6250 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6251 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6252 | timeout = (uint32_t)(phba->fc_ratov << 1); |
| 6253 | |
| 6254 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6255 | if ((phba->pport->load_flag & FC_UNLOADING)) |
| 6256 | return; |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6257 | spin_lock_irq(&phba->hbalock); |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6258 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6259 | spin_lock(&pring->ring_lock); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6260 | |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6261 | if ((phba->pport->load_flag & FC_UNLOADING)) { |
| 6262 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6263 | spin_unlock(&pring->ring_lock); |
| 6264 | spin_unlock_irq(&phba->hbalock); |
| 6265 | return; |
| 6266 | } |
| 6267 | |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6268 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6269 | cmd = &piocb->iocb; |
| 6270 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6271 | if ((piocb->iocb_flag & LPFC_IO_LIBDFC) != 0 || |
| 6272 | piocb->iocb.ulpCommand == CMD_ABORT_XRI_CN || |
| 6273 | piocb->iocb.ulpCommand == CMD_CLOSE_XRI_CN) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6274 | continue; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6275 | |
| 6276 | if (piocb->vport != vport) |
| 6277 | continue; |
| 6278 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6279 | pcmd = (struct lpfc_dmabuf *) piocb->context2; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6280 | if (pcmd) |
| 6281 | els_command = *(uint32_t *) (pcmd->virt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6282 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6283 | if (els_command == ELS_CMD_FARP || |
| 6284 | els_command == ELS_CMD_FARPR || |
| 6285 | els_command == ELS_CMD_FDISC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6286 | continue; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6287 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6288 | if (piocb->drvrTimeout > 0) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6289 | if (piocb->drvrTimeout >= timeout) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6290 | piocb->drvrTimeout -= timeout; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6291 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6292 | piocb->drvrTimeout = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6293 | continue; |
| 6294 | } |
| 6295 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6296 | remote_ID = 0xffffffff; |
| 6297 | if (cmd->ulpCommand != CMD_GEN_REQUEST64_CR) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6298 | remote_ID = cmd->un.elsreq64.remoteID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6299 | else { |
| 6300 | struct lpfc_nodelist *ndlp; |
| 6301 | ndlp = __lpfc_findnode_rpi(vport, cmd->ulpContext); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 6302 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6303 | remote_ID = ndlp->nlp_DID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6304 | } |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6305 | list_add_tail(&piocb->dlist, &abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6306 | } |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6307 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6308 | spin_unlock(&pring->ring_lock); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6309 | spin_unlock_irq(&phba->hbalock); |
James Smart | 5a0e326 | 2006-07-06 15:49:16 -0400 | [diff] [blame] | 6310 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6311 | list_for_each_entry_safe(piocb, tmp_iocb, &abort_list, dlist) { |
James Smart | 15026c9 | 2013-12-17 20:30:09 -0500 | [diff] [blame] | 6312 | cmd = &piocb->iocb; |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6313 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6314 | "0127 ELS timeout Data: x%x x%x x%x " |
| 6315 | "x%x\n", els_command, |
| 6316 | remote_ID, cmd->ulpCommand, cmd->ulpIoTag); |
| 6317 | spin_lock_irq(&phba->hbalock); |
| 6318 | list_del_init(&piocb->dlist); |
| 6319 | lpfc_sli_issue_abort_iotag(phba, pring, piocb); |
| 6320 | spin_unlock_irq(&phba->hbalock); |
| 6321 | } |
| 6322 | |
James Smart | 0e9bb8d | 2013-03-01 16:35:12 -0500 | [diff] [blame] | 6323 | if (!list_empty(&phba->sli.ring[LPFC_ELS_RING].txcmplq)) |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6324 | if (!(phba->pport->load_flag & FC_UNLOADING)) |
| 6325 | mod_timer(&vport->els_tmofunc, |
| 6326 | jiffies + msecs_to_jiffies(1000 * timeout)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6327 | } |
| 6328 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6329 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6330 | * 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] | 6331 | * @vport: pointer to a host virtual N_Port data structure. |
| 6332 | * |
| 6333 | * This routine is used to clean up all the outstanding ELS commands on a |
| 6334 | * @vport. It first aborts the @vport by invoking lpfc_fabric_abort_vport() |
| 6335 | * routine. After that, it walks the ELS transmit queue to remove all the |
| 6336 | * IOCBs with the @vport other than the QUE_RING and ABORT/CLOSE IOCBs. For |
| 6337 | * the IOCBs with a non-NULL completion callback function, the callback |
| 6338 | * function will be invoked with the status set to IOSTAT_LOCAL_REJECT and |
| 6339 | * un.ulpWord[4] set to IOERR_SLI_ABORTED. For IOCBs with a NULL completion |
| 6340 | * callback function, the IOCB will simply be released. Finally, it walks |
| 6341 | * the ELS transmit completion queue to issue an abort IOCB to any transmit |
| 6342 | * completion queue IOCB that is associated with the @vport and is not |
| 6343 | * an IOCB from libdfc (i.e., the management plane IOCBs that are not |
| 6344 | * part of the discovery state machine) out to HBA by invoking the |
| 6345 | * lpfc_sli_issue_abort_iotag() routine. Note that this function issues the |
| 6346 | * abort IOCB to any transmit completion queueed IOCB, it does not guarantee |
| 6347 | * the IOCBs are aborted when this function returns. |
| 6348 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6349 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6350 | lpfc_els_flush_cmd(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6351 | { |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6352 | LIST_HEAD(abort_list); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6353 | struct lpfc_hba *phba = vport->phba; |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6354 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6355 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 6356 | IOCB_t *cmd = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6357 | |
| 6358 | lpfc_fabric_abort_vport(vport); |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6359 | /* |
| 6360 | * For SLI3, only the hbalock is required. But SLI4 needs to coordinate |
| 6361 | * with the ring insert operation. Because lpfc_sli_issue_abort_iotag |
| 6362 | * ultimately grabs the ring_lock, the driver must splice the list into |
| 6363 | * a working list and release the locks before calling the abort. |
| 6364 | */ |
| 6365 | spin_lock_irq(&phba->hbalock); |
| 6366 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6367 | spin_lock(&pring->ring_lock); |
| 6368 | |
| 6369 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) { |
| 6370 | if (piocb->iocb_flag & LPFC_IO_LIBDFC) |
| 6371 | continue; |
| 6372 | |
| 6373 | if (piocb->vport != vport) |
| 6374 | continue; |
| 6375 | list_add_tail(&piocb->dlist, &abort_list); |
| 6376 | } |
| 6377 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6378 | spin_unlock(&pring->ring_lock); |
| 6379 | spin_unlock_irq(&phba->hbalock); |
| 6380 | /* Abort each iocb on the aborted list and remove the dlist links. */ |
| 6381 | list_for_each_entry_safe(piocb, tmp_iocb, &abort_list, dlist) { |
| 6382 | spin_lock_irq(&phba->hbalock); |
| 6383 | list_del_init(&piocb->dlist); |
| 6384 | lpfc_sli_issue_abort_iotag(phba, pring, piocb); |
| 6385 | spin_unlock_irq(&phba->hbalock); |
| 6386 | } |
| 6387 | if (!list_empty(&abort_list)) |
| 6388 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6389 | "3387 abort list for txq not empty\n"); |
| 6390 | INIT_LIST_HEAD(&abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6391 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6392 | spin_lock_irq(&phba->hbalock); |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6393 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6394 | spin_lock(&pring->ring_lock); |
| 6395 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6396 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txq, list) { |
| 6397 | cmd = &piocb->iocb; |
| 6398 | |
| 6399 | if (piocb->iocb_flag & LPFC_IO_LIBDFC) { |
| 6400 | continue; |
| 6401 | } |
| 6402 | |
| 6403 | /* Do not flush out the QUE_RING and ABORT/CLOSE iocbs */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6404 | if (cmd->ulpCommand == CMD_QUE_RING_BUF_CN || |
| 6405 | cmd->ulpCommand == CMD_QUE_RING_BUF64_CN || |
| 6406 | cmd->ulpCommand == CMD_CLOSE_XRI_CN || |
| 6407 | cmd->ulpCommand == CMD_ABORT_XRI_CN) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6408 | continue; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6409 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6410 | if (piocb->vport != vport) |
| 6411 | continue; |
| 6412 | |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6413 | list_del_init(&piocb->list); |
| 6414 | list_add_tail(&piocb->list, &abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6415 | } |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6416 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6417 | spin_unlock(&pring->ring_lock); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6418 | spin_unlock_irq(&phba->hbalock); |
James Smart | 2534ba7 | 2007-04-25 09:52:20 -0400 | [diff] [blame] | 6419 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 6420 | /* Cancell all the IOCBs from the completions list */ |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6421 | lpfc_sli_cancel_iocbs(phba, &abort_list, |
| 6422 | IOSTAT_LOCAL_REJECT, IOERR_SLI_ABORTED); |
James Smart | 2534ba7 | 2007-04-25 09:52:20 -0400 | [diff] [blame] | 6423 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6424 | return; |
| 6425 | } |
| 6426 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6427 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6428 | * 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] | 6429 | * @phba: pointer to lpfc hba data structure. |
| 6430 | * |
| 6431 | * This routine is used to clean up all the outstanding ELS commands on a |
| 6432 | * @phba. It first aborts the @phba by invoking the lpfc_fabric_abort_hba() |
| 6433 | * routine. After that, it walks the ELS transmit queue to remove all the |
| 6434 | * IOCBs to the @phba other than the QUE_RING and ABORT/CLOSE IOCBs. For |
| 6435 | * the IOCBs with the completion callback function associated, the callback |
| 6436 | * function will be invoked with the status set to IOSTAT_LOCAL_REJECT and |
| 6437 | * un.ulpWord[4] set to IOERR_SLI_ABORTED. For IOCBs without the completion |
| 6438 | * callback function associated, the IOCB will simply be released. Finally, |
| 6439 | * it walks the ELS transmit completion queue to issue an abort IOCB to any |
| 6440 | * transmit completion queue IOCB that is not an IOCB from libdfc (i.e., the |
| 6441 | * management plane IOCBs that are not part of the discovery state machine) |
| 6442 | * out to HBA by invoking the lpfc_sli_issue_abort_iotag() routine. |
| 6443 | **/ |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 6444 | void |
| 6445 | lpfc_els_flush_all_cmd(struct lpfc_hba *phba) |
| 6446 | { |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6447 | struct lpfc_vport *vport; |
| 6448 | list_for_each_entry(vport, &phba->port_list, listentry) |
| 6449 | lpfc_els_flush_cmd(vport); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 6450 | |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 6451 | return; |
| 6452 | } |
| 6453 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6454 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6455 | * lpfc_send_els_failure_event - Posts an ELS command failure event |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6456 | * @phba: Pointer to hba context object. |
| 6457 | * @cmdiocbp: Pointer to command iocb which reported error. |
| 6458 | * @rspiocbp: Pointer to response iocb which reported error. |
| 6459 | * |
| 6460 | * This function sends an event when there is an ELS command |
| 6461 | * failure. |
| 6462 | **/ |
| 6463 | void |
| 6464 | lpfc_send_els_failure_event(struct lpfc_hba *phba, |
| 6465 | struct lpfc_iocbq *cmdiocbp, |
| 6466 | struct lpfc_iocbq *rspiocbp) |
| 6467 | { |
| 6468 | struct lpfc_vport *vport = cmdiocbp->vport; |
| 6469 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 6470 | struct lpfc_lsrjt_event lsrjt_event; |
| 6471 | struct lpfc_fabric_event_header fabric_event; |
| 6472 | struct ls_rjt stat; |
| 6473 | struct lpfc_nodelist *ndlp; |
| 6474 | uint32_t *pcmd; |
| 6475 | |
| 6476 | ndlp = cmdiocbp->context1; |
| 6477 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 6478 | return; |
| 6479 | |
| 6480 | if (rspiocbp->iocb.ulpStatus == IOSTAT_LS_RJT) { |
| 6481 | lsrjt_event.header.event_type = FC_REG_ELS_EVENT; |
| 6482 | lsrjt_event.header.subcategory = LPFC_EVENT_LSRJT_RCV; |
| 6483 | memcpy(lsrjt_event.header.wwpn, &ndlp->nlp_portname, |
| 6484 | sizeof(struct lpfc_name)); |
| 6485 | memcpy(lsrjt_event.header.wwnn, &ndlp->nlp_nodename, |
| 6486 | sizeof(struct lpfc_name)); |
| 6487 | pcmd = (uint32_t *) (((struct lpfc_dmabuf *) |
| 6488 | cmdiocbp->context2)->virt); |
James Smart | 49198b3 | 2010-04-06 15:04:33 -0400 | [diff] [blame] | 6489 | lsrjt_event.command = (pcmd != NULL) ? *pcmd : 0; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6490 | stat.un.lsRjtError = be32_to_cpu(rspiocbp->iocb.un.ulpWord[4]); |
| 6491 | lsrjt_event.reason_code = stat.un.b.lsRjtRsnCode; |
| 6492 | lsrjt_event.explanation = stat.un.b.lsRjtRsnCodeExp; |
| 6493 | fc_host_post_vendor_event(shost, |
| 6494 | fc_get_event_number(), |
| 6495 | sizeof(lsrjt_event), |
| 6496 | (char *)&lsrjt_event, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6497 | LPFC_NL_VENDOR_ID); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6498 | return; |
| 6499 | } |
| 6500 | if ((rspiocbp->iocb.ulpStatus == IOSTAT_NPORT_BSY) || |
| 6501 | (rspiocbp->iocb.ulpStatus == IOSTAT_FABRIC_BSY)) { |
| 6502 | fabric_event.event_type = FC_REG_FABRIC_EVENT; |
| 6503 | if (rspiocbp->iocb.ulpStatus == IOSTAT_NPORT_BSY) |
| 6504 | fabric_event.subcategory = LPFC_EVENT_PORT_BUSY; |
| 6505 | else |
| 6506 | fabric_event.subcategory = LPFC_EVENT_FABRIC_BUSY; |
| 6507 | memcpy(fabric_event.wwpn, &ndlp->nlp_portname, |
| 6508 | sizeof(struct lpfc_name)); |
| 6509 | memcpy(fabric_event.wwnn, &ndlp->nlp_nodename, |
| 6510 | sizeof(struct lpfc_name)); |
| 6511 | fc_host_post_vendor_event(shost, |
| 6512 | fc_get_event_number(), |
| 6513 | sizeof(fabric_event), |
| 6514 | (char *)&fabric_event, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6515 | LPFC_NL_VENDOR_ID); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6516 | return; |
| 6517 | } |
| 6518 | |
| 6519 | } |
| 6520 | |
| 6521 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6522 | * lpfc_send_els_event - Posts unsolicited els event |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6523 | * @vport: Pointer to vport object. |
| 6524 | * @ndlp: Pointer FC node object. |
| 6525 | * @cmd: ELS command code. |
| 6526 | * |
| 6527 | * This function posts an event when there is an incoming |
| 6528 | * unsolicited ELS command. |
| 6529 | **/ |
| 6530 | static void |
| 6531 | lpfc_send_els_event(struct lpfc_vport *vport, |
| 6532 | struct lpfc_nodelist *ndlp, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6533 | uint32_t *payload) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6534 | { |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6535 | struct lpfc_els_event_header *els_data = NULL; |
| 6536 | struct lpfc_logo_event *logo_data = NULL; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6537 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 6538 | |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6539 | if (*payload == ELS_CMD_LOGO) { |
| 6540 | logo_data = kmalloc(sizeof(struct lpfc_logo_event), GFP_KERNEL); |
| 6541 | if (!logo_data) { |
| 6542 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6543 | "0148 Failed to allocate memory " |
| 6544 | "for LOGO event\n"); |
| 6545 | return; |
| 6546 | } |
| 6547 | els_data = &logo_data->header; |
| 6548 | } else { |
| 6549 | els_data = kmalloc(sizeof(struct lpfc_els_event_header), |
| 6550 | GFP_KERNEL); |
| 6551 | if (!els_data) { |
| 6552 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6553 | "0149 Failed to allocate memory " |
| 6554 | "for ELS event\n"); |
| 6555 | return; |
| 6556 | } |
| 6557 | } |
| 6558 | els_data->event_type = FC_REG_ELS_EVENT; |
| 6559 | switch (*payload) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6560 | case ELS_CMD_PLOGI: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6561 | els_data->subcategory = LPFC_EVENT_PLOGI_RCV; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6562 | break; |
| 6563 | case ELS_CMD_PRLO: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6564 | els_data->subcategory = LPFC_EVENT_PRLO_RCV; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6565 | break; |
| 6566 | case ELS_CMD_ADISC: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6567 | els_data->subcategory = LPFC_EVENT_ADISC_RCV; |
| 6568 | break; |
| 6569 | case ELS_CMD_LOGO: |
| 6570 | els_data->subcategory = LPFC_EVENT_LOGO_RCV; |
| 6571 | /* Copy the WWPN in the LOGO payload */ |
| 6572 | memcpy(logo_data->logo_wwpn, &payload[2], |
| 6573 | sizeof(struct lpfc_name)); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6574 | break; |
| 6575 | default: |
Julia Lawall | e916141 | 2009-02-08 22:43:19 +0100 | [diff] [blame] | 6576 | kfree(els_data); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6577 | return; |
| 6578 | } |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 6579 | memcpy(els_data->wwpn, &ndlp->nlp_portname, sizeof(struct lpfc_name)); |
| 6580 | memcpy(els_data->wwnn, &ndlp->nlp_nodename, sizeof(struct lpfc_name)); |
| 6581 | if (*payload == ELS_CMD_LOGO) { |
| 6582 | fc_host_post_vendor_event(shost, |
| 6583 | fc_get_event_number(), |
| 6584 | sizeof(struct lpfc_logo_event), |
| 6585 | (char *)logo_data, |
| 6586 | LPFC_NL_VENDOR_ID); |
| 6587 | kfree(logo_data); |
| 6588 | } else { |
| 6589 | fc_host_post_vendor_event(shost, |
| 6590 | fc_get_event_number(), |
| 6591 | sizeof(struct lpfc_els_event_header), |
| 6592 | (char *)els_data, |
| 6593 | LPFC_NL_VENDOR_ID); |
| 6594 | kfree(els_data); |
| 6595 | } |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 6596 | |
| 6597 | return; |
| 6598 | } |
| 6599 | |
| 6600 | |
| 6601 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6602 | * lpfc_els_unsol_buffer - Process an unsolicited event data buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6603 | * @phba: pointer to lpfc hba data structure. |
| 6604 | * @pring: pointer to a SLI ring. |
| 6605 | * @vport: pointer to a host virtual N_Port data structure. |
| 6606 | * @elsiocb: pointer to lpfc els command iocb data structure. |
| 6607 | * |
| 6608 | * This routine is used for processing the IOCB associated with a unsolicited |
| 6609 | * event. It first determines whether there is an existing ndlp that matches |
| 6610 | * the DID from the unsolicited IOCB. If not, it will create a new one with |
| 6611 | * the DID from the unsolicited IOCB. The ELS command from the unsolicited |
| 6612 | * IOCB is then used to invoke the proper routine and to set up proper state |
| 6613 | * of the discovery state machine. |
| 6614 | **/ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6615 | static void |
| 6616 | 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] | 6617 | struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6618 | { |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6619 | struct Scsi_Host *shost; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6620 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6621 | struct ls_rjt stat; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6622 | uint32_t *payload; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 6623 | uint32_t cmd, did, newnode; |
| 6624 | uint8_t rjt_exp, rjt_err = 0; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6625 | IOCB_t *icmd = &elsiocb->iocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6626 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6627 | if (!vport || !(elsiocb->context2)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6628 | goto dropit; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6629 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6630 | newnode = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6631 | payload = ((struct lpfc_dmabuf *)elsiocb->context2)->virt; |
| 6632 | cmd = *payload; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6633 | if ((phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) == 0) |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 6634 | lpfc_post_buffer(phba, pring, 1); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6635 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6636 | did = icmd->un.rcvels.remoteID; |
| 6637 | if (icmd->ulpStatus) { |
| 6638 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 6639 | "RCV Unsol ELS: status:x%x/x%x did:x%x", |
| 6640 | icmd->ulpStatus, icmd->un.ulpWord[4], did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6641 | goto dropit; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6642 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6643 | |
| 6644 | /* Check to see if link went down during discovery */ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6645 | if (lpfc_els_chk_latt(vport)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6646 | goto dropit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6647 | |
James Smart | c868595 | 2009-11-18 15:39:16 -0500 | [diff] [blame] | 6648 | /* Ignore traffic received during vport shutdown. */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6649 | if (vport->load_flag & FC_UNLOADING) |
| 6650 | goto dropit; |
| 6651 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 6652 | /* If NPort discovery is delayed drop incoming ELS */ |
| 6653 | if ((vport->fc_flag & FC_DISC_DELAYED) && |
| 6654 | (cmd != ELS_CMD_PLOGI)) |
| 6655 | goto dropit; |
| 6656 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6657 | ndlp = lpfc_findnode_did(vport, did); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6658 | if (!ndlp) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6659 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6660 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6661 | if (!ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6662 | goto dropit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6663 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6664 | lpfc_nlp_init(vport, ndlp, did); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 6665 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6666 | newnode = 1; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6667 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6668 | ndlp->nlp_type |= NLP_FABRIC; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 6669 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 6670 | ndlp = lpfc_enable_node(vport, ndlp, |
| 6671 | NLP_STE_UNUSED_NODE); |
| 6672 | if (!ndlp) |
| 6673 | goto dropit; |
| 6674 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 6675 | newnode = 1; |
| 6676 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
| 6677 | ndlp->nlp_type |= NLP_FABRIC; |
| 6678 | } else if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) { |
| 6679 | /* This is similar to the new node path */ |
| 6680 | ndlp = lpfc_nlp_get(ndlp); |
| 6681 | if (!ndlp) |
| 6682 | goto dropit; |
| 6683 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 6684 | newnode = 1; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 6685 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6686 | |
| 6687 | phba->fc_stat.elsRcvFrame++; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6688 | |
James Smart | 12838e7 | 2014-09-03 12:57:19 -0400 | [diff] [blame] | 6689 | /* |
| 6690 | * Do not process any unsolicited ELS commands |
| 6691 | * if the ndlp is in DEV_LOSS |
| 6692 | */ |
| 6693 | if (ndlp->nlp_add_flag & NLP_IN_DEV_LOSS) |
| 6694 | goto dropit; |
| 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); |
James Smart | a2fc4aef | 2014-09-03 12:57:55 -0400 | [diff] [blame] | 7517 | if (!prsp) |
| 7518 | goto out; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7519 | sp = prsp->virt + sizeof(uint32_t); |
| 7520 | fabric_param_changed = lpfc_check_clean_addr_bit(vport, sp); |
| 7521 | memcpy(&vport->fabric_portname, &sp->portName, |
| 7522 | sizeof(struct lpfc_name)); |
| 7523 | memcpy(&vport->fabric_nodename, &sp->nodeName, |
| 7524 | sizeof(struct lpfc_name)); |
| 7525 | if (fabric_param_changed && |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7526 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 7527 | /* If our NportID changed, we need to ensure all |
| 7528 | * remaining NPORTs get unreg_login'ed so we can |
| 7529 | * issue unreg_vpi. |
| 7530 | */ |
| 7531 | list_for_each_entry_safe(np, next_np, |
| 7532 | &vport->fc_nodes, nlp_listp) { |
| 7533 | if (!NLP_CHK_NODE_ACT(ndlp) || |
| 7534 | (np->nlp_state != NLP_STE_NPR_NODE) || |
| 7535 | !(np->nlp_flag & NLP_NPR_ADISC)) |
| 7536 | continue; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7537 | spin_lock_irq(shost->host_lock); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7538 | np->nlp_flag &= ~NLP_NPR_ADISC; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7539 | spin_unlock_irq(shost->host_lock); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7540 | lpfc_unreg_rpi(vport, np); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7541 | } |
James Smart | 78730cf | 2010-04-06 15:06:30 -0400 | [diff] [blame] | 7542 | lpfc_cleanup_pending_mbox(vport); |
James Smart | 5af5eee | 2010-10-22 11:06:38 -0400 | [diff] [blame] | 7543 | |
| 7544 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 7545 | lpfc_sli4_unreg_all_rpis(vport); |
| 7546 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7547 | lpfc_mbx_unreg_vpi(vport); |
| 7548 | spin_lock_irq(shost->host_lock); |
| 7549 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 7550 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 7551 | vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 7552 | else |
| 7553 | vport->fc_flag |= FC_LOGO_RCVD_DID_CHNG; |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7554 | spin_unlock_irq(shost->host_lock); |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 7555 | } else if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 7556 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 7557 | /* |
| 7558 | * Driver needs to re-reg VPI in order for f/w |
| 7559 | * to update the MAC address. |
| 7560 | */ |
| 7561 | lpfc_register_new_vport(phba, vport, ndlp); |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 7562 | goto out; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7563 | } |
| 7564 | |
James Smart | ecfd03c | 2010-02-12 14:41:27 -0500 | [diff] [blame] | 7565 | if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI) |
| 7566 | lpfc_issue_init_vpi(vport); |
| 7567 | else if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7568 | lpfc_register_new_vport(phba, vport, ndlp); |
| 7569 | else |
| 7570 | lpfc_do_scr_ns_plogi(phba, vport); |
| 7571 | goto out; |
| 7572 | fdisc_failed: |
| 7573 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 7574 | /* Cancel discovery timer */ |
| 7575 | lpfc_can_disctmo(vport); |
| 7576 | lpfc_nlp_put(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7577 | out: |
| 7578 | lpfc_els_free_iocb(phba, cmdiocb); |
| 7579 | } |
| 7580 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7581 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7582 | * lpfc_issue_els_fdisc - Issue a fdisc iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7583 | * @vport: pointer to a virtual N_Port data structure. |
| 7584 | * @ndlp: pointer to a node-list data structure. |
| 7585 | * @retry: number of retries to the command IOCB. |
| 7586 | * |
| 7587 | * This routine prepares and issues a Fabric Discover (FDISC) IOCB to |
| 7588 | * a remote node (@ndlp) off a @vport. It uses the lpfc_issue_fabric_iocb() |
| 7589 | * routine to issue the IOCB, which makes sure only one outstanding fabric |
| 7590 | * IOCB will be sent off HBA at any given time. |
| 7591 | * |
| 7592 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 7593 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 7594 | * will be stored into the context1 field of the IOCB for the completion |
| 7595 | * callback function to the FDISC ELS command. |
| 7596 | * |
| 7597 | * Return code |
| 7598 | * 0 - Successfully issued fdisc iocb command |
| 7599 | * 1 - Failed to issue fdisc iocb command |
| 7600 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 7601 | static int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7602 | lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 7603 | uint8_t retry) |
| 7604 | { |
| 7605 | struct lpfc_hba *phba = vport->phba; |
| 7606 | IOCB_t *icmd; |
| 7607 | struct lpfc_iocbq *elsiocb; |
| 7608 | struct serv_parm *sp; |
| 7609 | uint8_t *pcmd; |
| 7610 | uint16_t cmdsize; |
| 7611 | int did = ndlp->nlp_DID; |
| 7612 | int rc; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7613 | |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 7614 | vport->port_state = LPFC_FDISC; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 7615 | vport->fc_myDID = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7616 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
| 7617 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did, |
| 7618 | ELS_CMD_FDISC); |
| 7619 | if (!elsiocb) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7620 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7621 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7622 | "0255 Issue FDISC: no IOCB\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7623 | return 1; |
| 7624 | } |
| 7625 | |
| 7626 | icmd = &elsiocb->iocb; |
| 7627 | icmd->un.elsreq64.myID = 0; |
| 7628 | icmd->un.elsreq64.fl = 1; |
| 7629 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 7630 | /* |
| 7631 | * SLI3 ports require a different context type value than SLI4. |
| 7632 | * Catch SLI3 ports here and override the prep. |
| 7633 | */ |
| 7634 | if (phba->sli_rev == LPFC_SLI_REV3) { |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 7635 | icmd->ulpCt_h = 1; |
| 7636 | icmd->ulpCt_l = 0; |
| 7637 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7638 | |
| 7639 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 7640 | *((uint32_t *) (pcmd)) = ELS_CMD_FDISC; |
| 7641 | pcmd += sizeof(uint32_t); /* CSP Word 1 */ |
| 7642 | memcpy(pcmd, &vport->phba->pport->fc_sparam, sizeof(struct serv_parm)); |
| 7643 | sp = (struct serv_parm *) pcmd; |
| 7644 | /* Setup CSPs accordingly for Fabric */ |
| 7645 | sp->cmn.e_d_tov = 0; |
| 7646 | sp->cmn.w2.r_a_tov = 0; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 7647 | sp->cmn.virtual_fabric_support = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7648 | sp->cls1.classValid = 0; |
| 7649 | sp->cls2.seqDelivery = 1; |
| 7650 | sp->cls3.seqDelivery = 1; |
| 7651 | |
| 7652 | pcmd += sizeof(uint32_t); /* CSP Word 2 */ |
| 7653 | pcmd += sizeof(uint32_t); /* CSP Word 3 */ |
| 7654 | pcmd += sizeof(uint32_t); /* CSP Word 4 */ |
| 7655 | pcmd += sizeof(uint32_t); /* Port Name */ |
| 7656 | memcpy(pcmd, &vport->fc_portname, 8); |
| 7657 | pcmd += sizeof(uint32_t); /* Node Name */ |
| 7658 | pcmd += sizeof(uint32_t); /* Node Name */ |
| 7659 | memcpy(pcmd, &vport->fc_nodename, 8); |
| 7660 | |
| 7661 | lpfc_set_disctmo(vport); |
| 7662 | |
| 7663 | phba->fc_stat.elsXmitFDISC++; |
| 7664 | elsiocb->iocb_cmpl = lpfc_cmpl_els_fdisc; |
| 7665 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7666 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 7667 | "Issue FDISC: did:x%x", |
| 7668 | did, 0, 0); |
| 7669 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7670 | rc = lpfc_issue_fabric_iocb(phba, elsiocb); |
| 7671 | if (rc == IOCB_ERROR) { |
| 7672 | lpfc_els_free_iocb(phba, elsiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7673 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7674 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7675 | "0256 Issue FDISC: Cannot send IOCB\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7676 | return 1; |
| 7677 | } |
| 7678 | lpfc_vport_set_state(vport, FC_VPORT_INITIALIZING); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7679 | return 0; |
| 7680 | } |
| 7681 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7682 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7683 | * lpfc_cmpl_els_npiv_logo - Completion function with vport logo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7684 | * @phba: pointer to lpfc hba data structure. |
| 7685 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 7686 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 7687 | * |
| 7688 | * This routine is the completion callback function to the issuing of a LOGO |
| 7689 | * ELS command off a vport. It frees the command IOCB and then decrement the |
| 7690 | * reference count held on ndlp for this completion function, indicating that |
| 7691 | * the reference to the ndlp is no long needed. Note that the |
| 7692 | * lpfc_els_free_iocb() routine decrements the ndlp reference held for this |
| 7693 | * callback function and an additional explicit ndlp reference decrementation |
| 7694 | * will trigger the actual release of the ndlp. |
| 7695 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7696 | static void |
| 7697 | lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 7698 | struct lpfc_iocbq *rspiocb) |
| 7699 | { |
| 7700 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7701 | IOCB_t *irsp; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 7702 | struct lpfc_nodelist *ndlp; |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 7703 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7704 | |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 7705 | ndlp = (struct lpfc_nodelist *)cmdiocb->context1; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7706 | irsp = &rspiocb->iocb; |
| 7707 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 7708 | "LOGO npiv cmpl: status:x%x/x%x did:x%x", |
| 7709 | irsp->ulpStatus, irsp->un.ulpWord[4], irsp->un.rcvels.remoteID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7710 | |
| 7711 | lpfc_els_free_iocb(phba, cmdiocb); |
| 7712 | vport->unreg_vpi_cmpl = VPORT_ERROR; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 7713 | |
| 7714 | /* Trigger the release of the ndlp after logo */ |
| 7715 | lpfc_nlp_put(ndlp); |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 7716 | |
| 7717 | /* NPIV LOGO completes to NPort <nlp_DID> */ |
| 7718 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 7719 | "2928 NPIV LOGO completes to NPort x%x " |
| 7720 | "Data: x%x x%x x%x x%x\n", |
| 7721 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 7722 | irsp->ulpTimeout, vport->num_disc_nodes); |
| 7723 | |
| 7724 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 7725 | spin_lock_irq(shost->host_lock); |
| 7726 | vport->fc_flag &= ~FC_FABRIC; |
| 7727 | spin_unlock_irq(shost->host_lock); |
| 7728 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7729 | } |
| 7730 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7731 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7732 | * lpfc_issue_els_npiv_logo - Issue a logo off a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7733 | * @vport: pointer to a virtual N_Port data structure. |
| 7734 | * @ndlp: pointer to a node-list data structure. |
| 7735 | * |
| 7736 | * This routine issues a LOGO ELS command to an @ndlp off a @vport. |
| 7737 | * |
| 7738 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 7739 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 7740 | * will be stored into the context1 field of the IOCB for the completion |
| 7741 | * callback function to the LOGO ELS command. |
| 7742 | * |
| 7743 | * Return codes |
| 7744 | * 0 - Successfully issued logo off the @vport |
| 7745 | * 1 - Failed to issue logo off the @vport |
| 7746 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7747 | int |
| 7748 | lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) |
| 7749 | { |
| 7750 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 7751 | struct lpfc_hba *phba = vport->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7752 | IOCB_t *icmd; |
| 7753 | struct lpfc_iocbq *elsiocb; |
| 7754 | uint8_t *pcmd; |
| 7755 | uint16_t cmdsize; |
| 7756 | |
| 7757 | cmdsize = 2 * sizeof(uint32_t) + sizeof(struct lpfc_name); |
| 7758 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, ndlp->nlp_DID, |
| 7759 | ELS_CMD_LOGO); |
| 7760 | if (!elsiocb) |
| 7761 | return 1; |
| 7762 | |
| 7763 | icmd = &elsiocb->iocb; |
| 7764 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 7765 | *((uint32_t *) (pcmd)) = ELS_CMD_LOGO; |
| 7766 | pcmd += sizeof(uint32_t); |
| 7767 | |
| 7768 | /* Fill in LOGO payload */ |
| 7769 | *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID); |
| 7770 | pcmd += sizeof(uint32_t); |
| 7771 | memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 7772 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7773 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 7774 | "Issue LOGO npiv did:x%x flg:x%x", |
| 7775 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 7776 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7777 | elsiocb->iocb_cmpl = lpfc_cmpl_els_npiv_logo; |
| 7778 | spin_lock_irq(shost->host_lock); |
| 7779 | ndlp->nlp_flag |= NLP_LOGO_SND; |
| 7780 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 7781 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 7782 | IOCB_ERROR) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7783 | spin_lock_irq(shost->host_lock); |
| 7784 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
| 7785 | spin_unlock_irq(shost->host_lock); |
| 7786 | lpfc_els_free_iocb(phba, elsiocb); |
| 7787 | return 1; |
| 7788 | } |
| 7789 | return 0; |
| 7790 | } |
| 7791 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7792 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7793 | * lpfc_fabric_block_timeout - Handler function to the fabric block timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7794 | * @ptr: holder for the timer function associated data. |
| 7795 | * |
| 7796 | * This routine is invoked by the fabric iocb block timer after |
| 7797 | * timeout. It posts the fabric iocb block timeout event by setting the |
| 7798 | * WORKER_FABRIC_BLOCK_TMO bit to work port event bitmap and then invokes |
| 7799 | * lpfc_worker_wake_up() routine to wake up the worker thread. It is for |
| 7800 | * the worker thread to invoke the lpfc_unblock_fabric_iocbs() on the |
| 7801 | * posted event WORKER_FABRIC_BLOCK_TMO. |
| 7802 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7803 | void |
| 7804 | lpfc_fabric_block_timeout(unsigned long ptr) |
| 7805 | { |
| 7806 | struct lpfc_hba *phba = (struct lpfc_hba *) ptr; |
| 7807 | unsigned long iflags; |
| 7808 | uint32_t tmo_posted; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 7809 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7810 | spin_lock_irqsave(&phba->pport->work_port_lock, iflags); |
| 7811 | tmo_posted = phba->pport->work_port_events & WORKER_FABRIC_BLOCK_TMO; |
| 7812 | if (!tmo_posted) |
| 7813 | phba->pport->work_port_events |= WORKER_FABRIC_BLOCK_TMO; |
| 7814 | spin_unlock_irqrestore(&phba->pport->work_port_lock, iflags); |
| 7815 | |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 7816 | if (!tmo_posted) |
| 7817 | lpfc_worker_wake_up(phba); |
| 7818 | return; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7819 | } |
| 7820 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7821 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7822 | * lpfc_resume_fabric_iocbs - Issue a fabric iocb from driver internal list |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7823 | * @phba: pointer to lpfc hba data structure. |
| 7824 | * |
| 7825 | * This routine issues one fabric iocb from the driver internal list to |
| 7826 | * the HBA. It first checks whether it's ready to issue one fabric iocb to |
| 7827 | * the HBA (whether there is no outstanding fabric iocb). If so, it shall |
| 7828 | * remove one pending fabric iocb from the driver internal list and invokes |
| 7829 | * lpfc_sli_issue_iocb() routine to send the fabric iocb to the HBA. |
| 7830 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7831 | static void |
| 7832 | lpfc_resume_fabric_iocbs(struct lpfc_hba *phba) |
| 7833 | { |
| 7834 | struct lpfc_iocbq *iocb; |
| 7835 | unsigned long iflags; |
| 7836 | int ret; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7837 | IOCB_t *cmd; |
| 7838 | |
| 7839 | repeat: |
| 7840 | iocb = NULL; |
| 7841 | spin_lock_irqsave(&phba->hbalock, iflags); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7842 | /* Post any pending iocb to the SLI layer */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7843 | if (atomic_read(&phba->fabric_iocb_count) == 0) { |
| 7844 | list_remove_head(&phba->fabric_iocb_list, iocb, typeof(*iocb), |
| 7845 | list); |
| 7846 | if (iocb) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7847 | /* Increment fabric iocb count to hold the position */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7848 | atomic_inc(&phba->fabric_iocb_count); |
| 7849 | } |
| 7850 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 7851 | if (iocb) { |
| 7852 | iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; |
| 7853 | iocb->iocb_cmpl = lpfc_cmpl_fabric_iocb; |
| 7854 | iocb->iocb_flag |= LPFC_IO_FABRIC; |
| 7855 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7856 | lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD, |
| 7857 | "Fabric sched1: ste:x%x", |
| 7858 | iocb->vport->port_state, 0, 0); |
| 7859 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 7860 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, iocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7861 | |
| 7862 | if (ret == IOCB_ERROR) { |
| 7863 | iocb->iocb_cmpl = iocb->fabric_iocb_cmpl; |
| 7864 | iocb->fabric_iocb_cmpl = NULL; |
| 7865 | iocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 7866 | cmd = &iocb->iocb; |
| 7867 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; |
| 7868 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; |
| 7869 | iocb->iocb_cmpl(phba, iocb, iocb); |
| 7870 | |
| 7871 | atomic_dec(&phba->fabric_iocb_count); |
| 7872 | goto repeat; |
| 7873 | } |
| 7874 | } |
| 7875 | |
| 7876 | return; |
| 7877 | } |
| 7878 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7879 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7880 | * lpfc_unblock_fabric_iocbs - Unblock issuing fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7881 | * @phba: pointer to lpfc hba data structure. |
| 7882 | * |
| 7883 | * This routine unblocks the issuing fabric iocb command. The function |
| 7884 | * will clear the fabric iocb block bit and then invoke the routine |
| 7885 | * lpfc_resume_fabric_iocbs() to issue one of the pending fabric iocb |
| 7886 | * from the driver internal fabric iocb list. |
| 7887 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7888 | void |
| 7889 | lpfc_unblock_fabric_iocbs(struct lpfc_hba *phba) |
| 7890 | { |
| 7891 | clear_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
| 7892 | |
| 7893 | lpfc_resume_fabric_iocbs(phba); |
| 7894 | return; |
| 7895 | } |
| 7896 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7897 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7898 | * lpfc_block_fabric_iocbs - Block issuing fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7899 | * @phba: pointer to lpfc hba data structure. |
| 7900 | * |
| 7901 | * This routine blocks the issuing fabric iocb for a specified amount of |
| 7902 | * time (currently 100 ms). This is done by set the fabric iocb block bit |
| 7903 | * and set up a timeout timer for 100ms. When the block bit is set, no more |
| 7904 | * fabric iocb will be issued out of the HBA. |
| 7905 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7906 | static void |
| 7907 | lpfc_block_fabric_iocbs(struct lpfc_hba *phba) |
| 7908 | { |
| 7909 | int blocked; |
| 7910 | |
| 7911 | blocked = test_and_set_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7912 | /* Start a timer to unblock fabric iocbs after 100ms */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7913 | if (!blocked) |
James Smart | 256ec0d | 2013-04-17 20:14:58 -0400 | [diff] [blame] | 7914 | mod_timer(&phba->fabric_block_timer, |
| 7915 | jiffies + msecs_to_jiffies(100)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7916 | |
| 7917 | return; |
| 7918 | } |
| 7919 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7920 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7921 | * lpfc_cmpl_fabric_iocb - Completion callback function for fabric iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7922 | * @phba: pointer to lpfc hba data structure. |
| 7923 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 7924 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 7925 | * |
| 7926 | * This routine is the callback function that is put to the fabric iocb's |
| 7927 | * callback function pointer (iocb->iocb_cmpl). The original iocb's callback |
| 7928 | * function pointer has been stored in iocb->fabric_iocb_cmpl. This callback |
| 7929 | * function first restores and invokes the original iocb's callback function |
| 7930 | * and then invokes the lpfc_resume_fabric_iocbs() routine to issue the next |
| 7931 | * fabric bound iocb from the driver internal fabric iocb list onto the wire. |
| 7932 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7933 | static void |
| 7934 | lpfc_cmpl_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 7935 | struct lpfc_iocbq *rspiocb) |
| 7936 | { |
| 7937 | struct ls_rjt stat; |
| 7938 | |
| 7939 | if ((cmdiocb->iocb_flag & LPFC_IO_FABRIC) != LPFC_IO_FABRIC) |
| 7940 | BUG(); |
| 7941 | |
| 7942 | switch (rspiocb->iocb.ulpStatus) { |
| 7943 | case IOSTAT_NPORT_RJT: |
| 7944 | case IOSTAT_FABRIC_RJT: |
| 7945 | if (rspiocb->iocb.un.ulpWord[4] & RJT_UNAVAIL_TEMP) { |
| 7946 | lpfc_block_fabric_iocbs(phba); |
| 7947 | } |
| 7948 | break; |
| 7949 | |
| 7950 | case IOSTAT_NPORT_BSY: |
| 7951 | case IOSTAT_FABRIC_BSY: |
| 7952 | lpfc_block_fabric_iocbs(phba); |
| 7953 | break; |
| 7954 | |
| 7955 | case IOSTAT_LS_RJT: |
| 7956 | stat.un.lsRjtError = |
| 7957 | be32_to_cpu(rspiocb->iocb.un.ulpWord[4]); |
| 7958 | if ((stat.un.b.lsRjtRsnCode == LSRJT_UNABLE_TPC) || |
| 7959 | (stat.un.b.lsRjtRsnCode == LSRJT_LOGICAL_BSY)) |
| 7960 | lpfc_block_fabric_iocbs(phba); |
| 7961 | break; |
| 7962 | } |
| 7963 | |
| 7964 | if (atomic_read(&phba->fabric_iocb_count) == 0) |
| 7965 | BUG(); |
| 7966 | |
| 7967 | cmdiocb->iocb_cmpl = cmdiocb->fabric_iocb_cmpl; |
| 7968 | cmdiocb->fabric_iocb_cmpl = NULL; |
| 7969 | cmdiocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 7970 | cmdiocb->iocb_cmpl(phba, cmdiocb, rspiocb); |
| 7971 | |
| 7972 | atomic_dec(&phba->fabric_iocb_count); |
| 7973 | if (!test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags)) { |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7974 | /* Post any pending iocbs to HBA */ |
| 7975 | lpfc_resume_fabric_iocbs(phba); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7976 | } |
| 7977 | } |
| 7978 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7979 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7980 | * lpfc_issue_fabric_iocb - Issue a fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7981 | * @phba: pointer to lpfc hba data structure. |
| 7982 | * @iocb: pointer to lpfc command iocb data structure. |
| 7983 | * |
| 7984 | * This routine is used as the top-level API for issuing a fabric iocb command |
| 7985 | * such as FLOGI and FDISC. To accommodate certain switch fabric, this driver |
| 7986 | * function makes sure that only one fabric bound iocb will be outstanding at |
| 7987 | * any given time. As such, this function will first check to see whether there |
| 7988 | * is already an outstanding fabric iocb on the wire. If so, it will put the |
| 7989 | * newly issued iocb onto the driver internal fabric iocb list, waiting to be |
| 7990 | * issued later. Otherwise, it will issue the iocb on the wire and update the |
| 7991 | * fabric iocb count it indicate that there is one fabric iocb on the wire. |
| 7992 | * |
| 7993 | * Note, this implementation has a potential sending out fabric IOCBs out of |
| 7994 | * order. The problem is caused by the construction of the "ready" boolen does |
| 7995 | * not include the condition that the internal fabric IOCB list is empty. As |
| 7996 | * such, it is possible a fabric IOCB issued by this routine might be "jump" |
| 7997 | * ahead of the fabric IOCBs in the internal list. |
| 7998 | * |
| 7999 | * Return code |
| 8000 | * IOCB_SUCCESS - either fabric iocb put on the list or issued successfully |
| 8001 | * IOCB_ERROR - failed to issue fabric iocb |
| 8002 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 8003 | static int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8004 | lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb) |
| 8005 | { |
| 8006 | unsigned long iflags; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8007 | int ready; |
| 8008 | int ret; |
| 8009 | |
| 8010 | if (atomic_read(&phba->fabric_iocb_count) > 1) |
| 8011 | BUG(); |
| 8012 | |
| 8013 | spin_lock_irqsave(&phba->hbalock, iflags); |
| 8014 | ready = atomic_read(&phba->fabric_iocb_count) == 0 && |
| 8015 | !test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
| 8016 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 8017 | if (ready) |
| 8018 | /* Increment fabric iocb count to hold the position */ |
| 8019 | atomic_inc(&phba->fabric_iocb_count); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8020 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 8021 | if (ready) { |
| 8022 | iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; |
| 8023 | iocb->iocb_cmpl = lpfc_cmpl_fabric_iocb; |
| 8024 | iocb->iocb_flag |= LPFC_IO_FABRIC; |
| 8025 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 8026 | lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD, |
| 8027 | "Fabric sched2: ste:x%x", |
| 8028 | iocb->vport->port_state, 0, 0); |
| 8029 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 8030 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, iocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8031 | |
| 8032 | if (ret == IOCB_ERROR) { |
| 8033 | iocb->iocb_cmpl = iocb->fabric_iocb_cmpl; |
| 8034 | iocb->fabric_iocb_cmpl = NULL; |
| 8035 | iocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 8036 | atomic_dec(&phba->fabric_iocb_count); |
| 8037 | } |
| 8038 | } else { |
| 8039 | spin_lock_irqsave(&phba->hbalock, iflags); |
| 8040 | list_add_tail(&iocb->list, &phba->fabric_iocb_list); |
| 8041 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 8042 | ret = IOCB_SUCCESS; |
| 8043 | } |
| 8044 | return ret; |
| 8045 | } |
| 8046 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8047 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8048 | * 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] | 8049 | * @vport: pointer to a virtual N_Port data structure. |
| 8050 | * |
| 8051 | * This routine aborts all the IOCBs associated with a @vport from the |
| 8052 | * driver internal fabric IOCB list. The list contains fabric IOCBs to be |
| 8053 | * issued to the ELS IOCB ring. This abort function walks the fabric IOCB |
| 8054 | * list, removes each IOCB associated with the @vport off the list, set the |
| 8055 | * status feild to IOSTAT_LOCAL_REJECT, and invokes the callback function |
| 8056 | * associated with the IOCB. |
| 8057 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 8058 | static void lpfc_fabric_abort_vport(struct lpfc_vport *vport) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8059 | { |
| 8060 | LIST_HEAD(completions); |
| 8061 | struct lpfc_hba *phba = vport->phba; |
| 8062 | struct lpfc_iocbq *tmp_iocb, *piocb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8063 | |
| 8064 | spin_lock_irq(&phba->hbalock); |
| 8065 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, |
| 8066 | list) { |
| 8067 | |
| 8068 | if (piocb->vport != vport) |
| 8069 | continue; |
| 8070 | |
| 8071 | list_move_tail(&piocb->list, &completions); |
| 8072 | } |
| 8073 | spin_unlock_irq(&phba->hbalock); |
| 8074 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8075 | /* Cancel all the IOCBs from the completions list */ |
| 8076 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 8077 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8078 | } |
| 8079 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8080 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8081 | * 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] | 8082 | * @ndlp: pointer to a node-list data structure. |
| 8083 | * |
| 8084 | * This routine aborts all the IOCBs associated with an @ndlp from the |
| 8085 | * driver internal fabric IOCB list. The list contains fabric IOCBs to be |
| 8086 | * issued to the ELS IOCB ring. This abort function walks the fabric IOCB |
| 8087 | * list, removes each IOCB associated with the @ndlp off the list, set the |
| 8088 | * status feild to IOSTAT_LOCAL_REJECT, and invokes the callback function |
| 8089 | * associated with the IOCB. |
| 8090 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8091 | void lpfc_fabric_abort_nport(struct lpfc_nodelist *ndlp) |
| 8092 | { |
| 8093 | LIST_HEAD(completions); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8094 | struct lpfc_hba *phba = ndlp->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8095 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 8096 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8097 | |
| 8098 | spin_lock_irq(&phba->hbalock); |
| 8099 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, |
| 8100 | list) { |
| 8101 | if ((lpfc_check_sli_ndlp(phba, pring, piocb, ndlp))) { |
| 8102 | |
| 8103 | list_move_tail(&piocb->list, &completions); |
| 8104 | } |
| 8105 | } |
| 8106 | spin_unlock_irq(&phba->hbalock); |
| 8107 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8108 | /* Cancel all the IOCBs from the completions list */ |
| 8109 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 8110 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8111 | } |
| 8112 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8113 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8114 | * lpfc_fabric_abort_hba - Abort all iocbs on driver fabric iocb list |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8115 | * @phba: pointer to lpfc hba data structure. |
| 8116 | * |
| 8117 | * This routine aborts all the IOCBs currently on the driver internal |
| 8118 | * fabric IOCB list. The list contains fabric IOCBs to be issued to the ELS |
| 8119 | * IOCB ring. This function takes the entire IOCB list off the fabric IOCB |
| 8120 | * list, removes IOCBs off the list, set the status feild to |
| 8121 | * IOSTAT_LOCAL_REJECT, and invokes the callback function associated with |
| 8122 | * the IOCB. |
| 8123 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8124 | void lpfc_fabric_abort_hba(struct lpfc_hba *phba) |
| 8125 | { |
| 8126 | LIST_HEAD(completions); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8127 | |
| 8128 | spin_lock_irq(&phba->hbalock); |
| 8129 | list_splice_init(&phba->fabric_iocb_list, &completions); |
| 8130 | spin_unlock_irq(&phba->hbalock); |
| 8131 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8132 | /* Cancel all the IOCBs from the completions list */ |
| 8133 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 8134 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8135 | } |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8136 | |
| 8137 | /** |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 8138 | * lpfc_sli4_vport_delete_els_xri_aborted -Remove all ndlp references for vport |
| 8139 | * @vport: pointer to lpfc vport data structure. |
| 8140 | * |
| 8141 | * This routine is invoked by the vport cleanup for deletions and the cleanup |
| 8142 | * for an ndlp on removal. |
| 8143 | **/ |
| 8144 | void |
| 8145 | lpfc_sli4_vport_delete_els_xri_aborted(struct lpfc_vport *vport) |
| 8146 | { |
| 8147 | struct lpfc_hba *phba = vport->phba; |
| 8148 | struct lpfc_sglq *sglq_entry = NULL, *sglq_next = NULL; |
| 8149 | unsigned long iflag = 0; |
| 8150 | |
| 8151 | spin_lock_irqsave(&phba->hbalock, iflag); |
| 8152 | spin_lock(&phba->sli4_hba.abts_sgl_list_lock); |
| 8153 | list_for_each_entry_safe(sglq_entry, sglq_next, |
| 8154 | &phba->sli4_hba.lpfc_abts_els_sgl_list, list) { |
| 8155 | if (sglq_entry->ndlp && sglq_entry->ndlp->vport == vport) |
| 8156 | sglq_entry->ndlp = NULL; |
| 8157 | } |
| 8158 | spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); |
| 8159 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8160 | return; |
| 8161 | } |
| 8162 | |
| 8163 | /** |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8164 | * lpfc_sli4_els_xri_aborted - Slow-path process of els xri abort |
| 8165 | * @phba: pointer to lpfc hba data structure. |
| 8166 | * @axri: pointer to the els xri abort wcqe structure. |
| 8167 | * |
| 8168 | * This routine is invoked by the worker thread to process a SLI4 slow-path |
| 8169 | * ELS aborted xri. |
| 8170 | **/ |
| 8171 | void |
| 8172 | lpfc_sli4_els_xri_aborted(struct lpfc_hba *phba, |
| 8173 | struct sli4_wcqe_xri_aborted *axri) |
| 8174 | { |
| 8175 | uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8176 | uint16_t rxid = bf_get(lpfc_wcqe_xa_remote_xid, axri); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 8177 | uint16_t lxri = 0; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8178 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8179 | struct lpfc_sglq *sglq_entry = NULL, *sglq_next = NULL; |
| 8180 | unsigned long iflag = 0; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8181 | struct lpfc_nodelist *ndlp; |
James Smart | 589a52d | 2010-07-14 15:30:54 -0400 | [diff] [blame] | 8182 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8183 | |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8184 | spin_lock_irqsave(&phba->hbalock, iflag); |
| 8185 | spin_lock(&phba->sli4_hba.abts_sgl_list_lock); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8186 | list_for_each_entry_safe(sglq_entry, sglq_next, |
| 8187 | &phba->sli4_hba.lpfc_abts_els_sgl_list, list) { |
| 8188 | if (sglq_entry->sli4_xritag == xri) { |
| 8189 | list_del(&sglq_entry->list); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8190 | ndlp = sglq_entry->ndlp; |
| 8191 | sglq_entry->ndlp = NULL; |
James Smart | dafe8ce | 2014-09-03 12:56:40 -0400 | [diff] [blame] | 8192 | spin_lock(&pring->ring_lock); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8193 | list_add_tail(&sglq_entry->list, |
| 8194 | &phba->sli4_hba.lpfc_sgl_list); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8195 | sglq_entry->state = SGL_FREED; |
James Smart | dafe8ce | 2014-09-03 12:56:40 -0400 | [diff] [blame] | 8196 | spin_unlock(&pring->ring_lock); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8197 | spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8198 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
James Smart | ee0f4fe | 2012-05-09 21:19:14 -0400 | [diff] [blame] | 8199 | lpfc_set_rrq_active(phba, ndlp, |
| 8200 | sglq_entry->sli4_lxritag, |
| 8201 | rxid, 1); |
James Smart | 589a52d | 2010-07-14 15:30:54 -0400 | [diff] [blame] | 8202 | |
| 8203 | /* Check if TXQ queue needs to be serviced */ |
James Smart | 0e9bb8d | 2013-03-01 16:35:12 -0500 | [diff] [blame] | 8204 | if (!(list_empty(&pring->txq))) |
James Smart | 589a52d | 2010-07-14 15:30:54 -0400 | [diff] [blame] | 8205 | lpfc_worker_wake_up(phba); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8206 | return; |
| 8207 | } |
| 8208 | } |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8209 | spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 8210 | lxri = lpfc_sli4_xri_inrange(phba, xri); |
| 8211 | if (lxri == NO_XRI) { |
| 8212 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8213 | return; |
| 8214 | } |
James Smart | dafe8ce | 2014-09-03 12:56:40 -0400 | [diff] [blame] | 8215 | spin_lock(&pring->ring_lock); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 8216 | sglq_entry = __lpfc_get_active_sglq(phba, lxri); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8217 | if (!sglq_entry || (sglq_entry->sli4_xritag != xri)) { |
James Smart | dafe8ce | 2014-09-03 12:56:40 -0400 | [diff] [blame] | 8218 | spin_unlock(&pring->ring_lock); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8219 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8220 | return; |
| 8221 | } |
| 8222 | sglq_entry->state = SGL_XRI_ABORTED; |
James Smart | dafe8ce | 2014-09-03 12:56:40 -0400 | [diff] [blame] | 8223 | spin_unlock(&pring->ring_lock); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8224 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8225 | return; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8226 | } |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 8227 | |
| 8228 | /* lpfc_sli_abts_recover_port - Recover a port that failed a BLS_ABORT req. |
| 8229 | * @vport: pointer to virtual port object. |
| 8230 | * @ndlp: nodelist pointer for the impacted node. |
| 8231 | * |
| 8232 | * The driver calls this routine in response to an SLI4 XRI ABORT CQE |
| 8233 | * or an SLI3 ASYNC_STATUS_CN event from the port. For either event, |
| 8234 | * the driver is required to send a LOGO to the remote node before it |
| 8235 | * attempts to recover its login to the remote node. |
| 8236 | */ |
| 8237 | void |
| 8238 | lpfc_sli_abts_recover_port(struct lpfc_vport *vport, |
| 8239 | struct lpfc_nodelist *ndlp) |
| 8240 | { |
| 8241 | struct Scsi_Host *shost; |
| 8242 | struct lpfc_hba *phba; |
| 8243 | unsigned long flags = 0; |
| 8244 | |
| 8245 | shost = lpfc_shost_from_vport(vport); |
| 8246 | phba = vport->phba; |
| 8247 | if (ndlp->nlp_state != NLP_STE_MAPPED_NODE) { |
| 8248 | lpfc_printf_log(phba, KERN_INFO, |
| 8249 | LOG_SLI, "3093 No rport recovery needed. " |
| 8250 | "rport in state 0x%x\n", ndlp->nlp_state); |
| 8251 | return; |
| 8252 | } |
| 8253 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, |
| 8254 | "3094 Start rport recovery on shost id 0x%x " |
| 8255 | "fc_id 0x%06x vpi 0x%x rpi 0x%x state 0x%x " |
| 8256 | "flags 0x%x\n", |
| 8257 | shost->host_no, ndlp->nlp_DID, |
| 8258 | vport->vpi, ndlp->nlp_rpi, ndlp->nlp_state, |
| 8259 | ndlp->nlp_flag); |
| 8260 | /* |
| 8261 | * The rport is not responding. Remove the FCP-2 flag to prevent |
| 8262 | * an ADISC in the follow-up recovery code. |
| 8263 | */ |
| 8264 | spin_lock_irqsave(shost->host_lock, flags); |
| 8265 | ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE; |
| 8266 | spin_unlock_irqrestore(shost->host_lock, flags); |
| 8267 | lpfc_issue_els_logo(vport, ndlp, 0); |
| 8268 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE); |
| 8269 | } |
| 8270 | |