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