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