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