| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1 | /******************************************************************* |
| 2 | * This file is part of the Emulex Linux Device Driver for * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 3 | * Fibre Channel Host Bus Adapters. * |
James Smart | f25e8e7 | 2015-04-07 15:07:28 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2015 Emulex. All rights reserved. * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 5 | * EMULEX and SLI are trademarks of Emulex. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6 | * www.emulex.com * |
| 7 | * * |
| 8 | * 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] | 9 | * modify it under the terms of version 2 of the GNU General * |
| 10 | * Public License as published by the Free Software Foundation. * |
| 11 | * This program is distributed in the hope that it will be useful. * |
| 12 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 13 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 14 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 15 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 16 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 17 | * more details, a copy of which can be found in the file COPYING * |
| 18 | * included with this package. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 19 | *******************************************************************/ |
| 20 | |
| 21 | /* |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 22 | * Fibre Channel SCSI LAN Device Driver CT support: FC Generic Services FC-GS |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 23 | */ |
| 24 | |
| 25 | #include <linux/blkdev.h> |
| 26 | #include <linux/pci.h> |
| 27 | #include <linux/interrupt.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 28 | #include <linux/slab.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 29 | #include <linux/utsname.h> |
| 30 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 31 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 32 | #include <scsi/scsi_device.h> |
| 33 | #include <scsi/scsi_host.h> |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 34 | #include <scsi/scsi_transport_fc.h> |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 35 | #include <scsi/fc/fc_fs.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 36 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 37 | #include "lpfc_hw4.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 38 | #include "lpfc_hw.h" |
| 39 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 40 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 41 | #include "lpfc_nl.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 42 | #include "lpfc_disc.h" |
| 43 | #include "lpfc_scsi.h" |
| 44 | #include "lpfc.h" |
| 45 | #include "lpfc_logmsg.h" |
| 46 | #include "lpfc_crtn.h" |
| 47 | #include "lpfc_version.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 48 | #include "lpfc_vport.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 49 | #include "lpfc_debugfs.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 50 | |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 51 | /* FDMI Port Speed definitions */ |
| 52 | #define HBA_PORTSPEED_1GBIT 0x0001 /* 1 GBit/sec */ |
| 53 | #define HBA_PORTSPEED_2GBIT 0x0002 /* 2 GBit/sec */ |
| 54 | #define HBA_PORTSPEED_4GBIT 0x0008 /* 4 GBit/sec */ |
| 55 | #define HBA_PORTSPEED_10GBIT 0x0004 /* 10 GBit/sec */ |
| 56 | #define HBA_PORTSPEED_8GBIT 0x0010 /* 8 GBit/sec */ |
| 57 | #define HBA_PORTSPEED_16GBIT 0x0020 /* 16 GBit/sec */ |
James Smart | d38dd52 | 2015-08-31 16:48:17 -0400 | [diff] [blame] | 58 | #define HBA_PORTSPEED_32GBIT 0x0040 /* 32 GBit/sec */ |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 59 | #define HBA_PORTSPEED_UNKNOWN 0x0800 /* Unknown */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 60 | |
| 61 | #define FOURBYTES 4 |
| 62 | |
| 63 | |
| 64 | static char *lpfc_release_version = LPFC_DRIVER_VERSION; |
| 65 | |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 66 | static void |
| 67 | lpfc_ct_ignore_hbq_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 68 | struct lpfc_dmabuf *mp, uint32_t size) |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 69 | { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 70 | if (!mp) { |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 71 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, |
James Smart | 97eab63 | 2008-04-07 10:16:05 -0400 | [diff] [blame] | 72 | "0146 Ignoring unsolicited CT No HBQ " |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 73 | "status = x%x\n", |
| 74 | piocbq->iocb.ulpStatus); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 75 | } |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 76 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, |
| 77 | "0145 Ignoring unsolicted CT HBQ Size:%d " |
| 78 | "status = x%x\n", |
| 79 | size, piocbq->iocb.ulpStatus); |
| 80 | } |
| 81 | |
| 82 | static void |
| 83 | lpfc_ct_unsol_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq, |
| 84 | struct lpfc_dmabuf *mp, uint32_t size) |
| 85 | { |
| 86 | lpfc_ct_ignore_hbq_buffer(phba, piocbq, mp, size); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 87 | } |
| 88 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 89 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 90 | lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
| 91 | struct lpfc_iocbq *piocbq) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 92 | { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 93 | struct lpfc_dmabuf *mp = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 94 | IOCB_t *icmd = &piocbq->iocb; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 95 | int i; |
| 96 | struct lpfc_iocbq *iocbq; |
| 97 | dma_addr_t paddr; |
| 98 | uint32_t size; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 99 | struct list_head head; |
| 100 | struct lpfc_dmabuf *bdeBuf; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 101 | |
James Smart | 4fede78 | 2010-01-26 23:08:55 -0500 | [diff] [blame] | 102 | if (lpfc_bsg_ct_unsol_event(phba, pring, piocbq) == 0) |
| 103 | return; |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 104 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 105 | if (unlikely(icmd->ulpStatus == IOSTAT_NEED_BUFFER)) { |
| 106 | lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ); |
| 107 | } else if ((icmd->ulpStatus == IOSTAT_LOCAL_REJECT) && |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 108 | ((icmd->un.ulpWord[4] & IOERR_PARAM_MASK) == |
| 109 | IOERR_RCV_BUFFER_WAITING)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 110 | /* Not enough posted buffers; Try posting more buffers */ |
| 111 | phba->fc_stat.NoRcvBuf++; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 112 | if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)) |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 113 | lpfc_post_buffer(phba, pring, 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 114 | return; |
| 115 | } |
| 116 | |
| 117 | /* If there are no BDEs associated with this IOCB, |
| 118 | * there is nothing to do. |
| 119 | */ |
| 120 | if (icmd->ulpBdeCount == 0) |
| 121 | return; |
| 122 | |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 123 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 124 | INIT_LIST_HEAD(&head); |
| 125 | list_add_tail(&head, &piocbq->list); |
| 126 | list_for_each_entry(iocbq, &head, list) { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 127 | icmd = &iocbq->iocb; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 128 | if (icmd->ulpBdeCount == 0) |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 129 | continue; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 130 | bdeBuf = iocbq->context2; |
| 131 | iocbq->context2 = NULL; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 132 | size = icmd->un.cont64[0].tus.f.bdeSize; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 133 | lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, size); |
| 134 | lpfc_in_buf_free(phba, bdeBuf); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 135 | if (icmd->ulpBdeCount == 2) { |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 136 | bdeBuf = iocbq->context3; |
| 137 | iocbq->context3 = NULL; |
| 138 | size = icmd->unsli3.rcvsli3.bde2.tus.f.bdeSize; |
| 139 | lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, |
| 140 | size); |
| 141 | lpfc_in_buf_free(phba, bdeBuf); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 142 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 143 | } |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 144 | list_del(&head); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 145 | } else { |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 146 | INIT_LIST_HEAD(&head); |
| 147 | list_add_tail(&head, &piocbq->list); |
| 148 | list_for_each_entry(iocbq, &head, list) { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 149 | icmd = &iocbq->iocb; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 150 | if (icmd->ulpBdeCount == 0) |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 151 | lpfc_ct_unsol_buffer(phba, iocbq, NULL, 0); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 152 | for (i = 0; i < icmd->ulpBdeCount; i++) { |
| 153 | paddr = getPaddr(icmd->un.cont64[i].addrHigh, |
| 154 | icmd->un.cont64[i].addrLow); |
| 155 | mp = lpfc_sli_ringpostbuf_get(phba, pring, |
| 156 | paddr); |
| 157 | size = icmd->un.cont64[i].tus.f.bdeSize; |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 158 | lpfc_ct_unsol_buffer(phba, iocbq, mp, size); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 159 | lpfc_in_buf_free(phba, mp); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 160 | } |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 161 | lpfc_post_buffer(phba, pring, i); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 162 | } |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 163 | list_del(&head); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 164 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 165 | } |
| 166 | |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 167 | /** |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 168 | * lpfc_ct_handle_unsol_abort - ct upper level protocol abort handler |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 169 | * @phba: Pointer to HBA context object. |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 170 | * @dmabuf: pointer to a dmabuf that describes the FC sequence |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 171 | * |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 172 | * This function serves as the upper level protocol abort handler for CT |
| 173 | * protocol. |
| 174 | * |
| 175 | * Return 1 if abort has been handled, 0 otherwise. |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 176 | **/ |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 177 | int |
| 178 | lpfc_ct_handle_unsol_abort(struct lpfc_hba *phba, struct hbq_dmabuf *dmabuf) |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 179 | { |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 180 | int handled; |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 181 | |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 182 | /* CT upper level goes through BSG */ |
| 183 | handled = lpfc_bsg_ct_unsol_abort(phba, dmabuf); |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 184 | |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 185 | return handled; |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 186 | } |
| 187 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 188 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 189 | lpfc_free_ct_rsp(struct lpfc_hba *phba, struct lpfc_dmabuf *mlist) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 190 | { |
| 191 | struct lpfc_dmabuf *mlast, *next_mlast; |
| 192 | |
| 193 | list_for_each_entry_safe(mlast, next_mlast, &mlist->list, list) { |
| 194 | lpfc_mbuf_free(phba, mlast->virt, mlast->phys); |
| 195 | list_del(&mlast->list); |
| 196 | kfree(mlast); |
| 197 | } |
| 198 | lpfc_mbuf_free(phba, mlist->virt, mlist->phys); |
| 199 | kfree(mlist); |
| 200 | return; |
| 201 | } |
| 202 | |
| 203 | static struct lpfc_dmabuf * |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 204 | lpfc_alloc_ct_rsp(struct lpfc_hba *phba, int cmdcode, struct ulp_bde64 *bpl, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 205 | uint32_t size, int *entries) |
| 206 | { |
| 207 | struct lpfc_dmabuf *mlist = NULL; |
| 208 | struct lpfc_dmabuf *mp; |
| 209 | int cnt, i = 0; |
| 210 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 211 | /* We get chunks of FCELSSIZE */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 212 | cnt = size > FCELSSIZE ? FCELSSIZE: size; |
| 213 | |
| 214 | while (size) { |
| 215 | /* Allocate buffer for rsp payload */ |
| 216 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| 217 | if (!mp) { |
| 218 | if (mlist) |
| 219 | lpfc_free_ct_rsp(phba, mlist); |
| 220 | return NULL; |
| 221 | } |
| 222 | |
| 223 | INIT_LIST_HEAD(&mp->list); |
| 224 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 225 | if (cmdcode == be16_to_cpu(SLI_CTNS_GID_FT) || |
| 226 | cmdcode == be16_to_cpu(SLI_CTNS_GFF_ID)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 227 | mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); |
| 228 | else |
| 229 | mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys)); |
| 230 | |
| 231 | if (!mp->virt) { |
| 232 | kfree(mp); |
Eric Sesterhenn | 0b3a82d | 2006-10-10 14:41:43 -0700 | [diff] [blame] | 233 | if (mlist) |
| 234 | lpfc_free_ct_rsp(phba, mlist); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 235 | return NULL; |
| 236 | } |
| 237 | |
| 238 | /* Queue it to a linked list */ |
| 239 | if (!mlist) |
| 240 | mlist = mp; |
| 241 | else |
| 242 | list_add_tail(&mp->list, &mlist->list); |
| 243 | |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 244 | bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64I; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 245 | /* build buffer ptr list for IOCB */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 246 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); |
| 247 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 248 | bpl->tus.f.bdeSize = (uint16_t) cnt; |
| 249 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 250 | bpl++; |
| 251 | |
| 252 | i++; |
| 253 | size -= cnt; |
| 254 | } |
| 255 | |
| 256 | *entries = i; |
| 257 | return mlist; |
| 258 | } |
| 259 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 260 | int |
| 261 | lpfc_ct_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocb) |
| 262 | { |
| 263 | struct lpfc_dmabuf *buf_ptr; |
| 264 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 265 | if (ctiocb->context_un.ndlp) { |
| 266 | lpfc_nlp_put(ctiocb->context_un.ndlp); |
| 267 | ctiocb->context_un.ndlp = NULL; |
| 268 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 269 | if (ctiocb->context1) { |
| 270 | buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1; |
| 271 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 272 | kfree(buf_ptr); |
| 273 | ctiocb->context1 = NULL; |
| 274 | } |
| 275 | if (ctiocb->context2) { |
| 276 | lpfc_free_ct_rsp(phba, (struct lpfc_dmabuf *) ctiocb->context2); |
| 277 | ctiocb->context2 = NULL; |
| 278 | } |
| 279 | |
| 280 | if (ctiocb->context3) { |
| 281 | buf_ptr = (struct lpfc_dmabuf *) ctiocb->context3; |
| 282 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 283 | kfree(buf_ptr); |
Felipe Pena | 1109c94 | 2013-10-15 21:29:50 -0300 | [diff] [blame] | 284 | ctiocb->context3 = NULL; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 285 | } |
| 286 | lpfc_sli_release_iocbq(phba, ctiocb); |
| 287 | return 0; |
| 288 | } |
| 289 | |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 290 | /** |
| 291 | * lpfc_gen_req - Build and issue a GEN_REQUEST command to the SLI Layer |
| 292 | * @vport: pointer to a host virtual N_Port data structure. |
| 293 | * @bmp: Pointer to BPL for SLI command |
| 294 | * @inp: Pointer to data buffer for response data. |
| 295 | * @outp: Pointer to data buffer that hold the CT command. |
| 296 | * @cmpl: completion routine to call when command completes |
| 297 | * @ndlp: Destination NPort nodelist entry |
| 298 | * |
| 299 | * This function as the final part for issuing a CT command. |
| 300 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 301 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 302 | lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 303 | struct lpfc_dmabuf *inp, struct lpfc_dmabuf *outp, |
| 304 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 305 | struct lpfc_iocbq *), |
| 306 | struct lpfc_nodelist *ndlp, uint32_t usr_flg, uint32_t num_entry, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 307 | uint32_t tmo, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 308 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 309 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 310 | IOCB_t *icmd; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 311 | struct lpfc_iocbq *geniocb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 312 | int rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 313 | |
| 314 | /* Allocate buffer for command iocb */ |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 315 | geniocb = lpfc_sli_get_iocbq(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 316 | |
| 317 | if (geniocb == NULL) |
| 318 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 319 | |
| 320 | icmd = &geniocb->iocb; |
| 321 | icmd->un.genreq64.bdl.ulpIoTag32 = 0; |
| 322 | icmd->un.genreq64.bdl.addrHigh = putPaddrHigh(bmp->phys); |
| 323 | icmd->un.genreq64.bdl.addrLow = putPaddrLow(bmp->phys); |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 324 | icmd->un.genreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 325 | icmd->un.genreq64.bdl.bdeSize = (num_entry * sizeof(struct ulp_bde64)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 326 | |
| 327 | if (usr_flg) |
| 328 | geniocb->context3 = NULL; |
| 329 | else |
| 330 | geniocb->context3 = (uint8_t *) bmp; |
| 331 | |
| 332 | /* Save for completion so we can release these resources */ |
| 333 | geniocb->context1 = (uint8_t *) inp; |
| 334 | geniocb->context2 = (uint8_t *) outp; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 335 | geniocb->context_un.ndlp = lpfc_nlp_get(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 336 | |
| 337 | /* Fill in payload, bp points to frame payload */ |
| 338 | icmd->ulpCommand = CMD_GEN_REQUEST64_CR; |
| 339 | |
| 340 | /* Fill in rest of iocb */ |
| 341 | icmd->un.genreq64.w5.hcsw.Fctl = (SI | LA); |
| 342 | icmd->un.genreq64.w5.hcsw.Dfctl = 0; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 343 | icmd->un.genreq64.w5.hcsw.Rctl = FC_RCTL_DD_UNSOL_CTL; |
| 344 | icmd->un.genreq64.w5.hcsw.Type = FC_TYPE_CT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 345 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 346 | if (!tmo) { |
| 347 | /* FC spec states we need 3 * ratov for CT requests */ |
| 348 | tmo = (3 * phba->fc_ratov); |
| 349 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 350 | icmd->ulpTimeout = tmo; |
| 351 | icmd->ulpBdeCount = 1; |
| 352 | icmd->ulpLe = 1; |
| 353 | icmd->ulpClass = CLASS3; |
| 354 | icmd->ulpContext = ndlp->nlp_rpi; |
James Smart | 6d368e5 | 2011-05-24 11:44:12 -0400 | [diff] [blame] | 355 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 356 | icmd->ulpContext = phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 357 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 358 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
| 359 | /* For GEN_REQUEST64_CR, use the RPI */ |
| 360 | icmd->ulpCt_h = 0; |
| 361 | icmd->ulpCt_l = 0; |
| 362 | } |
| 363 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 364 | /* Issue GEN REQ IOCB for NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 365 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 366 | "0119 Issue GEN REQ IOCB to NPORT x%x " |
| 367 | "Data: x%x x%x\n", |
| 368 | ndlp->nlp_DID, icmd->ulpIoTag, |
| 369 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 370 | geniocb->iocb_cmpl = cmpl; |
| 371 | geniocb->drvrTimeout = icmd->ulpTimeout + LPFC_DRVR_TIMEOUT; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 372 | geniocb->vport = vport; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 373 | geniocb->retry = retry; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 374 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, geniocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 375 | |
| 376 | if (rc == IOCB_ERROR) { |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 377 | lpfc_sli_release_iocbq(phba, geniocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 378 | return 1; |
| 379 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 380 | |
| 381 | return 0; |
| 382 | } |
| 383 | |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 384 | /** |
| 385 | * lpfc_ct_cmd - Build and issue a CT command |
| 386 | * @vport: pointer to a host virtual N_Port data structure. |
| 387 | * @inmp: Pointer to data buffer for response data. |
| 388 | * @bmp: Pointer to BPL for SLI command |
| 389 | * @ndlp: Destination NPort nodelist entry |
| 390 | * @cmpl: completion routine to call when command completes |
| 391 | * |
| 392 | * This function is called for issuing a CT command. |
| 393 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 394 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 395 | lpfc_ct_cmd(struct lpfc_vport *vport, struct lpfc_dmabuf *inmp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 396 | struct lpfc_dmabuf *bmp, struct lpfc_nodelist *ndlp, |
| 397 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 398 | struct lpfc_iocbq *), |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 399 | uint32_t rsp_size, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 400 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 401 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 402 | struct ulp_bde64 *bpl = (struct ulp_bde64 *) bmp->virt; |
| 403 | struct lpfc_dmabuf *outmp; |
| 404 | int cnt = 0, status; |
| 405 | int cmdcode = ((struct lpfc_sli_ct_request *) inmp->virt)-> |
| 406 | CommandResponse.bits.CmdRsp; |
| 407 | |
| 408 | bpl++; /* Skip past ct request */ |
| 409 | |
| 410 | /* Put buffer(s) for ct rsp in bpl */ |
| 411 | outmp = lpfc_alloc_ct_rsp(phba, cmdcode, bpl, rsp_size, &cnt); |
| 412 | if (!outmp) |
| 413 | return -ENOMEM; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 414 | /* |
| 415 | * Form the CT IOCB. The total number of BDEs in this IOCB |
| 416 | * is the single command plus response count from |
| 417 | * lpfc_alloc_ct_rsp. |
| 418 | */ |
| 419 | cnt += 1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 420 | status = lpfc_gen_req(vport, bmp, inmp, outmp, cmpl, ndlp, 0, |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 421 | cnt, 0, retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 422 | if (status) { |
| 423 | lpfc_free_ct_rsp(phba, outmp); |
| 424 | return -ENOMEM; |
| 425 | } |
| 426 | return 0; |
| 427 | } |
| 428 | |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 429 | struct lpfc_vport * |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 430 | lpfc_find_vport_by_did(struct lpfc_hba *phba, uint32_t did) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 431 | struct lpfc_vport *vport_curr; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 432 | unsigned long flags; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 433 | |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 434 | spin_lock_irqsave(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 435 | list_for_each_entry(vport_curr, &phba->port_list, listentry) { |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 436 | if ((vport_curr->fc_myDID) && (vport_curr->fc_myDID == did)) { |
| 437 | spin_unlock_irqrestore(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 438 | return vport_curr; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 439 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 440 | } |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 441 | spin_unlock_irqrestore(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 442 | return NULL; |
| 443 | } |
| 444 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 445 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 446 | lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 447 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 448 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 449 | struct lpfc_sli_ct_request *Response = |
| 450 | (struct lpfc_sli_ct_request *) mp->virt; |
| 451 | struct lpfc_nodelist *ndlp = NULL; |
| 452 | struct lpfc_dmabuf *mlast, *next_mp; |
| 453 | uint32_t *ctptr = (uint32_t *) & Response->un.gid.PortType; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 454 | uint32_t Did, CTentry; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 455 | int Cnt; |
| 456 | struct list_head head; |
| 457 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 458 | lpfc_set_disctmo(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 459 | vport->num_disc_nodes = 0; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 460 | vport->fc_ns_retry = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 461 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 462 | |
| 463 | list_add_tail(&head, &mp->list); |
| 464 | list_for_each_entry_safe(mp, next_mp, &head, list) { |
| 465 | mlast = mp; |
| 466 | |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 467 | Cnt = Size > FCELSSIZE ? FCELSSIZE : Size; |
| 468 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 469 | Size -= Cnt; |
| 470 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 471 | if (!ctptr) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 472 | ctptr = (uint32_t *) mlast->virt; |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 473 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 474 | Cnt -= 16; /* subtract length of CT header */ |
| 475 | |
| 476 | /* Loop through entire NameServer list of DIDs */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 477 | while (Cnt >= sizeof(uint32_t)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 478 | /* Get next DID from NameServer List */ |
| 479 | CTentry = *ctptr++; |
| 480 | Did = ((be32_to_cpu(CTentry)) & Mask_DID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 481 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 482 | ndlp = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 483 | |
| 484 | /* |
| 485 | * Check for rscn processing or not |
| 486 | * To conserve rpi's, filter out addresses for other |
| 487 | * vports on the same physical HBAs. |
| 488 | */ |
| 489 | if ((Did != vport->fc_myDID) && |
| 490 | ((lpfc_find_vport_by_did(phba, Did) == NULL) || |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 491 | vport->cfg_peer_port_login)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 492 | if ((vport->port_type != LPFC_NPIV_PORT) || |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 493 | (!(vport->ct_flags & FC_CT_RFF_ID)) || |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 494 | (!vport->cfg_restrict_login)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 495 | ndlp = lpfc_setup_disc_node(vport, Did); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 496 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 497 | lpfc_debugfs_disc_trc(vport, |
| 498 | LPFC_DISC_TRC_CT, |
| 499 | "Parse GID_FTrsp: " |
| 500 | "did:x%x flg:x%x x%x", |
| 501 | Did, ndlp->nlp_flag, |
| 502 | vport->fc_flag); |
| 503 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 504 | lpfc_printf_vlog(vport, |
| 505 | KERN_INFO, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 506 | LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 507 | "0238 Process " |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 508 | "x%x NameServer Rsp" |
| 509 | "Data: x%x x%x x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 510 | Did, ndlp->nlp_flag, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 511 | vport->fc_flag, |
| 512 | vport->fc_rscn_id_cnt); |
| 513 | } else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 514 | lpfc_debugfs_disc_trc(vport, |
| 515 | LPFC_DISC_TRC_CT, |
| 516 | "Skip1 GID_FTrsp: " |
| 517 | "did:x%x flg:x%x cnt:%d", |
| 518 | Did, vport->fc_flag, |
| 519 | vport->fc_rscn_id_cnt); |
| 520 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 521 | lpfc_printf_vlog(vport, |
| 522 | KERN_INFO, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 523 | LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 524 | "0239 Skip x%x " |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 525 | "NameServer Rsp Data: " |
| 526 | "x%x x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 527 | Did, vport->fc_flag, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 528 | vport->fc_rscn_id_cnt); |
| 529 | } |
| 530 | |
| 531 | } else { |
| 532 | if (!(vport->fc_flag & FC_RSCN_MODE) || |
| 533 | (lpfc_rscn_payload_check(vport, Did))) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 534 | lpfc_debugfs_disc_trc(vport, |
| 535 | LPFC_DISC_TRC_CT, |
| 536 | "Query GID_FTrsp: " |
| 537 | "did:x%x flg:x%x cnt:%d", |
| 538 | Did, vport->fc_flag, |
| 539 | vport->fc_rscn_id_cnt); |
| 540 | |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 541 | /* This NPortID was previously |
| 542 | * a FCP target, * Don't even |
| 543 | * bother to send GFF_ID. |
| 544 | */ |
| 545 | ndlp = lpfc_findnode_did(vport, |
| 546 | Did); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 547 | if (ndlp && |
| 548 | NLP_CHK_NODE_ACT(ndlp) |
| 549 | && (ndlp->nlp_type & |
| 550 | NLP_FCP_TARGET)) |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 551 | lpfc_setup_disc_node |
| 552 | (vport, Did); |
| 553 | else if (lpfc_ns_cmd(vport, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 554 | SLI_CTNS_GFF_ID, |
| 555 | 0, Did) == 0) |
| 556 | vport->num_disc_nodes++; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 557 | else |
| 558 | lpfc_setup_disc_node |
| 559 | (vport, Did); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 560 | } |
| 561 | else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 562 | lpfc_debugfs_disc_trc(vport, |
| 563 | LPFC_DISC_TRC_CT, |
| 564 | "Skip2 GID_FTrsp: " |
| 565 | "did:x%x flg:x%x cnt:%d", |
| 566 | Did, vport->fc_flag, |
| 567 | vport->fc_rscn_id_cnt); |
| 568 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 569 | lpfc_printf_vlog(vport, |
| 570 | KERN_INFO, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 571 | LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 572 | "0245 Skip x%x " |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 573 | "NameServer Rsp Data: " |
| 574 | "x%x x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 575 | Did, vport->fc_flag, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 576 | vport->fc_rscn_id_cnt); |
| 577 | } |
| 578 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 579 | } |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 580 | if (CTentry & (cpu_to_be32(SLI_CT_LAST_ENTRY))) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 581 | goto nsout1; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 582 | Cnt -= sizeof(uint32_t); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 583 | } |
| 584 | ctptr = NULL; |
| 585 | |
| 586 | } |
| 587 | |
| 588 | nsout1: |
| 589 | list_del(&head); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 590 | return 0; |
| 591 | } |
| 592 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 593 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 594 | lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 595 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 596 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 597 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 598 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 599 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 600 | struct lpfc_dmabuf *outp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 601 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 602 | struct lpfc_nodelist *ndlp; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 603 | int rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 604 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 605 | /* First save ndlp, before we overwrite it */ |
| 606 | ndlp = cmdiocb->context_un.ndlp; |
| 607 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 608 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 609 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 610 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 611 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 612 | irsp = &rspiocb->iocb; |
| 613 | |
| 614 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 615 | "GID_FT cmpl: status:x%x/x%x rtry:%d", |
| 616 | irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_ns_retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 617 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 618 | /* Don't bother processing response if vport is being torn down. */ |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 619 | if (vport->load_flag & FC_UNLOADING) { |
| 620 | if (vport->fc_flag & FC_RSCN_MODE) |
| 621 | lpfc_els_flush_rscn(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 622 | goto out; |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 623 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 624 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 625 | if (lpfc_els_chk_latt(vport)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 626 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 627 | "0216 Link event during NS query\n"); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 628 | if (vport->fc_flag & FC_RSCN_MODE) |
| 629 | lpfc_els_flush_rscn(vport); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 630 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 631 | goto out; |
| 632 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 633 | if (lpfc_error_lost_link(irsp)) { |
| 634 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 635 | "0226 NS query failed due to link event\n"); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 636 | if (vport->fc_flag & FC_RSCN_MODE) |
| 637 | lpfc_els_flush_rscn(vport); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 638 | goto out; |
| 639 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 640 | if (irsp->ulpStatus) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 641 | /* Check for retry */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 642 | if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 643 | if (irsp->ulpStatus != IOSTAT_LOCAL_REJECT || |
James Smart | edb22f0 | 2012-10-31 14:45:21 -0400 | [diff] [blame] | 644 | (irsp->un.ulpWord[4] & IOERR_PARAM_MASK) != |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 645 | IOERR_NO_RESOURCES) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 646 | vport->fc_ns_retry++; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 647 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 648 | /* CT command is being retried */ |
| 649 | rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 650 | vport->fc_ns_retry, 0); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 651 | if (rc == 0) |
| 652 | goto out; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 653 | } |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 654 | if (vport->fc_flag & FC_RSCN_MODE) |
| 655 | lpfc_els_flush_rscn(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 656 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 657 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 658 | "0257 GID_FT Query error: 0x%x 0x%x\n", |
| 659 | irsp->ulpStatus, vport->fc_ns_retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 660 | } else { |
| 661 | /* Good status, continue checking */ |
| 662 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 663 | if (CTrsp->CommandResponse.bits.CmdRsp == |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 664 | cpu_to_be16(SLI_CT_RESPONSE_FS_ACC)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 665 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 666 | "0208 NameServer Rsp Data: x%x\n", |
| 667 | vport->fc_flag); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 668 | lpfc_ns_rsp(vport, outp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 669 | (uint32_t) (irsp->un.genreq64.bdl.bdeSize)); |
| 670 | } else if (CTrsp->CommandResponse.bits.CmdRsp == |
| 671 | be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { |
| 672 | /* NameServer Rsp Error */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 673 | if ((CTrsp->ReasonCode == SLI_CT_UNABLE_TO_PERFORM_REQ) |
| 674 | && (CTrsp->Explanation == SLI_CT_NO_FC4_TYPES)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 675 | lpfc_printf_vlog(vport, KERN_INFO, |
| 676 | LOG_DISCOVERY, |
| 677 | "0269 No NameServer Entries " |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 678 | "Data: x%x x%x x%x x%x\n", |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 679 | CTrsp->CommandResponse.bits.CmdRsp, |
| 680 | (uint32_t) CTrsp->ReasonCode, |
| 681 | (uint32_t) CTrsp->Explanation, |
| 682 | vport->fc_flag); |
| 683 | |
| 684 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 685 | "GID_FT no entry cmd:x%x rsn:x%x exp:x%x", |
| 686 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 687 | (uint32_t) CTrsp->ReasonCode, |
| 688 | (uint32_t) CTrsp->Explanation); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 689 | } else { |
| 690 | lpfc_printf_vlog(vport, KERN_INFO, |
| 691 | LOG_DISCOVERY, |
| 692 | "0240 NameServer Rsp Error " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 693 | "Data: x%x x%x x%x x%x\n", |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 694 | CTrsp->CommandResponse.bits.CmdRsp, |
| 695 | (uint32_t) CTrsp->ReasonCode, |
| 696 | (uint32_t) CTrsp->Explanation, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 697 | vport->fc_flag); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 698 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 699 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 700 | "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x", |
| 701 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 702 | (uint32_t) CTrsp->ReasonCode, |
| 703 | (uint32_t) CTrsp->Explanation); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 704 | } |
| 705 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 706 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 707 | } else { |
| 708 | /* NameServer Rsp Error */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 709 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 710 | "0241 NameServer Rsp Error " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 711 | "Data: x%x x%x x%x x%x\n", |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 712 | CTrsp->CommandResponse.bits.CmdRsp, |
| 713 | (uint32_t) CTrsp->ReasonCode, |
| 714 | (uint32_t) CTrsp->Explanation, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 715 | vport->fc_flag); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 716 | |
| 717 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 718 | "GID_FT rsp err2 cmd:x%x rsn:x%x exp:x%x", |
| 719 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 720 | (uint32_t) CTrsp->ReasonCode, |
| 721 | (uint32_t) CTrsp->Explanation); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 722 | } |
| 723 | } |
| 724 | /* Link up / RSCN discovery */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 725 | if (vport->num_disc_nodes == 0) { |
| 726 | /* |
| 727 | * The driver has cycled through all Nports in the RSCN payload. |
| 728 | * Complete the handling by cleaning up and marking the |
| 729 | * current driver state. |
| 730 | */ |
| 731 | if (vport->port_state >= LPFC_DISC_AUTH) { |
| 732 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 733 | lpfc_els_flush_rscn(vport); |
| 734 | spin_lock_irq(shost->host_lock); |
| 735 | vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ |
| 736 | spin_unlock_irq(shost->host_lock); |
| 737 | } |
| 738 | else |
| 739 | lpfc_els_flush_rscn(vport); |
| 740 | } |
| 741 | |
| 742 | lpfc_disc_start(vport); |
| 743 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 744 | out: |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 745 | cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 746 | lpfc_ct_free_iocb(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 747 | return; |
| 748 | } |
| 749 | |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 750 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 751 | lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 752 | struct lpfc_iocbq *rspiocb) |
| 753 | { |
| 754 | struct lpfc_vport *vport = cmdiocb->vport; |
| 755 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 756 | IOCB_t *irsp = &rspiocb->iocb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 757 | struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1; |
| 758 | struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 759 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 760 | int did, rc, retry; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 761 | uint8_t fbits; |
| 762 | struct lpfc_nodelist *ndlp; |
| 763 | |
| 764 | did = ((struct lpfc_sli_ct_request *) inp->virt)->un.gff.PortId; |
| 765 | did = be32_to_cpu(did); |
| 766 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 767 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 768 | "GFF_ID cmpl: status:x%x/x%x did:x%x", |
| 769 | irsp->ulpStatus, irsp->un.ulpWord[4], did); |
| 770 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 771 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 772 | /* Good status, continue checking */ |
| 773 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 774 | fbits = CTrsp->un.gff_acc.fbits[FCP_TYPE_FEATURE_OFFSET]; |
| 775 | |
| 776 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 777 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { |
| 778 | if ((fbits & FC4_FEATURE_INIT) && |
| 779 | !(fbits & FC4_FEATURE_TARGET)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 780 | lpfc_printf_vlog(vport, KERN_INFO, |
| 781 | LOG_DISCOVERY, |
| 782 | "0270 Skip x%x GFF " |
| 783 | "NameServer Rsp Data: (init) " |
| 784 | "x%x x%x\n", did, fbits, |
| 785 | vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 786 | goto out; |
| 787 | } |
| 788 | } |
| 789 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 790 | else { |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 791 | /* Check for retry */ |
| 792 | if (cmdiocb->retry < LPFC_MAX_NS_RETRY) { |
| 793 | retry = 1; |
| 794 | if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) { |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 795 | switch ((irsp->un.ulpWord[4] & |
| 796 | IOERR_PARAM_MASK)) { |
| 797 | |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 798 | case IOERR_NO_RESOURCES: |
| 799 | /* We don't increment the retry |
| 800 | * count for this case. |
| 801 | */ |
| 802 | break; |
| 803 | case IOERR_LINK_DOWN: |
| 804 | case IOERR_SLI_ABORTED: |
| 805 | case IOERR_SLI_DOWN: |
| 806 | retry = 0; |
| 807 | break; |
| 808 | default: |
| 809 | cmdiocb->retry++; |
| 810 | } |
| 811 | } |
| 812 | else |
| 813 | cmdiocb->retry++; |
| 814 | |
| 815 | if (retry) { |
| 816 | /* CT command is being retried */ |
| 817 | rc = lpfc_ns_cmd(vport, SLI_CTNS_GFF_ID, |
| 818 | cmdiocb->retry, did); |
| 819 | if (rc == 0) { |
| 820 | /* success */ |
| 821 | lpfc_ct_free_iocb(phba, cmdiocb); |
| 822 | return; |
| 823 | } |
| 824 | } |
| 825 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 826 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 827 | "0267 NameServer GFF Rsp " |
| 828 | "x%x Error (%d %d) Data: x%x x%x\n", |
| 829 | did, irsp->ulpStatus, irsp->un.ulpWord[4], |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 830 | vport->fc_flag, vport->fc_rscn_id_cnt); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 831 | } |
| 832 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 833 | /* This is a target port, unregistered port, or the GFF_ID failed */ |
| 834 | ndlp = lpfc_setup_disc_node(vport, did); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 835 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 836 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 837 | "0242 Process x%x GFF " |
| 838 | "NameServer Rsp Data: x%x x%x x%x\n", |
| 839 | did, ndlp->nlp_flag, vport->fc_flag, |
| 840 | vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 841 | } else { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 842 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 843 | "0243 Skip x%x GFF " |
| 844 | "NameServer Rsp Data: x%x x%x\n", did, |
| 845 | vport->fc_flag, vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 846 | } |
| 847 | out: |
| 848 | /* Link up / RSCN discovery */ |
| 849 | if (vport->num_disc_nodes) |
| 850 | vport->num_disc_nodes--; |
| 851 | if (vport->num_disc_nodes == 0) { |
| 852 | /* |
| 853 | * The driver has cycled through all Nports in the RSCN payload. |
| 854 | * Complete the handling by cleaning up and marking the |
| 855 | * current driver state. |
| 856 | */ |
| 857 | if (vport->port_state >= LPFC_DISC_AUTH) { |
| 858 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 859 | lpfc_els_flush_rscn(vport); |
| 860 | spin_lock_irq(shost->host_lock); |
| 861 | vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ |
| 862 | spin_unlock_irq(shost->host_lock); |
| 863 | } |
| 864 | else |
| 865 | lpfc_els_flush_rscn(vport); |
| 866 | } |
| 867 | lpfc_disc_start(vport); |
| 868 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 869 | lpfc_ct_free_iocb(phba, cmdiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 870 | return; |
| 871 | } |
| 872 | |
| 873 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 874 | static void |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 875 | lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 876 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 877 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 878 | struct lpfc_vport *vport = cmdiocb->vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 879 | struct lpfc_dmabuf *inp; |
| 880 | struct lpfc_dmabuf *outp; |
| 881 | IOCB_t *irsp; |
| 882 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 883 | struct lpfc_nodelist *ndlp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 884 | int cmdcode, rc; |
| 885 | uint8_t retry; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 886 | uint32_t latt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 887 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 888 | /* First save ndlp, before we overwrite it */ |
| 889 | ndlp = cmdiocb->context_un.ndlp; |
| 890 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 891 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 892 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 893 | |
| 894 | inp = (struct lpfc_dmabuf *) cmdiocb->context1; |
| 895 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 896 | irsp = &rspiocb->iocb; |
| 897 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 898 | cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)-> |
| 899 | CommandResponse.bits.CmdRsp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 900 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 901 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 902 | latt = lpfc_els_chk_latt(vport); |
| 903 | |
| 904 | /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 905 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 906 | "0209 CT Request completes, latt %d, " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 907 | "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n", |
| 908 | latt, irsp->ulpStatus, |
| 909 | CTrsp->CommandResponse.bits.CmdRsp, |
| 910 | cmdiocb->iocb.ulpContext, cmdiocb->iocb.ulpIoTag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 911 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 912 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 913 | "CT cmd cmpl: status:x%x/x%x cmd:x%x", |
| 914 | irsp->ulpStatus, irsp->un.ulpWord[4], cmdcode); |
| 915 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 916 | if (irsp->ulpStatus) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 917 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
James Smart | 6e15520 | 2013-07-15 18:35:21 -0400 | [diff] [blame] | 918 | "0268 NS cmd x%x Error (x%x x%x)\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 919 | cmdcode, irsp->ulpStatus, irsp->un.ulpWord[4]); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 920 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 921 | if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 922 | (((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) == |
| 923 | IOERR_SLI_DOWN) || |
| 924 | ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) == |
| 925 | IOERR_SLI_ABORTED))) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 926 | goto out; |
| 927 | |
| 928 | retry = cmdiocb->retry; |
| 929 | if (retry >= LPFC_MAX_NS_RETRY) |
| 930 | goto out; |
| 931 | |
| 932 | retry++; |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 933 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 934 | "0250 Retrying NS cmd %x\n", cmdcode); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 935 | rc = lpfc_ns_cmd(vport, cmdcode, retry, 0); |
| 936 | if (rc == 0) |
| 937 | goto out; |
| 938 | } |
| 939 | |
| 940 | out: |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 941 | cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 942 | lpfc_ct_free_iocb(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 943 | return; |
| 944 | } |
| 945 | |
| 946 | static void |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 947 | lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 948 | struct lpfc_iocbq *rspiocb) |
| 949 | { |
| 950 | IOCB_t *irsp = &rspiocb->iocb; |
| 951 | struct lpfc_vport *vport = cmdiocb->vport; |
| 952 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 953 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 954 | struct lpfc_dmabuf *outp; |
| 955 | struct lpfc_sli_ct_request *CTrsp; |
| 956 | |
| 957 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 958 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 959 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 960 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 961 | vport->ct_flags |= FC_CT_RFT_ID; |
| 962 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 963 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| 964 | return; |
| 965 | } |
| 966 | |
| 967 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 968 | lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 969 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 970 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 971 | IOCB_t *irsp = &rspiocb->iocb; |
| 972 | struct lpfc_vport *vport = cmdiocb->vport; |
| 973 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 974 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 975 | struct lpfc_dmabuf *outp; |
| 976 | struct lpfc_sli_ct_request *CTrsp; |
| 977 | |
| 978 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 979 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 980 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 981 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 982 | vport->ct_flags |= FC_CT_RNN_ID; |
| 983 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 984 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 985 | return; |
| 986 | } |
| 987 | |
| 988 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 989 | lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 990 | struct lpfc_iocbq *rspiocb) |
| 991 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 992 | IOCB_t *irsp = &rspiocb->iocb; |
| 993 | struct lpfc_vport *vport = cmdiocb->vport; |
| 994 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 995 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 996 | struct lpfc_dmabuf *outp; |
| 997 | struct lpfc_sli_ct_request *CTrsp; |
| 998 | |
| 999 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 1000 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 1001 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 1002 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 1003 | vport->ct_flags |= FC_CT_RSPN_ID; |
| 1004 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1005 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1006 | return; |
| 1007 | } |
| 1008 | |
| 1009 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1010 | lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1011 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1012 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1013 | IOCB_t *irsp = &rspiocb->iocb; |
| 1014 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1015 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1016 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 1017 | struct lpfc_dmabuf *outp; |
| 1018 | struct lpfc_sli_ct_request *CTrsp; |
| 1019 | |
| 1020 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 1021 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 1022 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 1023 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 1024 | vport->ct_flags |= FC_CT_RSNN_NN; |
| 1025 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1026 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| 1027 | return; |
| 1028 | } |
| 1029 | |
| 1030 | static void |
| 1031 | lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1032 | struct lpfc_iocbq *rspiocb) |
| 1033 | { |
| 1034 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1035 | |
| 1036 | /* even if it fails we will act as though it succeeded. */ |
| 1037 | vport->ct_flags = 0; |
| 1038 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1039 | return; |
| 1040 | } |
| 1041 | |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1042 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1043 | lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1044 | struct lpfc_iocbq *rspiocb) |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1045 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1046 | IOCB_t *irsp = &rspiocb->iocb; |
| 1047 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1048 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1049 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 1050 | struct lpfc_dmabuf *outp; |
| 1051 | struct lpfc_sli_ct_request *CTrsp; |
| 1052 | |
| 1053 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 1054 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 1055 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 1056 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 1057 | vport->ct_flags |= FC_CT_RFF_ID; |
| 1058 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1059 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1060 | return; |
| 1061 | } |
| 1062 | |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 1063 | int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1064 | lpfc_vport_symbolic_port_name(struct lpfc_vport *vport, char *symbol, |
| 1065 | size_t size) |
| 1066 | { |
| 1067 | int n; |
| 1068 | uint8_t *wwn = vport->phba->wwpn; |
| 1069 | |
| 1070 | n = snprintf(symbol, size, |
| 1071 | "Emulex PPN-%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", |
| 1072 | wwn[0], wwn[1], wwn[2], wwn[3], |
| 1073 | wwn[4], wwn[5], wwn[6], wwn[7]); |
| 1074 | |
| 1075 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1076 | return n; |
| 1077 | |
| 1078 | if (n < size) |
| 1079 | n += snprintf(symbol + n, size - n, " VPort-%d", vport->vpi); |
| 1080 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 1081 | if (n < size && |
| 1082 | strlen(vport->fc_vport->symbolic_name)) |
| 1083 | n += snprintf(symbol + n, size - n, " VName-%s", |
| 1084 | vport->fc_vport->symbolic_name); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1085 | return n; |
| 1086 | } |
| 1087 | |
| 1088 | int |
| 1089 | lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol, |
| 1090 | size_t size) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1091 | { |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1092 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1093 | int n; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1094 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1095 | lpfc_decode_firmware_rev(vport->phba, fwrev, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1096 | |
James Smart | f0bf5f9 | 2015-04-07 15:07:18 -0400 | [diff] [blame] | 1097 | n = snprintf(symbol, size, "Emulex %s", vport->phba->ModelName); |
| 1098 | |
| 1099 | if (size < n) |
| 1100 | return n; |
| 1101 | n += snprintf(symbol + n, size - n, " FV%s", fwrev); |
| 1102 | |
| 1103 | if (size < n) |
| 1104 | return n; |
| 1105 | n += snprintf(symbol + n, size - n, " DV%s", lpfc_release_version); |
| 1106 | |
| 1107 | if (size < n) |
| 1108 | return n; |
| 1109 | n += snprintf(symbol + n, size - n, " HN:%s", init_utsname()->nodename); |
| 1110 | |
| 1111 | /* Note :- OS name is "Linux" */ |
| 1112 | if (size < n) |
| 1113 | return n; |
| 1114 | n += snprintf(symbol + n, size - n, " OS:%s", init_utsname()->sysname); |
| 1115 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1116 | return n; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1117 | } |
| 1118 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1119 | static uint32_t |
| 1120 | lpfc_find_map_node(struct lpfc_vport *vport) |
| 1121 | { |
| 1122 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 1123 | struct Scsi_Host *shost; |
| 1124 | uint32_t cnt = 0; |
| 1125 | |
| 1126 | shost = lpfc_shost_from_vport(vport); |
| 1127 | spin_lock_irq(shost->host_lock); |
| 1128 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 1129 | if (ndlp->nlp_type & NLP_FABRIC) |
| 1130 | continue; |
| 1131 | if ((ndlp->nlp_state == NLP_STE_MAPPED_NODE) || |
| 1132 | (ndlp->nlp_state == NLP_STE_UNMAPPED_NODE)) |
| 1133 | cnt++; |
| 1134 | } |
| 1135 | spin_unlock_irq(shost->host_lock); |
| 1136 | return cnt; |
| 1137 | } |
| 1138 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1139 | /* |
| 1140 | * lpfc_ns_cmd |
| 1141 | * Description: |
| 1142 | * Issue Cmd to NameServer |
| 1143 | * SLI_CTNS_GID_FT |
| 1144 | * LI_CTNS_RFT_ID |
| 1145 | */ |
| 1146 | int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1147 | lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, |
| 1148 | uint8_t retry, uint32_t context) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1149 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1150 | struct lpfc_nodelist * ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1151 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1152 | struct lpfc_dmabuf *mp, *bmp; |
| 1153 | struct lpfc_sli_ct_request *CtReq; |
| 1154 | struct ulp_bde64 *bpl; |
| 1155 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 1156 | struct lpfc_iocbq *) = NULL; |
| 1157 | uint32_t rsp_size = 1024; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1158 | size_t size; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1159 | int rc = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1160 | |
| 1161 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1162 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) |
| 1163 | || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1164 | rc=1; |
| 1165 | goto ns_cmd_exit; |
| 1166 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1167 | |
| 1168 | /* fill in BDEs for command */ |
| 1169 | /* Allocate buffer for command payload */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1170 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1171 | if (!mp) { |
| 1172 | rc=2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1173 | goto ns_cmd_exit; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1174 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1175 | |
| 1176 | INIT_LIST_HEAD(&mp->list); |
| 1177 | mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1178 | if (!mp->virt) { |
| 1179 | rc=3; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1180 | goto ns_cmd_free_mp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1181 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1182 | |
| 1183 | /* Allocate buffer for Buffer ptr list */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1184 | bmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1185 | if (!bmp) { |
| 1186 | rc=4; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1187 | goto ns_cmd_free_mpvirt; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1188 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1189 | |
| 1190 | INIT_LIST_HEAD(&bmp->list); |
| 1191 | bmp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(bmp->phys)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1192 | if (!bmp->virt) { |
| 1193 | rc=5; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1194 | goto ns_cmd_free_bmp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1195 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1196 | |
| 1197 | /* NameServer Req */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1198 | lpfc_printf_vlog(vport, KERN_INFO ,LOG_DISCOVERY, |
| 1199 | "0236 NameServer Req Data: x%x x%x x%x\n", |
| 1200 | cmdcode, vport->fc_flag, vport->fc_rscn_id_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1201 | |
| 1202 | bpl = (struct ulp_bde64 *) bmp->virt; |
| 1203 | memset(bpl, 0, sizeof(struct ulp_bde64)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1204 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); |
| 1205 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1206 | bpl->tus.f.bdeFlags = 0; |
| 1207 | if (cmdcode == SLI_CTNS_GID_FT) |
| 1208 | bpl->tus.f.bdeSize = GID_REQUEST_SZ; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1209 | else if (cmdcode == SLI_CTNS_GFF_ID) |
| 1210 | bpl->tus.f.bdeSize = GFF_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1211 | else if (cmdcode == SLI_CTNS_RFT_ID) |
| 1212 | bpl->tus.f.bdeSize = RFT_REQUEST_SZ; |
| 1213 | else if (cmdcode == SLI_CTNS_RNN_ID) |
| 1214 | bpl->tus.f.bdeSize = RNN_REQUEST_SZ; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1215 | else if (cmdcode == SLI_CTNS_RSPN_ID) |
| 1216 | bpl->tus.f.bdeSize = RSPN_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1217 | else if (cmdcode == SLI_CTNS_RSNN_NN) |
| 1218 | bpl->tus.f.bdeSize = RSNN_REQUEST_SZ; |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1219 | else if (cmdcode == SLI_CTNS_DA_ID) |
| 1220 | bpl->tus.f.bdeSize = DA_ID_REQUEST_SZ; |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1221 | else if (cmdcode == SLI_CTNS_RFF_ID) |
| 1222 | bpl->tus.f.bdeSize = RFF_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1223 | else |
| 1224 | bpl->tus.f.bdeSize = 0; |
| 1225 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 1226 | |
| 1227 | CtReq = (struct lpfc_sli_ct_request *) mp->virt; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1228 | memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1229 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; |
| 1230 | CtReq->RevisionId.bits.InId = 0; |
| 1231 | CtReq->FsType = SLI_CT_DIRECTORY_SERVICE; |
| 1232 | CtReq->FsSubType = SLI_CT_DIRECTORY_NAME_SERVER; |
| 1233 | CtReq->CommandResponse.bits.Size = 0; |
| 1234 | switch (cmdcode) { |
| 1235 | case SLI_CTNS_GID_FT: |
| 1236 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1237 | cpu_to_be16(SLI_CTNS_GID_FT); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1238 | CtReq->un.gid.Fc4Type = SLI_CTPT_FCP; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1239 | if (vport->port_state < LPFC_NS_QRY) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1240 | vport->port_state = LPFC_NS_QRY; |
| 1241 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1242 | cmpl = lpfc_cmpl_ct_cmd_gid_ft; |
| 1243 | rsp_size = FC_MAX_NS_RSP; |
| 1244 | break; |
| 1245 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1246 | case SLI_CTNS_GFF_ID: |
| 1247 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1248 | cpu_to_be16(SLI_CTNS_GFF_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1249 | CtReq->un.gff.PortId = cpu_to_be32(context); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1250 | cmpl = lpfc_cmpl_ct_cmd_gff_id; |
| 1251 | break; |
| 1252 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1253 | case SLI_CTNS_RFT_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1254 | vport->ct_flags &= ~FC_CT_RFT_ID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1255 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1256 | cpu_to_be16(SLI_CTNS_RFT_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1257 | CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1258 | CtReq->un.rft.fcpReg = 1; |
| 1259 | cmpl = lpfc_cmpl_ct_cmd_rft_id; |
| 1260 | break; |
| 1261 | |
| 1262 | case SLI_CTNS_RNN_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1263 | vport->ct_flags &= ~FC_CT_RNN_ID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1264 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1265 | cpu_to_be16(SLI_CTNS_RNN_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1266 | CtReq->un.rnn.PortId = cpu_to_be32(vport->fc_myDID); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1267 | memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename, |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1268 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1269 | cmpl = lpfc_cmpl_ct_cmd_rnn_id; |
| 1270 | break; |
| 1271 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1272 | case SLI_CTNS_RSPN_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1273 | vport->ct_flags &= ~FC_CT_RSPN_ID; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1274 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1275 | cpu_to_be16(SLI_CTNS_RSPN_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1276 | CtReq->un.rspn.PortId = cpu_to_be32(vport->fc_myDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1277 | size = sizeof(CtReq->un.rspn.symbname); |
| 1278 | CtReq->un.rspn.len = |
| 1279 | lpfc_vport_symbolic_port_name(vport, |
| 1280 | CtReq->un.rspn.symbname, size); |
| 1281 | cmpl = lpfc_cmpl_ct_cmd_rspn_id; |
| 1282 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1283 | case SLI_CTNS_RSNN_NN: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1284 | vport->ct_flags &= ~FC_CT_RSNN_NN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1285 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1286 | cpu_to_be16(SLI_CTNS_RSNN_NN); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1287 | memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename, |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1288 | sizeof(struct lpfc_name)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1289 | size = sizeof(CtReq->un.rsnn.symbname); |
| 1290 | CtReq->un.rsnn.len = |
| 1291 | lpfc_vport_symbolic_node_name(vport, |
| 1292 | CtReq->un.rsnn.symbname, size); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1293 | cmpl = lpfc_cmpl_ct_cmd_rsnn_nn; |
| 1294 | break; |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1295 | case SLI_CTNS_DA_ID: |
| 1296 | /* Implement DA_ID Nameserver request */ |
| 1297 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1298 | cpu_to_be16(SLI_CTNS_DA_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1299 | CtReq->un.da_id.port_id = cpu_to_be32(vport->fc_myDID); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1300 | cmpl = lpfc_cmpl_ct_cmd_da_id; |
| 1301 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1302 | case SLI_CTNS_RFF_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1303 | vport->ct_flags &= ~FC_CT_RFF_ID; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1304 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1305 | cpu_to_be16(SLI_CTNS_RFF_ID); |
Joe Perches | a419aef | 2009-08-18 11:18:35 -0700 | [diff] [blame] | 1306 | CtReq->un.rff.PortId = cpu_to_be32(vport->fc_myDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1307 | CtReq->un.rff.fbits = FC4_FEATURE_INIT; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1308 | CtReq->un.rff.type_code = FC_TYPE_FCP; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1309 | cmpl = lpfc_cmpl_ct_cmd_rff_id; |
| 1310 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1311 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1312 | /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count |
| 1313 | * to hold ndlp reference for the corresponding callback function. |
| 1314 | */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1315 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1316 | /* On success, The cmpl function will free the buffers */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1317 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 1318 | "Issue CT cmd: cmd:x%x did:x%x", |
| 1319 | cmdcode, ndlp->nlp_DID, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1320 | return 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1321 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1322 | rc=6; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1323 | |
| 1324 | /* Decrement ndlp reference count to release ndlp reference held |
| 1325 | * for the failed command's callback function. |
| 1326 | */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1327 | lpfc_nlp_put(ndlp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1328 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1329 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 1330 | ns_cmd_free_bmp: |
| 1331 | kfree(bmp); |
| 1332 | ns_cmd_free_mpvirt: |
| 1333 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 1334 | ns_cmd_free_mp: |
| 1335 | kfree(mp); |
| 1336 | ns_cmd_exit: |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1337 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 1338 | "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n", |
| 1339 | cmdcode, rc, vport->fc_flag, vport->fc_rscn_id_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1340 | return 1; |
| 1341 | } |
| 1342 | |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1343 | /** |
| 1344 | * lpfc_cmpl_ct_disc_fdmi - Handle a discovery FDMI completion |
| 1345 | * @phba: Pointer to HBA context object. |
| 1346 | * @cmdiocb: Pointer to the command IOCBQ. |
| 1347 | * @rspiocb: Pointer to the response IOCBQ. |
| 1348 | * |
| 1349 | * This function to handle the completion of a driver initiated FDMI |
| 1350 | * CT command issued during discovery. |
| 1351 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1352 | static void |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1353 | lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1354 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1355 | { |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1356 | struct lpfc_vport *vport = cmdiocb->vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1357 | struct lpfc_dmabuf *inp = cmdiocb->context1; |
| 1358 | struct lpfc_dmabuf *outp = cmdiocb->context2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1359 | struct lpfc_sli_ct_request *CTcmd = inp->virt; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1360 | struct lpfc_sli_ct_request *CTrsp = outp->virt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1361 | uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp; |
| 1362 | uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1363 | IOCB_t *irsp = &rspiocb->iocb; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1364 | struct lpfc_nodelist *ndlp; |
| 1365 | uint32_t latt, cmd, err; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1366 | |
| 1367 | latt = lpfc_els_chk_latt(vport); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1368 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 1369 | "FDMI cmpl: status:x%x/x%x latt:%d", |
| 1370 | irsp->ulpStatus, irsp->un.ulpWord[4], latt); |
| 1371 | |
| 1372 | if (latt || irsp->ulpStatus) { |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1373 | |
| 1374 | /* Look for a retryable error */ |
| 1375 | if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) { |
| 1376 | switch ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK)) { |
| 1377 | case IOERR_SLI_ABORTED: |
| 1378 | case IOERR_ABORT_IN_PROGRESS: |
| 1379 | case IOERR_SEQUENCE_TIMEOUT: |
| 1380 | case IOERR_ILLEGAL_FRAME: |
| 1381 | case IOERR_NO_RESOURCES: |
| 1382 | case IOERR_ILLEGAL_COMMAND: |
| 1383 | cmdiocb->retry++; |
| 1384 | if (cmdiocb->retry >= LPFC_FDMI_MAX_RETRY) |
| 1385 | break; |
| 1386 | |
| 1387 | /* Retry the same FDMI command */ |
| 1388 | err = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, |
| 1389 | cmdiocb, 0); |
| 1390 | if (err == IOCB_ERROR) |
| 1391 | break; |
| 1392 | return; |
| 1393 | default: |
| 1394 | break; |
| 1395 | } |
| 1396 | } |
| 1397 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1398 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1399 | "0229 FDMI cmd %04x failed, latt = %d " |
| 1400 | "ulpStatus: x%x, rid x%x\n", |
| 1401 | be16_to_cpu(fdmi_cmd), latt, irsp->ulpStatus, |
| 1402 | irsp->un.ulpWord[4]); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1403 | } |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1404 | lpfc_ct_free_iocb(phba, cmdiocb); |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1405 | |
| 1406 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
| 1407 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 1408 | return; |
| 1409 | |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1410 | /* Check for a CT LS_RJT response */ |
| 1411 | cmd = be16_to_cpu(fdmi_cmd); |
| 1412 | if (fdmi_rsp == cpu_to_be16(SLI_CT_RESPONSE_FS_RJT)) { |
| 1413 | /* FDMI rsp failed */ |
| 1414 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1415 | "0220 FDMI cmd failed FS_RJT Data: x%x", cmd); |
| 1416 | |
| 1417 | /* Should we fallback to FDMI-2 / FDMI-1 ? */ |
| 1418 | switch (cmd) { |
| 1419 | case SLI_MGMT_RHBA: |
| 1420 | if (vport->fdmi_hba_mask == LPFC_FDMI2_HBA_ATTR) { |
| 1421 | /* Fallback to FDMI-1 */ |
| 1422 | vport->fdmi_hba_mask = LPFC_FDMI1_HBA_ATTR; |
| 1423 | vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR; |
| 1424 | /* Start over */ |
| 1425 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0); |
| 1426 | } |
| 1427 | return; |
| 1428 | |
| 1429 | case SLI_MGMT_RPRT: |
| 1430 | if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) { |
| 1431 | /* Fallback to FDMI-1 */ |
| 1432 | vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR; |
| 1433 | /* Start over */ |
| 1434 | lpfc_fdmi_cmd(vport, ndlp, cmd, 0); |
| 1435 | } |
| 1436 | if (vport->fdmi_port_mask == LPFC_FDMI2_SMART_ATTR) { |
| 1437 | vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; |
| 1438 | /* Retry the same command */ |
| 1439 | lpfc_fdmi_cmd(vport, ndlp, cmd, 0); |
| 1440 | } |
| 1441 | return; |
| 1442 | |
| 1443 | case SLI_MGMT_RPA: |
| 1444 | if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) { |
| 1445 | /* Fallback to FDMI-1 */ |
| 1446 | vport->fdmi_hba_mask = LPFC_FDMI1_HBA_ATTR; |
| 1447 | vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR; |
| 1448 | /* Start over */ |
| 1449 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0); |
| 1450 | } |
| 1451 | if (vport->fdmi_port_mask == LPFC_FDMI2_SMART_ATTR) { |
| 1452 | vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; |
| 1453 | /* Retry the same command */ |
| 1454 | lpfc_fdmi_cmd(vport, ndlp, cmd, 0); |
| 1455 | } |
| 1456 | return; |
| 1457 | } |
| 1458 | } |
| 1459 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1460 | /* |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1461 | * On success, need to cycle thru FDMI registration for discovery |
| 1462 | * DHBA -> DPRT -> RHBA -> RPA (physical port) |
| 1463 | * DPRT -> RPRT (vports) |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1464 | */ |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1465 | switch (cmd) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1466 | case SLI_MGMT_RHBA: |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1467 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1468 | break; |
| 1469 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1470 | case SLI_MGMT_DHBA: |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1471 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1472 | break; |
| 1473 | |
| 1474 | case SLI_MGMT_DPRT: |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1475 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1476 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA, 0); |
| 1477 | else |
| 1478 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1479 | break; |
| 1480 | } |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1481 | return; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1482 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1483 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1484 | |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1485 | /** |
| 1486 | * lpfc_fdmi_num_disc_check - Check how many mapped NPorts we are connected to |
| 1487 | * @vport: pointer to a host virtual N_Port data structure. |
| 1488 | * |
| 1489 | * Called from hbeat timeout routine to check if the number of discovered |
| 1490 | * ports has changed. If so, re-register thar port Attribute. |
| 1491 | */ |
| 1492 | void |
| 1493 | lpfc_fdmi_num_disc_check(struct lpfc_vport *vport) |
| 1494 | { |
| 1495 | struct lpfc_hba *phba = vport->phba; |
| 1496 | struct lpfc_nodelist *ndlp; |
| 1497 | uint16_t cnt; |
| 1498 | |
| 1499 | if (!lpfc_is_link_up(phba)) |
| 1500 | return; |
| 1501 | |
| 1502 | if (!(vport->fdmi_port_mask & LPFC_FDMI_PORT_ATTR_num_disc)) |
| 1503 | return; |
| 1504 | |
| 1505 | cnt = lpfc_find_map_node(vport); |
| 1506 | if (cnt == vport->fdmi_num_disc) |
| 1507 | return; |
| 1508 | |
| 1509 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
| 1510 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 1511 | return; |
| 1512 | |
| 1513 | if (vport->port_type == LPFC_PHYSICAL_PORT) { |
| 1514 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA, |
| 1515 | LPFC_FDMI_PORT_ATTR_num_disc); |
| 1516 | } else { |
| 1517 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, |
| 1518 | LPFC_FDMI_PORT_ATTR_num_disc); |
| 1519 | } |
| 1520 | } |
| 1521 | |
| 1522 | /* Routines for all individual HBA attributes */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1523 | int |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 1524 | lpfc_fdmi_hba_attr_wwnn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad) |
| 1525 | { |
| 1526 | struct lpfc_fdmi_attr_entry *ae; |
| 1527 | uint32_t size; |
| 1528 | |
| 1529 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1530 | memset(ae, 0, sizeof(struct lpfc_name)); |
| 1531 | |
| 1532 | memcpy(&ae->un.AttrWWN, &vport->fc_sparam.nodeName, |
| 1533 | sizeof(struct lpfc_name)); |
| 1534 | size = FOURBYTES + sizeof(struct lpfc_name); |
| 1535 | ad->AttrLen = cpu_to_be16(size); |
| 1536 | ad->AttrType = cpu_to_be16(RHBA_NODENAME); |
| 1537 | return size; |
| 1538 | } |
| 1539 | int |
| 1540 | lpfc_fdmi_hba_attr_manufacturer(struct lpfc_vport *vport, |
| 1541 | struct lpfc_fdmi_attr_def *ad) |
| 1542 | { |
| 1543 | struct lpfc_fdmi_attr_entry *ae; |
| 1544 | uint32_t len, size; |
| 1545 | |
| 1546 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1547 | memset(ae, 0, 256); |
| 1548 | |
| 1549 | strncpy(ae->un.AttrString, |
| 1550 | "Emulex Corporation", |
| 1551 | sizeof(ae->un.AttrString)); |
| 1552 | len = strnlen(ae->un.AttrString, |
| 1553 | sizeof(ae->un.AttrString)); |
| 1554 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1555 | size = FOURBYTES + len; |
| 1556 | ad->AttrLen = cpu_to_be16(size); |
| 1557 | ad->AttrType = cpu_to_be16(RHBA_MANUFACTURER); |
| 1558 | return size; |
| 1559 | } |
| 1560 | |
| 1561 | int |
| 1562 | lpfc_fdmi_hba_attr_sn(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad) |
| 1563 | { |
| 1564 | struct lpfc_hba *phba = vport->phba; |
| 1565 | struct lpfc_fdmi_attr_entry *ae; |
| 1566 | uint32_t len, size; |
| 1567 | |
| 1568 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1569 | memset(ae, 0, 256); |
| 1570 | |
| 1571 | strncpy(ae->un.AttrString, phba->SerialNumber, |
| 1572 | sizeof(ae->un.AttrString)); |
| 1573 | len = strnlen(ae->un.AttrString, |
| 1574 | sizeof(ae->un.AttrString)); |
| 1575 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1576 | size = FOURBYTES + len; |
| 1577 | ad->AttrLen = cpu_to_be16(size); |
| 1578 | ad->AttrType = cpu_to_be16(RHBA_SERIAL_NUMBER); |
| 1579 | return size; |
| 1580 | } |
| 1581 | |
| 1582 | int |
| 1583 | lpfc_fdmi_hba_attr_model(struct lpfc_vport *vport, |
| 1584 | struct lpfc_fdmi_attr_def *ad) |
| 1585 | { |
| 1586 | struct lpfc_hba *phba = vport->phba; |
| 1587 | struct lpfc_fdmi_attr_entry *ae; |
| 1588 | uint32_t len, size; |
| 1589 | |
| 1590 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1591 | memset(ae, 0, 256); |
| 1592 | |
| 1593 | strncpy(ae->un.AttrString, phba->ModelName, |
| 1594 | sizeof(ae->un.AttrString)); |
| 1595 | len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString)); |
| 1596 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1597 | size = FOURBYTES + len; |
| 1598 | ad->AttrLen = cpu_to_be16(size); |
| 1599 | ad->AttrType = cpu_to_be16(RHBA_MODEL); |
| 1600 | return size; |
| 1601 | } |
| 1602 | |
| 1603 | int |
| 1604 | lpfc_fdmi_hba_attr_description(struct lpfc_vport *vport, |
| 1605 | struct lpfc_fdmi_attr_def *ad) |
| 1606 | { |
| 1607 | struct lpfc_hba *phba = vport->phba; |
| 1608 | struct lpfc_fdmi_attr_entry *ae; |
| 1609 | uint32_t len, size; |
| 1610 | |
| 1611 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1612 | memset(ae, 0, 256); |
| 1613 | |
| 1614 | strncpy(ae->un.AttrString, phba->ModelDesc, |
| 1615 | sizeof(ae->un.AttrString)); |
| 1616 | len = strnlen(ae->un.AttrString, |
| 1617 | sizeof(ae->un.AttrString)); |
| 1618 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1619 | size = FOURBYTES + len; |
| 1620 | ad->AttrLen = cpu_to_be16(size); |
| 1621 | ad->AttrType = cpu_to_be16(RHBA_MODEL_DESCRIPTION); |
| 1622 | return size; |
| 1623 | } |
| 1624 | |
| 1625 | int |
| 1626 | lpfc_fdmi_hba_attr_hdw_ver(struct lpfc_vport *vport, |
| 1627 | struct lpfc_fdmi_attr_def *ad) |
| 1628 | { |
| 1629 | struct lpfc_hba *phba = vport->phba; |
| 1630 | lpfc_vpd_t *vp = &phba->vpd; |
| 1631 | struct lpfc_fdmi_attr_entry *ae; |
| 1632 | uint32_t i, j, incr, size; |
| 1633 | |
| 1634 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1635 | memset(ae, 0, 256); |
| 1636 | |
| 1637 | /* Convert JEDEC ID to ascii for hardware version */ |
| 1638 | incr = vp->rev.biuRev; |
| 1639 | for (i = 0; i < 8; i++) { |
| 1640 | j = (incr & 0xf); |
| 1641 | if (j <= 9) |
| 1642 | ae->un.AttrString[7 - i] = |
| 1643 | (char)((uint8_t) 0x30 + |
| 1644 | (uint8_t) j); |
| 1645 | else |
| 1646 | ae->un.AttrString[7 - i] = |
| 1647 | (char)((uint8_t) 0x61 + |
| 1648 | (uint8_t) (j - 10)); |
| 1649 | incr = (incr >> 4); |
| 1650 | } |
| 1651 | size = FOURBYTES + 8; |
| 1652 | ad->AttrLen = cpu_to_be16(size); |
| 1653 | ad->AttrType = cpu_to_be16(RHBA_HARDWARE_VERSION); |
| 1654 | return size; |
| 1655 | } |
| 1656 | |
| 1657 | int |
| 1658 | lpfc_fdmi_hba_attr_drvr_ver(struct lpfc_vport *vport, |
| 1659 | struct lpfc_fdmi_attr_def *ad) |
| 1660 | { |
| 1661 | struct lpfc_fdmi_attr_entry *ae; |
| 1662 | uint32_t len, size; |
| 1663 | |
| 1664 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1665 | memset(ae, 0, 256); |
| 1666 | |
| 1667 | strncpy(ae->un.AttrString, lpfc_release_version, |
| 1668 | sizeof(ae->un.AttrString)); |
| 1669 | len = strnlen(ae->un.AttrString, |
| 1670 | sizeof(ae->un.AttrString)); |
| 1671 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1672 | size = FOURBYTES + len; |
| 1673 | ad->AttrLen = cpu_to_be16(size); |
| 1674 | ad->AttrType = cpu_to_be16(RHBA_DRIVER_VERSION); |
| 1675 | return size; |
| 1676 | } |
| 1677 | |
| 1678 | int |
| 1679 | lpfc_fdmi_hba_attr_rom_ver(struct lpfc_vport *vport, |
| 1680 | struct lpfc_fdmi_attr_def *ad) |
| 1681 | { |
| 1682 | struct lpfc_hba *phba = vport->phba; |
| 1683 | struct lpfc_fdmi_attr_entry *ae; |
| 1684 | uint32_t len, size; |
| 1685 | |
| 1686 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1687 | memset(ae, 0, 256); |
| 1688 | |
| 1689 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1690 | lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1); |
| 1691 | else |
| 1692 | strncpy(ae->un.AttrString, phba->OptionROMVersion, |
| 1693 | sizeof(ae->un.AttrString)); |
| 1694 | len = strnlen(ae->un.AttrString, |
| 1695 | sizeof(ae->un.AttrString)); |
| 1696 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1697 | size = FOURBYTES + len; |
| 1698 | ad->AttrLen = cpu_to_be16(size); |
| 1699 | ad->AttrType = cpu_to_be16(RHBA_OPTION_ROM_VERSION); |
| 1700 | return size; |
| 1701 | } |
| 1702 | |
| 1703 | int |
| 1704 | lpfc_fdmi_hba_attr_fmw_ver(struct lpfc_vport *vport, |
| 1705 | struct lpfc_fdmi_attr_def *ad) |
| 1706 | { |
| 1707 | struct lpfc_hba *phba = vport->phba; |
| 1708 | struct lpfc_fdmi_attr_entry *ae; |
| 1709 | uint32_t len, size; |
| 1710 | |
| 1711 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1712 | memset(ae, 0, 256); |
| 1713 | |
| 1714 | lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1); |
| 1715 | len = strnlen(ae->un.AttrString, |
| 1716 | sizeof(ae->un.AttrString)); |
| 1717 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1718 | size = FOURBYTES + len; |
| 1719 | ad->AttrLen = cpu_to_be16(size); |
| 1720 | ad->AttrType = cpu_to_be16(RHBA_FIRMWARE_VERSION); |
| 1721 | return size; |
| 1722 | } |
| 1723 | |
| 1724 | int |
| 1725 | lpfc_fdmi_hba_attr_os_ver(struct lpfc_vport *vport, |
| 1726 | struct lpfc_fdmi_attr_def *ad) |
| 1727 | { |
| 1728 | struct lpfc_fdmi_attr_entry *ae; |
| 1729 | uint32_t len, size; |
| 1730 | |
| 1731 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1732 | memset(ae, 0, 256); |
| 1733 | |
| 1734 | snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s %s %s", |
| 1735 | init_utsname()->sysname, |
| 1736 | init_utsname()->release, |
| 1737 | init_utsname()->version); |
| 1738 | |
| 1739 | len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString)); |
| 1740 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1741 | size = FOURBYTES + len; |
| 1742 | ad->AttrLen = cpu_to_be16(size); |
| 1743 | ad->AttrType = cpu_to_be16(RHBA_OS_NAME_VERSION); |
| 1744 | return size; |
| 1745 | } |
| 1746 | |
| 1747 | int |
| 1748 | lpfc_fdmi_hba_attr_ct_len(struct lpfc_vport *vport, |
| 1749 | struct lpfc_fdmi_attr_def *ad) |
| 1750 | { |
| 1751 | struct lpfc_fdmi_attr_entry *ae; |
| 1752 | uint32_t size; |
| 1753 | |
| 1754 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1755 | |
| 1756 | ae->un.AttrInt = cpu_to_be32(LPFC_MAX_CT_SIZE); |
| 1757 | size = FOURBYTES + sizeof(uint32_t); |
| 1758 | ad->AttrLen = cpu_to_be16(size); |
| 1759 | ad->AttrType = cpu_to_be16(RHBA_MAX_CT_PAYLOAD_LEN); |
| 1760 | return size; |
| 1761 | } |
| 1762 | |
| 1763 | int |
| 1764 | lpfc_fdmi_hba_attr_symbolic_name(struct lpfc_vport *vport, |
| 1765 | struct lpfc_fdmi_attr_def *ad) |
| 1766 | { |
| 1767 | struct lpfc_fdmi_attr_entry *ae; |
| 1768 | uint32_t len, size; |
| 1769 | |
| 1770 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1771 | memset(ae, 0, 256); |
| 1772 | |
| 1773 | len = lpfc_vport_symbolic_node_name(vport, |
| 1774 | ae->un.AttrString, 256); |
| 1775 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1776 | size = FOURBYTES + len; |
| 1777 | ad->AttrLen = cpu_to_be16(size); |
| 1778 | ad->AttrType = cpu_to_be16(RHBA_SYM_NODENAME); |
| 1779 | return size; |
| 1780 | } |
| 1781 | |
| 1782 | int |
| 1783 | lpfc_fdmi_hba_attr_vendor_info(struct lpfc_vport *vport, |
| 1784 | struct lpfc_fdmi_attr_def *ad) |
| 1785 | { |
| 1786 | struct lpfc_fdmi_attr_entry *ae; |
| 1787 | uint32_t size; |
| 1788 | |
| 1789 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1790 | |
| 1791 | /* Nothing is defined for this currently */ |
| 1792 | ae->un.AttrInt = cpu_to_be32(0); |
| 1793 | size = FOURBYTES + sizeof(uint32_t); |
| 1794 | ad->AttrLen = cpu_to_be16(size); |
| 1795 | ad->AttrType = cpu_to_be16(RHBA_VENDOR_INFO); |
| 1796 | return size; |
| 1797 | } |
| 1798 | |
| 1799 | int |
| 1800 | lpfc_fdmi_hba_attr_num_ports(struct lpfc_vport *vport, |
| 1801 | struct lpfc_fdmi_attr_def *ad) |
| 1802 | { |
| 1803 | struct lpfc_fdmi_attr_entry *ae; |
| 1804 | uint32_t size; |
| 1805 | |
| 1806 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1807 | |
| 1808 | /* Each driver instance corresponds to a single port */ |
| 1809 | ae->un.AttrInt = cpu_to_be32(1); |
| 1810 | size = FOURBYTES + sizeof(uint32_t); |
| 1811 | ad->AttrLen = cpu_to_be16(size); |
| 1812 | ad->AttrType = cpu_to_be16(RHBA_NUM_PORTS); |
| 1813 | return size; |
| 1814 | } |
| 1815 | |
| 1816 | int |
| 1817 | lpfc_fdmi_hba_attr_fabric_wwnn(struct lpfc_vport *vport, |
| 1818 | struct lpfc_fdmi_attr_def *ad) |
| 1819 | { |
| 1820 | struct lpfc_fdmi_attr_entry *ae; |
| 1821 | uint32_t size; |
| 1822 | |
| 1823 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1824 | memset(ae, 0, sizeof(struct lpfc_name)); |
| 1825 | |
| 1826 | memcpy(&ae->un.AttrWWN, &vport->fabric_nodename, |
| 1827 | sizeof(struct lpfc_name)); |
| 1828 | size = FOURBYTES + sizeof(struct lpfc_name); |
| 1829 | ad->AttrLen = cpu_to_be16(size); |
| 1830 | ad->AttrType = cpu_to_be16(RHBA_FABRIC_WWNN); |
| 1831 | return size; |
| 1832 | } |
| 1833 | |
| 1834 | int |
| 1835 | lpfc_fdmi_hba_attr_bios_ver(struct lpfc_vport *vport, |
| 1836 | struct lpfc_fdmi_attr_def *ad) |
| 1837 | { |
| 1838 | struct lpfc_hba *phba = vport->phba; |
| 1839 | struct lpfc_fdmi_attr_entry *ae; |
| 1840 | uint32_t len, size; |
| 1841 | |
| 1842 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1843 | memset(ae, 0, 256); |
| 1844 | |
| 1845 | lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1); |
| 1846 | len = strnlen(ae->un.AttrString, |
| 1847 | sizeof(ae->un.AttrString)); |
| 1848 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1849 | size = FOURBYTES + len; |
| 1850 | ad->AttrLen = cpu_to_be16(size); |
| 1851 | ad->AttrType = cpu_to_be16(RHBA_BIOS_VERSION); |
| 1852 | return size; |
| 1853 | } |
| 1854 | |
| 1855 | int |
| 1856 | lpfc_fdmi_hba_attr_bios_state(struct lpfc_vport *vport, |
| 1857 | struct lpfc_fdmi_attr_def *ad) |
| 1858 | { |
| 1859 | struct lpfc_fdmi_attr_entry *ae; |
| 1860 | uint32_t size; |
| 1861 | |
| 1862 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1863 | |
| 1864 | /* Driver doesn't have access to this information */ |
| 1865 | ae->un.AttrInt = cpu_to_be32(0); |
| 1866 | size = FOURBYTES + sizeof(uint32_t); |
| 1867 | ad->AttrLen = cpu_to_be16(size); |
| 1868 | ad->AttrType = cpu_to_be16(RHBA_BIOS_STATE); |
| 1869 | return size; |
| 1870 | } |
| 1871 | |
| 1872 | int |
| 1873 | lpfc_fdmi_hba_attr_vendor_id(struct lpfc_vport *vport, |
| 1874 | struct lpfc_fdmi_attr_def *ad) |
| 1875 | { |
| 1876 | struct lpfc_fdmi_attr_entry *ae; |
| 1877 | uint32_t len, size; |
| 1878 | |
| 1879 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1880 | memset(ae, 0, 256); |
| 1881 | |
| 1882 | strncpy(ae->un.AttrString, "EMULEX", |
| 1883 | sizeof(ae->un.AttrString)); |
| 1884 | len = strnlen(ae->un.AttrString, |
| 1885 | sizeof(ae->un.AttrString)); |
| 1886 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1887 | size = FOURBYTES + len; |
| 1888 | ad->AttrLen = cpu_to_be16(size); |
| 1889 | ad->AttrType = cpu_to_be16(RHBA_VENDOR_ID); |
| 1890 | return size; |
| 1891 | } |
| 1892 | |
| 1893 | /* Routines for all individual PORT attributes */ |
| 1894 | int |
| 1895 | lpfc_fdmi_port_attr_fc4type(struct lpfc_vport *vport, |
| 1896 | struct lpfc_fdmi_attr_def *ad) |
| 1897 | { |
| 1898 | struct lpfc_fdmi_attr_entry *ae; |
| 1899 | uint32_t size; |
| 1900 | |
| 1901 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1902 | memset(ae, 0, 32); |
| 1903 | |
| 1904 | ae->un.AttrTypes[3] = 0x02; /* Type 1 - ELS */ |
| 1905 | ae->un.AttrTypes[2] = 0x01; /* Type 8 - FCP */ |
| 1906 | ae->un.AttrTypes[7] = 0x01; /* Type 32 - CT */ |
| 1907 | size = FOURBYTES + 32; |
| 1908 | ad->AttrLen = cpu_to_be16(size); |
| 1909 | ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_FC4_TYPES); |
| 1910 | return size; |
| 1911 | } |
| 1912 | |
| 1913 | int |
| 1914 | lpfc_fdmi_port_attr_support_speed(struct lpfc_vport *vport, |
| 1915 | struct lpfc_fdmi_attr_def *ad) |
| 1916 | { |
| 1917 | struct lpfc_hba *phba = vport->phba; |
| 1918 | struct lpfc_fdmi_attr_entry *ae; |
| 1919 | uint32_t size; |
| 1920 | |
| 1921 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1922 | |
| 1923 | ae->un.AttrInt = 0; |
| 1924 | if (phba->lmt & LMT_32Gb) |
| 1925 | ae->un.AttrInt |= HBA_PORTSPEED_32GBIT; |
| 1926 | if (phba->lmt & LMT_16Gb) |
| 1927 | ae->un.AttrInt |= HBA_PORTSPEED_16GBIT; |
| 1928 | if (phba->lmt & LMT_10Gb) |
| 1929 | ae->un.AttrInt |= HBA_PORTSPEED_10GBIT; |
| 1930 | if (phba->lmt & LMT_8Gb) |
| 1931 | ae->un.AttrInt |= HBA_PORTSPEED_8GBIT; |
| 1932 | if (phba->lmt & LMT_4Gb) |
| 1933 | ae->un.AttrInt |= HBA_PORTSPEED_4GBIT; |
| 1934 | if (phba->lmt & LMT_2Gb) |
| 1935 | ae->un.AttrInt |= HBA_PORTSPEED_2GBIT; |
| 1936 | if (phba->lmt & LMT_1Gb) |
| 1937 | ae->un.AttrInt |= HBA_PORTSPEED_1GBIT; |
| 1938 | ae->un.AttrInt = cpu_to_be32(ae->un.AttrInt); |
| 1939 | size = FOURBYTES + sizeof(uint32_t); |
| 1940 | ad->AttrLen = cpu_to_be16(size); |
| 1941 | ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_SPEED); |
| 1942 | return size; |
| 1943 | } |
| 1944 | |
| 1945 | int |
| 1946 | lpfc_fdmi_port_attr_speed(struct lpfc_vport *vport, |
| 1947 | struct lpfc_fdmi_attr_def *ad) |
| 1948 | { |
| 1949 | struct lpfc_hba *phba = vport->phba; |
| 1950 | struct lpfc_fdmi_attr_entry *ae; |
| 1951 | uint32_t size; |
| 1952 | |
| 1953 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1954 | |
| 1955 | switch (phba->fc_linkspeed) { |
| 1956 | case LPFC_LINK_SPEED_1GHZ: |
| 1957 | ae->un.AttrInt = HBA_PORTSPEED_1GBIT; |
| 1958 | break; |
| 1959 | case LPFC_LINK_SPEED_2GHZ: |
| 1960 | ae->un.AttrInt = HBA_PORTSPEED_2GBIT; |
| 1961 | break; |
| 1962 | case LPFC_LINK_SPEED_4GHZ: |
| 1963 | ae->un.AttrInt = HBA_PORTSPEED_4GBIT; |
| 1964 | break; |
| 1965 | case LPFC_LINK_SPEED_8GHZ: |
| 1966 | ae->un.AttrInt = HBA_PORTSPEED_8GBIT; |
| 1967 | break; |
| 1968 | case LPFC_LINK_SPEED_10GHZ: |
| 1969 | ae->un.AttrInt = HBA_PORTSPEED_10GBIT; |
| 1970 | break; |
| 1971 | case LPFC_LINK_SPEED_16GHZ: |
| 1972 | ae->un.AttrInt = HBA_PORTSPEED_16GBIT; |
| 1973 | break; |
| 1974 | case LPFC_LINK_SPEED_32GHZ: |
| 1975 | ae->un.AttrInt = HBA_PORTSPEED_32GBIT; |
| 1976 | break; |
| 1977 | default: |
| 1978 | ae->un.AttrInt = HBA_PORTSPEED_UNKNOWN; |
| 1979 | break; |
| 1980 | } |
| 1981 | ae->un.AttrInt = cpu_to_be32(ae->un.AttrInt); |
| 1982 | size = FOURBYTES + sizeof(uint32_t); |
| 1983 | ad->AttrLen = cpu_to_be16(size); |
| 1984 | ad->AttrType = cpu_to_be16(RPRT_PORT_SPEED); |
| 1985 | return size; |
| 1986 | } |
| 1987 | |
| 1988 | int |
| 1989 | lpfc_fdmi_port_attr_max_frame(struct lpfc_vport *vport, |
| 1990 | struct lpfc_fdmi_attr_def *ad) |
| 1991 | { |
| 1992 | struct serv_parm *hsp; |
| 1993 | struct lpfc_fdmi_attr_entry *ae; |
| 1994 | uint32_t size; |
| 1995 | |
| 1996 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1997 | |
| 1998 | hsp = (struct serv_parm *)&vport->fc_sparam; |
| 1999 | ae->un.AttrInt = (((uint32_t) hsp->cmn.bbRcvSizeMsb) << 8) | |
| 2000 | (uint32_t) hsp->cmn.bbRcvSizeLsb; |
| 2001 | ae->un.AttrInt = cpu_to_be32(ae->un.AttrInt); |
| 2002 | size = FOURBYTES + sizeof(uint32_t); |
| 2003 | ad->AttrLen = cpu_to_be16(size); |
| 2004 | ad->AttrType = cpu_to_be16(RPRT_MAX_FRAME_SIZE); |
| 2005 | return size; |
| 2006 | } |
| 2007 | |
| 2008 | int |
| 2009 | lpfc_fdmi_port_attr_os_devname(struct lpfc_vport *vport, |
| 2010 | struct lpfc_fdmi_attr_def *ad) |
| 2011 | { |
| 2012 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2013 | struct lpfc_fdmi_attr_entry *ae; |
| 2014 | uint32_t len, size; |
| 2015 | |
| 2016 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2017 | memset(ae, 0, 256); |
| 2018 | |
| 2019 | snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), |
| 2020 | "/sys/class/scsi_host/host%d", shost->host_no); |
| 2021 | len = strnlen((char *)ae->un.AttrString, |
| 2022 | sizeof(ae->un.AttrString)); |
| 2023 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 2024 | size = FOURBYTES + len; |
| 2025 | ad->AttrLen = cpu_to_be16(size); |
| 2026 | ad->AttrType = cpu_to_be16(RPRT_OS_DEVICE_NAME); |
| 2027 | return size; |
| 2028 | } |
| 2029 | |
| 2030 | int |
| 2031 | lpfc_fdmi_port_attr_host_name(struct lpfc_vport *vport, |
| 2032 | struct lpfc_fdmi_attr_def *ad) |
| 2033 | { |
| 2034 | struct lpfc_fdmi_attr_entry *ae; |
| 2035 | uint32_t len, size; |
| 2036 | |
| 2037 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2038 | memset(ae, 0, 256); |
| 2039 | |
| 2040 | snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s", |
| 2041 | init_utsname()->nodename); |
| 2042 | |
| 2043 | len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString)); |
| 2044 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 2045 | size = FOURBYTES + len; |
| 2046 | ad->AttrLen = cpu_to_be16(size); |
| 2047 | ad->AttrType = cpu_to_be16(RPRT_HOST_NAME); |
| 2048 | return size; |
| 2049 | } |
| 2050 | |
| 2051 | int |
| 2052 | lpfc_fdmi_port_attr_wwnn(struct lpfc_vport *vport, |
| 2053 | struct lpfc_fdmi_attr_def *ad) |
| 2054 | { |
| 2055 | struct lpfc_fdmi_attr_entry *ae; |
| 2056 | uint32_t size; |
| 2057 | |
| 2058 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2059 | memset(ae, 0, sizeof(struct lpfc_name)); |
| 2060 | |
| 2061 | memcpy(&ae->un.AttrWWN, &vport->fc_sparam.nodeName, |
| 2062 | sizeof(struct lpfc_name)); |
| 2063 | size = FOURBYTES + sizeof(struct lpfc_name); |
| 2064 | ad->AttrLen = cpu_to_be16(size); |
| 2065 | ad->AttrType = cpu_to_be16(RPRT_NODENAME); |
| 2066 | return size; |
| 2067 | } |
| 2068 | |
| 2069 | int |
| 2070 | lpfc_fdmi_port_attr_wwpn(struct lpfc_vport *vport, |
| 2071 | struct lpfc_fdmi_attr_def *ad) |
| 2072 | { |
| 2073 | struct lpfc_fdmi_attr_entry *ae; |
| 2074 | uint32_t size; |
| 2075 | |
| 2076 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2077 | memset(ae, 0, sizeof(struct lpfc_name)); |
| 2078 | |
| 2079 | memcpy(&ae->un.AttrWWN, &vport->fc_sparam.portName, |
| 2080 | sizeof(struct lpfc_name)); |
| 2081 | size = FOURBYTES + sizeof(struct lpfc_name); |
| 2082 | ad->AttrLen = cpu_to_be16(size); |
| 2083 | ad->AttrType = cpu_to_be16(RPRT_PORTNAME); |
| 2084 | return size; |
| 2085 | } |
| 2086 | |
| 2087 | int |
| 2088 | lpfc_fdmi_port_attr_symbolic_name(struct lpfc_vport *vport, |
| 2089 | struct lpfc_fdmi_attr_def *ad) |
| 2090 | { |
| 2091 | struct lpfc_fdmi_attr_entry *ae; |
| 2092 | uint32_t len, size; |
| 2093 | |
| 2094 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2095 | memset(ae, 0, 256); |
| 2096 | |
| 2097 | len = lpfc_vport_symbolic_port_name(vport, ae->un.AttrString, 256); |
| 2098 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 2099 | size = FOURBYTES + len; |
| 2100 | ad->AttrLen = cpu_to_be16(size); |
| 2101 | ad->AttrType = cpu_to_be16(RPRT_SYM_PORTNAME); |
| 2102 | return size; |
| 2103 | } |
| 2104 | |
| 2105 | int |
| 2106 | lpfc_fdmi_port_attr_port_type(struct lpfc_vport *vport, |
| 2107 | struct lpfc_fdmi_attr_def *ad) |
| 2108 | { |
| 2109 | struct lpfc_hba *phba = vport->phba; |
| 2110 | struct lpfc_fdmi_attr_entry *ae; |
| 2111 | uint32_t size; |
| 2112 | |
| 2113 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2114 | if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) |
| 2115 | ae->un.AttrInt = cpu_to_be32(LPFC_FDMI_PORTTYPE_NLPORT); |
| 2116 | else |
| 2117 | ae->un.AttrInt = cpu_to_be32(LPFC_FDMI_PORTTYPE_NPORT); |
| 2118 | size = FOURBYTES + sizeof(uint32_t); |
| 2119 | ad->AttrLen = cpu_to_be16(size); |
| 2120 | ad->AttrType = cpu_to_be16(RPRT_PORT_TYPE); |
| 2121 | return size; |
| 2122 | } |
| 2123 | |
| 2124 | int |
| 2125 | lpfc_fdmi_port_attr_class(struct lpfc_vport *vport, |
| 2126 | struct lpfc_fdmi_attr_def *ad) |
| 2127 | { |
| 2128 | struct lpfc_fdmi_attr_entry *ae; |
| 2129 | uint32_t size; |
| 2130 | |
| 2131 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2132 | ae->un.AttrInt = cpu_to_be32(FC_COS_CLASS2 | FC_COS_CLASS3); |
| 2133 | size = FOURBYTES + sizeof(uint32_t); |
| 2134 | ad->AttrLen = cpu_to_be16(size); |
| 2135 | ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_CLASS); |
| 2136 | return size; |
| 2137 | } |
| 2138 | |
| 2139 | int |
| 2140 | lpfc_fdmi_port_attr_fabric_wwpn(struct lpfc_vport *vport, |
| 2141 | struct lpfc_fdmi_attr_def *ad) |
| 2142 | { |
| 2143 | struct lpfc_fdmi_attr_entry *ae; |
| 2144 | uint32_t size; |
| 2145 | |
| 2146 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2147 | memset(ae, 0, sizeof(struct lpfc_name)); |
| 2148 | |
| 2149 | memcpy(&ae->un.AttrWWN, &vport->fabric_portname, |
| 2150 | sizeof(struct lpfc_name)); |
| 2151 | size = FOURBYTES + sizeof(struct lpfc_name); |
| 2152 | ad->AttrLen = cpu_to_be16(size); |
| 2153 | ad->AttrType = cpu_to_be16(RPRT_FABRICNAME); |
| 2154 | return size; |
| 2155 | } |
| 2156 | |
| 2157 | int |
| 2158 | lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport, |
| 2159 | struct lpfc_fdmi_attr_def *ad) |
| 2160 | { |
| 2161 | struct lpfc_fdmi_attr_entry *ae; |
| 2162 | uint32_t size; |
| 2163 | |
| 2164 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2165 | memset(ae, 0, 32); |
| 2166 | |
| 2167 | ae->un.AttrTypes[3] = 0x02; /* Type 1 - ELS */ |
| 2168 | ae->un.AttrTypes[2] = 0x01; /* Type 8 - FCP */ |
| 2169 | ae->un.AttrTypes[7] = 0x01; /* Type 32 - CT */ |
| 2170 | size = FOURBYTES + 32; |
| 2171 | ad->AttrLen = cpu_to_be16(size); |
| 2172 | ad->AttrType = cpu_to_be16(RPRT_ACTIVE_FC4_TYPES); |
| 2173 | return size; |
| 2174 | } |
| 2175 | |
| 2176 | int |
| 2177 | lpfc_fdmi_port_attr_port_state(struct lpfc_vport *vport, |
| 2178 | struct lpfc_fdmi_attr_def *ad) |
| 2179 | { |
| 2180 | struct lpfc_fdmi_attr_entry *ae; |
| 2181 | uint32_t size; |
| 2182 | |
| 2183 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2184 | /* Link Up - operational */ |
| 2185 | ae->un.AttrInt = cpu_to_be32(LPFC_FDMI_PORTSTATE_ONLINE); |
| 2186 | size = FOURBYTES + sizeof(uint32_t); |
| 2187 | ad->AttrLen = cpu_to_be16(size); |
| 2188 | ad->AttrType = cpu_to_be16(RPRT_PORT_STATE); |
| 2189 | return size; |
| 2190 | } |
| 2191 | |
| 2192 | int |
| 2193 | lpfc_fdmi_port_attr_num_disc(struct lpfc_vport *vport, |
| 2194 | struct lpfc_fdmi_attr_def *ad) |
| 2195 | { |
| 2196 | struct lpfc_fdmi_attr_entry *ae; |
| 2197 | uint32_t size; |
| 2198 | |
| 2199 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2200 | vport->fdmi_num_disc = lpfc_find_map_node(vport); |
| 2201 | ae->un.AttrInt = cpu_to_be32(vport->fdmi_num_disc); |
| 2202 | size = FOURBYTES + sizeof(uint32_t); |
| 2203 | ad->AttrLen = cpu_to_be16(size); |
| 2204 | ad->AttrType = cpu_to_be16(RPRT_DISC_PORT); |
| 2205 | return size; |
| 2206 | } |
| 2207 | |
| 2208 | int |
| 2209 | lpfc_fdmi_port_attr_nportid(struct lpfc_vport *vport, |
| 2210 | struct lpfc_fdmi_attr_def *ad) |
| 2211 | { |
| 2212 | struct lpfc_fdmi_attr_entry *ae; |
| 2213 | uint32_t size; |
| 2214 | |
| 2215 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2216 | ae->un.AttrInt = cpu_to_be32(vport->fc_myDID); |
| 2217 | size = FOURBYTES + sizeof(uint32_t); |
| 2218 | ad->AttrLen = cpu_to_be16(size); |
| 2219 | ad->AttrType = cpu_to_be16(RPRT_PORT_ID); |
| 2220 | return size; |
| 2221 | } |
| 2222 | |
| 2223 | int |
| 2224 | lpfc_fdmi_smart_attr_service(struct lpfc_vport *vport, |
| 2225 | struct lpfc_fdmi_attr_def *ad) |
| 2226 | { |
| 2227 | struct lpfc_fdmi_attr_entry *ae; |
| 2228 | uint32_t len, size; |
| 2229 | |
| 2230 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2231 | memset(ae, 0, 256); |
| 2232 | |
| 2233 | strncpy(ae->un.AttrString, "Smart SAN Initiator", |
| 2234 | sizeof(ae->un.AttrString)); |
| 2235 | len = strnlen(ae->un.AttrString, |
| 2236 | sizeof(ae->un.AttrString)); |
| 2237 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 2238 | size = FOURBYTES + len; |
| 2239 | ad->AttrLen = cpu_to_be16(size); |
| 2240 | ad->AttrType = cpu_to_be16(RPRT_SMART_SERVICE); |
| 2241 | return size; |
| 2242 | } |
| 2243 | |
| 2244 | int |
| 2245 | lpfc_fdmi_smart_attr_guid(struct lpfc_vport *vport, |
| 2246 | struct lpfc_fdmi_attr_def *ad) |
| 2247 | { |
| 2248 | struct lpfc_fdmi_attr_entry *ae; |
| 2249 | uint32_t size; |
| 2250 | |
| 2251 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2252 | memset(ae, 0, 256); |
| 2253 | |
| 2254 | memcpy(&ae->un.AttrString, &vport->fc_sparam.nodeName, |
| 2255 | sizeof(struct lpfc_name)); |
| 2256 | memcpy((((uint8_t *)&ae->un.AttrString) + |
| 2257 | sizeof(struct lpfc_name)), |
| 2258 | &vport->fc_sparam.portName, sizeof(struct lpfc_name)); |
| 2259 | size = FOURBYTES + (2 * sizeof(struct lpfc_name)); |
| 2260 | ad->AttrLen = cpu_to_be16(size); |
| 2261 | ad->AttrType = cpu_to_be16(RPRT_SMART_GUID); |
| 2262 | return size; |
| 2263 | } |
| 2264 | |
| 2265 | int |
| 2266 | lpfc_fdmi_smart_attr_version(struct lpfc_vport *vport, |
| 2267 | struct lpfc_fdmi_attr_def *ad) |
| 2268 | { |
| 2269 | struct lpfc_fdmi_attr_entry *ae; |
| 2270 | uint32_t len, size; |
| 2271 | |
| 2272 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2273 | memset(ae, 0, 256); |
| 2274 | |
| 2275 | strncpy(ae->un.AttrString, "Smart SAN Version 1.0", |
| 2276 | sizeof(ae->un.AttrString)); |
| 2277 | len = strnlen(ae->un.AttrString, |
| 2278 | sizeof(ae->un.AttrString)); |
| 2279 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 2280 | size = FOURBYTES + len; |
| 2281 | ad->AttrLen = cpu_to_be16(size); |
| 2282 | ad->AttrType = cpu_to_be16(RPRT_SMART_VERSION); |
| 2283 | return size; |
| 2284 | } |
| 2285 | |
| 2286 | int |
| 2287 | lpfc_fdmi_smart_attr_model(struct lpfc_vport *vport, |
| 2288 | struct lpfc_fdmi_attr_def *ad) |
| 2289 | { |
| 2290 | struct lpfc_hba *phba = vport->phba; |
| 2291 | struct lpfc_fdmi_attr_entry *ae; |
| 2292 | uint32_t len, size; |
| 2293 | |
| 2294 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2295 | memset(ae, 0, 256); |
| 2296 | |
| 2297 | strncpy(ae->un.AttrString, phba->ModelName, |
| 2298 | sizeof(ae->un.AttrString)); |
| 2299 | len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString)); |
| 2300 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 2301 | size = FOURBYTES + len; |
| 2302 | ad->AttrLen = cpu_to_be16(size); |
| 2303 | ad->AttrType = cpu_to_be16(RPRT_SMART_MODEL); |
| 2304 | return size; |
| 2305 | } |
| 2306 | |
| 2307 | int |
| 2308 | lpfc_fdmi_smart_attr_port_info(struct lpfc_vport *vport, |
| 2309 | struct lpfc_fdmi_attr_def *ad) |
| 2310 | { |
| 2311 | struct lpfc_fdmi_attr_entry *ae; |
| 2312 | uint32_t size; |
| 2313 | |
| 2314 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2315 | |
| 2316 | /* SRIOV (type 3) is not supported */ |
| 2317 | if (vport->vpi) |
| 2318 | ae->un.AttrInt = cpu_to_be32(2); /* NPIV */ |
| 2319 | else |
| 2320 | ae->un.AttrInt = cpu_to_be32(1); /* Physical */ |
| 2321 | size = FOURBYTES + sizeof(uint32_t); |
| 2322 | ad->AttrLen = cpu_to_be16(size); |
| 2323 | ad->AttrType = cpu_to_be16(RPRT_SMART_PORT_INFO); |
| 2324 | return size; |
| 2325 | } |
| 2326 | |
| 2327 | int |
| 2328 | lpfc_fdmi_smart_attr_qos(struct lpfc_vport *vport, |
| 2329 | struct lpfc_fdmi_attr_def *ad) |
| 2330 | { |
| 2331 | struct lpfc_fdmi_attr_entry *ae; |
| 2332 | uint32_t size; |
| 2333 | |
| 2334 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2335 | ae->un.AttrInt = cpu_to_be32(0); |
| 2336 | size = FOURBYTES + sizeof(uint32_t); |
| 2337 | ad->AttrLen = cpu_to_be16(size); |
| 2338 | ad->AttrType = cpu_to_be16(RPRT_SMART_QOS); |
| 2339 | return size; |
| 2340 | } |
| 2341 | |
| 2342 | int |
| 2343 | lpfc_fdmi_smart_attr_security(struct lpfc_vport *vport, |
| 2344 | struct lpfc_fdmi_attr_def *ad) |
| 2345 | { |
| 2346 | struct lpfc_fdmi_attr_entry *ae; |
| 2347 | uint32_t size; |
| 2348 | |
| 2349 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2350 | ae->un.AttrInt = cpu_to_be32(0); |
| 2351 | size = FOURBYTES + sizeof(uint32_t); |
| 2352 | ad->AttrLen = cpu_to_be16(size); |
| 2353 | ad->AttrType = cpu_to_be16(RPRT_SMART_SECURITY); |
| 2354 | return size; |
| 2355 | } |
| 2356 | |
| 2357 | /* RHBA attribute jump table */ |
| 2358 | int (*lpfc_fdmi_hba_action[]) |
| 2359 | (struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad) = { |
| 2360 | /* Action routine Mask bit Attribute type */ |
| 2361 | lpfc_fdmi_hba_attr_wwnn, /* bit0 RHBA_NODENAME */ |
| 2362 | lpfc_fdmi_hba_attr_manufacturer, /* bit1 RHBA_MANUFACTURER */ |
| 2363 | lpfc_fdmi_hba_attr_sn, /* bit2 RHBA_SERIAL_NUMBER */ |
| 2364 | lpfc_fdmi_hba_attr_model, /* bit3 RHBA_MODEL */ |
| 2365 | lpfc_fdmi_hba_attr_description, /* bit4 RHBA_MODEL_DESCRIPTION */ |
| 2366 | lpfc_fdmi_hba_attr_hdw_ver, /* bit5 RHBA_HARDWARE_VERSION */ |
| 2367 | lpfc_fdmi_hba_attr_drvr_ver, /* bit6 RHBA_DRIVER_VERSION */ |
| 2368 | lpfc_fdmi_hba_attr_rom_ver, /* bit7 RHBA_OPTION_ROM_VERSION */ |
| 2369 | lpfc_fdmi_hba_attr_fmw_ver, /* bit8 RHBA_FIRMWARE_VERSION */ |
| 2370 | lpfc_fdmi_hba_attr_os_ver, /* bit9 RHBA_OS_NAME_VERSION */ |
| 2371 | lpfc_fdmi_hba_attr_ct_len, /* bit10 RHBA_MAX_CT_PAYLOAD_LEN */ |
| 2372 | lpfc_fdmi_hba_attr_symbolic_name, /* bit11 RHBA_SYM_NODENAME */ |
| 2373 | lpfc_fdmi_hba_attr_vendor_info, /* bit12 RHBA_VENDOR_INFO */ |
| 2374 | lpfc_fdmi_hba_attr_num_ports, /* bit13 RHBA_NUM_PORTS */ |
| 2375 | lpfc_fdmi_hba_attr_fabric_wwnn, /* bit14 RHBA_FABRIC_WWNN */ |
| 2376 | lpfc_fdmi_hba_attr_bios_ver, /* bit15 RHBA_BIOS_VERSION */ |
| 2377 | lpfc_fdmi_hba_attr_bios_state, /* bit16 RHBA_BIOS_STATE */ |
| 2378 | lpfc_fdmi_hba_attr_vendor_id, /* bit17 RHBA_VENDOR_ID */ |
| 2379 | }; |
| 2380 | |
| 2381 | /* RPA / RPRT attribute jump table */ |
| 2382 | int (*lpfc_fdmi_port_action[]) |
| 2383 | (struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad) = { |
| 2384 | /* Action routine Mask bit Attribute type */ |
| 2385 | lpfc_fdmi_port_attr_fc4type, /* bit0 RPRT_SUPPORT_FC4_TYPES */ |
| 2386 | lpfc_fdmi_port_attr_support_speed, /* bit1 RPRT_SUPPORTED_SPEED */ |
| 2387 | lpfc_fdmi_port_attr_speed, /* bit2 RPRT_PORT_SPEED */ |
| 2388 | lpfc_fdmi_port_attr_max_frame, /* bit3 RPRT_MAX_FRAME_SIZE */ |
| 2389 | lpfc_fdmi_port_attr_os_devname, /* bit4 RPRT_OS_DEVICE_NAME */ |
| 2390 | lpfc_fdmi_port_attr_host_name, /* bit5 RPRT_HOST_NAME */ |
| 2391 | lpfc_fdmi_port_attr_wwnn, /* bit6 RPRT_NODENAME */ |
| 2392 | lpfc_fdmi_port_attr_wwpn, /* bit7 RPRT_PORTNAME */ |
| 2393 | lpfc_fdmi_port_attr_symbolic_name, /* bit8 RPRT_SYM_PORTNAME */ |
| 2394 | lpfc_fdmi_port_attr_port_type, /* bit9 RPRT_PORT_TYPE */ |
| 2395 | lpfc_fdmi_port_attr_class, /* bit10 RPRT_SUPPORTED_CLASS */ |
| 2396 | lpfc_fdmi_port_attr_fabric_wwpn, /* bit11 RPRT_FABRICNAME */ |
| 2397 | lpfc_fdmi_port_attr_active_fc4type, /* bit12 RPRT_ACTIVE_FC4_TYPES */ |
| 2398 | lpfc_fdmi_port_attr_port_state, /* bit13 RPRT_PORT_STATE */ |
| 2399 | lpfc_fdmi_port_attr_num_disc, /* bit14 RPRT_DISC_PORT */ |
| 2400 | lpfc_fdmi_port_attr_nportid, /* bit15 RPRT_PORT_ID */ |
| 2401 | lpfc_fdmi_smart_attr_service, /* bit16 RPRT_SMART_SERVICE */ |
| 2402 | lpfc_fdmi_smart_attr_guid, /* bit17 RPRT_SMART_GUID */ |
| 2403 | lpfc_fdmi_smart_attr_version, /* bit18 RPRT_SMART_VERSION */ |
| 2404 | lpfc_fdmi_smart_attr_model, /* bit19 RPRT_SMART_MODEL */ |
| 2405 | lpfc_fdmi_smart_attr_port_info, /* bit20 RPRT_SMART_PORT_INFO */ |
| 2406 | lpfc_fdmi_smart_attr_qos, /* bit21 RPRT_SMART_QOS */ |
| 2407 | lpfc_fdmi_smart_attr_security, /* bit22 RPRT_SMART_SECURITY */ |
| 2408 | }; |
| 2409 | |
| 2410 | /** |
| 2411 | * lpfc_fdmi_cmd - Build and send a FDMI cmd to the specified NPort |
| 2412 | * @vport: pointer to a host virtual N_Port data structure. |
| 2413 | * @ndlp: ndlp to send FDMI cmd to (if NULL use FDMI_DID) |
| 2414 | * cmdcode: FDMI command to send |
| 2415 | * mask: Mask of HBA or PORT Attributes to send |
| 2416 | * |
| 2417 | * Builds and sends a FDMI command using the CT subsystem. |
| 2418 | */ |
| 2419 | int |
| 2420 | lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
| 2421 | int cmdcode, uint32_t new_mask) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2422 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2423 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2424 | struct lpfc_dmabuf *mp, *bmp; |
| 2425 | struct lpfc_sli_ct_request *CtReq; |
| 2426 | struct ulp_bde64 *bpl; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 2427 | uint32_t bit_pos; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2428 | uint32_t size; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2429 | uint32_t rsp_size; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 2430 | uint32_t mask; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2431 | struct lpfc_fdmi_reg_hba *rh; |
| 2432 | struct lpfc_fdmi_port_entry *pe; |
| 2433 | struct lpfc_fdmi_reg_portattr *pab = NULL; |
| 2434 | struct lpfc_fdmi_attr_block *ab = NULL; |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 2435 | int (*func)(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad); |
| 2436 | void (*cmpl)(struct lpfc_hba *, struct lpfc_iocbq *, |
| 2437 | struct lpfc_iocbq *); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2438 | |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 2439 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 2440 | return 0; |
| 2441 | |
| 2442 | cmpl = lpfc_cmpl_ct_disc_fdmi; /* called from discovery */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2443 | |
| 2444 | /* fill in BDEs for command */ |
| 2445 | /* Allocate buffer for command payload */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2446 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2447 | if (!mp) |
| 2448 | goto fdmi_cmd_exit; |
| 2449 | |
| 2450 | mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys)); |
| 2451 | if (!mp->virt) |
| 2452 | goto fdmi_cmd_free_mp; |
| 2453 | |
| 2454 | /* Allocate buffer for Buffer ptr list */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2455 | bmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2456 | if (!bmp) |
| 2457 | goto fdmi_cmd_free_mpvirt; |
| 2458 | |
| 2459 | bmp->virt = lpfc_mbuf_alloc(phba, 0, &(bmp->phys)); |
| 2460 | if (!bmp->virt) |
| 2461 | goto fdmi_cmd_free_bmp; |
| 2462 | |
| 2463 | INIT_LIST_HEAD(&mp->list); |
| 2464 | INIT_LIST_HEAD(&bmp->list); |
| 2465 | |
| 2466 | /* FDMI request */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2467 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 2468 | "0218 FDMI Request Data: x%x x%x x%x\n", |
| 2469 | vport->fc_flag, vport->port_state, cmdcode); |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2470 | CtReq = (struct lpfc_sli_ct_request *)mp->virt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2471 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2472 | /* First populate the CT_IU preamble */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2473 | memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request)); |
| 2474 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; |
| 2475 | CtReq->RevisionId.bits.InId = 0; |
| 2476 | |
| 2477 | CtReq->FsType = SLI_CT_MANAGEMENT_SERVICE; |
| 2478 | CtReq->FsSubType = SLI_CT_FDMI_Subtypes; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2479 | |
| 2480 | CtReq->CommandResponse.bits.CmdRsp = cpu_to_be16(cmdcode); |
| 2481 | rsp_size = LPFC_BPL_SIZE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2482 | size = 0; |
| 2483 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2484 | /* Next fill in the specific FDMI cmd information */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2485 | switch (cmdcode) { |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2486 | case SLI_MGMT_RHAT: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2487 | case SLI_MGMT_RHBA: |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 2488 | rh = (struct lpfc_fdmi_reg_hba *)&CtReq->un.PortID; |
| 2489 | /* HBA Identifier */ |
| 2490 | memcpy(&rh->hi.PortName, &phba->pport->fc_sparam.portName, |
| 2491 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2492 | |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 2493 | if (cmdcode == SLI_MGMT_RHBA) { |
| 2494 | /* Registered Port List */ |
| 2495 | /* One entry (port) per adapter */ |
| 2496 | rh->rpl.EntryCnt = cpu_to_be32(1); |
| 2497 | memcpy(&rh->rpl.pe, &phba->pport->fc_sparam.portName, |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2498 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2499 | |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 2500 | /* point to the HBA attribute block */ |
| 2501 | size = 2 * sizeof(struct lpfc_name) + |
| 2502 | FOURBYTES; |
| 2503 | } else { |
| 2504 | size = sizeof(struct lpfc_name); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2505 | } |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 2506 | ab = (struct lpfc_fdmi_attr_block *)((uint8_t *)rh + size); |
| 2507 | ab->EntryCnt = 0; |
| 2508 | size += FOURBYTES; |
| 2509 | bit_pos = 0; |
| 2510 | if (new_mask) |
| 2511 | mask = new_mask; |
| 2512 | else |
| 2513 | mask = vport->fdmi_hba_mask; |
| 2514 | |
| 2515 | /* Mask will dictate what attributes to build in the request */ |
| 2516 | while (mask) { |
| 2517 | if (mask & 0x1) { |
| 2518 | func = lpfc_fdmi_hba_action[bit_pos]; |
| 2519 | size += func(vport, |
| 2520 | (struct lpfc_fdmi_attr_def *) |
| 2521 | ((uint8_t *)rh + size)); |
| 2522 | ab->EntryCnt++; |
| 2523 | if ((size + 256) > |
| 2524 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 2525 | goto hba_out; |
| 2526 | } |
| 2527 | mask = mask >> 1; |
| 2528 | bit_pos++; |
| 2529 | } |
| 2530 | hba_out: |
| 2531 | ab->EntryCnt = cpu_to_be32(ab->EntryCnt); |
| 2532 | /* Total size */ |
| 2533 | size = GID_REQUEST_SZ - 4 + size; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2534 | break; |
| 2535 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2536 | case SLI_MGMT_RPRT: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2537 | case SLI_MGMT_RPA: |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 2538 | pab = (struct lpfc_fdmi_reg_portattr *)&CtReq->un.PortID; |
| 2539 | if (cmdcode == SLI_MGMT_RPRT) { |
| 2540 | rh = (struct lpfc_fdmi_reg_hba *)pab; |
| 2541 | /* HBA Identifier */ |
| 2542 | memcpy(&rh->hi.PortName, |
| 2543 | &phba->pport->fc_sparam.portName, |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2544 | sizeof(struct lpfc_name)); |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 2545 | pab = (struct lpfc_fdmi_reg_portattr *) |
| 2546 | ((uint8_t *)pab + sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2547 | } |
James Smart | 4258e98 | 2015-12-16 18:11:58 -0500 | [diff] [blame^] | 2548 | |
| 2549 | memcpy((uint8_t *)&pab->PortName, |
| 2550 | (uint8_t *)&vport->fc_sparam.portName, |
| 2551 | sizeof(struct lpfc_name)); |
| 2552 | size += sizeof(struct lpfc_name) + FOURBYTES; |
| 2553 | pab->ab.EntryCnt = 0; |
| 2554 | bit_pos = 0; |
| 2555 | if (new_mask) |
| 2556 | mask = new_mask; |
| 2557 | else |
| 2558 | mask = vport->fdmi_port_mask; |
| 2559 | |
| 2560 | /* Mask will dictate what attributes to build in the request */ |
| 2561 | while (mask) { |
| 2562 | if (mask & 0x1) { |
| 2563 | func = lpfc_fdmi_port_action[bit_pos]; |
| 2564 | size += func(vport, |
| 2565 | (struct lpfc_fdmi_attr_def *) |
| 2566 | ((uint8_t *)pab + size)); |
| 2567 | pab->ab.EntryCnt++; |
| 2568 | if ((size + 256) > |
| 2569 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 2570 | goto port_out; |
| 2571 | } |
| 2572 | mask = mask >> 1; |
| 2573 | bit_pos++; |
| 2574 | } |
| 2575 | port_out: |
| 2576 | pab->ab.EntryCnt = cpu_to_be32(pab->ab.EntryCnt); |
| 2577 | /* Total size */ |
| 2578 | if (cmdcode == SLI_MGMT_RPRT) |
| 2579 | size += sizeof(struct lpfc_name); |
| 2580 | size = GID_REQUEST_SZ - 4 + size; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2581 | break; |
| 2582 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2583 | case SLI_MGMT_GHAT: |
| 2584 | case SLI_MGMT_GRPL: |
| 2585 | rsp_size = FC_MAX_NS_RSP; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2586 | case SLI_MGMT_DHBA: |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2587 | case SLI_MGMT_DHAT: |
| 2588 | pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID; |
| 2589 | memcpy((uint8_t *)&pe->PortName, |
| 2590 | (uint8_t *)&vport->fc_sparam.portName, |
| 2591 | sizeof(struct lpfc_name)); |
| 2592 | size = GID_REQUEST_SZ - 4 + sizeof(struct lpfc_name); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2593 | break; |
| 2594 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2595 | case SLI_MGMT_GPAT: |
| 2596 | case SLI_MGMT_GPAS: |
| 2597 | rsp_size = FC_MAX_NS_RSP; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2598 | case SLI_MGMT_DPRT: |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2599 | case SLI_MGMT_DPA: |
| 2600 | pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID; |
| 2601 | memcpy((uint8_t *)&pe->PortName, |
| 2602 | (uint8_t *)&vport->fc_sparam.portName, |
| 2603 | sizeof(struct lpfc_name)); |
| 2604 | size = GID_REQUEST_SZ - 4 + sizeof(struct lpfc_name); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2605 | break; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2606 | case SLI_MGMT_GRHL: |
| 2607 | size = GID_REQUEST_SZ - 4; |
| 2608 | break; |
| 2609 | default: |
| 2610 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_DISCOVERY, |
| 2611 | "0298 FDMI cmdcode x%x not supported\n", |
| 2612 | cmdcode); |
| 2613 | goto fdmi_cmd_free_bmpvirt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2614 | } |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2615 | CtReq->CommandResponse.bits.Size = cpu_to_be16(rsp_size); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2616 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2617 | bpl = (struct ulp_bde64 *)bmp->virt; |
| 2618 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys)); |
| 2619 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2620 | bpl->tus.f.bdeFlags = 0; |
| 2621 | bpl->tus.f.bdeSize = size; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2622 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2623 | /* |
| 2624 | * The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2625 | * to hold ndlp reference for the corresponding callback function. |
| 2626 | */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2627 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, 0)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2628 | return 0; |
| 2629 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2630 | /* |
| 2631 | * Decrement ndlp reference count to release ndlp reference held |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2632 | * for the failed command's callback function. |
| 2633 | */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2634 | lpfc_nlp_put(ndlp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2635 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2636 | fdmi_cmd_free_bmpvirt: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2637 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 2638 | fdmi_cmd_free_bmp: |
| 2639 | kfree(bmp); |
| 2640 | fdmi_cmd_free_mpvirt: |
| 2641 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 2642 | fdmi_cmd_free_mp: |
| 2643 | kfree(mp); |
| 2644 | fdmi_cmd_exit: |
| 2645 | /* Issue FDMI request failed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2646 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 2647 | "0244 Issue FDMI request failed Data: x%x\n", |
| 2648 | cmdcode); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2649 | return 1; |
| 2650 | } |
| 2651 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 2652 | /** |
| 2653 | * lpfc_delayed_disc_tmo - Timeout handler for delayed discovery timer. |
| 2654 | * @ptr - Context object of the timer. |
| 2655 | * |
| 2656 | * This function set the WORKER_DELAYED_DISC_TMO flag and wake up |
| 2657 | * the worker thread. |
| 2658 | **/ |
| 2659 | void |
| 2660 | lpfc_delayed_disc_tmo(unsigned long ptr) |
| 2661 | { |
| 2662 | struct lpfc_vport *vport = (struct lpfc_vport *)ptr; |
| 2663 | struct lpfc_hba *phba = vport->phba; |
| 2664 | uint32_t tmo_posted; |
| 2665 | unsigned long iflag; |
| 2666 | |
| 2667 | spin_lock_irqsave(&vport->work_port_lock, iflag); |
| 2668 | tmo_posted = vport->work_port_events & WORKER_DELAYED_DISC_TMO; |
| 2669 | if (!tmo_posted) |
| 2670 | vport->work_port_events |= WORKER_DELAYED_DISC_TMO; |
| 2671 | spin_unlock_irqrestore(&vport->work_port_lock, iflag); |
| 2672 | |
| 2673 | if (!tmo_posted) |
| 2674 | lpfc_worker_wake_up(phba); |
| 2675 | return; |
| 2676 | } |
| 2677 | |
| 2678 | /** |
| 2679 | * lpfc_delayed_disc_timeout_handler - Function called by worker thread to |
| 2680 | * handle delayed discovery. |
| 2681 | * @vport: pointer to a host virtual N_Port data structure. |
| 2682 | * |
| 2683 | * This function start nport discovery of the vport. |
| 2684 | **/ |
| 2685 | void |
| 2686 | lpfc_delayed_disc_timeout_handler(struct lpfc_vport *vport) |
| 2687 | { |
| 2688 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2689 | |
| 2690 | spin_lock_irq(shost->host_lock); |
| 2691 | if (!(vport->fc_flag & FC_DISC_DELAYED)) { |
| 2692 | spin_unlock_irq(shost->host_lock); |
| 2693 | return; |
| 2694 | } |
| 2695 | vport->fc_flag &= ~FC_DISC_DELAYED; |
| 2696 | spin_unlock_irq(shost->host_lock); |
| 2697 | |
| 2698 | lpfc_do_scr_ns_plogi(vport->phba, vport); |
| 2699 | } |
| 2700 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2701 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2702 | lpfc_decode_firmware_rev(struct lpfc_hba *phba, char *fwrevision, int flag) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2703 | { |
| 2704 | struct lpfc_sli *psli = &phba->sli; |
| 2705 | lpfc_vpd_t *vp = &phba->vpd; |
| 2706 | uint32_t b1, b2, b3, b4, i, rev; |
| 2707 | char c; |
| 2708 | uint32_t *ptr, str[4]; |
| 2709 | uint8_t *fwname; |
| 2710 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 2711 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 2712 | snprintf(fwrevision, FW_REV_STR_SIZE, "%s", vp->rev.opFwName); |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 2713 | else if (vp->rev.rBit) { |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2714 | if (psli->sli_flag & LPFC_SLI_ACTIVE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2715 | rev = vp->rev.sli2FwRev; |
| 2716 | else |
| 2717 | rev = vp->rev.sli1FwRev; |
| 2718 | |
| 2719 | b1 = (rev & 0x0000f000) >> 12; |
| 2720 | b2 = (rev & 0x00000f00) >> 8; |
| 2721 | b3 = (rev & 0x000000c0) >> 6; |
| 2722 | b4 = (rev & 0x00000030) >> 4; |
| 2723 | |
| 2724 | switch (b4) { |
| 2725 | case 0: |
| 2726 | c = 'N'; |
| 2727 | break; |
| 2728 | case 1: |
| 2729 | c = 'A'; |
| 2730 | break; |
| 2731 | case 2: |
| 2732 | c = 'B'; |
| 2733 | break; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 2734 | case 3: |
| 2735 | c = 'X'; |
| 2736 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2737 | default: |
| 2738 | c = 0; |
| 2739 | break; |
| 2740 | } |
| 2741 | b4 = (rev & 0x0000000f); |
| 2742 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2743 | if (psli->sli_flag & LPFC_SLI_ACTIVE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2744 | fwname = vp->rev.sli2FwName; |
| 2745 | else |
| 2746 | fwname = vp->rev.sli1FwName; |
| 2747 | |
| 2748 | for (i = 0; i < 16; i++) |
| 2749 | if (fwname[i] == 0x20) |
| 2750 | fwname[i] = 0; |
| 2751 | |
| 2752 | ptr = (uint32_t*)fwname; |
| 2753 | |
| 2754 | for (i = 0; i < 3; i++) |
| 2755 | str[i] = be32_to_cpu(*ptr++); |
| 2756 | |
| 2757 | if (c == 0) { |
| 2758 | if (flag) |
| 2759 | sprintf(fwrevision, "%d.%d%d (%s)", |
| 2760 | b1, b2, b3, (char *)str); |
| 2761 | else |
| 2762 | sprintf(fwrevision, "%d.%d%d", b1, |
| 2763 | b2, b3); |
| 2764 | } else { |
| 2765 | if (flag) |
| 2766 | sprintf(fwrevision, "%d.%d%d%c%d (%s)", |
| 2767 | b1, b2, b3, c, |
| 2768 | b4, (char *)str); |
| 2769 | else |
| 2770 | sprintf(fwrevision, "%d.%d%d%c%d", |
| 2771 | b1, b2, b3, c, b4); |
| 2772 | } |
| 2773 | } else { |
| 2774 | rev = vp->rev.smFwRev; |
| 2775 | |
| 2776 | b1 = (rev & 0xff000000) >> 24; |
| 2777 | b2 = (rev & 0x00f00000) >> 20; |
| 2778 | b3 = (rev & 0x000f0000) >> 16; |
| 2779 | c = (rev & 0x0000ff00) >> 8; |
| 2780 | b4 = (rev & 0x000000ff); |
| 2781 | |
Roel Kluin | d44a6d2 | 2010-01-17 16:15:57 +0100 | [diff] [blame] | 2782 | sprintf(fwrevision, "%d.%d%d%c%d", b1, b2, b3, c, b4); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2783 | } |
| 2784 | return; |
| 2785 | } |