| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1 | /******************************************************************* |
| 2 | * This file is part of the Emulex Linux Device Driver for * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 3 | * Fibre Channel Host Bus Adapters. * |
James Smart | 9413aff | 2007-04-25 09:53:35 -0400 | [diff] [blame] | 4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 5 | * EMULEX and SLI are trademarks of Emulex. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 6 | * www.emulex.com * |
| 7 | * * |
| 8 | * This program is free software; you can redistribute it and/or * |
James.Smart@Emulex.Com | c44ce17 | 2005-06-25 10:34:39 -0400 | [diff] [blame] | 9 | * modify it under the terms of version 2 of the GNU General * |
| 10 | * Public License as published by the Free Software Foundation. * |
| 11 | * This program is distributed in the hope that it will be useful. * |
| 12 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * |
| 13 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * |
| 14 | * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * |
| 15 | * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * |
| 16 | * TO BE LEGALLY INVALID. See the GNU General Public License for * |
| 17 | * more details, a copy of which can be found in the file COPYING * |
| 18 | * included with this package. * |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 19 | *******************************************************************/ |
| 20 | |
| 21 | /* |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 22 | * Fibre Channel SCSI LAN Device Driver CT support: FC Generic Services FC-GS |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 23 | */ |
| 24 | |
| 25 | #include <linux/blkdev.h> |
| 26 | #include <linux/pci.h> |
| 27 | #include <linux/interrupt.h> |
| 28 | #include <linux/utsname.h> |
| 29 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 30 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 31 | #include <scsi/scsi_device.h> |
| 32 | #include <scsi/scsi_host.h> |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 33 | #include <scsi/scsi_transport_fc.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 34 | |
| 35 | #include "lpfc_hw.h" |
| 36 | #include "lpfc_sli.h" |
| 37 | #include "lpfc_disc.h" |
| 38 | #include "lpfc_scsi.h" |
| 39 | #include "lpfc.h" |
| 40 | #include "lpfc_logmsg.h" |
| 41 | #include "lpfc_crtn.h" |
| 42 | #include "lpfc_version.h" |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 43 | #include "lpfc_vport.h" |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 44 | #include "lpfc_debugfs.h" |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 45 | |
| 46 | #define HBA_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver |
| 47 | * incapable of reporting */ |
| 48 | #define HBA_PORTSPEED_1GBIT 1 /* 1 GBit/sec */ |
| 49 | #define HBA_PORTSPEED_2GBIT 2 /* 2 GBit/sec */ |
| 50 | #define HBA_PORTSPEED_4GBIT 8 /* 4 GBit/sec */ |
| 51 | #define HBA_PORTSPEED_8GBIT 16 /* 8 GBit/sec */ |
| 52 | #define HBA_PORTSPEED_10GBIT 4 /* 10 GBit/sec */ |
| 53 | #define HBA_PORTSPEED_NOT_NEGOTIATED 5 /* Speed not established */ |
| 54 | |
| 55 | #define FOURBYTES 4 |
| 56 | |
| 57 | |
| 58 | static char *lpfc_release_version = LPFC_DRIVER_VERSION; |
| 59 | |
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 | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 297 | geniocb->context_un.ndlp = 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); |
| 492 | if (ndlp && (ndlp->nlp_type & |
| 493 | NLP_FCP_TARGET)) |
| 494 | lpfc_setup_disc_node |
| 495 | (vport, Did); |
| 496 | else if (lpfc_ns_cmd(vport, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 497 | SLI_CTNS_GFF_ID, |
| 498 | 0, Did) == 0) |
| 499 | vport->num_disc_nodes++; |
| 500 | } |
| 501 | else { |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 502 | lpfc_debugfs_disc_trc(vport, |
| 503 | LPFC_DISC_TRC_CT, |
| 504 | "Skip2 GID_FTrsp: " |
| 505 | "did:x%x flg:x%x cnt:%d", |
| 506 | Did, vport->fc_flag, |
| 507 | vport->fc_rscn_id_cnt); |
| 508 | |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 509 | lpfc_printf_vlog(vport, |
| 510 | KERN_INFO, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 511 | LOG_DISCOVERY, |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 512 | "0245 Skip x%x " |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 513 | "NameServer Rsp Data: " |
| 514 | "x%x x%x\n", |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 515 | Did, vport->fc_flag, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 516 | vport->fc_rscn_id_cnt); |
| 517 | } |
| 518 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 519 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 520 | if (CTentry & (be32_to_cpu(SLI_CT_LAST_ENTRY))) |
| 521 | goto nsout1; |
| 522 | Cnt -= sizeof (uint32_t); |
| 523 | } |
| 524 | ctptr = NULL; |
| 525 | |
| 526 | } |
| 527 | |
| 528 | nsout1: |
| 529 | list_del(&head); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 530 | return 0; |
| 531 | } |
| 532 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 533 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 534 | lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 535 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 536 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 537 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 538 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 539 | IOCB_t *irsp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 540 | struct lpfc_dmabuf *bmp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 541 | struct lpfc_dmabuf *outp; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 542 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 543 | struct lpfc_nodelist *ndlp; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 544 | int rc, retry; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 545 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 546 | /* First save ndlp, before we overwrite it */ |
| 547 | ndlp = cmdiocb->context_un.ndlp; |
| 548 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 549 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 550 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 551 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 552 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 553 | bmp = (struct lpfc_dmabuf *) cmdiocb->context3; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 554 | irsp = &rspiocb->iocb; |
| 555 | |
| 556 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 557 | "GID_FT cmpl: status:x%x/x%x rtry:%d", |
| 558 | irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_ns_retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 559 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 560 | /* Don't bother processing response if vport is being torn down. */ |
| 561 | if (vport->load_flag & FC_UNLOADING) |
| 562 | goto out; |
| 563 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 564 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 565 | if (lpfc_els_chk_latt(vport) || lpfc_error_lost_link(irsp)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 566 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 567 | "0216 Link event during NS query\n"); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 568 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
| 569 | goto out; |
| 570 | } |
| 571 | |
| 572 | if (irsp->ulpStatus) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 573 | /* Check for retry */ |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 574 | if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) { |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 575 | retry = 1; |
| 576 | if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) { |
| 577 | switch (irsp->un.ulpWord[4]) { |
| 578 | case IOERR_NO_RESOURCES: |
| 579 | /* We don't increment the retry |
| 580 | * count for this case. |
| 581 | */ |
| 582 | break; |
| 583 | case IOERR_LINK_DOWN: |
| 584 | case IOERR_SLI_ABORTED: |
| 585 | case IOERR_SLI_DOWN: |
| 586 | retry = 0; |
| 587 | break; |
| 588 | default: |
| 589 | vport->fc_ns_retry++; |
| 590 | } |
| 591 | } |
| 592 | else |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 593 | vport->fc_ns_retry++; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 594 | |
| 595 | if (retry) { |
| 596 | /* CT command is being retried */ |
| 597 | rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 598 | vport->fc_ns_retry, 0); |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 599 | if (rc == 0) { |
| 600 | /* success */ |
| 601 | goto out; |
| 602 | } |
| 603 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 604 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 605 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 606 | lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, |
| 607 | "0257 GID_FT Query error: 0x%x 0x%x\n", |
| 608 | irsp->ulpStatus, vport->fc_ns_retry); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 609 | } else { |
| 610 | /* Good status, continue checking */ |
| 611 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 612 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 613 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 614 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 615 | "0208 NameServer Rsp Data: x%x\n", |
| 616 | vport->fc_flag); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 617 | lpfc_ns_rsp(vport, outp, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 618 | (uint32_t) (irsp->un.genreq64.bdl.bdeSize)); |
| 619 | } else if (CTrsp->CommandResponse.bits.CmdRsp == |
| 620 | be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { |
| 621 | /* NameServer Rsp Error */ |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 622 | if ((CTrsp->ReasonCode == SLI_CT_UNABLE_TO_PERFORM_REQ) |
| 623 | && (CTrsp->Explanation == SLI_CT_NO_FC4_TYPES)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 624 | lpfc_printf_vlog(vport, KERN_INFO, |
| 625 | LOG_DISCOVERY, |
| 626 | "0269 No NameServer Entries " |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 627 | "Data: x%x x%x x%x x%x\n", |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 628 | CTrsp->CommandResponse.bits.CmdRsp, |
| 629 | (uint32_t) CTrsp->ReasonCode, |
| 630 | (uint32_t) CTrsp->Explanation, |
| 631 | vport->fc_flag); |
| 632 | |
| 633 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 634 | "GID_FT no entry cmd:x%x rsn:x%x exp:x%x", |
| 635 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 636 | (uint32_t) CTrsp->ReasonCode, |
| 637 | (uint32_t) CTrsp->Explanation); |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 638 | } else { |
| 639 | lpfc_printf_vlog(vport, KERN_INFO, |
| 640 | LOG_DISCOVERY, |
| 641 | "0240 NameServer Rsp Error " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 642 | "Data: x%x x%x x%x x%x\n", |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 643 | CTrsp->CommandResponse.bits.CmdRsp, |
| 644 | (uint32_t) CTrsp->ReasonCode, |
| 645 | (uint32_t) CTrsp->Explanation, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 646 | vport->fc_flag); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 647 | |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 648 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 649 | "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x", |
| 650 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 651 | (uint32_t) CTrsp->ReasonCode, |
| 652 | (uint32_t) CTrsp->Explanation); |
James Smart | a58cbd5 | 2007-08-02 11:09:43 -0400 | [diff] [blame] | 653 | } |
| 654 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 655 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 656 | } else { |
| 657 | /* NameServer Rsp Error */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 658 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 659 | "0241 NameServer Rsp Error " |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 660 | "Data: x%x x%x x%x x%x\n", |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 661 | CTrsp->CommandResponse.bits.CmdRsp, |
| 662 | (uint32_t) CTrsp->ReasonCode, |
| 663 | (uint32_t) CTrsp->Explanation, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 664 | vport->fc_flag); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 665 | |
| 666 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 667 | "GID_FT rsp err2 cmd:x%x rsn:x%x exp:x%x", |
| 668 | (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, |
| 669 | (uint32_t) CTrsp->ReasonCode, |
| 670 | (uint32_t) CTrsp->Explanation); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 671 | } |
| 672 | } |
| 673 | /* Link up / RSCN discovery */ |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 674 | if (vport->num_disc_nodes == 0) { |
| 675 | /* |
| 676 | * The driver has cycled through all Nports in the RSCN payload. |
| 677 | * Complete the handling by cleaning up and marking the |
| 678 | * current driver state. |
| 679 | */ |
| 680 | if (vport->port_state >= LPFC_DISC_AUTH) { |
| 681 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 682 | lpfc_els_flush_rscn(vport); |
| 683 | spin_lock_irq(shost->host_lock); |
| 684 | vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ |
| 685 | spin_unlock_irq(shost->host_lock); |
| 686 | } |
| 687 | else |
| 688 | lpfc_els_flush_rscn(vport); |
| 689 | } |
| 690 | |
| 691 | lpfc_disc_start(vport); |
| 692 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 693 | out: |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 694 | cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 695 | lpfc_ct_free_iocb(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 696 | return; |
| 697 | } |
| 698 | |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 699 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 700 | lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 701 | struct lpfc_iocbq *rspiocb) |
| 702 | { |
| 703 | struct lpfc_vport *vport = cmdiocb->vport; |
| 704 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); |
| 705 | IOCB_t *irsp = &rspiocb->iocb; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 706 | struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1; |
| 707 | struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 708 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 709 | int did, rc, retry; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 710 | uint8_t fbits; |
| 711 | struct lpfc_nodelist *ndlp; |
| 712 | |
| 713 | did = ((struct lpfc_sli_ct_request *) inp->virt)->un.gff.PortId; |
| 714 | did = be32_to_cpu(did); |
| 715 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 716 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 717 | "GFF_ID cmpl: status:x%x/x%x did:x%x", |
| 718 | irsp->ulpStatus, irsp->un.ulpWord[4], did); |
| 719 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 720 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 721 | /* Good status, continue checking */ |
| 722 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 723 | fbits = CTrsp->un.gff_acc.fbits[FCP_TYPE_FEATURE_OFFSET]; |
| 724 | |
| 725 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 726 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { |
| 727 | if ((fbits & FC4_FEATURE_INIT) && |
| 728 | !(fbits & FC4_FEATURE_TARGET)) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 729 | lpfc_printf_vlog(vport, KERN_INFO, |
| 730 | LOG_DISCOVERY, |
| 731 | "0270 Skip x%x GFF " |
| 732 | "NameServer Rsp Data: (init) " |
| 733 | "x%x x%x\n", did, fbits, |
| 734 | vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 735 | goto out; |
| 736 | } |
| 737 | } |
| 738 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 739 | else { |
James Smart | 0ff10d4 | 2008-01-11 01:52:36 -0500 | [diff] [blame] | 740 | /* Check for retry */ |
| 741 | if (cmdiocb->retry < LPFC_MAX_NS_RETRY) { |
| 742 | retry = 1; |
| 743 | if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) { |
| 744 | switch (irsp->un.ulpWord[4]) { |
| 745 | case IOERR_NO_RESOURCES: |
| 746 | /* We don't increment the retry |
| 747 | * count for this case. |
| 748 | */ |
| 749 | break; |
| 750 | case IOERR_LINK_DOWN: |
| 751 | case IOERR_SLI_ABORTED: |
| 752 | case IOERR_SLI_DOWN: |
| 753 | retry = 0; |
| 754 | break; |
| 755 | default: |
| 756 | cmdiocb->retry++; |
| 757 | } |
| 758 | } |
| 759 | else |
| 760 | cmdiocb->retry++; |
| 761 | |
| 762 | if (retry) { |
| 763 | /* CT command is being retried */ |
| 764 | rc = lpfc_ns_cmd(vport, SLI_CTNS_GFF_ID, |
| 765 | cmdiocb->retry, did); |
| 766 | if (rc == 0) { |
| 767 | /* success */ |
| 768 | lpfc_ct_free_iocb(phba, cmdiocb); |
| 769 | return; |
| 770 | } |
| 771 | } |
| 772 | } |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 773 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 774 | "0267 NameServer GFF Rsp " |
| 775 | "x%x Error (%d %d) Data: x%x x%x\n", |
| 776 | did, irsp->ulpStatus, irsp->un.ulpWord[4], |
| 777 | vport->fc_flag, vport->fc_rscn_id_cnt) |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 778 | } |
| 779 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 780 | /* This is a target port, unregistered port, or the GFF_ID failed */ |
| 781 | ndlp = lpfc_setup_disc_node(vport, did); |
| 782 | if (ndlp) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 783 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 784 | "0242 Process x%x GFF " |
| 785 | "NameServer Rsp Data: x%x x%x x%x\n", |
| 786 | did, ndlp->nlp_flag, vport->fc_flag, |
| 787 | vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 788 | } else { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 789 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 790 | "0243 Skip x%x GFF " |
| 791 | "NameServer Rsp Data: x%x x%x\n", did, |
| 792 | vport->fc_flag, vport->fc_rscn_id_cnt); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 793 | } |
| 794 | out: |
| 795 | /* Link up / RSCN discovery */ |
| 796 | if (vport->num_disc_nodes) |
| 797 | vport->num_disc_nodes--; |
| 798 | if (vport->num_disc_nodes == 0) { |
| 799 | /* |
| 800 | * The driver has cycled through all Nports in the RSCN payload. |
| 801 | * Complete the handling by cleaning up and marking the |
| 802 | * current driver state. |
| 803 | */ |
| 804 | if (vport->port_state >= LPFC_DISC_AUTH) { |
| 805 | if (vport->fc_flag & FC_RSCN_MODE) { |
| 806 | lpfc_els_flush_rscn(vport); |
| 807 | spin_lock_irq(shost->host_lock); |
| 808 | vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ |
| 809 | spin_unlock_irq(shost->host_lock); |
| 810 | } |
| 811 | else |
| 812 | lpfc_els_flush_rscn(vport); |
| 813 | } |
| 814 | lpfc_disc_start(vport); |
| 815 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 816 | lpfc_ct_free_iocb(phba, cmdiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 817 | return; |
| 818 | } |
| 819 | |
| 820 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 821 | static void |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 822 | lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 823 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 824 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 825 | struct lpfc_vport *vport = cmdiocb->vport; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 826 | struct lpfc_dmabuf *inp; |
| 827 | struct lpfc_dmabuf *outp; |
| 828 | IOCB_t *irsp; |
| 829 | struct lpfc_sli_ct_request *CTrsp; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 830 | struct lpfc_nodelist *ndlp; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 831 | int cmdcode, rc; |
| 832 | uint8_t retry; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 833 | uint32_t latt; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 834 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 835 | /* First save ndlp, before we overwrite it */ |
| 836 | ndlp = cmdiocb->context_un.ndlp; |
| 837 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 838 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 839 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 840 | |
| 841 | inp = (struct lpfc_dmabuf *) cmdiocb->context1; |
| 842 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 843 | irsp = &rspiocb->iocb; |
| 844 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 845 | cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)-> |
| 846 | CommandResponse.bits.CmdRsp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 847 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 848 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 849 | latt = lpfc_els_chk_latt(vport); |
| 850 | |
| 851 | /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 852 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 853 | "0209 CT Request completes, latt %d, " |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 854 | "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n", |
| 855 | latt, irsp->ulpStatus, |
| 856 | CTrsp->CommandResponse.bits.CmdRsp, |
| 857 | cmdiocb->iocb.ulpContext, cmdiocb->iocb.ulpIoTag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 858 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 859 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 860 | "CT cmd cmpl: status:x%x/x%x cmd:x%x", |
| 861 | irsp->ulpStatus, irsp->un.ulpWord[4], cmdcode); |
| 862 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 863 | if (irsp->ulpStatus) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 864 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 865 | "0268 NS cmd %x Error (%d %d)\n", |
| 866 | cmdcode, irsp->ulpStatus, irsp->un.ulpWord[4]); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 867 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 868 | if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && |
| 869 | ((irsp->un.ulpWord[4] == IOERR_SLI_DOWN) || |
| 870 | (irsp->un.ulpWord[4] == IOERR_SLI_ABORTED))) |
| 871 | goto out; |
| 872 | |
| 873 | retry = cmdiocb->retry; |
| 874 | if (retry >= LPFC_MAX_NS_RETRY) |
| 875 | goto out; |
| 876 | |
| 877 | retry++; |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 878 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 879 | "0216 Retrying NS cmd %x\n", cmdcode); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 880 | rc = lpfc_ns_cmd(vport, cmdcode, retry, 0); |
| 881 | if (rc == 0) |
| 882 | goto out; |
| 883 | } |
| 884 | |
| 885 | out: |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 886 | cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 887 | lpfc_ct_free_iocb(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 888 | return; |
| 889 | } |
| 890 | |
| 891 | static void |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 892 | lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 893 | struct lpfc_iocbq *rspiocb) |
| 894 | { |
| 895 | IOCB_t *irsp = &rspiocb->iocb; |
| 896 | struct lpfc_vport *vport = cmdiocb->vport; |
| 897 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 898 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 899 | struct lpfc_dmabuf *outp; |
| 900 | struct lpfc_sli_ct_request *CTrsp; |
| 901 | |
| 902 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 903 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 904 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 905 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 906 | vport->ct_flags |= FC_CT_RFT_ID; |
| 907 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 908 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| 909 | return; |
| 910 | } |
| 911 | |
| 912 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 913 | lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 914 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 915 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 916 | IOCB_t *irsp = &rspiocb->iocb; |
| 917 | struct lpfc_vport *vport = cmdiocb->vport; |
| 918 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 919 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 920 | struct lpfc_dmabuf *outp; |
| 921 | struct lpfc_sli_ct_request *CTrsp; |
| 922 | |
| 923 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 924 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 925 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 926 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 927 | vport->ct_flags |= FC_CT_RNN_ID; |
| 928 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 929 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 930 | return; |
| 931 | } |
| 932 | |
| 933 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 934 | lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 935 | struct lpfc_iocbq *rspiocb) |
| 936 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 937 | IOCB_t *irsp = &rspiocb->iocb; |
| 938 | struct lpfc_vport *vport = cmdiocb->vport; |
| 939 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 940 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 941 | struct lpfc_dmabuf *outp; |
| 942 | struct lpfc_sli_ct_request *CTrsp; |
| 943 | |
| 944 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 945 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 946 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 947 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 948 | vport->ct_flags |= FC_CT_RSPN_ID; |
| 949 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 950 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 951 | return; |
| 952 | } |
| 953 | |
| 954 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 955 | lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 956 | struct lpfc_iocbq *rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 957 | { |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 958 | IOCB_t *irsp = &rspiocb->iocb; |
| 959 | struct lpfc_vport *vport = cmdiocb->vport; |
| 960 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 961 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 962 | struct lpfc_dmabuf *outp; |
| 963 | struct lpfc_sli_ct_request *CTrsp; |
| 964 | |
| 965 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 966 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 967 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 968 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 969 | vport->ct_flags |= FC_CT_RSNN_NN; |
| 970 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 971 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| 972 | return; |
| 973 | } |
| 974 | |
| 975 | static void |
| 976 | lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 977 | struct lpfc_iocbq *rspiocb) |
| 978 | { |
| 979 | struct lpfc_vport *vport = cmdiocb->vport; |
| 980 | |
| 981 | /* even if it fails we will act as though it succeeded. */ |
| 982 | vport->ct_flags = 0; |
| 983 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 984 | return; |
| 985 | } |
| 986 | |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 987 | static void |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 988 | lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 989 | struct lpfc_iocbq *rspiocb) |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 990 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 991 | IOCB_t *irsp = &rspiocb->iocb; |
| 992 | struct lpfc_vport *vport = cmdiocb->vport; |
| 993 | |
James Smart | 98c9ea5 | 2007-10-27 13:37:33 -0400 | [diff] [blame] | 994 | if (irsp->ulpStatus == IOSTAT_SUCCESS) { |
| 995 | struct lpfc_dmabuf *outp; |
| 996 | struct lpfc_sli_ct_request *CTrsp; |
| 997 | |
| 998 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 999 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 1000 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 1001 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) |
| 1002 | vport->ct_flags |= FC_CT_RFF_ID; |
| 1003 | } |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1004 | lpfc_cmpl_ct(phba, cmdiocb, rspiocb); |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1005 | return; |
| 1006 | } |
| 1007 | |
James Smart | 311464e | 2007-08-02 11:10:37 -0400 | [diff] [blame] | 1008 | static int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1009 | lpfc_vport_symbolic_port_name(struct lpfc_vport *vport, char *symbol, |
| 1010 | size_t size) |
| 1011 | { |
| 1012 | int n; |
| 1013 | uint8_t *wwn = vport->phba->wwpn; |
| 1014 | |
| 1015 | n = snprintf(symbol, size, |
| 1016 | "Emulex PPN-%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", |
| 1017 | wwn[0], wwn[1], wwn[2], wwn[3], |
| 1018 | wwn[4], wwn[5], wwn[6], wwn[7]); |
| 1019 | |
| 1020 | if (vport->port_type == LPFC_PHYSICAL_PORT) |
| 1021 | return n; |
| 1022 | |
| 1023 | if (n < size) |
| 1024 | n += snprintf(symbol + n, size - n, " VPort-%d", vport->vpi); |
| 1025 | |
| 1026 | if (n < size && vport->vname) |
| 1027 | n += snprintf(symbol + n, size - n, " VName-%s", vport->vname); |
| 1028 | return n; |
| 1029 | } |
| 1030 | |
| 1031 | int |
| 1032 | lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol, |
| 1033 | size_t size) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1034 | { |
| 1035 | char fwrev[16]; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1036 | int n; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1037 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1038 | lpfc_decode_firmware_rev(vport->phba, fwrev, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1039 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1040 | n = snprintf(symbol, size, "Emulex %s FV%s DV%s", |
| 1041 | vport->phba->ModelName, fwrev, lpfc_release_version); |
| 1042 | return n; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1043 | } |
| 1044 | |
| 1045 | /* |
| 1046 | * lpfc_ns_cmd |
| 1047 | * Description: |
| 1048 | * Issue Cmd to NameServer |
| 1049 | * SLI_CTNS_GID_FT |
| 1050 | * LI_CTNS_RFT_ID |
| 1051 | */ |
| 1052 | int |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1053 | lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, |
| 1054 | uint8_t retry, uint32_t context) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1055 | { |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1056 | struct lpfc_nodelist * ndlp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1057 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1058 | struct lpfc_dmabuf *mp, *bmp; |
| 1059 | struct lpfc_sli_ct_request *CtReq; |
| 1060 | struct ulp_bde64 *bpl; |
| 1061 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 1062 | struct lpfc_iocbq *) = NULL; |
| 1063 | uint32_t rsp_size = 1024; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1064 | size_t size; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1065 | int rc = 0; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1066 | |
| 1067 | ndlp = lpfc_findnode_did(vport, NameServer_DID); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1068 | if (ndlp == NULL || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) { |
| 1069 | rc=1; |
| 1070 | goto ns_cmd_exit; |
| 1071 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1072 | |
| 1073 | /* fill in BDEs for command */ |
| 1074 | /* Allocate buffer for command payload */ |
| 1075 | mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1076 | if (!mp) { |
| 1077 | rc=2; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1078 | goto ns_cmd_exit; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1079 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1080 | |
| 1081 | INIT_LIST_HEAD(&mp->list); |
| 1082 | mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1083 | if (!mp->virt) { |
| 1084 | rc=3; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1085 | goto ns_cmd_free_mp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1086 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1087 | |
| 1088 | /* Allocate buffer for Buffer ptr list */ |
| 1089 | bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1090 | if (!bmp) { |
| 1091 | rc=4; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1092 | goto ns_cmd_free_mpvirt; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1093 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1094 | |
| 1095 | INIT_LIST_HEAD(&bmp->list); |
| 1096 | bmp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(bmp->phys)); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1097 | if (!bmp->virt) { |
| 1098 | rc=5; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1099 | goto ns_cmd_free_bmp; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1100 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1101 | |
| 1102 | /* NameServer Req */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1103 | lpfc_printf_vlog(vport, KERN_INFO ,LOG_DISCOVERY, |
| 1104 | "0236 NameServer Req Data: x%x x%x x%x\n", |
| 1105 | cmdcode, vport->fc_flag, vport->fc_rscn_id_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1106 | |
| 1107 | bpl = (struct ulp_bde64 *) bmp->virt; |
| 1108 | memset(bpl, 0, sizeof(struct ulp_bde64)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1109 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); |
| 1110 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1111 | bpl->tus.f.bdeFlags = 0; |
| 1112 | if (cmdcode == SLI_CTNS_GID_FT) |
| 1113 | bpl->tus.f.bdeSize = GID_REQUEST_SZ; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1114 | else if (cmdcode == SLI_CTNS_GFF_ID) |
| 1115 | bpl->tus.f.bdeSize = GFF_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1116 | else if (cmdcode == SLI_CTNS_RFT_ID) |
| 1117 | bpl->tus.f.bdeSize = RFT_REQUEST_SZ; |
| 1118 | else if (cmdcode == SLI_CTNS_RNN_ID) |
| 1119 | bpl->tus.f.bdeSize = RNN_REQUEST_SZ; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1120 | else if (cmdcode == SLI_CTNS_RSPN_ID) |
| 1121 | bpl->tus.f.bdeSize = RSPN_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1122 | else if (cmdcode == SLI_CTNS_RSNN_NN) |
| 1123 | bpl->tus.f.bdeSize = RSNN_REQUEST_SZ; |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1124 | else if (cmdcode == SLI_CTNS_DA_ID) |
| 1125 | bpl->tus.f.bdeSize = DA_ID_REQUEST_SZ; |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1126 | else if (cmdcode == SLI_CTNS_RFF_ID) |
| 1127 | bpl->tus.f.bdeSize = RFF_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1128 | else |
| 1129 | bpl->tus.f.bdeSize = 0; |
| 1130 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 1131 | |
| 1132 | CtReq = (struct lpfc_sli_ct_request *) mp->virt; |
| 1133 | memset(CtReq, 0, sizeof (struct lpfc_sli_ct_request)); |
| 1134 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; |
| 1135 | CtReq->RevisionId.bits.InId = 0; |
| 1136 | CtReq->FsType = SLI_CT_DIRECTORY_SERVICE; |
| 1137 | CtReq->FsSubType = SLI_CT_DIRECTORY_NAME_SERVER; |
| 1138 | CtReq->CommandResponse.bits.Size = 0; |
| 1139 | switch (cmdcode) { |
| 1140 | case SLI_CTNS_GID_FT: |
| 1141 | CtReq->CommandResponse.bits.CmdRsp = |
| 1142 | be16_to_cpu(SLI_CTNS_GID_FT); |
| 1143 | CtReq->un.gid.Fc4Type = SLI_CTPT_FCP; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1144 | if (vport->port_state < LPFC_NS_QRY) |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1145 | vport->port_state = LPFC_NS_QRY; |
| 1146 | lpfc_set_disctmo(vport); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1147 | cmpl = lpfc_cmpl_ct_cmd_gid_ft; |
| 1148 | rsp_size = FC_MAX_NS_RSP; |
| 1149 | break; |
| 1150 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1151 | case SLI_CTNS_GFF_ID: |
| 1152 | CtReq->CommandResponse.bits.CmdRsp = |
| 1153 | be16_to_cpu(SLI_CTNS_GFF_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1154 | CtReq->un.gff.PortId = cpu_to_be32(context); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1155 | cmpl = lpfc_cmpl_ct_cmd_gff_id; |
| 1156 | break; |
| 1157 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1158 | case SLI_CTNS_RFT_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1159 | vport->ct_flags &= ~FC_CT_RFT_ID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1160 | CtReq->CommandResponse.bits.CmdRsp = |
| 1161 | be16_to_cpu(SLI_CTNS_RFT_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1162 | CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1163 | CtReq->un.rft.fcpReg = 1; |
| 1164 | cmpl = lpfc_cmpl_ct_cmd_rft_id; |
| 1165 | break; |
| 1166 | |
| 1167 | case SLI_CTNS_RNN_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1168 | vport->ct_flags &= ~FC_CT_RNN_ID; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1169 | CtReq->CommandResponse.bits.CmdRsp = |
| 1170 | be16_to_cpu(SLI_CTNS_RNN_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1171 | CtReq->un.rnn.PortId = cpu_to_be32(vport->fc_myDID); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1172 | memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1173 | sizeof (struct lpfc_name)); |
| 1174 | cmpl = lpfc_cmpl_ct_cmd_rnn_id; |
| 1175 | break; |
| 1176 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1177 | case SLI_CTNS_RSPN_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1178 | vport->ct_flags &= ~FC_CT_RSPN_ID; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1179 | CtReq->CommandResponse.bits.CmdRsp = |
| 1180 | be16_to_cpu(SLI_CTNS_RSPN_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1181 | CtReq->un.rspn.PortId = cpu_to_be32(vport->fc_myDID); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1182 | size = sizeof(CtReq->un.rspn.symbname); |
| 1183 | CtReq->un.rspn.len = |
| 1184 | lpfc_vport_symbolic_port_name(vport, |
| 1185 | CtReq->un.rspn.symbname, size); |
| 1186 | cmpl = lpfc_cmpl_ct_cmd_rspn_id; |
| 1187 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1188 | case SLI_CTNS_RSNN_NN: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1189 | vport->ct_flags &= ~FC_CT_RSNN_NN; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1190 | CtReq->CommandResponse.bits.CmdRsp = |
| 1191 | be16_to_cpu(SLI_CTNS_RSNN_NN); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1192 | memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1193 | sizeof (struct lpfc_name)); |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1194 | size = sizeof(CtReq->un.rsnn.symbname); |
| 1195 | CtReq->un.rsnn.len = |
| 1196 | lpfc_vport_symbolic_node_name(vport, |
| 1197 | CtReq->un.rsnn.symbname, size); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1198 | cmpl = lpfc_cmpl_ct_cmd_rsnn_nn; |
| 1199 | break; |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1200 | case SLI_CTNS_DA_ID: |
| 1201 | /* Implement DA_ID Nameserver request */ |
| 1202 | CtReq->CommandResponse.bits.CmdRsp = |
| 1203 | be16_to_cpu(SLI_CTNS_DA_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1204 | CtReq->un.da_id.port_id = cpu_to_be32(vport->fc_myDID); |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1205 | cmpl = lpfc_cmpl_ct_cmd_da_id; |
| 1206 | break; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1207 | case SLI_CTNS_RFF_ID: |
James Smart | 7ee5d43 | 2007-10-27 13:37:17 -0400 | [diff] [blame] | 1208 | vport->ct_flags &= ~FC_CT_RFF_ID; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1209 | CtReq->CommandResponse.bits.CmdRsp = |
| 1210 | be16_to_cpu(SLI_CTNS_RFF_ID); |
James Smart | 0937282 | 2008-01-11 01:52:54 -0500 | [diff] [blame] | 1211 | CtReq->un.rff.PortId = cpu_to_be32(vport->fc_myDID);; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1212 | CtReq->un.rff.fbits = FC4_FEATURE_INIT; |
| 1213 | CtReq->un.rff.type_code = FC_FCP_DATA; |
| 1214 | cmpl = lpfc_cmpl_ct_cmd_rff_id; |
| 1215 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1216 | } |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1217 | lpfc_nlp_get(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1218 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1219 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1220 | /* On success, The cmpl function will free the buffers */ |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1221 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 1222 | "Issue CT cmd: cmd:x%x did:x%x", |
| 1223 | cmdcode, ndlp->nlp_DID, 0); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1224 | return 0; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1225 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1226 | |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1227 | rc=6; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1228 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1229 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 1230 | ns_cmd_free_bmp: |
| 1231 | kfree(bmp); |
| 1232 | ns_cmd_free_mpvirt: |
| 1233 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 1234 | ns_cmd_free_mp: |
| 1235 | kfree(mp); |
| 1236 | ns_cmd_exit: |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1237 | lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY, |
| 1238 | "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n", |
| 1239 | cmdcode, rc, vport->fc_flag, vport->fc_rscn_id_cnt); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1240 | return 1; |
| 1241 | } |
| 1242 | |
| 1243 | static void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1244 | lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, |
| 1245 | struct lpfc_iocbq * rspiocb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1246 | { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1247 | struct lpfc_dmabuf *inp = cmdiocb->context1; |
| 1248 | struct lpfc_dmabuf *outp = cmdiocb->context2; |
| 1249 | struct lpfc_sli_ct_request *CTrsp = outp->virt; |
| 1250 | struct lpfc_sli_ct_request *CTcmd = inp->virt; |
| 1251 | struct lpfc_nodelist *ndlp; |
| 1252 | uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp; |
| 1253 | uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1254 | struct lpfc_vport *vport = cmdiocb->vport; |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1255 | IOCB_t *irsp = &rspiocb->iocb; |
| 1256 | uint32_t latt; |
| 1257 | |
| 1258 | latt = lpfc_els_chk_latt(vport); |
| 1259 | |
| 1260 | lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, |
| 1261 | "FDMI cmpl: status:x%x/x%x latt:%d", |
| 1262 | irsp->ulpStatus, irsp->un.ulpWord[4], latt); |
| 1263 | |
| 1264 | if (latt || irsp->ulpStatus) { |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1265 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1266 | "0229 FDMI cmd %04x failed, latt = %d " |
| 1267 | "ulpStatus: x%x, rid x%x\n", |
| 1268 | be16_to_cpu(fdmi_cmd), latt, irsp->ulpStatus, |
| 1269 | irsp->un.ulpWord[4]); |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1270 | lpfc_ct_free_iocb(phba, cmdiocb); |
| 1271 | return; |
| 1272 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1273 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1274 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1275 | if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { |
| 1276 | /* FDMI rsp failed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1277 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1278 | "0220 FDMI rsp failed Data: x%x\n", |
| 1279 | be16_to_cpu(fdmi_cmd)); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1280 | } |
| 1281 | |
| 1282 | switch (be16_to_cpu(fdmi_cmd)) { |
| 1283 | case SLI_MGMT_RHBA: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1284 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1285 | break; |
| 1286 | |
| 1287 | case SLI_MGMT_RPA: |
| 1288 | break; |
| 1289 | |
| 1290 | case SLI_MGMT_DHBA: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1291 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1292 | break; |
| 1293 | |
| 1294 | case SLI_MGMT_DPRT: |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1295 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1296 | break; |
| 1297 | } |
James Smart | 858c9f6 | 2007-06-17 19:56:39 -0500 | [diff] [blame] | 1298 | lpfc_ct_free_iocb(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1299 | return; |
| 1300 | } |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1301 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1302 | int |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1303 | lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1304 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1305 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1306 | struct lpfc_dmabuf *mp, *bmp; |
| 1307 | struct lpfc_sli_ct_request *CtReq; |
| 1308 | struct ulp_bde64 *bpl; |
| 1309 | uint32_t size; |
| 1310 | REG_HBA *rh; |
| 1311 | PORT_ENTRY *pe; |
| 1312 | REG_PORT_ATTRIBUTE *pab; |
| 1313 | ATTRIBUTE_BLOCK *ab; |
| 1314 | ATTRIBUTE_ENTRY *ae; |
| 1315 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 1316 | struct lpfc_iocbq *); |
| 1317 | |
| 1318 | |
| 1319 | /* fill in BDEs for command */ |
| 1320 | /* Allocate buffer for command payload */ |
| 1321 | mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
| 1322 | if (!mp) |
| 1323 | goto fdmi_cmd_exit; |
| 1324 | |
| 1325 | mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys)); |
| 1326 | if (!mp->virt) |
| 1327 | goto fdmi_cmd_free_mp; |
| 1328 | |
| 1329 | /* Allocate buffer for Buffer ptr list */ |
| 1330 | bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
| 1331 | if (!bmp) |
| 1332 | goto fdmi_cmd_free_mpvirt; |
| 1333 | |
| 1334 | bmp->virt = lpfc_mbuf_alloc(phba, 0, &(bmp->phys)); |
| 1335 | if (!bmp->virt) |
| 1336 | goto fdmi_cmd_free_bmp; |
| 1337 | |
| 1338 | INIT_LIST_HEAD(&mp->list); |
| 1339 | INIT_LIST_HEAD(&bmp->list); |
| 1340 | |
| 1341 | /* FDMI request */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1342 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1343 | "0218 FDMI Request Data: x%x x%x x%x\n", |
| 1344 | vport->fc_flag, vport->port_state, cmdcode); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1345 | CtReq = (struct lpfc_sli_ct_request *) mp->virt; |
| 1346 | |
| 1347 | memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request)); |
| 1348 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; |
| 1349 | CtReq->RevisionId.bits.InId = 0; |
| 1350 | |
| 1351 | CtReq->FsType = SLI_CT_MANAGEMENT_SERVICE; |
| 1352 | CtReq->FsSubType = SLI_CT_FDMI_Subtypes; |
| 1353 | size = 0; |
| 1354 | |
| 1355 | switch (cmdcode) { |
| 1356 | case SLI_MGMT_RHBA: |
| 1357 | { |
| 1358 | lpfc_vpd_t *vp = &phba->vpd; |
| 1359 | uint32_t i, j, incr; |
| 1360 | int len; |
| 1361 | |
| 1362 | CtReq->CommandResponse.bits.CmdRsp = |
| 1363 | be16_to_cpu(SLI_MGMT_RHBA); |
| 1364 | CtReq->CommandResponse.bits.Size = 0; |
| 1365 | rh = (REG_HBA *) & CtReq->un.PortID; |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1366 | memcpy(&rh->hi.PortName, &vport->fc_sparam.portName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1367 | sizeof (struct lpfc_name)); |
| 1368 | /* One entry (port) per adapter */ |
| 1369 | rh->rpl.EntryCnt = be32_to_cpu(1); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1370 | memcpy(&rh->rpl.pe, &vport->fc_sparam.portName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1371 | sizeof (struct lpfc_name)); |
| 1372 | |
| 1373 | /* point to the HBA attribute block */ |
| 1374 | size = 2 * sizeof (struct lpfc_name) + FOURBYTES; |
| 1375 | ab = (ATTRIBUTE_BLOCK *) ((uint8_t *) rh + size); |
| 1376 | ab->EntryCnt = 0; |
| 1377 | |
| 1378 | /* Point to the beginning of the first HBA attribute |
| 1379 | entry */ |
| 1380 | /* #1 HBA attribute entry */ |
| 1381 | size += FOURBYTES; |
| 1382 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1383 | ae->ad.bits.AttrType = be16_to_cpu(NODE_NAME); |
| 1384 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES |
| 1385 | + sizeof (struct lpfc_name)); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1386 | memcpy(&ae->un.NodeName, &vport->fc_sparam.nodeName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1387 | sizeof (struct lpfc_name)); |
| 1388 | ab->EntryCnt++; |
| 1389 | size += FOURBYTES + sizeof (struct lpfc_name); |
| 1390 | |
| 1391 | /* #2 HBA attribute entry */ |
| 1392 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1393 | ae->ad.bits.AttrType = be16_to_cpu(MANUFACTURER); |
| 1394 | strcpy(ae->un.Manufacturer, "Emulex Corporation"); |
| 1395 | len = strlen(ae->un.Manufacturer); |
| 1396 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1397 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1398 | ab->EntryCnt++; |
| 1399 | size += FOURBYTES + len; |
| 1400 | |
| 1401 | /* #3 HBA attribute entry */ |
| 1402 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1403 | ae->ad.bits.AttrType = be16_to_cpu(SERIAL_NUMBER); |
| 1404 | strcpy(ae->un.SerialNumber, phba->SerialNumber); |
| 1405 | len = strlen(ae->un.SerialNumber); |
| 1406 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1407 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1408 | ab->EntryCnt++; |
| 1409 | size += FOURBYTES + len; |
| 1410 | |
| 1411 | /* #4 HBA attribute entry */ |
| 1412 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1413 | ae->ad.bits.AttrType = be16_to_cpu(MODEL); |
| 1414 | strcpy(ae->un.Model, phba->ModelName); |
| 1415 | len = strlen(ae->un.Model); |
| 1416 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1417 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1418 | ab->EntryCnt++; |
| 1419 | size += FOURBYTES + len; |
| 1420 | |
| 1421 | /* #5 HBA attribute entry */ |
| 1422 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1423 | ae->ad.bits.AttrType = be16_to_cpu(MODEL_DESCRIPTION); |
| 1424 | strcpy(ae->un.ModelDescription, phba->ModelDesc); |
| 1425 | len = strlen(ae->un.ModelDescription); |
| 1426 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1427 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1428 | ab->EntryCnt++; |
| 1429 | size += FOURBYTES + len; |
| 1430 | |
| 1431 | /* #6 HBA attribute entry */ |
| 1432 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1433 | ae->ad.bits.AttrType = be16_to_cpu(HARDWARE_VERSION); |
| 1434 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 8); |
| 1435 | /* Convert JEDEC ID to ascii for hardware version */ |
| 1436 | incr = vp->rev.biuRev; |
| 1437 | for (i = 0; i < 8; i++) { |
| 1438 | j = (incr & 0xf); |
| 1439 | if (j <= 9) |
| 1440 | ae->un.HardwareVersion[7 - i] = |
| 1441 | (char)((uint8_t) 0x30 + |
| 1442 | (uint8_t) j); |
| 1443 | else |
| 1444 | ae->un.HardwareVersion[7 - i] = |
| 1445 | (char)((uint8_t) 0x61 + |
| 1446 | (uint8_t) (j - 10)); |
| 1447 | incr = (incr >> 4); |
| 1448 | } |
| 1449 | ab->EntryCnt++; |
| 1450 | size += FOURBYTES + 8; |
| 1451 | |
| 1452 | /* #7 HBA attribute entry */ |
| 1453 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1454 | ae->ad.bits.AttrType = be16_to_cpu(DRIVER_VERSION); |
| 1455 | strcpy(ae->un.DriverVersion, lpfc_release_version); |
| 1456 | len = strlen(ae->un.DriverVersion); |
| 1457 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1458 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1459 | ab->EntryCnt++; |
| 1460 | size += FOURBYTES + len; |
| 1461 | |
| 1462 | /* #8 HBA attribute entry */ |
| 1463 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1464 | ae->ad.bits.AttrType = be16_to_cpu(OPTION_ROM_VERSION); |
| 1465 | strcpy(ae->un.OptionROMVersion, phba->OptionROMVersion); |
| 1466 | len = strlen(ae->un.OptionROMVersion); |
| 1467 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1468 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1469 | ab->EntryCnt++; |
| 1470 | size += FOURBYTES + len; |
| 1471 | |
| 1472 | /* #9 HBA attribute entry */ |
| 1473 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1474 | ae->ad.bits.AttrType = be16_to_cpu(FIRMWARE_VERSION); |
| 1475 | lpfc_decode_firmware_rev(phba, ae->un.FirmwareVersion, |
| 1476 | 1); |
| 1477 | len = strlen(ae->un.FirmwareVersion); |
| 1478 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1479 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1480 | ab->EntryCnt++; |
| 1481 | size += FOURBYTES + len; |
| 1482 | |
| 1483 | /* #10 HBA attribute entry */ |
| 1484 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1485 | ae->ad.bits.AttrType = be16_to_cpu(OS_NAME_VERSION); |
| 1486 | sprintf(ae->un.OsNameVersion, "%s %s %s", |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 1487 | init_utsname()->sysname, |
| 1488 | init_utsname()->release, |
Serge E. Hallyn | 96b644b | 2006-10-02 02:18:13 -0700 | [diff] [blame] | 1489 | init_utsname()->version); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1490 | len = strlen(ae->un.OsNameVersion); |
| 1491 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1492 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1493 | ab->EntryCnt++; |
| 1494 | size += FOURBYTES + len; |
| 1495 | |
| 1496 | /* #11 HBA attribute entry */ |
| 1497 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 1498 | ae->ad.bits.AttrType = be16_to_cpu(MAX_CT_PAYLOAD_LEN); |
| 1499 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
| 1500 | ae->un.MaxCTPayloadLen = (65 * 4096); |
| 1501 | ab->EntryCnt++; |
| 1502 | size += FOURBYTES + 4; |
| 1503 | |
| 1504 | ab->EntryCnt = be32_to_cpu(ab->EntryCnt); |
| 1505 | /* Total size */ |
| 1506 | size = GID_REQUEST_SZ - 4 + size; |
| 1507 | } |
| 1508 | break; |
| 1509 | |
| 1510 | case SLI_MGMT_RPA: |
| 1511 | { |
| 1512 | lpfc_vpd_t *vp; |
| 1513 | struct serv_parm *hsp; |
| 1514 | int len; |
| 1515 | |
| 1516 | vp = &phba->vpd; |
| 1517 | |
| 1518 | CtReq->CommandResponse.bits.CmdRsp = |
| 1519 | be16_to_cpu(SLI_MGMT_RPA); |
| 1520 | CtReq->CommandResponse.bits.Size = 0; |
| 1521 | pab = (REG_PORT_ATTRIBUTE *) & CtReq->un.PortID; |
| 1522 | size = sizeof (struct lpfc_name) + FOURBYTES; |
| 1523 | memcpy((uint8_t *) & pab->PortName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1524 | (uint8_t *) & vport->fc_sparam.portName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1525 | sizeof (struct lpfc_name)); |
| 1526 | pab->ab.EntryCnt = 0; |
| 1527 | |
| 1528 | /* #1 Port attribute entry */ |
| 1529 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1530 | ae->ad.bits.AttrType = be16_to_cpu(SUPPORTED_FC4_TYPES); |
| 1531 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 32); |
| 1532 | ae->un.SupportFC4Types[2] = 1; |
| 1533 | ae->un.SupportFC4Types[7] = 1; |
| 1534 | pab->ab.EntryCnt++; |
| 1535 | size += FOURBYTES + 32; |
| 1536 | |
| 1537 | /* #2 Port attribute entry */ |
| 1538 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1539 | ae->ad.bits.AttrType = be16_to_cpu(SUPPORTED_SPEED); |
| 1540 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 1541 | |
| 1542 | ae->un.SupportSpeed = 0; |
| 1543 | if (phba->lmt & LMT_10Gb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1544 | ae->un.SupportSpeed = HBA_PORTSPEED_10GBIT; |
Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 1545 | if (phba->lmt & LMT_8Gb) |
| 1546 | ae->un.SupportSpeed |= HBA_PORTSPEED_8GBIT; |
| 1547 | if (phba->lmt & LMT_4Gb) |
| 1548 | ae->un.SupportSpeed |= HBA_PORTSPEED_4GBIT; |
| 1549 | if (phba->lmt & LMT_2Gb) |
| 1550 | ae->un.SupportSpeed |= HBA_PORTSPEED_2GBIT; |
| 1551 | if (phba->lmt & LMT_1Gb) |
| 1552 | ae->un.SupportSpeed |= HBA_PORTSPEED_1GBIT; |
| 1553 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1554 | pab->ab.EntryCnt++; |
| 1555 | size += FOURBYTES + 4; |
| 1556 | |
| 1557 | /* #3 Port attribute entry */ |
| 1558 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1559 | ae->ad.bits.AttrType = be16_to_cpu(PORT_SPEED); |
| 1560 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
| 1561 | switch(phba->fc_linkspeed) { |
| 1562 | case LA_1GHZ_LINK: |
| 1563 | ae->un.PortSpeed = HBA_PORTSPEED_1GBIT; |
| 1564 | break; |
| 1565 | case LA_2GHZ_LINK: |
| 1566 | ae->un.PortSpeed = HBA_PORTSPEED_2GBIT; |
| 1567 | break; |
| 1568 | case LA_4GHZ_LINK: |
| 1569 | ae->un.PortSpeed = HBA_PORTSPEED_4GBIT; |
| 1570 | break; |
James Smart | b87eab3 | 2007-04-25 09:53:28 -0400 | [diff] [blame] | 1571 | case LA_8GHZ_LINK: |
| 1572 | ae->un.PortSpeed = HBA_PORTSPEED_8GBIT; |
| 1573 | break; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1574 | default: |
| 1575 | ae->un.PortSpeed = |
| 1576 | HBA_PORTSPEED_UNKNOWN; |
| 1577 | break; |
| 1578 | } |
| 1579 | pab->ab.EntryCnt++; |
| 1580 | size += FOURBYTES + 4; |
| 1581 | |
| 1582 | /* #4 Port attribute entry */ |
| 1583 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1584 | ae->ad.bits.AttrType = be16_to_cpu(MAX_FRAME_SIZE); |
| 1585 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1586 | hsp = (struct serv_parm *) & vport->fc_sparam; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1587 | ae->un.MaxFrameSize = |
| 1588 | (((uint32_t) hsp->cmn. |
| 1589 | bbRcvSizeMsb) << 8) | (uint32_t) hsp->cmn. |
| 1590 | bbRcvSizeLsb; |
| 1591 | pab->ab.EntryCnt++; |
| 1592 | size += FOURBYTES + 4; |
| 1593 | |
| 1594 | /* #5 Port attribute entry */ |
| 1595 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1596 | ae->ad.bits.AttrType = be16_to_cpu(OS_DEVICE_NAME); |
| 1597 | strcpy((char *)ae->un.OsDeviceName, LPFC_DRIVER_NAME); |
| 1598 | len = strlen((char *)ae->un.OsDeviceName); |
| 1599 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1600 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1601 | pab->ab.EntryCnt++; |
| 1602 | size += FOURBYTES + len; |
| 1603 | |
James Smart | 3de2a65 | 2007-08-02 11:09:59 -0400 | [diff] [blame] | 1604 | if (vport->cfg_fdmi_on == 2) { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1605 | /* #6 Port attribute entry */ |
| 1606 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + |
| 1607 | size); |
| 1608 | ae->ad.bits.AttrType = be16_to_cpu(HOST_NAME); |
| 1609 | sprintf(ae->un.HostName, "%s", |
Serge E. Hallyn | 96b644b | 2006-10-02 02:18:13 -0700 | [diff] [blame] | 1610 | init_utsname()->nodename); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1611 | len = strlen(ae->un.HostName); |
| 1612 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1613 | ae->ad.bits.AttrLen = |
| 1614 | be16_to_cpu(FOURBYTES + len); |
| 1615 | pab->ab.EntryCnt++; |
| 1616 | size += FOURBYTES + len; |
| 1617 | } |
| 1618 | |
| 1619 | pab->ab.EntryCnt = be32_to_cpu(pab->ab.EntryCnt); |
| 1620 | /* Total size */ |
| 1621 | size = GID_REQUEST_SZ - 4 + size; |
| 1622 | } |
| 1623 | break; |
| 1624 | |
| 1625 | case SLI_MGMT_DHBA: |
| 1626 | CtReq->CommandResponse.bits.CmdRsp = be16_to_cpu(SLI_MGMT_DHBA); |
| 1627 | CtReq->CommandResponse.bits.Size = 0; |
| 1628 | pe = (PORT_ENTRY *) & CtReq->un.PortID; |
| 1629 | memcpy((uint8_t *) & pe->PortName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1630 | (uint8_t *) & vport->fc_sparam.portName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1631 | sizeof (struct lpfc_name)); |
| 1632 | size = GID_REQUEST_SZ - 4 + sizeof (struct lpfc_name); |
| 1633 | break; |
| 1634 | |
| 1635 | case SLI_MGMT_DPRT: |
| 1636 | CtReq->CommandResponse.bits.CmdRsp = be16_to_cpu(SLI_MGMT_DPRT); |
| 1637 | CtReq->CommandResponse.bits.Size = 0; |
| 1638 | pe = (PORT_ENTRY *) & CtReq->un.PortID; |
| 1639 | memcpy((uint8_t *) & pe->PortName, |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1640 | (uint8_t *) & vport->fc_sparam.portName, |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1641 | sizeof (struct lpfc_name)); |
| 1642 | size = GID_REQUEST_SZ - 4 + sizeof (struct lpfc_name); |
| 1643 | break; |
| 1644 | } |
| 1645 | |
| 1646 | bpl = (struct ulp_bde64 *) bmp->virt; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1647 | bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) ); |
| 1648 | bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) ); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1649 | bpl->tus.f.bdeFlags = 0; |
| 1650 | bpl->tus.f.bdeSize = size; |
| 1651 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 1652 | |
| 1653 | cmpl = lpfc_cmpl_ct_cmd_fdmi; |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1654 | lpfc_nlp_get(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1655 | |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1656 | if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, FC_MAX_NS_RSP, 0)) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1657 | return 0; |
| 1658 | |
James Smart | 51ef4c2 | 2007-08-02 11:10:31 -0400 | [diff] [blame] | 1659 | lpfc_nlp_put(ndlp); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1660 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 1661 | fdmi_cmd_free_bmp: |
| 1662 | kfree(bmp); |
| 1663 | fdmi_cmd_free_mpvirt: |
| 1664 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 1665 | fdmi_cmd_free_mp: |
| 1666 | kfree(mp); |
| 1667 | fdmi_cmd_exit: |
| 1668 | /* Issue FDMI request failed */ |
James Smart | e8b6201 | 2007-08-02 11:10:09 -0400 | [diff] [blame] | 1669 | lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, |
| 1670 | "0244 Issue FDMI request failed Data: x%x\n", |
| 1671 | cmdcode); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1672 | return 1; |
| 1673 | } |
| 1674 | |
| 1675 | void |
| 1676 | lpfc_fdmi_tmo(unsigned long ptr) |
| 1677 | { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1678 | struct lpfc_vport *vport = (struct lpfc_vport *)ptr; |
| 1679 | struct lpfc_hba *phba = vport->phba; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1680 | unsigned long iflag; |
| 1681 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1682 | spin_lock_irqsave(&vport->work_port_lock, iflag); |
| 1683 | if (!(vport->work_port_events & WORKER_FDMI_TMO)) { |
| 1684 | vport->work_port_events |= WORKER_FDMI_TMO; |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1685 | spin_unlock_irqrestore(&vport->work_port_lock, iflag); |
| 1686 | |
| 1687 | spin_lock_irqsave(&phba->hbalock, iflag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1688 | if (phba->work_wait) |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1689 | lpfc_worker_wake_up(phba); |
| 1690 | spin_unlock_irqrestore(&phba->hbalock, iflag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1691 | } |
James Smart | 92d7f7b | 2007-06-17 19:56:38 -0500 | [diff] [blame] | 1692 | else |
| 1693 | spin_unlock_irqrestore(&vport->work_port_lock, iflag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1694 | } |
| 1695 | |
| 1696 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1697 | lpfc_fdmi_timeout_handler(struct lpfc_vport *vport) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1698 | { |
| 1699 | struct lpfc_nodelist *ndlp; |
| 1700 | |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1701 | ndlp = lpfc_findnode_did(vport, FDMI_DID); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1702 | if (ndlp) { |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1703 | if (init_utsname()->nodename[0] != '\0') |
| 1704 | lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA); |
| 1705 | else |
| 1706 | mod_timer(&vport->fc_fdmitmo, jiffies + HZ * 60); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1707 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1708 | return; |
| 1709 | } |
| 1710 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1711 | void |
James Smart | 2e0fef8 | 2007-06-17 19:56:36 -0500 | [diff] [blame] | 1712 | lpfc_decode_firmware_rev(struct lpfc_hba *phba, char *fwrevision, int flag) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1713 | { |
| 1714 | struct lpfc_sli *psli = &phba->sli; |
| 1715 | lpfc_vpd_t *vp = &phba->vpd; |
| 1716 | uint32_t b1, b2, b3, b4, i, rev; |
| 1717 | char c; |
| 1718 | uint32_t *ptr, str[4]; |
| 1719 | uint8_t *fwname; |
| 1720 | |
| 1721 | if (vp->rev.rBit) { |
| 1722 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) |
| 1723 | rev = vp->rev.sli2FwRev; |
| 1724 | else |
| 1725 | rev = vp->rev.sli1FwRev; |
| 1726 | |
| 1727 | b1 = (rev & 0x0000f000) >> 12; |
| 1728 | b2 = (rev & 0x00000f00) >> 8; |
| 1729 | b3 = (rev & 0x000000c0) >> 6; |
| 1730 | b4 = (rev & 0x00000030) >> 4; |
| 1731 | |
| 1732 | switch (b4) { |
| 1733 | case 0: |
| 1734 | c = 'N'; |
| 1735 | break; |
| 1736 | case 1: |
| 1737 | c = 'A'; |
| 1738 | break; |
| 1739 | case 2: |
| 1740 | c = 'B'; |
| 1741 | break; |
| 1742 | default: |
| 1743 | c = 0; |
| 1744 | break; |
| 1745 | } |
| 1746 | b4 = (rev & 0x0000000f); |
| 1747 | |
| 1748 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) |
| 1749 | fwname = vp->rev.sli2FwName; |
| 1750 | else |
| 1751 | fwname = vp->rev.sli1FwName; |
| 1752 | |
| 1753 | for (i = 0; i < 16; i++) |
| 1754 | if (fwname[i] == 0x20) |
| 1755 | fwname[i] = 0; |
| 1756 | |
| 1757 | ptr = (uint32_t*)fwname; |
| 1758 | |
| 1759 | for (i = 0; i < 3; i++) |
| 1760 | str[i] = be32_to_cpu(*ptr++); |
| 1761 | |
| 1762 | if (c == 0) { |
| 1763 | if (flag) |
| 1764 | sprintf(fwrevision, "%d.%d%d (%s)", |
| 1765 | b1, b2, b3, (char *)str); |
| 1766 | else |
| 1767 | sprintf(fwrevision, "%d.%d%d", b1, |
| 1768 | b2, b3); |
| 1769 | } else { |
| 1770 | if (flag) |
| 1771 | sprintf(fwrevision, "%d.%d%d%c%d (%s)", |
| 1772 | b1, b2, b3, c, |
| 1773 | b4, (char *)str); |
| 1774 | else |
| 1775 | sprintf(fwrevision, "%d.%d%d%c%d", |
| 1776 | b1, b2, b3, c, b4); |
| 1777 | } |
| 1778 | } else { |
| 1779 | rev = vp->rev.smFwRev; |
| 1780 | |
| 1781 | b1 = (rev & 0xff000000) >> 24; |
| 1782 | b2 = (rev & 0x00f00000) >> 20; |
| 1783 | b3 = (rev & 0x000f0000) >> 16; |
| 1784 | c = (rev & 0x0000ff00) >> 8; |
| 1785 | b4 = (rev & 0x000000ff); |
| 1786 | |
| 1787 | if (flag) |
| 1788 | sprintf(fwrevision, "%d.%d%d%c%d ", b1, |
| 1789 | b2, b3, c, b4); |
| 1790 | else |
| 1791 | sprintf(fwrevision, "%d.%d%d%c%d ", b1, |
| 1792 | b2, b3, c, b4); |
| 1793 | } |
| 1794 | return; |
| 1795 | } |