| 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 */ |
| 58 | #define HBA_PORTSPEED_UNKNOWN 0x0800 /* Unknown */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 59 | |
| 60 | #define FOURBYTES 4 |
| 61 | |
| 62 | |
| 63 | static char *lpfc_release_version = LPFC_DRIVER_VERSION; |
| 64 | |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 65 | static void |
| 66 | 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] | 67 | struct lpfc_dmabuf *mp, uint32_t size) |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 68 | { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 69 | if (!mp) { |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 70 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, |
James Smart | 97eab63 | 2008-04-07 10:16:05 -0400 | [diff] [blame] | 71 | "0146 Ignoring unsolicited CT No HBQ " |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 72 | "status = x%x\n", |
| 73 | piocbq->iocb.ulpStatus); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 74 | } |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 75 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, |
| 76 | "0145 Ignoring unsolicted CT HBQ Size:%d " |
| 77 | "status = x%x\n", |
| 78 | size, piocbq->iocb.ulpStatus); |
| 79 | } |
| 80 | |
| 81 | static void |
| 82 | lpfc_ct_unsol_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq, |
| 83 | struct lpfc_dmabuf *mp, uint32_t size) |
| 84 | { |
| 85 | lpfc_ct_ignore_hbq_buffer(phba, piocbq, mp, size); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 86 | } |
| 87 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 88 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 89 | lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
| 90 | struct lpfc_iocbq *piocbq) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 91 | { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 92 | struct lpfc_dmabuf *mp = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 93 | IOCB_t *icmd = &piocbq->iocb; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 94 | int i; |
| 95 | struct lpfc_iocbq *iocbq; |
| 96 | dma_addr_t paddr; |
| 97 | uint32_t size; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 98 | struct list_head head; |
| 99 | struct lpfc_dmabuf *bdeBuf; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 100 | |
James Smart | 4fede78 | 2010-01-26 23:08:55 -0500 | [diff] [blame] | 101 | if (lpfc_bsg_ct_unsol_event(phba, pring, piocbq) == 0) |
| 102 | return; |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 103 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 104 | if (unlikely(icmd->ulpStatus == IOSTAT_NEED_BUFFER)) { |
| 105 | lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ); |
| 106 | } else if ((icmd->ulpStatus == IOSTAT_LOCAL_REJECT) && |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 107 | ((icmd->un.ulpWord[4] & IOERR_PARAM_MASK) == |
| 108 | IOERR_RCV_BUFFER_WAITING)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 109 | /* Not enough posted buffers; Try posting more buffers */ |
| 110 | phba->fc_stat.NoRcvBuf++; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 111 | if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)) |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 112 | lpfc_post_buffer(phba, pring, 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 113 | return; |
| 114 | } |
| 115 | |
| 116 | /* If there are no BDEs associated with this IOCB, |
| 117 | * there is nothing to do. |
| 118 | */ |
| 119 | if (icmd->ulpBdeCount == 0) |
| 120 | return; |
| 121 | |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 122 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 123 | INIT_LIST_HEAD(&head); |
| 124 | list_add_tail(&head, &piocbq->list); |
| 125 | list_for_each_entry(iocbq, &head, list) { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 126 | icmd = &iocbq->iocb; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 127 | if (icmd->ulpBdeCount == 0) |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 128 | continue; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 129 | bdeBuf = iocbq->context2; |
| 130 | iocbq->context2 = NULL; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 131 | size = icmd->un.cont64[0].tus.f.bdeSize; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 132 | lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, size); |
| 133 | lpfc_in_buf_free(phba, bdeBuf); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 134 | if (icmd->ulpBdeCount == 2) { |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 135 | bdeBuf = iocbq->context3; |
| 136 | iocbq->context3 = NULL; |
| 137 | size = icmd->unsli3.rcvsli3.bde2.tus.f.bdeSize; |
| 138 | lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, |
| 139 | size); |
| 140 | lpfc_in_buf_free(phba, bdeBuf); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 141 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 142 | } |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 143 | list_del(&head); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 144 | } else { |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 145 | INIT_LIST_HEAD(&head); |
| 146 | list_add_tail(&head, &piocbq->list); |
| 147 | list_for_each_entry(iocbq, &head, list) { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 148 | icmd = &iocbq->iocb; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 149 | if (icmd->ulpBdeCount == 0) |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 150 | lpfc_ct_unsol_buffer(phba, iocbq, NULL, 0); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 151 | for (i = 0; i < icmd->ulpBdeCount; i++) { |
| 152 | paddr = getPaddr(icmd->un.cont64[i].addrHigh, |
| 153 | icmd->un.cont64[i].addrLow); |
| 154 | mp = lpfc_sli_ringpostbuf_get(phba, pring, |
| 155 | paddr); |
| 156 | size = icmd->un.cont64[i].tus.f.bdeSize; |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 157 | lpfc_ct_unsol_buffer(phba, iocbq, mp, size); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 158 | lpfc_in_buf_free(phba, mp); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 159 | } |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 160 | lpfc_post_buffer(phba, pring, i); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 161 | } |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 162 | list_del(&head); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 163 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 164 | } |
| 165 | |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 166 | /** |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 167 | * lpfc_ct_handle_unsol_abort - ct upper level protocol abort handler |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 168 | * @phba: Pointer to HBA context object. |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 169 | * @dmabuf: pointer to a dmabuf that describes the FC sequence |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 170 | * |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 171 | * This function serves as the upper level protocol abort handler for CT |
| 172 | * protocol. |
| 173 | * |
| 174 | * Return 1 if abort has been handled, 0 otherwise. |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 175 | **/ |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 176 | int |
| 177 | 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] | 178 | { |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 179 | int handled; |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 180 | |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 181 | /* CT upper level goes through BSG */ |
| 182 | handled = lpfc_bsg_ct_unsol_abort(phba, dmabuf); |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 183 | |
James Smart | 6dd9e31 | 2013-01-03 15:43:37 -0500 | [diff] [blame] | 184 | return handled; |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame] | 185 | } |
| 186 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 187 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 188 | lpfc_free_ct_rsp(struct lpfc_hba *phba, struct lpfc_dmabuf *mlist) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 189 | { |
| 190 | struct lpfc_dmabuf *mlast, *next_mlast; |
| 191 | |
| 192 | list_for_each_entry_safe(mlast, next_mlast, &mlist->list, list) { |
| 193 | lpfc_mbuf_free(phba, mlast->virt, mlast->phys); |
| 194 | list_del(&mlast->list); |
| 195 | kfree(mlast); |
| 196 | } |
| 197 | lpfc_mbuf_free(phba, mlist->virt, mlist->phys); |
| 198 | kfree(mlist); |
| 199 | return; |
| 200 | } |
| 201 | |
| 202 | static struct lpfc_dmabuf * |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 203 | lpfc_alloc_ct_rsp(struct lpfc_hba *phba, int cmdcode, struct ulp_bde64 *bpl, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 204 | uint32_t size, int *entries) |
| 205 | { |
| 206 | struct lpfc_dmabuf *mlist = NULL; |
| 207 | struct lpfc_dmabuf *mp; |
| 208 | int cnt, i = 0; |
| 209 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 210 | /* We get chunks of FCELSSIZE */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 211 | cnt = size > FCELSSIZE ? FCELSSIZE: size; |
| 212 | |
| 213 | while (size) { |
| 214 | /* Allocate buffer for rsp payload */ |
| 215 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| 216 | if (!mp) { |
| 217 | if (mlist) |
| 218 | lpfc_free_ct_rsp(phba, mlist); |
| 219 | return NULL; |
| 220 | } |
| 221 | |
| 222 | INIT_LIST_HEAD(&mp->list); |
| 223 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 224 | if (cmdcode == be16_to_cpu(SLI_CTNS_GID_FT) || |
| 225 | cmdcode == be16_to_cpu(SLI_CTNS_GFF_ID)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 226 | mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); |
| 227 | else |
| 228 | mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys)); |
| 229 | |
| 230 | if (!mp->virt) { |
| 231 | kfree(mp); |
Eric Sesterhenn | 0b3a82d | 2006-10-10 14:41:43 -0700 | [diff] [blame] | 232 | if (mlist) |
| 233 | lpfc_free_ct_rsp(phba, mlist); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 234 | return NULL; |
| 235 | } |
| 236 | |
| 237 | /* Queue it to a linked list */ |
| 238 | if (!mlist) |
| 239 | mlist = mp; |
| 240 | else |
| 241 | list_add_tail(&mp->list, &mlist->list); |
| 242 | |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 243 | bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64I; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 244 | /* build buffer ptr list for IOCB */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 245 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); |
| 246 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 247 | bpl->tus.f.bdeSize = (uint16_t) cnt; |
| 248 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 249 | bpl++; |
| 250 | |
| 251 | i++; |
| 252 | size -= cnt; |
| 253 | } |
| 254 | |
| 255 | *entries = i; |
| 256 | return mlist; |
| 257 | } |
| 258 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 259 | int |
| 260 | lpfc_ct_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocb) |
| 261 | { |
| 262 | struct lpfc_dmabuf *buf_ptr; |
| 263 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 264 | if (ctiocb->context_un.ndlp) { |
| 265 | lpfc_nlp_put(ctiocb->context_un.ndlp); |
| 266 | ctiocb->context_un.ndlp = NULL; |
| 267 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 268 | if (ctiocb->context1) { |
| 269 | buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1; |
| 270 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 271 | kfree(buf_ptr); |
| 272 | ctiocb->context1 = NULL; |
| 273 | } |
| 274 | if (ctiocb->context2) { |
| 275 | lpfc_free_ct_rsp(phba, (struct lpfc_dmabuf *) ctiocb->context2); |
| 276 | ctiocb->context2 = NULL; |
| 277 | } |
| 278 | |
| 279 | if (ctiocb->context3) { |
| 280 | buf_ptr = (struct lpfc_dmabuf *) ctiocb->context3; |
| 281 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 282 | kfree(buf_ptr); |
Felipe Pena | 1109c94 | 2013-10-15 21:29:50 -0300 | [diff] [blame] | 283 | ctiocb->context3 = NULL; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 284 | } |
| 285 | lpfc_sli_release_iocbq(phba, ctiocb); |
| 286 | return 0; |
| 287 | } |
| 288 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 289 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 290 | lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 291 | struct lpfc_dmabuf *inp, struct lpfc_dmabuf *outp, |
| 292 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 293 | struct lpfc_iocbq *), |
| 294 | struct lpfc_nodelist *ndlp, uint32_t usr_flg, uint32_t num_entry, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 295 | uint32_t tmo, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 296 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 297 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 298 | IOCB_t *icmd; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 299 | struct lpfc_iocbq *geniocb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 300 | int rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 301 | |
| 302 | /* Allocate buffer for command iocb */ |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 303 | geniocb = lpfc_sli_get_iocbq(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 304 | |
| 305 | if (geniocb == NULL) |
| 306 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 307 | |
| 308 | icmd = &geniocb->iocb; |
| 309 | icmd->un.genreq64.bdl.ulpIoTag32 = 0; |
| 310 | icmd->un.genreq64.bdl.addrHigh = putPaddrHigh(bmp->phys); |
| 311 | icmd->un.genreq64.bdl.addrLow = putPaddrLow(bmp->phys); |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 312 | icmd->un.genreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 313 | icmd->un.genreq64.bdl.bdeSize = (num_entry * sizeof (struct ulp_bde64)); |
| 314 | |
| 315 | if (usr_flg) |
| 316 | geniocb->context3 = NULL; |
| 317 | else |
| 318 | geniocb->context3 = (uint8_t *) bmp; |
| 319 | |
| 320 | /* Save for completion so we can release these resources */ |
| 321 | geniocb->context1 = (uint8_t *) inp; |
| 322 | geniocb->context2 = (uint8_t *) outp; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 323 | geniocb->context_un.ndlp = lpfc_nlp_get(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 324 | |
| 325 | /* Fill in payload, bp points to frame payload */ |
| 326 | icmd->ulpCommand = CMD_GEN_REQUEST64_CR; |
| 327 | |
| 328 | /* Fill in rest of iocb */ |
| 329 | icmd->un.genreq64.w5.hcsw.Fctl = (SI | LA); |
| 330 | icmd->un.genreq64.w5.hcsw.Dfctl = 0; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 331 | icmd->un.genreq64.w5.hcsw.Rctl = FC_RCTL_DD_UNSOL_CTL; |
| 332 | icmd->un.genreq64.w5.hcsw.Type = FC_TYPE_CT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 333 | |
Jamie Wellnitz | c9f8735b | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 334 | if (!tmo) { |
| 335 | /* FC spec states we need 3 * ratov for CT requests */ |
| 336 | tmo = (3 * phba->fc_ratov); |
| 337 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 338 | icmd->ulpTimeout = tmo; |
| 339 | icmd->ulpBdeCount = 1; |
| 340 | icmd->ulpLe = 1; |
| 341 | icmd->ulpClass = CLASS3; |
| 342 | icmd->ulpContext = ndlp->nlp_rpi; |
James Smart | 6d368e5 | 2011-05-24 11:44:12 -0400 | [diff] [blame] | 343 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 344 | icmd->ulpContext = phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 345 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 346 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
| 347 | /* For GEN_REQUEST64_CR, use the RPI */ |
| 348 | icmd->ulpCt_h = 0; |
| 349 | icmd->ulpCt_l = 0; |
| 350 | } |
| 351 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 352 | /* Issue GEN REQ IOCB for NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 353 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 354 | "0119 Issue GEN REQ IOCB to NPORT x%x " |
| 355 | "Data: x%x x%x\n", |
| 356 | ndlp->nlp_DID, icmd->ulpIoTag, |
| 357 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 358 | geniocb->iocb_cmpl = cmpl; |
| 359 | geniocb->drvrTimeout = icmd->ulpTimeout + LPFC_DRVR_TIMEOUT; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 360 | geniocb->vport = vport; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 361 | geniocb->retry = retry; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 362 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, geniocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 363 | |
| 364 | if (rc == IOCB_ERROR) { |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 365 | lpfc_sli_release_iocbq(phba, geniocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 366 | return 1; |
| 367 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 368 | |
| 369 | return 0; |
| 370 | } |
| 371 | |
| 372 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 373 | lpfc_ct_cmd(struct lpfc_vport *vport, struct lpfc_dmabuf *inmp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 374 | struct lpfc_dmabuf *bmp, struct lpfc_nodelist *ndlp, |
| 375 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 376 | struct lpfc_iocbq *), |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 377 | uint32_t rsp_size, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 378 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 379 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 380 | struct ulp_bde64 *bpl = (struct ulp_bde64 *) bmp->virt; |
| 381 | struct lpfc_dmabuf *outmp; |
| 382 | int cnt = 0, status; |
| 383 | int cmdcode = ((struct lpfc_sli_ct_request *) inmp->virt)-> |
| 384 | CommandResponse.bits.CmdRsp; |
| 385 | |
| 386 | bpl++; /* Skip past ct request */ |
| 387 | |
| 388 | /* Put buffer(s) for ct rsp in bpl */ |
| 389 | outmp = lpfc_alloc_ct_rsp(phba, cmdcode, bpl, rsp_size, &cnt); |
| 390 | if (!outmp) |
| 391 | return -ENOMEM; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 392 | /* |
| 393 | * Form the CT IOCB. The total number of BDEs in this IOCB |
| 394 | * is the single command plus response count from |
| 395 | * lpfc_alloc_ct_rsp. |
| 396 | */ |
| 397 | cnt += 1; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 398 | status = lpfc_gen_req(vport, bmp, inmp, outmp, cmpl, ndlp, 0, |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 399 | cnt, 0, retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 400 | if (status) { |
| 401 | lpfc_free_ct_rsp(phba, outmp); |
| 402 | return -ENOMEM; |
| 403 | } |
| 404 | return 0; |
| 405 | } |
| 406 | |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 407 | struct lpfc_vport * |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 408 | lpfc_find_vport_by_did(struct lpfc_hba *phba, uint32_t did) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 409 | struct lpfc_vport *vport_curr; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 410 | unsigned long flags; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 411 | |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 412 | spin_lock_irqsave(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 413 | list_for_each_entry(vport_curr, &phba->port_list, listentry) { |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 414 | if ((vport_curr->fc_myDID) && (vport_curr->fc_myDID == did)) { |
| 415 | spin_unlock_irqrestore(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 416 | return vport_curr; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 417 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 418 | } |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 419 | spin_unlock_irqrestore(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 420 | return NULL; |
| 421 | } |
| 422 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 423 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 424 | lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 425 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 426 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 427 | struct lpfc_sli_ct_request *Response = |
| 428 | (struct lpfc_sli_ct_request *) mp->virt; |
| 429 | struct lpfc_nodelist *ndlp = NULL; |
| 430 | struct lpfc_dmabuf *mlast, *next_mp; |
| 431 | uint32_t *ctptr = (uint32_t *) & Response->un.gid.PortType; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 432 | uint32_t Did, CTentry; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 433 | int Cnt; |
| 434 | struct list_head head; |
| 435 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 436 | lpfc_set_disctmo(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 437 | vport->num_disc_nodes = 0; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 438 | vport->fc_ns_retry = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 439 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 440 | |
| 441 | list_add_tail(&head, &mp->list); |
| 442 | list_for_each_entry_safe(mp, next_mp, &head, list) { |
| 443 | mlast = mp; |
| 444 | |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 445 | Cnt = Size > FCELSSIZE ? FCELSSIZE : Size; |
| 446 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 447 | Size -= Cnt; |
| 448 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 449 | if (!ctptr) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 450 | ctptr = (uint32_t *) mlast->virt; |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 451 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 452 | Cnt -= 16; /* subtract length of CT header */ |
| 453 | |
| 454 | /* Loop through entire NameServer list of DIDs */ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 455 | while (Cnt >= sizeof (uint32_t)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 456 | /* Get next DID from NameServer List */ |
| 457 | CTentry = *ctptr++; |
| 458 | Did = ((be32_to_cpu(CTentry)) & Mask_DID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 459 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 460 | ndlp = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 461 | |
| 462 | /* |
| 463 | * Check for rscn processing or not |
| 464 | * To conserve rpi's, filter out addresses for other |
| 465 | * vports on the same physical HBAs. |
| 466 | */ |
| 467 | if ((Did != vport->fc_myDID) && |
| 468 | ((lpfc_find_vport_by_did(phba, Did) == NULL) || |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 469 | vport->cfg_peer_port_login)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 470 | if ((vport->port_type != LPFC_NPIV_PORT) || |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 471 | (!(vport->ct_flags & FC_CT_RFF_ID)) || |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 472 | (!vport->cfg_restrict_login)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 473 | ndlp = lpfc_setup_disc_node(vport, Did); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 474 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 475 | lpfc_debugfs_disc_trc(vport, |
| 476 | LPFC_DISC_TRC_CT, |
| 477 | "Parse GID_FTrsp: " |
| 478 | "did:x%x flg:x%x x%x", |
| 479 | Did, ndlp->nlp_flag, |
| 480 | vport->fc_flag); |
| 481 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 482 | lpfc_printf_vlog(vport, |
| 483 | KERN_INFO, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 484 | LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 485 | "0238 Process " |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 486 | "x%x NameServer Rsp" |
| 487 | "Data: x%x x%x x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 488 | Did, ndlp->nlp_flag, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 489 | vport->fc_flag, |
| 490 | vport->fc_rscn_id_cnt); |
| 491 | } else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 492 | lpfc_debugfs_disc_trc(vport, |
| 493 | LPFC_DISC_TRC_CT, |
| 494 | "Skip1 GID_FTrsp: " |
| 495 | "did:x%x flg:x%x cnt:%d", |
| 496 | Did, vport->fc_flag, |
| 497 | vport->fc_rscn_id_cnt); |
| 498 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 499 | lpfc_printf_vlog(vport, |
| 500 | KERN_INFO, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 501 | LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 502 | "0239 Skip x%x " |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 503 | "NameServer Rsp Data: " |
| 504 | "x%x x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 505 | Did, vport->fc_flag, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 506 | vport->fc_rscn_id_cnt); |
| 507 | } |
| 508 | |
| 509 | } else { |
| 510 | if (!(vport->fc_flag & FC_RSCN_MODE) || |
| 511 | (lpfc_rscn_payload_check(vport, Did))) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 512 | lpfc_debugfs_disc_trc(vport, |
| 513 | LPFC_DISC_TRC_CT, |
| 514 | "Query GID_FTrsp: " |
| 515 | "did:x%x flg:x%x cnt:%d", |
| 516 | Did, vport->fc_flag, |
| 517 | vport->fc_rscn_id_cnt); |
| 518 | |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 519 | /* This NPortID was previously |
| 520 | * a FCP target, * Don't even |
| 521 | * bother to send GFF_ID. |
| 522 | */ |
| 523 | ndlp = lpfc_findnode_did(vport, |
| 524 | Did); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 525 | if (ndlp && |
| 526 | NLP_CHK_NODE_ACT(ndlp) |
| 527 | && (ndlp->nlp_type & |
| 528 | NLP_FCP_TARGET)) |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 529 | lpfc_setup_disc_node |
| 530 | (vport, Did); |
| 531 | else if (lpfc_ns_cmd(vport, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 532 | SLI_CTNS_GFF_ID, |
| 533 | 0, Did) == 0) |
| 534 | vport->num_disc_nodes++; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 535 | else |
| 536 | lpfc_setup_disc_node |
| 537 | (vport, Did); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 538 | } |
| 539 | else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 540 | lpfc_debugfs_disc_trc(vport, |
| 541 | LPFC_DISC_TRC_CT, |
| 542 | "Skip2 GID_FTrsp: " |
| 543 | "did:x%x flg:x%x cnt:%d", |
| 544 | Did, vport->fc_flag, |
| 545 | vport->fc_rscn_id_cnt); |
| 546 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 547 | lpfc_printf_vlog(vport, |
| 548 | KERN_INFO, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 549 | LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 550 | "0245 Skip x%x " |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 551 | "NameServer Rsp Data: " |
| 552 | "x%x x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 553 | Did, vport->fc_flag, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 554 | vport->fc_rscn_id_cnt); |
| 555 | } |
| 556 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 557 | } |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 558 | if (CTentry & (cpu_to_be32(SLI_CT_LAST_ENTRY))) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 559 | goto nsout1; |
| 560 | Cnt -= sizeof (uint32_t); |
| 561 | } |
| 562 | ctptr = NULL; |
| 563 | |
| 564 | } |
| 565 | |
| 566 | nsout1: |
| 567 | list_del(&head); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 568 | return 0; |
| 569 | } |
| 570 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 571 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 572 | lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 573 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 574 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 575 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 576 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 577 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 578 | struct lpfc_dmabuf *bmp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 579 | struct lpfc_dmabuf *outp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 580 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 581 | struct lpfc_nodelist *ndlp; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 582 | int rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 583 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 584 | /* First save ndlp, before we overwrite it */ |
| 585 | ndlp = cmdiocb->context_un.ndlp; |
| 586 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 587 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 588 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 589 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 590 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 591 | bmp = (struct lpfc_dmabuf *) cmdiocb->context3; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 592 | irsp = &rspiocb->iocb; |
| 593 | |
| 594 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 595 | "GID_FT cmpl: status:x%x/x%x rtry:%d", |
| 596 | irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_ns_retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 597 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 598 | /* Don't bother processing response if vport is being torn down. */ |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 599 | if (vport->load_flag & FC_UNLOADING) { |
| 600 | if (vport->fc_flag & FC_RSCN_MODE) |
| 601 | lpfc_els_flush_rscn(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 602 | goto out; |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 603 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 604 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 605 | if (lpfc_els_chk_latt(vport)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 606 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 607 | "0216 Link event during NS query\n"); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 608 | if (vport->fc_flag & FC_RSCN_MODE) |
| 609 | lpfc_els_flush_rscn(vport); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 610 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 611 | goto out; |
| 612 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 613 | if (lpfc_error_lost_link(irsp)) { |
| 614 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 615 | "0226 NS query failed due to link event\n"); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 616 | if (vport->fc_flag & FC_RSCN_MODE) |
| 617 | lpfc_els_flush_rscn(vport); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 618 | goto out; |
| 619 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 620 | if (irsp->ulpStatus) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 621 | /* Check for retry */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 622 | if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 623 | if (irsp->ulpStatus != IOSTAT_LOCAL_REJECT || |
James Smart | edb22f0 | 2012-10-31 14:45:21 -0400 | [diff] [blame] | 624 | (irsp->un.ulpWord[4] & IOERR_PARAM_MASK) != |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 625 | IOERR_NO_RESOURCES) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 626 | vport->fc_ns_retry++; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 627 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 628 | /* CT command is being retried */ |
| 629 | rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 630 | vport->fc_ns_retry, 0); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 631 | if (rc == 0) |
| 632 | goto out; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 633 | } |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 634 | if (vport->fc_flag & FC_RSCN_MODE) |
| 635 | lpfc_els_flush_rscn(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 636 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 637 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 638 | "0257 GID_FT Query error: 0x%x 0x%x\n", |
| 639 | irsp->ulpStatus, vport->fc_ns_retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 640 | } else { |
| 641 | /* Good status, continue checking */ |
| 642 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 643 | if (CTrsp->CommandResponse.bits.CmdRsp == |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 644 | cpu_to_be16(SLI_CT_RESPONSE_FS_ACC)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 645 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 646 | "0208 NameServer Rsp Data: x%x\n", |
| 647 | vport->fc_flag); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 648 | lpfc_ns_rsp(vport, outp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 649 | (uint32_t) (irsp->un.genreq64.bdl.bdeSize)); |
| 650 | } else if (CTrsp->CommandResponse.bits.CmdRsp == |
| 651 | be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { |
| 652 | /* NameServer Rsp Error */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 653 | if ((CTrsp->ReasonCode == SLI_CT_UNABLE_TO_PERFORM_REQ) |
| 654 | && (CTrsp->Explanation == SLI_CT_NO_FC4_TYPES)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 655 | lpfc_printf_vlog(vport, KERN_INFO, |
| 656 | LOG_DISCOVERY, |
| 657 | "0269 No NameServer Entries " |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 658 | "Data: x%x x%x x%x x%x\n", |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 659 | CTrsp->CommandResponse.bits.CmdRsp, |
| 660 | (uint32_t) CTrsp->ReasonCode, |
| 661 | (uint32_t) CTrsp->Explanation, |
| 662 | vport->fc_flag); |
| 663 | |
| 664 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 665 | "GID_FT no entry cmd:x%x rsn:x%x exp:x%x", |
| 666 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 667 | (uint32_t) CTrsp->ReasonCode, |
| 668 | (uint32_t) CTrsp->Explanation); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 669 | } else { |
| 670 | lpfc_printf_vlog(vport, KERN_INFO, |
| 671 | LOG_DISCOVERY, |
| 672 | "0240 NameServer Rsp Error " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 673 | "Data: x%x x%x x%x x%x\n", |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 674 | CTrsp->CommandResponse.bits.CmdRsp, |
| 675 | (uint32_t) CTrsp->ReasonCode, |
| 676 | (uint32_t) CTrsp->Explanation, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 677 | vport->fc_flag); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 678 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 679 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 680 | "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x", |
| 681 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 682 | (uint32_t) CTrsp->ReasonCode, |
| 683 | (uint32_t) CTrsp->Explanation); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 684 | } |
| 685 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 686 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 687 | } else { |
| 688 | /* NameServer Rsp Error */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 689 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 690 | "0241 NameServer Rsp Error " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 691 | "Data: x%x x%x x%x x%x\n", |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 692 | CTrsp->CommandResponse.bits.CmdRsp, |
| 693 | (uint32_t) CTrsp->ReasonCode, |
| 694 | (uint32_t) CTrsp->Explanation, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 695 | vport->fc_flag); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 696 | |
| 697 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 698 | "GID_FT rsp err2 cmd:x%x rsn:x%x exp:x%x", |
| 699 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 700 | (uint32_t) CTrsp->ReasonCode, |
| 701 | (uint32_t) CTrsp->Explanation); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 702 | } |
| 703 | } |
| 704 | /* Link up / RSCN discovery */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 705 | if (vport->num_disc_nodes == 0) { |
| 706 | /* |
| 707 | * The driver has cycled through all Nports in the RSCN payload. |
| 708 | * Complete the handling by cleaning up and marking the |
| 709 | * current driver state. |
| 710 | */ |
| 711 | if (vport->port_state >= LPFC_DISC_AUTH) { |
| 712 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 713 | lpfc_els_flush_rscn(vport); |
| 714 | spin_lock_irq(shost->host_lock); |
| 715 | vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ |
| 716 | spin_unlock_irq(shost->host_lock); |
| 717 | } |
| 718 | else |
| 719 | lpfc_els_flush_rscn(vport); |
| 720 | } |
| 721 | |
| 722 | lpfc_disc_start(vport); |
| 723 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 724 | out: |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 725 | cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 726 | lpfc_ct_free_iocb(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 727 | return; |
| 728 | } |
| 729 | |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 730 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 731 | lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 732 | struct lpfc_iocbq *rspiocb) |
| 733 | { |
| 734 | struct lpfc_vport *vport = cmdiocb->vport; |
| 735 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 736 | IOCB_t *irsp = &rspiocb->iocb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 737 | struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1; |
| 738 | struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 739 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 740 | int did, rc, retry; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 741 | uint8_t fbits; |
| 742 | struct lpfc_nodelist *ndlp; |
| 743 | |
| 744 | did = ((struct lpfc_sli_ct_request *) inp->virt)->un.gff.PortId; |
| 745 | did = be32_to_cpu(did); |
| 746 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 747 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 748 | "GFF_ID cmpl: status:x%x/x%x did:x%x", |
| 749 | irsp->ulpStatus, irsp->un.ulpWord[4], did); |
| 750 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 751 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 752 | /* Good status, continue checking */ |
| 753 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 754 | fbits = CTrsp->un.gff_acc.fbits[FCP_TYPE_FEATURE_OFFSET]; |
| 755 | |
| 756 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 757 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { |
| 758 | if ((fbits & FC4_FEATURE_INIT) && |
| 759 | !(fbits & FC4_FEATURE_TARGET)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 760 | lpfc_printf_vlog(vport, KERN_INFO, |
| 761 | LOG_DISCOVERY, |
| 762 | "0270 Skip x%x GFF " |
| 763 | "NameServer Rsp Data: (init) " |
| 764 | "x%x x%x\n", did, fbits, |
| 765 | vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 766 | goto out; |
| 767 | } |
| 768 | } |
| 769 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 770 | else { |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 771 | /* Check for retry */ |
| 772 | if (cmdiocb->retry < LPFC_MAX_NS_RETRY) { |
| 773 | retry = 1; |
| 774 | if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) { |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 775 | switch ((irsp->un.ulpWord[4] & |
| 776 | IOERR_PARAM_MASK)) { |
| 777 | |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 778 | case IOERR_NO_RESOURCES: |
| 779 | /* We don't increment the retry |
| 780 | * count for this case. |
| 781 | */ |
| 782 | break; |
| 783 | case IOERR_LINK_DOWN: |
| 784 | case IOERR_SLI_ABORTED: |
| 785 | case IOERR_SLI_DOWN: |
| 786 | retry = 0; |
| 787 | break; |
| 788 | default: |
| 789 | cmdiocb->retry++; |
| 790 | } |
| 791 | } |
| 792 | else |
| 793 | cmdiocb->retry++; |
| 794 | |
| 795 | if (retry) { |
| 796 | /* CT command is being retried */ |
| 797 | rc = lpfc_ns_cmd(vport, SLI_CTNS_GFF_ID, |
| 798 | cmdiocb->retry, did); |
| 799 | if (rc == 0) { |
| 800 | /* success */ |
| 801 | lpfc_ct_free_iocb(phba, cmdiocb); |
| 802 | return; |
| 803 | } |
| 804 | } |
| 805 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 806 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 807 | "0267 NameServer GFF Rsp " |
| 808 | "x%x Error (%d %d) Data: x%x x%x\n", |
| 809 | did, irsp->ulpStatus, irsp->un.ulpWord[4], |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 810 | vport->fc_flag, vport->fc_rscn_id_cnt); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 811 | } |
| 812 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 813 | /* This is a target port, unregistered port, or the GFF_ID failed */ |
| 814 | ndlp = lpfc_setup_disc_node(vport, did); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 815 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 816 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 817 | "0242 Process x%x GFF " |
| 818 | "NameServer Rsp Data: x%x x%x x%x\n", |
| 819 | did, ndlp->nlp_flag, vport->fc_flag, |
| 820 | vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 821 | } else { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 822 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 823 | "0243 Skip x%x GFF " |
| 824 | "NameServer Rsp Data: x%x x%x\n", did, |
| 825 | vport->fc_flag, vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 826 | } |
| 827 | out: |
| 828 | /* Link up / RSCN discovery */ |
| 829 | if (vport->num_disc_nodes) |
| 830 | vport->num_disc_nodes--; |
| 831 | if (vport->num_disc_nodes == 0) { |
| 832 | /* |
| 833 | * The driver has cycled through all Nports in the RSCN payload. |
| 834 | * Complete the handling by cleaning up and marking the |
| 835 | * current driver state. |
| 836 | */ |
| 837 | if (vport->port_state >= LPFC_DISC_AUTH) { |
| 838 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 839 | lpfc_els_flush_rscn(vport); |
| 840 | spin_lock_irq(shost->host_lock); |
| 841 | vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ |
| 842 | spin_unlock_irq(shost->host_lock); |
| 843 | } |
| 844 | else |
| 845 | lpfc_els_flush_rscn(vport); |
| 846 | } |
| 847 | lpfc_disc_start(vport); |
| 848 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 849 | lpfc_ct_free_iocb(phba, cmdiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 850 | return; |
| 851 | } |
| 852 | |
| 853 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 854 | static void |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 855 | lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 856 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 857 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 858 | struct lpfc_vport *vport = cmdiocb->vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 859 | struct lpfc_dmabuf *inp; |
| 860 | struct lpfc_dmabuf *outp; |
| 861 | IOCB_t *irsp; |
| 862 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 863 | struct lpfc_nodelist *ndlp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 864 | int cmdcode, rc; |
| 865 | uint8_t retry; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 866 | uint32_t latt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 867 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 868 | /* First save ndlp, before we overwrite it */ |
| 869 | ndlp = cmdiocb->context_un.ndlp; |
| 870 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 871 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 872 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 873 | |
| 874 | inp = (struct lpfc_dmabuf *) cmdiocb->context1; |
| 875 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 876 | irsp = &rspiocb->iocb; |
| 877 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 878 | cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)-> |
| 879 | CommandResponse.bits.CmdRsp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 880 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 881 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 882 | latt = lpfc_els_chk_latt(vport); |
| 883 | |
| 884 | /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 885 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 886 | "0209 CT Request completes, latt %d, " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 887 | "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n", |
| 888 | latt, irsp->ulpStatus, |
| 889 | CTrsp->CommandResponse.bits.CmdRsp, |
| 890 | cmdiocb->iocb.ulpContext, cmdiocb->iocb.ulpIoTag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 891 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 892 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 893 | "CT cmd cmpl: status:x%x/x%x cmd:x%x", |
| 894 | irsp->ulpStatus, irsp->un.ulpWord[4], cmdcode); |
| 895 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 896 | if (irsp->ulpStatus) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 897 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
James Smart | 6e15520 | 2013-07-15 18:35:21 -0400 | [diff] [blame] | 898 | "0268 NS cmd x%x Error (x%x x%x)\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 899 | cmdcode, irsp->ulpStatus, irsp->un.ulpWord[4]); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 900 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 901 | if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && |
James Smart | e3d2b80 | 2012-08-14 14:25:43 -0400 | [diff] [blame] | 902 | (((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) == |
| 903 | IOERR_SLI_DOWN) || |
| 904 | ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) == |
| 905 | IOERR_SLI_ABORTED))) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 906 | goto out; |
| 907 | |
| 908 | retry = cmdiocb->retry; |
| 909 | if (retry >= LPFC_MAX_NS_RETRY) |
| 910 | goto out; |
| 911 | |
| 912 | retry++; |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 913 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 914 | "0250 Retrying NS cmd %x\n", cmdcode); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 915 | rc = lpfc_ns_cmd(vport, cmdcode, retry, 0); |
| 916 | if (rc == 0) |
| 917 | goto out; |
| 918 | } |
| 919 | |
| 920 | out: |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 921 | cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 922 | lpfc_ct_free_iocb(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 923 | return; |
| 924 | } |
| 925 | |
| 926 | static void |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 927 | lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 928 | struct lpfc_iocbq *rspiocb) |
| 929 | { |
| 930 | IOCB_t *irsp = &rspiocb->iocb; |
| 931 | struct lpfc_vport *vport = cmdiocb->vport; |
| 932 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 933 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 934 | struct lpfc_dmabuf *outp; |
| 935 | struct lpfc_sli_ct_request *CTrsp; |
| 936 | |
| 937 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 938 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 939 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 940 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 941 | vport->ct_flags |= FC_CT_RFT_ID; |
| 942 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 943 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| 944 | return; |
| 945 | } |
| 946 | |
| 947 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 948 | lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 949 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 950 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 951 | IOCB_t *irsp = &rspiocb->iocb; |
| 952 | struct lpfc_vport *vport = cmdiocb->vport; |
| 953 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 954 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 955 | struct lpfc_dmabuf *outp; |
| 956 | struct lpfc_sli_ct_request *CTrsp; |
| 957 | |
| 958 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 959 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 960 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 961 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 962 | vport->ct_flags |= FC_CT_RNN_ID; |
| 963 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 964 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 965 | return; |
| 966 | } |
| 967 | |
| 968 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 969 | lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 970 | struct lpfc_iocbq *rspiocb) |
| 971 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 972 | IOCB_t *irsp = &rspiocb->iocb; |
| 973 | struct lpfc_vport *vport = cmdiocb->vport; |
| 974 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 975 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 976 | struct lpfc_dmabuf *outp; |
| 977 | struct lpfc_sli_ct_request *CTrsp; |
| 978 | |
| 979 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 980 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 981 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 982 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 983 | vport->ct_flags |= FC_CT_RSPN_ID; |
| 984 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 985 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 986 | return; |
| 987 | } |
| 988 | |
| 989 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 990 | lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 991 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 992 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 993 | IOCB_t *irsp = &rspiocb->iocb; |
| 994 | struct lpfc_vport *vport = cmdiocb->vport; |
| 995 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 996 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 997 | struct lpfc_dmabuf *outp; |
| 998 | struct lpfc_sli_ct_request *CTrsp; |
| 999 | |
| 1000 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 1001 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 1002 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 1003 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 1004 | vport->ct_flags |= FC_CT_RSNN_NN; |
| 1005 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1006 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| 1007 | return; |
| 1008 | } |
| 1009 | |
| 1010 | static void |
| 1011 | lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1012 | struct lpfc_iocbq *rspiocb) |
| 1013 | { |
| 1014 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1015 | |
| 1016 | /* even if it fails we will act as though it succeeded. */ |
| 1017 | vport->ct_flags = 0; |
| 1018 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1019 | return; |
| 1020 | } |
| 1021 | |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1022 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1023 | lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1024 | struct lpfc_iocbq *rspiocb) |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1025 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1026 | IOCB_t *irsp = &rspiocb->iocb; |
| 1027 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1028 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1029 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 1030 | struct lpfc_dmabuf *outp; |
| 1031 | struct lpfc_sli_ct_request *CTrsp; |
| 1032 | |
| 1033 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 1034 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 1035 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 1036 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 1037 | vport->ct_flags |= FC_CT_RFF_ID; |
| 1038 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1039 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1040 | return; |
| 1041 | } |
| 1042 | |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 1043 | int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1044 | lpfc_vport_symbolic_port_name(struct lpfc_vport *vport, char *symbol, |
| 1045 | size_t size) |
| 1046 | { |
| 1047 | int n; |
| 1048 | uint8_t *wwn = vport->phba->wwpn; |
| 1049 | |
| 1050 | n = snprintf(symbol, size, |
| 1051 | "Emulex PPN-%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", |
| 1052 | wwn[0], wwn[1], wwn[2], wwn[3], |
| 1053 | wwn[4], wwn[5], wwn[6], wwn[7]); |
| 1054 | |
| 1055 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1056 | return n; |
| 1057 | |
| 1058 | if (n < size) |
| 1059 | n += snprintf(symbol + n, size - n, " VPort-%d", vport->vpi); |
| 1060 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 1061 | if (n < size && |
| 1062 | strlen(vport->fc_vport->symbolic_name)) |
| 1063 | n += snprintf(symbol + n, size - n, " VName-%s", |
| 1064 | vport->fc_vport->symbolic_name); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1065 | return n; |
| 1066 | } |
| 1067 | |
| 1068 | int |
| 1069 | lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol, |
| 1070 | size_t size) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1071 | { |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 1072 | char fwrev[FW_REV_STR_SIZE]; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1073 | int n; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1074 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1075 | lpfc_decode_firmware_rev(vport->phba, fwrev, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1076 | |
James Smart | f0bf5f9 | 2015-04-07 15:07:18 -0400 | [diff] [blame] | 1077 | n = snprintf(symbol, size, "Emulex %s", vport->phba->ModelName); |
| 1078 | |
| 1079 | if (size < n) |
| 1080 | return n; |
| 1081 | n += snprintf(symbol + n, size - n, " FV%s", fwrev); |
| 1082 | |
| 1083 | if (size < n) |
| 1084 | return n; |
| 1085 | n += snprintf(symbol + n, size - n, " DV%s", lpfc_release_version); |
| 1086 | |
| 1087 | if (size < n) |
| 1088 | return n; |
| 1089 | n += snprintf(symbol + n, size - n, " HN:%s", init_utsname()->nodename); |
| 1090 | |
| 1091 | /* Note :- OS name is "Linux" */ |
| 1092 | if (size < n) |
| 1093 | return n; |
| 1094 | n += snprintf(symbol + n, size - n, " OS:%s", init_utsname()->sysname); |
| 1095 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1096 | return n; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1097 | } |
| 1098 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1099 | static uint32_t |
| 1100 | lpfc_find_map_node(struct lpfc_vport *vport) |
| 1101 | { |
| 1102 | struct lpfc_nodelist *ndlp, *next_ndlp; |
| 1103 | struct Scsi_Host *shost; |
| 1104 | uint32_t cnt = 0; |
| 1105 | |
| 1106 | shost = lpfc_shost_from_vport(vport); |
| 1107 | spin_lock_irq(shost->host_lock); |
| 1108 | list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { |
| 1109 | if (ndlp->nlp_type & NLP_FABRIC) |
| 1110 | continue; |
| 1111 | if ((ndlp->nlp_state == NLP_STE_MAPPED_NODE) || |
| 1112 | (ndlp->nlp_state == NLP_STE_UNMAPPED_NODE)) |
| 1113 | cnt++; |
| 1114 | } |
| 1115 | spin_unlock_irq(shost->host_lock); |
| 1116 | return cnt; |
| 1117 | } |
| 1118 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1119 | /* |
| 1120 | * lpfc_ns_cmd |
| 1121 | * Description: |
| 1122 | * Issue Cmd to NameServer |
| 1123 | * SLI_CTNS_GID_FT |
| 1124 | * LI_CTNS_RFT_ID |
| 1125 | */ |
| 1126 | int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1127 | lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, |
| 1128 | uint8_t retry, uint32_t context) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1129 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1130 | struct lpfc_nodelist * ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1131 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1132 | struct lpfc_dmabuf *mp, *bmp; |
| 1133 | struct lpfc_sli_ct_request *CtReq; |
| 1134 | struct ulp_bde64 *bpl; |
| 1135 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 1136 | struct lpfc_iocbq *) = NULL; |
| 1137 | uint32_t rsp_size = 1024; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1138 | size_t size; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1139 | int rc = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1140 | |
| 1141 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1142 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) |
| 1143 | || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1144 | rc=1; |
| 1145 | goto ns_cmd_exit; |
| 1146 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1147 | |
| 1148 | /* fill in BDEs for command */ |
| 1149 | /* Allocate buffer for command payload */ |
| 1150 | mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1151 | if (!mp) { |
| 1152 | rc=2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1153 | goto ns_cmd_exit; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1154 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1155 | |
| 1156 | INIT_LIST_HEAD(&mp->list); |
| 1157 | mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1158 | if (!mp->virt) { |
| 1159 | rc=3; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1160 | goto ns_cmd_free_mp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1161 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1162 | |
| 1163 | /* Allocate buffer for Buffer ptr list */ |
| 1164 | bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1165 | if (!bmp) { |
| 1166 | rc=4; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1167 | goto ns_cmd_free_mpvirt; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1168 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1169 | |
| 1170 | INIT_LIST_HEAD(&bmp->list); |
| 1171 | bmp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(bmp->phys)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1172 | if (!bmp->virt) { |
| 1173 | rc=5; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1174 | goto ns_cmd_free_bmp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1175 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1176 | |
| 1177 | /* NameServer Req */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1178 | lpfc_printf_vlog(vport, KERN_INFO ,LOG_DISCOVERY, |
| 1179 | "0236 NameServer Req Data: x%x x%x x%x\n", |
| 1180 | cmdcode, vport->fc_flag, vport->fc_rscn_id_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1181 | |
| 1182 | bpl = (struct ulp_bde64 *) bmp->virt; |
| 1183 | memset(bpl, 0, sizeof(struct ulp_bde64)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1184 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); |
| 1185 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1186 | bpl->tus.f.bdeFlags = 0; |
| 1187 | if (cmdcode == SLI_CTNS_GID_FT) |
| 1188 | bpl->tus.f.bdeSize = GID_REQUEST_SZ; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1189 | else if (cmdcode == SLI_CTNS_GFF_ID) |
| 1190 | bpl->tus.f.bdeSize = GFF_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1191 | else if (cmdcode == SLI_CTNS_RFT_ID) |
| 1192 | bpl->tus.f.bdeSize = RFT_REQUEST_SZ; |
| 1193 | else if (cmdcode == SLI_CTNS_RNN_ID) |
| 1194 | bpl->tus.f.bdeSize = RNN_REQUEST_SZ; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1195 | else if (cmdcode == SLI_CTNS_RSPN_ID) |
| 1196 | bpl->tus.f.bdeSize = RSPN_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1197 | else if (cmdcode == SLI_CTNS_RSNN_NN) |
| 1198 | bpl->tus.f.bdeSize = RSNN_REQUEST_SZ; |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1199 | else if (cmdcode == SLI_CTNS_DA_ID) |
| 1200 | bpl->tus.f.bdeSize = DA_ID_REQUEST_SZ; |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1201 | else if (cmdcode == SLI_CTNS_RFF_ID) |
| 1202 | bpl->tus.f.bdeSize = RFF_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1203 | else |
| 1204 | bpl->tus.f.bdeSize = 0; |
| 1205 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 1206 | |
| 1207 | CtReq = (struct lpfc_sli_ct_request *) mp->virt; |
| 1208 | memset(CtReq, 0, sizeof (struct lpfc_sli_ct_request)); |
| 1209 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; |
| 1210 | CtReq->RevisionId.bits.InId = 0; |
| 1211 | CtReq->FsType = SLI_CT_DIRECTORY_SERVICE; |
| 1212 | CtReq->FsSubType = SLI_CT_DIRECTORY_NAME_SERVER; |
| 1213 | CtReq->CommandResponse.bits.Size = 0; |
| 1214 | switch (cmdcode) { |
| 1215 | case SLI_CTNS_GID_FT: |
| 1216 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1217 | cpu_to_be16(SLI_CTNS_GID_FT); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1218 | CtReq->un.gid.Fc4Type = SLI_CTPT_FCP; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1219 | if (vport->port_state < LPFC_NS_QRY) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1220 | vport->port_state = LPFC_NS_QRY; |
| 1221 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1222 | cmpl = lpfc_cmpl_ct_cmd_gid_ft; |
| 1223 | rsp_size = FC_MAX_NS_RSP; |
| 1224 | break; |
| 1225 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1226 | case SLI_CTNS_GFF_ID: |
| 1227 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1228 | cpu_to_be16(SLI_CTNS_GFF_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1229 | CtReq->un.gff.PortId = cpu_to_be32(context); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1230 | cmpl = lpfc_cmpl_ct_cmd_gff_id; |
| 1231 | break; |
| 1232 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1233 | case SLI_CTNS_RFT_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1234 | vport->ct_flags &= ~FC_CT_RFT_ID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1235 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1236 | cpu_to_be16(SLI_CTNS_RFT_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1237 | CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1238 | CtReq->un.rft.fcpReg = 1; |
| 1239 | cmpl = lpfc_cmpl_ct_cmd_rft_id; |
| 1240 | break; |
| 1241 | |
| 1242 | case SLI_CTNS_RNN_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1243 | vport->ct_flags &= ~FC_CT_RNN_ID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1244 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1245 | cpu_to_be16(SLI_CTNS_RNN_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1246 | CtReq->un.rnn.PortId = cpu_to_be32(vport->fc_myDID); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1247 | memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1248 | sizeof (struct lpfc_name)); |
| 1249 | cmpl = lpfc_cmpl_ct_cmd_rnn_id; |
| 1250 | break; |
| 1251 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1252 | case SLI_CTNS_RSPN_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1253 | vport->ct_flags &= ~FC_CT_RSPN_ID; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1254 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1255 | cpu_to_be16(SLI_CTNS_RSPN_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1256 | CtReq->un.rspn.PortId = cpu_to_be32(vport->fc_myDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1257 | size = sizeof(CtReq->un.rspn.symbname); |
| 1258 | CtReq->un.rspn.len = |
| 1259 | lpfc_vport_symbolic_port_name(vport, |
| 1260 | CtReq->un.rspn.symbname, size); |
| 1261 | cmpl = lpfc_cmpl_ct_cmd_rspn_id; |
| 1262 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1263 | case SLI_CTNS_RSNN_NN: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1264 | vport->ct_flags &= ~FC_CT_RSNN_NN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1265 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1266 | cpu_to_be16(SLI_CTNS_RSNN_NN); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1267 | memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1268 | sizeof (struct lpfc_name)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1269 | size = sizeof(CtReq->un.rsnn.symbname); |
| 1270 | CtReq->un.rsnn.len = |
| 1271 | lpfc_vport_symbolic_node_name(vport, |
| 1272 | CtReq->un.rsnn.symbname, size); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1273 | cmpl = lpfc_cmpl_ct_cmd_rsnn_nn; |
| 1274 | break; |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1275 | case SLI_CTNS_DA_ID: |
| 1276 | /* Implement DA_ID Nameserver request */ |
| 1277 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1278 | cpu_to_be16(SLI_CTNS_DA_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1279 | CtReq->un.da_id.port_id = cpu_to_be32(vport->fc_myDID); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1280 | cmpl = lpfc_cmpl_ct_cmd_da_id; |
| 1281 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1282 | case SLI_CTNS_RFF_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1283 | vport->ct_flags &= ~FC_CT_RFF_ID; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1284 | CtReq->CommandResponse.bits.CmdRsp = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1285 | cpu_to_be16(SLI_CTNS_RFF_ID); |
Joe Perches | a419aef | 2009-08-18 11:18:35 -0700 | [diff] [blame] | 1286 | CtReq->un.rff.PortId = cpu_to_be32(vport->fc_myDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1287 | CtReq->un.rff.fbits = FC4_FEATURE_INIT; |
James Smart | 6a9c52c | 2009-10-02 15:16:51 -0400 | [diff] [blame] | 1288 | CtReq->un.rff.type_code = FC_TYPE_FCP; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1289 | cmpl = lpfc_cmpl_ct_cmd_rff_id; |
| 1290 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1291 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1292 | /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count |
| 1293 | * to hold ndlp reference for the corresponding callback function. |
| 1294 | */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1295 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1296 | /* On success, The cmpl function will free the buffers */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1297 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 1298 | "Issue CT cmd: cmd:x%x did:x%x", |
| 1299 | cmdcode, ndlp->nlp_DID, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1300 | return 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1301 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1302 | rc=6; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1303 | |
| 1304 | /* Decrement ndlp reference count to release ndlp reference held |
| 1305 | * for the failed command's callback function. |
| 1306 | */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1307 | lpfc_nlp_put(ndlp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1308 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1309 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 1310 | ns_cmd_free_bmp: |
| 1311 | kfree(bmp); |
| 1312 | ns_cmd_free_mpvirt: |
| 1313 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 1314 | ns_cmd_free_mp: |
| 1315 | kfree(mp); |
| 1316 | ns_cmd_exit: |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1317 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 1318 | "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n", |
| 1319 | cmdcode, rc, vport->fc_flag, vport->fc_rscn_id_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1320 | return 1; |
| 1321 | } |
| 1322 | |
| 1323 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1324 | lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1325 | struct lpfc_iocbq * rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1326 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1327 | struct lpfc_dmabuf *inp = cmdiocb->context1; |
| 1328 | struct lpfc_dmabuf *outp = cmdiocb->context2; |
| 1329 | struct lpfc_sli_ct_request *CTrsp = outp->virt; |
| 1330 | struct lpfc_sli_ct_request *CTcmd = inp->virt; |
| 1331 | struct lpfc_nodelist *ndlp; |
| 1332 | uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp; |
| 1333 | uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1334 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1335 | IOCB_t *irsp = &rspiocb->iocb; |
| 1336 | uint32_t latt; |
| 1337 | |
| 1338 | latt = lpfc_els_chk_latt(vport); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1339 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 1340 | "FDMI cmpl: status:x%x/x%x latt:%d", |
| 1341 | irsp->ulpStatus, irsp->un.ulpWord[4], latt); |
| 1342 | |
| 1343 | if (latt || irsp->ulpStatus) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1344 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1345 | "0229 FDMI cmd %04x failed, latt = %d " |
| 1346 | "ulpStatus: x%x, rid x%x\n", |
| 1347 | be16_to_cpu(fdmi_cmd), latt, irsp->ulpStatus, |
| 1348 | irsp->un.ulpWord[4]); |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1349 | goto fail_out; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1350 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1351 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1352 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1353 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 1354 | goto fail_out; |
| 1355 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1356 | if (fdmi_rsp == cpu_to_be16(SLI_CT_RESPONSE_FS_RJT)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1357 | /* FDMI rsp failed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1358 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1359 | "0220 FDMI rsp failed Data: x%x\n", |
| 1360 | be16_to_cpu(fdmi_cmd)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1361 | } |
| 1362 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1363 | fail_out: |
| 1364 | lpfc_ct_free_iocb(phba, cmdiocb); |
| 1365 | } |
| 1366 | |
| 1367 | static void |
| 1368 | lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1369 | struct lpfc_iocbq *rspiocb) |
| 1370 | { |
| 1371 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1372 | struct lpfc_dmabuf *inp = cmdiocb->context1; |
| 1373 | struct lpfc_sli_ct_request *CTcmd = inp->virt; |
| 1374 | uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp; |
| 1375 | struct lpfc_nodelist *ndlp; |
| 1376 | |
| 1377 | lpfc_cmpl_ct_cmd_fdmi(phba, cmdiocb, rspiocb); |
| 1378 | |
| 1379 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
| 1380 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 1381 | return; |
| 1382 | |
| 1383 | /* |
| 1384 | * Need to cycle thru FDMI registration for discovery |
| 1385 | * DHBA -> DPRT -> RHBA -> RPA |
| 1386 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1387 | switch (be16_to_cpu(fdmi_cmd)) { |
| 1388 | case SLI_MGMT_RHBA: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1389 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1390 | break; |
| 1391 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1392 | case SLI_MGMT_DHBA: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1393 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1394 | break; |
| 1395 | |
| 1396 | case SLI_MGMT_DPRT: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1397 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1398 | break; |
| 1399 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1400 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1401 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1402 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1403 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1404 | lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1405 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1406 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1407 | struct lpfc_dmabuf *mp, *bmp; |
| 1408 | struct lpfc_sli_ct_request *CtReq; |
| 1409 | struct ulp_bde64 *bpl; |
| 1410 | uint32_t size; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1411 | uint32_t rsp_size; |
| 1412 | struct lpfc_fdmi_reg_hba *rh; |
| 1413 | struct lpfc_fdmi_port_entry *pe; |
| 1414 | struct lpfc_fdmi_reg_portattr *pab = NULL; |
| 1415 | struct lpfc_fdmi_attr_block *ab = NULL; |
| 1416 | struct lpfc_fdmi_attr_entry *ae; |
| 1417 | struct lpfc_fdmi_attr_def *ad; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1418 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 1419 | struct lpfc_iocbq *); |
| 1420 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1421 | if (ndlp == NULL) { |
| 1422 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
| 1423 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 1424 | return 0; |
| 1425 | cmpl = lpfc_cmpl_ct_cmd_fdmi; /* cmd interface */ |
| 1426 | } else { |
| 1427 | cmpl = lpfc_cmpl_ct_disc_fdmi; /* called from discovery */ |
| 1428 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1429 | |
| 1430 | /* fill in BDEs for command */ |
| 1431 | /* Allocate buffer for command payload */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1432 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1433 | if (!mp) |
| 1434 | goto fdmi_cmd_exit; |
| 1435 | |
| 1436 | mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys)); |
| 1437 | if (!mp->virt) |
| 1438 | goto fdmi_cmd_free_mp; |
| 1439 | |
| 1440 | /* Allocate buffer for Buffer ptr list */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1441 | bmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1442 | if (!bmp) |
| 1443 | goto fdmi_cmd_free_mpvirt; |
| 1444 | |
| 1445 | bmp->virt = lpfc_mbuf_alloc(phba, 0, &(bmp->phys)); |
| 1446 | if (!bmp->virt) |
| 1447 | goto fdmi_cmd_free_bmp; |
| 1448 | |
| 1449 | INIT_LIST_HEAD(&mp->list); |
| 1450 | INIT_LIST_HEAD(&bmp->list); |
| 1451 | |
| 1452 | /* FDMI request */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1453 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1454 | "0218 FDMI Request Data: x%x x%x x%x\n", |
| 1455 | vport->fc_flag, vport->port_state, cmdcode); |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1456 | CtReq = (struct lpfc_sli_ct_request *)mp->virt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1457 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1458 | /* First populate the CT_IU preamble */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1459 | memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request)); |
| 1460 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; |
| 1461 | CtReq->RevisionId.bits.InId = 0; |
| 1462 | |
| 1463 | CtReq->FsType = SLI_CT_MANAGEMENT_SERVICE; |
| 1464 | CtReq->FsSubType = SLI_CT_FDMI_Subtypes; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1465 | |
| 1466 | CtReq->CommandResponse.bits.CmdRsp = cpu_to_be16(cmdcode); |
| 1467 | rsp_size = LPFC_BPL_SIZE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1468 | size = 0; |
| 1469 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1470 | /* Next fill in the specific FDMI cmd information */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1471 | switch (cmdcode) { |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1472 | case SLI_MGMT_RHAT: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1473 | case SLI_MGMT_RHBA: |
| 1474 | { |
| 1475 | lpfc_vpd_t *vp = &phba->vpd; |
| 1476 | uint32_t i, j, incr; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1477 | int len = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1478 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1479 | rh = (struct lpfc_fdmi_reg_hba *)&CtReq->un.PortID; |
| 1480 | /* HBA Identifier */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1481 | memcpy(&rh->hi.PortName, &vport->fc_sparam.portName, |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1482 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1483 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1484 | if (cmdcode == SLI_MGMT_RHBA) { |
| 1485 | /* Registered Port List */ |
| 1486 | /* One entry (port) per adapter */ |
| 1487 | rh->rpl.EntryCnt = cpu_to_be32(1); |
| 1488 | memcpy(&rh->rpl.pe, &vport->fc_sparam.portName, |
| 1489 | sizeof(struct lpfc_name)); |
| 1490 | |
| 1491 | /* point to the HBA attribute block */ |
| 1492 | size = 2 * sizeof(struct lpfc_name) + |
| 1493 | FOURBYTES; |
| 1494 | } else { |
| 1495 | size = sizeof(struct lpfc_name); |
| 1496 | } |
| 1497 | ab = (struct lpfc_fdmi_attr_block *) |
| 1498 | ((uint8_t *)rh + size); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1499 | ab->EntryCnt = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1500 | size += FOURBYTES; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1501 | |
| 1502 | /* |
| 1503 | * Point to beginning of first HBA attribute entry |
| 1504 | */ |
| 1505 | /* #1 HBA attribute entry */ |
| 1506 | ad = (struct lpfc_fdmi_attr_def *) |
| 1507 | ((uint8_t *)rh + size); |
| 1508 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1509 | memset(ae, 0, sizeof(struct lpfc_name)); |
| 1510 | ad->AttrType = cpu_to_be16(RHBA_NODENAME); |
| 1511 | ad->AttrLen = cpu_to_be16(FOURBYTES |
| 1512 | + sizeof(struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1513 | memcpy(&ae->un.NodeName, &vport->fc_sparam.nodeName, |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1514 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1515 | ab->EntryCnt++; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1516 | size += FOURBYTES + sizeof(struct lpfc_name); |
| 1517 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1518 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1519 | goto hba_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1520 | |
| 1521 | /* #2 HBA attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1522 | ad = (struct lpfc_fdmi_attr_def *) |
| 1523 | ((uint8_t *)rh + size); |
| 1524 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1525 | memset(ae, 0, sizeof(ae->un.Manufacturer)); |
| 1526 | ad->AttrType = cpu_to_be16(RHBA_MANUFACTURER); |
| 1527 | strncpy(ae->un.Manufacturer, "Emulex Corporation", |
| 1528 | sizeof(ae->un.Manufacturer)); |
| 1529 | len = strnlen(ae->un.Manufacturer, |
| 1530 | sizeof(ae->un.Manufacturer)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1531 | len += (len & 3) ? (4 - (len & 3)) : 4; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1532 | ad->AttrLen = cpu_to_be16(FOURBYTES + len); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1533 | ab->EntryCnt++; |
| 1534 | size += FOURBYTES + len; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1535 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1536 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1537 | goto hba_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1538 | |
| 1539 | /* #3 HBA attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1540 | ad = (struct lpfc_fdmi_attr_def *) |
| 1541 | ((uint8_t *)rh + size); |
| 1542 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1543 | memset(ae, 0, sizeof(ae->un.SerialNumber)); |
| 1544 | ad->AttrType = cpu_to_be16(RHBA_SERIAL_NUMBER); |
| 1545 | strncpy(ae->un.SerialNumber, phba->SerialNumber, |
| 1546 | sizeof(ae->un.SerialNumber)); |
| 1547 | len = strnlen(ae->un.SerialNumber, |
| 1548 | sizeof(ae->un.SerialNumber)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1549 | len += (len & 3) ? (4 - (len & 3)) : 4; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1550 | ad->AttrLen = cpu_to_be16(FOURBYTES + len); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1551 | ab->EntryCnt++; |
| 1552 | size += FOURBYTES + len; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1553 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1554 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1555 | goto hba_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1556 | |
| 1557 | /* #4 HBA attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1558 | ad = (struct lpfc_fdmi_attr_def *) |
| 1559 | ((uint8_t *)rh + size); |
| 1560 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1561 | memset(ae, 0, sizeof(ae->un.Model)); |
| 1562 | ad->AttrType = cpu_to_be16(RHBA_MODEL); |
| 1563 | strncpy(ae->un.Model, phba->ModelName, |
| 1564 | sizeof(ae->un.Model)); |
| 1565 | len = strnlen(ae->un.Model, sizeof(ae->un.Model)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1566 | len += (len & 3) ? (4 - (len & 3)) : 4; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1567 | ad->AttrLen = cpu_to_be16(FOURBYTES + len); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1568 | ab->EntryCnt++; |
| 1569 | size += FOURBYTES + len; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1570 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1571 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1572 | goto hba_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1573 | |
| 1574 | /* #5 HBA attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1575 | ad = (struct lpfc_fdmi_attr_def *) |
| 1576 | ((uint8_t *)rh + size); |
| 1577 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1578 | memset(ae, 0, sizeof(ae->un.ModelDescription)); |
| 1579 | ad->AttrType = cpu_to_be16(RHBA_MODEL_DESCRIPTION); |
| 1580 | strncpy(ae->un.ModelDescription, phba->ModelDesc, |
| 1581 | sizeof(ae->un.ModelDescription)); |
| 1582 | len = strnlen(ae->un.ModelDescription, |
| 1583 | sizeof(ae->un.ModelDescription)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1584 | len += (len & 3) ? (4 - (len & 3)) : 4; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1585 | ad->AttrLen = cpu_to_be16(FOURBYTES + len); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1586 | ab->EntryCnt++; |
| 1587 | size += FOURBYTES + len; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1588 | if ((size + 8) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1589 | goto hba_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1590 | |
| 1591 | /* #6 HBA attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1592 | ad = (struct lpfc_fdmi_attr_def *) |
| 1593 | ((uint8_t *)rh + size); |
| 1594 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1595 | memset(ae, 0, 8); |
| 1596 | ad->AttrType = cpu_to_be16(RHBA_HARDWARE_VERSION); |
| 1597 | ad->AttrLen = cpu_to_be16(FOURBYTES + 8); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1598 | /* Convert JEDEC ID to ascii for hardware version */ |
| 1599 | incr = vp->rev.biuRev; |
| 1600 | for (i = 0; i < 8; i++) { |
| 1601 | j = (incr & 0xf); |
| 1602 | if (j <= 9) |
| 1603 | ae->un.HardwareVersion[7 - i] = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1604 | (char)((uint8_t)0x30 + |
| 1605 | (uint8_t)j); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1606 | else |
| 1607 | ae->un.HardwareVersion[7 - i] = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1608 | (char)((uint8_t)0x61 + |
| 1609 | (uint8_t)(j - 10)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1610 | incr = (incr >> 4); |
| 1611 | } |
| 1612 | ab->EntryCnt++; |
| 1613 | size += FOURBYTES + 8; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1614 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1615 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1616 | goto hba_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1617 | |
| 1618 | /* #7 HBA attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1619 | ad = (struct lpfc_fdmi_attr_def *) |
| 1620 | ((uint8_t *)rh + size); |
| 1621 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1622 | memset(ae, 0, sizeof(ae->un.DriverVersion)); |
| 1623 | ad->AttrType = cpu_to_be16(RHBA_DRIVER_VERSION); |
| 1624 | strncpy(ae->un.DriverVersion, lpfc_release_version, |
| 1625 | sizeof(ae->un.DriverVersion)); |
| 1626 | len = strnlen(ae->un.DriverVersion, |
| 1627 | sizeof(ae->un.DriverVersion)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1628 | len += (len & 3) ? (4 - (len & 3)) : 4; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1629 | ad->AttrLen = cpu_to_be16(FOURBYTES + len); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1630 | ab->EntryCnt++; |
| 1631 | size += FOURBYTES + len; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1632 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1633 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1634 | goto hba_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1635 | |
| 1636 | /* #8 HBA attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1637 | ad = (struct lpfc_fdmi_attr_def *) |
| 1638 | ((uint8_t *)rh + size); |
| 1639 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1640 | memset(ae, 0, sizeof(ae->un.OptionROMVersion)); |
| 1641 | ad->AttrType = cpu_to_be16(RHBA_OPTION_ROM_VERSION); |
| 1642 | strncpy(ae->un.OptionROMVersion, phba->OptionROMVersion, |
| 1643 | sizeof(ae->un.OptionROMVersion)); |
| 1644 | len = strnlen(ae->un.OptionROMVersion, |
| 1645 | sizeof(ae->un.OptionROMVersion)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1646 | len += (len & 3) ? (4 - (len & 3)) : 4; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1647 | ad->AttrLen = cpu_to_be16(FOURBYTES + len); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1648 | ab->EntryCnt++; |
| 1649 | size += FOURBYTES + len; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1650 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1651 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1652 | goto hba_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1653 | |
| 1654 | /* #9 HBA attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1655 | ad = (struct lpfc_fdmi_attr_def *) |
| 1656 | ((uint8_t *)rh + size); |
| 1657 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1658 | memset(ae, 0, sizeof(ae->un.FirmwareVersion)); |
| 1659 | ad->AttrType = cpu_to_be16(RHBA_FIRMWARE_VERSION); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1660 | lpfc_decode_firmware_rev(phba, ae->un.FirmwareVersion, |
| 1661 | 1); |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1662 | len = strnlen(ae->un.FirmwareVersion, |
| 1663 | sizeof(ae->un.FirmwareVersion)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1664 | len += (len & 3) ? (4 - (len & 3)) : 4; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1665 | ad->AttrLen = cpu_to_be16(FOURBYTES + len); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1666 | ab->EntryCnt++; |
| 1667 | size += FOURBYTES + len; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1668 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1669 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1670 | goto hba_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1671 | |
| 1672 | /* #10 HBA attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1673 | ad = (struct lpfc_fdmi_attr_def *) |
| 1674 | ((uint8_t *)rh + size); |
| 1675 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1676 | memset(ae, 0, sizeof(ae->un.OsNameVersion)); |
| 1677 | ad->AttrType = cpu_to_be16(RHBA_OS_NAME_VERSION); |
| 1678 | snprintf(ae->un.OsNameVersion, |
| 1679 | sizeof(ae->un.OsNameVersion), |
| 1680 | "%s %s %s", |
| 1681 | init_utsname()->sysname, |
| 1682 | init_utsname()->release, |
| 1683 | init_utsname()->version); |
| 1684 | len = strnlen(ae->un.OsNameVersion, |
| 1685 | sizeof(ae->un.OsNameVersion)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1686 | len += (len & 3) ? (4 - (len & 3)) : 4; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1687 | ad->AttrLen = cpu_to_be16(FOURBYTES + len); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1688 | ab->EntryCnt++; |
| 1689 | size += FOURBYTES + len; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1690 | if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1691 | goto hba_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1692 | |
| 1693 | /* #11 HBA attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1694 | ad = (struct lpfc_fdmi_attr_def *) |
| 1695 | ((uint8_t *)rh + size); |
| 1696 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1697 | ad->AttrType = |
| 1698 | cpu_to_be16(RHBA_MAX_CT_PAYLOAD_LEN); |
| 1699 | ad->AttrLen = cpu_to_be16(FOURBYTES + 4); |
| 1700 | ae->un.MaxCTPayloadLen = cpu_to_be32(LPFC_MAX_CT_SIZE); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1701 | ab->EntryCnt++; |
| 1702 | size += FOURBYTES + 4; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1703 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1704 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1705 | goto hba_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1706 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1707 | /* |
| 1708 | * Currently switches don't seem to support the |
| 1709 | * following extended HBA attributes. |
| 1710 | */ |
| 1711 | if (!(vport->cfg_fdmi_on & LPFC_FDMI_ALL_ATTRIB)) |
| 1712 | goto hba_out; |
| 1713 | |
| 1714 | /* #12 HBA attribute entry */ |
| 1715 | ad = (struct lpfc_fdmi_attr_def *) |
| 1716 | ((uint8_t *)rh + size); |
| 1717 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1718 | memset(ae, 0, sizeof(ae->un.NodeSymName)); |
| 1719 | ad->AttrType = cpu_to_be16(RHBA_SYM_NODENAME); |
| 1720 | len = lpfc_vport_symbolic_node_name(vport, |
| 1721 | ae->un.NodeSymName, sizeof(ae->un.NodeSymName)); |
| 1722 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1723 | ad->AttrLen = cpu_to_be16(FOURBYTES + len); |
| 1724 | ab->EntryCnt++; |
| 1725 | size += FOURBYTES + len; |
| 1726 | hba_out: |
| 1727 | ab->EntryCnt = cpu_to_be32(ab->EntryCnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1728 | /* Total size */ |
| 1729 | size = GID_REQUEST_SZ - 4 + size; |
| 1730 | } |
| 1731 | break; |
| 1732 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1733 | case SLI_MGMT_RPRT: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1734 | case SLI_MGMT_RPA: |
| 1735 | { |
| 1736 | lpfc_vpd_t *vp; |
| 1737 | struct serv_parm *hsp; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1738 | int len = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1739 | |
| 1740 | vp = &phba->vpd; |
| 1741 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1742 | if (cmdcode == SLI_MGMT_RPRT) { |
| 1743 | rh = (struct lpfc_fdmi_reg_hba *) |
| 1744 | &CtReq->un.PortID; |
| 1745 | /* HBA Identifier */ |
| 1746 | memcpy(&rh->hi.PortName, |
| 1747 | &vport->fc_sparam.portName, |
| 1748 | sizeof(struct lpfc_name)); |
| 1749 | pab = (struct lpfc_fdmi_reg_portattr *) |
| 1750 | &rh->rpl.EntryCnt; |
| 1751 | } else |
| 1752 | pab = (struct lpfc_fdmi_reg_portattr *) |
| 1753 | &CtReq->un.PortID; |
| 1754 | size = sizeof(struct lpfc_name) + FOURBYTES; |
| 1755 | memcpy((uint8_t *)&pab->PortName, |
| 1756 | (uint8_t *)&vport->fc_sparam.portName, |
| 1757 | sizeof(struct lpfc_name)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1758 | pab->ab.EntryCnt = 0; |
| 1759 | |
| 1760 | /* #1 Port attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1761 | ad = (struct lpfc_fdmi_attr_def *) |
| 1762 | ((uint8_t *)pab + size); |
| 1763 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1764 | memset(ae, 0, sizeof(ae->un.FC4Types)); |
| 1765 | ad->AttrType = |
| 1766 | cpu_to_be16(RPRT_SUPPORTED_FC4_TYPES); |
| 1767 | ad->AttrLen = cpu_to_be16(FOURBYTES + 32); |
| 1768 | ae->un.FC4Types[0] = 0x40; /* Type 1 - ELS */ |
| 1769 | ae->un.FC4Types[1] = 0x80; /* Type 8 - FCP */ |
| 1770 | ae->un.FC4Types[4] = 0x80; /* Type 32 - CT */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1771 | pab->ab.EntryCnt++; |
| 1772 | size += FOURBYTES + 32; |
| 1773 | |
| 1774 | /* #2 Port attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1775 | ad = (struct lpfc_fdmi_attr_def *) |
| 1776 | ((uint8_t *)pab + size); |
| 1777 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1778 | ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_SPEED); |
| 1779 | ad->AttrLen = cpu_to_be16(FOURBYTES + 4); |
Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 1780 | ae->un.SupportSpeed = 0; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1781 | if (phba->lmt & LMT_16Gb) |
| 1782 | ae->un.SupportSpeed |= HBA_PORTSPEED_16GBIT; |
Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 1783 | if (phba->lmt & LMT_10Gb) |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1784 | ae->un.SupportSpeed |= HBA_PORTSPEED_10GBIT; |
Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 1785 | if (phba->lmt & LMT_8Gb) |
| 1786 | ae->un.SupportSpeed |= HBA_PORTSPEED_8GBIT; |
| 1787 | if (phba->lmt & LMT_4Gb) |
| 1788 | ae->un.SupportSpeed |= HBA_PORTSPEED_4GBIT; |
| 1789 | if (phba->lmt & LMT_2Gb) |
| 1790 | ae->un.SupportSpeed |= HBA_PORTSPEED_2GBIT; |
| 1791 | if (phba->lmt & LMT_1Gb) |
| 1792 | ae->un.SupportSpeed |= HBA_PORTSPEED_1GBIT; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1793 | ae->un.SupportSpeed = |
| 1794 | cpu_to_be32(ae->un.SupportSpeed); |
Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 1795 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1796 | pab->ab.EntryCnt++; |
| 1797 | size += FOURBYTES + 4; |
| 1798 | |
| 1799 | /* #3 Port attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1800 | ad = (struct lpfc_fdmi_attr_def *) |
| 1801 | ((uint8_t *)pab + size); |
| 1802 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1803 | ad->AttrType = cpu_to_be16(RPRT_PORT_SPEED); |
| 1804 | ad->AttrLen = cpu_to_be16(FOURBYTES + 4); |
| 1805 | switch (phba->fc_linkspeed) { |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1806 | case LPFC_LINK_SPEED_1GHZ: |
| 1807 | ae->un.PortSpeed = HBA_PORTSPEED_1GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1808 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1809 | case LPFC_LINK_SPEED_2GHZ: |
| 1810 | ae->un.PortSpeed = HBA_PORTSPEED_2GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1811 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1812 | case LPFC_LINK_SPEED_4GHZ: |
| 1813 | ae->un.PortSpeed = HBA_PORTSPEED_4GBIT; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1814 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1815 | case LPFC_LINK_SPEED_8GHZ: |
| 1816 | ae->un.PortSpeed = HBA_PORTSPEED_8GBIT; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 1817 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1818 | case LPFC_LINK_SPEED_10GHZ: |
| 1819 | ae->un.PortSpeed = HBA_PORTSPEED_10GBIT; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1820 | break; |
James Smart | 76a95d7 | 2010-11-20 23:11:48 -0500 | [diff] [blame] | 1821 | case LPFC_LINK_SPEED_16GHZ: |
| 1822 | ae->un.PortSpeed = HBA_PORTSPEED_16GBIT; |
| 1823 | break; |
| 1824 | default: |
| 1825 | ae->un.PortSpeed = HBA_PORTSPEED_UNKNOWN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1826 | break; |
| 1827 | } |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1828 | ae->un.PortSpeed = cpu_to_be32(ae->un.PortSpeed); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1829 | pab->ab.EntryCnt++; |
| 1830 | size += FOURBYTES + 4; |
| 1831 | |
| 1832 | /* #4 Port attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1833 | ad = (struct lpfc_fdmi_attr_def *) |
| 1834 | ((uint8_t *)pab + size); |
| 1835 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1836 | ad->AttrType = cpu_to_be16(RPRT_MAX_FRAME_SIZE); |
| 1837 | ad->AttrLen = cpu_to_be16(FOURBYTES + 4); |
| 1838 | hsp = (struct serv_parm *)&vport->fc_sparam; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1839 | ae->un.MaxFrameSize = |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1840 | (((uint32_t)hsp->cmn. |
| 1841 | bbRcvSizeMsb) << 8) | (uint32_t)hsp->cmn. |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1842 | bbRcvSizeLsb; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1843 | ae->un.MaxFrameSize = |
| 1844 | cpu_to_be32(ae->un.MaxFrameSize); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1845 | pab->ab.EntryCnt++; |
| 1846 | size += FOURBYTES + 4; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1847 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1848 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1849 | goto port_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1850 | |
| 1851 | /* #5 Port attribute entry */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1852 | ad = (struct lpfc_fdmi_attr_def *) |
| 1853 | ((uint8_t *)pab + size); |
| 1854 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1855 | memset(ae, 0, sizeof(ae->un.OsDeviceName)); |
| 1856 | ad->AttrType = cpu_to_be16(RPRT_OS_DEVICE_NAME); |
| 1857 | strncpy((char *)ae->un.OsDeviceName, LPFC_DRIVER_NAME, |
| 1858 | sizeof(ae->un.OsDeviceName)); |
| 1859 | len = strnlen((char *)ae->un.OsDeviceName, |
| 1860 | sizeof(ae->un.OsDeviceName)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1861 | len += (len & 3) ? (4 - (len & 3)) : 4; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1862 | ad->AttrLen = cpu_to_be16(FOURBYTES + len); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1863 | pab->ab.EntryCnt++; |
| 1864 | size += FOURBYTES + len; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1865 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1866 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1867 | goto port_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1868 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1869 | /* #6 Port attribute entry */ |
| 1870 | ad = (struct lpfc_fdmi_attr_def *) |
| 1871 | ((uint8_t *)pab + size); |
| 1872 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1873 | memset(ae, 0, sizeof(ae->un.HostName)); |
| 1874 | snprintf(ae->un.HostName, sizeof(ae->un.HostName), "%s", |
| 1875 | init_utsname()->nodename); |
| 1876 | ad->AttrType = cpu_to_be16(RPRT_HOST_NAME); |
| 1877 | len = strnlen(ae->un.HostName, |
| 1878 | sizeof(ae->un.HostName)); |
| 1879 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1880 | ad->AttrLen = |
| 1881 | cpu_to_be16(FOURBYTES + len); |
| 1882 | pab->ab.EntryCnt++; |
| 1883 | size += FOURBYTES + len; |
| 1884 | if ((size + sizeof(struct lpfc_name)) > |
| 1885 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1886 | goto port_out; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1887 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 1888 | /* |
| 1889 | * Currently switches don't seem to support the |
| 1890 | * following extended Port attributes. |
| 1891 | */ |
| 1892 | if (!(vport->cfg_fdmi_on & LPFC_FDMI_ALL_ATTRIB)) |
| 1893 | goto port_out; |
| 1894 | |
| 1895 | /* #7 Port attribute entry */ |
| 1896 | ad = (struct lpfc_fdmi_attr_def *) |
| 1897 | ((uint8_t *)pab + size); |
| 1898 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1899 | memset(ae, 0, sizeof(struct lpfc_name)); |
| 1900 | ad->AttrType = cpu_to_be16(RPRT_NODENAME); |
| 1901 | ad->AttrLen = cpu_to_be16(FOURBYTES |
| 1902 | + sizeof(struct lpfc_name)); |
| 1903 | memcpy(&ae->un.NodeName, &vport->fc_sparam.nodeName, |
| 1904 | sizeof(struct lpfc_name)); |
| 1905 | pab->ab.EntryCnt++; |
| 1906 | size += FOURBYTES + sizeof(struct lpfc_name); |
| 1907 | if ((size + sizeof(struct lpfc_name)) > |
| 1908 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1909 | goto port_out; |
| 1910 | |
| 1911 | /* #8 Port attribute entry */ |
| 1912 | ad = (struct lpfc_fdmi_attr_def *) |
| 1913 | ((uint8_t *)pab + size); |
| 1914 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1915 | memset(ae, 0, sizeof(struct lpfc_name)); |
| 1916 | ad->AttrType = cpu_to_be16(RPRT_PORTNAME); |
| 1917 | ad->AttrLen = cpu_to_be16(FOURBYTES |
| 1918 | + sizeof(struct lpfc_name)); |
| 1919 | memcpy(&ae->un.PortName, &vport->fc_sparam.portName, |
| 1920 | sizeof(struct lpfc_name)); |
| 1921 | pab->ab.EntryCnt++; |
| 1922 | size += FOURBYTES + sizeof(struct lpfc_name); |
| 1923 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1924 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1925 | goto port_out; |
| 1926 | |
| 1927 | /* #9 Port attribute entry */ |
| 1928 | ad = (struct lpfc_fdmi_attr_def *) |
| 1929 | ((uint8_t *)pab + size); |
| 1930 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1931 | memset(ae, 0, sizeof(ae->un.NodeSymName)); |
| 1932 | ad->AttrType = cpu_to_be16(RPRT_SYM_PORTNAME); |
| 1933 | len = lpfc_vport_symbolic_port_name(vport, |
| 1934 | ae->un.NodeSymName, sizeof(ae->un.NodeSymName)); |
| 1935 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1936 | ad->AttrLen = cpu_to_be16(FOURBYTES + len); |
| 1937 | pab->ab.EntryCnt++; |
| 1938 | size += FOURBYTES + len; |
| 1939 | if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1940 | goto port_out; |
| 1941 | |
| 1942 | /* #10 Port attribute entry */ |
| 1943 | ad = (struct lpfc_fdmi_attr_def *) |
| 1944 | ((uint8_t *)pab + size); |
| 1945 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1946 | ad->AttrType = cpu_to_be16(RPRT_PORT_TYPE); |
| 1947 | ae->un.PortState = 0; |
| 1948 | ad->AttrLen = cpu_to_be16(FOURBYTES + 4); |
| 1949 | pab->ab.EntryCnt++; |
| 1950 | size += FOURBYTES + 4; |
| 1951 | if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1952 | goto port_out; |
| 1953 | |
| 1954 | /* #11 Port attribute entry */ |
| 1955 | ad = (struct lpfc_fdmi_attr_def *) |
| 1956 | ((uint8_t *)pab + size); |
| 1957 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1958 | ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_CLASS); |
| 1959 | ae->un.SupportClass = |
| 1960 | cpu_to_be32(FC_COS_CLASS2 | FC_COS_CLASS3); |
| 1961 | ad->AttrLen = cpu_to_be16(FOURBYTES + 4); |
| 1962 | pab->ab.EntryCnt++; |
| 1963 | size += FOURBYTES + 4; |
| 1964 | if ((size + sizeof(struct lpfc_name)) > |
| 1965 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1966 | goto port_out; |
| 1967 | |
| 1968 | /* #12 Port attribute entry */ |
| 1969 | ad = (struct lpfc_fdmi_attr_def *) |
| 1970 | ((uint8_t *)pab + size); |
| 1971 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1972 | memset(ae, 0, sizeof(struct lpfc_name)); |
| 1973 | ad->AttrType = cpu_to_be16(RPRT_FABRICNAME); |
| 1974 | ad->AttrLen = cpu_to_be16(FOURBYTES |
| 1975 | + sizeof(struct lpfc_name)); |
| 1976 | memcpy(&ae->un.FabricName, &vport->fabric_nodename, |
| 1977 | sizeof(struct lpfc_name)); |
| 1978 | pab->ab.EntryCnt++; |
| 1979 | size += FOURBYTES + sizeof(struct lpfc_name); |
| 1980 | if ((size + LPFC_FDMI_MAX_AE_SIZE) > |
| 1981 | (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1982 | goto port_out; |
| 1983 | |
| 1984 | /* #13 Port attribute entry */ |
| 1985 | ad = (struct lpfc_fdmi_attr_def *) |
| 1986 | ((uint8_t *)pab + size); |
| 1987 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 1988 | memset(ae, 0, sizeof(ae->un.FC4Types)); |
| 1989 | ad->AttrType = |
| 1990 | cpu_to_be16(RPRT_ACTIVE_FC4_TYPES); |
| 1991 | ad->AttrLen = cpu_to_be16(FOURBYTES + 32); |
| 1992 | ae->un.FC4Types[0] = 0x40; /* Type 1 - ELS */ |
| 1993 | ae->un.FC4Types[1] = 0x80; /* Type 8 - FCP */ |
| 1994 | ae->un.FC4Types[4] = 0x80; /* Type 32 - CT */ |
| 1995 | pab->ab.EntryCnt++; |
| 1996 | size += FOURBYTES + 32; |
| 1997 | if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 1998 | goto port_out; |
| 1999 | |
| 2000 | /* #257 Port attribute entry */ |
| 2001 | ad = (struct lpfc_fdmi_attr_def *) |
| 2002 | ((uint8_t *)pab + size); |
| 2003 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2004 | ad->AttrType = cpu_to_be16(RPRT_PORT_STATE); |
| 2005 | ae->un.PortState = 0; |
| 2006 | ad->AttrLen = cpu_to_be16(FOURBYTES + 4); |
| 2007 | pab->ab.EntryCnt++; |
| 2008 | size += FOURBYTES + 4; |
| 2009 | if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 2010 | goto port_out; |
| 2011 | |
| 2012 | /* #258 Port attribute entry */ |
| 2013 | ad = (struct lpfc_fdmi_attr_def *) |
| 2014 | ((uint8_t *)pab + size); |
| 2015 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2016 | ad->AttrType = cpu_to_be16(RPRT_DISC_PORT); |
| 2017 | ae->un.PortState = lpfc_find_map_node(vport); |
| 2018 | ae->un.PortState = cpu_to_be32(ae->un.PortState); |
| 2019 | ad->AttrLen = cpu_to_be16(FOURBYTES + 4); |
| 2020 | pab->ab.EntryCnt++; |
| 2021 | size += FOURBYTES + 4; |
| 2022 | if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE)) |
| 2023 | goto port_out; |
| 2024 | |
| 2025 | /* #259 Port attribute entry */ |
| 2026 | ad = (struct lpfc_fdmi_attr_def *) |
| 2027 | ((uint8_t *)pab + size); |
| 2028 | ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue; |
| 2029 | ad->AttrType = cpu_to_be16(RPRT_PORT_ID); |
| 2030 | ae->un.PortId = cpu_to_be32(vport->fc_myDID); |
| 2031 | ad->AttrLen = cpu_to_be16(FOURBYTES + 4); |
| 2032 | pab->ab.EntryCnt++; |
| 2033 | size += FOURBYTES + 4; |
| 2034 | port_out: |
| 2035 | pab->ab.EntryCnt = cpu_to_be32(pab->ab.EntryCnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2036 | /* Total size */ |
| 2037 | size = GID_REQUEST_SZ - 4 + size; |
| 2038 | } |
| 2039 | break; |
| 2040 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2041 | case SLI_MGMT_GHAT: |
| 2042 | case SLI_MGMT_GRPL: |
| 2043 | rsp_size = FC_MAX_NS_RSP; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2044 | case SLI_MGMT_DHBA: |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2045 | case SLI_MGMT_DHAT: |
| 2046 | pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID; |
| 2047 | memcpy((uint8_t *)&pe->PortName, |
| 2048 | (uint8_t *)&vport->fc_sparam.portName, |
| 2049 | sizeof(struct lpfc_name)); |
| 2050 | size = GID_REQUEST_SZ - 4 + sizeof(struct lpfc_name); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2051 | break; |
| 2052 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2053 | case SLI_MGMT_GPAT: |
| 2054 | case SLI_MGMT_GPAS: |
| 2055 | rsp_size = FC_MAX_NS_RSP; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2056 | case SLI_MGMT_DPRT: |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2057 | case SLI_MGMT_DPA: |
| 2058 | pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID; |
| 2059 | memcpy((uint8_t *)&pe->PortName, |
| 2060 | (uint8_t *)&vport->fc_sparam.portName, |
| 2061 | sizeof(struct lpfc_name)); |
| 2062 | size = GID_REQUEST_SZ - 4 + sizeof(struct lpfc_name); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2063 | break; |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2064 | case SLI_MGMT_GRHL: |
| 2065 | size = GID_REQUEST_SZ - 4; |
| 2066 | break; |
| 2067 | default: |
| 2068 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_DISCOVERY, |
| 2069 | "0298 FDMI cmdcode x%x not supported\n", |
| 2070 | cmdcode); |
| 2071 | goto fdmi_cmd_free_bmpvirt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2072 | } |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2073 | CtReq->CommandResponse.bits.Size = cpu_to_be16(rsp_size); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2074 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2075 | bpl = (struct ulp_bde64 *)bmp->virt; |
| 2076 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys)); |
| 2077 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2078 | bpl->tus.f.bdeFlags = 0; |
| 2079 | bpl->tus.f.bdeSize = size; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2080 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2081 | /* |
| 2082 | * The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2083 | * to hold ndlp reference for the corresponding callback function. |
| 2084 | */ |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2085 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, 0)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2086 | return 0; |
| 2087 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2088 | /* |
| 2089 | * Decrement ndlp reference count to release ndlp reference held |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2090 | * for the failed command's callback function. |
| 2091 | */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 2092 | lpfc_nlp_put(ndlp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2093 | |
James Smart | 76b2c34 | 2015-04-07 15:07:19 -0400 | [diff] [blame] | 2094 | fdmi_cmd_free_bmpvirt: |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2095 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 2096 | fdmi_cmd_free_bmp: |
| 2097 | kfree(bmp); |
| 2098 | fdmi_cmd_free_mpvirt: |
| 2099 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 2100 | fdmi_cmd_free_mp: |
| 2101 | kfree(mp); |
| 2102 | fdmi_cmd_exit: |
| 2103 | /* Issue FDMI request failed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 2104 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 2105 | "0244 Issue FDMI request failed Data: x%x\n", |
| 2106 | cmdcode); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2107 | return 1; |
| 2108 | } |
| 2109 | |
James Smart | 9249414 | 2011-02-16 12:39:44 -0500 | [diff] [blame] | 2110 | /** |
| 2111 | * lpfc_delayed_disc_tmo - Timeout handler for delayed discovery timer. |
| 2112 | * @ptr - Context object of the timer. |
| 2113 | * |
| 2114 | * This function set the WORKER_DELAYED_DISC_TMO flag and wake up |
| 2115 | * the worker thread. |
| 2116 | **/ |
| 2117 | void |
| 2118 | lpfc_delayed_disc_tmo(unsigned long ptr) |
| 2119 | { |
| 2120 | struct lpfc_vport *vport = (struct lpfc_vport *)ptr; |
| 2121 | struct lpfc_hba *phba = vport->phba; |
| 2122 | uint32_t tmo_posted; |
| 2123 | unsigned long iflag; |
| 2124 | |
| 2125 | spin_lock_irqsave(&vport->work_port_lock, iflag); |
| 2126 | tmo_posted = vport->work_port_events & WORKER_DELAYED_DISC_TMO; |
| 2127 | if (!tmo_posted) |
| 2128 | vport->work_port_events |= WORKER_DELAYED_DISC_TMO; |
| 2129 | spin_unlock_irqrestore(&vport->work_port_lock, iflag); |
| 2130 | |
| 2131 | if (!tmo_posted) |
| 2132 | lpfc_worker_wake_up(phba); |
| 2133 | return; |
| 2134 | } |
| 2135 | |
| 2136 | /** |
| 2137 | * lpfc_delayed_disc_timeout_handler - Function called by worker thread to |
| 2138 | * handle delayed discovery. |
| 2139 | * @vport: pointer to a host virtual N_Port data structure. |
| 2140 | * |
| 2141 | * This function start nport discovery of the vport. |
| 2142 | **/ |
| 2143 | void |
| 2144 | lpfc_delayed_disc_timeout_handler(struct lpfc_vport *vport) |
| 2145 | { |
| 2146 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 2147 | |
| 2148 | spin_lock_irq(shost->host_lock); |
| 2149 | if (!(vport->fc_flag & FC_DISC_DELAYED)) { |
| 2150 | spin_unlock_irq(shost->host_lock); |
| 2151 | return; |
| 2152 | } |
| 2153 | vport->fc_flag &= ~FC_DISC_DELAYED; |
| 2154 | spin_unlock_irq(shost->host_lock); |
| 2155 | |
| 2156 | lpfc_do_scr_ns_plogi(vport->phba, vport); |
| 2157 | } |
| 2158 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2159 | void |
| 2160 | lpfc_fdmi_tmo(unsigned long ptr) |
| 2161 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2162 | struct lpfc_vport *vport = (struct lpfc_vport *)ptr; |
| 2163 | struct lpfc_hba *phba = vport->phba; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 2164 | uint32_t tmo_posted; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2165 | unsigned long iflag; |
| 2166 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2167 | spin_lock_irqsave(&vport->work_port_lock, iflag); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 2168 | tmo_posted = vport->work_port_events & WORKER_FDMI_TMO; |
| 2169 | if (!tmo_posted) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2170 | vport->work_port_events |= WORKER_FDMI_TMO; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 2171 | spin_unlock_irqrestore(&vport->work_port_lock, iflag); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 2172 | |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 2173 | if (!tmo_posted) |
| 2174 | lpfc_worker_wake_up(phba); |
| 2175 | return; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2176 | } |
| 2177 | |
| 2178 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2179 | lpfc_fdmi_timeout_handler(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2180 | { |
| 2181 | struct lpfc_nodelist *ndlp; |
| 2182 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2183 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 2184 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2185 | if (init_utsname()->nodename[0] != '\0') |
| 2186 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA); |
| 2187 | else |
James Smart | 256ec0d | 2013-04-17 20:14:58 -0400 | [diff] [blame] | 2188 | mod_timer(&vport->fc_fdmitmo, jiffies + |
| 2189 | msecs_to_jiffies(1000 * 60)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2190 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2191 | return; |
| 2192 | } |
| 2193 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2194 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 2195 | lpfc_decode_firmware_rev(struct lpfc_hba *phba, char *fwrevision, int flag) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2196 | { |
| 2197 | struct lpfc_sli *psli = &phba->sli; |
| 2198 | lpfc_vpd_t *vp = &phba->vpd; |
| 2199 | uint32_t b1, b2, b3, b4, i, rev; |
| 2200 | char c; |
| 2201 | uint32_t *ptr, str[4]; |
| 2202 | uint8_t *fwname; |
| 2203 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 2204 | if (phba->sli_rev == LPFC_SLI_REV4) |
James Smart | 6b5151f | 2012-01-18 16:24:06 -0500 | [diff] [blame] | 2205 | snprintf(fwrevision, FW_REV_STR_SIZE, "%s", vp->rev.opFwName); |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 2206 | else if (vp->rev.rBit) { |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2207 | if (psli->sli_flag & LPFC_SLI_ACTIVE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2208 | rev = vp->rev.sli2FwRev; |
| 2209 | else |
| 2210 | rev = vp->rev.sli1FwRev; |
| 2211 | |
| 2212 | b1 = (rev & 0x0000f000) >> 12; |
| 2213 | b2 = (rev & 0x00000f00) >> 8; |
| 2214 | b3 = (rev & 0x000000c0) >> 6; |
| 2215 | b4 = (rev & 0x00000030) >> 4; |
| 2216 | |
| 2217 | switch (b4) { |
| 2218 | case 0: |
| 2219 | c = 'N'; |
| 2220 | break; |
| 2221 | case 1: |
| 2222 | c = 'A'; |
| 2223 | break; |
| 2224 | case 2: |
| 2225 | c = 'B'; |
| 2226 | break; |
James Smart | 73d91e5 | 2011-10-10 21:32:10 -0400 | [diff] [blame] | 2227 | case 3: |
| 2228 | c = 'X'; |
| 2229 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2230 | default: |
| 2231 | c = 0; |
| 2232 | break; |
| 2233 | } |
| 2234 | b4 = (rev & 0x0000000f); |
| 2235 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 2236 | if (psli->sli_flag & LPFC_SLI_ACTIVE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2237 | fwname = vp->rev.sli2FwName; |
| 2238 | else |
| 2239 | fwname = vp->rev.sli1FwName; |
| 2240 | |
| 2241 | for (i = 0; i < 16; i++) |
| 2242 | if (fwname[i] == 0x20) |
| 2243 | fwname[i] = 0; |
| 2244 | |
| 2245 | ptr = (uint32_t*)fwname; |
| 2246 | |
| 2247 | for (i = 0; i < 3; i++) |
| 2248 | str[i] = be32_to_cpu(*ptr++); |
| 2249 | |
| 2250 | if (c == 0) { |
| 2251 | if (flag) |
| 2252 | sprintf(fwrevision, "%d.%d%d (%s)", |
| 2253 | b1, b2, b3, (char *)str); |
| 2254 | else |
| 2255 | sprintf(fwrevision, "%d.%d%d", b1, |
| 2256 | b2, b3); |
| 2257 | } else { |
| 2258 | if (flag) |
| 2259 | sprintf(fwrevision, "%d.%d%d%c%d (%s)", |
| 2260 | b1, b2, b3, c, |
| 2261 | b4, (char *)str); |
| 2262 | else |
| 2263 | sprintf(fwrevision, "%d.%d%d%c%d", |
| 2264 | b1, b2, b3, c, b4); |
| 2265 | } |
| 2266 | } else { |
| 2267 | rev = vp->rev.smFwRev; |
| 2268 | |
| 2269 | b1 = (rev & 0xff000000) >> 24; |
| 2270 | b2 = (rev & 0x00f00000) >> 20; |
| 2271 | b3 = (rev & 0x000f0000) >> 16; |
| 2272 | c = (rev & 0x0000ff00) >> 8; |
| 2273 | b4 = (rev & 0x000000ff); |
| 2274 | |
Roel Kluin | d44a6d2 | 2010-01-17 16:15:57 +0100 | [diff] [blame] | 2275 | sprintf(fwrevision, "%d.%d%d%c%d", b1, b2, b3, c, b4); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 2276 | } |
| 2277 | return; |
| 2278 | } |