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