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