| 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. * |
Jamie Wellnitz | 2fe165b | 2006-02-28 19:25:31 -0500 | [diff] [blame] | 4 | * Copyright (C) 2004-2006 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 | /* |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 22 | * Fibre Channel SCSI LAN Device Driver CT support |
| 23 | */ |
| 24 | |
| 25 | #include <linux/blkdev.h> |
| 26 | #include <linux/pci.h> |
| 27 | #include <linux/interrupt.h> |
| 28 | #include <linux/utsname.h> |
| 29 | |
James.Smart@Emulex.Com | 9188652 | 2005-08-10 15:03:09 -0400 | [diff] [blame] | 30 | #include <scsi/scsi.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 31 | #include <scsi/scsi_device.h> |
| 32 | #include <scsi/scsi_host.h> |
James.Smart@Emulex.Com | f888ba3 | 2005-08-10 15:03:01 -0400 | [diff] [blame] | 33 | #include <scsi/scsi_transport_fc.h> |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 34 | |
| 35 | #include "lpfc_hw.h" |
| 36 | #include "lpfc_sli.h" |
| 37 | #include "lpfc_disc.h" |
| 38 | #include "lpfc_scsi.h" |
| 39 | #include "lpfc.h" |
| 40 | #include "lpfc_logmsg.h" |
| 41 | #include "lpfc_crtn.h" |
| 42 | #include "lpfc_version.h" |
| 43 | |
| 44 | #define HBA_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver |
| 45 | * incapable of reporting */ |
| 46 | #define HBA_PORTSPEED_1GBIT 1 /* 1 GBit/sec */ |
| 47 | #define HBA_PORTSPEED_2GBIT 2 /* 2 GBit/sec */ |
| 48 | #define HBA_PORTSPEED_4GBIT 8 /* 4 GBit/sec */ |
| 49 | #define HBA_PORTSPEED_8GBIT 16 /* 8 GBit/sec */ |
| 50 | #define HBA_PORTSPEED_10GBIT 4 /* 10 GBit/sec */ |
| 51 | #define HBA_PORTSPEED_NOT_NEGOTIATED 5 /* Speed not established */ |
| 52 | |
| 53 | #define FOURBYTES 4 |
| 54 | |
| 55 | |
| 56 | static char *lpfc_release_version = LPFC_DRIVER_VERSION; |
| 57 | |
| 58 | /* |
| 59 | * lpfc_ct_unsol_event |
| 60 | */ |
| 61 | void |
| 62 | lpfc_ct_unsol_event(struct lpfc_hba * phba, |
| 63 | struct lpfc_sli_ring * pring, struct lpfc_iocbq * piocbq) |
| 64 | { |
| 65 | |
| 66 | struct lpfc_iocbq *next_piocbq; |
| 67 | struct lpfc_dmabuf *pmbuf = NULL; |
| 68 | struct lpfc_dmabuf *matp, *next_matp; |
| 69 | uint32_t ctx = 0, size = 0, cnt = 0; |
| 70 | IOCB_t *icmd = &piocbq->iocb; |
| 71 | IOCB_t *save_icmd = icmd; |
| 72 | int i, go_exit = 0; |
| 73 | struct list_head head; |
| 74 | |
| 75 | if ((icmd->ulpStatus == IOSTAT_LOCAL_REJECT) && |
| 76 | ((icmd->un.ulpWord[4] & 0xff) == IOERR_RCV_BUFFER_WAITING)) { |
| 77 | /* Not enough posted buffers; Try posting more buffers */ |
| 78 | phba->fc_stat.NoRcvBuf++; |
| 79 | lpfc_post_buffer(phba, pring, 0, 1); |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | /* If there are no BDEs associated with this IOCB, |
| 84 | * there is nothing to do. |
| 85 | */ |
| 86 | if (icmd->ulpBdeCount == 0) |
| 87 | return; |
| 88 | |
| 89 | INIT_LIST_HEAD(&head); |
| 90 | list_add_tail(&head, &piocbq->list); |
| 91 | |
| 92 | list_for_each_entry_safe(piocbq, next_piocbq, &head, list) { |
| 93 | icmd = &piocbq->iocb; |
| 94 | if (ctx == 0) |
| 95 | ctx = (uint32_t) (icmd->ulpContext); |
| 96 | if (icmd->ulpBdeCount == 0) |
| 97 | continue; |
| 98 | |
| 99 | for (i = 0; i < icmd->ulpBdeCount; i++) { |
| 100 | matp = lpfc_sli_ringpostbuf_get(phba, pring, |
| 101 | getPaddr(icmd->un. |
| 102 | cont64[i]. |
| 103 | addrHigh, |
| 104 | icmd->un. |
| 105 | cont64[i]. |
| 106 | addrLow)); |
| 107 | if (!matp) { |
| 108 | /* Insert lpfc log message here */ |
| 109 | lpfc_post_buffer(phba, pring, cnt, 1); |
| 110 | go_exit = 1; |
| 111 | goto ct_unsol_event_exit_piocbq; |
| 112 | } |
| 113 | |
| 114 | /* Typically for Unsolicited CT requests */ |
| 115 | if (!pmbuf) { |
| 116 | pmbuf = matp; |
| 117 | INIT_LIST_HEAD(&pmbuf->list); |
| 118 | } else |
| 119 | list_add_tail(&matp->list, &pmbuf->list); |
| 120 | |
| 121 | size += icmd->un.cont64[i].tus.f.bdeSize; |
| 122 | cnt++; |
| 123 | } |
| 124 | |
| 125 | icmd->ulpBdeCount = 0; |
| 126 | } |
| 127 | |
| 128 | lpfc_post_buffer(phba, pring, cnt, 1); |
| 129 | if (save_icmd->ulpStatus) { |
| 130 | go_exit = 1; |
| 131 | } |
| 132 | |
| 133 | ct_unsol_event_exit_piocbq: |
James Smart | 8f6d98d | 2006-08-01 07:34:00 -0400 | [diff] [blame] | 134 | list_del(&head); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 135 | if (pmbuf) { |
| 136 | list_for_each_entry_safe(matp, next_matp, &pmbuf->list, list) { |
| 137 | lpfc_mbuf_free(phba, matp->virt, matp->phys); |
| 138 | list_del(&matp->list); |
| 139 | kfree(matp); |
| 140 | } |
| 141 | lpfc_mbuf_free(phba, pmbuf->virt, pmbuf->phys); |
| 142 | kfree(pmbuf); |
| 143 | } |
| 144 | return; |
| 145 | } |
| 146 | |
| 147 | static void |
| 148 | lpfc_free_ct_rsp(struct lpfc_hba * phba, struct lpfc_dmabuf * mlist) |
| 149 | { |
| 150 | struct lpfc_dmabuf *mlast, *next_mlast; |
| 151 | |
| 152 | list_for_each_entry_safe(mlast, next_mlast, &mlist->list, list) { |
| 153 | lpfc_mbuf_free(phba, mlast->virt, mlast->phys); |
| 154 | list_del(&mlast->list); |
| 155 | kfree(mlast); |
| 156 | } |
| 157 | lpfc_mbuf_free(phba, mlist->virt, mlist->phys); |
| 158 | kfree(mlist); |
| 159 | return; |
| 160 | } |
| 161 | |
| 162 | static struct lpfc_dmabuf * |
| 163 | lpfc_alloc_ct_rsp(struct lpfc_hba * phba, int cmdcode, struct ulp_bde64 * bpl, |
| 164 | uint32_t size, int *entries) |
| 165 | { |
| 166 | struct lpfc_dmabuf *mlist = NULL; |
| 167 | struct lpfc_dmabuf *mp; |
| 168 | int cnt, i = 0; |
| 169 | |
| 170 | /* We get chucks of FCELSSIZE */ |
| 171 | cnt = size > FCELSSIZE ? FCELSSIZE: size; |
| 172 | |
| 173 | while (size) { |
| 174 | /* Allocate buffer for rsp payload */ |
| 175 | mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
| 176 | if (!mp) { |
| 177 | if (mlist) |
| 178 | lpfc_free_ct_rsp(phba, mlist); |
| 179 | return NULL; |
| 180 | } |
| 181 | |
| 182 | INIT_LIST_HEAD(&mp->list); |
| 183 | |
| 184 | if (cmdcode == be16_to_cpu(SLI_CTNS_GID_FT)) |
| 185 | mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); |
| 186 | else |
| 187 | mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys)); |
| 188 | |
| 189 | if (!mp->virt) { |
| 190 | kfree(mp); |
Eric Sesterhenn | 0b3a82d | 2006-10-10 14:41:43 -0700 | [diff] [blame] | 191 | if (mlist) |
| 192 | lpfc_free_ct_rsp(phba, mlist); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 193 | return NULL; |
| 194 | } |
| 195 | |
| 196 | /* Queue it to a linked list */ |
| 197 | if (!mlist) |
| 198 | mlist = mp; |
| 199 | else |
| 200 | list_add_tail(&mp->list, &mlist->list); |
| 201 | |
| 202 | bpl->tus.f.bdeFlags = BUFF_USE_RCV; |
| 203 | /* build buffer ptr list for IOCB */ |
| 204 | bpl->addrLow = le32_to_cpu( putPaddrLow(mp->phys) ); |
| 205 | bpl->addrHigh = le32_to_cpu( putPaddrHigh(mp->phys) ); |
| 206 | bpl->tus.f.bdeSize = (uint16_t) cnt; |
| 207 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 208 | bpl++; |
| 209 | |
| 210 | i++; |
| 211 | size -= cnt; |
| 212 | } |
| 213 | |
| 214 | *entries = i; |
| 215 | return mlist; |
| 216 | } |
| 217 | |
| 218 | static int |
| 219 | lpfc_gen_req(struct lpfc_hba *phba, struct lpfc_dmabuf *bmp, |
| 220 | struct lpfc_dmabuf *inp, struct lpfc_dmabuf *outp, |
| 221 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 222 | struct lpfc_iocbq *), |
| 223 | struct lpfc_nodelist *ndlp, uint32_t usr_flg, uint32_t num_entry, |
| 224 | uint32_t tmo) |
| 225 | { |
| 226 | |
| 227 | struct lpfc_sli *psli = &phba->sli; |
| 228 | struct lpfc_sli_ring *pring = &psli->ring[LPFC_ELS_RING]; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 229 | IOCB_t *icmd; |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 230 | struct lpfc_iocbq *geniocb; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 231 | |
| 232 | /* Allocate buffer for command iocb */ |
| 233 | spin_lock_irq(phba->host->host_lock); |
James.Smart@Emulex.Com | 0bd4ca2 | 2005-10-28 20:30:02 -0400 | [diff] [blame] | 234 | geniocb = lpfc_sli_get_iocbq(phba); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 235 | spin_unlock_irq(phba->host->host_lock); |
| 236 | |
| 237 | if (geniocb == NULL) |
| 238 | return 1; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 239 | |
| 240 | icmd = &geniocb->iocb; |
| 241 | icmd->un.genreq64.bdl.ulpIoTag32 = 0; |
| 242 | icmd->un.genreq64.bdl.addrHigh = putPaddrHigh(bmp->phys); |
| 243 | icmd->un.genreq64.bdl.addrLow = putPaddrLow(bmp->phys); |
| 244 | icmd->un.genreq64.bdl.bdeFlags = BUFF_TYPE_BDL; |
| 245 | icmd->un.genreq64.bdl.bdeSize = (num_entry * sizeof (struct ulp_bde64)); |
| 246 | |
| 247 | if (usr_flg) |
| 248 | geniocb->context3 = NULL; |
| 249 | else |
| 250 | geniocb->context3 = (uint8_t *) bmp; |
| 251 | |
| 252 | /* Save for completion so we can release these resources */ |
| 253 | geniocb->context1 = (uint8_t *) inp; |
| 254 | geniocb->context2 = (uint8_t *) outp; |
| 255 | |
| 256 | /* Fill in payload, bp points to frame payload */ |
| 257 | icmd->ulpCommand = CMD_GEN_REQUEST64_CR; |
| 258 | |
| 259 | /* Fill in rest of iocb */ |
| 260 | icmd->un.genreq64.w5.hcsw.Fctl = (SI | LA); |
| 261 | icmd->un.genreq64.w5.hcsw.Dfctl = 0; |
| 262 | icmd->un.genreq64.w5.hcsw.Rctl = FC_UNSOL_CTL; |
| 263 | icmd->un.genreq64.w5.hcsw.Type = FC_COMMON_TRANSPORT_ULP; |
| 264 | |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 265 | if (!tmo) { |
| 266 | /* FC spec states we need 3 * ratov for CT requests */ |
| 267 | tmo = (3 * phba->fc_ratov); |
| 268 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 269 | icmd->ulpTimeout = tmo; |
| 270 | icmd->ulpBdeCount = 1; |
| 271 | icmd->ulpLe = 1; |
| 272 | icmd->ulpClass = CLASS3; |
| 273 | icmd->ulpContext = ndlp->nlp_rpi; |
| 274 | |
| 275 | /* Issue GEN REQ IOCB for NPORT <did> */ |
| 276 | lpfc_printf_log(phba, KERN_INFO, LOG_ELS, |
| 277 | "%d:0119 Issue GEN REQ IOCB for NPORT x%x " |
| 278 | "Data: x%x x%x\n", phba->brd_no, icmd->un.ulpWord[5], |
| 279 | icmd->ulpIoTag, phba->hba_state); |
| 280 | geniocb->iocb_cmpl = cmpl; |
| 281 | geniocb->drvrTimeout = icmd->ulpTimeout + LPFC_DRVR_TIMEOUT; |
| 282 | spin_lock_irq(phba->host->host_lock); |
| 283 | if (lpfc_sli_issue_iocb(phba, pring, geniocb, 0) == IOCB_ERROR) { |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 284 | lpfc_sli_release_iocbq(phba, geniocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 285 | spin_unlock_irq(phba->host->host_lock); |
| 286 | return 1; |
| 287 | } |
| 288 | spin_unlock_irq(phba->host->host_lock); |
| 289 | |
| 290 | return 0; |
| 291 | } |
| 292 | |
| 293 | static int |
| 294 | lpfc_ct_cmd(struct lpfc_hba *phba, struct lpfc_dmabuf *inmp, |
| 295 | struct lpfc_dmabuf *bmp, struct lpfc_nodelist *ndlp, |
| 296 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 297 | struct lpfc_iocbq *), |
| 298 | uint32_t rsp_size) |
| 299 | { |
| 300 | struct ulp_bde64 *bpl = (struct ulp_bde64 *) bmp->virt; |
| 301 | struct lpfc_dmabuf *outmp; |
| 302 | int cnt = 0, status; |
| 303 | int cmdcode = ((struct lpfc_sli_ct_request *) inmp->virt)-> |
| 304 | CommandResponse.bits.CmdRsp; |
| 305 | |
| 306 | bpl++; /* Skip past ct request */ |
| 307 | |
| 308 | /* Put buffer(s) for ct rsp in bpl */ |
| 309 | outmp = lpfc_alloc_ct_rsp(phba, cmdcode, bpl, rsp_size, &cnt); |
| 310 | if (!outmp) |
| 311 | return -ENOMEM; |
| 312 | |
| 313 | status = lpfc_gen_req(phba, bmp, inmp, outmp, cmpl, ndlp, 0, |
| 314 | cnt+1, 0); |
| 315 | if (status) { |
| 316 | lpfc_free_ct_rsp(phba, outmp); |
| 317 | return -ENOMEM; |
| 318 | } |
| 319 | return 0; |
| 320 | } |
| 321 | |
| 322 | static int |
| 323 | lpfc_ns_rsp(struct lpfc_hba * phba, struct lpfc_dmabuf * mp, uint32_t Size) |
| 324 | { |
| 325 | struct lpfc_sli_ct_request *Response = |
| 326 | (struct lpfc_sli_ct_request *) mp->virt; |
| 327 | struct lpfc_nodelist *ndlp = NULL; |
| 328 | struct lpfc_dmabuf *mlast, *next_mp; |
| 329 | uint32_t *ctptr = (uint32_t *) & Response->un.gid.PortType; |
| 330 | uint32_t Did; |
| 331 | uint32_t CTentry; |
| 332 | int Cnt; |
| 333 | struct list_head head; |
| 334 | |
| 335 | lpfc_set_disctmo(phba); |
| 336 | |
| 337 | Cnt = Size > FCELSSIZE ? FCELSSIZE : Size; |
| 338 | |
| 339 | list_add_tail(&head, &mp->list); |
| 340 | list_for_each_entry_safe(mp, next_mp, &head, list) { |
| 341 | mlast = mp; |
| 342 | |
| 343 | Size -= Cnt; |
| 344 | |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame^] | 345 | if (!ctptr) { |
| 346 | Cnt = FCELSSIZE; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 347 | ctptr = (uint32_t *) mlast->virt; |
James Smart | 1dcb58e | 2007-04-25 09:51:30 -0400 | [diff] [blame^] | 348 | } else |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 349 | Cnt -= 16; /* subtract length of CT header */ |
| 350 | |
| 351 | /* Loop through entire NameServer list of DIDs */ |
| 352 | while (Cnt) { |
| 353 | |
| 354 | /* Get next DID from NameServer List */ |
| 355 | CTentry = *ctptr++; |
| 356 | Did = ((be32_to_cpu(CTentry)) & Mask_DID); |
| 357 | |
| 358 | ndlp = NULL; |
| 359 | if (Did != phba->fc_myDID) { |
| 360 | /* Check for rscn processing or not */ |
| 361 | ndlp = lpfc_setup_disc_node(phba, Did); |
| 362 | } |
| 363 | /* Mark all node table entries that are in the |
| 364 | Nameserver */ |
| 365 | if (ndlp) { |
| 366 | /* NameServer Rsp */ |
| 367 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, |
| 368 | "%d:0238 Process x%x NameServer" |
| 369 | " Rsp Data: x%x x%x x%x\n", |
| 370 | phba->brd_no, |
| 371 | Did, ndlp->nlp_flag, |
| 372 | phba->fc_flag, |
| 373 | phba->fc_rscn_id_cnt); |
| 374 | } else { |
| 375 | /* NameServer Rsp */ |
| 376 | lpfc_printf_log(phba, |
| 377 | KERN_INFO, |
| 378 | LOG_DISCOVERY, |
| 379 | "%d:0239 Skip x%x NameServer " |
| 380 | "Rsp Data: x%x x%x x%x\n", |
| 381 | phba->brd_no, |
| 382 | Did, Size, phba->fc_flag, |
| 383 | phba->fc_rscn_id_cnt); |
| 384 | } |
| 385 | |
| 386 | if (CTentry & (be32_to_cpu(SLI_CT_LAST_ENTRY))) |
| 387 | goto nsout1; |
| 388 | Cnt -= sizeof (uint32_t); |
| 389 | } |
| 390 | ctptr = NULL; |
| 391 | |
| 392 | } |
| 393 | |
| 394 | nsout1: |
| 395 | list_del(&head); |
| 396 | |
Jamie Wellnitz | 50eba24 | 2006-02-28 19:25:38 -0500 | [diff] [blame] | 397 | /* |
| 398 | * The driver has cycled through all Nports in the RSCN payload. |
| 399 | * Complete the handling by cleaning up and marking the |
| 400 | * current driver state. |
| 401 | */ |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 402 | if (phba->hba_state == LPFC_HBA_READY) { |
| 403 | lpfc_els_flush_rscn(phba); |
| 404 | spin_lock_irq(phba->host->host_lock); |
| 405 | phba->fc_flag |= FC_RSCN_MODE; /* we are still in RSCN mode */ |
| 406 | spin_unlock_irq(phba->host->host_lock); |
| 407 | } |
| 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | static void |
| 415 | lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, |
| 416 | struct lpfc_iocbq * rspiocb) |
| 417 | { |
| 418 | IOCB_t *irsp; |
| 419 | struct lpfc_sli *psli; |
| 420 | struct lpfc_dmabuf *bmp; |
| 421 | struct lpfc_dmabuf *inp; |
| 422 | struct lpfc_dmabuf *outp; |
| 423 | struct lpfc_nodelist *ndlp; |
| 424 | struct lpfc_sli_ct_request *CTrsp; |
| 425 | |
| 426 | psli = &phba->sli; |
| 427 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 428 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 429 | |
| 430 | inp = (struct lpfc_dmabuf *) cmdiocb->context1; |
| 431 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 432 | bmp = (struct lpfc_dmabuf *) cmdiocb->context3; |
| 433 | |
| 434 | irsp = &rspiocb->iocb; |
| 435 | if (irsp->ulpStatus) { |
| 436 | if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && |
| 437 | ((irsp->un.ulpWord[4] == IOERR_SLI_DOWN) || |
| 438 | (irsp->un.ulpWord[4] == IOERR_SLI_ABORTED))) { |
| 439 | goto out; |
| 440 | } |
| 441 | |
| 442 | /* Check for retry */ |
| 443 | if (phba->fc_ns_retry < LPFC_MAX_NS_RETRY) { |
| 444 | phba->fc_ns_retry++; |
| 445 | /* CT command is being retried */ |
| 446 | ndlp = |
| 447 | lpfc_findnode_did(phba, NLP_SEARCH_UNMAPPED, |
| 448 | NameServer_DID); |
| 449 | if (ndlp) { |
| 450 | if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT) == |
| 451 | 0) { |
| 452 | goto out; |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | } else { |
| 457 | /* Good status, continue checking */ |
| 458 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 459 | if (CTrsp->CommandResponse.bits.CmdRsp == |
| 460 | be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 461 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, |
James Smart | dca9479 | 2006-08-01 07:34:08 -0400 | [diff] [blame] | 462 | "%d:0208 NameServer Rsp " |
Jamie Wellnitz | c9f8735 | 2006-02-28 19:25:23 -0500 | [diff] [blame] | 463 | "Data: x%x\n", |
| 464 | phba->brd_no, |
| 465 | phba->fc_flag); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 466 | lpfc_ns_rsp(phba, outp, |
| 467 | (uint32_t) (irsp->un.genreq64.bdl.bdeSize)); |
| 468 | } else if (CTrsp->CommandResponse.bits.CmdRsp == |
| 469 | be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { |
| 470 | /* NameServer Rsp Error */ |
| 471 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, |
| 472 | "%d:0240 NameServer Rsp Error " |
| 473 | "Data: x%x x%x x%x x%x\n", |
| 474 | phba->brd_no, |
| 475 | CTrsp->CommandResponse.bits.CmdRsp, |
| 476 | (uint32_t) CTrsp->ReasonCode, |
| 477 | (uint32_t) CTrsp->Explanation, |
| 478 | phba->fc_flag); |
| 479 | } else { |
| 480 | /* NameServer Rsp Error */ |
| 481 | lpfc_printf_log(phba, |
| 482 | KERN_INFO, |
| 483 | LOG_DISCOVERY, |
| 484 | "%d:0241 NameServer Rsp Error " |
| 485 | "Data: x%x x%x x%x x%x\n", |
| 486 | phba->brd_no, |
| 487 | CTrsp->CommandResponse.bits.CmdRsp, |
| 488 | (uint32_t) CTrsp->ReasonCode, |
| 489 | (uint32_t) CTrsp->Explanation, |
| 490 | phba->fc_flag); |
| 491 | } |
| 492 | } |
| 493 | /* Link up / RSCN discovery */ |
| 494 | lpfc_disc_start(phba); |
| 495 | out: |
| 496 | lpfc_free_ct_rsp(phba, outp); |
| 497 | lpfc_mbuf_free(phba, inp->virt, inp->phys); |
| 498 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 499 | kfree(inp); |
| 500 | kfree(bmp); |
| 501 | spin_lock_irq(phba->host->host_lock); |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 502 | lpfc_sli_release_iocbq(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 503 | spin_unlock_irq(phba->host->host_lock); |
| 504 | return; |
| 505 | } |
| 506 | |
| 507 | static void |
| 508 | lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, |
| 509 | struct lpfc_iocbq * rspiocb) |
| 510 | { |
| 511 | struct lpfc_sli *psli; |
| 512 | struct lpfc_dmabuf *bmp; |
| 513 | struct lpfc_dmabuf *inp; |
| 514 | struct lpfc_dmabuf *outp; |
| 515 | IOCB_t *irsp; |
| 516 | struct lpfc_sli_ct_request *CTrsp; |
| 517 | |
| 518 | psli = &phba->sli; |
| 519 | /* we pass cmdiocb to state machine which needs rspiocb as well */ |
| 520 | cmdiocb->context_un.rsp_iocb = rspiocb; |
| 521 | |
| 522 | inp = (struct lpfc_dmabuf *) cmdiocb->context1; |
| 523 | outp = (struct lpfc_dmabuf *) cmdiocb->context2; |
| 524 | bmp = (struct lpfc_dmabuf *) cmdiocb->context3; |
| 525 | irsp = &rspiocb->iocb; |
| 526 | |
| 527 | CTrsp = (struct lpfc_sli_ct_request *) outp->virt; |
| 528 | |
| 529 | /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */ |
| 530 | lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, |
| 531 | "%d:0209 RFT request completes ulpStatus x%x " |
| 532 | "CmdRsp x%x\n", phba->brd_no, irsp->ulpStatus, |
| 533 | CTrsp->CommandResponse.bits.CmdRsp); |
| 534 | |
| 535 | lpfc_free_ct_rsp(phba, outp); |
| 536 | lpfc_mbuf_free(phba, inp->virt, inp->phys); |
| 537 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 538 | kfree(inp); |
| 539 | kfree(bmp); |
| 540 | spin_lock_irq(phba->host->host_lock); |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 541 | lpfc_sli_release_iocbq(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 542 | spin_unlock_irq(phba->host->host_lock); |
| 543 | return; |
| 544 | } |
| 545 | |
| 546 | static void |
| 547 | lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, |
| 548 | struct lpfc_iocbq * rspiocb) |
| 549 | { |
| 550 | lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb); |
| 551 | return; |
| 552 | } |
| 553 | |
| 554 | static void |
| 555 | lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, |
| 556 | struct lpfc_iocbq * rspiocb) |
| 557 | { |
| 558 | lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb); |
| 559 | return; |
| 560 | } |
| 561 | |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 562 | static void |
| 563 | lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, |
| 564 | struct lpfc_iocbq * rspiocb) |
| 565 | { |
| 566 | lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb); |
| 567 | return; |
| 568 | } |
| 569 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 570 | void |
| 571 | lpfc_get_hba_sym_node_name(struct lpfc_hba * phba, uint8_t * symbp) |
| 572 | { |
| 573 | char fwrev[16]; |
| 574 | |
| 575 | lpfc_decode_firmware_rev(phba, fwrev, 0); |
| 576 | |
James Smart | dca9479 | 2006-08-01 07:34:08 -0400 | [diff] [blame] | 577 | sprintf(symbp, "Emulex %s FV%s DV%s", phba->ModelName, |
| 578 | fwrev, lpfc_release_version); |
| 579 | return; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | /* |
| 583 | * lpfc_ns_cmd |
| 584 | * Description: |
| 585 | * Issue Cmd to NameServer |
| 586 | * SLI_CTNS_GID_FT |
| 587 | * LI_CTNS_RFT_ID |
| 588 | */ |
| 589 | int |
| 590 | lpfc_ns_cmd(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, int cmdcode) |
| 591 | { |
| 592 | struct lpfc_dmabuf *mp, *bmp; |
| 593 | struct lpfc_sli_ct_request *CtReq; |
| 594 | struct ulp_bde64 *bpl; |
| 595 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 596 | struct lpfc_iocbq *) = NULL; |
| 597 | uint32_t rsp_size = 1024; |
| 598 | |
| 599 | /* fill in BDEs for command */ |
| 600 | /* Allocate buffer for command payload */ |
| 601 | mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
| 602 | if (!mp) |
| 603 | goto ns_cmd_exit; |
| 604 | |
| 605 | INIT_LIST_HEAD(&mp->list); |
| 606 | mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); |
| 607 | if (!mp->virt) |
| 608 | goto ns_cmd_free_mp; |
| 609 | |
| 610 | /* Allocate buffer for Buffer ptr list */ |
| 611 | bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
| 612 | if (!bmp) |
| 613 | goto ns_cmd_free_mpvirt; |
| 614 | |
| 615 | INIT_LIST_HEAD(&bmp->list); |
| 616 | bmp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(bmp->phys)); |
| 617 | if (!bmp->virt) |
| 618 | goto ns_cmd_free_bmp; |
| 619 | |
| 620 | /* NameServer Req */ |
| 621 | lpfc_printf_log(phba, |
| 622 | KERN_INFO, |
| 623 | LOG_DISCOVERY, |
| 624 | "%d:0236 NameServer Req Data: x%x x%x x%x\n", |
| 625 | phba->brd_no, cmdcode, phba->fc_flag, |
| 626 | phba->fc_rscn_id_cnt); |
| 627 | |
| 628 | bpl = (struct ulp_bde64 *) bmp->virt; |
| 629 | memset(bpl, 0, sizeof(struct ulp_bde64)); |
| 630 | bpl->addrHigh = le32_to_cpu( putPaddrHigh(mp->phys) ); |
| 631 | bpl->addrLow = le32_to_cpu( putPaddrLow(mp->phys) ); |
| 632 | bpl->tus.f.bdeFlags = 0; |
| 633 | if (cmdcode == SLI_CTNS_GID_FT) |
| 634 | bpl->tus.f.bdeSize = GID_REQUEST_SZ; |
| 635 | else if (cmdcode == SLI_CTNS_RFT_ID) |
| 636 | bpl->tus.f.bdeSize = RFT_REQUEST_SZ; |
| 637 | else if (cmdcode == SLI_CTNS_RNN_ID) |
| 638 | bpl->tus.f.bdeSize = RNN_REQUEST_SZ; |
| 639 | else if (cmdcode == SLI_CTNS_RSNN_NN) |
| 640 | bpl->tus.f.bdeSize = RSNN_REQUEST_SZ; |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 641 | else if (cmdcode == SLI_CTNS_RFF_ID) |
| 642 | bpl->tus.f.bdeSize = RFF_REQUEST_SZ; |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 643 | else |
| 644 | bpl->tus.f.bdeSize = 0; |
| 645 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 646 | |
| 647 | CtReq = (struct lpfc_sli_ct_request *) mp->virt; |
| 648 | memset(CtReq, 0, sizeof (struct lpfc_sli_ct_request)); |
| 649 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; |
| 650 | CtReq->RevisionId.bits.InId = 0; |
| 651 | CtReq->FsType = SLI_CT_DIRECTORY_SERVICE; |
| 652 | CtReq->FsSubType = SLI_CT_DIRECTORY_NAME_SERVER; |
| 653 | CtReq->CommandResponse.bits.Size = 0; |
| 654 | switch (cmdcode) { |
| 655 | case SLI_CTNS_GID_FT: |
| 656 | CtReq->CommandResponse.bits.CmdRsp = |
| 657 | be16_to_cpu(SLI_CTNS_GID_FT); |
| 658 | CtReq->un.gid.Fc4Type = SLI_CTPT_FCP; |
| 659 | if (phba->hba_state < LPFC_HBA_READY) |
| 660 | phba->hba_state = LPFC_NS_QRY; |
| 661 | lpfc_set_disctmo(phba); |
| 662 | cmpl = lpfc_cmpl_ct_cmd_gid_ft; |
| 663 | rsp_size = FC_MAX_NS_RSP; |
| 664 | break; |
| 665 | |
| 666 | case SLI_CTNS_RFT_ID: |
| 667 | CtReq->CommandResponse.bits.CmdRsp = |
| 668 | be16_to_cpu(SLI_CTNS_RFT_ID); |
| 669 | CtReq->un.rft.PortId = be32_to_cpu(phba->fc_myDID); |
| 670 | CtReq->un.rft.fcpReg = 1; |
| 671 | cmpl = lpfc_cmpl_ct_cmd_rft_id; |
| 672 | break; |
| 673 | |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 674 | case SLI_CTNS_RFF_ID: |
| 675 | CtReq->CommandResponse.bits.CmdRsp = |
| 676 | be16_to_cpu(SLI_CTNS_RFF_ID); |
| 677 | CtReq->un.rff.PortId = be32_to_cpu(phba->fc_myDID); |
| 678 | CtReq->un.rff.feature_res = 0; |
| 679 | CtReq->un.rff.feature_tgt = 0; |
| 680 | CtReq->un.rff.type_code = FC_FCP_DATA; |
| 681 | CtReq->un.rff.feature_init = 1; |
| 682 | cmpl = lpfc_cmpl_ct_cmd_rff_id; |
| 683 | break; |
| 684 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 685 | case SLI_CTNS_RNN_ID: |
| 686 | CtReq->CommandResponse.bits.CmdRsp = |
| 687 | be16_to_cpu(SLI_CTNS_RNN_ID); |
| 688 | CtReq->un.rnn.PortId = be32_to_cpu(phba->fc_myDID); |
| 689 | memcpy(CtReq->un.rnn.wwnn, &phba->fc_nodename, |
| 690 | sizeof (struct lpfc_name)); |
| 691 | cmpl = lpfc_cmpl_ct_cmd_rnn_id; |
| 692 | break; |
| 693 | |
| 694 | case SLI_CTNS_RSNN_NN: |
| 695 | CtReq->CommandResponse.bits.CmdRsp = |
| 696 | be16_to_cpu(SLI_CTNS_RSNN_NN); |
| 697 | memcpy(CtReq->un.rsnn.wwnn, &phba->fc_nodename, |
| 698 | sizeof (struct lpfc_name)); |
| 699 | lpfc_get_hba_sym_node_name(phba, CtReq->un.rsnn.symbname); |
| 700 | CtReq->un.rsnn.len = strlen(CtReq->un.rsnn.symbname); |
| 701 | cmpl = lpfc_cmpl_ct_cmd_rsnn_nn; |
| 702 | break; |
| 703 | } |
| 704 | |
| 705 | if (!lpfc_ct_cmd(phba, mp, bmp, ndlp, cmpl, rsp_size)) |
| 706 | /* On success, The cmpl function will free the buffers */ |
| 707 | return 0; |
| 708 | |
| 709 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 710 | ns_cmd_free_bmp: |
| 711 | kfree(bmp); |
| 712 | ns_cmd_free_mpvirt: |
| 713 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 714 | ns_cmd_free_mp: |
| 715 | kfree(mp); |
| 716 | ns_cmd_exit: |
| 717 | return 1; |
| 718 | } |
| 719 | |
| 720 | static void |
| 721 | lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba * phba, |
| 722 | struct lpfc_iocbq * cmdiocb, struct lpfc_iocbq * rspiocb) |
| 723 | { |
| 724 | struct lpfc_dmabuf *bmp = cmdiocb->context3; |
| 725 | struct lpfc_dmabuf *inp = cmdiocb->context1; |
| 726 | struct lpfc_dmabuf *outp = cmdiocb->context2; |
| 727 | struct lpfc_sli_ct_request *CTrsp = outp->virt; |
| 728 | struct lpfc_sli_ct_request *CTcmd = inp->virt; |
| 729 | struct lpfc_nodelist *ndlp; |
| 730 | uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp; |
| 731 | uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp; |
| 732 | |
| 733 | ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, FDMI_DID); |
| 734 | if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { |
| 735 | /* FDMI rsp failed */ |
| 736 | lpfc_printf_log(phba, |
| 737 | KERN_INFO, |
| 738 | LOG_DISCOVERY, |
| 739 | "%d:0220 FDMI rsp failed Data: x%x\n", |
| 740 | phba->brd_no, |
| 741 | be16_to_cpu(fdmi_cmd)); |
| 742 | } |
| 743 | |
| 744 | switch (be16_to_cpu(fdmi_cmd)) { |
| 745 | case SLI_MGMT_RHBA: |
| 746 | lpfc_fdmi_cmd(phba, ndlp, SLI_MGMT_RPA); |
| 747 | break; |
| 748 | |
| 749 | case SLI_MGMT_RPA: |
| 750 | break; |
| 751 | |
| 752 | case SLI_MGMT_DHBA: |
| 753 | lpfc_fdmi_cmd(phba, ndlp, SLI_MGMT_DPRT); |
| 754 | break; |
| 755 | |
| 756 | case SLI_MGMT_DPRT: |
| 757 | lpfc_fdmi_cmd(phba, ndlp, SLI_MGMT_RHBA); |
| 758 | break; |
| 759 | } |
| 760 | |
| 761 | lpfc_free_ct_rsp(phba, outp); |
| 762 | lpfc_mbuf_free(phba, inp->virt, inp->phys); |
| 763 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 764 | kfree(inp); |
| 765 | kfree(bmp); |
| 766 | spin_lock_irq(phba->host->host_lock); |
James Bottomley | 604a3e3 | 2005-10-29 10:28:33 -0500 | [diff] [blame] | 767 | lpfc_sli_release_iocbq(phba, cmdiocb); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 768 | spin_unlock_irq(phba->host->host_lock); |
| 769 | return; |
| 770 | } |
| 771 | int |
| 772 | lpfc_fdmi_cmd(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, int cmdcode) |
| 773 | { |
| 774 | struct lpfc_dmabuf *mp, *bmp; |
| 775 | struct lpfc_sli_ct_request *CtReq; |
| 776 | struct ulp_bde64 *bpl; |
| 777 | uint32_t size; |
| 778 | REG_HBA *rh; |
| 779 | PORT_ENTRY *pe; |
| 780 | REG_PORT_ATTRIBUTE *pab; |
| 781 | ATTRIBUTE_BLOCK *ab; |
| 782 | ATTRIBUTE_ENTRY *ae; |
| 783 | void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, |
| 784 | struct lpfc_iocbq *); |
| 785 | |
| 786 | |
| 787 | /* fill in BDEs for command */ |
| 788 | /* Allocate buffer for command payload */ |
| 789 | mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
| 790 | if (!mp) |
| 791 | goto fdmi_cmd_exit; |
| 792 | |
| 793 | mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys)); |
| 794 | if (!mp->virt) |
| 795 | goto fdmi_cmd_free_mp; |
| 796 | |
| 797 | /* Allocate buffer for Buffer ptr list */ |
| 798 | bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); |
| 799 | if (!bmp) |
| 800 | goto fdmi_cmd_free_mpvirt; |
| 801 | |
| 802 | bmp->virt = lpfc_mbuf_alloc(phba, 0, &(bmp->phys)); |
| 803 | if (!bmp->virt) |
| 804 | goto fdmi_cmd_free_bmp; |
| 805 | |
| 806 | INIT_LIST_HEAD(&mp->list); |
| 807 | INIT_LIST_HEAD(&bmp->list); |
| 808 | |
| 809 | /* FDMI request */ |
| 810 | lpfc_printf_log(phba, |
| 811 | KERN_INFO, |
| 812 | LOG_DISCOVERY, |
| 813 | "%d:0218 FDMI Request Data: x%x x%x x%x\n", |
| 814 | phba->brd_no, |
| 815 | phba->fc_flag, phba->hba_state, cmdcode); |
| 816 | |
| 817 | CtReq = (struct lpfc_sli_ct_request *) mp->virt; |
| 818 | |
| 819 | memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request)); |
| 820 | CtReq->RevisionId.bits.Revision = SLI_CT_REVISION; |
| 821 | CtReq->RevisionId.bits.InId = 0; |
| 822 | |
| 823 | CtReq->FsType = SLI_CT_MANAGEMENT_SERVICE; |
| 824 | CtReq->FsSubType = SLI_CT_FDMI_Subtypes; |
| 825 | size = 0; |
| 826 | |
| 827 | switch (cmdcode) { |
| 828 | case SLI_MGMT_RHBA: |
| 829 | { |
| 830 | lpfc_vpd_t *vp = &phba->vpd; |
| 831 | uint32_t i, j, incr; |
| 832 | int len; |
| 833 | |
| 834 | CtReq->CommandResponse.bits.CmdRsp = |
| 835 | be16_to_cpu(SLI_MGMT_RHBA); |
| 836 | CtReq->CommandResponse.bits.Size = 0; |
| 837 | rh = (REG_HBA *) & CtReq->un.PortID; |
| 838 | memcpy(&rh->hi.PortName, &phba->fc_sparam.portName, |
| 839 | sizeof (struct lpfc_name)); |
| 840 | /* One entry (port) per adapter */ |
| 841 | rh->rpl.EntryCnt = be32_to_cpu(1); |
| 842 | memcpy(&rh->rpl.pe, &phba->fc_sparam.portName, |
| 843 | sizeof (struct lpfc_name)); |
| 844 | |
| 845 | /* point to the HBA attribute block */ |
| 846 | size = 2 * sizeof (struct lpfc_name) + FOURBYTES; |
| 847 | ab = (ATTRIBUTE_BLOCK *) ((uint8_t *) rh + size); |
| 848 | ab->EntryCnt = 0; |
| 849 | |
| 850 | /* Point to the beginning of the first HBA attribute |
| 851 | entry */ |
| 852 | /* #1 HBA attribute entry */ |
| 853 | size += FOURBYTES; |
| 854 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 855 | ae->ad.bits.AttrType = be16_to_cpu(NODE_NAME); |
| 856 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES |
| 857 | + sizeof (struct lpfc_name)); |
| 858 | memcpy(&ae->un.NodeName, &phba->fc_sparam.nodeName, |
| 859 | sizeof (struct lpfc_name)); |
| 860 | ab->EntryCnt++; |
| 861 | size += FOURBYTES + sizeof (struct lpfc_name); |
| 862 | |
| 863 | /* #2 HBA attribute entry */ |
| 864 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 865 | ae->ad.bits.AttrType = be16_to_cpu(MANUFACTURER); |
| 866 | strcpy(ae->un.Manufacturer, "Emulex Corporation"); |
| 867 | len = strlen(ae->un.Manufacturer); |
| 868 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 869 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 870 | ab->EntryCnt++; |
| 871 | size += FOURBYTES + len; |
| 872 | |
| 873 | /* #3 HBA attribute entry */ |
| 874 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 875 | ae->ad.bits.AttrType = be16_to_cpu(SERIAL_NUMBER); |
| 876 | strcpy(ae->un.SerialNumber, phba->SerialNumber); |
| 877 | len = strlen(ae->un.SerialNumber); |
| 878 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 879 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 880 | ab->EntryCnt++; |
| 881 | size += FOURBYTES + len; |
| 882 | |
| 883 | /* #4 HBA attribute entry */ |
| 884 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 885 | ae->ad.bits.AttrType = be16_to_cpu(MODEL); |
| 886 | strcpy(ae->un.Model, phba->ModelName); |
| 887 | len = strlen(ae->un.Model); |
| 888 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 889 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 890 | ab->EntryCnt++; |
| 891 | size += FOURBYTES + len; |
| 892 | |
| 893 | /* #5 HBA attribute entry */ |
| 894 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 895 | ae->ad.bits.AttrType = be16_to_cpu(MODEL_DESCRIPTION); |
| 896 | strcpy(ae->un.ModelDescription, phba->ModelDesc); |
| 897 | len = strlen(ae->un.ModelDescription); |
| 898 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 899 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 900 | ab->EntryCnt++; |
| 901 | size += FOURBYTES + len; |
| 902 | |
| 903 | /* #6 HBA attribute entry */ |
| 904 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 905 | ae->ad.bits.AttrType = be16_to_cpu(HARDWARE_VERSION); |
| 906 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 8); |
| 907 | /* Convert JEDEC ID to ascii for hardware version */ |
| 908 | incr = vp->rev.biuRev; |
| 909 | for (i = 0; i < 8; i++) { |
| 910 | j = (incr & 0xf); |
| 911 | if (j <= 9) |
| 912 | ae->un.HardwareVersion[7 - i] = |
| 913 | (char)((uint8_t) 0x30 + |
| 914 | (uint8_t) j); |
| 915 | else |
| 916 | ae->un.HardwareVersion[7 - i] = |
| 917 | (char)((uint8_t) 0x61 + |
| 918 | (uint8_t) (j - 10)); |
| 919 | incr = (incr >> 4); |
| 920 | } |
| 921 | ab->EntryCnt++; |
| 922 | size += FOURBYTES + 8; |
| 923 | |
| 924 | /* #7 HBA attribute entry */ |
| 925 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 926 | ae->ad.bits.AttrType = be16_to_cpu(DRIVER_VERSION); |
| 927 | strcpy(ae->un.DriverVersion, lpfc_release_version); |
| 928 | len = strlen(ae->un.DriverVersion); |
| 929 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 930 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 931 | ab->EntryCnt++; |
| 932 | size += FOURBYTES + len; |
| 933 | |
| 934 | /* #8 HBA attribute entry */ |
| 935 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 936 | ae->ad.bits.AttrType = be16_to_cpu(OPTION_ROM_VERSION); |
| 937 | strcpy(ae->un.OptionROMVersion, phba->OptionROMVersion); |
| 938 | len = strlen(ae->un.OptionROMVersion); |
| 939 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 940 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 941 | ab->EntryCnt++; |
| 942 | size += FOURBYTES + len; |
| 943 | |
| 944 | /* #9 HBA attribute entry */ |
| 945 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 946 | ae->ad.bits.AttrType = be16_to_cpu(FIRMWARE_VERSION); |
| 947 | lpfc_decode_firmware_rev(phba, ae->un.FirmwareVersion, |
| 948 | 1); |
| 949 | len = strlen(ae->un.FirmwareVersion); |
| 950 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 951 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 952 | ab->EntryCnt++; |
| 953 | size += FOURBYTES + len; |
| 954 | |
| 955 | /* #10 HBA attribute entry */ |
| 956 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 957 | ae->ad.bits.AttrType = be16_to_cpu(OS_NAME_VERSION); |
| 958 | sprintf(ae->un.OsNameVersion, "%s %s %s", |
James Smart | 2fb9bd8 | 2006-12-02 13:33:57 -0500 | [diff] [blame] | 959 | init_utsname()->sysname, |
| 960 | init_utsname()->release, |
Serge E. Hallyn | 96b644b | 2006-10-02 02:18:13 -0700 | [diff] [blame] | 961 | init_utsname()->version); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 962 | len = strlen(ae->un.OsNameVersion); |
| 963 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 964 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 965 | ab->EntryCnt++; |
| 966 | size += FOURBYTES + len; |
| 967 | |
| 968 | /* #11 HBA attribute entry */ |
| 969 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); |
| 970 | ae->ad.bits.AttrType = be16_to_cpu(MAX_CT_PAYLOAD_LEN); |
| 971 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
| 972 | ae->un.MaxCTPayloadLen = (65 * 4096); |
| 973 | ab->EntryCnt++; |
| 974 | size += FOURBYTES + 4; |
| 975 | |
| 976 | ab->EntryCnt = be32_to_cpu(ab->EntryCnt); |
| 977 | /* Total size */ |
| 978 | size = GID_REQUEST_SZ - 4 + size; |
| 979 | } |
| 980 | break; |
| 981 | |
| 982 | case SLI_MGMT_RPA: |
| 983 | { |
| 984 | lpfc_vpd_t *vp; |
| 985 | struct serv_parm *hsp; |
| 986 | int len; |
| 987 | |
| 988 | vp = &phba->vpd; |
| 989 | |
| 990 | CtReq->CommandResponse.bits.CmdRsp = |
| 991 | be16_to_cpu(SLI_MGMT_RPA); |
| 992 | CtReq->CommandResponse.bits.Size = 0; |
| 993 | pab = (REG_PORT_ATTRIBUTE *) & CtReq->un.PortID; |
| 994 | size = sizeof (struct lpfc_name) + FOURBYTES; |
| 995 | memcpy((uint8_t *) & pab->PortName, |
| 996 | (uint8_t *) & phba->fc_sparam.portName, |
| 997 | sizeof (struct lpfc_name)); |
| 998 | pab->ab.EntryCnt = 0; |
| 999 | |
| 1000 | /* #1 Port attribute entry */ |
| 1001 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1002 | ae->ad.bits.AttrType = be16_to_cpu(SUPPORTED_FC4_TYPES); |
| 1003 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 32); |
| 1004 | ae->un.SupportFC4Types[2] = 1; |
| 1005 | ae->un.SupportFC4Types[7] = 1; |
| 1006 | pab->ab.EntryCnt++; |
| 1007 | size += FOURBYTES + 32; |
| 1008 | |
| 1009 | /* #2 Port attribute entry */ |
| 1010 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1011 | ae->ad.bits.AttrType = be16_to_cpu(SUPPORTED_SPEED); |
| 1012 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 1013 | |
| 1014 | ae->un.SupportSpeed = 0; |
| 1015 | if (phba->lmt & LMT_10Gb) |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1016 | ae->un.SupportSpeed = HBA_PORTSPEED_10GBIT; |
Jamie Wellnitz | 74b72a5 | 2006-02-28 22:33:04 -0500 | [diff] [blame] | 1017 | if (phba->lmt & LMT_8Gb) |
| 1018 | ae->un.SupportSpeed |= HBA_PORTSPEED_8GBIT; |
| 1019 | if (phba->lmt & LMT_4Gb) |
| 1020 | ae->un.SupportSpeed |= HBA_PORTSPEED_4GBIT; |
| 1021 | if (phba->lmt & LMT_2Gb) |
| 1022 | ae->un.SupportSpeed |= HBA_PORTSPEED_2GBIT; |
| 1023 | if (phba->lmt & LMT_1Gb) |
| 1024 | ae->un.SupportSpeed |= HBA_PORTSPEED_1GBIT; |
| 1025 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1026 | pab->ab.EntryCnt++; |
| 1027 | size += FOURBYTES + 4; |
| 1028 | |
| 1029 | /* #3 Port attribute entry */ |
| 1030 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1031 | ae->ad.bits.AttrType = be16_to_cpu(PORT_SPEED); |
| 1032 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
| 1033 | switch(phba->fc_linkspeed) { |
| 1034 | case LA_1GHZ_LINK: |
| 1035 | ae->un.PortSpeed = HBA_PORTSPEED_1GBIT; |
| 1036 | break; |
| 1037 | case LA_2GHZ_LINK: |
| 1038 | ae->un.PortSpeed = HBA_PORTSPEED_2GBIT; |
| 1039 | break; |
| 1040 | case LA_4GHZ_LINK: |
| 1041 | ae->un.PortSpeed = HBA_PORTSPEED_4GBIT; |
| 1042 | break; |
| 1043 | default: |
| 1044 | ae->un.PortSpeed = |
| 1045 | HBA_PORTSPEED_UNKNOWN; |
| 1046 | break; |
| 1047 | } |
| 1048 | pab->ab.EntryCnt++; |
| 1049 | size += FOURBYTES + 4; |
| 1050 | |
| 1051 | /* #4 Port attribute entry */ |
| 1052 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1053 | ae->ad.bits.AttrType = be16_to_cpu(MAX_FRAME_SIZE); |
| 1054 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + 4); |
| 1055 | hsp = (struct serv_parm *) & phba->fc_sparam; |
| 1056 | ae->un.MaxFrameSize = |
| 1057 | (((uint32_t) hsp->cmn. |
| 1058 | bbRcvSizeMsb) << 8) | (uint32_t) hsp->cmn. |
| 1059 | bbRcvSizeLsb; |
| 1060 | pab->ab.EntryCnt++; |
| 1061 | size += FOURBYTES + 4; |
| 1062 | |
| 1063 | /* #5 Port attribute entry */ |
| 1064 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + size); |
| 1065 | ae->ad.bits.AttrType = be16_to_cpu(OS_DEVICE_NAME); |
| 1066 | strcpy((char *)ae->un.OsDeviceName, LPFC_DRIVER_NAME); |
| 1067 | len = strlen((char *)ae->un.OsDeviceName); |
| 1068 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1069 | ae->ad.bits.AttrLen = be16_to_cpu(FOURBYTES + len); |
| 1070 | pab->ab.EntryCnt++; |
| 1071 | size += FOURBYTES + len; |
| 1072 | |
| 1073 | if (phba->cfg_fdmi_on == 2) { |
| 1074 | /* #6 Port attribute entry */ |
| 1075 | ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + |
| 1076 | size); |
| 1077 | ae->ad.bits.AttrType = be16_to_cpu(HOST_NAME); |
| 1078 | sprintf(ae->un.HostName, "%s", |
Serge E. Hallyn | 96b644b | 2006-10-02 02:18:13 -0700 | [diff] [blame] | 1079 | init_utsname()->nodename); |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1080 | len = strlen(ae->un.HostName); |
| 1081 | len += (len & 3) ? (4 - (len & 3)) : 4; |
| 1082 | ae->ad.bits.AttrLen = |
| 1083 | be16_to_cpu(FOURBYTES + len); |
| 1084 | pab->ab.EntryCnt++; |
| 1085 | size += FOURBYTES + len; |
| 1086 | } |
| 1087 | |
| 1088 | pab->ab.EntryCnt = be32_to_cpu(pab->ab.EntryCnt); |
| 1089 | /* Total size */ |
| 1090 | size = GID_REQUEST_SZ - 4 + size; |
| 1091 | } |
| 1092 | break; |
| 1093 | |
| 1094 | case SLI_MGMT_DHBA: |
| 1095 | CtReq->CommandResponse.bits.CmdRsp = be16_to_cpu(SLI_MGMT_DHBA); |
| 1096 | CtReq->CommandResponse.bits.Size = 0; |
| 1097 | pe = (PORT_ENTRY *) & CtReq->un.PortID; |
| 1098 | memcpy((uint8_t *) & pe->PortName, |
| 1099 | (uint8_t *) & phba->fc_sparam.portName, |
| 1100 | sizeof (struct lpfc_name)); |
| 1101 | size = GID_REQUEST_SZ - 4 + sizeof (struct lpfc_name); |
| 1102 | break; |
| 1103 | |
| 1104 | case SLI_MGMT_DPRT: |
| 1105 | CtReq->CommandResponse.bits.CmdRsp = be16_to_cpu(SLI_MGMT_DPRT); |
| 1106 | CtReq->CommandResponse.bits.Size = 0; |
| 1107 | pe = (PORT_ENTRY *) & CtReq->un.PortID; |
| 1108 | memcpy((uint8_t *) & pe->PortName, |
| 1109 | (uint8_t *) & phba->fc_sparam.portName, |
| 1110 | sizeof (struct lpfc_name)); |
| 1111 | size = GID_REQUEST_SZ - 4 + sizeof (struct lpfc_name); |
| 1112 | break; |
| 1113 | } |
| 1114 | |
| 1115 | bpl = (struct ulp_bde64 *) bmp->virt; |
| 1116 | bpl->addrHigh = le32_to_cpu( putPaddrHigh(mp->phys) ); |
| 1117 | bpl->addrLow = le32_to_cpu( putPaddrLow(mp->phys) ); |
| 1118 | bpl->tus.f.bdeFlags = 0; |
| 1119 | bpl->tus.f.bdeSize = size; |
| 1120 | bpl->tus.w = le32_to_cpu(bpl->tus.w); |
| 1121 | |
| 1122 | cmpl = lpfc_cmpl_ct_cmd_fdmi; |
| 1123 | |
| 1124 | if (!lpfc_ct_cmd(phba, mp, bmp, ndlp, cmpl, FC_MAX_NS_RSP)) |
| 1125 | return 0; |
| 1126 | |
| 1127 | lpfc_mbuf_free(phba, bmp->virt, bmp->phys); |
| 1128 | fdmi_cmd_free_bmp: |
| 1129 | kfree(bmp); |
| 1130 | fdmi_cmd_free_mpvirt: |
| 1131 | lpfc_mbuf_free(phba, mp->virt, mp->phys); |
| 1132 | fdmi_cmd_free_mp: |
| 1133 | kfree(mp); |
| 1134 | fdmi_cmd_exit: |
| 1135 | /* Issue FDMI request failed */ |
| 1136 | lpfc_printf_log(phba, |
| 1137 | KERN_INFO, |
| 1138 | LOG_DISCOVERY, |
| 1139 | "%d:0244 Issue FDMI request failed Data: x%x\n", |
| 1140 | phba->brd_no, |
| 1141 | cmdcode); |
| 1142 | return 1; |
| 1143 | } |
| 1144 | |
| 1145 | void |
| 1146 | lpfc_fdmi_tmo(unsigned long ptr) |
| 1147 | { |
| 1148 | struct lpfc_hba *phba = (struct lpfc_hba *)ptr; |
| 1149 | unsigned long iflag; |
| 1150 | |
| 1151 | spin_lock_irqsave(phba->host->host_lock, iflag); |
| 1152 | if (!(phba->work_hba_events & WORKER_FDMI_TMO)) { |
| 1153 | phba->work_hba_events |= WORKER_FDMI_TMO; |
| 1154 | if (phba->work_wait) |
| 1155 | wake_up(phba->work_wait); |
| 1156 | } |
| 1157 | spin_unlock_irqrestore(phba->host->host_lock,iflag); |
| 1158 | } |
| 1159 | |
| 1160 | void |
| 1161 | lpfc_fdmi_tmo_handler(struct lpfc_hba *phba) |
| 1162 | { |
| 1163 | struct lpfc_nodelist *ndlp; |
| 1164 | |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1165 | ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, FDMI_DID); |
| 1166 | if (ndlp) { |
Serge E. Hallyn | 96b644b | 2006-10-02 02:18:13 -0700 | [diff] [blame] | 1167 | if (init_utsname()->nodename[0] != '\0') { |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1168 | lpfc_fdmi_cmd(phba, ndlp, SLI_MGMT_DHBA); |
| 1169 | } else { |
| 1170 | mod_timer(&phba->fc_fdmitmo, jiffies + HZ * 60); |
| 1171 | } |
| 1172 | } |
| dea3101 | 2005-04-17 16:05:31 -0500 | [diff] [blame] | 1173 | return; |
| 1174 | } |
| 1175 | |
| 1176 | |
| 1177 | void |
| 1178 | lpfc_decode_firmware_rev(struct lpfc_hba * phba, char *fwrevision, int flag) |
| 1179 | { |
| 1180 | struct lpfc_sli *psli = &phba->sli; |
| 1181 | lpfc_vpd_t *vp = &phba->vpd; |
| 1182 | uint32_t b1, b2, b3, b4, i, rev; |
| 1183 | char c; |
| 1184 | uint32_t *ptr, str[4]; |
| 1185 | uint8_t *fwname; |
| 1186 | |
| 1187 | if (vp->rev.rBit) { |
| 1188 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) |
| 1189 | rev = vp->rev.sli2FwRev; |
| 1190 | else |
| 1191 | rev = vp->rev.sli1FwRev; |
| 1192 | |
| 1193 | b1 = (rev & 0x0000f000) >> 12; |
| 1194 | b2 = (rev & 0x00000f00) >> 8; |
| 1195 | b3 = (rev & 0x000000c0) >> 6; |
| 1196 | b4 = (rev & 0x00000030) >> 4; |
| 1197 | |
| 1198 | switch (b4) { |
| 1199 | case 0: |
| 1200 | c = 'N'; |
| 1201 | break; |
| 1202 | case 1: |
| 1203 | c = 'A'; |
| 1204 | break; |
| 1205 | case 2: |
| 1206 | c = 'B'; |
| 1207 | break; |
| 1208 | default: |
| 1209 | c = 0; |
| 1210 | break; |
| 1211 | } |
| 1212 | b4 = (rev & 0x0000000f); |
| 1213 | |
| 1214 | if (psli->sli_flag & LPFC_SLI2_ACTIVE) |
| 1215 | fwname = vp->rev.sli2FwName; |
| 1216 | else |
| 1217 | fwname = vp->rev.sli1FwName; |
| 1218 | |
| 1219 | for (i = 0; i < 16; i++) |
| 1220 | if (fwname[i] == 0x20) |
| 1221 | fwname[i] = 0; |
| 1222 | |
| 1223 | ptr = (uint32_t*)fwname; |
| 1224 | |
| 1225 | for (i = 0; i < 3; i++) |
| 1226 | str[i] = be32_to_cpu(*ptr++); |
| 1227 | |
| 1228 | if (c == 0) { |
| 1229 | if (flag) |
| 1230 | sprintf(fwrevision, "%d.%d%d (%s)", |
| 1231 | b1, b2, b3, (char *)str); |
| 1232 | else |
| 1233 | sprintf(fwrevision, "%d.%d%d", b1, |
| 1234 | b2, b3); |
| 1235 | } else { |
| 1236 | if (flag) |
| 1237 | sprintf(fwrevision, "%d.%d%d%c%d (%s)", |
| 1238 | b1, b2, b3, c, |
| 1239 | b4, (char *)str); |
| 1240 | else |
| 1241 | sprintf(fwrevision, "%d.%d%d%c%d", |
| 1242 | b1, b2, b3, c, b4); |
| 1243 | } |
| 1244 | } else { |
| 1245 | rev = vp->rev.smFwRev; |
| 1246 | |
| 1247 | b1 = (rev & 0xff000000) >> 24; |
| 1248 | b2 = (rev & 0x00f00000) >> 20; |
| 1249 | b3 = (rev & 0x000f0000) >> 16; |
| 1250 | c = (rev & 0x0000ff00) >> 8; |
| 1251 | b4 = (rev & 0x000000ff); |
| 1252 | |
| 1253 | if (flag) |
| 1254 | sprintf(fwrevision, "%d.%d%d%c%d ", b1, |
| 1255 | b2, b3, c, b4); |
| 1256 | else |
| 1257 | sprintf(fwrevision, "%d.%d%d%c%d ", b1, |
| 1258 | b2, b3, c, b4); |
| 1259 | } |
| 1260 | return; |
| 1261 | } |