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