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