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