| 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 | d8e93df | 2009-05-22 14:53:05 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2009 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 | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 32 | #include "lpfc_hw4.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 33 | #include "lpfc_hw.h" |
| 34 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 35 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 36 | #include "lpfc_nl.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 37 | #include "lpfc_disc.h" |
| 38 | #include "lpfc_scsi.h" |
| 39 | #include "lpfc.h" |
| 40 | #include "lpfc_logmsg.h" |
| 41 | #include "lpfc_crtn.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 42 | #include "lpfc_vport.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 43 | #include "lpfc_debugfs.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 44 | |
| 45 | static int lpfc_els_retry(struct lpfc_hba *, struct lpfc_iocbq *, |
| 46 | struct lpfc_iocbq *); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 47 | static void lpfc_cmpl_fabric_iocb(struct lpfc_hba *, struct lpfc_iocbq *, |
| 48 | struct lpfc_iocbq *); |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 49 | static void lpfc_fabric_abort_vport(struct lpfc_vport *vport); |
| 50 | static int lpfc_issue_els_fdisc(struct lpfc_vport *vport, |
| 51 | struct lpfc_nodelist *ndlp, uint8_t retry); |
| 52 | static int lpfc_issue_fabric_iocb(struct lpfc_hba *phba, |
| 53 | struct lpfc_iocbq *iocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 54 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 55 | static int lpfc_max_els_tries = 3; |
| 56 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 57 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 58 | * lpfc_els_chk_latt - Check host link attention event for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 59 | * @vport: pointer to a host virtual N_Port data structure. |
| 60 | * |
| 61 | * This routine checks whether there is an outstanding host link |
| 62 | * attention event during the discovery process with the @vport. It is done |
| 63 | * by reading the HBA's Host Attention (HA) register. If there is any host |
| 64 | * link attention events during this @vport's discovery process, the @vport |
| 65 | * shall be marked as FC_ABORT_DISCOVERY, a host link attention clear shall |
| 66 | * be issued if the link state is not already in host link cleared state, |
| 67 | * and a return code shall indicate whether the host link attention event |
| 68 | * had happened. |
| 69 | * |
| 70 | * Note that, if either the host link is in state LPFC_LINK_DOWN or @vport |
| 71 | * state in LPFC_VPORT_READY, the request for checking host link attention |
| 72 | * event will be ignored and a return code shall indicate no host link |
| 73 | * attention event had happened. |
| 74 | * |
| 75 | * Return codes |
| 76 | * 0 - no host link attention event happened |
| 77 | * 1 - host link attention event happened |
| 78 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 79 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 80 | lpfc_els_chk_latt(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 81 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 82 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 83 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 84 | uint32_t ha_copy; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 85 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 86 | if (vport->port_state >= LPFC_VPORT_READY || |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 87 | phba->link_state == LPFC_LINK_DOWN || |
| 88 | phba->sli_rev > LPFC_SLI_REV3) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 89 | return 0; |
| 90 | |
| 91 | /* Read the HBA Host Attention Register */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 92 | ha_copy = readl(phba->HAregaddr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 93 | |
| 94 | if (!(ha_copy & HA_LATT)) |
| 95 | return 0; |
| 96 | |
| 97 | /* Pending Link Event during Discovery */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 98 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 99 | "0237 Pending Link Event during " |
| 100 | "Discovery: State x%x\n", |
| 101 | phba->pport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 102 | |
| 103 | /* CLEAR_LA should re-enable link attention events and |
| 104 | * we should then imediately take a LATT event. The |
| 105 | * LATT processing should call lpfc_linkdown() which |
| 106 | * will cleanup any left over in-progress discovery |
| 107 | * events. |
| 108 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 109 | spin_lock_irq(shost->host_lock); |
| 110 | vport->fc_flag |= FC_ABORT_DISCOVERY; |
| 111 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 112 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 113 | if (phba->link_state != LPFC_CLEAR_LA) |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 114 | lpfc_issue_clear_la(phba, vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 115 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 116 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 117 | } |
| 118 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 119 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 120 | * lpfc_prep_els_iocb - Allocate and prepare a lpfc iocb data structure |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 121 | * @vport: pointer to a host virtual N_Port data structure. |
| 122 | * @expectRsp: flag indicating whether response is expected. |
| 123 | * @cmdSize: size of the ELS command. |
| 124 | * @retry: number of retries to the command IOCB when it fails. |
| 125 | * @ndlp: pointer to a node-list data structure. |
| 126 | * @did: destination identifier. |
| 127 | * @elscmd: the ELS command code. |
| 128 | * |
| 129 | * This routine is used for allocating a lpfc-IOCB data structure from |
| 130 | * the driver lpfc-IOCB free-list and prepare the IOCB with the parameters |
| 131 | * passed into the routine for discovery state machine to issue an Extended |
| 132 | * Link Service (ELS) commands. It is a generic lpfc-IOCB allocation |
| 133 | * and preparation routine that is used by all the discovery state machine |
| 134 | * routines and the ELS command-specific fields will be later set up by |
| 135 | * the individual discovery machine routines after calling this routine |
| 136 | * allocating and preparing a generic IOCB data structure. It fills in the |
| 137 | * Buffer Descriptor Entries (BDEs), allocates buffers for both command |
| 138 | * payload and response payload (if expected). The reference count on the |
| 139 | * ndlp is incremented by 1 and the reference to the ndlp is put into |
| 140 | * context1 of the IOCB data structure for this IOCB to hold the ndlp |
| 141 | * reference for the command's callback function to access later. |
| 142 | * |
| 143 | * Return code |
| 144 | * Pointer to the newly allocated/prepared els iocb data structure |
| 145 | * NULL - when els iocb data structure allocation/preparation failed |
| 146 | **/ |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 147 | struct lpfc_iocbq * |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 148 | lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp, |
| 149 | uint16_t cmdSize, uint8_t retry, |
| 150 | struct lpfc_nodelist *ndlp, uint32_t did, |
| 151 | uint32_t elscmd) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 152 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 153 | struct lpfc_hba *phba = vport->phba; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 154 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 155 | struct lpfc_dmabuf *pcmd, *prsp, *pbuflist; |
| 156 | struct ulp_bde64 *bpl; |
| 157 | IOCB_t *icmd; |
| 158 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 159 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 160 | if (!lpfc_is_link_up(phba)) |
| 161 | return NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 162 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 163 | /* Allocate buffer for command iocb */ |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 164 | elsiocb = lpfc_sli_get_iocbq(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 165 | |
| 166 | if (elsiocb == NULL) |
| 167 | return NULL; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 168 | |
James Smart | 0c28758 | 2009-06-10 17:22:56 -0400 | [diff] [blame] | 169 | /* |
| 170 | * If this command is for fabric controller and HBA running |
| 171 | * in FIP mode send FLOGI, FDISC and LOGO as FIP frames. |
| 172 | */ |
| 173 | if ((did == Fabric_DID) && |
James Smart | 45ed119 | 2009-10-02 15:17:02 -0400 | [diff] [blame] | 174 | (phba->hba_flag & HBA_FIP_SUPPORT) && |
James Smart | 0c28758 | 2009-06-10 17:22:56 -0400 | [diff] [blame] | 175 | ((elscmd == ELS_CMD_FLOGI) || |
| 176 | (elscmd == ELS_CMD_FDISC) || |
| 177 | (elscmd == ELS_CMD_LOGO))) |
James Smart | c868595 | 2009-11-18 15:39:16 -0500 | [diff] [blame] | 178 | switch (elscmd) { |
| 179 | case ELS_CMD_FLOGI: |
| 180 | elsiocb->iocb_flag |= ((ELS_ID_FLOGI << LPFC_FIP_ELS_ID_SHIFT) |
| 181 | & LPFC_FIP_ELS_ID_MASK); |
| 182 | break; |
| 183 | case ELS_CMD_FDISC: |
| 184 | elsiocb->iocb_flag |= ((ELS_ID_FDISC << LPFC_FIP_ELS_ID_SHIFT) |
| 185 | & LPFC_FIP_ELS_ID_MASK); |
| 186 | break; |
| 187 | case ELS_CMD_LOGO: |
| 188 | elsiocb->iocb_flag |= ((ELS_ID_LOGO << LPFC_FIP_ELS_ID_SHIFT) |
| 189 | & LPFC_FIP_ELS_ID_MASK); |
| 190 | break; |
| 191 | } |
James Smart | 0c28758 | 2009-06-10 17:22:56 -0400 | [diff] [blame] | 192 | else |
James Smart | c868595 | 2009-11-18 15:39:16 -0500 | [diff] [blame] | 193 | elsiocb->iocb_flag &= ~LPFC_FIP_ELS_ID_MASK; |
James Smart | 0c28758 | 2009-06-10 17:22:56 -0400 | [diff] [blame] | 194 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 195 | icmd = &elsiocb->iocb; |
| 196 | |
| 197 | /* fill in BDEs for command */ |
| 198 | /* Allocate buffer for command payload */ |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 199 | pcmd = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| 200 | if (pcmd) |
| 201 | pcmd->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &pcmd->phys); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 202 | if (!pcmd || !pcmd->virt) |
| 203 | goto els_iocb_free_pcmb_exit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 204 | |
| 205 | INIT_LIST_HEAD(&pcmd->list); |
| 206 | |
| 207 | /* Allocate buffer for response payload */ |
| 208 | if (expectRsp) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 209 | prsp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 210 | if (prsp) |
| 211 | prsp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, |
| 212 | &prsp->phys); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 213 | if (!prsp || !prsp->virt) |
| 214 | goto els_iocb_free_prsp_exit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 215 | INIT_LIST_HEAD(&prsp->list); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 216 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 217 | prsp = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 218 | |
| 219 | /* Allocate buffer for Buffer ptr list */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 220 | pbuflist = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 221 | if (pbuflist) |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 222 | pbuflist->virt = lpfc_mbuf_alloc(phba, MEM_PRI, |
| 223 | &pbuflist->phys); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 224 | if (!pbuflist || !pbuflist->virt) |
| 225 | goto els_iocb_free_pbuf_exit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 226 | |
| 227 | INIT_LIST_HEAD(&pbuflist->list); |
| 228 | |
| 229 | icmd->un.elsreq64.bdl.addrHigh = putPaddrHigh(pbuflist->phys); |
| 230 | icmd->un.elsreq64.bdl.addrLow = putPaddrLow(pbuflist->phys); |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 231 | icmd->un.elsreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 232 | icmd->un.elsreq64.remoteID = did; /* DID */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 233 | if (expectRsp) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 234 | icmd->un.elsreq64.bdl.bdeSize = (2 * sizeof(struct ulp_bde64)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 235 | icmd->ulpCommand = CMD_ELS_REQUEST64_CR; |
James Smart | 2680eea | 2007-04-25 09:52:55 -0400 | [diff] [blame] | 236 | icmd->ulpTimeout = phba->fc_ratov * 2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 237 | } else { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 238 | icmd->un.elsreq64.bdl.bdeSize = sizeof(struct ulp_bde64); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 239 | icmd->ulpCommand = CMD_XMIT_ELS_RSP64_CX; |
| 240 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 241 | icmd->ulpBdeCount = 1; |
| 242 | icmd->ulpLe = 1; |
| 243 | icmd->ulpClass = CLASS3; |
| 244 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 245 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
| 246 | icmd->un.elsreq64.myID = vport->fc_myDID; |
| 247 | |
| 248 | /* For ELS_REQUEST64_CR, use the VPI by default */ |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 249 | icmd->ulpContext = vport->vpi + phba->vpi_base; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 250 | icmd->ulpCt_h = 0; |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 251 | /* The CT field must be 0=INVALID_RPI for the ECHO cmd */ |
| 252 | if (elscmd == ELS_CMD_ECHO) |
| 253 | icmd->ulpCt_l = 0; /* context = invalid RPI */ |
| 254 | else |
| 255 | icmd->ulpCt_l = 1; /* context = VPI */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 256 | } |
| 257 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 258 | bpl = (struct ulp_bde64 *) pbuflist->virt; |
| 259 | bpl->addrLow = le32_to_cpu(putPaddrLow(pcmd->phys)); |
| 260 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(pcmd->phys)); |
| 261 | bpl->tus.f.bdeSize = cmdSize; |
| 262 | bpl->tus.f.bdeFlags = 0; |
| 263 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 264 | |
| 265 | if (expectRsp) { |
| 266 | bpl++; |
| 267 | bpl->addrLow = le32_to_cpu(putPaddrLow(prsp->phys)); |
| 268 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(prsp->phys)); |
| 269 | bpl->tus.f.bdeSize = FCELSSIZE; |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 270 | bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 271 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 272 | } |
| 273 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 274 | /* prevent preparing iocb with NULL ndlp reference */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 275 | elsiocb->context1 = lpfc_nlp_get(ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 276 | if (!elsiocb->context1) |
| 277 | goto els_iocb_free_pbuf_exit; |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 278 | elsiocb->context2 = pcmd; |
| 279 | elsiocb->context3 = pbuflist; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 280 | elsiocb->retry = retry; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 281 | elsiocb->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 282 | elsiocb->drvrTimeout = (phba->fc_ratov << 1) + LPFC_DRVR_TIMEOUT; |
| 283 | |
| 284 | if (prsp) { |
| 285 | list_add(&prsp->list, &pcmd->list); |
| 286 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 287 | if (expectRsp) { |
| 288 | /* Xmit ELS command <elsCmd> to remote NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 289 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 290 | "0116 Xmit ELS command x%x to remote " |
| 291 | "NPORT x%x I/O tag: x%x, port state: x%x\n", |
| 292 | elscmd, did, elsiocb->iotag, |
| 293 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 294 | } else { |
| 295 | /* Xmit ELS response <elsCmd> to remote NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 296 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 297 | "0117 Xmit ELS response x%x to remote " |
| 298 | "NPORT x%x I/O tag: x%x, size: x%x\n", |
| 299 | elscmd, ndlp->nlp_DID, elsiocb->iotag, |
| 300 | cmdSize); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 301 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 302 | return elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 303 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 304 | els_iocb_free_pbuf_exit: |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 305 | if (expectRsp) |
| 306 | lpfc_mbuf_free(phba, prsp->virt, prsp->phys); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 307 | kfree(pbuflist); |
| 308 | |
| 309 | els_iocb_free_prsp_exit: |
| 310 | lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys); |
| 311 | kfree(prsp); |
| 312 | |
| 313 | els_iocb_free_pcmb_exit: |
| 314 | kfree(pcmd); |
| 315 | lpfc_sli_release_iocbq(phba, elsiocb); |
| 316 | return NULL; |
| 317 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 318 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 319 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 320 | * lpfc_issue_fabric_reglogin - Issue fabric registration login for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 321 | * @vport: pointer to a host virtual N_Port data structure. |
| 322 | * |
| 323 | * This routine issues a fabric registration login for a @vport. An |
| 324 | * active ndlp node with Fabric_DID must already exist for this @vport. |
| 325 | * The routine invokes two mailbox commands to carry out fabric registration |
| 326 | * login through the HBA firmware: the first mailbox command requests the |
| 327 | * HBA to perform link configuration for the @vport; and the second mailbox |
| 328 | * command requests the HBA to perform the actual fabric registration login |
| 329 | * with the @vport. |
| 330 | * |
| 331 | * Return code |
| 332 | * 0 - successfully issued fabric registration login for @vport |
| 333 | * -ENXIO -- failed to issue fabric registration login for @vport |
| 334 | **/ |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 335 | int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 336 | lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) |
| 337 | { |
| 338 | struct lpfc_hba *phba = vport->phba; |
| 339 | LPFC_MBOXQ_t *mbox; |
| 340 | struct lpfc_dmabuf *mp; |
| 341 | struct lpfc_nodelist *ndlp; |
| 342 | struct serv_parm *sp; |
| 343 | int rc; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 344 | int err = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 345 | |
| 346 | sp = &phba->fc_fabparam; |
| 347 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 348 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 349 | err = 1; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 350 | goto fail; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 351 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 352 | |
| 353 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 354 | if (!mbox) { |
| 355 | err = 2; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 356 | goto fail; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 357 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 358 | |
| 359 | vport->port_state = LPFC_FABRIC_CFG_LINK; |
| 360 | lpfc_config_link(phba, mbox); |
| 361 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
| 362 | mbox->vport = vport; |
| 363 | |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 364 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 365 | if (rc == MBX_NOT_FINISHED) { |
| 366 | err = 3; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 367 | goto fail_free_mbox; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 368 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 369 | |
| 370 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 371 | if (!mbox) { |
| 372 | err = 4; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 373 | goto fail; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 374 | } |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 375 | rc = lpfc_reg_rpi(phba, vport->vpi, Fabric_DID, (uint8_t *)sp, mbox, 0); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 376 | if (rc) { |
| 377 | err = 5; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 378 | goto fail_free_mbox; |
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->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login; |
| 382 | mbox->vport = vport; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 383 | /* increment the reference count on ndlp to hold reference |
| 384 | * for the callback routine. |
| 385 | */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 386 | mbox->context2 = lpfc_nlp_get(ndlp); |
| 387 | |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 388 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 389 | if (rc == MBX_NOT_FINISHED) { |
| 390 | err = 6; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 391 | goto fail_issue_reg_login; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 392 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 393 | |
| 394 | return 0; |
| 395 | |
| 396 | fail_issue_reg_login: |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 397 | /* decrement the reference count on ndlp just incremented |
| 398 | * for the failed mbox command. |
| 399 | */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 400 | lpfc_nlp_put(ndlp); |
| 401 | mp = (struct lpfc_dmabuf *) mbox->context1; |
| 402 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 403 | kfree(mp); |
| 404 | fail_free_mbox: |
| 405 | mempool_free(mbox, phba->mbox_mem_pool); |
| 406 | |
| 407 | fail: |
| 408 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 409 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 410 | "0249 Cannot issue Register Fabric login: Err %d\n", err); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 411 | return -ENXIO; |
| 412 | } |
| 413 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 414 | /** |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 415 | * lpfc_issue_reg_vfi - Register VFI for this vport's fabric login |
| 416 | * @vport: pointer to a host virtual N_Port data structure. |
| 417 | * |
| 418 | * This routine issues a REG_VFI mailbox for the vfi, vpi, fcfi triplet for |
| 419 | * the @vport. This mailbox command is necessary for FCoE only. |
| 420 | * |
| 421 | * Return code |
| 422 | * 0 - successfully issued REG_VFI for @vport |
| 423 | * A failure code otherwise. |
| 424 | **/ |
| 425 | static int |
| 426 | lpfc_issue_reg_vfi(struct lpfc_vport *vport) |
| 427 | { |
| 428 | struct lpfc_hba *phba = vport->phba; |
| 429 | LPFC_MBOXQ_t *mboxq; |
| 430 | struct lpfc_nodelist *ndlp; |
| 431 | struct serv_parm *sp; |
| 432 | struct lpfc_dmabuf *dmabuf; |
| 433 | int rc = 0; |
| 434 | |
| 435 | sp = &phba->fc_fabparam; |
| 436 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
| 437 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
| 438 | rc = -ENODEV; |
| 439 | goto fail; |
| 440 | } |
| 441 | |
| 442 | dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| 443 | if (!dmabuf) { |
| 444 | rc = -ENOMEM; |
| 445 | goto fail; |
| 446 | } |
| 447 | dmabuf->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &dmabuf->phys); |
| 448 | if (!dmabuf->virt) { |
| 449 | rc = -ENOMEM; |
| 450 | goto fail_free_dmabuf; |
| 451 | } |
| 452 | mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 453 | if (!mboxq) { |
| 454 | rc = -ENOMEM; |
| 455 | goto fail_free_coherent; |
| 456 | } |
| 457 | vport->port_state = LPFC_FABRIC_CFG_LINK; |
| 458 | memcpy(dmabuf->virt, &phba->fc_fabparam, sizeof(vport->fc_sparam)); |
| 459 | lpfc_reg_vfi(mboxq, vport, dmabuf->phys); |
| 460 | mboxq->mbox_cmpl = lpfc_mbx_cmpl_reg_vfi; |
| 461 | mboxq->vport = vport; |
| 462 | mboxq->context1 = dmabuf; |
| 463 | rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); |
| 464 | if (rc == MBX_NOT_FINISHED) { |
| 465 | rc = -ENXIO; |
| 466 | goto fail_free_mbox; |
| 467 | } |
| 468 | return 0; |
| 469 | |
| 470 | fail_free_mbox: |
| 471 | mempool_free(mboxq, phba->mbox_mem_pool); |
| 472 | fail_free_coherent: |
| 473 | lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys); |
| 474 | fail_free_dmabuf: |
| 475 | kfree(dmabuf); |
| 476 | fail: |
| 477 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 478 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 479 | "0289 Issue Register VFI failed: Err %d\n", rc); |
| 480 | return rc; |
| 481 | } |
| 482 | |
| 483 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 484 | * 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] | 485 | * @vport: pointer to a host virtual N_Port data structure. |
| 486 | * @ndlp: pointer to a node-list data structure. |
| 487 | * @sp: pointer to service parameter data structure. |
| 488 | * @irsp: pointer to the IOCB within the lpfc response IOCB. |
| 489 | * |
| 490 | * This routine is invoked by the lpfc_cmpl_els_flogi() completion callback |
| 491 | * function to handle the completion of a Fabric Login (FLOGI) into a fabric |
| 492 | * port in a fabric topology. It properly sets up the parameters to the @ndlp |
| 493 | * from the IOCB response. It also check the newly assigned N_Port ID to the |
| 494 | * @vport against the previously assigned N_Port ID. If it is different from |
| 495 | * the previously assigned Destination ID (DID), the lpfc_unreg_rpi() routine |
| 496 | * is invoked on all the remaining nodes with the @vport to unregister the |
| 497 | * Remote Port Indicators (RPIs). Finally, the lpfc_issue_fabric_reglogin() |
| 498 | * is invoked to register login to the fabric. |
| 499 | * |
| 500 | * Return code |
| 501 | * 0 - Success (currently, always return 0) |
| 502 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 503 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 504 | lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 505 | struct serv_parm *sp, IOCB_t *irsp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 506 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 507 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 508 | struct lpfc_hba *phba = vport->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 509 | struct lpfc_nodelist *np; |
| 510 | struct lpfc_nodelist *next_np; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 511 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 512 | spin_lock_irq(shost->host_lock); |
| 513 | vport->fc_flag |= FC_FABRIC; |
| 514 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 515 | |
| 516 | phba->fc_edtov = be32_to_cpu(sp->cmn.e_d_tov); |
| 517 | if (sp->cmn.edtovResolution) /* E_D_TOV ticks are in nanoseconds */ |
| 518 | phba->fc_edtov = (phba->fc_edtov + 999999) / 1000000; |
| 519 | |
| 520 | phba->fc_ratov = (be32_to_cpu(sp->cmn.w2.r_a_tov) + 999) / 1000; |
| 521 | |
| 522 | if (phba->fc_topology == TOPOLOGY_LOOP) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 523 | spin_lock_irq(shost->host_lock); |
| 524 | vport->fc_flag |= FC_PUBLIC_LOOP; |
| 525 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 526 | } |
| 527 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 528 | vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 529 | memcpy(&ndlp->nlp_portname, &sp->portName, sizeof(struct lpfc_name)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 530 | memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 531 | ndlp->nlp_class_sup = 0; |
| 532 | if (sp->cls1.classValid) |
| 533 | ndlp->nlp_class_sup |= FC_COS_CLASS1; |
| 534 | if (sp->cls2.classValid) |
| 535 | ndlp->nlp_class_sup |= FC_COS_CLASS2; |
| 536 | if (sp->cls3.classValid) |
| 537 | ndlp->nlp_class_sup |= FC_COS_CLASS3; |
| 538 | if (sp->cls4.classValid) |
| 539 | ndlp->nlp_class_sup |= FC_COS_CLASS4; |
| 540 | ndlp->nlp_maxframe = ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | |
| 541 | sp->cmn.bbRcvSizeLsb; |
| 542 | memcpy(&phba->fc_fabparam, sp, sizeof(struct serv_parm)); |
| 543 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 544 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
| 545 | if (sp->cmn.response_multiple_NPort) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 546 | lpfc_printf_vlog(vport, KERN_WARNING, |
| 547 | LOG_ELS | LOG_VPORT, |
| 548 | "1816 FLOGI NPIV supported, " |
| 549 | "response data 0x%x\n", |
| 550 | sp->cmn.response_multiple_NPort); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 551 | phba->link_flag |= LS_NPIV_FAB_SUPPORTED; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 552 | } else { |
| 553 | /* Because we asked f/w for NPIV it still expects us |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 554 | to call reg_vnpid atleast for the physcial host */ |
| 555 | lpfc_printf_vlog(vport, KERN_WARNING, |
| 556 | LOG_ELS | LOG_VPORT, |
| 557 | "1817 Fabric does not support NPIV " |
| 558 | "- configuring single port mode.\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 559 | phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED; |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | if ((vport->fc_prevDID != vport->fc_myDID) && |
| 564 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 565 | |
| 566 | /* If our NportID changed, we need to ensure all |
| 567 | * remaining NPORTs get unreg_login'ed. |
| 568 | */ |
| 569 | list_for_each_entry_safe(np, next_np, |
| 570 | &vport->fc_nodes, nlp_listp) { |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 571 | if (!NLP_CHK_NODE_ACT(np)) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 572 | continue; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 573 | if ((np->nlp_state != NLP_STE_NPR_NODE) || |
| 574 | !(np->nlp_flag & NLP_NPR_ADISC)) |
| 575 | continue; |
| 576 | spin_lock_irq(shost->host_lock); |
| 577 | np->nlp_flag &= ~NLP_NPR_ADISC; |
| 578 | spin_unlock_irq(shost->host_lock); |
| 579 | lpfc_unreg_rpi(vport, np); |
| 580 | } |
James Smart | 78730cf | 2010-04-06 15:06:30 -0400 | [diff] [blame] | 581 | lpfc_cleanup_pending_mbox(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 582 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
| 583 | lpfc_mbx_unreg_vpi(vport); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 584 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 585 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 586 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 587 | } |
James Smart | ecfd03c | 2010-02-12 14:41:27 -0500 | [diff] [blame] | 588 | /* |
| 589 | * If VPI is unreged, driver need to do INIT_VPI |
| 590 | * before re-registering |
| 591 | */ |
| 592 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 593 | spin_lock_irq(shost->host_lock); |
| 594 | vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; |
| 595 | spin_unlock_irq(shost->host_lock); |
| 596 | } |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 597 | } else if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 598 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 599 | /* |
| 600 | * Driver needs to re-reg VPI in order for f/w |
| 601 | * to update the MAC address. |
| 602 | */ |
| 603 | lpfc_register_new_vport(phba, vport, ndlp); |
| 604 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 605 | } |
| 606 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 607 | if (phba->sli_rev < LPFC_SLI_REV4) { |
| 608 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE); |
| 609 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED && |
| 610 | vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) |
| 611 | lpfc_register_new_vport(phba, vport, ndlp); |
| 612 | else |
| 613 | lpfc_issue_fabric_reglogin(vport); |
| 614 | } else { |
| 615 | ndlp->nlp_type |= NLP_FABRIC; |
| 616 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 617 | if ((!(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) && |
| 618 | (vport->vpi_state & LPFC_VPI_REGISTERED)) { |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 619 | lpfc_start_fdiscs(phba); |
| 620 | lpfc_do_scr_ns_plogi(phba, vport); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 621 | } else if (vport->fc_flag & FC_VFI_REGISTERED) |
James Smart | ecfd03c | 2010-02-12 14:41:27 -0500 | [diff] [blame] | 622 | lpfc_issue_init_vpi(vport); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 623 | else |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 624 | lpfc_issue_reg_vfi(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 625 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 626 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 627 | } |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 628 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 629 | * 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] | 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 | * |
| 634 | * This routine is invoked by the lpfc_cmpl_els_flogi() completion callback |
| 635 | * function to handle the completion of a Fabric Login (FLOGI) into an N_Port |
| 636 | * in a point-to-point topology. First, the @vport's N_Port Name is compared |
| 637 | * with the received N_Port Name: if the @vport's N_Port Name is greater than |
| 638 | * the received N_Port Name lexicographically, this node shall assign local |
| 639 | * N_Port ID (PT2PT_LocalID: 1) and remote N_Port ID (PT2PT_RemoteID: 2) and |
| 640 | * will send out Port Login (PLOGI) with the N_Port IDs assigned. Otherwise, |
| 641 | * this node shall just wait for the remote node to issue PLOGI and assign |
| 642 | * N_Port IDs. |
| 643 | * |
| 644 | * Return code |
| 645 | * 0 - Success |
| 646 | * -ENXIO - Fail |
| 647 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 648 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 649 | lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 650 | struct serv_parm *sp) |
| 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; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 654 | LPFC_MBOXQ_t *mbox; |
| 655 | int rc; |
| 656 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 657 | spin_lock_irq(shost->host_lock); |
| 658 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
| 659 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 660 | |
| 661 | phba->fc_edtov = FF_DEF_EDTOV; |
| 662 | phba->fc_ratov = FF_DEF_RATOV; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 663 | rc = memcmp(&vport->fc_portname, &sp->portName, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 664 | sizeof(vport->fc_portname)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 665 | if (rc >= 0) { |
| 666 | /* This side will initiate the PLOGI */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 667 | spin_lock_irq(shost->host_lock); |
| 668 | vport->fc_flag |= FC_PT2PT_PLOGI; |
| 669 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 670 | |
| 671 | /* |
| 672 | * N_Port ID cannot be 0, set our to LocalID the other |
| 673 | * side will be RemoteID. |
| 674 | */ |
| 675 | |
| 676 | /* not equal */ |
| 677 | if (rc) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 678 | vport->fc_myDID = PT2PT_LocalID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 679 | |
| 680 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 681 | if (!mbox) |
| 682 | goto fail; |
| 683 | |
| 684 | lpfc_config_link(phba, mbox); |
| 685 | |
| 686 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 687 | mbox->vport = vport; |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 688 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 689 | if (rc == MBX_NOT_FINISHED) { |
| 690 | mempool_free(mbox, phba->mbox_mem_pool); |
| 691 | goto fail; |
| 692 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 693 | /* Decrement ndlp reference count indicating that ndlp can be |
| 694 | * safely released when other references to it are done. |
| 695 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 696 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 697 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 698 | ndlp = lpfc_findnode_did(vport, PT2PT_RemoteID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 699 | if (!ndlp) { |
| 700 | /* |
| 701 | * Cannot find existing Fabric ndlp, so allocate a |
| 702 | * new one |
| 703 | */ |
| 704 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 705 | if (!ndlp) |
| 706 | goto fail; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 707 | lpfc_nlp_init(vport, ndlp, PT2PT_RemoteID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 708 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 709 | ndlp = lpfc_enable_node(vport, ndlp, |
| 710 | NLP_STE_UNUSED_NODE); |
| 711 | if(!ndlp) |
| 712 | goto fail; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | memcpy(&ndlp->nlp_portname, &sp->portName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 716 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 717 | memcpy(&ndlp->nlp_nodename, &sp->nodeName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 718 | sizeof(struct lpfc_name)); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 719 | /* Set state will put ndlp onto node list if not already done */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 720 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 721 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 722 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 723 | spin_unlock_irq(shost->host_lock); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 724 | } else |
| 725 | /* This side will wait for the PLOGI, decrement ndlp reference |
| 726 | * count indicating that ndlp can be released when other |
| 727 | * references to it are done. |
| 728 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 729 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 730 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 731 | /* If we are pt2pt with another NPort, force NPIV off! */ |
| 732 | phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; |
| 733 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 734 | spin_lock_irq(shost->host_lock); |
| 735 | vport->fc_flag |= FC_PT2PT; |
| 736 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 737 | |
| 738 | /* Start discovery - this should just do CLEAR_LA */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 739 | lpfc_disc_start(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 740 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 741 | fail: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 742 | return -ENXIO; |
| 743 | } |
| 744 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 745 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 746 | * lpfc_cmpl_els_flogi - Completion callback function for flogi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 747 | * @phba: pointer to lpfc hba data structure. |
| 748 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 749 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 750 | * |
| 751 | * This routine is the top-level completion callback function for issuing |
| 752 | * a Fabric Login (FLOGI) command. If the response IOCB reported error, |
| 753 | * the lpfc_els_retry() routine shall be invoked to retry the FLOGI. If |
| 754 | * retry has been made (either immediately or delayed with lpfc_els_retry() |
| 755 | * returning 1), the command IOCB will be released and function returned. |
| 756 | * If the retry attempt has been given up (possibly reach the maximum |
| 757 | * number of retries), one additional decrement of ndlp reference shall be |
| 758 | * invoked before going out after releasing the command IOCB. This will |
| 759 | * actually release the remote node (Note, lpfc_els_free_iocb() will also |
| 760 | * invoke one decrement of ndlp reference count). If no error reported in |
| 761 | * the IOCB status, the command Port ID field is used to determine whether |
| 762 | * this is a point-to-point topology or a fabric topology: if the Port ID |
| 763 | * field is assigned, it is a fabric topology; otherwise, it is a |
| 764 | * point-to-point topology. The routine lpfc_cmpl_els_flogi_fabric() or |
| 765 | * lpfc_cmpl_els_flogi_nport() shall be invoked accordingly to handle the |
| 766 | * specific topology completion conditions. |
| 767 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 768 | static void |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 769 | lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 770 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 771 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 772 | struct lpfc_vport *vport = cmdiocb->vport; |
| 773 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 774 | IOCB_t *irsp = &rspiocb->iocb; |
| 775 | struct lpfc_nodelist *ndlp = cmdiocb->context1; |
| 776 | struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp; |
| 777 | struct serv_parm *sp; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 778 | uint16_t fcf_index; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 779 | int rc; |
| 780 | |
| 781 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 782 | if (lpfc_els_chk_latt(vport)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 783 | /* One additional decrement on node reference count to |
| 784 | * trigger the release of the node |
| 785 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 786 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 787 | goto out; |
| 788 | } |
| 789 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 790 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 791 | "FLOGI cmpl: status:x%x/x%x state:x%x", |
| 792 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 793 | vport->port_state); |
| 794 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 795 | if (irsp->ulpStatus) { |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 796 | /* |
| 797 | * In case of FIP mode, perform round robin FCF failover |
| 798 | * due to new FCF discovery |
| 799 | */ |
| 800 | if ((phba->hba_flag & HBA_FIP_SUPPORT) && |
James Smart | dbb6b3a | 2010-06-08 18:31:37 -0400 | [diff] [blame] | 801 | (phba->fcf.fcf_flag & FCF_DISCOVERY) && |
| 802 | (irsp->ulpStatus != IOSTAT_LOCAL_REJECT) && |
| 803 | (irsp->un.ulpWord[4] != IOERR_SLI_ABORTED)) { |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 804 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP | LOG_ELS, |
| 805 | "2611 FLOGI failed on registered " |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 806 | "FCF record fcf_index(%d), status: " |
| 807 | "x%x/x%x, tmo:x%x, trying to perform " |
| 808 | "round robin failover\n", |
| 809 | phba->fcf.current_rec.fcf_indx, |
| 810 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 811 | irsp->ulpTimeout); |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 812 | fcf_index = lpfc_sli4_fcf_rr_next_index_get(phba); |
| 813 | if (fcf_index == LPFC_FCOE_FCF_NEXT_NONE) { |
| 814 | /* |
| 815 | * Exhausted the eligible FCF record list, |
| 816 | * fail through to retry FLOGI on current |
| 817 | * FCF record. |
| 818 | */ |
| 819 | lpfc_printf_log(phba, KERN_WARNING, |
| 820 | LOG_FIP | LOG_ELS, |
James Smart | 3804dc8 | 2010-07-14 15:31:37 -0400 | [diff] [blame] | 821 | "2760 Completed one round " |
| 822 | "of FLOGI FCF round robin " |
| 823 | "failover list, retry FLOGI " |
| 824 | "on currently registered " |
| 825 | "FCF index:%d\n", |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 826 | phba->fcf.current_rec.fcf_indx); |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 827 | } else { |
James Smart | 3804dc8 | 2010-07-14 15:31:37 -0400 | [diff] [blame] | 828 | lpfc_printf_log(phba, KERN_INFO, |
| 829 | LOG_FIP | LOG_ELS, |
| 830 | "2794 FLOGI FCF round robin " |
| 831 | "failover to FCF index x%x\n", |
| 832 | fcf_index); |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 833 | rc = lpfc_sli4_fcf_rr_read_fcf_rec(phba, |
| 834 | fcf_index); |
James Smart | 3804dc8 | 2010-07-14 15:31:37 -0400 | [diff] [blame] | 835 | if (rc) |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 836 | lpfc_printf_log(phba, KERN_WARNING, |
| 837 | LOG_FIP | LOG_ELS, |
| 838 | "2761 FLOGI round " |
| 839 | "robin FCF failover " |
| 840 | "read FCF failed " |
| 841 | "rc:x%x, fcf_index:" |
| 842 | "%d\n", rc, |
| 843 | phba->fcf.current_rec.fcf_indx); |
James Smart | 3804dc8 | 2010-07-14 15:31:37 -0400 | [diff] [blame] | 844 | else |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 845 | goto out; |
| 846 | } |
| 847 | } |
| 848 | |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 849 | /* FLOGI failure */ |
| 850 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 851 | "2858 FLOGI failure Status:x%x/x%x TMO:x%x\n", |
| 852 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 853 | irsp->ulpTimeout); |
| 854 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 855 | /* Check for retry */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 856 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 857 | goto out; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 858 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 859 | /* FLOGI failed, so there is no fabric */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 860 | spin_lock_irq(shost->host_lock); |
| 861 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
| 862 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 863 | |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 864 | /* If private loop, then allow max outstanding els to be |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 865 | * LPFC_MAX_DISC_THREADS (32). Scanning in the case of no |
| 866 | * alpa map would take too long otherwise. |
| 867 | */ |
| 868 | if (phba->alpa_map[0] == 0) { |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 869 | vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 870 | } |
| 871 | |
| 872 | /* FLOGI failure */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 873 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 874 | "0100 FLOGI failure Status:x%x/x%x TMO:x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 875 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 876 | irsp->ulpTimeout); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 877 | goto flogifail; |
| 878 | } |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 879 | spin_lock_irq(shost->host_lock); |
| 880 | vport->fc_flag &= ~FC_VPORT_CVL_RCVD; |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 881 | vport->fc_flag &= ~FC_VPORT_LOGO_RCVD; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 882 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 883 | |
| 884 | /* |
| 885 | * The FLogI succeeded. Sync the data for the CPU before |
| 886 | * accessing it. |
| 887 | */ |
| 888 | prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list); |
| 889 | |
| 890 | sp = prsp->virt + sizeof(uint32_t); |
| 891 | |
| 892 | /* FLOGI completes successfully */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 893 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 894 | "0101 FLOGI completes successfully " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 895 | "Data: x%x x%x x%x x%x\n", |
| 896 | irsp->un.ulpWord[4], sp->cmn.e_d_tov, |
| 897 | sp->cmn.w2.r_a_tov, sp->cmn.edtovResolution); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 898 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 899 | if (vport->port_state == LPFC_FLOGI) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 900 | /* |
| 901 | * If Common Service Parameters indicate Nport |
| 902 | * we are point to point, if Fport we are Fabric. |
| 903 | */ |
| 904 | if (sp->cmn.fPort) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 905 | rc = lpfc_cmpl_els_flogi_fabric(vport, ndlp, sp, irsp); |
James Smart | dbb6b3a | 2010-06-08 18:31:37 -0400 | [diff] [blame] | 906 | else if (!(phba->hba_flag & HBA_FCOE_SUPPORT)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 907 | rc = lpfc_cmpl_els_flogi_nport(vport, ndlp, sp); |
James Smart | dbb6b3a | 2010-06-08 18:31:37 -0400 | [diff] [blame] | 908 | else { |
| 909 | lpfc_printf_vlog(vport, KERN_ERR, |
| 910 | LOG_FIP | LOG_ELS, |
| 911 | "2831 FLOGI response with cleared Fabric " |
| 912 | "bit fcf_index 0x%x " |
| 913 | "Switch Name %02x%02x%02x%02x%02x%02x%02x%02x " |
| 914 | "Fabric Name " |
| 915 | "%02x%02x%02x%02x%02x%02x%02x%02x\n", |
| 916 | phba->fcf.current_rec.fcf_indx, |
| 917 | phba->fcf.current_rec.switch_name[0], |
| 918 | phba->fcf.current_rec.switch_name[1], |
| 919 | phba->fcf.current_rec.switch_name[2], |
| 920 | phba->fcf.current_rec.switch_name[3], |
| 921 | phba->fcf.current_rec.switch_name[4], |
| 922 | phba->fcf.current_rec.switch_name[5], |
| 923 | phba->fcf.current_rec.switch_name[6], |
| 924 | phba->fcf.current_rec.switch_name[7], |
| 925 | phba->fcf.current_rec.fabric_name[0], |
| 926 | phba->fcf.current_rec.fabric_name[1], |
| 927 | phba->fcf.current_rec.fabric_name[2], |
| 928 | phba->fcf.current_rec.fabric_name[3], |
| 929 | phba->fcf.current_rec.fabric_name[4], |
| 930 | phba->fcf.current_rec.fabric_name[5], |
| 931 | phba->fcf.current_rec.fabric_name[6], |
| 932 | phba->fcf.current_rec.fabric_name[7]); |
| 933 | lpfc_nlp_put(ndlp); |
| 934 | spin_lock_irq(&phba->hbalock); |
| 935 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; |
| 936 | spin_unlock_irq(&phba->hbalock); |
| 937 | goto out; |
| 938 | } |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 939 | if (!rc) { |
| 940 | /* Mark the FCF discovery process done */ |
James Smart | 999d813 | 2010-03-15 11:24:56 -0400 | [diff] [blame] | 941 | if (phba->hba_flag & HBA_FIP_SUPPORT) |
| 942 | lpfc_printf_vlog(vport, KERN_INFO, LOG_FIP | |
| 943 | LOG_ELS, |
| 944 | "2769 FLOGI successful on FCF " |
| 945 | "record: current_fcf_index:" |
| 946 | "x%x, terminate FCF round " |
| 947 | "robin failover process\n", |
| 948 | phba->fcf.current_rec.fcf_indx); |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 949 | spin_lock_irq(&phba->hbalock); |
| 950 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; |
| 951 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 952 | goto out; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 953 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 954 | } |
| 955 | |
| 956 | flogifail: |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 957 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 958 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 959 | if (!lpfc_error_lost_link(irsp)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 960 | /* FLOGI failed, so just use loop map to make discovery list */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 961 | lpfc_disc_list_loopmap(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 962 | |
| 963 | /* Start discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 964 | lpfc_disc_start(vport); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 965 | } else if (((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || |
| 966 | ((irsp->un.ulpWord[4] != IOERR_SLI_ABORTED) && |
| 967 | (irsp->un.ulpWord[4] != IOERR_SLI_DOWN))) && |
| 968 | (phba->link_state != LPFC_CLEAR_LA)) { |
| 969 | /* If FLOGI failed enable link interrupt. */ |
| 970 | lpfc_issue_clear_la(phba, vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 971 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 972 | out: |
| 973 | lpfc_els_free_iocb(phba, cmdiocb); |
| 974 | } |
| 975 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 976 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 977 | * lpfc_issue_els_flogi - Issue an flogi iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 978 | * @vport: pointer to a host virtual N_Port data structure. |
| 979 | * @ndlp: pointer to a node-list data structure. |
| 980 | * @retry: number of retries to the command IOCB. |
| 981 | * |
| 982 | * This routine issues a Fabric Login (FLOGI) Request ELS command |
| 983 | * for a @vport. The initiator service parameters are put into the payload |
| 984 | * of the FLOGI Request IOCB and the top-level callback function pointer |
| 985 | * to lpfc_cmpl_els_flogi() routine is put to the IOCB completion callback |
| 986 | * function field. The lpfc_issue_fabric_iocb routine is invoked to send |
| 987 | * out FLOGI ELS command with one outstanding fabric IOCB at a time. |
| 988 | * |
| 989 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 990 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 991 | * will be stored into the context1 field of the IOCB for the completion |
| 992 | * callback function to the FLOGI ELS command. |
| 993 | * |
| 994 | * Return code |
| 995 | * 0 - successfully issued flogi iocb for @vport |
| 996 | * 1 - failed to issue flogi iocb for @vport |
| 997 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 998 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 999 | lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1000 | uint8_t retry) |
| 1001 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1002 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1003 | struct serv_parm *sp; |
| 1004 | IOCB_t *icmd; |
| 1005 | struct lpfc_iocbq *elsiocb; |
| 1006 | struct lpfc_sli_ring *pring; |
| 1007 | uint8_t *pcmd; |
| 1008 | uint16_t cmdsize; |
| 1009 | uint32_t tmo; |
| 1010 | int rc; |
| 1011 | |
| 1012 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
| 1013 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1014 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1015 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 1016 | ndlp->nlp_DID, ELS_CMD_FLOGI); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1017 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1018 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1019 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1020 | |
| 1021 | icmd = &elsiocb->iocb; |
| 1022 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 1023 | |
| 1024 | /* For FLOGI request, remainder of payload is service parameters */ |
| 1025 | *((uint32_t *) (pcmd)) = ELS_CMD_FLOGI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1026 | pcmd += sizeof(uint32_t); |
| 1027 | memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1028 | sp = (struct serv_parm *) pcmd; |
| 1029 | |
| 1030 | /* Setup CSPs accordingly for Fabric */ |
| 1031 | sp->cmn.e_d_tov = 0; |
| 1032 | sp->cmn.w2.r_a_tov = 0; |
| 1033 | sp->cls1.classValid = 0; |
| 1034 | sp->cls2.seqDelivery = 1; |
| 1035 | sp->cls3.seqDelivery = 1; |
| 1036 | if (sp->cmn.fcphLow < FC_PH3) |
| 1037 | sp->cmn.fcphLow = FC_PH3; |
| 1038 | if (sp->cmn.fcphHigh < FC_PH3) |
| 1039 | sp->cmn.fcphHigh = FC_PH3; |
| 1040 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 1041 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 1042 | elsiocb->iocb.ulpCt_h = ((SLI4_CT_FCFI >> 1) & 1); |
| 1043 | elsiocb->iocb.ulpCt_l = (SLI4_CT_FCFI & 1); |
| 1044 | /* FLOGI needs to be 3 for WQE FCFI */ |
| 1045 | /* Set the fcfi to the fcfi we registered with */ |
| 1046 | elsiocb->iocb.ulpContext = phba->fcf.fcfi; |
| 1047 | } else if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1048 | sp->cmn.request_multiple_Nport = 1; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1049 | /* For FLOGI, Let FLOGI rsp set the NPortID for VPI 0 */ |
| 1050 | icmd->ulpCt_h = 1; |
| 1051 | icmd->ulpCt_l = 0; |
| 1052 | } |
| 1053 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1054 | if (phba->fc_topology != TOPOLOGY_LOOP) { |
| 1055 | icmd->un.elsreq64.myID = 0; |
| 1056 | icmd->un.elsreq64.fl = 1; |
| 1057 | } |
| 1058 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1059 | tmo = phba->fc_ratov; |
| 1060 | phba->fc_ratov = LPFC_DISC_FLOGI_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1061 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1062 | phba->fc_ratov = tmo; |
| 1063 | |
| 1064 | phba->fc_stat.elsXmitFLOGI++; |
| 1065 | elsiocb->iocb_cmpl = lpfc_cmpl_els_flogi; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1066 | |
| 1067 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1068 | "Issue FLOGI: opt:x%x", |
| 1069 | phba->sli3_options, 0, 0); |
| 1070 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1071 | rc = lpfc_issue_fabric_iocb(phba, elsiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1072 | if (rc == IOCB_ERROR) { |
| 1073 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1074 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1075 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1076 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1077 | } |
| 1078 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1079 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1080 | * lpfc_els_abort_flogi - Abort all outstanding flogi iocbs |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1081 | * @phba: pointer to lpfc hba data structure. |
| 1082 | * |
| 1083 | * This routine aborts all the outstanding Fabric Login (FLOGI) IOCBs |
| 1084 | * with a @phba. This routine walks all the outstanding IOCBs on the txcmplq |
| 1085 | * list and issues an abort IOCB commond on each outstanding IOCB that |
| 1086 | * contains a active Fabric_DID ndlp. Note that this function is to issue |
| 1087 | * the abort IOCB command on all the outstanding IOCBs, thus when this |
| 1088 | * function returns, it does not guarantee all the IOCBs are actually aborted. |
| 1089 | * |
| 1090 | * Return code |
Daniel Mack | 3ad2f3f | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 1091 | * 0 - Successfully issued abort iocb on all outstanding flogis (Always 0) |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1092 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1093 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1094 | lpfc_els_abort_flogi(struct lpfc_hba *phba) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1095 | { |
| 1096 | struct lpfc_sli_ring *pring; |
| 1097 | struct lpfc_iocbq *iocb, *next_iocb; |
| 1098 | struct lpfc_nodelist *ndlp; |
| 1099 | IOCB_t *icmd; |
| 1100 | |
| 1101 | /* Abort outstanding I/O on NPort <nlp_DID> */ |
| 1102 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1103 | "0201 Abort outstanding I/O on NPort x%x\n", |
| 1104 | Fabric_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1105 | |
| 1106 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
| 1107 | |
| 1108 | /* |
| 1109 | * Check the txcmplq for an iocb that matches the nport the driver is |
| 1110 | * searching for. |
| 1111 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1112 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1113 | list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) { |
| 1114 | icmd = &iocb->iocb; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1115 | if (icmd->ulpCommand == CMD_ELS_REQUEST64_CR && |
| 1116 | icmd->un.elsreq64.bdl.ulpIoTag32) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1117 | ndlp = (struct lpfc_nodelist *)(iocb->context1); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1118 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 1119 | (ndlp->nlp_DID == Fabric_DID)) |
James Smart | 0795107 | 2007-04-25 09:51:38 -0400 | [diff] [blame] | 1120 | lpfc_sli_issue_abort_iotag(phba, pring, iocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1121 | } |
| 1122 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1123 | spin_unlock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1124 | |
| 1125 | return 0; |
| 1126 | } |
| 1127 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1128 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1129 | * lpfc_initial_flogi - Issue an initial fabric login for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1130 | * @vport: pointer to a host virtual N_Port data structure. |
| 1131 | * |
| 1132 | * This routine issues an initial Fabric Login (FLOGI) for the @vport |
| 1133 | * specified. It first searches the ndlp with the Fabric_DID (0xfffffe) from |
| 1134 | * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and |
| 1135 | * put it into the @vport's ndlp list. If an inactive ndlp found on the list, |
| 1136 | * it will just be enabled and made active. The lpfc_issue_els_flogi() routine |
| 1137 | * is then invoked with the @vport and the ndlp to perform the FLOGI for the |
| 1138 | * @vport. |
| 1139 | * |
| 1140 | * Return code |
| 1141 | * 0 - failed to issue initial flogi for @vport |
| 1142 | * 1 - successfully issued initial flogi for @vport |
| 1143 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1144 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1145 | lpfc_initial_flogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1146 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1147 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1148 | struct lpfc_nodelist *ndlp; |
| 1149 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1150 | vport->port_state = LPFC_FLOGI; |
| 1151 | lpfc_set_disctmo(vport); |
| 1152 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1153 | /* First look for the Fabric ndlp */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1154 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1155 | if (!ndlp) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1156 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1157 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 1158 | if (!ndlp) |
| 1159 | return 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1160 | lpfc_nlp_init(vport, ndlp, Fabric_DID); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 1161 | /* Set the node type */ |
| 1162 | ndlp->nlp_type |= NLP_FABRIC; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1163 | /* Put ndlp onto node list */ |
| 1164 | lpfc_enqueue_node(vport, ndlp); |
| 1165 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 1166 | /* re-setup ndlp without removing from node list */ |
| 1167 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 1168 | if (!ndlp) |
| 1169 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1170 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1171 | |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame^] | 1172 | if (lpfc_issue_els_flogi(vport, ndlp, 0)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1173 | /* This decrement of reference count to node shall kick off |
| 1174 | * the release of the node. |
| 1175 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 1176 | lpfc_nlp_put(ndlp); |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame^] | 1177 | return 0; |
| 1178 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1179 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1180 | } |
| 1181 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1182 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1183 | * lpfc_initial_fdisc - Issue an initial fabric discovery for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1184 | * @vport: pointer to a host virtual N_Port data structure. |
| 1185 | * |
| 1186 | * This routine issues an initial Fabric Discover (FDISC) for the @vport |
| 1187 | * specified. It first searches the ndlp with the Fabric_DID (0xfffffe) from |
| 1188 | * the @vport's ndlp list. If no such ndlp found, it will create an ndlp and |
| 1189 | * put it into the @vport's ndlp list. If an inactive ndlp found on the list, |
| 1190 | * it will just be enabled and made active. The lpfc_issue_els_fdisc() routine |
| 1191 | * is then invoked with the @vport and the ndlp to perform the FDISC for the |
| 1192 | * @vport. |
| 1193 | * |
| 1194 | * Return code |
| 1195 | * 0 - failed to issue initial fdisc for @vport |
| 1196 | * 1 - successfully issued initial fdisc for @vport |
| 1197 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1198 | int |
| 1199 | lpfc_initial_fdisc(struct lpfc_vport *vport) |
| 1200 | { |
| 1201 | struct lpfc_hba *phba = vport->phba; |
| 1202 | struct lpfc_nodelist *ndlp; |
| 1203 | |
| 1204 | /* First look for the Fabric ndlp */ |
| 1205 | ndlp = lpfc_findnode_did(vport, Fabric_DID); |
| 1206 | if (!ndlp) { |
| 1207 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
| 1208 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 1209 | if (!ndlp) |
| 1210 | return 0; |
| 1211 | lpfc_nlp_init(vport, ndlp, Fabric_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1212 | /* Put ndlp onto node list */ |
| 1213 | lpfc_enqueue_node(vport, ndlp); |
| 1214 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 1215 | /* re-setup ndlp without removing from node list */ |
| 1216 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 1217 | if (!ndlp) |
| 1218 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1219 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1220 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1221 | if (lpfc_issue_els_fdisc(vport, ndlp, 0)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1222 | /* decrement node reference count to trigger the release of |
| 1223 | * the node. |
| 1224 | */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1225 | lpfc_nlp_put(ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 1226 | return 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1227 | } |
| 1228 | return 1; |
| 1229 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1230 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1231 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1232 | * lpfc_more_plogi - Check and issue remaining plogis for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1233 | * @vport: pointer to a host virtual N_Port data structure. |
| 1234 | * |
| 1235 | * This routine checks whether there are more remaining Port Logins |
| 1236 | * (PLOGI) to be issued for the @vport. If so, it will invoke the routine |
| 1237 | * lpfc_els_disc_plogi() to go through the Node Port Recovery (NPR) nodes |
| 1238 | * to issue ELS PLOGIs up to the configured discover threads with the |
| 1239 | * @vport (@vport->cfg_discovery_threads). The function also decrement |
| 1240 | * the @vport's num_disc_node by 1 if it is not already 0. |
| 1241 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1242 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1243 | lpfc_more_plogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1244 | { |
| 1245 | int sentplogi; |
| 1246 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1247 | if (vport->num_disc_nodes) |
| 1248 | vport->num_disc_nodes--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1249 | |
| 1250 | /* Continue discovery with <num_disc_nodes> PLOGIs to go */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1251 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1252 | "0232 Continue discovery with %d PLOGIs to go " |
| 1253 | "Data: x%x x%x x%x\n", |
| 1254 | vport->num_disc_nodes, vport->fc_plogi_cnt, |
| 1255 | vport->fc_flag, vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1256 | /* Check to see if there are more PLOGIs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1257 | if (vport->fc_flag & FC_NLP_MORE) |
| 1258 | /* go thru NPR nodes and issue any remaining ELS PLOGIs */ |
| 1259 | sentplogi = lpfc_els_disc_plogi(vport); |
| 1260 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1261 | return; |
| 1262 | } |
| 1263 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1264 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1265 | * lpfc_plogi_confirm_nport - Confirm pologi wwpn matches stored ndlp |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1266 | * @phba: pointer to lpfc hba data structure. |
| 1267 | * @prsp: pointer to response IOCB payload. |
| 1268 | * @ndlp: pointer to a node-list data structure. |
| 1269 | * |
| 1270 | * This routine checks and indicates whether the WWPN of an N_Port, retrieved |
| 1271 | * from a PLOGI, matches the WWPN that is stored in the @ndlp for that N_POrt. |
| 1272 | * The following cases are considered N_Port confirmed: |
| 1273 | * 1) The N_Port is a Fabric ndlp; 2) The @ndlp is on vport list and matches |
| 1274 | * the WWPN of the N_Port logged into; 3) The @ndlp is not on vport list but |
| 1275 | * it does not have WWPN assigned either. If the WWPN is confirmed, the |
| 1276 | * pointer to the @ndlp will be returned. If the WWPN is not confirmed: |
| 1277 | * 1) if there is a node on vport list other than the @ndlp with the same |
| 1278 | * WWPN of the N_Port PLOGI logged into, the lpfc_unreg_rpi() will be invoked |
| 1279 | * on that node to release the RPI associated with the node; 2) if there is |
| 1280 | * no node found on vport list with the same WWPN of the N_Port PLOGI logged |
| 1281 | * into, a new node shall be allocated (or activated). In either case, the |
| 1282 | * parameters of the @ndlp shall be copied to the new_ndlp, the @ndlp shall |
| 1283 | * be released and the new_ndlp shall be put on to the vport node list and |
| 1284 | * its pointer returned as the confirmed node. |
| 1285 | * |
| 1286 | * Note that before the @ndlp got "released", the keepDID from not-matching |
| 1287 | * or inactive "new_ndlp" on the vport node list is assigned to the nlp_DID |
| 1288 | * of the @ndlp. This is because the release of @ndlp is actually to put it |
| 1289 | * into an inactive state on the vport node list and the vport node list |
| 1290 | * management algorithm does not allow two node with a same DID. |
| 1291 | * |
| 1292 | * Return code |
| 1293 | * pointer to the PLOGI N_Port @ndlp |
| 1294 | **/ |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1295 | static struct lpfc_nodelist * |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1296 | lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1297 | struct lpfc_nodelist *ndlp) |
| 1298 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1299 | struct lpfc_vport *vport = ndlp->vport; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1300 | struct lpfc_nodelist *new_ndlp; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1301 | struct lpfc_rport_data *rdata; |
| 1302 | struct fc_rport *rport; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1303 | struct serv_parm *sp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1304 | uint8_t name[sizeof(struct lpfc_name)]; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1305 | uint32_t rc, keepDID = 0; |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1306 | int put_node; |
| 1307 | int put_rport; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1308 | |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1309 | /* Fabric nodes can have the same WWPN so we don't bother searching |
| 1310 | * by WWPN. Just return the ndlp that was given to us. |
| 1311 | */ |
| 1312 | if (ndlp->nlp_type & NLP_FABRIC) |
| 1313 | return ndlp; |
| 1314 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1315 | sp = (struct serv_parm *) ((uint8_t *) prsp + sizeof(uint32_t)); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 1316 | memset(name, 0, sizeof(struct lpfc_name)); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1317 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 1318 | /* 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] | 1319 | * we have for that ndlp. If not, we have some work to do. |
| 1320 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1321 | new_ndlp = lpfc_findnode_wwpn(vport, &sp->portName); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1322 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1323 | if (new_ndlp == ndlp && NLP_CHK_NODE_ACT(new_ndlp)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1324 | return ndlp; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1325 | |
| 1326 | if (!new_ndlp) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1327 | rc = memcmp(&ndlp->nlp_portname, name, |
| 1328 | sizeof(struct lpfc_name)); |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1329 | if (!rc) |
| 1330 | return ndlp; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1331 | new_ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_ATOMIC); |
| 1332 | if (!new_ndlp) |
| 1333 | return ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1334 | lpfc_nlp_init(vport, new_ndlp, ndlp->nlp_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1335 | } else if (!NLP_CHK_NODE_ACT(new_ndlp)) { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1336 | rc = memcmp(&ndlp->nlp_portname, name, |
| 1337 | sizeof(struct lpfc_name)); |
| 1338 | if (!rc) |
| 1339 | return ndlp; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1340 | new_ndlp = lpfc_enable_node(vport, new_ndlp, |
| 1341 | NLP_STE_UNUSED_NODE); |
| 1342 | if (!new_ndlp) |
| 1343 | return ndlp; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1344 | keepDID = new_ndlp->nlp_DID; |
| 1345 | } else |
| 1346 | keepDID = new_ndlp->nlp_DID; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1347 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1348 | lpfc_unreg_rpi(vport, new_ndlp); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1349 | new_ndlp->nlp_DID = ndlp->nlp_DID; |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1350 | new_ndlp->nlp_prev_state = ndlp->nlp_prev_state; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1351 | |
| 1352 | if (ndlp->nlp_flag & NLP_NPR_2B_DISC) |
| 1353 | new_ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
| 1354 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
| 1355 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1356 | /* Set state will put new_ndlp on to node list if not already done */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1357 | lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1358 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1359 | /* Move this back to NPR state */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1360 | if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0) { |
| 1361 | /* The new_ndlp is replacing ndlp totally, so we need |
| 1362 | * to put ndlp on UNUSED list and try to free it. |
| 1363 | */ |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1364 | |
| 1365 | /* Fix up the rport accordingly */ |
| 1366 | rport = ndlp->rport; |
| 1367 | if (rport) { |
| 1368 | rdata = rport->dd_data; |
| 1369 | if (rdata->pnode == ndlp) { |
| 1370 | lpfc_nlp_put(ndlp); |
| 1371 | ndlp->rport = NULL; |
| 1372 | rdata->pnode = lpfc_nlp_get(new_ndlp); |
| 1373 | new_ndlp->rport = rport; |
| 1374 | } |
| 1375 | new_ndlp->nlp_type = ndlp->nlp_type; |
| 1376 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1377 | /* We shall actually free the ndlp with both nlp_DID and |
| 1378 | * nlp_portname fields equals 0 to avoid any ndlp on the |
| 1379 | * nodelist never to be used. |
| 1380 | */ |
| 1381 | if (ndlp->nlp_DID == 0) { |
| 1382 | spin_lock_irq(&phba->ndlp_lock); |
| 1383 | NLP_SET_FREE_REQ(ndlp); |
| 1384 | spin_unlock_irq(&phba->ndlp_lock); |
| 1385 | } |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1386 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1387 | /* Two ndlps cannot have the same did on the nodelist */ |
| 1388 | ndlp->nlp_DID = keepDID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1389 | lpfc_drop_node(vport, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1390 | } |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1391 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1392 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 1393 | /* Two ndlps cannot have the same did */ |
| 1394 | ndlp->nlp_DID = keepDID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1395 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 1396 | /* Since we are swapping the ndlp passed in with the new one |
| 1397 | * and the did has already been swapped, copy over the |
| 1398 | * state and names. |
| 1399 | */ |
| 1400 | memcpy(&new_ndlp->nlp_portname, &ndlp->nlp_portname, |
| 1401 | sizeof(struct lpfc_name)); |
| 1402 | memcpy(&new_ndlp->nlp_nodename, &ndlp->nlp_nodename, |
| 1403 | sizeof(struct lpfc_name)); |
| 1404 | new_ndlp->nlp_state = ndlp->nlp_state; |
| 1405 | /* Fix up the rport accordingly */ |
| 1406 | rport = ndlp->rport; |
| 1407 | if (rport) { |
| 1408 | rdata = rport->dd_data; |
| 1409 | put_node = rdata->pnode != NULL; |
| 1410 | put_rport = ndlp->rport != NULL; |
| 1411 | rdata->pnode = NULL; |
| 1412 | ndlp->rport = NULL; |
| 1413 | if (put_node) |
| 1414 | lpfc_nlp_put(ndlp); |
| 1415 | if (put_rport) |
| 1416 | put_device(&rport->dev); |
| 1417 | } |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1418 | } |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1419 | return new_ndlp; |
| 1420 | } |
| 1421 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1422 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1423 | * lpfc_end_rscn - Check and handle more rscn for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1424 | * @vport: pointer to a host virtual N_Port data structure. |
| 1425 | * |
| 1426 | * This routine checks whether more Registration State Change |
| 1427 | * Notifications (RSCNs) came in while the discovery state machine was in |
| 1428 | * the FC_RSCN_MODE. If so, the lpfc_els_handle_rscn() routine will be |
| 1429 | * invoked to handle the additional RSCNs for the @vport. Otherwise, the |
| 1430 | * FC_RSCN_MODE bit will be cleared with the @vport to mark as the end of |
| 1431 | * handling the RSCNs. |
| 1432 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1433 | void |
| 1434 | lpfc_end_rscn(struct lpfc_vport *vport) |
| 1435 | { |
| 1436 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 1437 | |
| 1438 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 1439 | /* |
| 1440 | * Check to see if more RSCNs came in while we were |
| 1441 | * processing this one. |
| 1442 | */ |
| 1443 | if (vport->fc_rscn_id_cnt || |
| 1444 | (vport->fc_flag & FC_RSCN_DISCOVERY) != 0) |
| 1445 | lpfc_els_handle_rscn(vport); |
| 1446 | else { |
| 1447 | spin_lock_irq(shost->host_lock); |
| 1448 | vport->fc_flag &= ~FC_RSCN_MODE; |
| 1449 | spin_unlock_irq(shost->host_lock); |
| 1450 | } |
| 1451 | } |
| 1452 | } |
| 1453 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1454 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1455 | * lpfc_cmpl_els_plogi - Completion callback function for plogi |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1456 | * @phba: pointer to lpfc hba data structure. |
| 1457 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 1458 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 1459 | * |
| 1460 | * This routine is the completion callback function for issuing the Port |
| 1461 | * Login (PLOGI) command. For PLOGI completion, there must be an active |
| 1462 | * ndlp on the vport node list that matches the remote node ID from the |
| 1463 | * PLOGI reponse IOCB. If such ndlp does not exist, the PLOGI is simply |
| 1464 | * ignored and command IOCB released. The PLOGI response IOCB status is |
| 1465 | * checked for error conditons. If there is error status reported, PLOGI |
| 1466 | * retry shall be attempted by invoking the lpfc_els_retry() routine. |
| 1467 | * Otherwise, the lpfc_plogi_confirm_nport() routine shall be invoked on |
| 1468 | * the ndlp and the NLP_EVT_CMPL_PLOGI state to the Discover State Machine |
| 1469 | * (DSM) is set for this PLOGI completion. Finally, it checks whether |
| 1470 | * there are additional N_Port nodes with the vport that need to perform |
| 1471 | * PLOGI. If so, the lpfc_more_plogi() routine is invoked to issue addition |
| 1472 | * PLOGIs. |
| 1473 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1474 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1475 | lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1476 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1477 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1478 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1479 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1480 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1481 | struct lpfc_nodelist *ndlp; |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1482 | struct lpfc_dmabuf *prsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1483 | int disc, rc, did, type; |
| 1484 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1485 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 1486 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 1487 | |
| 1488 | irsp = &rspiocb->iocb; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1489 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1490 | "PLOGI cmpl: status:x%x/x%x did:x%x", |
| 1491 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1492 | irsp->un.elsreq64.remoteID); |
| 1493 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1494 | ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1495 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1496 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1497 | "0136 PLOGI completes to NPort x%x " |
| 1498 | "with no ndlp. Data: x%x x%x x%x\n", |
| 1499 | irsp->un.elsreq64.remoteID, |
| 1500 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1501 | irsp->ulpIoTag); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1502 | goto out; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 1503 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1504 | |
| 1505 | /* Since ndlp can be freed in the disc state machine, note if this node |
| 1506 | * is being used during discovery. |
| 1507 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1508 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1509 | disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1510 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1511 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1512 | rc = 0; |
| 1513 | |
| 1514 | /* PLOGI completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1515 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1516 | "0102 PLOGI completes to NPort x%x " |
| 1517 | "Data: x%x x%x x%x x%x x%x\n", |
| 1518 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1519 | irsp->ulpTimeout, disc, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1520 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1521 | if (lpfc_els_chk_latt(vport)) { |
| 1522 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1523 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1524 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1525 | goto out; |
| 1526 | } |
| 1527 | |
| 1528 | /* ndlp could be freed in DSM, save these values now */ |
| 1529 | type = ndlp->nlp_type; |
| 1530 | did = ndlp->nlp_DID; |
| 1531 | |
| 1532 | if (irsp->ulpStatus) { |
| 1533 | /* Check for retry */ |
| 1534 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 1535 | /* ELS command is being retried */ |
| 1536 | if (disc) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1537 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1538 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1539 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1540 | } |
| 1541 | goto out; |
| 1542 | } |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 1543 | /* PLOGI failed Don't print the vport to vport rjts */ |
| 1544 | if (irsp->ulpStatus != IOSTAT_LS_RJT || |
| 1545 | (((irsp->un.ulpWord[4]) >> 16 != LSRJT_INVALID_CMD) && |
| 1546 | ((irsp->un.ulpWord[4]) >> 16 != LSRJT_UNABLE_TPC)) || |
| 1547 | (phba)->pport->cfg_log_verbose & LOG_ELS) |
| 1548 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 1549 | "2753 PLOGI failure DID:%06X Status:x%x/x%x\n", |
| 1550 | ndlp->nlp_DID, irsp->ulpStatus, |
| 1551 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1552 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1553 | if (lpfc_error_lost_link(irsp)) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1554 | rc = NLP_STE_FREED_NODE; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1555 | else |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1556 | rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1557 | NLP_EVT_CMPL_PLOGI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1558 | } else { |
| 1559 | /* Good status, call state machine */ |
James Smart | 9279565 | 2006-07-06 15:50:02 -0400 | [diff] [blame] | 1560 | prsp = list_entry(((struct lpfc_dmabuf *) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1561 | cmdiocb->context2)->list.next, |
| 1562 | struct lpfc_dmabuf, list); |
| 1563 | ndlp = lpfc_plogi_confirm_nport(phba, prsp->virt, ndlp); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1564 | rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1565 | NLP_EVT_CMPL_PLOGI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1566 | } |
| 1567 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1568 | if (disc && vport->num_disc_nodes) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1569 | /* Check to see if there are more PLOGIs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1570 | lpfc_more_plogi(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1571 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1572 | if (vport->num_disc_nodes == 0) { |
| 1573 | spin_lock_irq(shost->host_lock); |
| 1574 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 1575 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1576 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1577 | lpfc_can_disctmo(vport); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 1578 | lpfc_end_rscn(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1579 | } |
| 1580 | } |
| 1581 | |
| 1582 | out: |
| 1583 | lpfc_els_free_iocb(phba, cmdiocb); |
| 1584 | return; |
| 1585 | } |
| 1586 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1587 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1588 | * lpfc_issue_els_plogi - Issue an plogi iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1589 | * @vport: pointer to a host virtual N_Port data structure. |
| 1590 | * @did: destination port identifier. |
| 1591 | * @retry: number of retries to the command IOCB. |
| 1592 | * |
| 1593 | * This routine issues a Port Login (PLOGI) command to a remote N_Port |
| 1594 | * (with the @did) for a @vport. Before issuing a PLOGI to a remote N_Port, |
| 1595 | * the ndlp with the remote N_Port DID must exist on the @vport's ndlp list. |
| 1596 | * This routine constructs the proper feilds of the PLOGI IOCB and invokes |
| 1597 | * the lpfc_sli_issue_iocb() routine to send out PLOGI ELS command. |
| 1598 | * |
| 1599 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 1600 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 1601 | * will be stored into the context1 field of the IOCB for the completion |
| 1602 | * callback function to the PLOGI ELS command. |
| 1603 | * |
| 1604 | * Return code |
| 1605 | * 0 - Successfully issued a plogi for @vport |
| 1606 | * 1 - failed to issue a plogi for @vport |
| 1607 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1608 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1609 | lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1610 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1611 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1612 | struct serv_parm *sp; |
| 1613 | IOCB_t *icmd; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1614 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1615 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1616 | struct lpfc_sli *psli; |
| 1617 | uint8_t *pcmd; |
| 1618 | uint16_t cmdsize; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1619 | int ret; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1620 | |
| 1621 | psli = &phba->sli; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1622 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1623 | ndlp = lpfc_findnode_did(vport, did); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1624 | if (ndlp && !NLP_CHK_NODE_ACT(ndlp)) |
| 1625 | ndlp = NULL; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1626 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1627 | /* 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] | 1628 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1629 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1630 | ELS_CMD_PLOGI); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1631 | if (!elsiocb) |
| 1632 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1633 | |
| 1634 | icmd = &elsiocb->iocb; |
| 1635 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 1636 | |
| 1637 | /* For PLOGI request, remainder of payload is service parameters */ |
| 1638 | *((uint32_t *) (pcmd)) = ELS_CMD_PLOGI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1639 | pcmd += sizeof(uint32_t); |
| 1640 | memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1641 | sp = (struct serv_parm *) pcmd; |
| 1642 | |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame^] | 1643 | /* |
| 1644 | * If we are a N-port connected to a Fabric, fix-up paramm's so logins |
| 1645 | * to device on remote loops work. |
| 1646 | */ |
| 1647 | if ((vport->fc_flag & FC_FABRIC) && !(vport->fc_flag & FC_PUBLIC_LOOP)) |
| 1648 | sp->cmn.altBbCredit = 1; |
| 1649 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1650 | if (sp->cmn.fcphLow < FC_PH_4_3) |
| 1651 | sp->cmn.fcphLow = FC_PH_4_3; |
| 1652 | |
| 1653 | if (sp->cmn.fcphHigh < FC_PH3) |
| 1654 | sp->cmn.fcphHigh = FC_PH3; |
| 1655 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1656 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1657 | "Issue PLOGI: did:x%x", |
| 1658 | did, 0, 0); |
| 1659 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1660 | phba->fc_stat.elsXmitPLOGI++; |
| 1661 | elsiocb->iocb_cmpl = lpfc_cmpl_els_plogi; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 1662 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1663 | |
| 1664 | if (ret == IOCB_ERROR) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1665 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1666 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1667 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1668 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1669 | } |
| 1670 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1671 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1672 | * lpfc_cmpl_els_prli - Completion callback function for prli |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1673 | * @phba: pointer to lpfc hba data structure. |
| 1674 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 1675 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 1676 | * |
| 1677 | * This routine is the completion callback function for a Process Login |
| 1678 | * (PRLI) ELS command. The PRLI response IOCB status is checked for error |
| 1679 | * status. If there is error status reported, PRLI retry shall be attempted |
| 1680 | * by invoking the lpfc_els_retry() routine. Otherwise, the state |
| 1681 | * NLP_EVT_CMPL_PRLI is sent to the Discover State Machine (DSM) for this |
| 1682 | * ndlp to mark the PRLI completion. |
| 1683 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1684 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1685 | lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1686 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1687 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1688 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1689 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1690 | IOCB_t *irsp; |
| 1691 | struct lpfc_sli *psli; |
| 1692 | struct lpfc_nodelist *ndlp; |
| 1693 | |
| 1694 | psli = &phba->sli; |
| 1695 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 1696 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 1697 | |
| 1698 | irsp = &(rspiocb->iocb); |
| 1699 | ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1700 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1701 | ndlp->nlp_flag &= ~NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1702 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1703 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1704 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1705 | "PRLI cmpl: status:x%x/x%x did:x%x", |
| 1706 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1707 | ndlp->nlp_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1708 | /* PRLI completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1709 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1710 | "0103 PRLI completes to NPort x%x " |
| 1711 | "Data: x%x x%x x%x x%x\n", |
| 1712 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1713 | irsp->ulpTimeout, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1714 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1715 | vport->fc_prli_sent--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1716 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1717 | if (lpfc_els_chk_latt(vport)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1718 | goto out; |
| 1719 | |
| 1720 | if (irsp->ulpStatus) { |
| 1721 | /* Check for retry */ |
| 1722 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 1723 | /* ELS command is being retried */ |
| 1724 | goto out; |
| 1725 | } |
| 1726 | /* PRLI failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 1727 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 1728 | "2754 PRLI failure DID:%06X Status:x%x/x%x\n", |
| 1729 | ndlp->nlp_DID, irsp->ulpStatus, |
| 1730 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1731 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1732 | if (lpfc_error_lost_link(irsp)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1733 | goto out; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1734 | else |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1735 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1736 | NLP_EVT_CMPL_PRLI); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1737 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1738 | /* Good status, call state machine */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1739 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1740 | NLP_EVT_CMPL_PRLI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1741 | out: |
| 1742 | lpfc_els_free_iocb(phba, cmdiocb); |
| 1743 | return; |
| 1744 | } |
| 1745 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1746 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1747 | * lpfc_issue_els_prli - Issue a prli iocb command for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1748 | * @vport: pointer to a host virtual N_Port data structure. |
| 1749 | * @ndlp: pointer to a node-list data structure. |
| 1750 | * @retry: number of retries to the command IOCB. |
| 1751 | * |
| 1752 | * This routine issues a Process Login (PRLI) ELS command for the |
| 1753 | * @vport. The PRLI service parameters are set up in the payload of the |
| 1754 | * PRLI Request command and the pointer to lpfc_cmpl_els_prli() routine |
| 1755 | * is put to the IOCB completion callback func field before invoking the |
| 1756 | * routine lpfc_sli_issue_iocb() to send out PRLI command. |
| 1757 | * |
| 1758 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 1759 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 1760 | * will be stored into the context1 field of the IOCB for the completion |
| 1761 | * callback function to the PRLI ELS command. |
| 1762 | * |
| 1763 | * Return code |
| 1764 | * 0 - successfully issued prli iocb command for @vport |
| 1765 | * 1 - failed to issue prli iocb command for @vport |
| 1766 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1767 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1768 | lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1769 | uint8_t retry) |
| 1770 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1771 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 1772 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1773 | PRLI *npr; |
| 1774 | IOCB_t *icmd; |
| 1775 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1776 | uint8_t *pcmd; |
| 1777 | uint16_t cmdsize; |
| 1778 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1779 | cmdsize = (sizeof(uint32_t) + sizeof(PRLI)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1780 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 1781 | ndlp->nlp_DID, ELS_CMD_PRLI); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 1782 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1783 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1784 | |
| 1785 | icmd = &elsiocb->iocb; |
| 1786 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 1787 | |
| 1788 | /* For PRLI request, remainder of payload is service parameters */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1789 | memset(pcmd, 0, (sizeof(PRLI) + sizeof(uint32_t))); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1790 | *((uint32_t *) (pcmd)) = ELS_CMD_PRLI; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1791 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1792 | |
| 1793 | /* For PRLI, remainder of payload is PRLI parameter page */ |
| 1794 | npr = (PRLI *) pcmd; |
| 1795 | /* |
| 1796 | * If our firmware version is 3.20 or later, |
| 1797 | * set the following bits for FC-TAPE support. |
| 1798 | */ |
| 1799 | if (phba->vpd.rev.feaLevelHigh >= 0x02) { |
| 1800 | npr->ConfmComplAllowed = 1; |
| 1801 | npr->Retry = 1; |
| 1802 | npr->TaskRetryIdReq = 1; |
| 1803 | } |
| 1804 | npr->estabImagePair = 1; |
| 1805 | npr->readXferRdyDis = 1; |
| 1806 | |
| 1807 | /* For FCP support */ |
| 1808 | npr->prliType = PRLI_FCP_TYPE; |
| 1809 | npr->initiatorFunc = 1; |
| 1810 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1811 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1812 | "Issue PRLI: did:x%x", |
| 1813 | ndlp->nlp_DID, 0, 0); |
| 1814 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1815 | phba->fc_stat.elsXmitPRLI++; |
| 1816 | elsiocb->iocb_cmpl = lpfc_cmpl_els_prli; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1817 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1818 | ndlp->nlp_flag |= NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1819 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 1820 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 1821 | IOCB_ERROR) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1822 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1823 | ndlp->nlp_flag &= ~NLP_PRLI_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1824 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1825 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1826 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1827 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1828 | vport->fc_prli_sent++; |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1829 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1830 | } |
| 1831 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1832 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1833 | * lpfc_rscn_disc - Perform rscn discovery for a vport |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 1834 | * @vport: pointer to a host virtual N_Port data structure. |
| 1835 | * |
| 1836 | * This routine performs Registration State Change Notification (RSCN) |
| 1837 | * discovery for a @vport. If the @vport's node port recovery count is not |
| 1838 | * zero, it will invoke the lpfc_els_disc_plogi() to perform PLOGI for all |
| 1839 | * the nodes that need recovery. If none of the PLOGI were needed through |
| 1840 | * the lpfc_els_disc_plogi() routine, the lpfc_end_rscn() routine shall be |
| 1841 | * invoked to check and handle possible more RSCN came in during the period |
| 1842 | * of processing the current ones. |
| 1843 | **/ |
| 1844 | static void |
| 1845 | lpfc_rscn_disc(struct lpfc_vport *vport) |
| 1846 | { |
| 1847 | lpfc_can_disctmo(vport); |
| 1848 | |
| 1849 | /* RSCN discovery */ |
| 1850 | /* go thru NPR nodes and issue ELS PLOGIs */ |
| 1851 | if (vport->fc_npr_cnt) |
| 1852 | if (lpfc_els_disc_plogi(vport)) |
| 1853 | return; |
| 1854 | |
| 1855 | lpfc_end_rscn(vport); |
| 1856 | } |
| 1857 | |
| 1858 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1859 | * lpfc_adisc_done - Complete the adisc phase of discovery |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 1860 | * @vport: pointer to lpfc_vport hba data structure that finished all ADISCs. |
| 1861 | * |
| 1862 | * This function is called when the final ADISC is completed during discovery. |
| 1863 | * This function handles clearing link attention or issuing reg_vpi depending |
| 1864 | * on whether npiv is enabled. This function also kicks off the PLOGI phase of |
| 1865 | * discovery. |
| 1866 | * This function is called with no locks held. |
| 1867 | **/ |
| 1868 | static void |
| 1869 | lpfc_adisc_done(struct lpfc_vport *vport) |
| 1870 | { |
| 1871 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 1872 | struct lpfc_hba *phba = vport->phba; |
| 1873 | |
| 1874 | /* |
| 1875 | * For NPIV, cmpl_reg_vpi will set port_state to READY, |
| 1876 | * and continue discovery. |
| 1877 | */ |
| 1878 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 1879 | !(vport->fc_flag & FC_RSCN_MODE) && |
| 1880 | (phba->sli_rev < LPFC_SLI_REV4)) { |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 1881 | lpfc_issue_reg_vpi(phba, vport); |
| 1882 | return; |
| 1883 | } |
| 1884 | /* |
| 1885 | * For SLI2, we need to set port_state to READY |
| 1886 | * and continue discovery. |
| 1887 | */ |
| 1888 | if (vport->port_state < LPFC_VPORT_READY) { |
| 1889 | /* If we get here, there is nothing to ADISC */ |
| 1890 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1891 | lpfc_issue_clear_la(phba, vport); |
| 1892 | if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) { |
| 1893 | vport->num_disc_nodes = 0; |
| 1894 | /* go thru NPR list, issue ELS PLOGIs */ |
| 1895 | if (vport->fc_npr_cnt) |
| 1896 | lpfc_els_disc_plogi(vport); |
| 1897 | if (!vport->num_disc_nodes) { |
| 1898 | spin_lock_irq(shost->host_lock); |
| 1899 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 1900 | spin_unlock_irq(shost->host_lock); |
| 1901 | lpfc_can_disctmo(vport); |
| 1902 | lpfc_end_rscn(vport); |
| 1903 | } |
| 1904 | } |
| 1905 | vport->port_state = LPFC_VPORT_READY; |
| 1906 | } else |
| 1907 | lpfc_rscn_disc(vport); |
| 1908 | } |
| 1909 | |
| 1910 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1911 | * lpfc_more_adisc - Issue more adisc as needed |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1912 | * @vport: pointer to a host virtual N_Port data structure. |
| 1913 | * |
| 1914 | * This routine determines whether there are more ndlps on a @vport |
| 1915 | * node list need to have Address Discover (ADISC) issued. If so, it will |
| 1916 | * invoke the lpfc_els_disc_adisc() routine to issue ADISC on the @vport's |
| 1917 | * remaining nodes which need to have ADISC sent. |
| 1918 | **/ |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 1919 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1920 | lpfc_more_adisc(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1921 | { |
| 1922 | int sentadisc; |
| 1923 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1924 | if (vport->num_disc_nodes) |
| 1925 | vport->num_disc_nodes--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1926 | /* Continue discovery with <num_disc_nodes> ADISCs to go */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1927 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1928 | "0210 Continue discovery with %d ADISCs to go " |
| 1929 | "Data: x%x x%x x%x\n", |
| 1930 | vport->num_disc_nodes, vport->fc_adisc_cnt, |
| 1931 | vport->fc_flag, vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1932 | /* Check to see if there are more ADISCs to be sent */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1933 | if (vport->fc_flag & FC_NLP_MORE) { |
| 1934 | lpfc_set_disctmo(vport); |
| 1935 | /* go thru NPR nodes and issue any remaining ELS ADISCs */ |
| 1936 | sentadisc = lpfc_els_disc_adisc(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1937 | } |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 1938 | if (!vport->num_disc_nodes) |
| 1939 | lpfc_adisc_done(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1940 | return; |
| 1941 | } |
| 1942 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1943 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 1944 | * lpfc_cmpl_els_adisc - Completion callback function for adisc |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 1945 | * @phba: pointer to lpfc hba data structure. |
| 1946 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 1947 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 1948 | * |
| 1949 | * This routine is the completion function for issuing the Address Discover |
| 1950 | * (ADISC) command. It first checks to see whether link went down during |
| 1951 | * the discovery process. If so, the node will be marked as node port |
| 1952 | * recovery for issuing discover IOCB by the link attention handler and |
| 1953 | * exit. Otherwise, the response status is checked. If error was reported |
| 1954 | * in the response status, the ADISC command shall be retried by invoking |
| 1955 | * the lpfc_els_retry() routine. Otherwise, if no error was reported in |
| 1956 | * the response status, the state machine is invoked to set transition |
| 1957 | * with respect to NLP_EVT_CMPL_ADISC event. |
| 1958 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1959 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1960 | lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1961 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1962 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1963 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1964 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1965 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1966 | struct lpfc_nodelist *ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1967 | int disc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1968 | |
| 1969 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 1970 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 1971 | |
| 1972 | irsp = &(rspiocb->iocb); |
| 1973 | ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1974 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1975 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 1976 | "ADISC cmpl: status:x%x/x%x did:x%x", |
| 1977 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1978 | ndlp->nlp_DID); |
| 1979 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1980 | /* Since ndlp can be freed in the disc state machine, note if this node |
| 1981 | * is being used during discovery. |
| 1982 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1983 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1984 | disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 1985 | ndlp->nlp_flag &= ~(NLP_ADISC_SND | NLP_NPR_2B_DISC); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1986 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1987 | /* ADISC completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1988 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 1989 | "0104 ADISC completes to NPort x%x " |
| 1990 | "Data: x%x x%x x%x x%x x%x\n", |
| 1991 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 1992 | irsp->ulpTimeout, disc, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1993 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1994 | if (lpfc_els_chk_latt(vport)) { |
| 1995 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1996 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1997 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1998 | goto out; |
| 1999 | } |
| 2000 | |
| 2001 | if (irsp->ulpStatus) { |
| 2002 | /* Check for retry */ |
| 2003 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) { |
| 2004 | /* ELS command is being retried */ |
| 2005 | if (disc) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2006 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2007 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2008 | spin_unlock_irq(shost->host_lock); |
| 2009 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2010 | } |
| 2011 | goto out; |
| 2012 | } |
| 2013 | /* ADISC failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2014 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2015 | "2755 ADISC failure DID:%06X Status:x%x/x%x\n", |
| 2016 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2017 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2018 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2019 | if (!lpfc_error_lost_link(irsp)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2020 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2021 | NLP_EVT_CMPL_ADISC); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2022 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2023 | /* Good status, call state machine */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2024 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2025 | NLP_EVT_CMPL_ADISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2026 | |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2027 | /* Check to see if there are more ADISCs to be sent */ |
| 2028 | if (disc && vport->num_disc_nodes) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2029 | lpfc_more_adisc(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2030 | out: |
| 2031 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2032 | return; |
| 2033 | } |
| 2034 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2035 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2036 | * 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] | 2037 | * @vport: pointer to a virtual N_Port data structure. |
| 2038 | * @ndlp: pointer to a node-list data structure. |
| 2039 | * @retry: number of retries to the command IOCB. |
| 2040 | * |
| 2041 | * This routine issues an Address Discover (ADISC) for an @ndlp on a |
| 2042 | * @vport. It prepares the payload of the ADISC ELS command, updates the |
| 2043 | * and states of the ndlp, and invokes the lpfc_sli_issue_iocb() routine |
| 2044 | * to issue the ADISC ELS command. |
| 2045 | * |
| 2046 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2047 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2048 | * will be stored into the context1 field of the IOCB for the completion |
| 2049 | * callback function to the ADISC ELS command. |
| 2050 | * |
| 2051 | * Return code |
| 2052 | * 0 - successfully issued adisc |
| 2053 | * 1 - failed to issue adisc |
| 2054 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2055 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2056 | lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2057 | uint8_t retry) |
| 2058 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2059 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2060 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2061 | ADISC *ap; |
| 2062 | IOCB_t *icmd; |
| 2063 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2064 | uint8_t *pcmd; |
| 2065 | uint16_t cmdsize; |
| 2066 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2067 | cmdsize = (sizeof(uint32_t) + sizeof(ADISC)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2068 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2069 | ndlp->nlp_DID, ELS_CMD_ADISC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2070 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2071 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2072 | |
| 2073 | icmd = &elsiocb->iocb; |
| 2074 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2075 | |
| 2076 | /* For ADISC request, remainder of payload is service parameters */ |
| 2077 | *((uint32_t *) (pcmd)) = ELS_CMD_ADISC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2078 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2079 | |
| 2080 | /* Fill in ADISC payload */ |
| 2081 | ap = (ADISC *) pcmd; |
| 2082 | ap->hardAL_PA = phba->fc_pref_ALPA; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2083 | memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 2084 | memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2085 | ap->DID = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2086 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2087 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2088 | "Issue ADISC: did:x%x", |
| 2089 | ndlp->nlp_DID, 0, 0); |
| 2090 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2091 | phba->fc_stat.elsXmitADISC++; |
| 2092 | elsiocb->iocb_cmpl = lpfc_cmpl_els_adisc; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2093 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2094 | ndlp->nlp_flag |= NLP_ADISC_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2095 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2096 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2097 | IOCB_ERROR) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2098 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2099 | ndlp->nlp_flag &= ~NLP_ADISC_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2100 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2101 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2102 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2103 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2104 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2105 | } |
| 2106 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2107 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2108 | * lpfc_cmpl_els_logo - Completion callback function for logo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2109 | * @phba: pointer to lpfc hba data structure. |
| 2110 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2111 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2112 | * |
| 2113 | * This routine is the completion function for issuing the ELS Logout (LOGO) |
| 2114 | * command. If no error status was reported from the LOGO response, the |
| 2115 | * state machine of the associated ndlp shall be invoked for transition with |
| 2116 | * respect to NLP_EVT_CMPL_LOGO event. Otherwise, if error status was reported, |
| 2117 | * the lpfc_els_retry() routine will be invoked to retry the LOGO command. |
| 2118 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2119 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2120 | lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2121 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2122 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2123 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 2124 | struct lpfc_vport *vport = ndlp->vport; |
| 2125 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2126 | IOCB_t *irsp; |
| 2127 | struct lpfc_sli *psli; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2128 | |
| 2129 | psli = &phba->sli; |
| 2130 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 2131 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 2132 | |
| 2133 | irsp = &(rspiocb->iocb); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2134 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2135 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2136 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2137 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2138 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2139 | "LOGO cmpl: status:x%x/x%x did:x%x", |
| 2140 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2141 | ndlp->nlp_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2142 | /* LOGO completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2143 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2144 | "0105 LOGO completes to NPort x%x " |
| 2145 | "Data: x%x x%x x%x x%x\n", |
| 2146 | ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2147 | irsp->ulpTimeout, vport->num_disc_nodes); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2148 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2149 | if (lpfc_els_chk_latt(vport)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2150 | goto out; |
| 2151 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2152 | if (ndlp->nlp_flag & NLP_TARGET_REMOVE) { |
| 2153 | /* NLP_EVT_DEVICE_RM should unregister the RPI |
| 2154 | * which should abort all outstanding IOs. |
| 2155 | */ |
| 2156 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
| 2157 | NLP_EVT_DEVICE_RM); |
| 2158 | goto out; |
| 2159 | } |
| 2160 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2161 | if (irsp->ulpStatus) { |
| 2162 | /* Check for retry */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2163 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2164 | /* ELS command is being retried */ |
| 2165 | goto out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2166 | /* LOGO failed */ |
James Smart | e40a02c | 2010-02-26 14:13:54 -0500 | [diff] [blame] | 2167 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2168 | "2756 LOGO failure DID:%06X Status:x%x/x%x\n", |
| 2169 | ndlp->nlp_DID, irsp->ulpStatus, |
| 2170 | irsp->un.ulpWord[4]); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2171 | /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2172 | if (lpfc_error_lost_link(irsp)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2173 | goto out; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2174 | else |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2175 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2176 | NLP_EVT_CMPL_LOGO); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2177 | } else |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 2178 | /* Good status, call state machine. |
| 2179 | * This will unregister the rpi if needed. |
| 2180 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2181 | lpfc_disc_state_machine(vport, ndlp, cmdiocb, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2182 | NLP_EVT_CMPL_LOGO); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2183 | out: |
| 2184 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2185 | return; |
| 2186 | } |
| 2187 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2188 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2189 | * 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] | 2190 | * @vport: pointer to a virtual N_Port data structure. |
| 2191 | * @ndlp: pointer to a node-list data structure. |
| 2192 | * @retry: number of retries to the command IOCB. |
| 2193 | * |
| 2194 | * This routine constructs and issues an ELS Logout (LOGO) iocb command |
| 2195 | * to a remote node, referred by an @ndlp on a @vport. It constructs the |
| 2196 | * payload of the IOCB, properly sets up the @ndlp state, and invokes the |
| 2197 | * lpfc_sli_issue_iocb() routine to send out the LOGO ELS command. |
| 2198 | * |
| 2199 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2200 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2201 | * will be stored into the context1 field of the IOCB for the completion |
| 2202 | * callback function to the LOGO ELS command. |
| 2203 | * |
| 2204 | * Return code |
| 2205 | * 0 - successfully issued logo |
| 2206 | * 1 - failed to issue logo |
| 2207 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2208 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2209 | lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2210 | uint8_t retry) |
| 2211 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2212 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2213 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2214 | IOCB_t *icmd; |
| 2215 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2216 | uint8_t *pcmd; |
| 2217 | uint16_t cmdsize; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2218 | int rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2219 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 2220 | spin_lock_irq(shost->host_lock); |
| 2221 | if (ndlp->nlp_flag & NLP_LOGO_SND) { |
| 2222 | spin_unlock_irq(shost->host_lock); |
| 2223 | return 0; |
| 2224 | } |
| 2225 | spin_unlock_irq(shost->host_lock); |
| 2226 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2227 | cmdsize = (2 * sizeof(uint32_t)) + sizeof(struct lpfc_name); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2228 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2229 | ndlp->nlp_DID, ELS_CMD_LOGO); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2230 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2231 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2232 | |
| 2233 | icmd = &elsiocb->iocb; |
| 2234 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2235 | *((uint32_t *) (pcmd)) = ELS_CMD_LOGO; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2236 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2237 | |
| 2238 | /* Fill in LOGO payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2239 | *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2240 | pcmd += sizeof(uint32_t); |
| 2241 | memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2242 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2243 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2244 | "Issue LOGO: did:x%x", |
| 2245 | ndlp->nlp_DID, 0, 0); |
| 2246 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2247 | phba->fc_stat.elsXmitLOGO++; |
| 2248 | elsiocb->iocb_cmpl = lpfc_cmpl_els_logo; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2249 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2250 | ndlp->nlp_flag |= NLP_LOGO_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2251 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2252 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2253 | |
| 2254 | if (rc == IOCB_ERROR) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2255 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2256 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2257 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2258 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2259 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2260 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2261 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2262 | } |
| 2263 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2264 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2265 | * lpfc_cmpl_els_cmd - Completion callback function for generic els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2266 | * @phba: pointer to lpfc hba data structure. |
| 2267 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2268 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2269 | * |
| 2270 | * This routine is a generic completion callback function for ELS commands. |
| 2271 | * Specifically, it is the callback function which does not need to perform |
| 2272 | * any command specific operations. It is currently used by the ELS command |
| 2273 | * issuing routines for the ELS State Change Request (SCR), |
| 2274 | * lpfc_issue_els_scr(), and the ELS Fibre Channel Address Resolution |
| 2275 | * Protocol Response (FARPR) routine, lpfc_issue_els_farpr(). Other than |
| 2276 | * certain debug loggings, this callback function simply invokes the |
| 2277 | * lpfc_els_chk_latt() routine to check whether link went down during the |
| 2278 | * discovery process. |
| 2279 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2280 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2281 | lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2282 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2283 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2284 | struct lpfc_vport *vport = cmdiocb->vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2285 | IOCB_t *irsp; |
| 2286 | |
| 2287 | irsp = &rspiocb->iocb; |
| 2288 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2289 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2290 | "ELS cmd cmpl: status:x%x/x%x did:x%x", |
| 2291 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 2292 | irsp->un.elsreq64.remoteID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2293 | /* ELS cmd tag <ulpIoTag> completes */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2294 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2295 | "0106 ELS cmd tag x%x completes Data: x%x x%x x%x\n", |
| 2296 | irsp->ulpIoTag, irsp->ulpStatus, |
| 2297 | irsp->un.ulpWord[4], irsp->ulpTimeout); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2298 | /* Check to see if link went down during discovery */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2299 | lpfc_els_chk_latt(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2300 | lpfc_els_free_iocb(phba, cmdiocb); |
| 2301 | return; |
| 2302 | } |
| 2303 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2304 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2305 | * 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] | 2306 | * @vport: pointer to a host virtual N_Port data structure. |
| 2307 | * @nportid: N_Port identifier to the remote node. |
| 2308 | * @retry: number of retries to the command IOCB. |
| 2309 | * |
| 2310 | * This routine issues a State Change Request (SCR) to a fabric node |
| 2311 | * on a @vport. The remote node @nportid is passed into the function. It |
| 2312 | * first search the @vport node list to find the matching ndlp. If no such |
| 2313 | * ndlp is found, a new ndlp shall be created for this (SCR) purpose. An |
| 2314 | * IOCB is allocated, payload prepared, and the lpfc_sli_issue_iocb() |
| 2315 | * routine is invoked to send the SCR IOCB. |
| 2316 | * |
| 2317 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2318 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2319 | * will be stored into the context1 field of the IOCB for the completion |
| 2320 | * callback function to the SCR ELS command. |
| 2321 | * |
| 2322 | * Return code |
| 2323 | * 0 - Successfully issued scr command |
| 2324 | * 1 - Failed to issue scr command |
| 2325 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2326 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2327 | lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2328 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2329 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2330 | IOCB_t *icmd; |
| 2331 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2332 | struct lpfc_sli *psli; |
| 2333 | uint8_t *pcmd; |
| 2334 | uint16_t cmdsize; |
| 2335 | struct lpfc_nodelist *ndlp; |
| 2336 | |
| 2337 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2338 | cmdsize = (sizeof(uint32_t) + sizeof(SCR)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2339 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2340 | ndlp = lpfc_findnode_did(vport, nportid); |
| 2341 | if (!ndlp) { |
| 2342 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 2343 | if (!ndlp) |
| 2344 | return 1; |
| 2345 | lpfc_nlp_init(vport, ndlp, nportid); |
| 2346 | lpfc_enqueue_node(vport, ndlp); |
| 2347 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 2348 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 2349 | if (!ndlp) |
| 2350 | return 1; |
| 2351 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2352 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2353 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2354 | ndlp->nlp_DID, ELS_CMD_SCR); |
| 2355 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2356 | if (!elsiocb) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2357 | /* This will trigger the release of the node just |
| 2358 | * allocated |
| 2359 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2360 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2361 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2362 | } |
| 2363 | |
| 2364 | icmd = &elsiocb->iocb; |
| 2365 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2366 | |
| 2367 | *((uint32_t *) (pcmd)) = ELS_CMD_SCR; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2368 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2369 | |
| 2370 | /* For SCR, remainder of payload is SCR parameter page */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2371 | memset(pcmd, 0, sizeof(SCR)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2372 | ((SCR *) pcmd)->Function = SCR_FUNC_FULL; |
| 2373 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2374 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2375 | "Issue SCR: did:x%x", |
| 2376 | ndlp->nlp_DID, 0, 0); |
| 2377 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2378 | phba->fc_stat.elsXmitSCR++; |
| 2379 | elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2380 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2381 | IOCB_ERROR) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2382 | /* The additional lpfc_nlp_put will cause the following |
| 2383 | * lpfc_els_free_iocb routine to trigger the rlease of |
| 2384 | * the node. |
| 2385 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2386 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2387 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2388 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2389 | } |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2390 | /* This will cause the callback-function lpfc_cmpl_els_cmd to |
| 2391 | * trigger the release of node. |
| 2392 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2393 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2394 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2395 | } |
| 2396 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2397 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2398 | * 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] | 2399 | * @vport: pointer to a host virtual N_Port data structure. |
| 2400 | * @nportid: N_Port identifier to the remote node. |
| 2401 | * @retry: number of retries to the command IOCB. |
| 2402 | * |
| 2403 | * This routine issues a Fibre Channel Address Resolution Response |
| 2404 | * (FARPR) to a node on a vport. The remote node N_Port identifier (@nportid) |
| 2405 | * is passed into the function. It first search the @vport node list to find |
| 2406 | * the matching ndlp. If no such ndlp is found, a new ndlp shall be created |
| 2407 | * for this (FARPR) purpose. An IOCB is allocated, payload prepared, and the |
| 2408 | * lpfc_sli_issue_iocb() routine is invoked to send the FARPR ELS command. |
| 2409 | * |
| 2410 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 2411 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 2412 | * will be stored into the context1 field of the IOCB for the completion |
| 2413 | * callback function to the PARPR ELS command. |
| 2414 | * |
| 2415 | * Return code |
| 2416 | * 0 - Successfully issued farpr command |
| 2417 | * 1 - Failed to issue farpr command |
| 2418 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2419 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2420 | lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2421 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2422 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2423 | IOCB_t *icmd; |
| 2424 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2425 | struct lpfc_sli *psli; |
| 2426 | FARP *fp; |
| 2427 | uint8_t *pcmd; |
| 2428 | uint32_t *lp; |
| 2429 | uint16_t cmdsize; |
| 2430 | struct lpfc_nodelist *ondlp; |
| 2431 | struct lpfc_nodelist *ndlp; |
| 2432 | |
| 2433 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2434 | cmdsize = (sizeof(uint32_t) + sizeof(FARP)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2435 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2436 | ndlp = lpfc_findnode_did(vport, nportid); |
| 2437 | if (!ndlp) { |
| 2438 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 2439 | if (!ndlp) |
| 2440 | return 1; |
| 2441 | lpfc_nlp_init(vport, ndlp, nportid); |
| 2442 | lpfc_enqueue_node(vport, ndlp); |
| 2443 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 2444 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 2445 | if (!ndlp) |
| 2446 | return 1; |
| 2447 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2448 | |
| 2449 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, |
| 2450 | ndlp->nlp_DID, ELS_CMD_RNID); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2451 | if (!elsiocb) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2452 | /* This will trigger the release of the node just |
| 2453 | * allocated |
| 2454 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2455 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2456 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2457 | } |
| 2458 | |
| 2459 | icmd = &elsiocb->iocb; |
| 2460 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 2461 | |
| 2462 | *((uint32_t *) (pcmd)) = ELS_CMD_FARPR; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2463 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2464 | |
| 2465 | /* Fill in FARPR payload */ |
| 2466 | fp = (FARP *) (pcmd); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2467 | memset(fp, 0, sizeof(FARP)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2468 | lp = (uint32_t *) pcmd; |
| 2469 | *lp++ = be32_to_cpu(nportid); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2470 | *lp++ = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2471 | fp->Rflags = 0; |
| 2472 | fp->Mflags = (FARP_MATCH_PORT | FARP_MATCH_NODE); |
| 2473 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2474 | memcpy(&fp->RportName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 2475 | memcpy(&fp->RnodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2476 | ondlp = lpfc_findnode_did(vport, nportid); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2477 | if (ondlp && NLP_CHK_NODE_ACT(ondlp)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2478 | memcpy(&fp->OportName, &ondlp->nlp_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2479 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2480 | memcpy(&fp->OnodeName, &ondlp->nlp_nodename, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2481 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2482 | } |
| 2483 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2484 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2485 | "Issue FARPR: did:x%x", |
| 2486 | ndlp->nlp_DID, 0, 0); |
| 2487 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2488 | phba->fc_stat.elsXmitFARPR++; |
| 2489 | elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 2490 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 2491 | IOCB_ERROR) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2492 | /* The additional lpfc_nlp_put will cause the following |
| 2493 | * lpfc_els_free_iocb routine to trigger the release of |
| 2494 | * the node. |
| 2495 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2496 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2497 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2498 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2499 | } |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2500 | /* This will cause the callback-function lpfc_cmpl_els_cmd to |
| 2501 | * trigger the release of the node. |
| 2502 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 2503 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2504 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2505 | } |
| 2506 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2507 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2508 | * 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] | 2509 | * @vport: pointer to a host virtual N_Port data structure. |
| 2510 | * @nlp: pointer to a node-list data structure. |
| 2511 | * |
| 2512 | * This routine cancels the timer with a delayed IOCB-command retry for |
| 2513 | * a @vport's @ndlp. It stops the timer for the delayed function retrial and |
| 2514 | * removes the ELS retry event if it presents. In addition, if the |
| 2515 | * NLP_NPR_2B_DISC bit is set in the @nlp's nlp_flag bitmap, ADISC IOCB |
| 2516 | * commands are sent for the @vport's nodes that require issuing discovery |
| 2517 | * ADISC. |
| 2518 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2519 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2520 | 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] | 2521 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2522 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2523 | struct lpfc_work_evt *evtp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2524 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2525 | if (!(nlp->nlp_flag & NLP_DELAY_TMO)) |
| 2526 | return; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2527 | spin_lock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2528 | nlp->nlp_flag &= ~NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2529 | spin_unlock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2530 | del_timer_sync(&nlp->nlp_delayfunc); |
| 2531 | nlp->nlp_last_elscmd = 0; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2532 | if (!list_empty(&nlp->els_retry_evt.evt_listp)) { |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2533 | list_del_init(&nlp->els_retry_evt.evt_listp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2534 | /* Decrement nlp reference count held for the delayed retry */ |
| 2535 | evtp = &nlp->els_retry_evt; |
| 2536 | lpfc_nlp_put((struct lpfc_nodelist *)evtp->evt_arg1); |
| 2537 | } |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2538 | if (nlp->nlp_flag & NLP_NPR_2B_DISC) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2539 | spin_lock_irq(shost->host_lock); |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2540 | nlp->nlp_flag &= ~NLP_NPR_2B_DISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2541 | spin_unlock_irq(shost->host_lock); |
| 2542 | if (vport->num_disc_nodes) { |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2543 | if (vport->port_state < LPFC_VPORT_READY) { |
| 2544 | /* Check if there are more ADISCs to be sent */ |
| 2545 | lpfc_more_adisc(vport); |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 2546 | } else { |
| 2547 | /* Check if there are more PLOGIs to be sent */ |
| 2548 | lpfc_more_plogi(vport); |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 2549 | if (vport->num_disc_nodes == 0) { |
| 2550 | spin_lock_irq(shost->host_lock); |
| 2551 | vport->fc_flag &= ~FC_NDISC_ACTIVE; |
| 2552 | spin_unlock_irq(shost->host_lock); |
| 2553 | lpfc_can_disctmo(vport); |
| 2554 | lpfc_end_rscn(vport); |
| 2555 | } |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2556 | } |
| 2557 | } |
| 2558 | } |
| 2559 | return; |
| 2560 | } |
| 2561 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2562 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2563 | * lpfc_els_retry_delay - Timer function with a ndlp delayed function timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2564 | * @ptr: holder for the pointer to the timer function associated data (ndlp). |
| 2565 | * |
| 2566 | * This routine is invoked by the ndlp delayed-function timer to check |
| 2567 | * whether there is any pending ELS retry event(s) with the node. If not, it |
| 2568 | * simply returns. Otherwise, if there is at least one ELS delayed event, it |
| 2569 | * adds the delayed events to the HBA work list and invokes the |
| 2570 | * lpfc_worker_wake_up() routine to wake up worker thread to process the |
| 2571 | * event. Note that lpfc_nlp_get() is called before posting the event to |
| 2572 | * the work list to hold reference count of ndlp so that it guarantees the |
| 2573 | * reference to ndlp will still be available when the worker thread gets |
| 2574 | * to the event associated with the ndlp. |
| 2575 | **/ |
James Smart | fdcebe2 | 2006-03-07 15:04:01 -0500 | [diff] [blame] | 2576 | void |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2577 | lpfc_els_retry_delay(unsigned long ptr) |
| 2578 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2579 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) ptr; |
| 2580 | struct lpfc_vport *vport = ndlp->vport; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2581 | struct lpfc_hba *phba = vport->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2582 | unsigned long flags; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2583 | struct lpfc_work_evt *evtp = &ndlp->els_retry_evt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2584 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2585 | spin_lock_irqsave(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2586 | if (!list_empty(&evtp->evt_listp)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2587 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2588 | return; |
| 2589 | } |
| 2590 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 2591 | /* We need to hold the node by incrementing the reference |
| 2592 | * count until the queued work is done |
| 2593 | */ |
| 2594 | evtp->evt_arg1 = lpfc_nlp_get(ndlp); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 2595 | if (evtp->evt_arg1) { |
| 2596 | evtp->evt = LPFC_EVT_ELS_RETRY; |
| 2597 | list_add_tail(&evtp->evt_listp, &phba->work_list); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2598 | lpfc_worker_wake_up(phba); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 2599 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2600 | spin_unlock_irqrestore(&phba->hbalock, flags); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2601 | return; |
| 2602 | } |
| 2603 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2604 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2605 | * lpfc_els_retry_delay_handler - Work thread handler for ndlp delayed function |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2606 | * @ndlp: pointer to a node-list data structure. |
| 2607 | * |
| 2608 | * This routine is the worker-thread handler for processing the @ndlp delayed |
| 2609 | * event(s), posted by the lpfc_els_retry_delay() routine. It simply retrieves |
| 2610 | * the last ELS command from the associated ndlp and invokes the proper ELS |
| 2611 | * function according to the delayed ELS command to retry the command. |
| 2612 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2613 | void |
| 2614 | lpfc_els_retry_delay_handler(struct lpfc_nodelist *ndlp) |
| 2615 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2616 | struct lpfc_vport *vport = ndlp->vport; |
| 2617 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2618 | uint32_t cmd, did, retry; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2619 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2620 | spin_lock_irq(shost->host_lock); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 2621 | did = ndlp->nlp_DID; |
| 2622 | cmd = ndlp->nlp_last_elscmd; |
| 2623 | ndlp->nlp_last_elscmd = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2624 | |
| 2625 | if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2626 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2627 | return; |
| 2628 | } |
| 2629 | |
| 2630 | ndlp->nlp_flag &= ~NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2631 | spin_unlock_irq(shost->host_lock); |
James Smart | 1a16968 | 2006-03-07 15:04:06 -0500 | [diff] [blame] | 2632 | /* |
| 2633 | * If a discovery event readded nlp_delayfunc after timer |
| 2634 | * firing and before processing the timer, cancel the |
| 2635 | * nlp_delayfunc. |
| 2636 | */ |
| 2637 | del_timer_sync(&ndlp->nlp_delayfunc); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2638 | retry = ndlp->nlp_retry; |
James Smart | 4d9ab99 | 2009-10-02 15:16:39 -0400 | [diff] [blame] | 2639 | ndlp->nlp_retry = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2640 | |
| 2641 | switch (cmd) { |
| 2642 | case ELS_CMD_FLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2643 | lpfc_issue_els_flogi(vport, ndlp, retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2644 | break; |
| 2645 | case ELS_CMD_PLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2646 | if (!lpfc_issue_els_plogi(vport, ndlp->nlp_DID, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 2647 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2648 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 2649 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2650 | break; |
| 2651 | case ELS_CMD_ADISC: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2652 | if (!lpfc_issue_els_adisc(vport, ndlp, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 2653 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2654 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 2655 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2656 | break; |
| 2657 | case ELS_CMD_PRLI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2658 | if (!lpfc_issue_els_prli(vport, ndlp, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 2659 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2660 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 2661 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2662 | break; |
| 2663 | case ELS_CMD_LOGO: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2664 | if (!lpfc_issue_els_logo(vport, ndlp, retry)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 2665 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2666 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
Jamie Wellnitz | 6ad4253 | 2006-02-28 19:25:16 -0500 | [diff] [blame] | 2667 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2668 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2669 | case ELS_CMD_FDISC: |
| 2670 | lpfc_issue_els_fdisc(vport, ndlp, retry); |
| 2671 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2672 | } |
| 2673 | return; |
| 2674 | } |
| 2675 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2676 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 2677 | * lpfc_els_retry - Make retry decision on an els command iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 2678 | * @phba: pointer to lpfc hba data structure. |
| 2679 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 2680 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 2681 | * |
| 2682 | * This routine makes a retry decision on an ELS command IOCB, which has |
| 2683 | * failed. The following ELS IOCBs use this function for retrying the command |
| 2684 | * when previously issued command responsed with error status: FLOGI, PLOGI, |
| 2685 | * PRLI, ADISC, LOGO, and FDISC. Based on the ELS command type and the |
| 2686 | * returned error status, it makes the decision whether a retry shall be |
| 2687 | * issued for the command, and whether a retry shall be made immediately or |
| 2688 | * delayed. In the former case, the corresponding ELS command issuing-function |
| 2689 | * is called to retry the command. In the later case, the ELS command shall |
| 2690 | * be posted to the ndlp delayed event and delayed function timer set to the |
| 2691 | * ndlp for the delayed command issusing. |
| 2692 | * |
| 2693 | * Return code |
| 2694 | * 0 - No retry of els command is made |
| 2695 | * 1 - Immediate or delayed retry of els command is made |
| 2696 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2697 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2698 | lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 2699 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2700 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2701 | struct lpfc_vport *vport = cmdiocb->vport; |
| 2702 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2703 | IOCB_t *irsp = &rspiocb->iocb; |
| 2704 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 2705 | struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2706 | uint32_t *elscmd; |
| 2707 | struct ls_rjt stat; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2708 | int retry = 0, maxretry = lpfc_max_els_tries, delay = 0; |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 2709 | int logerr = 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2710 | uint32_t cmd = 0; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2711 | uint32_t did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2712 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2713 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2714 | /* Note: context2 may be 0 for internal driver abort |
| 2715 | * of delays ELS command. |
| 2716 | */ |
| 2717 | |
| 2718 | if (pcmd && pcmd->virt) { |
| 2719 | elscmd = (uint32_t *) (pcmd->virt); |
| 2720 | cmd = *elscmd++; |
| 2721 | } |
| 2722 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2723 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2724 | did = ndlp->nlp_DID; |
| 2725 | else { |
| 2726 | /* We should only hit this case for retrying PLOGI */ |
| 2727 | did = irsp->un.elsreq64.remoteID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2728 | ndlp = lpfc_findnode_did(vport, did); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2729 | if ((!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 2730 | && (cmd != ELS_CMD_PLOGI)) |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2731 | return 1; |
| 2732 | } |
| 2733 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2734 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 2735 | "Retry ELS: wd7:x%x wd4:x%x did:x%x", |
| 2736 | *(((uint32_t *) irsp) + 7), irsp->un.ulpWord[4], ndlp->nlp_DID); |
| 2737 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2738 | switch (irsp->ulpStatus) { |
| 2739 | case IOSTAT_FCP_RSP_ERROR: |
| 2740 | case IOSTAT_REMOTE_STOP: |
| 2741 | break; |
| 2742 | |
| 2743 | case IOSTAT_LOCAL_REJECT: |
| 2744 | switch ((irsp->un.ulpWord[4] & 0xff)) { |
| 2745 | case IOERR_LOOP_OPEN_FAILURE: |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 2746 | if (cmd == ELS_CMD_FLOGI) { |
| 2747 | if (PCI_DEVICE_ID_HORNET == |
| 2748 | phba->pcidev->device) { |
| 2749 | phba->fc_topology = TOPOLOGY_LOOP; |
| 2750 | phba->pport->fc_myDID = 0; |
| 2751 | phba->alpa_map[0] = 0; |
| 2752 | phba->alpa_map[1] = 0; |
| 2753 | } |
| 2754 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2755 | if (cmd == ELS_CMD_PLOGI && cmdiocb->retry == 0) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2756 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2757 | retry = 1; |
| 2758 | break; |
| 2759 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2760 | case IOERR_ILLEGAL_COMMAND: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 2761 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2762 | "0124 Retry illegal cmd x%x " |
| 2763 | "retry:x%x delay:x%x\n", |
| 2764 | cmd, cmdiocb->retry, delay); |
| 2765 | retry = 1; |
| 2766 | /* All command's retry policy */ |
| 2767 | maxretry = 8; |
| 2768 | if (cmdiocb->retry > 2) |
| 2769 | delay = 1000; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2770 | break; |
| 2771 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2772 | case IOERR_NO_RESOURCES: |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 2773 | logerr = 1; /* HBA out of resources */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2774 | retry = 1; |
| 2775 | if (cmdiocb->retry > 100) |
| 2776 | delay = 100; |
| 2777 | maxretry = 250; |
| 2778 | break; |
| 2779 | |
| 2780 | case IOERR_ILLEGAL_FRAME: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2781 | delay = 100; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2782 | retry = 1; |
| 2783 | break; |
| 2784 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2785 | case IOERR_SEQUENCE_TIMEOUT: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2786 | case IOERR_INVALID_RPI: |
| 2787 | retry = 1; |
| 2788 | break; |
| 2789 | } |
| 2790 | break; |
| 2791 | |
| 2792 | case IOSTAT_NPORT_RJT: |
| 2793 | case IOSTAT_FABRIC_RJT: |
| 2794 | if (irsp->un.ulpWord[4] & RJT_UNAVAIL_TEMP) { |
| 2795 | retry = 1; |
| 2796 | break; |
| 2797 | } |
| 2798 | break; |
| 2799 | |
| 2800 | case IOSTAT_NPORT_BSY: |
| 2801 | case IOSTAT_FABRIC_BSY: |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 2802 | logerr = 1; /* Fabric / Remote NPort out of resources */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2803 | retry = 1; |
| 2804 | break; |
| 2805 | |
| 2806 | case IOSTAT_LS_RJT: |
| 2807 | stat.un.lsRjtError = be32_to_cpu(irsp->un.ulpWord[4]); |
| 2808 | /* Added for Vendor specifc support |
| 2809 | * Just keep retrying for these Rsn / Exp codes |
| 2810 | */ |
| 2811 | switch (stat.un.b.lsRjtRsnCode) { |
| 2812 | case LSRJT_UNABLE_TPC: |
| 2813 | if (stat.un.b.lsRjtRsnCodeExp == |
| 2814 | LSEXP_CMD_IN_PROGRESS) { |
| 2815 | if (cmd == ELS_CMD_PLOGI) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2816 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2817 | maxretry = 48; |
| 2818 | } |
| 2819 | retry = 1; |
| 2820 | break; |
| 2821 | } |
James Smart | ffc9549 | 2010-06-07 15:23:17 -0400 | [diff] [blame] | 2822 | if (stat.un.b.lsRjtRsnCodeExp == |
| 2823 | LSEXP_CANT_GIVE_DATA) { |
| 2824 | if (cmd == ELS_CMD_PLOGI) { |
| 2825 | delay = 1000; |
| 2826 | maxretry = 48; |
| 2827 | } |
| 2828 | retry = 1; |
| 2829 | break; |
| 2830 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2831 | if (cmd == ELS_CMD_PLOGI) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2832 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2833 | maxretry = lpfc_max_els_tries + 1; |
| 2834 | retry = 1; |
| 2835 | break; |
| 2836 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2837 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
| 2838 | (cmd == ELS_CMD_FDISC) && |
| 2839 | (stat.un.b.lsRjtRsnCodeExp == LSEXP_OUT_OF_RESOURCE)){ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2840 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 2841 | "0125 FDISC Failed (x%x). " |
| 2842 | "Fabric out of resources\n", |
| 2843 | stat.un.lsRjtError); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2844 | lpfc_vport_set_state(vport, |
| 2845 | FC_VPORT_NO_FABRIC_RSCS); |
| 2846 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2847 | break; |
| 2848 | |
| 2849 | case LSRJT_LOGICAL_BSY: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2850 | if ((cmd == ELS_CMD_PLOGI) || |
| 2851 | (cmd == ELS_CMD_PRLI)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2852 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2853 | maxretry = 48; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2854 | } else if (cmd == ELS_CMD_FDISC) { |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2855 | /* FDISC retry policy */ |
| 2856 | maxretry = 48; |
| 2857 | if (cmdiocb->retry >= 32) |
| 2858 | delay = 1000; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2859 | } |
| 2860 | retry = 1; |
| 2861 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2862 | |
| 2863 | case LSRJT_LOGICAL_ERR: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 2864 | /* There are some cases where switches return this |
| 2865 | * error when they are not ready and should be returning |
| 2866 | * Logical Busy. We should delay every time. |
| 2867 | */ |
| 2868 | if (cmd == ELS_CMD_FDISC && |
| 2869 | stat.un.b.lsRjtRsnCodeExp == LSEXP_PORT_LOGIN_REQ) { |
| 2870 | maxretry = 3; |
| 2871 | delay = 1000; |
| 2872 | retry = 1; |
| 2873 | break; |
| 2874 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2875 | case LSRJT_PROTOCOL_ERR: |
| 2876 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
| 2877 | (cmd == ELS_CMD_FDISC) && |
| 2878 | ((stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_PNAME) || |
| 2879 | (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID)) |
| 2880 | ) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2881 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 2882 | "0122 FDISC Failed (x%x). " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2883 | "Fabric Detected Bad WWN\n", |
| 2884 | stat.un.lsRjtError); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2885 | lpfc_vport_set_state(vport, |
| 2886 | FC_VPORT_FABRIC_REJ_WWN); |
| 2887 | } |
| 2888 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2889 | } |
| 2890 | break; |
| 2891 | |
| 2892 | case IOSTAT_INTERMED_RSP: |
| 2893 | case IOSTAT_BA_RJT: |
| 2894 | break; |
| 2895 | |
| 2896 | default: |
| 2897 | break; |
| 2898 | } |
| 2899 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2900 | if (did == FDMI_DID) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2901 | retry = 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2902 | |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 2903 | if (((cmd == ELS_CMD_FLOGI) || (cmd == ELS_CMD_FDISC)) && |
James Smart | 1b32f6a | 2008-02-08 18:49:39 -0500 | [diff] [blame] | 2904 | (phba->fc_topology != TOPOLOGY_LOOP) && |
| 2905 | !lpfc_error_lost_link(irsp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 2906 | /* FLOGI retry policy */ |
| 2907 | retry = 1; |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 2908 | /* retry forever */ |
| 2909 | maxretry = 0; |
| 2910 | if (cmdiocb->retry >= 100) |
| 2911 | delay = 5000; |
| 2912 | else if (cmdiocb->retry >= 32) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 2913 | delay = 1000; |
| 2914 | } |
| 2915 | |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 2916 | cmdiocb->retry++; |
| 2917 | if (maxretry && (cmdiocb->retry >= maxretry)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2918 | phba->fc_stat.elsRetryExceeded++; |
| 2919 | retry = 0; |
| 2920 | } |
| 2921 | |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 2922 | if ((vport->load_flag & FC_UNLOADING) != 0) |
| 2923 | retry = 0; |
| 2924 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2925 | if (retry) { |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 2926 | if ((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_FDISC)) { |
| 2927 | /* Stop retrying PLOGI and FDISC if in FCF discovery */ |
| 2928 | if (phba->fcf.fcf_flag & FCF_DISCOVERY) { |
| 2929 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2930 | "2849 Stop retry ELS command " |
| 2931 | "x%x to remote NPORT x%x, " |
| 2932 | "Data: x%x x%x\n", cmd, did, |
| 2933 | cmdiocb->retry, delay); |
| 2934 | return 0; |
| 2935 | } |
| 2936 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2937 | |
| 2938 | /* Retry ELS command <elsCmd> to remote NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2939 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 2940 | "0107 Retry ELS command x%x to remote " |
| 2941 | "NPORT x%x Data: x%x x%x\n", |
| 2942 | cmd, did, cmdiocb->retry, delay); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2943 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2944 | if (((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_ADISC)) && |
| 2945 | ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || |
| 2946 | ((irsp->un.ulpWord[4] & 0xff) != IOERR_NO_RESOURCES))) { |
| 2947 | /* Don't reset timer for no resources */ |
| 2948 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2949 | /* If discovery / RSCN timer is running, reset it */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2950 | if (timer_pending(&vport->fc_disctmo) || |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2951 | (vport->fc_flag & FC_RSCN_MODE)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2952 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2953 | } |
| 2954 | |
| 2955 | phba->fc_stat.elsXmitRetry++; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 2956 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && delay) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2957 | phba->fc_stat.elsDelayRetry++; |
| 2958 | ndlp->nlp_retry = cmdiocb->retry; |
| 2959 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2960 | /* delay is specified in milliseconds */ |
| 2961 | mod_timer(&ndlp->nlp_delayfunc, |
| 2962 | jiffies + msecs_to_jiffies(delay)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2963 | spin_lock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2964 | ndlp->nlp_flag |= NLP_DELAY_TMO; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2965 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2966 | |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 2967 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 2968 | if (cmd == ELS_CMD_PRLI) |
| 2969 | lpfc_nlp_set_state(vport, ndlp, |
| 2970 | NLP_STE_REG_LOGIN_ISSUE); |
| 2971 | else |
| 2972 | lpfc_nlp_set_state(vport, ndlp, |
| 2973 | NLP_STE_NPR_NODE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2974 | ndlp->nlp_last_elscmd = cmd; |
| 2975 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2976 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2977 | } |
| 2978 | switch (cmd) { |
| 2979 | case ELS_CMD_FLOGI: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2980 | lpfc_issue_els_flogi(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2981 | return 1; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2982 | case ELS_CMD_FDISC: |
| 2983 | lpfc_issue_els_fdisc(vport, ndlp, cmdiocb->retry); |
| 2984 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2985 | case ELS_CMD_PLOGI: |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 2986 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2987 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2988 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | de0c5b3 | 2007-04-25 09:52:27 -0400 | [diff] [blame] | 2989 | NLP_STE_PLOGI_ISSUE); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 2990 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2991 | lpfc_issue_els_plogi(vport, did, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2992 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2993 | case ELS_CMD_ADISC: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 2994 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2995 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE); |
| 2996 | lpfc_issue_els_adisc(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 2997 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2998 | case ELS_CMD_PRLI: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 2999 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3000 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE); |
| 3001 | lpfc_issue_els_prli(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3002 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3003 | case ELS_CMD_LOGO: |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3004 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3005 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 3006 | lpfc_issue_els_logo(vport, ndlp, cmdiocb->retry); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3007 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3008 | } |
| 3009 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3010 | /* No retry ELS command <elsCmd> to remote NPORT <did> */ |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3011 | if (logerr) { |
| 3012 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3013 | "0137 No retry ELS command x%x to remote " |
| 3014 | "NPORT x%x: Out of Resources: Error:x%x/%x\n", |
| 3015 | cmd, did, irsp->ulpStatus, |
| 3016 | irsp->un.ulpWord[4]); |
| 3017 | } |
| 3018 | else { |
| 3019 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 3020 | "0108 No retry ELS command x%x to remote " |
| 3021 | "NPORT x%x Retried:%d Error:x%x/%x\n", |
| 3022 | cmd, did, cmdiocb->retry, irsp->ulpStatus, |
| 3023 | irsp->un.ulpWord[4]); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3024 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3025 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3026 | } |
| 3027 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3028 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3029 | * 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] | 3030 | * @phba: pointer to lpfc hba data structure. |
| 3031 | * @buf_ptr1: pointer to the lpfc DMA buffer data structure. |
| 3032 | * |
| 3033 | * This routine releases the lpfc DMA (Direct Memory Access) buffer(s) |
| 3034 | * associated with a command IOCB back to the lpfc DMA buffer pool. It first |
| 3035 | * checks to see whether there is a lpfc DMA buffer associated with the |
| 3036 | * response of the command IOCB. If so, it will be released before releasing |
| 3037 | * the lpfc DMA buffer associated with the IOCB itself. |
| 3038 | * |
| 3039 | * Return code |
| 3040 | * 0 - Successfully released lpfc DMA buffer (currently, always return 0) |
| 3041 | **/ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3042 | static int |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3043 | lpfc_els_free_data(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr1) |
| 3044 | { |
| 3045 | struct lpfc_dmabuf *buf_ptr; |
| 3046 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3047 | /* Free the response before processing the command. */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3048 | if (!list_empty(&buf_ptr1->list)) { |
| 3049 | list_remove_head(&buf_ptr1->list, buf_ptr, |
| 3050 | struct lpfc_dmabuf, |
| 3051 | list); |
| 3052 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 3053 | kfree(buf_ptr); |
| 3054 | } |
| 3055 | lpfc_mbuf_free(phba, buf_ptr1->virt, buf_ptr1->phys); |
| 3056 | kfree(buf_ptr1); |
| 3057 | return 0; |
| 3058 | } |
| 3059 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3060 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3061 | * 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] | 3062 | * @phba: pointer to lpfc hba data structure. |
| 3063 | * @buf_ptr: pointer to the lpfc dma buffer data structure. |
| 3064 | * |
| 3065 | * This routine releases the lpfc Direct Memory Access (DMA) buffer |
| 3066 | * associated with a Buffer Pointer List (BPL) back to the lpfc DMA buffer |
| 3067 | * pool. |
| 3068 | * |
| 3069 | * Return code |
| 3070 | * 0 - Successfully released lpfc DMA buffer (currently, always return 0) |
| 3071 | **/ |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 3072 | static int |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3073 | lpfc_els_free_bpl(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr) |
| 3074 | { |
| 3075 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 3076 | kfree(buf_ptr); |
| 3077 | return 0; |
| 3078 | } |
| 3079 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3080 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3081 | * lpfc_els_free_iocb - Free a command iocb and its associated resources |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3082 | * @phba: pointer to lpfc hba data structure. |
| 3083 | * @elsiocb: pointer to lpfc els command iocb data structure. |
| 3084 | * |
| 3085 | * This routine frees a command IOCB and its associated resources. The |
| 3086 | * command IOCB data structure contains the reference to various associated |
| 3087 | * resources, these fields must be set to NULL if the associated reference |
| 3088 | * not present: |
| 3089 | * context1 - reference to ndlp |
| 3090 | * context2 - reference to cmd |
| 3091 | * context2->next - reference to rsp |
| 3092 | * context3 - reference to bpl |
| 3093 | * |
| 3094 | * It first properly decrements the reference count held on ndlp for the |
| 3095 | * IOCB completion callback function. If LPFC_DELAY_MEM_FREE flag is not |
| 3096 | * set, it invokes the lpfc_els_free_data() routine to release the Direct |
| 3097 | * Memory Access (DMA) buffers associated with the IOCB. Otherwise, it |
| 3098 | * adds the DMA buffer the @phba data structure for the delayed release. |
| 3099 | * If reference to the Buffer Pointer List (BPL) is present, the |
| 3100 | * lpfc_els_free_bpl() routine is invoked to release the DMA memory |
| 3101 | * associated with BPL. Finally, the lpfc_sli_release_iocbq() routine is |
| 3102 | * invoked to release the IOCB data structure back to @phba IOCBQ list. |
| 3103 | * |
| 3104 | * Return code |
| 3105 | * 0 - Success (currently, always return 0) |
| 3106 | **/ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3107 | int |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3108 | lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3109 | { |
| 3110 | struct lpfc_dmabuf *buf_ptr, *buf_ptr1; |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3111 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3112 | |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3113 | ndlp = (struct lpfc_nodelist *)elsiocb->context1; |
| 3114 | if (ndlp) { |
| 3115 | if (ndlp->nlp_flag & NLP_DEFER_RM) { |
| 3116 | lpfc_nlp_put(ndlp); |
| 3117 | |
| 3118 | /* If the ndlp is not being used by another discovery |
| 3119 | * thread, free it. |
| 3120 | */ |
| 3121 | if (!lpfc_nlp_not_used(ndlp)) { |
| 3122 | /* If ndlp is being used by another discovery |
| 3123 | * thread, just clear NLP_DEFER_RM |
| 3124 | */ |
| 3125 | ndlp->nlp_flag &= ~NLP_DEFER_RM; |
| 3126 | } |
| 3127 | } |
| 3128 | else |
| 3129 | lpfc_nlp_put(ndlp); |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3130 | elsiocb->context1 = NULL; |
| 3131 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3132 | /* context2 = cmd, context2->next = rsp, context3 = bpl */ |
| 3133 | if (elsiocb->context2) { |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 3134 | if (elsiocb->iocb_flag & LPFC_DELAY_MEM_FREE) { |
| 3135 | /* Firmware could still be in progress of DMAing |
| 3136 | * payload, so don't free data buffer till after |
| 3137 | * a hbeat. |
| 3138 | */ |
| 3139 | elsiocb->iocb_flag &= ~LPFC_DELAY_MEM_FREE; |
| 3140 | buf_ptr = elsiocb->context2; |
| 3141 | elsiocb->context2 = NULL; |
| 3142 | if (buf_ptr) { |
| 3143 | buf_ptr1 = NULL; |
| 3144 | spin_lock_irq(&phba->hbalock); |
| 3145 | if (!list_empty(&buf_ptr->list)) { |
| 3146 | list_remove_head(&buf_ptr->list, |
| 3147 | buf_ptr1, struct lpfc_dmabuf, |
| 3148 | list); |
| 3149 | INIT_LIST_HEAD(&buf_ptr1->list); |
| 3150 | list_add_tail(&buf_ptr1->list, |
| 3151 | &phba->elsbuf); |
| 3152 | phba->elsbuf_cnt++; |
| 3153 | } |
| 3154 | INIT_LIST_HEAD(&buf_ptr->list); |
| 3155 | list_add_tail(&buf_ptr->list, &phba->elsbuf); |
| 3156 | phba->elsbuf_cnt++; |
| 3157 | spin_unlock_irq(&phba->hbalock); |
| 3158 | } |
| 3159 | } else { |
| 3160 | buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2; |
| 3161 | lpfc_els_free_data(phba, buf_ptr1); |
| 3162 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3163 | } |
| 3164 | |
| 3165 | if (elsiocb->context3) { |
| 3166 | buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3167 | lpfc_els_free_bpl(phba, buf_ptr); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3168 | } |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 3169 | lpfc_sli_release_iocbq(phba, elsiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3170 | return 0; |
| 3171 | } |
| 3172 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3173 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3174 | * lpfc_cmpl_els_logo_acc - Completion callback function to logo acc response |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3175 | * @phba: pointer to lpfc hba data structure. |
| 3176 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 3177 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 3178 | * |
| 3179 | * This routine is the completion callback function to the Logout (LOGO) |
| 3180 | * Accept (ACC) Response ELS command. This routine is invoked to indicate |
| 3181 | * the completion of the LOGO process. It invokes the lpfc_nlp_not_used() to |
| 3182 | * release the ndlp if it has the last reference remaining (reference count |
| 3183 | * is 1). If succeeded (meaning ndlp released), it sets the IOCB context1 |
| 3184 | * field to NULL to inform the following lpfc_els_free_iocb() routine no |
| 3185 | * ndlp reference count needs to be decremented. Otherwise, the ndlp |
| 3186 | * reference use-count shall be decremented by the lpfc_els_free_iocb() |
| 3187 | * routine. Finally, the lpfc_els_free_iocb() is invoked to release the |
| 3188 | * IOCB data structure. |
| 3189 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3190 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3191 | lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 3192 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3193 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3194 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 3195 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3196 | IOCB_t *irsp; |
| 3197 | |
| 3198 | irsp = &rspiocb->iocb; |
| 3199 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3200 | "ACC LOGO cmpl: status:x%x/x%x did:x%x", |
| 3201 | irsp->ulpStatus, irsp->un.ulpWord[4], ndlp->nlp_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3202 | /* ACC to LOGO completes to NPort <nlp_DID> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3203 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3204 | "0109 ACC to LOGO completes to NPort x%x " |
| 3205 | "Data: x%x x%x x%x\n", |
| 3206 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3207 | ndlp->nlp_rpi); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3208 | |
| 3209 | if (ndlp->nlp_state == NLP_STE_NPR_NODE) { |
| 3210 | /* NPort Recovery mode or node is just allocated */ |
| 3211 | if (!lpfc_nlp_not_used(ndlp)) { |
| 3212 | /* If the ndlp is being used by another discovery |
| 3213 | * thread, just unregister the RPI. |
| 3214 | */ |
| 3215 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3216 | } else { |
| 3217 | /* Indicate the node has already released, should |
| 3218 | * not reference to it from within lpfc_els_free_iocb. |
| 3219 | */ |
| 3220 | cmdiocb->context1 = NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3221 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3222 | } |
| 3223 | lpfc_els_free_iocb(phba, cmdiocb); |
| 3224 | return; |
| 3225 | } |
| 3226 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3227 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3228 | * 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] | 3229 | * @phba: pointer to lpfc hba data structure. |
| 3230 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 3231 | * |
| 3232 | * This routine is the completion callback function for unregister default |
| 3233 | * RPI (Remote Port Index) mailbox command to the @phba. It simply releases |
| 3234 | * the associated lpfc Direct Memory Access (DMA) buffer back to the pool and |
| 3235 | * decrements the ndlp reference count held for this completion callback |
| 3236 | * function. After that, it invokes the lpfc_nlp_not_used() to check |
| 3237 | * whether there is only one reference left on the ndlp. If so, it will |
| 3238 | * perform one more decrement and trigger the release of the ndlp. |
| 3239 | **/ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3240 | void |
| 3241 | lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
| 3242 | { |
| 3243 | struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1); |
| 3244 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2; |
| 3245 | |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 3246 | /* |
| 3247 | * This routine is used to register and unregister in previous SLI |
| 3248 | * modes. |
| 3249 | */ |
| 3250 | if ((pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) && |
| 3251 | (phba->sli_rev == LPFC_SLI_REV4)) |
| 3252 | lpfc_sli4_free_rpi(phba, pmb->u.mb.un.varUnregLogin.rpi); |
| 3253 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3254 | pmb->context1 = NULL; |
James Smart | d439d28 | 2010-09-29 11:18:45 -0400 | [diff] [blame] | 3255 | pmb->context2 = NULL; |
| 3256 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3257 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3258 | kfree(mp); |
| 3259 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3260 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3261 | lpfc_nlp_put(ndlp); |
James Smart | a8adb83 | 2007-10-27 13:37:53 -0400 | [diff] [blame] | 3262 | /* This is the end of the default RPI cleanup logic for this |
| 3263 | * ndlp. If no other discovery threads are using this ndlp. |
| 3264 | * we should free all resources associated with it. |
| 3265 | */ |
| 3266 | lpfc_nlp_not_used(ndlp); |
| 3267 | } |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 3268 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3269 | return; |
| 3270 | } |
| 3271 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3272 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3273 | * lpfc_cmpl_els_rsp - Completion callback function for els response iocb cmd |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3274 | * @phba: pointer to lpfc hba data structure. |
| 3275 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 3276 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 3277 | * |
| 3278 | * This routine is the completion callback function for ELS Response IOCB |
| 3279 | * command. In normal case, this callback function just properly sets the |
| 3280 | * nlp_flag bitmap in the ndlp data structure, if the mbox command reference |
| 3281 | * field in the command IOCB is not NULL, the referred mailbox command will |
| 3282 | * be send out, and then invokes the lpfc_els_free_iocb() routine to release |
| 3283 | * the IOCB. Under error conditions, such as when a LS_RJT is returned or a |
| 3284 | * link down event occurred during the discovery, the lpfc_nlp_not_used() |
| 3285 | * routine shall be invoked trying to release the ndlp if no other threads |
| 3286 | * are currently referring it. |
| 3287 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3288 | static void |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3289 | lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3290 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3291 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3292 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 3293 | struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL; |
| 3294 | struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3295 | IOCB_t *irsp; |
| 3296 | uint8_t *pcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3297 | LPFC_MBOXQ_t *mbox = NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3298 | struct lpfc_dmabuf *mp = NULL; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3299 | uint32_t ls_rjt = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3300 | |
James Smart | 33ccf8d | 2006-08-17 11:57:58 -0400 | [diff] [blame] | 3301 | irsp = &rspiocb->iocb; |
| 3302 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3303 | if (cmdiocb->context_un.mbox) |
| 3304 | mbox = cmdiocb->context_un.mbox; |
| 3305 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3306 | /* First determine if this is a LS_RJT cmpl. Note, this callback |
| 3307 | * function can have cmdiocb->contest1 (ndlp) field set to NULL. |
| 3308 | */ |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3309 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3310 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 3311 | (*((uint32_t *) (pcmd)) == ELS_CMD_LS_RJT)) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3312 | /* A LS_RJT associated with Default RPI cleanup has its own |
Daniel Mack | 3ad2f3f | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 3313 | * separate code path. |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3314 | */ |
| 3315 | if (!(ndlp->nlp_flag & NLP_RM_DFLT_RPI)) |
| 3316 | ls_rjt = 1; |
| 3317 | } |
| 3318 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3319 | /* Check to see if link went down during discovery */ |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3320 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) || lpfc_els_chk_latt(vport)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3321 | if (mbox) { |
James Smart | 1469115 | 2006-12-02 13:34:28 -0500 | [diff] [blame] | 3322 | mp = (struct lpfc_dmabuf *) mbox->context1; |
| 3323 | if (mp) { |
| 3324 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3325 | kfree(mp); |
| 3326 | } |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3327 | mempool_free(mbox, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3328 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3329 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) && |
| 3330 | (ndlp->nlp_flag & NLP_RM_DFLT_RPI)) |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3331 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3332 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3333 | /* Indicate the node has already released, |
| 3334 | * should not reference to it from within |
| 3335 | * the routine lpfc_els_free_iocb. |
| 3336 | */ |
| 3337 | cmdiocb->context1 = NULL; |
| 3338 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3339 | goto out; |
| 3340 | } |
| 3341 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3342 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3343 | "ELS rsp cmpl: status:x%x/x%x did:x%x", |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3344 | irsp->ulpStatus, irsp->un.ulpWord[4], |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3345 | cmdiocb->iocb.un.elsreq64.remoteID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3346 | /* ELS response tag <ulpIoTag> completes */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3347 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3348 | "0110 ELS response tag x%x completes " |
| 3349 | "Data: x%x x%x x%x x%x x%x x%x x%x\n", |
| 3350 | cmdiocb->iocb.ulpIoTag, rspiocb->iocb.ulpStatus, |
| 3351 | rspiocb->iocb.un.ulpWord[4], rspiocb->iocb.ulpTimeout, |
| 3352 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3353 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3354 | if (mbox) { |
| 3355 | if ((rspiocb->iocb.ulpStatus == 0) |
| 3356 | && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3357 | lpfc_unreg_rpi(vport, ndlp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3358 | /* Increment reference count to ndlp to hold the |
| 3359 | * reference to ndlp for the callback function. |
| 3360 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3361 | mbox->context2 = lpfc_nlp_get(ndlp); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3362 | mbox->vport = vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3363 | if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) { |
| 3364 | mbox->mbox_flag |= LPFC_MBX_IMED_UNREG; |
| 3365 | mbox->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi; |
| 3366 | } |
| 3367 | else { |
| 3368 | mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; |
| 3369 | ndlp->nlp_prev_state = ndlp->nlp_state; |
| 3370 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3371 | NLP_STE_REG_LOGIN_ISSUE); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3372 | } |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 3373 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3374 | != MBX_NOT_FINISHED) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3375 | goto out; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 3376 | else |
| 3377 | /* Decrement the ndlp reference count we |
| 3378 | * set for this failed mailbox command. |
| 3379 | */ |
| 3380 | lpfc_nlp_put(ndlp); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3381 | |
| 3382 | /* ELS rsp: Cannot issue reg_login for <NPortid> */ |
| 3383 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 3384 | "0138 ELS rsp: Cannot issue reg_login for x%x " |
| 3385 | "Data: x%x x%x x%x\n", |
| 3386 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3387 | ndlp->nlp_rpi); |
| 3388 | |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3389 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3390 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3391 | /* Indicate node has already been released, |
| 3392 | * should not reference to it from within |
| 3393 | * the routine lpfc_els_free_iocb. |
| 3394 | */ |
| 3395 | cmdiocb->context1 = NULL; |
| 3396 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3397 | } else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3398 | /* Do not drop node for lpfc_els_abort'ed ELS cmds */ |
| 3399 | if (!lpfc_error_lost_link(irsp) && |
| 3400 | ndlp->nlp_flag & NLP_ACC_REGLOGIN) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3401 | if (lpfc_nlp_not_used(ndlp)) { |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 3402 | ndlp = NULL; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3403 | /* Indicate node has already been |
| 3404 | * released, should not reference |
| 3405 | * to it from within the routine |
| 3406 | * lpfc_els_free_iocb. |
| 3407 | */ |
| 3408 | cmdiocb->context1 = NULL; |
| 3409 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3410 | } |
| 3411 | } |
James Smart | 1469115 | 2006-12-02 13:34:28 -0500 | [diff] [blame] | 3412 | mp = (struct lpfc_dmabuf *) mbox->context1; |
| 3413 | if (mp) { |
| 3414 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 3415 | kfree(mp); |
| 3416 | } |
| 3417 | mempool_free(mbox, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3418 | } |
| 3419 | out: |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 3420 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3421 | spin_lock_irq(shost->host_lock); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3422 | ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3423 | spin_unlock_irq(shost->host_lock); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3424 | |
| 3425 | /* If the node is not being used by another discovery thread, |
| 3426 | * and we are sending a reject, we are done with it. |
| 3427 | * Release driver reference count here and free associated |
| 3428 | * resources. |
| 3429 | */ |
| 3430 | if (ls_rjt) |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 3431 | if (lpfc_nlp_not_used(ndlp)) |
| 3432 | /* Indicate node has already been released, |
| 3433 | * should not reference to it from within |
| 3434 | * the routine lpfc_els_free_iocb. |
| 3435 | */ |
| 3436 | cmdiocb->context1 = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3437 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 3438 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3439 | lpfc_els_free_iocb(phba, cmdiocb); |
| 3440 | return; |
| 3441 | } |
| 3442 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3443 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3444 | * lpfc_els_rsp_acc - Prepare and issue an acc response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3445 | * @vport: pointer to a host virtual N_Port data structure. |
| 3446 | * @flag: the els command code to be accepted. |
| 3447 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 3448 | * @ndlp: pointer to a node-list data structure. |
| 3449 | * @mbox: pointer to the driver internal queue element for mailbox command. |
| 3450 | * |
| 3451 | * This routine prepares and issues an Accept (ACC) response IOCB |
| 3452 | * command. It uses the @flag to properly set up the IOCB field for the |
| 3453 | * specific ACC response command to be issued and invokes the |
| 3454 | * lpfc_sli_issue_iocb() routine to send out ACC response IOCB. If a |
| 3455 | * @mbox pointer is passed in, it will be put into the context_un.mbox |
| 3456 | * field of the IOCB for the completion callback function to issue the |
| 3457 | * mailbox command to the HBA later when callback is invoked. |
| 3458 | * |
| 3459 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 3460 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 3461 | * will be stored into the context1 field of the IOCB for the completion |
| 3462 | * callback function to the corresponding response ELS IOCB command. |
| 3463 | * |
| 3464 | * Return code |
| 3465 | * 0 - Successfully issued acc response |
| 3466 | * 1 - Failed to issue acc response |
| 3467 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3468 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3469 | lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, |
| 3470 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3471 | LPFC_MBOXQ_t *mbox) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3472 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3473 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 3474 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3475 | IOCB_t *icmd; |
| 3476 | IOCB_t *oldcmd; |
| 3477 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3478 | struct lpfc_sli *psli; |
| 3479 | uint8_t *pcmd; |
| 3480 | uint16_t cmdsize; |
| 3481 | int rc; |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3482 | ELS_PKT *els_pkt_ptr; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3483 | |
| 3484 | psli = &phba->sli; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3485 | oldcmd = &oldiocb->iocb; |
| 3486 | |
| 3487 | switch (flag) { |
| 3488 | case ELS_CMD_ACC: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3489 | cmdsize = sizeof(uint32_t); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3490 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
| 3491 | ndlp, ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3492 | if (!elsiocb) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3493 | spin_lock_irq(shost->host_lock); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 3494 | ndlp->nlp_flag &= ~NLP_LOGO_ACC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3495 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3496 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3497 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3498 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3499 | icmd = &elsiocb->iocb; |
| 3500 | icmd->ulpContext = oldcmd->ulpContext; /* Xri */ |
| 3501 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3502 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3503 | pcmd += sizeof(uint32_t); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3504 | |
| 3505 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3506 | "Issue ACC: did:x%x flg:x%x", |
| 3507 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3508 | break; |
| 3509 | case ELS_CMD_PLOGI: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3510 | cmdsize = (sizeof(struct serv_parm) + sizeof(uint32_t)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3511 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
| 3512 | ndlp, ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3513 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3514 | return 1; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3515 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3516 | icmd = &elsiocb->iocb; |
| 3517 | icmd->ulpContext = oldcmd->ulpContext; /* Xri */ |
| 3518 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3519 | |
| 3520 | if (mbox) |
| 3521 | elsiocb->context_un.mbox = mbox; |
| 3522 | |
| 3523 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3524 | pcmd += sizeof(uint32_t); |
| 3525 | memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3526 | |
| 3527 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3528 | "Issue ACC PLOGI: did:x%x flg:x%x", |
| 3529 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3530 | break; |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3531 | case ELS_CMD_PRLO: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3532 | cmdsize = sizeof(uint32_t) + sizeof(PRLO); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3533 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3534 | ndlp, ndlp->nlp_DID, ELS_CMD_PRLO); |
| 3535 | if (!elsiocb) |
| 3536 | return 1; |
| 3537 | |
| 3538 | icmd = &elsiocb->iocb; |
| 3539 | icmd->ulpContext = oldcmd->ulpContext; /* Xri */ |
| 3540 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3541 | |
| 3542 | memcpy(pcmd, ((struct lpfc_dmabuf *) oldiocb->context2)->virt, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3543 | sizeof(uint32_t) + sizeof(PRLO)); |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3544 | *((uint32_t *) (pcmd)) = ELS_CMD_PRLO_ACC; |
| 3545 | els_pkt_ptr = (ELS_PKT *) pcmd; |
| 3546 | els_pkt_ptr->un.prlo.acceptRspCode = PRLO_REQ_EXECUTED; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3547 | |
| 3548 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3549 | "Issue ACC PRLO: did:x%x flg:x%x", |
| 3550 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
James Smart | 82d9a2a | 2006-04-15 11:53:05 -0400 | [diff] [blame] | 3551 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3552 | default: |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3553 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3554 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3555 | /* Xmit ELS ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3556 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3557 | "0128 Xmit ELS ACC response tag x%x, XRI: x%x, " |
| 3558 | "DID: x%x, nlp_flag: x%x nlp_state: x%x RPI: x%x\n", |
| 3559 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 3560 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3561 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3562 | if (ndlp->nlp_flag & NLP_LOGO_ACC) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3563 | spin_lock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3564 | ndlp->nlp_flag &= ~NLP_LOGO_ACC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3565 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3566 | elsiocb->iocb_cmpl = lpfc_cmpl_els_logo_acc; |
| 3567 | } else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3568 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3569 | } |
| 3570 | |
| 3571 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 3572 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3573 | if (rc == IOCB_ERROR) { |
| 3574 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3575 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3576 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3577 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3578 | } |
| 3579 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3580 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3581 | * lpfc_els_rsp_reject - Propare and issue a rjt response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3582 | * @vport: pointer to a virtual N_Port data structure. |
| 3583 | * @rejectError: |
| 3584 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 3585 | * @ndlp: pointer to a node-list data structure. |
| 3586 | * @mbox: pointer to the driver internal queue element for mailbox command. |
| 3587 | * |
| 3588 | * This routine prepares and issue an Reject (RJT) response IOCB |
| 3589 | * command. If a @mbox pointer is passed in, it will be put into the |
| 3590 | * context_un.mbox field of the IOCB for the completion callback function |
| 3591 | * to issue to the HBA later. |
| 3592 | * |
| 3593 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 3594 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 3595 | * will be stored into the context1 field of the IOCB for the completion |
| 3596 | * callback function to the reject response ELS IOCB command. |
| 3597 | * |
| 3598 | * Return code |
| 3599 | * 0 - Successfully issued reject response |
| 3600 | * 1 - Failed to issue reject response |
| 3601 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3602 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3603 | lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3604 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, |
| 3605 | LPFC_MBOXQ_t *mbox) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3606 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3607 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3608 | IOCB_t *icmd; |
| 3609 | IOCB_t *oldcmd; |
| 3610 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3611 | struct lpfc_sli *psli; |
| 3612 | uint8_t *pcmd; |
| 3613 | uint16_t cmdsize; |
| 3614 | int rc; |
| 3615 | |
| 3616 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3617 | cmdsize = 2 * sizeof(uint32_t); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3618 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 3619 | ndlp->nlp_DID, ELS_CMD_LS_RJT); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3620 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3621 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3622 | |
| 3623 | icmd = &elsiocb->iocb; |
| 3624 | oldcmd = &oldiocb->iocb; |
| 3625 | icmd->ulpContext = oldcmd->ulpContext; /* Xri */ |
| 3626 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3627 | |
| 3628 | *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3629 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3630 | *((uint32_t *) (pcmd)) = rejectError; |
| 3631 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3632 | if (mbox) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3633 | elsiocb->context_un.mbox = mbox; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3634 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3635 | /* Xmit ELS RJT <err> response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3636 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3637 | "0129 Xmit ELS RJT x%x response tag x%x " |
| 3638 | "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " |
| 3639 | "rpi x%x\n", |
| 3640 | rejectError, elsiocb->iotag, |
| 3641 | elsiocb->iocb.ulpContext, ndlp->nlp_DID, |
| 3642 | ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3643 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3644 | "Issue LS_RJT: did:x%x flg:x%x err:x%x", |
| 3645 | ndlp->nlp_DID, ndlp->nlp_flag, rejectError); |
| 3646 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3647 | phba->fc_stat.elsXmitLSRJT++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3648 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 3649 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 3650 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3651 | if (rc == IOCB_ERROR) { |
| 3652 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3653 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3654 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3655 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3656 | } |
| 3657 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3658 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3659 | * 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] | 3660 | * @vport: pointer to a virtual N_Port data structure. |
| 3661 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 3662 | * @ndlp: pointer to a node-list data structure. |
| 3663 | * |
| 3664 | * This routine prepares and issues an Accept (ACC) response to Address |
| 3665 | * Discover (ADISC) ELS command. It simply prepares the payload of the IOCB |
| 3666 | * and invokes the lpfc_sli_issue_iocb() routine to send out the command. |
| 3667 | * |
| 3668 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 3669 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 3670 | * will be stored into the context1 field of the IOCB for the completion |
| 3671 | * callback function to the ADISC Accept response ELS IOCB command. |
| 3672 | * |
| 3673 | * Return code |
| 3674 | * 0 - Successfully issued acc adisc response |
| 3675 | * 1 - Failed to issue adisc acc response |
| 3676 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3677 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3678 | lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, |
| 3679 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3680 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3681 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3682 | ADISC *ap; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3683 | IOCB_t *icmd, *oldcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3684 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3685 | uint8_t *pcmd; |
| 3686 | uint16_t cmdsize; |
| 3687 | int rc; |
| 3688 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3689 | cmdsize = sizeof(uint32_t) + sizeof(ADISC); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3690 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 3691 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3692 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3693 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3694 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3695 | icmd = &elsiocb->iocb; |
| 3696 | oldcmd = &oldiocb->iocb; |
| 3697 | icmd->ulpContext = oldcmd->ulpContext; /* Xri */ |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 3698 | |
| 3699 | /* Xmit ADISC ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3700 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3701 | "0130 Xmit ADISC ACC response iotag x%x xri: " |
| 3702 | "x%x, did x%x, nlp_flag x%x, nlp_state x%x rpi x%x\n", |
| 3703 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 3704 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3705 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3706 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3707 | |
| 3708 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3709 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3710 | |
| 3711 | ap = (ADISC *) (pcmd); |
| 3712 | ap->hardAL_PA = phba->fc_pref_ALPA; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3713 | memcpy(&ap->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 3714 | memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3715 | ap->DID = be32_to_cpu(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3716 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3717 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3718 | "Issue ACC ADISC: did:x%x flg:x%x", |
| 3719 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 3720 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3721 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3722 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 3723 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3724 | if (rc == IOCB_ERROR) { |
| 3725 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3726 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3727 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3728 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3729 | } |
| 3730 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3731 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3732 | * 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] | 3733 | * @vport: pointer to a virtual N_Port data structure. |
| 3734 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 3735 | * @ndlp: pointer to a node-list data structure. |
| 3736 | * |
| 3737 | * This routine prepares and issues an Accept (ACC) response to Process |
| 3738 | * Login (PRLI) ELS command. It simply prepares the payload of the IOCB |
| 3739 | * and invokes the lpfc_sli_issue_iocb() routine to send out the command. |
| 3740 | * |
| 3741 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 3742 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 3743 | * will be stored into the context1 field of the IOCB for the completion |
| 3744 | * callback function to the PRLI Accept response ELS IOCB command. |
| 3745 | * |
| 3746 | * Return code |
| 3747 | * 0 - Successfully issued acc prli response |
| 3748 | * 1 - Failed to issue acc prli response |
| 3749 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3750 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3751 | 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] | 3752 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3753 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3754 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3755 | PRLI *npr; |
| 3756 | lpfc_vpd_t *vpd; |
| 3757 | IOCB_t *icmd; |
| 3758 | IOCB_t *oldcmd; |
| 3759 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3760 | struct lpfc_sli *psli; |
| 3761 | uint8_t *pcmd; |
| 3762 | uint16_t cmdsize; |
| 3763 | int rc; |
| 3764 | |
| 3765 | psli = &phba->sli; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3766 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3767 | cmdsize = sizeof(uint32_t) + sizeof(PRLI); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3768 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3769 | ndlp->nlp_DID, (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK))); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3770 | if (!elsiocb) |
| 3771 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3772 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3773 | icmd = &elsiocb->iocb; |
| 3774 | oldcmd = &oldiocb->iocb; |
| 3775 | icmd->ulpContext = oldcmd->ulpContext; /* Xri */ |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 3776 | /* Xmit PRLI ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3777 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3778 | "0131 Xmit PRLI ACC response tag x%x xri x%x, " |
| 3779 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", |
| 3780 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 3781 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 3782 | ndlp->nlp_rpi); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3783 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 3784 | |
| 3785 | *((uint32_t *) (pcmd)) = (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3786 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3787 | |
| 3788 | /* For PRLI, remainder of payload is PRLI parameter page */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3789 | memset(pcmd, 0, sizeof(PRLI)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3790 | |
| 3791 | npr = (PRLI *) pcmd; |
| 3792 | vpd = &phba->vpd; |
| 3793 | /* |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 3794 | * If the remote port is a target and our firmware version is 3.20 or |
| 3795 | * later, set the following bits for FC-TAPE support. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3796 | */ |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 3797 | if ((ndlp->nlp_type & NLP_FCP_TARGET) && |
| 3798 | (vpd->rev.feaLevelHigh >= 0x02)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3799 | npr->ConfmComplAllowed = 1; |
| 3800 | npr->Retry = 1; |
| 3801 | npr->TaskRetryIdReq = 1; |
| 3802 | } |
| 3803 | |
| 3804 | npr->acceptRspCode = PRLI_REQ_EXECUTED; |
| 3805 | npr->estabImagePair = 1; |
| 3806 | npr->readXferRdyDis = 1; |
| 3807 | npr->ConfmComplAllowed = 1; |
| 3808 | |
| 3809 | npr->prliType = PRLI_FCP_TYPE; |
| 3810 | npr->initiatorFunc = 1; |
| 3811 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3812 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3813 | "Issue ACC PRLI: did:x%x flg:x%x", |
| 3814 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 3815 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3816 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3817 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3818 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 3819 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3820 | if (rc == IOCB_ERROR) { |
| 3821 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3822 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3823 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3824 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3825 | } |
| 3826 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3827 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3828 | * lpfc_els_rsp_rnid_acc - Issue rnid acc response iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3829 | * @vport: pointer to a virtual N_Port data structure. |
| 3830 | * @format: rnid command format. |
| 3831 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 3832 | * @ndlp: pointer to a node-list data structure. |
| 3833 | * |
| 3834 | * This routine issues a Request Node Identification Data (RNID) Accept |
| 3835 | * (ACC) response. It constructs the RNID ACC response command according to |
| 3836 | * the proper @format and then calls the lpfc_sli_issue_iocb() routine to |
| 3837 | * issue the response. Note that this command does not need to hold the ndlp |
| 3838 | * reference count for the callback. So, the ndlp reference count taken by |
| 3839 | * the lpfc_prep_els_iocb() routine is put back and the context1 field of |
| 3840 | * IOCB is set to NULL to indicate to the lpfc_els_free_iocb() routine that |
| 3841 | * there is no ndlp reference available. |
| 3842 | * |
| 3843 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 3844 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 3845 | * will be stored into the context1 field of the IOCB for the completion |
| 3846 | * callback function. However, for the RNID Accept Response ELS command, |
| 3847 | * this is undone later by this routine after the IOCB is allocated. |
| 3848 | * |
| 3849 | * Return code |
| 3850 | * 0 - Successfully issued acc rnid response |
| 3851 | * 1 - Failed to issue acc rnid response |
| 3852 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3853 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3854 | lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3855 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3856 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3857 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3858 | RNID *rn; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3859 | IOCB_t *icmd, *oldcmd; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3860 | struct lpfc_iocbq *elsiocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3861 | struct lpfc_sli *psli; |
| 3862 | uint8_t *pcmd; |
| 3863 | uint16_t cmdsize; |
| 3864 | int rc; |
| 3865 | |
| 3866 | psli = &phba->sli; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3867 | cmdsize = sizeof(uint32_t) + sizeof(uint32_t) |
| 3868 | + (2 * sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3869 | if (format) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3870 | cmdsize += sizeof(RNID_TOP_DISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3871 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3872 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 3873 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 3874 | if (!elsiocb) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3875 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3876 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3877 | icmd = &elsiocb->iocb; |
| 3878 | oldcmd = &oldiocb->iocb; |
| 3879 | icmd->ulpContext = oldcmd->ulpContext; /* Xri */ |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 3880 | /* Xmit RNID ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 3881 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 3882 | "0132 Xmit RNID ACC response tag x%x xri x%x\n", |
| 3883 | elsiocb->iotag, elsiocb->iocb.ulpContext); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3884 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3885 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3886 | pcmd += sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3887 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3888 | memset(pcmd, 0, sizeof(RNID)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3889 | rn = (RNID *) (pcmd); |
| 3890 | rn->Format = format; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3891 | rn->CommonLen = (2 * sizeof(struct lpfc_name)); |
| 3892 | memcpy(&rn->portName, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 3893 | memcpy(&rn->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3894 | switch (format) { |
| 3895 | case 0: |
| 3896 | rn->SpecificLen = 0; |
| 3897 | break; |
| 3898 | case RNID_TOPOLOGY_DISC: |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3899 | rn->SpecificLen = sizeof(RNID_TOP_DISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3900 | memcpy(&rn->un.topologyDisc.portName, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 3901 | &vport->fc_portname, sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3902 | rn->un.topologyDisc.unitType = RNID_HBA; |
| 3903 | rn->un.topologyDisc.physPort = 0; |
| 3904 | rn->un.topologyDisc.attachedNodes = 0; |
| 3905 | break; |
| 3906 | default: |
| 3907 | rn->CommonLen = 0; |
| 3908 | rn->SpecificLen = 0; |
| 3909 | break; |
| 3910 | } |
| 3911 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3912 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, |
| 3913 | "Issue ACC RNID: did:x%x flg:x%x", |
| 3914 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 3915 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3916 | phba->fc_stat.elsXmitACC++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 3917 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 3918 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3919 | elsiocb->context1 = NULL; /* Don't need ndlp for cmpl, |
| 3920 | * it could be freed */ |
| 3921 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 3922 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3923 | if (rc == IOCB_ERROR) { |
| 3924 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3925 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3926 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 3927 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3928 | } |
| 3929 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3930 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3931 | * 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] | 3932 | * @vport: pointer to a host virtual N_Port data structure. |
| 3933 | * |
| 3934 | * This routine issues Address Discover (ADISC) ELS commands to those |
| 3935 | * N_Ports which are in node port recovery state and ADISC has not been issued |
| 3936 | * for the @vport. Each time an ELS ADISC IOCB is issued by invoking the |
| 3937 | * lpfc_issue_els_adisc() routine, the per @vport number of discover count |
| 3938 | * (num_disc_nodes) shall be incremented. If the num_disc_nodes reaches a |
| 3939 | * pre-configured threshold (cfg_discovery_threads), the @vport fc_flag will |
| 3940 | * be marked with FC_NLP_MORE bit and the process of issuing remaining ADISC |
| 3941 | * IOCBs quit for later pick up. On the other hand, after walking through |
| 3942 | * all the ndlps with the @vport and there is none ADISC IOCB issued, the |
| 3943 | * @vport fc_flag shall be cleared with FC_NLP_MORE bit indicating there is |
| 3944 | * no more ADISC need to be sent. |
| 3945 | * |
| 3946 | * Return code |
| 3947 | * The number of N_Ports with adisc issued. |
| 3948 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3949 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3950 | lpfc_els_disc_adisc(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3951 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3952 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3953 | struct lpfc_nodelist *ndlp, *next_ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3954 | int sentadisc = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3955 | |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 3956 | /* go thru NPR nodes and issue any remaining ELS ADISCs */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3957 | 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] | 3958 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 3959 | continue; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 3960 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && |
| 3961 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && |
| 3962 | (ndlp->nlp_flag & NLP_NPR_ADISC) != 0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3963 | spin_lock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 3964 | ndlp->nlp_flag &= ~NLP_NPR_ADISC; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3965 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 3966 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3967 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_ADISC_ISSUE); |
| 3968 | lpfc_issue_els_adisc(vport, ndlp, 0); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 3969 | sentadisc++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3970 | vport->num_disc_nodes++; |
| 3971 | if (vport->num_disc_nodes >= |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 3972 | vport->cfg_discovery_threads) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3973 | spin_lock_irq(shost->host_lock); |
| 3974 | vport->fc_flag |= FC_NLP_MORE; |
| 3975 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 3976 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3977 | } |
| 3978 | } |
| 3979 | } |
| 3980 | if (sentadisc == 0) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 3981 | spin_lock_irq(shost->host_lock); |
| 3982 | vport->fc_flag &= ~FC_NLP_MORE; |
| 3983 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3984 | } |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 3985 | return sentadisc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 3986 | } |
| 3987 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 3988 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 3989 | * 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] | 3990 | * @vport: pointer to a host virtual N_Port data structure. |
| 3991 | * |
| 3992 | * This routine issues Port Login (PLOGI) ELS commands to all the N_Ports |
| 3993 | * which are in node port recovery state, with a @vport. Each time an ELS |
| 3994 | * ADISC PLOGI IOCB is issued by invoking the lpfc_issue_els_plogi() routine, |
| 3995 | * the per @vport number of discover count (num_disc_nodes) shall be |
| 3996 | * incremented. If the num_disc_nodes reaches a pre-configured threshold |
| 3997 | * (cfg_discovery_threads), the @vport fc_flag will be marked with FC_NLP_MORE |
| 3998 | * bit set and quit the process of issuing remaining ADISC PLOGIN IOCBs for |
| 3999 | * later pick up. On the other hand, after walking through all the ndlps with |
| 4000 | * the @vport and there is none ADISC PLOGI IOCB issued, the @vport fc_flag |
| 4001 | * shall be cleared with the FC_NLP_MORE bit indicating there is no more ADISC |
| 4002 | * PLOGI need to be sent. |
| 4003 | * |
| 4004 | * Return code |
| 4005 | * The number of N_Ports with plogi issued. |
| 4006 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4007 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4008 | lpfc_els_disc_plogi(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4009 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4010 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4011 | struct lpfc_nodelist *ndlp, *next_ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4012 | int sentplogi = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4013 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4014 | /* go thru NPR nodes and issue any remaining ELS PLOGIs */ |
| 4015 | 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] | 4016 | if (!NLP_CHK_NODE_ACT(ndlp)) |
| 4017 | continue; |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4018 | if (ndlp->nlp_state == NLP_STE_NPR_NODE && |
| 4019 | (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 && |
| 4020 | (ndlp->nlp_flag & NLP_DELAY_TMO) == 0 && |
| 4021 | (ndlp->nlp_flag & NLP_NPR_ADISC) == 0) { |
| 4022 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4023 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
| 4024 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4025 | sentplogi++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4026 | vport->num_disc_nodes++; |
| 4027 | if (vport->num_disc_nodes >= |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4028 | vport->cfg_discovery_threads) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4029 | spin_lock_irq(shost->host_lock); |
| 4030 | vport->fc_flag |= FC_NLP_MORE; |
| 4031 | spin_unlock_irq(shost->host_lock); |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4032 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4033 | } |
| 4034 | } |
| 4035 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 4036 | if (sentplogi) { |
| 4037 | lpfc_set_disctmo(vport); |
| 4038 | } |
| 4039 | else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4040 | spin_lock_irq(shost->host_lock); |
| 4041 | vport->fc_flag &= ~FC_NLP_MORE; |
| 4042 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4043 | } |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 4044 | return sentplogi; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4045 | } |
| 4046 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4047 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4048 | * lpfc_els_flush_rscn - Clean up any rscn activities with a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4049 | * @vport: pointer to a host virtual N_Port data structure. |
| 4050 | * |
| 4051 | * This routine cleans up any Registration State Change Notification |
| 4052 | * (RSCN) activity with a @vport. Note that the fc_rscn_flush flag of the |
| 4053 | * @vport together with the host_lock is used to prevent multiple thread |
| 4054 | * trying to access the RSCN array on a same @vport at the same time. |
| 4055 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4056 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4057 | lpfc_els_flush_rscn(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4058 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4059 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4060 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4061 | int i; |
| 4062 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4063 | spin_lock_irq(shost->host_lock); |
| 4064 | if (vport->fc_rscn_flush) { |
| 4065 | /* Another thread is walking fc_rscn_id_list on this vport */ |
| 4066 | spin_unlock_irq(shost->host_lock); |
| 4067 | return; |
| 4068 | } |
| 4069 | /* Indicate we are walking lpfc_els_flush_rscn on this vport */ |
| 4070 | vport->fc_rscn_flush = 1; |
| 4071 | spin_unlock_irq(shost->host_lock); |
| 4072 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4073 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4074 | lpfc_in_buf_free(phba, vport->fc_rscn_id_list[i]); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4075 | vport->fc_rscn_id_list[i] = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4076 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4077 | spin_lock_irq(shost->host_lock); |
| 4078 | vport->fc_rscn_id_cnt = 0; |
| 4079 | vport->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY); |
| 4080 | spin_unlock_irq(shost->host_lock); |
| 4081 | lpfc_can_disctmo(vport); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4082 | /* Indicate we are done walking this fc_rscn_id_list */ |
| 4083 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4084 | } |
| 4085 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4086 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4087 | * 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] | 4088 | * @vport: pointer to a host virtual N_Port data structure. |
| 4089 | * @did: remote destination port identifier. |
| 4090 | * |
| 4091 | * This routine checks whether there is any pending Registration State |
| 4092 | * Configuration Notification (RSCN) to a @did on @vport. |
| 4093 | * |
| 4094 | * Return code |
| 4095 | * None zero - The @did matched with a pending rscn |
| 4096 | * 0 - not able to match @did with a pending rscn |
| 4097 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4098 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4099 | lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4100 | { |
| 4101 | D_ID ns_did; |
| 4102 | D_ID rscn_did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4103 | uint32_t *lp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4104 | uint32_t payload_len, i; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4105 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4106 | |
| 4107 | ns_did.un.word = did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4108 | |
| 4109 | /* Never match fabric nodes for RSCNs */ |
| 4110 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4111 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4112 | |
| 4113 | /* If we are doing a FULL RSCN rediscovery, match everything */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4114 | if (vport->fc_flag & FC_RSCN_DISCOVERY) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4115 | return did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4116 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4117 | spin_lock_irq(shost->host_lock); |
| 4118 | if (vport->fc_rscn_flush) { |
| 4119 | /* Another thread is walking fc_rscn_id_list on this vport */ |
| 4120 | spin_unlock_irq(shost->host_lock); |
| 4121 | return 0; |
| 4122 | } |
| 4123 | /* Indicate we are walking fc_rscn_id_list on this vport */ |
| 4124 | vport->fc_rscn_flush = 1; |
| 4125 | spin_unlock_irq(shost->host_lock); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4126 | for (i = 0; i < vport->fc_rscn_id_cnt; i++) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4127 | lp = vport->fc_rscn_id_list[i]->virt; |
| 4128 | payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); |
| 4129 | payload_len -= sizeof(uint32_t); /* take off word 0 */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4130 | while (payload_len) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4131 | rscn_did.un.word = be32_to_cpu(*lp++); |
| 4132 | payload_len -= sizeof(uint32_t); |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4133 | switch (rscn_did.un.b.resv & RSCN_ADDRESS_FORMAT_MASK) { |
| 4134 | case RSCN_ADDRESS_FORMAT_PORT: |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 4135 | if ((ns_did.un.b.domain == rscn_did.un.b.domain) |
| 4136 | && (ns_did.un.b.area == rscn_did.un.b.area) |
| 4137 | && (ns_did.un.b.id == rscn_did.un.b.id)) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4138 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4139 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4140 | case RSCN_ADDRESS_FORMAT_AREA: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4141 | if ((ns_did.un.b.domain == rscn_did.un.b.domain) |
| 4142 | && (ns_did.un.b.area == rscn_did.un.b.area)) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4143 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4144 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4145 | case RSCN_ADDRESS_FORMAT_DOMAIN: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4146 | if (ns_did.un.b.domain == rscn_did.un.b.domain) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4147 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4148 | break; |
James Smart | eaf15d5 | 2008-12-04 22:39:29 -0500 | [diff] [blame] | 4149 | case RSCN_ADDRESS_FORMAT_FABRIC: |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4150 | goto return_did_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4151 | } |
| 4152 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4153 | } |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4154 | /* Indicate we are done with walking fc_rscn_id_list on this vport */ |
| 4155 | vport->fc_rscn_flush = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4156 | return 0; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4157 | return_did_out: |
| 4158 | /* Indicate we are done with walking fc_rscn_id_list on this vport */ |
| 4159 | vport->fc_rscn_flush = 0; |
| 4160 | return did; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4161 | } |
| 4162 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4163 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4164 | * lpfc_rscn_recovery_check - Send recovery event to vport nodes matching rscn |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4165 | * @vport: pointer to a host virtual N_Port data structure. |
| 4166 | * |
| 4167 | * This routine sends recovery (NLP_EVT_DEVICE_RECOVERY) event to the |
| 4168 | * state machine for a @vport's nodes that are with pending RSCN (Registration |
| 4169 | * State Change Notification). |
| 4170 | * |
| 4171 | * Return code |
| 4172 | * 0 - Successful (currently alway return 0) |
| 4173 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4174 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4175 | lpfc_rscn_recovery_check(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4176 | { |
James Smart | 685f0bf | 2007-04-25 09:53:08 -0400 | [diff] [blame] | 4177 | struct lpfc_nodelist *ndlp = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4178 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4179 | /* Move all affected nodes by pending RSCNs to NPR state. */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4180 | list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4181 | if (!NLP_CHK_NODE_ACT(ndlp) || |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4182 | (ndlp->nlp_state == NLP_STE_UNUSED_NODE) || |
| 4183 | !lpfc_rscn_payload_check(vport, ndlp->nlp_DID)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4184 | continue; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4185 | lpfc_disc_state_machine(vport, ndlp, NULL, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 4186 | NLP_EVT_DEVICE_RECOVERY); |
| 4187 | lpfc_cancel_retry_delay_tmo(vport, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4188 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4189 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4190 | } |
| 4191 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4192 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4193 | * lpfc_send_rscn_event - Send an RSCN event to management application |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 4194 | * @vport: pointer to a host virtual N_Port data structure. |
| 4195 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4196 | * |
| 4197 | * lpfc_send_rscn_event sends an RSCN netlink event to management |
| 4198 | * applications. |
| 4199 | */ |
| 4200 | static void |
| 4201 | lpfc_send_rscn_event(struct lpfc_vport *vport, |
| 4202 | struct lpfc_iocbq *cmdiocb) |
| 4203 | { |
| 4204 | struct lpfc_dmabuf *pcmd; |
| 4205 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4206 | uint32_t *payload_ptr; |
| 4207 | uint32_t payload_len; |
| 4208 | struct lpfc_rscn_event_header *rscn_event_data; |
| 4209 | |
| 4210 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 4211 | payload_ptr = (uint32_t *) pcmd->virt; |
| 4212 | payload_len = be32_to_cpu(*payload_ptr & ~ELS_CMD_MASK); |
| 4213 | |
| 4214 | rscn_event_data = kmalloc(sizeof(struct lpfc_rscn_event_header) + |
| 4215 | payload_len, GFP_KERNEL); |
| 4216 | if (!rscn_event_data) { |
| 4217 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 4218 | "0147 Failed to allocate memory for RSCN event\n"); |
| 4219 | return; |
| 4220 | } |
| 4221 | rscn_event_data->event_type = FC_REG_RSCN_EVENT; |
| 4222 | rscn_event_data->payload_length = payload_len; |
| 4223 | memcpy(rscn_event_data->rscn_payload, payload_ptr, |
| 4224 | payload_len); |
| 4225 | |
| 4226 | fc_host_post_vendor_event(shost, |
| 4227 | fc_get_event_number(), |
| 4228 | sizeof(struct lpfc_els_event_header) + payload_len, |
| 4229 | (char *)rscn_event_data, |
| 4230 | LPFC_NL_VENDOR_ID); |
| 4231 | |
| 4232 | kfree(rscn_event_data); |
| 4233 | } |
| 4234 | |
| 4235 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4236 | * lpfc_els_rcv_rscn - Process an unsolicited rscn iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4237 | * @vport: pointer to a host virtual N_Port data structure. |
| 4238 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4239 | * @ndlp: pointer to a node-list data structure. |
| 4240 | * |
| 4241 | * This routine processes an unsolicited RSCN (Registration State Change |
| 4242 | * Notification) IOCB. First, the payload of the unsolicited RSCN is walked |
| 4243 | * to invoke fc_host_post_event() routine to the FC transport layer. If the |
| 4244 | * discover state machine is about to begin discovery, it just accepts the |
| 4245 | * RSCN and the discovery process will satisfy the RSCN. If this RSCN only |
| 4246 | * contains N_Port IDs for other vports on this HBA, it just accepts the |
| 4247 | * RSCN and ignore processing it. If the state machine is in the recovery |
| 4248 | * state, the fc_rscn_id_list of this @vport is walked and the |
| 4249 | * lpfc_rscn_recovery_check() routine is invoked to send recovery event for |
| 4250 | * all nodes that match RSCN payload. Otherwise, the lpfc_els_handle_rscn() |
| 4251 | * routine is invoked to handle the RSCN event. |
| 4252 | * |
| 4253 | * Return code |
| 4254 | * 0 - Just sent the acc response |
| 4255 | * 1 - Sent the acc response and waited for name server completion |
| 4256 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4257 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4258 | lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4259 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4260 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4261 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4262 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4263 | struct lpfc_dmabuf *pcmd; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4264 | uint32_t *lp, *datap; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4265 | IOCB_t *icmd; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4266 | uint32_t payload_len, length, nportid, *cmd; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4267 | int rscn_cnt; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4268 | int rscn_id = 0, hba_id = 0; |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 4269 | int i; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4270 | |
| 4271 | icmd = &cmdiocb->iocb; |
| 4272 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 4273 | lp = (uint32_t *) pcmd->virt; |
| 4274 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4275 | payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); |
| 4276 | payload_len -= sizeof(uint32_t); /* take off word 0 */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4277 | /* RSCN received */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4278 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 4279 | "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] | 4280 | vport->fc_flag, payload_len, *lp, |
| 4281 | vport->fc_rscn_id_cnt); |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 4282 | |
| 4283 | /* Send an RSCN event to the management application */ |
| 4284 | lpfc_send_rscn_event(vport, cmdiocb); |
| 4285 | |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 4286 | for (i = 0; i < payload_len/sizeof(uint32_t); i++) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4287 | fc_host_post_event(shost, fc_get_event_number(), |
James Smart | d2873e4 | 2006-08-18 17:46:43 -0400 | [diff] [blame] | 4288 | FCH_EVT_RSCN, lp[i]); |
| 4289 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4290 | /* If we are about to begin discovery, just ACC the RSCN. |
| 4291 | * Discovery processing will satisfy it. |
| 4292 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4293 | if (vport->port_state <= LPFC_NS_QRY) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4294 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4295 | "RCV RSCN ignore: did:x%x/ste:x%x flg:x%x", |
| 4296 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 4297 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4298 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4299 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4300 | } |
| 4301 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4302 | /* If this RSCN just contains NPortIDs for other vports on this HBA, |
| 4303 | * just ACC and ignore it. |
| 4304 | */ |
| 4305 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 4306 | !(vport->cfg_peer_port_login)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4307 | i = payload_len; |
| 4308 | datap = lp; |
| 4309 | while (i > 0) { |
| 4310 | nportid = *datap++; |
| 4311 | nportid = ((be32_to_cpu(nportid)) & Mask_DID); |
| 4312 | i -= sizeof(uint32_t); |
| 4313 | rscn_id++; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 4314 | if (lpfc_find_vport_by_did(phba, nportid)) |
| 4315 | hba_id++; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4316 | } |
| 4317 | if (rscn_id == hba_id) { |
| 4318 | /* ALL NPortIDs in RSCN are on HBA */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4319 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 4320 | "0219 Ignore RSCN " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4321 | "Data: x%x x%x x%x x%x\n", |
| 4322 | vport->fc_flag, payload_len, |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4323 | *lp, vport->fc_rscn_id_cnt); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4324 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4325 | "RCV RSCN vport: did:x%x/ste:x%x flg:x%x", |
| 4326 | ndlp->nlp_DID, vport->port_state, |
| 4327 | ndlp->nlp_flag); |
| 4328 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4329 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4330 | ndlp, NULL); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4331 | return 0; |
| 4332 | } |
| 4333 | } |
| 4334 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4335 | spin_lock_irq(shost->host_lock); |
| 4336 | if (vport->fc_rscn_flush) { |
| 4337 | /* Another thread is walking fc_rscn_id_list on this vport */ |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4338 | vport->fc_flag |= FC_RSCN_DISCOVERY; |
James Smart | 9795724 | 2009-12-21 17:03:15 -0500 | [diff] [blame] | 4339 | spin_unlock_irq(shost->host_lock); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 4340 | /* Send back ACC */ |
| 4341 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4342 | return 0; |
| 4343 | } |
| 4344 | /* Indicate we are walking fc_rscn_id_list on this vport */ |
| 4345 | vport->fc_rscn_flush = 1; |
| 4346 | spin_unlock_irq(shost->host_lock); |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 4347 | /* Get the array count after successfully have the token */ |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4348 | rscn_cnt = vport->fc_rscn_id_cnt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4349 | /* If we are already processing an RSCN, save the received |
| 4350 | * RSCN payload buffer, cmdiocb->context2 to process later. |
| 4351 | */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4352 | if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4353 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4354 | "RCV RSCN defer: did:x%x/ste:x%x flg:x%x", |
| 4355 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 4356 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4357 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4358 | vport->fc_flag |= FC_RSCN_DEFERRED; |
| 4359 | if ((rscn_cnt < FC_MAX_HOLD_RSCN) && |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4360 | !(vport->fc_flag & FC_RSCN_DISCOVERY)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4361 | vport->fc_flag |= FC_RSCN_MODE; |
| 4362 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4363 | if (rscn_cnt) { |
| 4364 | cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt; |
| 4365 | length = be32_to_cpu(*cmd & ~ELS_CMD_MASK); |
| 4366 | } |
| 4367 | if ((rscn_cnt) && |
| 4368 | (payload_len + length <= LPFC_BPL_SIZE)) { |
| 4369 | *cmd &= ELS_CMD_MASK; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4370 | *cmd |= cpu_to_be32(payload_len + length); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4371 | memcpy(((uint8_t *)cmd) + length, lp, |
| 4372 | payload_len); |
| 4373 | } else { |
| 4374 | vport->fc_rscn_id_list[rscn_cnt] = pcmd; |
| 4375 | vport->fc_rscn_id_cnt++; |
| 4376 | /* If we zero, cmdiocb->context2, the calling |
| 4377 | * routine will not try to free it. |
| 4378 | */ |
| 4379 | cmdiocb->context2 = NULL; |
| 4380 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4381 | /* Deferred RSCN */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4382 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 4383 | "0235 Deferred RSCN " |
| 4384 | "Data: x%x x%x x%x\n", |
| 4385 | vport->fc_rscn_id_cnt, vport->fc_flag, |
| 4386 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4387 | } else { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4388 | vport->fc_flag |= FC_RSCN_DISCOVERY; |
| 4389 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4390 | /* ReDiscovery RSCN */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4391 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 4392 | "0234 ReDiscovery RSCN " |
| 4393 | "Data: x%x x%x x%x\n", |
| 4394 | vport->fc_rscn_id_cnt, vport->fc_flag, |
| 4395 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4396 | } |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4397 | /* Indicate we are done walking fc_rscn_id_list on this vport */ |
| 4398 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4399 | /* Send back ACC */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4400 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4401 | /* send RECOVERY event for ALL nodes that match RSCN payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4402 | lpfc_rscn_recovery_check(vport); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4403 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4404 | vport->fc_flag &= ~FC_RSCN_DEFERRED; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4405 | spin_unlock_irq(shost->host_lock); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4406 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4407 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4408 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 4409 | "RCV RSCN: did:x%x/ste:x%x flg:x%x", |
| 4410 | ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); |
| 4411 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4412 | spin_lock_irq(shost->host_lock); |
| 4413 | vport->fc_flag |= FC_RSCN_MODE; |
| 4414 | spin_unlock_irq(shost->host_lock); |
| 4415 | vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd; |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 4416 | /* Indicate we are done walking fc_rscn_id_list on this vport */ |
| 4417 | vport->fc_rscn_flush = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4418 | /* |
| 4419 | * If we zero, cmdiocb->context2, the calling routine will |
| 4420 | * not try to free it. |
| 4421 | */ |
| 4422 | cmdiocb->context2 = NULL; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4423 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4424 | /* Send back ACC */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4425 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4426 | /* send RECOVERY event for ALL nodes that match RSCN payload */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4427 | lpfc_rscn_recovery_check(vport); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4428 | return lpfc_els_handle_rscn(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4429 | } |
| 4430 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4431 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4432 | * lpfc_els_handle_rscn - Handle rscn for a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4433 | * @vport: pointer to a host virtual N_Port data structure. |
| 4434 | * |
| 4435 | * This routine handles the Registration State Configuration Notification |
| 4436 | * (RSCN) for a @vport. If login to NameServer does not exist, a new ndlp shall |
| 4437 | * be created and a Port Login (PLOGI) to the NameServer is issued. Otherwise, |
| 4438 | * if the ndlp to NameServer exists, a Common Transport (CT) command to the |
| 4439 | * NameServer shall be issued. If CT command to the NameServer fails to be |
| 4440 | * issued, the lpfc_els_flush_rscn() routine shall be invoked to clean up any |
| 4441 | * RSCN activities with the @vport. |
| 4442 | * |
| 4443 | * Return code |
| 4444 | * 0 - Cleaned up rscn on the @vport |
| 4445 | * 1 - Wait for plogi to name server before proceed |
| 4446 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4447 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4448 | lpfc_els_handle_rscn(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4449 | { |
| 4450 | struct lpfc_nodelist *ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4451 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4452 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4453 | /* Ignore RSCN if the port is being torn down. */ |
| 4454 | if (vport->load_flag & FC_UNLOADING) { |
| 4455 | lpfc_els_flush_rscn(vport); |
| 4456 | return 0; |
| 4457 | } |
| 4458 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4459 | /* Start timer for RSCN processing */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4460 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4461 | |
| 4462 | /* RSCN processed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4463 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 4464 | "0215 RSCN processed Data: x%x x%x x%x x%x\n", |
| 4465 | vport->fc_flag, 0, vport->fc_rscn_id_cnt, |
| 4466 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4467 | |
| 4468 | /* To process RSCN, first compare RSCN data with NameServer */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4469 | vport->fc_ns_retry = 0; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 4470 | vport->num_disc_nodes = 0; |
| 4471 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4472 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4473 | if (ndlp && NLP_CHK_NODE_ACT(ndlp) |
| 4474 | && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4475 | /* Good ndlp, issue CT Request to NameServer */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4476 | if (lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 0, 0) == 0) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4477 | /* Wait for NameServer query cmpl before we can |
| 4478 | continue */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4479 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4480 | } else { |
| 4481 | /* If login to NameServer does not exist, issue one */ |
| 4482 | /* Good status, issue PLOGI to NameServer */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4483 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4484 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4485 | /* Wait for NameServer login cmpl before we can |
| 4486 | continue */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4487 | return 1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4488 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4489 | if (ndlp) { |
| 4490 | ndlp = lpfc_enable_node(vport, ndlp, |
| 4491 | NLP_STE_PLOGI_ISSUE); |
| 4492 | if (!ndlp) { |
| 4493 | lpfc_els_flush_rscn(vport); |
| 4494 | return 0; |
| 4495 | } |
| 4496 | ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4497 | } else { |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4498 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 4499 | if (!ndlp) { |
| 4500 | lpfc_els_flush_rscn(vport); |
| 4501 | return 0; |
| 4502 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4503 | lpfc_nlp_init(vport, ndlp, NameServer_DID); |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 4504 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4505 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4506 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 4507 | ndlp->nlp_type |= NLP_FABRIC; |
| 4508 | lpfc_issue_els_plogi(vport, NameServer_DID, 0); |
| 4509 | /* Wait for NameServer login cmpl before we can |
| 4510 | * continue |
| 4511 | */ |
| 4512 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4513 | } |
| 4514 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4515 | lpfc_els_flush_rscn(vport); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4516 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4517 | } |
| 4518 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4519 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4520 | * lpfc_els_rcv_flogi - Process an unsolicited flogi iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4521 | * @vport: pointer to a host virtual N_Port data structure. |
| 4522 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4523 | * @ndlp: pointer to a node-list data structure. |
| 4524 | * |
| 4525 | * This routine processes Fabric Login (FLOGI) IOCB received as an ELS |
| 4526 | * unsolicited event. An unsolicited FLOGI can be received in a point-to- |
| 4527 | * point topology. As an unsolicited FLOGI should not be received in a loop |
| 4528 | * mode, any unsolicited FLOGI received in loop mode shall be ignored. The |
| 4529 | * lpfc_check_sparm() routine is invoked to check the parameters in the |
| 4530 | * unsolicited FLOGI. If parameters validation failed, the routine |
| 4531 | * lpfc_els_rsp_reject() shall be called with reject reason code set to |
| 4532 | * LSEXP_SPARM_OPTIONS to reject the FLOGI. Otherwise, the Port WWN in the |
| 4533 | * FLOGI shall be compared with the Port WWN of the @vport to determine who |
| 4534 | * will initiate PLOGI. The higher lexicographical value party shall has |
| 4535 | * higher priority (as the winning port) and will initiate PLOGI and |
| 4536 | * communicate Port_IDs (Addresses) for both nodes in PLOGI. The result |
| 4537 | * of this will be marked in the @vport fc_flag field with FC_PT2PT_PLOGI |
| 4538 | * and then the lpfc_els_rsp_acc() routine is invoked to accept the FLOGI. |
| 4539 | * |
| 4540 | * Return code |
| 4541 | * 0 - Successfully processed the unsolicited flogi |
| 4542 | * 1 - Failed to process the unsolicited flogi |
| 4543 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4544 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4545 | lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4546 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4547 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4548 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 4549 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4550 | struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 4551 | uint32_t *lp = (uint32_t *) pcmd->virt; |
| 4552 | IOCB_t *icmd = &cmdiocb->iocb; |
| 4553 | struct serv_parm *sp; |
| 4554 | LPFC_MBOXQ_t *mbox; |
| 4555 | struct ls_rjt stat; |
| 4556 | uint32_t cmd, did; |
| 4557 | int rc; |
| 4558 | |
| 4559 | cmd = *lp++; |
| 4560 | sp = (struct serv_parm *) lp; |
| 4561 | |
| 4562 | /* FLOGI received */ |
| 4563 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4564 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4565 | |
| 4566 | if (phba->fc_topology == TOPOLOGY_LOOP) { |
| 4567 | /* We should never receive a FLOGI in loop mode, ignore it */ |
| 4568 | did = icmd->un.elsreq64.remoteID; |
| 4569 | |
| 4570 | /* An FLOGI ELS command <elsCmd> was received from DID <did> in |
| 4571 | Loop Mode */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4572 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 4573 | "0113 An FLOGI ELS command x%x was " |
| 4574 | "received from DID x%x in Loop Mode\n", |
| 4575 | cmd, did); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4576 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4577 | } |
| 4578 | |
| 4579 | did = Fabric_DID; |
| 4580 | |
James Smart | 341af10 | 2010-01-26 23:07:37 -0500 | [diff] [blame] | 4581 | if ((lpfc_check_sparm(vport, ndlp, sp, CLASS3, 1))) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4582 | /* For a FLOGI we accept, then if our portname is greater |
| 4583 | * then the remote portname we initiate Nport login. |
| 4584 | */ |
| 4585 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4586 | rc = memcmp(&vport->fc_portname, &sp->portName, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4587 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4588 | |
| 4589 | if (!rc) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4590 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 4591 | if (!mbox) |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4592 | return 1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4593 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4594 | lpfc_linkdown(phba); |
| 4595 | lpfc_init_link(phba, mbox, |
| 4596 | phba->cfg_topology, |
| 4597 | phba->cfg_link_speed); |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 4598 | mbox->u.mb.un.varInitLnk.lipsr_AL_PA = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4599 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 4600 | mbox->vport = vport; |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 4601 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); |
James Smart | 5b8bd0c | 2007-04-25 09:52:49 -0400 | [diff] [blame] | 4602 | lpfc_set_loopback_flag(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4603 | if (rc == MBX_NOT_FINISHED) { |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 4604 | mempool_free(mbox, phba->mbox_mem_pool); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4605 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4606 | return 1; |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 4607 | } else if (rc > 0) { /* greater than */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4608 | spin_lock_irq(shost->host_lock); |
| 4609 | vport->fc_flag |= FC_PT2PT_PLOGI; |
| 4610 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4611 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4612 | spin_lock_irq(shost->host_lock); |
| 4613 | vport->fc_flag |= FC_PT2PT; |
| 4614 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
| 4615 | spin_unlock_irq(shost->host_lock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4616 | } else { |
| 4617 | /* Reject this request because invalid parameters */ |
| 4618 | stat.un.b.lsRjtRsvd0 = 0; |
| 4619 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 4620 | stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; |
| 4621 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4622 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
| 4623 | NULL); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4624 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4625 | } |
| 4626 | |
| 4627 | /* Send back ACC */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 4628 | lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4629 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4630 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4631 | } |
| 4632 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4633 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4634 | * lpfc_els_rcv_rnid - Process an unsolicited rnid iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4635 | * @vport: pointer to a host virtual N_Port data structure. |
| 4636 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4637 | * @ndlp: pointer to a node-list data structure. |
| 4638 | * |
| 4639 | * This routine processes Request Node Identification Data (RNID) IOCB |
| 4640 | * received as an ELS unsolicited event. Only when the RNID specified format |
| 4641 | * 0x0 or 0xDF (Topology Discovery Specific Node Identification Data) |
| 4642 | * present, this routine will invoke the lpfc_els_rsp_rnid_acc() routine to |
| 4643 | * Accept (ACC) the RNID ELS command. All the other RNID formats are |
| 4644 | * rejected by invoking the lpfc_els_rsp_reject() routine. |
| 4645 | * |
| 4646 | * Return code |
| 4647 | * 0 - Successfully processed rnid iocb (currently always return 0) |
| 4648 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4649 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4650 | lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 4651 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4652 | { |
| 4653 | struct lpfc_dmabuf *pcmd; |
| 4654 | uint32_t *lp; |
| 4655 | IOCB_t *icmd; |
| 4656 | RNID *rn; |
| 4657 | struct ls_rjt stat; |
| 4658 | uint32_t cmd, did; |
| 4659 | |
| 4660 | icmd = &cmdiocb->iocb; |
| 4661 | did = icmd->un.elsreq64.remoteID; |
| 4662 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 4663 | lp = (uint32_t *) pcmd->virt; |
| 4664 | |
| 4665 | cmd = *lp++; |
| 4666 | rn = (RNID *) lp; |
| 4667 | |
| 4668 | /* RNID received */ |
| 4669 | |
| 4670 | switch (rn->Format) { |
| 4671 | case 0: |
| 4672 | case RNID_TOPOLOGY_DISC: |
| 4673 | /* Send back ACC */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4674 | lpfc_els_rsp_rnid_acc(vport, rn->Format, cmdiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4675 | break; |
| 4676 | default: |
| 4677 | /* Reject this request because format not supported */ |
| 4678 | stat.un.b.lsRjtRsvd0 = 0; |
| 4679 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 4680 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 4681 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4682 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
| 4683 | NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4684 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4685 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4686 | } |
| 4687 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4688 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4689 | * lpfc_els_rcv_lirr - Process an unsolicited lirr iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4690 | * @vport: pointer to a host virtual N_Port data structure. |
| 4691 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4692 | * @ndlp: pointer to a node-list data structure. |
| 4693 | * |
| 4694 | * This routine processes a Link Incident Report Registration(LIRR) IOCB |
| 4695 | * received as an ELS unsolicited event. Currently, this function just invokes |
| 4696 | * the lpfc_els_rsp_reject() routine to reject the LIRR IOCB unconditionally. |
| 4697 | * |
| 4698 | * Return code |
| 4699 | * 0 - Successfully processed lirr iocb (currently always return 0) |
| 4700 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4701 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4702 | lpfc_els_rcv_lirr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 4703 | struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4704 | { |
| 4705 | struct ls_rjt stat; |
| 4706 | |
| 4707 | /* For now, unconditionally reject this command */ |
| 4708 | stat.un.b.lsRjtRsvd0 = 0; |
| 4709 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 4710 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 4711 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4712 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4713 | return 0; |
| 4714 | } |
| 4715 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4716 | /** |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 4717 | * lpfc_els_rcv_rrq - Process an unsolicited rrq iocb |
| 4718 | * @vport: pointer to a host virtual N_Port data structure. |
| 4719 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4720 | * @ndlp: pointer to a node-list data structure. |
| 4721 | * |
| 4722 | * This routine processes a Reinstate Recovery Qualifier (RRQ) IOCB |
| 4723 | * received as an ELS unsolicited event. A request to RRQ shall only |
| 4724 | * be accepted if the Originator Nx_Port N_Port_ID or the Responder |
| 4725 | * Nx_Port N_Port_ID of the target Exchange is the same as the |
| 4726 | * N_Port_ID of the Nx_Port that makes the request. If the RRQ is |
| 4727 | * not accepted, an LS_RJT with reason code "Unable to perform |
| 4728 | * command request" and reason code explanation "Invalid Originator |
| 4729 | * S_ID" shall be returned. For now, we just unconditionally accept |
| 4730 | * RRQ from the target. |
| 4731 | **/ |
| 4732 | static void |
| 4733 | lpfc_els_rcv_rrq(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 4734 | struct lpfc_nodelist *ndlp) |
| 4735 | { |
| 4736 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| 4737 | } |
| 4738 | |
| 4739 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4740 | * 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] | 4741 | * @phba: pointer to lpfc hba data structure. |
| 4742 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 4743 | * |
| 4744 | * This routine is the completion callback function for the MBX_READ_LNK_STAT |
| 4745 | * mailbox command. This callback function is to actually send the Accept |
| 4746 | * (ACC) response to a Read Port Status (RPS) unsolicited IOCB event. It |
| 4747 | * collects the link statistics from the completion of the MBX_READ_LNK_STAT |
| 4748 | * mailbox command, constructs the RPS response with the link statistics |
| 4749 | * collected, and then invokes the lpfc_sli_issue_iocb() routine to send ACC |
| 4750 | * response to the RPS. |
| 4751 | * |
| 4752 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4753 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4754 | * will be stored into the context1 field of the IOCB for the completion |
| 4755 | * callback function to the RPS Accept Response ELS IOCB command. |
| 4756 | * |
| 4757 | **/ |
Jamie Wellnitz | 082c026 | 2006-02-28 19:25:30 -0500 | [diff] [blame] | 4758 | static void |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 4759 | 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] | 4760 | { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4761 | MAILBOX_t *mb; |
| 4762 | IOCB_t *icmd; |
| 4763 | RPS_RSP *rps_rsp; |
| 4764 | uint8_t *pcmd; |
| 4765 | struct lpfc_iocbq *elsiocb; |
| 4766 | struct lpfc_nodelist *ndlp; |
| 4767 | uint16_t xri, status; |
| 4768 | uint32_t cmdsize; |
| 4769 | |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 4770 | mb = &pmb->u.mb; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4771 | |
| 4772 | ndlp = (struct lpfc_nodelist *) pmb->context2; |
| 4773 | xri = (uint16_t) ((unsigned long)(pmb->context1)); |
Randy Dunlap | 041976f | 2006-06-25 01:58:51 -0700 | [diff] [blame] | 4774 | pmb->context1 = NULL; |
| 4775 | pmb->context2 = NULL; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4776 | |
| 4777 | if (mb->mbxStatus) { |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 4778 | mempool_free(pmb, phba->mbox_mem_pool); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4779 | return; |
| 4780 | } |
| 4781 | |
| 4782 | cmdsize = sizeof(RPS_RSP) + sizeof(uint32_t); |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 4783 | mempool_free(pmb, phba->mbox_mem_pool); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4784 | elsiocb = lpfc_prep_els_iocb(phba->pport, 0, cmdsize, |
| 4785 | lpfc_max_els_tries, ndlp, |
| 4786 | ndlp->nlp_DID, ELS_CMD_ACC); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 4787 | |
| 4788 | /* Decrement the ndlp reference count from previous mbox command */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 4789 | lpfc_nlp_put(ndlp); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 4790 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 4791 | if (!elsiocb) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4792 | return; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4793 | |
| 4794 | icmd = &elsiocb->iocb; |
| 4795 | icmd->ulpContext = xri; |
| 4796 | |
| 4797 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4798 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4799 | pcmd += sizeof(uint32_t); /* Skip past command */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4800 | rps_rsp = (RPS_RSP *)pcmd; |
| 4801 | |
| 4802 | if (phba->fc_topology != TOPOLOGY_LOOP) |
| 4803 | status = 0x10; |
| 4804 | else |
| 4805 | status = 0x8; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4806 | if (phba->pport->fc_flag & FC_FABRIC) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4807 | status |= 0x4; |
| 4808 | |
| 4809 | rps_rsp->rsvd1 = 0; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 4810 | rps_rsp->portStatus = cpu_to_be16(status); |
| 4811 | rps_rsp->linkFailureCnt = cpu_to_be32(mb->un.varRdLnk.linkFailureCnt); |
| 4812 | rps_rsp->lossSyncCnt = cpu_to_be32(mb->un.varRdLnk.lossSyncCnt); |
| 4813 | rps_rsp->lossSignalCnt = cpu_to_be32(mb->un.varRdLnk.lossSignalCnt); |
| 4814 | rps_rsp->primSeqErrCnt = cpu_to_be32(mb->un.varRdLnk.primSeqErrCnt); |
| 4815 | rps_rsp->invalidXmitWord = cpu_to_be32(mb->un.varRdLnk.invalidXmitWord); |
| 4816 | rps_rsp->crcCnt = cpu_to_be32(mb->un.varRdLnk.crcCnt); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4817 | /* Xmit ELS RPS ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4818 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS, |
| 4819 | "0118 Xmit ELS RPS ACC response tag x%x xri x%x, " |
| 4820 | "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", |
| 4821 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 4822 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 4823 | ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4824 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4825 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4826 | 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] | 4827 | lpfc_els_free_iocb(phba, elsiocb); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4828 | return; |
| 4829 | } |
| 4830 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4831 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4832 | * lpfc_els_rcv_rps - Process an unsolicited rps iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4833 | * @vport: pointer to a host virtual N_Port data structure. |
| 4834 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4835 | * @ndlp: pointer to a node-list data structure. |
| 4836 | * |
| 4837 | * This routine processes Read Port Status (RPS) IOCB received as an |
| 4838 | * ELS unsolicited event. It first checks the remote port state. If the |
| 4839 | * remote port is not in NLP_STE_UNMAPPED_NODE state or NLP_STE_MAPPED_NODE |
| 4840 | * state, it invokes the lpfc_els_rsp_reject() routine to send the reject |
| 4841 | * response. Otherwise, it issue the MBX_READ_LNK_STAT mailbox command |
| 4842 | * for reading the HBA link statistics. It is for the callback function, |
| 4843 | * lpfc_els_rsp_rps_acc(), set to the MBX_READ_LNK_STAT mailbox command |
| 4844 | * to actually sending out RPS Accept (ACC) response. |
| 4845 | * |
| 4846 | * Return codes |
| 4847 | * 0 - Successfully processed rps iocb (currently always return 0) |
| 4848 | **/ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4849 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4850 | lpfc_els_rcv_rps(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 4851 | struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4852 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4853 | struct lpfc_hba *phba = vport->phba; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4854 | uint32_t *lp; |
| 4855 | uint8_t flag; |
| 4856 | LPFC_MBOXQ_t *mbox; |
| 4857 | struct lpfc_dmabuf *pcmd; |
| 4858 | RPS *rps; |
| 4859 | struct ls_rjt stat; |
| 4860 | |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 4861 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 4862 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) |
| 4863 | /* reject the unsolicited RPS request and done with it */ |
| 4864 | goto reject_out; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4865 | |
| 4866 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 4867 | lp = (uint32_t *) pcmd->virt; |
| 4868 | flag = (be32_to_cpu(*lp++) & 0xf); |
| 4869 | rps = (RPS *) lp; |
| 4870 | |
| 4871 | if ((flag == 0) || |
| 4872 | ((flag == 1) && (be32_to_cpu(rps->un.portNum) == 0)) || |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4873 | ((flag == 2) && (memcmp(&rps->un.portName, &vport->fc_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4874 | sizeof(struct lpfc_name)) == 0))) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4875 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4876 | printk("Fix me....\n"); |
| 4877 | dump_stack(); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4878 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC); |
| 4879 | if (mbox) { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4880 | lpfc_read_lnk_stat(phba, mbox); |
| 4881 | mbox->context1 = |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4882 | (void *)((unsigned long) cmdiocb->iocb.ulpContext); |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 4883 | mbox->context2 = lpfc_nlp_get(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4884 | mbox->vport = vport; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4885 | mbox->mbox_cmpl = lpfc_els_rsp_rps_acc; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 4886 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 4887 | != MBX_NOT_FINISHED) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4888 | /* Mbox completion will send ELS Response */ |
| 4889 | return 0; |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 4890 | /* Decrement reference count used for the failed mbox |
| 4891 | * command. |
| 4892 | */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 4893 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4894 | mempool_free(mbox, phba->mbox_mem_pool); |
| 4895 | } |
| 4896 | } |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 4897 | |
| 4898 | reject_out: |
| 4899 | /* issue rejection response */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4900 | stat.un.b.lsRjtRsvd0 = 0; |
| 4901 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 4902 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 4903 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4904 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4905 | return 0; |
| 4906 | } |
| 4907 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4908 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4909 | * lpfc_els_rsp_rpl_acc - Issue an accept rpl els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4910 | * @vport: pointer to a host virtual N_Port data structure. |
| 4911 | * @cmdsize: size of the ELS command. |
| 4912 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
| 4913 | * @ndlp: pointer to a node-list data structure. |
| 4914 | * |
| 4915 | * This routine issuees an Accept (ACC) Read Port List (RPL) ELS command. |
| 4916 | * It is to be called by the lpfc_els_rcv_rpl() routine to accept the RPL. |
| 4917 | * |
| 4918 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 4919 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 4920 | * will be stored into the context1 field of the IOCB for the completion |
| 4921 | * callback function to the RPL Accept Response ELS command. |
| 4922 | * |
| 4923 | * Return code |
| 4924 | * 0 - Successfully issued ACC RPL ELS command |
| 4925 | * 1 - Failed to issue ACC RPL ELS command |
| 4926 | **/ |
Jamie Wellnitz | 082c026 | 2006-02-28 19:25:30 -0500 | [diff] [blame] | 4927 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4928 | lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, |
| 4929 | struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4930 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4931 | struct lpfc_hba *phba = vport->phba; |
| 4932 | IOCB_t *icmd, *oldcmd; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4933 | RPL_RSP rpl_rsp; |
| 4934 | struct lpfc_iocbq *elsiocb; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4935 | uint8_t *pcmd; |
| 4936 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4937 | elsiocb = lpfc_prep_els_iocb(vport, 0, cmdsize, oldiocb->retry, ndlp, |
| 4938 | ndlp->nlp_DID, ELS_CMD_ACC); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4939 | |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 4940 | if (!elsiocb) |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4941 | return 1; |
James Smart | 488d146 | 2006-03-07 15:02:37 -0500 | [diff] [blame] | 4942 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4943 | icmd = &elsiocb->iocb; |
| 4944 | oldcmd = &oldiocb->iocb; |
| 4945 | icmd->ulpContext = oldcmd->ulpContext; /* Xri */ |
| 4946 | |
| 4947 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 4948 | *((uint32_t *) (pcmd)) = ELS_CMD_ACC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 4949 | pcmd += sizeof(uint16_t); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4950 | *((uint16_t *)(pcmd)) = be16_to_cpu(cmdsize); |
| 4951 | pcmd += sizeof(uint16_t); |
| 4952 | |
| 4953 | /* Setup the RPL ACC payload */ |
| 4954 | rpl_rsp.listLen = be32_to_cpu(1); |
| 4955 | rpl_rsp.index = 0; |
| 4956 | rpl_rsp.port_num_blk.portNum = 0; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4957 | rpl_rsp.port_num_blk.portID = be32_to_cpu(vport->fc_myDID); |
| 4958 | memcpy(&rpl_rsp.port_num_blk.portName, &vport->fc_portname, |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4959 | sizeof(struct lpfc_name)); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4960 | memcpy(pcmd, &rpl_rsp, cmdsize - sizeof(uint32_t)); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4961 | /* Xmit ELS RPL ACC response tag <ulpIoTag> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 4962 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 4963 | "0120 Xmit ELS RPL ACC response tag x%x " |
| 4964 | "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " |
| 4965 | "rpi x%x\n", |
| 4966 | elsiocb->iotag, elsiocb->iocb.ulpContext, |
| 4967 | ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, |
| 4968 | ndlp->nlp_rpi); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 4969 | elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4970 | phba->fc_stat.elsXmitACC++; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 4971 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 4972 | IOCB_ERROR) { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4973 | lpfc_els_free_iocb(phba, elsiocb); |
| 4974 | return 1; |
| 4975 | } |
| 4976 | return 0; |
| 4977 | } |
| 4978 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4979 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 4980 | * lpfc_els_rcv_rpl - Process an unsolicited rpl iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 4981 | * @vport: pointer to a host virtual N_Port data structure. |
| 4982 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 4983 | * @ndlp: pointer to a node-list data structure. |
| 4984 | * |
| 4985 | * This routine processes Read Port List (RPL) IOCB received as an ELS |
| 4986 | * unsolicited event. It first checks the remote port state. If the remote |
| 4987 | * port is not in NLP_STE_UNMAPPED_NODE and NLP_STE_MAPPED_NODE states, it |
| 4988 | * invokes the lpfc_els_rsp_reject() routine to send reject response. |
| 4989 | * Otherwise, this routine then invokes the lpfc_els_rsp_rpl_acc() routine |
| 4990 | * to accept the RPL. |
| 4991 | * |
| 4992 | * Return code |
| 4993 | * 0 - Successfully processed rpl iocb (currently always return 0) |
| 4994 | **/ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 4995 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 4996 | lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 4997 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 4998 | { |
| 4999 | struct lpfc_dmabuf *pcmd; |
| 5000 | uint32_t *lp; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5001 | uint32_t maxsize; |
| 5002 | uint16_t cmdsize; |
| 5003 | RPL *rpl; |
| 5004 | struct ls_rjt stat; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5005 | |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 5006 | if ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && |
| 5007 | (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) { |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 5008 | /* issue rejection response */ |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5009 | stat.un.b.lsRjtRsvd0 = 0; |
| 5010 | stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; |
| 5011 | stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; |
| 5012 | stat.un.b.vendorUnique = 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5013 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, |
| 5014 | NULL); |
James Smart | 90160e0 | 2008-08-24 21:49:45 -0400 | [diff] [blame] | 5015 | /* rejected the unsolicited RPL request and done with it */ |
| 5016 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5017 | } |
| 5018 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5019 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5020 | lp = (uint32_t *) pcmd->virt; |
| 5021 | rpl = (RPL *) (lp + 1); |
| 5022 | |
| 5023 | maxsize = be32_to_cpu(rpl->maxsize); |
| 5024 | |
| 5025 | /* We support only one port */ |
| 5026 | if ((rpl->index == 0) && |
| 5027 | ((maxsize == 0) || |
| 5028 | ((maxsize * sizeof(uint32_t)) >= sizeof(RPL_RSP)))) { |
| 5029 | cmdsize = sizeof(uint32_t) + sizeof(RPL_RSP); |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 5030 | } else { |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5031 | cmdsize = sizeof(uint32_t) + maxsize * sizeof(uint32_t); |
| 5032 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5033 | lpfc_els_rsp_rpl_acc(vport, cmdsize, cmdiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5034 | |
| 5035 | return 0; |
| 5036 | } |
| 5037 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5038 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5039 | * lpfc_els_rcv_farp - Process an unsolicited farp request els command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5040 | * @vport: pointer to a virtual N_Port data structure. |
| 5041 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5042 | * @ndlp: pointer to a node-list data structure. |
| 5043 | * |
| 5044 | * This routine processes Fibre Channel Address Resolution Protocol |
| 5045 | * (FARP) Request IOCB received as an ELS unsolicited event. Currently, |
| 5046 | * the lpfc driver only supports matching on WWPN or WWNN for FARP. As such, |
| 5047 | * FARP_MATCH_PORT flag and FARP_MATCH_NODE flag are checked against the |
| 5048 | * Match Flag in the FARP request IOCB: if FARP_MATCH_PORT flag is set, the |
| 5049 | * remote PortName is compared against the FC PortName stored in the @vport |
| 5050 | * data structure; if FARP_MATCH_NODE flag is set, the remote NodeName is |
| 5051 | * compared against the FC NodeName stored in the @vport data structure. |
| 5052 | * If any of these matches and the FARP_REQUEST_FARPR flag is set in the |
| 5053 | * FARP request IOCB Response Flag, the lpfc_issue_els_farpr() routine is |
| 5054 | * invoked to send out FARP Response to the remote node. Before sending the |
| 5055 | * FARP Response, however, the FARP_REQUEST_PLOGI flag is check in the FARP |
| 5056 | * request IOCB Response Flag and, if it is set, the lpfc_issue_els_plogi() |
| 5057 | * routine is invoked to log into the remote port first. |
| 5058 | * |
| 5059 | * Return code |
| 5060 | * 0 - Either the FARP Match Mode not supported or successfully processed |
| 5061 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5062 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5063 | lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5064 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5065 | { |
| 5066 | struct lpfc_dmabuf *pcmd; |
| 5067 | uint32_t *lp; |
| 5068 | IOCB_t *icmd; |
| 5069 | FARP *fp; |
| 5070 | uint32_t cmd, cnt, did; |
| 5071 | |
| 5072 | icmd = &cmdiocb->iocb; |
| 5073 | did = icmd->un.elsreq64.remoteID; |
| 5074 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5075 | lp = (uint32_t *) pcmd->virt; |
| 5076 | |
| 5077 | cmd = *lp++; |
| 5078 | fp = (FARP *) lp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5079 | /* FARP-REQ received from DID <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5080 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 5081 | "0601 FARP-REQ received from DID x%x\n", did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5082 | /* We will only support match on WWPN or WWNN */ |
| 5083 | if (fp->Mflags & ~(FARP_MATCH_NODE | FARP_MATCH_PORT)) { |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5084 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5085 | } |
| 5086 | |
| 5087 | cnt = 0; |
| 5088 | /* If this FARP command is searching for my portname */ |
| 5089 | if (fp->Mflags & FARP_MATCH_PORT) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5090 | if (memcmp(&fp->RportName, &vport->fc_portname, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5091 | sizeof(struct lpfc_name)) == 0) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5092 | cnt = 1; |
| 5093 | } |
| 5094 | |
| 5095 | /* If this FARP command is searching for my nodename */ |
| 5096 | if (fp->Mflags & FARP_MATCH_NODE) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5097 | if (memcmp(&fp->RnodeName, &vport->fc_nodename, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5098 | sizeof(struct lpfc_name)) == 0) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5099 | cnt = 1; |
| 5100 | } |
| 5101 | |
| 5102 | if (cnt) { |
| 5103 | if ((ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) || |
| 5104 | (ndlp->nlp_state == NLP_STE_MAPPED_NODE)) { |
| 5105 | /* Log back into the node before sending the FARP. */ |
| 5106 | if (fp->Rflags & FARP_REQUEST_PLOGI) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 5107 | ndlp->nlp_prev_state = ndlp->nlp_state; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5108 | lpfc_nlp_set_state(vport, ndlp, |
James Smart | de0c5b3 | 2007-04-25 09:52:27 -0400 | [diff] [blame] | 5109 | NLP_STE_PLOGI_ISSUE); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5110 | lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5111 | } |
| 5112 | |
| 5113 | /* Send a FARP response to that node */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5114 | if (fp->Rflags & FARP_REQUEST_FARPR) |
| 5115 | lpfc_issue_els_farpr(vport, did, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5116 | } |
| 5117 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5118 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5119 | } |
| 5120 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5121 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5122 | * lpfc_els_rcv_farpr - Process an unsolicited farp response iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5123 | * @vport: pointer to a host virtual N_Port data structure. |
| 5124 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5125 | * @ndlp: pointer to a node-list data structure. |
| 5126 | * |
| 5127 | * This routine processes Fibre Channel Address Resolution Protocol |
| 5128 | * Response (FARPR) IOCB received as an ELS unsolicited event. It simply |
| 5129 | * invokes the lpfc_els_rsp_acc() routine to the remote node to accept |
| 5130 | * the FARP response request. |
| 5131 | * |
| 5132 | * Return code |
| 5133 | * 0 - Successfully processed FARPR IOCB (currently always return 0) |
| 5134 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5135 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5136 | lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5137 | struct lpfc_nodelist *ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5138 | { |
| 5139 | struct lpfc_dmabuf *pcmd; |
| 5140 | uint32_t *lp; |
| 5141 | IOCB_t *icmd; |
| 5142 | uint32_t cmd, did; |
| 5143 | |
| 5144 | icmd = &cmdiocb->iocb; |
| 5145 | did = icmd->un.elsreq64.remoteID; |
| 5146 | pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 5147 | lp = (uint32_t *) pcmd->virt; |
| 5148 | |
| 5149 | cmd = *lp++; |
| 5150 | /* FARP-RSP received from DID <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5151 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 5152 | "0600 FARP-RSP received from DID x%x\n", did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5153 | /* ACCEPT the Farp resp request */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5154 | lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5155 | |
| 5156 | return 0; |
| 5157 | } |
| 5158 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5159 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5160 | * lpfc_els_rcv_fan - Process an unsolicited fan iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5161 | * @vport: pointer to a host virtual N_Port data structure. |
| 5162 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 5163 | * @fan_ndlp: pointer to a node-list data structure. |
| 5164 | * |
| 5165 | * This routine processes a Fabric Address Notification (FAN) IOCB |
| 5166 | * command received as an ELS unsolicited event. The FAN ELS command will |
| 5167 | * only be processed on a physical port (i.e., the @vport represents the |
| 5168 | * physical port). The fabric NodeName and PortName from the FAN IOCB are |
| 5169 | * compared against those in the phba data structure. If any of those is |
| 5170 | * different, the lpfc_initial_flogi() routine is invoked to initialize |
| 5171 | * Fabric Login (FLOGI) to the fabric to start the discover over. Otherwise, |
| 5172 | * if both of those are identical, the lpfc_issue_fabric_reglogin() routine |
| 5173 | * is invoked to register login to the fabric. |
| 5174 | * |
| 5175 | * Return code |
| 5176 | * 0 - Successfully processed fan iocb (currently always return 0). |
| 5177 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5178 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5179 | lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, |
| 5180 | struct lpfc_nodelist *fan_ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5181 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5182 | struct lpfc_hba *phba = vport->phba; |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 5183 | uint32_t *lp; |
| 5184 | FAN *fp; |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 5185 | |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 5186 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0265 FAN received\n"); |
| 5187 | lp = (uint32_t *)((struct lpfc_dmabuf *)cmdiocb->context2)->virt; |
| 5188 | fp = (FAN *) ++lp; |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 5189 | /* FAN received; Fan does not have a reply sequence */ |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 5190 | if ((vport == phba->pport) && |
| 5191 | (vport->port_state == LPFC_LOCAL_CFG_LINK)) { |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 5192 | if ((memcmp(&phba->fc_fabparam.nodeName, &fp->FnodeName, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 5193 | sizeof(struct lpfc_name))) || |
Jamie Wellnitz | 5024ab1 | 2006-02-28 19:25:28 -0500 | [diff] [blame] | 5194 | (memcmp(&phba->fc_fabparam.portName, &fp->FportName, |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 5195 | sizeof(struct lpfc_name)))) { |
| 5196 | /* This port has switched fabrics. FLOGI is required */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5197 | lpfc_initial_flogi(vport); |
James Smart | 0d2b6b8 | 2008-06-14 22:52:47 -0400 | [diff] [blame] | 5198 | } else { |
| 5199 | /* FAN verified - skip FLOGI */ |
| 5200 | vport->fc_myDID = vport->fc_prevDID; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5201 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 5202 | lpfc_issue_fabric_reglogin(vport); |
| 5203 | else |
| 5204 | lpfc_issue_reg_vfi(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5205 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5206 | } |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5207 | return 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5208 | } |
| 5209 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5210 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5211 | * lpfc_els_timeout - Handler funciton to the els timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5212 | * @ptr: holder for the timer function associated data. |
| 5213 | * |
| 5214 | * This routine is invoked by the ELS timer after timeout. It posts the ELS |
| 5215 | * timer timeout event by setting the WORKER_ELS_TMO bit to the work port |
| 5216 | * event bitmap and then invokes the lpfc_worker_wake_up() routine to wake |
| 5217 | * up the worker thread. It is for the worker thread to invoke the routine |
| 5218 | * lpfc_els_timeout_handler() to work on the posted event WORKER_ELS_TMO. |
| 5219 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5220 | void |
| 5221 | lpfc_els_timeout(unsigned long ptr) |
| 5222 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5223 | struct lpfc_vport *vport = (struct lpfc_vport *) ptr; |
| 5224 | struct lpfc_hba *phba = vport->phba; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 5225 | uint32_t tmo_posted; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5226 | unsigned long iflag; |
| 5227 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5228 | spin_lock_irqsave(&vport->work_port_lock, iflag); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 5229 | tmo_posted = vport->work_port_events & WORKER_ELS_TMO; |
| 5230 | if (!tmo_posted) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5231 | vport->work_port_events |= WORKER_ELS_TMO; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 5232 | spin_unlock_irqrestore(&vport->work_port_lock, iflag); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5233 | |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 5234 | if (!tmo_posted) |
| 5235 | lpfc_worker_wake_up(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5236 | return; |
| 5237 | } |
| 5238 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5239 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5240 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5241 | * lpfc_els_timeout_handler - Process an els timeout event |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5242 | * @vport: pointer to a virtual N_Port data structure. |
| 5243 | * |
| 5244 | * This routine is the actual handler function that processes an ELS timeout |
| 5245 | * event. It walks the ELS ring to get and abort all the IOCBs (except the |
| 5246 | * ABORT/CLOSE/FARP/FARPR/FDISC), which are associated with the @vport by |
| 5247 | * invoking the lpfc_sli_issue_abort_iotag() routine. |
| 5248 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5249 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5250 | lpfc_els_timeout_handler(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5251 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5252 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5253 | struct lpfc_sli_ring *pring; |
| 5254 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 5255 | IOCB_t *cmd = NULL; |
| 5256 | struct lpfc_dmabuf *pcmd; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5257 | uint32_t els_command = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5258 | uint32_t timeout; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5259 | uint32_t remote_ID = 0xffffffff; |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5260 | LIST_HEAD(txcmplq_completions); |
| 5261 | LIST_HEAD(abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5262 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5263 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5264 | timeout = (uint32_t)(phba->fc_ratov << 1); |
| 5265 | |
| 5266 | pring = &phba->sli.ring[LPFC_ELS_RING]; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5267 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5268 | spin_lock_irq(&phba->hbalock); |
| 5269 | list_splice_init(&pring->txcmplq, &txcmplq_completions); |
| 5270 | spin_unlock_irq(&phba->hbalock); |
| 5271 | |
| 5272 | list_for_each_entry_safe(piocb, tmp_iocb, &txcmplq_completions, list) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5273 | cmd = &piocb->iocb; |
| 5274 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5275 | if ((piocb->iocb_flag & LPFC_IO_LIBDFC) != 0 || |
| 5276 | piocb->iocb.ulpCommand == CMD_ABORT_XRI_CN || |
| 5277 | piocb->iocb.ulpCommand == CMD_CLOSE_XRI_CN) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5278 | continue; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5279 | |
| 5280 | if (piocb->vport != vport) |
| 5281 | continue; |
| 5282 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5283 | pcmd = (struct lpfc_dmabuf *) piocb->context2; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5284 | if (pcmd) |
| 5285 | els_command = *(uint32_t *) (pcmd->virt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5286 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5287 | if (els_command == ELS_CMD_FARP || |
| 5288 | els_command == ELS_CMD_FARPR || |
| 5289 | els_command == ELS_CMD_FDISC) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5290 | continue; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5291 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5292 | if (piocb->drvrTimeout > 0) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5293 | if (piocb->drvrTimeout >= timeout) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5294 | piocb->drvrTimeout -= timeout; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5295 | else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5296 | piocb->drvrTimeout = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5297 | continue; |
| 5298 | } |
| 5299 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5300 | remote_ID = 0xffffffff; |
| 5301 | if (cmd->ulpCommand != CMD_GEN_REQUEST64_CR) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5302 | remote_ID = cmd->un.elsreq64.remoteID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5303 | else { |
| 5304 | struct lpfc_nodelist *ndlp; |
| 5305 | ndlp = __lpfc_findnode_rpi(vport, cmd->ulpContext); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 5306 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5307 | remote_ID = ndlp->nlp_DID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5308 | } |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5309 | list_add_tail(&piocb->dlist, &abort_list); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5310 | } |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5311 | spin_lock_irq(&phba->hbalock); |
| 5312 | list_splice(&txcmplq_completions, &pring->txcmplq); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5313 | spin_unlock_irq(&phba->hbalock); |
James Smart | 5a0e326 | 2006-07-06 15:49:16 -0400 | [diff] [blame] | 5314 | |
James Smart | 2a9bf3d | 2010-06-07 15:24:45 -0400 | [diff] [blame] | 5315 | list_for_each_entry_safe(piocb, tmp_iocb, &abort_list, dlist) { |
| 5316 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 5317 | "0127 ELS timeout Data: x%x x%x x%x " |
| 5318 | "x%x\n", els_command, |
| 5319 | remote_ID, cmd->ulpCommand, cmd->ulpIoTag); |
| 5320 | spin_lock_irq(&phba->hbalock); |
| 5321 | list_del_init(&piocb->dlist); |
| 5322 | lpfc_sli_issue_abort_iotag(phba, pring, piocb); |
| 5323 | spin_unlock_irq(&phba->hbalock); |
| 5324 | } |
| 5325 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5326 | if (phba->sli.ring[LPFC_ELS_RING].txcmplq_cnt) |
| 5327 | mod_timer(&vport->els_tmofunc, jiffies + HZ * timeout); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5328 | } |
| 5329 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5330 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5331 | * 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] | 5332 | * @vport: pointer to a host virtual N_Port data structure. |
| 5333 | * |
| 5334 | * This routine is used to clean up all the outstanding ELS commands on a |
| 5335 | * @vport. It first aborts the @vport by invoking lpfc_fabric_abort_vport() |
| 5336 | * routine. After that, it walks the ELS transmit queue to remove all the |
| 5337 | * IOCBs with the @vport other than the QUE_RING and ABORT/CLOSE IOCBs. For |
| 5338 | * the IOCBs with a non-NULL completion callback function, the callback |
| 5339 | * function will be invoked with the status set to IOSTAT_LOCAL_REJECT and |
| 5340 | * un.ulpWord[4] set to IOERR_SLI_ABORTED. For IOCBs with a NULL completion |
| 5341 | * callback function, the IOCB will simply be released. Finally, it walks |
| 5342 | * the ELS transmit completion queue to issue an abort IOCB to any transmit |
| 5343 | * completion queue IOCB that is associated with the @vport and is not |
| 5344 | * an IOCB from libdfc (i.e., the management plane IOCBs that are not |
| 5345 | * part of the discovery state machine) out to HBA by invoking the |
| 5346 | * lpfc_sli_issue_abort_iotag() routine. Note that this function issues the |
| 5347 | * abort IOCB to any transmit completion queueed IOCB, it does not guarantee |
| 5348 | * the IOCBs are aborted when this function returns. |
| 5349 | **/ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5350 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5351 | lpfc_els_flush_cmd(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5352 | { |
James Smart | 2534ba7 | 2007-04-25 09:52:20 -0400 | [diff] [blame] | 5353 | LIST_HEAD(completions); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5354 | struct lpfc_hba *phba = vport->phba; |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5355 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5356 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 5357 | IOCB_t *cmd = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5358 | |
| 5359 | lpfc_fabric_abort_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5360 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5361 | spin_lock_irq(&phba->hbalock); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5362 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txq, list) { |
| 5363 | cmd = &piocb->iocb; |
| 5364 | |
| 5365 | if (piocb->iocb_flag & LPFC_IO_LIBDFC) { |
| 5366 | continue; |
| 5367 | } |
| 5368 | |
| 5369 | /* Do not flush out the QUE_RING and ABORT/CLOSE iocbs */ |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5370 | if (cmd->ulpCommand == CMD_QUE_RING_BUF_CN || |
| 5371 | cmd->ulpCommand == CMD_QUE_RING_BUF64_CN || |
| 5372 | cmd->ulpCommand == CMD_CLOSE_XRI_CN || |
| 5373 | cmd->ulpCommand == CMD_ABORT_XRI_CN) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5374 | continue; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5375 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5376 | if (piocb->vport != vport) |
| 5377 | continue; |
| 5378 | |
James Smart | 2534ba7 | 2007-04-25 09:52:20 -0400 | [diff] [blame] | 5379 | list_move_tail(&piocb->list, &completions); |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 5380 | pring->txq_cnt--; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5381 | } |
| 5382 | |
| 5383 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5384 | if (piocb->iocb_flag & LPFC_IO_LIBDFC) { |
| 5385 | continue; |
| 5386 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5387 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5388 | if (piocb->vport != vport) |
| 5389 | continue; |
| 5390 | |
James Smart | 0795107 | 2007-04-25 09:51:38 -0400 | [diff] [blame] | 5391 | lpfc_sli_issue_abort_iotag(phba, pring, piocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5392 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5393 | spin_unlock_irq(&phba->hbalock); |
James Smart | 2534ba7 | 2007-04-25 09:52:20 -0400 | [diff] [blame] | 5394 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 5395 | /* Cancell all the IOCBs from the completions list */ |
| 5396 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 5397 | IOERR_SLI_ABORTED); |
James Smart | 2534ba7 | 2007-04-25 09:52:20 -0400 | [diff] [blame] | 5398 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5399 | return; |
| 5400 | } |
| 5401 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5402 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5403 | * 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] | 5404 | * @phba: pointer to lpfc hba data structure. |
| 5405 | * |
| 5406 | * This routine is used to clean up all the outstanding ELS commands on a |
| 5407 | * @phba. It first aborts the @phba by invoking the lpfc_fabric_abort_hba() |
| 5408 | * routine. After that, it walks the ELS transmit queue to remove all the |
| 5409 | * IOCBs to the @phba other than the QUE_RING and ABORT/CLOSE IOCBs. For |
| 5410 | * the IOCBs with the completion callback function associated, the callback |
| 5411 | * function will be invoked with the status set to IOSTAT_LOCAL_REJECT and |
| 5412 | * un.ulpWord[4] set to IOERR_SLI_ABORTED. For IOCBs without the completion |
| 5413 | * callback function associated, the IOCB will simply be released. Finally, |
| 5414 | * it walks the ELS transmit completion queue to issue an abort IOCB to any |
| 5415 | * transmit completion queue IOCB that is not an IOCB from libdfc (i.e., the |
| 5416 | * management plane IOCBs that are not part of the discovery state machine) |
| 5417 | * out to HBA by invoking the lpfc_sli_issue_abort_iotag() routine. |
| 5418 | **/ |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 5419 | void |
| 5420 | lpfc_els_flush_all_cmd(struct lpfc_hba *phba) |
| 5421 | { |
| 5422 | LIST_HEAD(completions); |
| 5423 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
| 5424 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 5425 | IOCB_t *cmd = NULL; |
| 5426 | |
| 5427 | lpfc_fabric_abort_hba(phba); |
| 5428 | spin_lock_irq(&phba->hbalock); |
| 5429 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txq, list) { |
| 5430 | cmd = &piocb->iocb; |
| 5431 | if (piocb->iocb_flag & LPFC_IO_LIBDFC) |
| 5432 | continue; |
| 5433 | /* Do not flush out the QUE_RING and ABORT/CLOSE iocbs */ |
| 5434 | if (cmd->ulpCommand == CMD_QUE_RING_BUF_CN || |
| 5435 | cmd->ulpCommand == CMD_QUE_RING_BUF64_CN || |
| 5436 | cmd->ulpCommand == CMD_CLOSE_XRI_CN || |
| 5437 | cmd->ulpCommand == CMD_ABORT_XRI_CN) |
| 5438 | continue; |
| 5439 | list_move_tail(&piocb->list, &completions); |
| 5440 | pring->txq_cnt--; |
| 5441 | } |
| 5442 | list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) { |
| 5443 | if (piocb->iocb_flag & LPFC_IO_LIBDFC) |
| 5444 | continue; |
| 5445 | lpfc_sli_issue_abort_iotag(phba, pring, piocb); |
| 5446 | } |
| 5447 | spin_unlock_irq(&phba->hbalock); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 5448 | |
| 5449 | /* Cancel all the IOCBs from the completions list */ |
| 5450 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 5451 | IOERR_SLI_ABORTED); |
| 5452 | |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 5453 | return; |
| 5454 | } |
| 5455 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5456 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5457 | * lpfc_send_els_failure_event - Posts an ELS command failure event |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5458 | * @phba: Pointer to hba context object. |
| 5459 | * @cmdiocbp: Pointer to command iocb which reported error. |
| 5460 | * @rspiocbp: Pointer to response iocb which reported error. |
| 5461 | * |
| 5462 | * This function sends an event when there is an ELS command |
| 5463 | * failure. |
| 5464 | **/ |
| 5465 | void |
| 5466 | lpfc_send_els_failure_event(struct lpfc_hba *phba, |
| 5467 | struct lpfc_iocbq *cmdiocbp, |
| 5468 | struct lpfc_iocbq *rspiocbp) |
| 5469 | { |
| 5470 | struct lpfc_vport *vport = cmdiocbp->vport; |
| 5471 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5472 | struct lpfc_lsrjt_event lsrjt_event; |
| 5473 | struct lpfc_fabric_event_header fabric_event; |
| 5474 | struct ls_rjt stat; |
| 5475 | struct lpfc_nodelist *ndlp; |
| 5476 | uint32_t *pcmd; |
| 5477 | |
| 5478 | ndlp = cmdiocbp->context1; |
| 5479 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 5480 | return; |
| 5481 | |
| 5482 | if (rspiocbp->iocb.ulpStatus == IOSTAT_LS_RJT) { |
| 5483 | lsrjt_event.header.event_type = FC_REG_ELS_EVENT; |
| 5484 | lsrjt_event.header.subcategory = LPFC_EVENT_LSRJT_RCV; |
| 5485 | memcpy(lsrjt_event.header.wwpn, &ndlp->nlp_portname, |
| 5486 | sizeof(struct lpfc_name)); |
| 5487 | memcpy(lsrjt_event.header.wwnn, &ndlp->nlp_nodename, |
| 5488 | sizeof(struct lpfc_name)); |
| 5489 | pcmd = (uint32_t *) (((struct lpfc_dmabuf *) |
| 5490 | cmdiocbp->context2)->virt); |
James Smart | 49198b3 | 2010-04-06 15:04:33 -0400 | [diff] [blame] | 5491 | lsrjt_event.command = (pcmd != NULL) ? *pcmd : 0; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5492 | stat.un.lsRjtError = be32_to_cpu(rspiocbp->iocb.un.ulpWord[4]); |
| 5493 | lsrjt_event.reason_code = stat.un.b.lsRjtRsnCode; |
| 5494 | lsrjt_event.explanation = stat.un.b.lsRjtRsnCodeExp; |
| 5495 | fc_host_post_vendor_event(shost, |
| 5496 | fc_get_event_number(), |
| 5497 | sizeof(lsrjt_event), |
| 5498 | (char *)&lsrjt_event, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5499 | LPFC_NL_VENDOR_ID); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5500 | return; |
| 5501 | } |
| 5502 | if ((rspiocbp->iocb.ulpStatus == IOSTAT_NPORT_BSY) || |
| 5503 | (rspiocbp->iocb.ulpStatus == IOSTAT_FABRIC_BSY)) { |
| 5504 | fabric_event.event_type = FC_REG_FABRIC_EVENT; |
| 5505 | if (rspiocbp->iocb.ulpStatus == IOSTAT_NPORT_BSY) |
| 5506 | fabric_event.subcategory = LPFC_EVENT_PORT_BUSY; |
| 5507 | else |
| 5508 | fabric_event.subcategory = LPFC_EVENT_FABRIC_BUSY; |
| 5509 | memcpy(fabric_event.wwpn, &ndlp->nlp_portname, |
| 5510 | sizeof(struct lpfc_name)); |
| 5511 | memcpy(fabric_event.wwnn, &ndlp->nlp_nodename, |
| 5512 | sizeof(struct lpfc_name)); |
| 5513 | fc_host_post_vendor_event(shost, |
| 5514 | fc_get_event_number(), |
| 5515 | sizeof(fabric_event), |
| 5516 | (char *)&fabric_event, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5517 | LPFC_NL_VENDOR_ID); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5518 | return; |
| 5519 | } |
| 5520 | |
| 5521 | } |
| 5522 | |
| 5523 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5524 | * lpfc_send_els_event - Posts unsolicited els event |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5525 | * @vport: Pointer to vport object. |
| 5526 | * @ndlp: Pointer FC node object. |
| 5527 | * @cmd: ELS command code. |
| 5528 | * |
| 5529 | * This function posts an event when there is an incoming |
| 5530 | * unsolicited ELS command. |
| 5531 | **/ |
| 5532 | static void |
| 5533 | lpfc_send_els_event(struct lpfc_vport *vport, |
| 5534 | struct lpfc_nodelist *ndlp, |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5535 | uint32_t *payload) |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5536 | { |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5537 | struct lpfc_els_event_header *els_data = NULL; |
| 5538 | struct lpfc_logo_event *logo_data = NULL; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5539 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 5540 | |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5541 | if (*payload == ELS_CMD_LOGO) { |
| 5542 | logo_data = kmalloc(sizeof(struct lpfc_logo_event), GFP_KERNEL); |
| 5543 | if (!logo_data) { |
| 5544 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 5545 | "0148 Failed to allocate memory " |
| 5546 | "for LOGO event\n"); |
| 5547 | return; |
| 5548 | } |
| 5549 | els_data = &logo_data->header; |
| 5550 | } else { |
| 5551 | els_data = kmalloc(sizeof(struct lpfc_els_event_header), |
| 5552 | GFP_KERNEL); |
| 5553 | if (!els_data) { |
| 5554 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 5555 | "0149 Failed to allocate memory " |
| 5556 | "for ELS event\n"); |
| 5557 | return; |
| 5558 | } |
| 5559 | } |
| 5560 | els_data->event_type = FC_REG_ELS_EVENT; |
| 5561 | switch (*payload) { |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5562 | case ELS_CMD_PLOGI: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5563 | els_data->subcategory = LPFC_EVENT_PLOGI_RCV; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5564 | break; |
| 5565 | case ELS_CMD_PRLO: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5566 | els_data->subcategory = LPFC_EVENT_PRLO_RCV; |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5567 | break; |
| 5568 | case ELS_CMD_ADISC: |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5569 | els_data->subcategory = LPFC_EVENT_ADISC_RCV; |
| 5570 | break; |
| 5571 | case ELS_CMD_LOGO: |
| 5572 | els_data->subcategory = LPFC_EVENT_LOGO_RCV; |
| 5573 | /* Copy the WWPN in the LOGO payload */ |
| 5574 | memcpy(logo_data->logo_wwpn, &payload[2], |
| 5575 | sizeof(struct lpfc_name)); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5576 | break; |
| 5577 | default: |
Julia Lawall | e916141 | 2009-02-08 22:43:19 +0100 | [diff] [blame] | 5578 | kfree(els_data); |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5579 | return; |
| 5580 | } |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5581 | memcpy(els_data->wwpn, &ndlp->nlp_portname, sizeof(struct lpfc_name)); |
| 5582 | memcpy(els_data->wwnn, &ndlp->nlp_nodename, sizeof(struct lpfc_name)); |
| 5583 | if (*payload == ELS_CMD_LOGO) { |
| 5584 | fc_host_post_vendor_event(shost, |
| 5585 | fc_get_event_number(), |
| 5586 | sizeof(struct lpfc_logo_event), |
| 5587 | (char *)logo_data, |
| 5588 | LPFC_NL_VENDOR_ID); |
| 5589 | kfree(logo_data); |
| 5590 | } else { |
| 5591 | fc_host_post_vendor_event(shost, |
| 5592 | fc_get_event_number(), |
| 5593 | sizeof(struct lpfc_els_event_header), |
| 5594 | (char *)els_data, |
| 5595 | LPFC_NL_VENDOR_ID); |
| 5596 | kfree(els_data); |
| 5597 | } |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 5598 | |
| 5599 | return; |
| 5600 | } |
| 5601 | |
| 5602 | |
| 5603 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5604 | * lpfc_els_unsol_buffer - Process an unsolicited event data buffer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5605 | * @phba: pointer to lpfc hba data structure. |
| 5606 | * @pring: pointer to a SLI ring. |
| 5607 | * @vport: pointer to a host virtual N_Port data structure. |
| 5608 | * @elsiocb: pointer to lpfc els command iocb data structure. |
| 5609 | * |
| 5610 | * This routine is used for processing the IOCB associated with a unsolicited |
| 5611 | * event. It first determines whether there is an existing ndlp that matches |
| 5612 | * the DID from the unsolicited IOCB. If not, it will create a new one with |
| 5613 | * the DID from the unsolicited IOCB. The ELS command from the unsolicited |
| 5614 | * IOCB is then used to invoke the proper routine and to set up proper state |
| 5615 | * of the discovery state machine. |
| 5616 | **/ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5617 | static void |
| 5618 | 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] | 5619 | struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5620 | { |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 5621 | struct Scsi_Host *shost; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5622 | struct lpfc_nodelist *ndlp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5623 | struct ls_rjt stat; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5624 | uint32_t *payload; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5625 | uint32_t cmd, did, newnode, rjt_err = 0; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5626 | IOCB_t *icmd = &elsiocb->iocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5627 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5628 | if (!vport || !(elsiocb->context2)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5629 | goto dropit; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5630 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5631 | newnode = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5632 | payload = ((struct lpfc_dmabuf *)elsiocb->context2)->virt; |
| 5633 | cmd = *payload; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5634 | if ((phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) == 0) |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 5635 | lpfc_post_buffer(phba, pring, 1); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5636 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5637 | did = icmd->un.rcvels.remoteID; |
| 5638 | if (icmd->ulpStatus) { |
| 5639 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5640 | "RCV Unsol ELS: status:x%x/x%x did:x%x", |
| 5641 | icmd->ulpStatus, icmd->un.ulpWord[4], did); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5642 | goto dropit; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5643 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5644 | |
| 5645 | /* Check to see if link went down during discovery */ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5646 | if (lpfc_els_chk_latt(vport)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5647 | goto dropit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5648 | |
James Smart | c868595 | 2009-11-18 15:39:16 -0500 | [diff] [blame] | 5649 | /* Ignore traffic received during vport shutdown. */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5650 | if (vport->load_flag & FC_UNLOADING) |
| 5651 | goto dropit; |
| 5652 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5653 | ndlp = lpfc_findnode_did(vport, did); |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5654 | if (!ndlp) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5655 | /* Cannot find existing Fabric ndlp, so allocate a new one */ |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 5656 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5657 | if (!ndlp) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5658 | goto dropit; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5659 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5660 | lpfc_nlp_init(vport, ndlp, did); |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5661 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5662 | newnode = 1; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5663 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5664 | ndlp->nlp_type |= NLP_FABRIC; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 5665 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 5666 | ndlp = lpfc_enable_node(vport, ndlp, |
| 5667 | NLP_STE_UNUSED_NODE); |
| 5668 | if (!ndlp) |
| 5669 | goto dropit; |
| 5670 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 5671 | newnode = 1; |
| 5672 | if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) |
| 5673 | ndlp->nlp_type |= NLP_FABRIC; |
| 5674 | } else if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) { |
| 5675 | /* This is similar to the new node path */ |
| 5676 | ndlp = lpfc_nlp_get(ndlp); |
| 5677 | if (!ndlp) |
| 5678 | goto dropit; |
| 5679 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); |
| 5680 | newnode = 1; |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 5681 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5682 | |
| 5683 | phba->fc_stat.elsRcvFrame++; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 5684 | |
James Smart | 329f9bc | 2007-04-25 09:53:01 -0400 | [diff] [blame] | 5685 | elsiocb->context1 = lpfc_nlp_get(ndlp); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5686 | elsiocb->vport = vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5687 | |
| 5688 | if ((cmd & ELS_CMD_MASK) == ELS_CMD_RSCN) { |
| 5689 | cmd &= ELS_CMD_MASK; |
| 5690 | } |
| 5691 | /* ELS command <elsCmd> received from NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5692 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 5693 | "0112 ELS command x%x received from NPORT x%x " |
| 5694 | "Data: x%x\n", cmd, did, vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5695 | switch (cmd) { |
| 5696 | case ELS_CMD_PLOGI: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5697 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5698 | "RCV PLOGI: did:x%x/ste:x%x flg:x%x", |
| 5699 | did, vport->port_state, ndlp->nlp_flag); |
| 5700 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5701 | phba->fc_stat.elsRcvPLOGI++; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5702 | ndlp = lpfc_plogi_confirm_nport(phba, payload, ndlp); |
| 5703 | |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5704 | lpfc_send_els_event(vport, ndlp, payload); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5705 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 1b32f6a | 2008-02-08 18:49:39 -0500 | [diff] [blame] | 5706 | if (!(phba->pport->fc_flag & FC_PT2PT) || |
| 5707 | (phba->pport->fc_flag & FC_PT2PT_PLOGI)) { |
| 5708 | rjt_err = LSRJT_UNABLE_TPC; |
| 5709 | break; |
| 5710 | } |
| 5711 | /* We get here, and drop thru, if we are PT2PT with |
| 5712 | * another NPort and the other side has initiated |
| 5713 | * the PLOGI before responding to our FLOGI. |
| 5714 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5715 | } |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 5716 | |
| 5717 | shost = lpfc_shost_from_vport(vport); |
| 5718 | spin_lock_irq(shost->host_lock); |
| 5719 | ndlp->nlp_flag &= ~NLP_TARGET_REMOVE; |
| 5720 | spin_unlock_irq(shost->host_lock); |
| 5721 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5722 | lpfc_disc_state_machine(vport, ndlp, elsiocb, |
| 5723 | NLP_EVT_RCV_PLOGI); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5724 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5725 | break; |
| 5726 | case ELS_CMD_FLOGI: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5727 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5728 | "RCV FLOGI: did:x%x/ste:x%x flg:x%x", |
| 5729 | did, vport->port_state, ndlp->nlp_flag); |
| 5730 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5731 | phba->fc_stat.elsRcvFLOGI++; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5732 | lpfc_els_rcv_flogi(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 5733 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5734 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5735 | break; |
| 5736 | case ELS_CMD_LOGO: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5737 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5738 | "RCV LOGO: did:x%x/ste:x%x flg:x%x", |
| 5739 | did, vport->port_state, ndlp->nlp_flag); |
| 5740 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5741 | phba->fc_stat.elsRcvLOGO++; |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5742 | lpfc_send_els_event(vport, ndlp, payload); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5743 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5744 | rjt_err = LSRJT_UNABLE_TPC; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5745 | break; |
| 5746 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5747 | lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_LOGO); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5748 | break; |
| 5749 | case ELS_CMD_PRLO: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5750 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5751 | "RCV PRLO: did:x%x/ste:x%x flg:x%x", |
| 5752 | did, vport->port_state, ndlp->nlp_flag); |
| 5753 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5754 | phba->fc_stat.elsRcvPRLO++; |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5755 | lpfc_send_els_event(vport, ndlp, payload); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5756 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5757 | rjt_err = LSRJT_UNABLE_TPC; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5758 | break; |
| 5759 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5760 | lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLO); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5761 | break; |
| 5762 | case ELS_CMD_RSCN: |
| 5763 | phba->fc_stat.elsRcvRSCN++; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 5764 | lpfc_els_rcv_rscn(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 5765 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5766 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5767 | break; |
| 5768 | case ELS_CMD_ADISC: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5769 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5770 | "RCV ADISC: did:x%x/ste:x%x flg:x%x", |
| 5771 | did, vport->port_state, ndlp->nlp_flag); |
| 5772 | |
James Smart | ddcc50f | 2008-12-04 22:38:46 -0500 | [diff] [blame] | 5773 | lpfc_send_els_event(vport, ndlp, payload); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5774 | phba->fc_stat.elsRcvADISC++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5775 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5776 | rjt_err = LSRJT_UNABLE_TPC; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5777 | break; |
| 5778 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5779 | lpfc_disc_state_machine(vport, ndlp, elsiocb, |
| 5780 | NLP_EVT_RCV_ADISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5781 | break; |
| 5782 | case ELS_CMD_PDISC: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5783 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5784 | "RCV PDISC: did:x%x/ste:x%x flg:x%x", |
| 5785 | did, vport->port_state, ndlp->nlp_flag); |
| 5786 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5787 | phba->fc_stat.elsRcvPDISC++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5788 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5789 | rjt_err = LSRJT_UNABLE_TPC; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5790 | break; |
| 5791 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5792 | lpfc_disc_state_machine(vport, ndlp, elsiocb, |
| 5793 | NLP_EVT_RCV_PDISC); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5794 | break; |
| 5795 | case ELS_CMD_FARPR: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5796 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5797 | "RCV FARPR: did:x%x/ste:x%x flg:x%x", |
| 5798 | did, vport->port_state, ndlp->nlp_flag); |
| 5799 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5800 | phba->fc_stat.elsRcvFARPR++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5801 | lpfc_els_rcv_farpr(vport, elsiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5802 | break; |
| 5803 | case ELS_CMD_FARP: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5804 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5805 | "RCV FARP: did:x%x/ste:x%x flg:x%x", |
| 5806 | did, vport->port_state, ndlp->nlp_flag); |
| 5807 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5808 | phba->fc_stat.elsRcvFARP++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5809 | lpfc_els_rcv_farp(vport, elsiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5810 | break; |
| 5811 | case ELS_CMD_FAN: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5812 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5813 | "RCV FAN: did:x%x/ste:x%x flg:x%x", |
| 5814 | did, vport->port_state, ndlp->nlp_flag); |
| 5815 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5816 | phba->fc_stat.elsRcvFAN++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5817 | lpfc_els_rcv_fan(vport, elsiocb, ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5818 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5819 | case ELS_CMD_PRLI: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5820 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5821 | "RCV PRLI: did:x%x/ste:x%x flg:x%x", |
| 5822 | did, vport->port_state, ndlp->nlp_flag); |
| 5823 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5824 | phba->fc_stat.elsRcvPRLI++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5825 | if (vport->port_state < LPFC_DISC_AUTH) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5826 | rjt_err = LSRJT_UNABLE_TPC; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5827 | break; |
| 5828 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5829 | lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLI); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5830 | break; |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5831 | case ELS_CMD_LIRR: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5832 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5833 | "RCV LIRR: did:x%x/ste:x%x flg:x%x", |
| 5834 | did, vport->port_state, ndlp->nlp_flag); |
| 5835 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5836 | phba->fc_stat.elsRcvLIRR++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5837 | lpfc_els_rcv_lirr(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 5838 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5839 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5840 | break; |
| 5841 | case ELS_CMD_RPS: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5842 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5843 | "RCV RPS: did:x%x/ste:x%x flg:x%x", |
| 5844 | did, vport->port_state, ndlp->nlp_flag); |
| 5845 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5846 | phba->fc_stat.elsRcvRPS++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5847 | lpfc_els_rcv_rps(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 5848 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5849 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5850 | break; |
| 5851 | case ELS_CMD_RPL: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5852 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5853 | "RCV RPL: did:x%x/ste:x%x flg:x%x", |
| 5854 | did, vport->port_state, ndlp->nlp_flag); |
| 5855 | |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5856 | phba->fc_stat.elsRcvRPL++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5857 | lpfc_els_rcv_rpl(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 5858 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5859 | lpfc_nlp_put(ndlp); |
Jamie Wellnitz | 7bb3b13 | 2006-02-28 19:25:15 -0500 | [diff] [blame] | 5860 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5861 | case ELS_CMD_RNID: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5862 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5863 | "RCV RNID: did:x%x/ste:x%x flg:x%x", |
| 5864 | did, vport->port_state, ndlp->nlp_flag); |
| 5865 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5866 | phba->fc_stat.elsRcvRNID++; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 5867 | lpfc_els_rcv_rnid(vport, elsiocb, ndlp); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 5868 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5869 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5870 | break; |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 5871 | case ELS_CMD_RRQ: |
| 5872 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5873 | "RCV RRQ: did:x%x/ste:x%x flg:x%x", |
| 5874 | did, vport->port_state, ndlp->nlp_flag); |
| 5875 | |
| 5876 | phba->fc_stat.elsRcvRRQ++; |
| 5877 | lpfc_els_rcv_rrq(vport, elsiocb, ndlp); |
| 5878 | if (newnode) |
| 5879 | lpfc_nlp_put(ndlp); |
| 5880 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5881 | default: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5882 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, |
| 5883 | "RCV ELS cmd: cmd:x%x did:x%x/ste:x%x", |
| 5884 | cmd, did, vport->port_state); |
| 5885 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5886 | /* Unsupported ELS command, reject */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5887 | rjt_err = LSRJT_INVALID_CMD; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5888 | |
| 5889 | /* Unknown ELS command <elsCmd> received from NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 5890 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 5891 | "0115 Unknown ELS command x%x " |
| 5892 | "received from NPORT x%x\n", cmd, did); |
James Smart | 87af33f | 2007-10-27 13:37:43 -0400 | [diff] [blame] | 5893 | if (newnode) |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5894 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5895 | break; |
| 5896 | } |
| 5897 | |
| 5898 | /* check if need to LS_RJT received ELS cmd */ |
| 5899 | if (rjt_err) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5900 | memset(&stat, 0, sizeof(stat)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5901 | stat.un.b.lsRjtRsnCode = rjt_err; |
James.Smart@Emulex.Com | 1f679ca | 2005-06-25 10:34:27 -0400 | [diff] [blame] | 5902 | stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 5903 | lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp, |
| 5904 | NULL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 5905 | } |
| 5906 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 5907 | lpfc_nlp_put(elsiocb->context1); |
| 5908 | elsiocb->context1 = NULL; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5909 | return; |
| 5910 | |
| 5911 | dropit: |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 5912 | if (vport && !(vport->load_flag & FC_UNLOADING)) |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5913 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 5914 | "0111 Dropping received ELS cmd " |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5915 | "Data: x%x x%x x%x\n", |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5916 | icmd->ulpStatus, icmd->un.ulpWord[4], icmd->ulpTimeout); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5917 | phba->fc_stat.elsRcvDrop++; |
| 5918 | } |
| 5919 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5920 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5921 | * lpfc_find_vport_by_vpid - Find a vport on a HBA through vport identifier |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5922 | * @phba: pointer to lpfc hba data structure. |
| 5923 | * @vpi: host virtual N_Port identifier. |
| 5924 | * |
| 5925 | * This routine finds a vport on a HBA (referred by @phba) through a |
| 5926 | * @vpi. The function walks the HBA's vport list and returns the address |
| 5927 | * of the vport with the matching @vpi. |
| 5928 | * |
| 5929 | * Return code |
| 5930 | * NULL - No vport with the matching @vpi found |
| 5931 | * Otherwise - Address to the vport with the matching @vpi. |
| 5932 | **/ |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 5933 | struct lpfc_vport * |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5934 | lpfc_find_vport_by_vpid(struct lpfc_hba *phba, uint16_t vpi) |
| 5935 | { |
| 5936 | struct lpfc_vport *vport; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 5937 | unsigned long flags; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5938 | |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 5939 | spin_lock_irqsave(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5940 | list_for_each_entry(vport, &phba->port_list, listentry) { |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 5941 | if (vport->vpi == vpi) { |
| 5942 | spin_unlock_irqrestore(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5943 | return vport; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 5944 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5945 | } |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 5946 | spin_unlock_irqrestore(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5947 | return NULL; |
| 5948 | } |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5949 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 5950 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 5951 | * 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] | 5952 | * @phba: pointer to lpfc hba data structure. |
| 5953 | * @pring: pointer to a SLI ring. |
| 5954 | * @elsiocb: pointer to lpfc els iocb data structure. |
| 5955 | * |
| 5956 | * This routine is used to process an unsolicited event received from a SLI |
| 5957 | * (Service Level Interface) ring. The actual processing of the data buffer |
| 5958 | * associated with the unsolicited event is done by invoking the routine |
| 5959 | * lpfc_els_unsol_buffer() after properly set up the iocb buffer from the |
| 5960 | * SLI ring on which the unsolicited event was received. |
| 5961 | **/ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5962 | void |
| 5963 | lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
| 5964 | struct lpfc_iocbq *elsiocb) |
| 5965 | { |
| 5966 | struct lpfc_vport *vport = phba->pport; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5967 | IOCB_t *icmd = &elsiocb->iocb; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5968 | dma_addr_t paddr; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5969 | struct lpfc_dmabuf *bdeBuf1 = elsiocb->context2; |
| 5970 | struct lpfc_dmabuf *bdeBuf2 = elsiocb->context3; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5971 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 5972 | elsiocb->context1 = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5973 | elsiocb->context2 = NULL; |
| 5974 | elsiocb->context3 = NULL; |
| 5975 | |
| 5976 | if (icmd->ulpStatus == IOSTAT_NEED_BUFFER) { |
| 5977 | lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ); |
| 5978 | } else if (icmd->ulpStatus == IOSTAT_LOCAL_REJECT && |
| 5979 | (icmd->un.ulpWord[4] & 0xff) == IOERR_RCV_BUFFER_WAITING) { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5980 | phba->fc_stat.NoRcvBuf++; |
| 5981 | /* Not enough posted buffers; Try posting more buffers */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5982 | if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)) |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 5983 | lpfc_post_buffer(phba, pring, 0); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5984 | return; |
| 5985 | } |
| 5986 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5987 | if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && |
| 5988 | (icmd->ulpCommand == CMD_IOCB_RCV_ELS64_CX || |
| 5989 | icmd->ulpCommand == CMD_IOCB_RCV_SEQ64_CX)) { |
| 5990 | if (icmd->unsli3.rcvsli3.vpi == 0xffff) |
| 5991 | vport = phba->pport; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 5992 | else |
| 5993 | vport = lpfc_find_vport_by_vpid(phba, |
| 5994 | icmd->unsli3.rcvsli3.vpi - phba->vpi_base); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 5995 | } |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 5996 | /* If there are no BDEs associated |
| 5997 | * with this IOCB, there is nothing to do. |
| 5998 | */ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 5999 | if (icmd->ulpBdeCount == 0) |
| 6000 | return; |
| 6001 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 6002 | /* type of ELS cmd is first 32bit word |
| 6003 | * in packet |
| 6004 | */ |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6005 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6006 | elsiocb->context2 = bdeBuf1; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6007 | } else { |
| 6008 | paddr = getPaddr(icmd->un.cont64[0].addrHigh, |
| 6009 | icmd->un.cont64[0].addrLow); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6010 | elsiocb->context2 = lpfc_sli_ringpostbuf_get(phba, pring, |
| 6011 | paddr); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6012 | } |
| 6013 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6014 | lpfc_els_unsol_buffer(phba, pring, vport, elsiocb); |
| 6015 | /* |
| 6016 | * The different unsolicited event handlers would tell us |
| 6017 | * if they are done with "mp" by setting context2 to NULL. |
| 6018 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6019 | if (elsiocb->context2) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6020 | lpfc_in_buf_free(phba, (struct lpfc_dmabuf *)elsiocb->context2); |
| 6021 | elsiocb->context2 = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6022 | } |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6023 | |
| 6024 | /* RCV_ELS64_CX provide for 2 BDEs - process 2nd if included */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6025 | if ((phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) && |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6026 | icmd->ulpBdeCount == 2) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6027 | elsiocb->context2 = bdeBuf2; |
| 6028 | lpfc_els_unsol_buffer(phba, pring, vport, elsiocb); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6029 | /* free mp if we are done with it */ |
| 6030 | if (elsiocb->context2) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6031 | lpfc_in_buf_free(phba, elsiocb->context2); |
| 6032 | elsiocb->context2 = NULL; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 6033 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6034 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6035 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6036 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6037 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6038 | * 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] | 6039 | * @phba: pointer to lpfc hba data structure. |
| 6040 | * @vport: pointer to a virtual N_Port data structure. |
| 6041 | * |
| 6042 | * This routine issues a Port Login (PLOGI) to the Name Server with |
| 6043 | * State Change Request (SCR) for a @vport. This routine will create an |
| 6044 | * ndlp for the Name Server associated to the @vport if such node does |
| 6045 | * not already exist. The PLOGI to Name Server is issued by invoking the |
| 6046 | * lpfc_issue_els_plogi() routine. If Fabric-Device Management Interface |
| 6047 | * (FDMI) is configured to the @vport, a FDMI node will be created and |
| 6048 | * the PLOGI to FDMI is issued by invoking lpfc_issue_els_plogi() routine. |
| 6049 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6050 | void |
| 6051 | lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport) |
| 6052 | { |
| 6053 | struct lpfc_nodelist *ndlp, *ndlp_fdmi; |
| 6054 | |
| 6055 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
| 6056 | if (!ndlp) { |
| 6057 | ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); |
| 6058 | if (!ndlp) { |
| 6059 | if (phba->fc_topology == TOPOLOGY_LOOP) { |
| 6060 | lpfc_disc_start(vport); |
| 6061 | return; |
| 6062 | } |
| 6063 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6064 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6065 | "0251 NameServer login: no memory\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6066 | return; |
| 6067 | } |
| 6068 | lpfc_nlp_init(vport, ndlp, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6069 | } else if (!NLP_CHK_NODE_ACT(ndlp)) { |
| 6070 | ndlp = lpfc_enable_node(vport, ndlp, NLP_STE_UNUSED_NODE); |
| 6071 | if (!ndlp) { |
| 6072 | if (phba->fc_topology == TOPOLOGY_LOOP) { |
| 6073 | lpfc_disc_start(vport); |
| 6074 | return; |
| 6075 | } |
| 6076 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 6077 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6078 | "0348 NameServer login: node freed\n"); |
| 6079 | return; |
| 6080 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6081 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 6082 | ndlp->nlp_type |= NLP_FABRIC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6083 | |
| 6084 | lpfc_nlp_set_state(vport, ndlp, NLP_STE_PLOGI_ISSUE); |
| 6085 | |
| 6086 | if (lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0)) { |
| 6087 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6088 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6089 | "0252 Cannot issue NameServer login\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6090 | return; |
| 6091 | } |
| 6092 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 6093 | if (vport->cfg_fdmi_on) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6094 | ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool, |
| 6095 | GFP_KERNEL); |
| 6096 | if (ndlp_fdmi) { |
| 6097 | lpfc_nlp_init(vport, ndlp_fdmi, FDMI_DID); |
| 6098 | ndlp_fdmi->nlp_type |= NLP_FABRIC; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 6099 | lpfc_nlp_set_state(vport, ndlp_fdmi, |
| 6100 | NLP_STE_PLOGI_ISSUE); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6101 | lpfc_issue_els_plogi(vport, ndlp_fdmi->nlp_DID, |
| 6102 | 0); |
| 6103 | } |
| 6104 | } |
| 6105 | return; |
| 6106 | } |
| 6107 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6108 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6109 | * lpfc_cmpl_reg_new_vport - Completion callback function to register new vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6110 | * @phba: pointer to lpfc hba data structure. |
| 6111 | * @pmb: pointer to the driver internal queue element for mailbox command. |
| 6112 | * |
| 6113 | * This routine is the completion callback function to register new vport |
| 6114 | * mailbox command. If the new vport mailbox command completes successfully, |
| 6115 | * the fabric registration login shall be performed on physical port (the |
| 6116 | * new vport created is actually a physical port, with VPI 0) or the port |
| 6117 | * login to Name Server for State Change Request (SCR) will be performed |
| 6118 | * on virtual port (real virtual port, with VPI greater than 0). |
| 6119 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6120 | static void |
| 6121 | lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) |
| 6122 | { |
| 6123 | struct lpfc_vport *vport = pmb->vport; |
| 6124 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 6125 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2; |
James Smart | 04c6849 | 2009-05-22 14:52:52 -0400 | [diff] [blame] | 6126 | MAILBOX_t *mb = &pmb->u.mb; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6127 | int rc; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6128 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6129 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6130 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6131 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6132 | |
| 6133 | if (mb->mbxStatus) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6134 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 6135 | "0915 Register VPI failed : Status: x%x" |
| 6136 | " upd bit: x%x \n", mb->mbxStatus, |
| 6137 | mb->un.varRegVpi.upd); |
| 6138 | if (phba->sli_rev == LPFC_SLI_REV4 && |
| 6139 | mb->un.varRegVpi.upd) |
| 6140 | goto mbox_err_exit ; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6141 | |
| 6142 | switch (mb->mbxStatus) { |
| 6143 | case 0x11: /* unsupported feature */ |
| 6144 | case 0x9603: /* max_vpi exceeded */ |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 6145 | case 0x9602: /* Link event since CLEAR_LA */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6146 | /* giving up on vport registration */ |
| 6147 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 6148 | spin_lock_irq(shost->host_lock); |
| 6149 | vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); |
| 6150 | spin_unlock_irq(shost->host_lock); |
| 6151 | lpfc_can_disctmo(vport); |
| 6152 | break; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6153 | /* If reg_vpi fail with invalid VPI status, re-init VPI */ |
| 6154 | case 0x20: |
| 6155 | spin_lock_irq(shost->host_lock); |
| 6156 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
| 6157 | spin_unlock_irq(shost->host_lock); |
| 6158 | lpfc_init_vpi(phba, pmb, vport->vpi); |
| 6159 | pmb->vport = vport; |
| 6160 | pmb->mbox_cmpl = lpfc_init_vpi_cmpl; |
| 6161 | rc = lpfc_sli_issue_mbox(phba, pmb, |
| 6162 | MBX_NOWAIT); |
| 6163 | if (rc == MBX_NOT_FINISHED) { |
| 6164 | lpfc_printf_vlog(vport, |
| 6165 | KERN_ERR, LOG_MBOX, |
| 6166 | "2732 Failed to issue INIT_VPI" |
| 6167 | " mailbox command\n"); |
| 6168 | } else { |
| 6169 | lpfc_nlp_put(ndlp); |
| 6170 | return; |
| 6171 | } |
| 6172 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6173 | default: |
| 6174 | /* Try to recover from this error */ |
| 6175 | lpfc_mbx_unreg_vpi(vport); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6176 | spin_lock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6177 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6178 | spin_unlock_irq(shost->host_lock); |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 6179 | if (vport->port_type == LPFC_PHYSICAL_PORT |
| 6180 | && !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 6181 | lpfc_initial_flogi(vport); |
| 6182 | else |
| 6183 | lpfc_initial_fdisc(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6184 | break; |
| 6185 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6186 | } else { |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6187 | spin_lock_irq(shost->host_lock); |
James Smart | 1987807 | 2009-12-21 17:02:00 -0500 | [diff] [blame] | 6188 | vport->vpi_state |= LPFC_VPI_REGISTERED; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6189 | spin_unlock_irq(shost->host_lock); |
| 6190 | if (vport == phba->pport) { |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6191 | if (phba->sli_rev < LPFC_SLI_REV4) |
| 6192 | lpfc_issue_fabric_reglogin(vport); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6193 | else { |
James Smart | fc2b989 | 2010-02-26 14:15:29 -0500 | [diff] [blame] | 6194 | /* |
| 6195 | * If the physical port is instantiated using |
| 6196 | * FDISC, do not start vport discovery. |
| 6197 | */ |
| 6198 | if (vport->port_state != LPFC_FDISC) |
| 6199 | lpfc_start_fdiscs(phba); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6200 | lpfc_do_scr_ns_plogi(phba, vport); |
| 6201 | } |
| 6202 | } else |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6203 | lpfc_do_scr_ns_plogi(phba, vport); |
| 6204 | } |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 6205 | mbox_err_exit: |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 6206 | /* Now, we decrement the ndlp reference count held for this |
| 6207 | * callback function |
| 6208 | */ |
| 6209 | lpfc_nlp_put(ndlp); |
| 6210 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6211 | mempool_free(pmb, phba->mbox_mem_pool); |
| 6212 | return; |
| 6213 | } |
| 6214 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6215 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6216 | * lpfc_register_new_vport - Register a new vport with a HBA |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6217 | * @phba: pointer to lpfc hba data structure. |
| 6218 | * @vport: pointer to a host virtual N_Port data structure. |
| 6219 | * @ndlp: pointer to a node-list data structure. |
| 6220 | * |
| 6221 | * This routine registers the @vport as a new virtual port with a HBA. |
| 6222 | * It is done through a registering vpi mailbox command. |
| 6223 | **/ |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6224 | void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6225 | lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport, |
| 6226 | struct lpfc_nodelist *ndlp) |
| 6227 | { |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6228 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6229 | LPFC_MBOXQ_t *mbox; |
| 6230 | |
| 6231 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
| 6232 | if (mbox) { |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 6233 | lpfc_reg_vpi(vport, mbox); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6234 | mbox->vport = vport; |
| 6235 | mbox->context2 = lpfc_nlp_get(ndlp); |
| 6236 | mbox->mbox_cmpl = lpfc_cmpl_reg_new_vport; |
James Smart | 0b727fe | 2007-10-27 13:37:25 -0400 | [diff] [blame] | 6237 | if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6238 | == MBX_NOT_FINISHED) { |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 6239 | /* mailbox command not success, decrement ndlp |
| 6240 | * reference count for this command |
| 6241 | */ |
| 6242 | lpfc_nlp_put(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6243 | mempool_free(mbox, phba->mbox_mem_pool); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6244 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6245 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
| 6246 | "0253 Register VPI: Can't send mbox\n"); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 6247 | goto mbox_err_exit; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6248 | } |
| 6249 | } else { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6250 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
| 6251 | "0254 Register VPI: no memory\n"); |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 6252 | goto mbox_err_exit; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6253 | } |
James Smart | fa4066b | 2008-01-11 01:53:27 -0500 | [diff] [blame] | 6254 | return; |
| 6255 | |
| 6256 | mbox_err_exit: |
| 6257 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 6258 | spin_lock_irq(shost->host_lock); |
| 6259 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; |
| 6260 | spin_unlock_irq(shost->host_lock); |
| 6261 | return; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6262 | } |
| 6263 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6264 | /** |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 6265 | * 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] | 6266 | * @phba: pointer to lpfc hba data structure. |
| 6267 | * |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 6268 | * This routine cancels the retry delay timers to all the vports. |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6269 | **/ |
| 6270 | void |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 6271 | lpfc_cancel_all_vport_retry_delay_timer(struct lpfc_hba *phba) |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6272 | { |
| 6273 | struct lpfc_vport **vports; |
| 6274 | struct lpfc_nodelist *ndlp; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6275 | uint32_t link_state; |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 6276 | int i; |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6277 | |
| 6278 | /* Treat this failure as linkdown for all vports */ |
| 6279 | link_state = phba->link_state; |
| 6280 | lpfc_linkdown(phba); |
| 6281 | phba->link_state = link_state; |
| 6282 | |
| 6283 | vports = lpfc_create_vport_work_array(phba); |
| 6284 | |
| 6285 | if (vports) { |
| 6286 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
| 6287 | ndlp = lpfc_findnode_did(vports[i], Fabric_DID); |
| 6288 | if (ndlp) |
| 6289 | lpfc_cancel_retry_delay_tmo(vports[i], ndlp); |
| 6290 | lpfc_els_flush_cmd(vports[i]); |
| 6291 | } |
| 6292 | lpfc_destroy_vport_work_array(phba, vports); |
| 6293 | } |
James Smart | 0c9ab6f | 2010-02-26 14:15:57 -0500 | [diff] [blame] | 6294 | } |
| 6295 | |
| 6296 | /** |
| 6297 | * lpfc_retry_pport_discovery - Start timer to retry FLOGI. |
| 6298 | * @phba: pointer to lpfc hba data structure. |
| 6299 | * |
| 6300 | * This routine abort all pending discovery commands and |
| 6301 | * start a timer to retry FLOGI for the physical port |
| 6302 | * discovery. |
| 6303 | **/ |
| 6304 | void |
| 6305 | lpfc_retry_pport_discovery(struct lpfc_hba *phba) |
| 6306 | { |
| 6307 | struct lpfc_nodelist *ndlp; |
| 6308 | struct Scsi_Host *shost; |
| 6309 | |
| 6310 | /* Cancel the all vports retry delay retry timers */ |
| 6311 | lpfc_cancel_all_vport_retry_delay_timer(phba); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6312 | |
| 6313 | /* If fabric require FLOGI, then re-instantiate physical login */ |
| 6314 | ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); |
| 6315 | if (!ndlp) |
| 6316 | return; |
| 6317 | |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6318 | shost = lpfc_shost_from_vport(phba->pport); |
| 6319 | mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ); |
| 6320 | spin_lock_irq(shost->host_lock); |
| 6321 | ndlp->nlp_flag |= NLP_DELAY_TMO; |
| 6322 | spin_unlock_irq(shost->host_lock); |
| 6323 | ndlp->nlp_last_elscmd = ELS_CMD_FLOGI; |
| 6324 | phba->pport->port_state = LPFC_FLOGI; |
| 6325 | return; |
| 6326 | } |
| 6327 | |
| 6328 | /** |
| 6329 | * lpfc_fabric_login_reqd - Check if FLOGI required. |
| 6330 | * @phba: pointer to lpfc hba data structure. |
| 6331 | * @cmdiocb: pointer to FDISC command iocb. |
| 6332 | * @rspiocb: pointer to FDISC response iocb. |
| 6333 | * |
| 6334 | * This routine checks if a FLOGI is reguired for FDISC |
| 6335 | * to succeed. |
| 6336 | **/ |
| 6337 | static int |
| 6338 | lpfc_fabric_login_reqd(struct lpfc_hba *phba, |
| 6339 | struct lpfc_iocbq *cmdiocb, |
| 6340 | struct lpfc_iocbq *rspiocb) |
| 6341 | { |
| 6342 | |
| 6343 | if ((rspiocb->iocb.ulpStatus != IOSTAT_FABRIC_RJT) || |
| 6344 | (rspiocb->iocb.un.ulpWord[4] != RJT_LOGIN_REQUIRED)) |
| 6345 | return 0; |
| 6346 | else |
| 6347 | return 1; |
| 6348 | } |
| 6349 | |
| 6350 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6351 | * lpfc_cmpl_els_fdisc - Completion function for fdisc iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6352 | * @phba: pointer to lpfc hba data structure. |
| 6353 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6354 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 6355 | * |
| 6356 | * This routine is the completion callback function to a Fabric Discover |
| 6357 | * (FDISC) ELS command. Since all the FDISC ELS commands are issued |
| 6358 | * single threaded, each FDISC completion callback function will reset |
| 6359 | * the discovery timer for all vports such that the timers will not get |
| 6360 | * unnecessary timeout. The function checks the FDISC IOCB status. If error |
| 6361 | * detected, the vport will be set to FC_VPORT_FAILED state. Otherwise,the |
| 6362 | * vport will set to FC_VPORT_ACTIVE state. It then checks whether the DID |
| 6363 | * assigned to the vport has been changed with the completion of the FDISC |
| 6364 | * command. If so, both RPI (Remote Port Index) and VPI (Virtual Port Index) |
| 6365 | * are unregistered from the HBA, and then the lpfc_register_new_vport() |
| 6366 | * routine is invoked to register new vport with the HBA. Otherwise, the |
| 6367 | * lpfc_do_scr_ns_plogi() routine is invoked to issue a PLOGI to the Name |
| 6368 | * Server for State Change Request (SCR). |
| 6369 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6370 | static void |
| 6371 | lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 6372 | struct lpfc_iocbq *rspiocb) |
| 6373 | { |
| 6374 | struct lpfc_vport *vport = cmdiocb->vport; |
| 6375 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 6376 | struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; |
| 6377 | struct lpfc_nodelist *np; |
| 6378 | struct lpfc_nodelist *next_np; |
| 6379 | IOCB_t *irsp = &rspiocb->iocb; |
| 6380 | struct lpfc_iocbq *piocb; |
| 6381 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6382 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 6383 | "0123 FDISC completes. x%x/x%x prevDID: x%x\n", |
| 6384 | irsp->ulpStatus, irsp->un.ulpWord[4], |
| 6385 | vport->fc_prevDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6386 | /* Since all FDISCs are being single threaded, we |
| 6387 | * must reset the discovery timer for ALL vports |
| 6388 | * waiting to send FDISC when one completes. |
| 6389 | */ |
| 6390 | list_for_each_entry(piocb, &phba->fabric_iocb_list, list) { |
| 6391 | lpfc_set_disctmo(piocb->vport); |
| 6392 | } |
| 6393 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6394 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 6395 | "FDISC cmpl: status:x%x/x%x prevdid:x%x", |
| 6396 | irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_prevDID); |
| 6397 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6398 | if (irsp->ulpStatus) { |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6399 | |
| 6400 | if (lpfc_fabric_login_reqd(phba, cmdiocb, rspiocb)) { |
| 6401 | lpfc_retry_pport_discovery(phba); |
| 6402 | goto out; |
| 6403 | } |
| 6404 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6405 | /* Check for retry */ |
| 6406 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) |
| 6407 | goto out; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6408 | /* FDISC failed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6409 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6410 | "0126 FDISC failed. (%d/%d)\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6411 | irsp->ulpStatus, irsp->un.ulpWord[4]); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6412 | goto fdisc_failed; |
| 6413 | } |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6414 | spin_lock_irq(shost->host_lock); |
James Smart | 695a814 | 2010-01-26 23:08:03 -0500 | [diff] [blame] | 6415 | vport->fc_flag &= ~FC_VPORT_CVL_RCVD; |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 6416 | vport->fc_flag &= ~FC_VPORT_LOGO_RCVD; |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6417 | vport->fc_flag |= FC_FABRIC; |
| 6418 | if (vport->phba->fc_topology == TOPOLOGY_LOOP) |
| 6419 | vport->fc_flag |= FC_PUBLIC_LOOP; |
| 6420 | spin_unlock_irq(shost->host_lock); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6421 | |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6422 | vport->fc_myDID = irsp->un.ulpWord[4] & Mask_DID; |
| 6423 | lpfc_vport_set_state(vport, FC_VPORT_ACTIVE); |
| 6424 | if ((vport->fc_prevDID != vport->fc_myDID) && |
| 6425 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 6426 | /* If our NportID changed, we need to ensure all |
| 6427 | * remaining NPORTs get unreg_login'ed so we can |
| 6428 | * issue unreg_vpi. |
| 6429 | */ |
| 6430 | list_for_each_entry_safe(np, next_np, |
| 6431 | &vport->fc_nodes, nlp_listp) { |
| 6432 | if (!NLP_CHK_NODE_ACT(ndlp) || |
| 6433 | (np->nlp_state != NLP_STE_NPR_NODE) || |
| 6434 | !(np->nlp_flag & NLP_NPR_ADISC)) |
| 6435 | continue; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6436 | spin_lock_irq(shost->host_lock); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6437 | np->nlp_flag &= ~NLP_NPR_ADISC; |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 6438 | spin_unlock_irq(shost->host_lock); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6439 | lpfc_unreg_rpi(vport, np); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6440 | } |
James Smart | 78730cf | 2010-04-06 15:06:30 -0400 | [diff] [blame] | 6441 | lpfc_cleanup_pending_mbox(vport); |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6442 | lpfc_mbx_unreg_vpi(vport); |
| 6443 | spin_lock_irq(shost->host_lock); |
| 6444 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 6445 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 6446 | vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; |
James Smart | 4b40c59 | 2010-03-15 11:25:44 -0400 | [diff] [blame] | 6447 | else |
| 6448 | vport->fc_flag |= FC_LOGO_RCVD_DID_CHNG; |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6449 | spin_unlock_irq(shost->host_lock); |
James Smart | 38b92ef | 2010-08-04 16:11:39 -0400 | [diff] [blame] | 6450 | } else if ((phba->sli_rev == LPFC_SLI_REV4) && |
| 6451 | !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { |
| 6452 | /* |
| 6453 | * Driver needs to re-reg VPI in order for f/w |
| 6454 | * to update the MAC address. |
| 6455 | */ |
| 6456 | lpfc_register_new_vport(phba, vport, ndlp); |
James Smart | 5ac6b30 | 2010-10-22 11:05:36 -0400 | [diff] [blame^] | 6457 | goto out; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6458 | } |
| 6459 | |
James Smart | ecfd03c | 2010-02-12 14:41:27 -0500 | [diff] [blame] | 6460 | if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI) |
| 6461 | lpfc_issue_init_vpi(vport); |
| 6462 | else if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 6463 | lpfc_register_new_vport(phba, vport, ndlp); |
| 6464 | else |
| 6465 | lpfc_do_scr_ns_plogi(phba, vport); |
| 6466 | goto out; |
| 6467 | fdisc_failed: |
| 6468 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 6469 | /* Cancel discovery timer */ |
| 6470 | lpfc_can_disctmo(vport); |
| 6471 | lpfc_nlp_put(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6472 | out: |
| 6473 | lpfc_els_free_iocb(phba, cmdiocb); |
| 6474 | } |
| 6475 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6476 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6477 | * lpfc_issue_els_fdisc - Issue a fdisc iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6478 | * @vport: pointer to a virtual N_Port data structure. |
| 6479 | * @ndlp: pointer to a node-list data structure. |
| 6480 | * @retry: number of retries to the command IOCB. |
| 6481 | * |
| 6482 | * This routine prepares and issues a Fabric Discover (FDISC) IOCB to |
| 6483 | * a remote node (@ndlp) off a @vport. It uses the lpfc_issue_fabric_iocb() |
| 6484 | * routine to issue the IOCB, which makes sure only one outstanding fabric |
| 6485 | * IOCB will be sent off HBA at any given time. |
| 6486 | * |
| 6487 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 6488 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 6489 | * will be stored into the context1 field of the IOCB for the completion |
| 6490 | * callback function to the FDISC ELS command. |
| 6491 | * |
| 6492 | * Return code |
| 6493 | * 0 - Successfully issued fdisc iocb command |
| 6494 | * 1 - Failed to issue fdisc iocb command |
| 6495 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 6496 | static int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6497 | lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 6498 | uint8_t retry) |
| 6499 | { |
| 6500 | struct lpfc_hba *phba = vport->phba; |
| 6501 | IOCB_t *icmd; |
| 6502 | struct lpfc_iocbq *elsiocb; |
| 6503 | struct serv_parm *sp; |
| 6504 | uint8_t *pcmd; |
| 6505 | uint16_t cmdsize; |
| 6506 | int did = ndlp->nlp_DID; |
| 6507 | int rc; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6508 | |
James Smart | 5ffc266 | 2009-11-18 15:39:44 -0500 | [diff] [blame] | 6509 | vport->port_state = LPFC_FDISC; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6510 | cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); |
| 6511 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did, |
| 6512 | ELS_CMD_FDISC); |
| 6513 | if (!elsiocb) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6514 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6515 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6516 | "0255 Issue FDISC: no IOCB\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6517 | return 1; |
| 6518 | } |
| 6519 | |
| 6520 | icmd = &elsiocb->iocb; |
| 6521 | icmd->un.elsreq64.myID = 0; |
| 6522 | icmd->un.elsreq64.fl = 1; |
| 6523 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 6524 | if (phba->sli_rev == LPFC_SLI_REV4) { |
| 6525 | /* FDISC needs to be 1 for WQE VPI */ |
| 6526 | elsiocb->iocb.ulpCt_h = (SLI4_CT_VPI >> 1) & 1; |
| 6527 | elsiocb->iocb.ulpCt_l = SLI4_CT_VPI & 1 ; |
| 6528 | /* Set the ulpContext to the vpi */ |
| 6529 | elsiocb->iocb.ulpContext = vport->vpi + phba->vpi_base; |
| 6530 | } else { |
| 6531 | /* For FDISC, Let FDISC rsp set the NPortID for this VPI */ |
| 6532 | icmd->ulpCt_h = 1; |
| 6533 | icmd->ulpCt_l = 0; |
| 6534 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6535 | |
| 6536 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 6537 | *((uint32_t *) (pcmd)) = ELS_CMD_FDISC; |
| 6538 | pcmd += sizeof(uint32_t); /* CSP Word 1 */ |
| 6539 | memcpy(pcmd, &vport->phba->pport->fc_sparam, sizeof(struct serv_parm)); |
| 6540 | sp = (struct serv_parm *) pcmd; |
| 6541 | /* Setup CSPs accordingly for Fabric */ |
| 6542 | sp->cmn.e_d_tov = 0; |
| 6543 | sp->cmn.w2.r_a_tov = 0; |
| 6544 | sp->cls1.classValid = 0; |
| 6545 | sp->cls2.seqDelivery = 1; |
| 6546 | sp->cls3.seqDelivery = 1; |
| 6547 | |
| 6548 | pcmd += sizeof(uint32_t); /* CSP Word 2 */ |
| 6549 | pcmd += sizeof(uint32_t); /* CSP Word 3 */ |
| 6550 | pcmd += sizeof(uint32_t); /* CSP Word 4 */ |
| 6551 | pcmd += sizeof(uint32_t); /* Port Name */ |
| 6552 | memcpy(pcmd, &vport->fc_portname, 8); |
| 6553 | pcmd += sizeof(uint32_t); /* Node Name */ |
| 6554 | pcmd += sizeof(uint32_t); /* Node Name */ |
| 6555 | memcpy(pcmd, &vport->fc_nodename, 8); |
| 6556 | |
| 6557 | lpfc_set_disctmo(vport); |
| 6558 | |
| 6559 | phba->fc_stat.elsXmitFDISC++; |
| 6560 | elsiocb->iocb_cmpl = lpfc_cmpl_els_fdisc; |
| 6561 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6562 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 6563 | "Issue FDISC: did:x%x", |
| 6564 | did, 0, 0); |
| 6565 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6566 | rc = lpfc_issue_fabric_iocb(phba, elsiocb); |
| 6567 | if (rc == IOCB_ERROR) { |
| 6568 | lpfc_els_free_iocb(phba, elsiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6569 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 6570 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 6571 | "0256 Issue FDISC: Cannot send IOCB\n"); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6572 | return 1; |
| 6573 | } |
| 6574 | lpfc_vport_set_state(vport, FC_VPORT_INITIALIZING); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6575 | return 0; |
| 6576 | } |
| 6577 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6578 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6579 | * lpfc_cmpl_els_npiv_logo - Completion function with vport logo |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6580 | * @phba: pointer to lpfc hba data structure. |
| 6581 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6582 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 6583 | * |
| 6584 | * This routine is the completion callback function to the issuing of a LOGO |
| 6585 | * ELS command off a vport. It frees the command IOCB and then decrement the |
| 6586 | * reference count held on ndlp for this completion function, indicating that |
| 6587 | * the reference to the ndlp is no long needed. Note that the |
| 6588 | * lpfc_els_free_iocb() routine decrements the ndlp reference held for this |
| 6589 | * callback function and an additional explicit ndlp reference decrementation |
| 6590 | * will trigger the actual release of the ndlp. |
| 6591 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6592 | static void |
| 6593 | lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 6594 | struct lpfc_iocbq *rspiocb) |
| 6595 | { |
| 6596 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6597 | IOCB_t *irsp; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6598 | struct lpfc_nodelist *ndlp; |
| 6599 | ndlp = (struct lpfc_nodelist *)cmdiocb->context1; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6600 | |
| 6601 | irsp = &rspiocb->iocb; |
| 6602 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 6603 | "LOGO npiv cmpl: status:x%x/x%x did:x%x", |
| 6604 | irsp->ulpStatus, irsp->un.ulpWord[4], irsp->un.rcvels.remoteID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6605 | |
| 6606 | lpfc_els_free_iocb(phba, cmdiocb); |
| 6607 | vport->unreg_vpi_cmpl = VPORT_ERROR; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 6608 | |
| 6609 | /* Trigger the release of the ndlp after logo */ |
| 6610 | lpfc_nlp_put(ndlp); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6611 | } |
| 6612 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6613 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6614 | * lpfc_issue_els_npiv_logo - Issue a logo off a vport |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6615 | * @vport: pointer to a virtual N_Port data structure. |
| 6616 | * @ndlp: pointer to a node-list data structure. |
| 6617 | * |
| 6618 | * This routine issues a LOGO ELS command to an @ndlp off a @vport. |
| 6619 | * |
| 6620 | * Note that, in lpfc_prep_els_iocb() routine, the reference count of ndlp |
| 6621 | * will be incremented by 1 for holding the ndlp and the reference to ndlp |
| 6622 | * will be stored into the context1 field of the IOCB for the completion |
| 6623 | * callback function to the LOGO ELS command. |
| 6624 | * |
| 6625 | * Return codes |
| 6626 | * 0 - Successfully issued logo off the @vport |
| 6627 | * 1 - Failed to issue logo off the @vport |
| 6628 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6629 | int |
| 6630 | lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) |
| 6631 | { |
| 6632 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 6633 | struct lpfc_hba *phba = vport->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6634 | IOCB_t *icmd; |
| 6635 | struct lpfc_iocbq *elsiocb; |
| 6636 | uint8_t *pcmd; |
| 6637 | uint16_t cmdsize; |
| 6638 | |
| 6639 | cmdsize = 2 * sizeof(uint32_t) + sizeof(struct lpfc_name); |
| 6640 | elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, 0, ndlp, ndlp->nlp_DID, |
| 6641 | ELS_CMD_LOGO); |
| 6642 | if (!elsiocb) |
| 6643 | return 1; |
| 6644 | |
| 6645 | icmd = &elsiocb->iocb; |
| 6646 | pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); |
| 6647 | *((uint32_t *) (pcmd)) = ELS_CMD_LOGO; |
| 6648 | pcmd += sizeof(uint32_t); |
| 6649 | |
| 6650 | /* Fill in LOGO payload */ |
| 6651 | *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID); |
| 6652 | pcmd += sizeof(uint32_t); |
| 6653 | memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name)); |
| 6654 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6655 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, |
| 6656 | "Issue LOGO npiv did:x%x flg:x%x", |
| 6657 | ndlp->nlp_DID, ndlp->nlp_flag, 0); |
| 6658 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6659 | elsiocb->iocb_cmpl = lpfc_cmpl_els_npiv_logo; |
| 6660 | spin_lock_irq(shost->host_lock); |
| 6661 | ndlp->nlp_flag |= NLP_LOGO_SND; |
| 6662 | spin_unlock_irq(shost->host_lock); |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 6663 | if (lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0) == |
| 6664 | IOCB_ERROR) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6665 | spin_lock_irq(shost->host_lock); |
| 6666 | ndlp->nlp_flag &= ~NLP_LOGO_SND; |
| 6667 | spin_unlock_irq(shost->host_lock); |
| 6668 | lpfc_els_free_iocb(phba, elsiocb); |
| 6669 | return 1; |
| 6670 | } |
| 6671 | return 0; |
| 6672 | } |
| 6673 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6674 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6675 | * lpfc_fabric_block_timeout - Handler function to the fabric block timer |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6676 | * @ptr: holder for the timer function associated data. |
| 6677 | * |
| 6678 | * This routine is invoked by the fabric iocb block timer after |
| 6679 | * timeout. It posts the fabric iocb block timeout event by setting the |
| 6680 | * WORKER_FABRIC_BLOCK_TMO bit to work port event bitmap and then invokes |
| 6681 | * lpfc_worker_wake_up() routine to wake up the worker thread. It is for |
| 6682 | * the worker thread to invoke the lpfc_unblock_fabric_iocbs() on the |
| 6683 | * posted event WORKER_FABRIC_BLOCK_TMO. |
| 6684 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6685 | void |
| 6686 | lpfc_fabric_block_timeout(unsigned long ptr) |
| 6687 | { |
| 6688 | struct lpfc_hba *phba = (struct lpfc_hba *) ptr; |
| 6689 | unsigned long iflags; |
| 6690 | uint32_t tmo_posted; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6691 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6692 | spin_lock_irqsave(&phba->pport->work_port_lock, iflags); |
| 6693 | tmo_posted = phba->pport->work_port_events & WORKER_FABRIC_BLOCK_TMO; |
| 6694 | if (!tmo_posted) |
| 6695 | phba->pport->work_port_events |= WORKER_FABRIC_BLOCK_TMO; |
| 6696 | spin_unlock_irqrestore(&phba->pport->work_port_lock, iflags); |
| 6697 | |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 6698 | if (!tmo_posted) |
| 6699 | lpfc_worker_wake_up(phba); |
| 6700 | return; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6701 | } |
| 6702 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6703 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6704 | * lpfc_resume_fabric_iocbs - Issue a fabric iocb from driver internal list |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6705 | * @phba: pointer to lpfc hba data structure. |
| 6706 | * |
| 6707 | * This routine issues one fabric iocb from the driver internal list to |
| 6708 | * the HBA. It first checks whether it's ready to issue one fabric iocb to |
| 6709 | * the HBA (whether there is no outstanding fabric iocb). If so, it shall |
| 6710 | * remove one pending fabric iocb from the driver internal list and invokes |
| 6711 | * lpfc_sli_issue_iocb() routine to send the fabric iocb to the HBA. |
| 6712 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6713 | static void |
| 6714 | lpfc_resume_fabric_iocbs(struct lpfc_hba *phba) |
| 6715 | { |
| 6716 | struct lpfc_iocbq *iocb; |
| 6717 | unsigned long iflags; |
| 6718 | int ret; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6719 | IOCB_t *cmd; |
| 6720 | |
| 6721 | repeat: |
| 6722 | iocb = NULL; |
| 6723 | spin_lock_irqsave(&phba->hbalock, iflags); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 6724 | /* Post any pending iocb to the SLI layer */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6725 | if (atomic_read(&phba->fabric_iocb_count) == 0) { |
| 6726 | list_remove_head(&phba->fabric_iocb_list, iocb, typeof(*iocb), |
| 6727 | list); |
| 6728 | if (iocb) |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 6729 | /* Increment fabric iocb count to hold the position */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6730 | atomic_inc(&phba->fabric_iocb_count); |
| 6731 | } |
| 6732 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 6733 | if (iocb) { |
| 6734 | iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; |
| 6735 | iocb->iocb_cmpl = lpfc_cmpl_fabric_iocb; |
| 6736 | iocb->iocb_flag |= LPFC_IO_FABRIC; |
| 6737 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6738 | lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD, |
| 6739 | "Fabric sched1: ste:x%x", |
| 6740 | iocb->vport->port_state, 0, 0); |
| 6741 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 6742 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, iocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6743 | |
| 6744 | if (ret == IOCB_ERROR) { |
| 6745 | iocb->iocb_cmpl = iocb->fabric_iocb_cmpl; |
| 6746 | iocb->fabric_iocb_cmpl = NULL; |
| 6747 | iocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 6748 | cmd = &iocb->iocb; |
| 6749 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; |
| 6750 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; |
| 6751 | iocb->iocb_cmpl(phba, iocb, iocb); |
| 6752 | |
| 6753 | atomic_dec(&phba->fabric_iocb_count); |
| 6754 | goto repeat; |
| 6755 | } |
| 6756 | } |
| 6757 | |
| 6758 | return; |
| 6759 | } |
| 6760 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6761 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6762 | * lpfc_unblock_fabric_iocbs - Unblock issuing fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6763 | * @phba: pointer to lpfc hba data structure. |
| 6764 | * |
| 6765 | * This routine unblocks the issuing fabric iocb command. The function |
| 6766 | * will clear the fabric iocb block bit and then invoke the routine |
| 6767 | * lpfc_resume_fabric_iocbs() to issue one of the pending fabric iocb |
| 6768 | * from the driver internal fabric iocb list. |
| 6769 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6770 | void |
| 6771 | lpfc_unblock_fabric_iocbs(struct lpfc_hba *phba) |
| 6772 | { |
| 6773 | clear_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
| 6774 | |
| 6775 | lpfc_resume_fabric_iocbs(phba); |
| 6776 | return; |
| 6777 | } |
| 6778 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6779 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6780 | * lpfc_block_fabric_iocbs - Block issuing fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6781 | * @phba: pointer to lpfc hba data structure. |
| 6782 | * |
| 6783 | * This routine blocks the issuing fabric iocb for a specified amount of |
| 6784 | * time (currently 100 ms). This is done by set the fabric iocb block bit |
| 6785 | * and set up a timeout timer for 100ms. When the block bit is set, no more |
| 6786 | * fabric iocb will be issued out of the HBA. |
| 6787 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6788 | static void |
| 6789 | lpfc_block_fabric_iocbs(struct lpfc_hba *phba) |
| 6790 | { |
| 6791 | int blocked; |
| 6792 | |
| 6793 | blocked = test_and_set_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 6794 | /* Start a timer to unblock fabric iocbs after 100ms */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6795 | if (!blocked) |
| 6796 | mod_timer(&phba->fabric_block_timer, jiffies + HZ/10 ); |
| 6797 | |
| 6798 | return; |
| 6799 | } |
| 6800 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6801 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6802 | * lpfc_cmpl_fabric_iocb - Completion callback function for fabric iocb |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6803 | * @phba: pointer to lpfc hba data structure. |
| 6804 | * @cmdiocb: pointer to lpfc command iocb data structure. |
| 6805 | * @rspiocb: pointer to lpfc response iocb data structure. |
| 6806 | * |
| 6807 | * This routine is the callback function that is put to the fabric iocb's |
| 6808 | * callback function pointer (iocb->iocb_cmpl). The original iocb's callback |
| 6809 | * function pointer has been stored in iocb->fabric_iocb_cmpl. This callback |
| 6810 | * function first restores and invokes the original iocb's callback function |
| 6811 | * and then invokes the lpfc_resume_fabric_iocbs() routine to issue the next |
| 6812 | * fabric bound iocb from the driver internal fabric iocb list onto the wire. |
| 6813 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6814 | static void |
| 6815 | lpfc_cmpl_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 6816 | struct lpfc_iocbq *rspiocb) |
| 6817 | { |
| 6818 | struct ls_rjt stat; |
| 6819 | |
| 6820 | if ((cmdiocb->iocb_flag & LPFC_IO_FABRIC) != LPFC_IO_FABRIC) |
| 6821 | BUG(); |
| 6822 | |
| 6823 | switch (rspiocb->iocb.ulpStatus) { |
| 6824 | case IOSTAT_NPORT_RJT: |
| 6825 | case IOSTAT_FABRIC_RJT: |
| 6826 | if (rspiocb->iocb.un.ulpWord[4] & RJT_UNAVAIL_TEMP) { |
| 6827 | lpfc_block_fabric_iocbs(phba); |
| 6828 | } |
| 6829 | break; |
| 6830 | |
| 6831 | case IOSTAT_NPORT_BSY: |
| 6832 | case IOSTAT_FABRIC_BSY: |
| 6833 | lpfc_block_fabric_iocbs(phba); |
| 6834 | break; |
| 6835 | |
| 6836 | case IOSTAT_LS_RJT: |
| 6837 | stat.un.lsRjtError = |
| 6838 | be32_to_cpu(rspiocb->iocb.un.ulpWord[4]); |
| 6839 | if ((stat.un.b.lsRjtRsnCode == LSRJT_UNABLE_TPC) || |
| 6840 | (stat.un.b.lsRjtRsnCode == LSRJT_LOGICAL_BSY)) |
| 6841 | lpfc_block_fabric_iocbs(phba); |
| 6842 | break; |
| 6843 | } |
| 6844 | |
| 6845 | if (atomic_read(&phba->fabric_iocb_count) == 0) |
| 6846 | BUG(); |
| 6847 | |
| 6848 | cmdiocb->iocb_cmpl = cmdiocb->fabric_iocb_cmpl; |
| 6849 | cmdiocb->fabric_iocb_cmpl = NULL; |
| 6850 | cmdiocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 6851 | cmdiocb->iocb_cmpl(phba, cmdiocb, rspiocb); |
| 6852 | |
| 6853 | atomic_dec(&phba->fabric_iocb_count); |
| 6854 | if (!test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags)) { |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 6855 | /* Post any pending iocbs to HBA */ |
| 6856 | lpfc_resume_fabric_iocbs(phba); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6857 | } |
| 6858 | } |
| 6859 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6860 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6861 | * lpfc_issue_fabric_iocb - Issue a fabric iocb command |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6862 | * @phba: pointer to lpfc hba data structure. |
| 6863 | * @iocb: pointer to lpfc command iocb data structure. |
| 6864 | * |
| 6865 | * This routine is used as the top-level API for issuing a fabric iocb command |
| 6866 | * such as FLOGI and FDISC. To accommodate certain switch fabric, this driver |
| 6867 | * function makes sure that only one fabric bound iocb will be outstanding at |
| 6868 | * any given time. As such, this function will first check to see whether there |
| 6869 | * is already an outstanding fabric iocb on the wire. If so, it will put the |
| 6870 | * newly issued iocb onto the driver internal fabric iocb list, waiting to be |
| 6871 | * issued later. Otherwise, it will issue the iocb on the wire and update the |
| 6872 | * fabric iocb count it indicate that there is one fabric iocb on the wire. |
| 6873 | * |
| 6874 | * Note, this implementation has a potential sending out fabric IOCBs out of |
| 6875 | * order. The problem is caused by the construction of the "ready" boolen does |
| 6876 | * not include the condition that the internal fabric IOCB list is empty. As |
| 6877 | * such, it is possible a fabric IOCB issued by this routine might be "jump" |
| 6878 | * ahead of the fabric IOCBs in the internal list. |
| 6879 | * |
| 6880 | * Return code |
| 6881 | * IOCB_SUCCESS - either fabric iocb put on the list or issued successfully |
| 6882 | * IOCB_ERROR - failed to issue fabric iocb |
| 6883 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 6884 | static int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6885 | lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb) |
| 6886 | { |
| 6887 | unsigned long iflags; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6888 | int ready; |
| 6889 | int ret; |
| 6890 | |
| 6891 | if (atomic_read(&phba->fabric_iocb_count) > 1) |
| 6892 | BUG(); |
| 6893 | |
| 6894 | spin_lock_irqsave(&phba->hbalock, iflags); |
| 6895 | ready = atomic_read(&phba->fabric_iocb_count) == 0 && |
| 6896 | !test_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); |
| 6897 | |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 6898 | if (ready) |
| 6899 | /* Increment fabric iocb count to hold the position */ |
| 6900 | atomic_inc(&phba->fabric_iocb_count); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6901 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 6902 | if (ready) { |
| 6903 | iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; |
| 6904 | iocb->iocb_cmpl = lpfc_cmpl_fabric_iocb; |
| 6905 | iocb->iocb_flag |= LPFC_IO_FABRIC; |
| 6906 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 6907 | lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD, |
| 6908 | "Fabric sched2: ste:x%x", |
| 6909 | iocb->vport->port_state, 0, 0); |
| 6910 | |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 6911 | ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, iocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6912 | |
| 6913 | if (ret == IOCB_ERROR) { |
| 6914 | iocb->iocb_cmpl = iocb->fabric_iocb_cmpl; |
| 6915 | iocb->fabric_iocb_cmpl = NULL; |
| 6916 | iocb->iocb_flag &= ~LPFC_IO_FABRIC; |
| 6917 | atomic_dec(&phba->fabric_iocb_count); |
| 6918 | } |
| 6919 | } else { |
| 6920 | spin_lock_irqsave(&phba->hbalock, iflags); |
| 6921 | list_add_tail(&iocb->list, &phba->fabric_iocb_list); |
| 6922 | spin_unlock_irqrestore(&phba->hbalock, iflags); |
| 6923 | ret = IOCB_SUCCESS; |
| 6924 | } |
| 6925 | return ret; |
| 6926 | } |
| 6927 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6928 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6929 | * 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] | 6930 | * @vport: pointer to a virtual N_Port data structure. |
| 6931 | * |
| 6932 | * This routine aborts all the IOCBs associated with a @vport from the |
| 6933 | * driver internal fabric IOCB list. The list contains fabric IOCBs to be |
| 6934 | * issued to the ELS IOCB ring. This abort function walks the fabric IOCB |
| 6935 | * list, removes each IOCB associated with the @vport off the list, set the |
| 6936 | * status feild to IOSTAT_LOCAL_REJECT, and invokes the callback function |
| 6937 | * associated with the IOCB. |
| 6938 | **/ |
Adrian Bunk | a6ababd | 2007-11-05 18:07:33 +0100 | [diff] [blame] | 6939 | static void lpfc_fabric_abort_vport(struct lpfc_vport *vport) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6940 | { |
| 6941 | LIST_HEAD(completions); |
| 6942 | struct lpfc_hba *phba = vport->phba; |
| 6943 | struct lpfc_iocbq *tmp_iocb, *piocb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6944 | |
| 6945 | spin_lock_irq(&phba->hbalock); |
| 6946 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, |
| 6947 | list) { |
| 6948 | |
| 6949 | if (piocb->vport != vport) |
| 6950 | continue; |
| 6951 | |
| 6952 | list_move_tail(&piocb->list, &completions); |
| 6953 | } |
| 6954 | spin_unlock_irq(&phba->hbalock); |
| 6955 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 6956 | /* Cancel all the IOCBs from the completions list */ |
| 6957 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 6958 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6959 | } |
| 6960 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6961 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6962 | * 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] | 6963 | * @ndlp: pointer to a node-list data structure. |
| 6964 | * |
| 6965 | * This routine aborts all the IOCBs associated with an @ndlp from the |
| 6966 | * driver internal fabric IOCB list. The list contains fabric IOCBs to be |
| 6967 | * issued to the ELS IOCB ring. This abort function walks the fabric IOCB |
| 6968 | * list, removes each IOCB associated with the @ndlp off the list, set the |
| 6969 | * status feild to IOSTAT_LOCAL_REJECT, and invokes the callback function |
| 6970 | * associated with the IOCB. |
| 6971 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6972 | void lpfc_fabric_abort_nport(struct lpfc_nodelist *ndlp) |
| 6973 | { |
| 6974 | LIST_HEAD(completions); |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 6975 | struct lpfc_hba *phba = ndlp->phba; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6976 | struct lpfc_iocbq *tmp_iocb, *piocb; |
| 6977 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6978 | |
| 6979 | spin_lock_irq(&phba->hbalock); |
| 6980 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, |
| 6981 | list) { |
| 6982 | if ((lpfc_check_sli_ndlp(phba, pring, piocb, ndlp))) { |
| 6983 | |
| 6984 | list_move_tail(&piocb->list, &completions); |
| 6985 | } |
| 6986 | } |
| 6987 | spin_unlock_irq(&phba->hbalock); |
| 6988 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 6989 | /* Cancel all the IOCBs from the completions list */ |
| 6990 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 6991 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 6992 | } |
| 6993 | |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6994 | /** |
James Smart | 3621a71 | 2009-04-06 18:47:14 -0400 | [diff] [blame] | 6995 | * lpfc_fabric_abort_hba - Abort all iocbs on driver fabric iocb list |
James Smart | e59058c | 2008-08-24 21:49:00 -0400 | [diff] [blame] | 6996 | * @phba: pointer to lpfc hba data structure. |
| 6997 | * |
| 6998 | * This routine aborts all the IOCBs currently on the driver internal |
| 6999 | * fabric IOCB list. The list contains fabric IOCBs to be issued to the ELS |
| 7000 | * IOCB ring. This function takes the entire IOCB list off the fabric IOCB |
| 7001 | * list, removes IOCBs off the list, set the status feild to |
| 7002 | * IOSTAT_LOCAL_REJECT, and invokes the callback function associated with |
| 7003 | * the IOCB. |
| 7004 | **/ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7005 | void lpfc_fabric_abort_hba(struct lpfc_hba *phba) |
| 7006 | { |
| 7007 | LIST_HEAD(completions); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7008 | |
| 7009 | spin_lock_irq(&phba->hbalock); |
| 7010 | list_splice_init(&phba->fabric_iocb_list, &completions); |
| 7011 | spin_unlock_irq(&phba->hbalock); |
| 7012 | |
James Smart | a257bf9 | 2009-04-06 18:48:10 -0400 | [diff] [blame] | 7013 | /* Cancel all the IOCBs from the completions list */ |
| 7014 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
| 7015 | IOERR_SLI_ABORTED); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 7016 | } |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7017 | |
| 7018 | /** |
| 7019 | * lpfc_sli4_els_xri_aborted - Slow-path process of els xri abort |
| 7020 | * @phba: pointer to lpfc hba data structure. |
| 7021 | * @axri: pointer to the els xri abort wcqe structure. |
| 7022 | * |
| 7023 | * This routine is invoked by the worker thread to process a SLI4 slow-path |
| 7024 | * ELS aborted xri. |
| 7025 | **/ |
| 7026 | void |
| 7027 | lpfc_sli4_els_xri_aborted(struct lpfc_hba *phba, |
| 7028 | struct sli4_wcqe_xri_aborted *axri) |
| 7029 | { |
| 7030 | uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri); |
| 7031 | struct lpfc_sglq *sglq_entry = NULL, *sglq_next = NULL; |
| 7032 | unsigned long iflag = 0; |
James Smart | 589a52d | 2010-07-14 15:30:54 -0400 | [diff] [blame] | 7033 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7034 | |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 7035 | spin_lock_irqsave(&phba->hbalock, iflag); |
| 7036 | spin_lock(&phba->sli4_hba.abts_sgl_list_lock); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7037 | list_for_each_entry_safe(sglq_entry, sglq_next, |
| 7038 | &phba->sli4_hba.lpfc_abts_els_sgl_list, list) { |
| 7039 | if (sglq_entry->sli4_xritag == xri) { |
| 7040 | list_del(&sglq_entry->list); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7041 | list_add_tail(&sglq_entry->list, |
| 7042 | &phba->sli4_hba.lpfc_sgl_list); |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 7043 | sglq_entry->state = SGL_FREED; |
| 7044 | spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7045 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
James Smart | 589a52d | 2010-07-14 15:30:54 -0400 | [diff] [blame] | 7046 | |
| 7047 | /* Check if TXQ queue needs to be serviced */ |
| 7048 | if (pring->txq_cnt) |
| 7049 | lpfc_worker_wake_up(phba); |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7050 | return; |
| 7051 | } |
| 7052 | } |
James Smart | 0f65ff6 | 2010-02-26 14:14:23 -0500 | [diff] [blame] | 7053 | spin_unlock(&phba->sli4_hba.abts_sgl_list_lock); |
| 7054 | sglq_entry = __lpfc_get_active_sglq(phba, xri); |
| 7055 | if (!sglq_entry || (sglq_entry->sli4_xritag != xri)) { |
| 7056 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 7057 | return; |
| 7058 | } |
| 7059 | sglq_entry->state = SGL_XRI_ABORTED; |
| 7060 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| 7061 | return; |
James Smart | 6fb120a | 2009-05-22 14:52:59 -0400 | [diff] [blame] | 7062 | } |