| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1 | /******************************************************************* |
| 2 | * This file is part of the Emulex Linux Device Driver for * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 3 | * Fibre Channel Host Bus Adapters. * |
James Smart | d8e93df | 2009-05-22 14:53:05 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2009 Emulex. All rights reserved. * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 5 | * EMULEX and SLI are trademarks of Emulex. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6 | * www.emulex.com * |
| 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> |
| 28 | #include <linux/utsname.h> |
| 29 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 30 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 31 | #include <scsi/scsi_device.h> |
| 32 | #include <scsi/scsi_host.h> |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 33 | #include <scsi/scsi_transport_fc.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 34 | |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 35 | #include "lpfc_hw4.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 36 | #include "lpfc_hw.h" |
| 37 | #include "lpfc_sli.h" |
James Smart | da0436e | 2009-05-22 14:51:39 -0400 | [diff] [blame] | 38 | #include "lpfc_sli4.h" |
James Smart | ea2151b | 2008-09-07 11:52:10 -0400 | [diff] [blame] | 39 | #include "lpfc_nl.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 40 | #include "lpfc_disc.h" |
| 41 | #include "lpfc_scsi.h" |
| 42 | #include "lpfc.h" |
| 43 | #include "lpfc_logmsg.h" |
| 44 | #include "lpfc_crtn.h" |
| 45 | #include "lpfc_version.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 46 | #include "lpfc_vport.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 47 | #include "lpfc_debugfs.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 48 | |
| 49 | #define HBA_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver |
| 50 | * incapable of reporting */ |
| 51 | #define HBA_PORTSPEED_1GBIT 1 /* 1 GBit/sec */ |
| 52 | #define HBA_PORTSPEED_2GBIT 2 /* 2 GBit/sec */ |
| 53 | #define HBA_PORTSPEED_4GBIT 8 /* 4 GBit/sec */ |
| 54 | #define HBA_PORTSPEED_8GBIT 16 /* 8 GBit/sec */ |
| 55 | #define HBA_PORTSPEED_10GBIT 4 /* 10 GBit/sec */ |
| 56 | #define HBA_PORTSPEED_NOT_NEGOTIATED 5 /* Speed not established */ |
| 57 | |
| 58 | #define FOURBYTES 4 |
| 59 | |
| 60 | |
| 61 | static char *lpfc_release_version = LPFC_DRIVER_VERSION; |
| 62 | |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 63 | static void |
| 64 | 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] | 65 | struct lpfc_dmabuf *mp, uint32_t size) |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 66 | { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 67 | if (!mp) { |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 68 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, |
James Smart | 97eab63 | 2008-04-07 10:16:05 -0400 | [diff] [blame] | 69 | "0146 Ignoring unsolicited CT No HBQ " |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 70 | "status = x%x\n", |
| 71 | piocbq->iocb.ulpStatus); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 72 | } |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 73 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, |
| 74 | "0145 Ignoring unsolicted CT HBQ Size:%d " |
| 75 | "status = x%x\n", |
| 76 | size, piocbq->iocb.ulpStatus); |
| 77 | } |
| 78 | |
| 79 | static void |
| 80 | lpfc_ct_unsol_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq, |
| 81 | struct lpfc_dmabuf *mp, uint32_t size) |
| 82 | { |
| 83 | lpfc_ct_ignore_hbq_buffer(phba, piocbq, mp, size); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 84 | } |
| 85 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 86 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 87 | lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, |
| 88 | struct lpfc_iocbq *piocbq) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 89 | { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 90 | struct lpfc_dmabuf *mp = NULL; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 91 | IOCB_t *icmd = &piocbq->iocb; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 92 | int i; |
| 93 | struct lpfc_iocbq *iocbq; |
| 94 | dma_addr_t paddr; |
| 95 | uint32_t size; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 96 | struct list_head head; |
| 97 | struct lpfc_dmabuf *bdeBuf; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 98 | |
James Smart | f1c3b0f | 2009-07-19 10:01:32 -0400 | [diff] [blame] | 99 | lpfc_bsg_ct_unsol_event(phba, pring, piocbq); |
| 100 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 101 | if (unlikely(icmd->ulpStatus == IOSTAT_NEED_BUFFER)) { |
| 102 | lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ); |
| 103 | } else if ((icmd->ulpStatus == IOSTAT_LOCAL_REJECT) && |
| 104 | ((icmd->un.ulpWord[4] & 0xff) == IOERR_RCV_BUFFER_WAITING)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 105 | /* Not enough posted buffers; Try posting more buffers */ |
| 106 | phba->fc_stat.NoRcvBuf++; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 107 | if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)) |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 108 | lpfc_post_buffer(phba, pring, 2); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 109 | return; |
| 110 | } |
| 111 | |
| 112 | /* If there are no BDEs associated with this IOCB, |
| 113 | * there is nothing to do. |
| 114 | */ |
| 115 | if (icmd->ulpBdeCount == 0) |
| 116 | return; |
| 117 | |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 118 | if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 119 | INIT_LIST_HEAD(&head); |
| 120 | list_add_tail(&head, &piocbq->list); |
| 121 | list_for_each_entry(iocbq, &head, list) { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 122 | icmd = &iocbq->iocb; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 123 | if (icmd->ulpBdeCount == 0) |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 124 | continue; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 125 | bdeBuf = iocbq->context2; |
| 126 | iocbq->context2 = NULL; |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 127 | size = icmd->un.cont64[0].tus.f.bdeSize; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 128 | lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, size); |
| 129 | lpfc_in_buf_free(phba, bdeBuf); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 130 | if (icmd->ulpBdeCount == 2) { |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 131 | bdeBuf = iocbq->context3; |
| 132 | iocbq->context3 = NULL; |
| 133 | size = icmd->unsli3.rcvsli3.bde2.tus.f.bdeSize; |
| 134 | lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, |
| 135 | size); |
| 136 | lpfc_in_buf_free(phba, bdeBuf); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 137 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 138 | } |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 139 | list_del(&head); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 140 | } else { |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 141 | INIT_LIST_HEAD(&head); |
| 142 | list_add_tail(&head, &piocbq->list); |
| 143 | list_for_each_entry(iocbq, &head, list) { |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 144 | icmd = &iocbq->iocb; |
James Smart | 9c2face | 2008-01-11 01:53:18 -0500 | [diff] [blame] | 145 | if (icmd->ulpBdeCount == 0) |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 146 | lpfc_ct_unsol_buffer(phba, iocbq, NULL, 0); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 147 | for (i = 0; i < icmd->ulpBdeCount; i++) { |
| 148 | paddr = getPaddr(icmd->un.cont64[i].addrHigh, |
| 149 | icmd->un.cont64[i].addrLow); |
| 150 | mp = lpfc_sli_ringpostbuf_get(phba, pring, |
| 151 | paddr); |
| 152 | size = icmd->un.cont64[i].tus.f.bdeSize; |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 153 | lpfc_ct_unsol_buffer(phba, iocbq, mp, size); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 154 | lpfc_in_buf_free(phba, mp); |
James Smart | ed95768 | 2007-06-17 19:56:37 -0500 | [diff] [blame] | 155 | } |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 156 | lpfc_post_buffer(phba, pring, i); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 157 | } |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 158 | list_del(&head); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 159 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 160 | } |
| 161 | |
James Smart | 6669f9b | 2009-10-02 15:16:45 -0400 | [diff] [blame^] | 162 | /** |
| 163 | * lpfc_sli4_ct_abort_unsol_event - Default handle for sli4 unsol abort |
| 164 | * @phba: Pointer to HBA context object. |
| 165 | * @pring: Pointer to the driver internal I/O ring. |
| 166 | * @piocbq: Pointer to the IOCBQ. |
| 167 | * |
| 168 | * This function serves as the default handler for the sli4 unsolicited |
| 169 | * abort event. It shall be invoked when there is no application interface |
| 170 | * registered unsolicited abort handler. This handler does nothing but |
| 171 | * just simply releases the dma buffer used by the unsol abort event. |
| 172 | **/ |
| 173 | void |
| 174 | lpfc_sli4_ct_abort_unsol_event(struct lpfc_hba *phba, |
| 175 | struct lpfc_sli_ring *pring, |
| 176 | struct lpfc_iocbq *piocbq) |
| 177 | { |
| 178 | IOCB_t *icmd = &piocbq->iocb; |
| 179 | struct lpfc_dmabuf *bdeBuf; |
| 180 | uint32_t size; |
| 181 | |
| 182 | /* Forward abort event to any process registered to receive ct event */ |
| 183 | lpfc_bsg_ct_unsol_event(phba, pring, piocbq); |
| 184 | |
| 185 | /* If there is no BDE associated with IOCB, there is nothing to do */ |
| 186 | if (icmd->ulpBdeCount == 0) |
| 187 | return; |
| 188 | bdeBuf = piocbq->context2; |
| 189 | piocbq->context2 = NULL; |
| 190 | size = icmd->un.cont64[0].tus.f.bdeSize; |
| 191 | lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, size); |
| 192 | lpfc_in_buf_free(phba, bdeBuf); |
| 193 | } |
| 194 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 195 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 196 | lpfc_free_ct_rsp(struct lpfc_hba *phba, struct lpfc_dmabuf *mlist) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 197 | { |
| 198 | struct lpfc_dmabuf *mlast, *next_mlast; |
| 199 | |
| 200 | list_for_each_entry_safe(mlast, next_mlast, &mlist->list, list) { |
| 201 | lpfc_mbuf_free(phba, mlast->virt, mlast->phys); |
| 202 | list_del(&mlast->list); |
| 203 | kfree(mlast); |
| 204 | } |
| 205 | lpfc_mbuf_free(phba, mlist->virt, mlist->phys); |
| 206 | kfree(mlist); |
| 207 | return; |
| 208 | } |
| 209 | |
| 210 | static struct lpfc_dmabuf * |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 211 | lpfc_alloc_ct_rsp(struct lpfc_hba *phba, int cmdcode, struct ulp_bde64 *bpl, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 212 | uint32_t size, int *entries) |
| 213 | { |
| 214 | struct lpfc_dmabuf *mlist = NULL; |
| 215 | struct lpfc_dmabuf *mp; |
| 216 | int cnt, i = 0; |
| 217 | |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 218 | /* We get chunks of FCELSSIZE */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 219 | cnt = size > FCELSSIZE ? FCELSSIZE: size; |
| 220 | |
| 221 | while (size) { |
| 222 | /* Allocate buffer for rsp payload */ |
| 223 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| 224 | if (!mp) { |
| 225 | if (mlist) |
| 226 | lpfc_free_ct_rsp(phba, mlist); |
| 227 | return NULL; |
| 228 | } |
| 229 | |
| 230 | INIT_LIST_HEAD(&mp->list); |
| 231 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 232 | if (cmdcode == be16_to_cpu(SLI_CTNS_GID_FT) || |
| 233 | cmdcode == be16_to_cpu(SLI_CTNS_GFF_ID)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 234 | mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); |
| 235 | else |
| 236 | mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys)); |
| 237 | |
| 238 | if (!mp->virt) { |
| 239 | kfree(mp); |
Eric Sesterhenn | 0b3a82d | 2006-10-10 14:41:43 -0700 | [diff] [blame] | 240 | if (mlist) |
| 241 | lpfc_free_ct_rsp(phba, mlist); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 242 | return NULL; |
| 243 | } |
| 244 | |
| 245 | /* Queue it to a linked list */ |
| 246 | if (!mlist) |
| 247 | mlist = mp; |
| 248 | else |
| 249 | list_add_tail(&mp->list, &mlist->list); |
| 250 | |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 251 | bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64I; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 252 | /* build buffer ptr list for IOCB */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 253 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); |
| 254 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 255 | bpl->tus.f.bdeSize = (uint16_t) cnt; |
| 256 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 257 | bpl++; |
| 258 | |
| 259 | i++; |
| 260 | size -= cnt; |
| 261 | } |
| 262 | |
| 263 | *entries = i; |
| 264 | return mlist; |
| 265 | } |
| 266 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 267 | int |
| 268 | lpfc_ct_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocb) |
| 269 | { |
| 270 | struct lpfc_dmabuf *buf_ptr; |
| 271 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 272 | if (ctiocb->context_un.ndlp) { |
| 273 | lpfc_nlp_put(ctiocb->context_un.ndlp); |
| 274 | ctiocb->context_un.ndlp = NULL; |
| 275 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 276 | if (ctiocb->context1) { |
| 277 | buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1; |
| 278 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 279 | kfree(buf_ptr); |
| 280 | ctiocb->context1 = NULL; |
| 281 | } |
| 282 | if (ctiocb->context2) { |
| 283 | lpfc_free_ct_rsp(phba, (struct lpfc_dmabuf *) ctiocb->context2); |
| 284 | ctiocb->context2 = NULL; |
| 285 | } |
| 286 | |
| 287 | if (ctiocb->context3) { |
| 288 | buf_ptr = (struct lpfc_dmabuf *) ctiocb->context3; |
| 289 | lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); |
| 290 | kfree(buf_ptr); |
| 291 | ctiocb->context1 = NULL; |
| 292 | } |
| 293 | lpfc_sli_release_iocbq(phba, ctiocb); |
| 294 | return 0; |
| 295 | } |
| 296 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 297 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 298 | lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 299 | struct lpfc_dmabuf *inp, struct lpfc_dmabuf *outp, |
| 300 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 301 | struct lpfc_iocbq *), |
| 302 | struct lpfc_nodelist *ndlp, uint32_t usr_flg, uint32_t num_entry, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 303 | uint32_t tmo, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 304 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 305 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 306 | IOCB_t *icmd; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 307 | struct lpfc_iocbq *geniocb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 308 | int rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 309 | |
| 310 | /* Allocate buffer for command iocb */ |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 311 | geniocb = lpfc_sli_get_iocbq(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 312 | |
| 313 | if (geniocb == NULL) |
| 314 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 315 | |
| 316 | icmd = &geniocb->iocb; |
| 317 | icmd->un.genreq64.bdl.ulpIoTag32 = 0; |
| 318 | icmd->un.genreq64.bdl.addrHigh = putPaddrHigh(bmp->phys); |
| 319 | icmd->un.genreq64.bdl.addrLow = putPaddrLow(bmp->phys); |
James Smart | 34b02dc | 2008-08-24 21:49:55 -0400 | [diff] [blame] | 320 | icmd->un.genreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 321 | icmd->un.genreq64.bdl.bdeSize = (num_entry * sizeof (struct ulp_bde64)); |
| 322 | |
| 323 | if (usr_flg) |
| 324 | geniocb->context3 = NULL; |
| 325 | else |
| 326 | geniocb->context3 = (uint8_t *) bmp; |
| 327 | |
| 328 | /* Save for completion so we can release these resources */ |
| 329 | geniocb->context1 = (uint8_t *) inp; |
| 330 | geniocb->context2 = (uint8_t *) outp; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 331 | geniocb->context_un.ndlp = lpfc_nlp_get(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 332 | |
| 333 | /* Fill in payload, bp points to frame payload */ |
| 334 | icmd->ulpCommand = CMD_GEN_REQUEST64_CR; |
| 335 | |
| 336 | /* Fill in rest of iocb */ |
| 337 | icmd->un.genreq64.w5.hcsw.Fctl = (SI | LA); |
| 338 | icmd->un.genreq64.w5.hcsw.Dfctl = 0; |
| 339 | icmd->un.genreq64.w5.hcsw.Rctl = FC_UNSOL_CTL; |
| 340 | icmd->un.genreq64.w5.hcsw.Type = FC_COMMON_TRANSPORT_ULP; |
| 341 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 342 | if (!tmo) { |
| 343 | /* FC spec states we need 3 * ratov for CT requests */ |
| 344 | tmo = (3 * phba->fc_ratov); |
| 345 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 346 | icmd->ulpTimeout = tmo; |
| 347 | icmd->ulpBdeCount = 1; |
| 348 | icmd->ulpLe = 1; |
| 349 | icmd->ulpClass = CLASS3; |
| 350 | icmd->ulpContext = ndlp->nlp_rpi; |
| 351 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 352 | if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { |
| 353 | /* For GEN_REQUEST64_CR, use the RPI */ |
| 354 | icmd->ulpCt_h = 0; |
| 355 | icmd->ulpCt_l = 0; |
| 356 | } |
| 357 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 358 | /* Issue GEN REQ IOCB for NPORT <did> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 359 | lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, |
| 360 | "0119 Issue GEN REQ IOCB to NPORT x%x " |
| 361 | "Data: x%x x%x\n", |
| 362 | ndlp->nlp_DID, icmd->ulpIoTag, |
| 363 | vport->port_state); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 364 | geniocb->iocb_cmpl = cmpl; |
| 365 | geniocb->drvrTimeout = icmd->ulpTimeout + LPFC_DRVR_TIMEOUT; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 366 | geniocb->vport = vport; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 367 | geniocb->retry = retry; |
James Smart | 3772a99 | 2009-05-22 14:50:54 -0400 | [diff] [blame] | 368 | rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, geniocb, 0); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 369 | |
| 370 | if (rc == IOCB_ERROR) { |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 371 | lpfc_sli_release_iocbq(phba, geniocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 372 | return 1; |
| 373 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 374 | |
| 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 379 | lpfc_ct_cmd(struct lpfc_vport *vport, struct lpfc_dmabuf *inmp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 380 | struct lpfc_dmabuf *bmp, struct lpfc_nodelist *ndlp, |
| 381 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 382 | struct lpfc_iocbq *), |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 383 | uint32_t rsp_size, uint8_t retry) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 384 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 385 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 386 | struct ulp_bde64 *bpl = (struct ulp_bde64 *) bmp->virt; |
| 387 | struct lpfc_dmabuf *outmp; |
| 388 | int cnt = 0, status; |
| 389 | int cmdcode = ((struct lpfc_sli_ct_request *) inmp->virt)-> |
| 390 | CommandResponse.bits.CmdRsp; |
| 391 | |
| 392 | bpl++; /* Skip past ct request */ |
| 393 | |
| 394 | /* Put buffer(s) for ct rsp in bpl */ |
| 395 | outmp = lpfc_alloc_ct_rsp(phba, cmdcode, bpl, rsp_size, &cnt); |
| 396 | if (!outmp) |
| 397 | return -ENOMEM; |
| 398 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 399 | status = lpfc_gen_req(vport, bmp, inmp, outmp, cmpl, ndlp, 0, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 400 | cnt+1, 0, retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 401 | if (status) { |
| 402 | lpfc_free_ct_rsp(phba, outmp); |
| 403 | return -ENOMEM; |
| 404 | } |
| 405 | return 0; |
| 406 | } |
| 407 | |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 408 | struct lpfc_vport * |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 409 | lpfc_find_vport_by_did(struct lpfc_hba *phba, uint32_t did) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 410 | struct lpfc_vport *vport_curr; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 411 | unsigned long flags; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 412 | |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 413 | spin_lock_irqsave(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 414 | list_for_each_entry(vport_curr, &phba->port_list, listentry) { |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 415 | if ((vport_curr->fc_myDID) && (vport_curr->fc_myDID == did)) { |
| 416 | spin_unlock_irqrestore(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 417 | return vport_curr; |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 418 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 419 | } |
James Smart | 549e55c | 2007-08-02 11:09:51 -0400 | [diff] [blame] | 420 | spin_unlock_irqrestore(&phba->hbalock, flags); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 421 | return NULL; |
| 422 | } |
| 423 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 424 | static int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 425 | lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 426 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 427 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 428 | struct lpfc_sli_ct_request *Response = |
| 429 | (struct lpfc_sli_ct_request *) mp->virt; |
| 430 | struct lpfc_nodelist *ndlp = NULL; |
| 431 | struct lpfc_dmabuf *mlast, *next_mp; |
| 432 | uint32_t *ctptr = (uint32_t *) & Response->un.gid.PortType; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 433 | uint32_t Did, CTentry; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 434 | int Cnt; |
| 435 | struct list_head head; |
| 436 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 437 | lpfc_set_disctmo(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 438 | vport->num_disc_nodes = 0; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 439 | vport->fc_ns_retry = 0; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 440 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 441 | |
| 442 | list_add_tail(&head, &mp->list); |
| 443 | list_for_each_entry_safe(mp, next_mp, &head, list) { |
| 444 | mlast = mp; |
| 445 | |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 446 | Cnt = Size > FCELSSIZE ? FCELSSIZE : Size; |
| 447 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 448 | Size -= Cnt; |
| 449 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 450 | if (!ctptr) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 451 | ctptr = (uint32_t *) mlast->virt; |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame] | 452 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 453 | Cnt -= 16; /* subtract length of CT header */ |
| 454 | |
| 455 | /* Loop through entire NameServer list of DIDs */ |
James Smart | 7054a60 | 2007-04-25 09:52:34 -0400 | [diff] [blame] | 456 | while (Cnt >= sizeof (uint32_t)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 457 | /* Get next DID from NameServer List */ |
| 458 | CTentry = *ctptr++; |
| 459 | Did = ((be32_to_cpu(CTentry)) & Mask_DID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 460 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 461 | ndlp = NULL; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 462 | |
| 463 | /* |
| 464 | * Check for rscn processing or not |
| 465 | * To conserve rpi's, filter out addresses for other |
| 466 | * vports on the same physical HBAs. |
| 467 | */ |
| 468 | if ((Did != vport->fc_myDID) && |
| 469 | ((lpfc_find_vport_by_did(phba, Did) == NULL) || |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 470 | vport->cfg_peer_port_login)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 471 | if ((vport->port_type != LPFC_NPIV_PORT) || |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 472 | (!(vport->ct_flags & FC_CT_RFF_ID)) || |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 473 | (!vport->cfg_restrict_login)) { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 474 | ndlp = lpfc_setup_disc_node(vport, Did); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 475 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 476 | lpfc_debugfs_disc_trc(vport, |
| 477 | LPFC_DISC_TRC_CT, |
| 478 | "Parse GID_FTrsp: " |
| 479 | "did:x%x flg:x%x x%x", |
| 480 | Did, ndlp->nlp_flag, |
| 481 | vport->fc_flag); |
| 482 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 483 | lpfc_printf_vlog(vport, |
| 484 | KERN_INFO, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 485 | LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 486 | "0238 Process " |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 487 | "x%x NameServer Rsp" |
| 488 | "Data: x%x x%x x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 489 | Did, ndlp->nlp_flag, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 490 | vport->fc_flag, |
| 491 | vport->fc_rscn_id_cnt); |
| 492 | } else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 493 | lpfc_debugfs_disc_trc(vport, |
| 494 | LPFC_DISC_TRC_CT, |
| 495 | "Skip1 GID_FTrsp: " |
| 496 | "did:x%x flg:x%x cnt:%d", |
| 497 | Did, vport->fc_flag, |
| 498 | vport->fc_rscn_id_cnt); |
| 499 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 500 | lpfc_printf_vlog(vport, |
| 501 | KERN_INFO, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 502 | LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 503 | "0239 Skip x%x " |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 504 | "NameServer Rsp Data: " |
| 505 | "x%x x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 506 | Did, vport->fc_flag, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 507 | vport->fc_rscn_id_cnt); |
| 508 | } |
| 509 | |
| 510 | } else { |
| 511 | if (!(vport->fc_flag & FC_RSCN_MODE) || |
| 512 | (lpfc_rscn_payload_check(vport, Did))) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 513 | lpfc_debugfs_disc_trc(vport, |
| 514 | LPFC_DISC_TRC_CT, |
| 515 | "Query GID_FTrsp: " |
| 516 | "did:x%x flg:x%x cnt:%d", |
| 517 | Did, vport->fc_flag, |
| 518 | vport->fc_rscn_id_cnt); |
| 519 | |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 520 | /* This NPortID was previously |
| 521 | * a FCP target, * Don't even |
| 522 | * bother to send GFF_ID. |
| 523 | */ |
| 524 | ndlp = lpfc_findnode_did(vport, |
| 525 | Did); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 526 | if (ndlp && |
| 527 | NLP_CHK_NODE_ACT(ndlp) |
| 528 | && (ndlp->nlp_type & |
| 529 | NLP_FCP_TARGET)) |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 530 | lpfc_setup_disc_node |
| 531 | (vport, Did); |
| 532 | else if (lpfc_ns_cmd(vport, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 533 | SLI_CTNS_GFF_ID, |
| 534 | 0, Did) == 0) |
| 535 | vport->num_disc_nodes++; |
| 536 | } |
| 537 | else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 538 | lpfc_debugfs_disc_trc(vport, |
| 539 | LPFC_DISC_TRC_CT, |
| 540 | "Skip2 GID_FTrsp: " |
| 541 | "did:x%x flg:x%x cnt:%d", |
| 542 | Did, vport->fc_flag, |
| 543 | vport->fc_rscn_id_cnt); |
| 544 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 545 | lpfc_printf_vlog(vport, |
| 546 | KERN_INFO, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 547 | LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 548 | "0245 Skip x%x " |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 549 | "NameServer Rsp Data: " |
| 550 | "x%x x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 551 | Did, vport->fc_flag, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 552 | vport->fc_rscn_id_cnt); |
| 553 | } |
| 554 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 555 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 556 | if (CTentry & (be32_to_cpu(SLI_CT_LAST_ENTRY))) |
| 557 | goto nsout1; |
| 558 | Cnt -= sizeof (uint32_t); |
| 559 | } |
| 560 | ctptr = NULL; |
| 561 | |
| 562 | } |
| 563 | |
| 564 | nsout1: |
| 565 | list_del(&head); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 566 | return 0; |
| 567 | } |
| 568 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 569 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 570 | lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 571 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 572 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 573 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 574 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 575 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 576 | struct lpfc_dmabuf *bmp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 577 | struct lpfc_dmabuf *outp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 578 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 579 | struct lpfc_nodelist *ndlp; |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 580 | int rc; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 581 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 582 | /* First save ndlp, before we overwrite it */ |
| 583 | ndlp = cmdiocb->context_un.ndlp; |
| 584 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 585 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 586 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 587 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 588 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 589 | bmp = (struct lpfc_dmabuf *) cmdiocb->context3; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 590 | irsp = &rspiocb->iocb; |
| 591 | |
| 592 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 593 | "GID_FT cmpl: status:x%x/x%x rtry:%d", |
| 594 | irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_ns_retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 595 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 596 | /* Don't bother processing response if vport is being torn down. */ |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 597 | if (vport->load_flag & FC_UNLOADING) { |
| 598 | if (vport->fc_flag & FC_RSCN_MODE) |
| 599 | lpfc_els_flush_rscn(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 600 | goto out; |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 601 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 602 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 603 | if (lpfc_els_chk_latt(vport)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 604 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 605 | "0216 Link event during NS query\n"); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 606 | if (vport->fc_flag & FC_RSCN_MODE) |
| 607 | lpfc_els_flush_rscn(vport); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 608 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 609 | goto out; |
| 610 | } |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 611 | if (lpfc_error_lost_link(irsp)) { |
| 612 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 613 | "0226 NS query failed due to link event\n"); |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 614 | if (vport->fc_flag & FC_RSCN_MODE) |
| 615 | lpfc_els_flush_rscn(vport); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 616 | goto out; |
| 617 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 618 | if (irsp->ulpStatus) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 619 | /* Check for retry */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 620 | if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) { |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 621 | if (irsp->ulpStatus != IOSTAT_LOCAL_REJECT || |
| 622 | irsp->un.ulpWord[4] != IOERR_NO_RESOURCES) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 623 | vport->fc_ns_retry++; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 624 | |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 625 | /* CT command is being retried */ |
| 626 | rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 627 | vport->fc_ns_retry, 0); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 628 | if (rc == 0) |
| 629 | goto out; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 630 | } |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 631 | if (vport->fc_flag & FC_RSCN_MODE) |
| 632 | lpfc_els_flush_rscn(vport); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 633 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 634 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 635 | "0257 GID_FT Query error: 0x%x 0x%x\n", |
| 636 | irsp->ulpStatus, vport->fc_ns_retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 637 | } else { |
| 638 | /* Good status, continue checking */ |
| 639 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 640 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 641 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 642 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 643 | "0208 NameServer Rsp Data: x%x\n", |
| 644 | vport->fc_flag); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 645 | lpfc_ns_rsp(vport, outp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 646 | (uint32_t) (irsp->un.genreq64.bdl.bdeSize)); |
| 647 | } else if (CTrsp->CommandResponse.bits.CmdRsp == |
| 648 | be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { |
| 649 | /* NameServer Rsp Error */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 650 | if ((CTrsp->ReasonCode == SLI_CT_UNABLE_TO_PERFORM_REQ) |
| 651 | && (CTrsp->Explanation == SLI_CT_NO_FC4_TYPES)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 652 | lpfc_printf_vlog(vport, KERN_INFO, |
| 653 | LOG_DISCOVERY, |
| 654 | "0269 No NameServer Entries " |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 655 | "Data: x%x x%x x%x x%x\n", |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 656 | CTrsp->CommandResponse.bits.CmdRsp, |
| 657 | (uint32_t) CTrsp->ReasonCode, |
| 658 | (uint32_t) CTrsp->Explanation, |
| 659 | vport->fc_flag); |
| 660 | |
| 661 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 662 | "GID_FT no entry cmd:x%x rsn:x%x exp:x%x", |
| 663 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 664 | (uint32_t) CTrsp->ReasonCode, |
| 665 | (uint32_t) CTrsp->Explanation); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 666 | } else { |
| 667 | lpfc_printf_vlog(vport, KERN_INFO, |
| 668 | LOG_DISCOVERY, |
| 669 | "0240 NameServer Rsp Error " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 670 | "Data: x%x x%x x%x x%x\n", |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 671 | CTrsp->CommandResponse.bits.CmdRsp, |
| 672 | (uint32_t) CTrsp->ReasonCode, |
| 673 | (uint32_t) CTrsp->Explanation, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 674 | vport->fc_flag); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 675 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 676 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 677 | "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x", |
| 678 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 679 | (uint32_t) CTrsp->ReasonCode, |
| 680 | (uint32_t) CTrsp->Explanation); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 681 | } |
| 682 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 683 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 684 | } else { |
| 685 | /* NameServer Rsp Error */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 686 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 687 | "0241 NameServer Rsp Error " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 688 | "Data: x%x x%x x%x x%x\n", |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 689 | CTrsp->CommandResponse.bits.CmdRsp, |
| 690 | (uint32_t) CTrsp->ReasonCode, |
| 691 | (uint32_t) CTrsp->Explanation, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 692 | vport->fc_flag); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 693 | |
| 694 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 695 | "GID_FT rsp err2 cmd:x%x rsn:x%x exp:x%x", |
| 696 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 697 | (uint32_t) CTrsp->ReasonCode, |
| 698 | (uint32_t) CTrsp->Explanation); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 699 | } |
| 700 | } |
| 701 | /* Link up / RSCN discovery */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 702 | if (vport->num_disc_nodes == 0) { |
| 703 | /* |
| 704 | * The driver has cycled through all Nports in the RSCN payload. |
| 705 | * Complete the handling by cleaning up and marking the |
| 706 | * current driver state. |
| 707 | */ |
| 708 | if (vport->port_state >= LPFC_DISC_AUTH) { |
| 709 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 710 | lpfc_els_flush_rscn(vport); |
| 711 | spin_lock_irq(shost->host_lock); |
| 712 | vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ |
| 713 | spin_unlock_irq(shost->host_lock); |
| 714 | } |
| 715 | else |
| 716 | lpfc_els_flush_rscn(vport); |
| 717 | } |
| 718 | |
| 719 | lpfc_disc_start(vport); |
| 720 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 721 | out: |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 722 | cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 723 | lpfc_ct_free_iocb(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 724 | return; |
| 725 | } |
| 726 | |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 727 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 728 | lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 729 | struct lpfc_iocbq *rspiocb) |
| 730 | { |
| 731 | struct lpfc_vport *vport = cmdiocb->vport; |
| 732 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 733 | IOCB_t *irsp = &rspiocb->iocb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 734 | struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1; |
| 735 | struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 736 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 737 | int did, rc, retry; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 738 | uint8_t fbits; |
| 739 | struct lpfc_nodelist *ndlp; |
| 740 | |
| 741 | did = ((struct lpfc_sli_ct_request *) inp->virt)->un.gff.PortId; |
| 742 | did = be32_to_cpu(did); |
| 743 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 744 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 745 | "GFF_ID cmpl: status:x%x/x%x did:x%x", |
| 746 | irsp->ulpStatus, irsp->un.ulpWord[4], did); |
| 747 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 748 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 749 | /* Good status, continue checking */ |
| 750 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 751 | fbits = CTrsp->un.gff_acc.fbits[FCP_TYPE_FEATURE_OFFSET]; |
| 752 | |
| 753 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 754 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { |
| 755 | if ((fbits & FC4_FEATURE_INIT) && |
| 756 | !(fbits & FC4_FEATURE_TARGET)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 757 | lpfc_printf_vlog(vport, KERN_INFO, |
| 758 | LOG_DISCOVERY, |
| 759 | "0270 Skip x%x GFF " |
| 760 | "NameServer Rsp Data: (init) " |
| 761 | "x%x x%x\n", did, fbits, |
| 762 | vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 763 | goto out; |
| 764 | } |
| 765 | } |
| 766 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 767 | else { |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 768 | /* Check for retry */ |
| 769 | if (cmdiocb->retry < LPFC_MAX_NS_RETRY) { |
| 770 | retry = 1; |
| 771 | if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) { |
| 772 | switch (irsp->un.ulpWord[4]) { |
| 773 | case IOERR_NO_RESOURCES: |
| 774 | /* We don't increment the retry |
| 775 | * count for this case. |
| 776 | */ |
| 777 | break; |
| 778 | case IOERR_LINK_DOWN: |
| 779 | case IOERR_SLI_ABORTED: |
| 780 | case IOERR_SLI_DOWN: |
| 781 | retry = 0; |
| 782 | break; |
| 783 | default: |
| 784 | cmdiocb->retry++; |
| 785 | } |
| 786 | } |
| 787 | else |
| 788 | cmdiocb->retry++; |
| 789 | |
| 790 | if (retry) { |
| 791 | /* CT command is being retried */ |
| 792 | rc = lpfc_ns_cmd(vport, SLI_CTNS_GFF_ID, |
| 793 | cmdiocb->retry, did); |
| 794 | if (rc == 0) { |
| 795 | /* success */ |
| 796 | lpfc_ct_free_iocb(phba, cmdiocb); |
| 797 | return; |
| 798 | } |
| 799 | } |
| 800 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 801 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 802 | "0267 NameServer GFF Rsp " |
| 803 | "x%x Error (%d %d) Data: x%x x%x\n", |
| 804 | did, irsp->ulpStatus, irsp->un.ulpWord[4], |
James Smart | 7f5f3d0 | 2008-02-08 18:50:14 -0500 | [diff] [blame] | 805 | vport->fc_flag, vport->fc_rscn_id_cnt); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 806 | } |
| 807 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 808 | /* This is a target port, unregistered port, or the GFF_ID failed */ |
| 809 | ndlp = lpfc_setup_disc_node(vport, did); |
James Smart | 58da1ff | 2008-04-07 10:15:56 -0400 | [diff] [blame] | 810 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 811 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 812 | "0242 Process x%x GFF " |
| 813 | "NameServer Rsp Data: x%x x%x x%x\n", |
| 814 | did, ndlp->nlp_flag, vport->fc_flag, |
| 815 | vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 816 | } else { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 817 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 818 | "0243 Skip x%x GFF " |
| 819 | "NameServer Rsp Data: x%x x%x\n", did, |
| 820 | vport->fc_flag, vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 821 | } |
| 822 | out: |
| 823 | /* Link up / RSCN discovery */ |
| 824 | if (vport->num_disc_nodes) |
| 825 | vport->num_disc_nodes--; |
| 826 | if (vport->num_disc_nodes == 0) { |
| 827 | /* |
| 828 | * The driver has cycled through all Nports in the RSCN payload. |
| 829 | * Complete the handling by cleaning up and marking the |
| 830 | * current driver state. |
| 831 | */ |
| 832 | if (vport->port_state >= LPFC_DISC_AUTH) { |
| 833 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 834 | lpfc_els_flush_rscn(vport); |
| 835 | spin_lock_irq(shost->host_lock); |
| 836 | vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ |
| 837 | spin_unlock_irq(shost->host_lock); |
| 838 | } |
| 839 | else |
| 840 | lpfc_els_flush_rscn(vport); |
| 841 | } |
| 842 | lpfc_disc_start(vport); |
| 843 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 844 | lpfc_ct_free_iocb(phba, cmdiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 845 | return; |
| 846 | } |
| 847 | |
| 848 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 849 | static void |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 850 | lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 851 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 852 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 853 | struct lpfc_vport *vport = cmdiocb->vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 854 | struct lpfc_dmabuf *inp; |
| 855 | struct lpfc_dmabuf *outp; |
| 856 | IOCB_t *irsp; |
| 857 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 858 | struct lpfc_nodelist *ndlp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 859 | int cmdcode, rc; |
| 860 | uint8_t retry; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 861 | uint32_t latt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 862 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 863 | /* First save ndlp, before we overwrite it */ |
| 864 | ndlp = cmdiocb->context_un.ndlp; |
| 865 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 866 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 867 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 868 | |
| 869 | inp = (struct lpfc_dmabuf *) cmdiocb->context1; |
| 870 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 871 | irsp = &rspiocb->iocb; |
| 872 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 873 | cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)-> |
| 874 | CommandResponse.bits.CmdRsp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 875 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 876 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 877 | latt = lpfc_els_chk_latt(vport); |
| 878 | |
| 879 | /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 880 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 881 | "0209 CT Request completes, latt %d, " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 882 | "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n", |
| 883 | latt, irsp->ulpStatus, |
| 884 | CTrsp->CommandResponse.bits.CmdRsp, |
| 885 | cmdiocb->iocb.ulpContext, cmdiocb->iocb.ulpIoTag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 886 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 887 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 888 | "CT cmd cmpl: status:x%x/x%x cmd:x%x", |
| 889 | irsp->ulpStatus, irsp->un.ulpWord[4], cmdcode); |
| 890 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 891 | if (irsp->ulpStatus) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 892 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 893 | "0268 NS cmd %x Error (%d %d)\n", |
| 894 | cmdcode, irsp->ulpStatus, irsp->un.ulpWord[4]); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 895 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 896 | if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && |
| 897 | ((irsp->un.ulpWord[4] == IOERR_SLI_DOWN) || |
| 898 | (irsp->un.ulpWord[4] == IOERR_SLI_ABORTED))) |
| 899 | goto out; |
| 900 | |
| 901 | retry = cmdiocb->retry; |
| 902 | if (retry >= LPFC_MAX_NS_RETRY) |
| 903 | goto out; |
| 904 | |
| 905 | retry++; |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 906 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
James Smart | d7c255b | 2008-08-24 21:50:00 -0400 | [diff] [blame] | 907 | "0250 Retrying NS cmd %x\n", cmdcode); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 908 | rc = lpfc_ns_cmd(vport, cmdcode, retry, 0); |
| 909 | if (rc == 0) |
| 910 | goto out; |
| 911 | } |
| 912 | |
| 913 | out: |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 914 | cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 915 | lpfc_ct_free_iocb(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 916 | return; |
| 917 | } |
| 918 | |
| 919 | static void |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 920 | lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 921 | struct lpfc_iocbq *rspiocb) |
| 922 | { |
| 923 | IOCB_t *irsp = &rspiocb->iocb; |
| 924 | struct lpfc_vport *vport = cmdiocb->vport; |
| 925 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 926 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 927 | struct lpfc_dmabuf *outp; |
| 928 | struct lpfc_sli_ct_request *CTrsp; |
| 929 | |
| 930 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 931 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 932 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 933 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 934 | vport->ct_flags |= FC_CT_RFT_ID; |
| 935 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 936 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| 937 | return; |
| 938 | } |
| 939 | |
| 940 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 941 | lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 942 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 943 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 944 | IOCB_t *irsp = &rspiocb->iocb; |
| 945 | struct lpfc_vport *vport = cmdiocb->vport; |
| 946 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 947 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 948 | struct lpfc_dmabuf *outp; |
| 949 | struct lpfc_sli_ct_request *CTrsp; |
| 950 | |
| 951 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 952 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 953 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 954 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 955 | vport->ct_flags |= FC_CT_RNN_ID; |
| 956 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 957 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 958 | return; |
| 959 | } |
| 960 | |
| 961 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 962 | lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 963 | struct lpfc_iocbq *rspiocb) |
| 964 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 965 | IOCB_t *irsp = &rspiocb->iocb; |
| 966 | struct lpfc_vport *vport = cmdiocb->vport; |
| 967 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 968 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 969 | struct lpfc_dmabuf *outp; |
| 970 | struct lpfc_sli_ct_request *CTrsp; |
| 971 | |
| 972 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 973 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 974 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 975 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 976 | vport->ct_flags |= FC_CT_RSPN_ID; |
| 977 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 978 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 979 | return; |
| 980 | } |
| 981 | |
| 982 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 983 | lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 984 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 985 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 986 | IOCB_t *irsp = &rspiocb->iocb; |
| 987 | struct lpfc_vport *vport = cmdiocb->vport; |
| 988 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 989 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 990 | struct lpfc_dmabuf *outp; |
| 991 | struct lpfc_sli_ct_request *CTrsp; |
| 992 | |
| 993 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 994 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 995 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 996 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 997 | vport->ct_flags |= FC_CT_RSNN_NN; |
| 998 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 999 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| 1000 | return; |
| 1001 | } |
| 1002 | |
| 1003 | static void |
| 1004 | lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1005 | struct lpfc_iocbq *rspiocb) |
| 1006 | { |
| 1007 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1008 | |
| 1009 | /* even if it fails we will act as though it succeeded. */ |
| 1010 | vport->ct_flags = 0; |
| 1011 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1012 | return; |
| 1013 | } |
| 1014 | |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1015 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1016 | lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1017 | struct lpfc_iocbq *rspiocb) |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1018 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1019 | IOCB_t *irsp = &rspiocb->iocb; |
| 1020 | struct lpfc_vport *vport = cmdiocb->vport; |
| 1021 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 1022 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 1023 | struct lpfc_dmabuf *outp; |
| 1024 | struct lpfc_sli_ct_request *CTrsp; |
| 1025 | |
| 1026 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 1027 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 1028 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 1029 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 1030 | vport->ct_flags |= FC_CT_RFF_ID; |
| 1031 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1032 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1033 | return; |
| 1034 | } |
| 1035 | |
James Smart | 495a714 | 2008-06-14 22:52:59 -0400 | [diff] [blame] | 1036 | int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1037 | lpfc_vport_symbolic_port_name(struct lpfc_vport *vport, char *symbol, |
| 1038 | size_t size) |
| 1039 | { |
| 1040 | int n; |
| 1041 | uint8_t *wwn = vport->phba->wwpn; |
| 1042 | |
| 1043 | n = snprintf(symbol, size, |
| 1044 | "Emulex PPN-%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", |
| 1045 | wwn[0], wwn[1], wwn[2], wwn[3], |
| 1046 | wwn[4], wwn[5], wwn[6], wwn[7]); |
| 1047 | |
| 1048 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1049 | return n; |
| 1050 | |
| 1051 | if (n < size) |
| 1052 | n += snprintf(symbol + n, size - n, " VPort-%d", vport->vpi); |
| 1053 | |
James Smart | eada272 | 2008-12-04 22:39:13 -0500 | [diff] [blame] | 1054 | if (n < size && |
| 1055 | strlen(vport->fc_vport->symbolic_name)) |
| 1056 | n += snprintf(symbol + n, size - n, " VName-%s", |
| 1057 | vport->fc_vport->symbolic_name); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1058 | return n; |
| 1059 | } |
| 1060 | |
| 1061 | int |
| 1062 | lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol, |
| 1063 | size_t size) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1064 | { |
| 1065 | char fwrev[16]; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1066 | int n; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1067 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1068 | lpfc_decode_firmware_rev(vport->phba, fwrev, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1069 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1070 | n = snprintf(symbol, size, "Emulex %s FV%s DV%s", |
| 1071 | vport->phba->ModelName, fwrev, lpfc_release_version); |
| 1072 | return n; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1073 | } |
| 1074 | |
| 1075 | /* |
| 1076 | * lpfc_ns_cmd |
| 1077 | * Description: |
| 1078 | * Issue Cmd to NameServer |
| 1079 | * SLI_CTNS_GID_FT |
| 1080 | * LI_CTNS_RFT_ID |
| 1081 | */ |
| 1082 | int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1083 | lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, |
| 1084 | uint8_t retry, uint32_t context) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1085 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1086 | struct lpfc_nodelist * ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1087 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1088 | struct lpfc_dmabuf *mp, *bmp; |
| 1089 | struct lpfc_sli_ct_request *CtReq; |
| 1090 | struct ulp_bde64 *bpl; |
| 1091 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 1092 | struct lpfc_iocbq *) = NULL; |
| 1093 | uint32_t rsp_size = 1024; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1094 | size_t size; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1095 | int rc = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1096 | |
| 1097 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1098 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) |
| 1099 | || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1100 | rc=1; |
| 1101 | goto ns_cmd_exit; |
| 1102 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1103 | |
| 1104 | /* fill in BDEs for command */ |
| 1105 | /* Allocate buffer for command payload */ |
| 1106 | mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1107 | if (!mp) { |
| 1108 | rc=2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1109 | goto ns_cmd_exit; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1110 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1111 | |
| 1112 | INIT_LIST_HEAD(&mp->list); |
| 1113 | mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1114 | if (!mp->virt) { |
| 1115 | rc=3; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1116 | goto ns_cmd_free_mp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1117 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1118 | |
| 1119 | /* Allocate buffer for Buffer ptr list */ |
| 1120 | bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1121 | if (!bmp) { |
| 1122 | rc=4; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1123 | goto ns_cmd_free_mpvirt; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1124 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1125 | |
| 1126 | INIT_LIST_HEAD(&bmp->list); |
| 1127 | bmp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(bmp->phys)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1128 | if (!bmp->virt) { |
| 1129 | rc=5; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1130 | goto ns_cmd_free_bmp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1131 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1132 | |
| 1133 | /* NameServer Req */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1134 | lpfc_printf_vlog(vport, KERN_INFO ,LOG_DISCOVERY, |
| 1135 | "0236 NameServer Req Data: x%x x%x x%x\n", |
| 1136 | cmdcode, vport->fc_flag, vport->fc_rscn_id_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1137 | |
| 1138 | bpl = (struct ulp_bde64 *) bmp->virt; |
| 1139 | memset(bpl, 0, sizeof(struct ulp_bde64)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1140 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); |
| 1141 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1142 | bpl->tus.f.bdeFlags = 0; |
| 1143 | if (cmdcode == SLI_CTNS_GID_FT) |
| 1144 | bpl->tus.f.bdeSize = GID_REQUEST_SZ; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1145 | else if (cmdcode == SLI_CTNS_GFF_ID) |
| 1146 | bpl->tus.f.bdeSize = GFF_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1147 | else if (cmdcode == SLI_CTNS_RFT_ID) |
| 1148 | bpl->tus.f.bdeSize = RFT_REQUEST_SZ; |
| 1149 | else if (cmdcode == SLI_CTNS_RNN_ID) |
| 1150 | bpl->tus.f.bdeSize = RNN_REQUEST_SZ; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1151 | else if (cmdcode == SLI_CTNS_RSPN_ID) |
| 1152 | bpl->tus.f.bdeSize = RSPN_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1153 | else if (cmdcode == SLI_CTNS_RSNN_NN) |
| 1154 | bpl->tus.f.bdeSize = RSNN_REQUEST_SZ; |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1155 | else if (cmdcode == SLI_CTNS_DA_ID) |
| 1156 | bpl->tus.f.bdeSize = DA_ID_REQUEST_SZ; |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1157 | else if (cmdcode == SLI_CTNS_RFF_ID) |
| 1158 | bpl->tus.f.bdeSize = RFF_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1159 | else |
| 1160 | bpl->tus.f.bdeSize = 0; |
| 1161 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 1162 | |
| 1163 | CtReq = (struct lpfc_sli_ct_request *) mp->virt; |
| 1164 | memset(CtReq, 0, sizeof (struct lpfc_sli_ct_request)); |
| 1165 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; |
| 1166 | CtReq->RevisionId.bits.InId = 0; |
| 1167 | CtReq->FsType = SLI_CT_DIRECTORY_SERVICE; |
| 1168 | CtReq->FsSubType = SLI_CT_DIRECTORY_NAME_SERVER; |
| 1169 | CtReq->CommandResponse.bits.Size = 0; |
| 1170 | switch (cmdcode) { |
| 1171 | case SLI_CTNS_GID_FT: |
| 1172 | CtReq->CommandResponse.bits.CmdRsp = |
| 1173 | be16_to_cpu(SLI_CTNS_GID_FT); |
| 1174 | CtReq->un.gid.Fc4Type = SLI_CTPT_FCP; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1175 | if (vport->port_state < LPFC_NS_QRY) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1176 | vport->port_state = LPFC_NS_QRY; |
| 1177 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1178 | cmpl = lpfc_cmpl_ct_cmd_gid_ft; |
| 1179 | rsp_size = FC_MAX_NS_RSP; |
| 1180 | break; |
| 1181 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1182 | case SLI_CTNS_GFF_ID: |
| 1183 | CtReq->CommandResponse.bits.CmdRsp = |
| 1184 | be16_to_cpu(SLI_CTNS_GFF_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1185 | CtReq->un.gff.PortId = cpu_to_be32(context); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1186 | cmpl = lpfc_cmpl_ct_cmd_gff_id; |
| 1187 | break; |
| 1188 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1189 | case SLI_CTNS_RFT_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1190 | vport->ct_flags &= ~FC_CT_RFT_ID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1191 | CtReq->CommandResponse.bits.CmdRsp = |
| 1192 | be16_to_cpu(SLI_CTNS_RFT_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1193 | CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1194 | CtReq->un.rft.fcpReg = 1; |
| 1195 | cmpl = lpfc_cmpl_ct_cmd_rft_id; |
| 1196 | break; |
| 1197 | |
| 1198 | case SLI_CTNS_RNN_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1199 | vport->ct_flags &= ~FC_CT_RNN_ID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1200 | CtReq->CommandResponse.bits.CmdRsp = |
| 1201 | be16_to_cpu(SLI_CTNS_RNN_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1202 | CtReq->un.rnn.PortId = cpu_to_be32(vport->fc_myDID); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1203 | memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1204 | sizeof (struct lpfc_name)); |
| 1205 | cmpl = lpfc_cmpl_ct_cmd_rnn_id; |
| 1206 | break; |
| 1207 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1208 | case SLI_CTNS_RSPN_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1209 | vport->ct_flags &= ~FC_CT_RSPN_ID; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1210 | CtReq->CommandResponse.bits.CmdRsp = |
| 1211 | be16_to_cpu(SLI_CTNS_RSPN_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1212 | CtReq->un.rspn.PortId = cpu_to_be32(vport->fc_myDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1213 | size = sizeof(CtReq->un.rspn.symbname); |
| 1214 | CtReq->un.rspn.len = |
| 1215 | lpfc_vport_symbolic_port_name(vport, |
| 1216 | CtReq->un.rspn.symbname, size); |
| 1217 | cmpl = lpfc_cmpl_ct_cmd_rspn_id; |
| 1218 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1219 | case SLI_CTNS_RSNN_NN: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1220 | vport->ct_flags &= ~FC_CT_RSNN_NN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1221 | CtReq->CommandResponse.bits.CmdRsp = |
| 1222 | be16_to_cpu(SLI_CTNS_RSNN_NN); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1223 | memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1224 | sizeof (struct lpfc_name)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1225 | size = sizeof(CtReq->un.rsnn.symbname); |
| 1226 | CtReq->un.rsnn.len = |
| 1227 | lpfc_vport_symbolic_node_name(vport, |
| 1228 | CtReq->un.rsnn.symbname, size); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1229 | cmpl = lpfc_cmpl_ct_cmd_rsnn_nn; |
| 1230 | break; |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1231 | case SLI_CTNS_DA_ID: |
| 1232 | /* Implement DA_ID Nameserver request */ |
| 1233 | CtReq->CommandResponse.bits.CmdRsp = |
| 1234 | be16_to_cpu(SLI_CTNS_DA_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1235 | CtReq->un.da_id.port_id = cpu_to_be32(vport->fc_myDID); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1236 | cmpl = lpfc_cmpl_ct_cmd_da_id; |
| 1237 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1238 | case SLI_CTNS_RFF_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1239 | vport->ct_flags &= ~FC_CT_RFF_ID; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1240 | CtReq->CommandResponse.bits.CmdRsp = |
| 1241 | be16_to_cpu(SLI_CTNS_RFF_ID); |
Joe Perches | a419aef | 2009-08-18 11:18:35 -0700 | [diff] [blame] | 1242 | CtReq->un.rff.PortId = cpu_to_be32(vport->fc_myDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1243 | CtReq->un.rff.fbits = FC4_FEATURE_INIT; |
| 1244 | CtReq->un.rff.type_code = FC_FCP_DATA; |
| 1245 | cmpl = lpfc_cmpl_ct_cmd_rff_id; |
| 1246 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1247 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1248 | /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count |
| 1249 | * to hold ndlp reference for the corresponding callback function. |
| 1250 | */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1251 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1252 | /* On success, The cmpl function will free the buffers */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1253 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 1254 | "Issue CT cmd: cmd:x%x did:x%x", |
| 1255 | cmdcode, ndlp->nlp_DID, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1256 | return 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1257 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1258 | rc=6; |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1259 | |
| 1260 | /* Decrement ndlp reference count to release ndlp reference held |
| 1261 | * for the failed command's callback function. |
| 1262 | */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1263 | lpfc_nlp_put(ndlp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1264 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1265 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 1266 | ns_cmd_free_bmp: |
| 1267 | kfree(bmp); |
| 1268 | ns_cmd_free_mpvirt: |
| 1269 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 1270 | ns_cmd_free_mp: |
| 1271 | kfree(mp); |
| 1272 | ns_cmd_exit: |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1273 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 1274 | "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n", |
| 1275 | cmdcode, rc, vport->fc_flag, vport->fc_rscn_id_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1276 | return 1; |
| 1277 | } |
| 1278 | |
| 1279 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1280 | lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1281 | struct lpfc_iocbq * rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1282 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1283 | struct lpfc_dmabuf *inp = cmdiocb->context1; |
| 1284 | struct lpfc_dmabuf *outp = cmdiocb->context2; |
| 1285 | struct lpfc_sli_ct_request *CTrsp = outp->virt; |
| 1286 | struct lpfc_sli_ct_request *CTcmd = inp->virt; |
| 1287 | struct lpfc_nodelist *ndlp; |
| 1288 | uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp; |
| 1289 | uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1290 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1291 | IOCB_t *irsp = &rspiocb->iocb; |
| 1292 | uint32_t latt; |
| 1293 | |
| 1294 | latt = lpfc_els_chk_latt(vport); |
| 1295 | |
| 1296 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 1297 | "FDMI cmpl: status:x%x/x%x latt:%d", |
| 1298 | irsp->ulpStatus, irsp->un.ulpWord[4], latt); |
| 1299 | |
| 1300 | if (latt || irsp->ulpStatus) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1301 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1302 | "0229 FDMI cmd %04x failed, latt = %d " |
| 1303 | "ulpStatus: x%x, rid x%x\n", |
| 1304 | be16_to_cpu(fdmi_cmd), latt, irsp->ulpStatus, |
| 1305 | irsp->un.ulpWord[4]); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1306 | lpfc_ct_free_iocb(phba, cmdiocb); |
| 1307 | return; |
| 1308 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1309 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1310 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1311 | if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) |
| 1312 | goto fail_out; |
| 1313 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1314 | if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { |
| 1315 | /* FDMI rsp failed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1316 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1317 | "0220 FDMI rsp failed Data: x%x\n", |
| 1318 | be16_to_cpu(fdmi_cmd)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1319 | } |
| 1320 | |
| 1321 | switch (be16_to_cpu(fdmi_cmd)) { |
| 1322 | case SLI_MGMT_RHBA: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1323 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1324 | break; |
| 1325 | |
| 1326 | case SLI_MGMT_RPA: |
| 1327 | break; |
| 1328 | |
| 1329 | case SLI_MGMT_DHBA: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1330 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1331 | break; |
| 1332 | |
| 1333 | case SLI_MGMT_DPRT: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1334 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1335 | break; |
| 1336 | } |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1337 | |
| 1338 | fail_out: |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1339 | lpfc_ct_free_iocb(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1340 | return; |
| 1341 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1342 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1343 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1344 | lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1345 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1346 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1347 | struct lpfc_dmabuf *mp, *bmp; |
| 1348 | struct lpfc_sli_ct_request *CtReq; |
| 1349 | struct ulp_bde64 *bpl; |
| 1350 | uint32_t size; |
| 1351 | REG_HBA *rh; |
| 1352 | PORT_ENTRY *pe; |
| 1353 | REG_PORT_ATTRIBUTE *pab; |
| 1354 | ATTRIBUTE_BLOCK *ab; |
| 1355 | ATTRIBUTE_ENTRY *ae; |
| 1356 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 1357 | struct lpfc_iocbq *); |
| 1358 | |
| 1359 | |
| 1360 | /* fill in BDEs for command */ |
| 1361 | /* Allocate buffer for command payload */ |
| 1362 | mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
| 1363 | if (!mp) |
| 1364 | goto fdmi_cmd_exit; |
| 1365 | |
| 1366 | mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys)); |
| 1367 | if (!mp->virt) |
| 1368 | goto fdmi_cmd_free_mp; |
| 1369 | |
| 1370 | /* Allocate buffer for Buffer ptr list */ |
| 1371 | bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
| 1372 | if (!bmp) |
| 1373 | goto fdmi_cmd_free_mpvirt; |
| 1374 | |
| 1375 | bmp->virt = lpfc_mbuf_alloc(phba, 0, &(bmp->phys)); |
| 1376 | if (!bmp->virt) |
| 1377 | goto fdmi_cmd_free_bmp; |
| 1378 | |
| 1379 | INIT_LIST_HEAD(&mp->list); |
| 1380 | INIT_LIST_HEAD(&bmp->list); |
| 1381 | |
| 1382 | /* FDMI request */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1383 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1384 | "0218 FDMI Request Data: x%x x%x x%x\n", |
| 1385 | vport->fc_flag, vport->port_state, cmdcode); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1386 | CtReq = (struct lpfc_sli_ct_request *) mp->virt; |
| 1387 | |
| 1388 | memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request)); |
| 1389 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; |
| 1390 | CtReq->RevisionId.bits.InId = 0; |
| 1391 | |
| 1392 | CtReq->FsType = SLI_CT_MANAGEMENT_SERVICE; |
| 1393 | CtReq->FsSubType = SLI_CT_FDMI_Subtypes; |
| 1394 | size = 0; |
| 1395 | |
| 1396 | switch (cmdcode) { |
| 1397 | case SLI_MGMT_RHBA: |
| 1398 | { |
| 1399 | lpfc_vpd_t *vp = &phba->vpd; |
| 1400 | uint32_t i, j, incr; |
| 1401 | int len; |
| 1402 | |
| 1403 | CtReq->CommandResponse.bits.CmdRsp = |
| 1404 | be16_to_cpu(SLI_MGMT_RHBA); |
| 1405 | CtReq->CommandResponse.bits.Size = 0; |
| 1406 | rh = (REG_HBA *) & CtReq->un.PortID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1407 | memcpy(&rh->hi.PortName, &vport->fc_sparam.portName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1408 | sizeof (struct lpfc_name)); |
| 1409 | /* One entry (port) per adapter */ |
| 1410 | rh->rpl.EntryCnt = be32_to_cpu(1); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1411 | memcpy(&rh->rpl.pe, &vport->fc_sparam.portName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1412 | sizeof (struct lpfc_name)); |
| 1413 | |
| 1414 | /* point to the HBA attribute block */ |
| 1415 | size = 2 * sizeof (struct lpfc_name) + FOURBYTES; |
| 1416 | ab = (ATTRIBUTE_BLOCK *) ((uint8_t *) rh + size); |
| 1417 | ab->EntryCnt = 0; |
| 1418 | |
| 1419 | /* Point to the beginning of the first HBA attribute |
| 1420 | entry */ |
| 1421 | /* #1 HBA attribute entry */ |
| 1422 | size += FOURBYTES; |
| 1423 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1424 | ae->ad.bits.AttrType = be16_to_cpu(NODE_NAME); |
| 1425 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES |
| 1426 | + sizeof (struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1427 | memcpy(&ae->un.NodeName, &vport->fc_sparam.nodeName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1428 | sizeof (struct lpfc_name)); |
| 1429 | ab->EntryCnt++; |
| 1430 | size += FOURBYTES + sizeof (struct lpfc_name); |
| 1431 | |
| 1432 | /* #2 HBA attribute entry */ |
| 1433 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1434 | ae->ad.bits.AttrType = be16_to_cpu(MANUFACTURER); |
| 1435 | strcpy(ae->un.Manufacturer, "Emulex Corporation"); |
| 1436 | len = strlen(ae->un.Manufacturer); |
| 1437 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1438 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1439 | ab->EntryCnt++; |
| 1440 | size += FOURBYTES + len; |
| 1441 | |
| 1442 | /* #3 HBA attribute entry */ |
| 1443 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1444 | ae->ad.bits.AttrType = be16_to_cpu(SERIAL_NUMBER); |
| 1445 | strcpy(ae->un.SerialNumber, phba->SerialNumber); |
| 1446 | len = strlen(ae->un.SerialNumber); |
| 1447 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1448 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1449 | ab->EntryCnt++; |
| 1450 | size += FOURBYTES + len; |
| 1451 | |
| 1452 | /* #4 HBA attribute entry */ |
| 1453 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1454 | ae->ad.bits.AttrType = be16_to_cpu(MODEL); |
| 1455 | strcpy(ae->un.Model, phba->ModelName); |
| 1456 | len = strlen(ae->un.Model); |
| 1457 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1458 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1459 | ab->EntryCnt++; |
| 1460 | size += FOURBYTES + len; |
| 1461 | |
| 1462 | /* #5 HBA attribute entry */ |
| 1463 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1464 | ae->ad.bits.AttrType = be16_to_cpu(MODEL_DESCRIPTION); |
| 1465 | strcpy(ae->un.ModelDescription, phba->ModelDesc); |
| 1466 | len = strlen(ae->un.ModelDescription); |
| 1467 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1468 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1469 | ab->EntryCnt++; |
| 1470 | size += FOURBYTES + len; |
| 1471 | |
| 1472 | /* #6 HBA attribute entry */ |
| 1473 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1474 | ae->ad.bits.AttrType = be16_to_cpu(HARDWARE_VERSION); |
| 1475 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 8); |
| 1476 | /* Convert JEDEC ID to ascii for hardware version */ |
| 1477 | incr = vp->rev.biuRev; |
| 1478 | for (i = 0; i < 8; i++) { |
| 1479 | j = (incr & 0xf); |
| 1480 | if (j <= 9) |
| 1481 | ae->un.HardwareVersion[7 - i] = |
| 1482 | (char)((uint8_t) 0x30 + |
| 1483 | (uint8_t) j); |
| 1484 | else |
| 1485 | ae->un.HardwareVersion[7 - i] = |
| 1486 | (char)((uint8_t) 0x61 + |
| 1487 | (uint8_t) (j - 10)); |
| 1488 | incr = (incr >> 4); |
| 1489 | } |
| 1490 | ab->EntryCnt++; |
| 1491 | size += FOURBYTES + 8; |
| 1492 | |
| 1493 | /* #7 HBA attribute entry */ |
| 1494 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1495 | ae->ad.bits.AttrType = be16_to_cpu(DRIVER_VERSION); |
| 1496 | strcpy(ae->un.DriverVersion, lpfc_release_version); |
| 1497 | len = strlen(ae->un.DriverVersion); |
| 1498 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1499 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1500 | ab->EntryCnt++; |
| 1501 | size += FOURBYTES + len; |
| 1502 | |
| 1503 | /* #8 HBA attribute entry */ |
| 1504 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1505 | ae->ad.bits.AttrType = be16_to_cpu(OPTION_ROM_VERSION); |
| 1506 | strcpy(ae->un.OptionROMVersion, phba->OptionROMVersion); |
| 1507 | len = strlen(ae->un.OptionROMVersion); |
| 1508 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1509 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1510 | ab->EntryCnt++; |
| 1511 | size += FOURBYTES + len; |
| 1512 | |
| 1513 | /* #9 HBA attribute entry */ |
| 1514 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1515 | ae->ad.bits.AttrType = be16_to_cpu(FIRMWARE_VERSION); |
| 1516 | lpfc_decode_firmware_rev(phba, ae->un.FirmwareVersion, |
| 1517 | 1); |
| 1518 | len = strlen(ae->un.FirmwareVersion); |
| 1519 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1520 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1521 | ab->EntryCnt++; |
| 1522 | size += FOURBYTES + len; |
| 1523 | |
| 1524 | /* #10 HBA attribute entry */ |
| 1525 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1526 | ae->ad.bits.AttrType = be16_to_cpu(OS_NAME_VERSION); |
| 1527 | sprintf(ae->un.OsNameVersion, "%s %s %s", |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1528 | init_utsname()->sysname, |
| 1529 | init_utsname()->release, |
Serge E. Hallyn | 96b644b | 2006-10-02 02:18:13 -0700 | [diff] [blame] | 1530 | init_utsname()->version); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1531 | len = strlen(ae->un.OsNameVersion); |
| 1532 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1533 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1534 | ab->EntryCnt++; |
| 1535 | size += FOURBYTES + len; |
| 1536 | |
| 1537 | /* #11 HBA attribute entry */ |
| 1538 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1539 | ae->ad.bits.AttrType = be16_to_cpu(MAX_CT_PAYLOAD_LEN); |
| 1540 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
| 1541 | ae->un.MaxCTPayloadLen = (65 * 4096); |
| 1542 | ab->EntryCnt++; |
| 1543 | size += FOURBYTES + 4; |
| 1544 | |
| 1545 | ab->EntryCnt = be32_to_cpu(ab->EntryCnt); |
| 1546 | /* Total size */ |
| 1547 | size = GID_REQUEST_SZ - 4 + size; |
| 1548 | } |
| 1549 | break; |
| 1550 | |
| 1551 | case SLI_MGMT_RPA: |
| 1552 | { |
| 1553 | lpfc_vpd_t *vp; |
| 1554 | struct serv_parm *hsp; |
| 1555 | int len; |
| 1556 | |
| 1557 | vp = &phba->vpd; |
| 1558 | |
| 1559 | CtReq->CommandResponse.bits.CmdRsp = |
| 1560 | be16_to_cpu(SLI_MGMT_RPA); |
| 1561 | CtReq->CommandResponse.bits.Size = 0; |
| 1562 | pab = (REG_PORT_ATTRIBUTE *) & CtReq->un.PortID; |
| 1563 | size = sizeof (struct lpfc_name) + FOURBYTES; |
| 1564 | memcpy((uint8_t *) & pab->PortName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1565 | (uint8_t *) & vport->fc_sparam.portName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1566 | sizeof (struct lpfc_name)); |
| 1567 | pab->ab.EntryCnt = 0; |
| 1568 | |
| 1569 | /* #1 Port attribute entry */ |
| 1570 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1571 | ae->ad.bits.AttrType = be16_to_cpu(SUPPORTED_FC4_TYPES); |
| 1572 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 32); |
| 1573 | ae->un.SupportFC4Types[2] = 1; |
| 1574 | ae->un.SupportFC4Types[7] = 1; |
| 1575 | pab->ab.EntryCnt++; |
| 1576 | size += FOURBYTES + 32; |
| 1577 | |
| 1578 | /* #2 Port attribute entry */ |
| 1579 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1580 | ae->ad.bits.AttrType = be16_to_cpu(SUPPORTED_SPEED); |
| 1581 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 1582 | |
| 1583 | ae->un.SupportSpeed = 0; |
| 1584 | if (phba->lmt & LMT_10Gb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1585 | ae->un.SupportSpeed = HBA_PORTSPEED_10GBIT; |
Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 1586 | if (phba->lmt & LMT_8Gb) |
| 1587 | ae->un.SupportSpeed |= HBA_PORTSPEED_8GBIT; |
| 1588 | if (phba->lmt & LMT_4Gb) |
| 1589 | ae->un.SupportSpeed |= HBA_PORTSPEED_4GBIT; |
| 1590 | if (phba->lmt & LMT_2Gb) |
| 1591 | ae->un.SupportSpeed |= HBA_PORTSPEED_2GBIT; |
| 1592 | if (phba->lmt & LMT_1Gb) |
| 1593 | ae->un.SupportSpeed |= HBA_PORTSPEED_1GBIT; |
| 1594 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1595 | pab->ab.EntryCnt++; |
| 1596 | size += FOURBYTES + 4; |
| 1597 | |
| 1598 | /* #3 Port attribute entry */ |
| 1599 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1600 | ae->ad.bits.AttrType = be16_to_cpu(PORT_SPEED); |
| 1601 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
| 1602 | switch(phba->fc_linkspeed) { |
| 1603 | case LA_1GHZ_LINK: |
| 1604 | ae->un.PortSpeed = HBA_PORTSPEED_1GBIT; |
| 1605 | break; |
| 1606 | case LA_2GHZ_LINK: |
| 1607 | ae->un.PortSpeed = HBA_PORTSPEED_2GBIT; |
| 1608 | break; |
| 1609 | case LA_4GHZ_LINK: |
| 1610 | ae->un.PortSpeed = HBA_PORTSPEED_4GBIT; |
| 1611 | break; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 1612 | case LA_8GHZ_LINK: |
| 1613 | ae->un.PortSpeed = HBA_PORTSPEED_8GBIT; |
| 1614 | break; |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1615 | case LA_10GHZ_LINK: |
| 1616 | ae->un.PortSpeed = HBA_PORTSPEED_10GBIT; |
| 1617 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1618 | default: |
| 1619 | ae->un.PortSpeed = |
| 1620 | HBA_PORTSPEED_UNKNOWN; |
| 1621 | break; |
| 1622 | } |
| 1623 | pab->ab.EntryCnt++; |
| 1624 | size += FOURBYTES + 4; |
| 1625 | |
| 1626 | /* #4 Port attribute entry */ |
| 1627 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1628 | ae->ad.bits.AttrType = be16_to_cpu(MAX_FRAME_SIZE); |
| 1629 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1630 | hsp = (struct serv_parm *) & vport->fc_sparam; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1631 | ae->un.MaxFrameSize = |
| 1632 | (((uint32_t) hsp->cmn. |
| 1633 | bbRcvSizeMsb) << 8) | (uint32_t) hsp->cmn. |
| 1634 | bbRcvSizeLsb; |
| 1635 | pab->ab.EntryCnt++; |
| 1636 | size += FOURBYTES + 4; |
| 1637 | |
| 1638 | /* #5 Port attribute entry */ |
| 1639 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1640 | ae->ad.bits.AttrType = be16_to_cpu(OS_DEVICE_NAME); |
| 1641 | strcpy((char *)ae->un.OsDeviceName, LPFC_DRIVER_NAME); |
| 1642 | len = strlen((char *)ae->un.OsDeviceName); |
| 1643 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1644 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1645 | pab->ab.EntryCnt++; |
| 1646 | size += FOURBYTES + len; |
| 1647 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1648 | if (vport->cfg_fdmi_on == 2) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1649 | /* #6 Port attribute entry */ |
| 1650 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + |
| 1651 | size); |
| 1652 | ae->ad.bits.AttrType = be16_to_cpu(HOST_NAME); |
| 1653 | sprintf(ae->un.HostName, "%s", |
Serge E. Hallyn | 96b644b | 2006-10-02 02:18:13 -0700 | [diff] [blame] | 1654 | init_utsname()->nodename); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1655 | len = strlen(ae->un.HostName); |
| 1656 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1657 | ae->ad.bits.AttrLen = |
| 1658 | be16_to_cpu(FOURBYTES + len); |
| 1659 | pab->ab.EntryCnt++; |
| 1660 | size += FOURBYTES + len; |
| 1661 | } |
| 1662 | |
| 1663 | pab->ab.EntryCnt = be32_to_cpu(pab->ab.EntryCnt); |
| 1664 | /* Total size */ |
| 1665 | size = GID_REQUEST_SZ - 4 + size; |
| 1666 | } |
| 1667 | break; |
| 1668 | |
| 1669 | case SLI_MGMT_DHBA: |
| 1670 | CtReq->CommandResponse.bits.CmdRsp = be16_to_cpu(SLI_MGMT_DHBA); |
| 1671 | CtReq->CommandResponse.bits.Size = 0; |
| 1672 | pe = (PORT_ENTRY *) & CtReq->un.PortID; |
| 1673 | memcpy((uint8_t *) & pe->PortName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1674 | (uint8_t *) & vport->fc_sparam.portName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1675 | sizeof (struct lpfc_name)); |
| 1676 | size = GID_REQUEST_SZ - 4 + sizeof (struct lpfc_name); |
| 1677 | break; |
| 1678 | |
| 1679 | case SLI_MGMT_DPRT: |
| 1680 | CtReq->CommandResponse.bits.CmdRsp = be16_to_cpu(SLI_MGMT_DPRT); |
| 1681 | CtReq->CommandResponse.bits.Size = 0; |
| 1682 | pe = (PORT_ENTRY *) & CtReq->un.PortID; |
| 1683 | memcpy((uint8_t *) & pe->PortName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1684 | (uint8_t *) & vport->fc_sparam.portName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1685 | sizeof (struct lpfc_name)); |
| 1686 | size = GID_REQUEST_SZ - 4 + sizeof (struct lpfc_name); |
| 1687 | break; |
| 1688 | } |
| 1689 | |
| 1690 | bpl = (struct ulp_bde64 *) bmp->virt; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1691 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); |
| 1692 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1693 | bpl->tus.f.bdeFlags = 0; |
| 1694 | bpl->tus.f.bdeSize = size; |
| 1695 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 1696 | |
| 1697 | cmpl = lpfc_cmpl_ct_cmd_fdmi; |
| 1698 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1699 | /* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count |
| 1700 | * to hold ndlp reference for the corresponding callback function. |
| 1701 | */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1702 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, FC_MAX_NS_RSP, 0)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1703 | return 0; |
| 1704 | |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1705 | /* Decrement ndlp reference count to release ndlp reference held |
| 1706 | * for the failed command's callback function. |
| 1707 | */ |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1708 | lpfc_nlp_put(ndlp); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1709 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1710 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 1711 | fdmi_cmd_free_bmp: |
| 1712 | kfree(bmp); |
| 1713 | fdmi_cmd_free_mpvirt: |
| 1714 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 1715 | fdmi_cmd_free_mp: |
| 1716 | kfree(mp); |
| 1717 | fdmi_cmd_exit: |
| 1718 | /* Issue FDMI request failed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1719 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1720 | "0244 Issue FDMI request failed Data: x%x\n", |
| 1721 | cmdcode); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1722 | return 1; |
| 1723 | } |
| 1724 | |
| 1725 | void |
| 1726 | lpfc_fdmi_tmo(unsigned long ptr) |
| 1727 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1728 | struct lpfc_vport *vport = (struct lpfc_vport *)ptr; |
| 1729 | struct lpfc_hba *phba = vport->phba; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 1730 | uint32_t tmo_posted; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1731 | unsigned long iflag; |
| 1732 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1733 | spin_lock_irqsave(&vport->work_port_lock, iflag); |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 1734 | tmo_posted = vport->work_port_events & WORKER_FDMI_TMO; |
| 1735 | if (!tmo_posted) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1736 | vport->work_port_events |= WORKER_FDMI_TMO; |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 1737 | spin_unlock_irqrestore(&vport->work_port_lock, iflag); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1738 | |
James Smart | 5e9d9b8 | 2008-06-14 22:52:53 -0400 | [diff] [blame] | 1739 | if (!tmo_posted) |
| 1740 | lpfc_worker_wake_up(phba); |
| 1741 | return; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1742 | } |
| 1743 | |
| 1744 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1745 | lpfc_fdmi_timeout_handler(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1746 | { |
| 1747 | struct lpfc_nodelist *ndlp; |
| 1748 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1749 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
James Smart | e47c909 | 2008-02-08 18:49:26 -0500 | [diff] [blame] | 1750 | if (ndlp && NLP_CHK_NODE_ACT(ndlp)) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1751 | if (init_utsname()->nodename[0] != '\0') |
| 1752 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA); |
| 1753 | else |
| 1754 | mod_timer(&vport->fc_fdmitmo, jiffies + HZ * 60); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1755 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1756 | return; |
| 1757 | } |
| 1758 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1759 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1760 | lpfc_decode_firmware_rev(struct lpfc_hba *phba, char *fwrevision, int flag) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1761 | { |
| 1762 | struct lpfc_sli *psli = &phba->sli; |
| 1763 | lpfc_vpd_t *vp = &phba->vpd; |
| 1764 | uint32_t b1, b2, b3, b4, i, rev; |
| 1765 | char c; |
| 1766 | uint32_t *ptr, str[4]; |
| 1767 | uint8_t *fwname; |
| 1768 | |
James Smart | f112668 | 2009-06-10 17:22:44 -0400 | [diff] [blame] | 1769 | if (phba->sli_rev == LPFC_SLI_REV4) |
| 1770 | sprintf(fwrevision, "%s", vp->rev.opFwName); |
| 1771 | else if (vp->rev.rBit) { |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1772 | if (psli->sli_flag & LPFC_SLI_ACTIVE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1773 | rev = vp->rev.sli2FwRev; |
| 1774 | else |
| 1775 | rev = vp->rev.sli1FwRev; |
| 1776 | |
| 1777 | b1 = (rev & 0x0000f000) >> 12; |
| 1778 | b2 = (rev & 0x00000f00) >> 8; |
| 1779 | b3 = (rev & 0x000000c0) >> 6; |
| 1780 | b4 = (rev & 0x00000030) >> 4; |
| 1781 | |
| 1782 | switch (b4) { |
| 1783 | case 0: |
| 1784 | c = 'N'; |
| 1785 | break; |
| 1786 | case 1: |
| 1787 | c = 'A'; |
| 1788 | break; |
| 1789 | case 2: |
| 1790 | c = 'B'; |
| 1791 | break; |
| 1792 | default: |
| 1793 | c = 0; |
| 1794 | break; |
| 1795 | } |
| 1796 | b4 = (rev & 0x0000000f); |
| 1797 | |
James Smart | f4b4c68 | 2009-05-22 14:53:12 -0400 | [diff] [blame] | 1798 | if (psli->sli_flag & LPFC_SLI_ACTIVE) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1799 | fwname = vp->rev.sli2FwName; |
| 1800 | else |
| 1801 | fwname = vp->rev.sli1FwName; |
| 1802 | |
| 1803 | for (i = 0; i < 16; i++) |
| 1804 | if (fwname[i] == 0x20) |
| 1805 | fwname[i] = 0; |
| 1806 | |
| 1807 | ptr = (uint32_t*)fwname; |
| 1808 | |
| 1809 | for (i = 0; i < 3; i++) |
| 1810 | str[i] = be32_to_cpu(*ptr++); |
| 1811 | |
| 1812 | if (c == 0) { |
| 1813 | if (flag) |
| 1814 | sprintf(fwrevision, "%d.%d%d (%s)", |
| 1815 | b1, b2, b3, (char *)str); |
| 1816 | else |
| 1817 | sprintf(fwrevision, "%d.%d%d", b1, |
| 1818 | b2, b3); |
| 1819 | } else { |
| 1820 | if (flag) |
| 1821 | sprintf(fwrevision, "%d.%d%d%c%d (%s)", |
| 1822 | b1, b2, b3, c, |
| 1823 | b4, (char *)str); |
| 1824 | else |
| 1825 | sprintf(fwrevision, "%d.%d%d%c%d", |
| 1826 | b1, b2, b3, c, b4); |
| 1827 | } |
| 1828 | } else { |
| 1829 | rev = vp->rev.smFwRev; |
| 1830 | |
| 1831 | b1 = (rev & 0xff000000) >> 24; |
| 1832 | b2 = (rev & 0x00f00000) >> 20; |
| 1833 | b3 = (rev & 0x000f0000) >> 16; |
| 1834 | c = (rev & 0x0000ff00) >> 8; |
| 1835 | b4 = (rev & 0x000000ff); |
| 1836 | |
| 1837 | if (flag) |
| 1838 | sprintf(fwrevision, "%d.%d%d%c%d ", b1, |
| 1839 | b2, b3, c, b4); |
| 1840 | else |
| 1841 | sprintf(fwrevision, "%d.%d%d%c%d ", b1, |
| 1842 | b2, b3, c, b4); |
| 1843 | } |
| 1844 | return; |
| 1845 | } |