2005-04-18 05:05:31 +08:00
|
|
|
/*******************************************************************
|
|
|
|
* This file is part of the Emulex Linux Device Driver for *
|
2005-06-25 22:34:39 +08:00
|
|
|
* Fibre Channel Host Bus Adapters. *
|
2015-04-08 03:07:28 +08:00
|
|
|
* Copyright (C) 2004-2015 Emulex. All rights reserved. *
|
2005-06-25 22:34:39 +08:00
|
|
|
* EMULEX and SLI are trademarks of Emulex. *
|
2005-04-18 05:05:31 +08:00
|
|
|
* www.emulex.com *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
2005-06-25 22:34:39 +08:00
|
|
|
* modify it under the terms of version 2 of the GNU General *
|
|
|
|
* Public License as published by the Free Software Foundation. *
|
|
|
|
* This program is distributed in the hope that it will be useful. *
|
|
|
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
|
|
|
|
* WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
|
|
|
|
* DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
|
|
|
|
* TO BE LEGALLY INVALID. See the GNU General Public License for *
|
|
|
|
* more details, a copy of which can be found in the file COPYING *
|
|
|
|
* included with this package. *
|
2005-04-18 05:05:31 +08:00
|
|
|
*******************************************************************/
|
|
|
|
|
|
|
|
/*
|
2008-01-11 14:52:54 +08:00
|
|
|
* Fibre Channel SCSI LAN Device Driver CT support: FC Generic Services FC-GS
|
2005-04-18 05:05:31 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/interrupt.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-18 05:05:31 +08:00
|
|
|
#include <linux/utsname.h>
|
|
|
|
|
2005-08-11 03:03:09 +08:00
|
|
|
#include <scsi/scsi.h>
|
2005-04-18 05:05:31 +08:00
|
|
|
#include <scsi/scsi_device.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
2005-08-11 03:03:01 +08:00
|
|
|
#include <scsi/scsi_transport_fc.h>
|
2009-10-03 03:16:51 +08:00
|
|
|
#include <scsi/fc/fc_fs.h>
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2009-05-23 02:51:39 +08:00
|
|
|
#include "lpfc_hw4.h"
|
2005-04-18 05:05:31 +08:00
|
|
|
#include "lpfc_hw.h"
|
|
|
|
#include "lpfc_sli.h"
|
2009-05-23 02:51:39 +08:00
|
|
|
#include "lpfc_sli4.h"
|
2008-09-07 23:52:10 +08:00
|
|
|
#include "lpfc_nl.h"
|
2005-04-18 05:05:31 +08:00
|
|
|
#include "lpfc_disc.h"
|
|
|
|
#include "lpfc_scsi.h"
|
|
|
|
#include "lpfc.h"
|
|
|
|
#include "lpfc_logmsg.h"
|
|
|
|
#include "lpfc_crtn.h"
|
|
|
|
#include "lpfc_version.h"
|
2007-06-18 08:56:38 +08:00
|
|
|
#include "lpfc_vport.h"
|
2007-06-18 08:56:39 +08:00
|
|
|
#include "lpfc_debugfs.h"
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2010-11-21 12:11:48 +08:00
|
|
|
/* FDMI Port Speed definitions */
|
|
|
|
#define HBA_PORTSPEED_1GBIT 0x0001 /* 1 GBit/sec */
|
|
|
|
#define HBA_PORTSPEED_2GBIT 0x0002 /* 2 GBit/sec */
|
|
|
|
#define HBA_PORTSPEED_4GBIT 0x0008 /* 4 GBit/sec */
|
|
|
|
#define HBA_PORTSPEED_10GBIT 0x0004 /* 10 GBit/sec */
|
|
|
|
#define HBA_PORTSPEED_8GBIT 0x0010 /* 8 GBit/sec */
|
|
|
|
#define HBA_PORTSPEED_16GBIT 0x0020 /* 16 GBit/sec */
|
2015-09-01 04:48:17 +08:00
|
|
|
#define HBA_PORTSPEED_32GBIT 0x0040 /* 32 GBit/sec */
|
2010-11-21 12:11:48 +08:00
|
|
|
#define HBA_PORTSPEED_UNKNOWN 0x0800 /* Unknown */
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
#define FOURBYTES 4
|
|
|
|
|
|
|
|
|
|
|
|
static char *lpfc_release_version = LPFC_DRIVER_VERSION;
|
|
|
|
|
2007-06-18 08:56:37 +08:00
|
|
|
static void
|
2008-01-11 14:53:18 +08:00
|
|
|
lpfc_ct_ignore_hbq_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
|
|
|
|
struct lpfc_dmabuf *mp, uint32_t size)
|
2007-06-18 08:56:37 +08:00
|
|
|
{
|
|
|
|
if (!mp) {
|
2008-01-11 14:53:18 +08:00
|
|
|
lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
|
2008-04-07 22:16:05 +08:00
|
|
|
"0146 Ignoring unsolicited CT No HBQ "
|
2008-01-11 14:53:18 +08:00
|
|
|
"status = x%x\n",
|
|
|
|
piocbq->iocb.ulpStatus);
|
2007-06-18 08:56:37 +08:00
|
|
|
}
|
2008-01-11 14:53:18 +08:00
|
|
|
lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
|
|
|
|
"0145 Ignoring unsolicted CT HBQ Size:%d "
|
|
|
|
"status = x%x\n",
|
|
|
|
size, piocbq->iocb.ulpStatus);
|
2007-06-18 08:56:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-01-11 14:53:18 +08:00
|
|
|
lpfc_ct_unsol_buffer(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq,
|
|
|
|
struct lpfc_dmabuf *mp, uint32_t size)
|
2007-06-18 08:56:37 +08:00
|
|
|
{
|
2008-01-11 14:53:18 +08:00
|
|
|
lpfc_ct_ignore_hbq_buffer(phba, piocbq, mp, size);
|
2007-06-18 08:56:37 +08:00
|
|
|
}
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
void
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
|
|
|
|
struct lpfc_iocbq *piocbq)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
2007-06-18 08:56:37 +08:00
|
|
|
struct lpfc_dmabuf *mp = NULL;
|
2005-04-18 05:05:31 +08:00
|
|
|
IOCB_t *icmd = &piocbq->iocb;
|
2007-06-18 08:56:37 +08:00
|
|
|
int i;
|
|
|
|
struct lpfc_iocbq *iocbq;
|
|
|
|
dma_addr_t paddr;
|
|
|
|
uint32_t size;
|
2008-01-11 14:53:18 +08:00
|
|
|
struct list_head head;
|
|
|
|
struct lpfc_dmabuf *bdeBuf;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2010-01-27 12:08:55 +08:00
|
|
|
if (lpfc_bsg_ct_unsol_event(phba, pring, piocbq) == 0)
|
|
|
|
return;
|
2009-07-19 22:01:32 +08:00
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
if (unlikely(icmd->ulpStatus == IOSTAT_NEED_BUFFER)) {
|
|
|
|
lpfc_sli_hbqbuf_add_hbqs(phba, LPFC_ELS_HBQ);
|
|
|
|
} else if ((icmd->ulpStatus == IOSTAT_LOCAL_REJECT) &&
|
2012-08-15 02:25:43 +08:00
|
|
|
((icmd->un.ulpWord[4] & IOERR_PARAM_MASK) ==
|
|
|
|
IOERR_RCV_BUFFER_WAITING)) {
|
2005-04-18 05:05:31 +08:00
|
|
|
/* Not enough posted buffers; Try posting more buffers */
|
|
|
|
phba->fc_stat.NoRcvBuf++;
|
2007-06-18 08:56:38 +08:00
|
|
|
if (!(phba->sli3_options & LPFC_SLI3_HBQ_ENABLED))
|
2008-06-15 10:52:59 +08:00
|
|
|
lpfc_post_buffer(phba, pring, 2);
|
2005-04-18 05:05:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If there are no BDEs associated with this IOCB,
|
|
|
|
* there is nothing to do.
|
|
|
|
*/
|
|
|
|
if (icmd->ulpBdeCount == 0)
|
|
|
|
return;
|
|
|
|
|
2007-06-18 08:56:37 +08:00
|
|
|
if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
|
2008-01-11 14:53:18 +08:00
|
|
|
INIT_LIST_HEAD(&head);
|
|
|
|
list_add_tail(&head, &piocbq->list);
|
|
|
|
list_for_each_entry(iocbq, &head, list) {
|
2007-06-18 08:56:37 +08:00
|
|
|
icmd = &iocbq->iocb;
|
2008-01-11 14:53:18 +08:00
|
|
|
if (icmd->ulpBdeCount == 0)
|
2007-06-18 08:56:37 +08:00
|
|
|
continue;
|
2008-01-11 14:53:18 +08:00
|
|
|
bdeBuf = iocbq->context2;
|
|
|
|
iocbq->context2 = NULL;
|
2007-06-18 08:56:37 +08:00
|
|
|
size = icmd->un.cont64[0].tus.f.bdeSize;
|
2008-01-11 14:53:18 +08:00
|
|
|
lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf, size);
|
|
|
|
lpfc_in_buf_free(phba, bdeBuf);
|
2007-06-18 08:56:37 +08:00
|
|
|
if (icmd->ulpBdeCount == 2) {
|
2008-01-11 14:53:18 +08:00
|
|
|
bdeBuf = iocbq->context3;
|
|
|
|
iocbq->context3 = NULL;
|
|
|
|
size = icmd->unsli3.rcvsli3.bde2.tus.f.bdeSize;
|
|
|
|
lpfc_ct_unsol_buffer(phba, piocbq, bdeBuf,
|
|
|
|
size);
|
|
|
|
lpfc_in_buf_free(phba, bdeBuf);
|
2007-06-18 08:56:37 +08:00
|
|
|
}
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
2008-01-11 14:53:18 +08:00
|
|
|
list_del(&head);
|
2007-06-18 08:56:37 +08:00
|
|
|
} else {
|
2008-08-25 09:50:00 +08:00
|
|
|
INIT_LIST_HEAD(&head);
|
|
|
|
list_add_tail(&head, &piocbq->list);
|
|
|
|
list_for_each_entry(iocbq, &head, list) {
|
2007-06-18 08:56:37 +08:00
|
|
|
icmd = &iocbq->iocb;
|
2008-01-11 14:53:18 +08:00
|
|
|
if (icmd->ulpBdeCount == 0)
|
2008-08-25 09:50:00 +08:00
|
|
|
lpfc_ct_unsol_buffer(phba, iocbq, NULL, 0);
|
2007-06-18 08:56:37 +08:00
|
|
|
for (i = 0; i < icmd->ulpBdeCount; i++) {
|
|
|
|
paddr = getPaddr(icmd->un.cont64[i].addrHigh,
|
|
|
|
icmd->un.cont64[i].addrLow);
|
|
|
|
mp = lpfc_sli_ringpostbuf_get(phba, pring,
|
|
|
|
paddr);
|
|
|
|
size = icmd->un.cont64[i].tus.f.bdeSize;
|
2008-08-25 09:50:00 +08:00
|
|
|
lpfc_ct_unsol_buffer(phba, iocbq, mp, size);
|
2007-06-18 08:56:38 +08:00
|
|
|
lpfc_in_buf_free(phba, mp);
|
2007-06-18 08:56:37 +08:00
|
|
|
}
|
2008-06-15 10:52:59 +08:00
|
|
|
lpfc_post_buffer(phba, pring, i);
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
2008-08-25 09:50:00 +08:00
|
|
|
list_del(&head);
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-03 03:16:45 +08:00
|
|
|
/**
|
2013-01-04 04:43:37 +08:00
|
|
|
* lpfc_ct_handle_unsol_abort - ct upper level protocol abort handler
|
2009-10-03 03:16:45 +08:00
|
|
|
* @phba: Pointer to HBA context object.
|
2013-01-04 04:43:37 +08:00
|
|
|
* @dmabuf: pointer to a dmabuf that describes the FC sequence
|
2009-10-03 03:16:45 +08:00
|
|
|
*
|
2013-01-04 04:43:37 +08:00
|
|
|
* This function serves as the upper level protocol abort handler for CT
|
|
|
|
* protocol.
|
|
|
|
*
|
|
|
|
* Return 1 if abort has been handled, 0 otherwise.
|
2009-10-03 03:16:45 +08:00
|
|
|
**/
|
2013-01-04 04:43:37 +08:00
|
|
|
int
|
|
|
|
lpfc_ct_handle_unsol_abort(struct lpfc_hba *phba, struct hbq_dmabuf *dmabuf)
|
2009-10-03 03:16:45 +08:00
|
|
|
{
|
2013-01-04 04:43:37 +08:00
|
|
|
int handled;
|
2009-10-03 03:16:45 +08:00
|
|
|
|
2013-01-04 04:43:37 +08:00
|
|
|
/* CT upper level goes through BSG */
|
|
|
|
handled = lpfc_bsg_ct_unsol_abort(phba, dmabuf);
|
2009-10-03 03:16:45 +08:00
|
|
|
|
2013-01-04 04:43:37 +08:00
|
|
|
return handled;
|
2009-10-03 03:16:45 +08:00
|
|
|
}
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
static void
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_free_ct_rsp(struct lpfc_hba *phba, struct lpfc_dmabuf *mlist)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
|
|
|
struct lpfc_dmabuf *mlast, *next_mlast;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(mlast, next_mlast, &mlist->list, list) {
|
|
|
|
lpfc_mbuf_free(phba, mlast->virt, mlast->phys);
|
|
|
|
list_del(&mlast->list);
|
|
|
|
kfree(mlast);
|
|
|
|
}
|
|
|
|
lpfc_mbuf_free(phba, mlist->virt, mlist->phys);
|
|
|
|
kfree(mlist);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct lpfc_dmabuf *
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_alloc_ct_rsp(struct lpfc_hba *phba, int cmdcode, struct ulp_bde64 *bpl,
|
2005-04-18 05:05:31 +08:00
|
|
|
uint32_t size, int *entries)
|
|
|
|
{
|
|
|
|
struct lpfc_dmabuf *mlist = NULL;
|
|
|
|
struct lpfc_dmabuf *mp;
|
|
|
|
int cnt, i = 0;
|
|
|
|
|
2008-01-11 14:52:54 +08:00
|
|
|
/* We get chunks of FCELSSIZE */
|
2005-04-18 05:05:31 +08:00
|
|
|
cnt = size > FCELSSIZE ? FCELSSIZE: size;
|
|
|
|
|
|
|
|
while (size) {
|
|
|
|
/* Allocate buffer for rsp payload */
|
|
|
|
mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
|
|
|
|
if (!mp) {
|
|
|
|
if (mlist)
|
|
|
|
lpfc_free_ct_rsp(phba, mlist);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&mp->list);
|
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
if (cmdcode == be16_to_cpu(SLI_CTNS_GID_FT) ||
|
|
|
|
cmdcode == be16_to_cpu(SLI_CTNS_GFF_ID))
|
2005-04-18 05:05:31 +08:00
|
|
|
mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys));
|
|
|
|
else
|
|
|
|
mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys));
|
|
|
|
|
|
|
|
if (!mp->virt) {
|
|
|
|
kfree(mp);
|
2006-10-11 05:41:43 +08:00
|
|
|
if (mlist)
|
|
|
|
lpfc_free_ct_rsp(phba, mlist);
|
2005-04-18 05:05:31 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Queue it to a linked list */
|
|
|
|
if (!mlist)
|
|
|
|
mlist = mp;
|
|
|
|
else
|
|
|
|
list_add_tail(&mp->list, &mlist->list);
|
|
|
|
|
2008-08-25 09:49:55 +08:00
|
|
|
bpl->tus.f.bdeFlags = BUFF_TYPE_BDE_64I;
|
2005-04-18 05:05:31 +08:00
|
|
|
/* build buffer ptr list for IOCB */
|
2007-06-18 08:56:38 +08:00
|
|
|
bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) );
|
|
|
|
bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) );
|
2005-04-18 05:05:31 +08:00
|
|
|
bpl->tus.f.bdeSize = (uint16_t) cnt;
|
|
|
|
bpl->tus.w = le32_to_cpu(bpl->tus.w);
|
|
|
|
bpl++;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
size -= cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
*entries = i;
|
|
|
|
return mlist;
|
|
|
|
}
|
|
|
|
|
2007-06-18 08:56:39 +08:00
|
|
|
int
|
|
|
|
lpfc_ct_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocb)
|
|
|
|
{
|
|
|
|
struct lpfc_dmabuf *buf_ptr;
|
|
|
|
|
2007-08-02 23:10:31 +08:00
|
|
|
if (ctiocb->context_un.ndlp) {
|
|
|
|
lpfc_nlp_put(ctiocb->context_un.ndlp);
|
|
|
|
ctiocb->context_un.ndlp = NULL;
|
|
|
|
}
|
2007-06-18 08:56:39 +08:00
|
|
|
if (ctiocb->context1) {
|
|
|
|
buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1;
|
|
|
|
lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
|
|
|
|
kfree(buf_ptr);
|
|
|
|
ctiocb->context1 = NULL;
|
|
|
|
}
|
|
|
|
if (ctiocb->context2) {
|
|
|
|
lpfc_free_ct_rsp(phba, (struct lpfc_dmabuf *) ctiocb->context2);
|
|
|
|
ctiocb->context2 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctiocb->context3) {
|
|
|
|
buf_ptr = (struct lpfc_dmabuf *) ctiocb->context3;
|
|
|
|
lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
|
|
|
|
kfree(buf_ptr);
|
2013-10-16 08:29:50 +08:00
|
|
|
ctiocb->context3 = NULL;
|
2007-06-18 08:56:39 +08:00
|
|
|
}
|
|
|
|
lpfc_sli_release_iocbq(phba, ctiocb);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
static int
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp,
|
2005-04-18 05:05:31 +08:00
|
|
|
struct lpfc_dmabuf *inp, struct lpfc_dmabuf *outp,
|
|
|
|
void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
|
|
|
|
struct lpfc_iocbq *),
|
|
|
|
struct lpfc_nodelist *ndlp, uint32_t usr_flg, uint32_t num_entry,
|
2007-06-18 08:56:38 +08:00
|
|
|
uint32_t tmo, uint8_t retry)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
2007-06-18 08:56:36 +08:00
|
|
|
struct lpfc_hba *phba = vport->phba;
|
2005-04-18 05:05:31 +08:00
|
|
|
IOCB_t *icmd;
|
2005-10-29 08:30:02 +08:00
|
|
|
struct lpfc_iocbq *geniocb;
|
2007-06-18 08:56:38 +08:00
|
|
|
int rc;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* Allocate buffer for command iocb */
|
2005-10-29 08:30:02 +08:00
|
|
|
geniocb = lpfc_sli_get_iocbq(phba);
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
if (geniocb == NULL)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
icmd = &geniocb->iocb;
|
|
|
|
icmd->un.genreq64.bdl.ulpIoTag32 = 0;
|
|
|
|
icmd->un.genreq64.bdl.addrHigh = putPaddrHigh(bmp->phys);
|
|
|
|
icmd->un.genreq64.bdl.addrLow = putPaddrLow(bmp->phys);
|
2008-08-25 09:49:55 +08:00
|
|
|
icmd->un.genreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64;
|
2005-04-18 05:05:31 +08:00
|
|
|
icmd->un.genreq64.bdl.bdeSize = (num_entry * sizeof (struct ulp_bde64));
|
|
|
|
|
|
|
|
if (usr_flg)
|
|
|
|
geniocb->context3 = NULL;
|
|
|
|
else
|
|
|
|
geniocb->context3 = (uint8_t *) bmp;
|
|
|
|
|
|
|
|
/* Save for completion so we can release these resources */
|
|
|
|
geniocb->context1 = (uint8_t *) inp;
|
|
|
|
geniocb->context2 = (uint8_t *) outp;
|
2008-02-09 07:49:26 +08:00
|
|
|
geniocb->context_un.ndlp = lpfc_nlp_get(ndlp);
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* Fill in payload, bp points to frame payload */
|
|
|
|
icmd->ulpCommand = CMD_GEN_REQUEST64_CR;
|
|
|
|
|
|
|
|
/* Fill in rest of iocb */
|
|
|
|
icmd->un.genreq64.w5.hcsw.Fctl = (SI | LA);
|
|
|
|
icmd->un.genreq64.w5.hcsw.Dfctl = 0;
|
2009-10-03 03:16:51 +08:00
|
|
|
icmd->un.genreq64.w5.hcsw.Rctl = FC_RCTL_DD_UNSOL_CTL;
|
|
|
|
icmd->un.genreq64.w5.hcsw.Type = FC_TYPE_CT;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2006-03-01 08:25:23 +08:00
|
|
|
if (!tmo) {
|
|
|
|
/* FC spec states we need 3 * ratov for CT requests */
|
|
|
|
tmo = (3 * phba->fc_ratov);
|
|
|
|
}
|
2005-04-18 05:05:31 +08:00
|
|
|
icmd->ulpTimeout = tmo;
|
|
|
|
icmd->ulpBdeCount = 1;
|
|
|
|
icmd->ulpLe = 1;
|
|
|
|
icmd->ulpClass = CLASS3;
|
|
|
|
icmd->ulpContext = ndlp->nlp_rpi;
|
2011-05-24 23:44:12 +08:00
|
|
|
if (phba->sli_rev == LPFC_SLI_REV4)
|
|
|
|
icmd->ulpContext = phba->sli4_hba.rpi_ids[ndlp->nlp_rpi];
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) {
|
|
|
|
/* For GEN_REQUEST64_CR, use the RPI */
|
|
|
|
icmd->ulpCt_h = 0;
|
|
|
|
icmd->ulpCt_l = 0;
|
|
|
|
}
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
/* Issue GEN REQ IOCB for NPORT <did> */
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
|
|
|
|
"0119 Issue GEN REQ IOCB to NPORT x%x "
|
|
|
|
"Data: x%x x%x\n",
|
|
|
|
ndlp->nlp_DID, icmd->ulpIoTag,
|
|
|
|
vport->port_state);
|
2005-04-18 05:05:31 +08:00
|
|
|
geniocb->iocb_cmpl = cmpl;
|
|
|
|
geniocb->drvrTimeout = icmd->ulpTimeout + LPFC_DRVR_TIMEOUT;
|
2007-06-18 08:56:36 +08:00
|
|
|
geniocb->vport = vport;
|
2007-06-18 08:56:38 +08:00
|
|
|
geniocb->retry = retry;
|
[SCSI] lpfc 8.3.2 : Reorganization for SLI4
Preps the organization of the driver so that the bottom half, which
interacts with the hardware, can share common code sequences for
attachment, detachment, initialization, teardown, etc with new hardware.
For very common code sections, which become specific to the interface
type, the driver uses an indirect function call. The function is set at
initialization. For less common sections, such as initialization, the
driver looks at the interface type and calls the routines relative to
the interface.
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2009-05-23 02:50:54 +08:00
|
|
|
rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, geniocb, 0);
|
2007-06-18 08:56:38 +08:00
|
|
|
|
|
|
|
if (rc == IOCB_ERROR) {
|
2005-10-29 23:28:33 +08:00
|
|
|
lpfc_sli_release_iocbq(phba, geniocb);
|
2005-04-18 05:05:31 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_ct_cmd(struct lpfc_vport *vport, struct lpfc_dmabuf *inmp,
|
2005-04-18 05:05:31 +08:00
|
|
|
struct lpfc_dmabuf *bmp, struct lpfc_nodelist *ndlp,
|
|
|
|
void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
|
|
|
|
struct lpfc_iocbq *),
|
2007-06-18 08:56:38 +08:00
|
|
|
uint32_t rsp_size, uint8_t retry)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
2007-06-18 08:56:36 +08:00
|
|
|
struct lpfc_hba *phba = vport->phba;
|
2005-04-18 05:05:31 +08:00
|
|
|
struct ulp_bde64 *bpl = (struct ulp_bde64 *) bmp->virt;
|
|
|
|
struct lpfc_dmabuf *outmp;
|
|
|
|
int cnt = 0, status;
|
|
|
|
int cmdcode = ((struct lpfc_sli_ct_request *) inmp->virt)->
|
|
|
|
CommandResponse.bits.CmdRsp;
|
|
|
|
|
|
|
|
bpl++; /* Skip past ct request */
|
|
|
|
|
|
|
|
/* Put buffer(s) for ct rsp in bpl */
|
|
|
|
outmp = lpfc_alloc_ct_rsp(phba, cmdcode, bpl, rsp_size, &cnt);
|
|
|
|
if (!outmp)
|
|
|
|
return -ENOMEM;
|
2009-10-03 03:16:51 +08:00
|
|
|
/*
|
|
|
|
* Form the CT IOCB. The total number of BDEs in this IOCB
|
|
|
|
* is the single command plus response count from
|
|
|
|
* lpfc_alloc_ct_rsp.
|
|
|
|
*/
|
|
|
|
cnt += 1;
|
2007-06-18 08:56:36 +08:00
|
|
|
status = lpfc_gen_req(vport, bmp, inmp, outmp, cmpl, ndlp, 0,
|
2009-10-03 03:16:51 +08:00
|
|
|
cnt, 0, retry);
|
2005-04-18 05:05:31 +08:00
|
|
|
if (status) {
|
|
|
|
lpfc_free_ct_rsp(phba, outmp);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-02 23:09:51 +08:00
|
|
|
struct lpfc_vport *
|
2007-06-18 08:56:38 +08:00
|
|
|
lpfc_find_vport_by_did(struct lpfc_hba *phba, uint32_t did) {
|
|
|
|
struct lpfc_vport *vport_curr;
|
2007-08-02 23:09:51 +08:00
|
|
|
unsigned long flags;
|
2007-06-18 08:56:38 +08:00
|
|
|
|
2007-08-02 23:09:51 +08:00
|
|
|
spin_lock_irqsave(&phba->hbalock, flags);
|
2007-06-18 08:56:38 +08:00
|
|
|
list_for_each_entry(vport_curr, &phba->port_list, listentry) {
|
2007-08-02 23:09:51 +08:00
|
|
|
if ((vport_curr->fc_myDID) && (vport_curr->fc_myDID == did)) {
|
|
|
|
spin_unlock_irqrestore(&phba->hbalock, flags);
|
2007-06-18 08:56:38 +08:00
|
|
|
return vport_curr;
|
2007-08-02 23:09:51 +08:00
|
|
|
}
|
2007-06-18 08:56:38 +08:00
|
|
|
}
|
2007-08-02 23:09:51 +08:00
|
|
|
spin_unlock_irqrestore(&phba->hbalock, flags);
|
2007-06-18 08:56:38 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
static int
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
2007-06-18 08:56:36 +08:00
|
|
|
struct lpfc_hba *phba = vport->phba;
|
2005-04-18 05:05:31 +08:00
|
|
|
struct lpfc_sli_ct_request *Response =
|
|
|
|
(struct lpfc_sli_ct_request *) mp->virt;
|
|
|
|
struct lpfc_nodelist *ndlp = NULL;
|
|
|
|
struct lpfc_dmabuf *mlast, *next_mp;
|
|
|
|
uint32_t *ctptr = (uint32_t *) & Response->un.gid.PortType;
|
2007-06-18 08:56:36 +08:00
|
|
|
uint32_t Did, CTentry;
|
2005-04-18 05:05:31 +08:00
|
|
|
int Cnt;
|
|
|
|
struct list_head head;
|
|
|
|
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_set_disctmo(vport);
|
2007-06-18 08:56:38 +08:00
|
|
|
vport->num_disc_nodes = 0;
|
2008-01-11 14:52:36 +08:00
|
|
|
vport->fc_ns_retry = 0;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
list_add_tail(&head, &mp->list);
|
|
|
|
list_for_each_entry_safe(mp, next_mp, &head, list) {
|
|
|
|
mlast = mp;
|
|
|
|
|
2007-04-25 21:52:34 +08:00
|
|
|
Cnt = Size > FCELSSIZE ? FCELSSIZE : Size;
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
Size -= Cnt;
|
|
|
|
|
2007-04-25 21:51:30 +08:00
|
|
|
if (!ctptr) {
|
2005-04-18 05:05:31 +08:00
|
|
|
ctptr = (uint32_t *) mlast->virt;
|
2007-04-25 21:51:30 +08:00
|
|
|
} else
|
2005-04-18 05:05:31 +08:00
|
|
|
Cnt -= 16; /* subtract length of CT header */
|
|
|
|
|
|
|
|
/* Loop through entire NameServer list of DIDs */
|
2007-04-25 21:52:34 +08:00
|
|
|
while (Cnt >= sizeof (uint32_t)) {
|
2005-04-18 05:05:31 +08:00
|
|
|
/* Get next DID from NameServer List */
|
|
|
|
CTentry = *ctptr++;
|
|
|
|
Did = ((be32_to_cpu(CTentry)) & Mask_DID);
|
2007-06-18 08:56:38 +08:00
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
ndlp = NULL;
|
2007-06-18 08:56:38 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for rscn processing or not
|
|
|
|
* To conserve rpi's, filter out addresses for other
|
|
|
|
* vports on the same physical HBAs.
|
|
|
|
*/
|
|
|
|
if ((Did != vport->fc_myDID) &&
|
|
|
|
((lpfc_find_vport_by_did(phba, Did) == NULL) ||
|
2007-08-02 23:09:59 +08:00
|
|
|
vport->cfg_peer_port_login)) {
|
2007-06-18 08:56:38 +08:00
|
|
|
if ((vport->port_type != LPFC_NPIV_PORT) ||
|
2007-10-28 01:37:33 +08:00
|
|
|
(!(vport->ct_flags & FC_CT_RFF_ID)) ||
|
2007-08-02 23:09:59 +08:00
|
|
|
(!vport->cfg_restrict_login)) {
|
2007-06-18 08:56:38 +08:00
|
|
|
ndlp = lpfc_setup_disc_node(vport, Did);
|
2008-04-07 22:15:56 +08:00
|
|
|
if (ndlp && NLP_CHK_NODE_ACT(ndlp)) {
|
2007-06-18 08:56:39 +08:00
|
|
|
lpfc_debugfs_disc_trc(vport,
|
|
|
|
LPFC_DISC_TRC_CT,
|
|
|
|
"Parse GID_FTrsp: "
|
|
|
|
"did:x%x flg:x%x x%x",
|
|
|
|
Did, ndlp->nlp_flag,
|
|
|
|
vport->fc_flag);
|
|
|
|
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport,
|
|
|
|
KERN_INFO,
|
2007-06-18 08:56:38 +08:00
|
|
|
LOG_DISCOVERY,
|
2007-08-02 23:10:09 +08:00
|
|
|
"0238 Process "
|
2007-06-18 08:56:38 +08:00
|
|
|
"x%x NameServer Rsp"
|
|
|
|
"Data: x%x x%x x%x\n",
|
2007-08-02 23:10:09 +08:00
|
|
|
Did, ndlp->nlp_flag,
|
2007-06-18 08:56:38 +08:00
|
|
|
vport->fc_flag,
|
|
|
|
vport->fc_rscn_id_cnt);
|
|
|
|
} else {
|
2007-06-18 08:56:39 +08:00
|
|
|
lpfc_debugfs_disc_trc(vport,
|
|
|
|
LPFC_DISC_TRC_CT,
|
|
|
|
"Skip1 GID_FTrsp: "
|
|
|
|
"did:x%x flg:x%x cnt:%d",
|
|
|
|
Did, vport->fc_flag,
|
|
|
|
vport->fc_rscn_id_cnt);
|
|
|
|
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport,
|
|
|
|
KERN_INFO,
|
2007-06-18 08:56:38 +08:00
|
|
|
LOG_DISCOVERY,
|
2007-08-02 23:10:09 +08:00
|
|
|
"0239 Skip x%x "
|
2007-06-18 08:56:38 +08:00
|
|
|
"NameServer Rsp Data: "
|
|
|
|
"x%x x%x\n",
|
2007-08-02 23:10:09 +08:00
|
|
|
Did, vport->fc_flag,
|
2007-06-18 08:56:38 +08:00
|
|
|
vport->fc_rscn_id_cnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (!(vport->fc_flag & FC_RSCN_MODE) ||
|
|
|
|
(lpfc_rscn_payload_check(vport, Did))) {
|
2007-06-18 08:56:39 +08:00
|
|
|
lpfc_debugfs_disc_trc(vport,
|
|
|
|
LPFC_DISC_TRC_CT,
|
|
|
|
"Query GID_FTrsp: "
|
|
|
|
"did:x%x flg:x%x cnt:%d",
|
|
|
|
Did, vport->fc_flag,
|
|
|
|
vport->fc_rscn_id_cnt);
|
|
|
|
|
2008-01-11 14:52:36 +08:00
|
|
|
/* This NPortID was previously
|
|
|
|
* a FCP target, * Don't even
|
|
|
|
* bother to send GFF_ID.
|
|
|
|
*/
|
|
|
|
ndlp = lpfc_findnode_did(vport,
|
|
|
|
Did);
|
2008-02-09 07:49:26 +08:00
|
|
|
if (ndlp &&
|
|
|
|
NLP_CHK_NODE_ACT(ndlp)
|
|
|
|
&& (ndlp->nlp_type &
|
|
|
|
NLP_FCP_TARGET))
|
2008-01-11 14:52:36 +08:00
|
|
|
lpfc_setup_disc_node
|
|
|
|
(vport, Did);
|
|
|
|
else if (lpfc_ns_cmd(vport,
|
2007-06-18 08:56:38 +08:00
|
|
|
SLI_CTNS_GFF_ID,
|
|
|
|
0, Did) == 0)
|
|
|
|
vport->num_disc_nodes++;
|
2009-10-03 03:16:51 +08:00
|
|
|
else
|
|
|
|
lpfc_setup_disc_node
|
|
|
|
(vport, Did);
|
2007-06-18 08:56:38 +08:00
|
|
|
}
|
|
|
|
else {
|
2007-06-18 08:56:39 +08:00
|
|
|
lpfc_debugfs_disc_trc(vport,
|
|
|
|
LPFC_DISC_TRC_CT,
|
|
|
|
"Skip2 GID_FTrsp: "
|
|
|
|
"did:x%x flg:x%x cnt:%d",
|
|
|
|
Did, vport->fc_flag,
|
|
|
|
vport->fc_rscn_id_cnt);
|
|
|
|
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport,
|
|
|
|
KERN_INFO,
|
2007-06-18 08:56:38 +08:00
|
|
|
LOG_DISCOVERY,
|
2007-08-02 23:10:09 +08:00
|
|
|
"0245 Skip x%x "
|
2007-06-18 08:56:38 +08:00
|
|
|
"NameServer Rsp Data: "
|
|
|
|
"x%x x%x\n",
|
2007-08-02 23:10:09 +08:00
|
|
|
Did, vport->fc_flag,
|
2007-06-18 08:56:38 +08:00
|
|
|
vport->fc_rscn_id_cnt);
|
|
|
|
}
|
|
|
|
}
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
2015-04-08 03:07:19 +08:00
|
|
|
if (CTentry & (cpu_to_be32(SLI_CT_LAST_ENTRY)))
|
2005-04-18 05:05:31 +08:00
|
|
|
goto nsout1;
|
|
|
|
Cnt -= sizeof (uint32_t);
|
|
|
|
}
|
|
|
|
ctptr = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
nsout1:
|
|
|
|
list_del(&head);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|
|
|
struct lpfc_iocbq *rspiocb)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
2007-06-18 08:56:36 +08:00
|
|
|
struct lpfc_vport *vport = cmdiocb->vport;
|
2007-06-18 08:56:38 +08:00
|
|
|
struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
|
2005-04-18 05:05:31 +08:00
|
|
|
IOCB_t *irsp;
|
|
|
|
struct lpfc_dmabuf *outp;
|
|
|
|
struct lpfc_sli_ct_request *CTrsp;
|
2007-08-02 23:10:31 +08:00
|
|
|
struct lpfc_nodelist *ndlp;
|
2008-04-07 22:15:56 +08:00
|
|
|
int rc;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2007-08-02 23:10:31 +08:00
|
|
|
/* First save ndlp, before we overwrite it */
|
|
|
|
ndlp = cmdiocb->context_un.ndlp;
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
/* we pass cmdiocb to state machine which needs rspiocb as well */
|
|
|
|
cmdiocb->context_un.rsp_iocb = rspiocb;
|
|
|
|
|
|
|
|
outp = (struct lpfc_dmabuf *) cmdiocb->context2;
|
2007-06-18 08:56:39 +08:00
|
|
|
irsp = &rspiocb->iocb;
|
|
|
|
|
|
|
|
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
|
|
|
|
"GID_FT cmpl: status:x%x/x%x rtry:%d",
|
|
|
|
irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_ns_retry);
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
/* Don't bother processing response if vport is being torn down. */
|
2008-12-05 11:39:13 +08:00
|
|
|
if (vport->load_flag & FC_UNLOADING) {
|
|
|
|
if (vport->fc_flag & FC_RSCN_MODE)
|
|
|
|
lpfc_els_flush_rscn(vport);
|
2007-06-18 08:56:38 +08:00
|
|
|
goto out;
|
2008-12-05 11:39:13 +08:00
|
|
|
}
|
2007-06-18 08:56:38 +08:00
|
|
|
|
2008-04-07 22:15:56 +08:00
|
|
|
if (lpfc_els_chk_latt(vport)) {
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
|
|
|
|
"0216 Link event during NS query\n");
|
2008-12-05 11:39:13 +08:00
|
|
|
if (vport->fc_flag & FC_RSCN_MODE)
|
|
|
|
lpfc_els_flush_rscn(vport);
|
2007-06-18 08:56:39 +08:00
|
|
|
lpfc_vport_set_state(vport, FC_VPORT_FAILED);
|
|
|
|
goto out;
|
|
|
|
}
|
2008-04-07 22:15:56 +08:00
|
|
|
if (lpfc_error_lost_link(irsp)) {
|
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
|
|
|
|
"0226 NS query failed due to link event\n");
|
2008-12-05 11:39:13 +08:00
|
|
|
if (vport->fc_flag & FC_RSCN_MODE)
|
|
|
|
lpfc_els_flush_rscn(vport);
|
2008-04-07 22:15:56 +08:00
|
|
|
goto out;
|
|
|
|
}
|
2007-06-18 08:56:39 +08:00
|
|
|
if (irsp->ulpStatus) {
|
2005-04-18 05:05:31 +08:00
|
|
|
/* Check for retry */
|
2007-06-18 08:56:36 +08:00
|
|
|
if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) {
|
2008-04-07 22:15:56 +08:00
|
|
|
if (irsp->ulpStatus != IOSTAT_LOCAL_REJECT ||
|
2012-11-01 02:45:21 +08:00
|
|
|
(irsp->un.ulpWord[4] & IOERR_PARAM_MASK) !=
|
2012-08-15 02:25:43 +08:00
|
|
|
IOERR_NO_RESOURCES)
|
2007-06-18 08:56:39 +08:00
|
|
|
vport->fc_ns_retry++;
|
2008-01-11 14:52:36 +08:00
|
|
|
|
2008-04-07 22:15:56 +08:00
|
|
|
/* CT command is being retried */
|
|
|
|
rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT,
|
2007-06-18 08:56:38 +08:00
|
|
|
vport->fc_ns_retry, 0);
|
2008-04-07 22:15:56 +08:00
|
|
|
if (rc == 0)
|
|
|
|
goto out;
|
2007-06-18 08:56:38 +08:00
|
|
|
}
|
2008-12-05 11:39:13 +08:00
|
|
|
if (vport->fc_flag & FC_RSCN_MODE)
|
|
|
|
lpfc_els_flush_rscn(vport);
|
2007-06-18 08:56:38 +08:00
|
|
|
lpfc_vport_set_state(vport, FC_VPORT_FAILED);
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
|
|
|
|
"0257 GID_FT Query error: 0x%x 0x%x\n",
|
|
|
|
irsp->ulpStatus, vport->fc_ns_retry);
|
2005-04-18 05:05:31 +08:00
|
|
|
} else {
|
|
|
|
/* Good status, continue checking */
|
|
|
|
CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
|
|
|
|
if (CTrsp->CommandResponse.bits.CmdRsp ==
|
2015-04-08 03:07:19 +08:00
|
|
|
cpu_to_be16(SLI_CT_RESPONSE_FS_ACC)) {
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
|
|
|
|
"0208 NameServer Rsp Data: x%x\n",
|
|
|
|
vport->fc_flag);
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_ns_rsp(vport, outp,
|
2005-04-18 05:05:31 +08:00
|
|
|
(uint32_t) (irsp->un.genreq64.bdl.bdeSize));
|
|
|
|
} else if (CTrsp->CommandResponse.bits.CmdRsp ==
|
|
|
|
be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
|
|
|
|
/* NameServer Rsp Error */
|
2007-08-02 23:09:43 +08:00
|
|
|
if ((CTrsp->ReasonCode == SLI_CT_UNABLE_TO_PERFORM_REQ)
|
|
|
|
&& (CTrsp->Explanation == SLI_CT_NO_FC4_TYPES)) {
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO,
|
|
|
|
LOG_DISCOVERY,
|
|
|
|
"0269 No NameServer Entries "
|
2007-08-02 23:09:43 +08:00
|
|
|
"Data: x%x x%x x%x x%x\n",
|
|
|
|
CTrsp->CommandResponse.bits.CmdRsp,
|
|
|
|
(uint32_t) CTrsp->ReasonCode,
|
|
|
|
(uint32_t) CTrsp->Explanation,
|
|
|
|
vport->fc_flag);
|
|
|
|
|
|
|
|
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
|
|
|
|
"GID_FT no entry cmd:x%x rsn:x%x exp:x%x",
|
|
|
|
(uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
|
|
|
|
(uint32_t) CTrsp->ReasonCode,
|
|
|
|
(uint32_t) CTrsp->Explanation);
|
2007-08-02 23:10:09 +08:00
|
|
|
} else {
|
|
|
|
lpfc_printf_vlog(vport, KERN_INFO,
|
|
|
|
LOG_DISCOVERY,
|
|
|
|
"0240 NameServer Rsp Error "
|
2005-04-18 05:05:31 +08:00
|
|
|
"Data: x%x x%x x%x x%x\n",
|
|
|
|
CTrsp->CommandResponse.bits.CmdRsp,
|
|
|
|
(uint32_t) CTrsp->ReasonCode,
|
|
|
|
(uint32_t) CTrsp->Explanation,
|
2007-06-18 08:56:36 +08:00
|
|
|
vport->fc_flag);
|
2007-06-18 08:56:39 +08:00
|
|
|
|
2007-08-02 23:09:43 +08:00
|
|
|
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
|
2007-06-18 08:56:39 +08:00
|
|
|
"GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x",
|
|
|
|
(uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
|
|
|
|
(uint32_t) CTrsp->ReasonCode,
|
|
|
|
(uint32_t) CTrsp->Explanation);
|
2007-08-02 23:09:43 +08:00
|
|
|
}
|
|
|
|
|
2007-06-18 08:56:39 +08:00
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
} else {
|
|
|
|
/* NameServer Rsp Error */
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
|
|
|
|
"0241 NameServer Rsp Error "
|
2005-04-18 05:05:31 +08:00
|
|
|
"Data: x%x x%x x%x x%x\n",
|
|
|
|
CTrsp->CommandResponse.bits.CmdRsp,
|
|
|
|
(uint32_t) CTrsp->ReasonCode,
|
|
|
|
(uint32_t) CTrsp->Explanation,
|
2007-06-18 08:56:36 +08:00
|
|
|
vport->fc_flag);
|
2007-06-18 08:56:39 +08:00
|
|
|
|
|
|
|
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
|
|
|
|
"GID_FT rsp err2 cmd:x%x rsn:x%x exp:x%x",
|
|
|
|
(uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
|
|
|
|
(uint32_t) CTrsp->ReasonCode,
|
|
|
|
(uint32_t) CTrsp->Explanation);
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Link up / RSCN discovery */
|
2007-06-18 08:56:38 +08:00
|
|
|
if (vport->num_disc_nodes == 0) {
|
|
|
|
/*
|
|
|
|
* The driver has cycled through all Nports in the RSCN payload.
|
|
|
|
* Complete the handling by cleaning up and marking the
|
|
|
|
* current driver state.
|
|
|
|
*/
|
|
|
|
if (vport->port_state >= LPFC_DISC_AUTH) {
|
|
|
|
if (vport->fc_flag & FC_RSCN_MODE) {
|
|
|
|
lpfc_els_flush_rscn(vport);
|
|
|
|
spin_lock_irq(shost->host_lock);
|
|
|
|
vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */
|
|
|
|
spin_unlock_irq(shost->host_lock);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
lpfc_els_flush_rscn(vport);
|
|
|
|
}
|
|
|
|
|
|
|
|
lpfc_disc_start(vport);
|
|
|
|
}
|
|
|
|
out:
|
2007-08-02 23:10:31 +08:00
|
|
|
cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */
|
2007-06-18 08:56:39 +08:00
|
|
|
lpfc_ct_free_iocb(phba, cmdiocb);
|
2007-06-18 08:56:38 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-02 23:10:37 +08:00
|
|
|
static void
|
2007-06-18 08:56:38 +08:00
|
|
|
lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|
|
|
struct lpfc_iocbq *rspiocb)
|
|
|
|
{
|
|
|
|
struct lpfc_vport *vport = cmdiocb->vport;
|
|
|
|
struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
|
|
|
|
IOCB_t *irsp = &rspiocb->iocb;
|
|
|
|
struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1;
|
|
|
|
struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2;
|
|
|
|
struct lpfc_sli_ct_request *CTrsp;
|
2008-01-11 14:52:36 +08:00
|
|
|
int did, rc, retry;
|
2007-06-18 08:56:38 +08:00
|
|
|
uint8_t fbits;
|
|
|
|
struct lpfc_nodelist *ndlp;
|
|
|
|
|
|
|
|
did = ((struct lpfc_sli_ct_request *) inp->virt)->un.gff.PortId;
|
|
|
|
did = be32_to_cpu(did);
|
|
|
|
|
2007-06-18 08:56:39 +08:00
|
|
|
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
|
|
|
|
"GFF_ID cmpl: status:x%x/x%x did:x%x",
|
|
|
|
irsp->ulpStatus, irsp->un.ulpWord[4], did);
|
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
if (irsp->ulpStatus == IOSTAT_SUCCESS) {
|
|
|
|
/* Good status, continue checking */
|
|
|
|
CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
|
|
|
|
fbits = CTrsp->un.gff_acc.fbits[FCP_TYPE_FEATURE_OFFSET];
|
|
|
|
|
|
|
|
if (CTrsp->CommandResponse.bits.CmdRsp ==
|
|
|
|
be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) {
|
|
|
|
if ((fbits & FC4_FEATURE_INIT) &&
|
|
|
|
!(fbits & FC4_FEATURE_TARGET)) {
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO,
|
|
|
|
LOG_DISCOVERY,
|
|
|
|
"0270 Skip x%x GFF "
|
|
|
|
"NameServer Rsp Data: (init) "
|
|
|
|
"x%x x%x\n", did, fbits,
|
|
|
|
vport->fc_rscn_id_cnt);
|
2007-06-18 08:56:38 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-06-18 08:56:39 +08:00
|
|
|
else {
|
2008-01-11 14:52:36 +08:00
|
|
|
/* Check for retry */
|
|
|
|
if (cmdiocb->retry < LPFC_MAX_NS_RETRY) {
|
|
|
|
retry = 1;
|
|
|
|
if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) {
|
2012-08-15 02:25:43 +08:00
|
|
|
switch ((irsp->un.ulpWord[4] &
|
|
|
|
IOERR_PARAM_MASK)) {
|
|
|
|
|
2008-01-11 14:52:36 +08:00
|
|
|
case IOERR_NO_RESOURCES:
|
|
|
|
/* We don't increment the retry
|
|
|
|
* count for this case.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
case IOERR_LINK_DOWN:
|
|
|
|
case IOERR_SLI_ABORTED:
|
|
|
|
case IOERR_SLI_DOWN:
|
|
|
|
retry = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cmdiocb->retry++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cmdiocb->retry++;
|
|
|
|
|
|
|
|
if (retry) {
|
|
|
|
/* CT command is being retried */
|
|
|
|
rc = lpfc_ns_cmd(vport, SLI_CTNS_GFF_ID,
|
|
|
|
cmdiocb->retry, did);
|
|
|
|
if (rc == 0) {
|
|
|
|
/* success */
|
|
|
|
lpfc_ct_free_iocb(phba, cmdiocb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
|
|
|
|
"0267 NameServer GFF Rsp "
|
|
|
|
"x%x Error (%d %d) Data: x%x x%x\n",
|
|
|
|
did, irsp->ulpStatus, irsp->un.ulpWord[4],
|
2008-02-09 07:50:14 +08:00
|
|
|
vport->fc_flag, vport->fc_rscn_id_cnt);
|
2007-06-18 08:56:39 +08:00
|
|
|
}
|
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
/* This is a target port, unregistered port, or the GFF_ID failed */
|
|
|
|
ndlp = lpfc_setup_disc_node(vport, did);
|
2008-04-07 22:15:56 +08:00
|
|
|
if (ndlp && NLP_CHK_NODE_ACT(ndlp)) {
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
|
|
|
|
"0242 Process x%x GFF "
|
|
|
|
"NameServer Rsp Data: x%x x%x x%x\n",
|
|
|
|
did, ndlp->nlp_flag, vport->fc_flag,
|
|
|
|
vport->fc_rscn_id_cnt);
|
2007-06-18 08:56:38 +08:00
|
|
|
} else {
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
|
|
|
|
"0243 Skip x%x GFF "
|
|
|
|
"NameServer Rsp Data: x%x x%x\n", did,
|
|
|
|
vport->fc_flag, vport->fc_rscn_id_cnt);
|
2007-06-18 08:56:38 +08:00
|
|
|
}
|
2005-04-18 05:05:31 +08:00
|
|
|
out:
|
2007-06-18 08:56:38 +08:00
|
|
|
/* Link up / RSCN discovery */
|
|
|
|
if (vport->num_disc_nodes)
|
|
|
|
vport->num_disc_nodes--;
|
|
|
|
if (vport->num_disc_nodes == 0) {
|
|
|
|
/*
|
|
|
|
* The driver has cycled through all Nports in the RSCN payload.
|
|
|
|
* Complete the handling by cleaning up and marking the
|
|
|
|
* current driver state.
|
|
|
|
*/
|
|
|
|
if (vport->port_state >= LPFC_DISC_AUTH) {
|
|
|
|
if (vport->fc_flag & FC_RSCN_MODE) {
|
|
|
|
lpfc_els_flush_rscn(vport);
|
|
|
|
spin_lock_irq(shost->host_lock);
|
|
|
|
vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */
|
|
|
|
spin_unlock_irq(shost->host_lock);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
lpfc_els_flush_rscn(vport);
|
|
|
|
}
|
|
|
|
lpfc_disc_start(vport);
|
|
|
|
}
|
2007-06-18 08:56:39 +08:00
|
|
|
lpfc_ct_free_iocb(phba, cmdiocb);
|
2005-04-18 05:05:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
static void
|
2007-10-28 01:37:17 +08:00
|
|
|
lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|
|
|
struct lpfc_iocbq *rspiocb)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
2007-06-18 08:56:38 +08:00
|
|
|
struct lpfc_vport *vport = cmdiocb->vport;
|
2005-04-18 05:05:31 +08:00
|
|
|
struct lpfc_dmabuf *inp;
|
|
|
|
struct lpfc_dmabuf *outp;
|
|
|
|
IOCB_t *irsp;
|
|
|
|
struct lpfc_sli_ct_request *CTrsp;
|
2007-08-02 23:10:31 +08:00
|
|
|
struct lpfc_nodelist *ndlp;
|
2007-06-18 08:56:38 +08:00
|
|
|
int cmdcode, rc;
|
|
|
|
uint8_t retry;
|
2007-06-18 08:56:39 +08:00
|
|
|
uint32_t latt;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2007-08-02 23:10:31 +08:00
|
|
|
/* First save ndlp, before we overwrite it */
|
|
|
|
ndlp = cmdiocb->context_un.ndlp;
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
/* we pass cmdiocb to state machine which needs rspiocb as well */
|
|
|
|
cmdiocb->context_un.rsp_iocb = rspiocb;
|
|
|
|
|
|
|
|
inp = (struct lpfc_dmabuf *) cmdiocb->context1;
|
|
|
|
outp = (struct lpfc_dmabuf *) cmdiocb->context2;
|
|
|
|
irsp = &rspiocb->iocb;
|
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)->
|
|
|
|
CommandResponse.bits.CmdRsp);
|
2005-04-18 05:05:31 +08:00
|
|
|
CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
|
|
|
|
|
2007-06-18 08:56:39 +08:00
|
|
|
latt = lpfc_els_chk_latt(vport);
|
|
|
|
|
|
|
|
/* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
|
2007-10-28 01:37:17 +08:00
|
|
|
"0209 CT Request completes, latt %d, "
|
2007-08-02 23:10:09 +08:00
|
|
|
"ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n",
|
|
|
|
latt, irsp->ulpStatus,
|
|
|
|
CTrsp->CommandResponse.bits.CmdRsp,
|
|
|
|
cmdiocb->iocb.ulpContext, cmdiocb->iocb.ulpIoTag);
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2007-06-18 08:56:39 +08:00
|
|
|
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
|
|
|
|
"CT cmd cmpl: status:x%x/x%x cmd:x%x",
|
|
|
|
irsp->ulpStatus, irsp->un.ulpWord[4], cmdcode);
|
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
if (irsp->ulpStatus) {
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
|
2013-07-16 06:35:21 +08:00
|
|
|
"0268 NS cmd x%x Error (x%x x%x)\n",
|
2007-08-02 23:10:09 +08:00
|
|
|
cmdcode, irsp->ulpStatus, irsp->un.ulpWord[4]);
|
2007-06-18 08:56:39 +08:00
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) &&
|
2012-08-15 02:25:43 +08:00
|
|
|
(((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) ==
|
|
|
|
IOERR_SLI_DOWN) ||
|
|
|
|
((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) ==
|
|
|
|
IOERR_SLI_ABORTED)))
|
2007-06-18 08:56:38 +08:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
retry = cmdiocb->retry;
|
|
|
|
if (retry >= LPFC_MAX_NS_RETRY)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
retry++;
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
|
2008-08-25 09:50:00 +08:00
|
|
|
"0250 Retrying NS cmd %x\n", cmdcode);
|
2007-06-18 08:56:38 +08:00
|
|
|
rc = lpfc_ns_cmd(vport, cmdcode, retry, 0);
|
|
|
|
if (rc == 0)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2007-08-02 23:10:31 +08:00
|
|
|
cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */
|
2007-06-18 08:56:39 +08:00
|
|
|
lpfc_ct_free_iocb(phba, cmdiocb);
|
2005-04-18 05:05:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-10-28 01:37:17 +08:00
|
|
|
static void
|
|
|
|
lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|
|
|
struct lpfc_iocbq *rspiocb)
|
|
|
|
{
|
|
|
|
IOCB_t *irsp = &rspiocb->iocb;
|
|
|
|
struct lpfc_vport *vport = cmdiocb->vport;
|
|
|
|
|
2007-10-28 01:37:33 +08:00
|
|
|
if (irsp->ulpStatus == IOSTAT_SUCCESS) {
|
|
|
|
struct lpfc_dmabuf *outp;
|
|
|
|
struct lpfc_sli_ct_request *CTrsp;
|
|
|
|
|
|
|
|
outp = (struct lpfc_dmabuf *) cmdiocb->context2;
|
|
|
|
CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
|
|
|
|
if (CTrsp->CommandResponse.bits.CmdRsp ==
|
|
|
|
be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
|
|
|
|
vport->ct_flags |= FC_CT_RFT_ID;
|
|
|
|
}
|
2007-10-28 01:37:17 +08:00
|
|
|
lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
static void
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|
|
|
struct lpfc_iocbq *rspiocb)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
2007-10-28 01:37:17 +08:00
|
|
|
IOCB_t *irsp = &rspiocb->iocb;
|
|
|
|
struct lpfc_vport *vport = cmdiocb->vport;
|
|
|
|
|
2007-10-28 01:37:33 +08:00
|
|
|
if (irsp->ulpStatus == IOSTAT_SUCCESS) {
|
|
|
|
struct lpfc_dmabuf *outp;
|
|
|
|
struct lpfc_sli_ct_request *CTrsp;
|
|
|
|
|
|
|
|
outp = (struct lpfc_dmabuf *) cmdiocb->context2;
|
|
|
|
CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
|
|
|
|
if (CTrsp->CommandResponse.bits.CmdRsp ==
|
|
|
|
be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
|
|
|
|
vport->ct_flags |= FC_CT_RNN_ID;
|
|
|
|
}
|
2007-10-28 01:37:17 +08:00
|
|
|
lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
|
2005-04-18 05:05:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
static void
|
|
|
|
lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|
|
|
struct lpfc_iocbq *rspiocb)
|
|
|
|
{
|
2007-10-28 01:37:17 +08:00
|
|
|
IOCB_t *irsp = &rspiocb->iocb;
|
|
|
|
struct lpfc_vport *vport = cmdiocb->vport;
|
|
|
|
|
2007-10-28 01:37:33 +08:00
|
|
|
if (irsp->ulpStatus == IOSTAT_SUCCESS) {
|
|
|
|
struct lpfc_dmabuf *outp;
|
|
|
|
struct lpfc_sli_ct_request *CTrsp;
|
|
|
|
|
|
|
|
outp = (struct lpfc_dmabuf *) cmdiocb->context2;
|
|
|
|
CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
|
|
|
|
if (CTrsp->CommandResponse.bits.CmdRsp ==
|
|
|
|
be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
|
|
|
|
vport->ct_flags |= FC_CT_RSPN_ID;
|
|
|
|
}
|
2007-10-28 01:37:17 +08:00
|
|
|
lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
|
2007-06-18 08:56:38 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
static void
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|
|
|
struct lpfc_iocbq *rspiocb)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
2007-10-28 01:37:17 +08:00
|
|
|
IOCB_t *irsp = &rspiocb->iocb;
|
|
|
|
struct lpfc_vport *vport = cmdiocb->vport;
|
|
|
|
|
2007-10-28 01:37:33 +08:00
|
|
|
if (irsp->ulpStatus == IOSTAT_SUCCESS) {
|
|
|
|
struct lpfc_dmabuf *outp;
|
|
|
|
struct lpfc_sli_ct_request *CTrsp;
|
|
|
|
|
|
|
|
outp = (struct lpfc_dmabuf *) cmdiocb->context2;
|
|
|
|
CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
|
|
|
|
if (CTrsp->CommandResponse.bits.CmdRsp ==
|
|
|
|
be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
|
|
|
|
vport->ct_flags |= FC_CT_RSNN_NN;
|
|
|
|
}
|
2007-10-28 01:37:17 +08:00
|
|
|
lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lpfc_cmpl_ct_cmd_da_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|
|
|
struct lpfc_iocbq *rspiocb)
|
|
|
|
{
|
|
|
|
struct lpfc_vport *vport = cmdiocb->vport;
|
|
|
|
|
|
|
|
/* even if it fails we will act as though it succeeded. */
|
|
|
|
vport->ct_flags = 0;
|
|
|
|
lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
|
2005-04-18 05:05:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-12-03 02:33:57 +08:00
|
|
|
static void
|
2007-06-18 08:56:38 +08:00
|
|
|
lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|
|
|
struct lpfc_iocbq *rspiocb)
|
2006-12-03 02:33:57 +08:00
|
|
|
{
|
2007-06-18 08:56:38 +08:00
|
|
|
IOCB_t *irsp = &rspiocb->iocb;
|
|
|
|
struct lpfc_vport *vport = cmdiocb->vport;
|
|
|
|
|
2007-10-28 01:37:33 +08:00
|
|
|
if (irsp->ulpStatus == IOSTAT_SUCCESS) {
|
|
|
|
struct lpfc_dmabuf *outp;
|
|
|
|
struct lpfc_sli_ct_request *CTrsp;
|
|
|
|
|
|
|
|
outp = (struct lpfc_dmabuf *) cmdiocb->context2;
|
|
|
|
CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
|
|
|
|
if (CTrsp->CommandResponse.bits.CmdRsp ==
|
|
|
|
be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
|
|
|
|
vport->ct_flags |= FC_CT_RFF_ID;
|
|
|
|
}
|
2007-10-28 01:37:17 +08:00
|
|
|
lpfc_cmpl_ct(phba, cmdiocb, rspiocb);
|
2006-12-03 02:33:57 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-15 10:52:59 +08:00
|
|
|
int
|
2007-06-18 08:56:38 +08:00
|
|
|
lpfc_vport_symbolic_port_name(struct lpfc_vport *vport, char *symbol,
|
|
|
|
size_t size)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
uint8_t *wwn = vport->phba->wwpn;
|
|
|
|
|
|
|
|
n = snprintf(symbol, size,
|
|
|
|
"Emulex PPN-%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
|
|
|
wwn[0], wwn[1], wwn[2], wwn[3],
|
|
|
|
wwn[4], wwn[5], wwn[6], wwn[7]);
|
|
|
|
|
|
|
|
if (vport->port_type == LPFC_PHYSICAL_PORT)
|
|
|
|
return n;
|
|
|
|
|
|
|
|
if (n < size)
|
|
|
|
n += snprintf(symbol + n, size - n, " VPort-%d", vport->vpi);
|
|
|
|
|
2008-12-05 11:39:13 +08:00
|
|
|
if (n < size &&
|
|
|
|
strlen(vport->fc_vport->symbolic_name))
|
|
|
|
n += snprintf(symbol + n, size - n, " VName-%s",
|
|
|
|
vport->fc_vport->symbolic_name);
|
2007-06-18 08:56:38 +08:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol,
|
|
|
|
size_t size)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
2012-01-19 05:24:06 +08:00
|
|
|
char fwrev[FW_REV_STR_SIZE];
|
2007-06-18 08:56:38 +08:00
|
|
|
int n;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
lpfc_decode_firmware_rev(vport->phba, fwrev, 0);
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2015-04-08 03:07:18 +08:00
|
|
|
n = snprintf(symbol, size, "Emulex %s", vport->phba->ModelName);
|
|
|
|
|
|
|
|
if (size < n)
|
|
|
|
return n;
|
|
|
|
n += snprintf(symbol + n, size - n, " FV%s", fwrev);
|
|
|
|
|
|
|
|
if (size < n)
|
|
|
|
return n;
|
|
|
|
n += snprintf(symbol + n, size - n, " DV%s", lpfc_release_version);
|
|
|
|
|
|
|
|
if (size < n)
|
|
|
|
return n;
|
|
|
|
n += snprintf(symbol + n, size - n, " HN:%s", init_utsname()->nodename);
|
|
|
|
|
|
|
|
/* Note :- OS name is "Linux" */
|
|
|
|
if (size < n)
|
|
|
|
return n;
|
|
|
|
n += snprintf(symbol + n, size - n, " OS:%s", init_utsname()->sysname);
|
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
return n;
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
static uint32_t
|
|
|
|
lpfc_find_map_node(struct lpfc_vport *vport)
|
|
|
|
{
|
|
|
|
struct lpfc_nodelist *ndlp, *next_ndlp;
|
|
|
|
struct Scsi_Host *shost;
|
|
|
|
uint32_t cnt = 0;
|
|
|
|
|
|
|
|
shost = lpfc_shost_from_vport(vport);
|
|
|
|
spin_lock_irq(shost->host_lock);
|
|
|
|
list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) {
|
|
|
|
if (ndlp->nlp_type & NLP_FABRIC)
|
|
|
|
continue;
|
|
|
|
if ((ndlp->nlp_state == NLP_STE_MAPPED_NODE) ||
|
|
|
|
(ndlp->nlp_state == NLP_STE_UNMAPPED_NODE))
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
spin_unlock_irq(shost->host_lock);
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
/*
|
|
|
|
* lpfc_ns_cmd
|
|
|
|
* Description:
|
|
|
|
* Issue Cmd to NameServer
|
|
|
|
* SLI_CTNS_GID_FT
|
|
|
|
* LI_CTNS_RFT_ID
|
|
|
|
*/
|
|
|
|
int
|
2007-06-18 08:56:38 +08:00
|
|
|
lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
|
|
|
|
uint8_t retry, uint32_t context)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
2007-06-18 08:56:38 +08:00
|
|
|
struct lpfc_nodelist * ndlp;
|
2007-06-18 08:56:36 +08:00
|
|
|
struct lpfc_hba *phba = vport->phba;
|
2005-04-18 05:05:31 +08:00
|
|
|
struct lpfc_dmabuf *mp, *bmp;
|
|
|
|
struct lpfc_sli_ct_request *CtReq;
|
|
|
|
struct ulp_bde64 *bpl;
|
|
|
|
void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
|
|
|
|
struct lpfc_iocbq *) = NULL;
|
|
|
|
uint32_t rsp_size = 1024;
|
2007-06-18 08:56:38 +08:00
|
|
|
size_t size;
|
2007-06-18 08:56:39 +08:00
|
|
|
int rc = 0;
|
2007-06-18 08:56:38 +08:00
|
|
|
|
|
|
|
ndlp = lpfc_findnode_did(vport, NameServer_DID);
|
2008-02-09 07:49:26 +08:00
|
|
|
if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)
|
|
|
|
|| ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) {
|
2007-06-18 08:56:39 +08:00
|
|
|
rc=1;
|
|
|
|
goto ns_cmd_exit;
|
|
|
|
}
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* fill in BDEs for command */
|
|
|
|
/* Allocate buffer for command payload */
|
|
|
|
mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
|
2007-06-18 08:56:39 +08:00
|
|
|
if (!mp) {
|
|
|
|
rc=2;
|
2005-04-18 05:05:31 +08:00
|
|
|
goto ns_cmd_exit;
|
2007-06-18 08:56:39 +08:00
|
|
|
}
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
INIT_LIST_HEAD(&mp->list);
|
|
|
|
mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys));
|
2007-06-18 08:56:39 +08:00
|
|
|
if (!mp->virt) {
|
|
|
|
rc=3;
|
2005-04-18 05:05:31 +08:00
|
|
|
goto ns_cmd_free_mp;
|
2007-06-18 08:56:39 +08:00
|
|
|
}
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* Allocate buffer for Buffer ptr list */
|
|
|
|
bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
|
2007-06-18 08:56:39 +08:00
|
|
|
if (!bmp) {
|
|
|
|
rc=4;
|
2005-04-18 05:05:31 +08:00
|
|
|
goto ns_cmd_free_mpvirt;
|
2007-06-18 08:56:39 +08:00
|
|
|
}
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
INIT_LIST_HEAD(&bmp->list);
|
|
|
|
bmp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(bmp->phys));
|
2007-06-18 08:56:39 +08:00
|
|
|
if (!bmp->virt) {
|
|
|
|
rc=5;
|
2005-04-18 05:05:31 +08:00
|
|
|
goto ns_cmd_free_bmp;
|
2007-06-18 08:56:39 +08:00
|
|
|
}
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* NameServer Req */
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO ,LOG_DISCOVERY,
|
|
|
|
"0236 NameServer Req Data: x%x x%x x%x\n",
|
|
|
|
cmdcode, vport->fc_flag, vport->fc_rscn_id_cnt);
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
bpl = (struct ulp_bde64 *) bmp->virt;
|
|
|
|
memset(bpl, 0, sizeof(struct ulp_bde64));
|
2007-06-18 08:56:38 +08:00
|
|
|
bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys) );
|
|
|
|
bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys) );
|
2005-04-18 05:05:31 +08:00
|
|
|
bpl->tus.f.bdeFlags = 0;
|
|
|
|
if (cmdcode == SLI_CTNS_GID_FT)
|
|
|
|
bpl->tus.f.bdeSize = GID_REQUEST_SZ;
|
2007-06-18 08:56:38 +08:00
|
|
|
else if (cmdcode == SLI_CTNS_GFF_ID)
|
|
|
|
bpl->tus.f.bdeSize = GFF_REQUEST_SZ;
|
2005-04-18 05:05:31 +08:00
|
|
|
else if (cmdcode == SLI_CTNS_RFT_ID)
|
|
|
|
bpl->tus.f.bdeSize = RFT_REQUEST_SZ;
|
|
|
|
else if (cmdcode == SLI_CTNS_RNN_ID)
|
|
|
|
bpl->tus.f.bdeSize = RNN_REQUEST_SZ;
|
2007-06-18 08:56:38 +08:00
|
|
|
else if (cmdcode == SLI_CTNS_RSPN_ID)
|
|
|
|
bpl->tus.f.bdeSize = RSPN_REQUEST_SZ;
|
2005-04-18 05:05:31 +08:00
|
|
|
else if (cmdcode == SLI_CTNS_RSNN_NN)
|
|
|
|
bpl->tus.f.bdeSize = RSNN_REQUEST_SZ;
|
2007-10-28 01:37:17 +08:00
|
|
|
else if (cmdcode == SLI_CTNS_DA_ID)
|
|
|
|
bpl->tus.f.bdeSize = DA_ID_REQUEST_SZ;
|
2006-12-03 02:33:57 +08:00
|
|
|
else if (cmdcode == SLI_CTNS_RFF_ID)
|
|
|
|
bpl->tus.f.bdeSize = RFF_REQUEST_SZ;
|
2005-04-18 05:05:31 +08:00
|
|
|
else
|
|
|
|
bpl->tus.f.bdeSize = 0;
|
|
|
|
bpl->tus.w = le32_to_cpu(bpl->tus.w);
|
|
|
|
|
|
|
|
CtReq = (struct lpfc_sli_ct_request *) mp->virt;
|
|
|
|
memset(CtReq, 0, sizeof (struct lpfc_sli_ct_request));
|
|
|
|
CtReq->RevisionId.bits.Revision = SLI_CT_REVISION;
|
|
|
|
CtReq->RevisionId.bits.InId = 0;
|
|
|
|
CtReq->FsType = SLI_CT_DIRECTORY_SERVICE;
|
|
|
|
CtReq->FsSubType = SLI_CT_DIRECTORY_NAME_SERVER;
|
|
|
|
CtReq->CommandResponse.bits.Size = 0;
|
|
|
|
switch (cmdcode) {
|
|
|
|
case SLI_CTNS_GID_FT:
|
|
|
|
CtReq->CommandResponse.bits.CmdRsp =
|
2015-04-08 03:07:19 +08:00
|
|
|
cpu_to_be16(SLI_CTNS_GID_FT);
|
2005-04-18 05:05:31 +08:00
|
|
|
CtReq->un.gid.Fc4Type = SLI_CTPT_FCP;
|
2007-06-18 08:56:38 +08:00
|
|
|
if (vport->port_state < LPFC_NS_QRY)
|
2007-06-18 08:56:36 +08:00
|
|
|
vport->port_state = LPFC_NS_QRY;
|
|
|
|
lpfc_set_disctmo(vport);
|
2005-04-18 05:05:31 +08:00
|
|
|
cmpl = lpfc_cmpl_ct_cmd_gid_ft;
|
|
|
|
rsp_size = FC_MAX_NS_RSP;
|
|
|
|
break;
|
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
case SLI_CTNS_GFF_ID:
|
|
|
|
CtReq->CommandResponse.bits.CmdRsp =
|
2015-04-08 03:07:19 +08:00
|
|
|
cpu_to_be16(SLI_CTNS_GFF_ID);
|
2008-01-11 14:52:54 +08:00
|
|
|
CtReq->un.gff.PortId = cpu_to_be32(context);
|
2007-06-18 08:56:38 +08:00
|
|
|
cmpl = lpfc_cmpl_ct_cmd_gff_id;
|
|
|
|
break;
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
case SLI_CTNS_RFT_ID:
|
2007-10-28 01:37:17 +08:00
|
|
|
vport->ct_flags &= ~FC_CT_RFT_ID;
|
2005-04-18 05:05:31 +08:00
|
|
|
CtReq->CommandResponse.bits.CmdRsp =
|
2015-04-08 03:07:19 +08:00
|
|
|
cpu_to_be16(SLI_CTNS_RFT_ID);
|
2008-01-11 14:52:54 +08:00
|
|
|
CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID);
|
2005-04-18 05:05:31 +08:00
|
|
|
CtReq->un.rft.fcpReg = 1;
|
|
|
|
cmpl = lpfc_cmpl_ct_cmd_rft_id;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SLI_CTNS_RNN_ID:
|
2007-10-28 01:37:17 +08:00
|
|
|
vport->ct_flags &= ~FC_CT_RNN_ID;
|
2005-04-18 05:05:31 +08:00
|
|
|
CtReq->CommandResponse.bits.CmdRsp =
|
2015-04-08 03:07:19 +08:00
|
|
|
cpu_to_be16(SLI_CTNS_RNN_ID);
|
2008-01-11 14:52:54 +08:00
|
|
|
CtReq->un.rnn.PortId = cpu_to_be32(vport->fc_myDID);
|
2007-06-18 08:56:36 +08:00
|
|
|
memcpy(CtReq->un.rnn.wwnn, &vport->fc_nodename,
|
2005-04-18 05:05:31 +08:00
|
|
|
sizeof (struct lpfc_name));
|
|
|
|
cmpl = lpfc_cmpl_ct_cmd_rnn_id;
|
|
|
|
break;
|
|
|
|
|
2007-06-18 08:56:38 +08:00
|
|
|
case SLI_CTNS_RSPN_ID:
|
2007-10-28 01:37:17 +08:00
|
|
|
vport->ct_flags &= ~FC_CT_RSPN_ID;
|
2007-06-18 08:56:38 +08:00
|
|
|
CtReq->CommandResponse.bits.CmdRsp =
|
2015-04-08 03:07:19 +08:00
|
|
|
cpu_to_be16(SLI_CTNS_RSPN_ID);
|
2008-01-11 14:52:54 +08:00
|
|
|
CtReq->un.rspn.PortId = cpu_to_be32(vport->fc_myDID);
|
2007-06-18 08:56:38 +08:00
|
|
|
size = sizeof(CtReq->un.rspn.symbname);
|
|
|
|
CtReq->un.rspn.len =
|
|
|
|
lpfc_vport_symbolic_port_name(vport,
|
|
|
|
CtReq->un.rspn.symbname, size);
|
|
|
|
cmpl = lpfc_cmpl_ct_cmd_rspn_id;
|
|
|
|
break;
|
2005-04-18 05:05:31 +08:00
|
|
|
case SLI_CTNS_RSNN_NN:
|
2007-10-28 01:37:17 +08:00
|
|
|
vport->ct_flags &= ~FC_CT_RSNN_NN;
|
2005-04-18 05:05:31 +08:00
|
|
|
CtReq->CommandResponse.bits.CmdRsp =
|
2015-04-08 03:07:19 +08:00
|
|
|
cpu_to_be16(SLI_CTNS_RSNN_NN);
|
2007-06-18 08:56:36 +08:00
|
|
|
memcpy(CtReq->un.rsnn.wwnn, &vport->fc_nodename,
|
2005-04-18 05:05:31 +08:00
|
|
|
sizeof (struct lpfc_name));
|
2007-06-18 08:56:38 +08:00
|
|
|
size = sizeof(CtReq->un.rsnn.symbname);
|
|
|
|
CtReq->un.rsnn.len =
|
|
|
|
lpfc_vport_symbolic_node_name(vport,
|
|
|
|
CtReq->un.rsnn.symbname, size);
|
2005-04-18 05:05:31 +08:00
|
|
|
cmpl = lpfc_cmpl_ct_cmd_rsnn_nn;
|
|
|
|
break;
|
2007-10-28 01:37:17 +08:00
|
|
|
case SLI_CTNS_DA_ID:
|
|
|
|
/* Implement DA_ID Nameserver request */
|
|
|
|
CtReq->CommandResponse.bits.CmdRsp =
|
2015-04-08 03:07:19 +08:00
|
|
|
cpu_to_be16(SLI_CTNS_DA_ID);
|
2008-01-11 14:52:54 +08:00
|
|
|
CtReq->un.da_id.port_id = cpu_to_be32(vport->fc_myDID);
|
2007-10-28 01:37:17 +08:00
|
|
|
cmpl = lpfc_cmpl_ct_cmd_da_id;
|
|
|
|
break;
|
2007-06-18 08:56:38 +08:00
|
|
|
case SLI_CTNS_RFF_ID:
|
2007-10-28 01:37:17 +08:00
|
|
|
vport->ct_flags &= ~FC_CT_RFF_ID;
|
2007-06-18 08:56:38 +08:00
|
|
|
CtReq->CommandResponse.bits.CmdRsp =
|
2015-04-08 03:07:19 +08:00
|
|
|
cpu_to_be16(SLI_CTNS_RFF_ID);
|
2009-08-19 02:18:35 +08:00
|
|
|
CtReq->un.rff.PortId = cpu_to_be32(vport->fc_myDID);
|
2007-06-18 08:56:38 +08:00
|
|
|
CtReq->un.rff.fbits = FC4_FEATURE_INIT;
|
2009-10-03 03:16:51 +08:00
|
|
|
CtReq->un.rff.type_code = FC_TYPE_FCP;
|
2007-06-18 08:56:38 +08:00
|
|
|
cmpl = lpfc_cmpl_ct_cmd_rff_id;
|
|
|
|
break;
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
2008-02-09 07:49:26 +08:00
|
|
|
/* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count
|
|
|
|
* to hold ndlp reference for the corresponding callback function.
|
|
|
|
*/
|
2007-06-18 08:56:39 +08:00
|
|
|
if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) {
|
2005-04-18 05:05:31 +08:00
|
|
|
/* On success, The cmpl function will free the buffers */
|
2007-06-18 08:56:39 +08:00
|
|
|
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
|
|
|
|
"Issue CT cmd: cmd:x%x did:x%x",
|
|
|
|
cmdcode, ndlp->nlp_DID, 0);
|
2005-04-18 05:05:31 +08:00
|
|
|
return 0;
|
2007-06-18 08:56:39 +08:00
|
|
|
}
|
|
|
|
rc=6;
|
2008-02-09 07:49:26 +08:00
|
|
|
|
|
|
|
/* Decrement ndlp reference count to release ndlp reference held
|
|
|
|
* for the failed command's callback function.
|
|
|
|
*/
|
2007-08-02 23:10:31 +08:00
|
|
|
lpfc_nlp_put(ndlp);
|
2008-02-09 07:49:26 +08:00
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
|
|
|
|
ns_cmd_free_bmp:
|
|
|
|
kfree(bmp);
|
|
|
|
ns_cmd_free_mpvirt:
|
|
|
|
lpfc_mbuf_free(phba, mp->virt, mp->phys);
|
|
|
|
ns_cmd_free_mp:
|
|
|
|
kfree(mp);
|
|
|
|
ns_cmd_exit:
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
|
|
|
|
"0266 Issue NameServer Req x%x err %d Data: x%x x%x\n",
|
|
|
|
cmdcode, rc, vport->fc_flag, vport->fc_rscn_id_cnt);
|
2005-04-18 05:05:31 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|
|
|
struct lpfc_iocbq * rspiocb)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
|
|
|
struct lpfc_dmabuf *inp = cmdiocb->context1;
|
|
|
|
struct lpfc_dmabuf *outp = cmdiocb->context2;
|
|
|
|
struct lpfc_sli_ct_request *CTrsp = outp->virt;
|
|
|
|
struct lpfc_sli_ct_request *CTcmd = inp->virt;
|
|
|
|
struct lpfc_nodelist *ndlp;
|
|
|
|
uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp;
|
|
|
|
uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp;
|
2007-06-18 08:56:36 +08:00
|
|
|
struct lpfc_vport *vport = cmdiocb->vport;
|
2007-06-18 08:56:39 +08:00
|
|
|
IOCB_t *irsp = &rspiocb->iocb;
|
|
|
|
uint32_t latt;
|
|
|
|
|
|
|
|
latt = lpfc_els_chk_latt(vport);
|
|
|
|
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
|
|
|
|
"FDMI cmpl: status:x%x/x%x latt:%d",
|
|
|
|
irsp->ulpStatus, irsp->un.ulpWord[4], latt);
|
|
|
|
|
|
|
|
if (latt || irsp->ulpStatus) {
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
|
|
|
|
"0229 FDMI cmd %04x failed, latt = %d "
|
|
|
|
"ulpStatus: x%x, rid x%x\n",
|
|
|
|
be16_to_cpu(fdmi_cmd), latt, irsp->ulpStatus,
|
|
|
|
irsp->un.ulpWord[4]);
|
2015-04-08 03:07:19 +08:00
|
|
|
goto fail_out;
|
2007-06-18 08:56:39 +08:00
|
|
|
}
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2007-06-18 08:56:36 +08:00
|
|
|
ndlp = lpfc_findnode_did(vport, FDMI_DID);
|
2008-02-09 07:49:26 +08:00
|
|
|
if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
|
|
|
|
goto fail_out;
|
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
if (fdmi_rsp == cpu_to_be16(SLI_CT_RESPONSE_FS_RJT)) {
|
2005-04-18 05:05:31 +08:00
|
|
|
/* FDMI rsp failed */
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
|
|
|
|
"0220 FDMI rsp failed Data: x%x\n",
|
|
|
|
be16_to_cpu(fdmi_cmd));
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
fail_out:
|
|
|
|
lpfc_ct_free_iocb(phba, cmdiocb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
|
|
|
|
struct lpfc_iocbq *rspiocb)
|
|
|
|
{
|
|
|
|
struct lpfc_vport *vport = cmdiocb->vport;
|
|
|
|
struct lpfc_dmabuf *inp = cmdiocb->context1;
|
|
|
|
struct lpfc_sli_ct_request *CTcmd = inp->virt;
|
|
|
|
uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp;
|
|
|
|
struct lpfc_nodelist *ndlp;
|
|
|
|
|
|
|
|
lpfc_cmpl_ct_cmd_fdmi(phba, cmdiocb, rspiocb);
|
|
|
|
|
|
|
|
ndlp = lpfc_findnode_did(vport, FDMI_DID);
|
|
|
|
if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Need to cycle thru FDMI registration for discovery
|
|
|
|
* DHBA -> DPRT -> RHBA -> RPA
|
|
|
|
*/
|
2005-04-18 05:05:31 +08:00
|
|
|
switch (be16_to_cpu(fdmi_cmd)) {
|
|
|
|
case SLI_MGMT_RHBA:
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA);
|
2005-04-18 05:05:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SLI_MGMT_DHBA:
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT);
|
2005-04-18 05:05:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SLI_MGMT_DPRT:
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA);
|
2005-04-18 05:05:31 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-06-18 08:56:36 +08:00
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
int
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
2007-06-18 08:56:36 +08:00
|
|
|
struct lpfc_hba *phba = vport->phba;
|
2005-04-18 05:05:31 +08:00
|
|
|
struct lpfc_dmabuf *mp, *bmp;
|
|
|
|
struct lpfc_sli_ct_request *CtReq;
|
|
|
|
struct ulp_bde64 *bpl;
|
|
|
|
uint32_t size;
|
2015-04-08 03:07:19 +08:00
|
|
|
uint32_t rsp_size;
|
|
|
|
struct lpfc_fdmi_reg_hba *rh;
|
|
|
|
struct lpfc_fdmi_port_entry *pe;
|
|
|
|
struct lpfc_fdmi_reg_portattr *pab = NULL;
|
|
|
|
struct lpfc_fdmi_attr_block *ab = NULL;
|
|
|
|
struct lpfc_fdmi_attr_entry *ae;
|
|
|
|
struct lpfc_fdmi_attr_def *ad;
|
2005-04-18 05:05:31 +08:00
|
|
|
void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
|
|
|
|
struct lpfc_iocbq *);
|
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
if (ndlp == NULL) {
|
|
|
|
ndlp = lpfc_findnode_did(vport, FDMI_DID);
|
|
|
|
if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
|
|
|
|
return 0;
|
|
|
|
cmpl = lpfc_cmpl_ct_cmd_fdmi; /* cmd interface */
|
|
|
|
} else {
|
|
|
|
cmpl = lpfc_cmpl_ct_disc_fdmi; /* called from discovery */
|
|
|
|
}
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* fill in BDEs for command */
|
|
|
|
/* Allocate buffer for command payload */
|
2015-04-08 03:07:19 +08:00
|
|
|
mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
|
2005-04-18 05:05:31 +08:00
|
|
|
if (!mp)
|
|
|
|
goto fdmi_cmd_exit;
|
|
|
|
|
|
|
|
mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys));
|
|
|
|
if (!mp->virt)
|
|
|
|
goto fdmi_cmd_free_mp;
|
|
|
|
|
|
|
|
/* Allocate buffer for Buffer ptr list */
|
2015-04-08 03:07:19 +08:00
|
|
|
bmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
|
2005-04-18 05:05:31 +08:00
|
|
|
if (!bmp)
|
|
|
|
goto fdmi_cmd_free_mpvirt;
|
|
|
|
|
|
|
|
bmp->virt = lpfc_mbuf_alloc(phba, 0, &(bmp->phys));
|
|
|
|
if (!bmp->virt)
|
|
|
|
goto fdmi_cmd_free_bmp;
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&mp->list);
|
|
|
|
INIT_LIST_HEAD(&bmp->list);
|
|
|
|
|
|
|
|
/* FDMI request */
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
|
|
|
|
"0218 FDMI Request Data: x%x x%x x%x\n",
|
|
|
|
vport->fc_flag, vport->port_state, cmdcode);
|
2015-04-08 03:07:19 +08:00
|
|
|
CtReq = (struct lpfc_sli_ct_request *)mp->virt;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
/* First populate the CT_IU preamble */
|
2005-04-18 05:05:31 +08:00
|
|
|
memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request));
|
|
|
|
CtReq->RevisionId.bits.Revision = SLI_CT_REVISION;
|
|
|
|
CtReq->RevisionId.bits.InId = 0;
|
|
|
|
|
|
|
|
CtReq->FsType = SLI_CT_MANAGEMENT_SERVICE;
|
|
|
|
CtReq->FsSubType = SLI_CT_FDMI_Subtypes;
|
2015-04-08 03:07:19 +08:00
|
|
|
|
|
|
|
CtReq->CommandResponse.bits.CmdRsp = cpu_to_be16(cmdcode);
|
|
|
|
rsp_size = LPFC_BPL_SIZE;
|
2005-04-18 05:05:31 +08:00
|
|
|
size = 0;
|
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
/* Next fill in the specific FDMI cmd information */
|
2005-04-18 05:05:31 +08:00
|
|
|
switch (cmdcode) {
|
2015-04-08 03:07:19 +08:00
|
|
|
case SLI_MGMT_RHAT:
|
2005-04-18 05:05:31 +08:00
|
|
|
case SLI_MGMT_RHBA:
|
|
|
|
{
|
|
|
|
lpfc_vpd_t *vp = &phba->vpd;
|
|
|
|
uint32_t i, j, incr;
|
2015-04-08 03:07:19 +08:00
|
|
|
int len = 0;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
rh = (struct lpfc_fdmi_reg_hba *)&CtReq->un.PortID;
|
|
|
|
/* HBA Identifier */
|
2007-06-18 08:56:36 +08:00
|
|
|
memcpy(&rh->hi.PortName, &vport->fc_sparam.portName,
|
2015-04-08 03:07:19 +08:00
|
|
|
sizeof(struct lpfc_name));
|
|
|
|
|
|
|
|
if (cmdcode == SLI_MGMT_RHBA) {
|
|
|
|
/* Registered Port List */
|
|
|
|
/* One entry (port) per adapter */
|
|
|
|
rh->rpl.EntryCnt = cpu_to_be32(1);
|
|
|
|
memcpy(&rh->rpl.pe, &vport->fc_sparam.portName,
|
|
|
|
sizeof(struct lpfc_name));
|
|
|
|
|
|
|
|
/* point to the HBA attribute block */
|
|
|
|
size = 2 * sizeof(struct lpfc_name) +
|
|
|
|
FOURBYTES;
|
|
|
|
} else {
|
|
|
|
size = sizeof(struct lpfc_name);
|
|
|
|
}
|
|
|
|
ab = (struct lpfc_fdmi_attr_block *)
|
|
|
|
((uint8_t *)rh + size);
|
2005-04-18 05:05:31 +08:00
|
|
|
ab->EntryCnt = 0;
|
2015-04-08 03:07:19 +08:00
|
|
|
size += FOURBYTES;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
/*
|
|
|
|
* Point to beginning of first HBA attribute entry
|
|
|
|
*/
|
2005-04-18 05:05:31 +08:00
|
|
|
/* #1 HBA attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(struct lpfc_name));
|
|
|
|
ad->AttrType = cpu_to_be16(RHBA_NODENAME);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES
|
|
|
|
+ sizeof(struct lpfc_name));
|
2007-06-18 08:56:36 +08:00
|
|
|
memcpy(&ae->un.NodeName, &vport->fc_sparam.nodeName,
|
2015-04-08 03:07:19 +08:00
|
|
|
sizeof(struct lpfc_name));
|
2005-04-18 05:05:31 +08:00
|
|
|
ab->EntryCnt++;
|
2015-04-08 03:07:19 +08:00
|
|
|
size += FOURBYTES + sizeof(struct lpfc_name);
|
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto hba_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* #2 HBA attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.Manufacturer));
|
|
|
|
ad->AttrType = cpu_to_be16(RHBA_MANUFACTURER);
|
|
|
|
strncpy(ae->un.Manufacturer, "Emulex Corporation",
|
|
|
|
sizeof(ae->un.Manufacturer));
|
|
|
|
len = strnlen(ae->un.Manufacturer,
|
|
|
|
sizeof(ae->un.Manufacturer));
|
2005-04-18 05:05:31 +08:00
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
2015-04-08 03:07:19 +08:00
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + len);
|
2005-04-18 05:05:31 +08:00
|
|
|
ab->EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto hba_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* #3 HBA attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.SerialNumber));
|
|
|
|
ad->AttrType = cpu_to_be16(RHBA_SERIAL_NUMBER);
|
|
|
|
strncpy(ae->un.SerialNumber, phba->SerialNumber,
|
|
|
|
sizeof(ae->un.SerialNumber));
|
|
|
|
len = strnlen(ae->un.SerialNumber,
|
|
|
|
sizeof(ae->un.SerialNumber));
|
2005-04-18 05:05:31 +08:00
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
2015-04-08 03:07:19 +08:00
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + len);
|
2005-04-18 05:05:31 +08:00
|
|
|
ab->EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto hba_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* #4 HBA attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.Model));
|
|
|
|
ad->AttrType = cpu_to_be16(RHBA_MODEL);
|
|
|
|
strncpy(ae->un.Model, phba->ModelName,
|
|
|
|
sizeof(ae->un.Model));
|
|
|
|
len = strnlen(ae->un.Model, sizeof(ae->un.Model));
|
2005-04-18 05:05:31 +08:00
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
2015-04-08 03:07:19 +08:00
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + len);
|
2005-04-18 05:05:31 +08:00
|
|
|
ab->EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto hba_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* #5 HBA attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.ModelDescription));
|
|
|
|
ad->AttrType = cpu_to_be16(RHBA_MODEL_DESCRIPTION);
|
|
|
|
strncpy(ae->un.ModelDescription, phba->ModelDesc,
|
|
|
|
sizeof(ae->un.ModelDescription));
|
|
|
|
len = strnlen(ae->un.ModelDescription,
|
|
|
|
sizeof(ae->un.ModelDescription));
|
2005-04-18 05:05:31 +08:00
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
2015-04-08 03:07:19 +08:00
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + len);
|
2005-04-18 05:05:31 +08:00
|
|
|
ab->EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + 8) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto hba_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* #6 HBA attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, 8);
|
|
|
|
ad->AttrType = cpu_to_be16(RHBA_HARDWARE_VERSION);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 8);
|
2005-04-18 05:05:31 +08:00
|
|
|
/* Convert JEDEC ID to ascii for hardware version */
|
|
|
|
incr = vp->rev.biuRev;
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
j = (incr & 0xf);
|
|
|
|
if (j <= 9)
|
|
|
|
ae->un.HardwareVersion[7 - i] =
|
2015-04-08 03:07:19 +08:00
|
|
|
(char)((uint8_t)0x30 +
|
|
|
|
(uint8_t)j);
|
2005-04-18 05:05:31 +08:00
|
|
|
else
|
|
|
|
ae->un.HardwareVersion[7 - i] =
|
2015-04-08 03:07:19 +08:00
|
|
|
(char)((uint8_t)0x61 +
|
|
|
|
(uint8_t)(j - 10));
|
2005-04-18 05:05:31 +08:00
|
|
|
incr = (incr >> 4);
|
|
|
|
}
|
|
|
|
ab->EntryCnt++;
|
|
|
|
size += FOURBYTES + 8;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto hba_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* #7 HBA attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.DriverVersion));
|
|
|
|
ad->AttrType = cpu_to_be16(RHBA_DRIVER_VERSION);
|
|
|
|
strncpy(ae->un.DriverVersion, lpfc_release_version,
|
|
|
|
sizeof(ae->un.DriverVersion));
|
|
|
|
len = strnlen(ae->un.DriverVersion,
|
|
|
|
sizeof(ae->un.DriverVersion));
|
2005-04-18 05:05:31 +08:00
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
2015-04-08 03:07:19 +08:00
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + len);
|
2005-04-18 05:05:31 +08:00
|
|
|
ab->EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto hba_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* #8 HBA attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.OptionROMVersion));
|
|
|
|
ad->AttrType = cpu_to_be16(RHBA_OPTION_ROM_VERSION);
|
|
|
|
strncpy(ae->un.OptionROMVersion, phba->OptionROMVersion,
|
|
|
|
sizeof(ae->un.OptionROMVersion));
|
|
|
|
len = strnlen(ae->un.OptionROMVersion,
|
|
|
|
sizeof(ae->un.OptionROMVersion));
|
2005-04-18 05:05:31 +08:00
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
2015-04-08 03:07:19 +08:00
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + len);
|
2005-04-18 05:05:31 +08:00
|
|
|
ab->EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto hba_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* #9 HBA attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.FirmwareVersion));
|
|
|
|
ad->AttrType = cpu_to_be16(RHBA_FIRMWARE_VERSION);
|
2005-04-18 05:05:31 +08:00
|
|
|
lpfc_decode_firmware_rev(phba, ae->un.FirmwareVersion,
|
|
|
|
1);
|
2015-04-08 03:07:19 +08:00
|
|
|
len = strnlen(ae->un.FirmwareVersion,
|
|
|
|
sizeof(ae->un.FirmwareVersion));
|
2005-04-18 05:05:31 +08:00
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
2015-04-08 03:07:19 +08:00
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + len);
|
2005-04-18 05:05:31 +08:00
|
|
|
ab->EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto hba_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* #10 HBA attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.OsNameVersion));
|
|
|
|
ad->AttrType = cpu_to_be16(RHBA_OS_NAME_VERSION);
|
|
|
|
snprintf(ae->un.OsNameVersion,
|
|
|
|
sizeof(ae->un.OsNameVersion),
|
|
|
|
"%s %s %s",
|
|
|
|
init_utsname()->sysname,
|
|
|
|
init_utsname()->release,
|
|
|
|
init_utsname()->version);
|
|
|
|
len = strnlen(ae->un.OsNameVersion,
|
|
|
|
sizeof(ae->un.OsNameVersion));
|
2005-04-18 05:05:31 +08:00
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
2015-04-08 03:07:19 +08:00
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + len);
|
2005-04-18 05:05:31 +08:00
|
|
|
ab->EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto hba_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* #11 HBA attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
ad->AttrType =
|
|
|
|
cpu_to_be16(RHBA_MAX_CT_PAYLOAD_LEN);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
|
|
|
|
ae->un.MaxCTPayloadLen = cpu_to_be32(LPFC_MAX_CT_SIZE);
|
2005-04-18 05:05:31 +08:00
|
|
|
ab->EntryCnt++;
|
|
|
|
size += FOURBYTES + 4;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto hba_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
/*
|
|
|
|
* Currently switches don't seem to support the
|
|
|
|
* following extended HBA attributes.
|
|
|
|
*/
|
|
|
|
if (!(vport->cfg_fdmi_on & LPFC_FDMI_ALL_ATTRIB))
|
|
|
|
goto hba_out;
|
|
|
|
|
|
|
|
/* #12 HBA attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)rh + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.NodeSymName));
|
|
|
|
ad->AttrType = cpu_to_be16(RHBA_SYM_NODENAME);
|
|
|
|
len = lpfc_vport_symbolic_node_name(vport,
|
|
|
|
ae->un.NodeSymName, sizeof(ae->un.NodeSymName));
|
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + len);
|
|
|
|
ab->EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
|
|
|
hba_out:
|
|
|
|
ab->EntryCnt = cpu_to_be32(ab->EntryCnt);
|
2005-04-18 05:05:31 +08:00
|
|
|
/* Total size */
|
|
|
|
size = GID_REQUEST_SZ - 4 + size;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
case SLI_MGMT_RPRT:
|
2005-04-18 05:05:31 +08:00
|
|
|
case SLI_MGMT_RPA:
|
|
|
|
{
|
|
|
|
struct serv_parm *hsp;
|
2015-04-08 03:07:19 +08:00
|
|
|
int len = 0;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
if (cmdcode == SLI_MGMT_RPRT) {
|
|
|
|
rh = (struct lpfc_fdmi_reg_hba *)
|
|
|
|
&CtReq->un.PortID;
|
|
|
|
/* HBA Identifier */
|
|
|
|
memcpy(&rh->hi.PortName,
|
|
|
|
&vport->fc_sparam.portName,
|
|
|
|
sizeof(struct lpfc_name));
|
|
|
|
pab = (struct lpfc_fdmi_reg_portattr *)
|
|
|
|
&rh->rpl.EntryCnt;
|
|
|
|
} else
|
|
|
|
pab = (struct lpfc_fdmi_reg_portattr *)
|
|
|
|
&CtReq->un.PortID;
|
|
|
|
size = sizeof(struct lpfc_name) + FOURBYTES;
|
|
|
|
memcpy((uint8_t *)&pab->PortName,
|
|
|
|
(uint8_t *)&vport->fc_sparam.portName,
|
|
|
|
sizeof(struct lpfc_name));
|
2005-04-18 05:05:31 +08:00
|
|
|
pab->ab.EntryCnt = 0;
|
|
|
|
|
|
|
|
/* #1 Port attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.FC4Types));
|
|
|
|
ad->AttrType =
|
|
|
|
cpu_to_be16(RPRT_SUPPORTED_FC4_TYPES);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 32);
|
|
|
|
ae->un.FC4Types[0] = 0x40; /* Type 1 - ELS */
|
|
|
|
ae->un.FC4Types[1] = 0x80; /* Type 8 - FCP */
|
|
|
|
ae->un.FC4Types[4] = 0x80; /* Type 32 - CT */
|
2005-04-18 05:05:31 +08:00
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + 32;
|
|
|
|
|
|
|
|
/* #2 Port attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_SPEED);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
|
2006-03-01 11:33:04 +08:00
|
|
|
ae->un.SupportSpeed = 0;
|
2015-09-01 04:48:17 +08:00
|
|
|
if (phba->lmt & LMT_32Gb)
|
|
|
|
ae->un.SupportSpeed |= HBA_PORTSPEED_32GBIT;
|
2010-11-21 12:11:48 +08:00
|
|
|
if (phba->lmt & LMT_16Gb)
|
|
|
|
ae->un.SupportSpeed |= HBA_PORTSPEED_16GBIT;
|
2006-03-01 11:33:04 +08:00
|
|
|
if (phba->lmt & LMT_10Gb)
|
2010-11-21 12:11:48 +08:00
|
|
|
ae->un.SupportSpeed |= HBA_PORTSPEED_10GBIT;
|
2006-03-01 11:33:04 +08:00
|
|
|
if (phba->lmt & LMT_8Gb)
|
|
|
|
ae->un.SupportSpeed |= HBA_PORTSPEED_8GBIT;
|
|
|
|
if (phba->lmt & LMT_4Gb)
|
|
|
|
ae->un.SupportSpeed |= HBA_PORTSPEED_4GBIT;
|
|
|
|
if (phba->lmt & LMT_2Gb)
|
|
|
|
ae->un.SupportSpeed |= HBA_PORTSPEED_2GBIT;
|
|
|
|
if (phba->lmt & LMT_1Gb)
|
|
|
|
ae->un.SupportSpeed |= HBA_PORTSPEED_1GBIT;
|
2015-04-08 03:07:19 +08:00
|
|
|
ae->un.SupportSpeed =
|
|
|
|
cpu_to_be32(ae->un.SupportSpeed);
|
2006-03-01 11:33:04 +08:00
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + 4;
|
|
|
|
|
|
|
|
/* #3 Port attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_PORT_SPEED);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
|
|
|
|
switch (phba->fc_linkspeed) {
|
2010-11-21 12:11:48 +08:00
|
|
|
case LPFC_LINK_SPEED_1GHZ:
|
|
|
|
ae->un.PortSpeed = HBA_PORTSPEED_1GBIT;
|
2005-04-18 05:05:31 +08:00
|
|
|
break;
|
2010-11-21 12:11:48 +08:00
|
|
|
case LPFC_LINK_SPEED_2GHZ:
|
|
|
|
ae->un.PortSpeed = HBA_PORTSPEED_2GBIT;
|
2005-04-18 05:05:31 +08:00
|
|
|
break;
|
2010-11-21 12:11:48 +08:00
|
|
|
case LPFC_LINK_SPEED_4GHZ:
|
|
|
|
ae->un.PortSpeed = HBA_PORTSPEED_4GBIT;
|
2005-04-18 05:05:31 +08:00
|
|
|
break;
|
2010-11-21 12:11:48 +08:00
|
|
|
case LPFC_LINK_SPEED_8GHZ:
|
|
|
|
ae->un.PortSpeed = HBA_PORTSPEED_8GBIT;
|
2007-04-25 21:53:28 +08:00
|
|
|
break;
|
2010-11-21 12:11:48 +08:00
|
|
|
case LPFC_LINK_SPEED_10GHZ:
|
|
|
|
ae->un.PortSpeed = HBA_PORTSPEED_10GBIT;
|
2009-05-23 02:53:12 +08:00
|
|
|
break;
|
2010-11-21 12:11:48 +08:00
|
|
|
case LPFC_LINK_SPEED_16GHZ:
|
|
|
|
ae->un.PortSpeed = HBA_PORTSPEED_16GBIT;
|
|
|
|
break;
|
2015-09-01 04:48:17 +08:00
|
|
|
case LPFC_LINK_SPEED_32GHZ:
|
|
|
|
ae->un.PortSpeed = HBA_PORTSPEED_32GBIT;
|
|
|
|
break;
|
2010-11-21 12:11:48 +08:00
|
|
|
default:
|
|
|
|
ae->un.PortSpeed = HBA_PORTSPEED_UNKNOWN;
|
2005-04-18 05:05:31 +08:00
|
|
|
break;
|
|
|
|
}
|
2015-04-08 03:07:19 +08:00
|
|
|
ae->un.PortSpeed = cpu_to_be32(ae->un.PortSpeed);
|
2005-04-18 05:05:31 +08:00
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + 4;
|
|
|
|
|
|
|
|
/* #4 Port attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_MAX_FRAME_SIZE);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
|
|
|
|
hsp = (struct serv_parm *)&vport->fc_sparam;
|
2005-04-18 05:05:31 +08:00
|
|
|
ae->un.MaxFrameSize =
|
2015-04-08 03:07:19 +08:00
|
|
|
(((uint32_t)hsp->cmn.
|
|
|
|
bbRcvSizeMsb) << 8) | (uint32_t)hsp->cmn.
|
2005-04-18 05:05:31 +08:00
|
|
|
bbRcvSizeLsb;
|
2015-04-08 03:07:19 +08:00
|
|
|
ae->un.MaxFrameSize =
|
|
|
|
cpu_to_be32(ae->un.MaxFrameSize);
|
2005-04-18 05:05:31 +08:00
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + 4;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
|
|
|
/* #5 Port attribute entry */
|
2015-04-08 03:07:19 +08:00
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.OsDeviceName));
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_OS_DEVICE_NAME);
|
|
|
|
strncpy((char *)ae->un.OsDeviceName, LPFC_DRIVER_NAME,
|
|
|
|
sizeof(ae->un.OsDeviceName));
|
|
|
|
len = strnlen((char *)ae->un.OsDeviceName,
|
|
|
|
sizeof(ae->un.OsDeviceName));
|
2005-04-18 05:05:31 +08:00
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
2015-04-08 03:07:19 +08:00
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + len);
|
2005-04-18 05:05:31 +08:00
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
2015-04-08 03:07:19 +08:00
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
|
|
|
|
|
|
|
/* #6 Port attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.HostName));
|
|
|
|
snprintf(ae->un.HostName, sizeof(ae->un.HostName), "%s",
|
|
|
|
init_utsname()->nodename);
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_HOST_NAME);
|
|
|
|
len = strnlen(ae->un.HostName,
|
|
|
|
sizeof(ae->un.HostName));
|
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
|
|
|
ad->AttrLen =
|
|
|
|
cpu_to_be16(FOURBYTES + len);
|
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
|
|
|
if ((size + sizeof(struct lpfc_name)) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
/*
|
|
|
|
* Currently switches don't seem to support the
|
|
|
|
* following extended Port attributes.
|
|
|
|
*/
|
|
|
|
if (!(vport->cfg_fdmi_on & LPFC_FDMI_ALL_ATTRIB))
|
|
|
|
goto port_out;
|
|
|
|
|
|
|
|
/* #7 Port attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(struct lpfc_name));
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_NODENAME);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES
|
|
|
|
+ sizeof(struct lpfc_name));
|
|
|
|
memcpy(&ae->un.NodeName, &vport->fc_sparam.nodeName,
|
|
|
|
sizeof(struct lpfc_name));
|
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + sizeof(struct lpfc_name);
|
|
|
|
if ((size + sizeof(struct lpfc_name)) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
|
|
|
|
|
|
|
/* #8 Port attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(struct lpfc_name));
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_PORTNAME);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES
|
|
|
|
+ sizeof(struct lpfc_name));
|
|
|
|
memcpy(&ae->un.PortName, &vport->fc_sparam.portName,
|
|
|
|
sizeof(struct lpfc_name));
|
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + sizeof(struct lpfc_name);
|
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
|
|
|
|
|
|
|
/* #9 Port attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.NodeSymName));
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_SYM_PORTNAME);
|
|
|
|
len = lpfc_vport_symbolic_port_name(vport,
|
|
|
|
ae->un.NodeSymName, sizeof(ae->un.NodeSymName));
|
|
|
|
len += (len & 3) ? (4 - (len & 3)) : 4;
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + len);
|
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + len;
|
|
|
|
if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
|
|
|
|
|
|
|
/* #10 Port attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_PORT_TYPE);
|
|
|
|
ae->un.PortState = 0;
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
|
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + 4;
|
|
|
|
if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
|
|
|
|
|
|
|
/* #11 Port attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_CLASS);
|
|
|
|
ae->un.SupportClass =
|
|
|
|
cpu_to_be32(FC_COS_CLASS2 | FC_COS_CLASS3);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
|
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + 4;
|
|
|
|
if ((size + sizeof(struct lpfc_name)) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
|
|
|
|
|
|
|
/* #12 Port attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(struct lpfc_name));
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_FABRICNAME);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES
|
|
|
|
+ sizeof(struct lpfc_name));
|
|
|
|
memcpy(&ae->un.FabricName, &vport->fabric_nodename,
|
|
|
|
sizeof(struct lpfc_name));
|
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + sizeof(struct lpfc_name);
|
|
|
|
if ((size + LPFC_FDMI_MAX_AE_SIZE) >
|
|
|
|
(LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
|
|
|
|
|
|
|
/* #13 Port attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
memset(ae, 0, sizeof(ae->un.FC4Types));
|
|
|
|
ad->AttrType =
|
|
|
|
cpu_to_be16(RPRT_ACTIVE_FC4_TYPES);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 32);
|
|
|
|
ae->un.FC4Types[0] = 0x40; /* Type 1 - ELS */
|
|
|
|
ae->un.FC4Types[1] = 0x80; /* Type 8 - FCP */
|
|
|
|
ae->un.FC4Types[4] = 0x80; /* Type 32 - CT */
|
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + 32;
|
|
|
|
if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
|
|
|
|
|
|
|
/* #257 Port attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_PORT_STATE);
|
|
|
|
ae->un.PortState = 0;
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
|
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + 4;
|
|
|
|
if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
|
|
|
|
|
|
|
/* #258 Port attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_DISC_PORT);
|
|
|
|
ae->un.PortState = lpfc_find_map_node(vport);
|
|
|
|
ae->un.PortState = cpu_to_be32(ae->un.PortState);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
|
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + 4;
|
|
|
|
if ((size + 4) > (LPFC_BPL_SIZE - LPFC_CT_PREAMBLE))
|
|
|
|
goto port_out;
|
|
|
|
|
|
|
|
/* #259 Port attribute entry */
|
|
|
|
ad = (struct lpfc_fdmi_attr_def *)
|
|
|
|
((uint8_t *)pab + size);
|
|
|
|
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
|
|
|
|
ad->AttrType = cpu_to_be16(RPRT_PORT_ID);
|
|
|
|
ae->un.PortId = cpu_to_be32(vport->fc_myDID);
|
|
|
|
ad->AttrLen = cpu_to_be16(FOURBYTES + 4);
|
|
|
|
pab->ab.EntryCnt++;
|
|
|
|
size += FOURBYTES + 4;
|
|
|
|
port_out:
|
|
|
|
pab->ab.EntryCnt = cpu_to_be32(pab->ab.EntryCnt);
|
2005-04-18 05:05:31 +08:00
|
|
|
/* Total size */
|
|
|
|
size = GID_REQUEST_SZ - 4 + size;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
case SLI_MGMT_GHAT:
|
|
|
|
case SLI_MGMT_GRPL:
|
|
|
|
rsp_size = FC_MAX_NS_RSP;
|
2005-04-18 05:05:31 +08:00
|
|
|
case SLI_MGMT_DHBA:
|
2015-04-08 03:07:19 +08:00
|
|
|
case SLI_MGMT_DHAT:
|
|
|
|
pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
|
|
|
|
memcpy((uint8_t *)&pe->PortName,
|
|
|
|
(uint8_t *)&vport->fc_sparam.portName,
|
|
|
|
sizeof(struct lpfc_name));
|
|
|
|
size = GID_REQUEST_SZ - 4 + sizeof(struct lpfc_name);
|
2005-04-18 05:05:31 +08:00
|
|
|
break;
|
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
case SLI_MGMT_GPAT:
|
|
|
|
case SLI_MGMT_GPAS:
|
|
|
|
rsp_size = FC_MAX_NS_RSP;
|
2005-04-18 05:05:31 +08:00
|
|
|
case SLI_MGMT_DPRT:
|
2015-04-08 03:07:19 +08:00
|
|
|
case SLI_MGMT_DPA:
|
|
|
|
pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
|
|
|
|
memcpy((uint8_t *)&pe->PortName,
|
|
|
|
(uint8_t *)&vport->fc_sparam.portName,
|
|
|
|
sizeof(struct lpfc_name));
|
|
|
|
size = GID_REQUEST_SZ - 4 + sizeof(struct lpfc_name);
|
|
|
|
break;
|
|
|
|
case SLI_MGMT_GRHL:
|
|
|
|
size = GID_REQUEST_SZ - 4;
|
2005-04-18 05:05:31 +08:00
|
|
|
break;
|
2015-04-08 03:07:19 +08:00
|
|
|
default:
|
|
|
|
lpfc_printf_vlog(vport, KERN_WARNING, LOG_DISCOVERY,
|
|
|
|
"0298 FDMI cmdcode x%x not supported\n",
|
|
|
|
cmdcode);
|
|
|
|
goto fdmi_cmd_free_bmpvirt;
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
2015-04-08 03:07:19 +08:00
|
|
|
CtReq->CommandResponse.bits.Size = cpu_to_be16(rsp_size);
|
2005-04-18 05:05:31 +08:00
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
bpl = (struct ulp_bde64 *)bmp->virt;
|
|
|
|
bpl->addrHigh = le32_to_cpu(putPaddrHigh(mp->phys));
|
|
|
|
bpl->addrLow = le32_to_cpu(putPaddrLow(mp->phys));
|
2005-04-18 05:05:31 +08:00
|
|
|
bpl->tus.f.bdeFlags = 0;
|
|
|
|
bpl->tus.f.bdeSize = size;
|
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
/*
|
|
|
|
* The lpfc_ct_cmd/lpfc_get_req shall increment ndlp reference count
|
2008-02-09 07:49:26 +08:00
|
|
|
* to hold ndlp reference for the corresponding callback function.
|
|
|
|
*/
|
2015-04-08 03:07:19 +08:00
|
|
|
if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, 0))
|
2005-04-18 05:05:31 +08:00
|
|
|
return 0;
|
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
/*
|
|
|
|
* Decrement ndlp reference count to release ndlp reference held
|
2008-02-09 07:49:26 +08:00
|
|
|
* for the failed command's callback function.
|
|
|
|
*/
|
2007-08-02 23:10:31 +08:00
|
|
|
lpfc_nlp_put(ndlp);
|
2008-02-09 07:49:26 +08:00
|
|
|
|
2015-04-08 03:07:19 +08:00
|
|
|
fdmi_cmd_free_bmpvirt:
|
2005-04-18 05:05:31 +08:00
|
|
|
lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
|
|
|
|
fdmi_cmd_free_bmp:
|
|
|
|
kfree(bmp);
|
|
|
|
fdmi_cmd_free_mpvirt:
|
|
|
|
lpfc_mbuf_free(phba, mp->virt, mp->phys);
|
|
|
|
fdmi_cmd_free_mp:
|
|
|
|
kfree(mp);
|
|
|
|
fdmi_cmd_exit:
|
|
|
|
/* Issue FDMI request failed */
|
2007-08-02 23:10:09 +08:00
|
|
|
lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
|
|
|
|
"0244 Issue FDMI request failed Data: x%x\n",
|
|
|
|
cmdcode);
|
2005-04-18 05:05:31 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-02-17 01:39:44 +08:00
|
|
|
/**
|
|
|
|
* lpfc_delayed_disc_tmo - Timeout handler for delayed discovery timer.
|
|
|
|
* @ptr - Context object of the timer.
|
|
|
|
*
|
|
|
|
* This function set the WORKER_DELAYED_DISC_TMO flag and wake up
|
|
|
|
* the worker thread.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
lpfc_delayed_disc_tmo(unsigned long ptr)
|
|
|
|
{
|
|
|
|
struct lpfc_vport *vport = (struct lpfc_vport *)ptr;
|
|
|
|
struct lpfc_hba *phba = vport->phba;
|
|
|
|
uint32_t tmo_posted;
|
|
|
|
unsigned long iflag;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&vport->work_port_lock, iflag);
|
|
|
|
tmo_posted = vport->work_port_events & WORKER_DELAYED_DISC_TMO;
|
|
|
|
if (!tmo_posted)
|
|
|
|
vport->work_port_events |= WORKER_DELAYED_DISC_TMO;
|
|
|
|
spin_unlock_irqrestore(&vport->work_port_lock, iflag);
|
|
|
|
|
|
|
|
if (!tmo_posted)
|
|
|
|
lpfc_worker_wake_up(phba);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lpfc_delayed_disc_timeout_handler - Function called by worker thread to
|
|
|
|
* handle delayed discovery.
|
|
|
|
* @vport: pointer to a host virtual N_Port data structure.
|
|
|
|
*
|
|
|
|
* This function start nport discovery of the vport.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
lpfc_delayed_disc_timeout_handler(struct lpfc_vport *vport)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
|
|
|
|
|
|
|
|
spin_lock_irq(shost->host_lock);
|
|
|
|
if (!(vport->fc_flag & FC_DISC_DELAYED)) {
|
|
|
|
spin_unlock_irq(shost->host_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
vport->fc_flag &= ~FC_DISC_DELAYED;
|
|
|
|
spin_unlock_irq(shost->host_lock);
|
|
|
|
|
|
|
|
lpfc_do_scr_ns_plogi(vport->phba, vport);
|
|
|
|
}
|
|
|
|
|
2005-04-18 05:05:31 +08:00
|
|
|
void
|
|
|
|
lpfc_fdmi_tmo(unsigned long ptr)
|
|
|
|
{
|
2007-06-18 08:56:36 +08:00
|
|
|
struct lpfc_vport *vport = (struct lpfc_vport *)ptr;
|
|
|
|
struct lpfc_hba *phba = vport->phba;
|
2008-06-15 10:52:53 +08:00
|
|
|
uint32_t tmo_posted;
|
2005-04-18 05:05:31 +08:00
|
|
|
unsigned long iflag;
|
|
|
|
|
2007-06-18 08:56:36 +08:00
|
|
|
spin_lock_irqsave(&vport->work_port_lock, iflag);
|
2008-06-15 10:52:53 +08:00
|
|
|
tmo_posted = vport->work_port_events & WORKER_FDMI_TMO;
|
|
|
|
if (!tmo_posted)
|
2007-06-18 08:56:36 +08:00
|
|
|
vport->work_port_events |= WORKER_FDMI_TMO;
|
2008-06-15 10:52:53 +08:00
|
|
|
spin_unlock_irqrestore(&vport->work_port_lock, iflag);
|
2007-06-18 08:56:38 +08:00
|
|
|
|
2008-06-15 10:52:53 +08:00
|
|
|
if (!tmo_posted)
|
|
|
|
lpfc_worker_wake_up(phba);
|
|
|
|
return;
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_fdmi_timeout_handler(struct lpfc_vport *vport)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
|
|
|
struct lpfc_nodelist *ndlp;
|
|
|
|
|
2007-06-18 08:56:36 +08:00
|
|
|
ndlp = lpfc_findnode_did(vport, FDMI_DID);
|
2008-02-09 07:49:26 +08:00
|
|
|
if (ndlp && NLP_CHK_NODE_ACT(ndlp)) {
|
2007-06-18 08:56:36 +08:00
|
|
|
if (init_utsname()->nodename[0] != '\0')
|
|
|
|
lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA);
|
|
|
|
else
|
2013-04-18 08:14:58 +08:00
|
|
|
mod_timer(&vport->fc_fdmitmo, jiffies +
|
|
|
|
msecs_to_jiffies(1000 * 60));
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-18 08:56:36 +08:00
|
|
|
lpfc_decode_firmware_rev(struct lpfc_hba *phba, char *fwrevision, int flag)
|
2005-04-18 05:05:31 +08:00
|
|
|
{
|
|
|
|
struct lpfc_sli *psli = &phba->sli;
|
|
|
|
lpfc_vpd_t *vp = &phba->vpd;
|
|
|
|
uint32_t b1, b2, b3, b4, i, rev;
|
|
|
|
char c;
|
|
|
|
uint32_t *ptr, str[4];
|
|
|
|
uint8_t *fwname;
|
|
|
|
|
2009-06-11 05:22:44 +08:00
|
|
|
if (phba->sli_rev == LPFC_SLI_REV4)
|
2012-01-19 05:24:06 +08:00
|
|
|
snprintf(fwrevision, FW_REV_STR_SIZE, "%s", vp->rev.opFwName);
|
2009-06-11 05:22:44 +08:00
|
|
|
else if (vp->rev.rBit) {
|
2009-05-23 02:53:12 +08:00
|
|
|
if (psli->sli_flag & LPFC_SLI_ACTIVE)
|
2005-04-18 05:05:31 +08:00
|
|
|
rev = vp->rev.sli2FwRev;
|
|
|
|
else
|
|
|
|
rev = vp->rev.sli1FwRev;
|
|
|
|
|
|
|
|
b1 = (rev & 0x0000f000) >> 12;
|
|
|
|
b2 = (rev & 0x00000f00) >> 8;
|
|
|
|
b3 = (rev & 0x000000c0) >> 6;
|
|
|
|
b4 = (rev & 0x00000030) >> 4;
|
|
|
|
|
|
|
|
switch (b4) {
|
|
|
|
case 0:
|
|
|
|
c = 'N';
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
c = 'A';
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
c = 'B';
|
|
|
|
break;
|
2011-10-11 09:32:10 +08:00
|
|
|
case 3:
|
|
|
|
c = 'X';
|
|
|
|
break;
|
2005-04-18 05:05:31 +08:00
|
|
|
default:
|
|
|
|
c = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
b4 = (rev & 0x0000000f);
|
|
|
|
|
2009-05-23 02:53:12 +08:00
|
|
|
if (psli->sli_flag & LPFC_SLI_ACTIVE)
|
2005-04-18 05:05:31 +08:00
|
|
|
fwname = vp->rev.sli2FwName;
|
|
|
|
else
|
|
|
|
fwname = vp->rev.sli1FwName;
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
if (fwname[i] == 0x20)
|
|
|
|
fwname[i] = 0;
|
|
|
|
|
|
|
|
ptr = (uint32_t*)fwname;
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
str[i] = be32_to_cpu(*ptr++);
|
|
|
|
|
|
|
|
if (c == 0) {
|
|
|
|
if (flag)
|
|
|
|
sprintf(fwrevision, "%d.%d%d (%s)",
|
|
|
|
b1, b2, b3, (char *)str);
|
|
|
|
else
|
|
|
|
sprintf(fwrevision, "%d.%d%d", b1,
|
|
|
|
b2, b3);
|
|
|
|
} else {
|
|
|
|
if (flag)
|
|
|
|
sprintf(fwrevision, "%d.%d%d%c%d (%s)",
|
|
|
|
b1, b2, b3, c,
|
|
|
|
b4, (char *)str);
|
|
|
|
else
|
|
|
|
sprintf(fwrevision, "%d.%d%d%c%d",
|
|
|
|
b1, b2, b3, c, b4);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rev = vp->rev.smFwRev;
|
|
|
|
|
|
|
|
b1 = (rev & 0xff000000) >> 24;
|
|
|
|
b2 = (rev & 0x00f00000) >> 20;
|
|
|
|
b3 = (rev & 0x000f0000) >> 16;
|
|
|
|
c = (rev & 0x0000ff00) >> 8;
|
|
|
|
b4 = (rev & 0x000000ff);
|
|
|
|
|
2010-01-17 23:15:57 +08:00
|
|
|
sprintf(fwrevision, "%d.%d%d%c%d", b1, b2, b3, c, b4);
|
2005-04-18 05:05:31 +08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|