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