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