| 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 | f25e8e7 | 2015-04-07 15:07:28 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2015 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 | c9f8735b | 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 | c9f8735b | 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; |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 458 | LPFC_MBOXQ_t *mboxq = NULL; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 459 | struct lpfc_nodelist *ndlp; |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 460 | struct lpfc_dmabuf *dmabuf = NULL; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 461 | int rc = 0; |
| 462 | |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 463 | /* 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] | 464 | if ((phba->sli_rev == LPFC_SLI_REV4) && |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 465 | !(phba->link_flag & LS_LOOPBACK_MODE) && |
| 466 | !(vport->fc_flag & FC_PT2PT)) { |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 467 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
| 468 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
| 469 | rc = -ENODEV; |
| 470 | goto fail; |
| 471 | } |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 472 | } |
| 473 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 474 | mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 475 | if (!mboxq) { |
| 476 | rc = -ENOMEM; |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 477 | goto fail; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 478 | } |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 479 | |
| 480 | /* Supply CSP's only if we are fabric connect or pt-to-pt connect */ |
| 481 | if ((vport->fc_flag & FC_FABRIC) || (vport->fc_flag & FC_PT2PT)) { |
| 482 | dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| 483 | if (!dmabuf) { |
| 484 | rc = -ENOMEM; |
| 485 | goto fail; |
| 486 | } |
| 487 | dmabuf->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &dmabuf->phys); |
| 488 | if (!dmabuf->virt) { |
| 489 | rc = -ENOMEM; |
| 490 | goto fail; |
| 491 | } |
| 492 | memcpy(dmabuf->virt, &phba->fc_fabparam, |
| 493 | sizeof(struct serv_parm)); |
| 494 | } |
| 495 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 496 | vport->port_state = LPFC_FABRIC_CFG_LINK; |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 497 | if (dmabuf) |
| 498 | lpfc_reg_vfi(mboxq, vport, dmabuf->phys); |
| 499 | else |
| 500 | lpfc_reg_vfi(mboxq, vport, 0); |
James Smart | ae05ebe | 2013-03-01 16:35:38 -0500 | [diff] [blame] | 501 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 502 | mboxq->mbox_cmpl = lpfc_mbx_cmpl_reg_vfi; |
| 503 | mboxq->vport = vport; |
| 504 | mboxq->context1 = dmabuf; |
| 505 | rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); |
| 506 | if (rc == MBX_NOT_FINISHED) { |
| 507 | rc = -ENXIO; |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 508 | goto fail; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 509 | } |
| 510 | return 0; |
| 511 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 512 | fail: |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 513 | if (mboxq) |
| 514 | mempool_free(mboxq, phba->mbox_mem_pool); |
| 515 | if (dmabuf) { |
| 516 | if (dmabuf->virt) |
| 517 | lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys); |
| 518 | kfree(dmabuf); |
| 519 | } |
| 520 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 521 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 522 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 523 | "0289 Issue Register VFI failed: Err %d\n", rc); |
| 524 | return rc; |
| 525 | } |
| 526 | |
| 527 | /** |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 528 | * lpfc_issue_unreg_vfi - Unregister VFI for this vport's fabric login |
| 529 | * @vport: pointer to a host virtual N_Port data structure. |
| 530 | * |
| 531 | * This routine issues a UNREG_VFI mailbox with the vfi, vpi, fcfi triplet for |
| 532 | * the @vport. This mailbox command is necessary for SLI4 port only. |
| 533 | * |
| 534 | * Return code |
| 535 | * 0 - successfully issued REG_VFI for @vport |
| 536 | * A failure code otherwise. |
| 537 | **/ |
| 538 | int |
| 539 | lpfc_issue_unreg_vfi(struct lpfc_vport *vport) |
| 540 | { |
| 541 | struct lpfc_hba *phba = vport->phba; |
| 542 | struct Scsi_Host *shost; |
| 543 | LPFC_MBOXQ_t *mboxq; |
| 544 | int rc; |
| 545 | |
| 546 | mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 547 | if (!mboxq) { |
| 548 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, |
| 549 | "2556 UNREG_VFI mbox allocation failed" |
| 550 | "HBA state x%x\n", phba->pport->port_state); |
| 551 | return -ENOMEM; |
| 552 | } |
| 553 | |
| 554 | lpfc_unreg_vfi(mboxq, vport); |
| 555 | mboxq->vport = vport; |
| 556 | mboxq->mbox_cmpl = lpfc_unregister_vfi_cmpl; |
| 557 | |
| 558 | rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); |
| 559 | if (rc == MBX_NOT_FINISHED) { |
| 560 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, |
| 561 | "2557 UNREG_VFI issue mbox failed rc x%x " |
| 562 | "HBA state x%x\n", |
| 563 | rc, phba->pport->port_state); |
| 564 | mempool_free(mboxq, phba->mbox_mem_pool); |
| 565 | return -EIO; |
| 566 | } |
| 567 | |
| 568 | shost = lpfc_shost_from_vport(vport); |
| 569 | spin_lock_irq(shost->host_lock); |
| 570 | vport->fc_flag &= ~FC_VFI_REGISTERED; |
| 571 | spin_unlock_irq(shost->host_lock); |
| 572 | return 0; |
| 573 | } |
| 574 | |
| 575 | /** |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 576 | * lpfc_check_clean_addr_bit - Check whether assigned FCID is clean. |
| 577 | * @vport: pointer to a host virtual N_Port data structure. |
| 578 | * @sp: pointer to service parameter data structure. |
| 579 | * |
| 580 | * This routine is called from FLOGI/FDISC completion handler functions. |
| 581 | * lpfc_check_clean_addr_bit return 1 when FCID/Fabric portname/ Fabric |
| 582 | * node nodename is changed in the completion service parameter else return |
| 583 | * 0. This function also set flag in the vport data structure to delay |
| 584 | * NP_Port discovery after the FLOGI/FDISC completion if Clean address bit |
| 585 | * in FLOGI/FDISC response is cleared and FCID/Fabric portname/ Fabric |
| 586 | * node nodename is changed in the completion service parameter. |
| 587 | * |
| 588 | * Return code |
| 589 | * 0 - FCID and Fabric Nodename and Fabric portname is not changed. |
| 590 | * 1 - FCID or Fabric Nodename or Fabric portname is changed. |
| 591 | * |
| 592 | **/ |
| 593 | static uint8_t |
| 594 | lpfc_check_clean_addr_bit(struct lpfc_vport *vport, |
| 595 | struct serv_parm *sp) |
| 596 | { |
| 597 | uint8_t fabric_param_changed = 0; |
| 598 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 599 | |
| 600 | if ((vport->fc_prevDID != vport->fc_myDID) || |
| 601 | memcmp(&vport->fabric_portname, &sp->portName, |
| 602 | sizeof(struct lpfc_name)) || |
| 603 | memcmp(&vport->fabric_nodename, &sp->nodeName, |
| 604 | sizeof(struct lpfc_name))) |
| 605 | fabric_param_changed = 1; |
| 606 | |
| 607 | /* |
| 608 | * Word 1 Bit 31 in common service parameter is overloaded. |
| 609 | * Word 1 Bit 31 in FLOGI request is multiple NPort request |
| 610 | * Word 1 Bit 31 in FLOGI response is clean address bit |
| 611 | * |
| 612 | * If fabric parameter is changed and clean address bit is |
| 613 | * cleared delay nport discovery if |
| 614 | * - vport->fc_prevDID != 0 (not initial discovery) OR |
| 615 | * - lpfc_delay_discovery module parameter is set. |
| 616 | */ |
| 617 | if (fabric_param_changed && !sp->cmn.clean_address_bit && |
| 618 | (vport->fc_prevDID || lpfc_delay_discovery)) { |
| 619 | spin_lock_irq(shost->host_lock); |
| 620 | vport->fc_flag |= FC_DISC_DELAYED; |
| 621 | spin_unlock_irq(shost->host_lock); |
| 622 | } |
| 623 | |
| 624 | return fabric_param_changed; |
| 625 | } |
| 626 | |
| 627 | |
| 628 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 629 | * 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] | 630 | * @vport: pointer to a host virtual N_Port data structure. |
| 631 | * @ndlp: pointer to a node-list data structure. |
| 632 | * @sp: pointer to service parameter data structure. |
| 633 | * @irsp: pointer to the IOCB within the lpfc response IOCB. |
| 634 | * |
| 635 | * This routine is invoked by the lpfc_cmpl_els_flogi() completion callback |
| 636 | * function to handle the completion of a Fabric Login (FLOGI) into a fabric |
| 637 | * port in a fabric topology. It properly sets up the parameters to the @ndlp |
| 638 | * from the IOCB response. It also check the newly assigned N_Port ID to the |
| 639 | * @vport against the previously assigned N_Port ID. If it is different from |
| 640 | * the previously assigned Destination ID (DID), the lpfc_unreg_rpi() routine |
| 641 | * is invoked on all the remaining nodes with the @vport to unregister the |
| 642 | * Remote Port Indicators (RPIs). Finally, the lpfc_issue_fabric_reglogin() |
| 643 | * is invoked to register login to the fabric. |
| 644 | * |
| 645 | * Return code |
| 646 | * 0 - Success (currently, always return 0) |
| 647 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 648 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 649 | lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 650 | struct serv_parm *sp, IOCB_t *irsp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 651 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 652 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 653 | struct lpfc_hba *phba = vport->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 654 | struct lpfc_nodelist *np; |
| 655 | struct lpfc_nodelist *next_np; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 656 | uint8_t fabric_param_changed; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 657 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 658 | spin_lock_irq(shost->host_lock); |
| 659 | vport->fc_flag |= FC_FABRIC; |
| 660 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 661 | |
| 662 | phba->fc_edtov = be32_to_cpu(sp->cmn.e_d_tov); |
| 663 | if (sp->cmn.edtovResolution) /* E_D_TOV ticks are in nanoseconds */ |
| 664 | phba->fc_edtov = (phba->fc_edtov + 999999) / 1000000; |
| 665 | |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 666 | phba->fc_edtovResol = sp->cmn.edtovResolution; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 667 | phba->fc_ratov = (be32_to_cpu(sp->cmn.w2.r_a_tov) + 999) / 1000; |
| 668 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 669 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 670 | spin_lock_irq(shost->host_lock); |
| 671 | vport->fc_flag |= FC_PUBLIC_LOOP; |
| 672 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 673 | } |
| 674 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 675 | vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 676 | memcpy(&ndlp->nlp_portname, &sp->portName, sizeof(struct lpfc_name)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 677 | memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 678 | ndlp->nlp_class_sup = 0; |
| 679 | if (sp->cls1.classValid) |
| 680 | ndlp->nlp_class_sup |= FC_COS_CLASS1; |
| 681 | if (sp->cls2.classValid) |
| 682 | ndlp->nlp_class_sup |= FC_COS_CLASS2; |
| 683 | if (sp->cls3.classValid) |
| 684 | ndlp->nlp_class_sup |= FC_COS_CLASS3; |
| 685 | if (sp->cls4.classValid) |
| 686 | ndlp->nlp_class_sup |= FC_COS_CLASS4; |
| 687 | ndlp->nlp_maxframe = ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | |
| 688 | sp->cmn.bbRcvSizeLsb; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 689 | |
| 690 | fabric_param_changed = lpfc_check_clean_addr_bit(vport, sp); |
| 691 | memcpy(&vport->fabric_portname, &sp->portName, |
| 692 | sizeof(struct lpfc_name)); |
| 693 | memcpy(&vport->fabric_nodename, &sp->nodeName, |
| 694 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 695 | memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm)); |
| 696 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 697 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
| 698 | if (sp->cmn.response_multiple_NPort) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 699 | lpfc_printf_vlog(vport, KERN_WARNING, |
| 700 | LOG_ELS | LOG_VPORT, |
| 701 | "1816 FLOGI NPIV supported, " |
| 702 | "response data 0x%x\n", |
| 703 | sp->cmn.response_multiple_NPort); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 704 | spin_lock_irq(&phba->hbalock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 705 | phba->link_flag |= LS_NPIV_FAB_SUPPORTED; |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 706 | spin_unlock_irq(&phba->hbalock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 707 | } else { |
| 708 | /* Because we asked f/w for NPIV it still expects us |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 709 | to call reg_vnpid atleast for the physcial host */ |
| 710 | lpfc_printf_vlog(vport, KERN_WARNING, |
| 711 | LOG_ELS | LOG_VPORT, |
| 712 | "1817 Fabric does not support NPIV " |
| 713 | "- configuring single port mode.\n"); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 714 | spin_lock_irq(&phba->hbalock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 715 | phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED; |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 716 | spin_unlock_irq(&phba->hbalock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 717 | } |
| 718 | } |
| 719 | |
James Smart | ae05ebe | 2013-03-01 16:35:38 -0500 | [diff] [blame] | 720 | /* |
| 721 | * For FC we need to do some special processing because of the SLI |
| 722 | * Port's default settings of the Common Service Parameters. |
| 723 | */ |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 724 | if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 725 | (phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC)) { |
James Smart | ae05ebe | 2013-03-01 16:35:38 -0500 | [diff] [blame] | 726 | /* If physical FC port changed, unreg VFI and ALL VPIs / RPIs */ |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 727 | if (fabric_param_changed) |
James Smart | ae05ebe | 2013-03-01 16:35:38 -0500 | [diff] [blame] | 728 | lpfc_unregister_fcf_prep(phba); |
| 729 | |
| 730 | /* This should just update the VFI CSPs*/ |
| 731 | if (vport->fc_flag & FC_VFI_REGISTERED) |
| 732 | lpfc_issue_reg_vfi(vport); |
| 733 | } |
| 734 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 735 | if (fabric_param_changed && |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 736 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 737 | |
| 738 | /* If our NportID changed, we need to ensure all |
| 739 | * remaining NPORTs get unreg_login'ed. |
| 740 | */ |
| 741 | list_for_each_entry_safe(np, next_np, |
| 742 | &vport->fc_nodes, nlp_listp) { |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 743 | if (!NLP_CHK_NODE_ACT(np)) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 744 | continue; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 745 | if ((np->nlp_state != NLP_STE_NPR_NODE) || |
| 746 | !(np->nlp_flag & NLP_NPR_ADISC)) |
| 747 | continue; |
| 748 | spin_lock_irq(shost->host_lock); |
| 749 | np->nlp_flag &= ~NLP_NPR_ADISC; |
| 750 | spin_unlock_irq(shost->host_lock); |
| 751 | lpfc_unreg_rpi(vport, np); |
| 752 | } |
James Smart | 78730cf | 2010-04-06 15:06:30 -0400 | [diff] [blame] | 753 | lpfc_cleanup_pending_mbox(vport); |
James Smart | 5af5eee | 2010-10-22 11:06:38 -0400 | [diff] [blame] | 754 | |
James Smart | 5248a74 | 2011-07-22 18:37:06 -0400 | [diff] [blame] | 755 | if (phba->sli_rev == LPFC_SLI_REV4) { |
James Smart | 5af5eee | 2010-10-22 11:06:38 -0400 | [diff] [blame] | 756 | lpfc_sli4_unreg_all_rpis(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 757 | lpfc_mbx_unreg_vpi(vport); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 758 | spin_lock_irq(shost->host_lock); |
James Smart | ecfd03c | 2010-02-12 14:41:27 -0500 | [diff] [blame] | 759 | vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; |
| 760 | spin_unlock_irq(shost->host_lock); |
| 761 | } |
James Smart | 27aa1b7 | 2012-05-09 21:18:49 -0400 | [diff] [blame] | 762 | |
| 763 | /* |
| 764 | * For SLI3 and SLI4, the VPI needs to be reregistered in |
| 765 | * response to this fabric parameter change event. |
| 766 | */ |
| 767 | spin_lock_irq(shost->host_lock); |
| 768 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
| 769 | spin_unlock_irq(shost->host_lock); |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 770 | } else if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 771 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 772 | /* |
| 773 | * Driver needs to re-reg VPI in order for f/w |
| 774 | * to update the MAC address. |
| 775 | */ |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 776 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 777 | lpfc_register_new_vport(phba, vport, ndlp); |
| 778 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 779 | } |
| 780 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 781 | if (phba->sli_rev < LPFC_SLI_REV4) { |
| 782 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE); |
| 783 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED && |
| 784 | vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) |
| 785 | lpfc_register_new_vport(phba, vport, ndlp); |
| 786 | else |
| 787 | lpfc_issue_fabric_reglogin(vport); |
| 788 | } else { |
| 789 | ndlp->nlp_type |= NLP_FABRIC; |
| 790 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 791 | if ((!(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) && |
| 792 | (vport->vpi_state & LPFC_VPI_REGISTERED)) { |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 793 | lpfc_start_fdiscs(phba); |
| 794 | lpfc_do_scr_ns_plogi(phba, vport); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 795 | } else if (vport->fc_flag & FC_VFI_REGISTERED) |
James Smart | ecfd03c | 2010-02-12 14:41:27 -0500 | [diff] [blame] | 796 | lpfc_issue_init_vpi(vport); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 797 | else { |
| 798 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 799 | "3135 Need register VFI: (x%x/%x)\n", |
| 800 | vport->fc_prevDID, vport->fc_myDID); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 801 | lpfc_issue_reg_vfi(vport); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 802 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 803 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 804 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 805 | } |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 806 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 807 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 808 | * 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] | 809 | * @vport: pointer to a host virtual N_Port data structure. |
| 810 | * @ndlp: pointer to a node-list data structure. |
| 811 | * @sp: pointer to service parameter data structure. |
| 812 | * |
| 813 | * This routine is invoked by the lpfc_cmpl_els_flogi() completion callback |
| 814 | * function to handle the completion of a Fabric Login (FLOGI) into an N_Port |
| 815 | * in a point-to-point topology. First, the @vport's N_Port Name is compared |
| 816 | * with the received N_Port Name: if the @vport's N_Port Name is greater than |
| 817 | * the received N_Port Name lexicographically, this node shall assign local |
| 818 | * N_Port ID (PT2PT_LocalID: 1) and remote N_Port ID (PT2PT_RemoteID: 2) and |
| 819 | * will send out Port Login (PLOGI) with the N_Port IDs assigned. Otherwise, |
| 820 | * this node shall just wait for the remote node to issue PLOGI and assign |
| 821 | * N_Port IDs. |
| 822 | * |
| 823 | * Return code |
| 824 | * 0 - Success |
| 825 | * -ENXIO - Fail |
| 826 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 827 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 828 | lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 829 | struct serv_parm *sp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 830 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 831 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 832 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 833 | LPFC_MBOXQ_t *mbox; |
| 834 | int rc; |
| 835 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 836 | spin_lock_irq(shost->host_lock); |
| 837 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 838 | vport->fc_flag |= FC_PT2PT; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 839 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 840 | |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 841 | /* If physical FC port changed, unreg VFI and ALL VPIs / RPIs */ |
| 842 | if ((phba->sli_rev == LPFC_SLI_REV4) && phba->fc_topology_changed) { |
| 843 | lpfc_unregister_fcf_prep(phba); |
| 844 | |
| 845 | spin_lock_irq(shost->host_lock); |
| 846 | vport->fc_flag &= ~FC_VFI_REGISTERED; |
| 847 | spin_unlock_irq(shost->host_lock); |
| 848 | phba->fc_topology_changed = 0; |
| 849 | } |
| 850 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 851 | rc = memcmp(&vport->fc_portname, &sp->portName, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 852 | sizeof(vport->fc_portname)); |
James Smart | 2eb6862 | 2012-09-29 11:32:27 -0400 | [diff] [blame] | 853 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 854 | if (rc >= 0) { |
| 855 | /* This side will initiate the PLOGI */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 856 | spin_lock_irq(shost->host_lock); |
| 857 | vport->fc_flag |= FC_PT2PT_PLOGI; |
| 858 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 859 | |
| 860 | /* |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 861 | * N_Port ID cannot be 0, set our Id to LocalID |
| 862 | * the other side will be RemoteID. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 863 | */ |
| 864 | |
| 865 | /* not equal */ |
| 866 | if (rc) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 867 | vport->fc_myDID = PT2PT_LocalID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 868 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 869 | /* Decrement ndlp reference count indicating that ndlp can be |
| 870 | * safely released when other references to it are done. |
| 871 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 872 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 873 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 874 | ndlp = lpfc_findnode_did(vport, PT2PT_RemoteID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 875 | if (!ndlp) { |
| 876 | /* |
| 877 | * Cannot find existing Fabric ndlp, so allocate a |
| 878 | * new one |
| 879 | */ |
| 880 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 881 | if (!ndlp) |
| 882 | goto fail; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 883 | lpfc_nlp_init(vport, ndlp, PT2PT_RemoteID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 884 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 885 | ndlp = lpfc_enable_node(vport, ndlp, |
| 886 | NLP_STE_UNUSED_NODE); |
| 887 | if(!ndlp) |
| 888 | goto fail; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 889 | } |
| 890 | |
| 891 | memcpy(&ndlp->nlp_portname, &sp->portName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 892 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 893 | memcpy(&ndlp->nlp_nodename, &sp->nodeName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 894 | sizeof(struct lpfc_name)); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 895 | /* Set state will put ndlp onto node list if not already done */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 896 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 897 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 898 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 899 | spin_unlock_irq(shost->host_lock); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 900 | } else |
| 901 | /* This side will wait for the PLOGI, decrement ndlp reference |
| 902 | * count indicating that ndlp can be released when other |
| 903 | * references to it are done. |
| 904 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 905 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 906 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 907 | /* If we are pt2pt with another NPort, force NPIV off! */ |
| 908 | phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; |
| 909 | |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 910 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 911 | if (!mbox) |
| 912 | goto fail; |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 913 | |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 914 | lpfc_config_link(phba, mbox); |
| 915 | |
| 916 | mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link; |
| 917 | mbox->vport = vport; |
| 918 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
| 919 | if (rc == MBX_NOT_FINISHED) { |
| 920 | mempool_free(mbox, phba->mbox_mem_pool); |
| 921 | goto fail; |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 922 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 923 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 924 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 925 | fail: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 926 | return -ENXIO; |
| 927 | } |
| 928 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 929 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 930 | * lpfc_cmpl_els_flogi - Completion callback function for flogi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 931 | * @phba: pointer to lpfc hba data structure. |
| 932 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 933 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 934 | * |
| 935 | * This routine is the top-level completion callback function for issuing |
| 936 | * a Fabric Login (FLOGI) command. If the response IOCB reported error, |
| 937 | * the lpfc_els_retry() routine shall be invoked to retry the FLOGI. If |
| 938 | * retry has been made (either immediately or delayed with lpfc_els_retry() |
| 939 | * returning 1), the command IOCB will be released and function returned. |
| 940 | * If the retry attempt has been given up (possibly reach the maximum |
| 941 | * number of retries), one additional decrement of ndlp reference shall be |
| 942 | * invoked before going out after releasing the command IOCB. This will |
| 943 | * actually release the remote node (Note, lpfc_els_free_iocb() will also |
| 944 | * invoke one decrement of ndlp reference count). If no error reported in |
| 945 | * the IOCB status, the command Port ID field is used to determine whether |
| 946 | * this is a point-to-point topology or a fabric topology: if the Port ID |
| 947 | * field is assigned, it is a fabric topology; otherwise, it is a |
| 948 | * point-to-point topology. The routine lpfc_cmpl_els_flogi_fabric() or |
| 949 | * lpfc_cmpl_els_flogi_nport() shall be invoked accordingly to handle the |
| 950 | * specific topology completion conditions. |
| 951 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 952 | static void |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 953 | lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 954 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 955 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 956 | struct lpfc_vport *vport = cmdiocb->vport; |
| 957 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 958 | IOCB_t *irsp = &rspiocb->iocb; |
| 959 | struct lpfc_nodelist *ndlp = cmdiocb->context1; |
| 960 | struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp; |
| 961 | struct serv_parm *sp; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 962 | uint16_t fcf_index; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 963 | int rc; |
| 964 | |
| 965 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 966 | if (lpfc_els_chk_latt(vport)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 967 | /* One additional decrement on node reference count to |
| 968 | * trigger the release of the node |
| 969 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 970 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 971 | goto out; |
| 972 | } |
| 973 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 974 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 975 | "FLOGI cmpl: status:x%x/x%x state:x%x", |
| 976 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 977 | vport->port_state); |
| 978 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 979 | if (irsp->ulpStatus) { |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 980 | /* |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 981 | * In case of FIP mode, perform roundrobin FCF failover |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 982 | * due to new FCF discovery |
| 983 | */ |
| 984 | if ((phba->hba_flag & HBA_FIP_SUPPORT) && |
James Smart | 80c1784 | 2012-03-01 22:35:45 -0500 | [diff] [blame] | 985 | (phba->fcf.fcf_flag & FCF_DISCOVERY)) { |
| 986 | if (phba->link_state < LPFC_LINK_UP) |
| 987 | goto stop_rr_fcf_flogi; |
| 988 | if ((phba->fcoe_cvl_eventtag_attn == |
| 989 | phba->fcoe_cvl_eventtag) && |
| 990 | (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 991 | ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) == |
| 992 | IOERR_SLI_ABORTED)) |
James Smart | 80c1784 | 2012-03-01 22:35:45 -0500 | [diff] [blame] | 993 | goto stop_rr_fcf_flogi; |
| 994 | else |
| 995 | phba->fcoe_cvl_eventtag_attn = |
| 996 | phba->fcoe_cvl_eventtag; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 997 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP | LOG_ELS, |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 998 | "2611 FLOGI failed on FCF (x%x), " |
| 999 | "status:x%x/x%x, tmo:x%x, perform " |
| 1000 | "roundrobin FCF failover\n", |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1001 | phba->fcf.current_rec.fcf_indx, |
| 1002 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1003 | irsp->ulpTimeout); |
James Smart | 7d791df | 2011-07-22 18:37:52 -0400 | [diff] [blame] | 1004 | lpfc_sli4_set_fcf_flogi_fail(phba, |
| 1005 | phba->fcf.current_rec.fcf_indx); |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1006 | fcf_index = lpfc_sli4_fcf_rr_next_index_get(phba); |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 1007 | rc = lpfc_sli4_fcf_rr_next_proc(vport, fcf_index); |
| 1008 | if (rc) |
| 1009 | goto out; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1010 | } |
| 1011 | |
James Smart | 80c1784 | 2012-03-01 22:35:45 -0500 | [diff] [blame] | 1012 | stop_rr_fcf_flogi: |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1013 | /* FLOGI failure */ |
| 1014 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | 8fe5c16 | 2015-08-31 16:48:19 -0400 | [diff] [blame] | 1015 | "2858 FLOGI failure Status:x%x/x%x TMO:x%x " |
| 1016 | "Data x%x x%x\n", |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1017 | irsp->ulpStatus, irsp->un.ulpWord[4], |
James Smart | 8fe5c16 | 2015-08-31 16:48:19 -0400 | [diff] [blame] | 1018 | irsp->ulpTimeout, phba->hba_flag, |
| 1019 | phba->fcf.fcf_flag); |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1020 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1021 | /* Check for retry */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1022 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1023 | goto out; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1024 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1025 | /* FLOGI failure */ |
| 1026 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1027 | "0100 FLOGI failure Status:x%x/x%x TMO:x%x\n", |
| 1028 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1029 | irsp->ulpTimeout); |
| 1030 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1031 | /* FLOGI failed, so there is no fabric */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1032 | spin_lock_irq(shost->host_lock); |
| 1033 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
| 1034 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1035 | |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 1036 | /* If private loop, then allow max outstanding els to be |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1037 | * LPFC_MAX_DISC_THREADS (32). Scanning in the case of no |
| 1038 | * alpa map would take too long otherwise. |
| 1039 | */ |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 1040 | if (phba->alpa_map[0] == 0) |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1041 | vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS; |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 1042 | if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 1043 | (!(vport->fc_flag & FC_VFI_REGISTERED) || |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 1044 | (vport->fc_prevDID != vport->fc_myDID) || |
| 1045 | phba->fc_topology_changed)) { |
| 1046 | if (vport->fc_flag & FC_VFI_REGISTERED) { |
| 1047 | if (phba->fc_topology_changed) { |
| 1048 | lpfc_unregister_fcf_prep(phba); |
| 1049 | spin_lock_irq(shost->host_lock); |
| 1050 | vport->fc_flag &= ~FC_VFI_REGISTERED; |
| 1051 | spin_unlock_irq(shost->host_lock); |
| 1052 | phba->fc_topology_changed = 0; |
| 1053 | } else { |
| 1054 | lpfc_sli4_unreg_all_rpis(vport); |
| 1055 | } |
| 1056 | } |
James Smart | ff78d8f | 2011-12-13 13:21:35 -0500 | [diff] [blame] | 1057 | lpfc_issue_reg_vfi(vport); |
| 1058 | lpfc_nlp_put(ndlp); |
| 1059 | goto out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1060 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1061 | goto flogifail; |
| 1062 | } |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 1063 | spin_lock_irq(shost->host_lock); |
| 1064 | vport->fc_flag &= ~FC_VPORT_CVL_RCVD; |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 1065 | vport->fc_flag &= ~FC_VPORT_LOGO_RCVD; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 1066 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1067 | |
| 1068 | /* |
| 1069 | * The FLogI succeeded. Sync the data for the CPU before |
| 1070 | * accessing it. |
| 1071 | */ |
| 1072 | prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list); |
James Smart | a2fc4aef | 2014-09-03 12:57:55 -0400 | [diff] [blame] | 1073 | if (!prsp) |
| 1074 | goto out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1075 | sp = prsp->virt + sizeof(uint32_t); |
| 1076 | |
| 1077 | /* FLOGI completes successfully */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1078 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
James Smart | 88f43a0 | 2013-04-17 20:19:44 -0400 | [diff] [blame] | 1079 | "0101 FLOGI completes successfully, I/O tag:x%x, " |
| 1080 | "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] | 1081 | irsp->un.ulpWord[4], sp->cmn.e_d_tov, |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 1082 | sp->cmn.w2.r_a_tov, sp->cmn.edtovResolution, |
| 1083 | vport->port_state, vport->fc_flag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1084 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1085 | if (vport->port_state == LPFC_FLOGI) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1086 | /* |
| 1087 | * If Common Service Parameters indicate Nport |
| 1088 | * we are point to point, if Fport we are Fabric. |
| 1089 | */ |
| 1090 | if (sp->cmn.fPort) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1091 | rc = lpfc_cmpl_els_flogi_fabric(vport, ndlp, sp, irsp); |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1092 | else if (!(phba->hba_flag & HBA_FCOE_MODE)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1093 | rc = lpfc_cmpl_els_flogi_nport(vport, ndlp, sp); |
James Smart | dbb6b3a | 2010-06-08 18:31:37 -0400 | [diff] [blame] | 1094 | else { |
| 1095 | lpfc_printf_vlog(vport, KERN_ERR, |
| 1096 | LOG_FIP | LOG_ELS, |
| 1097 | "2831 FLOGI response with cleared Fabric " |
| 1098 | "bit fcf_index 0x%x " |
| 1099 | "Switch Name %02x%02x%02x%02x%02x%02x%02x%02x " |
| 1100 | "Fabric Name " |
| 1101 | "%02x%02x%02x%02x%02x%02x%02x%02x\n", |
| 1102 | phba->fcf.current_rec.fcf_indx, |
| 1103 | phba->fcf.current_rec.switch_name[0], |
| 1104 | phba->fcf.current_rec.switch_name[1], |
| 1105 | phba->fcf.current_rec.switch_name[2], |
| 1106 | phba->fcf.current_rec.switch_name[3], |
| 1107 | phba->fcf.current_rec.switch_name[4], |
| 1108 | phba->fcf.current_rec.switch_name[5], |
| 1109 | phba->fcf.current_rec.switch_name[6], |
| 1110 | phba->fcf.current_rec.switch_name[7], |
| 1111 | phba->fcf.current_rec.fabric_name[0], |
| 1112 | phba->fcf.current_rec.fabric_name[1], |
| 1113 | phba->fcf.current_rec.fabric_name[2], |
| 1114 | phba->fcf.current_rec.fabric_name[3], |
| 1115 | phba->fcf.current_rec.fabric_name[4], |
| 1116 | phba->fcf.current_rec.fabric_name[5], |
| 1117 | phba->fcf.current_rec.fabric_name[6], |
| 1118 | phba->fcf.current_rec.fabric_name[7]); |
| 1119 | lpfc_nlp_put(ndlp); |
| 1120 | spin_lock_irq(&phba->hbalock); |
| 1121 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 1122 | phba->hba_flag &= ~(FCF_RR_INPROG | HBA_DEVLOSS_TMO); |
James Smart | dbb6b3a | 2010-06-08 18:31:37 -0400 | [diff] [blame] | 1123 | spin_unlock_irq(&phba->hbalock); |
| 1124 | goto out; |
| 1125 | } |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1126 | if (!rc) { |
| 1127 | /* Mark the FCF discovery process done */ |
James Smart | 999d813 | 2010-03-15 11:24:56 -0400 | [diff] [blame] | 1128 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 1129 | lpfc_printf_vlog(vport, KERN_INFO, LOG_FIP | |
| 1130 | LOG_ELS, |
James Smart | a93ff37 | 2010-10-22 11:06:08 -0400 | [diff] [blame] | 1131 | "2769 FLOGI to FCF (x%x) " |
| 1132 | "completed successfully\n", |
James Smart | 999d813 | 2010-03-15 11:24:56 -0400 | [diff] [blame] | 1133 | phba->fcf.current_rec.fcf_indx); |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 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 | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1137 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1138 | goto out; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 1139 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1140 | } |
| 1141 | |
| 1142 | flogifail: |
James Smart | 8fe5c16 | 2015-08-31 16:48:19 -0400 | [diff] [blame] | 1143 | spin_lock_irq(&phba->hbalock); |
| 1144 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; |
| 1145 | spin_unlock_irq(&phba->hbalock); |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 1146 | |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 1147 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1148 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1149 | if (!lpfc_error_lost_link(irsp)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1150 | /* FLOGI failed, so just use loop map to make discovery list */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1151 | lpfc_disc_list_loopmap(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1152 | |
| 1153 | /* Start discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1154 | lpfc_disc_start(vport); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1155 | } else if (((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 1156 | (((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) != |
| 1157 | IOERR_SLI_ABORTED) && |
| 1158 | ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) != |
| 1159 | IOERR_SLI_DOWN))) && |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1160 | (phba->link_state != LPFC_CLEAR_LA)) { |
| 1161 | /* If FLOGI failed enable link interrupt. */ |
| 1162 | lpfc_issue_clear_la(phba, vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1163 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1164 | out: |
| 1165 | lpfc_els_free_iocb(phba, cmdiocb); |
| 1166 | } |
| 1167 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1168 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1169 | * lpfc_issue_els_flogi - Issue an flogi iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1170 | * @vport: pointer to a host virtual N_Port data structure. |
| 1171 | * @ndlp: pointer to a node-list data structure. |
| 1172 | * @retry: number of retries to the command IOCB. |
| 1173 | * |
| 1174 | * This routine issues a Fabric Login (FLOGI) Request ELS command |
| 1175 | * for a @vport. The initiator service parameters are put into the payload |
| 1176 | * of the FLOGI Request IOCB and the top-level callback function pointer |
| 1177 | * to lpfc_cmpl_els_flogi() routine is put to the IOCB completion callback |
| 1178 | * function field. The lpfc_issue_fabric_iocb routine is invoked to send |
| 1179 | * out FLOGI ELS command with one outstanding fabric IOCB at a time. |
| 1180 | * |
| 1181 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 1182 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 1183 | * will be stored into the context1 field of the IOCB for the completion |
| 1184 | * callback function to the FLOGI ELS command. |
| 1185 | * |
| 1186 | * Return code |
| 1187 | * 0 - successfully issued flogi iocb for @vport |
| 1188 | * 1 - failed to issue flogi iocb for @vport |
| 1189 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1190 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1191 | lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1192 | uint8_t retry) |
| 1193 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1194 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1195 | struct serv_parm *sp; |
| 1196 | IOCB_t *icmd; |
| 1197 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1198 | uint8_t *pcmd; |
| 1199 | uint16_t cmdsize; |
| 1200 | uint32_t tmo; |
| 1201 | int rc; |
| 1202 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1203 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1204 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 1205 | ndlp->nlp_DID, ELS_CMD_FLOGI); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1206 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1207 | if (!elsiocb) |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1208 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1209 | |
| 1210 | icmd = &elsiocb->iocb; |
| 1211 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 1212 | |
| 1213 | /* For FLOGI request, remainder of payload is service parameters */ |
| 1214 | *((uint32_t *) (pcmd)) = ELS_CMD_FLOGI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1215 | pcmd += sizeof(uint32_t); |
| 1216 | memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1217 | sp = (struct serv_parm *) pcmd; |
| 1218 | |
| 1219 | /* Setup CSPs accordingly for Fabric */ |
| 1220 | sp->cmn.e_d_tov = 0; |
| 1221 | sp->cmn.w2.r_a_tov = 0; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 1222 | sp->cmn.virtual_fabric_support = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1223 | sp->cls1.classValid = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1224 | if (sp->cmn.fcphLow < FC_PH3) |
| 1225 | sp->cmn.fcphLow = FC_PH3; |
| 1226 | if (sp->cmn.fcphHigh < FC_PH3) |
| 1227 | sp->cmn.fcphHigh = FC_PH3; |
| 1228 | |
James Smart | c31098c | 2011-04-16 11:03:33 -0400 | [diff] [blame] | 1229 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1230 | if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == |
| 1231 | LPFC_SLI_INTF_IF_TYPE_0) { |
| 1232 | elsiocb->iocb.ulpCt_h = ((SLI4_CT_FCFI >> 1) & 1); |
| 1233 | elsiocb->iocb.ulpCt_l = (SLI4_CT_FCFI & 1); |
| 1234 | /* FLOGI needs to be 3 for WQE FCFI */ |
| 1235 | /* Set the fcfi to the fcfi we registered with */ |
| 1236 | elsiocb->iocb.ulpContext = phba->fcf.fcfi; |
| 1237 | } |
James Smart | 0f37887 | 2012-10-31 14:45:01 -0400 | [diff] [blame] | 1238 | /* Can't do SLI4 class2 without support sequence coalescing */ |
| 1239 | sp->cls2.classValid = 0; |
| 1240 | sp->cls2.seqDelivery = 0; |
James Smart | 5248a74 | 2011-07-22 18:37:06 -0400 | [diff] [blame] | 1241 | } else { |
James Smart | 0f37887 | 2012-10-31 14:45:01 -0400 | [diff] [blame] | 1242 | /* Historical, setting sequential-delivery bit for SLI3 */ |
| 1243 | sp->cls2.seqDelivery = (sp->cls2.classValid) ? 1 : 0; |
| 1244 | sp->cls3.seqDelivery = (sp->cls3.classValid) ? 1 : 0; |
James Smart | 5248a74 | 2011-07-22 18:37:06 -0400 | [diff] [blame] | 1245 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
| 1246 | sp->cmn.request_multiple_Nport = 1; |
| 1247 | /* For FLOGI, Let FLOGI rsp set the NPortID for VPI 0 */ |
| 1248 | icmd->ulpCt_h = 1; |
| 1249 | icmd->ulpCt_l = 0; |
| 1250 | } else |
| 1251 | sp->cmn.request_multiple_Nport = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1252 | } |
| 1253 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1254 | if (phba->fc_topology != LPFC_TOPOLOGY_LOOP) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1255 | icmd->un.elsreq64.myID = 0; |
| 1256 | icmd->un.elsreq64.fl = 1; |
| 1257 | } |
| 1258 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1259 | tmo = phba->fc_ratov; |
| 1260 | phba->fc_ratov = LPFC_DISC_FLOGI_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1261 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1262 | phba->fc_ratov = tmo; |
| 1263 | |
| 1264 | phba->fc_stat.elsXmitFLOGI++; |
| 1265 | elsiocb->iocb_cmpl = lpfc_cmpl_els_flogi; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1266 | |
| 1267 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1268 | "Issue FLOGI: opt:x%x", |
| 1269 | phba->sli3_options, 0, 0); |
| 1270 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1271 | rc = lpfc_issue_fabric_iocb(phba, elsiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1272 | if (rc == IOCB_ERROR) { |
| 1273 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1274 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1275 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1276 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1277 | } |
| 1278 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1279 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1280 | * lpfc_els_abort_flogi - Abort all outstanding flogi iocbs |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1281 | * @phba: pointer to lpfc hba data structure. |
| 1282 | * |
| 1283 | * This routine aborts all the outstanding Fabric Login (FLOGI) IOCBs |
| 1284 | * with a @phba. This routine walks all the outstanding IOCBs on the txcmplq |
| 1285 | * list and issues an abort IOCB commond on each outstanding IOCB that |
| 1286 | * contains a active Fabric_DID ndlp. Note that this function is to issue |
| 1287 | * the abort IOCB command on all the outstanding IOCBs, thus when this |
| 1288 | * function returns, it does not guarantee all the IOCBs are actually aborted. |
| 1289 | * |
| 1290 | * Return code |
Daniel Mack | 3ad2f3fb | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 1291 | * 0 - Successfully issued abort iocb on all outstanding flogis (Always 0) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1292 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1293 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1294 | lpfc_els_abort_flogi(struct lpfc_hba *phba) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1295 | { |
| 1296 | struct lpfc_sli_ring *pring; |
| 1297 | struct lpfc_iocbq *iocb, *next_iocb; |
| 1298 | struct lpfc_nodelist *ndlp; |
| 1299 | IOCB_t *icmd; |
| 1300 | |
| 1301 | /* Abort outstanding I/O on NPort <nlp_DID> */ |
| 1302 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1303 | "0201 Abort outstanding I/O on NPort x%x\n", |
| 1304 | Fabric_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1305 | |
| 1306 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
| 1307 | |
| 1308 | /* |
| 1309 | * Check the txcmplq for an iocb that matches the nport the driver is |
| 1310 | * searching for. |
| 1311 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1312 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1313 | list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) { |
| 1314 | icmd = &iocb->iocb; |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 1315 | if (icmd->ulpCommand == CMD_ELS_REQUEST64_CR) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1316 | ndlp = (struct lpfc_nodelist *)(iocb->context1); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1317 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 1318 | (ndlp->nlp_DID == Fabric_DID)) |
James Smart | 0795107 | 2007-04-25 09:51:38 -0400 | [diff] [blame] | 1319 | lpfc_sli_issue_abort_iotag(phba, pring, iocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1320 | } |
| 1321 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1322 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1323 | |
| 1324 | return 0; |
| 1325 | } |
| 1326 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1327 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1328 | * lpfc_initial_flogi - Issue an initial fabric login for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1329 | * @vport: pointer to a host virtual N_Port data structure. |
| 1330 | * |
| 1331 | * This routine issues an initial Fabric Login (FLOGI) for the @vport |
| 1332 | * specified. It first searches the ndlp with the Fabric_DID (0xfffffe) from |
| 1333 | * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and |
| 1334 | * put it into the @vport's ndlp list. If an inactive ndlp found on the list, |
| 1335 | * it will just be enabled and made active. The lpfc_issue_els_flogi() routine |
| 1336 | * is then invoked with the @vport and the ndlp to perform the FLOGI for the |
| 1337 | * @vport. |
| 1338 | * |
| 1339 | * Return code |
| 1340 | * 0 - failed to issue initial flogi for @vport |
| 1341 | * 1 - successfully issued initial flogi for @vport |
| 1342 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1343 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1344 | lpfc_initial_flogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1345 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1346 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1347 | struct lpfc_nodelist *ndlp; |
| 1348 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1349 | vport->port_state = LPFC_FLOGI; |
| 1350 | lpfc_set_disctmo(vport); |
| 1351 | |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1352 | /* First look for the Fabric ndlp */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1353 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1354 | if (!ndlp) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1355 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1356 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 1357 | if (!ndlp) |
| 1358 | return 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1359 | lpfc_nlp_init(vport, ndlp, Fabric_DID); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 1360 | /* Set the node type */ |
| 1361 | ndlp->nlp_type |= NLP_FABRIC; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1362 | /* Put ndlp onto node list */ |
| 1363 | lpfc_enqueue_node(vport, ndlp); |
| 1364 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 1365 | /* re-setup ndlp without removing from node list */ |
| 1366 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 1367 | if (!ndlp) |
| 1368 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1369 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1370 | |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 1371 | if (lpfc_issue_els_flogi(vport, ndlp, 0)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1372 | /* This decrement of reference count to node shall kick off |
| 1373 | * the release of the node. |
| 1374 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 1375 | lpfc_nlp_put(ndlp); |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 1376 | return 0; |
| 1377 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1378 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1379 | } |
| 1380 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1381 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1382 | * lpfc_initial_fdisc - Issue an initial fabric discovery for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1383 | * @vport: pointer to a host virtual N_Port data structure. |
| 1384 | * |
| 1385 | * This routine issues an initial Fabric Discover (FDISC) for the @vport |
| 1386 | * specified. It first searches the ndlp with the Fabric_DID (0xfffffe) from |
| 1387 | * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and |
| 1388 | * put it into the @vport's ndlp list. If an inactive ndlp found on the list, |
| 1389 | * it will just be enabled and made active. The lpfc_issue_els_fdisc() routine |
| 1390 | * is then invoked with the @vport and the ndlp to perform the FDISC for the |
| 1391 | * @vport. |
| 1392 | * |
| 1393 | * Return code |
| 1394 | * 0 - failed to issue initial fdisc for @vport |
| 1395 | * 1 - successfully issued initial fdisc for @vport |
| 1396 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1397 | int |
| 1398 | lpfc_initial_fdisc(struct lpfc_vport *vport) |
| 1399 | { |
| 1400 | struct lpfc_hba *phba = vport->phba; |
| 1401 | struct lpfc_nodelist *ndlp; |
| 1402 | |
| 1403 | /* First look for the Fabric ndlp */ |
| 1404 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
| 1405 | if (!ndlp) { |
| 1406 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
| 1407 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 1408 | if (!ndlp) |
| 1409 | return 0; |
| 1410 | lpfc_nlp_init(vport, ndlp, Fabric_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1411 | /* Put ndlp onto node list */ |
| 1412 | lpfc_enqueue_node(vport, ndlp); |
| 1413 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 1414 | /* re-setup ndlp without removing from node list */ |
| 1415 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 1416 | if (!ndlp) |
| 1417 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1418 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1419 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1420 | if (lpfc_issue_els_fdisc(vport, ndlp, 0)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1421 | /* decrement node reference count to trigger the release of |
| 1422 | * the node. |
| 1423 | */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1424 | lpfc_nlp_put(ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1425 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1426 | } |
| 1427 | return 1; |
| 1428 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1429 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1430 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1431 | * lpfc_more_plogi - Check and issue remaining plogis for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1432 | * @vport: pointer to a host virtual N_Port data structure. |
| 1433 | * |
| 1434 | * This routine checks whether there are more remaining Port Logins |
| 1435 | * (PLOGI) to be issued for the @vport. If so, it will invoke the routine |
| 1436 | * lpfc_els_disc_plogi() to go through the Node Port Recovery (NPR) nodes |
| 1437 | * to issue ELS PLOGIs up to the configured discover threads with the |
| 1438 | * @vport (@vport->cfg_discovery_threads). The function also decrement |
| 1439 | * the @vport's num_disc_node by 1 if it is not already 0. |
| 1440 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1441 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1442 | lpfc_more_plogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1443 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1444 | if (vport->num_disc_nodes) |
| 1445 | vport->num_disc_nodes--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1446 | |
| 1447 | /* Continue discovery with <num_disc_nodes> PLOGIs to go */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1448 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1449 | "0232 Continue discovery with %d PLOGIs to go " |
| 1450 | "Data: x%x x%x x%x\n", |
| 1451 | vport->num_disc_nodes, vport->fc_plogi_cnt, |
| 1452 | vport->fc_flag, vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1453 | /* Check to see if there are more PLOGIs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1454 | if (vport->fc_flag & FC_NLP_MORE) |
| 1455 | /* go thru NPR nodes and issue any remaining ELS PLOGIs */ |
Sebastian Herbszt | db6f1c2 | 2015-08-31 16:48:14 -0400 | [diff] [blame] | 1456 | lpfc_els_disc_plogi(vport); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1457 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1458 | return; |
| 1459 | } |
| 1460 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1461 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1462 | * lpfc_plogi_confirm_nport - Confirm pologi wwpn matches stored ndlp |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1463 | * @phba: pointer to lpfc hba data structure. |
| 1464 | * @prsp: pointer to response IOCB payload. |
| 1465 | * @ndlp: pointer to a node-list data structure. |
| 1466 | * |
| 1467 | * This routine checks and indicates whether the WWPN of an N_Port, retrieved |
| 1468 | * from a PLOGI, matches the WWPN that is stored in the @ndlp for that N_POrt. |
| 1469 | * The following cases are considered N_Port confirmed: |
| 1470 | * 1) The N_Port is a Fabric ndlp; 2) The @ndlp is on vport list and matches |
| 1471 | * the WWPN of the N_Port logged into; 3) The @ndlp is not on vport list but |
| 1472 | * it does not have WWPN assigned either. If the WWPN is confirmed, the |
| 1473 | * pointer to the @ndlp will be returned. If the WWPN is not confirmed: |
| 1474 | * 1) if there is a node on vport list other than the @ndlp with the same |
| 1475 | * WWPN of the N_Port PLOGI logged into, the lpfc_unreg_rpi() will be invoked |
| 1476 | * on that node to release the RPI associated with the node; 2) if there is |
| 1477 | * no node found on vport list with the same WWPN of the N_Port PLOGI logged |
| 1478 | * into, a new node shall be allocated (or activated). In either case, the |
| 1479 | * parameters of the @ndlp shall be copied to the new_ndlp, the @ndlp shall |
| 1480 | * be released and the new_ndlp shall be put on to the vport node list and |
| 1481 | * its pointer returned as the confirmed node. |
| 1482 | * |
| 1483 | * Note that before the @ndlp got "released", the keepDID from not-matching |
| 1484 | * or inactive "new_ndlp" on the vport node list is assigned to the nlp_DID |
| 1485 | * of the @ndlp. This is because the release of @ndlp is actually to put it |
| 1486 | * into an inactive state on the vport node list and the vport node list |
| 1487 | * management algorithm does not allow two node with a same DID. |
| 1488 | * |
| 1489 | * Return code |
| 1490 | * pointer to the PLOGI N_Port @ndlp |
| 1491 | **/ |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1492 | static struct lpfc_nodelist * |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1493 | lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1494 | struct lpfc_nodelist *ndlp) |
| 1495 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1496 | struct lpfc_vport *vport = ndlp->vport; |
James Smart | 953ceed | 2015-05-22 10:42:37 -0400 | [diff] [blame] | 1497 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1498 | struct lpfc_nodelist *new_ndlp; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1499 | struct lpfc_rport_data *rdata; |
| 1500 | struct fc_rport *rport; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1501 | struct serv_parm *sp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1502 | uint8_t name[sizeof(struct lpfc_name)]; |
James Smart | e5abba4 | 2015-05-21 13:55:27 -0400 | [diff] [blame] | 1503 | uint32_t rc, keepDID = 0, keep_nlp_flag = 0; |
James Smart | 953ceed | 2015-05-22 10:42:37 -0400 | [diff] [blame] | 1504 | uint16_t keep_nlp_state; |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1505 | int put_node; |
| 1506 | int put_rport; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1507 | unsigned long *active_rrqs_xri_bitmap = NULL; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1508 | |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1509 | /* Fabric nodes can have the same WWPN so we don't bother searching |
| 1510 | * by WWPN. Just return the ndlp that was given to us. |
| 1511 | */ |
| 1512 | if (ndlp->nlp_type & NLP_FABRIC) |
| 1513 | return ndlp; |
| 1514 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1515 | sp = (struct serv_parm *) ((uint8_t *) prsp + sizeof(uint32_t)); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 1516 | memset(name, 0, sizeof(struct lpfc_name)); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1517 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 1518 | /* 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] | 1519 | * we have for that ndlp. If not, we have some work to do. |
| 1520 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1521 | new_ndlp = lpfc_findnode_wwpn(vport, &sp->portName); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1522 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1523 | if (new_ndlp == ndlp && NLP_CHK_NODE_ACT(new_ndlp)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1524 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1525 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1526 | active_rrqs_xri_bitmap = mempool_alloc(phba->active_rrq_pool, |
| 1527 | GFP_KERNEL); |
| 1528 | if (active_rrqs_xri_bitmap) |
| 1529 | memset(active_rrqs_xri_bitmap, 0, |
| 1530 | phba->cfg_rrq_xri_bitmap_sz); |
| 1531 | } |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1532 | |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1533 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1534 | "3178 PLOGI confirm: ndlp %p x%x: new_ndlp %p\n", |
| 1535 | ndlp, ndlp->nlp_DID, new_ndlp); |
| 1536 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1537 | if (!new_ndlp) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1538 | rc = memcmp(&ndlp->nlp_portname, name, |
| 1539 | sizeof(struct lpfc_name)); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1540 | if (!rc) { |
| 1541 | if (active_rrqs_xri_bitmap) |
| 1542 | mempool_free(active_rrqs_xri_bitmap, |
| 1543 | phba->active_rrq_pool); |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1544 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1545 | } |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1546 | new_ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_ATOMIC); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1547 | if (!new_ndlp) { |
| 1548 | if (active_rrqs_xri_bitmap) |
| 1549 | mempool_free(active_rrqs_xri_bitmap, |
| 1550 | phba->active_rrq_pool); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1551 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1552 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1553 | lpfc_nlp_init(vport, new_ndlp, ndlp->nlp_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1554 | } else if (!NLP_CHK_NODE_ACT(new_ndlp)) { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1555 | rc = memcmp(&ndlp->nlp_portname, name, |
| 1556 | sizeof(struct lpfc_name)); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1557 | if (!rc) { |
| 1558 | if (active_rrqs_xri_bitmap) |
| 1559 | mempool_free(active_rrqs_xri_bitmap, |
| 1560 | phba->active_rrq_pool); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1561 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1562 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1563 | new_ndlp = lpfc_enable_node(vport, new_ndlp, |
| 1564 | NLP_STE_UNUSED_NODE); |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1565 | if (!new_ndlp) { |
| 1566 | if (active_rrqs_xri_bitmap) |
| 1567 | mempool_free(active_rrqs_xri_bitmap, |
| 1568 | phba->active_rrq_pool); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1569 | return ndlp; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1570 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1571 | keepDID = new_ndlp->nlp_DID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1572 | if ((phba->sli_rev == LPFC_SLI_REV4) && active_rrqs_xri_bitmap) |
| 1573 | memcpy(active_rrqs_xri_bitmap, |
| 1574 | new_ndlp->active_rrqs_xri_bitmap, |
| 1575 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1576 | } else { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1577 | keepDID = new_ndlp->nlp_DID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1578 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1579 | active_rrqs_xri_bitmap) |
| 1580 | memcpy(active_rrqs_xri_bitmap, |
| 1581 | new_ndlp->active_rrqs_xri_bitmap, |
| 1582 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1583 | } |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1584 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1585 | lpfc_unreg_rpi(vport, new_ndlp); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1586 | new_ndlp->nlp_DID = ndlp->nlp_DID; |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1587 | new_ndlp->nlp_prev_state = ndlp->nlp_prev_state; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1588 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1589 | memcpy(new_ndlp->active_rrqs_xri_bitmap, |
| 1590 | ndlp->active_rrqs_xri_bitmap, |
| 1591 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1592 | |
James Smart | 953ceed | 2015-05-22 10:42:37 -0400 | [diff] [blame] | 1593 | spin_lock_irq(shost->host_lock); |
James Smart | e5abba4 | 2015-05-21 13:55:27 -0400 | [diff] [blame] | 1594 | keep_nlp_flag = new_ndlp->nlp_flag; |
| 1595 | new_ndlp->nlp_flag = ndlp->nlp_flag; |
| 1596 | ndlp->nlp_flag = keep_nlp_flag; |
James Smart | 953ceed | 2015-05-22 10:42:37 -0400 | [diff] [blame] | 1597 | spin_unlock_irq(shost->host_lock); |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1598 | |
James Smart | 953ceed | 2015-05-22 10:42:37 -0400 | [diff] [blame] | 1599 | /* Set nlp_states accordingly */ |
| 1600 | keep_nlp_state = new_ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1601 | lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1602 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1603 | /* Move this back to NPR state */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1604 | if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0) { |
| 1605 | /* The new_ndlp is replacing ndlp totally, so we need |
| 1606 | * to put ndlp on UNUSED list and try to free it. |
| 1607 | */ |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1608 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1609 | "3179 PLOGI confirm NEW: %x %x\n", |
| 1610 | new_ndlp->nlp_DID, keepDID); |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1611 | |
| 1612 | /* Fix up the rport accordingly */ |
| 1613 | rport = ndlp->rport; |
| 1614 | if (rport) { |
| 1615 | rdata = rport->dd_data; |
| 1616 | if (rdata->pnode == ndlp) { |
James Smart | 466e840 | 2015-05-21 13:55:28 -0400 | [diff] [blame] | 1617 | /* break the link before dropping the ref */ |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1618 | ndlp->rport = NULL; |
James Smart | 466e840 | 2015-05-21 13:55:28 -0400 | [diff] [blame] | 1619 | lpfc_nlp_put(ndlp); |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1620 | rdata->pnode = lpfc_nlp_get(new_ndlp); |
| 1621 | new_ndlp->rport = rport; |
| 1622 | } |
| 1623 | new_ndlp->nlp_type = ndlp->nlp_type; |
| 1624 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1625 | /* We shall actually free the ndlp with both nlp_DID and |
| 1626 | * nlp_portname fields equals 0 to avoid any ndlp on the |
| 1627 | * nodelist never to be used. |
| 1628 | */ |
| 1629 | if (ndlp->nlp_DID == 0) { |
| 1630 | spin_lock_irq(&phba->ndlp_lock); |
| 1631 | NLP_SET_FREE_REQ(ndlp); |
| 1632 | spin_unlock_irq(&phba->ndlp_lock); |
| 1633 | } |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1634 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1635 | /* Two ndlps cannot have the same did on the nodelist */ |
| 1636 | ndlp->nlp_DID = keepDID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1637 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1638 | active_rrqs_xri_bitmap) |
| 1639 | memcpy(ndlp->active_rrqs_xri_bitmap, |
| 1640 | active_rrqs_xri_bitmap, |
| 1641 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | e5abba4 | 2015-05-21 13:55:27 -0400 | [diff] [blame] | 1642 | |
| 1643 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 1644 | lpfc_drop_node(vport, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1645 | } |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1646 | else { |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1647 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1648 | "3180 PLOGI confirm SWAP: %x %x\n", |
| 1649 | new_ndlp->nlp_DID, keepDID); |
| 1650 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1651 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1652 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1653 | /* Two ndlps cannot have the same did */ |
| 1654 | ndlp->nlp_DID = keepDID; |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1655 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1656 | active_rrqs_xri_bitmap) |
| 1657 | memcpy(ndlp->active_rrqs_xri_bitmap, |
| 1658 | active_rrqs_xri_bitmap, |
| 1659 | phba->cfg_rrq_xri_bitmap_sz); |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1660 | |
James Smart | 953ceed | 2015-05-22 10:42:37 -0400 | [diff] [blame] | 1661 | /* Since we are switching over to the new_ndlp, |
| 1662 | * reset the old ndlp state |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1663 | */ |
| 1664 | if ((ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) || |
| 1665 | (ndlp->nlp_state == NLP_STE_MAPPED_NODE)) |
James Smart | 953ceed | 2015-05-22 10:42:37 -0400 | [diff] [blame] | 1666 | keep_nlp_state = NLP_STE_NPR_NODE; |
| 1667 | lpfc_nlp_set_state(vport, ndlp, keep_nlp_state); |
James Smart | 34f5ad8 | 2012-08-03 12:35:03 -0400 | [diff] [blame] | 1668 | |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1669 | /* Fix up the rport accordingly */ |
| 1670 | rport = ndlp->rport; |
| 1671 | if (rport) { |
| 1672 | rdata = rport->dd_data; |
| 1673 | put_node = rdata->pnode != NULL; |
| 1674 | put_rport = ndlp->rport != NULL; |
| 1675 | rdata->pnode = NULL; |
| 1676 | ndlp->rport = NULL; |
| 1677 | if (put_node) |
| 1678 | lpfc_nlp_put(ndlp); |
| 1679 | if (put_rport) |
| 1680 | put_device(&rport->dev); |
| 1681 | } |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1682 | } |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 1683 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 1684 | active_rrqs_xri_bitmap) |
| 1685 | mempool_free(active_rrqs_xri_bitmap, |
| 1686 | phba->active_rrq_pool); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1687 | return new_ndlp; |
| 1688 | } |
| 1689 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1690 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1691 | * lpfc_end_rscn - Check and handle more rscn for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1692 | * @vport: pointer to a host virtual N_Port data structure. |
| 1693 | * |
| 1694 | * This routine checks whether more Registration State Change |
| 1695 | * Notifications (RSCNs) came in while the discovery state machine was in |
| 1696 | * the FC_RSCN_MODE. If so, the lpfc_els_handle_rscn() routine will be |
| 1697 | * invoked to handle the additional RSCNs for the @vport. Otherwise, the |
| 1698 | * FC_RSCN_MODE bit will be cleared with the @vport to mark as the end of |
| 1699 | * handling the RSCNs. |
| 1700 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1701 | void |
| 1702 | lpfc_end_rscn(struct lpfc_vport *vport) |
| 1703 | { |
| 1704 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 1705 | |
| 1706 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 1707 | /* |
| 1708 | * Check to see if more RSCNs came in while we were |
| 1709 | * processing this one. |
| 1710 | */ |
| 1711 | if (vport->fc_rscn_id_cnt || |
| 1712 | (vport->fc_flag & FC_RSCN_DISCOVERY) != 0) |
| 1713 | lpfc_els_handle_rscn(vport); |
| 1714 | else { |
| 1715 | spin_lock_irq(shost->host_lock); |
| 1716 | vport->fc_flag &= ~FC_RSCN_MODE; |
| 1717 | spin_unlock_irq(shost->host_lock); |
| 1718 | } |
| 1719 | } |
| 1720 | } |
| 1721 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1722 | /** |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 1723 | * lpfc_cmpl_els_rrq - Completion handled for els RRQs. |
| 1724 | * @phba: pointer to lpfc hba data structure. |
| 1725 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 1726 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 1727 | * |
| 1728 | * This routine will call the clear rrq function to free the rrq and |
| 1729 | * clear the xri's bit in the ndlp's xri_bitmap. If the ndlp does not |
| 1730 | * exist then the clear_rrq is still called because the rrq needs to |
| 1731 | * be freed. |
| 1732 | **/ |
| 1733 | |
| 1734 | static void |
| 1735 | lpfc_cmpl_els_rrq(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1736 | struct lpfc_iocbq *rspiocb) |
| 1737 | { |
| 1738 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1739 | IOCB_t *irsp; |
| 1740 | struct lpfc_nodelist *ndlp; |
| 1741 | struct lpfc_node_rrq *rrq; |
| 1742 | |
| 1743 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 1744 | rrq = cmdiocb->context_un.rrq; |
| 1745 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 1746 | |
| 1747 | irsp = &rspiocb->iocb; |
| 1748 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1749 | "RRQ cmpl: status:x%x/x%x did:x%x", |
| 1750 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1751 | irsp->un.elsreq64.remoteID); |
| 1752 | |
| 1753 | ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); |
| 1754 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) || ndlp != rrq->ndlp) { |
| 1755 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1756 | "2882 RRQ completes to NPort x%x " |
| 1757 | "with no ndlp. Data: x%x x%x x%x\n", |
| 1758 | irsp->un.elsreq64.remoteID, |
| 1759 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1760 | irsp->ulpIoTag); |
| 1761 | goto out; |
| 1762 | } |
| 1763 | |
| 1764 | /* rrq completes to NPort <nlp_DID> */ |
| 1765 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1766 | "2880 RRQ completes to NPort x%x " |
| 1767 | "Data: x%x x%x x%x x%x x%x\n", |
| 1768 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1769 | irsp->ulpTimeout, rrq->xritag, rrq->rxid); |
| 1770 | |
| 1771 | if (irsp->ulpStatus) { |
| 1772 | /* Check for retry */ |
| 1773 | /* RRQ failed Don't print the vport to vport rjts */ |
| 1774 | if (irsp->ulpStatus != IOSTAT_LS_RJT || |
| 1775 | (((irsp->un.ulpWord[4]) >> 16 != LSRJT_INVALID_CMD) && |
| 1776 | ((irsp->un.ulpWord[4]) >> 16 != LSRJT_UNABLE_TPC)) || |
| 1777 | (phba)->pport->cfg_log_verbose & LOG_ELS) |
| 1778 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1779 | "2881 RRQ failure DID:%06X Status:x%x/x%x\n", |
| 1780 | ndlp->nlp_DID, irsp->ulpStatus, |
| 1781 | irsp->un.ulpWord[4]); |
| 1782 | } |
| 1783 | out: |
| 1784 | if (rrq) |
| 1785 | lpfc_clr_rrq_active(phba, rrq->xritag, rrq); |
| 1786 | lpfc_els_free_iocb(phba, cmdiocb); |
| 1787 | return; |
| 1788 | } |
| 1789 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1790 | * lpfc_cmpl_els_plogi - Completion callback function for plogi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1791 | * @phba: pointer to lpfc hba data structure. |
| 1792 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 1793 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 1794 | * |
| 1795 | * This routine is the completion callback function for issuing the Port |
| 1796 | * Login (PLOGI) command. For PLOGI completion, there must be an active |
| 1797 | * 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] | 1798 | * 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] | 1799 | * ignored and command IOCB released. The PLOGI response IOCB status is |
| 1800 | * checked for error conditons. If there is error status reported, PLOGI |
| 1801 | * retry shall be attempted by invoking the lpfc_els_retry() routine. |
| 1802 | * Otherwise, the lpfc_plogi_confirm_nport() routine shall be invoked on |
| 1803 | * the ndlp and the NLP_EVT_CMPL_PLOGI state to the Discover State Machine |
| 1804 | * (DSM) is set for this PLOGI completion. Finally, it checks whether |
| 1805 | * there are additional N_Port nodes with the vport that need to perform |
| 1806 | * PLOGI. If so, the lpfc_more_plogi() routine is invoked to issue addition |
| 1807 | * PLOGIs. |
| 1808 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1809 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1810 | lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1811 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1812 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1813 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1814 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1815 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1816 | struct lpfc_nodelist *ndlp; |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1817 | struct lpfc_dmabuf *prsp; |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 1818 | int disc, rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1819 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1820 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 1821 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 1822 | |
| 1823 | irsp = &rspiocb->iocb; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1824 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1825 | "PLOGI cmpl: status:x%x/x%x did:x%x", |
| 1826 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1827 | irsp->un.elsreq64.remoteID); |
| 1828 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1829 | ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1830 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1831 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1832 | "0136 PLOGI completes to NPort x%x " |
| 1833 | "with no ndlp. Data: x%x x%x x%x\n", |
| 1834 | irsp->un.elsreq64.remoteID, |
| 1835 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1836 | irsp->ulpIoTag); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1837 | goto out; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 1838 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1839 | |
| 1840 | /* Since ndlp can be freed in the disc state machine, note if this node |
| 1841 | * is being used during discovery. |
| 1842 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1843 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1844 | disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1845 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1846 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1847 | rc = 0; |
| 1848 | |
| 1849 | /* PLOGI completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1850 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1851 | "0102 PLOGI completes to NPort x%x " |
| 1852 | "Data: x%x x%x x%x x%x x%x\n", |
| 1853 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1854 | irsp->ulpTimeout, disc, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1855 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1856 | if (lpfc_els_chk_latt(vport)) { |
| 1857 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1858 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1859 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1860 | goto out; |
| 1861 | } |
| 1862 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1863 | if (irsp->ulpStatus) { |
| 1864 | /* Check for retry */ |
| 1865 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 1866 | /* ELS command is being retried */ |
| 1867 | if (disc) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1868 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1869 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1870 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1871 | } |
| 1872 | goto out; |
| 1873 | } |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 1874 | /* PLOGI failed Don't print the vport to vport rjts */ |
| 1875 | if (irsp->ulpStatus != IOSTAT_LS_RJT || |
| 1876 | (((irsp->un.ulpWord[4]) >> 16 != LSRJT_INVALID_CMD) && |
| 1877 | ((irsp->un.ulpWord[4]) >> 16 != LSRJT_UNABLE_TPC)) || |
| 1878 | (phba)->pport->cfg_log_verbose & LOG_ELS) |
| 1879 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 1880 | "2753 PLOGI failure DID:%06X Status:x%x/x%x\n", |
| 1881 | ndlp->nlp_DID, irsp->ulpStatus, |
| 1882 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1883 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1884 | if (lpfc_error_lost_link(irsp)) |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1885 | rc = NLP_STE_FREED_NODE; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1886 | else |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1887 | rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1888 | NLP_EVT_CMPL_PLOGI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1889 | } else { |
| 1890 | /* Good status, call state machine */ |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1891 | prsp = list_entry(((struct lpfc_dmabuf *) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1892 | cmdiocb->context2)->list.next, |
| 1893 | struct lpfc_dmabuf, list); |
| 1894 | ndlp = lpfc_plogi_confirm_nport(phba, prsp->virt, ndlp); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1895 | rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1896 | NLP_EVT_CMPL_PLOGI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1897 | } |
| 1898 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1899 | if (disc && vport->num_disc_nodes) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1900 | /* Check to see if there are more PLOGIs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1901 | lpfc_more_plogi(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1902 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1903 | if (vport->num_disc_nodes == 0) { |
| 1904 | spin_lock_irq(shost->host_lock); |
| 1905 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 1906 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1907 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1908 | lpfc_can_disctmo(vport); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1909 | lpfc_end_rscn(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1910 | } |
| 1911 | } |
| 1912 | |
| 1913 | out: |
| 1914 | lpfc_els_free_iocb(phba, cmdiocb); |
| 1915 | return; |
| 1916 | } |
| 1917 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1918 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1919 | * lpfc_issue_els_plogi - Issue an plogi iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1920 | * @vport: pointer to a host virtual N_Port data structure. |
| 1921 | * @did: destination port identifier. |
| 1922 | * @retry: number of retries to the command IOCB. |
| 1923 | * |
| 1924 | * This routine issues a Port Login (PLOGI) command to a remote N_Port |
| 1925 | * (with the @did) for a @vport. Before issuing a PLOGI to a remote N_Port, |
| 1926 | * the ndlp with the remote N_Port DID must exist on the @vport's ndlp list. |
| 1927 | * This routine constructs the proper feilds of the PLOGI IOCB and invokes |
| 1928 | * the lpfc_sli_issue_iocb() routine to send out PLOGI ELS command. |
| 1929 | * |
| 1930 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 1931 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 1932 | * will be stored into the context1 field of the IOCB for the completion |
| 1933 | * callback function to the PLOGI ELS command. |
| 1934 | * |
| 1935 | * Return code |
| 1936 | * 0 - Successfully issued a plogi for @vport |
| 1937 | * 1 - failed to issue a plogi for @vport |
| 1938 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1939 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1940 | lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1941 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1942 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1943 | struct serv_parm *sp; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1944 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1945 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1946 | uint8_t *pcmd; |
| 1947 | uint16_t cmdsize; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1948 | int ret; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1949 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1950 | ndlp = lpfc_findnode_did(vport, did); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1951 | if (ndlp && !NLP_CHK_NODE_ACT(ndlp)) |
| 1952 | ndlp = NULL; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1953 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1954 | /* 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] | 1955 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1956 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1957 | ELS_CMD_PLOGI); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1958 | if (!elsiocb) |
| 1959 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1960 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1961 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 1962 | |
| 1963 | /* For PLOGI request, remainder of payload is service parameters */ |
| 1964 | *((uint32_t *) (pcmd)) = ELS_CMD_PLOGI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1965 | pcmd += sizeof(uint32_t); |
| 1966 | memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1967 | sp = (struct serv_parm *) pcmd; |
| 1968 | |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 1969 | /* |
| 1970 | * If we are a N-port connected to a Fabric, fix-up paramm's so logins |
| 1971 | * to device on remote loops work. |
| 1972 | */ |
| 1973 | if ((vport->fc_flag & FC_FABRIC) && !(vport->fc_flag & FC_PUBLIC_LOOP)) |
| 1974 | sp->cmn.altBbCredit = 1; |
| 1975 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1976 | if (sp->cmn.fcphLow < FC_PH_4_3) |
| 1977 | sp->cmn.fcphLow = FC_PH_4_3; |
| 1978 | |
| 1979 | if (sp->cmn.fcphHigh < FC_PH3) |
| 1980 | sp->cmn.fcphHigh = FC_PH3; |
| 1981 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1982 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1983 | "Issue PLOGI: did:x%x", |
| 1984 | did, 0, 0); |
| 1985 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1986 | phba->fc_stat.elsXmitPLOGI++; |
| 1987 | elsiocb->iocb_cmpl = lpfc_cmpl_els_plogi; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 1988 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1989 | |
| 1990 | if (ret == IOCB_ERROR) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1991 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1992 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1993 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1994 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1995 | } |
| 1996 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1997 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1998 | * lpfc_cmpl_els_prli - Completion callback function for prli |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1999 | * @phba: pointer to lpfc hba data structure. |
| 2000 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2001 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2002 | * |
| 2003 | * This routine is the completion callback function for a Process Login |
| 2004 | * (PRLI) ELS command. The PRLI response IOCB status is checked for error |
| 2005 | * status. If there is error status reported, PRLI retry shall be attempted |
| 2006 | * by invoking the lpfc_els_retry() routine. Otherwise, the state |
| 2007 | * NLP_EVT_CMPL_PRLI is sent to the Discover State Machine (DSM) for this |
| 2008 | * ndlp to mark the PRLI completion. |
| 2009 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2010 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2011 | lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2012 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2013 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2014 | struct lpfc_vport *vport = cmdiocb->vport; |
| 2015 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2016 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2017 | struct lpfc_nodelist *ndlp; |
| 2018 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2019 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 2020 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 2021 | |
| 2022 | irsp = &(rspiocb->iocb); |
| 2023 | ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2024 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2025 | ndlp->nlp_flag &= ~NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2026 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2027 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2028 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2029 | "PRLI cmpl: status:x%x/x%x did:x%x", |
| 2030 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2031 | ndlp->nlp_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2032 | /* PRLI completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2033 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2034 | "0103 PRLI completes to NPort x%x " |
| 2035 | "Data: x%x x%x x%x x%x\n", |
| 2036 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2037 | irsp->ulpTimeout, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2038 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2039 | vport->fc_prli_sent--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2040 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2041 | if (lpfc_els_chk_latt(vport)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2042 | goto out; |
| 2043 | |
| 2044 | if (irsp->ulpStatus) { |
| 2045 | /* Check for retry */ |
| 2046 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 2047 | /* ELS command is being retried */ |
| 2048 | goto out; |
| 2049 | } |
| 2050 | /* PRLI failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2051 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2052 | "2754 PRLI failure DID:%06X Status:x%x/x%x\n", |
| 2053 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2054 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2055 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2056 | if (lpfc_error_lost_link(irsp)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2057 | goto out; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2058 | else |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2059 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2060 | NLP_EVT_CMPL_PRLI); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2061 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2062 | /* Good status, call state machine */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2063 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2064 | NLP_EVT_CMPL_PRLI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2065 | out: |
| 2066 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2067 | return; |
| 2068 | } |
| 2069 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2070 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2071 | * lpfc_issue_els_prli - Issue a prli iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2072 | * @vport: pointer to a host virtual N_Port data structure. |
| 2073 | * @ndlp: pointer to a node-list data structure. |
| 2074 | * @retry: number of retries to the command IOCB. |
| 2075 | * |
| 2076 | * This routine issues a Process Login (PRLI) ELS command for the |
| 2077 | * @vport. The PRLI service parameters are set up in the payload of the |
| 2078 | * PRLI Request command and the pointer to lpfc_cmpl_els_prli() routine |
| 2079 | * is put to the IOCB completion callback func field before invoking the |
| 2080 | * routine lpfc_sli_issue_iocb() to send out PRLI command. |
| 2081 | * |
| 2082 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2083 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2084 | * will be stored into the context1 field of the IOCB for the completion |
| 2085 | * callback function to the PRLI ELS command. |
| 2086 | * |
| 2087 | * Return code |
| 2088 | * 0 - successfully issued prli iocb command for @vport |
| 2089 | * 1 - failed to issue prli iocb command for @vport |
| 2090 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2091 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2092 | lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2093 | uint8_t retry) |
| 2094 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2095 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2096 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2097 | PRLI *npr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2098 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2099 | uint8_t *pcmd; |
| 2100 | uint16_t cmdsize; |
| 2101 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2102 | cmdsize = (sizeof(uint32_t) + sizeof(PRLI)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2103 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2104 | ndlp->nlp_DID, ELS_CMD_PRLI); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2105 | if (!elsiocb) |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2106 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2107 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2108 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2109 | |
| 2110 | /* For PRLI request, remainder of payload is service parameters */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2111 | memset(pcmd, 0, (sizeof(PRLI) + sizeof(uint32_t))); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2112 | *((uint32_t *) (pcmd)) = ELS_CMD_PRLI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2113 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2114 | |
| 2115 | /* For PRLI, remainder of payload is PRLI parameter page */ |
| 2116 | npr = (PRLI *) pcmd; |
| 2117 | /* |
| 2118 | * If our firmware version is 3.20 or later, |
| 2119 | * set the following bits for FC-TAPE support. |
| 2120 | */ |
| 2121 | if (phba->vpd.rev.feaLevelHigh >= 0x02) { |
| 2122 | npr->ConfmComplAllowed = 1; |
| 2123 | npr->Retry = 1; |
| 2124 | npr->TaskRetryIdReq = 1; |
| 2125 | } |
| 2126 | npr->estabImagePair = 1; |
| 2127 | npr->readXferRdyDis = 1; |
James Smart | 3cb01c5 | 2013-07-15 18:35:04 -0400 | [diff] [blame] | 2128 | if (vport->cfg_first_burst_size) |
| 2129 | npr->writeXferRdyDis = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2130 | |
| 2131 | /* For FCP support */ |
| 2132 | npr->prliType = PRLI_FCP_TYPE; |
| 2133 | npr->initiatorFunc = 1; |
| 2134 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2135 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2136 | "Issue PRLI: did:x%x", |
| 2137 | ndlp->nlp_DID, 0, 0); |
| 2138 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2139 | phba->fc_stat.elsXmitPRLI++; |
| 2140 | elsiocb->iocb_cmpl = lpfc_cmpl_els_prli; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2141 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2142 | ndlp->nlp_flag |= NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2143 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2144 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2145 | IOCB_ERROR) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2146 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2147 | ndlp->nlp_flag &= ~NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2148 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2149 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2150 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2151 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2152 | vport->fc_prli_sent++; |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2153 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2154 | } |
| 2155 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2156 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2157 | * lpfc_rscn_disc - Perform rscn discovery for a vport |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2158 | * @vport: pointer to a host virtual N_Port data structure. |
| 2159 | * |
| 2160 | * This routine performs Registration State Change Notification (RSCN) |
| 2161 | * discovery for a @vport. If the @vport's node port recovery count is not |
| 2162 | * zero, it will invoke the lpfc_els_disc_plogi() to perform PLOGI for all |
| 2163 | * the nodes that need recovery. If none of the PLOGI were needed through |
| 2164 | * the lpfc_els_disc_plogi() routine, the lpfc_end_rscn() routine shall be |
| 2165 | * invoked to check and handle possible more RSCN came in during the period |
| 2166 | * of processing the current ones. |
| 2167 | **/ |
| 2168 | static void |
| 2169 | lpfc_rscn_disc(struct lpfc_vport *vport) |
| 2170 | { |
| 2171 | lpfc_can_disctmo(vport); |
| 2172 | |
| 2173 | /* RSCN discovery */ |
| 2174 | /* go thru NPR nodes and issue ELS PLOGIs */ |
| 2175 | if (vport->fc_npr_cnt) |
| 2176 | if (lpfc_els_disc_plogi(vport)) |
| 2177 | return; |
| 2178 | |
| 2179 | lpfc_end_rscn(vport); |
| 2180 | } |
| 2181 | |
| 2182 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2183 | * lpfc_adisc_done - Complete the adisc phase of discovery |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2184 | * @vport: pointer to lpfc_vport hba data structure that finished all ADISCs. |
| 2185 | * |
| 2186 | * This function is called when the final ADISC is completed during discovery. |
| 2187 | * This function handles clearing link attention or issuing reg_vpi depending |
| 2188 | * on whether npiv is enabled. This function also kicks off the PLOGI phase of |
| 2189 | * discovery. |
| 2190 | * This function is called with no locks held. |
| 2191 | **/ |
| 2192 | static void |
| 2193 | lpfc_adisc_done(struct lpfc_vport *vport) |
| 2194 | { |
| 2195 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2196 | struct lpfc_hba *phba = vport->phba; |
| 2197 | |
| 2198 | /* |
| 2199 | * For NPIV, cmpl_reg_vpi will set port_state to READY, |
| 2200 | * and continue discovery. |
| 2201 | */ |
| 2202 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 2203 | !(vport->fc_flag & FC_RSCN_MODE) && |
| 2204 | (phba->sli_rev < LPFC_SLI_REV4)) { |
James Smart | d454c91 | 2014-12-30 12:08:58 -0500 | [diff] [blame] | 2205 | /* The ADISCs are complete. Doesn't matter if they |
| 2206 | * succeeded or failed because the ADISC completion |
| 2207 | * routine guarantees to call the state machine and |
| 2208 | * the RPI is either unregistered (failed ADISC response) |
| 2209 | * or the RPI is still valid and the node is marked |
| 2210 | * mapped for a target. The exchanges should be in the |
| 2211 | * correct state. This code is specific to SLI3. |
| 2212 | */ |
| 2213 | lpfc_issue_clear_la(phba, vport); |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2214 | lpfc_issue_reg_vpi(phba, vport); |
| 2215 | return; |
| 2216 | } |
| 2217 | /* |
| 2218 | * For SLI2, we need to set port_state to READY |
| 2219 | * and continue discovery. |
| 2220 | */ |
| 2221 | if (vport->port_state < LPFC_VPORT_READY) { |
| 2222 | /* If we get here, there is nothing to ADISC */ |
James Smart | 85c0f17 | 2015-04-07 15:07:12 -0400 | [diff] [blame] | 2223 | lpfc_issue_clear_la(phba, vport); |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2224 | if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) { |
| 2225 | vport->num_disc_nodes = 0; |
| 2226 | /* go thru NPR list, issue ELS PLOGIs */ |
| 2227 | if (vport->fc_npr_cnt) |
| 2228 | lpfc_els_disc_plogi(vport); |
| 2229 | if (!vport->num_disc_nodes) { |
| 2230 | spin_lock_irq(shost->host_lock); |
| 2231 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 2232 | spin_unlock_irq(shost->host_lock); |
| 2233 | lpfc_can_disctmo(vport); |
| 2234 | lpfc_end_rscn(vport); |
| 2235 | } |
| 2236 | } |
| 2237 | vport->port_state = LPFC_VPORT_READY; |
| 2238 | } else |
| 2239 | lpfc_rscn_disc(vport); |
| 2240 | } |
| 2241 | |
| 2242 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2243 | * lpfc_more_adisc - Issue more adisc as needed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2244 | * @vport: pointer to a host virtual N_Port data structure. |
| 2245 | * |
| 2246 | * This routine determines whether there are more ndlps on a @vport |
| 2247 | * node list need to have Address Discover (ADISC) issued. If so, it will |
| 2248 | * invoke the lpfc_els_disc_adisc() routine to issue ADISC on the @vport's |
| 2249 | * remaining nodes which need to have ADISC sent. |
| 2250 | **/ |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 2251 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2252 | lpfc_more_adisc(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2253 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2254 | if (vport->num_disc_nodes) |
| 2255 | vport->num_disc_nodes--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2256 | /* Continue discovery with <num_disc_nodes> ADISCs to go */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2257 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 2258 | "0210 Continue discovery with %d ADISCs to go " |
| 2259 | "Data: x%x x%x x%x\n", |
| 2260 | vport->num_disc_nodes, vport->fc_adisc_cnt, |
| 2261 | vport->fc_flag, vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2262 | /* Check to see if there are more ADISCs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2263 | if (vport->fc_flag & FC_NLP_MORE) { |
| 2264 | lpfc_set_disctmo(vport); |
| 2265 | /* go thru NPR nodes and issue any remaining ELS ADISCs */ |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 2266 | lpfc_els_disc_adisc(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2267 | } |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2268 | if (!vport->num_disc_nodes) |
| 2269 | lpfc_adisc_done(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2270 | return; |
| 2271 | } |
| 2272 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2273 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2274 | * lpfc_cmpl_els_adisc - Completion callback function for adisc |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2275 | * @phba: pointer to lpfc hba data structure. |
| 2276 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2277 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2278 | * |
| 2279 | * This routine is the completion function for issuing the Address Discover |
| 2280 | * (ADISC) command. It first checks to see whether link went down during |
| 2281 | * the discovery process. If so, the node will be marked as node port |
| 2282 | * recovery for issuing discover IOCB by the link attention handler and |
| 2283 | * exit. Otherwise, the response status is checked. If error was reported |
| 2284 | * in the response status, the ADISC command shall be retried by invoking |
| 2285 | * the lpfc_els_retry() routine. Otherwise, if no error was reported in |
| 2286 | * the response status, the state machine is invoked to set transition |
| 2287 | * with respect to NLP_EVT_CMPL_ADISC event. |
| 2288 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2289 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2290 | lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2291 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2292 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2293 | struct lpfc_vport *vport = cmdiocb->vport; |
| 2294 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2295 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2296 | struct lpfc_nodelist *ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2297 | int disc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2298 | |
| 2299 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 2300 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 2301 | |
| 2302 | irsp = &(rspiocb->iocb); |
| 2303 | ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2304 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2305 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2306 | "ADISC cmpl: status:x%x/x%x did:x%x", |
| 2307 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2308 | ndlp->nlp_DID); |
| 2309 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2310 | /* Since ndlp can be freed in the disc state machine, note if this node |
| 2311 | * is being used during discovery. |
| 2312 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2313 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2314 | disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2315 | ndlp->nlp_flag &= ~(NLP_ADISC_SND | NLP_NPR_2B_DISC); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2316 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2317 | /* ADISC completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2318 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2319 | "0104 ADISC completes to NPort x%x " |
| 2320 | "Data: x%x x%x x%x x%x x%x\n", |
| 2321 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2322 | irsp->ulpTimeout, disc, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2323 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2324 | if (lpfc_els_chk_latt(vport)) { |
| 2325 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2326 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2327 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2328 | goto out; |
| 2329 | } |
| 2330 | |
| 2331 | if (irsp->ulpStatus) { |
| 2332 | /* Check for retry */ |
| 2333 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 2334 | /* ELS command is being retried */ |
| 2335 | if (disc) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2336 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2337 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2338 | spin_unlock_irq(shost->host_lock); |
| 2339 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2340 | } |
| 2341 | goto out; |
| 2342 | } |
| 2343 | /* ADISC failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2344 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2345 | "2755 ADISC failure DID:%06X Status:x%x/x%x\n", |
| 2346 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2347 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2348 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2349 | if (!lpfc_error_lost_link(irsp)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2350 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2351 | NLP_EVT_CMPL_ADISC); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2352 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2353 | /* Good status, call state machine */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2354 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2355 | NLP_EVT_CMPL_ADISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2356 | |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2357 | /* Check to see if there are more ADISCs to be sent */ |
| 2358 | if (disc && vport->num_disc_nodes) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2359 | lpfc_more_adisc(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2360 | out: |
| 2361 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2362 | return; |
| 2363 | } |
| 2364 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2365 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2366 | * 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] | 2367 | * @vport: pointer to a virtual N_Port data structure. |
| 2368 | * @ndlp: pointer to a node-list data structure. |
| 2369 | * @retry: number of retries to the command IOCB. |
| 2370 | * |
| 2371 | * This routine issues an Address Discover (ADISC) for an @ndlp on a |
| 2372 | * @vport. It prepares the payload of the ADISC ELS command, updates the |
| 2373 | * and states of the ndlp, and invokes the lpfc_sli_issue_iocb() routine |
| 2374 | * to issue the ADISC ELS command. |
| 2375 | * |
| 2376 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2377 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2378 | * will be stored into the context1 field of the IOCB for the completion |
| 2379 | * callback function to the ADISC ELS command. |
| 2380 | * |
| 2381 | * Return code |
| 2382 | * 0 - successfully issued adisc |
| 2383 | * 1 - failed to issue adisc |
| 2384 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2385 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2386 | lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2387 | uint8_t retry) |
| 2388 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2389 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2390 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2391 | ADISC *ap; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2392 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2393 | uint8_t *pcmd; |
| 2394 | uint16_t cmdsize; |
| 2395 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2396 | cmdsize = (sizeof(uint32_t) + sizeof(ADISC)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2397 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2398 | ndlp->nlp_DID, ELS_CMD_ADISC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2399 | if (!elsiocb) |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2400 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2401 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2402 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2403 | |
| 2404 | /* For ADISC request, remainder of payload is service parameters */ |
| 2405 | *((uint32_t *) (pcmd)) = ELS_CMD_ADISC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2406 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2407 | |
| 2408 | /* Fill in ADISC payload */ |
| 2409 | ap = (ADISC *) pcmd; |
| 2410 | ap->hardAL_PA = phba->fc_pref_ALPA; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2411 | memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 2412 | memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2413 | ap->DID = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2414 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2415 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2416 | "Issue ADISC: did:x%x", |
| 2417 | ndlp->nlp_DID, 0, 0); |
| 2418 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2419 | phba->fc_stat.elsXmitADISC++; |
| 2420 | elsiocb->iocb_cmpl = lpfc_cmpl_els_adisc; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2421 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2422 | ndlp->nlp_flag |= NLP_ADISC_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2423 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2424 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2425 | IOCB_ERROR) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2426 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2427 | ndlp->nlp_flag &= ~NLP_ADISC_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2428 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2429 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2430 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2431 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2432 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2433 | } |
| 2434 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2435 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2436 | * lpfc_cmpl_els_logo - Completion callback function for logo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2437 | * @phba: pointer to lpfc hba data structure. |
| 2438 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2439 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2440 | * |
| 2441 | * This routine is the completion function for issuing the ELS Logout (LOGO) |
| 2442 | * command. If no error status was reported from the LOGO response, the |
| 2443 | * state machine of the associated ndlp shall be invoked for transition with |
| 2444 | * respect to NLP_EVT_CMPL_LOGO event. Otherwise, if error status was reported, |
| 2445 | * the lpfc_els_retry() routine will be invoked to retry the LOGO command. |
| 2446 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2447 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2448 | lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2449 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2450 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2451 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 2452 | struct lpfc_vport *vport = ndlp->vport; |
| 2453 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2454 | IOCB_t *irsp; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 2455 | struct lpfcMboxq *mbox; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2456 | unsigned long flags; |
| 2457 | uint32_t skip_recovery = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2458 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2459 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 2460 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 2461 | |
| 2462 | irsp = &(rspiocb->iocb); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2463 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2464 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2465 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2466 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2467 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2468 | "LOGO cmpl: status:x%x/x%x did:x%x", |
| 2469 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2470 | ndlp->nlp_DID); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2471 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2472 | /* LOGO completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2473 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2474 | "0105 LOGO completes to NPort x%x " |
| 2475 | "Data: x%x x%x x%x x%x\n", |
| 2476 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2477 | irsp->ulpTimeout, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2478 | |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2479 | if (lpfc_els_chk_latt(vport)) { |
| 2480 | skip_recovery = 1; |
| 2481 | goto out; |
| 2482 | } |
| 2483 | |
| 2484 | /* Check to see if link went down during discovery */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2485 | if (ndlp->nlp_flag & NLP_TARGET_REMOVE) { |
| 2486 | /* NLP_EVT_DEVICE_RM should unregister the RPI |
| 2487 | * which should abort all outstanding IOs. |
| 2488 | */ |
| 2489 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
| 2490 | NLP_EVT_DEVICE_RM); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2491 | skip_recovery = 1; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2492 | goto out; |
| 2493 | } |
| 2494 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2495 | if (irsp->ulpStatus) { |
| 2496 | /* Check for retry */ |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2497 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2498 | /* ELS command is being retried */ |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2499 | skip_recovery = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2500 | goto out; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2501 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2502 | /* LOGO failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2503 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2504 | "2756 LOGO failure DID:%06X Status:x%x/x%x\n", |
| 2505 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2506 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2507 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2508 | if (lpfc_error_lost_link(irsp)) { |
| 2509 | skip_recovery = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2510 | goto out; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2511 | } |
| 2512 | } |
| 2513 | |
| 2514 | /* Call state machine. This will unregister the rpi if needed. */ |
| 2515 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_CMPL_LOGO); |
| 2516 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2517 | out: |
| 2518 | lpfc_els_free_iocb(phba, cmdiocb); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 2519 | /* If we are in pt2pt mode, we could rcv new S_ID on PLOGI */ |
| 2520 | if ((vport->fc_flag & FC_PT2PT) && |
| 2521 | !(vport->fc_flag & FC_PT2PT_PLOGI)) { |
| 2522 | phba->pport->fc_myDID = 0; |
| 2523 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 2524 | if (mbox) { |
| 2525 | lpfc_config_link(phba, mbox); |
| 2526 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
| 2527 | mbox->vport = vport; |
| 2528 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) == |
| 2529 | MBX_NOT_FINISHED) { |
| 2530 | mempool_free(mbox, phba->mbox_mem_pool); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2531 | skip_recovery = 1; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 2532 | } |
| 2533 | } |
| 2534 | } |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2535 | |
| 2536 | /* |
| 2537 | * If the node is a target, the handling attempts to recover the port. |
| 2538 | * For any other port type, the rpi is unregistered as an implicit |
| 2539 | * LOGO. |
| 2540 | */ |
| 2541 | if ((ndlp->nlp_type & NLP_FCP_TARGET) && (skip_recovery == 0)) { |
| 2542 | lpfc_cancel_retry_delay_tmo(vport, ndlp); |
| 2543 | spin_lock_irqsave(shost->host_lock, flags); |
| 2544 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
| 2545 | spin_unlock_irqrestore(shost->host_lock, flags); |
| 2546 | |
| 2547 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2548 | "3187 LOGO completes to NPort x%x: Start " |
| 2549 | "Recovery Data: x%x x%x x%x x%x\n", |
| 2550 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2551 | irsp->un.ulpWord[4], irsp->ulpTimeout, |
| 2552 | vport->num_disc_nodes); |
| 2553 | lpfc_disc_start(vport); |
| 2554 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2555 | return; |
| 2556 | } |
| 2557 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2558 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2559 | * 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] | 2560 | * @vport: pointer to a virtual N_Port data structure. |
| 2561 | * @ndlp: pointer to a node-list data structure. |
| 2562 | * @retry: number of retries to the command IOCB. |
| 2563 | * |
| 2564 | * This routine constructs and issues an ELS Logout (LOGO) iocb command |
| 2565 | * to a remote node, referred by an @ndlp on a @vport. It constructs the |
| 2566 | * payload of the IOCB, properly sets up the @ndlp state, and invokes the |
| 2567 | * lpfc_sli_issue_iocb() routine to send out the LOGO ELS command. |
| 2568 | * |
| 2569 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2570 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2571 | * will be stored into the context1 field of the IOCB for the completion |
| 2572 | * callback function to the LOGO ELS command. |
| 2573 | * |
| 2574 | * Return code |
| 2575 | * 0 - successfully issued logo |
| 2576 | * 1 - failed to issue logo |
| 2577 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2578 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2579 | lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2580 | uint8_t retry) |
| 2581 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2582 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2583 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2584 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2585 | uint8_t *pcmd; |
| 2586 | uint16_t cmdsize; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2587 | int rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2588 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 2589 | spin_lock_irq(shost->host_lock); |
| 2590 | if (ndlp->nlp_flag & NLP_LOGO_SND) { |
| 2591 | spin_unlock_irq(shost->host_lock); |
| 2592 | return 0; |
| 2593 | } |
| 2594 | spin_unlock_irq(shost->host_lock); |
| 2595 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2596 | cmdsize = (2 * sizeof(uint32_t)) + sizeof(struct lpfc_name); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2597 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2598 | ndlp->nlp_DID, ELS_CMD_LOGO); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2599 | if (!elsiocb) |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2600 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2601 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2602 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2603 | *((uint32_t *) (pcmd)) = ELS_CMD_LOGO; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2604 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2605 | |
| 2606 | /* Fill in LOGO payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2607 | *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2608 | pcmd += sizeof(uint32_t); |
| 2609 | memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2610 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2611 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2612 | "Issue LOGO: did:x%x", |
| 2613 | ndlp->nlp_DID, 0, 0); |
| 2614 | |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2615 | /* |
| 2616 | * If we are issuing a LOGO, we may try to recover the remote NPort |
| 2617 | * by issuing a PLOGI later. Even though we issue ELS cmds by the |
| 2618 | * VPI, if we have a valid RPI, and that RPI gets unreg'ed while |
| 2619 | * that ELS command is in-flight, the HBA returns a IOERR_INVALID_RPI |
| 2620 | * for that ELS cmd. To avoid this situation, lets get rid of the |
| 2621 | * RPI right now, before any ELS cmds are sent. |
| 2622 | */ |
| 2623 | spin_lock_irq(shost->host_lock); |
| 2624 | ndlp->nlp_flag |= NLP_ISSUE_LOGO; |
| 2625 | spin_unlock_irq(shost->host_lock); |
| 2626 | if (lpfc_unreg_rpi(vport, ndlp)) { |
| 2627 | lpfc_els_free_iocb(phba, elsiocb); |
| 2628 | return 0; |
| 2629 | } |
| 2630 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2631 | phba->fc_stat.elsXmitLOGO++; |
| 2632 | elsiocb->iocb_cmpl = lpfc_cmpl_els_logo; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2633 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2634 | ndlp->nlp_flag |= NLP_LOGO_SND; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 2635 | ndlp->nlp_flag &= ~NLP_ISSUE_LOGO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2636 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2637 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2638 | |
| 2639 | if (rc == IOCB_ERROR) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2640 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2641 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2642 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2643 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2644 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2645 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2646 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2647 | } |
| 2648 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2649 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2650 | * lpfc_cmpl_els_cmd - Completion callback function for generic els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2651 | * @phba: pointer to lpfc hba data structure. |
| 2652 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2653 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2654 | * |
| 2655 | * This routine is a generic completion callback function for ELS commands. |
| 2656 | * Specifically, it is the callback function which does not need to perform |
| 2657 | * any command specific operations. It is currently used by the ELS command |
| 2658 | * issuing routines for the ELS State Change Request (SCR), |
| 2659 | * lpfc_issue_els_scr(), and the ELS Fibre Channel Address Resolution |
| 2660 | * Protocol Response (FARPR) routine, lpfc_issue_els_farpr(). Other than |
| 2661 | * certain debug loggings, this callback function simply invokes the |
| 2662 | * lpfc_els_chk_latt() routine to check whether link went down during the |
| 2663 | * discovery process. |
| 2664 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2665 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2666 | lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2667 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2668 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2669 | struct lpfc_vport *vport = cmdiocb->vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2670 | IOCB_t *irsp; |
| 2671 | |
| 2672 | irsp = &rspiocb->iocb; |
| 2673 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2674 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2675 | "ELS cmd cmpl: status:x%x/x%x did:x%x", |
| 2676 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2677 | irsp->un.elsreq64.remoteID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2678 | /* ELS cmd tag <ulpIoTag> completes */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2679 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2680 | "0106 ELS cmd tag x%x completes Data: x%x x%x x%x\n", |
| 2681 | irsp->ulpIoTag, irsp->ulpStatus, |
| 2682 | irsp->un.ulpWord[4], irsp->ulpTimeout); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2683 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2684 | lpfc_els_chk_latt(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2685 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2686 | return; |
| 2687 | } |
| 2688 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2689 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2690 | * 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] | 2691 | * @vport: pointer to a host virtual N_Port data structure. |
| 2692 | * @nportid: N_Port identifier to the remote node. |
| 2693 | * @retry: number of retries to the command IOCB. |
| 2694 | * |
| 2695 | * This routine issues a State Change Request (SCR) to a fabric node |
| 2696 | * on a @vport. The remote node @nportid is passed into the function. It |
| 2697 | * first search the @vport node list to find the matching ndlp. If no such |
| 2698 | * ndlp is found, a new ndlp shall be created for this (SCR) purpose. An |
| 2699 | * IOCB is allocated, payload prepared, and the lpfc_sli_issue_iocb() |
| 2700 | * routine is invoked to send the SCR IOCB. |
| 2701 | * |
| 2702 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2703 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2704 | * will be stored into the context1 field of the IOCB for the completion |
| 2705 | * callback function to the SCR ELS command. |
| 2706 | * |
| 2707 | * Return code |
| 2708 | * 0 - Successfully issued scr command |
| 2709 | * 1 - Failed to issue scr command |
| 2710 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2711 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2712 | lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2713 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2714 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2715 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2716 | uint8_t *pcmd; |
| 2717 | uint16_t cmdsize; |
| 2718 | struct lpfc_nodelist *ndlp; |
| 2719 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2720 | cmdsize = (sizeof(uint32_t) + sizeof(SCR)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2721 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2722 | ndlp = lpfc_findnode_did(vport, nportid); |
| 2723 | if (!ndlp) { |
| 2724 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 2725 | if (!ndlp) |
| 2726 | return 1; |
| 2727 | lpfc_nlp_init(vport, ndlp, nportid); |
| 2728 | lpfc_enqueue_node(vport, ndlp); |
| 2729 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 2730 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 2731 | if (!ndlp) |
| 2732 | return 1; |
| 2733 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2734 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2735 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2736 | ndlp->nlp_DID, ELS_CMD_SCR); |
| 2737 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2738 | if (!elsiocb) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2739 | /* This will trigger the release of the node just |
| 2740 | * allocated |
| 2741 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2742 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2743 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2744 | } |
| 2745 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2746 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2747 | |
| 2748 | *((uint32_t *) (pcmd)) = ELS_CMD_SCR; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2749 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2750 | |
| 2751 | /* For SCR, remainder of payload is SCR parameter page */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2752 | memset(pcmd, 0, sizeof(SCR)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2753 | ((SCR *) pcmd)->Function = SCR_FUNC_FULL; |
| 2754 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2755 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2756 | "Issue SCR: did:x%x", |
| 2757 | ndlp->nlp_DID, 0, 0); |
| 2758 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2759 | phba->fc_stat.elsXmitSCR++; |
| 2760 | elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2761 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2762 | IOCB_ERROR) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2763 | /* The additional lpfc_nlp_put will cause the following |
| 2764 | * lpfc_els_free_iocb routine to trigger the rlease of |
| 2765 | * the node. |
| 2766 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2767 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2768 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2769 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2770 | } |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2771 | /* This will cause the callback-function lpfc_cmpl_els_cmd to |
| 2772 | * trigger the release of node. |
| 2773 | */ |
James Smart | cff261f | 2013-12-17 20:29:47 -0500 | [diff] [blame] | 2774 | |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2775 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2776 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2777 | } |
| 2778 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2779 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2780 | * 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] | 2781 | * @vport: pointer to a host virtual N_Port data structure. |
| 2782 | * @nportid: N_Port identifier to the remote node. |
| 2783 | * @retry: number of retries to the command IOCB. |
| 2784 | * |
| 2785 | * This routine issues a Fibre Channel Address Resolution Response |
| 2786 | * (FARPR) to a node on a vport. The remote node N_Port identifier (@nportid) |
| 2787 | * is passed into the function. It first search the @vport node list to find |
| 2788 | * the matching ndlp. If no such ndlp is found, a new ndlp shall be created |
| 2789 | * for this (FARPR) purpose. An IOCB is allocated, payload prepared, and the |
| 2790 | * lpfc_sli_issue_iocb() routine is invoked to send the FARPR ELS command. |
| 2791 | * |
| 2792 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2793 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2794 | * will be stored into the context1 field of the IOCB for the completion |
| 2795 | * callback function to the PARPR ELS command. |
| 2796 | * |
| 2797 | * Return code |
| 2798 | * 0 - Successfully issued farpr command |
| 2799 | * 1 - Failed to issue farpr command |
| 2800 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2801 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2802 | lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2803 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2804 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2805 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2806 | FARP *fp; |
| 2807 | uint8_t *pcmd; |
| 2808 | uint32_t *lp; |
| 2809 | uint16_t cmdsize; |
| 2810 | struct lpfc_nodelist *ondlp; |
| 2811 | struct lpfc_nodelist *ndlp; |
| 2812 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2813 | cmdsize = (sizeof(uint32_t) + sizeof(FARP)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2814 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2815 | ndlp = lpfc_findnode_did(vport, nportid); |
| 2816 | if (!ndlp) { |
| 2817 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 2818 | if (!ndlp) |
| 2819 | return 1; |
| 2820 | lpfc_nlp_init(vport, ndlp, nportid); |
| 2821 | lpfc_enqueue_node(vport, ndlp); |
| 2822 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 2823 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 2824 | if (!ndlp) |
| 2825 | return 1; |
| 2826 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2827 | |
| 2828 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2829 | ndlp->nlp_DID, ELS_CMD_RNID); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2830 | if (!elsiocb) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2831 | /* This will trigger the release of the node just |
| 2832 | * allocated |
| 2833 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2834 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2835 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2836 | } |
| 2837 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2838 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2839 | |
| 2840 | *((uint32_t *) (pcmd)) = ELS_CMD_FARPR; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2841 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2842 | |
| 2843 | /* Fill in FARPR payload */ |
| 2844 | fp = (FARP *) (pcmd); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2845 | memset(fp, 0, sizeof(FARP)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2846 | lp = (uint32_t *) pcmd; |
| 2847 | *lp++ = be32_to_cpu(nportid); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2848 | *lp++ = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2849 | fp->Rflags = 0; |
| 2850 | fp->Mflags = (FARP_MATCH_PORT | FARP_MATCH_NODE); |
| 2851 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2852 | memcpy(&fp->RportName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 2853 | memcpy(&fp->RnodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2854 | ondlp = lpfc_findnode_did(vport, nportid); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2855 | if (ondlp && NLP_CHK_NODE_ACT(ondlp)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2856 | memcpy(&fp->OportName, &ondlp->nlp_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2857 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2858 | memcpy(&fp->OnodeName, &ondlp->nlp_nodename, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2859 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2860 | } |
| 2861 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2862 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2863 | "Issue FARPR: did:x%x", |
| 2864 | ndlp->nlp_DID, 0, 0); |
| 2865 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2866 | phba->fc_stat.elsXmitFARPR++; |
| 2867 | elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2868 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2869 | IOCB_ERROR) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2870 | /* The additional lpfc_nlp_put will cause the following |
| 2871 | * lpfc_els_free_iocb routine to trigger the release of |
| 2872 | * the node. |
| 2873 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2874 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2875 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2876 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2877 | } |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2878 | /* This will cause the callback-function lpfc_cmpl_els_cmd to |
| 2879 | * trigger the release of the node. |
| 2880 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2881 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2882 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2883 | } |
| 2884 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2885 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2886 | * 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] | 2887 | * @vport: pointer to a host virtual N_Port data structure. |
| 2888 | * @nlp: pointer to a node-list data structure. |
| 2889 | * |
| 2890 | * This routine cancels the timer with a delayed IOCB-command retry for |
| 2891 | * a @vport's @ndlp. It stops the timer for the delayed function retrial and |
| 2892 | * removes the ELS retry event if it presents. In addition, if the |
| 2893 | * NLP_NPR_2B_DISC bit is set in the @nlp's nlp_flag bitmap, ADISC IOCB |
| 2894 | * commands are sent for the @vport's nodes that require issuing discovery |
| 2895 | * ADISC. |
| 2896 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2897 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2898 | 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] | 2899 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2900 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2901 | struct lpfc_work_evt *evtp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2902 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2903 | if (!(nlp->nlp_flag & NLP_DELAY_TMO)) |
| 2904 | return; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2905 | spin_lock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2906 | nlp->nlp_flag &= ~NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2907 | spin_unlock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2908 | del_timer_sync(&nlp->nlp_delayfunc); |
| 2909 | nlp->nlp_last_elscmd = 0; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2910 | if (!list_empty(&nlp->els_retry_evt.evt_listp)) { |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2911 | list_del_init(&nlp->els_retry_evt.evt_listp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2912 | /* Decrement nlp reference count held for the delayed retry */ |
| 2913 | evtp = &nlp->els_retry_evt; |
| 2914 | lpfc_nlp_put((struct lpfc_nodelist *)evtp->evt_arg1); |
| 2915 | } |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2916 | if (nlp->nlp_flag & NLP_NPR_2B_DISC) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2917 | spin_lock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2918 | nlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2919 | spin_unlock_irq(shost->host_lock); |
| 2920 | if (vport->num_disc_nodes) { |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2921 | if (vport->port_state < LPFC_VPORT_READY) { |
| 2922 | /* Check if there are more ADISCs to be sent */ |
| 2923 | lpfc_more_adisc(vport); |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2924 | } else { |
| 2925 | /* Check if there are more PLOGIs to be sent */ |
| 2926 | lpfc_more_plogi(vport); |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2927 | if (vport->num_disc_nodes == 0) { |
| 2928 | spin_lock_irq(shost->host_lock); |
| 2929 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 2930 | spin_unlock_irq(shost->host_lock); |
| 2931 | lpfc_can_disctmo(vport); |
| 2932 | lpfc_end_rscn(vport); |
| 2933 | } |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2934 | } |
| 2935 | } |
| 2936 | } |
| 2937 | return; |
| 2938 | } |
| 2939 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2940 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2941 | * lpfc_els_retry_delay - Timer function with a ndlp delayed function timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2942 | * @ptr: holder for the pointer to the timer function associated data (ndlp). |
| 2943 | * |
| 2944 | * This routine is invoked by the ndlp delayed-function timer to check |
| 2945 | * whether there is any pending ELS retry event(s) with the node. If not, it |
| 2946 | * simply returns. Otherwise, if there is at least one ELS delayed event, it |
| 2947 | * adds the delayed events to the HBA work list and invokes the |
| 2948 | * lpfc_worker_wake_up() routine to wake up worker thread to process the |
| 2949 | * event. Note that lpfc_nlp_get() is called before posting the event to |
| 2950 | * the work list to hold reference count of ndlp so that it guarantees the |
| 2951 | * reference to ndlp will still be available when the worker thread gets |
| 2952 | * to the event associated with the ndlp. |
| 2953 | **/ |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2954 | void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2955 | lpfc_els_retry_delay(unsigned long ptr) |
| 2956 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2957 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) ptr; |
| 2958 | struct lpfc_vport *vport = ndlp->vport; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2959 | struct lpfc_hba *phba = vport->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2960 | unsigned long flags; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2961 | struct lpfc_work_evt *evtp = &ndlp->els_retry_evt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2962 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2963 | spin_lock_irqsave(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2964 | if (!list_empty(&evtp->evt_listp)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2965 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2966 | return; |
| 2967 | } |
| 2968 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2969 | /* We need to hold the node by incrementing the reference |
| 2970 | * count until the queued work is done |
| 2971 | */ |
| 2972 | evtp->evt_arg1 = lpfc_nlp_get(ndlp); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 2973 | if (evtp->evt_arg1) { |
| 2974 | evtp->evt = LPFC_EVT_ELS_RETRY; |
| 2975 | list_add_tail(&evtp->evt_listp, &phba->work_list); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2976 | lpfc_worker_wake_up(phba); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 2977 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2978 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2979 | return; |
| 2980 | } |
| 2981 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2982 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2983 | * lpfc_els_retry_delay_handler - Work thread handler for ndlp delayed function |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2984 | * @ndlp: pointer to a node-list data structure. |
| 2985 | * |
| 2986 | * This routine is the worker-thread handler for processing the @ndlp delayed |
| 2987 | * event(s), posted by the lpfc_els_retry_delay() routine. It simply retrieves |
| 2988 | * the last ELS command from the associated ndlp and invokes the proper ELS |
| 2989 | * function according to the delayed ELS command to retry the command. |
| 2990 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2991 | void |
| 2992 | lpfc_els_retry_delay_handler(struct lpfc_nodelist *ndlp) |
| 2993 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2994 | struct lpfc_vport *vport = ndlp->vport; |
| 2995 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 2996 | uint32_t cmd, retry; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2997 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2998 | spin_lock_irq(shost->host_lock); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 2999 | cmd = ndlp->nlp_last_elscmd; |
| 3000 | ndlp->nlp_last_elscmd = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3001 | |
| 3002 | if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3003 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3004 | return; |
| 3005 | } |
| 3006 | |
| 3007 | ndlp->nlp_flag &= ~NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3008 | spin_unlock_irq(shost->host_lock); |
James Smart | 1a16968 | 2006-03-07 15:04:06 -0500 | [diff] [blame] | 3009 | /* |
| 3010 | * If a discovery event readded nlp_delayfunc after timer |
| 3011 | * firing and before processing the timer, cancel the |
| 3012 | * nlp_delayfunc. |
| 3013 | */ |
| 3014 | del_timer_sync(&ndlp->nlp_delayfunc); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3015 | retry = ndlp->nlp_retry; |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 3016 | ndlp->nlp_retry = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3017 | |
| 3018 | switch (cmd) { |
| 3019 | case ELS_CMD_FLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3020 | lpfc_issue_els_flogi(vport, ndlp, retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3021 | break; |
| 3022 | case ELS_CMD_PLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3023 | if (!lpfc_issue_els_plogi(vport, ndlp->nlp_DID, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3024 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3025 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 3026 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3027 | break; |
| 3028 | case ELS_CMD_ADISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3029 | if (!lpfc_issue_els_adisc(vport, ndlp, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3030 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3031 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 3032 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3033 | break; |
| 3034 | case ELS_CMD_PRLI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3035 | if (!lpfc_issue_els_prli(vport, ndlp, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3036 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3037 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 3038 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3039 | break; |
| 3040 | case ELS_CMD_LOGO: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3041 | if (!lpfc_issue_els_logo(vport, ndlp, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3042 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 3043 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 3044 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3045 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3046 | case ELS_CMD_FDISC: |
James Smart | fedd3b7 | 2011-02-16 12:39:24 -0500 | [diff] [blame] | 3047 | if (!(vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI)) |
| 3048 | lpfc_issue_els_fdisc(vport, ndlp, retry); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3049 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3050 | } |
| 3051 | return; |
| 3052 | } |
| 3053 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3054 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3055 | * lpfc_els_retry - Make retry decision on an els command iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3056 | * @phba: pointer to lpfc hba data structure. |
| 3057 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 3058 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 3059 | * |
| 3060 | * This routine makes a retry decision on an ELS command IOCB, which has |
| 3061 | * failed. The following ELS IOCBs use this function for retrying the command |
| 3062 | * when previously issued command responsed with error status: FLOGI, PLOGI, |
| 3063 | * PRLI, ADISC, LOGO, and FDISC. Based on the ELS command type and the |
| 3064 | * returned error status, it makes the decision whether a retry shall be |
| 3065 | * issued for the command, and whether a retry shall be made immediately or |
| 3066 | * delayed. In the former case, the corresponding ELS command issuing-function |
| 3067 | * is called to retry the command. In the later case, the ELS command shall |
| 3068 | * be posted to the ndlp delayed event and delayed function timer set to the |
| 3069 | * ndlp for the delayed command issusing. |
| 3070 | * |
| 3071 | * Return code |
| 3072 | * 0 - No retry of els command is made |
| 3073 | * 1 - Immediate or delayed retry of els command is made |
| 3074 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3075 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3076 | lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 3077 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3078 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3079 | struct lpfc_vport *vport = cmdiocb->vport; |
| 3080 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3081 | IOCB_t *irsp = &rspiocb->iocb; |
| 3082 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 3083 | struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3084 | uint32_t *elscmd; |
| 3085 | struct ls_rjt stat; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3086 | int retry = 0, maxretry = lpfc_max_els_tries, delay = 0; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3087 | int logerr = 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3088 | uint32_t cmd = 0; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3089 | uint32_t did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3090 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3091 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3092 | /* Note: context2 may be 0 for internal driver abort |
| 3093 | * of delays ELS command. |
| 3094 | */ |
| 3095 | |
| 3096 | if (pcmd && pcmd->virt) { |
| 3097 | elscmd = (uint32_t *) (pcmd->virt); |
| 3098 | cmd = *elscmd++; |
| 3099 | } |
| 3100 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3101 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3102 | did = ndlp->nlp_DID; |
| 3103 | else { |
| 3104 | /* We should only hit this case for retrying PLOGI */ |
| 3105 | did = irsp->un.elsreq64.remoteID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3106 | ndlp = lpfc_findnode_did(vport, did); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3107 | if ((!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 3108 | && (cmd != ELS_CMD_PLOGI)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3109 | return 1; |
| 3110 | } |
| 3111 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3112 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 3113 | "Retry ELS: wd7:x%x wd4:x%x did:x%x", |
| 3114 | *(((uint32_t *) irsp) + 7), irsp->un.ulpWord[4], ndlp->nlp_DID); |
| 3115 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3116 | switch (irsp->ulpStatus) { |
| 3117 | case IOSTAT_FCP_RSP_ERROR: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3118 | break; |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 3119 | case IOSTAT_REMOTE_STOP: |
| 3120 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 3121 | /* This IO was aborted by the target, we don't |
| 3122 | * know the rxid and because we did not send the |
| 3123 | * ABTS we cannot generate and RRQ. |
| 3124 | */ |
| 3125 | lpfc_set_rrq_active(phba, ndlp, |
James Smart | ee0f4fe | 2012-05-09 21:19:14 -0400 | [diff] [blame] | 3126 | cmdiocb->sli4_lxritag, 0, 0); |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 3127 | } |
| 3128 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3129 | case IOSTAT_LOCAL_REJECT: |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 3130 | switch ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3131 | case IOERR_LOOP_OPEN_FAILURE: |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 3132 | if (cmd == ELS_CMD_FLOGI) { |
| 3133 | if (PCI_DEVICE_ID_HORNET == |
| 3134 | phba->pcidev->device) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3135 | phba->fc_topology = LPFC_TOPOLOGY_LOOP; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 3136 | phba->pport->fc_myDID = 0; |
| 3137 | phba->alpa_map[0] = 0; |
| 3138 | phba->alpa_map[1] = 0; |
| 3139 | } |
| 3140 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3141 | if (cmd == ELS_CMD_PLOGI && cmdiocb->retry == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3142 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3143 | retry = 1; |
| 3144 | break; |
| 3145 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3146 | case IOERR_ILLEGAL_COMMAND: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 3147 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3148 | "0124 Retry illegal cmd x%x " |
| 3149 | "retry:x%x delay:x%x\n", |
| 3150 | cmd, cmdiocb->retry, delay); |
| 3151 | retry = 1; |
| 3152 | /* All command's retry policy */ |
| 3153 | maxretry = 8; |
| 3154 | if (cmdiocb->retry > 2) |
| 3155 | delay = 1000; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3156 | break; |
| 3157 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3158 | case IOERR_NO_RESOURCES: |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3159 | logerr = 1; /* HBA out of resources */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3160 | retry = 1; |
| 3161 | if (cmdiocb->retry > 100) |
| 3162 | delay = 100; |
| 3163 | maxretry = 250; |
| 3164 | break; |
| 3165 | |
| 3166 | case IOERR_ILLEGAL_FRAME: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3167 | delay = 100; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3168 | retry = 1; |
| 3169 | break; |
| 3170 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3171 | case IOERR_SEQUENCE_TIMEOUT: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3172 | case IOERR_INVALID_RPI: |
James Smart | 5b5b36a | 2013-01-03 15:43:19 -0500 | [diff] [blame] | 3173 | if (cmd == ELS_CMD_PLOGI && |
| 3174 | did == NameServer_DID) { |
| 3175 | /* Continue forever if plogi to */ |
| 3176 | /* the nameserver fails */ |
| 3177 | maxretry = 0; |
| 3178 | delay = 100; |
| 3179 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3180 | retry = 1; |
| 3181 | break; |
| 3182 | } |
| 3183 | break; |
| 3184 | |
| 3185 | case IOSTAT_NPORT_RJT: |
| 3186 | case IOSTAT_FABRIC_RJT: |
| 3187 | if (irsp->un.ulpWord[4] & RJT_UNAVAIL_TEMP) { |
| 3188 | retry = 1; |
| 3189 | break; |
| 3190 | } |
| 3191 | break; |
| 3192 | |
| 3193 | case IOSTAT_NPORT_BSY: |
| 3194 | case IOSTAT_FABRIC_BSY: |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3195 | logerr = 1; /* Fabric / Remote NPort out of resources */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3196 | retry = 1; |
| 3197 | break; |
| 3198 | |
| 3199 | case IOSTAT_LS_RJT: |
| 3200 | stat.un.lsRjtError = be32_to_cpu(irsp->un.ulpWord[4]); |
| 3201 | /* Added for Vendor specifc support |
| 3202 | * Just keep retrying for these Rsn / Exp codes |
| 3203 | */ |
| 3204 | switch (stat.un.b.lsRjtRsnCode) { |
| 3205 | case LSRJT_UNABLE_TPC: |
| 3206 | if (stat.un.b.lsRjtRsnCodeExp == |
| 3207 | LSEXP_CMD_IN_PROGRESS) { |
| 3208 | if (cmd == ELS_CMD_PLOGI) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3209 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3210 | maxretry = 48; |
| 3211 | } |
| 3212 | retry = 1; |
| 3213 | break; |
| 3214 | } |
James Smart | ffc9549 | 2010-06-07 15:23:17 -0400 | [diff] [blame] | 3215 | if (stat.un.b.lsRjtRsnCodeExp == |
| 3216 | LSEXP_CANT_GIVE_DATA) { |
| 3217 | if (cmd == ELS_CMD_PLOGI) { |
| 3218 | delay = 1000; |
| 3219 | maxretry = 48; |
| 3220 | } |
| 3221 | retry = 1; |
| 3222 | break; |
| 3223 | } |
James Smart | 4c1b64b | 2012-09-29 11:31:11 -0400 | [diff] [blame] | 3224 | if ((cmd == ELS_CMD_PLOGI) || |
| 3225 | (cmd == ELS_CMD_PRLI)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3226 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3227 | maxretry = lpfc_max_els_tries + 1; |
| 3228 | retry = 1; |
| 3229 | break; |
| 3230 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3231 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
| 3232 | (cmd == ELS_CMD_FDISC) && |
| 3233 | (stat.un.b.lsRjtRsnCodeExp == LSEXP_OUT_OF_RESOURCE)){ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3234 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3235 | "0125 FDISC Failed (x%x). " |
| 3236 | "Fabric out of resources\n", |
| 3237 | stat.un.lsRjtError); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3238 | lpfc_vport_set_state(vport, |
| 3239 | FC_VPORT_NO_FABRIC_RSCS); |
| 3240 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3241 | break; |
| 3242 | |
| 3243 | case LSRJT_LOGICAL_BSY: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3244 | if ((cmd == ELS_CMD_PLOGI) || |
| 3245 | (cmd == ELS_CMD_PRLI)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3246 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3247 | maxretry = 48; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3248 | } else if (cmd == ELS_CMD_FDISC) { |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3249 | /* FDISC retry policy */ |
| 3250 | maxretry = 48; |
| 3251 | if (cmdiocb->retry >= 32) |
| 3252 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3253 | } |
| 3254 | retry = 1; |
| 3255 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3256 | |
| 3257 | case LSRJT_LOGICAL_ERR: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 3258 | /* There are some cases where switches return this |
| 3259 | * error when they are not ready and should be returning |
| 3260 | * Logical Busy. We should delay every time. |
| 3261 | */ |
| 3262 | if (cmd == ELS_CMD_FDISC && |
| 3263 | stat.un.b.lsRjtRsnCodeExp == LSEXP_PORT_LOGIN_REQ) { |
| 3264 | maxretry = 3; |
| 3265 | delay = 1000; |
| 3266 | retry = 1; |
| 3267 | break; |
| 3268 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3269 | case LSRJT_PROTOCOL_ERR: |
| 3270 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
| 3271 | (cmd == ELS_CMD_FDISC) && |
| 3272 | ((stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_PNAME) || |
| 3273 | (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID)) |
| 3274 | ) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3275 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 3276 | "0122 FDISC Failed (x%x). " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3277 | "Fabric Detected Bad WWN\n", |
| 3278 | stat.un.lsRjtError); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3279 | lpfc_vport_set_state(vport, |
| 3280 | FC_VPORT_FABRIC_REJ_WWN); |
| 3281 | } |
| 3282 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3283 | } |
| 3284 | break; |
| 3285 | |
| 3286 | case IOSTAT_INTERMED_RSP: |
| 3287 | case IOSTAT_BA_RJT: |
| 3288 | break; |
| 3289 | |
| 3290 | default: |
| 3291 | break; |
| 3292 | } |
| 3293 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3294 | if (did == FDMI_DID) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3295 | retry = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3296 | |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3297 | if ((cmd == ELS_CMD_FLOGI) && |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 3298 | (phba->fc_topology != LPFC_TOPOLOGY_LOOP) && |
James Smart | 1b32f6a | 2008-02-08 18:49:39 -0500 | [diff] [blame] | 3299 | !lpfc_error_lost_link(irsp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3300 | /* FLOGI retry policy */ |
| 3301 | retry = 1; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3302 | /* retry FLOGI forever */ |
James Smart | 6eae430 | 2015-04-07 15:07:23 -0400 | [diff] [blame] | 3303 | if (phba->link_flag != LS_LOOPBACK_MODE) |
| 3304 | maxretry = 0; |
| 3305 | else |
| 3306 | maxretry = 2; |
| 3307 | |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 3308 | if (cmdiocb->retry >= 100) |
| 3309 | delay = 5000; |
| 3310 | else if (cmdiocb->retry >= 32) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3311 | delay = 1000; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 3312 | } else if ((cmd == ELS_CMD_FDISC) && !lpfc_error_lost_link(irsp)) { |
| 3313 | /* retry FDISCs every second up to devloss */ |
| 3314 | retry = 1; |
| 3315 | maxretry = vport->cfg_devloss_tmo; |
| 3316 | delay = 1000; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3317 | } |
| 3318 | |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 3319 | cmdiocb->retry++; |
| 3320 | if (maxretry && (cmdiocb->retry >= maxretry)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3321 | phba->fc_stat.elsRetryExceeded++; |
| 3322 | retry = 0; |
| 3323 | } |
| 3324 | |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 3325 | if ((vport->load_flag & FC_UNLOADING) != 0) |
| 3326 | retry = 0; |
| 3327 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3328 | if (retry) { |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 3329 | if ((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_FDISC)) { |
| 3330 | /* Stop retrying PLOGI and FDISC if in FCF discovery */ |
| 3331 | if (phba->fcf.fcf_flag & FCF_DISCOVERY) { |
| 3332 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3333 | "2849 Stop retry ELS command " |
| 3334 | "x%x to remote NPORT x%x, " |
| 3335 | "Data: x%x x%x\n", cmd, did, |
| 3336 | cmdiocb->retry, delay); |
| 3337 | return 0; |
| 3338 | } |
| 3339 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3340 | |
| 3341 | /* Retry ELS command <elsCmd> to remote NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3342 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3343 | "0107 Retry ELS command x%x to remote " |
| 3344 | "NPORT x%x Data: x%x x%x\n", |
| 3345 | cmd, did, cmdiocb->retry, delay); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3346 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3347 | if (((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_ADISC)) && |
| 3348 | ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 3349 | ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) != |
| 3350 | IOERR_NO_RESOURCES))) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3351 | /* Don't reset timer for no resources */ |
| 3352 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3353 | /* If discovery / RSCN timer is running, reset it */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3354 | if (timer_pending(&vport->fc_disctmo) || |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3355 | (vport->fc_flag & FC_RSCN_MODE)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3356 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3357 | } |
| 3358 | |
| 3359 | phba->fc_stat.elsXmitRetry++; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3360 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && delay) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3361 | phba->fc_stat.elsDelayRetry++; |
| 3362 | ndlp->nlp_retry = cmdiocb->retry; |
| 3363 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3364 | /* delay is specified in milliseconds */ |
| 3365 | mod_timer(&ndlp->nlp_delayfunc, |
| 3366 | jiffies + msecs_to_jiffies(delay)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3367 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3368 | ndlp->nlp_flag |= NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3369 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3370 | |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3371 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3372 | if (cmd == ELS_CMD_PRLI) |
| 3373 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | 4c1b64b | 2012-09-29 11:31:11 -0400 | [diff] [blame] | 3374 | NLP_STE_PRLI_ISSUE); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3375 | else |
| 3376 | lpfc_nlp_set_state(vport, ndlp, |
| 3377 | NLP_STE_NPR_NODE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3378 | ndlp->nlp_last_elscmd = cmd; |
| 3379 | |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3380 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3381 | } |
| 3382 | switch (cmd) { |
| 3383 | case ELS_CMD_FLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3384 | lpfc_issue_els_flogi(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3385 | return 1; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3386 | case ELS_CMD_FDISC: |
| 3387 | lpfc_issue_els_fdisc(vport, ndlp, cmdiocb->retry); |
| 3388 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3389 | case ELS_CMD_PLOGI: |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3390 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3391 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3392 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | de0c5b3 | 2007-04-25 09:52:27 -0400 | [diff] [blame] | 3393 | NLP_STE_PLOGI_ISSUE); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3394 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3395 | lpfc_issue_els_plogi(vport, did, cmdiocb->retry); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3396 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3397 | case ELS_CMD_ADISC: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3398 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3399 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE); |
| 3400 | lpfc_issue_els_adisc(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3401 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3402 | case ELS_CMD_PRLI: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3403 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3404 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE); |
| 3405 | lpfc_issue_els_prli(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3406 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3407 | case ELS_CMD_LOGO: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3408 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 3409 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3410 | lpfc_issue_els_logo(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3411 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3412 | } |
| 3413 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3414 | /* No retry ELS command <elsCmd> to remote NPORT <did> */ |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3415 | if (logerr) { |
| 3416 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3417 | "0137 No retry ELS command x%x to remote " |
| 3418 | "NPORT x%x: Out of Resources: Error:x%x/%x\n", |
| 3419 | cmd, did, irsp->ulpStatus, |
| 3420 | irsp->un.ulpWord[4]); |
| 3421 | } |
| 3422 | else { |
| 3423 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3424 | "0108 No retry ELS command x%x to remote " |
| 3425 | "NPORT x%x Retried:%d Error:x%x/%x\n", |
| 3426 | cmd, did, cmdiocb->retry, irsp->ulpStatus, |
| 3427 | irsp->un.ulpWord[4]); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3428 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3429 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3430 | } |
| 3431 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3432 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3433 | * 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] | 3434 | * @phba: pointer to lpfc hba data structure. |
| 3435 | * @buf_ptr1: pointer to the lpfc DMA buffer data structure. |
| 3436 | * |
| 3437 | * This routine releases the lpfc DMA (Direct Memory Access) buffer(s) |
| 3438 | * associated with a command IOCB back to the lpfc DMA buffer pool. It first |
| 3439 | * checks to see whether there is a lpfc DMA buffer associated with the |
| 3440 | * response of the command IOCB. If so, it will be released before releasing |
| 3441 | * the lpfc DMA buffer associated with the IOCB itself. |
| 3442 | * |
| 3443 | * Return code |
| 3444 | * 0 - Successfully released lpfc DMA buffer (currently, always return 0) |
| 3445 | **/ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3446 | static int |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3447 | lpfc_els_free_data(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr1) |
| 3448 | { |
| 3449 | struct lpfc_dmabuf *buf_ptr; |
| 3450 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3451 | /* Free the response before processing the command. */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3452 | if (!list_empty(&buf_ptr1->list)) { |
| 3453 | list_remove_head(&buf_ptr1->list, buf_ptr, |
| 3454 | struct lpfc_dmabuf, |
| 3455 | list); |
| 3456 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 3457 | kfree(buf_ptr); |
| 3458 | } |
| 3459 | lpfc_mbuf_free(phba, buf_ptr1->virt, buf_ptr1->phys); |
| 3460 | kfree(buf_ptr1); |
| 3461 | return 0; |
| 3462 | } |
| 3463 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3464 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3465 | * 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] | 3466 | * @phba: pointer to lpfc hba data structure. |
| 3467 | * @buf_ptr: pointer to the lpfc dma buffer data structure. |
| 3468 | * |
| 3469 | * This routine releases the lpfc Direct Memory Access (DMA) buffer |
| 3470 | * associated with a Buffer Pointer List (BPL) back to the lpfc DMA buffer |
| 3471 | * pool. |
| 3472 | * |
| 3473 | * Return code |
| 3474 | * 0 - Successfully released lpfc DMA buffer (currently, always return 0) |
| 3475 | **/ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3476 | static int |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3477 | lpfc_els_free_bpl(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr) |
| 3478 | { |
| 3479 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 3480 | kfree(buf_ptr); |
| 3481 | return 0; |
| 3482 | } |
| 3483 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3484 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3485 | * lpfc_els_free_iocb - Free a command iocb and its associated resources |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3486 | * @phba: pointer to lpfc hba data structure. |
| 3487 | * @elsiocb: pointer to lpfc els command iocb data structure. |
| 3488 | * |
| 3489 | * This routine frees a command IOCB and its associated resources. The |
| 3490 | * command IOCB data structure contains the reference to various associated |
| 3491 | * resources, these fields must be set to NULL if the associated reference |
| 3492 | * not present: |
| 3493 | * context1 - reference to ndlp |
| 3494 | * context2 - reference to cmd |
| 3495 | * context2->next - reference to rsp |
| 3496 | * context3 - reference to bpl |
| 3497 | * |
| 3498 | * It first properly decrements the reference count held on ndlp for the |
| 3499 | * IOCB completion callback function. If LPFC_DELAY_MEM_FREE flag is not |
| 3500 | * set, it invokes the lpfc_els_free_data() routine to release the Direct |
| 3501 | * Memory Access (DMA) buffers associated with the IOCB. Otherwise, it |
| 3502 | * adds the DMA buffer the @phba data structure for the delayed release. |
| 3503 | * If reference to the Buffer Pointer List (BPL) is present, the |
| 3504 | * lpfc_els_free_bpl() routine is invoked to release the DMA memory |
| 3505 | * associated with BPL. Finally, the lpfc_sli_release_iocbq() routine is |
| 3506 | * invoked to release the IOCB data structure back to @phba IOCBQ list. |
| 3507 | * |
| 3508 | * Return code |
| 3509 | * 0 - Success (currently, always return 0) |
| 3510 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3511 | int |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3512 | lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3513 | { |
| 3514 | struct lpfc_dmabuf *buf_ptr, *buf_ptr1; |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3515 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3516 | |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3517 | ndlp = (struct lpfc_nodelist *)elsiocb->context1; |
| 3518 | if (ndlp) { |
| 3519 | if (ndlp->nlp_flag & NLP_DEFER_RM) { |
| 3520 | lpfc_nlp_put(ndlp); |
| 3521 | |
| 3522 | /* If the ndlp is not being used by another discovery |
| 3523 | * thread, free it. |
| 3524 | */ |
| 3525 | if (!lpfc_nlp_not_used(ndlp)) { |
| 3526 | /* If ndlp is being used by another discovery |
| 3527 | * thread, just clear NLP_DEFER_RM |
| 3528 | */ |
| 3529 | ndlp->nlp_flag &= ~NLP_DEFER_RM; |
| 3530 | } |
| 3531 | } |
| 3532 | else |
| 3533 | lpfc_nlp_put(ndlp); |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3534 | elsiocb->context1 = NULL; |
| 3535 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3536 | /* context2 = cmd, context2->next = rsp, context3 = bpl */ |
| 3537 | if (elsiocb->context2) { |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 3538 | if (elsiocb->iocb_flag & LPFC_DELAY_MEM_FREE) { |
| 3539 | /* Firmware could still be in progress of DMAing |
| 3540 | * payload, so don't free data buffer till after |
| 3541 | * a hbeat. |
| 3542 | */ |
| 3543 | elsiocb->iocb_flag &= ~LPFC_DELAY_MEM_FREE; |
| 3544 | buf_ptr = elsiocb->context2; |
| 3545 | elsiocb->context2 = NULL; |
| 3546 | if (buf_ptr) { |
| 3547 | buf_ptr1 = NULL; |
| 3548 | spin_lock_irq(&phba->hbalock); |
| 3549 | if (!list_empty(&buf_ptr->list)) { |
| 3550 | list_remove_head(&buf_ptr->list, |
| 3551 | buf_ptr1, struct lpfc_dmabuf, |
| 3552 | list); |
| 3553 | INIT_LIST_HEAD(&buf_ptr1->list); |
| 3554 | list_add_tail(&buf_ptr1->list, |
| 3555 | &phba->elsbuf); |
| 3556 | phba->elsbuf_cnt++; |
| 3557 | } |
| 3558 | INIT_LIST_HEAD(&buf_ptr->list); |
| 3559 | list_add_tail(&buf_ptr->list, &phba->elsbuf); |
| 3560 | phba->elsbuf_cnt++; |
| 3561 | spin_unlock_irq(&phba->hbalock); |
| 3562 | } |
| 3563 | } else { |
| 3564 | buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2; |
| 3565 | lpfc_els_free_data(phba, buf_ptr1); |
| 3566 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3567 | } |
| 3568 | |
| 3569 | if (elsiocb->context3) { |
| 3570 | buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3571 | lpfc_els_free_bpl(phba, buf_ptr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3572 | } |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 3573 | lpfc_sli_release_iocbq(phba, elsiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3574 | return 0; |
| 3575 | } |
| 3576 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3577 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3578 | * lpfc_cmpl_els_logo_acc - Completion callback function to logo acc response |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3579 | * @phba: pointer to lpfc hba data structure. |
| 3580 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 3581 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 3582 | * |
| 3583 | * This routine is the completion callback function to the Logout (LOGO) |
| 3584 | * Accept (ACC) Response ELS command. This routine is invoked to indicate |
| 3585 | * the completion of the LOGO process. It invokes the lpfc_nlp_not_used() to |
| 3586 | * release the ndlp if it has the last reference remaining (reference count |
| 3587 | * is 1). If succeeded (meaning ndlp released), it sets the IOCB context1 |
| 3588 | * field to NULL to inform the following lpfc_els_free_iocb() routine no |
| 3589 | * ndlp reference count needs to be decremented. Otherwise, the ndlp |
| 3590 | * reference use-count shall be decremented by the lpfc_els_free_iocb() |
| 3591 | * routine. Finally, the lpfc_els_free_iocb() is invoked to release the |
| 3592 | * IOCB data structure. |
| 3593 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3594 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3595 | lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 3596 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3597 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3598 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 3599 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3600 | IOCB_t *irsp; |
| 3601 | |
| 3602 | irsp = &rspiocb->iocb; |
| 3603 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3604 | "ACC LOGO cmpl: status:x%x/x%x did:x%x", |
| 3605 | irsp->ulpStatus, irsp->un.ulpWord[4], ndlp->nlp_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3606 | /* ACC to LOGO completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3607 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3608 | "0109 ACC to LOGO completes to NPort x%x " |
| 3609 | "Data: x%x x%x x%x\n", |
| 3610 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3611 | ndlp->nlp_rpi); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3612 | |
| 3613 | if (ndlp->nlp_state == NLP_STE_NPR_NODE) { |
| 3614 | /* NPort Recovery mode or node is just allocated */ |
| 3615 | if (!lpfc_nlp_not_used(ndlp)) { |
| 3616 | /* If the ndlp is being used by another discovery |
| 3617 | * thread, just unregister the RPI. |
| 3618 | */ |
| 3619 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3620 | } else { |
| 3621 | /* Indicate the node has already released, should |
| 3622 | * not reference to it from within lpfc_els_free_iocb. |
| 3623 | */ |
| 3624 | cmdiocb->context1 = NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3625 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3626 | } |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 3627 | |
| 3628 | /* |
| 3629 | * 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] | 3630 | * At this point, the driver is done so release the IOCB |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 3631 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3632 | lpfc_els_free_iocb(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3633 | } |
| 3634 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3635 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3636 | * 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] | 3637 | * @phba: pointer to lpfc hba data structure. |
| 3638 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 3639 | * |
| 3640 | * This routine is the completion callback function for unregister default |
| 3641 | * RPI (Remote Port Index) mailbox command to the @phba. It simply releases |
| 3642 | * the associated lpfc Direct Memory Access (DMA) buffer back to the pool and |
| 3643 | * decrements the ndlp reference count held for this completion callback |
| 3644 | * function. After that, it invokes the lpfc_nlp_not_used() to check |
| 3645 | * whether there is only one reference left on the ndlp. If so, it will |
| 3646 | * perform one more decrement and trigger the release of the ndlp. |
| 3647 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3648 | void |
| 3649 | lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
| 3650 | { |
| 3651 | struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1); |
| 3652 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2; |
| 3653 | |
| 3654 | pmb->context1 = NULL; |
James Smart | d439d28 | 2010-09-29 11:18:45 -0400 | [diff] [blame] | 3655 | pmb->context2 = NULL; |
| 3656 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3657 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3658 | kfree(mp); |
| 3659 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 3660 | if (ndlp) { |
James Smart | be6bb94 | 2015-04-07 15:07:22 -0400 | [diff] [blame] | 3661 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE, |
| 3662 | "0006 rpi%x DID:%x flg:%x %d map:%x %p\n", |
| 3663 | ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag, |
| 3664 | atomic_read(&ndlp->kref.refcount), |
| 3665 | ndlp->nlp_usg_map, ndlp); |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 3666 | if (NLP_CHK_NODE_ACT(ndlp)) { |
| 3667 | lpfc_nlp_put(ndlp); |
| 3668 | /* This is the end of the default RPI cleanup logic for |
| 3669 | * this ndlp. If no other discovery threads are using |
| 3670 | * this ndlp, free all resources associated with it. |
| 3671 | */ |
| 3672 | lpfc_nlp_not_used(ndlp); |
| 3673 | } else { |
| 3674 | lpfc_drop_node(ndlp->vport, ndlp); |
| 3675 | } |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3676 | } |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 3677 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3678 | return; |
| 3679 | } |
| 3680 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3681 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3682 | * lpfc_cmpl_els_rsp - Completion callback function for els response iocb cmd |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3683 | * @phba: pointer to lpfc hba data structure. |
| 3684 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 3685 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 3686 | * |
| 3687 | * This routine is the completion callback function for ELS Response IOCB |
| 3688 | * command. In normal case, this callback function just properly sets the |
| 3689 | * nlp_flag bitmap in the ndlp data structure, if the mbox command reference |
| 3690 | * field in the command IOCB is not NULL, the referred mailbox command will |
| 3691 | * be send out, and then invokes the lpfc_els_free_iocb() routine to release |
| 3692 | * the IOCB. Under error conditions, such as when a LS_RJT is returned or a |
| 3693 | * link down event occurred during the discovery, the lpfc_nlp_not_used() |
| 3694 | * routine shall be invoked trying to release the ndlp if no other threads |
| 3695 | * are currently referring it. |
| 3696 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3697 | static void |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3698 | lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3699 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3700 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3701 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 3702 | struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL; |
| 3703 | struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3704 | IOCB_t *irsp; |
| 3705 | uint8_t *pcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3706 | LPFC_MBOXQ_t *mbox = NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3707 | struct lpfc_dmabuf *mp = NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3708 | uint32_t ls_rjt = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3709 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 3710 | irsp = &rspiocb->iocb; |
| 3711 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3712 | if (cmdiocb->context_un.mbox) |
| 3713 | mbox = cmdiocb->context_un.mbox; |
| 3714 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3715 | /* First determine if this is a LS_RJT cmpl. Note, this callback |
| 3716 | * function can have cmdiocb->contest1 (ndlp) field set to NULL. |
| 3717 | */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3718 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3719 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 3720 | (*((uint32_t *) (pcmd)) == ELS_CMD_LS_RJT)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3721 | /* A LS_RJT associated with Default RPI cleanup has its own |
Daniel Mack | 3ad2f3fb | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 3722 | * separate code path. |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3723 | */ |
| 3724 | if (!(ndlp->nlp_flag & NLP_RM_DFLT_RPI)) |
| 3725 | ls_rjt = 1; |
| 3726 | } |
| 3727 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3728 | /* Check to see if link went down during discovery */ |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3729 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) || lpfc_els_chk_latt(vport)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3730 | if (mbox) { |
James Smart | 1469115 | 2006-12-02 13:34:28 -0500 | [diff] [blame] | 3731 | mp = (struct lpfc_dmabuf *) mbox->context1; |
| 3732 | if (mp) { |
| 3733 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3734 | kfree(mp); |
| 3735 | } |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3736 | mempool_free(mbox, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3737 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3738 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 3739 | (ndlp->nlp_flag & NLP_RM_DFLT_RPI)) |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3740 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3741 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3742 | /* Indicate the node has already released, |
| 3743 | * should not reference to it from within |
| 3744 | * the routine lpfc_els_free_iocb. |
| 3745 | */ |
| 3746 | cmdiocb->context1 = NULL; |
| 3747 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3748 | goto out; |
| 3749 | } |
| 3750 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3751 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3752 | "ELS rsp cmpl: status:x%x/x%x did:x%x", |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3753 | irsp->ulpStatus, irsp->un.ulpWord[4], |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3754 | cmdiocb->iocb.un.elsreq64.remoteID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3755 | /* ELS response tag <ulpIoTag> completes */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3756 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3757 | "0110 ELS response tag x%x completes " |
| 3758 | "Data: x%x x%x x%x x%x x%x x%x x%x\n", |
| 3759 | cmdiocb->iocb.ulpIoTag, rspiocb->iocb.ulpStatus, |
| 3760 | rspiocb->iocb.un.ulpWord[4], rspiocb->iocb.ulpTimeout, |
| 3761 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3762 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3763 | if (mbox) { |
| 3764 | if ((rspiocb->iocb.ulpStatus == 0) |
| 3765 | && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3766 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3767 | /* Increment reference count to ndlp to hold the |
| 3768 | * reference to ndlp for the callback function. |
| 3769 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3770 | mbox->context2 = lpfc_nlp_get(ndlp); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3771 | mbox->vport = vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3772 | if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) { |
| 3773 | mbox->mbox_flag |= LPFC_MBX_IMED_UNREG; |
| 3774 | mbox->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi; |
| 3775 | } |
| 3776 | else { |
| 3777 | mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; |
| 3778 | ndlp->nlp_prev_state = ndlp->nlp_state; |
| 3779 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3780 | NLP_STE_REG_LOGIN_ISSUE); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3781 | } |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 3782 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3783 | != MBX_NOT_FINISHED) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3784 | goto out; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3785 | else |
| 3786 | /* Decrement the ndlp reference count we |
| 3787 | * set for this failed mailbox command. |
| 3788 | */ |
| 3789 | lpfc_nlp_put(ndlp); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3790 | |
| 3791 | /* ELS rsp: Cannot issue reg_login for <NPortid> */ |
| 3792 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3793 | "0138 ELS rsp: Cannot issue reg_login for x%x " |
| 3794 | "Data: x%x x%x x%x\n", |
| 3795 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3796 | ndlp->nlp_rpi); |
| 3797 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3798 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3799 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3800 | /* Indicate node has already been released, |
| 3801 | * should not reference to it from within |
| 3802 | * the routine lpfc_els_free_iocb. |
| 3803 | */ |
| 3804 | cmdiocb->context1 = NULL; |
| 3805 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3806 | } else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3807 | /* Do not drop node for lpfc_els_abort'ed ELS cmds */ |
| 3808 | if (!lpfc_error_lost_link(irsp) && |
| 3809 | ndlp->nlp_flag & NLP_ACC_REGLOGIN) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3810 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3811 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3812 | /* Indicate node has already been |
| 3813 | * released, should not reference |
| 3814 | * to it from within the routine |
| 3815 | * lpfc_els_free_iocb. |
| 3816 | */ |
| 3817 | cmdiocb->context1 = NULL; |
| 3818 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3819 | } |
| 3820 | } |
James Smart | 1469115 | 2006-12-02 13:34:28 -0500 | [diff] [blame] | 3821 | mp = (struct lpfc_dmabuf *) mbox->context1; |
| 3822 | if (mp) { |
| 3823 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3824 | kfree(mp); |
| 3825 | } |
| 3826 | mempool_free(mbox, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3827 | } |
| 3828 | out: |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3829 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3830 | spin_lock_irq(shost->host_lock); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3831 | ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3832 | spin_unlock_irq(shost->host_lock); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3833 | |
| 3834 | /* If the node is not being used by another discovery thread, |
| 3835 | * and we are sending a reject, we are done with it. |
| 3836 | * Release driver reference count here and free associated |
| 3837 | * resources. |
| 3838 | */ |
| 3839 | if (ls_rjt) |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3840 | if (lpfc_nlp_not_used(ndlp)) |
| 3841 | /* Indicate node has already been released, |
| 3842 | * should not reference to it from within |
| 3843 | * the routine lpfc_els_free_iocb. |
| 3844 | */ |
| 3845 | cmdiocb->context1 = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3846 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3847 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3848 | lpfc_els_free_iocb(phba, cmdiocb); |
| 3849 | return; |
| 3850 | } |
| 3851 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3852 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3853 | * lpfc_els_rsp_acc - Prepare and issue an acc response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3854 | * @vport: pointer to a host virtual N_Port data structure. |
| 3855 | * @flag: the els command code to be accepted. |
| 3856 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 3857 | * @ndlp: pointer to a node-list data structure. |
| 3858 | * @mbox: pointer to the driver internal queue element for mailbox command. |
| 3859 | * |
| 3860 | * This routine prepares and issues an Accept (ACC) response IOCB |
| 3861 | * command. It uses the @flag to properly set up the IOCB field for the |
| 3862 | * specific ACC response command to be issued and invokes the |
| 3863 | * lpfc_sli_issue_iocb() routine to send out ACC response IOCB. If a |
| 3864 | * @mbox pointer is passed in, it will be put into the context_un.mbox |
| 3865 | * field of the IOCB for the completion callback function to issue the |
| 3866 | * mailbox command to the HBA later when callback is invoked. |
| 3867 | * |
| 3868 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 3869 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 3870 | * will be stored into the context1 field of the IOCB for the completion |
| 3871 | * callback function to the corresponding response ELS IOCB command. |
| 3872 | * |
| 3873 | * Return code |
| 3874 | * 0 - Successfully issued acc response |
| 3875 | * 1 - Failed to issue acc response |
| 3876 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3877 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3878 | lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, |
| 3879 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3880 | LPFC_MBOXQ_t *mbox) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3881 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3882 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3883 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3884 | IOCB_t *icmd; |
| 3885 | IOCB_t *oldcmd; |
| 3886 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3887 | uint8_t *pcmd; |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 3888 | struct serv_parm *sp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3889 | uint16_t cmdsize; |
| 3890 | int rc; |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3891 | ELS_PKT *els_pkt_ptr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3892 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3893 | oldcmd = &oldiocb->iocb; |
| 3894 | |
| 3895 | switch (flag) { |
| 3896 | case ELS_CMD_ACC: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3897 | cmdsize = sizeof(uint32_t); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3898 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
| 3899 | ndlp, ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3900 | if (!elsiocb) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3901 | spin_lock_irq(shost->host_lock); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3902 | ndlp->nlp_flag &= ~NLP_LOGO_ACC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3903 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3904 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3905 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3906 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3907 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 3908 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 3909 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3910 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3911 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3912 | pcmd += sizeof(uint32_t); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3913 | |
| 3914 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3915 | "Issue ACC: did:x%x flg:x%x", |
| 3916 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3917 | break; |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 3918 | case ELS_CMD_FLOGI: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3919 | case ELS_CMD_PLOGI: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3920 | cmdsize = (sizeof(struct serv_parm) + sizeof(uint32_t)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3921 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
| 3922 | ndlp, ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3923 | if (!elsiocb) |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3924 | return 1; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3925 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3926 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 3927 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 3928 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3929 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3930 | |
| 3931 | if (mbox) |
| 3932 | elsiocb->context_un.mbox = mbox; |
| 3933 | |
| 3934 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3935 | pcmd += sizeof(uint32_t); |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 3936 | sp = (struct serv_parm *)pcmd; |
| 3937 | |
| 3938 | if (flag == ELS_CMD_FLOGI) { |
| 3939 | /* Copy the received service parameters back */ |
| 3940 | memcpy(sp, &phba->fc_fabparam, |
| 3941 | sizeof(struct serv_parm)); |
| 3942 | |
| 3943 | /* Clear the F_Port bit */ |
| 3944 | sp->cmn.fPort = 0; |
| 3945 | |
| 3946 | /* Mark all class service parameters as invalid */ |
| 3947 | sp->cls1.classValid = 0; |
| 3948 | sp->cls2.classValid = 0; |
| 3949 | sp->cls3.classValid = 0; |
| 3950 | sp->cls4.classValid = 0; |
| 3951 | |
| 3952 | /* Copy our worldwide names */ |
| 3953 | memcpy(&sp->portName, &vport->fc_sparam.portName, |
| 3954 | sizeof(struct lpfc_name)); |
| 3955 | memcpy(&sp->nodeName, &vport->fc_sparam.nodeName, |
| 3956 | sizeof(struct lpfc_name)); |
| 3957 | } else { |
| 3958 | memcpy(pcmd, &vport->fc_sparam, |
| 3959 | sizeof(struct serv_parm)); |
| 3960 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3961 | |
| 3962 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 3963 | "Issue ACC FLOGI/PLOGI: did:x%x flg:x%x", |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3964 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3965 | break; |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3966 | case ELS_CMD_PRLO: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3967 | cmdsize = sizeof(uint32_t) + sizeof(PRLO); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3968 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3969 | ndlp, ndlp->nlp_DID, ELS_CMD_PRLO); |
| 3970 | if (!elsiocb) |
| 3971 | return 1; |
| 3972 | |
| 3973 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 3974 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 3975 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3976 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3977 | |
| 3978 | memcpy(pcmd, ((struct lpfc_dmabuf *) oldiocb->context2)->virt, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3979 | sizeof(uint32_t) + sizeof(PRLO)); |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3980 | *((uint32_t *) (pcmd)) = ELS_CMD_PRLO_ACC; |
| 3981 | els_pkt_ptr = (ELS_PKT *) pcmd; |
| 3982 | els_pkt_ptr->un.prlo.acceptRspCode = PRLO_REQ_EXECUTED; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3983 | |
| 3984 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3985 | "Issue ACC PRLO: did:x%x flg:x%x", |
| 3986 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3987 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3988 | default: |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3989 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3990 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3991 | /* Xmit ELS ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3992 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3993 | "0128 Xmit ELS ACC response tag x%x, XRI: x%x, " |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 3994 | "DID: x%x, nlp_flag: x%x nlp_state: x%x RPI: x%x " |
| 3995 | "fc_flag x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3996 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 3997 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
James Smart | e644643 | 2012-05-09 21:16:42 -0400 | [diff] [blame] | 3998 | ndlp->nlp_rpi, vport->fc_flag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3999 | if (ndlp->nlp_flag & NLP_LOGO_ACC) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4000 | spin_lock_irq(shost->host_lock); |
James Smart | 7c5e518 | 2015-05-22 10:42:43 -0400 | [diff] [blame] | 4001 | if (!(ndlp->nlp_flag & NLP_RPI_REGISTERED || |
| 4002 | ndlp->nlp_flag & NLP_REG_LOGIN_SEND)) |
| 4003 | ndlp->nlp_flag &= ~NLP_LOGO_ACC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4004 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4005 | elsiocb->iocb_cmpl = lpfc_cmpl_els_logo_acc; |
| 4006 | } else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4007 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4008 | } |
| 4009 | |
| 4010 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4011 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4012 | if (rc == IOCB_ERROR) { |
| 4013 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4014 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4015 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4016 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4017 | } |
| 4018 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4019 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4020 | * lpfc_els_rsp_reject - Propare and issue a rjt response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4021 | * @vport: pointer to a virtual N_Port data structure. |
| 4022 | * @rejectError: |
| 4023 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4024 | * @ndlp: pointer to a node-list data structure. |
| 4025 | * @mbox: pointer to the driver internal queue element for mailbox command. |
| 4026 | * |
| 4027 | * This routine prepares and issue an Reject (RJT) response IOCB |
| 4028 | * command. If a @mbox pointer is passed in, it will be put into the |
| 4029 | * context_un.mbox field of the IOCB for the completion callback function |
| 4030 | * to issue to the HBA later. |
| 4031 | * |
| 4032 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4033 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4034 | * will be stored into the context1 field of the IOCB for the completion |
| 4035 | * callback function to the reject response ELS IOCB command. |
| 4036 | * |
| 4037 | * Return code |
| 4038 | * 0 - Successfully issued reject response |
| 4039 | * 1 - Failed to issue reject response |
| 4040 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4041 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4042 | lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4043 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, |
| 4044 | LPFC_MBOXQ_t *mbox) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4045 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4046 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4047 | IOCB_t *icmd; |
| 4048 | IOCB_t *oldcmd; |
| 4049 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4050 | uint8_t *pcmd; |
| 4051 | uint16_t cmdsize; |
| 4052 | int rc; |
| 4053 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4054 | cmdsize = 2 * sizeof(uint32_t); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4055 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4056 | ndlp->nlp_DID, ELS_CMD_LS_RJT); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 4057 | if (!elsiocb) |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4058 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4059 | |
| 4060 | icmd = &elsiocb->iocb; |
| 4061 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4062 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4063 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4064 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4065 | |
| 4066 | *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4067 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4068 | *((uint32_t *) (pcmd)) = rejectError; |
| 4069 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4070 | if (mbox) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4071 | elsiocb->context_un.mbox = mbox; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4072 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4073 | /* Xmit ELS RJT <err> response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4074 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4075 | "0129 Xmit ELS RJT x%x response tag x%x " |
| 4076 | "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " |
| 4077 | "rpi x%x\n", |
| 4078 | rejectError, elsiocb->iotag, |
| 4079 | elsiocb->iocb.ulpContext, ndlp->nlp_DID, |
| 4080 | ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4081 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4082 | "Issue LS_RJT: did:x%x flg:x%x err:x%x", |
| 4083 | ndlp->nlp_DID, ndlp->nlp_flag, rejectError); |
| 4084 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4085 | phba->fc_stat.elsXmitLSRJT++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4086 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4087 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4088 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4089 | if (rc == IOCB_ERROR) { |
| 4090 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4091 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4092 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4093 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4094 | } |
| 4095 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4096 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4097 | * 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] | 4098 | * @vport: pointer to a virtual N_Port data structure. |
| 4099 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4100 | * @ndlp: pointer to a node-list data structure. |
| 4101 | * |
| 4102 | * This routine prepares and issues an Accept (ACC) response to Address |
| 4103 | * Discover (ADISC) ELS command. It simply prepares the payload of the IOCB |
| 4104 | * and invokes the lpfc_sli_issue_iocb() routine to send out the command. |
| 4105 | * |
| 4106 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4107 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4108 | * will be stored into the context1 field of the IOCB for the completion |
| 4109 | * callback function to the ADISC Accept response ELS IOCB command. |
| 4110 | * |
| 4111 | * Return code |
| 4112 | * 0 - Successfully issued acc adisc response |
| 4113 | * 1 - Failed to issue adisc acc response |
| 4114 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4115 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4116 | lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, |
| 4117 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4118 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4119 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4120 | ADISC *ap; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4121 | IOCB_t *icmd, *oldcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4122 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4123 | uint8_t *pcmd; |
| 4124 | uint16_t cmdsize; |
| 4125 | int rc; |
| 4126 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4127 | cmdsize = sizeof(uint32_t) + sizeof(ADISC); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4128 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4129 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 4130 | if (!elsiocb) |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4131 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4132 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4133 | icmd = &elsiocb->iocb; |
| 4134 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4135 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4136 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 4137 | |
| 4138 | /* Xmit ADISC ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4139 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4140 | "0130 Xmit ADISC ACC response iotag x%x xri: " |
| 4141 | "x%x, did x%x, nlp_flag x%x, nlp_state x%x rpi x%x\n", |
| 4142 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 4143 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 4144 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4145 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4146 | |
| 4147 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4148 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4149 | |
| 4150 | ap = (ADISC *) (pcmd); |
| 4151 | ap->hardAL_PA = phba->fc_pref_ALPA; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4152 | memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 4153 | memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4154 | ap->DID = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4155 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4156 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4157 | "Issue ACC ADISC: did:x%x flg:x%x", |
| 4158 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4159 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4160 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4161 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4162 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4163 | if (rc == IOCB_ERROR) { |
| 4164 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4165 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4166 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4167 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4168 | } |
| 4169 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4170 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4171 | * 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] | 4172 | * @vport: pointer to a virtual N_Port data structure. |
| 4173 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4174 | * @ndlp: pointer to a node-list data structure. |
| 4175 | * |
| 4176 | * This routine prepares and issues an Accept (ACC) response to Process |
| 4177 | * Login (PRLI) ELS command. It simply prepares the payload of the IOCB |
| 4178 | * and invokes the lpfc_sli_issue_iocb() routine to send out the command. |
| 4179 | * |
| 4180 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4181 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4182 | * will be stored into the context1 field of the IOCB for the completion |
| 4183 | * callback function to the PRLI Accept response ELS IOCB command. |
| 4184 | * |
| 4185 | * Return code |
| 4186 | * 0 - Successfully issued acc prli response |
| 4187 | * 1 - Failed to issue acc prli response |
| 4188 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4189 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4190 | 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] | 4191 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4192 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4193 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4194 | PRLI *npr; |
| 4195 | lpfc_vpd_t *vpd; |
| 4196 | IOCB_t *icmd; |
| 4197 | IOCB_t *oldcmd; |
| 4198 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4199 | uint8_t *pcmd; |
| 4200 | uint16_t cmdsize; |
| 4201 | int rc; |
| 4202 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4203 | cmdsize = sizeof(uint32_t) + sizeof(PRLI); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4204 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4205 | ndlp->nlp_DID, (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK))); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4206 | if (!elsiocb) |
| 4207 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4208 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4209 | icmd = &elsiocb->iocb; |
| 4210 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4211 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4212 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| 4213 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 4214 | /* Xmit PRLI ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4215 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4216 | "0131 Xmit PRLI ACC response tag x%x xri x%x, " |
| 4217 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", |
| 4218 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 4219 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 4220 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4221 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4222 | |
| 4223 | *((uint32_t *) (pcmd)) = (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4224 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4225 | |
| 4226 | /* For PRLI, remainder of payload is PRLI parameter page */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4227 | memset(pcmd, 0, sizeof(PRLI)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4228 | |
| 4229 | npr = (PRLI *) pcmd; |
| 4230 | vpd = &phba->vpd; |
| 4231 | /* |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4232 | * If the remote port is a target and our firmware version is 3.20 or |
| 4233 | * later, set the following bits for FC-TAPE support. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4234 | */ |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4235 | if ((ndlp->nlp_type & NLP_FCP_TARGET) && |
| 4236 | (vpd->rev.feaLevelHigh >= 0x02)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4237 | npr->ConfmComplAllowed = 1; |
| 4238 | npr->Retry = 1; |
| 4239 | npr->TaskRetryIdReq = 1; |
| 4240 | } |
| 4241 | |
| 4242 | npr->acceptRspCode = PRLI_REQ_EXECUTED; |
| 4243 | npr->estabImagePair = 1; |
| 4244 | npr->readXferRdyDis = 1; |
| 4245 | npr->ConfmComplAllowed = 1; |
| 4246 | |
| 4247 | npr->prliType = PRLI_FCP_TYPE; |
| 4248 | npr->initiatorFunc = 1; |
| 4249 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4250 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4251 | "Issue ACC PRLI: did:x%x flg:x%x", |
| 4252 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4253 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4254 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4255 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4256 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4257 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4258 | if (rc == IOCB_ERROR) { |
| 4259 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4260 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4261 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4262 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4263 | } |
| 4264 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4265 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4266 | * lpfc_els_rsp_rnid_acc - Issue rnid acc response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4267 | * @vport: pointer to a virtual N_Port data structure. |
| 4268 | * @format: rnid command format. |
| 4269 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4270 | * @ndlp: pointer to a node-list data structure. |
| 4271 | * |
| 4272 | * This routine issues a Request Node Identification Data (RNID) Accept |
| 4273 | * (ACC) response. It constructs the RNID ACC response command according to |
| 4274 | * the proper @format and then calls the lpfc_sli_issue_iocb() routine to |
| 4275 | * issue the response. Note that this command does not need to hold the ndlp |
| 4276 | * reference count for the callback. So, the ndlp reference count taken by |
| 4277 | * the lpfc_prep_els_iocb() routine is put back and the context1 field of |
| 4278 | * IOCB is set to NULL to indicate to the lpfc_els_free_iocb() routine that |
| 4279 | * there is no ndlp reference available. |
| 4280 | * |
| 4281 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4282 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4283 | * will be stored into the context1 field of the IOCB for the completion |
| 4284 | * callback function. However, for the RNID Accept Response ELS command, |
| 4285 | * this is undone later by this routine after the IOCB is allocated. |
| 4286 | * |
| 4287 | * Return code |
| 4288 | * 0 - Successfully issued acc rnid response |
| 4289 | * 1 - Failed to issue acc rnid response |
| 4290 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4291 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4292 | lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 4293 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4294 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4295 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4296 | RNID *rn; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4297 | IOCB_t *icmd, *oldcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4298 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4299 | uint8_t *pcmd; |
| 4300 | uint16_t cmdsize; |
| 4301 | int rc; |
| 4302 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4303 | cmdsize = sizeof(uint32_t) + sizeof(uint32_t) |
| 4304 | + (2 * sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4305 | if (format) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4306 | cmdsize += sizeof(RNID_TOP_DISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4307 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4308 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4309 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 4310 | if (!elsiocb) |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4311 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4312 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4313 | icmd = &elsiocb->iocb; |
| 4314 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4315 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 4316 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
| 4317 | |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 4318 | /* Xmit RNID ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4319 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4320 | "0132 Xmit RNID ACC response tag x%x xri x%x\n", |
| 4321 | elsiocb->iotag, elsiocb->iocb.ulpContext); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4322 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4323 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4324 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4325 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4326 | memset(pcmd, 0, sizeof(RNID)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4327 | rn = (RNID *) (pcmd); |
| 4328 | rn->Format = format; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4329 | rn->CommonLen = (2 * sizeof(struct lpfc_name)); |
| 4330 | memcpy(&rn->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 4331 | memcpy(&rn->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4332 | switch (format) { |
| 4333 | case 0: |
| 4334 | rn->SpecificLen = 0; |
| 4335 | break; |
| 4336 | case RNID_TOPOLOGY_DISC: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4337 | rn->SpecificLen = sizeof(RNID_TOP_DISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4338 | memcpy(&rn->un.topologyDisc.portName, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4339 | &vport->fc_portname, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4340 | rn->un.topologyDisc.unitType = RNID_HBA; |
| 4341 | rn->un.topologyDisc.physPort = 0; |
| 4342 | rn->un.topologyDisc.attachedNodes = 0; |
| 4343 | break; |
| 4344 | default: |
| 4345 | rn->CommonLen = 0; |
| 4346 | rn->SpecificLen = 0; |
| 4347 | break; |
| 4348 | } |
| 4349 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4350 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4351 | "Issue ACC RNID: did:x%x flg:x%x", |
| 4352 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4353 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4354 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4355 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4356 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4357 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4358 | if (rc == IOCB_ERROR) { |
| 4359 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4360 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4361 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4362 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4363 | } |
| 4364 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4365 | /** |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4366 | * lpfc_els_clear_rrq - Clear the rq that this rrq describes. |
| 4367 | * @vport: pointer to a virtual N_Port data structure. |
| 4368 | * @iocb: pointer to the lpfc command iocb data structure. |
| 4369 | * @ndlp: pointer to a node-list data structure. |
| 4370 | * |
| 4371 | * Return |
| 4372 | **/ |
| 4373 | static void |
| 4374 | lpfc_els_clear_rrq(struct lpfc_vport *vport, |
| 4375 | struct lpfc_iocbq *iocb, struct lpfc_nodelist *ndlp) |
| 4376 | { |
| 4377 | struct lpfc_hba *phba = vport->phba; |
| 4378 | uint8_t *pcmd; |
| 4379 | struct RRQ *rrq; |
| 4380 | uint16_t rxid; |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4381 | uint16_t xri; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4382 | struct lpfc_node_rrq *prrq; |
| 4383 | |
| 4384 | |
| 4385 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) iocb->context2)->virt); |
| 4386 | pcmd += sizeof(uint32_t); |
| 4387 | rrq = (struct RRQ *)pcmd; |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4388 | rrq->rrq_exchg = be32_to_cpu(rrq->rrq_exchg); |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 4389 | rxid = bf_get(rrq_rxid, rrq); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4390 | |
| 4391 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4392 | "2883 Clear RRQ for SID:x%x OXID:x%x RXID:x%x" |
| 4393 | " x%x x%x\n", |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4394 | be32_to_cpu(bf_get(rrq_did, rrq)), |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 4395 | bf_get(rrq_oxid, rrq), |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4396 | rxid, |
| 4397 | iocb->iotag, iocb->iocb.ulpContext); |
| 4398 | |
| 4399 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4400 | "Clear RRQ: did:x%x flg:x%x exchg:x%.08x", |
| 4401 | ndlp->nlp_DID, ndlp->nlp_flag, rrq->rrq_exchg); |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4402 | if (vport->fc_myDID == be32_to_cpu(bf_get(rrq_did, rrq))) |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 4403 | xri = bf_get(rrq_oxid, rrq); |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4404 | else |
| 4405 | xri = rxid; |
| 4406 | prrq = lpfc_get_active_rrq(vport, xri, ndlp->nlp_DID); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4407 | if (prrq) |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 4408 | lpfc_clr_rrq_active(phba, xri, prrq); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 4409 | return; |
| 4410 | } |
| 4411 | |
| 4412 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4413 | * lpfc_els_rsp_echo_acc - Issue echo acc response |
| 4414 | * @vport: pointer to a virtual N_Port data structure. |
| 4415 | * @data: pointer to echo data to return in the accept. |
| 4416 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4417 | * @ndlp: pointer to a node-list data structure. |
| 4418 | * |
| 4419 | * Return code |
| 4420 | * 0 - Successfully issued acc echo response |
| 4421 | * 1 - Failed to issue acc echo response |
| 4422 | **/ |
| 4423 | static int |
| 4424 | lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data, |
| 4425 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) |
| 4426 | { |
| 4427 | struct lpfc_hba *phba = vport->phba; |
| 4428 | struct lpfc_iocbq *elsiocb; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4429 | uint8_t *pcmd; |
| 4430 | uint16_t cmdsize; |
| 4431 | int rc; |
| 4432 | |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4433 | cmdsize = oldiocb->iocb.unsli3.rcvsli3.acc_len; |
| 4434 | |
James Smart | bf08611 | 2011-08-21 21:48:13 -0400 | [diff] [blame] | 4435 | /* The accumulated length can exceed the BPL_SIZE. For |
| 4436 | * now, use this as the limit |
| 4437 | */ |
| 4438 | if (cmdsize > LPFC_BPL_SIZE) |
| 4439 | cmdsize = LPFC_BPL_SIZE; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4440 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4441 | ndlp->nlp_DID, ELS_CMD_ACC); |
| 4442 | if (!elsiocb) |
| 4443 | return 1; |
| 4444 | |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 4445 | elsiocb->iocb.ulpContext = oldiocb->iocb.ulpContext; /* Xri / rx_id */ |
| 4446 | elsiocb->iocb.unsli3.rcvsli3.ox_id = oldiocb->iocb.unsli3.rcvsli3.ox_id; |
| 4447 | |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4448 | /* Xmit ECHO ACC response tag <ulpIoTag> */ |
| 4449 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4450 | "2876 Xmit ECHO ACC response tag x%x xri x%x\n", |
| 4451 | elsiocb->iotag, elsiocb->iocb.ulpContext); |
| 4452 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4453 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
| 4454 | pcmd += sizeof(uint32_t); |
| 4455 | memcpy(pcmd, data, cmdsize - sizeof(uint32_t)); |
| 4456 | |
| 4457 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 4458 | "Issue ACC ECHO: did:x%x flg:x%x", |
| 4459 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 4460 | |
| 4461 | phba->fc_stat.elsXmitACC++; |
| 4462 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 4463 | |
| 4464 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| 4465 | if (rc == IOCB_ERROR) { |
| 4466 | lpfc_els_free_iocb(phba, elsiocb); |
| 4467 | return 1; |
| 4468 | } |
| 4469 | return 0; |
| 4470 | } |
| 4471 | |
| 4472 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4473 | * 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] | 4474 | * @vport: pointer to a host virtual N_Port data structure. |
| 4475 | * |
| 4476 | * This routine issues Address Discover (ADISC) ELS commands to those |
| 4477 | * N_Ports which are in node port recovery state and ADISC has not been issued |
| 4478 | * for the @vport. Each time an ELS ADISC IOCB is issued by invoking the |
| 4479 | * lpfc_issue_els_adisc() routine, the per @vport number of discover count |
| 4480 | * (num_disc_nodes) shall be incremented. If the num_disc_nodes reaches a |
| 4481 | * pre-configured threshold (cfg_discovery_threads), the @vport fc_flag will |
| 4482 | * be marked with FC_NLP_MORE bit and the process of issuing remaining ADISC |
| 4483 | * IOCBs quit for later pick up. On the other hand, after walking through |
| 4484 | * all the ndlps with the @vport and there is none ADISC IOCB issued, the |
| 4485 | * @vport fc_flag shall be cleared with FC_NLP_MORE bit indicating there is |
| 4486 | * no more ADISC need to be sent. |
| 4487 | * |
| 4488 | * Return code |
| 4489 | * The number of N_Ports with adisc issued. |
| 4490 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4491 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4492 | lpfc_els_disc_adisc(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4493 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4494 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4495 | struct lpfc_nodelist *ndlp, *next_ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4496 | int sentadisc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4497 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4498 | /* go thru NPR nodes and issue any remaining ELS ADISCs */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4499 | 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] | 4500 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4501 | continue; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4502 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && |
| 4503 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && |
| 4504 | (ndlp->nlp_flag & NLP_NPR_ADISC) != 0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4505 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4506 | ndlp->nlp_flag &= ~NLP_NPR_ADISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4507 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4508 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4509 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE); |
| 4510 | lpfc_issue_els_adisc(vport, ndlp, 0); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4511 | sentadisc++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4512 | vport->num_disc_nodes++; |
| 4513 | if (vport->num_disc_nodes >= |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4514 | vport->cfg_discovery_threads) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4515 | spin_lock_irq(shost->host_lock); |
| 4516 | vport->fc_flag |= FC_NLP_MORE; |
| 4517 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4518 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4519 | } |
| 4520 | } |
| 4521 | } |
| 4522 | if (sentadisc == 0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4523 | spin_lock_irq(shost->host_lock); |
| 4524 | vport->fc_flag &= ~FC_NLP_MORE; |
| 4525 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4526 | } |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 4527 | return sentadisc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4528 | } |
| 4529 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4530 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4531 | * 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] | 4532 | * @vport: pointer to a host virtual N_Port data structure. |
| 4533 | * |
| 4534 | * This routine issues Port Login (PLOGI) ELS commands to all the N_Ports |
| 4535 | * which are in node port recovery state, with a @vport. Each time an ELS |
| 4536 | * ADISC PLOGI IOCB is issued by invoking the lpfc_issue_els_plogi() routine, |
| 4537 | * the per @vport number of discover count (num_disc_nodes) shall be |
| 4538 | * incremented. If the num_disc_nodes reaches a pre-configured threshold |
| 4539 | * (cfg_discovery_threads), the @vport fc_flag will be marked with FC_NLP_MORE |
| 4540 | * bit set and quit the process of issuing remaining ADISC PLOGIN IOCBs for |
| 4541 | * later pick up. On the other hand, after walking through all the ndlps with |
| 4542 | * the @vport and there is none ADISC PLOGI IOCB issued, the @vport fc_flag |
| 4543 | * shall be cleared with the FC_NLP_MORE bit indicating there is no more ADISC |
| 4544 | * PLOGI need to be sent. |
| 4545 | * |
| 4546 | * Return code |
| 4547 | * The number of N_Ports with plogi issued. |
| 4548 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4549 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4550 | lpfc_els_disc_plogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4551 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4552 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4553 | struct lpfc_nodelist *ndlp, *next_ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4554 | int sentplogi = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4555 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4556 | /* go thru NPR nodes and issue any remaining ELS PLOGIs */ |
| 4557 | 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] | 4558 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4559 | continue; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4560 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 4561 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && |
| 4562 | (ndlp->nlp_flag & NLP_DELAY_TMO) == 0 && |
| 4563 | (ndlp->nlp_flag & NLP_NPR_ADISC) == 0) { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4564 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4565 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
| 4566 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4567 | sentplogi++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4568 | vport->num_disc_nodes++; |
| 4569 | if (vport->num_disc_nodes >= |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 4570 | vport->cfg_discovery_threads) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4571 | spin_lock_irq(shost->host_lock); |
| 4572 | vport->fc_flag |= FC_NLP_MORE; |
| 4573 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4574 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4575 | } |
| 4576 | } |
| 4577 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 4578 | if (sentplogi) { |
| 4579 | lpfc_set_disctmo(vport); |
| 4580 | } |
| 4581 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4582 | spin_lock_irq(shost->host_lock); |
| 4583 | vport->fc_flag &= ~FC_NLP_MORE; |
| 4584 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4585 | } |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 4586 | return sentplogi; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4587 | } |
| 4588 | |
James Smart | 8647887 | 2015-05-21 13:55:21 -0400 | [diff] [blame] | 4589 | void |
| 4590 | lpfc_rdp_res_link_service(struct fc_rdp_link_service_desc *desc, |
| 4591 | uint32_t word0) |
| 4592 | { |
| 4593 | |
| 4594 | desc->tag = cpu_to_be32(RDP_LINK_SERVICE_DESC_TAG); |
| 4595 | desc->payload.els_req = word0; |
| 4596 | desc->length = cpu_to_be32(sizeof(desc->payload)); |
| 4597 | } |
| 4598 | |
| 4599 | void |
| 4600 | lpfc_rdp_res_sfp_desc(struct fc_rdp_sfp_desc *desc, |
| 4601 | uint8_t *page_a0, uint8_t *page_a2) |
| 4602 | { |
| 4603 | uint16_t wavelength; |
| 4604 | uint16_t temperature; |
| 4605 | uint16_t rx_power; |
| 4606 | uint16_t tx_bias; |
| 4607 | uint16_t tx_power; |
| 4608 | uint16_t vcc; |
| 4609 | uint16_t flag = 0; |
| 4610 | struct sff_trasnceiver_codes_byte4 *trasn_code_byte4; |
| 4611 | struct sff_trasnceiver_codes_byte5 *trasn_code_byte5; |
| 4612 | |
| 4613 | desc->tag = cpu_to_be32(RDP_SFP_DESC_TAG); |
| 4614 | |
| 4615 | trasn_code_byte4 = (struct sff_trasnceiver_codes_byte4 *) |
| 4616 | &page_a0[SSF_TRANSCEIVER_CODE_B4]; |
| 4617 | trasn_code_byte5 = (struct sff_trasnceiver_codes_byte5 *) |
| 4618 | &page_a0[SSF_TRANSCEIVER_CODE_B5]; |
| 4619 | |
| 4620 | if ((trasn_code_byte4->fc_sw_laser) || |
| 4621 | (trasn_code_byte5->fc_sw_laser_sl) || |
| 4622 | (trasn_code_byte5->fc_sw_laser_sn)) { /* check if its short WL */ |
| 4623 | flag |= (SFP_FLAG_PT_SWLASER << SFP_FLAG_PT_SHIFT); |
| 4624 | } else if (trasn_code_byte4->fc_lw_laser) { |
| 4625 | wavelength = (page_a0[SSF_WAVELENGTH_B1] << 8) | |
| 4626 | page_a0[SSF_WAVELENGTH_B0]; |
| 4627 | if (wavelength == SFP_WAVELENGTH_LC1310) |
| 4628 | flag |= SFP_FLAG_PT_LWLASER_LC1310 << SFP_FLAG_PT_SHIFT; |
| 4629 | if (wavelength == SFP_WAVELENGTH_LL1550) |
| 4630 | flag |= SFP_FLAG_PT_LWLASER_LL1550 << SFP_FLAG_PT_SHIFT; |
| 4631 | } |
| 4632 | /* check if its SFP+ */ |
| 4633 | flag |= ((page_a0[SSF_IDENTIFIER] == SFF_PG0_IDENT_SFP) ? |
| 4634 | SFP_FLAG_CT_SFP_PLUS : SFP_FLAG_CT_UNKNOWN) |
| 4635 | << SFP_FLAG_CT_SHIFT; |
| 4636 | |
| 4637 | /* check if its OPTICAL */ |
| 4638 | flag |= ((page_a0[SSF_CONNECTOR] == SFF_PG0_CONNECTOR_LC) ? |
| 4639 | SFP_FLAG_IS_OPTICAL_PORT : 0) |
| 4640 | << SFP_FLAG_IS_OPTICAL_SHIFT; |
| 4641 | |
| 4642 | temperature = (page_a2[SFF_TEMPERATURE_B1] << 8 | |
| 4643 | page_a2[SFF_TEMPERATURE_B0]); |
| 4644 | vcc = (page_a2[SFF_VCC_B1] << 8 | |
| 4645 | page_a2[SFF_VCC_B0]); |
| 4646 | tx_power = (page_a2[SFF_TXPOWER_B1] << 8 | |
| 4647 | page_a2[SFF_TXPOWER_B0]); |
| 4648 | tx_bias = (page_a2[SFF_TX_BIAS_CURRENT_B1] << 8 | |
| 4649 | page_a2[SFF_TX_BIAS_CURRENT_B0]); |
| 4650 | rx_power = (page_a2[SFF_RXPOWER_B1] << 8 | |
| 4651 | page_a2[SFF_RXPOWER_B0]); |
| 4652 | desc->sfp_info.temperature = cpu_to_be16(temperature); |
| 4653 | desc->sfp_info.rx_power = cpu_to_be16(rx_power); |
| 4654 | desc->sfp_info.tx_bias = cpu_to_be16(tx_bias); |
| 4655 | desc->sfp_info.tx_power = cpu_to_be16(tx_power); |
| 4656 | desc->sfp_info.vcc = cpu_to_be16(vcc); |
| 4657 | |
| 4658 | desc->sfp_info.flags = cpu_to_be16(flag); |
| 4659 | desc->length = cpu_to_be32(sizeof(desc->sfp_info)); |
| 4660 | } |
| 4661 | |
| 4662 | void |
| 4663 | lpfc_rdp_res_link_error(struct fc_rdp_link_error_status_desc *desc, |
| 4664 | READ_LNK_VAR *stat) |
| 4665 | { |
| 4666 | uint32_t type; |
| 4667 | |
| 4668 | desc->tag = cpu_to_be32(RDP_LINK_ERROR_STATUS_DESC_TAG); |
| 4669 | |
| 4670 | type = VN_PT_PHY_PF_PORT << VN_PT_PHY_SHIFT; |
| 4671 | |
| 4672 | desc->info.port_type = cpu_to_be32(type); |
| 4673 | |
| 4674 | desc->info.link_status.link_failure_cnt = |
| 4675 | cpu_to_be32(stat->linkFailureCnt); |
| 4676 | desc->info.link_status.loss_of_synch_cnt = |
| 4677 | cpu_to_be32(stat->lossSyncCnt); |
| 4678 | desc->info.link_status.loss_of_signal_cnt = |
| 4679 | cpu_to_be32(stat->lossSignalCnt); |
| 4680 | desc->info.link_status.primitive_seq_proto_err = |
| 4681 | cpu_to_be32(stat->primSeqErrCnt); |
| 4682 | desc->info.link_status.invalid_trans_word = |
| 4683 | cpu_to_be32(stat->invalidXmitWord); |
| 4684 | desc->info.link_status.invalid_crc_cnt = cpu_to_be32(stat->crcCnt); |
| 4685 | |
| 4686 | desc->length = cpu_to_be32(sizeof(desc->info)); |
| 4687 | } |
| 4688 | |
| 4689 | void |
| 4690 | lpfc_rdp_res_speed(struct fc_rdp_port_speed_desc *desc, struct lpfc_hba *phba) |
| 4691 | { |
| 4692 | uint16_t rdp_cap = 0; |
| 4693 | uint16_t rdp_speed; |
| 4694 | |
| 4695 | desc->tag = cpu_to_be32(RDP_PORT_SPEED_DESC_TAG); |
| 4696 | |
| 4697 | switch (phba->sli4_hba.link_state.speed) { |
| 4698 | case LPFC_FC_LA_SPEED_1G: |
| 4699 | rdp_speed = RDP_PS_1GB; |
| 4700 | break; |
| 4701 | case LPFC_FC_LA_SPEED_2G: |
| 4702 | rdp_speed = RDP_PS_2GB; |
| 4703 | break; |
| 4704 | case LPFC_FC_LA_SPEED_4G: |
| 4705 | rdp_speed = RDP_PS_4GB; |
| 4706 | break; |
| 4707 | case LPFC_FC_LA_SPEED_8G: |
| 4708 | rdp_speed = RDP_PS_8GB; |
| 4709 | break; |
| 4710 | case LPFC_FC_LA_SPEED_10G: |
| 4711 | rdp_speed = RDP_PS_10GB; |
| 4712 | break; |
| 4713 | case LPFC_FC_LA_SPEED_16G: |
| 4714 | rdp_speed = RDP_PS_16GB; |
| 4715 | break; |
| 4716 | case LPFC_FC_LA_SPEED_32G: |
| 4717 | rdp_speed = RDP_PS_32GB; |
| 4718 | break; |
| 4719 | default: |
| 4720 | rdp_speed = RDP_PS_UNKNOWN; |
| 4721 | break; |
| 4722 | } |
| 4723 | |
| 4724 | desc->info.port_speed.speed = cpu_to_be16(rdp_speed); |
| 4725 | |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 4726 | if (phba->lmt & LMT_32Gb) |
| 4727 | rdp_cap |= RDP_PS_32GB; |
James Smart | 8647887 | 2015-05-21 13:55:21 -0400 | [diff] [blame] | 4728 | if (phba->lmt & LMT_16Gb) |
| 4729 | rdp_cap |= RDP_PS_16GB; |
| 4730 | if (phba->lmt & LMT_10Gb) |
| 4731 | rdp_cap |= RDP_PS_10GB; |
| 4732 | if (phba->lmt & LMT_8Gb) |
| 4733 | rdp_cap |= RDP_PS_8GB; |
| 4734 | if (phba->lmt & LMT_4Gb) |
| 4735 | rdp_cap |= RDP_PS_4GB; |
| 4736 | if (phba->lmt & LMT_2Gb) |
| 4737 | rdp_cap |= RDP_PS_2GB; |
| 4738 | if (phba->lmt & LMT_1Gb) |
| 4739 | rdp_cap |= RDP_PS_1GB; |
| 4740 | |
| 4741 | if (rdp_cap == 0) |
| 4742 | rdp_cap = RDP_CAP_UNKNOWN; |
| 4743 | |
| 4744 | desc->info.port_speed.capabilities = cpu_to_be16(rdp_cap); |
| 4745 | desc->length = cpu_to_be32(sizeof(desc->info)); |
| 4746 | } |
| 4747 | |
| 4748 | void |
| 4749 | lpfc_rdp_res_diag_port_names(struct fc_rdp_port_name_desc *desc, |
| 4750 | struct lpfc_hba *phba) |
| 4751 | { |
| 4752 | |
| 4753 | desc->tag = cpu_to_be32(RDP_PORT_NAMES_DESC_TAG); |
| 4754 | |
| 4755 | memcpy(desc->port_names.wwnn, phba->wwnn, |
| 4756 | sizeof(desc->port_names.wwnn)); |
| 4757 | |
| 4758 | memcpy(desc->port_names.wwpn, &phba->wwpn, |
| 4759 | sizeof(desc->port_names.wwpn)); |
| 4760 | |
| 4761 | desc->length = cpu_to_be32(sizeof(desc->port_names)); |
| 4762 | } |
| 4763 | |
| 4764 | void |
| 4765 | lpfc_rdp_res_attach_port_names(struct fc_rdp_port_name_desc *desc, |
| 4766 | struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) |
| 4767 | { |
| 4768 | |
| 4769 | desc->tag = cpu_to_be32(RDP_PORT_NAMES_DESC_TAG); |
| 4770 | if (vport->fc_flag & FC_FABRIC) { |
| 4771 | memcpy(desc->port_names.wwnn, &vport->fabric_nodename, |
| 4772 | sizeof(desc->port_names.wwnn)); |
| 4773 | |
| 4774 | memcpy(desc->port_names.wwpn, &vport->fabric_portname, |
| 4775 | sizeof(desc->port_names.wwpn)); |
| 4776 | } else { /* Point to Point */ |
| 4777 | memcpy(desc->port_names.wwnn, &ndlp->nlp_nodename, |
| 4778 | sizeof(desc->port_names.wwnn)); |
| 4779 | |
| 4780 | memcpy(desc->port_names.wwnn, &ndlp->nlp_portname, |
| 4781 | sizeof(desc->port_names.wwpn)); |
| 4782 | } |
| 4783 | |
| 4784 | desc->length = cpu_to_be32(sizeof(desc->port_names)); |
| 4785 | } |
| 4786 | |
| 4787 | void |
| 4788 | lpfc_els_rdp_cmpl(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context, |
| 4789 | int status) |
| 4790 | { |
| 4791 | struct lpfc_nodelist *ndlp = rdp_context->ndlp; |
| 4792 | struct lpfc_vport *vport = ndlp->vport; |
| 4793 | struct lpfc_iocbq *elsiocb; |
| 4794 | IOCB_t *icmd; |
| 4795 | uint8_t *pcmd; |
| 4796 | struct ls_rjt *stat; |
| 4797 | struct fc_rdp_res_frame *rdp_res; |
| 4798 | uint32_t cmdsize; |
| 4799 | int rc; |
| 4800 | |
| 4801 | if (status != SUCCESS) |
| 4802 | goto error; |
| 4803 | cmdsize = sizeof(struct fc_rdp_res_frame); |
| 4804 | |
| 4805 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, |
| 4806 | lpfc_max_els_tries, rdp_context->ndlp, |
| 4807 | rdp_context->ndlp->nlp_DID, ELS_CMD_ACC); |
| 4808 | lpfc_nlp_put(ndlp); |
| 4809 | if (!elsiocb) |
| 4810 | goto free_rdp_context; |
| 4811 | |
| 4812 | icmd = &elsiocb->iocb; |
| 4813 | icmd->ulpContext = rdp_context->rx_id; |
| 4814 | icmd->unsli3.rcvsli3.ox_id = rdp_context->ox_id; |
| 4815 | |
| 4816 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4817 | "2171 Xmit RDP response tag x%x xri x%x, " |
| 4818 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x", |
| 4819 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 4820 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 4821 | ndlp->nlp_rpi); |
| 4822 | rdp_res = (struct fc_rdp_res_frame *) |
| 4823 | (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4824 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4825 | memset(pcmd, 0, sizeof(struct fc_rdp_res_frame)); |
| 4826 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
| 4827 | |
| 4828 | /* For RDP payload */ |
| 4829 | lpfc_rdp_res_link_service(&rdp_res->link_service_desc, ELS_CMD_RDP); |
| 4830 | |
| 4831 | lpfc_rdp_res_sfp_desc(&rdp_res->sfp_desc, |
| 4832 | rdp_context->page_a0, rdp_context->page_a2); |
| 4833 | lpfc_rdp_res_speed(&rdp_res->portspeed_desc, phba); |
| 4834 | lpfc_rdp_res_link_error(&rdp_res->link_error_desc, |
| 4835 | &rdp_context->link_stat); |
| 4836 | lpfc_rdp_res_diag_port_names(&rdp_res->diag_port_names_desc, phba); |
| 4837 | lpfc_rdp_res_attach_port_names(&rdp_res->attached_port_names_desc, |
| 4838 | vport, ndlp); |
| 4839 | rdp_res->length = cpu_to_be32(RDP_DESC_PAYLOAD_SIZE); |
| 4840 | |
| 4841 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| 4842 | |
| 4843 | phba->fc_stat.elsXmitACC++; |
| 4844 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| 4845 | if (rc == IOCB_ERROR) |
| 4846 | lpfc_els_free_iocb(phba, elsiocb); |
| 4847 | |
| 4848 | kfree(rdp_context); |
| 4849 | |
| 4850 | return; |
| 4851 | error: |
| 4852 | cmdsize = 2 * sizeof(uint32_t); |
| 4853 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, lpfc_max_els_tries, |
| 4854 | ndlp, ndlp->nlp_DID, ELS_CMD_LS_RJT); |
| 4855 | lpfc_nlp_put(ndlp); |
| 4856 | if (!elsiocb) |
| 4857 | goto free_rdp_context; |
| 4858 | |
| 4859 | icmd = &elsiocb->iocb; |
| 4860 | icmd->ulpContext = rdp_context->rx_id; |
| 4861 | icmd->unsli3.rcvsli3.ox_id = rdp_context->ox_id; |
| 4862 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4863 | |
| 4864 | *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT; |
| 4865 | stat = (struct ls_rjt *)(pcmd + sizeof(uint32_t)); |
| 4866 | stat->un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 4867 | |
| 4868 | phba->fc_stat.elsXmitLSRJT++; |
| 4869 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| 4870 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| 4871 | |
| 4872 | if (rc == IOCB_ERROR) |
| 4873 | lpfc_els_free_iocb(phba, elsiocb); |
| 4874 | free_rdp_context: |
| 4875 | kfree(rdp_context); |
| 4876 | } |
| 4877 | |
| 4878 | int |
| 4879 | lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context) |
| 4880 | { |
| 4881 | LPFC_MBOXQ_t *mbox = NULL; |
| 4882 | int rc; |
| 4883 | |
| 4884 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 4885 | if (!mbox) { |
| 4886 | lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX | LOG_ELS, |
| 4887 | "7105 failed to allocate mailbox memory"); |
| 4888 | return 1; |
| 4889 | } |
| 4890 | |
| 4891 | if (lpfc_sli4_dump_page_a0(phba, mbox)) |
| 4892 | goto prep_mbox_fail; |
| 4893 | mbox->vport = rdp_context->ndlp->vport; |
| 4894 | mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0; |
| 4895 | mbox->context2 = (struct lpfc_rdp_context *) rdp_context; |
| 4896 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
| 4897 | if (rc == MBX_NOT_FINISHED) |
| 4898 | goto issue_mbox_fail; |
| 4899 | |
| 4900 | return 0; |
| 4901 | |
| 4902 | prep_mbox_fail: |
| 4903 | issue_mbox_fail: |
| 4904 | mempool_free(mbox, phba->mbox_mem_pool); |
| 4905 | return 1; |
| 4906 | } |
| 4907 | |
| 4908 | /* |
| 4909 | * lpfc_els_rcv_rdp - Process an unsolicited RDP ELS. |
| 4910 | * @vport: pointer to a host virtual N_Port data structure. |
| 4911 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4912 | * @ndlp: pointer to a node-list data structure. |
| 4913 | * |
| 4914 | * This routine processes an unsolicited RDP(Read Diagnostic Parameters) |
| 4915 | * IOCB. First, the payload of the unsolicited RDP is checked. |
| 4916 | * Then it will (1) send MBX_DUMP_MEMORY, Embedded DMP_LMSD sub command TYPE-3 |
| 4917 | * for Page A0, (2) send MBX_DUMP_MEMORY, DMP_LMSD for Page A2, |
| 4918 | * (3) send MBX_READ_LNK_STAT to get link stat, (4) Call lpfc_els_rdp_cmpl |
| 4919 | * gather all data and send RDP response. |
| 4920 | * |
| 4921 | * Return code |
| 4922 | * 0 - Sent the acc response |
| 4923 | * 1 - Sent the reject response. |
| 4924 | */ |
| 4925 | static int |
| 4926 | lpfc_els_rcv_rdp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 4927 | struct lpfc_nodelist *ndlp) |
| 4928 | { |
| 4929 | struct lpfc_hba *phba = vport->phba; |
| 4930 | struct lpfc_dmabuf *pcmd; |
| 4931 | uint8_t rjt_err, rjt_expl = LSEXP_NOTHING_MORE; |
| 4932 | struct fc_rdp_req_frame *rdp_req; |
| 4933 | struct lpfc_rdp_context *rdp_context; |
| 4934 | IOCB_t *cmd = NULL; |
| 4935 | struct ls_rjt stat; |
| 4936 | |
| 4937 | if (phba->sli_rev < LPFC_SLI_REV4 || |
| 4938 | (bf_get(lpfc_sli_intf_if_type, |
| 4939 | &phba->sli4_hba.sli_intf) != |
| 4940 | LPFC_SLI_INTF_IF_TYPE_2)) { |
| 4941 | rjt_err = LSRJT_UNABLE_TPC; |
| 4942 | rjt_expl = LSEXP_REQ_UNSUPPORTED; |
| 4943 | goto error; |
| 4944 | } |
| 4945 | |
| 4946 | if (phba->sli_rev < LPFC_SLI_REV4 || (phba->hba_flag & HBA_FCOE_MODE)) { |
| 4947 | rjt_err = LSRJT_UNABLE_TPC; |
| 4948 | rjt_expl = LSEXP_REQ_UNSUPPORTED; |
| 4949 | goto error; |
| 4950 | } |
| 4951 | |
| 4952 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 4953 | rdp_req = (struct fc_rdp_req_frame *) pcmd->virt; |
| 4954 | |
| 4955 | |
| 4956 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4957 | "2422 ELS RDP Request " |
| 4958 | "dec len %d tag x%x port_id %d len %d\n", |
| 4959 | be32_to_cpu(rdp_req->rdp_des_length), |
| 4960 | be32_to_cpu(rdp_req->nport_id_desc.tag), |
| 4961 | be32_to_cpu(rdp_req->nport_id_desc.nport_id), |
| 4962 | be32_to_cpu(rdp_req->nport_id_desc.length)); |
| 4963 | |
| 4964 | if (sizeof(struct fc_rdp_nport_desc) != |
| 4965 | be32_to_cpu(rdp_req->rdp_des_length)) |
| 4966 | goto rjt_logerr; |
| 4967 | if (RDP_N_PORT_DESC_TAG != be32_to_cpu(rdp_req->nport_id_desc.tag)) |
| 4968 | goto rjt_logerr; |
| 4969 | if (RDP_NPORT_ID_SIZE != |
| 4970 | be32_to_cpu(rdp_req->nport_id_desc.length)) |
| 4971 | goto rjt_logerr; |
| 4972 | rdp_context = kmalloc(sizeof(struct lpfc_rdp_context), GFP_KERNEL); |
| 4973 | if (!rdp_context) { |
| 4974 | rjt_err = LSRJT_UNABLE_TPC; |
| 4975 | goto error; |
| 4976 | } |
| 4977 | |
| 4978 | memset(rdp_context, 0, sizeof(struct lpfc_rdp_context)); |
| 4979 | cmd = &cmdiocb->iocb; |
| 4980 | rdp_context->ndlp = lpfc_nlp_get(ndlp); |
| 4981 | rdp_context->ox_id = cmd->unsli3.rcvsli3.ox_id; |
| 4982 | rdp_context->rx_id = cmd->ulpContext; |
| 4983 | rdp_context->cmpl = lpfc_els_rdp_cmpl; |
| 4984 | if (lpfc_get_rdp_info(phba, rdp_context)) { |
| 4985 | lpfc_printf_vlog(ndlp->vport, KERN_WARNING, LOG_ELS, |
| 4986 | "2423 Unable to send mailbox"); |
| 4987 | kfree(rdp_context); |
| 4988 | rjt_err = LSRJT_UNABLE_TPC; |
| 4989 | lpfc_nlp_put(ndlp); |
| 4990 | goto error; |
| 4991 | } |
| 4992 | |
| 4993 | return 0; |
| 4994 | |
| 4995 | rjt_logerr: |
| 4996 | rjt_err = LSRJT_LOGICAL_ERR; |
| 4997 | |
| 4998 | error: |
| 4999 | memset(&stat, 0, sizeof(stat)); |
| 5000 | stat.un.b.lsRjtRsnCode = rjt_err; |
| 5001 | stat.un.b.lsRjtRsnCodeExp = rjt_expl; |
| 5002 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
| 5003 | return 1; |
| 5004 | } |
| 5005 | |
| 5006 | |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 5007 | static void |
| 5008 | lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
| 5009 | { |
| 5010 | MAILBOX_t *mb; |
| 5011 | IOCB_t *icmd; |
| 5012 | uint8_t *pcmd; |
| 5013 | struct lpfc_iocbq *elsiocb; |
| 5014 | struct lpfc_nodelist *ndlp; |
| 5015 | struct ls_rjt *stat; |
James Smart | 481ad96 | 2015-05-22 10:42:35 -0400 | [diff] [blame] | 5016 | union lpfc_sli4_cfg_shdr *shdr; |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 5017 | struct lpfc_lcb_context *lcb_context; |
| 5018 | struct fc_lcb_res_frame *lcb_res; |
James Smart | 481ad96 | 2015-05-22 10:42:35 -0400 | [diff] [blame] | 5019 | uint32_t cmdsize, shdr_status, shdr_add_status; |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 5020 | int rc; |
| 5021 | |
| 5022 | mb = &pmb->u.mb; |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 5023 | lcb_context = (struct lpfc_lcb_context *)pmb->context1; |
| 5024 | ndlp = lcb_context->ndlp; |
| 5025 | pmb->context1 = NULL; |
| 5026 | pmb->context2 = NULL; |
| 5027 | |
James Smart | 481ad96 | 2015-05-22 10:42:35 -0400 | [diff] [blame] | 5028 | shdr = (union lpfc_sli4_cfg_shdr *) |
| 5029 | &pmb->u.mqe.un.beacon_config.header.cfg_shdr; |
| 5030 | shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); |
| 5031 | shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); |
| 5032 | |
| 5033 | lpfc_printf_log(phba, KERN_INFO, LOG_MBOX, |
| 5034 | "0194 SET_BEACON_CONFIG mailbox " |
| 5035 | "completed with status x%x add_status x%x," |
| 5036 | " mbx status x%x\n", |
| 5037 | shdr_status, shdr_add_status, mb->mbxStatus); |
| 5038 | |
| 5039 | if (mb->mbxStatus && !(shdr_status && |
| 5040 | shdr_add_status == ADD_STATUS_OPERATION_ALREADY_ACTIVE)) { |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 5041 | mempool_free(pmb, phba->mbox_mem_pool); |
| 5042 | goto error; |
| 5043 | } |
| 5044 | |
| 5045 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 5046 | cmdsize = sizeof(struct fc_lcb_res_frame); |
| 5047 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 5048 | lpfc_max_els_tries, ndlp, |
| 5049 | ndlp->nlp_DID, ELS_CMD_ACC); |
| 5050 | |
| 5051 | /* Decrement the ndlp reference count from previous mbox command */ |
| 5052 | lpfc_nlp_put(ndlp); |
| 5053 | |
| 5054 | if (!elsiocb) |
| 5055 | goto free_lcb_context; |
| 5056 | |
| 5057 | lcb_res = (struct fc_lcb_res_frame *) |
| 5058 | (((struct lpfc_dmabuf *)elsiocb->context2)->virt); |
| 5059 | |
| 5060 | icmd = &elsiocb->iocb; |
| 5061 | icmd->ulpContext = lcb_context->rx_id; |
| 5062 | icmd->unsli3.rcvsli3.ox_id = lcb_context->ox_id; |
| 5063 | |
| 5064 | pcmd = (uint8_t *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt); |
| 5065 | *((uint32_t *)(pcmd)) = ELS_CMD_ACC; |
| 5066 | lcb_res->lcb_sub_command = lcb_context->sub_command; |
| 5067 | lcb_res->lcb_type = lcb_context->type; |
| 5068 | lcb_res->lcb_frequency = lcb_context->frequency; |
| 5069 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| 5070 | phba->fc_stat.elsXmitACC++; |
| 5071 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| 5072 | if (rc == IOCB_ERROR) |
| 5073 | lpfc_els_free_iocb(phba, elsiocb); |
| 5074 | |
| 5075 | kfree(lcb_context); |
| 5076 | return; |
| 5077 | |
| 5078 | error: |
| 5079 | cmdsize = sizeof(struct fc_lcb_res_frame); |
| 5080 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 5081 | lpfc_max_els_tries, ndlp, |
| 5082 | ndlp->nlp_DID, ELS_CMD_LS_RJT); |
| 5083 | lpfc_nlp_put(ndlp); |
| 5084 | if (!elsiocb) |
| 5085 | goto free_lcb_context; |
| 5086 | |
| 5087 | icmd = &elsiocb->iocb; |
| 5088 | icmd->ulpContext = lcb_context->rx_id; |
| 5089 | icmd->unsli3.rcvsli3.ox_id = lcb_context->ox_id; |
| 5090 | pcmd = (uint8_t *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt); |
| 5091 | |
| 5092 | *((uint32_t *)(pcmd)) = ELS_CMD_LS_RJT; |
| 5093 | stat = (struct ls_rjt *)(pcmd + sizeof(uint32_t)); |
| 5094 | stat->un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5095 | |
| 5096 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| 5097 | phba->fc_stat.elsXmitLSRJT++; |
| 5098 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| 5099 | if (rc == IOCB_ERROR) |
| 5100 | lpfc_els_free_iocb(phba, elsiocb); |
| 5101 | free_lcb_context: |
| 5102 | kfree(lcb_context); |
| 5103 | } |
| 5104 | |
| 5105 | static int |
| 5106 | lpfc_sli4_set_beacon(struct lpfc_vport *vport, |
| 5107 | struct lpfc_lcb_context *lcb_context, |
| 5108 | uint32_t beacon_state) |
| 5109 | { |
| 5110 | struct lpfc_hba *phba = vport->phba; |
| 5111 | LPFC_MBOXQ_t *mbox = NULL; |
| 5112 | uint32_t len; |
| 5113 | int rc; |
| 5114 | |
| 5115 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 5116 | if (!mbox) |
| 5117 | return 1; |
| 5118 | |
| 5119 | len = sizeof(struct lpfc_mbx_set_beacon_config) - |
| 5120 | sizeof(struct lpfc_sli4_cfg_mhdr); |
| 5121 | lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_COMMON, |
| 5122 | LPFC_MBOX_OPCODE_SET_BEACON_CONFIG, len, |
| 5123 | LPFC_SLI4_MBX_EMBED); |
| 5124 | mbox->context1 = (void *)lcb_context; |
| 5125 | mbox->vport = phba->pport; |
| 5126 | mbox->mbox_cmpl = lpfc_els_lcb_rsp; |
| 5127 | bf_set(lpfc_mbx_set_beacon_port_num, &mbox->u.mqe.un.beacon_config, |
| 5128 | phba->sli4_hba.physical_port); |
| 5129 | bf_set(lpfc_mbx_set_beacon_state, &mbox->u.mqe.un.beacon_config, |
| 5130 | beacon_state); |
| 5131 | bf_set(lpfc_mbx_set_beacon_port_type, &mbox->u.mqe.un.beacon_config, 1); |
| 5132 | bf_set(lpfc_mbx_set_beacon_duration, &mbox->u.mqe.un.beacon_config, 0); |
| 5133 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
| 5134 | if (rc == MBX_NOT_FINISHED) { |
| 5135 | mempool_free(mbox, phba->mbox_mem_pool); |
| 5136 | return 1; |
| 5137 | } |
| 5138 | |
| 5139 | return 0; |
| 5140 | } |
| 5141 | |
| 5142 | |
| 5143 | /** |
| 5144 | * lpfc_els_rcv_lcb - Process an unsolicited LCB |
| 5145 | * @vport: pointer to a host virtual N_Port data structure. |
| 5146 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5147 | * @ndlp: pointer to a node-list data structure. |
| 5148 | * |
| 5149 | * This routine processes an unsolicited LCB(LINK CABLE BEACON) IOCB. |
| 5150 | * First, the payload of the unsolicited LCB is checked. |
| 5151 | * Then based on Subcommand beacon will either turn on or off. |
| 5152 | * |
| 5153 | * Return code |
| 5154 | * 0 - Sent the acc response |
| 5155 | * 1 - Sent the reject response. |
| 5156 | **/ |
| 5157 | static int |
| 5158 | lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5159 | struct lpfc_nodelist *ndlp) |
| 5160 | { |
| 5161 | struct lpfc_hba *phba = vport->phba; |
| 5162 | struct lpfc_dmabuf *pcmd; |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 5163 | uint8_t *lp; |
| 5164 | struct fc_lcb_request_frame *beacon; |
| 5165 | struct lpfc_lcb_context *lcb_context; |
| 5166 | uint8_t state, rjt_err; |
| 5167 | struct ls_rjt stat; |
| 5168 | |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 5169 | pcmd = (struct lpfc_dmabuf *)cmdiocb->context2; |
| 5170 | lp = (uint8_t *)pcmd->virt; |
| 5171 | beacon = (struct fc_lcb_request_frame *)pcmd->virt; |
| 5172 | |
| 5173 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 5174 | "0192 ELS LCB Data x%x x%x x%x x%x sub x%x " |
| 5175 | "type x%x frequency %x duration x%x\n", |
| 5176 | lp[0], lp[1], lp[2], |
| 5177 | beacon->lcb_command, |
| 5178 | beacon->lcb_sub_command, |
| 5179 | beacon->lcb_type, |
| 5180 | beacon->lcb_frequency, |
| 5181 | be16_to_cpu(beacon->lcb_duration)); |
| 5182 | |
| 5183 | if (phba->sli_rev < LPFC_SLI_REV4 || |
| 5184 | (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != |
| 5185 | LPFC_SLI_INTF_IF_TYPE_2)) { |
| 5186 | rjt_err = LSRJT_CMD_UNSUPPORTED; |
| 5187 | goto rjt; |
| 5188 | } |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 5189 | |
| 5190 | if (phba->hba_flag & HBA_FCOE_MODE) { |
| 5191 | rjt_err = LSRJT_CMD_UNSUPPORTED; |
| 5192 | goto rjt; |
| 5193 | } |
| 5194 | if (beacon->lcb_frequency == 0) { |
| 5195 | rjt_err = LSRJT_CMD_UNSUPPORTED; |
| 5196 | goto rjt; |
| 5197 | } |
| 5198 | if ((beacon->lcb_type != LPFC_LCB_GREEN) && |
| 5199 | (beacon->lcb_type != LPFC_LCB_AMBER)) { |
| 5200 | rjt_err = LSRJT_CMD_UNSUPPORTED; |
| 5201 | goto rjt; |
| 5202 | } |
| 5203 | if ((beacon->lcb_sub_command != LPFC_LCB_ON) && |
| 5204 | (beacon->lcb_sub_command != LPFC_LCB_OFF)) { |
| 5205 | rjt_err = LSRJT_CMD_UNSUPPORTED; |
| 5206 | goto rjt; |
| 5207 | } |
| 5208 | if ((beacon->lcb_sub_command == LPFC_LCB_ON) && |
| 5209 | (beacon->lcb_type != LPFC_LCB_GREEN) && |
| 5210 | (beacon->lcb_type != LPFC_LCB_AMBER)) { |
| 5211 | rjt_err = LSRJT_CMD_UNSUPPORTED; |
| 5212 | goto rjt; |
| 5213 | } |
| 5214 | if (be16_to_cpu(beacon->lcb_duration) != 0) { |
| 5215 | rjt_err = LSRJT_CMD_UNSUPPORTED; |
| 5216 | goto rjt; |
| 5217 | } |
| 5218 | |
Sudip Mukherjee | e795042 | 2015-09-23 19:02:32 +0530 | [diff] [blame] | 5219 | lcb_context = kmalloc(sizeof(*lcb_context), GFP_KERNEL); |
| 5220 | if (!lcb_context) { |
| 5221 | rjt_err = LSRJT_UNABLE_TPC; |
| 5222 | goto rjt; |
| 5223 | } |
| 5224 | |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 5225 | state = (beacon->lcb_sub_command == LPFC_LCB_ON) ? 1 : 0; |
| 5226 | lcb_context->sub_command = beacon->lcb_sub_command; |
| 5227 | lcb_context->type = beacon->lcb_type; |
| 5228 | lcb_context->frequency = beacon->lcb_frequency; |
| 5229 | lcb_context->ox_id = cmdiocb->iocb.unsli3.rcvsli3.ox_id; |
| 5230 | lcb_context->rx_id = cmdiocb->iocb.ulpContext; |
| 5231 | lcb_context->ndlp = lpfc_nlp_get(ndlp); |
| 5232 | if (lpfc_sli4_set_beacon(vport, lcb_context, state)) { |
| 5233 | lpfc_printf_vlog(ndlp->vport, KERN_ERR, |
| 5234 | LOG_ELS, "0193 failed to send mail box"); |
Sudip Mukherjee | e795042 | 2015-09-23 19:02:32 +0530 | [diff] [blame] | 5235 | kfree(lcb_context); |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 5236 | lpfc_nlp_put(ndlp); |
| 5237 | rjt_err = LSRJT_UNABLE_TPC; |
| 5238 | goto rjt; |
| 5239 | } |
| 5240 | return 0; |
| 5241 | rjt: |
| 5242 | memset(&stat, 0, sizeof(stat)); |
| 5243 | stat.un.b.lsRjtRsnCode = rjt_err; |
| 5244 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
| 5245 | return 1; |
| 5246 | } |
| 5247 | |
| 5248 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5249 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5250 | * lpfc_els_flush_rscn - Clean up any rscn activities with a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5251 | * @vport: pointer to a host virtual N_Port data structure. |
| 5252 | * |
| 5253 | * This routine cleans up any Registration State Change Notification |
| 5254 | * (RSCN) activity with a @vport. Note that the fc_rscn_flush flag of the |
| 5255 | * @vport together with the host_lock is used to prevent multiple thread |
| 5256 | * trying to access the RSCN array on a same @vport at the same time. |
| 5257 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5258 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5259 | lpfc_els_flush_rscn(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5260 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5261 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5262 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5263 | int i; |
| 5264 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5265 | spin_lock_irq(shost->host_lock); |
| 5266 | if (vport->fc_rscn_flush) { |
| 5267 | /* Another thread is walking fc_rscn_id_list on this vport */ |
| 5268 | spin_unlock_irq(shost->host_lock); |
| 5269 | return; |
| 5270 | } |
| 5271 | /* Indicate we are walking lpfc_els_flush_rscn on this vport */ |
| 5272 | vport->fc_rscn_flush = 1; |
| 5273 | spin_unlock_irq(shost->host_lock); |
| 5274 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5275 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5276 | lpfc_in_buf_free(phba, vport->fc_rscn_id_list[i]); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5277 | vport->fc_rscn_id_list[i] = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5278 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5279 | spin_lock_irq(shost->host_lock); |
| 5280 | vport->fc_rscn_id_cnt = 0; |
| 5281 | vport->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY); |
| 5282 | spin_unlock_irq(shost->host_lock); |
| 5283 | lpfc_can_disctmo(vport); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5284 | /* Indicate we are done walking this fc_rscn_id_list */ |
| 5285 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5286 | } |
| 5287 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5288 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5289 | * 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] | 5290 | * @vport: pointer to a host virtual N_Port data structure. |
| 5291 | * @did: remote destination port identifier. |
| 5292 | * |
| 5293 | * This routine checks whether there is any pending Registration State |
| 5294 | * Configuration Notification (RSCN) to a @did on @vport. |
| 5295 | * |
| 5296 | * Return code |
| 5297 | * None zero - The @did matched with a pending rscn |
| 5298 | * 0 - not able to match @did with a pending rscn |
| 5299 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5300 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5301 | lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5302 | { |
| 5303 | D_ID ns_did; |
| 5304 | D_ID rscn_did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5305 | uint32_t *lp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5306 | uint32_t payload_len, i; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5307 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5308 | |
| 5309 | ns_did.un.word = did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5310 | |
| 5311 | /* Never match fabric nodes for RSCNs */ |
| 5312 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5313 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5314 | |
| 5315 | /* If we are doing a FULL RSCN rediscovery, match everything */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5316 | if (vport->fc_flag & FC_RSCN_DISCOVERY) |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5317 | return did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5318 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5319 | spin_lock_irq(shost->host_lock); |
| 5320 | if (vport->fc_rscn_flush) { |
| 5321 | /* Another thread is walking fc_rscn_id_list on this vport */ |
| 5322 | spin_unlock_irq(shost->host_lock); |
| 5323 | return 0; |
| 5324 | } |
| 5325 | /* Indicate we are walking fc_rscn_id_list on this vport */ |
| 5326 | vport->fc_rscn_flush = 1; |
| 5327 | spin_unlock_irq(shost->host_lock); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5328 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5329 | lp = vport->fc_rscn_id_list[i]->virt; |
| 5330 | payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); |
| 5331 | payload_len -= sizeof(uint32_t); /* take off word 0 */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5332 | while (payload_len) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5333 | rscn_did.un.word = be32_to_cpu(*lp++); |
| 5334 | payload_len -= sizeof(uint32_t); |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 5335 | switch (rscn_did.un.b.resv & RSCN_ADDRESS_FORMAT_MASK) { |
| 5336 | case RSCN_ADDRESS_FORMAT_PORT: |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5337 | if ((ns_did.un.b.domain == rscn_did.un.b.domain) |
| 5338 | && (ns_did.un.b.area == rscn_did.un.b.area) |
| 5339 | && (ns_did.un.b.id == rscn_did.un.b.id)) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5340 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5341 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 5342 | case RSCN_ADDRESS_FORMAT_AREA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5343 | if ((ns_did.un.b.domain == rscn_did.un.b.domain) |
| 5344 | && (ns_did.un.b.area == rscn_did.un.b.area)) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5345 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5346 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 5347 | case RSCN_ADDRESS_FORMAT_DOMAIN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5348 | if (ns_did.un.b.domain == rscn_did.un.b.domain) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5349 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5350 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 5351 | case RSCN_ADDRESS_FORMAT_FABRIC: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5352 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5353 | } |
| 5354 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5355 | } |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5356 | /* Indicate we are done with walking fc_rscn_id_list on this vport */ |
| 5357 | vport->fc_rscn_flush = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5358 | return 0; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5359 | return_did_out: |
| 5360 | /* Indicate we are done with walking fc_rscn_id_list on this vport */ |
| 5361 | vport->fc_rscn_flush = 0; |
| 5362 | return did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5363 | } |
| 5364 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5365 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5366 | * lpfc_rscn_recovery_check - Send recovery event to vport nodes matching rscn |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5367 | * @vport: pointer to a host virtual N_Port data structure. |
| 5368 | * |
| 5369 | * This routine sends recovery (NLP_EVT_DEVICE_RECOVERY) event to the |
| 5370 | * state machine for a @vport's nodes that are with pending RSCN (Registration |
| 5371 | * State Change Notification). |
| 5372 | * |
| 5373 | * Return code |
| 5374 | * 0 - Successful (currently alway return 0) |
| 5375 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5376 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5377 | lpfc_rscn_recovery_check(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5378 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 5379 | struct lpfc_nodelist *ndlp = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5380 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 5381 | /* Move all affected nodes by pending RSCNs to NPR state. */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5382 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5383 | if (!NLP_CHK_NODE_ACT(ndlp) || |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 5384 | (ndlp->nlp_state == NLP_STE_UNUSED_NODE) || |
| 5385 | !lpfc_rscn_payload_check(vport, ndlp->nlp_DID)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5386 | continue; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5387 | lpfc_disc_state_machine(vport, ndlp, NULL, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 5388 | NLP_EVT_DEVICE_RECOVERY); |
| 5389 | lpfc_cancel_retry_delay_tmo(vport, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5390 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5391 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5392 | } |
| 5393 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5394 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5395 | * lpfc_send_rscn_event - Send an RSCN event to management application |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5396 | * @vport: pointer to a host virtual N_Port data structure. |
| 5397 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5398 | * |
| 5399 | * lpfc_send_rscn_event sends an RSCN netlink event to management |
| 5400 | * applications. |
| 5401 | */ |
| 5402 | static void |
| 5403 | lpfc_send_rscn_event(struct lpfc_vport *vport, |
| 5404 | struct lpfc_iocbq *cmdiocb) |
| 5405 | { |
| 5406 | struct lpfc_dmabuf *pcmd; |
| 5407 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5408 | uint32_t *payload_ptr; |
| 5409 | uint32_t payload_len; |
| 5410 | struct lpfc_rscn_event_header *rscn_event_data; |
| 5411 | |
| 5412 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5413 | payload_ptr = (uint32_t *) pcmd->virt; |
| 5414 | payload_len = be32_to_cpu(*payload_ptr & ~ELS_CMD_MASK); |
| 5415 | |
| 5416 | rscn_event_data = kmalloc(sizeof(struct lpfc_rscn_event_header) + |
| 5417 | payload_len, GFP_KERNEL); |
| 5418 | if (!rscn_event_data) { |
| 5419 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 5420 | "0147 Failed to allocate memory for RSCN event\n"); |
| 5421 | return; |
| 5422 | } |
| 5423 | rscn_event_data->event_type = FC_REG_RSCN_EVENT; |
| 5424 | rscn_event_data->payload_length = payload_len; |
| 5425 | memcpy(rscn_event_data->rscn_payload, payload_ptr, |
| 5426 | payload_len); |
| 5427 | |
| 5428 | fc_host_post_vendor_event(shost, |
| 5429 | fc_get_event_number(), |
Ales Novak | 6599eaa | 2015-08-31 16:48:16 -0400 | [diff] [blame] | 5430 | sizeof(struct lpfc_rscn_event_header) + payload_len, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5431 | (char *)rscn_event_data, |
| 5432 | LPFC_NL_VENDOR_ID); |
| 5433 | |
| 5434 | kfree(rscn_event_data); |
| 5435 | } |
| 5436 | |
| 5437 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5438 | * lpfc_els_rcv_rscn - Process an unsolicited rscn iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5439 | * @vport: pointer to a host virtual N_Port data structure. |
| 5440 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5441 | * @ndlp: pointer to a node-list data structure. |
| 5442 | * |
| 5443 | * This routine processes an unsolicited RSCN (Registration State Change |
| 5444 | * Notification) IOCB. First, the payload of the unsolicited RSCN is walked |
| 5445 | * to invoke fc_host_post_event() routine to the FC transport layer. If the |
| 5446 | * discover state machine is about to begin discovery, it just accepts the |
| 5447 | * RSCN and the discovery process will satisfy the RSCN. If this RSCN only |
| 5448 | * contains N_Port IDs for other vports on this HBA, it just accepts the |
| 5449 | * RSCN and ignore processing it. If the state machine is in the recovery |
| 5450 | * state, the fc_rscn_id_list of this @vport is walked and the |
| 5451 | * lpfc_rscn_recovery_check() routine is invoked to send recovery event for |
| 5452 | * all nodes that match RSCN payload. Otherwise, the lpfc_els_handle_rscn() |
| 5453 | * routine is invoked to handle the RSCN event. |
| 5454 | * |
| 5455 | * Return code |
| 5456 | * 0 - Just sent the acc response |
| 5457 | * 1 - Sent the acc response and waited for name server completion |
| 5458 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5459 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5460 | lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5461 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5462 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5463 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5464 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5465 | struct lpfc_dmabuf *pcmd; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5466 | uint32_t *lp, *datap; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5467 | uint32_t payload_len, length, nportid, *cmd; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5468 | int rscn_cnt; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5469 | int rscn_id = 0, hba_id = 0; |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 5470 | int i; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5471 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5472 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5473 | lp = (uint32_t *) pcmd->virt; |
| 5474 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5475 | payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); |
| 5476 | payload_len -= sizeof(uint32_t); /* take off word 0 */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5477 | /* RSCN received */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5478 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 5479 | "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] | 5480 | vport->fc_flag, payload_len, *lp, |
| 5481 | vport->fc_rscn_id_cnt); |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5482 | |
| 5483 | /* Send an RSCN event to the management application */ |
| 5484 | lpfc_send_rscn_event(vport, cmdiocb); |
| 5485 | |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 5486 | for (i = 0; i < payload_len/sizeof(uint32_t); i++) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5487 | fc_host_post_event(shost, fc_get_event_number(), |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 5488 | FCH_EVT_RSCN, lp[i]); |
| 5489 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5490 | /* If we are about to begin discovery, just ACC the RSCN. |
| 5491 | * Discovery processing will satisfy it. |
| 5492 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5493 | if (vport->port_state <= LPFC_NS_QRY) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5494 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5495 | "RCV RSCN ignore: did:x%x/ste:x%x flg:x%x", |
| 5496 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 5497 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5498 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5499 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5500 | } |
| 5501 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5502 | /* If this RSCN just contains NPortIDs for other vports on this HBA, |
| 5503 | * just ACC and ignore it. |
| 5504 | */ |
| 5505 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 5506 | !(vport->cfg_peer_port_login)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5507 | i = payload_len; |
| 5508 | datap = lp; |
| 5509 | while (i > 0) { |
| 5510 | nportid = *datap++; |
| 5511 | nportid = ((be32_to_cpu(nportid)) & Mask_DID); |
| 5512 | i -= sizeof(uint32_t); |
| 5513 | rscn_id++; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 5514 | if (lpfc_find_vport_by_did(phba, nportid)) |
| 5515 | hba_id++; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5516 | } |
| 5517 | if (rscn_id == hba_id) { |
| 5518 | /* ALL NPortIDs in RSCN are on HBA */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5519 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 5520 | "0219 Ignore RSCN " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5521 | "Data: x%x x%x x%x x%x\n", |
| 5522 | vport->fc_flag, payload_len, |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5523 | *lp, vport->fc_rscn_id_cnt); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5524 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5525 | "RCV RSCN vport: did:x%x/ste:x%x flg:x%x", |
| 5526 | ndlp->nlp_DID, vport->port_state, |
| 5527 | ndlp->nlp_flag); |
| 5528 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5529 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5530 | ndlp, NULL); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5531 | return 0; |
| 5532 | } |
| 5533 | } |
| 5534 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5535 | spin_lock_irq(shost->host_lock); |
| 5536 | if (vport->fc_rscn_flush) { |
| 5537 | /* Another thread is walking fc_rscn_id_list on this vport */ |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5538 | vport->fc_flag |= FC_RSCN_DISCOVERY; |
James Smart | 9795724 | 2009-12-21 17:03:15 -0500 | [diff] [blame] | 5539 | spin_unlock_irq(shost->host_lock); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 5540 | /* Send back ACC */ |
| 5541 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5542 | return 0; |
| 5543 | } |
| 5544 | /* Indicate we are walking fc_rscn_id_list on this vport */ |
| 5545 | vport->fc_rscn_flush = 1; |
| 5546 | spin_unlock_irq(shost->host_lock); |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 5547 | /* Get the array count after successfully have the token */ |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5548 | rscn_cnt = vport->fc_rscn_id_cnt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5549 | /* If we are already processing an RSCN, save the received |
| 5550 | * RSCN payload buffer, cmdiocb->context2 to process later. |
| 5551 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5552 | if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5553 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5554 | "RCV RSCN defer: did:x%x/ste:x%x flg:x%x", |
| 5555 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 5556 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5557 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5558 | vport->fc_flag |= FC_RSCN_DEFERRED; |
| 5559 | if ((rscn_cnt < FC_MAX_HOLD_RSCN) && |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5560 | !(vport->fc_flag & FC_RSCN_DISCOVERY)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5561 | vport->fc_flag |= FC_RSCN_MODE; |
| 5562 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5563 | if (rscn_cnt) { |
| 5564 | cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt; |
| 5565 | length = be32_to_cpu(*cmd & ~ELS_CMD_MASK); |
| 5566 | } |
| 5567 | if ((rscn_cnt) && |
| 5568 | (payload_len + length <= LPFC_BPL_SIZE)) { |
| 5569 | *cmd &= ELS_CMD_MASK; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5570 | *cmd |= cpu_to_be32(payload_len + length); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5571 | memcpy(((uint8_t *)cmd) + length, lp, |
| 5572 | payload_len); |
| 5573 | } else { |
| 5574 | vport->fc_rscn_id_list[rscn_cnt] = pcmd; |
| 5575 | vport->fc_rscn_id_cnt++; |
| 5576 | /* If we zero, cmdiocb->context2, the calling |
| 5577 | * routine will not try to free it. |
| 5578 | */ |
| 5579 | cmdiocb->context2 = NULL; |
| 5580 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5581 | /* Deferred RSCN */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5582 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 5583 | "0235 Deferred RSCN " |
| 5584 | "Data: x%x x%x x%x\n", |
| 5585 | vport->fc_rscn_id_cnt, vport->fc_flag, |
| 5586 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5587 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5588 | vport->fc_flag |= FC_RSCN_DISCOVERY; |
| 5589 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5590 | /* ReDiscovery RSCN */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5591 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 5592 | "0234 ReDiscovery RSCN " |
| 5593 | "Data: x%x x%x x%x\n", |
| 5594 | vport->fc_rscn_id_cnt, vport->fc_flag, |
| 5595 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5596 | } |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5597 | /* Indicate we are done walking fc_rscn_id_list on this vport */ |
| 5598 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5599 | /* Send back ACC */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5600 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5601 | /* send RECOVERY event for ALL nodes that match RSCN payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5602 | lpfc_rscn_recovery_check(vport); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5603 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5604 | vport->fc_flag &= ~FC_RSCN_DEFERRED; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 5605 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5606 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5607 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5608 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5609 | "RCV RSCN: did:x%x/ste:x%x flg:x%x", |
| 5610 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 5611 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5612 | spin_lock_irq(shost->host_lock); |
| 5613 | vport->fc_flag |= FC_RSCN_MODE; |
| 5614 | spin_unlock_irq(shost->host_lock); |
| 5615 | vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5616 | /* Indicate we are done walking fc_rscn_id_list on this vport */ |
| 5617 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5618 | /* |
| 5619 | * If we zero, cmdiocb->context2, the calling routine will |
| 5620 | * not try to free it. |
| 5621 | */ |
| 5622 | cmdiocb->context2 = NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5623 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5624 | /* Send back ACC */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5625 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5626 | /* send RECOVERY event for ALL nodes that match RSCN payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5627 | lpfc_rscn_recovery_check(vport); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5628 | return lpfc_els_handle_rscn(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5629 | } |
| 5630 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5631 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5632 | * lpfc_els_handle_rscn - Handle rscn for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5633 | * @vport: pointer to a host virtual N_Port data structure. |
| 5634 | * |
| 5635 | * This routine handles the Registration State Configuration Notification |
| 5636 | * (RSCN) for a @vport. If login to NameServer does not exist, a new ndlp shall |
| 5637 | * be created and a Port Login (PLOGI) to the NameServer is issued. Otherwise, |
| 5638 | * if the ndlp to NameServer exists, a Common Transport (CT) command to the |
| 5639 | * NameServer shall be issued. If CT command to the NameServer fails to be |
| 5640 | * issued, the lpfc_els_flush_rscn() routine shall be invoked to clean up any |
| 5641 | * RSCN activities with the @vport. |
| 5642 | * |
| 5643 | * Return code |
| 5644 | * 0 - Cleaned up rscn on the @vport |
| 5645 | * 1 - Wait for plogi to name server before proceed |
| 5646 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5647 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5648 | lpfc_els_handle_rscn(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5649 | { |
| 5650 | struct lpfc_nodelist *ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5651 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5652 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5653 | /* Ignore RSCN if the port is being torn down. */ |
| 5654 | if (vport->load_flag & FC_UNLOADING) { |
| 5655 | lpfc_els_flush_rscn(vport); |
| 5656 | return 0; |
| 5657 | } |
| 5658 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5659 | /* Start timer for RSCN processing */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5660 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5661 | |
| 5662 | /* RSCN processed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5663 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 5664 | "0215 RSCN processed Data: x%x x%x x%x x%x\n", |
| 5665 | vport->fc_flag, 0, vport->fc_rscn_id_cnt, |
| 5666 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5667 | |
| 5668 | /* To process RSCN, first compare RSCN data with NameServer */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5669 | vport->fc_ns_retry = 0; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 5670 | vport->num_disc_nodes = 0; |
| 5671 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5672 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5673 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) |
| 5674 | && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5675 | /* Good ndlp, issue CT Request to NameServer */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5676 | if (lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 0, 0) == 0) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5677 | /* Wait for NameServer query cmpl before we can |
| 5678 | continue */ |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5679 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5680 | } else { |
| 5681 | /* If login to NameServer does not exist, issue one */ |
| 5682 | /* Good status, issue PLOGI to NameServer */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5683 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5684 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5685 | /* Wait for NameServer login cmpl before we can |
| 5686 | continue */ |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5687 | return 1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5688 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5689 | if (ndlp) { |
| 5690 | ndlp = lpfc_enable_node(vport, ndlp, |
| 5691 | NLP_STE_PLOGI_ISSUE); |
| 5692 | if (!ndlp) { |
| 5693 | lpfc_els_flush_rscn(vport); |
| 5694 | return 0; |
| 5695 | } |
| 5696 | ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5697 | } else { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5698 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 5699 | if (!ndlp) { |
| 5700 | lpfc_els_flush_rscn(vport); |
| 5701 | return 0; |
| 5702 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5703 | lpfc_nlp_init(vport, ndlp, NameServer_DID); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 5704 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5705 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5706 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5707 | ndlp->nlp_type |= NLP_FABRIC; |
| 5708 | lpfc_issue_els_plogi(vport, NameServer_DID, 0); |
| 5709 | /* Wait for NameServer login cmpl before we can |
| 5710 | * continue |
| 5711 | */ |
| 5712 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5713 | } |
| 5714 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5715 | lpfc_els_flush_rscn(vport); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5716 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5717 | } |
| 5718 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5719 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5720 | * lpfc_els_rcv_flogi - Process an unsolicited flogi iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5721 | * @vport: pointer to a host virtual N_Port data structure. |
| 5722 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5723 | * @ndlp: pointer to a node-list data structure. |
| 5724 | * |
| 5725 | * This routine processes Fabric Login (FLOGI) IOCB received as an ELS |
| 5726 | * unsolicited event. An unsolicited FLOGI can be received in a point-to- |
| 5727 | * point topology. As an unsolicited FLOGI should not be received in a loop |
| 5728 | * mode, any unsolicited FLOGI received in loop mode shall be ignored. The |
| 5729 | * lpfc_check_sparm() routine is invoked to check the parameters in the |
| 5730 | * unsolicited FLOGI. If parameters validation failed, the routine |
| 5731 | * lpfc_els_rsp_reject() shall be called with reject reason code set to |
| 5732 | * LSEXP_SPARM_OPTIONS to reject the FLOGI. Otherwise, the Port WWN in the |
| 5733 | * FLOGI shall be compared with the Port WWN of the @vport to determine who |
| 5734 | * will initiate PLOGI. The higher lexicographical value party shall has |
| 5735 | * higher priority (as the winning port) and will initiate PLOGI and |
| 5736 | * communicate Port_IDs (Addresses) for both nodes in PLOGI. The result |
| 5737 | * of this will be marked in the @vport fc_flag field with FC_PT2PT_PLOGI |
| 5738 | * and then the lpfc_els_rsp_acc() routine is invoked to accept the FLOGI. |
| 5739 | * |
| 5740 | * Return code |
| 5741 | * 0 - Successfully processed the unsolicited flogi |
| 5742 | * 1 - Failed to process the unsolicited flogi |
| 5743 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5744 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5745 | lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5746 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5747 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5748 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5749 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5750 | struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5751 | uint32_t *lp = (uint32_t *) pcmd->virt; |
| 5752 | IOCB_t *icmd = &cmdiocb->iocb; |
| 5753 | struct serv_parm *sp; |
| 5754 | LPFC_MBOXQ_t *mbox; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5755 | uint32_t cmd, did; |
| 5756 | int rc; |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 5757 | uint32_t fc_flag = 0; |
| 5758 | uint32_t port_state = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5759 | |
| 5760 | cmd = *lp++; |
| 5761 | sp = (struct serv_parm *) lp; |
| 5762 | |
| 5763 | /* FLOGI received */ |
| 5764 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5765 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5766 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 5767 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5768 | /* We should never receive a FLOGI in loop mode, ignore it */ |
| 5769 | did = icmd->un.elsreq64.remoteID; |
| 5770 | |
| 5771 | /* An FLOGI ELS command <elsCmd> was received from DID <did> in |
| 5772 | Loop Mode */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5773 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 5774 | "0113 An FLOGI ELS command x%x was " |
| 5775 | "received from DID x%x in Loop Mode\n", |
| 5776 | cmd, did); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5777 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5778 | } |
| 5779 | |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 5780 | (void) lpfc_check_sparm(vport, ndlp, sp, CLASS3, 1); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5781 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5782 | |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 5783 | /* |
| 5784 | * If our portname is greater than the remote portname, |
| 5785 | * then we initiate Nport login. |
| 5786 | */ |
| 5787 | |
| 5788 | rc = memcmp(&vport->fc_portname, &sp->portName, |
| 5789 | sizeof(struct lpfc_name)); |
| 5790 | |
| 5791 | if (!rc) { |
| 5792 | if (phba->sli_rev < LPFC_SLI_REV4) { |
| 5793 | mbox = mempool_alloc(phba->mbox_mem_pool, |
| 5794 | GFP_KERNEL); |
| 5795 | if (!mbox) |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5796 | return 1; |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 5797 | lpfc_linkdown(phba); |
| 5798 | lpfc_init_link(phba, mbox, |
| 5799 | phba->cfg_topology, |
| 5800 | phba->cfg_link_speed); |
| 5801 | mbox->u.mb.un.varInitLnk.lipsr_AL_PA = 0; |
| 5802 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
| 5803 | mbox->vport = vport; |
| 5804 | rc = lpfc_sli_issue_mbox(phba, mbox, |
| 5805 | MBX_NOWAIT); |
| 5806 | lpfc_set_loopback_flag(phba); |
| 5807 | if (rc == MBX_NOT_FINISHED) |
| 5808 | mempool_free(mbox, phba->mbox_mem_pool); |
| 5809 | return 1; |
| 5810 | } |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5811 | |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 5812 | /* abort the flogi coming back to ourselves |
| 5813 | * due to external loopback on the port. |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5814 | */ |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 5815 | lpfc_els_abort_flogi(phba); |
| 5816 | return 0; |
| 5817 | |
| 5818 | } else if (rc > 0) { /* greater than */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5819 | spin_lock_irq(shost->host_lock); |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 5820 | vport->fc_flag |= FC_PT2PT_PLOGI; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5821 | spin_unlock_irq(shost->host_lock); |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5822 | |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 5823 | /* If we have the high WWPN we can assign our own |
| 5824 | * myDID; otherwise, we have to WAIT for a PLOGI |
| 5825 | * from the remote NPort to find out what it |
| 5826 | * will be. |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5827 | */ |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 5828 | vport->fc_myDID = PT2PT_LocalID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5829 | } else { |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 5830 | vport->fc_myDID = PT2PT_RemoteID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5831 | } |
| 5832 | |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 5833 | /* |
| 5834 | * The vport state should go to LPFC_FLOGI only |
| 5835 | * AFTER we issue a FLOGI, not receive one. |
| 5836 | */ |
| 5837 | spin_lock_irq(shost->host_lock); |
| 5838 | fc_flag = vport->fc_flag; |
| 5839 | port_state = vport->port_state; |
| 5840 | vport->fc_flag |= FC_PT2PT; |
| 5841 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
| 5842 | spin_unlock_irq(shost->host_lock); |
| 5843 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 5844 | "3311 Rcv Flogi PS x%x new PS x%x " |
| 5845 | "fc_flag x%x new fc_flag x%x\n", |
| 5846 | port_state, vport->port_state, |
| 5847 | fc_flag, vport->fc_flag); |
| 5848 | |
| 5849 | /* |
| 5850 | * We temporarily set fc_myDID to make it look like we are |
| 5851 | * a Fabric. This is done just so we end up with the right |
| 5852 | * did / sid on the FLOGI ACC rsp. |
| 5853 | */ |
| 5854 | did = vport->fc_myDID; |
| 5855 | vport->fc_myDID = Fabric_DID; |
| 5856 | |
| 5857 | memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm)); |
James Smart | eec3d31 | 2015-08-31 16:48:18 -0400 | [diff] [blame] | 5858 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5859 | /* Send back ACC */ |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 5860 | lpfc_els_rsp_acc(vport, ELS_CMD_FLOGI, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5861 | |
James Smart | 939723a | 2012-05-09 21:19:03 -0400 | [diff] [blame] | 5862 | /* Now lets put fc_myDID back to what its supposed to be */ |
| 5863 | vport->fc_myDID = did; |
| 5864 | |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5865 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5866 | } |
| 5867 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5868 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5869 | * lpfc_els_rcv_rnid - Process an unsolicited rnid iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5870 | * @vport: pointer to a host virtual N_Port data structure. |
| 5871 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5872 | * @ndlp: pointer to a node-list data structure. |
| 5873 | * |
| 5874 | * This routine processes Request Node Identification Data (RNID) IOCB |
| 5875 | * received as an ELS unsolicited event. Only when the RNID specified format |
| 5876 | * 0x0 or 0xDF (Topology Discovery Specific Node Identification Data) |
| 5877 | * present, this routine will invoke the lpfc_els_rsp_rnid_acc() routine to |
| 5878 | * Accept (ACC) the RNID ELS command. All the other RNID formats are |
| 5879 | * rejected by invoking the lpfc_els_rsp_reject() routine. |
| 5880 | * |
| 5881 | * Return code |
| 5882 | * 0 - Successfully processed rnid iocb (currently always return 0) |
| 5883 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5884 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5885 | lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5886 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5887 | { |
| 5888 | struct lpfc_dmabuf *pcmd; |
| 5889 | uint32_t *lp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5890 | RNID *rn; |
| 5891 | struct ls_rjt stat; |
James Smart | eb01656 | 2014-09-03 12:58:06 -0400 | [diff] [blame] | 5892 | uint32_t cmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5893 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5894 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5895 | lp = (uint32_t *) pcmd->virt; |
| 5896 | |
| 5897 | cmd = *lp++; |
| 5898 | rn = (RNID *) lp; |
| 5899 | |
| 5900 | /* RNID received */ |
| 5901 | |
| 5902 | switch (rn->Format) { |
| 5903 | case 0: |
| 5904 | case RNID_TOPOLOGY_DISC: |
| 5905 | /* Send back ACC */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5906 | lpfc_els_rsp_rnid_acc(vport, rn->Format, cmdiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5907 | break; |
| 5908 | default: |
| 5909 | /* Reject this request because format not supported */ |
| 5910 | stat.un.b.lsRjtRsvd0 = 0; |
| 5911 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5912 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5913 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5914 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
| 5915 | NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5916 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5917 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5918 | } |
| 5919 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5920 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5921 | * lpfc_els_rcv_echo - Process an unsolicited echo iocb |
| 5922 | * @vport: pointer to a host virtual N_Port data structure. |
| 5923 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5924 | * @ndlp: pointer to a node-list data structure. |
| 5925 | * |
| 5926 | * Return code |
| 5927 | * 0 - Successfully processed echo iocb (currently always return 0) |
| 5928 | **/ |
| 5929 | static int |
| 5930 | lpfc_els_rcv_echo(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5931 | struct lpfc_nodelist *ndlp) |
| 5932 | { |
| 5933 | uint8_t *pcmd; |
| 5934 | |
| 5935 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt); |
| 5936 | |
| 5937 | /* skip over first word of echo command to find echo data */ |
| 5938 | pcmd += sizeof(uint32_t); |
| 5939 | |
| 5940 | lpfc_els_rsp_echo_acc(vport, pcmd, cmdiocb, ndlp); |
| 5941 | return 0; |
| 5942 | } |
| 5943 | |
| 5944 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5945 | * lpfc_els_rcv_lirr - Process an unsolicited lirr iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5946 | * @vport: pointer to a host virtual N_Port data structure. |
| 5947 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5948 | * @ndlp: pointer to a node-list data structure. |
| 5949 | * |
| 5950 | * This routine processes a Link Incident Report Registration(LIRR) IOCB |
| 5951 | * received as an ELS unsolicited event. Currently, this function just invokes |
| 5952 | * the lpfc_els_rsp_reject() routine to reject the LIRR IOCB unconditionally. |
| 5953 | * |
| 5954 | * Return code |
| 5955 | * 0 - Successfully processed lirr iocb (currently always return 0) |
| 5956 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5957 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5958 | lpfc_els_rcv_lirr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5959 | struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5960 | { |
| 5961 | struct ls_rjt stat; |
| 5962 | |
| 5963 | /* For now, unconditionally reject this command */ |
| 5964 | stat.un.b.lsRjtRsvd0 = 0; |
| 5965 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5966 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5967 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5968 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5969 | return 0; |
| 5970 | } |
| 5971 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5972 | /** |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 5973 | * lpfc_els_rcv_rrq - Process an unsolicited rrq iocb |
| 5974 | * @vport: pointer to a host virtual N_Port data structure. |
| 5975 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5976 | * @ndlp: pointer to a node-list data structure. |
| 5977 | * |
| 5978 | * This routine processes a Reinstate Recovery Qualifier (RRQ) IOCB |
| 5979 | * received as an ELS unsolicited event. A request to RRQ shall only |
| 5980 | * be accepted if the Originator Nx_Port N_Port_ID or the Responder |
| 5981 | * Nx_Port N_Port_ID of the target Exchange is the same as the |
| 5982 | * N_Port_ID of the Nx_Port that makes the request. If the RRQ is |
| 5983 | * not accepted, an LS_RJT with reason code "Unable to perform |
| 5984 | * command request" and reason code explanation "Invalid Originator |
| 5985 | * S_ID" shall be returned. For now, we just unconditionally accept |
| 5986 | * RRQ from the target. |
| 5987 | **/ |
| 5988 | static void |
| 5989 | lpfc_els_rcv_rrq(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5990 | struct lpfc_nodelist *ndlp) |
| 5991 | { |
| 5992 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 5993 | if (vport->phba->sli_rev == LPFC_SLI_REV4) |
| 5994 | lpfc_els_clear_rrq(vport, cmdiocb, ndlp); |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 5995 | } |
| 5996 | |
| 5997 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 5998 | * lpfc_els_rsp_rls_acc - Completion callbk func for MBX_READ_LNK_STAT mbox cmd |
| 5999 | * @phba: pointer to lpfc hba data structure. |
| 6000 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 6001 | * |
| 6002 | * This routine is the completion callback function for the MBX_READ_LNK_STAT |
| 6003 | * mailbox command. This callback function is to actually send the Accept |
| 6004 | * (ACC) response to a Read Port Status (RPS) unsolicited IOCB event. It |
| 6005 | * collects the link statistics from the completion of the MBX_READ_LNK_STAT |
| 6006 | * mailbox command, constructs the RPS response with the link statistics |
| 6007 | * collected, and then invokes the lpfc_sli_issue_iocb() routine to send ACC |
| 6008 | * response to the RPS. |
| 6009 | * |
| 6010 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 6011 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 6012 | * will be stored into the context1 field of the IOCB for the completion |
| 6013 | * callback function to the RPS Accept Response ELS IOCB command. |
| 6014 | * |
| 6015 | **/ |
| 6016 | static void |
| 6017 | lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
| 6018 | { |
| 6019 | MAILBOX_t *mb; |
| 6020 | IOCB_t *icmd; |
| 6021 | struct RLS_RSP *rls_rsp; |
| 6022 | uint8_t *pcmd; |
| 6023 | struct lpfc_iocbq *elsiocb; |
| 6024 | struct lpfc_nodelist *ndlp; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 6025 | uint16_t oxid; |
| 6026 | uint16_t rxid; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6027 | uint32_t cmdsize; |
| 6028 | |
| 6029 | mb = &pmb->u.mb; |
| 6030 | |
| 6031 | ndlp = (struct lpfc_nodelist *) pmb->context2; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 6032 | rxid = (uint16_t) ((unsigned long)(pmb->context1) & 0xffff); |
| 6033 | oxid = (uint16_t) (((unsigned long)(pmb->context1) >> 16) & 0xffff); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6034 | pmb->context1 = NULL; |
| 6035 | pmb->context2 = NULL; |
| 6036 | |
| 6037 | if (mb->mbxStatus) { |
| 6038 | mempool_free(pmb, phba->mbox_mem_pool); |
| 6039 | return; |
| 6040 | } |
| 6041 | |
| 6042 | cmdsize = sizeof(struct RLS_RSP) + sizeof(uint32_t); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6043 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 6044 | lpfc_max_els_tries, ndlp, |
| 6045 | ndlp->nlp_DID, ELS_CMD_ACC); |
| 6046 | |
| 6047 | /* Decrement the ndlp reference count from previous mbox command */ |
| 6048 | lpfc_nlp_put(ndlp); |
| 6049 | |
James Smart | 37db57e | 2012-05-09 21:17:16 -0400 | [diff] [blame] | 6050 | if (!elsiocb) { |
| 6051 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6052 | return; |
James Smart | 37db57e | 2012-05-09 21:17:16 -0400 | [diff] [blame] | 6053 | } |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6054 | |
| 6055 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 6056 | icmd->ulpContext = rxid; |
| 6057 | icmd->unsli3.rcvsli3.ox_id = oxid; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6058 | |
| 6059 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 6060 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
| 6061 | pcmd += sizeof(uint32_t); /* Skip past command */ |
| 6062 | rls_rsp = (struct RLS_RSP *)pcmd; |
| 6063 | |
| 6064 | rls_rsp->linkFailureCnt = cpu_to_be32(mb->un.varRdLnk.linkFailureCnt); |
| 6065 | rls_rsp->lossSyncCnt = cpu_to_be32(mb->un.varRdLnk.lossSyncCnt); |
| 6066 | rls_rsp->lossSignalCnt = cpu_to_be32(mb->un.varRdLnk.lossSignalCnt); |
| 6067 | rls_rsp->primSeqErrCnt = cpu_to_be32(mb->un.varRdLnk.primSeqErrCnt); |
| 6068 | rls_rsp->invalidXmitWord = cpu_to_be32(mb->un.varRdLnk.invalidXmitWord); |
| 6069 | rls_rsp->crcCnt = cpu_to_be32(mb->un.varRdLnk.crcCnt); |
James Smart | 37db57e | 2012-05-09 21:17:16 -0400 | [diff] [blame] | 6070 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6071 | /* Xmit ELS RLS ACC response tag <ulpIoTag> */ |
| 6072 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS, |
| 6073 | "2874 Xmit ELS RLS ACC response tag x%x xri x%x, " |
| 6074 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", |
| 6075 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 6076 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 6077 | ndlp->nlp_rpi); |
| 6078 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| 6079 | phba->fc_stat.elsXmitACC++; |
| 6080 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == IOCB_ERROR) |
| 6081 | lpfc_els_free_iocb(phba, elsiocb); |
| 6082 | } |
| 6083 | |
| 6084 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6085 | * 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] | 6086 | * @phba: pointer to lpfc hba data structure. |
| 6087 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 6088 | * |
| 6089 | * This routine is the completion callback function for the MBX_READ_LNK_STAT |
| 6090 | * mailbox command. This callback function is to actually send the Accept |
| 6091 | * (ACC) response to a Read Port Status (RPS) unsolicited IOCB event. It |
| 6092 | * collects the link statistics from the completion of the MBX_READ_LNK_STAT |
| 6093 | * mailbox command, constructs the RPS response with the link statistics |
| 6094 | * collected, and then invokes the lpfc_sli_issue_iocb() routine to send ACC |
| 6095 | * response to the RPS. |
| 6096 | * |
| 6097 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 6098 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 6099 | * will be stored into the context1 field of the IOCB for the completion |
| 6100 | * callback function to the RPS Accept Response ELS IOCB command. |
| 6101 | * |
| 6102 | **/ |
Jamie Wellnitz | 082c026 | 2006-02-28 19:25:30 -0500 | [diff] [blame] | 6103 | static void |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6104 | 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] | 6105 | { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6106 | MAILBOX_t *mb; |
| 6107 | IOCB_t *icmd; |
| 6108 | RPS_RSP *rps_rsp; |
| 6109 | uint8_t *pcmd; |
| 6110 | struct lpfc_iocbq *elsiocb; |
| 6111 | struct lpfc_nodelist *ndlp; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 6112 | uint16_t status; |
| 6113 | uint16_t oxid; |
| 6114 | uint16_t rxid; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6115 | uint32_t cmdsize; |
| 6116 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 6117 | mb = &pmb->u.mb; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6118 | |
| 6119 | ndlp = (struct lpfc_nodelist *) pmb->context2; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 6120 | rxid = (uint16_t) ((unsigned long)(pmb->context1) & 0xffff); |
| 6121 | oxid = (uint16_t) (((unsigned long)(pmb->context1) >> 16) & 0xffff); |
Randy Dunlap | 041976f | 2006-06-25 01:58:51 -0700 | [diff] [blame] | 6122 | pmb->context1 = NULL; |
| 6123 | pmb->context2 = NULL; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6124 | |
| 6125 | if (mb->mbxStatus) { |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6126 | mempool_free(pmb, phba->mbox_mem_pool); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6127 | return; |
| 6128 | } |
| 6129 | |
| 6130 | cmdsize = sizeof(RPS_RSP) + sizeof(uint32_t); |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6131 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6132 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 6133 | lpfc_max_els_tries, ndlp, |
| 6134 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 6135 | |
| 6136 | /* Decrement the ndlp reference count from previous mbox command */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6137 | lpfc_nlp_put(ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 6138 | |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6139 | if (!elsiocb) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6140 | return; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6141 | |
| 6142 | icmd = &elsiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 6143 | icmd->ulpContext = rxid; |
| 6144 | icmd->unsli3.rcvsli3.ox_id = oxid; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6145 | |
| 6146 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 6147 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6148 | pcmd += sizeof(uint32_t); /* Skip past command */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6149 | rps_rsp = (RPS_RSP *)pcmd; |
| 6150 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6151 | if (phba->fc_topology != LPFC_TOPOLOGY_LOOP) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6152 | status = 0x10; |
| 6153 | else |
| 6154 | status = 0x8; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6155 | if (phba->pport->fc_flag & FC_FABRIC) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6156 | status |= 0x4; |
| 6157 | |
| 6158 | rps_rsp->rsvd1 = 0; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6159 | rps_rsp->portStatus = cpu_to_be16(status); |
| 6160 | rps_rsp->linkFailureCnt = cpu_to_be32(mb->un.varRdLnk.linkFailureCnt); |
| 6161 | rps_rsp->lossSyncCnt = cpu_to_be32(mb->un.varRdLnk.lossSyncCnt); |
| 6162 | rps_rsp->lossSignalCnt = cpu_to_be32(mb->un.varRdLnk.lossSignalCnt); |
| 6163 | rps_rsp->primSeqErrCnt = cpu_to_be32(mb->un.varRdLnk.primSeqErrCnt); |
| 6164 | rps_rsp->invalidXmitWord = cpu_to_be32(mb->un.varRdLnk.invalidXmitWord); |
| 6165 | rps_rsp->crcCnt = cpu_to_be32(mb->un.varRdLnk.crcCnt); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6166 | /* Xmit ELS RPS ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6167 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS, |
| 6168 | "0118 Xmit ELS RPS ACC response tag x%x xri x%x, " |
| 6169 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", |
| 6170 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 6171 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 6172 | ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6173 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6174 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 6175 | 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] | 6176 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6177 | return; |
| 6178 | } |
| 6179 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6180 | /** |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6181 | * lpfc_els_rcv_rls - Process an unsolicited rls iocb |
| 6182 | * @vport: pointer to a host virtual N_Port data structure. |
| 6183 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6184 | * @ndlp: pointer to a node-list data structure. |
| 6185 | * |
| 6186 | * This routine processes Read Port Status (RPL) IOCB received as an |
| 6187 | * ELS unsolicited event. It first checks the remote port state. If the |
| 6188 | * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE |
| 6189 | * state, it invokes the lpfc_els_rsl_reject() routine to send the reject |
| 6190 | * response. Otherwise, it issue the MBX_READ_LNK_STAT mailbox command |
| 6191 | * for reading the HBA link statistics. It is for the callback function, |
| 6192 | * lpfc_els_rsp_rls_acc(), set to the MBX_READ_LNK_STAT mailbox command |
| 6193 | * to actually sending out RPL Accept (ACC) response. |
| 6194 | * |
| 6195 | * Return codes |
| 6196 | * 0 - Successfully processed rls iocb (currently always return 0) |
| 6197 | **/ |
| 6198 | static int |
| 6199 | lpfc_els_rcv_rls(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6200 | struct lpfc_nodelist *ndlp) |
| 6201 | { |
| 6202 | struct lpfc_hba *phba = vport->phba; |
| 6203 | LPFC_MBOXQ_t *mbox; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6204 | struct ls_rjt stat; |
| 6205 | |
| 6206 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
| 6207 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) |
| 6208 | /* reject the unsolicited RPS request and done with it */ |
| 6209 | goto reject_out; |
| 6210 | |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6211 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC); |
| 6212 | if (mbox) { |
| 6213 | lpfc_read_lnk_stat(phba, mbox); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 6214 | mbox->context1 = (void *)((unsigned long) |
| 6215 | ((cmdiocb->iocb.unsli3.rcvsli3.ox_id << 16) | |
| 6216 | cmdiocb->iocb.ulpContext)); /* rx_id */ |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6217 | mbox->context2 = lpfc_nlp_get(ndlp); |
| 6218 | mbox->vport = vport; |
| 6219 | mbox->mbox_cmpl = lpfc_els_rsp_rls_acc; |
| 6220 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
| 6221 | != MBX_NOT_FINISHED) |
| 6222 | /* Mbox completion will send ELS Response */ |
| 6223 | return 0; |
| 6224 | /* Decrement reference count used for the failed mbox |
| 6225 | * command. |
| 6226 | */ |
| 6227 | lpfc_nlp_put(ndlp); |
| 6228 | mempool_free(mbox, phba->mbox_mem_pool); |
| 6229 | } |
| 6230 | reject_out: |
| 6231 | /* issue rejection response */ |
| 6232 | stat.un.b.lsRjtRsvd0 = 0; |
| 6233 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 6234 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 6235 | stat.un.b.vendorUnique = 0; |
| 6236 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
| 6237 | return 0; |
| 6238 | } |
| 6239 | |
| 6240 | /** |
| 6241 | * lpfc_els_rcv_rtv - Process an unsolicited rtv iocb |
| 6242 | * @vport: pointer to a host virtual N_Port data structure. |
| 6243 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6244 | * @ndlp: pointer to a node-list data structure. |
| 6245 | * |
| 6246 | * This routine processes Read Timout Value (RTV) IOCB received as an |
| 6247 | * ELS unsolicited event. It first checks the remote port state. If the |
| 6248 | * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE |
| 6249 | * state, it invokes the lpfc_els_rsl_reject() routine to send the reject |
| 6250 | * response. Otherwise, it sends the Accept(ACC) response to a Read Timeout |
| 6251 | * Value (RTV) unsolicited IOCB event. |
| 6252 | * |
| 6253 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 6254 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 6255 | * will be stored into the context1 field of the IOCB for the completion |
| 6256 | * callback function to the RPS Accept Response ELS IOCB command. |
| 6257 | * |
| 6258 | * Return codes |
| 6259 | * 0 - Successfully processed rtv iocb (currently always return 0) |
| 6260 | **/ |
| 6261 | static int |
| 6262 | lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6263 | struct lpfc_nodelist *ndlp) |
| 6264 | { |
| 6265 | struct lpfc_hba *phba = vport->phba; |
| 6266 | struct ls_rjt stat; |
| 6267 | struct RTV_RSP *rtv_rsp; |
| 6268 | uint8_t *pcmd; |
| 6269 | struct lpfc_iocbq *elsiocb; |
| 6270 | uint32_t cmdsize; |
| 6271 | |
| 6272 | |
| 6273 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
| 6274 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) |
| 6275 | /* reject the unsolicited RPS request and done with it */ |
| 6276 | goto reject_out; |
| 6277 | |
| 6278 | cmdsize = sizeof(struct RTV_RSP) + sizeof(uint32_t); |
| 6279 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 6280 | lpfc_max_els_tries, ndlp, |
| 6281 | ndlp->nlp_DID, ELS_CMD_ACC); |
| 6282 | |
| 6283 | if (!elsiocb) |
| 6284 | return 1; |
| 6285 | |
| 6286 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 6287 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
| 6288 | pcmd += sizeof(uint32_t); /* Skip past command */ |
| 6289 | |
| 6290 | /* use the command's xri in the response */ |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 6291 | elsiocb->iocb.ulpContext = cmdiocb->iocb.ulpContext; /* Xri / rx_id */ |
| 6292 | elsiocb->iocb.unsli3.rcvsli3.ox_id = cmdiocb->iocb.unsli3.rcvsli3.ox_id; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 6293 | |
| 6294 | rtv_rsp = (struct RTV_RSP *)pcmd; |
| 6295 | |
| 6296 | /* populate RTV payload */ |
| 6297 | rtv_rsp->ratov = cpu_to_be32(phba->fc_ratov * 1000); /* report msecs */ |
| 6298 | rtv_rsp->edtov = cpu_to_be32(phba->fc_edtov); |
| 6299 | bf_set(qtov_edtovres, rtv_rsp, phba->fc_edtovResol ? 1 : 0); |
| 6300 | bf_set(qtov_rttov, rtv_rsp, 0); /* Field is for FC ONLY */ |
| 6301 | rtv_rsp->qtov = cpu_to_be32(rtv_rsp->qtov); |
| 6302 | |
| 6303 | /* Xmit ELS RLS ACC response tag <ulpIoTag> */ |
| 6304 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS, |
| 6305 | "2875 Xmit ELS RTV ACC response tag x%x xri x%x, " |
| 6306 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x, " |
| 6307 | "Data: x%x x%x x%x\n", |
| 6308 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 6309 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 6310 | ndlp->nlp_rpi, |
| 6311 | rtv_rsp->ratov, rtv_rsp->edtov, rtv_rsp->qtov); |
| 6312 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| 6313 | phba->fc_stat.elsXmitACC++; |
| 6314 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == IOCB_ERROR) |
| 6315 | lpfc_els_free_iocb(phba, elsiocb); |
| 6316 | return 0; |
| 6317 | |
| 6318 | reject_out: |
| 6319 | /* issue rejection response */ |
| 6320 | stat.un.b.lsRjtRsvd0 = 0; |
| 6321 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 6322 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 6323 | stat.un.b.vendorUnique = 0; |
| 6324 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
| 6325 | return 0; |
| 6326 | } |
| 6327 | |
| 6328 | /* lpfc_els_rcv_rps - Process an unsolicited rps iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6329 | * @vport: pointer to a host virtual N_Port data structure. |
| 6330 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6331 | * @ndlp: pointer to a node-list data structure. |
| 6332 | * |
| 6333 | * This routine processes Read Port Status (RPS) IOCB received as an |
| 6334 | * ELS unsolicited event. It first checks the remote port state. If the |
| 6335 | * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE |
| 6336 | * state, it invokes the lpfc_els_rsp_reject() routine to send the reject |
| 6337 | * response. Otherwise, it issue the MBX_READ_LNK_STAT mailbox command |
| 6338 | * for reading the HBA link statistics. It is for the callback function, |
| 6339 | * lpfc_els_rsp_rps_acc(), set to the MBX_READ_LNK_STAT mailbox command |
| 6340 | * to actually sending out RPS Accept (ACC) response. |
| 6341 | * |
| 6342 | * Return codes |
| 6343 | * 0 - Successfully processed rps iocb (currently always return 0) |
| 6344 | **/ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6345 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6346 | lpfc_els_rcv_rps(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6347 | struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6348 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6349 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6350 | uint32_t *lp; |
| 6351 | uint8_t flag; |
| 6352 | LPFC_MBOXQ_t *mbox; |
| 6353 | struct lpfc_dmabuf *pcmd; |
| 6354 | RPS *rps; |
| 6355 | struct ls_rjt stat; |
| 6356 | |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 6357 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 6358 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) |
| 6359 | /* reject the unsolicited RPS request and done with it */ |
| 6360 | goto reject_out; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6361 | |
| 6362 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 6363 | lp = (uint32_t *) pcmd->virt; |
| 6364 | flag = (be32_to_cpu(*lp++) & 0xf); |
| 6365 | rps = (RPS *) lp; |
| 6366 | |
| 6367 | if ((flag == 0) || |
| 6368 | ((flag == 1) && (be32_to_cpu(rps->un.portNum) == 0)) || |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6369 | ((flag == 2) && (memcmp(&rps->un.portName, &vport->fc_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6370 | sizeof(struct lpfc_name)) == 0))) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6371 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6372 | printk("Fix me....\n"); |
| 6373 | dump_stack(); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6374 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC); |
| 6375 | if (mbox) { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6376 | lpfc_read_lnk_stat(phba, mbox); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 6377 | mbox->context1 = (void *)((unsigned long) |
| 6378 | ((cmdiocb->iocb.unsli3.rcvsli3.ox_id << 16) | |
| 6379 | cmdiocb->iocb.ulpContext)); /* rx_id */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6380 | mbox->context2 = lpfc_nlp_get(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6381 | mbox->vport = vport; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6382 | mbox->mbox_cmpl = lpfc_els_rsp_rps_acc; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 6383 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 6384 | != MBX_NOT_FINISHED) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6385 | /* Mbox completion will send ELS Response */ |
| 6386 | return 0; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 6387 | /* Decrement reference count used for the failed mbox |
| 6388 | * command. |
| 6389 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6390 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6391 | mempool_free(mbox, phba->mbox_mem_pool); |
| 6392 | } |
| 6393 | } |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 6394 | |
| 6395 | reject_out: |
| 6396 | /* issue rejection response */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6397 | stat.un.b.lsRjtRsvd0 = 0; |
| 6398 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 6399 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 6400 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6401 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6402 | return 0; |
| 6403 | } |
| 6404 | |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 6405 | /* lpfc_issue_els_rrq - Process an unsolicited rps iocb |
| 6406 | * @vport: pointer to a host virtual N_Port data structure. |
| 6407 | * @ndlp: pointer to a node-list data structure. |
| 6408 | * @did: DID of the target. |
| 6409 | * @rrq: Pointer to the rrq struct. |
| 6410 | * |
| 6411 | * Build a ELS RRQ command and send it to the target. If the issue_iocb is |
| 6412 | * Successful the the completion handler will clear the RRQ. |
| 6413 | * |
| 6414 | * Return codes |
| 6415 | * 0 - Successfully sent rrq els iocb. |
| 6416 | * 1 - Failed to send rrq els iocb. |
| 6417 | **/ |
| 6418 | static int |
| 6419 | lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 6420 | uint32_t did, struct lpfc_node_rrq *rrq) |
| 6421 | { |
| 6422 | struct lpfc_hba *phba = vport->phba; |
| 6423 | struct RRQ *els_rrq; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 6424 | struct lpfc_iocbq *elsiocb; |
| 6425 | uint8_t *pcmd; |
| 6426 | uint16_t cmdsize; |
| 6427 | int ret; |
| 6428 | |
| 6429 | |
| 6430 | if (ndlp != rrq->ndlp) |
| 6431 | ndlp = rrq->ndlp; |
| 6432 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 6433 | return 1; |
| 6434 | |
| 6435 | /* If ndlp is not NULL, we will bump the reference count on it */ |
| 6436 | cmdsize = (sizeof(uint32_t) + sizeof(struct RRQ)); |
| 6437 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, did, |
| 6438 | ELS_CMD_RRQ); |
| 6439 | if (!elsiocb) |
| 6440 | return 1; |
| 6441 | |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 6442 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 6443 | |
| 6444 | /* For RRQ request, remainder of payload is Exchange IDs */ |
| 6445 | *((uint32_t *) (pcmd)) = ELS_CMD_RRQ; |
| 6446 | pcmd += sizeof(uint32_t); |
| 6447 | els_rrq = (struct RRQ *) pcmd; |
| 6448 | |
James Smart | ee0f4fe | 2012-05-09 21:19:14 -0400 | [diff] [blame] | 6449 | 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] | 6450 | bf_set(rrq_rxid, els_rrq, rrq->rxid); |
| 6451 | bf_set(rrq_did, els_rrq, vport->fc_myDID); |
| 6452 | els_rrq->rrq = cpu_to_be32(els_rrq->rrq); |
| 6453 | els_rrq->rrq_exchg = cpu_to_be32(els_rrq->rrq_exchg); |
| 6454 | |
| 6455 | |
| 6456 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 6457 | "Issue RRQ: did:x%x", |
| 6458 | did, rrq->xritag, rrq->rxid); |
| 6459 | elsiocb->context_un.rrq = rrq; |
| 6460 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rrq; |
| 6461 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| 6462 | |
| 6463 | if (ret == IOCB_ERROR) { |
| 6464 | lpfc_els_free_iocb(phba, elsiocb); |
| 6465 | return 1; |
| 6466 | } |
| 6467 | return 0; |
| 6468 | } |
| 6469 | |
| 6470 | /** |
| 6471 | * lpfc_send_rrq - Sends ELS RRQ if needed. |
| 6472 | * @phba: pointer to lpfc hba data structure. |
| 6473 | * @rrq: pointer to the active rrq. |
| 6474 | * |
| 6475 | * This routine will call the lpfc_issue_els_rrq if the rrq is |
| 6476 | * still active for the xri. If this function returns a failure then |
| 6477 | * the caller needs to clean up the RRQ by calling lpfc_clr_active_rrq. |
| 6478 | * |
| 6479 | * Returns 0 Success. |
| 6480 | * 1 Failure. |
| 6481 | **/ |
| 6482 | int |
| 6483 | lpfc_send_rrq(struct lpfc_hba *phba, struct lpfc_node_rrq *rrq) |
| 6484 | { |
| 6485 | struct lpfc_nodelist *ndlp = lpfc_findnode_did(rrq->vport, |
| 6486 | rrq->nlp_DID); |
| 6487 | if (lpfc_test_rrq_active(phba, ndlp, rrq->xritag)) |
| 6488 | return lpfc_issue_els_rrq(rrq->vport, ndlp, |
| 6489 | rrq->nlp_DID, rrq); |
| 6490 | else |
| 6491 | return 1; |
| 6492 | } |
| 6493 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6494 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6495 | * lpfc_els_rsp_rpl_acc - Issue an accept rpl els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6496 | * @vport: pointer to a host virtual N_Port data structure. |
| 6497 | * @cmdsize: size of the ELS command. |
| 6498 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 6499 | * @ndlp: pointer to a node-list data structure. |
| 6500 | * |
| 6501 | * This routine issuees an Accept (ACC) Read Port List (RPL) ELS command. |
| 6502 | * It is to be called by the lpfc_els_rcv_rpl() routine to accept the RPL. |
| 6503 | * |
| 6504 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 6505 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 6506 | * will be stored into the context1 field of the IOCB for the completion |
| 6507 | * callback function to the RPL Accept Response ELS command. |
| 6508 | * |
| 6509 | * Return code |
| 6510 | * 0 - Successfully issued ACC RPL ELS command |
| 6511 | * 1 - Failed to issue ACC RPL ELS command |
| 6512 | **/ |
Jamie Wellnitz | 082c026 | 2006-02-28 19:25:30 -0500 | [diff] [blame] | 6513 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6514 | lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, |
| 6515 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6516 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6517 | struct lpfc_hba *phba = vport->phba; |
| 6518 | IOCB_t *icmd, *oldcmd; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6519 | RPL_RSP rpl_rsp; |
| 6520 | struct lpfc_iocbq *elsiocb; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6521 | uint8_t *pcmd; |
| 6522 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6523 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 6524 | ndlp->nlp_DID, ELS_CMD_ACC); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6525 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 6526 | if (!elsiocb) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6527 | return 1; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 6528 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6529 | icmd = &elsiocb->iocb; |
| 6530 | oldcmd = &oldiocb->iocb; |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 6531 | icmd->ulpContext = oldcmd->ulpContext; /* Xri / rx_id */ |
| 6532 | icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6533 | |
| 6534 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 6535 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6536 | pcmd += sizeof(uint16_t); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6537 | *((uint16_t *)(pcmd)) = be16_to_cpu(cmdsize); |
| 6538 | pcmd += sizeof(uint16_t); |
| 6539 | |
| 6540 | /* Setup the RPL ACC payload */ |
| 6541 | rpl_rsp.listLen = be32_to_cpu(1); |
| 6542 | rpl_rsp.index = 0; |
| 6543 | rpl_rsp.port_num_blk.portNum = 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6544 | rpl_rsp.port_num_blk.portID = be32_to_cpu(vport->fc_myDID); |
| 6545 | memcpy(&rpl_rsp.port_num_blk.portName, &vport->fc_portname, |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6546 | sizeof(struct lpfc_name)); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6547 | memcpy(pcmd, &rpl_rsp, cmdsize - sizeof(uint32_t)); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6548 | /* Xmit ELS RPL ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6549 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6550 | "0120 Xmit ELS RPL ACC response tag x%x " |
| 6551 | "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " |
| 6552 | "rpi x%x\n", |
| 6553 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 6554 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 6555 | ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6556 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6557 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 6558 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 6559 | IOCB_ERROR) { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6560 | lpfc_els_free_iocb(phba, elsiocb); |
| 6561 | return 1; |
| 6562 | } |
| 6563 | return 0; |
| 6564 | } |
| 6565 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6566 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6567 | * lpfc_els_rcv_rpl - Process an unsolicited rpl iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6568 | * @vport: pointer to a host virtual N_Port data structure. |
| 6569 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6570 | * @ndlp: pointer to a node-list data structure. |
| 6571 | * |
| 6572 | * This routine processes Read Port List (RPL) IOCB received as an ELS |
| 6573 | * unsolicited event. It first checks the remote port state. If the remote |
| 6574 | * port is not in NLP_STE_UNMAPPED_NODE and NLP_STE_MAPPED_NODE states, it |
| 6575 | * invokes the lpfc_els_rsp_reject() routine to send reject response. |
| 6576 | * Otherwise, this routine then invokes the lpfc_els_rsp_rpl_acc() routine |
| 6577 | * to accept the RPL. |
| 6578 | * |
| 6579 | * Return code |
| 6580 | * 0 - Successfully processed rpl iocb (currently always return 0) |
| 6581 | **/ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6582 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6583 | lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6584 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6585 | { |
| 6586 | struct lpfc_dmabuf *pcmd; |
| 6587 | uint32_t *lp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6588 | uint32_t maxsize; |
| 6589 | uint16_t cmdsize; |
| 6590 | RPL *rpl; |
| 6591 | struct ls_rjt stat; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6592 | |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 6593 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
| 6594 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) { |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 6595 | /* issue rejection response */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6596 | stat.un.b.lsRjtRsvd0 = 0; |
| 6597 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 6598 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 6599 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6600 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
| 6601 | NULL); |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 6602 | /* rejected the unsolicited RPL request and done with it */ |
| 6603 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6604 | } |
| 6605 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6606 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 6607 | lp = (uint32_t *) pcmd->virt; |
| 6608 | rpl = (RPL *) (lp + 1); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6609 | maxsize = be32_to_cpu(rpl->maxsize); |
| 6610 | |
| 6611 | /* We support only one port */ |
| 6612 | if ((rpl->index == 0) && |
| 6613 | ((maxsize == 0) || |
| 6614 | ((maxsize * sizeof(uint32_t)) >= sizeof(RPL_RSP)))) { |
| 6615 | cmdsize = sizeof(uint32_t) + sizeof(RPL_RSP); |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 6616 | } else { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 6617 | cmdsize = sizeof(uint32_t) + maxsize * sizeof(uint32_t); |
| 6618 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6619 | lpfc_els_rsp_rpl_acc(vport, cmdsize, cmdiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6620 | |
| 6621 | return 0; |
| 6622 | } |
| 6623 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6624 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6625 | * lpfc_els_rcv_farp - Process an unsolicited farp request els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6626 | * @vport: pointer to a virtual N_Port data structure. |
| 6627 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6628 | * @ndlp: pointer to a node-list data structure. |
| 6629 | * |
| 6630 | * This routine processes Fibre Channel Address Resolution Protocol |
| 6631 | * (FARP) Request IOCB received as an ELS unsolicited event. Currently, |
| 6632 | * the lpfc driver only supports matching on WWPN or WWNN for FARP. As such, |
| 6633 | * FARP_MATCH_PORT flag and FARP_MATCH_NODE flag are checked against the |
| 6634 | * Match Flag in the FARP request IOCB: if FARP_MATCH_PORT flag is set, the |
| 6635 | * remote PortName is compared against the FC PortName stored in the @vport |
| 6636 | * data structure; if FARP_MATCH_NODE flag is set, the remote NodeName is |
| 6637 | * compared against the FC NodeName stored in the @vport data structure. |
| 6638 | * If any of these matches and the FARP_REQUEST_FARPR flag is set in the |
| 6639 | * FARP request IOCB Response Flag, the lpfc_issue_els_farpr() routine is |
| 6640 | * invoked to send out FARP Response to the remote node. Before sending the |
| 6641 | * FARP Response, however, the FARP_REQUEST_PLOGI flag is check in the FARP |
| 6642 | * request IOCB Response Flag and, if it is set, the lpfc_issue_els_plogi() |
| 6643 | * routine is invoked to log into the remote port first. |
| 6644 | * |
| 6645 | * Return code |
| 6646 | * 0 - Either the FARP Match Mode not supported or successfully processed |
| 6647 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6648 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6649 | lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6650 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6651 | { |
| 6652 | struct lpfc_dmabuf *pcmd; |
| 6653 | uint32_t *lp; |
| 6654 | IOCB_t *icmd; |
| 6655 | FARP *fp; |
| 6656 | uint32_t cmd, cnt, did; |
| 6657 | |
| 6658 | icmd = &cmdiocb->iocb; |
| 6659 | did = icmd->un.elsreq64.remoteID; |
| 6660 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 6661 | lp = (uint32_t *) pcmd->virt; |
| 6662 | |
| 6663 | cmd = *lp++; |
| 6664 | fp = (FARP *) lp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6665 | /* FARP-REQ received from DID <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6666 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6667 | "0601 FARP-REQ received from DID x%x\n", did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6668 | /* We will only support match on WWPN or WWNN */ |
| 6669 | if (fp->Mflags & ~(FARP_MATCH_NODE | FARP_MATCH_PORT)) { |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6670 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6671 | } |
| 6672 | |
| 6673 | cnt = 0; |
| 6674 | /* If this FARP command is searching for my portname */ |
| 6675 | if (fp->Mflags & FARP_MATCH_PORT) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6676 | if (memcmp(&fp->RportName, &vport->fc_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6677 | sizeof(struct lpfc_name)) == 0) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6678 | cnt = 1; |
| 6679 | } |
| 6680 | |
| 6681 | /* If this FARP command is searching for my nodename */ |
| 6682 | if (fp->Mflags & FARP_MATCH_NODE) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6683 | if (memcmp(&fp->RnodeName, &vport->fc_nodename, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6684 | sizeof(struct lpfc_name)) == 0) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6685 | cnt = 1; |
| 6686 | } |
| 6687 | |
| 6688 | if (cnt) { |
| 6689 | if ((ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) || |
| 6690 | (ndlp->nlp_state == NLP_STE_MAPPED_NODE)) { |
| 6691 | /* Log back into the node before sending the FARP. */ |
| 6692 | if (fp->Rflags & FARP_REQUEST_PLOGI) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6693 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6694 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | de0c5b3 | 2007-04-25 09:52:27 -0400 | [diff] [blame] | 6695 | NLP_STE_PLOGI_ISSUE); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6696 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6697 | } |
| 6698 | |
| 6699 | /* Send a FARP response to that node */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6700 | if (fp->Rflags & FARP_REQUEST_FARPR) |
| 6701 | lpfc_issue_els_farpr(vport, did, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6702 | } |
| 6703 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6704 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6705 | } |
| 6706 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6707 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6708 | * lpfc_els_rcv_farpr - Process an unsolicited farp response iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6709 | * @vport: pointer to a host virtual N_Port data structure. |
| 6710 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6711 | * @ndlp: pointer to a node-list data structure. |
| 6712 | * |
| 6713 | * This routine processes Fibre Channel Address Resolution Protocol |
| 6714 | * Response (FARPR) IOCB received as an ELS unsolicited event. It simply |
| 6715 | * invokes the lpfc_els_rsp_acc() routine to the remote node to accept |
| 6716 | * the FARP response request. |
| 6717 | * |
| 6718 | * Return code |
| 6719 | * 0 - Successfully processed FARPR IOCB (currently always return 0) |
| 6720 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6721 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6722 | lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6723 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6724 | { |
| 6725 | struct lpfc_dmabuf *pcmd; |
| 6726 | uint32_t *lp; |
| 6727 | IOCB_t *icmd; |
| 6728 | uint32_t cmd, did; |
| 6729 | |
| 6730 | icmd = &cmdiocb->iocb; |
| 6731 | did = icmd->un.elsreq64.remoteID; |
| 6732 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 6733 | lp = (uint32_t *) pcmd->virt; |
| 6734 | |
| 6735 | cmd = *lp++; |
| 6736 | /* FARP-RSP received from DID <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6737 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6738 | "0600 FARP-RSP received from DID x%x\n", did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6739 | /* ACCEPT the Farp resp request */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 6740 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6741 | |
| 6742 | return 0; |
| 6743 | } |
| 6744 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6745 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6746 | * lpfc_els_rcv_fan - Process an unsolicited fan iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6747 | * @vport: pointer to a host virtual N_Port data structure. |
| 6748 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6749 | * @fan_ndlp: pointer to a node-list data structure. |
| 6750 | * |
| 6751 | * This routine processes a Fabric Address Notification (FAN) IOCB |
| 6752 | * command received as an ELS unsolicited event. The FAN ELS command will |
| 6753 | * only be processed on a physical port (i.e., the @vport represents the |
| 6754 | * physical port). The fabric NodeName and PortName from the FAN IOCB are |
| 6755 | * compared against those in the phba data structure. If any of those is |
| 6756 | * different, the lpfc_initial_flogi() routine is invoked to initialize |
| 6757 | * Fabric Login (FLOGI) to the fabric to start the discover over. Otherwise, |
| 6758 | * if both of those are identical, the lpfc_issue_fabric_reglogin() routine |
| 6759 | * is invoked to register login to the fabric. |
| 6760 | * |
| 6761 | * Return code |
| 6762 | * 0 - Successfully processed fan iocb (currently always return 0). |
| 6763 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6764 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6765 | lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 6766 | struct lpfc_nodelist *fan_ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6767 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6768 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6769 | uint32_t *lp; |
| 6770 | FAN *fp; |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6771 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6772 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0265 FAN received\n"); |
| 6773 | lp = (uint32_t *)((struct lpfc_dmabuf *)cmdiocb->context2)->virt; |
| 6774 | fp = (FAN *) ++lp; |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6775 | /* FAN received; Fan does not have a reply sequence */ |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6776 | if ((vport == phba->pport) && |
| 6777 | (vport->port_state == LPFC_LOCAL_CFG_LINK)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6778 | if ((memcmp(&phba->fc_fabparam.nodeName, &fp->FnodeName, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6779 | sizeof(struct lpfc_name))) || |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 6780 | (memcmp(&phba->fc_fabparam.portName, &fp->FportName, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6781 | sizeof(struct lpfc_name)))) { |
| 6782 | /* This port has switched fabrics. FLOGI is required */ |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 6783 | lpfc_issue_init_vfi(vport); |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 6784 | } else { |
| 6785 | /* FAN verified - skip FLOGI */ |
| 6786 | vport->fc_myDID = vport->fc_prevDID; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6787 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 6788 | lpfc_issue_fabric_reglogin(vport); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 6789 | else { |
| 6790 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6791 | "3138 Need register VFI: (x%x/%x)\n", |
| 6792 | vport->fc_prevDID, vport->fc_myDID); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6793 | lpfc_issue_reg_vfi(vport); |
James Smart | 1b51197 | 2011-12-13 13:23:09 -0500 | [diff] [blame] | 6794 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6795 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6796 | } |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 6797 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6798 | } |
| 6799 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6800 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6801 | * lpfc_els_timeout - Handler funciton to the els timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6802 | * @ptr: holder for the timer function associated data. |
| 6803 | * |
| 6804 | * This routine is invoked by the ELS timer after timeout. It posts the ELS |
| 6805 | * timer timeout event by setting the WORKER_ELS_TMO bit to the work port |
| 6806 | * event bitmap and then invokes the lpfc_worker_wake_up() routine to wake |
| 6807 | * up the worker thread. It is for the worker thread to invoke the routine |
| 6808 | * lpfc_els_timeout_handler() to work on the posted event WORKER_ELS_TMO. |
| 6809 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6810 | void |
| 6811 | lpfc_els_timeout(unsigned long ptr) |
| 6812 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6813 | struct lpfc_vport *vport = (struct lpfc_vport *) ptr; |
| 6814 | struct lpfc_hba *phba = vport->phba; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6815 | uint32_t tmo_posted; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6816 | unsigned long iflag; |
| 6817 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6818 | spin_lock_irqsave(&vport->work_port_lock, iflag); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6819 | tmo_posted = vport->work_port_events & WORKER_ELS_TMO; |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6820 | if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING))) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6821 | vport->work_port_events |= WORKER_ELS_TMO; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6822 | spin_unlock_irqrestore(&vport->work_port_lock, iflag); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6823 | |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6824 | if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING))) |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6825 | lpfc_worker_wake_up(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6826 | return; |
| 6827 | } |
| 6828 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6829 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6830 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6831 | * lpfc_els_timeout_handler - Process an els timeout event |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6832 | * @vport: pointer to a virtual N_Port data structure. |
| 6833 | * |
| 6834 | * This routine is the actual handler function that processes an ELS timeout |
| 6835 | * event. It walks the ELS ring to get and abort all the IOCBs (except the |
| 6836 | * ABORT/CLOSE/FARP/FARPR/FDISC), which are associated with the @vport by |
| 6837 | * invoking the lpfc_sli_issue_abort_iotag() routine. |
| 6838 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6839 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6840 | lpfc_els_timeout_handler(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6841 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6842 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6843 | struct lpfc_sli_ring *pring; |
| 6844 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 6845 | IOCB_t *cmd = NULL; |
| 6846 | struct lpfc_dmabuf *pcmd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6847 | uint32_t els_command = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6848 | uint32_t timeout; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6849 | uint32_t remote_ID = 0xffffffff; |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6850 | LIST_HEAD(abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6851 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6852 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6853 | timeout = (uint32_t)(phba->fc_ratov << 1); |
| 6854 | |
| 6855 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6856 | if ((phba->pport->load_flag & FC_UNLOADING)) |
| 6857 | return; |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6858 | spin_lock_irq(&phba->hbalock); |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6859 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6860 | spin_lock(&pring->ring_lock); |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6861 | |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6862 | if ((phba->pport->load_flag & FC_UNLOADING)) { |
| 6863 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6864 | spin_unlock(&pring->ring_lock); |
| 6865 | spin_unlock_irq(&phba->hbalock); |
| 6866 | return; |
| 6867 | } |
| 6868 | |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6869 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6870 | cmd = &piocb->iocb; |
| 6871 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6872 | if ((piocb->iocb_flag & LPFC_IO_LIBDFC) != 0 || |
| 6873 | piocb->iocb.ulpCommand == CMD_ABORT_XRI_CN || |
| 6874 | piocb->iocb.ulpCommand == CMD_CLOSE_XRI_CN) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6875 | continue; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6876 | |
| 6877 | if (piocb->vport != vport) |
| 6878 | continue; |
| 6879 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6880 | pcmd = (struct lpfc_dmabuf *) piocb->context2; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6881 | if (pcmd) |
| 6882 | els_command = *(uint32_t *) (pcmd->virt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6883 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6884 | if (els_command == ELS_CMD_FARP || |
| 6885 | els_command == ELS_CMD_FARPR || |
| 6886 | els_command == ELS_CMD_FDISC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6887 | continue; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6888 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6889 | if (piocb->drvrTimeout > 0) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6890 | if (piocb->drvrTimeout >= timeout) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6891 | piocb->drvrTimeout -= timeout; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6892 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6893 | piocb->drvrTimeout = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6894 | continue; |
| 6895 | } |
| 6896 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6897 | remote_ID = 0xffffffff; |
| 6898 | if (cmd->ulpCommand != CMD_GEN_REQUEST64_CR) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6899 | remote_ID = cmd->un.elsreq64.remoteID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6900 | else { |
| 6901 | struct lpfc_nodelist *ndlp; |
| 6902 | ndlp = __lpfc_findnode_rpi(vport, cmd->ulpContext); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 6903 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6904 | remote_ID = ndlp->nlp_DID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6905 | } |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6906 | list_add_tail(&piocb->dlist, &abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6907 | } |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6908 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6909 | spin_unlock(&pring->ring_lock); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6910 | spin_unlock_irq(&phba->hbalock); |
James Smart | 5a0e326 | 2006-07-06 15:49:16 -0400 | [diff] [blame] | 6911 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6912 | list_for_each_entry_safe(piocb, tmp_iocb, &abort_list, dlist) { |
James Smart | 15026c9 | 2013-12-17 20:30:09 -0500 | [diff] [blame] | 6913 | cmd = &piocb->iocb; |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 6914 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6915 | "0127 ELS timeout Data: x%x x%x x%x " |
| 6916 | "x%x\n", els_command, |
| 6917 | remote_ID, cmd->ulpCommand, cmd->ulpIoTag); |
| 6918 | spin_lock_irq(&phba->hbalock); |
| 6919 | list_del_init(&piocb->dlist); |
| 6920 | lpfc_sli_issue_abort_iotag(phba, pring, piocb); |
| 6921 | spin_unlock_irq(&phba->hbalock); |
| 6922 | } |
| 6923 | |
James Smart | 0e9bb8d | 2013-03-01 16:35:12 -0500 | [diff] [blame] | 6924 | if (!list_empty(&phba->sli.ring[LPFC_ELS_RING].txcmplq)) |
James Smart | 06918ac | 2014-02-20 09:57:57 -0500 | [diff] [blame] | 6925 | if (!(phba->pport->load_flag & FC_UNLOADING)) |
| 6926 | mod_timer(&vport->els_tmofunc, |
| 6927 | jiffies + msecs_to_jiffies(1000 * timeout)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6928 | } |
| 6929 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6930 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6931 | * 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] | 6932 | * @vport: pointer to a host virtual N_Port data structure. |
| 6933 | * |
| 6934 | * This routine is used to clean up all the outstanding ELS commands on a |
| 6935 | * @vport. It first aborts the @vport by invoking lpfc_fabric_abort_vport() |
| 6936 | * routine. After that, it walks the ELS transmit queue to remove all the |
| 6937 | * IOCBs with the @vport other than the QUE_RING and ABORT/CLOSE IOCBs. For |
| 6938 | * the IOCBs with a non-NULL completion callback function, the callback |
| 6939 | * function will be invoked with the status set to IOSTAT_LOCAL_REJECT and |
| 6940 | * un.ulpWord[4] set to IOERR_SLI_ABORTED. For IOCBs with a NULL completion |
| 6941 | * callback function, the IOCB will simply be released. Finally, it walks |
| 6942 | * the ELS transmit completion queue to issue an abort IOCB to any transmit |
| 6943 | * completion queue IOCB that is associated with the @vport and is not |
| 6944 | * an IOCB from libdfc (i.e., the management plane IOCBs that are not |
| 6945 | * part of the discovery state machine) out to HBA by invoking the |
| 6946 | * lpfc_sli_issue_abort_iotag() routine. Note that this function issues the |
| 6947 | * abort IOCB to any transmit completion queueed IOCB, it does not guarantee |
| 6948 | * the IOCBs are aborted when this function returns. |
| 6949 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6950 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6951 | lpfc_els_flush_cmd(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6952 | { |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6953 | LIST_HEAD(abort_list); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6954 | struct lpfc_hba *phba = vport->phba; |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 6955 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6956 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 6957 | IOCB_t *cmd = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6958 | |
| 6959 | lpfc_fabric_abort_vport(vport); |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6960 | /* |
| 6961 | * For SLI3, only the hbalock is required. But SLI4 needs to coordinate |
| 6962 | * with the ring insert operation. Because lpfc_sli_issue_abort_iotag |
| 6963 | * ultimately grabs the ring_lock, the driver must splice the list into |
| 6964 | * a working list and release the locks before calling the abort. |
| 6965 | */ |
| 6966 | spin_lock_irq(&phba->hbalock); |
| 6967 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6968 | spin_lock(&pring->ring_lock); |
| 6969 | |
| 6970 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) { |
| 6971 | if (piocb->iocb_flag & LPFC_IO_LIBDFC) |
| 6972 | continue; |
| 6973 | |
| 6974 | if (piocb->vport != vport) |
| 6975 | continue; |
| 6976 | list_add_tail(&piocb->dlist, &abort_list); |
| 6977 | } |
| 6978 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6979 | spin_unlock(&pring->ring_lock); |
| 6980 | spin_unlock_irq(&phba->hbalock); |
| 6981 | /* Abort each iocb on the aborted list and remove the dlist links. */ |
| 6982 | list_for_each_entry_safe(piocb, tmp_iocb, &abort_list, dlist) { |
| 6983 | spin_lock_irq(&phba->hbalock); |
| 6984 | list_del_init(&piocb->dlist); |
| 6985 | lpfc_sli_issue_abort_iotag(phba, pring, piocb); |
| 6986 | spin_unlock_irq(&phba->hbalock); |
| 6987 | } |
| 6988 | if (!list_empty(&abort_list)) |
| 6989 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6990 | "3387 abort list for txq not empty\n"); |
| 6991 | INIT_LIST_HEAD(&abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6992 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 6993 | spin_lock_irq(&phba->hbalock); |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 6994 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6995 | spin_lock(&pring->ring_lock); |
| 6996 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6997 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txq, list) { |
| 6998 | cmd = &piocb->iocb; |
| 6999 | |
| 7000 | if (piocb->iocb_flag & LPFC_IO_LIBDFC) { |
| 7001 | continue; |
| 7002 | } |
| 7003 | |
| 7004 | /* Do not flush out the QUE_RING and ABORT/CLOSE iocbs */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 7005 | if (cmd->ulpCommand == CMD_QUE_RING_BUF_CN || |
| 7006 | cmd->ulpCommand == CMD_QUE_RING_BUF64_CN || |
| 7007 | cmd->ulpCommand == CMD_CLOSE_XRI_CN || |
| 7008 | cmd->ulpCommand == CMD_ABORT_XRI_CN) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7009 | continue; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7010 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7011 | if (piocb->vport != vport) |
| 7012 | continue; |
| 7013 | |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 7014 | list_del_init(&piocb->list); |
| 7015 | list_add_tail(&piocb->list, &abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7016 | } |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 7017 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 7018 | spin_unlock(&pring->ring_lock); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7019 | spin_unlock_irq(&phba->hbalock); |
James Smart | 2534ba7 | 2007-04-25 09:52:20 -0400 | [diff] [blame] | 7020 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 7021 | /* Cancell all the IOCBs from the completions list */ |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 7022 | lpfc_sli_cancel_iocbs(phba, &abort_list, |
| 7023 | IOSTAT_LOCAL_REJECT, IOERR_SLI_ABORTED); |
James Smart | 2534ba7 | 2007-04-25 09:52:20 -0400 | [diff] [blame] | 7024 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7025 | return; |
| 7026 | } |
| 7027 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7028 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7029 | * 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] | 7030 | * @phba: pointer to lpfc hba data structure. |
| 7031 | * |
| 7032 | * This routine is used to clean up all the outstanding ELS commands on a |
| 7033 | * @phba. It first aborts the @phba by invoking the lpfc_fabric_abort_hba() |
| 7034 | * routine. After that, it walks the ELS transmit queue to remove all the |
| 7035 | * IOCBs to the @phba other than the QUE_RING and ABORT/CLOSE IOCBs. For |
| 7036 | * the IOCBs with the completion callback function associated, the callback |
| 7037 | * function will be invoked with the status set to IOSTAT_LOCAL_REJECT and |
| 7038 | * un.ulpWord[4] set to IOERR_SLI_ABORTED. For IOCBs without the completion |
| 7039 | * callback function associated, the IOCB will simply be released. Finally, |
| 7040 | * it walks the ELS transmit completion queue to issue an abort IOCB to any |
| 7041 | * transmit completion queue IOCB that is not an IOCB from libdfc (i.e., the |
| 7042 | * management plane IOCBs that are not part of the discovery state machine) |
| 7043 | * out to HBA by invoking the lpfc_sli_issue_abort_iotag() routine. |
| 7044 | **/ |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 7045 | void |
| 7046 | lpfc_els_flush_all_cmd(struct lpfc_hba *phba) |
| 7047 | { |
James Smart | 0976e1a | 2013-12-17 20:29:36 -0500 | [diff] [blame] | 7048 | struct lpfc_vport *vport; |
| 7049 | list_for_each_entry(vport, &phba->port_list, listentry) |
| 7050 | lpfc_els_flush_cmd(vport); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 7051 | |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 7052 | return; |
| 7053 | } |
| 7054 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7055 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7056 | * lpfc_send_els_failure_event - Posts an ELS command failure event |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7057 | * @phba: Pointer to hba context object. |
| 7058 | * @cmdiocbp: Pointer to command iocb which reported error. |
| 7059 | * @rspiocbp: Pointer to response iocb which reported error. |
| 7060 | * |
| 7061 | * This function sends an event when there is an ELS command |
| 7062 | * failure. |
| 7063 | **/ |
| 7064 | void |
| 7065 | lpfc_send_els_failure_event(struct lpfc_hba *phba, |
| 7066 | struct lpfc_iocbq *cmdiocbp, |
| 7067 | struct lpfc_iocbq *rspiocbp) |
| 7068 | { |
| 7069 | struct lpfc_vport *vport = cmdiocbp->vport; |
| 7070 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 7071 | struct lpfc_lsrjt_event lsrjt_event; |
| 7072 | struct lpfc_fabric_event_header fabric_event; |
| 7073 | struct ls_rjt stat; |
| 7074 | struct lpfc_nodelist *ndlp; |
| 7075 | uint32_t *pcmd; |
| 7076 | |
| 7077 | ndlp = cmdiocbp->context1; |
| 7078 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 7079 | return; |
| 7080 | |
| 7081 | if (rspiocbp->iocb.ulpStatus == IOSTAT_LS_RJT) { |
| 7082 | lsrjt_event.header.event_type = FC_REG_ELS_EVENT; |
| 7083 | lsrjt_event.header.subcategory = LPFC_EVENT_LSRJT_RCV; |
| 7084 | memcpy(lsrjt_event.header.wwpn, &ndlp->nlp_portname, |
| 7085 | sizeof(struct lpfc_name)); |
| 7086 | memcpy(lsrjt_event.header.wwnn, &ndlp->nlp_nodename, |
| 7087 | sizeof(struct lpfc_name)); |
| 7088 | pcmd = (uint32_t *) (((struct lpfc_dmabuf *) |
| 7089 | cmdiocbp->context2)->virt); |
James Smart | 49198b3 | 2010-04-06 15:04:33 -0400 | [diff] [blame] | 7090 | lsrjt_event.command = (pcmd != NULL) ? *pcmd : 0; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7091 | stat.un.lsRjtError = be32_to_cpu(rspiocbp->iocb.un.ulpWord[4]); |
| 7092 | lsrjt_event.reason_code = stat.un.b.lsRjtRsnCode; |
| 7093 | lsrjt_event.explanation = stat.un.b.lsRjtRsnCodeExp; |
| 7094 | fc_host_post_vendor_event(shost, |
| 7095 | fc_get_event_number(), |
| 7096 | sizeof(lsrjt_event), |
| 7097 | (char *)&lsrjt_event, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7098 | LPFC_NL_VENDOR_ID); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7099 | return; |
| 7100 | } |
| 7101 | if ((rspiocbp->iocb.ulpStatus == IOSTAT_NPORT_BSY) || |
| 7102 | (rspiocbp->iocb.ulpStatus == IOSTAT_FABRIC_BSY)) { |
| 7103 | fabric_event.event_type = FC_REG_FABRIC_EVENT; |
| 7104 | if (rspiocbp->iocb.ulpStatus == IOSTAT_NPORT_BSY) |
| 7105 | fabric_event.subcategory = LPFC_EVENT_PORT_BUSY; |
| 7106 | else |
| 7107 | fabric_event.subcategory = LPFC_EVENT_FABRIC_BUSY; |
| 7108 | memcpy(fabric_event.wwpn, &ndlp->nlp_portname, |
| 7109 | sizeof(struct lpfc_name)); |
| 7110 | memcpy(fabric_event.wwnn, &ndlp->nlp_nodename, |
| 7111 | sizeof(struct lpfc_name)); |
| 7112 | fc_host_post_vendor_event(shost, |
| 7113 | fc_get_event_number(), |
| 7114 | sizeof(fabric_event), |
| 7115 | (char *)&fabric_event, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7116 | LPFC_NL_VENDOR_ID); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7117 | return; |
| 7118 | } |
| 7119 | |
| 7120 | } |
| 7121 | |
| 7122 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7123 | * lpfc_send_els_event - Posts unsolicited els event |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7124 | * @vport: Pointer to vport object. |
| 7125 | * @ndlp: Pointer FC node object. |
| 7126 | * @cmd: ELS command code. |
| 7127 | * |
| 7128 | * This function posts an event when there is an incoming |
| 7129 | * unsolicited ELS command. |
| 7130 | **/ |
| 7131 | static void |
| 7132 | lpfc_send_els_event(struct lpfc_vport *vport, |
| 7133 | struct lpfc_nodelist *ndlp, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7134 | uint32_t *payload) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7135 | { |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7136 | struct lpfc_els_event_header *els_data = NULL; |
| 7137 | struct lpfc_logo_event *logo_data = NULL; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7138 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 7139 | |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7140 | if (*payload == ELS_CMD_LOGO) { |
| 7141 | logo_data = kmalloc(sizeof(struct lpfc_logo_event), GFP_KERNEL); |
| 7142 | if (!logo_data) { |
| 7143 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7144 | "0148 Failed to allocate memory " |
| 7145 | "for LOGO event\n"); |
| 7146 | return; |
| 7147 | } |
| 7148 | els_data = &logo_data->header; |
| 7149 | } else { |
| 7150 | els_data = kmalloc(sizeof(struct lpfc_els_event_header), |
| 7151 | GFP_KERNEL); |
| 7152 | if (!els_data) { |
| 7153 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7154 | "0149 Failed to allocate memory " |
| 7155 | "for ELS event\n"); |
| 7156 | return; |
| 7157 | } |
| 7158 | } |
| 7159 | els_data->event_type = FC_REG_ELS_EVENT; |
| 7160 | switch (*payload) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7161 | case ELS_CMD_PLOGI: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7162 | els_data->subcategory = LPFC_EVENT_PLOGI_RCV; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7163 | break; |
| 7164 | case ELS_CMD_PRLO: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7165 | els_data->subcategory = LPFC_EVENT_PRLO_RCV; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7166 | break; |
| 7167 | case ELS_CMD_ADISC: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7168 | els_data->subcategory = LPFC_EVENT_ADISC_RCV; |
| 7169 | break; |
| 7170 | case ELS_CMD_LOGO: |
| 7171 | els_data->subcategory = LPFC_EVENT_LOGO_RCV; |
| 7172 | /* Copy the WWPN in the LOGO payload */ |
| 7173 | memcpy(logo_data->logo_wwpn, &payload[2], |
| 7174 | sizeof(struct lpfc_name)); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7175 | break; |
| 7176 | default: |
Julia Lawall | e916141 | 2009-02-08 22:43:19 +0100 | [diff] [blame] | 7177 | kfree(els_data); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7178 | return; |
| 7179 | } |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7180 | memcpy(els_data->wwpn, &ndlp->nlp_portname, sizeof(struct lpfc_name)); |
| 7181 | memcpy(els_data->wwnn, &ndlp->nlp_nodename, sizeof(struct lpfc_name)); |
| 7182 | if (*payload == ELS_CMD_LOGO) { |
| 7183 | fc_host_post_vendor_event(shost, |
| 7184 | fc_get_event_number(), |
| 7185 | sizeof(struct lpfc_logo_event), |
| 7186 | (char *)logo_data, |
| 7187 | LPFC_NL_VENDOR_ID); |
| 7188 | kfree(logo_data); |
| 7189 | } else { |
| 7190 | fc_host_post_vendor_event(shost, |
| 7191 | fc_get_event_number(), |
| 7192 | sizeof(struct lpfc_els_event_header), |
| 7193 | (char *)els_data, |
| 7194 | LPFC_NL_VENDOR_ID); |
| 7195 | kfree(els_data); |
| 7196 | } |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 7197 | |
| 7198 | return; |
| 7199 | } |
| 7200 | |
| 7201 | |
| 7202 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7203 | * lpfc_els_unsol_buffer - Process an unsolicited event data buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7204 | * @phba: pointer to lpfc hba data structure. |
| 7205 | * @pring: pointer to a SLI ring. |
| 7206 | * @vport: pointer to a host virtual N_Port data structure. |
| 7207 | * @elsiocb: pointer to lpfc els command iocb data structure. |
| 7208 | * |
| 7209 | * This routine is used for processing the IOCB associated with a unsolicited |
| 7210 | * event. It first determines whether there is an existing ndlp that matches |
| 7211 | * the DID from the unsolicited IOCB. If not, it will create a new one with |
| 7212 | * the DID from the unsolicited IOCB. The ELS command from the unsolicited |
| 7213 | * IOCB is then used to invoke the proper routine and to set up proper state |
| 7214 | * of the discovery state machine. |
| 7215 | **/ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7216 | static void |
| 7217 | 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] | 7218 | struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7219 | { |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 7220 | struct Scsi_Host *shost; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7221 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7222 | struct ls_rjt stat; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7223 | uint32_t *payload; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 7224 | uint32_t cmd, did, newnode; |
| 7225 | uint8_t rjt_exp, rjt_err = 0; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7226 | IOCB_t *icmd = &elsiocb->iocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7227 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 7228 | if (!vport || !(elsiocb->context2)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7229 | goto dropit; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7230 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7231 | newnode = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7232 | payload = ((struct lpfc_dmabuf *)elsiocb->context2)->virt; |
| 7233 | cmd = *payload; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7234 | if ((phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) == 0) |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 7235 | lpfc_post_buffer(phba, pring, 1); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7236 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7237 | did = icmd->un.rcvels.remoteID; |
| 7238 | if (icmd->ulpStatus) { |
| 7239 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7240 | "RCV Unsol ELS: status:x%x/x%x did:x%x", |
| 7241 | icmd->ulpStatus, icmd->un.ulpWord[4], did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7242 | goto dropit; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7243 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7244 | |
| 7245 | /* Check to see if link went down during discovery */ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7246 | if (lpfc_els_chk_latt(vport)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7247 | goto dropit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7248 | |
James Smart | c868595 | 2009-11-18 15:39:16 -0500 | [diff] [blame] | 7249 | /* Ignore traffic received during vport shutdown. */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7250 | if (vport->load_flag & FC_UNLOADING) |
| 7251 | goto dropit; |
| 7252 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7253 | /* If NPort discovery is delayed drop incoming ELS */ |
| 7254 | if ((vport->fc_flag & FC_DISC_DELAYED) && |
| 7255 | (cmd != ELS_CMD_PLOGI)) |
| 7256 | goto dropit; |
| 7257 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7258 | ndlp = lpfc_findnode_did(vport, did); |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 7259 | if (!ndlp) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7260 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 7261 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7262 | if (!ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7263 | goto dropit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7264 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7265 | lpfc_nlp_init(vport, ndlp, did); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7266 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7267 | newnode = 1; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 7268 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7269 | ndlp->nlp_type |= NLP_FABRIC; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 7270 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 7271 | ndlp = lpfc_enable_node(vport, ndlp, |
| 7272 | NLP_STE_UNUSED_NODE); |
| 7273 | if (!ndlp) |
| 7274 | goto dropit; |
| 7275 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 7276 | newnode = 1; |
| 7277 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
| 7278 | ndlp->nlp_type |= NLP_FABRIC; |
| 7279 | } else if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) { |
| 7280 | /* This is similar to the new node path */ |
| 7281 | ndlp = lpfc_nlp_get(ndlp); |
| 7282 | if (!ndlp) |
| 7283 | goto dropit; |
| 7284 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 7285 | newnode = 1; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 7286 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7287 | |
| 7288 | phba->fc_stat.elsRcvFrame++; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 7289 | |
James Smart | 12838e7 | 2014-09-03 12:57:19 -0400 | [diff] [blame] | 7290 | /* |
| 7291 | * Do not process any unsolicited ELS commands |
| 7292 | * if the ndlp is in DEV_LOSS |
| 7293 | */ |
James Smart | 466e840 | 2015-05-21 13:55:28 -0400 | [diff] [blame] | 7294 | shost = lpfc_shost_from_vport(vport); |
| 7295 | spin_lock_irq(shost->host_lock); |
| 7296 | if (ndlp->nlp_flag & NLP_IN_DEV_LOSS) { |
| 7297 | spin_unlock_irq(shost->host_lock); |
James Smart | 12838e7 | 2014-09-03 12:57:19 -0400 | [diff] [blame] | 7298 | goto dropit; |
James Smart | 466e840 | 2015-05-21 13:55:28 -0400 | [diff] [blame] | 7299 | } |
| 7300 | spin_unlock_irq(shost->host_lock); |
James Smart | 12838e7 | 2014-09-03 12:57:19 -0400 | [diff] [blame] | 7301 | |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 7302 | elsiocb->context1 = lpfc_nlp_get(ndlp); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7303 | elsiocb->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7304 | |
| 7305 | if ((cmd & ELS_CMD_MASK) == ELS_CMD_RSCN) { |
| 7306 | cmd &= ELS_CMD_MASK; |
| 7307 | } |
| 7308 | /* ELS command <elsCmd> received from NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7309 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 7310 | "0112 ELS command x%x received from NPORT x%x " |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 7311 | "Data: x%x x%x x%x x%x\n", |
| 7312 | cmd, did, vport->port_state, vport->fc_flag, |
| 7313 | vport->fc_myDID, vport->fc_prevDID); |
James Smart | eec3d31 | 2015-08-31 16:48:18 -0400 | [diff] [blame] | 7314 | |
| 7315 | /* reject till our FLOGI completes */ |
| 7316 | if ((vport->port_state < LPFC_FABRIC_CFG_LINK) && |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 7317 | (cmd != ELS_CMD_FLOGI)) { |
James Smart | eec3d31 | 2015-08-31 16:48:18 -0400 | [diff] [blame] | 7318 | rjt_err = LSRJT_UNABLE_TPC; |
| 7319 | rjt_exp = LSEXP_NOTHING_MORE; |
| 7320 | goto lsrjt; |
| 7321 | } |
| 7322 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7323 | switch (cmd) { |
| 7324 | case ELS_CMD_PLOGI: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7325 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7326 | "RCV PLOGI: did:x%x/ste:x%x flg:x%x", |
| 7327 | did, vport->port_state, ndlp->nlp_flag); |
| 7328 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7329 | phba->fc_stat.elsRcvPLOGI++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7330 | ndlp = lpfc_plogi_confirm_nport(phba, payload, ndlp); |
James Smart | e74c03c | 2013-04-17 20:15:19 -0400 | [diff] [blame] | 7331 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 7332 | (phba->pport->fc_flag & FC_PT2PT)) { |
| 7333 | vport->fc_prevDID = vport->fc_myDID; |
| 7334 | /* Our DID needs to be updated before registering |
| 7335 | * the vfi. This is done in lpfc_rcv_plogi but |
| 7336 | * that is called after the reg_vfi. |
| 7337 | */ |
| 7338 | vport->fc_myDID = elsiocb->iocb.un.rcvels.parmRo; |
| 7339 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 7340 | "3312 Remote port assigned DID x%x " |
| 7341 | "%x\n", vport->fc_myDID, |
| 7342 | vport->fc_prevDID); |
| 7343 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7344 | |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7345 | lpfc_send_els_event(vport, ndlp, payload); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7346 | |
| 7347 | /* If Nport discovery is delayed, reject PLOGIs */ |
| 7348 | if (vport->fc_flag & FC_DISC_DELAYED) { |
| 7349 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 7350 | rjt_exp = LSEXP_NOTHING_MORE; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7351 | break; |
| 7352 | } |
James Smart | d6de08c | 2015-12-16 18:11:53 -0500 | [diff] [blame^] | 7353 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7354 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 1b32f6a | 2008-02-08 18:49:39 -0500 | [diff] [blame] | 7355 | if (!(phba->pport->fc_flag & FC_PT2PT) || |
| 7356 | (phba->pport->fc_flag & FC_PT2PT_PLOGI)) { |
| 7357 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 7358 | rjt_exp = LSEXP_NOTHING_MORE; |
James Smart | 1b32f6a | 2008-02-08 18:49:39 -0500 | [diff] [blame] | 7359 | break; |
| 7360 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7361 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 7362 | |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 7363 | spin_lock_irq(shost->host_lock); |
| 7364 | ndlp->nlp_flag &= ~NLP_TARGET_REMOVE; |
| 7365 | spin_unlock_irq(shost->host_lock); |
| 7366 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7367 | lpfc_disc_state_machine(vport, ndlp, elsiocb, |
| 7368 | NLP_EVT_RCV_PLOGI); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7369 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7370 | break; |
| 7371 | case ELS_CMD_FLOGI: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7372 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7373 | "RCV FLOGI: did:x%x/ste:x%x flg:x%x", |
| 7374 | did, vport->port_state, ndlp->nlp_flag); |
| 7375 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7376 | phba->fc_stat.elsRcvFLOGI++; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 7377 | lpfc_els_rcv_flogi(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 7378 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7379 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7380 | break; |
| 7381 | case ELS_CMD_LOGO: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7382 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7383 | "RCV LOGO: did:x%x/ste:x%x flg:x%x", |
| 7384 | did, vport->port_state, ndlp->nlp_flag); |
| 7385 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7386 | phba->fc_stat.elsRcvLOGO++; |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7387 | lpfc_send_els_event(vport, ndlp, payload); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7388 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7389 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 7390 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7391 | break; |
| 7392 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7393 | lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_LOGO); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7394 | break; |
| 7395 | case ELS_CMD_PRLO: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7396 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7397 | "RCV PRLO: did:x%x/ste:x%x flg:x%x", |
| 7398 | did, vport->port_state, ndlp->nlp_flag); |
| 7399 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7400 | phba->fc_stat.elsRcvPRLO++; |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7401 | lpfc_send_els_event(vport, ndlp, payload); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7402 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7403 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 7404 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7405 | break; |
| 7406 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7407 | lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLO); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7408 | break; |
James Smart | 8b017a3 | 2015-05-21 13:55:18 -0400 | [diff] [blame] | 7409 | case ELS_CMD_LCB: |
| 7410 | phba->fc_stat.elsRcvLCB++; |
| 7411 | lpfc_els_rcv_lcb(vport, elsiocb, ndlp); |
| 7412 | break; |
James Smart | 8647887 | 2015-05-21 13:55:21 -0400 | [diff] [blame] | 7413 | case ELS_CMD_RDP: |
| 7414 | phba->fc_stat.elsRcvRDP++; |
| 7415 | lpfc_els_rcv_rdp(vport, elsiocb, ndlp); |
| 7416 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7417 | case ELS_CMD_RSCN: |
| 7418 | phba->fc_stat.elsRcvRSCN++; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 7419 | lpfc_els_rcv_rscn(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 7420 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7421 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7422 | break; |
| 7423 | case ELS_CMD_ADISC: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7424 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7425 | "RCV ADISC: did:x%x/ste:x%x flg:x%x", |
| 7426 | did, vport->port_state, ndlp->nlp_flag); |
| 7427 | |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 7428 | lpfc_send_els_event(vport, ndlp, payload); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7429 | phba->fc_stat.elsRcvADISC++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7430 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7431 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 7432 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7433 | break; |
| 7434 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7435 | lpfc_disc_state_machine(vport, ndlp, elsiocb, |
| 7436 | NLP_EVT_RCV_ADISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7437 | break; |
| 7438 | case ELS_CMD_PDISC: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7439 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7440 | "RCV PDISC: did:x%x/ste:x%x flg:x%x", |
| 7441 | did, vport->port_state, ndlp->nlp_flag); |
| 7442 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7443 | phba->fc_stat.elsRcvPDISC++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7444 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7445 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 7446 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7447 | break; |
| 7448 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7449 | lpfc_disc_state_machine(vport, ndlp, elsiocb, |
| 7450 | NLP_EVT_RCV_PDISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7451 | break; |
| 7452 | case ELS_CMD_FARPR: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7453 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7454 | "RCV FARPR: did:x%x/ste:x%x flg:x%x", |
| 7455 | did, vport->port_state, ndlp->nlp_flag); |
| 7456 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7457 | phba->fc_stat.elsRcvFARPR++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7458 | lpfc_els_rcv_farpr(vport, elsiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7459 | break; |
| 7460 | case ELS_CMD_FARP: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7461 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7462 | "RCV FARP: did:x%x/ste:x%x flg:x%x", |
| 7463 | did, vport->port_state, ndlp->nlp_flag); |
| 7464 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7465 | phba->fc_stat.elsRcvFARP++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7466 | lpfc_els_rcv_farp(vport, elsiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7467 | break; |
| 7468 | case ELS_CMD_FAN: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7469 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7470 | "RCV FAN: did:x%x/ste:x%x flg:x%x", |
| 7471 | did, vport->port_state, ndlp->nlp_flag); |
| 7472 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7473 | phba->fc_stat.elsRcvFAN++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7474 | lpfc_els_rcv_fan(vport, elsiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7475 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7476 | case ELS_CMD_PRLI: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7477 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7478 | "RCV PRLI: did:x%x/ste:x%x flg:x%x", |
| 7479 | did, vport->port_state, ndlp->nlp_flag); |
| 7480 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7481 | phba->fc_stat.elsRcvPRLI++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7482 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7483 | rjt_err = LSRJT_UNABLE_TPC; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 7484 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7485 | break; |
| 7486 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7487 | lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7488 | break; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 7489 | case ELS_CMD_LIRR: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7490 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7491 | "RCV LIRR: did:x%x/ste:x%x flg:x%x", |
| 7492 | did, vport->port_state, ndlp->nlp_flag); |
| 7493 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 7494 | phba->fc_stat.elsRcvLIRR++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7495 | lpfc_els_rcv_lirr(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 7496 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7497 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 7498 | break; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 7499 | case ELS_CMD_RLS: |
| 7500 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7501 | "RCV RLS: did:x%x/ste:x%x flg:x%x", |
| 7502 | did, vport->port_state, ndlp->nlp_flag); |
| 7503 | |
| 7504 | phba->fc_stat.elsRcvRLS++; |
| 7505 | lpfc_els_rcv_rls(vport, elsiocb, ndlp); |
| 7506 | if (newnode) |
| 7507 | lpfc_nlp_put(ndlp); |
| 7508 | break; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 7509 | case ELS_CMD_RPS: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7510 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7511 | "RCV RPS: did:x%x/ste:x%x flg:x%x", |
| 7512 | did, vport->port_state, ndlp->nlp_flag); |
| 7513 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 7514 | phba->fc_stat.elsRcvRPS++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7515 | lpfc_els_rcv_rps(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 7516 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7517 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 7518 | break; |
| 7519 | case ELS_CMD_RPL: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7520 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7521 | "RCV RPL: did:x%x/ste:x%x flg:x%x", |
| 7522 | did, vport->port_state, ndlp->nlp_flag); |
| 7523 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 7524 | phba->fc_stat.elsRcvRPL++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7525 | lpfc_els_rcv_rpl(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 7526 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7527 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 7528 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7529 | case ELS_CMD_RNID: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7530 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7531 | "RCV RNID: did:x%x/ste:x%x flg:x%x", |
| 7532 | did, vport->port_state, ndlp->nlp_flag); |
| 7533 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7534 | phba->fc_stat.elsRcvRNID++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 7535 | lpfc_els_rcv_rnid(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 7536 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7537 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7538 | break; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 7539 | case ELS_CMD_RTV: |
| 7540 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7541 | "RCV RTV: did:x%x/ste:x%x flg:x%x", |
| 7542 | did, vport->port_state, ndlp->nlp_flag); |
| 7543 | phba->fc_stat.elsRcvRTV++; |
| 7544 | lpfc_els_rcv_rtv(vport, elsiocb, ndlp); |
| 7545 | if (newnode) |
| 7546 | lpfc_nlp_put(ndlp); |
| 7547 | break; |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 7548 | case ELS_CMD_RRQ: |
| 7549 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7550 | "RCV RRQ: did:x%x/ste:x%x flg:x%x", |
| 7551 | did, vport->port_state, ndlp->nlp_flag); |
| 7552 | |
| 7553 | phba->fc_stat.elsRcvRRQ++; |
| 7554 | lpfc_els_rcv_rrq(vport, elsiocb, ndlp); |
| 7555 | if (newnode) |
| 7556 | lpfc_nlp_put(ndlp); |
| 7557 | break; |
James Smart | 12265f6 | 2010-10-22 11:05:53 -0400 | [diff] [blame] | 7558 | case ELS_CMD_ECHO: |
| 7559 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7560 | "RCV ECHO: did:x%x/ste:x%x flg:x%x", |
| 7561 | did, vport->port_state, ndlp->nlp_flag); |
| 7562 | |
| 7563 | phba->fc_stat.elsRcvECHO++; |
| 7564 | lpfc_els_rcv_echo(vport, elsiocb, ndlp); |
| 7565 | if (newnode) |
| 7566 | lpfc_nlp_put(ndlp); |
| 7567 | break; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 7568 | case ELS_CMD_REC: |
| 7569 | /* receive this due to exchange closed */ |
| 7570 | rjt_err = LSRJT_UNABLE_TPC; |
| 7571 | rjt_exp = LSEXP_INVALID_OX_RX; |
| 7572 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7573 | default: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7574 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 7575 | "RCV ELS cmd: cmd:x%x did:x%x/ste:x%x", |
| 7576 | cmd, did, vport->port_state); |
| 7577 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7578 | /* Unsupported ELS command, reject */ |
James Smart | 63e801c | 2010-11-20 23:14:19 -0500 | [diff] [blame] | 7579 | rjt_err = LSRJT_CMD_UNSUPPORTED; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 7580 | rjt_exp = LSEXP_NOTHING_MORE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7581 | |
| 7582 | /* Unknown ELS command <elsCmd> received from NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7583 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7584 | "0115 Unknown ELS command x%x " |
| 7585 | "received from NPORT x%x\n", cmd, did); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 7586 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7587 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7588 | break; |
| 7589 | } |
| 7590 | |
James Smart | eec3d31 | 2015-08-31 16:48:18 -0400 | [diff] [blame] | 7591 | lsrjt: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7592 | /* check if need to LS_RJT received ELS cmd */ |
| 7593 | if (rjt_err) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7594 | memset(&stat, 0, sizeof(stat)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7595 | stat.un.b.lsRjtRsnCode = rjt_err; |
James Smart | 303f2f9 | 2013-01-03 15:43:11 -0500 | [diff] [blame] | 7596 | stat.un.b.lsRjtRsnCodeExp = rjt_exp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 7597 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp, |
| 7598 | NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7599 | } |
| 7600 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7601 | lpfc_nlp_put(elsiocb->context1); |
| 7602 | elsiocb->context1 = NULL; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7603 | return; |
| 7604 | |
| 7605 | dropit: |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 7606 | if (vport && !(vport->load_flag & FC_UNLOADING)) |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7607 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7608 | "0111 Dropping received ELS cmd " |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7609 | "Data: x%x x%x x%x\n", |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7610 | icmd->ulpStatus, icmd->un.ulpWord[4], icmd->ulpTimeout); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7611 | phba->fc_stat.elsRcvDrop++; |
| 7612 | } |
| 7613 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7614 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7615 | * 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] | 7616 | * @phba: pointer to lpfc hba data structure. |
| 7617 | * @pring: pointer to a SLI ring. |
| 7618 | * @elsiocb: pointer to lpfc els iocb data structure. |
| 7619 | * |
| 7620 | * This routine is used to process an unsolicited event received from a SLI |
| 7621 | * (Service Level Interface) ring. The actual processing of the data buffer |
| 7622 | * associated with the unsolicited event is done by invoking the routine |
| 7623 | * lpfc_els_unsol_buffer() after properly set up the iocb buffer from the |
| 7624 | * SLI ring on which the unsolicited event was received. |
| 7625 | **/ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7626 | void |
| 7627 | lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
| 7628 | struct lpfc_iocbq *elsiocb) |
| 7629 | { |
| 7630 | struct lpfc_vport *vport = phba->pport; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7631 | IOCB_t *icmd = &elsiocb->iocb; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7632 | dma_addr_t paddr; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7633 | struct lpfc_dmabuf *bdeBuf1 = elsiocb->context2; |
| 7634 | struct lpfc_dmabuf *bdeBuf2 = elsiocb->context3; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7635 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 7636 | elsiocb->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7637 | elsiocb->context2 = NULL; |
| 7638 | elsiocb->context3 = NULL; |
| 7639 | |
| 7640 | if (icmd->ulpStatus == IOSTAT_NEED_BUFFER) { |
| 7641 | lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ); |
| 7642 | } else if (icmd->ulpStatus == IOSTAT_LOCAL_REJECT && |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 7643 | (icmd->un.ulpWord[4] & IOERR_PARAM_MASK) == |
| 7644 | IOERR_RCV_BUFFER_WAITING) { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7645 | phba->fc_stat.NoRcvBuf++; |
| 7646 | /* Not enough posted buffers; Try posting more buffers */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7647 | if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)) |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 7648 | lpfc_post_buffer(phba, pring, 0); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7649 | return; |
| 7650 | } |
| 7651 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7652 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
| 7653 | (icmd->ulpCommand == CMD_IOCB_RCV_ELS64_CX || |
| 7654 | icmd->ulpCommand == CMD_IOCB_RCV_SEQ64_CX)) { |
| 7655 | if (icmd->unsli3.rcvsli3.vpi == 0xffff) |
| 7656 | vport = phba->pport; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7657 | else |
| 7658 | vport = lpfc_find_vport_by_vpid(phba, |
James Smart | 6d368e5 | 2011-05-24 11:44:12 -0400 | [diff] [blame] | 7659 | icmd->unsli3.rcvsli3.vpi); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7660 | } |
James Smart | 6d368e5 | 2011-05-24 11:44:12 -0400 | [diff] [blame] | 7661 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7662 | /* If there are no BDEs associated |
| 7663 | * with this IOCB, there is nothing to do. |
| 7664 | */ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7665 | if (icmd->ulpBdeCount == 0) |
| 7666 | return; |
| 7667 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7668 | /* type of ELS cmd is first 32bit word |
| 7669 | * in packet |
| 7670 | */ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7671 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7672 | elsiocb->context2 = bdeBuf1; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7673 | } else { |
| 7674 | paddr = getPaddr(icmd->un.cont64[0].addrHigh, |
| 7675 | icmd->un.cont64[0].addrLow); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7676 | elsiocb->context2 = lpfc_sli_ringpostbuf_get(phba, pring, |
| 7677 | paddr); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7678 | } |
| 7679 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7680 | lpfc_els_unsol_buffer(phba, pring, vport, elsiocb); |
| 7681 | /* |
| 7682 | * The different unsolicited event handlers would tell us |
| 7683 | * if they are done with "mp" by setting context2 to NULL. |
| 7684 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7685 | if (elsiocb->context2) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7686 | lpfc_in_buf_free(phba, (struct lpfc_dmabuf *)elsiocb->context2); |
| 7687 | elsiocb->context2 = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7688 | } |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7689 | |
| 7690 | /* RCV_ELS64_CX provide for 2 BDEs - process 2nd if included */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7691 | if ((phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) && |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7692 | icmd->ulpBdeCount == 2) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7693 | elsiocb->context2 = bdeBuf2; |
| 7694 | lpfc_els_unsol_buffer(phba, pring, vport, elsiocb); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7695 | /* free mp if we are done with it */ |
| 7696 | if (elsiocb->context2) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7697 | lpfc_in_buf_free(phba, elsiocb->context2); |
| 7698 | elsiocb->context2 = NULL; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 7699 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7700 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 7701 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7702 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7703 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7704 | * 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] | 7705 | * @phba: pointer to lpfc hba data structure. |
| 7706 | * @vport: pointer to a virtual N_Port data structure. |
| 7707 | * |
| 7708 | * This routine issues a Port Login (PLOGI) to the Name Server with |
| 7709 | * State Change Request (SCR) for a @vport. This routine will create an |
| 7710 | * ndlp for the Name Server associated to the @vport if such node does |
| 7711 | * not already exist. The PLOGI to Name Server is issued by invoking the |
| 7712 | * lpfc_issue_els_plogi() routine. If Fabric-Device Management Interface |
| 7713 | * (FDMI) is configured to the @vport, a FDMI node will be created and |
| 7714 | * the PLOGI to FDMI is issued by invoking lpfc_issue_els_plogi() routine. |
| 7715 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7716 | void |
| 7717 | lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport) |
| 7718 | { |
| 7719 | struct lpfc_nodelist *ndlp, *ndlp_fdmi; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7720 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 7721 | |
| 7722 | /* |
| 7723 | * If lpfc_delay_discovery parameter is set and the clean address |
| 7724 | * bit is cleared and fc fabric parameters chenged, delay FC NPort |
| 7725 | * discovery. |
| 7726 | */ |
| 7727 | spin_lock_irq(shost->host_lock); |
| 7728 | if (vport->fc_flag & FC_DISC_DELAYED) { |
| 7729 | spin_unlock_irq(shost->host_lock); |
James Smart | 1877570 | 2013-04-17 20:19:25 -0400 | [diff] [blame] | 7730 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, |
| 7731 | "3334 Delay fc port discovery for %d seconds\n", |
| 7732 | phba->fc_ratov); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7733 | mod_timer(&vport->delayed_disc_tmo, |
James Smart | 256ec0d | 2013-04-17 20:14:58 -0400 | [diff] [blame] | 7734 | jiffies + msecs_to_jiffies(1000 * phba->fc_ratov)); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 7735 | return; |
| 7736 | } |
| 7737 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7738 | |
| 7739 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
| 7740 | if (!ndlp) { |
| 7741 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 7742 | if (!ndlp) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 7743 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7744 | lpfc_disc_start(vport); |
| 7745 | return; |
| 7746 | } |
| 7747 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7748 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7749 | "0251 NameServer login: no memory\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7750 | return; |
| 7751 | } |
| 7752 | lpfc_nlp_init(vport, ndlp, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 7753 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 7754 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 7755 | if (!ndlp) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 7756 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 7757 | lpfc_disc_start(vport); |
| 7758 | return; |
| 7759 | } |
| 7760 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 7761 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7762 | "0348 NameServer login: node freed\n"); |
| 7763 | return; |
| 7764 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7765 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 7766 | ndlp->nlp_type |= NLP_FABRIC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7767 | |
| 7768 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
| 7769 | |
| 7770 | if (lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0)) { |
| 7771 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7772 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 7773 | "0252 Cannot issue NameServer login\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7774 | return; |
| 7775 | } |
| 7776 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 7777 | if (vport->cfg_fdmi_on & LPFC_FDMI_SUPPORT) { |
James Smart | 63e801c | 2010-11-20 23:14:19 -0500 | [diff] [blame] | 7778 | /* If this is the first time, allocate an ndlp and initialize |
| 7779 | * it. Otherwise, make sure the node is enabled and then do the |
| 7780 | * login. |
| 7781 | */ |
| 7782 | ndlp_fdmi = lpfc_findnode_did(vport, FDMI_DID); |
| 7783 | if (!ndlp_fdmi) { |
| 7784 | ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool, |
| 7785 | GFP_KERNEL); |
| 7786 | if (ndlp_fdmi) { |
| 7787 | lpfc_nlp_init(vport, ndlp_fdmi, FDMI_DID); |
| 7788 | ndlp_fdmi->nlp_type |= NLP_FABRIC; |
| 7789 | } else |
| 7790 | return; |
| 7791 | } |
| 7792 | if (!NLP_CHK_NODE_ACT(ndlp_fdmi)) |
| 7793 | ndlp_fdmi = lpfc_enable_node(vport, |
| 7794 | ndlp_fdmi, |
| 7795 | NLP_STE_NPR_NODE); |
| 7796 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7797 | if (ndlp_fdmi) { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 7798 | lpfc_nlp_set_state(vport, ndlp_fdmi, |
James Smart | 63e801c | 2010-11-20 23:14:19 -0500 | [diff] [blame] | 7799 | NLP_STE_PLOGI_ISSUE); |
| 7800 | lpfc_issue_els_plogi(vport, ndlp_fdmi->nlp_DID, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7801 | } |
| 7802 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7803 | } |
| 7804 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7805 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7806 | * lpfc_cmpl_reg_new_vport - Completion callback function to register new vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7807 | * @phba: pointer to lpfc hba data structure. |
| 7808 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 7809 | * |
| 7810 | * This routine is the completion callback function to register new vport |
| 7811 | * mailbox command. If the new vport mailbox command completes successfully, |
| 7812 | * the fabric registration login shall be performed on physical port (the |
| 7813 | * new vport created is actually a physical port, with VPI 0) or the port |
| 7814 | * login to Name Server for State Change Request (SCR) will be performed |
| 7815 | * on virtual port (real virtual port, with VPI greater than 0). |
| 7816 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7817 | static void |
| 7818 | lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
| 7819 | { |
| 7820 | struct lpfc_vport *vport = pmb->vport; |
| 7821 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 7822 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2; |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 7823 | MAILBOX_t *mb = &pmb->u.mb; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7824 | int rc; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7825 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7826 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7827 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7828 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7829 | |
| 7830 | if (mb->mbxStatus) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7831 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 7832 | "0915 Register VPI failed : Status: x%x" |
| 7833 | " upd bit: x%x \n", mb->mbxStatus, |
| 7834 | mb->un.varRegVpi.upd); |
| 7835 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 7836 | mb->un.varRegVpi.upd) |
| 7837 | goto mbox_err_exit ; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7838 | |
| 7839 | switch (mb->mbxStatus) { |
| 7840 | case 0x11: /* unsupported feature */ |
| 7841 | case 0x9603: /* max_vpi exceeded */ |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7842 | case 0x9602: /* Link event since CLEAR_LA */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7843 | /* giving up on vport registration */ |
| 7844 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 7845 | spin_lock_irq(shost->host_lock); |
| 7846 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
| 7847 | spin_unlock_irq(shost->host_lock); |
| 7848 | lpfc_can_disctmo(vport); |
| 7849 | break; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7850 | /* If reg_vpi fail with invalid VPI status, re-init VPI */ |
| 7851 | case 0x20: |
| 7852 | spin_lock_irq(shost->host_lock); |
| 7853 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
| 7854 | spin_unlock_irq(shost->host_lock); |
| 7855 | lpfc_init_vpi(phba, pmb, vport->vpi); |
| 7856 | pmb->vport = vport; |
| 7857 | pmb->mbox_cmpl = lpfc_init_vpi_cmpl; |
| 7858 | rc = lpfc_sli_issue_mbox(phba, pmb, |
| 7859 | MBX_NOWAIT); |
| 7860 | if (rc == MBX_NOT_FINISHED) { |
| 7861 | lpfc_printf_vlog(vport, |
| 7862 | KERN_ERR, LOG_MBOX, |
| 7863 | "2732 Failed to issue INIT_VPI" |
| 7864 | " mailbox command\n"); |
| 7865 | } else { |
| 7866 | lpfc_nlp_put(ndlp); |
| 7867 | return; |
| 7868 | } |
| 7869 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7870 | default: |
| 7871 | /* Try to recover from this error */ |
James Smart | 5af5eee | 2010-10-22 11:06:38 -0400 | [diff] [blame] | 7872 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 7873 | lpfc_sli4_unreg_all_rpis(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7874 | lpfc_mbx_unreg_vpi(vport); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7875 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7876 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7877 | spin_unlock_irq(shost->host_lock); |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 7878 | if (vport->port_type == LPFC_PHYSICAL_PORT |
| 7879 | && !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 7880 | lpfc_issue_init_vfi(vport); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 7881 | else |
| 7882 | lpfc_initial_fdisc(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7883 | break; |
| 7884 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7885 | } else { |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7886 | spin_lock_irq(shost->host_lock); |
James Smart | 1987807 | 2009-12-21 17:02:00 -0500 | [diff] [blame] | 7887 | vport->vpi_state |= LPFC_VPI_REGISTERED; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7888 | spin_unlock_irq(shost->host_lock); |
| 7889 | if (vport == phba->pport) { |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7890 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 7891 | lpfc_issue_fabric_reglogin(vport); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7892 | else { |
James Smart | fc2b989 | 2010-02-26 14:15:29 -0500 | [diff] [blame] | 7893 | /* |
| 7894 | * If the physical port is instantiated using |
| 7895 | * FDISC, do not start vport discovery. |
| 7896 | */ |
| 7897 | if (vport->port_state != LPFC_FDISC) |
| 7898 | lpfc_start_fdiscs(phba); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7899 | lpfc_do_scr_ns_plogi(phba, vport); |
| 7900 | } |
| 7901 | } else |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7902 | lpfc_do_scr_ns_plogi(phba, vport); |
| 7903 | } |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 7904 | mbox_err_exit: |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 7905 | /* Now, we decrement the ndlp reference count held for this |
| 7906 | * callback function |
| 7907 | */ |
| 7908 | lpfc_nlp_put(ndlp); |
| 7909 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7910 | mempool_free(pmb, phba->mbox_mem_pool); |
| 7911 | return; |
| 7912 | } |
| 7913 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7914 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 7915 | * lpfc_register_new_vport - Register a new vport with a HBA |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7916 | * @phba: pointer to lpfc hba data structure. |
| 7917 | * @vport: pointer to a host virtual N_Port data structure. |
| 7918 | * @ndlp: pointer to a node-list data structure. |
| 7919 | * |
| 7920 | * This routine registers the @vport as a new virtual port with a HBA. |
| 7921 | * It is done through a registering vpi mailbox command. |
| 7922 | **/ |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7923 | void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7924 | lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport, |
| 7925 | struct lpfc_nodelist *ndlp) |
| 7926 | { |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 7927 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7928 | LPFC_MBOXQ_t *mbox; |
| 7929 | |
| 7930 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 7931 | if (mbox) { |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7932 | lpfc_reg_vpi(vport, mbox); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7933 | mbox->vport = vport; |
| 7934 | mbox->context2 = lpfc_nlp_get(ndlp); |
| 7935 | mbox->mbox_cmpl = lpfc_cmpl_reg_new_vport; |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 7936 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7937 | == MBX_NOT_FINISHED) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 7938 | /* mailbox command not success, decrement ndlp |
| 7939 | * reference count for this command |
| 7940 | */ |
| 7941 | lpfc_nlp_put(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7942 | mempool_free(mbox, phba->mbox_mem_pool); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7943 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7944 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
| 7945 | "0253 Register VPI: Can't send mbox\n"); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 7946 | goto mbox_err_exit; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7947 | } |
| 7948 | } else { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 7949 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
| 7950 | "0254 Register VPI: no memory\n"); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 7951 | goto mbox_err_exit; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7952 | } |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 7953 | return; |
| 7954 | |
| 7955 | mbox_err_exit: |
| 7956 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 7957 | spin_lock_irq(shost->host_lock); |
| 7958 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; |
| 7959 | spin_unlock_irq(shost->host_lock); |
| 7960 | return; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7961 | } |
| 7962 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 7963 | /** |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 7964 | * 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] | 7965 | * @phba: pointer to lpfc hba data structure. |
| 7966 | * |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 7967 | * This routine cancels the retry delay timers to all the vports. |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7968 | **/ |
| 7969 | void |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 7970 | lpfc_cancel_all_vport_retry_delay_timer(struct lpfc_hba *phba) |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7971 | { |
| 7972 | struct lpfc_vport **vports; |
| 7973 | struct lpfc_nodelist *ndlp; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7974 | uint32_t link_state; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 7975 | int i; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 7976 | |
| 7977 | /* Treat this failure as linkdown for all vports */ |
| 7978 | link_state = phba->link_state; |
| 7979 | lpfc_linkdown(phba); |
| 7980 | phba->link_state = link_state; |
| 7981 | |
| 7982 | vports = lpfc_create_vport_work_array(phba); |
| 7983 | |
| 7984 | if (vports) { |
| 7985 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
| 7986 | ndlp = lpfc_findnode_did(vports[i], Fabric_DID); |
| 7987 | if (ndlp) |
| 7988 | lpfc_cancel_retry_delay_tmo(vports[i], ndlp); |
| 7989 | lpfc_els_flush_cmd(vports[i]); |
| 7990 | } |
| 7991 | lpfc_destroy_vport_work_array(phba, vports); |
| 7992 | } |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 7993 | } |
| 7994 | |
| 7995 | /** |
| 7996 | * lpfc_retry_pport_discovery - Start timer to retry FLOGI. |
| 7997 | * @phba: pointer to lpfc hba data structure. |
| 7998 | * |
| 7999 | * This routine abort all pending discovery commands and |
| 8000 | * start a timer to retry FLOGI for the physical port |
| 8001 | * discovery. |
| 8002 | **/ |
| 8003 | void |
| 8004 | lpfc_retry_pport_discovery(struct lpfc_hba *phba) |
| 8005 | { |
| 8006 | struct lpfc_nodelist *ndlp; |
| 8007 | struct Scsi_Host *shost; |
| 8008 | |
| 8009 | /* Cancel the all vports retry delay retry timers */ |
| 8010 | lpfc_cancel_all_vport_retry_delay_timer(phba); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 8011 | |
| 8012 | /* If fabric require FLOGI, then re-instantiate physical login */ |
| 8013 | ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); |
| 8014 | if (!ndlp) |
| 8015 | return; |
| 8016 | |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 8017 | shost = lpfc_shost_from_vport(phba->pport); |
James Smart | 256ec0d | 2013-04-17 20:14:58 -0400 | [diff] [blame] | 8018 | mod_timer(&ndlp->nlp_delayfunc, jiffies + msecs_to_jiffies(1000)); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 8019 | spin_lock_irq(shost->host_lock); |
| 8020 | ndlp->nlp_flag |= NLP_DELAY_TMO; |
| 8021 | spin_unlock_irq(shost->host_lock); |
| 8022 | ndlp->nlp_last_elscmd = ELS_CMD_FLOGI; |
| 8023 | phba->pport->port_state = LPFC_FLOGI; |
| 8024 | return; |
| 8025 | } |
| 8026 | |
| 8027 | /** |
| 8028 | * lpfc_fabric_login_reqd - Check if FLOGI required. |
| 8029 | * @phba: pointer to lpfc hba data structure. |
| 8030 | * @cmdiocb: pointer to FDISC command iocb. |
| 8031 | * @rspiocb: pointer to FDISC response iocb. |
| 8032 | * |
| 8033 | * This routine checks if a FLOGI is reguired for FDISC |
| 8034 | * to succeed. |
| 8035 | **/ |
| 8036 | static int |
| 8037 | lpfc_fabric_login_reqd(struct lpfc_hba *phba, |
| 8038 | struct lpfc_iocbq *cmdiocb, |
| 8039 | struct lpfc_iocbq *rspiocb) |
| 8040 | { |
| 8041 | |
| 8042 | if ((rspiocb->iocb.ulpStatus != IOSTAT_FABRIC_RJT) || |
| 8043 | (rspiocb->iocb.un.ulpWord[4] != RJT_LOGIN_REQUIRED)) |
| 8044 | return 0; |
| 8045 | else |
| 8046 | return 1; |
| 8047 | } |
| 8048 | |
| 8049 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8050 | * lpfc_cmpl_els_fdisc - Completion function for fdisc iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8051 | * @phba: pointer to lpfc hba data structure. |
| 8052 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 8053 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 8054 | * |
| 8055 | * This routine is the completion callback function to a Fabric Discover |
| 8056 | * (FDISC) ELS command. Since all the FDISC ELS commands are issued |
| 8057 | * single threaded, each FDISC completion callback function will reset |
| 8058 | * the discovery timer for all vports such that the timers will not get |
| 8059 | * unnecessary timeout. The function checks the FDISC IOCB status. If error |
| 8060 | * detected, the vport will be set to FC_VPORT_FAILED state. Otherwise,the |
| 8061 | * vport will set to FC_VPORT_ACTIVE state. It then checks whether the DID |
| 8062 | * assigned to the vport has been changed with the completion of the FDISC |
| 8063 | * command. If so, both RPI (Remote Port Index) and VPI (Virtual Port Index) |
| 8064 | * are unregistered from the HBA, and then the lpfc_register_new_vport() |
| 8065 | * routine is invoked to register new vport with the HBA. Otherwise, the |
| 8066 | * lpfc_do_scr_ns_plogi() routine is invoked to issue a PLOGI to the Name |
| 8067 | * Server for State Change Request (SCR). |
| 8068 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8069 | static void |
| 8070 | lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 8071 | struct lpfc_iocbq *rspiocb) |
| 8072 | { |
| 8073 | struct lpfc_vport *vport = cmdiocb->vport; |
| 8074 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 8075 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 8076 | struct lpfc_nodelist *np; |
| 8077 | struct lpfc_nodelist *next_np; |
| 8078 | IOCB_t *irsp = &rspiocb->iocb; |
| 8079 | struct lpfc_iocbq *piocb; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 8080 | struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp; |
| 8081 | struct serv_parm *sp; |
| 8082 | uint8_t fabric_param_changed; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8083 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 8084 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 8085 | "0123 FDISC completes. x%x/x%x prevDID: x%x\n", |
| 8086 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 8087 | vport->fc_prevDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8088 | /* Since all FDISCs are being single threaded, we |
| 8089 | * must reset the discovery timer for ALL vports |
| 8090 | * waiting to send FDISC when one completes. |
| 8091 | */ |
| 8092 | list_for_each_entry(piocb, &phba->fabric_iocb_list, list) { |
| 8093 | lpfc_set_disctmo(piocb->vport); |
| 8094 | } |
| 8095 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 8096 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 8097 | "FDISC cmpl: status:x%x/x%x prevdid:x%x", |
| 8098 | irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_prevDID); |
| 8099 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8100 | if (irsp->ulpStatus) { |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 8101 | |
| 8102 | if (lpfc_fabric_login_reqd(phba, cmdiocb, rspiocb)) { |
| 8103 | lpfc_retry_pport_discovery(phba); |
| 8104 | goto out; |
| 8105 | } |
| 8106 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8107 | /* Check for retry */ |
| 8108 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) |
| 8109 | goto out; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8110 | /* FDISC failed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 8111 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 8112 | "0126 FDISC failed. (x%x/x%x)\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 8113 | irsp->ulpStatus, irsp->un.ulpWord[4]); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8114 | goto fdisc_failed; |
| 8115 | } |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8116 | spin_lock_irq(shost->host_lock); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 8117 | vport->fc_flag &= ~FC_VPORT_CVL_RCVD; |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 8118 | vport->fc_flag &= ~FC_VPORT_LOGO_RCVD; |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8119 | vport->fc_flag |= FC_FABRIC; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 8120 | if (vport->phba->fc_topology == LPFC_TOPOLOGY_LOOP) |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8121 | vport->fc_flag |= FC_PUBLIC_LOOP; |
| 8122 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8123 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8124 | vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID; |
| 8125 | lpfc_vport_set_state(vport, FC_VPORT_ACTIVE); |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 8126 | prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list); |
James Smart | a2fc4aef | 2014-09-03 12:57:55 -0400 | [diff] [blame] | 8127 | if (!prsp) |
| 8128 | goto out; |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 8129 | sp = prsp->virt + sizeof(uint32_t); |
| 8130 | fabric_param_changed = lpfc_check_clean_addr_bit(vport, sp); |
| 8131 | memcpy(&vport->fabric_portname, &sp->portName, |
| 8132 | sizeof(struct lpfc_name)); |
| 8133 | memcpy(&vport->fabric_nodename, &sp->nodeName, |
| 8134 | sizeof(struct lpfc_name)); |
| 8135 | if (fabric_param_changed && |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8136 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 8137 | /* If our NportID changed, we need to ensure all |
| 8138 | * remaining NPORTs get unreg_login'ed so we can |
| 8139 | * issue unreg_vpi. |
| 8140 | */ |
| 8141 | list_for_each_entry_safe(np, next_np, |
| 8142 | &vport->fc_nodes, nlp_listp) { |
| 8143 | if (!NLP_CHK_NODE_ACT(ndlp) || |
| 8144 | (np->nlp_state != NLP_STE_NPR_NODE) || |
| 8145 | !(np->nlp_flag & NLP_NPR_ADISC)) |
| 8146 | continue; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 8147 | spin_lock_irq(shost->host_lock); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8148 | np->nlp_flag &= ~NLP_NPR_ADISC; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 8149 | spin_unlock_irq(shost->host_lock); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8150 | lpfc_unreg_rpi(vport, np); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8151 | } |
James Smart | 78730cf | 2010-04-06 15:06:30 -0400 | [diff] [blame] | 8152 | lpfc_cleanup_pending_mbox(vport); |
James Smart | 5af5eee | 2010-10-22 11:06:38 -0400 | [diff] [blame] | 8153 | |
| 8154 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 8155 | lpfc_sli4_unreg_all_rpis(vport); |
| 8156 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8157 | lpfc_mbx_unreg_vpi(vport); |
| 8158 | spin_lock_irq(shost->host_lock); |
| 8159 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8160 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 8161 | vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 8162 | else |
| 8163 | vport->fc_flag |= FC_LOGO_RCVD_DID_CHNG; |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8164 | spin_unlock_irq(shost->host_lock); |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 8165 | } else if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 8166 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 8167 | /* |
| 8168 | * Driver needs to re-reg VPI in order for f/w |
| 8169 | * to update the MAC address. |
| 8170 | */ |
| 8171 | lpfc_register_new_vport(phba, vport, ndlp); |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame] | 8172 | goto out; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8173 | } |
| 8174 | |
James Smart | ecfd03c | 2010-02-12 14:41:27 -0500 | [diff] [blame] | 8175 | if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI) |
| 8176 | lpfc_issue_init_vpi(vport); |
| 8177 | else if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8178 | lpfc_register_new_vport(phba, vport, ndlp); |
| 8179 | else |
| 8180 | lpfc_do_scr_ns_plogi(phba, vport); |
| 8181 | goto out; |
| 8182 | fdisc_failed: |
James Smart | c84163d | 2015-05-21 13:55:22 -0400 | [diff] [blame] | 8183 | if (vport->fc_vport->vport_state != FC_VPORT_NO_FABRIC_RSCS) |
| 8184 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 8185 | /* Cancel discovery timer */ |
| 8186 | lpfc_can_disctmo(vport); |
| 8187 | lpfc_nlp_put(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8188 | out: |
| 8189 | lpfc_els_free_iocb(phba, cmdiocb); |
| 8190 | } |
| 8191 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8192 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8193 | * lpfc_issue_els_fdisc - Issue a fdisc iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8194 | * @vport: pointer to a virtual N_Port data structure. |
| 8195 | * @ndlp: pointer to a node-list data structure. |
| 8196 | * @retry: number of retries to the command IOCB. |
| 8197 | * |
| 8198 | * This routine prepares and issues a Fabric Discover (FDISC) IOCB to |
| 8199 | * a remote node (@ndlp) off a @vport. It uses the lpfc_issue_fabric_iocb() |
| 8200 | * routine to issue the IOCB, which makes sure only one outstanding fabric |
| 8201 | * IOCB will be sent off HBA at any given time. |
| 8202 | * |
| 8203 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 8204 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 8205 | * will be stored into the context1 field of the IOCB for the completion |
| 8206 | * callback function to the FDISC ELS command. |
| 8207 | * |
| 8208 | * Return code |
| 8209 | * 0 - Successfully issued fdisc iocb command |
| 8210 | * 1 - Failed to issue fdisc iocb command |
| 8211 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 8212 | static int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8213 | lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 8214 | uint8_t retry) |
| 8215 | { |
| 8216 | struct lpfc_hba *phba = vport->phba; |
| 8217 | IOCB_t *icmd; |
| 8218 | struct lpfc_iocbq *elsiocb; |
| 8219 | struct serv_parm *sp; |
| 8220 | uint8_t *pcmd; |
| 8221 | uint16_t cmdsize; |
| 8222 | int did = ndlp->nlp_DID; |
| 8223 | int rc; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8224 | |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 8225 | vport->port_state = LPFC_FDISC; |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 8226 | vport->fc_myDID = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8227 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
| 8228 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did, |
| 8229 | ELS_CMD_FDISC); |
| 8230 | if (!elsiocb) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8231 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 8232 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 8233 | "0255 Issue FDISC: no IOCB\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8234 | return 1; |
| 8235 | } |
| 8236 | |
| 8237 | icmd = &elsiocb->iocb; |
| 8238 | icmd->un.elsreq64.myID = 0; |
| 8239 | icmd->un.elsreq64.fl = 1; |
| 8240 | |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 8241 | /* |
| 8242 | * SLI3 ports require a different context type value than SLI4. |
| 8243 | * Catch SLI3 ports here and override the prep. |
| 8244 | */ |
| 8245 | if (phba->sli_rev == LPFC_SLI_REV3) { |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 8246 | icmd->ulpCt_h = 1; |
| 8247 | icmd->ulpCt_l = 0; |
| 8248 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8249 | |
| 8250 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 8251 | *((uint32_t *) (pcmd)) = ELS_CMD_FDISC; |
| 8252 | pcmd += sizeof(uint32_t); /* CSP Word 1 */ |
| 8253 | memcpy(pcmd, &vport->phba->pport->fc_sparam, sizeof(struct serv_parm)); |
| 8254 | sp = (struct serv_parm *) pcmd; |
| 8255 | /* Setup CSPs accordingly for Fabric */ |
| 8256 | sp->cmn.e_d_tov = 0; |
| 8257 | sp->cmn.w2.r_a_tov = 0; |
James Smart | df9e1b5 | 2011-12-13 13:22:17 -0500 | [diff] [blame] | 8258 | sp->cmn.virtual_fabric_support = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8259 | sp->cls1.classValid = 0; |
| 8260 | sp->cls2.seqDelivery = 1; |
| 8261 | sp->cls3.seqDelivery = 1; |
| 8262 | |
| 8263 | pcmd += sizeof(uint32_t); /* CSP Word 2 */ |
| 8264 | pcmd += sizeof(uint32_t); /* CSP Word 3 */ |
| 8265 | pcmd += sizeof(uint32_t); /* CSP Word 4 */ |
| 8266 | pcmd += sizeof(uint32_t); /* Port Name */ |
| 8267 | memcpy(pcmd, &vport->fc_portname, 8); |
| 8268 | pcmd += sizeof(uint32_t); /* Node Name */ |
| 8269 | pcmd += sizeof(uint32_t); /* Node Name */ |
| 8270 | memcpy(pcmd, &vport->fc_nodename, 8); |
| 8271 | |
| 8272 | lpfc_set_disctmo(vport); |
| 8273 | |
| 8274 | phba->fc_stat.elsXmitFDISC++; |
| 8275 | elsiocb->iocb_cmpl = lpfc_cmpl_els_fdisc; |
| 8276 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 8277 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 8278 | "Issue FDISC: did:x%x", |
| 8279 | did, 0, 0); |
| 8280 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8281 | rc = lpfc_issue_fabric_iocb(phba, elsiocb); |
| 8282 | if (rc == IOCB_ERROR) { |
| 8283 | lpfc_els_free_iocb(phba, elsiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8284 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 8285 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 8286 | "0256 Issue FDISC: Cannot send IOCB\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8287 | return 1; |
| 8288 | } |
| 8289 | lpfc_vport_set_state(vport, FC_VPORT_INITIALIZING); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8290 | return 0; |
| 8291 | } |
| 8292 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8293 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8294 | * lpfc_cmpl_els_npiv_logo - Completion function with vport logo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8295 | * @phba: pointer to lpfc hba data structure. |
| 8296 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 8297 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 8298 | * |
| 8299 | * This routine is the completion callback function to the issuing of a LOGO |
| 8300 | * ELS command off a vport. It frees the command IOCB and then decrement the |
| 8301 | * reference count held on ndlp for this completion function, indicating that |
| 8302 | * the reference to the ndlp is no long needed. Note that the |
| 8303 | * lpfc_els_free_iocb() routine decrements the ndlp reference held for this |
| 8304 | * callback function and an additional explicit ndlp reference decrementation |
| 8305 | * will trigger the actual release of the ndlp. |
| 8306 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8307 | static void |
| 8308 | lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 8309 | struct lpfc_iocbq *rspiocb) |
| 8310 | { |
| 8311 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 8312 | IOCB_t *irsp; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 8313 | struct lpfc_nodelist *ndlp; |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 8314 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 8315 | |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 8316 | ndlp = (struct lpfc_nodelist *)cmdiocb->context1; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 8317 | irsp = &rspiocb->iocb; |
| 8318 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 8319 | "LOGO npiv cmpl: status:x%x/x%x did:x%x", |
| 8320 | irsp->ulpStatus, irsp->un.ulpWord[4], irsp->un.rcvels.remoteID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8321 | |
| 8322 | lpfc_els_free_iocb(phba, cmdiocb); |
| 8323 | vport->unreg_vpi_cmpl = VPORT_ERROR; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 8324 | |
| 8325 | /* Trigger the release of the ndlp after logo */ |
| 8326 | lpfc_nlp_put(ndlp); |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 8327 | |
| 8328 | /* NPIV LOGO completes to NPort <nlp_DID> */ |
| 8329 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 8330 | "2928 NPIV LOGO completes to NPort x%x " |
| 8331 | "Data: x%x x%x x%x x%x\n", |
| 8332 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 8333 | irsp->ulpTimeout, vport->num_disc_nodes); |
| 8334 | |
| 8335 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 8336 | spin_lock_irq(shost->host_lock); |
James Smart | 73dc0db | 2015-05-22 10:42:36 -0400 | [diff] [blame] | 8337 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 8338 | vport->fc_flag &= ~FC_FABRIC; |
| 8339 | spin_unlock_irq(shost->host_lock); |
James Smart | 73dc0db | 2015-05-22 10:42:36 -0400 | [diff] [blame] | 8340 | lpfc_can_disctmo(vport); |
James Smart | 9589b062 | 2011-04-16 11:03:17 -0400 | [diff] [blame] | 8341 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8342 | } |
| 8343 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8344 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8345 | * lpfc_issue_els_npiv_logo - Issue a logo off a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8346 | * @vport: pointer to a virtual N_Port data structure. |
| 8347 | * @ndlp: pointer to a node-list data structure. |
| 8348 | * |
| 8349 | * This routine issues a LOGO ELS command to an @ndlp off a @vport. |
| 8350 | * |
| 8351 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 8352 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 8353 | * will be stored into the context1 field of the IOCB for the completion |
| 8354 | * callback function to the LOGO ELS command. |
| 8355 | * |
| 8356 | * Return codes |
| 8357 | * 0 - Successfully issued logo off the @vport |
| 8358 | * 1 - Failed to issue logo off the @vport |
| 8359 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8360 | int |
| 8361 | lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) |
| 8362 | { |
| 8363 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 8364 | struct lpfc_hba *phba = vport->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8365 | struct lpfc_iocbq *elsiocb; |
| 8366 | uint8_t *pcmd; |
| 8367 | uint16_t cmdsize; |
| 8368 | |
| 8369 | cmdsize = 2 * sizeof(uint32_t) + sizeof(struct lpfc_name); |
| 8370 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, ndlp->nlp_DID, |
| 8371 | ELS_CMD_LOGO); |
| 8372 | if (!elsiocb) |
| 8373 | return 1; |
| 8374 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8375 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 8376 | *((uint32_t *) (pcmd)) = ELS_CMD_LOGO; |
| 8377 | pcmd += sizeof(uint32_t); |
| 8378 | |
| 8379 | /* Fill in LOGO payload */ |
| 8380 | *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID); |
| 8381 | pcmd += sizeof(uint32_t); |
| 8382 | memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 8383 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 8384 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 8385 | "Issue LOGO npiv did:x%x flg:x%x", |
| 8386 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 8387 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8388 | elsiocb->iocb_cmpl = lpfc_cmpl_els_npiv_logo; |
| 8389 | spin_lock_irq(shost->host_lock); |
| 8390 | ndlp->nlp_flag |= NLP_LOGO_SND; |
| 8391 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 8392 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 8393 | IOCB_ERROR) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8394 | spin_lock_irq(shost->host_lock); |
| 8395 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
| 8396 | spin_unlock_irq(shost->host_lock); |
| 8397 | lpfc_els_free_iocb(phba, elsiocb); |
| 8398 | return 1; |
| 8399 | } |
| 8400 | return 0; |
| 8401 | } |
| 8402 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8403 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8404 | * lpfc_fabric_block_timeout - Handler function to the fabric block timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8405 | * @ptr: holder for the timer function associated data. |
| 8406 | * |
| 8407 | * This routine is invoked by the fabric iocb block timer after |
| 8408 | * timeout. It posts the fabric iocb block timeout event by setting the |
| 8409 | * WORKER_FABRIC_BLOCK_TMO bit to work port event bitmap and then invokes |
| 8410 | * lpfc_worker_wake_up() routine to wake up the worker thread. It is for |
| 8411 | * the worker thread to invoke the lpfc_unblock_fabric_iocbs() on the |
| 8412 | * posted event WORKER_FABRIC_BLOCK_TMO. |
| 8413 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8414 | void |
| 8415 | lpfc_fabric_block_timeout(unsigned long ptr) |
| 8416 | { |
| 8417 | struct lpfc_hba *phba = (struct lpfc_hba *) ptr; |
| 8418 | unsigned long iflags; |
| 8419 | uint32_t tmo_posted; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 8420 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8421 | spin_lock_irqsave(&phba->pport->work_port_lock, iflags); |
| 8422 | tmo_posted = phba->pport->work_port_events & WORKER_FABRIC_BLOCK_TMO; |
| 8423 | if (!tmo_posted) |
| 8424 | phba->pport->work_port_events |= WORKER_FABRIC_BLOCK_TMO; |
| 8425 | spin_unlock_irqrestore(&phba->pport->work_port_lock, iflags); |
| 8426 | |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 8427 | if (!tmo_posted) |
| 8428 | lpfc_worker_wake_up(phba); |
| 8429 | return; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8430 | } |
| 8431 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8432 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8433 | * lpfc_resume_fabric_iocbs - Issue a fabric iocb from driver internal list |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8434 | * @phba: pointer to lpfc hba data structure. |
| 8435 | * |
| 8436 | * This routine issues one fabric iocb from the driver internal list to |
| 8437 | * the HBA. It first checks whether it's ready to issue one fabric iocb to |
| 8438 | * the HBA (whether there is no outstanding fabric iocb). If so, it shall |
| 8439 | * remove one pending fabric iocb from the driver internal list and invokes |
| 8440 | * lpfc_sli_issue_iocb() routine to send the fabric iocb to the HBA. |
| 8441 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8442 | static void |
| 8443 | lpfc_resume_fabric_iocbs(struct lpfc_hba *phba) |
| 8444 | { |
| 8445 | struct lpfc_iocbq *iocb; |
| 8446 | unsigned long iflags; |
| 8447 | int ret; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8448 | IOCB_t *cmd; |
| 8449 | |
| 8450 | repeat: |
| 8451 | iocb = NULL; |
| 8452 | spin_lock_irqsave(&phba->hbalock, iflags); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 8453 | /* Post any pending iocb to the SLI layer */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8454 | if (atomic_read(&phba->fabric_iocb_count) == 0) { |
| 8455 | list_remove_head(&phba->fabric_iocb_list, iocb, typeof(*iocb), |
| 8456 | list); |
| 8457 | if (iocb) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 8458 | /* Increment fabric iocb count to hold the position */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8459 | atomic_inc(&phba->fabric_iocb_count); |
| 8460 | } |
| 8461 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 8462 | if (iocb) { |
| 8463 | iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; |
| 8464 | iocb->iocb_cmpl = lpfc_cmpl_fabric_iocb; |
| 8465 | iocb->iocb_flag |= LPFC_IO_FABRIC; |
| 8466 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 8467 | lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD, |
| 8468 | "Fabric sched1: ste:x%x", |
| 8469 | iocb->vport->port_state, 0, 0); |
| 8470 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 8471 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, iocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8472 | |
| 8473 | if (ret == IOCB_ERROR) { |
| 8474 | iocb->iocb_cmpl = iocb->fabric_iocb_cmpl; |
| 8475 | iocb->fabric_iocb_cmpl = NULL; |
| 8476 | iocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 8477 | cmd = &iocb->iocb; |
| 8478 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; |
| 8479 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; |
| 8480 | iocb->iocb_cmpl(phba, iocb, iocb); |
| 8481 | |
| 8482 | atomic_dec(&phba->fabric_iocb_count); |
| 8483 | goto repeat; |
| 8484 | } |
| 8485 | } |
| 8486 | |
| 8487 | return; |
| 8488 | } |
| 8489 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8490 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8491 | * lpfc_unblock_fabric_iocbs - Unblock issuing fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8492 | * @phba: pointer to lpfc hba data structure. |
| 8493 | * |
| 8494 | * This routine unblocks the issuing fabric iocb command. The function |
| 8495 | * will clear the fabric iocb block bit and then invoke the routine |
| 8496 | * lpfc_resume_fabric_iocbs() to issue one of the pending fabric iocb |
| 8497 | * from the driver internal fabric iocb list. |
| 8498 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8499 | void |
| 8500 | lpfc_unblock_fabric_iocbs(struct lpfc_hba *phba) |
| 8501 | { |
| 8502 | clear_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
| 8503 | |
| 8504 | lpfc_resume_fabric_iocbs(phba); |
| 8505 | return; |
| 8506 | } |
| 8507 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8508 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8509 | * lpfc_block_fabric_iocbs - Block issuing fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8510 | * @phba: pointer to lpfc hba data structure. |
| 8511 | * |
| 8512 | * This routine blocks the issuing fabric iocb for a specified amount of |
| 8513 | * time (currently 100 ms). This is done by set the fabric iocb block bit |
| 8514 | * and set up a timeout timer for 100ms. When the block bit is set, no more |
| 8515 | * fabric iocb will be issued out of the HBA. |
| 8516 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8517 | static void |
| 8518 | lpfc_block_fabric_iocbs(struct lpfc_hba *phba) |
| 8519 | { |
| 8520 | int blocked; |
| 8521 | |
| 8522 | blocked = test_and_set_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 8523 | /* Start a timer to unblock fabric iocbs after 100ms */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8524 | if (!blocked) |
James Smart | 256ec0d | 2013-04-17 20:14:58 -0400 | [diff] [blame] | 8525 | mod_timer(&phba->fabric_block_timer, |
| 8526 | jiffies + msecs_to_jiffies(100)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8527 | |
| 8528 | return; |
| 8529 | } |
| 8530 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8531 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8532 | * lpfc_cmpl_fabric_iocb - Completion callback function for fabric iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8533 | * @phba: pointer to lpfc hba data structure. |
| 8534 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 8535 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 8536 | * |
| 8537 | * This routine is the callback function that is put to the fabric iocb's |
| 8538 | * callback function pointer (iocb->iocb_cmpl). The original iocb's callback |
| 8539 | * function pointer has been stored in iocb->fabric_iocb_cmpl. This callback |
| 8540 | * function first restores and invokes the original iocb's callback function |
| 8541 | * and then invokes the lpfc_resume_fabric_iocbs() routine to issue the next |
| 8542 | * fabric bound iocb from the driver internal fabric iocb list onto the wire. |
| 8543 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8544 | static void |
| 8545 | lpfc_cmpl_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 8546 | struct lpfc_iocbq *rspiocb) |
| 8547 | { |
| 8548 | struct ls_rjt stat; |
| 8549 | |
| 8550 | if ((cmdiocb->iocb_flag & LPFC_IO_FABRIC) != LPFC_IO_FABRIC) |
| 8551 | BUG(); |
| 8552 | |
| 8553 | switch (rspiocb->iocb.ulpStatus) { |
| 8554 | case IOSTAT_NPORT_RJT: |
| 8555 | case IOSTAT_FABRIC_RJT: |
| 8556 | if (rspiocb->iocb.un.ulpWord[4] & RJT_UNAVAIL_TEMP) { |
| 8557 | lpfc_block_fabric_iocbs(phba); |
| 8558 | } |
| 8559 | break; |
| 8560 | |
| 8561 | case IOSTAT_NPORT_BSY: |
| 8562 | case IOSTAT_FABRIC_BSY: |
| 8563 | lpfc_block_fabric_iocbs(phba); |
| 8564 | break; |
| 8565 | |
| 8566 | case IOSTAT_LS_RJT: |
| 8567 | stat.un.lsRjtError = |
| 8568 | be32_to_cpu(rspiocb->iocb.un.ulpWord[4]); |
| 8569 | if ((stat.un.b.lsRjtRsnCode == LSRJT_UNABLE_TPC) || |
| 8570 | (stat.un.b.lsRjtRsnCode == LSRJT_LOGICAL_BSY)) |
| 8571 | lpfc_block_fabric_iocbs(phba); |
| 8572 | break; |
| 8573 | } |
| 8574 | |
| 8575 | if (atomic_read(&phba->fabric_iocb_count) == 0) |
| 8576 | BUG(); |
| 8577 | |
| 8578 | cmdiocb->iocb_cmpl = cmdiocb->fabric_iocb_cmpl; |
| 8579 | cmdiocb->fabric_iocb_cmpl = NULL; |
| 8580 | cmdiocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 8581 | cmdiocb->iocb_cmpl(phba, cmdiocb, rspiocb); |
| 8582 | |
| 8583 | atomic_dec(&phba->fabric_iocb_count); |
| 8584 | if (!test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags)) { |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 8585 | /* Post any pending iocbs to HBA */ |
| 8586 | lpfc_resume_fabric_iocbs(phba); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8587 | } |
| 8588 | } |
| 8589 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8590 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8591 | * lpfc_issue_fabric_iocb - Issue a fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8592 | * @phba: pointer to lpfc hba data structure. |
| 8593 | * @iocb: pointer to lpfc command iocb data structure. |
| 8594 | * |
| 8595 | * This routine is used as the top-level API for issuing a fabric iocb command |
| 8596 | * such as FLOGI and FDISC. To accommodate certain switch fabric, this driver |
| 8597 | * function makes sure that only one fabric bound iocb will be outstanding at |
| 8598 | * any given time. As such, this function will first check to see whether there |
| 8599 | * is already an outstanding fabric iocb on the wire. If so, it will put the |
| 8600 | * newly issued iocb onto the driver internal fabric iocb list, waiting to be |
| 8601 | * issued later. Otherwise, it will issue the iocb on the wire and update the |
| 8602 | * fabric iocb count it indicate that there is one fabric iocb on the wire. |
| 8603 | * |
| 8604 | * Note, this implementation has a potential sending out fabric IOCBs out of |
| 8605 | * order. The problem is caused by the construction of the "ready" boolen does |
| 8606 | * not include the condition that the internal fabric IOCB list is empty. As |
| 8607 | * such, it is possible a fabric IOCB issued by this routine might be "jump" |
| 8608 | * ahead of the fabric IOCBs in the internal list. |
| 8609 | * |
| 8610 | * Return code |
| 8611 | * IOCB_SUCCESS - either fabric iocb put on the list or issued successfully |
| 8612 | * IOCB_ERROR - failed to issue fabric iocb |
| 8613 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 8614 | static int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8615 | lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb) |
| 8616 | { |
| 8617 | unsigned long iflags; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8618 | int ready; |
| 8619 | int ret; |
| 8620 | |
| 8621 | if (atomic_read(&phba->fabric_iocb_count) > 1) |
| 8622 | BUG(); |
| 8623 | |
| 8624 | spin_lock_irqsave(&phba->hbalock, iflags); |
| 8625 | ready = atomic_read(&phba->fabric_iocb_count) == 0 && |
| 8626 | !test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
| 8627 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 8628 | if (ready) |
| 8629 | /* Increment fabric iocb count to hold the position */ |
| 8630 | atomic_inc(&phba->fabric_iocb_count); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8631 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 8632 | if (ready) { |
| 8633 | iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; |
| 8634 | iocb->iocb_cmpl = lpfc_cmpl_fabric_iocb; |
| 8635 | iocb->iocb_flag |= LPFC_IO_FABRIC; |
| 8636 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 8637 | lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD, |
| 8638 | "Fabric sched2: ste:x%x", |
| 8639 | iocb->vport->port_state, 0, 0); |
| 8640 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 8641 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, iocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8642 | |
| 8643 | if (ret == IOCB_ERROR) { |
| 8644 | iocb->iocb_cmpl = iocb->fabric_iocb_cmpl; |
| 8645 | iocb->fabric_iocb_cmpl = NULL; |
| 8646 | iocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 8647 | atomic_dec(&phba->fabric_iocb_count); |
| 8648 | } |
| 8649 | } else { |
| 8650 | spin_lock_irqsave(&phba->hbalock, iflags); |
| 8651 | list_add_tail(&iocb->list, &phba->fabric_iocb_list); |
| 8652 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 8653 | ret = IOCB_SUCCESS; |
| 8654 | } |
| 8655 | return ret; |
| 8656 | } |
| 8657 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8658 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8659 | * 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] | 8660 | * @vport: pointer to a virtual N_Port data structure. |
| 8661 | * |
| 8662 | * This routine aborts all the IOCBs associated with a @vport from the |
| 8663 | * driver internal fabric IOCB list. The list contains fabric IOCBs to be |
| 8664 | * issued to the ELS IOCB ring. This abort function walks the fabric IOCB |
| 8665 | * list, removes each IOCB associated with the @vport off the list, set the |
| 8666 | * status feild to IOSTAT_LOCAL_REJECT, and invokes the callback function |
| 8667 | * associated with the IOCB. |
| 8668 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 8669 | static void lpfc_fabric_abort_vport(struct lpfc_vport *vport) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8670 | { |
| 8671 | LIST_HEAD(completions); |
| 8672 | struct lpfc_hba *phba = vport->phba; |
| 8673 | struct lpfc_iocbq *tmp_iocb, *piocb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8674 | |
| 8675 | spin_lock_irq(&phba->hbalock); |
| 8676 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, |
| 8677 | list) { |
| 8678 | |
| 8679 | if (piocb->vport != vport) |
| 8680 | continue; |
| 8681 | |
| 8682 | list_move_tail(&piocb->list, &completions); |
| 8683 | } |
| 8684 | spin_unlock_irq(&phba->hbalock); |
| 8685 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8686 | /* Cancel all the IOCBs from the completions list */ |
| 8687 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 8688 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8689 | } |
| 8690 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8691 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8692 | * 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] | 8693 | * @ndlp: pointer to a node-list data structure. |
| 8694 | * |
| 8695 | * This routine aborts all the IOCBs associated with an @ndlp from the |
| 8696 | * driver internal fabric IOCB list. The list contains fabric IOCBs to be |
| 8697 | * issued to the ELS IOCB ring. This abort function walks the fabric IOCB |
| 8698 | * list, removes each IOCB associated with the @ndlp off the list, set the |
| 8699 | * status feild to IOSTAT_LOCAL_REJECT, and invokes the callback function |
| 8700 | * associated with the IOCB. |
| 8701 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8702 | void lpfc_fabric_abort_nport(struct lpfc_nodelist *ndlp) |
| 8703 | { |
| 8704 | LIST_HEAD(completions); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8705 | struct lpfc_hba *phba = ndlp->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8706 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 8707 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8708 | |
| 8709 | spin_lock_irq(&phba->hbalock); |
| 8710 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, |
| 8711 | list) { |
| 8712 | if ((lpfc_check_sli_ndlp(phba, pring, piocb, ndlp))) { |
| 8713 | |
| 8714 | list_move_tail(&piocb->list, &completions); |
| 8715 | } |
| 8716 | } |
| 8717 | spin_unlock_irq(&phba->hbalock); |
| 8718 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8719 | /* Cancel all the IOCBs from the completions list */ |
| 8720 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 8721 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8722 | } |
| 8723 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8724 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 8725 | * lpfc_fabric_abort_hba - Abort all iocbs on driver fabric iocb list |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 8726 | * @phba: pointer to lpfc hba data structure. |
| 8727 | * |
| 8728 | * This routine aborts all the IOCBs currently on the driver internal |
| 8729 | * fabric IOCB list. The list contains fabric IOCBs to be issued to the ELS |
| 8730 | * IOCB ring. This function takes the entire IOCB list off the fabric IOCB |
| 8731 | * list, removes IOCBs off the list, set the status feild to |
| 8732 | * IOSTAT_LOCAL_REJECT, and invokes the callback function associated with |
| 8733 | * the IOCB. |
| 8734 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8735 | void lpfc_fabric_abort_hba(struct lpfc_hba *phba) |
| 8736 | { |
| 8737 | LIST_HEAD(completions); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8738 | |
| 8739 | spin_lock_irq(&phba->hbalock); |
| 8740 | list_splice_init(&phba->fabric_iocb_list, &completions); |
| 8741 | spin_unlock_irq(&phba->hbalock); |
| 8742 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 8743 | /* Cancel all the IOCBs from the completions list */ |
| 8744 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 8745 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 8746 | } |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8747 | |
| 8748 | /** |
James Smart | 1151e3e | 2011-02-16 12:39:35 -0500 | [diff] [blame] | 8749 | * lpfc_sli4_vport_delete_els_xri_aborted -Remove all ndlp references for vport |
| 8750 | * @vport: pointer to lpfc vport data structure. |
| 8751 | * |
| 8752 | * This routine is invoked by the vport cleanup for deletions and the cleanup |
| 8753 | * for an ndlp on removal. |
| 8754 | **/ |
| 8755 | void |
| 8756 | lpfc_sli4_vport_delete_els_xri_aborted(struct lpfc_vport *vport) |
| 8757 | { |
| 8758 | struct lpfc_hba *phba = vport->phba; |
| 8759 | struct lpfc_sglq *sglq_entry = NULL, *sglq_next = NULL; |
| 8760 | unsigned long iflag = 0; |
| 8761 | |
| 8762 | spin_lock_irqsave(&phba->hbalock, iflag); |
| 8763 | spin_lock(&phba->sli4_hba.abts_sgl_list_lock); |
| 8764 | list_for_each_entry_safe(sglq_entry, sglq_next, |
| 8765 | &phba->sli4_hba.lpfc_abts_els_sgl_list, list) { |
| 8766 | if (sglq_entry->ndlp && sglq_entry->ndlp->vport == vport) |
| 8767 | sglq_entry->ndlp = NULL; |
| 8768 | } |
| 8769 | spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); |
| 8770 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8771 | return; |
| 8772 | } |
| 8773 | |
| 8774 | /** |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8775 | * lpfc_sli4_els_xri_aborted - Slow-path process of els xri abort |
| 8776 | * @phba: pointer to lpfc hba data structure. |
| 8777 | * @axri: pointer to the els xri abort wcqe structure. |
| 8778 | * |
| 8779 | * This routine is invoked by the worker thread to process a SLI4 slow-path |
| 8780 | * ELS aborted xri. |
| 8781 | **/ |
| 8782 | void |
| 8783 | lpfc_sli4_els_xri_aborted(struct lpfc_hba *phba, |
| 8784 | struct sli4_wcqe_xri_aborted *axri) |
| 8785 | { |
| 8786 | uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8787 | uint16_t rxid = bf_get(lpfc_wcqe_xa_remote_xid, axri); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 8788 | uint16_t lxri = 0; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8789 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8790 | struct lpfc_sglq *sglq_entry = NULL, *sglq_next = NULL; |
| 8791 | unsigned long iflag = 0; |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8792 | struct lpfc_nodelist *ndlp; |
James Smart | 589a52d | 2010-07-14 15:30:54 -0400 | [diff] [blame] | 8793 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8794 | |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8795 | spin_lock_irqsave(&phba->hbalock, iflag); |
| 8796 | spin_lock(&phba->sli4_hba.abts_sgl_list_lock); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8797 | list_for_each_entry_safe(sglq_entry, sglq_next, |
| 8798 | &phba->sli4_hba.lpfc_abts_els_sgl_list, list) { |
| 8799 | if (sglq_entry->sli4_xritag == xri) { |
| 8800 | list_del(&sglq_entry->list); |
James Smart | 19ca760 | 2010-11-20 23:11:55 -0500 | [diff] [blame] | 8801 | ndlp = sglq_entry->ndlp; |
| 8802 | sglq_entry->ndlp = NULL; |
James Smart | dafe8ce | 2014-09-03 12:56:40 -0400 | [diff] [blame] | 8803 | spin_lock(&pring->ring_lock); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8804 | list_add_tail(&sglq_entry->list, |
| 8805 | &phba->sli4_hba.lpfc_sgl_list); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8806 | sglq_entry->state = SGL_FREED; |
James Smart | dafe8ce | 2014-09-03 12:56:40 -0400 | [diff] [blame] | 8807 | spin_unlock(&pring->ring_lock); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8808 | spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8809 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
James Smart | ee0f4fe | 2012-05-09 21:19:14 -0400 | [diff] [blame] | 8810 | lpfc_set_rrq_active(phba, ndlp, |
| 8811 | sglq_entry->sli4_lxritag, |
| 8812 | rxid, 1); |
James Smart | 589a52d | 2010-07-14 15:30:54 -0400 | [diff] [blame] | 8813 | |
| 8814 | /* Check if TXQ queue needs to be serviced */ |
James Smart | 0e9bb8d | 2013-03-01 16:35:12 -0500 | [diff] [blame] | 8815 | if (!(list_empty(&pring->txq))) |
James Smart | 589a52d | 2010-07-14 15:30:54 -0400 | [diff] [blame] | 8816 | lpfc_worker_wake_up(phba); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8817 | return; |
| 8818 | } |
| 8819 | } |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8820 | spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 8821 | lxri = lpfc_sli4_xri_inrange(phba, xri); |
| 8822 | if (lxri == NO_XRI) { |
| 8823 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8824 | return; |
| 8825 | } |
James Smart | dafe8ce | 2014-09-03 12:56:40 -0400 | [diff] [blame] | 8826 | spin_lock(&pring->ring_lock); |
James Smart | 7851fe2 | 2011-07-22 18:36:52 -0400 | [diff] [blame] | 8827 | sglq_entry = __lpfc_get_active_sglq(phba, lxri); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8828 | if (!sglq_entry || (sglq_entry->sli4_xritag != xri)) { |
James Smart | dafe8ce | 2014-09-03 12:56:40 -0400 | [diff] [blame] | 8829 | spin_unlock(&pring->ring_lock); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8830 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8831 | return; |
| 8832 | } |
| 8833 | sglq_entry->state = SGL_XRI_ABORTED; |
James Smart | dafe8ce | 2014-09-03 12:56:40 -0400 | [diff] [blame] | 8834 | spin_unlock(&pring->ring_lock); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 8835 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 8836 | return; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 8837 | } |
James Smart | 086a345 | 2012-08-14 14:25:21 -0400 | [diff] [blame] | 8838 | |
| 8839 | /* lpfc_sli_abts_recover_port - Recover a port that failed a BLS_ABORT req. |
| 8840 | * @vport: pointer to virtual port object. |
| 8841 | * @ndlp: nodelist pointer for the impacted node. |
| 8842 | * |
| 8843 | * The driver calls this routine in response to an SLI4 XRI ABORT CQE |
| 8844 | * or an SLI3 ASYNC_STATUS_CN event from the port. For either event, |
| 8845 | * the driver is required to send a LOGO to the remote node before it |
| 8846 | * attempts to recover its login to the remote node. |
| 8847 | */ |
| 8848 | void |
| 8849 | lpfc_sli_abts_recover_port(struct lpfc_vport *vport, |
| 8850 | struct lpfc_nodelist *ndlp) |
| 8851 | { |
| 8852 | struct Scsi_Host *shost; |
| 8853 | struct lpfc_hba *phba; |
| 8854 | unsigned long flags = 0; |
| 8855 | |
| 8856 | shost = lpfc_shost_from_vport(vport); |
| 8857 | phba = vport->phba; |
| 8858 | if (ndlp->nlp_state != NLP_STE_MAPPED_NODE) { |
| 8859 | lpfc_printf_log(phba, KERN_INFO, |
| 8860 | LOG_SLI, "3093 No rport recovery needed. " |
| 8861 | "rport in state 0x%x\n", ndlp->nlp_state); |
| 8862 | return; |
| 8863 | } |
| 8864 | lpfc_printf_log(phba, KERN_INFO, LOG_SLI, |
| 8865 | "3094 Start rport recovery on shost id 0x%x " |
| 8866 | "fc_id 0x%06x vpi 0x%x rpi 0x%x state 0x%x " |
| 8867 | "flags 0x%x\n", |
| 8868 | shost->host_no, ndlp->nlp_DID, |
| 8869 | vport->vpi, ndlp->nlp_rpi, ndlp->nlp_state, |
| 8870 | ndlp->nlp_flag); |
| 8871 | /* |
| 8872 | * The rport is not responding. Remove the FCP-2 flag to prevent |
| 8873 | * an ADISC in the follow-up recovery code. |
| 8874 | */ |
| 8875 | spin_lock_irqsave(shost->host_lock, flags); |
| 8876 | ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE; |
| 8877 | spin_unlock_irqrestore(shost->host_lock, flags); |
| 8878 | lpfc_issue_els_logo(vport, ndlp, 0); |
| 8879 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_LOGO_ISSUE); |
| 8880 | } |
| 8881 | |