usr/src/uts/common/io/fibre-channel/impl/fp.c
author Rijawanemohammadhusen Nadaf<Riz.Nadaf@Sun.COM>
Thu, 12 Aug 2010 18:18:07 +0530
changeset 13096 33ad53eb7c84
parent 11617 8854b1d29e96
permissions -rw-r--r--
6956269 WARNING:fp(0)::fp_plogi_intr on NL nodes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
     1
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
     2
 * CDDL HEADER START
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
     3
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
     7
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    11
 * and limitations under the License.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    12
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    18
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    19
 * CDDL HEADER END
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    20
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    21
/*
13096
33ad53eb7c84 6956269 WARNING:fp(0)::fp_plogi_intr on NL nodes
Rijawanemohammadhusen Nadaf<Riz.Nadaf@Sun.COM>
parents: 11617
diff changeset
    22
 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    23
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    24
 * NOT a DDI compliant Sun Fibre Channel port driver(fp)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    25
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    26
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    27
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    28
#include <sys/types.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    29
#include <sys/varargs.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    30
#include <sys/param.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    31
#include <sys/errno.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    32
#include <sys/uio.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    33
#include <sys/buf.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    34
#include <sys/modctl.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    35
#include <sys/open.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    36
#include <sys/file.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    37
#include <sys/kmem.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    38
#include <sys/poll.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    39
#include <sys/conf.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    40
#include <sys/thread.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    41
#include <sys/var.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    42
#include <sys/cmn_err.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    43
#include <sys/stat.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    44
#include <sys/ddi.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    45
#include <sys/sunddi.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    46
#include <sys/promif.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    47
#include <sys/nvpair.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    48
#include <sys/byteorder.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    49
#include <sys/scsi/scsi.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    50
#include <sys/fibre-channel/fc.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    51
#include <sys/fibre-channel/impl/fc_ulpif.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    52
#include <sys/fibre-channel/impl/fc_fcaif.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    53
#include <sys/fibre-channel/impl/fctl_private.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    54
#include <sys/fibre-channel/impl/fc_portif.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    55
#include <sys/fibre-channel/impl/fp.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    56
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    57
/* These are defined in fctl.c! */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    58
extern int did_table_size;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    59
extern int pwwn_table_size;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    60
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    61
static struct cb_ops fp_cb_ops = {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    62
	fp_open,			/* open */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    63
	fp_close,			/* close */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    64
	nodev,				/* strategy */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    65
	nodev,				/* print */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    66
	nodev,				/* dump */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    67
	nodev,				/* read */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    68
	nodev,				/* write */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    69
	fp_ioctl,			/* ioctl */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    70
	nodev,				/* devmap */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    71
	nodev,				/* mmap */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    72
	nodev,				/* segmap */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    73
	nochpoll,			/* chpoll */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    74
	ddi_prop_op,			/* cb_prop_op */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    75
	0,				/* streamtab */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    76
	D_NEW | D_MP | D_HOTPLUG,	/* cb_flag */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    77
	CB_REV,				/* rev */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    78
	nodev,				/* aread */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    79
	nodev				/* awrite */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    80
};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    81
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    82
static struct dev_ops fp_ops = {
9163
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    83
	DEVO_REV,			/* build revision */
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    84
	0,				/* reference count */
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    85
	fp_getinfo,			/* getinfo */
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    86
	nulldev,			/* identify - Obsoleted */
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    87
	nulldev,			/* probe */
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    88
	fp_attach,			/* attach */
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    89
	fp_detach,			/* detach */
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    90
	nodev,				/* reset */
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    91
	&fp_cb_ops,			/* cb_ops */
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    92
	NULL,				/* bus_ops */
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    93
	fp_power,			/* power */
ebac8ae1690b 6809607 fp has no quiesce()
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8728
diff changeset
    94
	ddi_quiesce_not_needed 		/* quiesce */
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    95
};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    96
11156
fa5f12909da7 6677595 HBA_GetNumberOfAdapters occasionally does not return the correct adapter count
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 10339
diff changeset
    97
#define	FP_VERSION		"20091123-1.101"
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    98
#define	FP_NAME_VERSION		"SunFC Port v" FP_VERSION
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
    99
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   100
char *fp_version = FP_NAME_VERSION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   101
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   102
static struct modldrv modldrv = {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   103
	&mod_driverops,			/* Type of Module */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   104
	FP_NAME_VERSION,		/* Name/Version of fp */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   105
	&fp_ops				/* driver ops */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   106
};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   107
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   108
static struct modlinkage modlinkage = {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   109
	MODREV_1,	/* Rev of the loadable modules system */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   110
	&modldrv,	/* NULL terminated list of */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   111
	NULL		/* Linkage structures */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   112
};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   113
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   114
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   115
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   116
static uint16_t ns_reg_cmds[] = {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   117
	NS_RPN_ID,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   118
	NS_RNN_ID,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   119
	NS_RCS_ID,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   120
	NS_RFT_ID,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   121
	NS_RPT_ID,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   122
	NS_RSPN_ID,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   123
	NS_RSNN_NN
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   124
};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   125
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   126
struct fp_xlat {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   127
	uchar_t	xlat_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   128
	int	xlat_rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   129
} fp_xlat [] = {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   130
	{ FC_PKT_SUCCESS,	FC_SUCCESS },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   131
	{ FC_PKT_REMOTE_STOP,	FC_FAILURE },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   132
	{ FC_PKT_LOCAL_RJT,	FC_FAILURE },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   133
	{ FC_PKT_NPORT_RJT,	FC_ELS_PREJECT },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   134
	{ FC_PKT_FABRIC_RJT,	FC_ELS_FREJECT },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   135
	{ FC_PKT_LOCAL_BSY,	FC_TRAN_BUSY },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   136
	{ FC_PKT_TRAN_BSY,	FC_TRAN_BUSY },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   137
	{ FC_PKT_NPORT_BSY,	FC_PBUSY },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   138
	{ FC_PKT_FABRIC_BSY,	FC_FBUSY },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   139
	{ FC_PKT_LS_RJT,	FC_FAILURE },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   140
	{ FC_PKT_BA_RJT,	FC_FAILURE },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   141
	{ FC_PKT_TIMEOUT,	FC_FAILURE },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   142
	{ FC_PKT_TRAN_ERROR,	FC_TRANSPORT_ERROR },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   143
	{ FC_PKT_FAILURE,	FC_FAILURE },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   144
	{ FC_PKT_PORT_OFFLINE,	FC_OFFLINE }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   145
};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   146
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   147
static uchar_t fp_valid_alpas[] = {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   148
	0x01, 0x02, 0x04, 0x08, 0x0F, 0x10, 0x17, 0x18, 0x1B,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   149
	0x1D, 0x1E, 0x1F, 0x23, 0x25, 0x26, 0x27, 0x29, 0x2A,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   150
	0x2B, 0x2C, 0x2D, 0x2E, 0x31, 0x32, 0x33, 0x34, 0x35,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   151
	0x36, 0x39, 0x3A, 0x3C, 0x43, 0x45, 0x46, 0x47, 0x49,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   152
	0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x51, 0x52, 0x53, 0x54,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   153
	0x55, 0x56, 0x59, 0x5A, 0x5C, 0x63, 0x65, 0x66, 0x67,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   154
	0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x71, 0x72, 0x73,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   155
	0x74, 0x75, 0x76, 0x79, 0x7A, 0x7C, 0x80, 0x81, 0x82,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   156
	0x84, 0x88, 0x8F, 0x90, 0x97, 0x98, 0x9B, 0x9D, 0x9E,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   157
	0x9F, 0xA3, 0xA5, 0xA6, 0xA7, 0xA9, 0xAA, 0xAB, 0xAC,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   158
	0xAD, 0xAE, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB9,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   159
	0xBA, 0xBC, 0xC3, 0xC5, 0xC6, 0xC7, 0xC9, 0xCA, 0xCB,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   160
	0xCC, 0xCD, 0xCE, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   161
	0xD9, 0xDA, 0xDC, 0xE0, 0xE1, 0xE2, 0xE4, 0xE8, 0xEF
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   162
};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   163
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   164
static struct fp_perms {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   165
	uint16_t	fp_ioctl_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   166
	uchar_t		fp_open_flag;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   167
} fp_perm_list [] = {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   168
	{ FCIO_GET_NUM_DEVS,		FP_OPEN },
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   169
	{ FCIO_GET_DEV_LIST,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   170
	{ FCIO_GET_SYM_PNAME,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   171
	{ FCIO_GET_SYM_NNAME,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   172
	{ FCIO_SET_SYM_PNAME,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   173
	{ FCIO_SET_SYM_NNAME,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   174
	{ FCIO_GET_LOGI_PARAMS,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   175
	{ FCIO_DEV_LOGIN,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   176
	{ FCIO_DEV_LOGOUT,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   177
	{ FCIO_GET_STATE,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   178
	{ FCIO_DEV_REMOVE,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   179
	{ FCIO_GET_FCODE_REV,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   180
	{ FCIO_GET_FW_REV,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   181
	{ FCIO_GET_DUMP_SIZE,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   182
	{ FCIO_FORCE_DUMP,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   183
	{ FCIO_GET_DUMP,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   184
	{ FCIO_GET_TOPOLOGY,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   185
	{ FCIO_RESET_LINK,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   186
	{ FCIO_RESET_HARD,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   187
	{ FCIO_RESET_HARD_CORE,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   188
	{ FCIO_DIAG,			FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   189
	{ FCIO_NS,			FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   190
	{ FCIO_DOWNLOAD_FW,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   191
	{ FCIO_DOWNLOAD_FCODE,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   192
	{ FCIO_LINK_STATUS,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   193
	{ FCIO_GET_HOST_PARAMS,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   194
	{ FCIO_GET_NODE_ID,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   195
	{ FCIO_SET_NODE_ID,		FP_EXCL },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   196
	{ FCIO_SEND_NODE_ID,		FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   197
	{ FCIO_GET_ADAPTER_ATTRIBUTES,	FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   198
	{ FCIO_GET_OTHER_ADAPTER_PORTS,	FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   199
	{ FCIO_GET_ADAPTER_PORT_ATTRIBUTES,	FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   200
	{ FCIO_GET_DISCOVERED_PORT_ATTRIBUTES,	FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   201
	{ FCIO_GET_PORT_ATTRIBUTES,	FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   202
	{ FCIO_GET_ADAPTER_PORT_STATS,	FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   203
	{ FCIO_GET_ADAPTER_PORT_NPIV_ATTRIBUTES, FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   204
	{ FCIO_GET_NPIV_PORT_LIST, FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   205
	{ FCIO_DELETE_NPIV_PORT, FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   206
	{ FCIO_GET_NPIV_ATTRIBUTES, FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   207
	{ FCIO_CREATE_NPIV_PORT, FP_OPEN },
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   208
	{ FCIO_NPIV_GET_ADAPTER_ATTRIBUTES, FP_OPEN }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   209
};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   210
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   211
static char *fp_pm_comps[] = {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   212
	"NAME=FC Port",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   213
	"0=Port Down",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   214
	"1=Port Up"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   215
};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   216
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   217
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   218
#ifdef	_LITTLE_ENDIAN
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   219
#define	MAKE_BE_32(x)	{						\
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   220
		uint32_t	*ptr1, i;				\
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   221
		ptr1 = (uint32_t *)(x);					\
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   222
		for (i = 0; i < sizeof (*(x)) / sizeof (uint32_t); i++) { \
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   223
			*ptr1 = BE_32(*ptr1);				\
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   224
			ptr1++;						\
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   225
		}							\
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   226
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   227
#else
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   228
#define	MAKE_BE_32(x)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   229
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   230
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   231
static uchar_t fp_verbosity = (FP_WARNING_MESSAGES | FP_FATAL_MESSAGES);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   232
static uint32_t fp_options = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   233
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   234
static int fp_cmd_wait_cnt = FP_CMDWAIT_DELAY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   235
static int fp_retry_delay = FP_RETRY_DELAY;	/* retry after this delay */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   236
static int fp_retry_count = FP_RETRY_COUNT;	/* number of retries */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   237
unsigned int fp_offline_ticker;			/* seconds */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   238
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   239
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   240
 * Driver global variable to anchor the list of soft state structs for
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   241
 * all fp driver instances.  Used with the Solaris DDI soft state functions.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   242
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   243
static void *fp_driver_softstate;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   244
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   245
static clock_t	fp_retry_ticks;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   246
static clock_t	fp_offline_ticks;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   247
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   248
static int fp_retry_ticker;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   249
static uint32_t fp_unsol_buf_count = FP_UNSOL_BUF_COUNT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   250
static uint32_t fp_unsol_buf_size = FP_UNSOL_BUF_SIZE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   251
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   252
static int		fp_log_size = FP_LOG_SIZE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   253
static int		fp_trace = FP_TRACE_DEFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   254
static fc_trace_logq_t	*fp_logq = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   255
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   256
int fp_get_adapter_paths(char *pathList, int count);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   257
static void fp_log_port_event(fc_local_port_t *port, char *subclass);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   258
static void fp_log_target_event(fc_local_port_t *port, char *subclass,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   259
    la_wwn_t tgt_pwwn, uint32_t port_id);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   260
static uint32_t fp_map_remote_port_state(uint32_t rm_state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   261
static void fp_init_symbolic_names(fc_local_port_t *port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   262
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   263
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   264
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   265
 * Perform global initialization
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   266
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   267
int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   268
_init(void)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   269
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   270
	int ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   271
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   272
	if ((ret = ddi_soft_state_init(&fp_driver_softstate,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   273
	    sizeof (struct fc_local_port), 8)) != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   274
		return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   275
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   276
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   277
	if ((ret = scsi_hba_init(&modlinkage)) != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   278
		ddi_soft_state_fini(&fp_driver_softstate);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   279
		return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   280
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   281
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   282
	fp_logq = fc_trace_alloc_logq(fp_log_size);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   283
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   284
	if ((ret = mod_install(&modlinkage)) != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   285
		fc_trace_free_logq(fp_logq);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   286
		ddi_soft_state_fini(&fp_driver_softstate);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   287
		scsi_hba_fini(&modlinkage);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   288
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   289
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   290
	return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   291
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   292
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   293
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   294
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   295
 * Prepare for driver unload
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   296
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   297
int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   298
_fini(void)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   299
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   300
	int ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   301
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   302
	if ((ret = mod_remove(&modlinkage)) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   303
		fc_trace_free_logq(fp_logq);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   304
		ddi_soft_state_fini(&fp_driver_softstate);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   305
		scsi_hba_fini(&modlinkage);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   306
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   307
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   308
	return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   309
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   310
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   311
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   312
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   313
 * Request mod_info() to handle all cases
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   314
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   315
int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   316
_info(struct modinfo *modinfo)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   317
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   318
	return (mod_info(&modlinkage, modinfo));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   319
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   320
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   321
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   322
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   323
 * fp_attach:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   324
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   325
 * The respective cmd handlers take care of performing
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   326
 * ULP related invocations
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   327
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   328
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   329
fp_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   330
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   331
	int rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   332
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   333
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   334
	 * We check the value of fp_offline_ticker at this
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   335
	 * point. The variable is global for the driver and
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   336
	 * not specific to an instance.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   337
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   338
	 * If there is no user-defined value found in /etc/system
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   339
	 * or fp.conf, then we use 90 seconds (FP_OFFLINE_TICKER).
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   340
	 * The minimum setting for this offline timeout according
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   341
	 * to the FC-FS2 standard (Fibre Channel Framing and
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   342
	 * Signalling-2, see www.t11.org) is R_T_TOV == 100msec.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   343
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   344
	 * We do not recommend setting the value to less than 10
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   345
	 * seconds (RA_TOV) or more than 90 seconds. If this
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   346
	 * variable is greater than 90 seconds then drivers above
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   347
	 * fp (fcp, sd, scsi_vhci, vxdmp et al) might complain.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   348
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   349
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   350
	fp_offline_ticker = ddi_prop_get_int(DDI_DEV_T_ANY,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   351
	    dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "fp_offline_ticker",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   352
	    FP_OFFLINE_TICKER);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   353
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   354
	if ((fp_offline_ticker < 10) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   355
	    (fp_offline_ticker > 90)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   356
		cmn_err(CE_WARN, "Setting fp_offline_ticker to "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   357
		    "%d second(s). This is outside the "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   358
		    "recommended range of 10..90 seconds",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   359
		    fp_offline_ticker);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   360
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   361
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   362
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   363
	 * Tick every second when there are commands to retry.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   364
	 * It should tick at the least granular value of pkt_timeout
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   365
	 * (which is one second)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   366
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   367
	fp_retry_ticker = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   368
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   369
	fp_retry_ticks = drv_usectohz(fp_retry_ticker * 1000 * 1000);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   370
	fp_offline_ticks = drv_usectohz(fp_offline_ticker * 1000 * 1000);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   371
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   372
	switch (cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   373
	case DDI_ATTACH:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   374
		rval = fp_attach_handler(dip);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   375
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   376
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   377
	case DDI_RESUME:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   378
		rval = fp_resume_handler(dip);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   379
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   380
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   381
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   382
		rval = DDI_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   383
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   384
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   385
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   386
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   387
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   388
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   389
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   390
 * fp_detach:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   391
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   392
 * If a ULP fails to handle cmd request converse of
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   393
 * cmd is invoked for ULPs that previously succeeded
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   394
 * cmd request.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   395
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   396
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   397
fp_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   398
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   399
	int			rval = DDI_FAILURE;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   400
	fc_local_port_t		*port;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   401
	fc_attach_cmd_t		converse;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   402
	uint8_t			cnt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   403
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   404
	if ((port = ddi_get_soft_state(fp_driver_softstate,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   405
	    ddi_get_instance(dip))) == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   406
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   407
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   408
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   409
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   410
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   411
	if (port->fp_ulp_attach) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   412
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   413
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   414
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   415
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   416
	switch (cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   417
	case DDI_DETACH:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   418
		if (port->fp_task != FP_TASK_IDLE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   419
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   420
			return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   421
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   422
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   423
		/* Let's attempt to quit the job handler gracefully */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   424
		port->fp_soft_state |= FP_DETACH_INPROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   425
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   426
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   427
		converse = FC_CMD_ATTACH;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   428
		if (fctl_detach_ulps(port, FC_CMD_DETACH,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   429
		    &modlinkage) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   430
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   431
			port->fp_soft_state &= ~FP_DETACH_INPROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   432
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   433
			rval = DDI_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   434
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   435
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   436
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   437
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   438
		for (cnt = 0; (port->fp_job_head) && (cnt < fp_cmd_wait_cnt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   439
		    cnt++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   440
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   441
			delay(drv_usectohz(1000000));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   442
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   443
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   444
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   445
		if (port->fp_job_head) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   446
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   447
			rval = DDI_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   448
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   449
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   450
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   451
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   452
		rval = fp_detach_handler(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   453
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   454
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   455
	case DDI_SUSPEND:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   456
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   457
		converse = FC_CMD_RESUME;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   458
		if (fctl_detach_ulps(port, FC_CMD_SUSPEND,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   459
		    &modlinkage) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   460
			rval = DDI_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   461
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   462
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   463
		if ((rval = fp_suspend_handler(port)) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   464
			(void) callb_generic_cpr(&port->fp_cpr_info,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   465
			    CB_CODE_CPR_RESUME);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   466
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   467
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   468
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   469
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   470
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   471
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   472
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   473
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   474
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   475
	 * Use softint to perform reattach.  Mark fp_ulp_attach so we
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   476
	 * don't attempt to do this repeatedly on behalf of some persistent
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   477
	 * caller.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   478
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   479
	if (rval != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   480
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   481
		port->fp_ulp_attach = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   482
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   483
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   484
		 * If the port is in the low power mode then there is
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   485
		 * possibility that fca too could be in low power mode.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   486
		 * Try to raise the power before calling attach ulps.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   487
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   488
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   489
		if ((port->fp_soft_state & FP_SOFT_POWER_DOWN) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   490
		    (!(port->fp_soft_state & FP_SOFT_NO_PMCOMP))) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   491
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   492
			(void) pm_raise_power(port->fp_port_dip,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   493
			    FP_PM_COMPONENT, FP_PM_PORT_UP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   494
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   495
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   496
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   497
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   498
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   499
		fp_attach_ulps(port, converse);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   500
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   501
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   502
		while (port->fp_ulp_attach) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   503
			cv_wait(&port->fp_attach_cv, &port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   504
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   505
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   506
		port->fp_soft_state &= ~FP_DETACH_INPROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   507
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   508
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   509
		 * Mark state as detach failed so asynchronous ULP attach
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   510
		 * events (downstream, not the ones we're initiating with
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   511
		 * the call to fp_attach_ulps) are not honored.	 We're
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   512
		 * really still in pending detach.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   513
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   514
		port->fp_soft_state |= FP_DETACH_FAILED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   515
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   516
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   517
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   518
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   519
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   520
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   521
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   522
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   523
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   524
 * fp_getinfo:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   525
 *   Given the device number, return either the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   526
 *   dev_info_t pointer or the instance number.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   527
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   528
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   529
/* ARGSUSED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   530
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   531
fp_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   532
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   533
	int		rval;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   534
	minor_t		instance;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   535
	fc_local_port_t *port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   536
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   537
	rval = DDI_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   538
	instance = getminor((dev_t)arg);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   539
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   540
	switch (cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   541
	case DDI_INFO_DEVT2DEVINFO:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   542
		if ((port = ddi_get_soft_state(fp_driver_softstate,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   543
		    instance)) == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   544
			rval = DDI_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   545
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   546
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   547
		*result = (void *)port->fp_port_dip;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   548
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   549
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   550
	case DDI_INFO_DEVT2INSTANCE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   551
		*result = (void *)(uintptr_t)instance;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   552
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   553
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   554
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   555
		rval = DDI_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   556
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   557
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   558
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   559
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   560
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   561
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   562
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   563
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   564
 * Entry point for power up and power down request from kernel
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   565
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   566
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   567
fp_power(dev_info_t *dip, int comp, int level)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   568
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   569
	int		rval = DDI_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   570
	fc_local_port_t	*port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   571
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   572
	port = ddi_get_soft_state(fp_driver_softstate, ddi_get_instance(dip));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   573
	if (port == NULL || comp != FP_PM_COMPONENT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   574
		return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   575
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   576
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   577
	switch (level) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   578
	case FP_PM_PORT_UP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   579
		rval = DDI_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   580
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   581
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   582
		 * If the port is DDI_SUSPENDed, let the DDI_RESUME
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   583
		 * code complete the rediscovery.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   584
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   585
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   586
		if (port->fp_soft_state & FP_SOFT_SUSPEND) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   587
			port->fp_soft_state &= ~FP_SOFT_POWER_DOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   588
			port->fp_pm_level = FP_PM_PORT_UP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   589
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   590
			fctl_attach_ulps(port, FC_CMD_POWER_UP, &modlinkage);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   591
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   592
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   593
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   594
		if (port->fp_soft_state & FP_SOFT_POWER_DOWN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   595
			ASSERT(port->fp_pm_level == FP_PM_PORT_DOWN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   596
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   597
			port->fp_pm_level = FP_PM_PORT_UP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   598
			rval = fp_power_up(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   599
			if (rval != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   600
				port->fp_pm_level = FP_PM_PORT_DOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   601
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   602
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   603
			port->fp_pm_level = FP_PM_PORT_UP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   604
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   605
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   606
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   607
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   608
	case FP_PM_PORT_DOWN:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   609
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   610
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   611
		ASSERT(!(port->fp_soft_state & FP_SOFT_NO_PMCOMP));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   612
		if (port->fp_soft_state & FP_SOFT_NO_PMCOMP) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   613
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   614
			 * PM framework goofed up. We have don't
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   615
			 * have any PM components. Let's never go down.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   616
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   617
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   618
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   619
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   620
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   621
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   622
		if (port->fp_ulp_attach) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   623
			/* We shouldn't let the power go down */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   624
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   625
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   626
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   627
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   628
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   629
		 * Not a whole lot to do if we are detaching
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   630
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   631
		if (port->fp_soft_state & FP_SOFT_IN_DETACH) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   632
			port->fp_pm_level = FP_PM_PORT_DOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   633
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   634
			rval = DDI_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   635
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   636
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   637
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   638
		if (!port->fp_pm_busy && !port->fp_pm_busy_nocomp) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   639
			port->fp_pm_level = FP_PM_PORT_DOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   640
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   641
			rval = fp_power_down(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   642
			if (rval != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   643
				port->fp_pm_level = FP_PM_PORT_UP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   644
				ASSERT(!(port->fp_soft_state &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   645
				    FP_SOFT_POWER_DOWN));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   646
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   647
				ASSERT(port->fp_soft_state &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   648
				    FP_SOFT_POWER_DOWN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   649
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   650
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   651
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   652
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   653
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   654
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   655
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   656
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   657
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   658
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   659
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   660
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   661
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   662
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   663
 * Open FC port devctl node
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   664
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   665
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   666
fp_open(dev_t *devp, int flag, int otype, cred_t *credp)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   667
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   668
	int		instance;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   669
	fc_local_port_t *port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   670
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   671
	if (otype != OTYP_CHR) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   672
		return (EINVAL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   673
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   674
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   675
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   676
	 * This is not a toy to play with. Allow only powerful
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   677
	 * users (hopefully knowledgeable) to access the port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   678
	 * (A hacker potentially could download a sick binary
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   679
	 * file into FCA)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   680
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   681
	if (drv_priv(credp)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   682
		return (EPERM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   683
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   684
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   685
	instance = (int)getminor(*devp);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   686
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   687
	port = ddi_get_soft_state(fp_driver_softstate, instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   688
	if (port == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   689
		return (ENXIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   690
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   691
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   692
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   693
	if (port->fp_flag & FP_EXCL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   694
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   695
		 * It is already open for exclusive access.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   696
		 * So shut the door on this caller.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   697
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   698
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   699
		return (EBUSY);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   700
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   701
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   702
	if (flag & FEXCL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   703
		if (port->fp_flag & FP_OPEN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   704
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   705
			 * Exclusive operation not possible
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   706
			 * as it is already opened
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   707
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   708
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   709
			return (EBUSY);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   710
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   711
		port->fp_flag |= FP_EXCL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   712
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   713
	port->fp_flag |= FP_OPEN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   714
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   715
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   716
	return (0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   717
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   718
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   719
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   720
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   721
 * The driver close entry point is called on the last close()
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   722
 * of a device. So it is perfectly alright to just clobber the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   723
 * open flag and reset it to idle (instead of having to reset
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   724
 * each flag bits). For any confusion, check out close(9E).
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   725
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   726
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   727
/* ARGSUSED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   728
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   729
fp_close(dev_t dev, int flag, int otype, cred_t *credp)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   730
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   731
	int		instance;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   732
	fc_local_port_t *port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   733
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   734
	if (otype != OTYP_CHR) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   735
		return (EINVAL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   736
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   737
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   738
	instance = (int)getminor(dev);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   739
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   740
	port = ddi_get_soft_state(fp_driver_softstate, instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   741
	if (port == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   742
		return (ENXIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   743
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   744
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   745
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   746
	if ((port->fp_flag & FP_OPEN) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   747
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   748
		return (ENODEV);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   749
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   750
	port->fp_flag = FP_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   751
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   752
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   753
	return (0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   754
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   755
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   756
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   757
 * Handle IOCTL requests
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   758
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   759
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   760
/* ARGSUSED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   761
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   762
fp_ioctl(dev_t dev, int cmd, intptr_t data, int mode, cred_t *credp, int *rval)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   763
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   764
	int		instance;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   765
	int		ret = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   766
	fcio_t		fcio;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   767
	fc_local_port_t *port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   768
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   769
	instance = (int)getminor(dev);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   770
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   771
	port = ddi_get_soft_state(fp_driver_softstate, instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   772
	if (port == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   773
		return (ENXIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   774
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   775
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   776
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   777
	if ((port->fp_flag & FP_OPEN) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   778
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   779
		return (ENXIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   780
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   781
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   782
	if (port->fp_soft_state & FP_SOFT_SUSPEND) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   783
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   784
		return (ENXIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   785
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   786
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   787
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   788
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   789
	/* this will raise power if necessary */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   790
	ret = fctl_busy_port(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   791
	if (ret != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   792
		return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   793
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   794
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   795
	ASSERT(port->fp_pm_level == FP_PM_PORT_UP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   796
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   797
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   798
	switch (cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   799
	case FCIO_CMD: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   800
#ifdef	_MULTI_DATAMODEL
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   801
		switch (ddi_model_convert_from(mode & FMODELS)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   802
		case DDI_MODEL_ILP32: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   803
			struct fcio32 fcio32;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   804
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   805
			if (ddi_copyin((void *)data, (void *)&fcio32,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   806
			    sizeof (struct fcio32), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   807
				ret = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   808
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   809
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   810
			fcio.fcio_xfer = fcio32.fcio_xfer;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   811
			fcio.fcio_cmd = fcio32.fcio_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   812
			fcio.fcio_flags = fcio32.fcio_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   813
			fcio.fcio_cmd_flags = fcio32.fcio_cmd_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   814
			fcio.fcio_ilen = (size_t)fcio32.fcio_ilen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   815
			fcio.fcio_ibuf =
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   816
			    (caddr_t)(uintptr_t)fcio32.fcio_ibuf;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   817
			fcio.fcio_olen = (size_t)fcio32.fcio_olen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   818
			fcio.fcio_obuf =
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   819
			    (caddr_t)(uintptr_t)fcio32.fcio_obuf;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   820
			fcio.fcio_alen = (size_t)fcio32.fcio_alen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   821
			fcio.fcio_abuf =
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   822
			    (caddr_t)(uintptr_t)fcio32.fcio_abuf;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   823
			fcio.fcio_errno = fcio32.fcio_errno;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   824
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   825
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   826
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   827
		case DDI_MODEL_NONE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   828
			if (ddi_copyin((void *)data, (void *)&fcio,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   829
			    sizeof (fcio_t), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   830
				ret = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   831
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   832
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   833
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   834
#else	/* _MULTI_DATAMODEL */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   835
		if (ddi_copyin((void *)data, (void *)&fcio,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   836
		    sizeof (fcio_t), mode)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   837
			ret = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   838
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   839
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   840
#endif	/* _MULTI_DATAMODEL */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   841
		if (!ret) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   842
			ret = fp_fciocmd(port, data, mode, &fcio);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   843
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   844
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   845
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   846
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   847
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   848
		ret = fctl_ulp_port_ioctl(port, dev, cmd, data,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   849
		    mode, credp, rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   850
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   851
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   852
	fctl_idle_port(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   853
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   854
	return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   855
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   856
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   857
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   858
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   859
 * Init Symbolic Port Name and Node Name
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   860
 * LV will try to get symbolic names from FCA driver
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   861
 * and register these to name server,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   862
 * if LV fails to get these,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   863
 * LV will register its default symbolic names to name server.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   864
 * The Default symbolic node name format is :
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   865
 *	<hostname>:<hba driver name>(instance)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   866
 * The Default symbolic port name format is :
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   867
 *	<fp path name>
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   868
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   869
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   870
fp_init_symbolic_names(fc_local_port_t *port)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   871
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   872
	const char *vendorname = ddi_driver_name(port->fp_fca_dip);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   873
	char *sym_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   874
	char fcaname[50] = {0};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   875
	int hostnlen, fcanlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   876
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   877
	if (port->fp_sym_node_namelen == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   878
		hostnlen = strlen(utsname.nodename);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   879
		(void) snprintf(fcaname, sizeof (fcaname),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   880
		    "%s%d", vendorname, ddi_get_instance(port->fp_fca_dip));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   881
		fcanlen = strlen(fcaname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   882
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   883
		sym_name = kmem_zalloc(hostnlen + fcanlen + 2, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   884
		(void) sprintf(sym_name, "%s:%s", utsname.nodename, fcaname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   885
		port->fp_sym_node_namelen = strlen(sym_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   886
		if (port->fp_sym_node_namelen >= FCHBA_SYMB_NAME_LEN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   887
			port->fp_sym_node_namelen = FCHBA_SYMB_NAME_LEN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   888
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   889
		(void) strncpy(port->fp_sym_node_name, sym_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   890
		    port->fp_sym_node_namelen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   891
		kmem_free(sym_name, hostnlen + fcanlen + 2);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   892
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   893
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   894
	if (port->fp_sym_port_namelen == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   895
		char *pathname = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   896
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   897
		(void) ddi_pathname(port->fp_port_dip, pathname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   898
		port->fp_sym_port_namelen = strlen(pathname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   899
		if (port->fp_sym_port_namelen >= FCHBA_SYMB_NAME_LEN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   900
			port->fp_sym_port_namelen = FCHBA_SYMB_NAME_LEN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   901
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   902
		(void) strncpy(port->fp_sym_port_name, pathname,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   903
		    port->fp_sym_port_namelen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   904
		kmem_free(pathname, MAXPATHLEN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   905
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   906
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   907
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   908
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   909
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   910
 * Perform port attach
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   911
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   912
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   913
fp_attach_handler(dev_info_t *dip)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   914
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   915
	int			rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   916
	int			instance;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   917
	int			port_num;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   918
	int			port_len;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   919
	char			name[30];
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   920
	char			i_pwwn[17];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   921
	fp_cmd_t		*pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   922
	uint32_t		ub_count;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   923
	fc_local_port_t		*port;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
   924
	job_request_t		*job;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   925
	fc_local_port_t *phyport = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   926
	int portpro1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   927
	char pwwn[17], nwwn[17];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   928
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   929
	instance = ddi_get_instance(dip);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   930
	port_len = sizeof (port_num);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   931
	rval = ddi_prop_op(DDI_DEV_T_ANY, dip, PROP_LEN_AND_VAL_BUF,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   932
	    DDI_PROP_DONTPASS | DDI_PROP_CANSLEEP, "port",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   933
	    (caddr_t)&port_num, &port_len);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   934
	if (rval != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   935
		cmn_err(CE_WARN, "fp(%d): No port property in devinfo",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   936
		    instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   937
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   938
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   939
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   940
	if (ddi_create_minor_node(dip, "devctl", S_IFCHR, instance,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   941
	    DDI_NT_NEXUS, 0) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   942
		cmn_err(CE_WARN, "fp(%d): failed to create devctl minor node",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   943
		    instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   944
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   945
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   946
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   947
	if (ddi_create_minor_node(dip, "fc", S_IFCHR, instance,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   948
	    DDI_NT_FC_ATTACHMENT_POINT, 0) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   949
		cmn_err(CE_WARN, "fp(%d): failed to create fc attachment"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   950
		    " point minor node", instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   951
		ddi_remove_minor_node(dip, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   952
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   953
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   954
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   955
	if (ddi_soft_state_zalloc(fp_driver_softstate, instance)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   956
	    != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   957
		cmn_err(CE_WARN, "fp(%d): failed to alloc soft state",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   958
		    instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   959
		ddi_remove_minor_node(dip, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   960
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   961
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   962
	port = ddi_get_soft_state(fp_driver_softstate, instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   963
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   964
	(void) sprintf(port->fp_ibuf, "fp(%d)", instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   965
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   966
	port->fp_instance = instance;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   967
	port->fp_ulp_attach = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   968
	port->fp_port_num = port_num;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   969
	port->fp_verbose = fp_verbosity;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   970
	port->fp_options = fp_options;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   971
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   972
	port->fp_fca_dip = ddi_get_parent(dip);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   973
	port->fp_port_dip = dip;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   974
	port->fp_fca_tran = (fc_fca_tran_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   975
	    ddi_get_driver_private(port->fp_fca_dip);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   976
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   977
	port->fp_task = port->fp_last_task = FP_TASK_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   978
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   979
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   980
	 * Init the starting value of fp_rscn_count. Note that if
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   981
	 * FC_INVALID_RSCN_COUNT is 0 (which is what it currently is), the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   982
	 * actual # of RSCNs will be (fp_rscn_count - 1)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   983
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   984
	port->fp_rscn_count = FC_INVALID_RSCN_COUNT + 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   985
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   986
	mutex_init(&port->fp_mutex, NULL, MUTEX_DRIVER, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   987
	cv_init(&port->fp_cv, NULL, CV_DRIVER, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   988
	cv_init(&port->fp_attach_cv, NULL, CV_DRIVER, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   989
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   990
	(void) sprintf(name, "fp%d_cache", instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   991
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   992
	if ((portpro1 = ddi_prop_get_int(DDI_DEV_T_ANY,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   993
	    dip, DDI_PROP_DONTPASS | DDI_PROP_NOTPROM,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   994
	    "phyport-instance", -1)) != -1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   995
		phyport = ddi_get_soft_state(fp_driver_softstate, portpro1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   996
		fc_wwn_to_str(&phyport->fp_service_params.nport_ww_name, pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   997
		fc_wwn_to_str(&phyport->fp_service_params.node_ww_name, nwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   998
		port->fp_npiv_type = FC_NPIV_PORT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
   999
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1000
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1001
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1002
	 * Allocate the pool of fc_packet_t structs to be used with
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1003
	 * this fp instance.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1004
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1005
	port->fp_pkt_cache = kmem_cache_create(name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1006
	    (port->fp_fca_tran->fca_pkt_size) + sizeof (fp_cmd_t), 8,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1007
	    fp_cache_constructor, fp_cache_destructor, NULL, (void *)port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1008
	    NULL, 0);
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1009
	port->fp_out_fpcmds = 0;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1010
	if (port->fp_pkt_cache == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1011
		goto cache_alloc_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1012
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1013
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1014
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1015
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1016
	 * Allocate the d_id and pwwn hash tables for all remote ports
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1017
	 * connected to this local port.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1018
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1019
	port->fp_did_table = kmem_zalloc(did_table_size *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1020
	    sizeof (struct d_id_hash), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1021
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1022
	port->fp_pwwn_table = kmem_zalloc(pwwn_table_size *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1023
	    sizeof (struct pwwn_hash), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1024
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1025
	port->fp_taskq = taskq_create("fp_ulp_callback", 1,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1026
	    MINCLSYSPRI, 1, 16, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1027
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1028
	/* Indicate that don't have the pm components yet */
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1029
	port->fp_soft_state |=	FP_SOFT_NO_PMCOMP;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1030
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1031
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1032
	 * Bind the callbacks with the FCA driver. This will open the gate
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1033
	 * for asynchronous callbacks, so after this call the fp_mutex
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1034
	 * must be held when updating the fc_local_port_t struct.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1035
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1036
	 * This is done _before_ setting up the job thread so we can avoid
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1037
	 * cleaning up after the thread_create() in the error path. This
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1038
	 * also means fp will be operating with fp_els_resp_pkt set to NULL.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1039
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1040
	if (fp_bind_callbacks(port) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1041
		goto bind_callbacks_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1042
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1043
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1044
	if (phyport) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1045
		mutex_enter(&phyport->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1046
		if (phyport->fp_port_next) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1047
			phyport->fp_port_next->fp_port_prev = port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1048
			port->fp_port_next =  phyport->fp_port_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1049
			phyport->fp_port_next = port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1050
			port->fp_port_prev = phyport;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1051
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1052
			phyport->fp_port_next = port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1053
			phyport->fp_port_prev = port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1054
			port->fp_port_next =  phyport;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1055
			port->fp_port_prev = phyport;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1056
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1057
		mutex_exit(&phyport->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1058
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1059
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1060
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1061
	 * Init Symbolic Names
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1062
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1063
	fp_init_symbolic_names(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1064
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1065
	pkt = fp_alloc_pkt(port, sizeof (la_els_logi_t), sizeof (la_els_logi_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1066
	    KM_SLEEP, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1067
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1068
	if (pkt == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1069
		cmn_err(CE_WARN, "fp(%d): failed to allocate ELS packet",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1070
		    instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1071
		goto alloc_els_packet_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1072
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1073
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1074
	(void) thread_create(NULL, 0, fp_job_handler, port, 0, &p0, TS_RUN,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1075
	    v.v_maxsyspri - 2);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1076
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1077
	fc_wwn_to_str(&port->fp_service_params.nport_ww_name, i_pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1078
	if (ddi_prop_update_string(DDI_DEV_T_NONE, dip, "initiator-port",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1079
	    i_pwwn) != DDI_PROP_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1080
		fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1081
		    "fp(%d): Updating 'initiator-port' property"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1082
		    " on fp dev_info node failed", instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1083
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1084
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1085
	fc_wwn_to_str(&port->fp_service_params.node_ww_name, i_pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1086
	if (ddi_prop_update_string(DDI_DEV_T_NONE, dip, "initiator-node",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1087
	    i_pwwn) != DDI_PROP_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1088
		fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1089
		    "fp(%d): Updating 'initiator-node' property"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1090
		    " on fp dev_info node failed", instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1091
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1092
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1093
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1094
	port->fp_els_resp_pkt = pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1095
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1096
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1097
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1098
	 * Determine the count of unsolicited buffers this FCA can support
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1099
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1100
	fp_retrieve_caps(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1101
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1102
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1103
	 * Allocate unsolicited buffer tokens
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1104
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1105
	if (port->fp_ub_count) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1106
		ub_count = port->fp_ub_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1107
		port->fp_ub_tokens = kmem_zalloc(ub_count *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1108
		    sizeof (*port->fp_ub_tokens), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1109
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1110
		 * Do not fail the attach if unsolicited buffer allocation
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1111
		 * fails; Just try to get along with whatever the FCA can do.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1112
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1113
		if (fc_ulp_uballoc(port, &ub_count, fp_unsol_buf_size,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1114
		    FC_TYPE_EXTENDED_LS, port->fp_ub_tokens) !=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1115
		    FC_SUCCESS || ub_count != port->fp_ub_count) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1116
			cmn_err(CE_WARN, "fp(%d): failed to allocate "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1117
			    " Unsolicited buffers. proceeding with attach...",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1118
			    instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1119
			kmem_free(port->fp_ub_tokens,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1120
			    sizeof (*port->fp_ub_tokens) * port->fp_ub_count);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1121
			port->fp_ub_tokens = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1122
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1123
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1124
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1125
	fp_load_ulp_modules(dip, port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1126
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1127
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1128
	 * Enable DDI_SUSPEND and DDI_RESUME for this instance.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1129
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1130
	(void) ddi_prop_create(DDI_DEV_T_NONE, dip, DDI_PROP_CANSLEEP,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1131
	    "pm-hardware-state", "needs-suspend-resume",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1132
	    strlen("needs-suspend-resume") + 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1133
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1134
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1135
	 * fctl maintains a list of all port handles, so
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1136
	 * help fctl add this one to its list now.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1137
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1138
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1139
	fctl_add_port(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1140
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1141
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1142
	 * If a state change is already in progress, set the bind state t
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1143
	 * OFFLINE as well, so further state change callbacks into ULPs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1144
	 * will pass the appropriate states
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1145
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1146
	if (FC_PORT_STATE_MASK(port->fp_bind_state) == FC_STATE_OFFLINE ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1147
	    port->fp_statec_busy) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1148
		port->fp_bind_state = FC_STATE_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1149
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1150
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1151
		fp_startup_done((opaque_t)port, FC_PKT_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1152
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1153
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1154
		 * Without dropping the mutex, ensure that the port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1155
		 * startup happens ahead of state change callback
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1156
		 * processing
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1157
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1158
		ASSERT(port->fp_job_tail == NULL && port->fp_job_head == NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1159
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1160
		port->fp_last_task = port->fp_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1161
		port->fp_task = FP_TASK_PORT_STARTUP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1162
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1163
		job = fctl_alloc_job(JOB_PORT_STARTUP, JOB_TYPE_FCTL_ASYNC,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1164
		    fp_startup_done, (opaque_t)port, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1165
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1166
		port->fp_job_head = port->fp_job_tail = job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1167
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1168
		cv_signal(&port->fp_cv);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1169
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1170
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1171
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1172
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1173
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1174
	while (port->fp_ulp_attach) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1175
		cv_wait(&port->fp_attach_cv, &port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1176
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1177
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1178
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1179
	if (ddi_prop_update_string_array(DDI_DEV_T_NONE, dip,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1180
	    "pm-components", fp_pm_comps,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1181
	    sizeof (fp_pm_comps) / sizeof (fp_pm_comps[0])) !=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1182
	    DDI_PROP_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1183
		FP_TRACE(FP_NHEAD2(9, 0), "Failed to create PM"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1184
		    " components property, PM disabled on this port.");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1185
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1186
		port->fp_pm_level = FP_PM_PORT_UP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1187
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1188
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1189
		if (pm_raise_power(dip, FP_PM_COMPONENT,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1190
		    FP_PM_PORT_UP) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1191
			FP_TRACE(FP_NHEAD2(9, 0), "Failed to raise"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1192
			    " power level");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1193
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1194
			port->fp_pm_level = FP_PM_PORT_UP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1195
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1196
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1197
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1198
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1199
		 * Don't unset the FP_SOFT_NO_PMCOMP flag until after
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1200
		 * the call to pm_raise_power.	The PM framework can't
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1201
		 * handle multiple threads calling into it during attach.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1202
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1203
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1204
		mutex_enter(&port->fp_mutex);
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1205
		port->fp_soft_state &=	~FP_SOFT_NO_PMCOMP;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1206
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1207
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1208
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1209
	ddi_report_dev(dip);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1210
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1211
	fp_log_port_event(port, ESC_SUNFC_PORT_ATTACH);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1212
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1213
	return (DDI_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1214
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1215
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1216
	 * Unwind any/all preceeding allocations in the event of an error.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1217
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1218
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1219
alloc_els_packet_failed:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1220
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1221
	if (port->fp_fca_handle != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1222
		port->fp_fca_tran->fca_unbind_port(port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1223
		port->fp_fca_handle = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1224
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1225
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1226
	if (port->fp_ub_tokens != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1227
		(void) fc_ulp_ubfree(port, port->fp_ub_count,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1228
		    port->fp_ub_tokens);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1229
		kmem_free(port->fp_ub_tokens,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1230
		    port->fp_ub_count * sizeof (*port->fp_ub_tokens));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1231
		port->fp_ub_tokens = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1232
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1233
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1234
	if (port->fp_els_resp_pkt != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1235
		fp_free_pkt(port->fp_els_resp_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1236
		port->fp_els_resp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1237
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1238
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1239
bind_callbacks_failed:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1240
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1241
	if (port->fp_taskq != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1242
		taskq_destroy(port->fp_taskq);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1243
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1244
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1245
	if (port->fp_pwwn_table != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1246
		kmem_free(port->fp_pwwn_table,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1247
		    pwwn_table_size * sizeof (struct pwwn_hash));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1248
		port->fp_pwwn_table = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1249
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1250
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1251
	if (port->fp_did_table != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1252
		kmem_free(port->fp_did_table,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1253
		    did_table_size * sizeof (struct d_id_hash));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1254
		port->fp_did_table = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1255
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1256
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1257
	if (port->fp_pkt_cache != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1258
		kmem_cache_destroy(port->fp_pkt_cache);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1259
		port->fp_pkt_cache = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1260
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1261
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1262
cache_alloc_failed:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1263
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1264
	cv_destroy(&port->fp_attach_cv);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1265
	cv_destroy(&port->fp_cv);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1266
	mutex_destroy(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1267
	ddi_remove_minor_node(port->fp_port_dip, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1268
	ddi_soft_state_free(fp_driver_softstate, instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1269
	ddi_prop_remove_all(dip);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1270
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1271
	return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1272
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1273
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1274
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1275
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1276
 * Handle DDI_RESUME request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1277
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1278
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1279
fp_resume_handler(dev_info_t *dip)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1280
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1281
	int		rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1282
	fc_local_port_t *port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1283
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1284
	port = ddi_get_soft_state(fp_driver_softstate, ddi_get_instance(dip));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1285
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1286
	ASSERT(port != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1287
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1288
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1289
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1290
	ASSERT(port->fp_soft_state & FP_SOFT_SUSPEND);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1291
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1292
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1293
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1294
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1295
	 * If the port was power suspended, raise the power level
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1296
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1297
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1298
	if ((port->fp_soft_state & FP_SOFT_POWER_DOWN) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1299
	    (!(port->fp_soft_state & FP_SOFT_NO_PMCOMP))) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1300
		ASSERT(port->fp_pm_level == FP_PM_PORT_DOWN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1301
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1302
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1303
		if (pm_raise_power(dip, FP_PM_COMPONENT,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1304
		    FP_PM_PORT_UP) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1305
			FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1306
			    "Failed to raise the power level");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1307
			return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1308
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1309
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1310
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1311
	port->fp_soft_state &= ~FP_SOFT_SUSPEND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1312
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1313
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1314
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1315
	 * All the discovery is initiated and handled by per-port thread.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1316
	 * Further all the discovery is done in handled in callback mode
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1317
	 * (not polled mode); In a specific case such as this, the discovery
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1318
	 * is required to happen in polled mode. The easiest way out is
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1319
	 * to bail out port thread and get started. Come back and fix this
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1320
	 * to do on demand discovery initiated by ULPs. ULPs such as FCP
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1321
	 * will do on-demand discovery during pre-power-up busctl handling
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1322
	 * which will only be possible when SCSA provides a new HBA vector
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1323
	 * for sending down the PM busctl requests.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1324
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1325
	(void) callb_generic_cpr(&port->fp_cpr_info, CB_CODE_CPR_RESUME);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1326
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1327
	rval = fp_resume_all(port, FC_CMD_RESUME);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1328
	if (rval != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1329
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1330
		port->fp_soft_state |= FP_SOFT_SUSPEND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1331
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1332
		(void) callb_generic_cpr(&port->fp_cpr_info,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1333
		    CB_CODE_CPR_CHKPT);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1334
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1335
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1336
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1337
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1338
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1339
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1340
 * Perform FC Port power on initialization
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1341
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1342
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1343
fp_power_up(fc_local_port_t *port)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1344
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1345
	int	rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1346
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1347
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1348
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1349
	ASSERT((port->fp_soft_state & FP_SOFT_SUSPEND) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1350
	ASSERT(port->fp_soft_state & FP_SOFT_POWER_DOWN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1351
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1352
	port->fp_soft_state &= ~FP_SOFT_POWER_DOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1353
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1354
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1355
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1356
	rval = fp_resume_all(port, FC_CMD_POWER_UP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1357
	if (rval != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1358
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1359
		port->fp_soft_state |= FP_SOFT_POWER_DOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1360
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1361
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1362
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1363
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1364
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1365
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1366
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1367
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1368
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1369
 * It is important to note that the power may possibly be removed between
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1370
 * SUSPEND and the ensuing RESUME operation. In such a context the underlying
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1371
 * FC port hardware would have gone through an OFFLINE to ONLINE transition
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1372
 * (hardware state). In this case, the port driver may need to rediscover the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1373
 * topology, perform LOGINs, register with the name server again and perform
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1374
 * any such port initialization procedures. To perform LOGINs, the driver could
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1375
 * use the port device handle to see if a LOGIN needs to be performed and use
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1376
 * the D_ID and WWN in it. The LOGINs may fail (if the hardware is reconfigured
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1377
 * or removed) which will be reflected in the map the ULPs will see.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1378
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1379
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1380
fp_resume_all(fc_local_port_t *port, fc_attach_cmd_t cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1381
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1382
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1383
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1384
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1385
	if (fp_bind_callbacks(port) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1386
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1387
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1388
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1389
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1390
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1391
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1392
	 * If there are commands queued for delayed retry, instead of
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1393
	 * working the hard way to figure out which ones are good for
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1394
	 * restart and which ones not (ELSs are definitely not good
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1395
	 * as the port will have to go through a new spin of rediscovery
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1396
	 * now), so just flush them out.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1397
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1398
	if (port->fp_restore & FP_RESTORE_WAIT_TIMEOUT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1399
		fp_cmd_t	*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1400
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1401
		port->fp_restore &= ~FP_RESTORE_WAIT_TIMEOUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1402
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1403
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1404
		while ((cmd = fp_deque_cmd(port)) != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1405
			cmd->cmd_pkt.pkt_state = FC_PKT_TRAN_ERROR;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1406
			fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1407
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1408
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1409
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1410
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1411
	if (FC_PORT_STATE_MASK(port->fp_bind_state) == FC_STATE_OFFLINE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1412
		if ((port->fp_restore & FP_RESTORE_OFFLINE_TIMEOUT) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1413
		    port->fp_dev_count) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1414
			port->fp_restore &= ~FP_RESTORE_OFFLINE_TIMEOUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1415
			port->fp_offline_tid = timeout(fp_offline_timeout,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1416
			    (caddr_t)port, fp_offline_ticks);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1417
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1418
		if (port->fp_job_head) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1419
			cv_signal(&port->fp_cv);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1420
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1421
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1422
		fctl_attach_ulps(port, cmd, &modlinkage);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1423
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1424
		struct job_request *job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1425
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1426
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1427
		 * If an OFFLINE timer was running at the time of
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1428
		 * suspending, there is no need to restart it as
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1429
		 * the port is ONLINE now.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1430
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1431
		port->fp_restore &= ~FP_RESTORE_OFFLINE_TIMEOUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1432
		if (port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1433
			port->fp_soft_state |= FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1434
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1435
		port->fp_statec_busy++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1436
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1437
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1438
		job = fctl_alloc_job(JOB_PORT_ONLINE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1439
		    JOB_CANCEL_ULP_NOTIFICATION, NULL, NULL, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1440
		fctl_enque_job(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1441
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1442
		fctl_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1443
		fctl_remove_oldies(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1444
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1445
		fctl_attach_ulps(port, cmd, &modlinkage);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1446
		fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1447
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1448
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1449
	return (DDI_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1450
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1451
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1452
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1453
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1454
 * At this time, there shouldn't be any I/O requests on this port.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1455
 * But the unsolicited callbacks from the underlying FCA port need
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1456
 * to be handled very carefully. The steps followed to handle the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1457
 * DDI_DETACH are:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1458
 *	+	Grab the port driver mutex, check if the unsolicited
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1459
 *		callback is currently under processing. If true, fail
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1460
 *		the DDI_DETACH request by printing a message; If false
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1461
 *		mark the DDI_DETACH as under progress, so that any
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1462
 *		further unsolicited callbacks get bounced.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1463
 *	+	Perform PRLO/LOGO if necessary, cleanup all the data
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1464
 *		structures.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1465
 *	+	Get the job_handler thread to gracefully exit.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1466
 *	+	Unregister callbacks with the FCA port.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1467
 *	+	Now that some peace is found, notify all the ULPs of
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1468
 *		DDI_DETACH request (using ulp_port_detach entry point)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1469
 *	+	Free all mutexes, semaphores, conditional variables.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1470
 *	+	Free the soft state, return success.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1471
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1472
 * Important considerations:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1473
 *		Port driver de-registers state change and unsolicited
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1474
 *		callbacks before taking up the task of notifying ULPs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1475
 *		and performing PRLO and LOGOs.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1476
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1477
 *		A port may go offline at the time PRLO/LOGO is being
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1478
 *		requested. It is expected of all FCA drivers to fail
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1479
 *		such requests either immediately with a FC_OFFLINE
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1480
 *		return code to fc_fca_transport() or return the packet
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1481
 *		asynchronously with pkt state set to FC_PKT_PORT_OFFLINE
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1482
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1483
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1484
fp_detach_handler(fc_local_port_t *port)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1485
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1486
	job_request_t	*job;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1487
	uint32_t	delay_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1488
	fc_orphan_t	*orp, *tmporp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1489
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1490
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1491
	 * In a Fabric topology with many host ports connected to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1492
	 * a switch, another detaching instance of fp might have
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1493
	 * triggered a LOGO (which is an unsolicited request to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1494
	 * this instance). So in order to be able to successfully
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1495
	 * detach by taking care of such cases a delay of about
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1496
	 * 30 seconds is introduced.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1497
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1498
	delay_count = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1499
	mutex_enter(&port->fp_mutex);
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1500
	if (port->fp_out_fpcmds != 0) {
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1501
		/*
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1502
		 * At this time we can only check fp internal commands, because
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1503
		 * sd/ssd/scsi_vhci should have finsihed all their commands,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1504
		 * fcp/fcip/fcsm should have finished all their commands.
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1505
		 *
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1506
		 * It seems that all fp internal commands are asynchronous now.
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1507
		 */
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1508
		port->fp_soft_state &= ~FP_DETACH_INPROGRESS;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1509
		mutex_exit(&port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1510
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1511
		cmn_err(CE_WARN, "fp(%d): %d fp_cmd(s) is/are in progress"
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1512
		    " Failing detach", port->fp_instance, port->fp_out_fpcmds);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1513
		return (DDI_FAILURE);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1514
	}
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1515
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1516
	while ((port->fp_soft_state &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1517
	    (FP_SOFT_IN_STATEC_CB | FP_SOFT_IN_UNSOL_CB)) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1518
	    (delay_count < 30)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1519
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1520
		delay_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1521
		delay(drv_usectohz(1000000));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1522
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1523
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1524
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1525
	if (port->fp_soft_state &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1526
	    (FP_SOFT_IN_STATEC_CB | FP_SOFT_IN_UNSOL_CB)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1527
		port->fp_soft_state &= ~FP_DETACH_INPROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1528
		mutex_exit(&port->fp_mutex);
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1529
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1530
		cmn_err(CE_WARN, "fp(%d): FCA callback in progress: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1531
		    " Failing detach", port->fp_instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1532
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1533
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1534
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1535
	port->fp_soft_state |= FP_SOFT_IN_DETACH;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1536
	port->fp_soft_state &= ~FP_DETACH_INPROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1537
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1538
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1539
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1540
	 * If we're powered down, we need to raise power prior to submitting
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1541
	 * the JOB_PORT_SHUTDOWN job.  Otherwise, the job handler will never
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1542
	 * process the shutdown job.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1543
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1544
	if (fctl_busy_port(port) != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1545
		cmn_err(CE_WARN, "fp(%d): fctl_busy_port failed",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1546
		    port->fp_instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1547
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1548
		port->fp_soft_state &= ~FP_SOFT_IN_DETACH;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1549
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1550
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1551
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1552
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1553
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1554
	 * This will deallocate data structs and cause the "job" thread
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1555
	 * to exit, in preparation for DDI_DETACH on the instance.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1556
	 * This can sleep for an arbitrary duration, since it waits for
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1557
	 * commands over the wire, timeout(9F) callbacks, etc.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1558
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1559
	 * CAUTION: There is still a race here, where the "job" thread
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1560
	 * can still be executing code even tho the fctl_jobwait() call
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1561
	 * below has returned to us.  In theory the fp driver could even be
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1562
	 * modunloaded even tho the job thread isn't done executing.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1563
	 * without creating the race condition.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1564
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1565
	job = fctl_alloc_job(JOB_PORT_SHUTDOWN, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1566
	    (opaque_t)port, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1567
	fctl_enque_job(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1568
	fctl_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1569
	fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1570
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1571
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1572
	(void) pm_lower_power(port->fp_port_dip, FP_PM_COMPONENT,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1573
	    FP_PM_PORT_DOWN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1574
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1575
	if (port->fp_taskq) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1576
		taskq_destroy(port->fp_taskq);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1577
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1578
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1579
	ddi_prop_remove_all(port->fp_port_dip);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1580
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1581
	ddi_remove_minor_node(port->fp_port_dip, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1582
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1583
	fctl_remove_port(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1584
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1585
	fp_free_pkt(port->fp_els_resp_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1586
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1587
	if (port->fp_ub_tokens) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1588
		if (fc_ulp_ubfree(port, port->fp_ub_count,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1589
		    port->fp_ub_tokens) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1590
			cmn_err(CE_WARN, "fp(%d): couldn't free "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1591
			    " unsolicited buffers", port->fp_instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1592
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1593
		kmem_free(port->fp_ub_tokens,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1594
		    sizeof (*port->fp_ub_tokens) * port->fp_ub_count);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1595
		port->fp_ub_tokens = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1596
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1597
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1598
	if (port->fp_pkt_cache != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1599
		kmem_cache_destroy(port->fp_pkt_cache);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1600
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1601
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1602
	port->fp_fca_tran->fca_unbind_port(port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1603
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1604
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1605
	if (port->fp_did_table) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1606
		kmem_free(port->fp_did_table, did_table_size *
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1607
		    sizeof (struct d_id_hash));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1608
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1609
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1610
	if (port->fp_pwwn_table) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1611
		kmem_free(port->fp_pwwn_table, pwwn_table_size *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1612
		    sizeof (struct pwwn_hash));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1613
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1614
	orp = port->fp_orphan_list;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1615
	while (orp) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1616
		tmporp = orp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1617
		orp = orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1618
		kmem_free(tmporp, sizeof (*orp));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1619
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1620
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1621
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1622
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1623
	fp_log_port_event(port, ESC_SUNFC_PORT_DETACH);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1624
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1625
	mutex_destroy(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1626
	cv_destroy(&port->fp_attach_cv);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1627
	cv_destroy(&port->fp_cv);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1628
	ddi_soft_state_free(fp_driver_softstate, port->fp_instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1629
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1630
	return (DDI_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1631
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1632
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1633
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1634
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1635
 * Steps to perform DDI_SUSPEND operation on a FC port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1636
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1637
 *	- If already suspended return DDI_FAILURE
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1638
 *	- If already power-suspended return DDI_SUCCESS
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1639
 *	- If an unsolicited callback or state change handling is in
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1640
 *	    in progress, throw a warning message, return DDI_FAILURE
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1641
 *	- Cancel timeouts
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1642
 *	- SUSPEND the job_handler thread (means do nothing as it is
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1643
 *	    taken care of by the CPR frame work)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1644
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1645
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1646
fp_suspend_handler(fc_local_port_t *port)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1647
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1648
	uint32_t	delay_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1649
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1650
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1651
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1652
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1653
	 * The following should never happen, but
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1654
	 * let the driver be more defensive here
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1655
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1656
	if (port->fp_soft_state & FP_SOFT_SUSPEND) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1657
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1658
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1659
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1660
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1661
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1662
	 * If the port is already power suspended, there
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1663
	 * is nothing else to do, So return DDI_SUCCESS,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1664
	 * but mark the SUSPEND bit in the soft state
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1665
	 * before leaving.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1666
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1667
	if (port->fp_soft_state & FP_SOFT_POWER_DOWN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1668
		port->fp_soft_state |= FP_SOFT_SUSPEND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1669
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1670
		return (DDI_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1671
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1672
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1673
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1674
	 * Check if an unsolicited callback or state change handling is
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1675
	 * in progress. If true, fail the suspend operation; also throw
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1676
	 * a warning message notifying the failure. Note that Sun PCI
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1677
	 * hotplug spec recommends messages in cases of failure (but
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1678
	 * not flooding the console)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1679
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1680
	 * Busy waiting for a short interval (500 millisecond ?) to see
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1681
	 * if the callback processing completes may be another idea. Since
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1682
	 * most of the callback processing involves a lot of work, it
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1683
	 * is safe to just fail the SUSPEND operation. It is definitely
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1684
	 * not bad to fail the SUSPEND operation if the driver is busy.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1685
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1686
	delay_count = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1687
	while ((port->fp_soft_state & (FP_SOFT_IN_STATEC_CB |
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1688
	    FP_SOFT_IN_UNSOL_CB)) && (delay_count < 30)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1689
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1690
		delay_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1691
		delay(drv_usectohz(1000000));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1692
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1693
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1694
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1695
	if (port->fp_soft_state & (FP_SOFT_IN_STATEC_CB |
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1696
	    FP_SOFT_IN_UNSOL_CB)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1697
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1698
		cmn_err(CE_WARN, "fp(%d): FCA callback in progress: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1699
		    " Failing suspend", port->fp_instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1700
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1701
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1702
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1703
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1704
	 * Check of FC port thread is busy
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1705
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1706
	if (port->fp_job_head) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1707
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1708
		FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1709
		    "FC port thread is busy: Failing suspend");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1710
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1711
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1712
	port->fp_soft_state |= FP_SOFT_SUSPEND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1713
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1714
	fp_suspend_all(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1715
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1716
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1717
	return (DDI_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1718
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1719
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1720
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1721
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1722
 * Prepare for graceful power down of a FC port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1723
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1724
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1725
fp_power_down(fc_local_port_t *port)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1726
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1727
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1728
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1729
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1730
	 * Power down request followed by a DDI_SUSPEND should
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1731
	 * never happen; If it does return DDI_SUCCESS
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1732
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1733
	if (port->fp_soft_state & FP_SOFT_SUSPEND) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1734
		port->fp_soft_state |= FP_SOFT_POWER_DOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1735
		return (DDI_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1736
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1737
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1738
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1739
	 * If the port is already power suspended, there
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1740
	 * is nothing else to do, So return DDI_SUCCESS,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1741
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1742
	if (port->fp_soft_state & FP_SOFT_POWER_DOWN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1743
		return (DDI_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1744
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1745
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1746
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1747
	 * Check if an unsolicited callback or state change handling
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1748
	 * is in progress. If true, fail the PM suspend operation.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1749
	 * But don't print a message unless the verbosity of the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1750
	 * driver desires otherwise.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1751
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1752
	if ((port->fp_soft_state & FP_SOFT_IN_STATEC_CB) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1753
	    (port->fp_soft_state & FP_SOFT_IN_UNSOL_CB)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1754
		FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1755
		    "Unsolicited callback in progress: Failing power down");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1756
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1757
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1758
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1759
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1760
	 * Check of FC port thread is busy
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1761
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1762
	if (port->fp_job_head) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1763
		FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1764
		    "FC port thread is busy: Failing power down");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1765
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1766
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1767
	port->fp_soft_state |= FP_SOFT_POWER_DOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1768
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1769
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1770
	 * check if the ULPs are ready for power down
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1771
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1772
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1773
	if (fctl_detach_ulps(port, FC_CMD_POWER_DOWN,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1774
	    &modlinkage) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1775
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1776
		port->fp_soft_state &= ~FP_SOFT_POWER_DOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1777
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1778
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1779
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1780
		 * Power back up the obedient ULPs that went down
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1781
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1782
		fp_attach_ulps(port, FC_CMD_POWER_UP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1783
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1784
		FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1785
		    "ULP(s) busy, detach_ulps failed. Failing power down");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1786
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1787
		return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1788
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1789
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1790
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1791
	fp_suspend_all(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1792
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1793
	return (DDI_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1794
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1795
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1796
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1797
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1798
 * Suspend the entire FC port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1799
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1800
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1801
fp_suspend_all(fc_local_port_t *port)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1802
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1803
	int			index;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1804
	struct pwwn_hash	*head;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1805
	fc_remote_port_t	*pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1806
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1807
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1808
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1809
	if (port->fp_wait_tid != 0) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1810
		timeout_id_t	tid;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1811
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1812
		tid = port->fp_wait_tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1813
		port->fp_wait_tid = (timeout_id_t)NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1814
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1815
		(void) untimeout(tid);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1816
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1817
		port->fp_restore |= FP_RESTORE_WAIT_TIMEOUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1818
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1819
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1820
	if (port->fp_offline_tid) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1821
		timeout_id_t	tid;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1822
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1823
		tid = port->fp_offline_tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1824
		port->fp_offline_tid = (timeout_id_t)NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1825
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1826
		(void) untimeout(tid);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1827
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1828
		port->fp_restore |= FP_RESTORE_OFFLINE_TIMEOUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1829
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1830
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1831
	port->fp_fca_tran->fca_unbind_port(port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1832
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1833
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1834
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1835
	 * Mark all devices as OLD, and reset the LOGIN state as well
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1836
	 * (this will force the ULPs to perform a LOGIN after calling
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1837
	 * fc_portgetmap() during RESUME/PM_RESUME)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1838
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1839
	for (index = 0; index < pwwn_table_size; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1840
		head = &port->fp_pwwn_table[index];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1841
		pd = head->pwwn_head;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1842
		while (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1843
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1844
			fp_remote_port_offline(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1845
			fctl_delist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1846
			pd->pd_state = PORT_DEVICE_VALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1847
			pd->pd_login_count = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1848
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1849
			pd = pd->pd_wwn_hnext;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1850
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1851
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1852
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1853
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1854
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1855
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1856
 * fp_cache_constructor: Constructor function for kmem_cache_create(9F).
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1857
 * Performs intializations for fc_packet_t structs.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1858
 * Returns 0 for success or -1 for failure.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1859
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1860
 * This function allocates DMA handles for both command and responses.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1861
 * Most of the ELSs used have both command and responses so it is strongly
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1862
 * desired to move them to cache constructor routine.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1863
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1864
 * Context: Can sleep iff called with KM_SLEEP flag.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1865
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1866
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1867
fp_cache_constructor(void *buf, void *cdarg, int kmflags)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1868
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1869
	int		(*cb) (caddr_t);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1870
	fc_packet_t	*pkt;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1871
	fp_cmd_t	*cmd = (fp_cmd_t *)buf;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1872
	fc_local_port_t *port = (fc_local_port_t *)cdarg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1873
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1874
	cb = (kmflags == KM_SLEEP) ? DDI_DMA_SLEEP : DDI_DMA_DONTWAIT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1875
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1876
	cmd->cmd_next = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1877
	cmd->cmd_flags = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1878
	cmd->cmd_dflags = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1879
	cmd->cmd_job = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1880
	cmd->cmd_port = port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1881
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1882
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1883
	if (!(port->fp_soft_state & FP_SOFT_FCA_IS_NODMA)) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1884
		if (ddi_dma_alloc_handle(port->fp_fca_dip,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1885
		    port->fp_fca_tran->fca_dma_attr, cb, NULL,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1886
		    &pkt->pkt_cmd_dma) != DDI_SUCCESS) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1887
			return (-1);
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1888
		}
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1889
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1890
		if (ddi_dma_alloc_handle(port->fp_fca_dip,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1891
		    port->fp_fca_tran->fca_dma_attr, cb, NULL,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1892
		    &pkt->pkt_resp_dma) != DDI_SUCCESS) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1893
			ddi_dma_free_handle(&pkt->pkt_cmd_dma);
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1894
			return (-1);
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1895
		}
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1896
	} else {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1897
		pkt->pkt_cmd_dma = 0;
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1898
		pkt->pkt_resp_dma = 0;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1899
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1900
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1901
	pkt->pkt_cmd_acc = pkt->pkt_resp_acc = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1902
	pkt->pkt_cmd_cookie_cnt = pkt->pkt_resp_cookie_cnt =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1903
	    pkt->pkt_data_cookie_cnt = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1904
	pkt->pkt_cmd_cookie = pkt->pkt_resp_cookie =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1905
	    pkt->pkt_data_cookie = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1906
	pkt->pkt_fca_private = (caddr_t)buf + sizeof (fp_cmd_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1907
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1908
	return (0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1909
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1910
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1911
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1912
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1913
 * fp_cache_destructor: Destructor function for kmem_cache_create().
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1914
 * Performs un-intializations for fc_packet_t structs.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1915
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1916
/* ARGSUSED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1917
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1918
fp_cache_destructor(void *buf, void *cdarg)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1919
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1920
	fp_cmd_t	*cmd = (fp_cmd_t *)buf;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1921
	fc_packet_t	*pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1922
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1923
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1924
	if (pkt->pkt_cmd_dma) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1925
		ddi_dma_free_handle(&pkt->pkt_cmd_dma);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1926
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1927
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1928
	if (pkt->pkt_resp_dma) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1929
		ddi_dma_free_handle(&pkt->pkt_resp_dma);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1930
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1931
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1932
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1933
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1934
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1935
 * Packet allocation for ELS and any other port driver commands
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1936
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1937
 * Some ELSs like FLOGI and PLOGI are critical for topology and
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1938
 * device discovery and a system's inability to allocate memory
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1939
 * or DVMA resources while performing some of these critical ELSs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1940
 * cause a lot of problem. While memory allocation failures are
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1941
 * rare, DVMA resource failures are common as the applications
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1942
 * are becoming more and more powerful on huge servers.	 So it
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1943
 * is desirable to have a framework support to reserve a fragment
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1944
 * of DVMA. So until this is fixed the correct way, the suffering
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1945
 * is huge whenever a LIP happens at a time DVMA resources are
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1946
 * drained out completely - So an attempt needs to be made to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1947
 * KM_SLEEP while requesting for these resources, hoping that
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1948
 * the requests won't hang forever.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1949
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1950
 * The fc_remote_port_t argument is stored into the pkt_pd field in the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1951
 * fc_packet_t struct prior to the fc_ulp_init_packet() call.  This
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1952
 * ensures that the pd_ref_count for the fc_remote_port_t is valid.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1953
 * If there is no fc_remote_port_t associated with the fc_packet_t, then
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1954
 * fp_alloc_pkt() must be called with pd set to NULL.
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1955
 *
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1956
 * fp/fctl will resue fp_cmd_t somewhere, and change pkt_cmdlen/rsplen,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1957
 * actually, it's a design fault. But there's no problem for physical
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1958
 * FCAs. But it will cause memory leak or panic for virtual FCAs like fcoei.
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1959
 *
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1960
 * For FCAs that don't support DMA, such as fcoei, we will use
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1961
 * pkt_fctl_rsvd1/rsvd2 to keep the real cmd_len/resp_len.
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1962
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1963
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1964
static fp_cmd_t *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1965
fp_alloc_pkt(fc_local_port_t *port, int cmd_len, int resp_len, int kmflags,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1966
    fc_remote_port_t *pd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1967
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1968
	int		rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1969
	ulong_t		real_len;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1970
	fp_cmd_t	*cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1971
	fc_packet_t	*pkt;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  1972
	int		(*cb) (caddr_t);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1973
	ddi_dma_cookie_t	pkt_cookie;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1974
	ddi_dma_cookie_t	*cp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1975
	uint32_t		cnt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1976
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1977
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1978
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1979
	cb = (kmflags == KM_SLEEP) ? DDI_DMA_SLEEP : DDI_DMA_DONTWAIT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1980
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1981
	cmd = (fp_cmd_t *)kmem_cache_alloc(port->fp_pkt_cache, kmflags);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1982
	if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1983
		return (cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1984
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1985
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1986
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1987
	cmd->cmd_flags = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1988
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1989
	ASSERT(cmd->cmd_dflags == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1990
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1991
	pkt->pkt_datalen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1992
	pkt->pkt_data = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1993
	pkt->pkt_state = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1994
	pkt->pkt_action = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1995
	pkt->pkt_reason = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  1996
	pkt->pkt_expln = 0;
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1997
	pkt->pkt_cmd = NULL;
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1998
	pkt->pkt_resp = NULL;
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  1999
	pkt->pkt_fctl_rsvd1 = NULL;
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2000
	pkt->pkt_fctl_rsvd2 = NULL;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2001
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2002
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2003
	 * Init pkt_pd with the given pointer; this must be done _before_
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2004
	 * the call to fc_ulp_init_packet().
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2005
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2006
	pkt->pkt_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2007
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2008
	/* Now call the FCA driver to init its private, per-packet fields */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2009
	if (fc_ulp_init_packet((opaque_t)port, pkt, kmflags) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2010
		goto alloc_pkt_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2011
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2012
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2013
	if (cmd_len && !(port->fp_soft_state & FP_SOFT_FCA_IS_NODMA)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2014
		ASSERT(pkt->pkt_cmd_dma != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2015
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2016
		rval = ddi_dma_mem_alloc(pkt->pkt_cmd_dma, cmd_len,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2017
		    port->fp_fca_tran->fca_acc_attr, DDI_DMA_CONSISTENT,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2018
		    cb, NULL, (caddr_t *)&pkt->pkt_cmd, &real_len,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2019
		    &pkt->pkt_cmd_acc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2020
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2021
		if (rval != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2022
			goto alloc_pkt_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2023
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2024
		cmd->cmd_dflags |= FP_CMD_VALID_DMA_MEM;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2025
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2026
		if (real_len < cmd_len) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2027
			goto alloc_pkt_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2028
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2029
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2030
		rval = ddi_dma_addr_bind_handle(pkt->pkt_cmd_dma, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2031
		    pkt->pkt_cmd, real_len, DDI_DMA_WRITE |
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2032
		    DDI_DMA_CONSISTENT, cb, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2033
		    &pkt_cookie, &pkt->pkt_cmd_cookie_cnt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2034
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2035
		if (rval != DDI_DMA_MAPPED) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2036
			goto alloc_pkt_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2037
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2038
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2039
		cmd->cmd_dflags |= FP_CMD_VALID_DMA_BIND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2040
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2041
		if (pkt->pkt_cmd_cookie_cnt >
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2042
		    port->fp_fca_tran->fca_dma_attr->dma_attr_sgllen) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2043
			goto alloc_pkt_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2044
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2045
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2046
		ASSERT(pkt->pkt_cmd_cookie_cnt != 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2047
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2048
		cp = pkt->pkt_cmd_cookie = (ddi_dma_cookie_t *)kmem_alloc(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2049
		    pkt->pkt_cmd_cookie_cnt * sizeof (pkt_cookie),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2050
		    KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2051
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2052
		if (cp == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2053
			goto alloc_pkt_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2054
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2055
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2056
		*cp = pkt_cookie;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2057
		cp++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2058
		for (cnt = 1; cnt < pkt->pkt_cmd_cookie_cnt; cnt++, cp++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2059
			ddi_dma_nextcookie(pkt->pkt_cmd_dma, &pkt_cookie);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2060
			*cp = pkt_cookie;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2061
		}
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2062
	} else if (cmd_len != 0) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2063
		pkt->pkt_cmd = kmem_alloc(cmd_len, KM_SLEEP);
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2064
		pkt->pkt_fctl_rsvd1 = (opaque_t)(uintptr_t)cmd_len;
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2065
	}
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2066
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2067
	if (resp_len && !(port->fp_soft_state & FP_SOFT_FCA_IS_NODMA)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2068
		ASSERT(pkt->pkt_resp_dma != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2069
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2070
		rval = ddi_dma_mem_alloc(pkt->pkt_resp_dma, resp_len,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2071
		    port->fp_fca_tran->fca_acc_attr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2072
		    DDI_DMA_CONSISTENT, cb, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2073
		    (caddr_t *)&pkt->pkt_resp, &real_len,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2074
		    &pkt->pkt_resp_acc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2075
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2076
		if (rval != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2077
			goto alloc_pkt_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2078
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2079
		cmd->cmd_dflags |= FP_RESP_VALID_DMA_MEM;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2080
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2081
		if (real_len < resp_len) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2082
			goto alloc_pkt_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2083
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2084
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2085
		rval = ddi_dma_addr_bind_handle(pkt->pkt_resp_dma, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2086
		    pkt->pkt_resp, real_len, DDI_DMA_READ |
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2087
		    DDI_DMA_CONSISTENT, cb, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2088
		    &pkt_cookie, &pkt->pkt_resp_cookie_cnt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2089
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2090
		if (rval != DDI_DMA_MAPPED) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2091
			goto alloc_pkt_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2092
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2093
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2094
		cmd->cmd_dflags |= FP_RESP_VALID_DMA_BIND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2095
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2096
		if (pkt->pkt_resp_cookie_cnt >
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2097
		    port->fp_fca_tran->fca_dma_attr->dma_attr_sgllen) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2098
			goto alloc_pkt_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2099
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2100
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2101
		ASSERT(pkt->pkt_cmd_cookie_cnt != 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2102
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2103
		cp = pkt->pkt_resp_cookie = (ddi_dma_cookie_t *)kmem_alloc(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2104
		    pkt->pkt_resp_cookie_cnt * sizeof (pkt_cookie),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2105
		    KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2106
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2107
		if (cp == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2108
			goto alloc_pkt_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2109
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2110
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2111
		*cp = pkt_cookie;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2112
		cp++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2113
		for (cnt = 1; cnt < pkt->pkt_resp_cookie_cnt; cnt++, cp++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2114
			ddi_dma_nextcookie(pkt->pkt_resp_dma, &pkt_cookie);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2115
			*cp = pkt_cookie;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2116
		}
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2117
	} else if (resp_len != 0) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2118
		pkt->pkt_resp = kmem_alloc(resp_len, KM_SLEEP);
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2119
		pkt->pkt_fctl_rsvd2 = (opaque_t)(uintptr_t)resp_len;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2120
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2121
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2122
	pkt->pkt_cmdlen = cmd_len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2123
	pkt->pkt_rsplen = resp_len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2124
	pkt->pkt_ulp_private = cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2125
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2126
	return (cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2127
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2128
alloc_pkt_failed:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2129
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2130
	fp_free_dma(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2131
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2132
	if (pkt->pkt_cmd_cookie != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2133
		kmem_free(pkt->pkt_cmd_cookie,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2134
		    pkt->pkt_cmd_cookie_cnt * sizeof (ddi_dma_cookie_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2135
		pkt->pkt_cmd_cookie = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2136
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2137
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2138
	if (pkt->pkt_resp_cookie != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2139
		kmem_free(pkt->pkt_resp_cookie,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2140
		    pkt->pkt_resp_cookie_cnt * sizeof (ddi_dma_cookie_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2141
		pkt->pkt_resp_cookie = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2142
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2143
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2144
	if (port->fp_soft_state & FP_SOFT_FCA_IS_NODMA) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2145
		if (pkt->pkt_cmd) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2146
			kmem_free(pkt->pkt_cmd, cmd_len);
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2147
		}
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2148
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2149
		if (pkt->pkt_resp) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2150
			kmem_free(pkt->pkt_resp, resp_len);
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2151
		}
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2152
	}
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2153
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2154
	kmem_cache_free(port->fp_pkt_cache, cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2155
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2156
	return (NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2157
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2158
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2159
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2160
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2161
 * Free FC packet
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2162
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2163
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2164
fp_free_pkt(fp_cmd_t *cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2165
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2166
	fc_local_port_t *port;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  2167
	fc_packet_t	*pkt;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2168
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2169
	ASSERT(!MUTEX_HELD(&cmd->cmd_port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2170
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2171
	cmd->cmd_next = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2172
	cmd->cmd_job = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2173
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2174
	pkt->pkt_ulp_private = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2175
	pkt->pkt_tran_flags = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2176
	pkt->pkt_tran_type = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2177
	port = cmd->cmd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2178
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2179
	if (pkt->pkt_cmd_cookie != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2180
		kmem_free(pkt->pkt_cmd_cookie, pkt->pkt_cmd_cookie_cnt *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2181
		    sizeof (ddi_dma_cookie_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2182
		pkt->pkt_cmd_cookie = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2183
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2184
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2185
	if (pkt->pkt_resp_cookie != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2186
		kmem_free(pkt->pkt_resp_cookie, pkt->pkt_resp_cookie_cnt *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2187
		    sizeof (ddi_dma_cookie_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2188
		pkt->pkt_resp_cookie = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2189
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2190
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2191
	if (port->fp_soft_state & FP_SOFT_FCA_IS_NODMA) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2192
		if (pkt->pkt_cmd) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2193
			kmem_free(pkt->pkt_cmd,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2194
			    (uint32_t)(uintptr_t)pkt->pkt_fctl_rsvd1);
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2195
		}
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2196
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2197
		if (pkt->pkt_resp) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2198
			kmem_free(pkt->pkt_resp,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2199
			    (uint32_t)(uintptr_t)pkt->pkt_fctl_rsvd2);
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2200
		}
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2201
	}
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  2202
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2203
	fp_free_dma(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2204
	(void) fc_ulp_uninit_packet((opaque_t)port, pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2205
	kmem_cache_free(port->fp_pkt_cache, (void *)cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2206
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2207
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2208
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2209
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2210
 * Release DVMA resources
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2211
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2212
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2213
fp_free_dma(fp_cmd_t *cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2214
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2215
	fc_packet_t *pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2216
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2217
	pkt->pkt_cmdlen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2218
	pkt->pkt_rsplen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2219
	pkt->pkt_tran_type = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2220
	pkt->pkt_tran_flags = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2221
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2222
	if (cmd->cmd_dflags & FP_CMD_VALID_DMA_BIND) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2223
		(void) ddi_dma_unbind_handle(pkt->pkt_cmd_dma);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2224
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2225
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2226
	if (cmd->cmd_dflags & FP_CMD_VALID_DMA_MEM) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2227
		if (pkt->pkt_cmd_acc) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2228
			ddi_dma_mem_free(&pkt->pkt_cmd_acc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2229
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2230
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2231
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2232
	if (cmd->cmd_dflags & FP_RESP_VALID_DMA_BIND) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2233
		(void) ddi_dma_unbind_handle(pkt->pkt_resp_dma);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2234
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2235
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2236
	if (cmd->cmd_dflags & FP_RESP_VALID_DMA_MEM) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2237
		if (pkt->pkt_resp_acc) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2238
			ddi_dma_mem_free(&pkt->pkt_resp_acc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2239
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2240
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2241
	cmd->cmd_dflags = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2242
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2243
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2244
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2245
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2246
 * Dedicated thread to perform various activities.  One thread for
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2247
 * each fc_local_port_t (driver soft state) instance.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2248
 * Note, this effectively works out to one thread for each local
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2249
 * port, but there are also some Solaris taskq threads in use on a per-local
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2250
 * port basis; these also need to be taken into consideration.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2251
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2252
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2253
fp_job_handler(fc_local_port_t *port)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2254
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2255
	int			rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2256
	uint32_t		*d_id;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  2257
	fc_remote_port_t	*pd;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  2258
	job_request_t		*job;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2259
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2260
#ifndef	__lock_lint
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2261
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2262
	 * Solaris-internal stuff for proper operation of kernel threads
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2263
	 * with Solaris CPR.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2264
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2265
	CALLB_CPR_INIT(&port->fp_cpr_info, &port->fp_mutex,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2266
	    callb_generic_cpr, "fp_job_handler");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2267
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2268
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2269
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2270
	/* Loop forever waiting for work to do */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2271
	for (;;) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2272
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2273
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2274
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2275
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2276
		 * Sleep if no work to do right now, or if we want
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2277
		 * to suspend or power-down.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2278
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2279
		while (port->fp_job_head == NULL ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2280
		    (port->fp_soft_state & (FP_SOFT_POWER_DOWN |
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2281
		    FP_SOFT_SUSPEND))) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2282
			CALLB_CPR_SAFE_BEGIN(&port->fp_cpr_info);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2283
			cv_wait(&port->fp_cv, &port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2284
			CALLB_CPR_SAFE_END(&port->fp_cpr_info, &port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2285
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2286
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2287
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2288
		 * OK, we've just been woken up, so retrieve the next entry
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2289
		 * from the head of the job queue for this local port.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2290
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2291
		job = fctl_deque_job(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2292
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2293
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2294
		 * Handle all the fp driver's supported job codes here
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2295
		 * in this big honkin' switch.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2296
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2297
		switch (job->job_code) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2298
		case JOB_PORT_SHUTDOWN:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2299
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2300
			 * fp_port_shutdown() is only called from here. This
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2301
			 * will prepare the local port instance (softstate)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2302
			 * for detaching.  This cancels timeout callbacks,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2303
			 * executes LOGOs with remote ports, cleans up tables,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2304
			 * and deallocates data structs.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2305
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2306
			fp_port_shutdown(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2307
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2308
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2309
			 * This will exit the job thread.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2310
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2311
#ifndef __lock_lint
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2312
			CALLB_CPR_EXIT(&(port->fp_cpr_info));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2313
#else
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2314
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2315
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2316
			fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2317
			thread_exit();
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2318
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2319
			/* NOTREACHED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2320
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2321
		case JOB_ATTACH_ULP: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2322
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2323
			 * This job is spawned in response to a ULP calling
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2324
			 * fc_ulp_add().
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2325
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2326
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2327
			boolean_t do_attach_ulps = B_TRUE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2328
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2329
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2330
			 * If fp is detaching, we don't want to call
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2331
			 * fp_startup_done as this asynchronous
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2332
			 * notification may interfere with the re-attach.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2333
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2334
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2335
			if (port->fp_soft_state & (FP_DETACH_INPROGRESS |
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2336
			    FP_SOFT_IN_DETACH | FP_DETACH_FAILED)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2337
				do_attach_ulps = B_FALSE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2338
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2339
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2340
				 * We are going to force the transport
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2341
				 * to attach to the ULPs, so set
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2342
				 * fp_ulp_attach.  This will keep any
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2343
				 * potential detach from occurring until
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2344
				 * we are done.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2345
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2346
				port->fp_ulp_attach = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2347
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2348
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2349
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2350
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2351
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2352
			 * NOTE: Since we just dropped the mutex, there is now
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2353
			 * a race window where the fp_soft_state check above
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2354
			 * could change here.  This race is covered because an
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2355
			 * additional check was added in the functions hidden
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2356
			 * under fp_startup_done().
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2357
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2358
			if (do_attach_ulps == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2359
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2360
				 * This goes thru a bit of a convoluted call
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2361
				 * chain before spawning off a DDI taskq
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2362
				 * request to perform the actual attach
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2363
				 * operations. Blocking can occur at a number
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2364
				 * of points.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2365
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2366
				fp_startup_done((opaque_t)port, FC_PKT_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2367
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2368
			job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2369
			fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2370
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2371
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2372
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2373
		case JOB_ULP_NOTIFY: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2374
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2375
			 * Pass state change notifications up to any/all
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2376
			 * registered ULPs.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2377
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2378
			uint32_t statec;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2379
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2380
			statec = job->job_ulp_listlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2381
			if (statec == FC_STATE_RESET_REQUESTED) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2382
				port->fp_last_task = port->fp_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2383
				port->fp_task = FP_TASK_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2384
				fp_port_offline(port, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2385
				port->fp_task = port->fp_last_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2386
				port->fp_last_task = FP_TASK_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2387
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2388
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2389
			if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2390
				port->fp_soft_state &= ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2391
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2392
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2393
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2394
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2395
			job->job_result = fp_ulp_notify(port, statec, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2396
			fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2397
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2398
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2399
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2400
		case JOB_PLOGI_ONE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2401
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2402
			 * Issue a PLOGI to a single remote port. Multiple
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2403
			 * PLOGIs to different remote ports may occur in
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2404
			 * parallel.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2405
			 * This can create the fc_remote_port_t if it does not
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2406
			 * already exist.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2407
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2408
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2409
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2410
			d_id = (uint32_t *)job->job_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2411
			pd = fctl_get_remote_port_by_did(port, *d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2412
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2413
			if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2414
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2415
				if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2416
					pd->pd_login_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2417
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2418
					job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2419
					fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2420
					break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2421
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2422
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2423
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2424
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2425
				if (FC_IS_TOP_SWITCH(port->fp_topology)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2426
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2427
					pd = fp_create_remote_port_by_ns(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2428
					    *d_id, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2429
					if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2430
						job->job_result = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2431
						fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2432
						break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2433
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2434
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2435
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2436
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2437
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2438
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2439
			job->job_flags |= JOB_TYPE_FP_ASYNC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2440
			job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2441
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2442
			rval = fp_port_login(port, *d_id, job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2443
			    FP_CMD_PLOGI_RETAIN, KM_SLEEP, pd, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2444
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2445
			if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2446
				job->job_result = rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2447
				fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2448
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2449
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2450
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2451
		case JOB_LOGO_ONE: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2452
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2453
			 * Issue a PLOGO to a single remote port. Multiple
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2454
			 * PLOGOs to different remote ports may occur in
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2455
			 * parallel.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2456
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2457
			fc_remote_port_t *pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2458
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2459
#ifndef	__lock_lint
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2460
			ASSERT(job->job_counter > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2461
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2462
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2463
			pd = (fc_remote_port_t *)job->job_ulp_pkts;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2464
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2465
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2466
			if (pd->pd_state != PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2467
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2468
				job->job_result = FC_LOGINREQ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2469
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2470
				fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2471
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2472
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2473
			if (pd->pd_login_count > 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2474
				pd->pd_login_count--;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2475
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2476
				job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2477
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2478
				fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2479
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2480
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2481
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2482
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2483
			job->job_flags |= JOB_TYPE_FP_ASYNC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2484
			(void) fp_logout(port, pd, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2485
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2486
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2487
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2488
		case JOB_FCIO_LOGIN:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2489
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2490
			 * PLOGI initiated at ioctl request.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2491
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2492
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2493
			job->job_result =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2494
			    fp_fcio_login(port, job->job_private, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2495
			fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2496
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2497
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2498
		case JOB_FCIO_LOGOUT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2499
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2500
			 * PLOGO initiated at ioctl request.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2501
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2502
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2503
			job->job_result =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2504
			    fp_fcio_logout(port, job->job_private, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2505
			fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2506
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2507
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2508
		case JOB_PORT_GETMAP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2509
		case JOB_PORT_GETMAP_PLOGI_ALL: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2510
			port->fp_last_task = port->fp_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2511
			port->fp_task = FP_TASK_GETMAP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2512
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2513
			switch (port->fp_topology) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2514
			case FC_TOP_PRIVATE_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2515
				job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2516
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2517
				fp_get_loopmap(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2518
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2519
				fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2520
				fctl_fillout_map(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2521
				    (fc_portmap_t **)job->job_private,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2522
				    (uint32_t *)job->job_arg, 1, 0, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2523
				fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2524
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2525
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2526
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2527
			case FC_TOP_PUBLIC_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2528
			case FC_TOP_FABRIC:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2529
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2530
				job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2531
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2532
				job->job_result = fp_ns_getmap(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2533
				    job, (fc_portmap_t **)job->job_private,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2534
				    (uint32_t *)job->job_arg,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2535
				    FCTL_GAN_START_ID);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2536
				fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2537
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2538
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2539
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2540
			case FC_TOP_PT_PT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2541
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2542
				fctl_fillout_map(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2543
				    (fc_portmap_t **)job->job_private,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2544
				    (uint32_t *)job->job_arg, 1, 0, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2545
				fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2546
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2547
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2548
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2549
			default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2550
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2551
				fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2552
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2553
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2554
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2555
			port->fp_task = port->fp_last_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2556
			port->fp_last_task = FP_TASK_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2557
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2558
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2559
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2560
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2561
		case JOB_PORT_OFFLINE: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2562
			fp_log_port_event(port, ESC_SUNFC_PORT_OFFLINE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2563
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2564
			port->fp_last_task = port->fp_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2565
			port->fp_task = FP_TASK_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2566
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2567
			if (port->fp_statec_busy > 2) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2568
				job->job_flags |= JOB_CANCEL_ULP_NOTIFICATION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2569
				fp_port_offline(port, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2570
				if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2571
					port->fp_soft_state &=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2572
					    ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2573
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2574
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2575
				fp_port_offline(port, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2576
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2577
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2578
			port->fp_task = port->fp_last_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2579
			port->fp_last_task = FP_TASK_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2580
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2581
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2582
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2583
			fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2584
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2585
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2586
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2587
		case JOB_PORT_STARTUP: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2588
			if ((rval = fp_port_startup(port, job)) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2589
				if (port->fp_statec_busy > 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2590
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2591
					break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2592
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2593
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2594
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2595
				FP_TRACE(FP_NHEAD2(9, rval),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2596
				    "Topology discovery failed");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2597
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2598
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2599
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2600
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2601
			 * Attempt building device handles in case
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2602
			 * of private Loop.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2603
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2604
			if (port->fp_topology == FC_TOP_PRIVATE_LOOP) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2605
				job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2606
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2607
				fp_get_loopmap(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2608
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2609
				fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2610
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2611
				if (port->fp_lilp_map.lilp_magic < MAGIC_LIRP) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2612
					ASSERT(port->fp_total_devices == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2613
					port->fp_total_devices =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2614
					    port->fp_dev_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2615
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2616
			} else if (FC_IS_TOP_SWITCH(port->fp_topology)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2617
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2618
				 * Hack to avoid state changes going up early
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2619
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2620
				port->fp_statec_busy++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2621
				port->fp_soft_state |= FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2622
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2623
				job->job_flags |= JOB_CANCEL_ULP_NOTIFICATION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2624
				fp_fabric_online(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2625
				job->job_flags &= ~JOB_CANCEL_ULP_NOTIFICATION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2626
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2627
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2628
			fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2629
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2630
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2631
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2632
		case JOB_PORT_ONLINE: {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  2633
			char		*newtop;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  2634
			char		*oldtop;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2635
			uint32_t	old_top;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2636
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2637
			fp_log_port_event(port, ESC_SUNFC_PORT_ONLINE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2638
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2639
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2640
			 * Bail out early if there are a lot of
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2641
			 * state changes in the pipeline
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2642
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2643
			if (port->fp_statec_busy > 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2644
				--port->fp_statec_busy;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2645
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2646
				fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2647
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2648
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2649
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2650
			switch (old_top = port->fp_topology) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2651
			case FC_TOP_PRIVATE_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2652
				oldtop = "Private Loop";
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2653
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2654
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2655
			case FC_TOP_PUBLIC_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2656
				oldtop = "Public Loop";
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2657
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2658
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2659
			case FC_TOP_PT_PT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2660
				oldtop = "Point to Point";
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2661
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2662
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2663
			case FC_TOP_FABRIC:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2664
				oldtop = "Fabric";
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2665
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2666
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2667
			default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2668
				oldtop = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2669
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2670
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2671
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2672
			port->fp_last_task = port->fp_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2673
			port->fp_task = FP_TASK_ONLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2674
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2675
			if ((rval = fp_port_startup(port, job)) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2676
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2677
				port->fp_task = port->fp_last_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2678
				port->fp_last_task = FP_TASK_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2679
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2680
				if (port->fp_statec_busy > 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2681
					--port->fp_statec_busy;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2682
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2683
					break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2684
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2685
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2686
				port->fp_state = FC_STATE_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2687
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2688
				FP_TRACE(FP_NHEAD2(9, rval),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2689
				    "Topology discovery failed");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2690
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2691
				if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2692
					port->fp_soft_state &=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2693
					    ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2694
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2695
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2696
				if (port->fp_offline_tid == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2697
					port->fp_offline_tid =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2698
					    timeout(fp_offline_timeout,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2699
					    (caddr_t)port, fp_offline_ticks);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2700
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2701
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2702
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2703
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2704
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2705
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2706
			switch (port->fp_topology) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2707
			case FC_TOP_PRIVATE_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2708
				newtop = "Private Loop";
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2709
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2710
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2711
			case FC_TOP_PUBLIC_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2712
				newtop = "Public Loop";
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2713
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2714
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2715
			case FC_TOP_PT_PT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2716
				newtop = "Point to Point";
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2717
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2718
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2719
			case FC_TOP_FABRIC:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2720
				newtop = "Fabric";
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2721
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2722
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2723
			default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2724
				newtop = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2725
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2726
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2727
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2728
			if (oldtop && newtop && strcmp(oldtop, newtop)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2729
				fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2730
				    "Change in FC Topology old = %s new = %s",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2731
				    oldtop, newtop);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2732
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2733
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2734
			switch (port->fp_topology) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2735
			case FC_TOP_PRIVATE_LOOP: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2736
				int orphan = (old_top == FC_TOP_FABRIC ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2737
				    old_top == FC_TOP_PUBLIC_LOOP) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2738
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2739
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2740
				fp_loop_online(port, job, orphan);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2741
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2742
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2743
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2744
			case FC_TOP_PUBLIC_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2745
				/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2746
			case FC_TOP_FABRIC:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2747
				fp_fabric_online(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2748
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2749
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2750
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2751
			case FC_TOP_PT_PT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2752
				fp_p2p_online(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2753
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2754
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2755
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2756
			default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2757
				if (--port->fp_statec_busy != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2758
					/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2759
					 * Watch curiously at what the next
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2760
					 * state transition can do.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2761
					 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2762
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2763
					break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2764
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2765
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2766
				FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2767
				    "Topology Unknown, Offlining the port..");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2768
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2769
				port->fp_soft_state &= ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2770
				port->fp_state = FC_STATE_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2771
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2772
				if (port->fp_offline_tid == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2773
					port->fp_offline_tid =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2774
					    timeout(fp_offline_timeout,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2775
					    (caddr_t)port, fp_offline_ticks);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2776
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2777
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2778
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2779
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2780
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2781
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2782
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2783
			port->fp_task = port->fp_last_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2784
			port->fp_last_task = FP_TASK_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2785
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2786
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2787
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2788
			fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2789
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2790
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2791
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2792
		case JOB_PLOGI_GROUP: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2793
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2794
			fp_plogi_group(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2795
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2796
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2797
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2798
		case JOB_UNSOL_REQUEST: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2799
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2800
			fp_handle_unsol_buf(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2801
			    (fc_unsol_buf_t *)job->job_private, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2802
			fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2803
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2804
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2805
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2806
		case JOB_NS_CMD: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2807
			fctl_ns_req_t *ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2808
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2809
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2810
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2811
			job->job_flags |= JOB_TYPE_FP_ASYNC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2812
			ns_cmd = (fctl_ns_req_t *)job->job_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2813
			if (ns_cmd->ns_cmd_code < NS_GA_NXT ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2814
			    ns_cmd->ns_cmd_code > NS_DA_ID) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2815
				job->job_result = FC_BADCMD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2816
				fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2817
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2818
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2819
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2820
			if (FC_IS_CMD_A_REG(ns_cmd->ns_cmd_code)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2821
				if (ns_cmd->ns_pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2822
					job->job_result = FC_BADOBJECT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2823
					fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2824
					break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2825
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2826
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2827
				job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2828
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2829
				rval = fp_ns_reg(port, ns_cmd->ns_pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2830
				    ns_cmd->ns_cmd_code, job, 0, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2831
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2832
				if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2833
					job->job_result = rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2834
					fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2835
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2836
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2837
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2838
			job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2839
			job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2840
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2841
			rval = fp_ns_query(port, ns_cmd, job, 0, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2842
			if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2843
				fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2844
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2845
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2846
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2847
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2848
		case JOB_LINK_RESET: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2849
			la_wwn_t *pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2850
			uint32_t topology;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2851
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2852
			pwwn = (la_wwn_t *)job->job_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2853
			ASSERT(pwwn != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2854
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2855
			topology = port->fp_topology;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2856
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2857
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2858
			if (fctl_is_wwn_zero(pwwn) == FC_SUCCESS ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2859
			    topology == FC_TOP_PRIVATE_LOOP) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2860
				job->job_flags |= JOB_TYPE_FP_ASYNC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2861
				rval = port->fp_fca_tran->fca_reset(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2862
				    port->fp_fca_handle, FC_FCA_LINK_RESET);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2863
				job->job_result = rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2864
				fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2865
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2866
				ASSERT((job->job_flags &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2867
				    JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2868
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2869
				if (FC_IS_TOP_SWITCH(topology)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2870
					rval = fp_remote_lip(port, pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2871
					    KM_SLEEP, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2872
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2873
					rval = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2874
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2875
				if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2876
					job->job_result = rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2877
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2878
				fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2879
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2880
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2881
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2882
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2883
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2884
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2885
			job->job_result = FC_BADCMD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2886
			fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2887
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2888
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2889
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2890
	/* NOTREACHED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2891
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2892
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2893
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2894
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2895
 * Perform FC port bring up initialization
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2896
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2897
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2898
fp_port_startup(fc_local_port_t *port, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2899
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2900
	int		rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2901
	uint32_t	state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2902
	uint32_t	src_id;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  2903
	fc_lilpmap_t	*lilp_map;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2904
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2905
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2906
	ASSERT((job->job_flags & JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2907
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2908
	FP_DTRACE(FP_NHEAD1(2, 0), "Entering fp_port_startup;"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2909
	    " port=%p, job=%p", port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2910
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2911
	port->fp_topology = FC_TOP_UNKNOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2912
	port->fp_port_id.port_id = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2913
	state = FC_PORT_STATE_MASK(port->fp_state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2914
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2915
	if (state == FC_STATE_OFFLINE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2916
		port->fp_port_type.port_type = FC_NS_PORT_UNKNOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2917
		job->job_result = FC_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2918
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2919
		fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2920
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2921
		return (FC_OFFLINE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2922
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2923
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2924
	if (state == FC_STATE_LOOP) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2925
		port->fp_port_type.port_type = FC_NS_PORT_NL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2926
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2927
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2928
		lilp_map = &port->fp_lilp_map;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2929
		if ((rval = fp_get_lilpmap(port, lilp_map)) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2930
			job->job_result = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2931
			fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2932
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2933
			FP_TRACE(FP_NHEAD1(9, rval),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2934
			    "LILP map Invalid or not present");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2935
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2936
			return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2937
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2938
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2939
		if (lilp_map->lilp_length == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2940
			job->job_result = FC_NO_MAP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2941
			fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2942
			fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2943
			    "LILP map length zero");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2944
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2945
			return (FC_NO_MAP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2946
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2947
		src_id = lilp_map->lilp_myalpa & 0xFF;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2948
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2949
		fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2950
		fc_fca_pm_t		pm;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2951
		fc_fca_p2p_info_t	p2p_info;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2952
		int			pd_recepient;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2953
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2954
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2955
		 * Get P2P remote port info if possible
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2956
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2957
		bzero((caddr_t)&pm, sizeof (pm));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2958
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2959
		pm.pm_cmd_flags = FC_FCA_PM_READ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2960
		pm.pm_cmd_code = FC_PORT_GET_P2P_INFO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2961
		pm.pm_data_len = sizeof (fc_fca_p2p_info_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2962
		pm.pm_data_buf = (caddr_t)&p2p_info;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2963
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2964
		rval = port->fp_fca_tran->fca_port_manage(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2965
		    port->fp_fca_handle, &pm);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2966
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2967
		if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2968
			port->fp_port_id.port_id = p2p_info.fca_d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2969
			port->fp_port_type.port_type = FC_NS_PORT_N;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2970
			port->fp_topology = FC_TOP_PT_PT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2971
			port->fp_total_devices = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2972
			pd_recepient = fctl_wwn_cmp(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2973
			    &port->fp_service_params.nport_ww_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2974
			    &p2p_info.pwwn) < 0 ?
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2975
			    PD_PLOGI_RECEPIENT : PD_PLOGI_INITIATOR;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2976
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2977
			pd = fctl_create_remote_port(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2978
			    &p2p_info.nwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2979
			    &p2p_info.pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2980
			    p2p_info.d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2981
			    pd_recepient, KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2982
			FP_DTRACE(FP_NHEAD1(2, 0), "Exiting fp_port_startup;"
10107
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
  2983
			    " P2P port=%p pd=%p fp %x pd %x", port, pd,
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
  2984
			    port->fp_port_id.port_id, p2p_info.d_id);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2985
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2986
			return (FC_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2987
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2988
		port->fp_port_type.port_type = FC_NS_PORT_N;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2989
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2990
		src_id = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2991
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2992
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2993
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2994
	job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2995
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2996
	if ((rval = fp_fabric_login(port, src_id, job, FP_CMD_PLOGI_DONT_CARE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2997
	    KM_SLEEP)) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2998
		port->fp_port_type.port_type = FC_NS_PORT_UNKNOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  2999
		job->job_result = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3000
		fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3001
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3002
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3003
		if (port->fp_statec_busy <= 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3004
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3005
			fp_printf(port, CE_NOTE, FP_LOG_ONLY, rval, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3006
			    "Couldn't transport FLOGI");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3007
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3008
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3009
		return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3010
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3011
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3012
	fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3013
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3014
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3015
	if (job->job_result == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3016
		if (FC_IS_TOP_SWITCH(port->fp_topology)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3017
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3018
			fp_ns_init(port, job, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3019
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3020
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3021
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3022
		if (state == FC_STATE_LOOP) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3023
			port->fp_topology = FC_TOP_PRIVATE_LOOP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3024
			port->fp_port_id.port_id =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3025
			    port->fp_lilp_map.lilp_myalpa & 0xFF;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3026
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3027
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3028
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3029
	FP_DTRACE(FP_NHEAD1(2, 0), "Exiting fp_port_startup; port=%p, job=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3030
	    port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3031
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3032
	return (FC_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3033
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3034
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3035
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3036
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3037
 * Perform ULP invocations following FC port startup
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3038
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3039
/* ARGSUSED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3040
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3041
fp_startup_done(opaque_t arg, uchar_t result)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3042
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3043
	fc_local_port_t *port = arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3044
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3045
	fp_attach_ulps(port, FC_CMD_ATTACH);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3046
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3047
	FP_DTRACE(FP_NHEAD1(2, 0), "fp_startup almost complete; port=%p", port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3048
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3049
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3050
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3051
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3052
 * Perform ULP port attach
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3053
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3054
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3055
fp_ulp_port_attach(void *arg)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3056
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3057
	fp_soft_attach_t *att = (fp_soft_attach_t *)arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3058
	fc_local_port_t	 *port = att->att_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3059
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3060
	FP_DTRACE(FP_NHEAD1(1, 0), "port attach of"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3061
	    " ULPs begin; port=%p, cmd=%x", port, att->att_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3062
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3063
	fctl_attach_ulps(att->att_port, att->att_cmd, &modlinkage);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3064
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3065
	if (att->att_need_pm_idle == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3066
		fctl_idle_port(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3067
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3068
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3069
	FP_DTRACE(FP_NHEAD1(1, 0), "port attach of"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3070
	    " ULPs end; port=%p, cmd=%x", port, att->att_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3071
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3072
	mutex_enter(&att->att_port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3073
	att->att_port->fp_ulp_attach = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3074
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3075
	port->fp_task = port->fp_last_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3076
	port->fp_last_task = FP_TASK_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3077
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3078
	cv_signal(&att->att_port->fp_attach_cv);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3079
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3080
	mutex_exit(&att->att_port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3081
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3082
	kmem_free(att, sizeof (fp_soft_attach_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3083
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3084
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3085
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3086
 * Entry point to funnel all requests down to FCAs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3087
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3088
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3089
fp_sendcmd(fc_local_port_t *port, fp_cmd_t *cmd, opaque_t fca_handle)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3090
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3091
	int rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3092
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3093
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3094
	if (port->fp_statec_busy > 1 || (cmd->cmd_ulp_pkt != NULL &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3095
	    (port->fp_statec_busy || FC_PORT_STATE_MASK(port->fp_state) ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3096
	    FC_STATE_OFFLINE))) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3097
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3098
		 * This means there is more than one state change
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3099
		 * at this point of time - Since they are processed
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3100
		 * serially, any processing of the current one should
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3101
		 * be failed, failed and move up in processing the next
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3102
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3103
		cmd->cmd_pkt.pkt_state = FC_PKT_ELS_IN_PROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3104
		cmd->cmd_pkt.pkt_reason = FC_REASON_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3105
		if (cmd->cmd_job) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3106
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3107
			 * A state change that is going to be invalidated
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3108
			 * by another one already in the port driver's queue
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3109
			 * need not go up to all ULPs. This will minimize
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3110
			 * needless processing and ripples in ULP modules
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3111
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3112
			cmd->cmd_job->job_flags |= JOB_CANCEL_ULP_NOTIFICATION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3113
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3114
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3115
		return (FC_STATEC_BUSY);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3116
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3117
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3118
	if (FC_PORT_STATE_MASK(port->fp_state) == FC_STATE_OFFLINE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3119
		cmd->cmd_pkt.pkt_state = FC_PKT_PORT_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3120
		cmd->cmd_pkt.pkt_reason = FC_REASON_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3121
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3122
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3123
		return (FC_OFFLINE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3124
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3125
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3126
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3127
	rval = cmd->cmd_transport(fca_handle, &cmd->cmd_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3128
	if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3129
		if (rval == FC_TRAN_BUSY) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3130
			cmd->cmd_retry_interval = fp_retry_delay;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3131
			rval = fp_retry_cmd(&cmd->cmd_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3132
			if (rval == FC_FAILURE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3133
				cmd->cmd_pkt.pkt_state = FC_PKT_TRAN_BSY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3134
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3135
		}
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3136
	} else {
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3137
		mutex_enter(&port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3138
		port->fp_out_fpcmds++;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3139
		mutex_exit(&port->fp_mutex);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3140
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3141
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3142
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3143
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3144
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3145
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3146
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3147
 * Each time a timeout kicks in, walk the wait queue, decrement the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3148
 * the retry_interval, when the retry_interval becomes less than
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3149
 * or equal to zero, re-transport the command: If the re-transport
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3150
 * fails with BUSY, enqueue the command in the wait queue.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3151
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3152
 * In order to prevent looping forever because of commands enqueued
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3153
 * from within this function itself, save the current tail pointer
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3154
 * (in cur_tail) and exit the loop after serving this command.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3155
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3156
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3157
fp_resendcmd(void *port_handle)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3158
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3159
	int		rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3160
	fc_local_port_t	*port;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3161
	fp_cmd_t	*cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3162
	fp_cmd_t	*cur_tail;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3163
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3164
	port = port_handle;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3165
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3166
	cur_tail = port->fp_wait_tail;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3167
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3168
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3169
	while ((cmd = fp_deque_cmd(port)) != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3170
		cmd->cmd_retry_interval -= fp_retry_ticker;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3171
		/* Check if we are detaching */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3172
		if (port->fp_soft_state &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3173
		    (FP_SOFT_IN_DETACH | FP_DETACH_INPROGRESS)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3174
			cmd->cmd_pkt.pkt_state = FC_PKT_TRAN_ERROR;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3175
			cmd->cmd_pkt.pkt_reason = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3176
			fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3177
		} else if (cmd->cmd_retry_interval <= 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3178
			rval = cmd->cmd_transport(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3179
			    &cmd->cmd_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3180
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3181
			if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3182
				if (cmd->cmd_pkt.pkt_state == FC_PKT_TRAN_BSY) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3183
					if (--cmd->cmd_retry_count) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3184
						fp_enque_cmd(port, cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3185
						if (cmd == cur_tail) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3186
							break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3187
						}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3188
						continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3189
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3190
					cmd->cmd_pkt.pkt_state =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3191
					    FC_PKT_TRAN_BSY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3192
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3193
					cmd->cmd_pkt.pkt_state =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3194
					    FC_PKT_TRAN_ERROR;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3195
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3196
				cmd->cmd_pkt.pkt_reason = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3197
				fp_iodone(cmd);
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3198
			} else {
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3199
				mutex_enter(&port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3200
				port->fp_out_fpcmds++;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3201
				mutex_exit(&port->fp_mutex);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3202
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3203
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3204
			fp_enque_cmd(port, cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3205
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3206
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3207
		if (cmd == cur_tail) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3208
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3209
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3210
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3211
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3212
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3213
	if (port->fp_wait_head) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3214
		timeout_id_t tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3215
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3216
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3217
		tid = timeout(fp_resendcmd, (caddr_t)port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3218
		    fp_retry_ticks);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3219
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3220
		port->fp_wait_tid = tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3221
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3222
		port->fp_wait_tid = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3223
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3224
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3225
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3226
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3227
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3228
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3229
 * Handle Local, Fabric, N_Port, Transport (whatever that means) BUSY here.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3230
 *
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3231
 * Yes, as you can see below, cmd_retry_count is used here too.	 That means
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3232
 * the retries for BUSY are less if there were transport failures (transport
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3233
 * failure means fca_transport failure). The goal is not to exceed overall
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3234
 * retries set in the cmd_retry_count (whatever may be the reason for retry)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3235
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3236
 * Return Values:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3237
 *	FC_SUCCESS
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3238
 *	FC_FAILURE
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3239
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3240
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3241
fp_retry_cmd(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3242
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3243
	fp_cmd_t *cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3244
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3245
	cmd = pkt->pkt_ulp_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3246
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3247
	if (--cmd->cmd_retry_count) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3248
		fp_enque_cmd(cmd->cmd_port, cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3249
		return (FC_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3250
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3251
		return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3252
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3253
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3254
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3255
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3256
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3257
 * Queue up FC packet for deferred retry
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3258
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3259
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3260
fp_enque_cmd(fc_local_port_t *port, fp_cmd_t *cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3261
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3262
	timeout_id_t tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3263
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3264
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3265
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3266
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3267
	fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, &cmd->cmd_pkt,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3268
	    "Retrying ELS for %x", cmd->cmd_pkt.pkt_cmd_fhdr.d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3269
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3270
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3271
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3272
	if (port->fp_wait_tail) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3273
		port->fp_wait_tail->cmd_next = cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3274
		port->fp_wait_tail = cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3275
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3276
		ASSERT(port->fp_wait_head == NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3277
		port->fp_wait_head = port->fp_wait_tail = cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3278
		if (port->fp_wait_tid == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3279
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3280
			tid = timeout(fp_resendcmd, (caddr_t)port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3281
			    fp_retry_ticks);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3282
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3283
			port->fp_wait_tid = tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3284
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3285
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3286
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3287
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3288
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3289
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3290
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3291
 * Handle all RJT codes
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3292
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3293
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3294
fp_handle_reject(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3295
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3296
	int		rval = FC_FAILURE;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3297
	uchar_t		next_class;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3298
	fp_cmd_t	*cmd;
8051
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3299
	fc_local_port_t *port;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3300
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3301
	cmd = pkt->pkt_ulp_private;
8051
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3302
	port = cmd->cmd_port;
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3303
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3304
	switch (pkt->pkt_state) {
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3305
	case FC_PKT_FABRIC_RJT:
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3306
	case FC_PKT_NPORT_RJT:
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3307
		if (pkt->pkt_reason == FC_REASON_CLASS_NOT_SUPP) {
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3308
			next_class = fp_get_nextclass(cmd->cmd_port,
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3309
			    FC_TRAN_CLASS(pkt->pkt_tran_flags));
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3310
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3311
			if (next_class == FC_TRAN_CLASS_INVALID) {
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3312
				return (rval);
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3313
			}
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3314
			pkt->pkt_tran_flags = FC_TRAN_INTR | next_class;
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3315
			pkt->pkt_tran_type = FC_PKT_EXCHANGE;
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3316
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3317
			rval = fp_sendcmd(cmd->cmd_port, cmd,
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3318
			    cmd->cmd_port->fp_fca_handle);
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3319
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3320
			if (rval != FC_SUCCESS) {
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3321
				pkt->pkt_state = FC_PKT_TRAN_ERROR;
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3322
			}
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3323
		}
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3324
		break;
8051
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3325
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3326
	case FC_PKT_LS_RJT:
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3327
	case FC_PKT_BA_RJT:
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3328
		if ((pkt->pkt_reason == FC_REASON_LOGICAL_ERROR) ||
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3329
		    (pkt->pkt_reason == FC_REASON_LOGICAL_BSY)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3330
			cmd->cmd_retry_interval = fp_retry_delay;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3331
			rval = fp_retry_cmd(pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3332
		}
8051
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3333
		break;
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3334
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3335
	case FC_PKT_FS_RJT:
10107
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
  3336
		if ((pkt->pkt_reason == FC_REASON_FS_LOGICAL_BUSY) ||
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
  3337
		    ((pkt->pkt_reason == FC_REASON_FS_CMD_UNABLE) &&
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
  3338
		    (pkt->pkt_expln == 0x00))) {
8051
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3339
			cmd->cmd_retry_interval = fp_retry_delay;
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3340
			rval = fp_retry_cmd(pkt);
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3341
		}
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3342
		break;
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3343
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3344
	case FC_PKT_LOCAL_RJT:
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3345
		if (pkt->pkt_reason == FC_REASON_QFULL) {
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3346
			cmd->cmd_retry_interval = fp_retry_delay;
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3347
			rval = fp_retry_cmd(pkt);
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3348
		}
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3349
		break;
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3350
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3351
	default:
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3352
		FP_TRACE(FP_NHEAD1(1, 0),
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3353
		    "fp_handle_reject(): Invalid pkt_state");
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  3354
		break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3355
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3356
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3357
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3358
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3359
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3360
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3361
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3362
 * Return the next class of service supported by the FCA
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3363
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3364
static uchar_t
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3365
fp_get_nextclass(fc_local_port_t *port, uchar_t cur_class)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3366
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3367
	uchar_t next_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3368
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3369
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3370
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3371
	switch (cur_class) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3372
	case FC_TRAN_CLASS_INVALID:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3373
		if (port->fp_cos & FC_NS_CLASS1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3374
			next_class = FC_TRAN_CLASS1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3375
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3376
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3377
		/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3378
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3379
	case FC_TRAN_CLASS1:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3380
		if (port->fp_cos & FC_NS_CLASS2) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3381
			next_class = FC_TRAN_CLASS2;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3382
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3383
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3384
		/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3385
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3386
	case FC_TRAN_CLASS2:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3387
		if (port->fp_cos & FC_NS_CLASS3) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3388
			next_class = FC_TRAN_CLASS3;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3389
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3390
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3391
		/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3392
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3393
	case FC_TRAN_CLASS3:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3394
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3395
		next_class = FC_TRAN_CLASS_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3396
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3397
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3398
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3399
	return (next_class);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3400
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3401
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3402
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3403
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3404
 * Determine if a class of service is supported by the FCA
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3405
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3406
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3407
fp_is_class_supported(uint32_t cos, uchar_t tran_class)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3408
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3409
	int rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3410
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3411
	switch (tran_class) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3412
	case FC_TRAN_CLASS1:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3413
		if (cos & FC_NS_CLASS1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3414
			rval = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3415
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3416
			rval = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3417
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3418
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3419
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3420
	case FC_TRAN_CLASS2:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3421
		if (cos & FC_NS_CLASS2) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3422
			rval = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3423
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3424
			rval = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3425
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3426
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3427
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3428
	case FC_TRAN_CLASS3:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3429
		if (cos & FC_NS_CLASS3) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3430
			rval = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3431
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3432
			rval = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3433
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3434
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3435
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3436
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3437
		rval = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3438
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3439
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3440
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3441
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3442
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3443
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3444
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3445
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3446
 * Dequeue FC packet for retry
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3447
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3448
static fp_cmd_t *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3449
fp_deque_cmd(fc_local_port_t *port)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3450
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3451
	fp_cmd_t *cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3452
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3453
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3454
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3455
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3456
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3457
	if (port->fp_wait_head == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3458
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3459
		 * To avoid races, NULL the fp_wait_tid as
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3460
		 * we are about to exit the timeout thread.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3461
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3462
		port->fp_wait_tid = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3463
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3464
		return (NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3465
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3466
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3467
	cmd = port->fp_wait_head;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3468
	port->fp_wait_head = cmd->cmd_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3469
	cmd->cmd_next = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3470
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3471
	if (port->fp_wait_head == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3472
		port->fp_wait_tail = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3473
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3474
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3475
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3476
	return (cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3477
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3478
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3479
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3480
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3481
 * Wait for job completion
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3482
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3483
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3484
fp_jobwait(job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3485
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3486
	sema_p(&job->job_port_sema);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3487
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3488
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3489
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3490
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3491
 * Convert FC packet state to FC errno
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3492
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3493
int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3494
fp_state_to_rval(uchar_t state)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3495
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3496
	int count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3497
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3498
	for (count = 0; count < sizeof (fp_xlat) /
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3499
	    sizeof (fp_xlat[0]); count++) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3500
		if (fp_xlat[count].xlat_state == state) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3501
			return (fp_xlat[count].xlat_rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3502
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3503
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3504
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3505
	return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3506
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3507
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3508
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3509
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3510
 * For Synchronous I/O requests, the caller is
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3511
 * expected to do fctl_jobdone(if necessary)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3512
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3513
 * We want to preserve at least one failure in the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3514
 * job_result if it happens.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3515
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3516
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3517
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3518
fp_iodone(fp_cmd_t *cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3519
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3520
	fc_packet_t		*ulp_pkt = cmd->cmd_ulp_pkt;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3521
	job_request_t		*job = cmd->cmd_job;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3522
	fc_remote_port_t	*pd = cmd->cmd_pkt.pkt_pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3523
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3524
	ASSERT(job != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3525
	ASSERT(cmd->cmd_port != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3526
	ASSERT(&cmd->cmd_pkt != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3527
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3528
	mutex_enter(&job->job_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3529
	if (job->job_result == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3530
		job->job_result = fp_state_to_rval(cmd->cmd_pkt.pkt_state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3531
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3532
	mutex_exit(&job->job_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3533
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3534
	if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3535
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3536
		pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3537
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3538
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3539
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3540
	if (ulp_pkt) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3541
		if (pd && cmd->cmd_flags & FP_CMD_DELDEV_ON_ERROR &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3542
		    FP_IS_PKT_ERROR(ulp_pkt)) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3543
			fc_local_port_t		*port;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3544
			fc_remote_node_t	*node;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3545
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3546
			port = cmd->cmd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3547
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3548
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3549
			pd->pd_state = PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3550
			pd->pd_ref_count--;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3551
			node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3552
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3553
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3554
			ASSERT(node != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3555
			ASSERT(port != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3556
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3557
			if (fctl_destroy_remote_port(port, pd) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3558
				fctl_destroy_remote_node(node);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3559
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3560
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3561
			ulp_pkt->pkt_pd = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3562
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3563
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3564
		ulp_pkt->pkt_comp(ulp_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3565
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3566
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3567
	fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3568
	fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3569
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3570
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3571
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3572
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3573
 * Job completion handler
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3574
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3575
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3576
fp_jobdone(job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3577
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3578
	mutex_enter(&job->job_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3579
	ASSERT(job->job_counter > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3580
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3581
	if (--job->job_counter != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3582
		mutex_exit(&job->job_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3583
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3584
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3585
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3586
	if (job->job_ulp_pkts) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3587
		ASSERT(job->job_ulp_listlen > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3588
		kmem_free(job->job_ulp_pkts,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3589
		    sizeof (fc_packet_t *) * job->job_ulp_listlen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3590
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3591
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3592
	if (job->job_flags & JOB_TYPE_FP_ASYNC) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3593
		mutex_exit(&job->job_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3594
		fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3595
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3596
		mutex_exit(&job->job_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3597
		sema_v(&job->job_port_sema);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3598
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3599
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3600
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3601
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3602
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3603
 * Try to perform shutdown of a port during a detach. No return
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3604
 * value since the detach should not fail because the port shutdown
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3605
 * failed.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3606
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3607
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3608
fp_port_shutdown(fc_local_port_t *port, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3609
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3610
	int			index;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3611
	int			count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3612
	int			flags;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3613
	fp_cmd_t		*cmd;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3614
	struct pwwn_hash	*head;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3615
	fc_remote_port_t	*pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3616
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3617
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3618
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3619
	job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3620
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3621
	if (port->fp_taskq) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3622
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3623
		 * We must release the mutex here to ensure that other
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3624
		 * potential jobs can complete their processing.  Many
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3625
		 * also need this mutex.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3626
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3627
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3628
		taskq_wait(port->fp_taskq);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3629
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3630
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3631
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3632
	if (port->fp_offline_tid) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3633
		timeout_id_t tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3634
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3635
		tid = port->fp_offline_tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3636
		port->fp_offline_tid = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3637
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3638
		(void) untimeout(tid);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3639
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3640
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3641
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3642
	if (port->fp_wait_tid) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3643
		timeout_id_t tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3644
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3645
		tid = port->fp_wait_tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3646
		port->fp_wait_tid = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3647
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3648
		(void) untimeout(tid);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3649
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3650
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3651
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3652
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3653
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3654
	 * While we cancel the timeout, let's also return the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3655
	 * the outstanding requests back to the callers.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3656
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3657
	while ((cmd = fp_deque_cmd(port)) != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3658
		ASSERT(cmd->cmd_job != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3659
		cmd->cmd_job->job_result = FC_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3660
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3661
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3662
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3663
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3664
	 * Gracefully LOGO with all the devices logged in.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3665
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3666
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3667
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3668
	for (count = index = 0; index < pwwn_table_size; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3669
		head = &port->fp_pwwn_table[index];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3670
		pd = head->pwwn_head;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3671
		while (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3672
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3673
			if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3674
				count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3675
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3676
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3677
			pd = pd->pd_wwn_hnext;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3678
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3679
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3680
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3681
	if (job->job_flags & JOB_TYPE_FP_ASYNC) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3682
		flags = job->job_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3683
		job->job_flags &= ~JOB_TYPE_FP_ASYNC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3684
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3685
		flags = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3686
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3687
	if (count) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3688
		job->job_counter = count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3689
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3690
		for (index = 0; index < pwwn_table_size; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3691
			head = &port->fp_pwwn_table[index];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3692
			pd = head->pwwn_head;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3693
			while (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3694
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3695
				if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3696
					ASSERT(pd->pd_login_count > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3697
					/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3698
					 * Force the counter to ONE in order
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3699
					 * for us to really send LOGO els.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3700
					 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3701
					pd->pd_login_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3702
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3703
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3704
					(void) fp_logout(port, pd, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3705
					mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3706
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3707
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3708
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3709
				pd = pd->pd_wwn_hnext;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3710
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3711
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3712
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3713
		fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3714
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3715
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3716
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3717
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3718
	if (job->job_result != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3719
		FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3720
		    "Can't logout all devices. Proceeding with"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3721
		    " port shutdown");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3722
		job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3723
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3724
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3725
	fctl_destroy_all_remote_ports(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3726
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3727
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3728
	if (FC_IS_TOP_SWITCH(port->fp_topology)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3729
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3730
		fp_ns_fini(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3731
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3732
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3733
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3734
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3735
	if (flags) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3736
		job->job_flags = flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3737
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3738
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3739
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3740
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3741
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3742
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3743
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3744
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3745
 * Build the port driver's data structures based on the AL_PA list
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3746
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3747
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3748
fp_get_loopmap(fc_local_port_t *port, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3749
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3750
	int			rval;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3751
	int			flag;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3752
	int			count;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3753
	uint32_t		d_id;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3754
	fc_remote_port_t	*pd;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3755
	fc_lilpmap_t		*lilp_map;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3756
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3757
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3758
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3759
	if (FC_PORT_STATE_MASK(port->fp_state) == FC_STATE_OFFLINE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3760
		job->job_result = FC_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3761
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3762
		fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3763
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3764
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3765
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3766
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3767
	if (port->fp_lilp_map.lilp_length == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3768
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3769
		job->job_result = FC_NO_MAP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3770
		fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3771
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3772
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3773
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3774
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3775
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3776
	lilp_map = &port->fp_lilp_map;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3777
	job->job_counter = lilp_map->lilp_length;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3778
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3779
	if (job->job_code == JOB_PORT_GETMAP_PLOGI_ALL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3780
		flag = FP_CMD_PLOGI_RETAIN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3781
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3782
		flag = FP_CMD_PLOGI_DONT_CARE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3783
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3784
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3785
	for (count = 0; count < lilp_map->lilp_length; count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3786
		d_id = lilp_map->lilp_alpalist[count];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3787
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3788
		if (d_id == (lilp_map->lilp_myalpa & 0xFF)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3789
			fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3790
			continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3791
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3792
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3793
		pd = fctl_get_remote_port_by_did(port, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3794
		if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3795
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3796
			if (flag == FP_CMD_PLOGI_DONT_CARE ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3797
			    pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3798
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3799
				fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3800
				continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3801
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3802
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3803
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3804
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3805
		rval = fp_port_login(port, d_id, job, flag,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3806
		    KM_SLEEP, pd, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3807
		if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3808
			fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3809
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3810
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3811
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3812
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3813
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3814
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3815
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3816
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3817
 * Perform loop ONLINE processing
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3818
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3819
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3820
fp_loop_online(fc_local_port_t *port, job_request_t *job, int orphan)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3821
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3822
	int			count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3823
	int			rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3824
	uint32_t		d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3825
	uint32_t		listlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3826
	fc_lilpmap_t		*lilp_map;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3827
	fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3828
	fc_portmap_t		*changelist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3829
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3830
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3831
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3832
	FP_TRACE(FP_NHEAD1(1, 0), "fp_loop_online begin; port=%p, job=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3833
	    port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3834
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3835
	lilp_map = &port->fp_lilp_map;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3837
	if (lilp_map->lilp_length) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3838
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3839
		if (port->fp_soft_state & FP_SOFT_IN_FCA_RESET) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3840
			port->fp_soft_state &= ~FP_SOFT_IN_FCA_RESET;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3841
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3842
			delay(drv_usectohz(PLDA_RR_TOV * 1000 * 1000));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3843
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3844
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3845
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3846
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3847
		job->job_counter = lilp_map->lilp_length;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3848
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3849
		for (count = 0; count < lilp_map->lilp_length; count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3850
			d_id = lilp_map->lilp_alpalist[count];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3851
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3852
			if (d_id == (lilp_map->lilp_myalpa & 0xFF)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3853
				fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3854
				continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3855
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3856
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3857
			pd = fctl_get_remote_port_by_did(port, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3858
			if (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3859
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3860
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3861
				if (pd->pd_recepient == PD_PLOGI_INITIATOR) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3862
					ASSERT(pd->pd_type != PORT_DEVICE_OLD);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3863
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3864
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3865
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3866
				fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3867
				continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3868
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3869
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3870
			rval = fp_port_login(port, d_id, job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3871
			    FP_CMD_PLOGI_DONT_CARE, KM_SLEEP, pd, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3872
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3873
			if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3874
				fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3875
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3876
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3877
		fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3878
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3879
	listlen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3880
	changelist = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3881
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3882
	if ((job->job_flags & JOB_CANCEL_ULP_NOTIFICATION) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3883
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3884
		ASSERT(port->fp_statec_busy > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3885
		if (port->fp_statec_busy == 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3886
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3887
			fctl_fillout_map(port, &changelist, &listlen,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3888
			    1, 0, orphan);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3889
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3890
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3891
			if (port->fp_lilp_map.lilp_magic < MAGIC_LIRP) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3892
				ASSERT(port->fp_total_devices == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3893
				port->fp_total_devices = port->fp_dev_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3894
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3895
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3896
			job->job_flags |= JOB_CANCEL_ULP_NOTIFICATION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3897
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3898
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3899
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3900
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3901
	if ((job->job_flags & JOB_CANCEL_ULP_NOTIFICATION) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3902
		(void) fp_ulp_statec_cb(port, FC_STATE_ONLINE, changelist,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3903
		    listlen, listlen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3904
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3905
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3906
		if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3907
			port->fp_soft_state &= ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3908
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3909
		ASSERT(changelist == NULL && listlen == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3910
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3911
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3912
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3913
	FP_TRACE(FP_NHEAD1(1, 0), "fp_loop_online end; port=%p, job=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3914
	    port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3915
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3916
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3917
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3918
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3919
 * Get an Arbitrated Loop map from the underlying FCA
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3920
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3921
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3922
fp_get_lilpmap(fc_local_port_t *port, fc_lilpmap_t *lilp_map)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3923
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3924
	int rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3925
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3926
	FP_TRACE(FP_NHEAD1(1, 0), "fp_get_lilpmap Begin; port=%p, map=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3927
	    port, lilp_map);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3928
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3929
	bzero((caddr_t)lilp_map, sizeof (fc_lilpmap_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3930
	rval = port->fp_fca_tran->fca_getmap(port->fp_fca_handle, lilp_map);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3931
	lilp_map->lilp_magic &= 0xFF;	/* Ignore upper byte */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3932
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3933
	if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3934
		rval = FC_NO_MAP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3935
	} else if (lilp_map->lilp_length == 0 &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3936
	    (lilp_map->lilp_magic >= MAGIC_LISM &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3937
	    lilp_map->lilp_magic < MAGIC_LIRP)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3938
		uchar_t lilp_length;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3939
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3940
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3941
		 * Since the map length is zero, provide all
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3942
		 * the valid AL_PAs for NL_ports discovery.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3943
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3944
		lilp_length = sizeof (fp_valid_alpas) /
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3945
		    sizeof (fp_valid_alpas[0]);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3946
		lilp_map->lilp_length = lilp_length;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3947
		bcopy(fp_valid_alpas, lilp_map->lilp_alpalist,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3948
		    lilp_length);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3949
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3950
		rval = fp_validate_lilp_map(lilp_map);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3951
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3952
		if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3953
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3954
			port->fp_total_devices = lilp_map->lilp_length - 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3955
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3956
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3957
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3958
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3959
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3960
	if (rval != FC_SUCCESS && !(port->fp_soft_state & FP_SOFT_BAD_LINK)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3961
		port->fp_soft_state |= FP_SOFT_BAD_LINK;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3962
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3963
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3964
		if (port->fp_fca_tran->fca_reset(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3965
		    FC_FCA_RESET_CORE) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3966
			FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3967
			    "FCA reset failed after LILP map was found"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3968
			    " to be invalid");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3969
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3970
	} else if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3971
		port->fp_soft_state &= ~FP_SOFT_BAD_LINK;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3972
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3973
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3974
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3975
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3976
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3977
	FP_TRACE(FP_NHEAD1(1, 0), "fp_get_lilpmap End; port=%p, map=%p", port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3978
	    lilp_map);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3979
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3980
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3981
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3982
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3983
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3984
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3985
 * Perform Fabric Login:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3986
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3987
 * Return Values:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3988
 *		FC_SUCCESS
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3989
 *		FC_FAILURE
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3990
 *		FC_NOMEM
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3991
 *		FC_TRANSPORT_ERROR
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3992
 *		and a lot others defined in fc_error.h
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3993
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3994
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3995
fp_fabric_login(fc_local_port_t *port, uint32_t s_id, job_request_t *job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3996
    int flag, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3997
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  3998
	int		rval;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  3999
	fp_cmd_t	*cmd;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4000
	uchar_t		class;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4001
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4002
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4003
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4004
	FP_TRACE(FP_NHEAD1(1, 0), "fp_fabric_login Begin; port=%p, job=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4005
	    port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4006
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4007
	class = fp_get_nextclass(port, FC_TRAN_CLASS_INVALID);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4008
	if (class == FC_TRAN_CLASS_INVALID) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4009
		return (FC_ELS_BAD);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4010
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4011
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4012
	cmd = fp_alloc_pkt(port, sizeof (la_els_logi_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4013
	    sizeof (la_els_logi_t), sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4014
	if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4015
		return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4016
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4017
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4018
	cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4019
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4020
	cmd->cmd_flags = flag;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4021
	cmd->cmd_retry_count = fp_retry_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4022
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4023
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4024
	fp_xlogi_init(port, cmd, s_id, 0xFFFFFE, fp_flogi_intr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4025
	    job, LA_ELS_FLOGI);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4026
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4027
	rval = fp_sendcmd(port, cmd, port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4028
	if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4029
		fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4030
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4031
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4032
	FP_TRACE(FP_NHEAD1(1, 0), "fp_fabric_login End; port=%p, job=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4033
	    port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4034
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4035
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4036
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4037
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4038
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4039
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4040
 * In some scenarios such as private loop device discovery period
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4041
 * the fc_remote_port_t data structure isn't allocated. The allocation
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4042
 * is done when the PLOGI is successful. In some other scenarios
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4043
 * such as Fabric topology, the fc_remote_port_t is already created
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4044
 * and initialized with appropriate values (as the NS provides
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4045
 * them)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4046
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4047
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4048
fp_port_login(fc_local_port_t *port, uint32_t d_id, job_request_t *job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4049
    int cmd_flag, int sleep, fc_remote_port_t *pd, fc_packet_t *ulp_pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4050
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4051
	uchar_t class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4052
	fp_cmd_t *cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4053
	uint32_t src_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4054
	fc_remote_port_t *tmp_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4055
	int relogin;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4056
	int found = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4057
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4058
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4059
	if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4060
		ASSERT(fctl_get_remote_port_by_did(port, d_id) == NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4061
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4062
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4063
	ASSERT(job->job_counter > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4064
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4065
	class = fp_get_nextclass(port, FC_TRAN_CLASS_INVALID);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4066
	if (class == FC_TRAN_CLASS_INVALID) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4067
		return (FC_ELS_BAD);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4068
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4069
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4070
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4071
	tmp_pd = fctl_lookup_pd_by_did(port, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4072
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4073
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4074
	relogin = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4075
	if (tmp_pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4076
		mutex_enter(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4077
		if ((tmp_pd->pd_aux_flags & PD_DISABLE_RELOGIN) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4078
		    !(tmp_pd->pd_aux_flags & PD_LOGGED_OUT)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4079
			tmp_pd->pd_state = PORT_DEVICE_LOGGED_IN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4080
			relogin = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4081
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4082
		mutex_exit(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4083
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4084
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4085
	if (!relogin) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4086
		mutex_enter(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4087
		if (tmp_pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4088
			cmd_flag |= FP_CMD_PLOGI_RETAIN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4089
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4090
		mutex_exit(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4091
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4092
		cmd = fp_alloc_pkt(port, sizeof (la_els_adisc_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4093
		    sizeof (la_els_adisc_t), sleep, tmp_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4094
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4095
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4096
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4097
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4098
		cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4099
		cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4100
		cmd->cmd_flags = cmd_flag;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4101
		cmd->cmd_retry_count = fp_retry_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4102
		cmd->cmd_ulp_pkt = ulp_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4103
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4104
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4105
		mutex_enter(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4106
		fp_adisc_init(cmd, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4107
		mutex_exit(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4108
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4109
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4110
		cmd->cmd_pkt.pkt_cmdlen = sizeof (la_els_adisc_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4111
		cmd->cmd_pkt.pkt_rsplen = sizeof (la_els_adisc_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4112
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4113
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4114
		cmd = fp_alloc_pkt(port, sizeof (la_els_logi_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4115
		    sizeof (la_els_logi_t), sleep, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4116
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4117
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4118
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4119
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4120
		cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4121
		cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4122
		cmd->cmd_flags = cmd_flag;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4123
		cmd->cmd_retry_count = fp_retry_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4124
		cmd->cmd_ulp_pkt = ulp_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4125
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4126
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4127
		src_id = port->fp_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4128
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4129
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4130
		fp_xlogi_init(port, cmd, src_id, d_id, fp_plogi_intr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4131
		    job, LA_ELS_PLOGI);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4132
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4133
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4134
	if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4135
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4136
		pd->pd_flags = PD_ELS_IN_PROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4137
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4138
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4139
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4140
	/* npiv check to make sure we don't log into ourself */
8588
f9b38706f703 6783141 The check in fp_port_login to avoid PLOGI to itself is wrong
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8494
diff changeset
  4141
	if (relogin &&
f9b38706f703 6783141 The check in fp_port_login to avoid PLOGI to itself is wrong
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8494
diff changeset
  4142
	    ((port->fp_npiv_type == FC_NPIV_PORT) ||
f9b38706f703 6783141 The check in fp_port_login to avoid PLOGI to itself is wrong
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 8494
diff changeset
  4143
	    (port->fp_npiv_flag == FC_NPIV_ENABLE))) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4144
		if ((d_id & 0xffff00) ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4145
		    (port->fp_port_id.port_id & 0xffff00)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4146
			found = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4147
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4148
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4149
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4150
	if (found ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4151
	    (fp_sendcmd(port, cmd, port->fp_fca_handle) != FC_SUCCESS)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4152
		if (found) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4153
			fc_packet_t *pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4154
			pkt->pkt_state = FC_PKT_NPORT_RJT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4155
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4156
		if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4157
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4158
			pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4159
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4160
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4161
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4162
		if (ulp_pkt) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4163
			fc_packet_t *pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4164
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4165
			ulp_pkt->pkt_state = pkt->pkt_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4166
			ulp_pkt->pkt_reason = pkt->pkt_reason;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4167
			ulp_pkt->pkt_action = pkt->pkt_action;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4168
			ulp_pkt->pkt_expln = pkt->pkt_expln;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4169
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4170
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4171
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4172
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4173
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4174
	return (FC_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4175
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4176
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4177
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4178
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4179
 * Register the LOGIN parameters with a port device
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4180
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4181
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4182
fp_register_login(ddi_acc_handle_t *handle, fc_remote_port_t *pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4183
    la_els_logi_t *acc, uchar_t class)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4184
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4185
	fc_remote_node_t	*node;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4186
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4187
	ASSERT(pd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4188
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4189
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4190
	node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4191
	if (pd->pd_login_count == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4192
		pd->pd_login_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4193
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4194
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4195
	if (handle) {
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4196
		FC_GET_RSP(pd->pd_port, *handle, (uint8_t *)&pd->pd_csp,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4197
		    (uint8_t *)&acc->common_service,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4198
		    sizeof (acc->common_service), DDI_DEV_AUTOINCR);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4199
		FC_GET_RSP(pd->pd_port, *handle, (uint8_t *)&pd->pd_clsp1,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4200
		    (uint8_t *)&acc->class_1, sizeof (acc->class_1),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4201
		    DDI_DEV_AUTOINCR);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4202
		FC_GET_RSP(pd->pd_port, *handle, (uint8_t *)&pd->pd_clsp2,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4203
		    (uint8_t *)&acc->class_2, sizeof (acc->class_2),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4204
		    DDI_DEV_AUTOINCR);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4205
		FC_GET_RSP(pd->pd_port, *handle, (uint8_t *)&pd->pd_clsp3,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4206
		    (uint8_t *)&acc->class_3, sizeof (acc->class_3),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4207
		    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4208
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4209
		pd->pd_csp = acc->common_service;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4210
		pd->pd_clsp1 = acc->class_1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4211
		pd->pd_clsp2 = acc->class_2;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4212
		pd->pd_clsp3 = acc->class_3;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4213
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4214
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4215
	pd->pd_state = PORT_DEVICE_LOGGED_IN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4216
	pd->pd_login_class = class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4217
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4218
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4219
#ifndef	__lock_lint
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4220
	ASSERT(fctl_get_remote_port_by_did(pd->pd_port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4221
	    pd->pd_port_id.port_id) == pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4222
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4223
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4224
	mutex_enter(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4225
	if (handle) {
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4226
		FC_GET_RSP(pd->pd_port, *handle, (uint8_t *)node->fd_vv,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4227
		    (uint8_t *)acc->vendor_version, sizeof (node->fd_vv),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4228
		    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4229
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4230
		bcopy(acc->vendor_version, node->fd_vv, sizeof (node->fd_vv));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4231
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4232
	mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4233
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4234
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4235
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4236
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4237
 * Mark the remote port as OFFLINE
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4238
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4239
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4240
fp_remote_port_offline(fc_remote_port_t *pd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4241
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4242
	ASSERT(MUTEX_HELD(&pd->pd_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4243
	if (pd->pd_login_count &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4244
	    ((pd->pd_aux_flags & PD_DISABLE_RELOGIN) == 0)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4245
		bzero((caddr_t)&pd->pd_csp, sizeof (struct common_service));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4246
		bzero((caddr_t)&pd->pd_clsp1, sizeof (struct service_param));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4247
		bzero((caddr_t)&pd->pd_clsp2, sizeof (struct service_param));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4248
		bzero((caddr_t)&pd->pd_clsp3, sizeof (struct service_param));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4249
		pd->pd_login_class = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4250
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4251
	pd->pd_type = PORT_DEVICE_OLD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4252
	pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4253
	fctl_tc_reset(&pd->pd_logo_tc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4254
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4255
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4256
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4257
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4258
 * Deregistration of a port device
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4259
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4260
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4261
fp_unregister_login(fc_remote_port_t *pd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4262
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4263
	fc_remote_node_t *node;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4264
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4265
	ASSERT(pd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4266
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4267
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4268
	pd->pd_login_count = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4269
	bzero((caddr_t)&pd->pd_csp, sizeof (struct common_service));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4270
	bzero((caddr_t)&pd->pd_clsp1, sizeof (struct service_param));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4271
	bzero((caddr_t)&pd->pd_clsp2, sizeof (struct service_param));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4272
	bzero((caddr_t)&pd->pd_clsp3, sizeof (struct service_param));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4273
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4274
	pd->pd_state = PORT_DEVICE_VALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4275
	pd->pd_login_class = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4276
	node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4277
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4278
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4279
	mutex_enter(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4280
	bzero(node->fd_vv, sizeof (node->fd_vv));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4281
	mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4282
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4283
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4284
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4285
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4286
 * Handle OFFLINE state of an FCA port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4287
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4288
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4289
fp_port_offline(fc_local_port_t *port, int notify)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4290
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4291
	int			index;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4292
	int			statec;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4293
	timeout_id_t		tid;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4294
	struct pwwn_hash	*head;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4295
	fc_remote_port_t	*pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4296
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4297
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4298
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4299
	for (index = 0; index < pwwn_table_size; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4300
		head = &port->fp_pwwn_table[index];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4301
		pd = head->pwwn_head;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4302
		while (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4303
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4304
			fp_remote_port_offline(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4305
			fctl_delist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4306
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4307
			pd = pd->pd_wwn_hnext;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4308
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4309
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4310
	port->fp_total_devices = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4311
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4312
	statec = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4313
	if (notify) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4314
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4315
		 * Decrement the statec busy counter as we
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4316
		 * are almost done with handling the state
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4317
		 * change
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4318
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4319
		ASSERT(port->fp_statec_busy > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4320
		if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4321
			port->fp_soft_state &= ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4322
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4323
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4324
		(void) fp_ulp_statec_cb(port, FC_STATE_OFFLINE, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4325
		    0, 0, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4326
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4327
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4328
		if (port->fp_statec_busy) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4329
			statec++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4330
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4331
	} else if (port->fp_statec_busy > 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4332
		statec++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4333
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4334
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4335
	if ((tid = port->fp_offline_tid) != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4336
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4337
		(void) untimeout(tid);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4338
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4339
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4340
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4341
	if (!statec) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4342
		port->fp_offline_tid = timeout(fp_offline_timeout,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4343
		    (caddr_t)port, fp_offline_ticks);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4344
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4345
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4346
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4347
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4348
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4349
 * Offline devices and send up a state change notification to ULPs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4350
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4351
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4352
fp_offline_timeout(void *port_handle)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4353
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4354
	int		ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4355
	fc_local_port_t *port = port_handle;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4356
	uint32_t	listlen = 0;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4357
	fc_portmap_t	*changelist = NULL;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4358
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4359
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4360
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4361
	if ((FC_PORT_STATE_MASK(port->fp_state) != FC_STATE_OFFLINE) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4362
	    (port->fp_soft_state &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4363
	    (FP_SOFT_IN_DETACH | FP_SOFT_SUSPEND | FP_SOFT_POWER_DOWN)) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4364
	    port->fp_dev_count == 0 || port->fp_statec_busy) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4365
		port->fp_offline_tid = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4366
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4367
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4368
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4369
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4370
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4371
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4372
	FP_TRACE(FP_NHEAD2(9, 0), "OFFLINE timeout");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4373
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4374
	if (port->fp_options & FP_CORE_ON_OFFLINE_TIMEOUT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4375
		if ((ret = port->fp_fca_tran->fca_reset(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4376
		    FC_FCA_CORE)) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4377
			FP_TRACE(FP_NHEAD1(9, ret),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4378
			    "Failed to force adapter dump");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4379
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4380
			FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4381
			    "Forced adapter dump successfully");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4382
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4383
	} else if (port->fp_options & FP_RESET_CORE_ON_OFFLINE_TIMEOUT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4384
		if ((ret = port->fp_fca_tran->fca_reset(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4385
		    FC_FCA_RESET_CORE)) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4386
			FP_TRACE(FP_NHEAD1(9, ret),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4387
			    "Failed to force adapter dump and reset");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4388
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4389
			FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4390
			    "Forced adapter dump and reset successfully");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4391
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4392
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4393
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4394
	fctl_fillout_map(port, &changelist, &listlen, 1, 0, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4395
	(void) fp_ulp_statec_cb(port, FC_STATE_OFFLINE, changelist,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4396
	    listlen, listlen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4397
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4398
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4399
	port->fp_offline_tid = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4400
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4401
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4402
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4403
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4404
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4405
 * Perform general purpose ELS request initialization
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4406
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4407
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4408
fp_els_init(fp_cmd_t *cmd, uint32_t s_id, uint32_t d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4409
    void (*comp) (), job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4410
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4411
	fc_packet_t *pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4412
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4413
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4414
	cmd->cmd_job = job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4415
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4416
	pkt->pkt_cmd_fhdr.r_ctl = R_CTL_ELS_REQ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4417
	pkt->pkt_cmd_fhdr.d_id = d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4418
	pkt->pkt_cmd_fhdr.s_id = s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4419
	pkt->pkt_cmd_fhdr.type = FC_TYPE_EXTENDED_LS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4420
	pkt->pkt_cmd_fhdr.f_ctl = F_CTL_SEQ_INITIATIVE | F_CTL_FIRST_SEQ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4421
	pkt->pkt_cmd_fhdr.seq_id = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4422
	pkt->pkt_cmd_fhdr.df_ctl  = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4423
	pkt->pkt_cmd_fhdr.seq_cnt = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4424
	pkt->pkt_cmd_fhdr.ox_id = 0xffff;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4425
	pkt->pkt_cmd_fhdr.rx_id = 0xffff;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4426
	pkt->pkt_cmd_fhdr.ro = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4427
	pkt->pkt_cmd_fhdr.rsvd = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4428
	pkt->pkt_comp = comp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4429
	pkt->pkt_timeout = FP_ELS_TIMEOUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4430
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4431
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4432
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4433
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4434
 * Initialize PLOGI/FLOGI ELS request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4435
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4436
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4437
fp_xlogi_init(fc_local_port_t *port, fp_cmd_t *cmd, uint32_t s_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4438
    uint32_t d_id, void (*intr) (), job_request_t *job, uchar_t ls_code)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4439
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4440
	ls_code_t	payload;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4441
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4442
	fp_els_init(cmd, s_id, d_id, intr, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4443
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4444
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4445
	payload.ls_code = ls_code;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4446
	payload.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4447
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4448
	FC_SET_CMD(port, cmd->cmd_pkt.pkt_cmd_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4449
	    (uint8_t *)&port->fp_service_params,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4450
	    (uint8_t *)cmd->cmd_pkt.pkt_cmd, sizeof (port->fp_service_params),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4451
	    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4452
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4453
	FC_SET_CMD(port, cmd->cmd_pkt.pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4454
	    (uint8_t *)cmd->cmd_pkt.pkt_cmd, sizeof (payload),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4455
	    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4456
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4457
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4458
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4459
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4460
 * Initialize LOGO ELS request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4461
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4462
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4463
fp_logo_init(fc_remote_port_t *pd, fp_cmd_t *cmd, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4464
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4465
	fc_local_port_t	*port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4466
	fc_packet_t	*pkt;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4467
	la_els_logo_t	payload;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4468
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4469
	port = pd->pd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4470
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4471
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4472
	ASSERT(MUTEX_HELD(&pd->pd_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4473
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4474
	fp_els_init(cmd, port->fp_port_id.port_id, pd->pd_port_id.port_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4475
	    fp_logo_intr, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4476
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4477
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4478
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4479
	pkt->pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4480
	pkt->pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4481
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4482
	payload.ls_code.ls_code = LA_ELS_LOGO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4483
	payload.ls_code.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4484
	payload.nport_ww_name = port->fp_service_params.nport_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4485
	payload.nport_id = port->fp_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4486
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4487
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4488
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4489
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4490
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4491
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4492
 * Initialize RNID ELS request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4493
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4494
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4495
fp_rnid_init(fp_cmd_t *cmd, uint16_t flag, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4496
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4497
	fc_local_port_t	*port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4498
	fc_packet_t	*pkt;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4499
	la_els_rnid_t	payload;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4500
	fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4501
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4502
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4503
	pd = pkt->pkt_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4504
	port = pd->pd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4505
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4506
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4507
	ASSERT(MUTEX_HELD(&pd->pd_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4508
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4509
	fp_els_init(cmd, port->fp_port_id.port_id, pd->pd_port_id.port_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4510
	    fp_rnid_intr, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4511
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4512
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4513
	pkt->pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4514
	pkt->pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4515
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4516
	payload.ls_code.ls_code = LA_ELS_RNID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4517
	payload.ls_code.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4518
	payload.data_format = flag;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4519
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4520
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4521
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4522
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4523
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4524
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4525
 * Initialize RLS ELS request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4526
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4527
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4528
fp_rls_init(fp_cmd_t *cmd, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4529
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4530
	fc_local_port_t	*port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4531
	fc_packet_t	*pkt;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4532
	la_els_rls_t	payload;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4533
	fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4534
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4535
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4536
	pd = pkt->pkt_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4537
	port = pd->pd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4538
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4539
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4540
	ASSERT(MUTEX_HELD(&pd->pd_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4541
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4542
	fp_els_init(cmd, port->fp_port_id.port_id, pd->pd_port_id.port_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4543
	    fp_rls_intr, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4544
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4545
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4546
	pkt->pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4547
	pkt->pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4548
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4549
	payload.ls_code.ls_code = LA_ELS_RLS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4550
	payload.ls_code.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4551
	payload.rls_portid = port->fp_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4552
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4553
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4554
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4555
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4556
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4557
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4558
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4559
 * Initialize an ADISC ELS request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4560
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4561
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4562
fp_adisc_init(fp_cmd_t *cmd, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4563
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4564
	fc_local_port_t *port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4565
	fc_packet_t	*pkt;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4566
	la_els_adisc_t	payload;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4567
	fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4568
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4569
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4570
	pd = pkt->pkt_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4571
	port = pd->pd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4572
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4573
	ASSERT(MUTEX_HELD(&pd->pd_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4574
	ASSERT(MUTEX_HELD(&pd->pd_port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4575
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4576
	fp_els_init(cmd, port->fp_port_id.port_id, pd->pd_port_id.port_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4577
	    fp_adisc_intr, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4578
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4579
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4580
	pkt->pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4581
	pkt->pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4582
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4583
	payload.ls_code.ls_code = LA_ELS_ADISC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4584
	payload.ls_code.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4585
	payload.nport_id = port->fp_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4586
	payload.port_wwn = port->fp_service_params.nport_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4587
	payload.node_wwn = port->fp_service_params.node_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4588
	payload.hard_addr = port->fp_hard_addr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4589
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4590
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4591
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4592
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4593
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4594
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4595
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4596
 * Send up a state change notification to ULPs.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4597
 * Spawns a call to fctl_ulp_statec_cb in a taskq thread.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4598
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4599
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4600
fp_ulp_statec_cb(fc_local_port_t *port, uint32_t state,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4601
    fc_portmap_t *changelist, uint32_t listlen, uint32_t alloc_len, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4602
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4603
	fc_port_clist_t		*clist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4604
	fc_remote_port_t	*pd;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4605
	int			count;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4606
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4607
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4608
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4609
	clist = kmem_zalloc(sizeof (*clist), sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4610
	if (clist == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4611
		kmem_free(changelist, alloc_len * sizeof (*changelist));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4612
		return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4613
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4614
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4615
	clist->clist_state = state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4616
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4617
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4618
	clist->clist_flags = port->fp_topology;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4619
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4620
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4621
	clist->clist_port = (opaque_t)port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4622
	clist->clist_len = listlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4623
	clist->clist_size = alloc_len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4624
	clist->clist_map = changelist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4625
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4626
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4627
	 * Bump the reference count of each fc_remote_port_t in this changelist.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4628
	 * This is necessary since these devices will be sitting in a taskq
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4629
	 * and referenced later.  When the state change notification is
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4630
	 * complete, the reference counts will be decremented.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4631
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4632
	for (count = 0; count < clist->clist_len; count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4633
		pd = clist->clist_map[count].map_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4634
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4635
		if (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4636
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4637
			ASSERT((pd->pd_ref_count >= 0) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4638
			    (pd->pd_aux_flags & PD_GIVEN_TO_ULPS));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4639
			pd->pd_ref_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4640
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4641
			if (clist->clist_map[count].map_state !=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4642
			    PORT_DEVICE_INVALID) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4643
				pd->pd_aux_flags |= PD_GIVEN_TO_ULPS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4644
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4645
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4646
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4647
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4648
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4649
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4650
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4651
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4652
	 * Sanity check for presence of OLD devices in the hash lists
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4653
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4654
	if (clist->clist_size) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4655
		ASSERT(clist->clist_map != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4656
		for (count = 0; count < clist->clist_len; count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4657
			if (clist->clist_map[count].map_state ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4658
			    PORT_DEVICE_INVALID) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4659
				la_wwn_t	pwwn;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4660
				fc_portid_t	d_id;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4661
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4662
				pd = clist->clist_map[count].map_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4663
				ASSERT(pd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4664
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4665
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4666
				pwwn = pd->pd_port_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4667
				d_id = pd->pd_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4668
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4669
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4670
				pd = fctl_get_remote_port_by_pwwn(port, &pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4671
				ASSERT(pd != clist->clist_map[count].map_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4672
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4673
				pd = fctl_get_remote_port_by_did(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4674
				    d_id.port_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4675
				ASSERT(pd != clist->clist_map[count].map_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4676
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4677
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4678
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4679
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4680
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4681
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4682
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4683
	if (state == FC_STATE_ONLINE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4684
		if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4685
			port->fp_soft_state &= ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4686
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4687
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4688
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4689
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4690
	(void) taskq_dispatch(port->fp_taskq, fctl_ulp_statec_cb,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4691
	    clist, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4692
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4693
	FP_TRACE(FP_NHEAD1(4, 0), "fp_ulp_statec fired; Port=%p,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4694
	    "state=%x, len=%d", port, state, listlen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4695
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4696
	return (FC_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4697
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4698
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4699
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4700
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4701
 * Send up a FC_STATE_DEVICE_CHANGE state notification to ULPs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4702
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4703
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4704
fp_ulp_devc_cb(fc_local_port_t *port, fc_portmap_t *changelist,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4705
    uint32_t listlen, uint32_t alloc_len, int sleep, int sync)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4706
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4707
	int		ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4708
	fc_port_clist_t *clist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4709
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4710
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4711
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4712
	clist = kmem_zalloc(sizeof (*clist), sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4713
	if (clist == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4714
		kmem_free(changelist, alloc_len * sizeof (*changelist));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4715
		return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4716
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4717
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4718
	clist->clist_state = FC_STATE_DEVICE_CHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4719
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4720
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4721
	clist->clist_flags = port->fp_topology;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4722
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4723
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4724
	clist->clist_port = (opaque_t)port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4725
	clist->clist_len = listlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4726
	clist->clist_size = alloc_len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4727
	clist->clist_map = changelist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4728
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4729
	/* Send sysevents for target state changes */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4730
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4731
	if (clist->clist_size) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4732
		int			count;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4733
		fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4734
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4735
		ASSERT(clist->clist_map != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4736
		for (count = 0; count < clist->clist_len; count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4737
			pd = clist->clist_map[count].map_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4738
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4739
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4740
			 * Bump reference counts on all fc_remote_port_t
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4741
			 * structs in this list.  We don't know when the task
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4742
			 * will fire, and we don't need these fc_remote_port_t
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4743
			 * structs going away behind our back.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4744
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4745
			if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4746
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4747
				ASSERT((pd->pd_ref_count >= 0) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4748
				    (pd->pd_aux_flags & PD_GIVEN_TO_ULPS));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4749
				pd->pd_ref_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4750
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4751
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4752
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4753
			if (clist->clist_map[count].map_state ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4754
			    PORT_DEVICE_VALID) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4755
				if (clist->clist_map[count].map_type ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4756
				    PORT_DEVICE_NEW) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4757
					/* Update our state change counter */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4758
					mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4759
					port->fp_last_change++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4760
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4761
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4762
					/* Additions */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4763
					fp_log_target_event(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4764
					    ESC_SUNFC_TARGET_ADD,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4765
					    clist->clist_map[count].map_pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4766
					    clist->clist_map[count].map_did.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4767
					    port_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4768
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4769
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4770
			} else if ((clist->clist_map[count].map_type ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4771
			    PORT_DEVICE_OLD) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4772
			    (clist->clist_map[count].map_state ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4773
			    PORT_DEVICE_INVALID)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4774
				/* Update our state change counter */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4775
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4776
				port->fp_last_change++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4777
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4778
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4779
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4780
				 * For removals, we don't decrement
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4781
				 * pd_ref_count until after the ULP's
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4782
				 * state change callback function has
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4783
				 * completed.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4784
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4785
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4786
				/* Removals */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4787
				fp_log_target_event(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4788
				    ESC_SUNFC_TARGET_REMOVE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4789
				    clist->clist_map[count].map_pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4790
				    clist->clist_map[count].map_did.port_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4791
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4792
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4793
			if (clist->clist_map[count].map_state !=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4794
			    PORT_DEVICE_INVALID) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4795
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4796
				 * Indicate that the ULPs are now aware of
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4797
				 * this device.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4798
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4799
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4800
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4801
				pd->pd_aux_flags |= PD_GIVEN_TO_ULPS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4802
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4803
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4804
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4805
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4806
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4807
			 * Sanity check for OLD devices in the hash lists
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4808
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4809
			if (pd && clist->clist_map[count].map_state ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4810
			    PORT_DEVICE_INVALID) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4811
				la_wwn_t	pwwn;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4812
				fc_portid_t	d_id;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4813
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4814
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4815
				pwwn = pd->pd_port_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4816
				d_id = pd->pd_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4817
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4818
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4819
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4820
				 * This overwrites the 'pd' local variable.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4821
				 * Beware of this if 'pd' ever gets
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4822
				 * referenced below this block.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4823
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4824
				pd = fctl_get_remote_port_by_pwwn(port, &pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4825
				ASSERT(pd != clist->clist_map[count].map_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4826
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4827
				pd = fctl_get_remote_port_by_did(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4828
				    d_id.port_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4829
				ASSERT(pd != clist->clist_map[count].map_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4830
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4831
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4832
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4833
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4834
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4835
	if (sync) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4836
		clist->clist_wait = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4837
		mutex_init(&clist->clist_mutex, NULL, MUTEX_DRIVER, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4838
		cv_init(&clist->clist_cv, NULL, CV_DRIVER, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4839
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4840
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4841
	ret = taskq_dispatch(port->fp_taskq, fctl_ulp_statec_cb, clist, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4842
	if (sync && ret) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4843
		mutex_enter(&clist->clist_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4844
		while (clist->clist_wait) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4845
			cv_wait(&clist->clist_cv, &clist->clist_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4846
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4847
		mutex_exit(&clist->clist_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4848
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4849
		mutex_destroy(&clist->clist_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4850
		cv_destroy(&clist->clist_cv);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4851
		kmem_free(clist, sizeof (*clist));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4852
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4853
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4854
	if (!ret) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4855
		FP_TRACE(FP_NHEAD1(4, 0), "fp_ulp_devc dispatch failed; "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4856
		    "port=%p", port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4857
		kmem_free(clist->clist_map,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4858
		    sizeof (*(clist->clist_map)) * clist->clist_size);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4859
		kmem_free(clist, sizeof (*clist));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4860
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4861
		FP_TRACE(FP_NHEAD1(4, 0), "fp_ulp_devc fired; port=%p, len=%d",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4862
		    port, listlen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4863
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4864
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4865
	return (FC_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4866
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4867
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4868
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4869
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4870
 * Perform PLOGI to the group of devices for ULPs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4871
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4872
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4873
fp_plogi_group(fc_local_port_t *port, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4874
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4875
	int			offline;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4876
	int			count;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4877
	int			rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4878
	uint32_t		listlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4879
	uint32_t		done;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4880
	uint32_t		d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4881
	fc_remote_node_t	*node;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4882
	fc_remote_port_t	*pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4883
	fc_remote_port_t	*tmp_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4884
	fc_packet_t		*ulp_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4885
	la_els_logi_t		*els_data;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4886
	ls_code_t		ls_code;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4887
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4888
	FP_TRACE(FP_NHEAD1(1, 0), "fp_plogi_group begin; port=%p, job=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4889
	    port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4890
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4891
	done = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4892
	listlen = job->job_ulp_listlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4893
	job->job_counter = job->job_ulp_listlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4894
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4895
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4896
	offline = (port->fp_statec_busy ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4897
	    FC_PORT_STATE_MASK(port->fp_state) == FC_STATE_OFFLINE) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4898
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4899
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4900
	for (count = 0; count < listlen; count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4901
		ASSERT(job->job_ulp_pkts[count]->pkt_rsplen >=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4902
		    sizeof (la_els_logi_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4903
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4904
		ulp_pkt = job->job_ulp_pkts[count];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4905
		pd = ulp_pkt->pkt_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4906
		d_id = ulp_pkt->pkt_cmd_fhdr.d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4907
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4908
		if (offline) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4909
			done++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4910
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4911
			ulp_pkt->pkt_state = FC_PKT_PORT_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4912
			ulp_pkt->pkt_reason = FC_REASON_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4913
			ulp_pkt->pkt_pd = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4914
			ulp_pkt->pkt_comp(ulp_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4915
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4916
			job->job_ulp_pkts[count] = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4917
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4918
			fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4919
			continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4920
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4921
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4922
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4923
			pd = fctl_get_remote_port_by_did(port, d_id);
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4924
			if (pd == NULL) {
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  4925
				/* reset later */
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4926
				ulp_pkt->pkt_state = FC_PKT_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4927
				continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4928
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4929
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4930
			if (pd->pd_flags == PD_ELS_IN_PROGRESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4931
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4932
				ulp_pkt->pkt_state = FC_PKT_ELS_IN_PROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4933
				done++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4934
				ulp_pkt->pkt_comp(ulp_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4935
				job->job_ulp_pkts[count] = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4936
				fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4937
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4938
				ulp_pkt->pkt_state = FC_PKT_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4939
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4940
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4941
			continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4942
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4943
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4944
		switch (ulp_pkt->pkt_state) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4945
		case FC_PKT_ELS_IN_PROGRESS:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4946
			ulp_pkt->pkt_reason = FC_REASON_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4947
			/* FALLTHRU */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4948
		case FC_PKT_LOCAL_RJT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4949
			done++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4950
			ulp_pkt->pkt_comp(ulp_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4951
			job->job_ulp_pkts[count] = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4952
			fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4953
			continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4954
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4955
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4956
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4957
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4958
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4959
		 * Validate the pd corresponding to the d_id passed
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4960
		 * by the ULPs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4961
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4962
		tmp_pd = fctl_get_remote_port_by_did(port, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4963
		if ((tmp_pd == NULL) || (pd != tmp_pd)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4964
			done++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4965
			ulp_pkt->pkt_state = FC_PKT_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4966
			ulp_pkt->pkt_reason = FC_REASON_NO_CONNECTION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4967
			ulp_pkt->pkt_pd = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4968
			ulp_pkt->pkt_comp(ulp_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4969
			job->job_ulp_pkts[count] = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4970
			fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4971
			continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4972
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4973
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4974
		FP_TRACE(FP_NHEAD1(3, 0), "fp_plogi_group contd; "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4975
		    "port=%p, pd=%p", port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4976
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4977
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4978
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4979
		if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4980
			done++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4981
			els_data = (la_els_logi_t *)ulp_pkt->pkt_resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4982
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4983
			ls_code.ls_code = LA_ELS_ACC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4984
			ls_code.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4985
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4986
			FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4987
			    (uint8_t *)&ls_code, (uint8_t *)&els_data->ls_code,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4988
			    sizeof (ls_code_t), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4989
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4990
			FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4991
			    (uint8_t *)&pd->pd_csp,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4992
			    (uint8_t *)&els_data->common_service,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4993
			    sizeof (pd->pd_csp), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4994
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  4995
			FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4996
			    (uint8_t *)&pd->pd_port_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4997
			    (uint8_t *)&els_data->nport_ww_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4998
			    sizeof (pd->pd_port_name), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  4999
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5000
			FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5001
			    (uint8_t *)&pd->pd_clsp1,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5002
			    (uint8_t *)&els_data->class_1,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5003
			    sizeof (pd->pd_clsp1), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5004
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5005
			FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5006
			    (uint8_t *)&pd->pd_clsp2,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5007
			    (uint8_t *)&els_data->class_2,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5008
			    sizeof (pd->pd_clsp2), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5009
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5010
			FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5011
			    (uint8_t *)&pd->pd_clsp3,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5012
			    (uint8_t *)&els_data->class_3,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5013
			    sizeof (pd->pd_clsp3), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5014
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5015
			node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5016
			pd->pd_login_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5017
			pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5018
			ulp_pkt->pkt_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5019
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5020
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5021
			mutex_enter(&node->fd_mutex);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5022
			FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5023
			    (uint8_t *)&node->fd_node_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5024
			    (uint8_t *)(&els_data->node_ww_name),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5025
			    sizeof (node->fd_node_name), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5026
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5027
			FC_SET_CMD(pd->pd_port, ulp_pkt->pkt_resp_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5028
			    (uint8_t *)&node->fd_vv,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5029
			    (uint8_t *)(&els_data->vendor_version),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5030
			    sizeof (node->fd_vv), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5031
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5032
			mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5033
			ulp_pkt->pkt_state = FC_PKT_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5034
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5035
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5036
			ulp_pkt->pkt_state = FC_PKT_FAILURE; /* reset later */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5037
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5038
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5039
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5040
		if (ulp_pkt->pkt_state != FC_PKT_FAILURE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5041
			ulp_pkt->pkt_comp(ulp_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5042
			job->job_ulp_pkts[count] = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5043
			fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5044
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5045
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5046
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5047
	if (done == listlen) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5048
		fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5049
		fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5050
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5051
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5052
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5053
	job->job_counter = listlen - done;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5054
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5055
	for (count = 0; count < listlen; count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5056
		int cmd_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5057
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5058
		if ((ulp_pkt = job->job_ulp_pkts[count]) == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5059
			continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5060
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5061
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5062
		ASSERT(ulp_pkt->pkt_state == FC_PKT_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5063
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5064
		cmd_flags = FP_CMD_PLOGI_RETAIN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5065
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5066
		d_id = ulp_pkt->pkt_cmd_fhdr.d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5067
		ASSERT(d_id != 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5068
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5069
		pd = fctl_get_remote_port_by_did(port, d_id);
8201
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5070
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5071
		/*
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5072
		 * We need to properly adjust the port device
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5073
		 * reference counter before we assign the pd
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5074
		 * to the ULP packets port device pointer.
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5075
		 */
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5076
		if (pd != NULL && ulp_pkt->pkt_pd == NULL) {
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5077
			mutex_enter(&pd->pd_mutex);
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5078
			pd->pd_ref_count++;
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5079
			mutex_exit(&pd->pd_mutex);
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5080
			FP_TRACE(FP_NHEAD1(3, 0),
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5081
			    "fp_plogi_group: DID = 0x%x using new pd %p \
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5082
			    old pd NULL\n", d_id, pd);
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5083
		} else if (pd != NULL && ulp_pkt->pkt_pd != NULL &&
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5084
		    ulp_pkt->pkt_pd != pd) {
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5085
			mutex_enter(&pd->pd_mutex);
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5086
			pd->pd_ref_count++;
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5087
			mutex_exit(&pd->pd_mutex);
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5088
			mutex_enter(&ulp_pkt->pkt_pd->pd_mutex);
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5089
			ulp_pkt->pkt_pd->pd_ref_count--;
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5090
			mutex_exit(&ulp_pkt->pkt_pd->pd_mutex);
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5091
			FP_TRACE(FP_NHEAD1(3, 0),
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5092
			    "fp_plogi_group: DID = 0x%x pkt_pd %p != pd %p\n",
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5093
			    d_id, ulp_pkt->pkt_pd, pd);
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5094
		} else if (pd == NULL && ulp_pkt->pkt_pd != NULL) {
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5095
			mutex_enter(&ulp_pkt->pkt_pd->pd_mutex);
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5096
			ulp_pkt->pkt_pd->pd_ref_count--;
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5097
			mutex_exit(&ulp_pkt->pkt_pd->pd_mutex);
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5098
			FP_TRACE(FP_NHEAD1(3, 0),
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5099
			    "fp_plogi_group: DID = 0x%x pd is NULL and \
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5100
			    pkt_pd = %p\n", d_id, ulp_pkt->pkt_pd);
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5101
		}
dc6d67c22e5b 6566262 mutex_enter: bad mutex, lp=600109b1540 owner=2a1003b7cc0
Zach Kissel <Zachary.Kissel@Sun.COM>
parents: 8051
diff changeset
  5102
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5103
		ulp_pkt->pkt_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5104
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5105
		if (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5106
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5107
			d_id = pd->pd_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5108
			pd->pd_flags = PD_ELS_IN_PROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5109
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5110
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5111
			d_id = ulp_pkt->pkt_cmd_fhdr.d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5112
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5113
			pd = fctl_get_remote_port_by_did(port, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5114
			ASSERT(pd == NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5115
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5116
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5117
			 * In the Fabric topology, use NS to create
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5118
			 * port device, and if that fails still try
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5119
			 * with PLOGI - which will make yet another
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5120
			 * attempt to create after successful PLOGI
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5121
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5122
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5123
			if (FC_IS_TOP_SWITCH(port->fp_topology)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5124
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5125
				pd = fp_create_remote_port_by_ns(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5126
				    d_id, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5127
				if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5128
					cmd_flags |= FP_CMD_DELDEV_ON_ERROR;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5129
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5130
					mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5131
					pd->pd_flags = PD_ELS_IN_PROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5132
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5133
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5134
					FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5135
					    "fp_plogi_group;"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5136
					    " NS created PD port=%p, job=%p,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5137
					    " pd=%p", port, job, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5138
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5139
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5140
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5141
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5142
			if ((ulp_pkt->pkt_pd == NULL) && (pd != NULL)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5143
				FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5144
				    "fp_plogi_group;"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5145
				    "ulp_pkt's pd is NULL, get a pd %p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5146
				    pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5147
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5148
				pd->pd_ref_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5149
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5150
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5151
			ulp_pkt->pkt_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5152
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5153
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5154
		rval = fp_port_login(port, d_id, job, cmd_flags,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5155
		    KM_SLEEP, pd, ulp_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5156
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5157
		if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5158
			continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5159
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5160
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5161
		if (rval == FC_STATEC_BUSY) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5162
			ulp_pkt->pkt_state = FC_PKT_PORT_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5163
			ulp_pkt->pkt_reason = FC_REASON_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5164
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5165
			ulp_pkt->pkt_state = FC_PKT_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5166
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5167
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5168
		if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5169
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5170
			pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5171
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5172
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5173
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5174
		if (cmd_flags & FP_CMD_DELDEV_ON_ERROR) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5175
			ASSERT(pd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5176
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5177
			FP_TRACE(FP_NHEAD1(3, 0), "fp_plogi_group: NS created,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5178
			    " PD removed; port=%p, job=%p", port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5179
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5180
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5181
			pd->pd_ref_count--;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5182
			node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5183
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5184
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5185
			ASSERT(node != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5186
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5187
			if (fctl_destroy_remote_port(port, pd) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5188
				fctl_destroy_remote_node(node);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5189
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5190
			ulp_pkt->pkt_pd = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5191
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5192
		ulp_pkt->pkt_comp(ulp_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5193
		fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5194
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5195
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5196
	fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5197
	fctl_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5198
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5199
	FP_TRACE(FP_NHEAD1(1, 0), "fp_plogi_group end: port=%p, job=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5200
	    port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5201
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5202
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5203
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5204
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5205
 * Name server request initialization
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5206
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5207
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5208
fp_ns_init(fc_local_port_t *port, job_request_t *job, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5209
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5210
	int rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5211
	int count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5212
	int size;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5213
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5214
	ASSERT((job->job_flags & JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5215
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5216
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5217
	job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5218
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5219
	rval = fp_port_login(port, 0xFFFFFC, job, FP_CMD_PLOGI_RETAIN,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5220
	    KM_SLEEP, NULL, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5221
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5222
	if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5223
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5224
		port->fp_topology = FC_TOP_NO_NS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5225
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5226
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5227
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5228
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5229
	fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5230
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5231
	if (job->job_result != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5232
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5233
		port->fp_topology = FC_TOP_NO_NS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5234
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5235
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5236
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5237
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5238
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5239
	 * At this time, we'll do NS registration for objects in the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5240
	 * ns_reg_cmds (see top of this file) array.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5241
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5242
	 * Each time a ULP module registers with the transport, the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5243
	 * appropriate fc4 bit is set fc4 types and registered with
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5244
	 * the NS for this support. Also, ULPs and FC admin utilities
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5245
	 * may do registration for objects like IP address, symbolic
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5246
	 * port/node name, Initial process associator at run time.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5247
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5248
	size = sizeof (ns_reg_cmds) / sizeof (ns_reg_cmds[0]);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5249
	job->job_counter = size;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5250
	job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5251
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5252
	for (count = 0; count < size; count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5253
		if (fp_ns_reg(port, NULL, ns_reg_cmds[count],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5254
		    job, 0, sleep) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5255
			fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5256
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5257
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5258
	if (size) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5259
		fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5260
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5261
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5262
	job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5263
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5264
	(void) fp_ns_get_devcount(port, job, 0, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5265
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5266
	if (port->fp_dev_count < FP_MAX_DEVICES) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5267
		(void) fp_ns_get_devcount(port, job, 1, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5268
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5269
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5270
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5271
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5272
	if (fp_ns_scr(port, job, FC_SCR_FULL_REGISTRATION,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5273
	    sleep) == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5274
		fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5275
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5276
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5277
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5278
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5279
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5280
 * Name server finish:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5281
 *	Unregister for RSCNs
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5282
 *	Unregister all the host port objects in the Name Server
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5283
 *	Perform LOGO with the NS;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5284
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5285
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5286
fp_ns_fini(fc_local_port_t *port, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5287
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5288
	fp_cmd_t	*cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5289
	uchar_t		class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5290
	uint32_t	s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5291
	fc_packet_t	*pkt;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5292
	la_els_logo_t	payload;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5293
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5294
	ASSERT((job->job_flags & JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5295
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5296
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5297
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5298
	if (fp_ns_scr(port, job, FC_SCR_CLEAR_REGISTRATION, KM_SLEEP) !=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5299
	    FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5300
		fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5301
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5302
	fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5303
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5304
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5305
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5306
	if (fp_ns_reg(port, NULL, NS_DA_ID, job, 0, KM_SLEEP) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5307
		fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5308
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5309
	fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5310
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5311
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5312
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5313
	cmd = fp_alloc_pkt(port, sizeof (la_els_logo_t),
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5314
	    FP_PORT_IDENTIFIER_LEN, KM_SLEEP, NULL);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5315
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5316
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5317
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5318
	class = port->fp_ns_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5319
	s_id = port->fp_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5320
	payload.nport_id = port->fp_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5321
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5322
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5323
	cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5324
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5325
	cmd->cmd_flags = FP_CMD_PLOGI_DONT_CARE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5326
	cmd->cmd_retry_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5327
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5328
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5329
	if (port->fp_npiv_type == FC_NPIV_PORT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5330
		fp_els_init(cmd, s_id, 0xFFFFFE, fp_logo_intr, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5331
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5332
		fp_els_init(cmd, s_id, 0xFFFFFC, fp_logo_intr, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5333
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5334
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5335
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5336
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5337
	payload.ls_code.ls_code = LA_ELS_LOGO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5338
	payload.ls_code.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5339
	payload.nport_ww_name = port->fp_service_params.nport_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5340
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5341
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5342
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5343
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5344
	if (fp_sendcmd(port, cmd, port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5345
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5346
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5347
	fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5348
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5349
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5350
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5351
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5352
 * NS Registration function.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5353
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5354
 *	It should be seriously noted that FC-GS-2 currently doesn't support
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5355
 *	an Object Registration by a D_ID other than the owner of the object.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5356
 *	What we are aiming at currently is to at least allow Symbolic Node/Port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5357
 *	Name registration for any N_Port Identifier by the host software.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5358
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5359
 *	Anyway, if the second argument (fc_remote_port_t *) is NULL, this
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5360
 *	function treats the request as Host NS Object.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5361
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5362
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5363
fp_ns_reg(fc_local_port_t *port, fc_remote_port_t *pd, uint16_t cmd_code,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5364
    job_request_t *job, int polled, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5365
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5366
	int		rval;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5367
	fc_portid_t	s_id;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5368
	fc_packet_t	*pkt;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5369
	fp_cmd_t	*cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5370
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5371
	if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5372
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5373
		s_id = port->fp_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5374
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5375
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5376
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5377
		s_id = pd->pd_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5378
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5379
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5380
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5381
	if (polled) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5382
		job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5383
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5384
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5385
	switch (cmd_code) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5386
	case NS_RPN_ID:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5387
	case NS_RNN_ID: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5388
		ns_rxn_req_t rxn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5389
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5390
		cmd = fp_alloc_pkt(port, sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5391
		    sizeof (ns_rxn_req_t), sizeof (fc_reg_resp_t), sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5392
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5393
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5394
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5395
		fp_ct_init(port, cmd, NULL, cmd_code, NULL, 0, 0, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5396
		pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5397
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5398
		if (pd == NULL) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5399
			rxn.rxn_xname = ((cmd_code == NS_RPN_ID) ?
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5400
			    (port->fp_service_params.nport_ww_name) :
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5401
			    (port->fp_service_params.node_ww_name));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5402
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5403
			if (cmd_code == NS_RPN_ID) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5404
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5405
				rxn.rxn_xname = pd->pd_port_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5406
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5407
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5408
				fc_remote_node_t *node;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5409
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5410
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5411
				node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5412
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5413
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5414
				mutex_enter(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5415
				rxn.rxn_xname = node->fd_node_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5416
				mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5417
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5418
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5419
		rxn.rxn_port_id = s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5420
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5421
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&rxn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5422
		    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t)),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5423
		    sizeof (rxn), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5424
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5425
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5426
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5427
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5428
	case NS_RCS_ID: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5429
		ns_rcos_t rcos;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5430
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5431
		cmd = fp_alloc_pkt(port, sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5432
		    sizeof (ns_rcos_t), sizeof (fc_reg_resp_t), sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5433
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5434
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5435
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5436
		fp_ct_init(port, cmd, NULL, cmd_code, NULL, 0, 0, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5437
		pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5438
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5439
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5440
			rcos.rcos_cos = port->fp_cos;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5441
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5442
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5443
			rcos.rcos_cos = pd->pd_cos;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5444
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5445
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5446
		rcos.rcos_port_id = s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5447
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5448
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&rcos,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5449
		    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t)),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5450
		    sizeof (rcos), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5451
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5452
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5453
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5454
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5455
	case NS_RFT_ID: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5456
		ns_rfc_type_t rfc;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5457
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5458
		cmd = fp_alloc_pkt(port, sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5459
		    sizeof (ns_rfc_type_t), sizeof (fc_reg_resp_t), sleep,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5460
		    NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5461
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5462
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5463
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5464
		fp_ct_init(port, cmd, NULL, cmd_code, NULL, 0, 0, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5465
		pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5466
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5467
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5468
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5469
			bcopy(port->fp_fc4_types, rfc.rfc_types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5470
			    sizeof (port->fp_fc4_types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5471
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5472
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5473
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5474
			bcopy(pd->pd_fc4types, rfc.rfc_types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5475
			    sizeof (pd->pd_fc4types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5476
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5477
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5478
		rfc.rfc_port_id = s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5479
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5480
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&rfc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5481
		    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t)),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5482
		    sizeof (rfc), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5483
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5484
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5485
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5486
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5487
	case NS_RSPN_ID: {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5488
		uchar_t		name_len;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5489
		int		pl_size;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5490
		fc_portid_t	spn;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5491
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5492
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5493
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5494
			name_len = port->fp_sym_port_namelen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5495
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5496
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5497
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5498
			name_len = pd->pd_spn_len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5499
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5500
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5501
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5502
		pl_size = sizeof (fc_portid_t) + name_len + 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5503
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5504
		cmd = fp_alloc_pkt(port, sizeof (fc_ct_header_t) + pl_size,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5505
		    sizeof (fc_reg_resp_t), sleep, NULL);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5506
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5507
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5508
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5509
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5510
		fp_ct_init(port, cmd, NULL, cmd_code, NULL, 0, 0, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5511
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5512
		pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5513
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5514
		spn = s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5515
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5516
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&spn, (uint8_t *)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5517
		    (pkt->pkt_cmd + sizeof (fc_ct_header_t)), sizeof (spn),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5518
		    DDI_DEV_AUTOINCR);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5519
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&name_len,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5520
		    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5521
		    + sizeof (fc_portid_t)), 1, DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5522
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5523
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5524
			mutex_enter(&port->fp_mutex);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5525
			FC_SET_CMD(port, pkt->pkt_cmd_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5526
			    (uint8_t *)port->fp_sym_port_name, (uint8_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5527
			    (pkt->pkt_cmd + sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5528
			    sizeof (spn) + 1), name_len, DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5529
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5530
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5531
			mutex_enter(&pd->pd_mutex);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5532
			FC_SET_CMD(port, pkt->pkt_cmd_acc,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5533
			    (uint8_t *)pd->pd_spn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5534
			    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5535
			    sizeof (spn) + 1), name_len, DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5536
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5537
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5538
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5539
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5540
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5541
	case NS_RPT_ID: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5542
		ns_rpt_t rpt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5543
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5544
		cmd = fp_alloc_pkt(port, sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5545
		    sizeof (ns_rpt_t), sizeof (fc_reg_resp_t), sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5546
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5547
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5548
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5549
		fp_ct_init(port, cmd, NULL, cmd_code, NULL, 0, 0, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5550
		pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5551
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5552
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5553
			rpt.rpt_type = port->fp_port_type;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5554
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5555
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5556
			rpt.rpt_type = pd->pd_porttype;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5557
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5558
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5559
		rpt.rpt_port_id = s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5560
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5561
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&rpt,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5562
		    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t)),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5563
		    sizeof (rpt), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5564
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5565
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5566
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5567
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5568
	case NS_RIP_NN: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5569
		ns_rip_t rip;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5570
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5571
		cmd = fp_alloc_pkt(port, sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5572
		    sizeof (ns_rip_t), sizeof (fc_reg_resp_t), sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5573
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5574
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5575
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5576
		fp_ct_init(port, cmd, NULL, cmd_code, NULL, 0, 0, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5577
		pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5578
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5579
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5580
			rip.rip_node_name =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5581
			    port->fp_service_params.node_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5582
			bcopy(port->fp_ip_addr, rip.rip_ip_addr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5583
			    sizeof (port->fp_ip_addr));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5584
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5585
			fc_remote_node_t *node;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5586
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5587
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5588
			 * The most correct implementation should have the IP
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5589
			 * address in the fc_remote_node_t structure; I believe
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5590
			 * Node WWN and IP address should have one to one
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5591
			 * correlation (but guess what this is changing in
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5592
			 * FC-GS-2 latest draft)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5593
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5594
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5595
			node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5596
			bcopy(pd->pd_ip_addr, rip.rip_ip_addr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5597
			    sizeof (pd->pd_ip_addr));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5598
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5599
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5600
			mutex_enter(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5601
			rip.rip_node_name = node->fd_node_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5602
			mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5603
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5604
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5605
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&rip,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5606
		    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t)),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5607
		    sizeof (rip), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5608
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5609
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5610
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5611
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5612
	case NS_RIPA_NN: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5613
		ns_ipa_t ipa;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5614
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5615
		cmd = fp_alloc_pkt(port, sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5616
		    sizeof (ns_ipa_t), sizeof (fc_reg_resp_t), sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5617
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5618
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5619
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5620
		fp_ct_init(port, cmd, NULL, cmd_code, NULL, 0, 0, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5621
		pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5622
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5623
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5624
			ipa.ipa_node_name =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5625
			    port->fp_service_params.node_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5626
			bcopy(port->fp_ipa, ipa.ipa_value,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5627
			    sizeof (port->fp_ipa));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5628
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5629
			fc_remote_node_t *node;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5630
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5631
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5632
			node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5633
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5634
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5635
			mutex_enter(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5636
			ipa.ipa_node_name = node->fd_node_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5637
			bcopy(node->fd_ipa, ipa.ipa_value,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5638
			    sizeof (node->fd_ipa));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5639
			mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5640
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5641
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5642
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&ipa,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5643
		    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t)),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5644
		    sizeof (ipa), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5645
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5646
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5647
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5648
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5649
	case NS_RSNN_NN: {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5650
		uchar_t			name_len;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5651
		int			pl_size;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5652
		la_wwn_t		snn;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5653
		fc_remote_node_t	*node = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5654
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5655
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5656
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5657
			name_len = port->fp_sym_node_namelen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5658
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5659
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5660
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5661
			node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5662
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5663
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5664
			mutex_enter(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5665
			name_len = node->fd_snn_len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5666
			mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5667
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5668
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5669
		pl_size = sizeof (la_wwn_t) + name_len + 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5670
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5671
		cmd = fp_alloc_pkt(port, sizeof (fc_ct_header_t) +
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5672
		    pl_size, sizeof (fc_reg_resp_t), sleep, NULL);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5673
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5674
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5675
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5676
		fp_ct_init(port, cmd, NULL, cmd_code, NULL, 0, 0, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5677
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5678
		pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5679
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5680
		bcopy(&port->fp_service_params.node_ww_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5681
		    &snn, sizeof (la_wwn_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5682
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5683
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5684
			mutex_enter(&port->fp_mutex);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5685
			FC_SET_CMD(port, pkt->pkt_cmd_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5686
			    (uint8_t *)port->fp_sym_node_name, (uint8_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5687
			    (pkt->pkt_cmd + sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5688
			    sizeof (snn) + 1), name_len, DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5689
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5690
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5691
			ASSERT(node != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5692
			mutex_enter(&node->fd_mutex);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5693
			FC_SET_CMD(port, pkt->pkt_cmd_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5694
			    (uint8_t *)node->fd_snn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5695
			    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5696
			    sizeof (snn) + 1), name_len, DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5697
			mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5698
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5699
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5700
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&snn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5701
		    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t)),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5702
		    sizeof (snn), DDI_DEV_AUTOINCR);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5703
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&name_len,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5704
		    (uint8_t *)(pkt->pkt_cmd
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5705
		    + sizeof (fc_ct_header_t) + sizeof (snn)),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5706
		    1, DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5707
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5708
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5709
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5710
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5711
	case NS_DA_ID: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5712
		ns_remall_t rall;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5713
		char tmp[4] = {0};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5714
		char *ptr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5715
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5716
		cmd = fp_alloc_pkt(port, sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5717
		    sizeof (ns_remall_t), sizeof (fc_reg_resp_t), sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5718
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5719
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5720
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5721
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5722
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5723
		fp_ct_init(port, cmd, NULL, cmd_code, NULL, 0, 0, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5724
		pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5725
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5726
		ptr = (char *)(&s_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5727
		tmp[3] = *ptr++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5728
		tmp[2] = *ptr++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5729
		tmp[1] = *ptr++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5730
		tmp[0] = *ptr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5731
#if defined(_BIT_FIELDS_LTOH)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5732
		bcopy((caddr_t)tmp, (caddr_t)(&rall.rem_port_id), 4);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5733
#else
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5734
		rall.rem_port_id = s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5735
#endif
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5736
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&rall,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5737
		    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t)),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5738
		    sizeof (rall), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5739
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5740
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5741
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5742
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5743
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5744
		return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5745
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5746
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5747
	rval = fp_sendcmd(port, cmd, port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5748
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5749
	if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5750
		job->job_result = rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5751
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5752
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5753
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5754
	if (polled) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5755
		ASSERT((job->job_flags & JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5756
		fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5757
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5758
		rval = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5759
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5760
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5761
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5762
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5763
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5764
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5765
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5766
 * Common interrupt handler
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5767
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5768
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5769
fp_common_intr(fc_packet_t *pkt, int iodone)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5770
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5771
	int		rval = FC_FAILURE;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5772
	fp_cmd_t	*cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5773
	fc_local_port_t	*port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5774
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5775
	cmd = pkt->pkt_ulp_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5776
	port = cmd->cmd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5777
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5778
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5779
	 * Fail fast the upper layer requests if
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5780
	 * a state change has occurred amidst.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5781
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5782
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5783
	if (cmd->cmd_ulp_pkt != NULL && port->fp_statec_busy) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5784
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5785
		cmd->cmd_ulp_pkt->pkt_state = FC_PKT_PORT_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5786
		cmd->cmd_ulp_pkt->pkt_reason = FC_REASON_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5787
	} else if (!(port->fp_soft_state &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5788
	    (FP_SOFT_IN_DETACH | FP_DETACH_INPROGRESS))) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5789
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5790
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5791
		switch (pkt->pkt_state) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5792
		case FC_PKT_LOCAL_BSY:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5793
		case FC_PKT_FABRIC_BSY:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5794
		case FC_PKT_NPORT_BSY:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5795
		case FC_PKT_TIMEOUT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5796
			cmd->cmd_retry_interval = (pkt->pkt_state ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5797
			    FC_PKT_TIMEOUT) ? 0 : fp_retry_delay;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5798
			rval = fp_retry_cmd(pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5799
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5800
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5801
		case FC_PKT_FABRIC_RJT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5802
		case FC_PKT_NPORT_RJT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5803
		case FC_PKT_LOCAL_RJT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5804
		case FC_PKT_LS_RJT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5805
		case FC_PKT_FS_RJT:
8051
939c256309b2 6739576 PLOGI is not retried when busy response is returned
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 7836
diff changeset
  5806
		case FC_PKT_BA_RJT:
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5807
			rval = fp_handle_reject(pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5808
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5809
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5810
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5811
			if (pkt->pkt_resp_resid) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5812
				cmd->cmd_retry_interval = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5813
				rval = fp_retry_cmd(pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5814
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5815
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5816
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5817
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5818
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5819
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5820
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5821
	if (rval != FC_SUCCESS && iodone) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5822
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5823
		rval = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5824
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5825
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5826
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5827
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5828
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5829
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5830
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5831
 * Some not so long winding theory on point to point topology:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5832
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5833
 *	In the ACC payload, if the D_ID is ZERO and the common service
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5834
 *	parameters indicate N_Port, then the topology is POINT TO POINT.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5835
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5836
 *	In a point to point topology with an N_Port, during Fabric Login,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5837
 *	the destination N_Port will check with our WWN and decide if it
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5838
 *	needs to issue PLOGI or not. That means, FLOGI could potentially
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5839
 *	trigger an unsolicited PLOGI from an N_Port. The Unsolicited
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5840
 *	PLOGI creates the device handles.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5841
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5842
 *	Assuming that the host port WWN is greater than the other N_Port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5843
 *	WWN, then we become the master (be aware that this isn't the word
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5844
 *	used in the FC standards) and initiate the PLOGI.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5845
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5846
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5847
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5848
fp_flogi_intr(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5849
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5850
	int			state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5851
	int			f_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5852
	uint32_t		s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5853
	uint32_t		d_id;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5854
	fp_cmd_t		*cmd;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5855
	fc_local_port_t		*port;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5856
	la_wwn_t		*swwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5857
	la_wwn_t		dwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5858
	la_wwn_t		nwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5859
	fc_remote_port_t	*pd;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5860
	la_els_logi_t		*acc;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5861
	com_svc_t		csp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5862
	ls_code_t		resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5863
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5864
	cmd = pkt->pkt_ulp_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5865
	port = cmd->cmd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5866
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5867
	mutex_enter(&port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5868
	port->fp_out_fpcmds--;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5869
	mutex_exit(&port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5870
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5871
	FP_TRACE(FP_NHEAD1(1, 0), "fp_flogi_intr; port=%p, pkt=%p, state=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5872
	    port, pkt, pkt->pkt_state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5873
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5874
	if (FP_IS_PKT_ERROR(pkt)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5875
		(void) fp_common_intr(pkt, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5876
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5877
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5878
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5879
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5880
	 * Currently, we don't need to swap bytes here because qlc is faking the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5881
	 * response for us and so endianness is getting taken care of. But we
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5882
	 * have to fix this and generalize this at some point
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5883
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5884
	acc = (la_els_logi_t *)pkt->pkt_resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5885
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5886
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&resp, (uint8_t *)acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5887
	    sizeof (resp), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5888
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5889
	ASSERT(resp.ls_code == LA_ELS_ACC);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5890
	if (resp.ls_code != LA_ELS_ACC) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5891
		(void) fp_common_intr(pkt, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5892
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5893
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5894
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5895
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&csp,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5896
	    (uint8_t *)&acc->common_service, sizeof (csp), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5897
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5898
	f_port = FP_IS_F_PORT(csp.cmn_features) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5899
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5900
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5901
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5902
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5903
	state = FC_PORT_STATE_MASK(port->fp_state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5904
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5905
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5906
	if (f_port == 0) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5907
		if (state != FC_STATE_LOOP) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5908
			swwn = &port->fp_service_params.nport_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5909
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5910
			FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&dwwn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5911
			    (uint8_t *)&acc->nport_ww_name, sizeof (la_wwn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5912
			    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5913
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5914
			FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&nwwn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5915
			    (uint8_t *)&acc->node_ww_name, sizeof (la_wwn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5916
			    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5917
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5918
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5919
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5920
			port->fp_topology = FC_TOP_PT_PT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5921
			port->fp_total_devices = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5922
			if (fctl_wwn_cmp(swwn, &dwwn) >= 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5923
				port->fp_ptpt_master = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5924
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5925
				 * Let us choose 'X' as S_ID and 'Y'
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5926
				 * as D_ID and that'll work; hopefully
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5927
				 * If not, it will get changed.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5928
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5929
				s_id = port->fp_instance + FP_DEFAULT_SID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5930
				d_id = port->fp_instance + FP_DEFAULT_DID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5931
				port->fp_port_id.port_id = s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5932
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5933
10107
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
  5934
				FP_TRACE(FP_NHEAD1(1, 0), "fp_flogi_intr: fp %x"
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
  5935
				    "pd %x", port->fp_port_id.port_id, d_id);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5936
				pd = fctl_create_remote_port(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5937
				    &nwwn, &dwwn, d_id, PD_PLOGI_INITIATOR,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5938
				    KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5939
				if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5940
					fp_printf(port, CE_NOTE, FP_LOG_ONLY,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5941
					    0, NULL, "couldn't create device"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5942
					    " d_id=%X", d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5943
					fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5944
					return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5945
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5946
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5947
				cmd->cmd_pkt.pkt_tran_flags =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5948
				    pkt->pkt_tran_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5949
				cmd->cmd_pkt.pkt_tran_type = pkt->pkt_tran_type;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5950
				cmd->cmd_flags = FP_CMD_PLOGI_RETAIN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5951
				cmd->cmd_retry_count = fp_retry_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5952
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5953
				fp_xlogi_init(port, cmd, s_id, d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5954
				    fp_plogi_intr, cmd->cmd_job, LA_ELS_PLOGI);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5955
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5956
				(&cmd->cmd_pkt)->pkt_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5957
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5958
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5959
				 * We've just created this fc_remote_port_t, and
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5960
				 * we're about to use it to send a PLOGI, so
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  5961
				 * bump the reference count right now.	When
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5962
				 * the packet is freed, the reference count will
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5963
				 * be decremented.  The ULP may also start using
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5964
				 * it, so mark it as given away as well.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5965
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5966
				pd->pd_ref_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5967
				pd->pd_aux_flags |= PD_GIVEN_TO_ULPS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5968
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5969
				if (fp_sendcmd(port, cmd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5970
				    port->fp_fca_handle) == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5971
					return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5972
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5973
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5974
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5975
				 * The device handles will be created when the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5976
				 * unsolicited PLOGI is completed successfully
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5977
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5978
				port->fp_ptpt_master = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5979
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5980
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5981
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5982
		pkt->pkt_state = FC_PKT_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5983
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5984
		if (f_port) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5985
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5986
			if (state == FC_STATE_LOOP) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5987
				port->fp_topology = FC_TOP_PUBLIC_LOOP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5988
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5989
				port->fp_topology = FC_TOP_FABRIC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5990
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  5991
				FC_GET_RSP(port, pkt->pkt_resp_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5992
				    (uint8_t *)&port->fp_fabric_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5993
				    (uint8_t *)&acc->node_ww_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5994
				    sizeof (la_wwn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5995
				    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5996
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5997
			port->fp_port_id.port_id = pkt->pkt_resp_fhdr.d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5998
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  5999
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6000
			pkt->pkt_state = FC_PKT_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6001
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6002
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6003
	fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6004
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6005
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6006
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6007
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6008
 * Handle solicited PLOGI response
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6009
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6010
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6011
fp_plogi_intr(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6012
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6013
	int			nl_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6014
	int			bailout;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6015
	uint32_t		d_id;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6016
	fp_cmd_t		*cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6017
	la_els_logi_t		*acc;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6018
	fc_local_port_t		*port;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6019
	fc_remote_port_t	*pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6020
	la_wwn_t		nwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6021
	la_wwn_t		pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6022
	ls_code_t		resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6023
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6024
	nl_port = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6025
	cmd = pkt->pkt_ulp_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6026
	port = cmd->cmd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6027
	d_id = pkt->pkt_cmd_fhdr.d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6028
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6029
#ifndef	__lock_lint
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6030
	ASSERT(cmd->cmd_job && cmd->cmd_job->job_counter);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6031
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6032
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6033
	FP_TRACE(FP_NHEAD1(3, 0), "fp_plogi_intr: port=%p, job=%p, d_id=%x,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6034
	    " jcount=%d pkt=%p, state=%x", port, cmd->cmd_job, d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6035
	    cmd->cmd_job->job_counter, pkt, pkt->pkt_state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6036
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6037
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6038
	 * Bail out early on ULP initiated requests if the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6039
	 * state change has occurred
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6040
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6041
	mutex_enter(&port->fp_mutex);
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6042
	port->fp_out_fpcmds--;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6043
	bailout = ((port->fp_statec_busy ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6044
	    FC_PORT_STATE_MASK(port->fp_state) == FC_STATE_OFFLINE) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6045
	    cmd->cmd_ulp_pkt) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6046
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6047
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6048
	if (FP_IS_PKT_ERROR(pkt) || bailout) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6049
		int skip_msg = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6050
		int giveup = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6051
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6052
		if (cmd->cmd_ulp_pkt) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6053
			cmd->cmd_ulp_pkt->pkt_state = pkt->pkt_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6054
			cmd->cmd_ulp_pkt->pkt_reason = pkt->pkt_reason;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6055
			cmd->cmd_ulp_pkt->pkt_action = pkt->pkt_action;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6056
			cmd->cmd_ulp_pkt->pkt_expln = pkt->pkt_expln;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6057
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6058
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6059
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6060
		 * If an unsolicited cross login already created
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6061
		 * a device speed up the discovery by not retrying
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6062
		 * the command mindlessly.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6063
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6064
		if (pkt->pkt_pd == NULL &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6065
		    fctl_get_remote_port_by_did(port, d_id) != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6066
			fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6067
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6068
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6069
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6070
		if (pkt->pkt_pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6071
			giveup = (pkt->pkt_pd->pd_recepient ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6072
			    PD_PLOGI_RECEPIENT) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6073
			if (giveup) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6074
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6075
				 * This pd is marked as plogi
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6076
				 * recipient, stop retrying
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6077
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6078
				FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6079
				    "fp_plogi_intr: stop retry as"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6080
				    " a cross login was accepted"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6081
				    " from d_id=%x, port=%p.",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6082
				    d_id, port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6083
				fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6084
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6085
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6086
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6087
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6088
		if (fp_common_intr(pkt, 0) == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6089
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6090
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6091
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6092
		if ((pd = fctl_get_remote_port_by_did(port, d_id)) != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6093
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6094
			if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6095
				skip_msg++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6096
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6097
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6098
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6099
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6100
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6101
		if (!bailout && !(skip_msg && port->fp_statec_busy) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6102
		    port->fp_statec_busy <= 1 &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6103
		    pkt->pkt_reason != FC_REASON_FCAL_OPN_FAIL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6104
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6105
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6106
			 * In case of Login Collisions, JNI HBAs returns the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6107
			 * FC pkt back to the Initiator with the state set to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6108
			 * FC_PKT_LS_RJT and reason to FC_REASON_LOGICAL_ERROR.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6109
			 * QLC HBAs handles such cases in the FW and doesnot
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6110
			 * return the LS_RJT with Logical error when
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6111
			 * login collision happens.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6112
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6113
			if ((pkt->pkt_state != FC_PKT_LS_RJT) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6114
			    (pkt->pkt_reason != FC_REASON_LOGICAL_ERROR)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6115
				fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, pkt,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6116
				    "PLOGI to %x failed", d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6117
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6118
			FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6119
			    "PLOGI to %x failed. state=%x reason=%x.",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6120
			    d_id, pkt->pkt_state, pkt->pkt_reason);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6121
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6122
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6123
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6124
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6125
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6126
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6127
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6128
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6129
	acc = (la_els_logi_t *)pkt->pkt_resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6130
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6131
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&resp, (uint8_t *)acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6132
	    sizeof (resp), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6133
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6134
	ASSERT(resp.ls_code == LA_ELS_ACC);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6135
	if (resp.ls_code != LA_ELS_ACC) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6136
		(void) fp_common_intr(pkt, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6137
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6138
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6139
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6140
	if (d_id == FS_NAME_SERVER || d_id == FS_FABRIC_CONTROLLER) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6141
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6142
		port->fp_ns_login_class = FC_TRAN_CLASS(pkt->pkt_tran_flags);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6143
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6144
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6145
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6146
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6147
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6148
	ASSERT(acc == (la_els_logi_t *)pkt->pkt_resp);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6149
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6150
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&pwwn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6151
	    (uint8_t *)&acc->nport_ww_name, sizeof (la_wwn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6152
	    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6153
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6154
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&nwwn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6155
	    (uint8_t *)&acc->node_ww_name, sizeof (la_wwn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6156
	    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6157
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6158
	ASSERT(fctl_is_wwn_zero(&pwwn) == FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6159
	ASSERT(fctl_is_wwn_zero(&nwwn) == FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6160
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6161
	if ((pd = pkt->pkt_pd) == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6162
		pd = fctl_get_remote_port_by_pwwn(port, &pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6163
		if (pd == NULL) {
13096
33ad53eb7c84 6956269 WARNING:fp(0)::fp_plogi_intr on NL nodes
Rijawanemohammadhusen Nadaf<Riz.Nadaf@Sun.COM>
parents: 11617
diff changeset
  6164
			FP_TRACE(FP_NHEAD2(1, 0), "fp_plogi_intr: fp %x pd %x",
10107
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
  6165
			    port->fp_port_id.port_id, d_id);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6166
			pd = fctl_create_remote_port(port, &nwwn, &pwwn, d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6167
			    PD_PLOGI_INITIATOR, KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6168
			if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6169
				fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6170
				    "couldn't create port device handles"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6171
				    " d_id=%x", d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6172
				fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6173
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6174
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6175
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6176
			fc_remote_port_t *tmp_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6177
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6178
			tmp_pd = fctl_get_remote_port_by_did(port, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6179
			if (tmp_pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6180
				fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6181
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6182
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6183
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6184
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6185
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6186
			if ((pd->pd_state == PORT_DEVICE_LOGGED_IN) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6187
			    (pd->pd_aux_flags & PD_LOGGED_OUT)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6188
				cmd->cmd_flags |= FP_CMD_PLOGI_RETAIN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6189
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6190
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6191
			if (pd->pd_type == PORT_DEVICE_OLD) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6192
				if (pd->pd_port_id.port_id != d_id) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6193
					fctl_delist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6194
					pd->pd_type = PORT_DEVICE_CHANGED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6195
					pd->pd_port_id.port_id = d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6196
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6197
					pd->pd_type = PORT_DEVICE_NOCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6198
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6199
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6200
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6201
			if (pd->pd_aux_flags & PD_IN_DID_QUEUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6202
				char ww_name[17];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6203
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6204
				fc_wwn_to_str(&pd->pd_port_name, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6205
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6206
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6207
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6208
				FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6209
				    "Possible Duplicate name or address"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6210
				    " identifiers in the PLOGI response"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6211
				    " D_ID=%x, PWWN=%s: Please check the"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6212
				    " configuration", d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6213
				fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6214
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6215
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6216
			fctl_enlist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6217
			pd->pd_aux_flags &= ~PD_LOGGED_OUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6218
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6219
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6220
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6221
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6222
		fc_remote_port_t *tmp_pd, *new_wwn_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6223
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6224
		tmp_pd = fctl_get_remote_port_by_did(port, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6225
		new_wwn_pd = fctl_get_remote_port_by_pwwn(port, &pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6226
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6227
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6228
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6229
		if (fctl_wwn_cmp(&pd->pd_port_name, &pwwn) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6230
			FP_TRACE(FP_NHEAD1(3, 0), "fp_plogi_intr: d_id=%x,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6231
			    " pd_state=%x pd_type=%x", d_id, pd->pd_state,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6232
			    pd->pd_type);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6233
			if ((pd->pd_state == PORT_DEVICE_LOGGED_IN &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6234
			    pd->pd_type == PORT_DEVICE_OLD) ||
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6235
			    (pd->pd_aux_flags & PD_LOGGED_OUT)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6236
				pd->pd_type = PORT_DEVICE_NOCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6237
			} else if (pd->pd_state != PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6238
				pd->pd_type = PORT_DEVICE_NEW;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6239
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6240
		} else {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6241
			char	old_name[17];
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6242
			char	new_name[17];
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6243
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6244
			fc_wwn_to_str(&pd->pd_port_name, old_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6245
			fc_wwn_to_str(&pwwn, new_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6246
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6247
			FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6248
			    "fp_plogi_intr: PWWN of a device with D_ID=%x "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6249
			    "changed. New PWWN = %s, OLD PWWN = %s ; tmp_pd:%p "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6250
			    "pd:%p new_wwn_pd:%p, cmd_ulp_pkt:%p, bailout:0x%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6251
			    d_id, new_name, old_name, tmp_pd, pd, new_wwn_pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6252
			    cmd->cmd_ulp_pkt, bailout);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6253
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6254
			FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6255
			    "PWWN of a device with D_ID=%x changed."
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6256
			    " New PWWN = %s, OLD PWWN = %s", d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6257
			    new_name, old_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6258
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6259
			if (cmd->cmd_ulp_pkt && !bailout) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6260
				fc_remote_node_t	*rnodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6261
				fc_portmap_t	*changelist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6262
				fc_portmap_t	*listptr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6263
				int		len = 1;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6264
				/* # entries in changelist */
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6265
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6266
				fctl_delist_pwwn_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6267
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6268
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6269
				 * Lets now check if there already is a pd with
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6270
				 * this new WWN in the table. If so, we'll mark
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6271
				 * it as invalid
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6272
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6273
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6274
				if (new_wwn_pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6275
					/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6276
					 * There is another pd with in the pwwn
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6277
					 * table with the same WWN that we got
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6278
					 * in the PLOGI payload. We have to get
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6279
					 * it out of the pwwn table, update the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6280
					 * pd's state (fp_fillout_old_map does
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6281
					 * this for us) and add it to the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6282
					 * changelist that goes up to ULPs.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6283
					 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6284
					 * len is length of changelist and so
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6285
					 * increment it.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6286
					 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6287
					len++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6288
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6289
					if (tmp_pd != pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6290
						/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6291
						 * Odd case where pwwn and did
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6292
						 * tables are out of sync but
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6293
						 * we will handle that too. See
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6294
						 * more comments below.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6295
						 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6296
						 * One more device that ULPs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6297
						 * should know about and so len
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6298
						 * gets incremented again.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6299
						 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6300
						len++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6301
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6302
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6303
					listptr = changelist = kmem_zalloc(len *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6304
					    sizeof (*changelist), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6305
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6306
					mutex_enter(&new_wwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6307
					rnodep = new_wwn_pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6308
					mutex_exit(&new_wwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6309
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6310
					/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6311
					 * Hold the fd_mutex since
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6312
					 * fctl_copy_portmap_held expects it.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6313
					 * Preserve lock hierarchy by grabbing
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6314
					 * fd_mutex before pd_mutex
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6315
					 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6316
					if (rnodep) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6317
						mutex_enter(&rnodep->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6318
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6319
					mutex_enter(&new_wwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6320
					fp_fillout_old_map_held(listptr++,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6321
					    new_wwn_pd, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6322
					mutex_exit(&new_wwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6323
					if (rnodep) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6324
						mutex_exit(&rnodep->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6325
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6326
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6327
					/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6328
					 * Safety check :
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6329
					 * Lets ensure that the pwwn and did
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6330
					 * tables are in sync. Ideally, we
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6331
					 * should not find that these two pd's
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6332
					 * are different.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6333
					 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6334
					if (tmp_pd != pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6335
						mutex_enter(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6336
						rnodep =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6337
						    tmp_pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6338
						mutex_exit(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6339
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6340
						/* As above grab fd_mutex */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6341
						if (rnodep) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6342
							mutex_enter(&rnodep->
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6343
							    fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6344
						}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6345
						mutex_enter(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6346
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6347
						fp_fillout_old_map_held(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6348
						    listptr++, tmp_pd, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6349
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6350
						mutex_exit(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6351
						if (rnodep) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6352
							mutex_exit(&rnodep->
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6353
							    fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6354
						}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6355
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6356
						/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6357
						 * Now add "pd" (not tmp_pd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6358
						 * to fp_did_table to sync it up
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6359
						 * with fp_pwwn_table
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6360
						 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6361
						 * pd->pd_mutex is already held
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6362
						 * at this point
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6363
						 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6364
						fctl_enlist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6365
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6366
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6367
					listptr = changelist = kmem_zalloc(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6368
					    sizeof (*changelist), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6369
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6370
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6371
				ASSERT(changelist != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6372
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6373
				fp_fillout_changed_map(listptr, pd, &d_id,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6374
				    &pwwn);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6375
				fctl_enlist_pwwn_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6376
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6377
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6378
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6379
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6380
				fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6381
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6382
				(void) fp_ulp_devc_cb(port, changelist, len,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6383
				    len, KM_NOSLEEP, 0);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6384
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6385
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6386
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6387
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6388
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6389
		if (pd->pd_porttype.port_type == FC_NS_PORT_NL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6390
			nl_port = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6391
		}
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6392
		if (pd->pd_aux_flags & PD_DISABLE_RELOGIN) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6393
			pd->pd_aux_flags &= ~PD_LOGGED_OUT;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6394
		}
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6395
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6396
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6397
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6398
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6399
		if (tmp_pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6400
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6401
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6402
			if (pd->pd_aux_flags & PD_IN_DID_QUEUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6403
				char ww_name[17];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6404
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6405
				fc_wwn_to_str(&pd->pd_port_name, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6406
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6407
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6408
				FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6409
				    "Possible Duplicate name or address"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6410
				    " identifiers in the PLOGI response"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6411
				    " D_ID=%x, PWWN=%s: Please check the"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6412
				    " configuration", d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6413
				fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6414
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6415
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6416
			fctl_enlist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6417
			pd->pd_aux_flags &= ~PD_LOGGED_OUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6418
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6419
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6420
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6421
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6422
	fp_register_login(&pkt->pkt_resp_acc, pd, acc,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6423
	    FC_TRAN_CLASS(pkt->pkt_tran_flags));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6424
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6425
	if (cmd->cmd_ulp_pkt) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6426
		cmd->cmd_ulp_pkt->pkt_state = pkt->pkt_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6427
		cmd->cmd_ulp_pkt->pkt_action = pkt->pkt_action;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6428
		cmd->cmd_ulp_pkt->pkt_expln = pkt->pkt_expln;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6429
		if (cmd->cmd_ulp_pkt->pkt_pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6430
			if (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6431
				FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6432
				    "fp_plogi_intr;"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6433
				    "ulp_pkt's pd is NULL, get a pd %p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6434
				    pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6435
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6436
				pd->pd_ref_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6437
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6438
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6439
			cmd->cmd_ulp_pkt->pkt_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6440
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6441
		bcopy((caddr_t)&pkt->pkt_resp_fhdr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6442
		    (caddr_t)&cmd->cmd_ulp_pkt->pkt_resp_fhdr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6443
		    sizeof (fc_frame_hdr_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6444
		bcopy((caddr_t)pkt->pkt_resp,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6445
		    (caddr_t)cmd->cmd_ulp_pkt->pkt_resp,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6446
		    sizeof (la_els_logi_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6447
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6448
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6449
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6450
	if (port->fp_topology == FC_TOP_PRIVATE_LOOP || nl_port) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6451
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6452
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6453
		cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6454
		cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6455
		cmd->cmd_retry_count = fp_retry_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6456
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6457
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6458
		 * If the fc_remote_port_t pointer is not set in the given
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6459
		 * fc_packet_t, then this fc_remote_port_t must have just
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6460
		 * been created.  Save the pointer and also increment the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6461
		 * fc_remote_port_t reference count.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6462
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6463
		if (pkt->pkt_pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6464
			pkt->pkt_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6465
			pd->pd_ref_count++;	/* It's in use! */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6466
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6467
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6468
		fp_adisc_init(cmd, cmd->cmd_job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6469
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6470
		pkt->pkt_cmdlen = sizeof (la_els_adisc_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6471
		pkt->pkt_rsplen = sizeof (la_els_adisc_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6472
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6473
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6474
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6475
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6476
		if (fp_sendcmd(port, cmd, port->fp_fca_handle) == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6477
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6478
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6479
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6480
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6481
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6482
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6483
	if ((cmd->cmd_flags & FP_CMD_PLOGI_RETAIN) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6484
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6485
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6486
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6487
		cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6488
		cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6489
		cmd->cmd_retry_count = fp_retry_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6490
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6491
		fp_logo_init(pd, cmd, cmd->cmd_job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6492
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6493
		pkt->pkt_cmdlen = sizeof (la_els_logo_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6494
		pkt->pkt_rsplen = FP_PORT_IDENTIFIER_LEN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6495
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6496
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6497
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6498
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6499
		if (fp_sendcmd(port, cmd, port->fp_fca_handle) == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6500
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6501
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6502
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6503
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6504
	fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6505
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6506
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6507
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6508
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6509
 * Handle solicited ADISC response
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6510
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6511
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6512
fp_adisc_intr(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6513
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6514
	int			rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6515
	int			bailout;
11467
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6516
	fp_cmd_t		*cmd, *logi_cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6517
	fc_local_port_t		*port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6518
	fc_remote_port_t	*pd;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6519
	la_els_adisc_t		*acc;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6520
	ls_code_t		resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6521
	fc_hardaddr_t		ha;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6522
	fc_portmap_t		*changelist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6523
	int			initiator, adiscfail = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6524
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6525
	pd = pkt->pkt_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6526
	cmd = pkt->pkt_ulp_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6527
	port = cmd->cmd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6528
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6529
#ifndef	__lock_lint
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6530
	ASSERT(cmd->cmd_job && cmd->cmd_job->job_counter);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6531
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6532
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6533
	ASSERT(pd != NULL && port != NULL && cmd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6534
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6535
	mutex_enter(&port->fp_mutex);
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6536
	port->fp_out_fpcmds--;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6537
	bailout = ((port->fp_statec_busy ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6538
	    FC_PORT_STATE_MASK(port->fp_state) == FC_STATE_OFFLINE) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6539
	    cmd->cmd_ulp_pkt) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6540
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6541
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6542
	if (bailout) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6543
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6544
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6545
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6546
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6547
	if (pkt->pkt_state == FC_PKT_SUCCESS && pkt->pkt_resp_resid == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6548
		acc = (la_els_adisc_t *)pkt->pkt_resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6549
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6550
		FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&resp,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6551
		    (uint8_t *)acc, sizeof (resp), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6552
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6553
		if (resp.ls_code == LA_ELS_ACC) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6554
			int	is_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6555
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6556
			FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&ha,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6557
			    (uint8_t *)&acc->hard_addr, sizeof (ha),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6558
			    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6559
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6560
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6561
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6562
			is_private =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6563
			    (port->fp_topology == FC_TOP_PRIVATE_LOOP) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6564
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6565
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6566
			if ((pd->pd_aux_flags & PD_IN_DID_QUEUE) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6567
				fctl_enlist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6568
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6569
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6570
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6571
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6572
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6573
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6574
			if (pd->pd_type != PORT_DEVICE_NEW) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6575
				if (is_private && (pd->pd_hard_addr.hard_addr !=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6576
				    ha.hard_addr)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6577
					pd->pd_type = PORT_DEVICE_CHANGED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6578
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6579
					pd->pd_type = PORT_DEVICE_NOCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6580
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6581
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6582
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6583
			if (is_private && (ha.hard_addr &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6584
			    pd->pd_port_id.port_id != ha.hard_addr)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6585
				char ww_name[17];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6586
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6587
				fc_wwn_to_str(&pd->pd_port_name, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6588
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6589
				fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6590
				    "NL_Port Identifier %x doesn't match"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6591
				    " with Hard Address %x, Will use Port"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6592
				    " WWN %s", pd->pd_port_id.port_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6593
				    ha.hard_addr, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6594
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6595
				pd->pd_hard_addr.hard_addr = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6596
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6597
				pd->pd_hard_addr.hard_addr = ha.hard_addr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6598
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6599
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6600
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6601
			if (fp_common_intr(pkt, 0) == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6602
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6603
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6604
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6605
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6606
		if (fp_common_intr(pkt, 0) == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6607
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6608
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6609
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6610
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6611
		if (port->fp_statec_busy <= 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6612
			mutex_exit(&port->fp_mutex);
11467
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6613
			if (pkt->pkt_state == FC_PKT_LS_RJT &&
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6614
			    pkt->pkt_reason == FC_REASON_CMD_UNABLE) {
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6615
				uchar_t class;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6616
				int cmd_flag;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6617
				uint32_t src_id;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6618
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6619
				class = fp_get_nextclass(port,
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6620
				    FC_TRAN_CLASS_INVALID);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6621
				if (class == FC_TRAN_CLASS_INVALID) {
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6622
					fp_iodone(cmd);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6623
					return;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6624
				}
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6625
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6626
				FP_TRACE(FP_NHEAD1(1, 0), "ADISC re-login; "
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6627
				    "fp_state=0x%x, pkt_state=0x%x, "
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6628
				    "reason=0x%x, class=0x%x",
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6629
				    port->fp_state, pkt->pkt_state,
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6630
				    pkt->pkt_reason, class);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6631
				cmd_flag = FP_CMD_PLOGI_RETAIN;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6632
11617
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  6633
				logi_cmd = fp_alloc_pkt(port,
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  6634
				    sizeof (la_els_logi_t),
11467
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6635
				    sizeof (la_els_logi_t), KM_SLEEP, pd);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6636
				if (logi_cmd == NULL) {
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6637
					fp_iodone(cmd);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6638
					return;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6639
				}
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6640
11617
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  6641
				logi_cmd->cmd_pkt.pkt_tran_flags =
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  6642
				    FC_TRAN_INTR | class;
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  6643
				logi_cmd->cmd_pkt.pkt_tran_type =
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  6644
				    FC_PKT_EXCHANGE;
11467
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6645
				logi_cmd->cmd_flags = cmd_flag;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6646
				logi_cmd->cmd_retry_count = fp_retry_count;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6647
				logi_cmd->cmd_ulp_pkt = NULL;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6648
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6649
				mutex_enter(&port->fp_mutex);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6650
				src_id = port->fp_port_id.port_id;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6651
				mutex_exit(&port->fp_mutex);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6652
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6653
				fp_xlogi_init(port, logi_cmd, src_id,
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6654
				    pkt->pkt_cmd_fhdr.d_id, fp_plogi_intr,
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6655
				    cmd->cmd_job, LA_ELS_PLOGI);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6656
				if (pd) {
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6657
					mutex_enter(&pd->pd_mutex);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6658
					pd->pd_flags = PD_ELS_IN_PROGRESS;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6659
					mutex_exit(&pd->pd_mutex);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6660
				}
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6661
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6662
				if (fp_sendcmd(port, logi_cmd,
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6663
				    port->fp_fca_handle) == FC_SUCCESS) {
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6664
					fp_free_pkt(cmd);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6665
					return;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6666
				} else {
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6667
					fp_free_pkt(logi_cmd);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6668
				}
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6669
			} else {
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6670
				fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, pkt,
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6671
				    "ADISC to %x failed, cmd_flags=%x",
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6672
				    pkt->pkt_cmd_fhdr.d_id, cmd->cmd_flags);
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6673
				cmd->cmd_flags &= ~FP_CMD_PLOGI_RETAIN;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6674
				adiscfail = 1;
6b79cab3fe43 6884747 Direct-attached tape device not rediscovered after reset
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 11156
diff changeset
  6675
			}
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6676
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6677
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6678
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6679
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6680
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6681
	if (cmd->cmd_ulp_pkt) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6682
		cmd->cmd_ulp_pkt->pkt_state = pkt->pkt_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6683
		cmd->cmd_ulp_pkt->pkt_action = pkt->pkt_action;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6684
		cmd->cmd_ulp_pkt->pkt_expln = pkt->pkt_expln;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6685
		if (cmd->cmd_ulp_pkt->pkt_pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6686
			cmd->cmd_ulp_pkt->pkt_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6687
			FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6688
			    "fp_adisc__intr;"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6689
			    "ulp_pkt's pd is NULL, get a pd %p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6690
			    pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6691
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6692
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6693
		bcopy((caddr_t)&pkt->pkt_resp_fhdr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6694
		    (caddr_t)&cmd->cmd_ulp_pkt->pkt_resp_fhdr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6695
		    sizeof (fc_frame_hdr_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6696
		bcopy((caddr_t)pkt->pkt_resp,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6697
		    (caddr_t)cmd->cmd_ulp_pkt->pkt_resp,
8728
cf60d71a50b2 6791420 Incorrect size copied to ULP in fp_adisc_intr
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 8588
diff changeset
  6698
		    sizeof (la_els_adisc_t));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6699
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6700
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6701
	if ((cmd->cmd_flags & FP_CMD_PLOGI_RETAIN) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6702
		FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6703
		    "fp_adisc_intr: Perform LOGO.cmd_flags=%x, "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6704
		    "fp_retry_count=%x, ulp_pkt=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6705
		    cmd->cmd_flags, fp_retry_count, cmd->cmd_ulp_pkt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6706
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6707
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6708
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6709
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6710
		cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6711
		cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6712
		cmd->cmd_retry_count = fp_retry_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6713
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6714
		fp_logo_init(pd, cmd, cmd->cmd_job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6715
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6716
		pkt->pkt_cmdlen = sizeof (la_els_logo_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6717
		pkt->pkt_rsplen = FP_PORT_IDENTIFIER_LEN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6718
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6719
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6720
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6721
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6722
		rval = fp_sendcmd(port, cmd, port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6723
		if (adiscfail) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6724
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6725
			initiator =
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6726
			    ((pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6727
			pd->pd_state = PORT_DEVICE_VALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6728
			pd->pd_aux_flags |= PD_LOGGED_OUT;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6729
			if (pd->pd_aux_flags & PD_DISABLE_RELOGIN) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6730
				pd->pd_type = PORT_DEVICE_NEW;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6731
			} else {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6732
				pd->pd_type = PORT_DEVICE_NOCHANGE;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6733
			}
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6734
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6735
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6736
			changelist =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6737
			    kmem_zalloc(sizeof (*changelist), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6738
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6739
			if (initiator) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6740
				fp_unregister_login(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6741
				fctl_copy_portmap(changelist, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6742
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6743
				fp_fillout_old_map(changelist, pd, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6744
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6745
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6746
			FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6747
			    "fp_adisc_intr: Dev change notification "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6748
			    "to ULP port=%p, pd=%p, map_type=%x map_state=%x "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6749
			    "map_flags=%x initiator=%d", port, pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6750
			    changelist->map_type, changelist->map_state,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6751
			    changelist->map_flags, initiator);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6752
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6753
			(void) fp_ulp_devc_cb(port, changelist,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6754
			    1, 1, KM_SLEEP, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6755
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6756
		if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6757
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6758
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6759
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6760
	fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6761
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6762
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6763
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6764
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6765
 * Handle solicited LOGO response
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6766
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6767
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6768
fp_logo_intr(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6769
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6770
	ls_code_t	resp;
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6771
	fc_local_port_t *port = ((fp_cmd_t *)pkt->pkt_ulp_private)->cmd_port;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6772
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6773
	mutex_enter(&((fp_cmd_t *)pkt->pkt_ulp_private)->cmd_port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6774
	((fp_cmd_t *)pkt->pkt_ulp_private)->cmd_port->fp_out_fpcmds--;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6775
	mutex_exit(&((fp_cmd_t *)pkt->pkt_ulp_private)->cmd_port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6776
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6777
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&resp,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6778
	    (uint8_t *)pkt->pkt_resp, sizeof (resp), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6779
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6780
	if (FP_IS_PKT_ERROR(pkt)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6781
		(void) fp_common_intr(pkt, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6782
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6783
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6784
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6785
	ASSERT(resp.ls_code == LA_ELS_ACC);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6786
	if (resp.ls_code != LA_ELS_ACC) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6787
		(void) fp_common_intr(pkt, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6788
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6789
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6790
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6791
	if (pkt->pkt_pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6792
		fp_unregister_login(pkt->pkt_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6793
	}
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6794
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6795
	fp_iodone(pkt->pkt_ulp_private);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6796
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6797
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6798
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6799
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6800
 * Handle solicited RNID response
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6801
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6802
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6803
fp_rnid_intr(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6804
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6805
	ls_code_t		resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6806
	job_request_t		*job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6807
	fp_cmd_t		*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6808
	la_els_rnid_acc_t	*acc;
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6809
	fc_local_port_t *port = ((fp_cmd_t *)pkt->pkt_ulp_private)->cmd_port;
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6810
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6811
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&resp,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6812
	    (uint8_t *)pkt->pkt_resp, sizeof (resp), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6813
	cmd = pkt->pkt_ulp_private;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6814
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6815
	mutex_enter(&cmd->cmd_port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6816
	cmd->cmd_port->fp_out_fpcmds--;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6817
	mutex_exit(&cmd->cmd_port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6818
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6819
	job = cmd->cmd_job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6820
	ASSERT(job->job_private != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6821
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6822
	/* If failure or LS_RJT then retry the packet, if needed */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6823
	if (pkt->pkt_state != FC_PKT_SUCCESS || resp.ls_code != LA_ELS_ACC) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6824
		(void) fp_common_intr(pkt, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6825
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6826
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6827
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6828
	/* Save node_id memory allocated in ioctl code */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6829
	acc = (la_els_rnid_acc_t *)pkt->pkt_resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6830
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6831
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)job->job_private,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6832
	    (uint8_t *)acc, sizeof (la_els_rnid_acc_t), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6833
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6834
	/* wakeup the ioctl thread and free the pkt */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6835
	fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6836
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6837
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6838
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6839
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6840
 * Handle solicited RLS response
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6841
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6842
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6843
fp_rls_intr(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6844
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6845
	ls_code_t		resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6846
	job_request_t		*job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6847
	fp_cmd_t		*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6848
	la_els_rls_acc_t	*acc;
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6849
	fc_local_port_t *port = ((fp_cmd_t *)pkt->pkt_ulp_private)->cmd_port;
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6850
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6851
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&resp,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6852
	    (uint8_t *)pkt->pkt_resp, sizeof (resp), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6853
	cmd = pkt->pkt_ulp_private;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6854
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6855
	mutex_enter(&cmd->cmd_port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6856
	cmd->cmd_port->fp_out_fpcmds--;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6857
	mutex_exit(&cmd->cmd_port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6858
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6859
	job = cmd->cmd_job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6860
	ASSERT(job->job_private != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6861
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6862
	/* If failure or LS_RJT then retry the packet, if needed */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6863
	if (FP_IS_PKT_ERROR(pkt) || resp.ls_code != LA_ELS_ACC) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6864
		(void) fp_common_intr(pkt, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6865
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6866
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6867
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6868
	/* Save link error status block in memory allocated in ioctl code */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6869
	acc = (la_els_rls_acc_t *)pkt->pkt_resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6870
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  6871
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)job->job_private,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6872
	    (uint8_t *)&acc->rls_link_params, sizeof (fc_rls_acc_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6873
	    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6874
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6875
	/* wakeup the ioctl thread and free the pkt */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6876
	fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6877
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6878
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6879
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6880
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6881
 * A solicited command completion interrupt (mostly for commands
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6882
 * that require almost no post processing such as SCR ELS)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6883
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6884
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6885
fp_intr(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6886
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6887
	mutex_enter(&((fp_cmd_t *)pkt->pkt_ulp_private)->cmd_port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6888
	((fp_cmd_t *)pkt->pkt_ulp_private)->cmd_port->fp_out_fpcmds--;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6889
	mutex_exit(&((fp_cmd_t *)pkt->pkt_ulp_private)->cmd_port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6890
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6891
	if (FP_IS_PKT_ERROR(pkt)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6892
		(void) fp_common_intr(pkt, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6893
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6894
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6895
	fp_iodone(pkt->pkt_ulp_private);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6896
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6897
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6898
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6899
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6900
 * Handle the underlying port's state change
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6901
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6902
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6903
fp_statec_cb(opaque_t port_handle, uint32_t state)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6904
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6905
	fc_local_port_t *port = port_handle;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  6906
	job_request_t	*job;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6907
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6908
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6909
	 * If it is not possible to process the callbacks
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6910
	 * just drop the callback on the floor; Don't bother
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6911
	 * to do something that isn't safe at this time
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6912
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6913
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6914
	if ((port->fp_soft_state &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6915
	    (FP_SOFT_IN_DETACH | FP_SOFT_SUSPEND | FP_SOFT_POWER_DOWN)) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6916
	    (FC_PORT_STATE_MASK(port->fp_state) == FC_PORT_STATE_MASK(state))) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6917
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6918
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6919
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6920
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6921
	if (port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6922
		port->fp_soft_state |= FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6923
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6924
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6925
		ASSERT(port->fp_soft_state & FP_SOFT_IN_STATEC_CB);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6926
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6927
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6928
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6929
	port->fp_statec_busy++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6930
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6931
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6932
	 * For now, force the trusted method of device authentication (by
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6933
	 * PLOGI) when LIPs do not involve OFFLINE to ONLINE transition.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6934
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6935
	if (FC_PORT_STATE_MASK(state) == FC_STATE_LIP ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6936
	    FC_PORT_STATE_MASK(state) == FC_STATE_LIP_LBIT_SET) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6937
		state = FC_PORT_SPEED_MASK(port->fp_state) | FC_STATE_LOOP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6938
		fp_port_offline(port, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6939
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6940
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6941
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6942
	switch (FC_PORT_STATE_MASK(state)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6943
	case FC_STATE_OFFLINE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6944
		job = fctl_alloc_job(JOB_PORT_OFFLINE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6945
		    JOB_TYPE_FCTL_ASYNC, NULL, NULL, KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6946
		if (job == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6947
			fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6948
			    " fp_statec_cb() couldn't submit a job "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6949
			    " to the thread: failing..");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6950
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6951
			if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6952
				port->fp_soft_state &= ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6953
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6954
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6955
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6956
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6957
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6958
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6959
		 * Zero out this field so that we do not retain
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6960
		 * the fabric name as its no longer valid
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6961
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6962
		bzero(&port->fp_fabric_name, sizeof (la_wwn_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6963
		port->fp_state = state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6964
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6965
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6966
		fctl_enque_job(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6967
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6968
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6969
	case FC_STATE_ONLINE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6970
	case FC_STATE_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6971
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6972
		port->fp_state = state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6973
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6974
		if (port->fp_offline_tid) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6975
			timeout_id_t tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6976
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6977
			tid = port->fp_offline_tid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6978
			port->fp_offline_tid = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6979
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6980
			(void) untimeout(tid);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6981
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6982
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6983
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6984
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6985
		job = fctl_alloc_job(JOB_PORT_ONLINE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6986
		    JOB_TYPE_FCTL_ASYNC, NULL, NULL, KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6987
		if (job == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6988
			fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6989
			    "fp_statec_cb() couldn't submit a job "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6990
			    "to the thread: failing..");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6991
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6992
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6993
			if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6994
				port->fp_soft_state &= ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6995
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6996
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6997
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6998
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  6999
		fctl_enque_job(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7000
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7001
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7002
	case FC_STATE_RESET_REQUESTED:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7003
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7004
		port->fp_state = FC_STATE_OFFLINE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7005
		port->fp_soft_state |= FP_SOFT_IN_FCA_RESET;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7006
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7007
		/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7008
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7009
	case FC_STATE_RESET:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7010
		job = fctl_alloc_job(JOB_ULP_NOTIFY,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7011
		    JOB_TYPE_FCTL_ASYNC, NULL, NULL, KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7012
		if (job == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7013
			fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7014
			    "fp_statec_cb() couldn't submit a job"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7015
			    " to the thread: failing..");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7016
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7017
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7018
			if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7019
				port->fp_soft_state &= ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7020
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7021
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7022
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7023
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7024
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7025
		/* squeeze into some field in the job structure */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7026
		job->job_ulp_listlen = FC_PORT_STATE_MASK(state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7027
		fctl_enque_job(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7028
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7029
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7030
	case FC_STATE_TARGET_PORT_RESET:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7031
		(void) fp_ulp_notify(port, state, KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7032
		/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7033
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7034
	case FC_STATE_NAMESERVICE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7035
		/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7036
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7037
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7038
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7039
		if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7040
			port->fp_soft_state &= ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7041
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7042
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7043
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7044
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7045
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7046
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7047
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7048
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7049
 * Register with the Name Server for RSCNs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7050
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7051
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7052
fp_ns_scr(fc_local_port_t *port, job_request_t *job, uchar_t scr_func,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7053
    int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7054
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7055
	uint32_t	s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7056
	uchar_t		class;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7057
	fc_scr_req_t	payload;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7058
	fp_cmd_t	*cmd;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7059
	fc_packet_t	*pkt;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7060
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7061
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7062
	s_id = port->fp_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7063
	class = port->fp_ns_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7064
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7065
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7066
	cmd = fp_alloc_pkt(port, sizeof (fc_scr_req_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7067
	    sizeof (fc_scr_resp_t), sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7068
	if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7069
		return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7070
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7071
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7072
	cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7073
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7074
	cmd->cmd_flags = FP_CMD_CFLAG_UNDEFINED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7075
	cmd->cmd_retry_count = fp_retry_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7076
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7077
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7078
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7079
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7080
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7081
	fp_els_init(cmd, s_id, 0xFFFFFD, fp_intr, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7082
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7083
	payload.ls_code.ls_code = LA_ELS_SCR;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7084
	payload.ls_code.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7085
	payload.scr_rsvd = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7086
	payload.scr_func = scr_func;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7087
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
  7088
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7089
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7090
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7091
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7092
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7093
	if (fp_sendcmd(port, cmd, port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7094
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7095
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7096
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7097
	return (FC_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7098
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7099
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7100
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7101
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7102
 * There are basically two methods to determine the total number of
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7103
 * devices out in the NS database; Reading the details of the two
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7104
 * methods described below, it shouldn't be hard to identify which
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7105
 * of the two methods is better.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7106
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7107
 *	Method 1.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7108
 *		Iteratively issue GANs until all ports identifiers are walked
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7109
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7110
 *	Method 2.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7111
 *		Issue GID_PT (get port Identifiers) with Maximum residual
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7112
 *		field in the request CT HEADER set to accommodate only the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7113
 *		CT HEADER in the response frame. And if FC-GS2 has been
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7114
 *		carefully read, the NS here has a chance to FS_ACC the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7115
 *		request and indicate the residual size in the FS_ACC.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7116
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7117
 *	Method 2 is wonderful, although it's not mandatory for the NS
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7118
 *	to update the Maximum/Residual Field as can be seen in 4.3.1.6
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7119
 *	(note with particular care the use of the auxiliary verb 'may')
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7120
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7121
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7122
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7123
fp_ns_get_devcount(fc_local_port_t *port, job_request_t *job, int create,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7124
    int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7125
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7126
	int		flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7127
	int		rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7128
	uint32_t	src_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7129
	fctl_ns_req_t	*ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7130
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7131
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7132
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7133
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7134
	src_id = port->fp_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7135
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7136
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7137
	if (!create && (port->fp_options & FP_NS_SMART_COUNT)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7138
		ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gid_pt_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7139
		    sizeof (ns_resp_gid_pt_t), 0,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7140
		    (FCTL_NS_GET_DEV_COUNT | FCTL_NS_NO_DATA_BUF), sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7141
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7142
		if (ns_cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7143
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7144
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7145
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7146
		ns_cmd->ns_cmd_code = NS_GID_PT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7147
		((ns_req_gid_pt_t *)(ns_cmd->ns_cmd_buf))->port_type.port_type
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7148
		    = FC_NS_PORT_NX;	/* All port types */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7149
		((ns_req_gid_pt_t *)(ns_cmd->ns_cmd_buf))->port_type.rsvd = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7150
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7151
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7152
		uint32_t ns_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7153
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7154
		ns_flags = FCTL_NS_GET_DEV_COUNT | FCTL_NS_NO_DATA_BUF;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7155
		if (create) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7156
			ns_flags |= FCTL_NS_CREATE_DEVICE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7157
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7158
		ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gan_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7159
		    sizeof (ns_resp_gan_t), sizeof (int), ns_flags, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7160
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7161
		if (ns_cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7162
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7163
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7164
		ns_cmd->ns_gan_index = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7165
		ns_cmd->ns_gan_sid = FCTL_GAN_START_ID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7166
		ns_cmd->ns_cmd_code = NS_GA_NXT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7167
		ns_cmd->ns_gan_max = 0xFFFF;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7168
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7169
		((ns_req_gan_t *)(ns_cmd->ns_cmd_buf))->pid.port_id = src_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7170
		((ns_req_gan_t *)(ns_cmd->ns_cmd_buf))->pid.priv_lilp_posit = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7171
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7172
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7173
	flags = job->job_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7174
	job->job_flags &= ~JOB_TYPE_FP_ASYNC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7175
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7176
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7177
	rval = fp_ns_query(port, ns_cmd, job, 1, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7178
	job->job_flags = flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7179
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7180
	if (!create && (port->fp_options & FP_NS_SMART_COUNT)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7181
		uint16_t max_resid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7182
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7183
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7184
		 * Revert to scanning the NS if NS_GID_PT isn't
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7185
		 * helping us figure out total number of devices.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7186
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7187
		if (job->job_result != FC_SUCCESS ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7188
		    ns_cmd->ns_resp_hdr.ct_cmdrsp != FS_ACC_IU) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7189
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7190
			port->fp_options &= ~FP_NS_SMART_COUNT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7191
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7192
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7193
			fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7194
			return (fp_ns_get_devcount(port, job, create, sleep));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7195
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7196
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7197
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7198
		port->fp_total_devices = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7199
		max_resid = ns_cmd->ns_resp_hdr.ct_aiusize;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7200
		if (max_resid) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7201
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7202
			 * Since port identifier is 4 bytes and max_resid
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7203
			 * is also in WORDS, max_resid simply indicates
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7204
			 * the total number of port identifiers	not
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7205
			 * transferred
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7206
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7207
			port->fp_total_devices += max_resid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7208
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7209
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7210
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7211
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7212
	port->fp_total_devices = *((int *)ns_cmd->ns_data_buf);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7213
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7214
	fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7215
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7216
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7217
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7218
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7219
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7220
 * One heck of a function to serve userland.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7221
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7222
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7223
fp_fciocmd(fc_local_port_t *port, intptr_t data, int mode, fcio_t *fcio)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7224
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7225
	int		rval = 0;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7226
	int		jcode;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7227
	uint32_t	ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7228
	uchar_t		open_flag;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7229
	fcio_t		*kfcio;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7230
	job_request_t	*job;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7231
	boolean_t	use32 = B_FALSE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7232
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7233
#ifdef _MULTI_DATAMODEL
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7234
	switch (ddi_model_convert_from(mode & FMODELS)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7235
	case DDI_MODEL_ILP32:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7236
		use32 = B_TRUE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7237
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7238
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7239
	case DDI_MODEL_NONE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7240
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7241
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7242
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7243
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7244
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7245
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7246
	if (port->fp_soft_state & (FP_SOFT_IN_STATEC_CB |
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7247
	    FP_SOFT_IN_UNSOL_CB)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7248
		fcio->fcio_errno = FC_STATEC_BUSY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7249
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7250
		rval = EAGAIN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7251
		if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7252
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7253
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7254
		return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7255
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7256
	open_flag = port->fp_flag;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7257
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7258
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7259
	if (fp_check_perms(open_flag, fcio->fcio_cmd) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7260
		fcio->fcio_errno = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7261
		rval = EACCES;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7262
		if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7263
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7264
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7265
		return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7266
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7267
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7268
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7269
	 * If an exclusive open was demanded during open, don't let
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7270
	 * either innocuous or devil threads to share the file
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7271
	 * descriptor and fire down exclusive access commands
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7272
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7273
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7274
	if (port->fp_flag & FP_EXCL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7275
		if (port->fp_flag & FP_EXCL_BUSY) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7276
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7277
			fcio->fcio_errno = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7278
			return (EBUSY);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7279
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7280
		port->fp_flag |= FP_EXCL_BUSY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7281
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7282
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7283
11156
fa5f12909da7 6677595 HBA_GetNumberOfAdapters occasionally does not return the correct adapter count
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 10339
diff changeset
  7284
	fcio->fcio_errno = FC_SUCCESS;
fa5f12909da7 6677595 HBA_GetNumberOfAdapters occasionally does not return the correct adapter count
Yu Renia Miao <Renia.Miao@Sun.COM>
parents: 10339
diff changeset
  7285
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7286
	switch (fcio->fcio_cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7287
	case FCIO_GET_HOST_PARAMS: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7288
		fc_port_dev_t	*val;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7289
		fc_port_dev32_t	*val32;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7290
		int		index;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7291
		int		lilp_device_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7292
		fc_lilpmap_t	*lilp_map;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7293
		uchar_t		*alpa_list;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7294
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7295
		if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7296
			if (fcio->fcio_olen != sizeof (*val32) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7297
			    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7298
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7299
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7300
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7301
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7302
			if (fcio->fcio_olen != sizeof (*val) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7303
			    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7304
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7305
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7306
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7307
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7308
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7309
		val = kmem_zalloc(sizeof (*val), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7310
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7311
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7312
		val->dev_did = port->fp_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7313
		val->dev_hard_addr = port->fp_hard_addr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7314
		val->dev_pwwn = port->fp_service_params.nport_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7315
		val->dev_nwwn = port->fp_service_params.node_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7316
		val->dev_state = port->fp_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7317
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7318
		lilp_map = &port->fp_lilp_map;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7319
		alpa_list = &lilp_map->lilp_alpalist[0];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7320
		lilp_device_count = lilp_map->lilp_length;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7321
		for (index = 0; index < lilp_device_count; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7322
			uint32_t d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7323
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7324
			d_id = alpa_list[index];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7325
			if (d_id == port->fp_port_id.port_id) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7326
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7327
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7328
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7329
		val->dev_did.priv_lilp_posit = (uint8_t)(index & 0xff);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7330
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7331
		bcopy(port->fp_fc4_types, val->dev_type,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7332
		    sizeof (port->fp_fc4_types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7333
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7334
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7335
		if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7336
			val32 = kmem_zalloc(sizeof (*val32), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7337
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7338
			val32->dev_did = val->dev_did;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7339
			val32->dev_hard_addr = val->dev_hard_addr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7340
			val32->dev_pwwn = val->dev_pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7341
			val32->dev_nwwn = val->dev_nwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7342
			val32->dev_state = val->dev_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7343
			val32->dev_did.priv_lilp_posit =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7344
			    val->dev_did.priv_lilp_posit;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7345
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7346
			bcopy(val->dev_type, val32->dev_type,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7347
			    sizeof (port->fp_fc4_types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7348
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7349
			if (fp_copyout((void *)val32, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7350
			    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7351
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7352
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7353
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7354
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7355
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7356
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7357
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7358
			kmem_free(val32, sizeof (*val32));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7359
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7360
			if (fp_copyout((void *)val, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7361
			    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7362
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7363
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7364
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7365
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7366
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7367
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7368
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7369
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7370
		/* need to free "val" here */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7371
		kmem_free(val, sizeof (*val));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7372
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7373
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7374
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7375
	case FCIO_GET_OTHER_ADAPTER_PORTS: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7376
		uint32_t    index;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7377
		char	    *tmpPath;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7378
		fc_local_port_t	  *tmpPort;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7379
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7380
		if (fcio->fcio_olen < MAXPATHLEN ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7381
		    fcio->fcio_ilen != sizeof (uint32_t)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7382
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7383
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7384
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7385
		if (ddi_copyin(fcio->fcio_ibuf, &index, sizeof (index), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7386
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7387
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7388
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7389
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7390
		tmpPort = fctl_get_adapter_port_by_index(port, index);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7391
		if (tmpPort == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7392
			FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7393
			    "User supplied index out of range");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7394
			fcio->fcio_errno = FC_BADPORT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7395
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7396
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7397
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7398
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7399
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7400
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7401
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7402
		tmpPath = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7403
		(void) ddi_pathname(tmpPort->fp_port_dip, tmpPath);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7404
		if (fp_copyout((void *)tmpPath, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7405
		    MAXPATHLEN, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7406
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7407
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7408
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7409
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7410
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7411
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7412
		kmem_free(tmpPath, MAXPATHLEN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7413
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7414
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7415
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7416
	case FCIO_NPIV_GET_ADAPTER_ATTRIBUTES:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7417
	case FCIO_GET_ADAPTER_ATTRIBUTES: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7418
		fc_hba_adapter_attributes_t	*val;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7419
		fc_hba_adapter_attributes32_t	*val32;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7420
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7421
		if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7422
			if (fcio->fcio_olen < sizeof (*val32) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7423
			    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7424
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7425
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7426
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7427
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7428
			if (fcio->fcio_olen < sizeof (*val) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7429
			    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7430
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7431
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7432
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7433
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7434
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7435
		val = kmem_zalloc(sizeof (*val), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7436
		val->version = FC_HBA_ADAPTER_ATTRIBUTES_VERSION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7437
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7438
		bcopy(port->fp_hba_port_attrs.manufacturer,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7439
		    val->Manufacturer,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7440
		    sizeof (val->Manufacturer));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7441
		bcopy(port->fp_hba_port_attrs.serial_number,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7442
		    val->SerialNumber,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7443
		    sizeof (val->SerialNumber));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7444
		bcopy(port->fp_hba_port_attrs.model,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7445
		    val->Model,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7446
		    sizeof (val->Model));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7447
		bcopy(port->fp_hba_port_attrs.model_description,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7448
		    val->ModelDescription,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7449
		    sizeof (val->ModelDescription));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7450
		bcopy(port->fp_sym_node_name, val->NodeSymbolicName,
10005
b6940fb2404d 6679330 fp needs to reset the sysmbolic port name buffer before storing it into userland.
bing hu - Sun Microsystems - Beijing China <Bing.Hu@Sun.COM>
parents: 9163
diff changeset
  7451
		    port->fp_sym_node_namelen);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7452
		bcopy(port->fp_hba_port_attrs.hardware_version,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7453
		    val->HardwareVersion,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7454
		    sizeof (val->HardwareVersion));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7455
		bcopy(port->fp_hba_port_attrs.option_rom_version,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7456
		    val->OptionROMVersion,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7457
		    sizeof (val->OptionROMVersion));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7458
		bcopy(port->fp_hba_port_attrs.firmware_version,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7459
		    val->FirmwareVersion,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7460
		    sizeof (val->FirmwareVersion));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7461
		val->VendorSpecificID =
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7462
		    port->fp_hba_port_attrs.vendor_specific_id;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7463
		bcopy(&port->fp_service_params.node_ww_name.raw_wwn,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7464
		    &val->NodeWWN.raw_wwn,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7465
		    sizeof (val->NodeWWN.raw_wwn));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7466
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7467
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7468
		bcopy(port->fp_hba_port_attrs.driver_name,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7469
		    val->DriverName,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7470
		    sizeof (val->DriverName));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7471
		bcopy(port->fp_hba_port_attrs.driver_version,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7472
		    val->DriverVersion,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7473
		    sizeof (val->DriverVersion));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7474
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7475
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7476
		if (fcio->fcio_cmd == FCIO_GET_ADAPTER_ATTRIBUTES) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7477
			val->NumberOfPorts = fctl_count_fru_ports(port, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7478
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7479
			val->NumberOfPorts = fctl_count_fru_ports(port, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7480
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7481
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7482
		if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7483
			val32 = kmem_zalloc(sizeof (*val32), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7484
			val32->version = val->version;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7485
			bcopy(val->Manufacturer, val32->Manufacturer,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7486
			    sizeof (val->Manufacturer));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7487
			bcopy(val->SerialNumber, val32->SerialNumber,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7488
			    sizeof (val->SerialNumber));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7489
			bcopy(val->Model, val32->Model,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7490
			    sizeof (val->Model));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7491
			bcopy(val->ModelDescription, val32->ModelDescription,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7492
			    sizeof (val->ModelDescription));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7493
			bcopy(val->NodeSymbolicName, val32->NodeSymbolicName,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7494
			    sizeof (val->NodeSymbolicName));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7495
			bcopy(val->HardwareVersion, val32->HardwareVersion,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7496
			    sizeof (val->HardwareVersion));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7497
			bcopy(val->OptionROMVersion, val32->OptionROMVersion,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7498
			    sizeof (val->OptionROMVersion));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7499
			bcopy(val->FirmwareVersion, val32->FirmwareVersion,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7500
			    sizeof (val->FirmwareVersion));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7501
			val32->VendorSpecificID = val->VendorSpecificID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7502
			bcopy(&val->NodeWWN.raw_wwn, &val32->NodeWWN.raw_wwn,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7503
			    sizeof (val->NodeWWN.raw_wwn));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7504
			bcopy(val->DriverName, val32->DriverName,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7505
			    sizeof (val->DriverName));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7506
			bcopy(val->DriverVersion, val32->DriverVersion,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7507
			    sizeof (val->DriverVersion));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7508
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7509
			val32->NumberOfPorts = val->NumberOfPorts;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7510
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7511
			if (fp_copyout((void *)val32, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7512
			    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7513
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7514
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7515
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7516
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7517
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7518
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7519
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7520
			kmem_free(val32, sizeof (*val32));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7521
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7522
			if (fp_copyout((void *)val, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7523
			    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7524
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7525
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7526
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7527
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7528
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7529
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7530
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7531
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7532
		kmem_free(val, sizeof (*val));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7533
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7534
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7535
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7536
	case FCIO_GET_NPIV_ATTRIBUTES: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7537
		fc_hba_npiv_attributes_t *attrs;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7538
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7539
		attrs = kmem_zalloc(sizeof (*attrs), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7540
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7541
		bcopy(&port->fp_service_params.node_ww_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7542
		    &attrs->NodeWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7543
		    sizeof (attrs->NodeWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7544
		bcopy(&port->fp_service_params.nport_ww_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7545
		    &attrs->PortWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7546
		    sizeof (attrs->PortWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7547
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7548
		if (fp_copyout((void *)attrs, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7549
		    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7550
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7551
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7552
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7553
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7554
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7555
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7556
		kmem_free(attrs, sizeof (*attrs));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7557
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7558
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7559
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7560
	case FCIO_DELETE_NPIV_PORT: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7561
		fc_local_port_t *tmpport;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7562
		char	ww_pname[17];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7563
		la_wwn_t	vwwn[1];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7564
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7565
		FP_TRACE(FP_NHEAD1(1, 0), "Delete NPIV Port");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7566
		if (ddi_copyin(fcio->fcio_ibuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7567
		    &vwwn, sizeof (la_wwn_t), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7568
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7569
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7570
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7571
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7572
		fc_wwn_to_str(&vwwn[0], ww_pname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7573
		FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7574
		    "Delete NPIV Port %s", ww_pname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7575
		tmpport = fc_delete_npiv_port(port, &vwwn[0]);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7576
		if (tmpport == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7577
			FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7578
			    "Delete NPIV Port : no found");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7579
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7580
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7581
			fc_local_port_t *nextport = tmpport->fp_port_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7582
			fc_local_port_t *prevport = tmpport->fp_port_prev;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7583
			int portlen, portindex, ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7584
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7585
			portlen = sizeof (portindex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7586
			ret = ddi_prop_op(DDI_DEV_T_ANY,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7587
			    tmpport->fp_port_dip, PROP_LEN_AND_VAL_BUF,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7588
			    DDI_PROP_DONTPASS | DDI_PROP_CANSLEEP, "port",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7589
			    (caddr_t)&portindex, &portlen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7590
			if (ret != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7591
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7592
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7593
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7594
			if (ndi_devi_offline(tmpport->fp_port_dip,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7595
			    NDI_DEVI_REMOVE) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7596
				FP_TRACE(FP_NHEAD1(1, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7597
				    "Delete NPIV Port failed");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7598
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7599
				tmpport->fp_npiv_state = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7600
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7601
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7602
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7603
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7604
				nextport->fp_port_prev = prevport;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7605
				prevport->fp_port_next = nextport;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7606
				if (port == port->fp_port_next) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7607
					port->fp_port_next =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7608
					    port->fp_port_prev = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7609
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7610
				port->fp_npiv_portnum--;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7611
				FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7612
				    "Delete NPIV Port %d", portindex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7613
				port->fp_npiv_portindex[portindex-1] = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7614
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7615
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7616
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7617
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7618
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7619
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7620
	case FCIO_CREATE_NPIV_PORT: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7621
		char ww_nname[17], ww_pname[17];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7622
		la_npiv_create_entry_t entrybuf;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7623
		uint32_t vportindex = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7624
		int npiv_ret = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7625
		char *portname, *fcaname;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7626
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7627
		portname = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7628
		(void) ddi_pathname(port->fp_port_dip, portname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7629
		fcaname = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7630
		(void) ddi_pathname(port->fp_fca_dip, fcaname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7631
		FP_TRACE(FP_NHEAD1(1, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7632
		    "Create NPIV port %s %s %s", portname, fcaname,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7633
		    ddi_driver_name(port->fp_fca_dip));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7634
		kmem_free(portname, MAXPATHLEN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7635
		kmem_free(fcaname, MAXPATHLEN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7636
		if (ddi_copyin(fcio->fcio_ibuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7637
		    &entrybuf, sizeof (la_npiv_create_entry_t), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7638
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7639
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7640
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7641
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7642
		fc_wwn_to_str(&entrybuf.VNodeWWN, ww_nname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7643
		fc_wwn_to_str(&entrybuf.VPortWWN, ww_pname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7644
		vportindex = entrybuf.vindex;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7645
		FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7646
		    "Create NPIV Port %s %s %d",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7647
		    ww_nname, ww_pname, vportindex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7648
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7649
		if (fc_get_npiv_port(port, &entrybuf.VPortWWN)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7650
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7651
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7652
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7653
		npiv_ret = fctl_fca_create_npivport(port->fp_fca_dip,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7654
		    port->fp_port_dip, ww_nname, ww_pname, &vportindex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7655
		if (npiv_ret == NDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7656
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7657
			port->fp_npiv_portnum++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7658
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7659
			if (fp_copyout((void *)&vportindex,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7660
			    (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7661
			    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7662
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7663
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7664
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7665
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7666
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7667
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7668
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7669
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7670
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7671
		FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7672
		    "Create NPIV Port %d %d", npiv_ret, vportindex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7673
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7674
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7675
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7676
	case FCIO_GET_NPIV_PORT_LIST: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7677
		fc_hba_npiv_port_list_t *list;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7678
		int count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7679
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7680
		if ((fcio->fcio_xfer != FCIO_XFER_READ) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7681
		    (fcio->fcio_olen == 0) || (fcio->fcio_obuf == 0)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7682
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7683
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7684
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7685
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7686
		list = kmem_zalloc(fcio->fcio_olen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7687
		list->version = FC_HBA_LIST_VERSION;
11617
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7688
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7689
		count = (fcio->fcio_olen -
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7690
		    (int)sizeof (fc_hba_npiv_port_list_t))/MAXPATHLEN  + 1;
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7691
		if (port->fp_npiv_portnum > count) {
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7692
			list->numAdapters = port->fp_npiv_portnum;
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7693
		} else {
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7694
			/* build npiv port list */
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7695
			count = fc_ulp_get_npiv_port_list(port,
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7696
			    (char *)list->hbaPaths);
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7697
			if (count < 0) {
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7698
				rval = ENXIO;
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7699
				FP_TRACE(FP_NHEAD1(1, 0),
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7700
				    "Build NPIV Port List error");
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7701
				kmem_free(list, fcio->fcio_olen);
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7702
				break;
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7703
			}
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7704
			list->numAdapters = count;
8854b1d29e96 6906192 System panics when creating greater than 205 NPIV vports on 8G adapter.
allan <Allan.Ou@Sun.COM>
parents: 11467
diff changeset
  7705
		}
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7706
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7707
		if (fp_copyout((void *)list, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7708
		    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7709
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7710
				FP_TRACE(FP_NHEAD1(1, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7711
				    "Copy NPIV Port data error");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7712
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7713
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7714
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7715
			FP_TRACE(FP_NHEAD1(1, 0), "Copy NPIV Port List error");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7716
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7717
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7718
		kmem_free(list, fcio->fcio_olen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7719
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7720
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7721
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7722
	case FCIO_GET_ADAPTER_PORT_NPIV_ATTRIBUTES: {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7723
		fc_hba_port_npiv_attributes_t	*val;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7724
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7725
		val = kmem_zalloc(sizeof (*val), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7726
		val->version = FC_HBA_PORT_NPIV_ATTRIBUTES_VERSION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7727
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7728
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7729
		val->npivflag = port->fp_npiv_flag;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7730
		val->lastChange = port->fp_last_change;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7731
		bcopy(&port->fp_service_params.nport_ww_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7732
		    &val->PortWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7733
		    sizeof (val->PortWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7734
		bcopy(&port->fp_service_params.node_ww_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7735
		    &val->NodeWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7736
		    sizeof (val->NodeWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7737
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7738
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7739
		val->NumberOfNPIVPorts = fc_ulp_get_npiv_port_num(port);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7740
		if (port->fp_npiv_type != FC_NPIV_PORT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7741
			val->MaxNumberOfNPIVPorts =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7742
			    port->fp_fca_tran->fca_num_npivports;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7743
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7744
			val->MaxNumberOfNPIVPorts = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7745
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7746
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7747
		if (fp_copyout((void *)val, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7748
		    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7749
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7750
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7751
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7752
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7753
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7754
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7755
		kmem_free(val, sizeof (*val));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7756
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7757
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7758
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7759
	case FCIO_GET_ADAPTER_PORT_ATTRIBUTES: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7760
		fc_hba_port_attributes_t	*val;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7761
		fc_hba_port_attributes32_t	*val32;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7762
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7763
		if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7764
			if (fcio->fcio_olen < sizeof (*val32) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7765
			    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7766
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7767
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7768
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7769
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7770
			if (fcio->fcio_olen < sizeof (*val) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7771
			    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7772
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7773
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7774
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7775
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7776
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7777
		val = kmem_zalloc(sizeof (*val), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7778
		val->version = FC_HBA_PORT_ATTRIBUTES_VERSION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7779
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7780
		val->lastChange = port->fp_last_change;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7781
		val->fp_minor = port->fp_instance;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7782
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7783
		bcopy(&port->fp_service_params.nport_ww_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7784
		    &val->PortWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7785
		    sizeof (val->PortWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7786
		bcopy(&port->fp_service_params.node_ww_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7787
		    &val->NodeWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7788
		    sizeof (val->NodeWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7789
		bcopy(&port->fp_fabric_name, &val->FabricName.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7790
		    sizeof (val->FabricName.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7791
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7792
		val->PortFcId = port->fp_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7793
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7794
		switch (FC_PORT_STATE_MASK(port->fp_state)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7795
		case FC_STATE_OFFLINE:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7796
			val->PortState = FC_HBA_PORTSTATE_OFFLINE;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7797
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7798
		case FC_STATE_ONLINE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7799
		case FC_STATE_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7800
		case FC_STATE_NAMESERVICE:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7801
			val->PortState = FC_HBA_PORTSTATE_ONLINE;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7802
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7803
		default:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7804
			val->PortState = FC_HBA_PORTSTATE_UNKNOWN;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7805
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7806
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7807
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7808
		/* Translate from LV to FC-HBA port type codes */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7809
		switch (port->fp_port_type.port_type) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7810
		case FC_NS_PORT_N:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7811
			val->PortType = FC_HBA_PORTTYPE_NPORT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7812
			break;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7813
		case FC_NS_PORT_NL:
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7814
			/* Actually means loop for us */
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7815
			val->PortType = FC_HBA_PORTTYPE_LPORT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7816
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7817
		case FC_NS_PORT_F:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7818
			val->PortType = FC_HBA_PORTTYPE_FPORT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7819
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7820
		case FC_NS_PORT_FL:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7821
			val->PortType = FC_HBA_PORTTYPE_FLPORT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7822
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7823
		case FC_NS_PORT_E:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7824
			val->PortType = FC_HBA_PORTTYPE_EPORT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7825
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7826
		default:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7827
			val->PortType = FC_HBA_PORTTYPE_OTHER;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7828
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7829
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7830
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7831
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7832
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7833
		 * If fp has decided that the topology is public loop,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7834
		 * we will indicate that using the appropriate
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7835
		 * FC HBA API constant.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7836
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7837
		switch (port->fp_topology) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7838
		case FC_TOP_PUBLIC_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7839
			val->PortType = FC_HBA_PORTTYPE_NLPORT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7840
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7841
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7842
		case FC_TOP_PT_PT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7843
			val->PortType = FC_HBA_PORTTYPE_PTP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7844
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7845
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7846
		case FC_TOP_UNKNOWN:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7847
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7848
			 * This should cover the case where nothing is connected
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7849
			 * to the port. Crystal+ is p'bly an exception here.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7850
			 * For Crystal+, port 0 will come up as private loop
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7851
			 * (i.e fp_bind_state will be FC_STATE_LOOP) even when
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7852
			 * nothing is connected to it.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7853
			 * Current plan is to let userland handle this.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7854
			 */
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7855
			if (port->fp_bind_state == FC_STATE_OFFLINE) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7856
				val->PortType = FC_HBA_PORTTYPE_UNKNOWN;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7857
			}
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7858
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7859
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7860
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7861
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7862
			 * Do Nothing.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7863
			 * Unused:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7864
			 *   val->PortType = FC_HBA_PORTTYPE_GPORT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7865
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7866
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7867
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7868
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7869
		val->PortSupportedClassofService =
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7870
		    port->fp_hba_port_attrs.supported_cos;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7871
		val->PortSupportedFc4Types[0] = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7872
		bcopy(port->fp_fc4_types, val->PortActiveFc4Types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7873
		    sizeof (val->PortActiveFc4Types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7874
		bcopy(port->fp_sym_port_name, val->PortSymbolicName,
10005
b6940fb2404d 6679330 fp needs to reset the sysmbolic port name buffer before storing it into userland.
bing hu - Sun Microsystems - Beijing China <Bing.Hu@Sun.COM>
parents: 9163
diff changeset
  7875
		    port->fp_sym_port_namelen);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7876
		val->PortSupportedSpeed =
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7877
		    port->fp_hba_port_attrs.supported_speed;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7878
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7879
		switch (FC_PORT_SPEED_MASK(port->fp_state)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7880
		case FC_STATE_1GBIT_SPEED:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7881
			val->PortSpeed = FC_HBA_PORTSPEED_1GBIT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7882
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7883
		case FC_STATE_2GBIT_SPEED:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7884
			val->PortSpeed = FC_HBA_PORTSPEED_2GBIT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7885
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7886
		case FC_STATE_4GBIT_SPEED:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7887
			val->PortSpeed = FC_HBA_PORTSPEED_4GBIT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7888
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7889
		case FC_STATE_8GBIT_SPEED:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7890
			val->PortSpeed = FC_HBA_PORTSPEED_8GBIT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7891
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7892
		case FC_STATE_10GBIT_SPEED:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7893
			val->PortSpeed = FC_HBA_PORTSPEED_10GBIT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7894
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7895
		case FC_STATE_16GBIT_SPEED:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7896
			val->PortSpeed = FC_HBA_PORTSPEED_16GBIT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7897
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7898
		default:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7899
			val->PortSpeed = FC_HBA_PORTSPEED_UNKNOWN;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7900
			break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7901
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7902
		val->PortMaxFrameSize = port->fp_hba_port_attrs.max_frame_size;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7903
		val->NumberofDiscoveredPorts = port->fp_dev_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7904
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7905
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7906
		if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7907
			val32 = kmem_zalloc(sizeof (*val32), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7908
			val32->version = val->version;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7909
			val32->lastChange = val->lastChange;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7910
			val32->fp_minor = val->fp_minor;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7911
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7912
			bcopy(&val->PortWWN.raw_wwn, &val32->PortWWN.raw_wwn,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7913
			    sizeof (val->PortWWN.raw_wwn));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7914
			bcopy(&val->NodeWWN.raw_wwn, &val32->NodeWWN.raw_wwn,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  7915
			    sizeof (val->NodeWWN.raw_wwn));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7916
			val32->PortFcId = val->PortFcId;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7917
			val32->PortState = val->PortState;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7918
			val32->PortType = val->PortType;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7919
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7920
			val32->PortSupportedClassofService =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7921
			    val->PortSupportedClassofService;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7922
			bcopy(val->PortActiveFc4Types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7923
			    val32->PortActiveFc4Types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7924
			    sizeof (val->PortActiveFc4Types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7925
			bcopy(val->PortSymbolicName, val32->PortSymbolicName,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7926
			    sizeof (val->PortSymbolicName));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7927
			bcopy(&val->FabricName, &val32->FabricName,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7928
			    sizeof (val->FabricName.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7929
			val32->PortSupportedSpeed = val->PortSupportedSpeed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7930
			val32->PortSpeed = val->PortSpeed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7931
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7932
			val32->PortMaxFrameSize = val->PortMaxFrameSize;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7933
			val32->NumberofDiscoveredPorts =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7934
			    val->NumberofDiscoveredPorts;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7935
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7936
			if (fp_copyout((void *)val32, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7937
			    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7938
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7939
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7940
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7941
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7942
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7943
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7944
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7945
			kmem_free(val32, sizeof (*val32));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7946
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7947
			if (fp_copyout((void *)val, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7948
			    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7949
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7950
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7951
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7952
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7953
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7954
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7955
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7956
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7957
		kmem_free(val, sizeof (*val));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7958
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7959
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7960
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7961
	case FCIO_GET_DISCOVERED_PORT_ATTRIBUTES: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7962
		fc_hba_port_attributes_t	*val;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7963
		fc_hba_port_attributes32_t	*val32;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7964
		uint32_t	index = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7965
		fc_remote_port_t *tmp_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7966
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7967
		if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7968
			if (fcio->fcio_olen < sizeof (*val32) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7969
			    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7970
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7971
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7972
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7973
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7974
			if (fcio->fcio_olen < sizeof (*val) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7975
			    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7976
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7977
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7978
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7979
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7980
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7981
		if (ddi_copyin(fcio->fcio_ibuf, &index, sizeof (index), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7982
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7983
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7984
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7985
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7986
		if (index >= port->fp_dev_count) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7987
			FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7988
			    "User supplied index out of range");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7989
			fcio->fcio_errno = FC_OUTOFBOUNDS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7990
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7991
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7992
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7993
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7994
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7995
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7996
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7997
		val = kmem_zalloc(sizeof (*val), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7998
		val->version = FC_HBA_PORT_ATTRIBUTES_VERSION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  7999
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8000
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8001
		tmp_pd = fctl_lookup_pd_by_index(port, index);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8002
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8003
		if (tmp_pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8004
			fcio->fcio_errno = FC_BADPORT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8005
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8006
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8007
			val->lastChange = port->fp_last_change;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8008
			val->fp_minor = port->fp_instance;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8009
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8010
			mutex_enter(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8011
			bcopy(&tmp_pd->pd_port_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8012
			    &val->PortWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8013
			    sizeof (val->PortWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8014
			bcopy(&tmp_pd->pd_remote_nodep->fd_node_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8015
			    &val->NodeWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8016
			    sizeof (val->NodeWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8017
			val->PortFcId = tmp_pd->pd_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8018
			bcopy(tmp_pd->pd_spn, val->PortSymbolicName,
10005
b6940fb2404d 6679330 fp needs to reset the sysmbolic port name buffer before storing it into userland.
bing hu - Sun Microsystems - Beijing China <Bing.Hu@Sun.COM>
parents: 9163
diff changeset
  8019
			    tmp_pd->pd_spn_len);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8020
			val->PortSupportedClassofService = tmp_pd->pd_cos;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8021
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8022
			 * we will assume the sizeof these pd_fc4types and
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8023
			 * portActiveFc4Types will remain the same.  we could
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8024
			 * add in a check for it, but we decided it was unneeded
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8025
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8026
			bcopy((caddr_t)tmp_pd->pd_fc4types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8027
			    val->PortActiveFc4Types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8028
			    sizeof (tmp_pd->pd_fc4types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8029
			val->PortState =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8030
			    fp_map_remote_port_state(tmp_pd->pd_state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8031
			mutex_exit(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8032
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8033
			val->PortType = FC_HBA_PORTTYPE_UNKNOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8034
			val->PortSupportedFc4Types[0] = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8035
			val->PortSupportedSpeed = FC_HBA_PORTSPEED_UNKNOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8036
			val->PortSpeed = FC_HBA_PORTSPEED_UNKNOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8037
			val->PortMaxFrameSize = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8038
			val->NumberofDiscoveredPorts = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8039
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8040
			if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8041
				val32 = kmem_zalloc(sizeof (*val32), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8042
				val32->version = val->version;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8043
				val32->lastChange = val->lastChange;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8044
				val32->fp_minor = val->fp_minor;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8045
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8046
				bcopy(&val->PortWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8047
				    &val32->PortWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8048
				    sizeof (val->PortWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8049
				bcopy(&val->NodeWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8050
				    &val32->NodeWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8051
				    sizeof (val->NodeWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8052
				val32->PortFcId = val->PortFcId;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8053
				bcopy(val->PortSymbolicName,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8054
				    val32->PortSymbolicName,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8055
				    sizeof (val->PortSymbolicName));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8056
				val32->PortSupportedClassofService =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8057
				    val->PortSupportedClassofService;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8058
				bcopy(val->PortActiveFc4Types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8059
				    val32->PortActiveFc4Types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8060
				    sizeof (tmp_pd->pd_fc4types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8061
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8062
				val32->PortType = val->PortType;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8063
				val32->PortState = val->PortState;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8064
				val32->PortSupportedFc4Types[0] =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8065
				    val->PortSupportedFc4Types[0];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8066
				val32->PortSupportedSpeed =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8067
				    val->PortSupportedSpeed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8068
				val32->PortSpeed = val->PortSpeed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8069
				val32->PortMaxFrameSize =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8070
				    val->PortMaxFrameSize;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8071
				val32->NumberofDiscoveredPorts =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8072
				    val->NumberofDiscoveredPorts;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8073
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8074
				if (fp_copyout((void *)val32,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8075
				    (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8076
				    fcio->fcio_olen, mode) == 0) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  8077
					if (fp_fcio_copyout(fcio,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  8078
					    data, mode)) {
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  8079
						rval = EFAULT;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  8080
					}
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8081
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8082
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8083
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8084
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8085
				kmem_free(val32, sizeof (*val32));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8086
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8087
				if (fp_copyout((void *)val,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8088
				    (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8089
				    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8090
					if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8091
						rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8092
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8093
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8094
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8095
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8096
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8097
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8098
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8099
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8100
		kmem_free(val, sizeof (*val));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8101
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8102
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8103
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8104
	case FCIO_GET_PORT_ATTRIBUTES: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8105
		fc_hba_port_attributes_t    *val;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8106
		fc_hba_port_attributes32_t  *val32;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8107
		la_wwn_t		    wwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8108
		fc_remote_port_t	    *tmp_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8109
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8110
		if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8111
			if (fcio->fcio_olen < sizeof (*val32) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8112
			    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8113
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8114
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8115
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8116
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8117
			if (fcio->fcio_olen < sizeof (*val) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8118
			    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8119
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8120
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8121
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8122
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8123
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8124
		if (ddi_copyin(fcio->fcio_ibuf, &wwn, sizeof (wwn), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8125
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8126
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8127
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8128
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8129
		val = kmem_zalloc(sizeof (*val), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8130
		val->version = FC_HBA_PORT_ATTRIBUTES_VERSION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8131
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8132
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8133
		tmp_pd = fctl_lookup_pd_by_wwn(port, wwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8134
		val->lastChange = port->fp_last_change;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8135
		val->fp_minor = port->fp_instance;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8136
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8137
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8138
		if (tmp_pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8139
			fcio->fcio_errno = FC_BADWWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8140
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8141
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8142
			mutex_enter(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8143
			bcopy(&tmp_pd->pd_port_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8144
			    &val->PortWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8145
			    sizeof (val->PortWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8146
			bcopy(&tmp_pd->pd_remote_nodep->fd_node_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8147
			    &val->NodeWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8148
			    sizeof (val->NodeWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8149
			val->PortFcId = tmp_pd->pd_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8150
			bcopy(tmp_pd->pd_spn, val->PortSymbolicName,
10005
b6940fb2404d 6679330 fp needs to reset the sysmbolic port name buffer before storing it into userland.
bing hu - Sun Microsystems - Beijing China <Bing.Hu@Sun.COM>
parents: 9163
diff changeset
  8151
			    tmp_pd->pd_spn_len);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8152
			val->PortSupportedClassofService = tmp_pd->pd_cos;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8153
			val->PortType = FC_HBA_PORTTYPE_UNKNOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8154
			val->PortState =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8155
			    fp_map_remote_port_state(tmp_pd->pd_state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8156
			val->PortSupportedFc4Types[0] = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8157
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8158
			 * we will assume the sizeof these pd_fc4types and
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8159
			 * portActiveFc4Types will remain the same.  we could
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8160
			 * add in a check for it, but we decided it was unneeded
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8161
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8162
			bcopy((caddr_t)tmp_pd->pd_fc4types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8163
			    val->PortActiveFc4Types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8164
			    sizeof (tmp_pd->pd_fc4types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8165
			val->PortSupportedSpeed = FC_HBA_PORTSPEED_UNKNOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8166
			val->PortSpeed = FC_HBA_PORTSPEED_UNKNOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8167
			val->PortMaxFrameSize = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8168
			val->NumberofDiscoveredPorts = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8169
			mutex_exit(&tmp_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8170
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8171
			if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8172
				val32 = kmem_zalloc(sizeof (*val32), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8173
				val32->version = val->version;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8174
				val32->lastChange = val->lastChange;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8175
				val32->fp_minor = val->fp_minor;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8176
				bcopy(&val->PortWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8177
				    &val32->PortWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8178
				    sizeof (val->PortWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8179
				bcopy(&val->NodeWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8180
				    &val32->NodeWWN.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8181
				    sizeof (val->NodeWWN.raw_wwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8182
				val32->PortFcId = val->PortFcId;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8183
				bcopy(val->PortSymbolicName,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8184
				    val32->PortSymbolicName,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8185
				    sizeof (val->PortSymbolicName));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8186
				val32->PortSupportedClassofService =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8187
				    val->PortSupportedClassofService;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8188
				val32->PortType = val->PortType;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8189
				val32->PortState = val->PortState;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8190
				val32->PortSupportedFc4Types[0] =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8191
				    val->PortSupportedFc4Types[0];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8192
				bcopy(val->PortActiveFc4Types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8193
				    val32->PortActiveFc4Types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8194
				    sizeof (tmp_pd->pd_fc4types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8195
				val32->PortSupportedSpeed =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8196
				    val->PortSupportedSpeed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8197
				val32->PortSpeed = val->PortSpeed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8198
				val32->PortMaxFrameSize = val->PortMaxFrameSize;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8199
				val32->NumberofDiscoveredPorts =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8200
				    val->NumberofDiscoveredPorts;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8201
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8202
				if (fp_copyout((void *)val32,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8203
				    (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8204
				    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8205
					if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8206
						rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8207
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8208
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8209
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8210
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8211
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8212
				kmem_free(val32, sizeof (*val32));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8213
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8214
				if (fp_copyout((void *)val,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8215
				    (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8216
				    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8217
					if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8218
						rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8219
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8220
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8221
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8222
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8223
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8224
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8225
		kmem_free(val, sizeof (*val));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8226
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8227
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8228
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8229
	case FCIO_GET_NUM_DEVS: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8230
		int num_devices;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8231
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8232
		if (fcio->fcio_olen != sizeof (num_devices) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8233
		    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8234
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8235
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8236
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8237
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8238
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8239
		switch (port->fp_topology) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8240
		case FC_TOP_PRIVATE_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8241
		case FC_TOP_PT_PT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8242
			num_devices = port->fp_total_devices;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8243
			fcio->fcio_errno = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8244
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8245
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8246
		case FC_TOP_PUBLIC_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8247
		case FC_TOP_FABRIC:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8248
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8249
			job = fctl_alloc_job(JOB_NS_CMD, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8250
			    NULL, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8251
			ASSERT(job != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8252
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8253
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8254
			 * In FC-GS-2 the Name Server doesn't send out
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8255
			 * RSCNs for any Name Server Database updates
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8256
			 * When it is finally fixed there is no need
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8257
			 * to probe as below and should be removed.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8258
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8259
			(void) fp_ns_get_devcount(port, job, 0, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8260
			fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8261
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8262
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8263
			num_devices = port->fp_total_devices;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8264
			fcio->fcio_errno = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8265
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8266
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8267
		case FC_TOP_NO_NS:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8268
			/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8269
		case FC_TOP_UNKNOWN:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8270
			/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8271
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8272
			num_devices = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8273
			fcio->fcio_errno = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8274
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8275
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8276
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8277
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8278
		if (fp_copyout((void *)&num_devices,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8279
		    (void *)fcio->fcio_obuf, fcio->fcio_olen,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8280
		    mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8281
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8282
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8283
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8284
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8285
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8286
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8287
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8288
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8289
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8290
	case FCIO_GET_DEV_LIST: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8291
		int num_devices;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8292
		int new_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8293
		int map_size;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8294
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8295
		if (fcio->fcio_xfer != FCIO_XFER_READ ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8296
		    fcio->fcio_alen != sizeof (new_count)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8297
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8298
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8299
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8300
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8301
		num_devices = fcio->fcio_olen / sizeof (fc_port_dev_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8302
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8303
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8304
		if (num_devices < port->fp_total_devices) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8305
			fcio->fcio_errno = FC_TOOMANY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8306
			new_count = port->fp_total_devices;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8307
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8308
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8309
			if (fp_copyout((void *)&new_count,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8310
			    (void *)fcio->fcio_abuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8311
			    sizeof (new_count), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8312
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8313
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8314
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8315
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8316
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8317
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8318
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8319
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8320
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8321
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8322
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8323
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8324
		if (port->fp_total_devices <= 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8325
			fcio->fcio_errno = FC_NO_MAP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8326
			new_count = port->fp_total_devices;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8327
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8328
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8329
			if (fp_copyout((void *)&new_count,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8330
			    (void *)fcio->fcio_abuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8331
			    sizeof (new_count), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8332
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8333
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8334
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8335
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8336
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8337
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8338
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8339
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8340
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8341
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8342
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8343
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8344
		switch (port->fp_topology) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8345
		case FC_TOP_PRIVATE_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8346
			if (fp_fillout_loopmap(port, fcio,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8347
			    mode) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8348
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8349
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8350
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8351
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8352
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8353
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8354
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8355
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8356
		case FC_TOP_PT_PT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8357
			if (fp_fillout_p2pmap(port, fcio,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8358
			    mode) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8359
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8360
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8361
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8362
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8363
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8364
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8365
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8366
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8367
		case FC_TOP_PUBLIC_LOOP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8368
		case FC_TOP_FABRIC: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8369
			fctl_ns_req_t *ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8370
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8371
			map_size =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8372
			    sizeof (fc_port_dev_t) * port->fp_total_devices;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8373
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8374
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8375
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8376
			ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gan_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8377
			    sizeof (ns_resp_gan_t), map_size,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8378
			    (FCTL_NS_FILL_NS_MAP | FCTL_NS_BUF_IS_USERLAND),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8379
			    KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8380
			ASSERT(ns_cmd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8381
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8382
			ns_cmd->ns_gan_index = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8383
			ns_cmd->ns_gan_sid = FCTL_GAN_START_ID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8384
			ns_cmd->ns_cmd_code = NS_GA_NXT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8385
			ns_cmd->ns_gan_max = map_size / sizeof (fc_port_dev_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8386
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8387
			job = fctl_alloc_job(JOB_PORT_GETMAP, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8388
			    NULL, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8389
			ASSERT(job != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8390
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8391
			ret = fp_ns_query(port, ns_cmd, job, 1, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8392
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8393
			if (ret != FC_SUCCESS ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8394
			    job->job_result != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8395
				fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8396
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8397
				fcio->fcio_errno = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8398
				new_count = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8399
				if (fp_copyout((void *)&new_count,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8400
				    (void *)fcio->fcio_abuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8401
				    sizeof (new_count), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8402
					fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8403
					mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8404
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8405
					break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8406
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8407
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8408
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8409
					fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8410
					mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8411
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8412
					break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8413
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8414
				rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8415
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8416
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8417
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8418
			fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8419
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8420
			new_count = ns_cmd->ns_gan_index;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8421
			if (fp_copyout((void *)&new_count,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8422
			    (void *)fcio->fcio_abuf, sizeof (new_count),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8423
			    mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8424
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8425
				fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8426
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8427
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8428
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8429
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8430
			if (fp_copyout((void *)ns_cmd->ns_data_buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8431
			    (void *)fcio->fcio_obuf, sizeof (fc_port_dev_t) *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8432
			    ns_cmd->ns_gan_index, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8433
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8434
				fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8435
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8436
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8437
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8438
			fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8439
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8440
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8441
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8442
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8443
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8444
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8445
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8446
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8447
		case FC_TOP_NO_NS:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8448
			/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8449
		case FC_TOP_UNKNOWN:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8450
			/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8451
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8452
			fcio->fcio_errno = FC_NO_MAP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8453
			num_devices = port->fp_total_devices;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8454
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8455
			if (fp_copyout((void *)&new_count,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8456
			    (void *)fcio->fcio_abuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8457
			    sizeof (new_count), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8458
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8459
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8460
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8461
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8462
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8463
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8464
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8465
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8466
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8467
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8468
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8469
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8470
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8471
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8472
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8473
	case FCIO_GET_SYM_PNAME: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8474
		rval = ENOTSUP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8475
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8476
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8477
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8478
	case FCIO_GET_SYM_NNAME: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8479
		rval = ENOTSUP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8480
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8481
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8482
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8483
	case FCIO_SET_SYM_PNAME: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8484
		rval = ENOTSUP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8485
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8486
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8487
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8488
	case FCIO_SET_SYM_NNAME: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8489
		rval = ENOTSUP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8490
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8491
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8492
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8493
	case FCIO_GET_LOGI_PARAMS: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8494
		la_wwn_t		pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8495
		la_wwn_t		*my_pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8496
		la_els_logi_t		*params;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8497
		la_els_logi32_t		*params32;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8498
		fc_remote_node_t	*node;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8499
		fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8500
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8501
		if (fcio->fcio_ilen != sizeof (la_wwn_t) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8502
		    (fcio->fcio_xfer & FCIO_XFER_READ) == 0 ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8503
		    (fcio->fcio_xfer & FCIO_XFER_WRITE) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8504
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8505
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8506
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8507
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8508
		if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8509
			if (fcio->fcio_olen != sizeof (la_els_logi32_t)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8510
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8511
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8512
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8513
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8514
			if (fcio->fcio_olen != sizeof (la_els_logi_t)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8515
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8516
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8517
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8518
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8519
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8520
		if (ddi_copyin(fcio->fcio_ibuf, &pwwn, sizeof (pwwn), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8521
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8522
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8523
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8524
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8525
		pd = fctl_hold_remote_port_by_pwwn(port, &pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8526
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8527
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8528
			my_pwwn = &port->fp_service_params.nport_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8529
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8530
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8531
			if (fctl_wwn_cmp(&pwwn, my_pwwn) != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8532
				rval = ENXIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8533
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8534
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8535
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8536
			params = kmem_zalloc(sizeof (*params), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8537
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8538
			*params = port->fp_service_params;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8539
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8540
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8541
			params = kmem_zalloc(sizeof (*params), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8542
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8543
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8544
			params->ls_code.mbz = params->ls_code.ls_code = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8545
			params->common_service = pd->pd_csp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8546
			params->nport_ww_name = pd->pd_port_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8547
			params->class_1 = pd->pd_clsp1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8548
			params->class_2 = pd->pd_clsp2;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8549
			params->class_3 = pd->pd_clsp3;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8550
			node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8551
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8552
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8553
			bzero(params->reserved, sizeof (params->reserved));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8554
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8555
			mutex_enter(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8556
			bcopy(node->fd_vv, params->vendor_version,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8557
			    sizeof (node->fd_vv));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8558
			params->node_ww_name = node->fd_node_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8559
			mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8560
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8561
			fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8562
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8563
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8564
		if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8565
			params32 = kmem_zalloc(sizeof (*params32), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8566
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8567
			params32->ls_code.mbz = params->ls_code.mbz;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8568
			params32->common_service = params->common_service;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8569
			params32->nport_ww_name = params->nport_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8570
			params32->class_1 = params->class_1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8571
			params32->class_2 = params->class_2;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8572
			params32->class_3 = params->class_3;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8573
			bzero(params32->reserved, sizeof (params32->reserved));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8574
			bcopy(params->vendor_version, params32->vendor_version,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8575
			    sizeof (node->fd_vv));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8576
			params32->node_ww_name = params->node_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8577
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8578
			if (ddi_copyout((void *)params32,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8579
			    (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8580
			    sizeof (*params32), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8581
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8582
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8583
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8584
			kmem_free(params32, sizeof (*params32));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8585
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8586
			if (ddi_copyout((void *)params, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8587
			    sizeof (*params), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8588
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8589
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8590
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8591
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8592
		kmem_free(params, sizeof (*params));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8593
		if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8594
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8595
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8596
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8597
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8598
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8599
	case FCIO_DEV_LOGOUT:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8600
	case FCIO_DEV_LOGIN:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8601
		if (fcio->fcio_ilen != sizeof (la_wwn_t) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8602
		    fcio->fcio_xfer != FCIO_XFER_WRITE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8603
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8604
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8605
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8606
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8607
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8608
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8609
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8610
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8611
		if (fcio->fcio_cmd == FCIO_DEV_LOGIN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8612
			jcode = JOB_FCIO_LOGIN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8613
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8614
			jcode = JOB_FCIO_LOGOUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8615
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8616
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8617
		kfcio = kmem_zalloc(sizeof (*kfcio), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8618
		bcopy(fcio, kfcio, sizeof (*fcio));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8619
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8620
		if (kfcio->fcio_ilen) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8621
			kfcio->fcio_ibuf = kmem_zalloc(kfcio->fcio_ilen,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8622
			    KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8623
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8624
			if (ddi_copyin((void *)fcio->fcio_ibuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8625
			    (void *)kfcio->fcio_ibuf, kfcio->fcio_ilen,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8626
			    mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8627
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8628
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8629
				kmem_free(kfcio->fcio_ibuf, kfcio->fcio_ilen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8630
				kmem_free(kfcio, sizeof (*kfcio));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8631
				fcio->fcio_errno = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8632
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8633
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8634
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8635
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8636
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8637
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8638
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8639
		job = fctl_alloc_job(jcode, 0, NULL, NULL, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8640
		job->job_private = kfcio;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8641
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8642
		fctl_enque_job(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8643
		fctl_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8644
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8645
		rval = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8646
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8647
		fcio->fcio_errno = kfcio->fcio_errno;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8648
		if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8649
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8650
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8651
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8652
		kmem_free(kfcio->fcio_ibuf, kfcio->fcio_ilen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8653
		kmem_free(kfcio, sizeof (*kfcio));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8654
		fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8655
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8656
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8657
	case FCIO_GET_STATE: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8658
		la_wwn_t		pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8659
		uint32_t		state;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  8660
		fc_remote_port_t	*pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8661
		fctl_ns_req_t		*ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8662
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8663
		if (fcio->fcio_ilen != sizeof (la_wwn_t) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8664
		    fcio->fcio_olen != sizeof (state) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8665
		    (fcio->fcio_xfer & FCIO_XFER_WRITE) == 0 ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8666
		    (fcio->fcio_xfer & FCIO_XFER_READ) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8667
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8668
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8669
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8670
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8671
		if (ddi_copyin(fcio->fcio_ibuf, &pwwn, sizeof (pwwn), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8672
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8673
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8674
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8675
		fcio->fcio_errno = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8676
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8677
		pd = fctl_hold_remote_port_by_pwwn(port, &pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8678
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8679
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8680
			if (FC_IS_TOP_SWITCH(port->fp_topology)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8681
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8682
				job = fctl_alloc_job(JOB_PLOGI_ONE, 0,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8683
				    NULL, NULL, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8684
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8685
				job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8686
				job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8687
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8688
				ns_cmd = fctl_alloc_ns_cmd(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8689
				    sizeof (ns_req_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8690
				    sizeof (ns_resp_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8691
				    sizeof (ns_resp_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8692
				    FCTL_NS_BUF_IS_USERLAND, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8693
				ASSERT(ns_cmd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8694
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8695
				ns_cmd->ns_cmd_code = NS_GID_PN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8696
				((ns_req_gid_pn_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8697
				    (ns_cmd->ns_cmd_buf))->pwwn = pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8698
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8699
				ret = fp_ns_query(port, ns_cmd, job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8700
				    1, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8701
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8702
				if (ret != FC_SUCCESS || job->job_result !=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8703
				    FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8704
					if (ret != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8705
						fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8706
					} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8707
						fcio->fcio_errno =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8708
						    job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8709
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8710
					rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8711
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8712
					state = PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8713
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8714
				fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8715
				fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8716
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8717
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8718
				fcio->fcio_errno = FC_BADWWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8719
				rval = ENXIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8720
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8721
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8722
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8723
			state = pd->pd_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8724
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8725
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8726
			fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8727
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8728
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8729
		if (!rval) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8730
			if (ddi_copyout((void *)&state,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8731
			    (void *)fcio->fcio_obuf, sizeof (state),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8732
			    mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8733
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8734
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8735
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8736
		if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8737
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8738
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8739
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8740
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8741
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8742
	case FCIO_DEV_REMOVE: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8743
		la_wwn_t	pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8744
		fc_portmap_t	*changelist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8745
		fc_remote_port_t *pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8746
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8747
		if (fcio->fcio_ilen != sizeof (la_wwn_t) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8748
		    fcio->fcio_xfer != FCIO_XFER_WRITE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8749
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8750
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8751
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8752
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8753
		if (ddi_copyin(fcio->fcio_ibuf, &pwwn, sizeof (pwwn), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8754
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8755
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8756
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8757
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8758
		pd = fctl_hold_remote_port_by_pwwn(port, &pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8759
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8760
			rval = ENXIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8761
			fcio->fcio_errno = FC_BADWWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8762
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8763
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8764
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8765
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8766
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8767
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8768
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8769
		if (pd->pd_ref_count > 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8770
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8771
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8772
			rval = EBUSY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8773
			fcio->fcio_errno = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8774
			fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8775
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8776
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8777
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8778
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8779
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8780
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8781
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8782
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8783
		changelist = kmem_zalloc(sizeof (*changelist), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8784
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8785
		fctl_copy_portmap(changelist, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8786
		changelist->map_type = PORT_DEVICE_USER_LOGOUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8787
		(void) fp_ulp_devc_cb(port, changelist, 1, 1, KM_SLEEP, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8788
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8789
		fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8790
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8791
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8792
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8793
	case FCIO_GET_FCODE_REV: {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  8794
		caddr_t		fcode_rev;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8795
		fc_fca_pm_t	pm;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8796
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8797
		if (fcio->fcio_olen < FC_FCODE_REV_SIZE ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8798
		    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8799
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8800
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8801
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8802
		bzero((caddr_t)&pm, sizeof (pm));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8803
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8804
		fcode_rev = kmem_zalloc(fcio->fcio_olen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8805
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8806
		pm.pm_cmd_flags = FC_FCA_PM_READ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8807
		pm.pm_cmd_code = FC_PORT_GET_FCODE_REV;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8808
		pm.pm_data_len = fcio->fcio_olen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8809
		pm.pm_data_buf = fcode_rev;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8810
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8811
		ret = port->fp_fca_tran->fca_port_manage(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8812
		    port->fp_fca_handle, &pm);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8813
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8814
		if (ret == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8815
			if (ddi_copyout((void *)fcode_rev,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8816
			    (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8817
			    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8818
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8819
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8820
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8821
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8822
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8823
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8824
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8825
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8826
			 * check if buffer was not large enough to obtain
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8827
			 * FCODE version.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8828
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8829
			if (pm.pm_data_len > fcio->fcio_olen) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8830
				rval = ENOMEM;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8831
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8832
				rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8833
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8834
			fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8835
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8836
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8837
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8838
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8839
		kmem_free(fcode_rev, fcio->fcio_olen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8840
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8841
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8842
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8843
	case FCIO_GET_FW_REV: {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  8844
		caddr_t		fw_rev;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8845
		fc_fca_pm_t	pm;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8846
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8847
		if (fcio->fcio_olen < FC_FW_REV_SIZE ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8848
		    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8849
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8850
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8851
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8852
		bzero((caddr_t)&pm, sizeof (pm));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8853
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8854
		fw_rev = kmem_zalloc(fcio->fcio_olen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8855
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8856
		pm.pm_cmd_flags = FC_FCA_PM_READ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8857
		pm.pm_cmd_code = FC_PORT_GET_FW_REV;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8858
		pm.pm_data_len = fcio->fcio_olen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8859
		pm.pm_data_buf = fw_rev;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8860
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8861
		ret = port->fp_fca_tran->fca_port_manage(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8862
		    port->fp_fca_handle, &pm);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8863
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8864
		if (ret == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8865
			if (ddi_copyout((void *)fw_rev,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8866
			    (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8867
			    fcio->fcio_olen, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8868
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8869
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8870
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8871
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8872
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8873
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8874
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8875
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8876
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8877
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8878
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8879
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8880
		kmem_free(fw_rev, fcio->fcio_olen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8881
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8882
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8883
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8884
	case FCIO_GET_DUMP_SIZE: {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  8885
		uint32_t	dump_size;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8886
		fc_fca_pm_t	pm;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8887
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8888
		if (fcio->fcio_olen != sizeof (dump_size) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8889
		    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8890
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8891
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8892
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8893
		bzero((caddr_t)&pm, sizeof (pm));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8894
		pm.pm_cmd_flags = FC_FCA_PM_READ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8895
		pm.pm_cmd_code = FC_PORT_GET_DUMP_SIZE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8896
		pm.pm_data_len = sizeof (dump_size);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8897
		pm.pm_data_buf = (caddr_t)&dump_size;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8898
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8899
		ret = port->fp_fca_tran->fca_port_manage(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8900
		    port->fp_fca_handle, &pm);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8901
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8902
		if (ret == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8903
			if (ddi_copyout((void *)&dump_size,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8904
			    (void *)fcio->fcio_obuf, sizeof (dump_size),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8905
			    mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8906
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8907
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8908
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8909
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8910
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8911
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8912
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8913
			fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8914
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8915
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8916
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8917
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8918
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8919
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8920
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8921
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8922
	case FCIO_DOWNLOAD_FW: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8923
		caddr_t		firmware;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8924
		fc_fca_pm_t	pm;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8925
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8926
		if (fcio->fcio_ilen <= 0 ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8927
		    fcio->fcio_xfer != FCIO_XFER_WRITE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8928
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8929
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8930
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8931
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8932
		firmware = kmem_zalloc(fcio->fcio_ilen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8933
		if (ddi_copyin(fcio->fcio_ibuf, firmware,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8934
		    fcio->fcio_ilen, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8935
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8936
			kmem_free(firmware, fcio->fcio_ilen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8937
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8938
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8939
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8940
		bzero((caddr_t)&pm, sizeof (pm));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8941
		pm.pm_cmd_flags = FC_FCA_PM_WRITE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8942
		pm.pm_cmd_code = FC_PORT_DOWNLOAD_FW;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8943
		pm.pm_data_len = fcio->fcio_ilen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8944
		pm.pm_data_buf = firmware;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8945
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8946
		ret = port->fp_fca_tran->fca_port_manage(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8947
		    port->fp_fca_handle, &pm);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8948
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8949
		kmem_free(firmware, fcio->fcio_ilen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8950
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8951
		if (ret != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8952
			fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8953
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8954
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8955
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8956
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8957
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8958
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8959
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8960
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8961
	case FCIO_DOWNLOAD_FCODE: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8962
		caddr_t		fcode;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8963
		fc_fca_pm_t	pm;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8964
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8965
		if (fcio->fcio_ilen <= 0 ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8966
		    fcio->fcio_xfer != FCIO_XFER_WRITE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8967
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8968
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8969
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8970
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8971
		fcode = kmem_zalloc(fcio->fcio_ilen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8972
		if (ddi_copyin(fcio->fcio_ibuf, fcode,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8973
		    fcio->fcio_ilen, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8974
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8975
			kmem_free(fcode, fcio->fcio_ilen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8976
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8977
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8978
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8979
		bzero((caddr_t)&pm, sizeof (pm));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8980
		pm.pm_cmd_flags = FC_FCA_PM_WRITE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8981
		pm.pm_cmd_code = FC_PORT_DOWNLOAD_FCODE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8982
		pm.pm_data_len = fcio->fcio_ilen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8983
		pm.pm_data_buf = fcode;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8984
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8985
		ret = port->fp_fca_tran->fca_port_manage(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8986
		    port->fp_fca_handle, &pm);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8987
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8988
		kmem_free(fcode, fcio->fcio_ilen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8989
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8990
		if (ret != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8991
			fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8992
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8993
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8994
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8995
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8996
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8997
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8998
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  8999
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9000
	case FCIO_FORCE_DUMP:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9001
		ret = port->fp_fca_tran->fca_reset(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9002
		    port->fp_fca_handle, FC_FCA_CORE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9003
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9004
		if (ret != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9005
			fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9006
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9007
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9008
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9009
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9010
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9011
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9012
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9013
	case FCIO_GET_DUMP: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9014
		caddr_t		dump;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9015
		uint32_t	dump_size;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9016
		fc_fca_pm_t	pm;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9017
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9018
		if (fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9019
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9020
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9021
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9022
		bzero((caddr_t)&pm, sizeof (pm));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9023
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9024
		pm.pm_cmd_flags = FC_FCA_PM_READ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9025
		pm.pm_cmd_code = FC_PORT_GET_DUMP_SIZE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9026
		pm.pm_data_len = sizeof (dump_size);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9027
		pm.pm_data_buf = (caddr_t)&dump_size;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9028
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9029
		ret = port->fp_fca_tran->fca_port_manage(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9030
		    port->fp_fca_handle, &pm);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9031
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9032
		if (ret != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9033
			fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9034
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9035
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9036
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9037
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9038
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9039
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9040
		if (fcio->fcio_olen != dump_size) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9041
			fcio->fcio_errno = FC_NOMEM;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9042
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9043
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9044
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9045
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9046
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9047
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9048
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9049
		dump = kmem_zalloc(dump_size, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9050
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9051
		bzero((caddr_t)&pm, sizeof (pm));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9052
		pm.pm_cmd_flags = FC_FCA_PM_READ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9053
		pm.pm_cmd_code = FC_PORT_GET_DUMP;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9054
		pm.pm_data_len = dump_size;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9055
		pm.pm_data_buf = dump;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9056
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9057
		ret = port->fp_fca_tran->fca_port_manage(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9058
		    port->fp_fca_handle, &pm);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9059
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9060
		if (ret == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9061
			if (ddi_copyout((void *)dump, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9062
			    dump_size, mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9063
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9064
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9065
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9066
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9067
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9068
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9069
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9070
			fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9071
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9072
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9073
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9074
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9075
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9076
		kmem_free(dump, dump_size);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9077
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9078
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9079
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9080
	case FCIO_GET_TOPOLOGY: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9081
		uint32_t user_topology;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9082
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9083
		if (fcio->fcio_xfer != FCIO_XFER_READ ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9084
		    fcio->fcio_olen != sizeof (user_topology)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9085
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9086
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9087
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9088
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9089
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9090
		if (FC_PORT_STATE_MASK(port->fp_state) == FC_STATE_OFFLINE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9091
			user_topology = FC_TOP_UNKNOWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9092
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9093
			user_topology = port->fp_topology;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9094
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9095
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9096
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9097
		if (ddi_copyout((void *)&user_topology,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9098
		    (void *)fcio->fcio_obuf, sizeof (user_topology),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9099
		    mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9100
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9101
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9102
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9103
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9104
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9105
	case FCIO_RESET_LINK: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9106
		la_wwn_t pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9107
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9108
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9109
		 * Look at the output buffer field; if this field has zero
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9110
		 * bytes then attempt to reset the local link/loop. If the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9111
		 * fcio_ibuf field points to a WWN, see if it's an NL_Port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9112
		 * and if yes, determine the LFA and reset the remote LIP
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9113
		 * by LINIT ELS.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9114
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9115
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9116
		if (fcio->fcio_xfer != FCIO_XFER_WRITE ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9117
		    fcio->fcio_ilen != sizeof (pwwn)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9118
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9119
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9120
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9121
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9122
		if (ddi_copyin(fcio->fcio_ibuf, &pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9123
		    sizeof (pwwn), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9124
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9125
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9126
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9127
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9128
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9129
		if (port->fp_soft_state & FP_SOFT_IN_LINK_RESET) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9130
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9131
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9132
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9133
		port->fp_soft_state |= FP_SOFT_IN_LINK_RESET;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9134
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9135
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9136
		job = fctl_alloc_job(JOB_LINK_RESET, 0, NULL, NULL, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9137
		if (job == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9138
			rval = ENOMEM;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9139
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9140
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9141
		job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9142
		job->job_private = (void *)&pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9143
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9144
		fctl_enque_job(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9145
		fctl_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9146
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9147
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9148
		port->fp_soft_state &= ~FP_SOFT_IN_LINK_RESET;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9149
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9150
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9151
		if (job->job_result != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9152
			fcio->fcio_errno = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9153
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9154
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9155
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9156
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9157
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9158
		fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9159
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9160
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9161
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9162
	case FCIO_RESET_HARD:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9163
		ret = port->fp_fca_tran->fca_reset(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9164
		    port->fp_fca_handle, FC_FCA_RESET);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9165
		if (ret != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9166
			fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9167
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9168
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9169
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9170
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9171
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9172
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9173
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9174
	case FCIO_RESET_HARD_CORE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9175
		ret = port->fp_fca_tran->fca_reset(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9176
		    port->fp_fca_handle, FC_FCA_RESET_CORE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9177
		if (ret != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9178
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9179
			fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9180
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9181
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9182
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9183
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9184
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9185
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9186
	case FCIO_DIAG: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9187
		fc_fca_pm_t pm;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9188
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9189
		bzero((caddr_t)&pm, sizeof (fc_fca_pm_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9190
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9191
		/* Validate user buffer from ioctl call. */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9192
		if (((fcio->fcio_ilen > 0) && (fcio->fcio_ibuf == NULL)) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9193
		    ((fcio->fcio_ilen <= 0) && (fcio->fcio_ibuf != NULL)) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9194
		    ((fcio->fcio_alen > 0) && (fcio->fcio_abuf == NULL)) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9195
		    ((fcio->fcio_alen <= 0) && (fcio->fcio_abuf != NULL)) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9196
		    ((fcio->fcio_olen > 0) && (fcio->fcio_obuf == NULL)) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9197
		    ((fcio->fcio_olen <= 0) && (fcio->fcio_obuf != NULL))) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9198
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9199
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9200
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9201
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9202
		if ((pm.pm_cmd_len = fcio->fcio_ilen) > 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9203
			pm.pm_cmd_buf = kmem_zalloc(fcio->fcio_ilen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9204
			if (ddi_copyin(fcio->fcio_ibuf, pm.pm_cmd_buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9205
			    fcio->fcio_ilen, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9206
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9207
				goto fp_fcio_diag_cleanup;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9208
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9209
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9210
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9211
		if ((pm.pm_data_len = fcio->fcio_alen) > 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9212
			pm.pm_data_buf = kmem_zalloc(fcio->fcio_alen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9213
			if (ddi_copyin(fcio->fcio_abuf, pm.pm_data_buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9214
			    fcio->fcio_alen, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9215
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9216
				goto fp_fcio_diag_cleanup;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9217
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9218
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9219
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9220
		if ((pm.pm_stat_len = fcio->fcio_olen) > 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9221
			pm.pm_stat_buf = kmem_zalloc(fcio->fcio_olen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9222
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9223
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9224
		pm.pm_cmd_code = FC_PORT_DIAG;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9225
		pm.pm_cmd_flags = fcio->fcio_cmd_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9226
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9227
		ret = port->fp_fca_tran->fca_port_manage(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9228
		    port->fp_fca_handle, &pm);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9229
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9230
		if (ret != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9231
			if (ret == FC_INVALID_REQUEST) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9232
				rval = ENOTTY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9233
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9234
				rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9235
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9236
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9237
			fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9238
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9239
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9240
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9241
			goto fp_fcio_diag_cleanup;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9242
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9243
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9244
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9245
		 * pm_stat_len will contain the number of status bytes
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9246
		 * an FCA driver requires to return the complete status
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9247
		 * of the requested diag operation. If the user buffer
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9248
		 * is not large enough to hold the entire status, We
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9249
		 * copy only the portion of data the fits in the buffer and
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9250
		 * return a ENOMEM to the user application.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9251
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9252
		if (pm.pm_stat_len > fcio->fcio_olen) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9253
			fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9254
			    "fp:FCIO_DIAG:status buffer too small\n");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9255
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9256
			rval = ENOMEM;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9257
			if (ddi_copyout(pm.pm_stat_buf, fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9258
			    fcio->fcio_olen, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9259
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9260
				goto fp_fcio_diag_cleanup;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9261
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9262
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9263
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9264
			 * Copy only data pm_stat_len bytes of data
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9265
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9266
			if (ddi_copyout(pm.pm_stat_buf, fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9267
			    pm.pm_stat_len, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9268
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9269
				goto fp_fcio_diag_cleanup;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9270
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9271
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9272
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9273
		if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9274
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9275
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9276
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9277
		fp_fcio_diag_cleanup:
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9278
		if (pm.pm_cmd_buf != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9279
			kmem_free(pm.pm_cmd_buf, fcio->fcio_ilen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9280
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9281
		if (pm.pm_data_buf != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9282
			kmem_free(pm.pm_data_buf, fcio->fcio_alen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9283
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9284
		if (pm.pm_stat_buf != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9285
			kmem_free(pm.pm_stat_buf, fcio->fcio_olen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9286
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9287
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9288
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9289
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9290
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9291
	case FCIO_GET_NODE_ID: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9292
		/* validate parameters */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9293
		if (fcio->fcio_xfer != FCIO_XFER_READ ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9294
		    fcio->fcio_olen < sizeof (fc_rnid_t)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9295
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9296
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9297
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9298
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9299
		rval = fp_get_rnid(port, data, mode, fcio);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9300
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9301
		/* ioctl handling is over */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9302
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9303
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9304
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9305
	case FCIO_SEND_NODE_ID: {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9306
		la_wwn_t		pwwn;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9307
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9308
		/* validate parameters */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9309
		if (fcio->fcio_ilen != sizeof (la_wwn_t) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9310
		    fcio->fcio_xfer != FCIO_XFER_READ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9311
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9312
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9313
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9314
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9315
		if (ddi_copyin(fcio->fcio_ibuf, &pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9316
		    sizeof (la_wwn_t), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9317
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9318
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9319
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9320
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9321
		rval = fp_send_rnid(port, data, mode, fcio, &pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9322
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9323
		/* ioctl handling is over */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9324
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9325
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9326
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9327
	case FCIO_SET_NODE_ID: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9328
		if (fcio->fcio_ilen != sizeof (fc_rnid_t) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9329
		    (fcio->fcio_xfer != FCIO_XFER_WRITE)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9330
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9331
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9332
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9333
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9334
		rval = fp_set_rnid(port, data, mode, fcio);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9335
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9336
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9337
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9338
	case FCIO_LINK_STATUS: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9339
		fc_portid_t		rls_req;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9340
		fc_rls_acc_t		*rls_acc;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9341
		fc_fca_pm_t		pm;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9342
		uint32_t		dest, src_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9343
		fp_cmd_t		*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9344
		fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9345
		uchar_t			pd_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9346
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9347
		/* validate parameters */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9348
		if (fcio->fcio_ilen != sizeof (fc_portid_t) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9349
		    fcio->fcio_olen != sizeof (fc_rls_acc_t) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9350
		    fcio->fcio_xfer != FCIO_XFER_RW) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9351
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9352
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9353
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9354
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9355
		if ((fcio->fcio_cmd_flags != FCIO_CFLAGS_RLS_DEST_FPORT) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9356
		    (fcio->fcio_cmd_flags != FCIO_CFLAGS_RLS_DEST_NPORT)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9357
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9358
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9359
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9360
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9361
		if (ddi_copyin((void *)fcio->fcio_ibuf, (void *)&rls_req,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9362
		    sizeof (fc_portid_t), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9363
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9364
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9365
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9366
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9367
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9368
		/* Determine the destination of the RLS frame */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9369
		if (fcio->fcio_cmd_flags == FCIO_CFLAGS_RLS_DEST_FPORT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9370
			dest = FS_FABRIC_F_PORT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9371
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9372
			dest = rls_req.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9373
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9374
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9375
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9376
		src_id = port->fp_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9377
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9378
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9379
		/* If dest is zero OR same as FCA ID, then use port_manage() */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9380
		if (dest == 0 || dest == src_id) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9381
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9382
			/* Allocate memory for link error status block */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9383
			rls_acc = kmem_zalloc(sizeof (*rls_acc), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9384
			ASSERT(rls_acc != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9385
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9386
			/* Prepare the port management structure */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9387
			bzero((caddr_t)&pm, sizeof (pm));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9388
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9389
			pm.pm_cmd_flags = FC_FCA_PM_READ;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9390
			pm.pm_cmd_code	= FC_PORT_RLS;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9391
			pm.pm_data_len	= sizeof (*rls_acc);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9392
			pm.pm_data_buf	= (caddr_t)rls_acc;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9393
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9394
			/* Get the adapter's link error status block */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9395
			ret = port->fp_fca_tran->fca_port_manage(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9396
			    port->fp_fca_handle, &pm);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9397
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9398
			if (ret == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9399
				/* xfer link status block to userland */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9400
				if (ddi_copyout((void *)rls_acc,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9401
				    (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9402
				    sizeof (*rls_acc), mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9403
					if (fp_fcio_copyout(fcio, data,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9404
					    mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9405
						rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9406
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9407
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9408
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9409
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9410
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9411
				rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9412
				fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9413
				if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9414
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9415
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9416
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9417
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9418
			kmem_free(rls_acc, sizeof (*rls_acc));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9419
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9420
			/* ioctl handling is over */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9421
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9422
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9423
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9424
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9425
		 * Send RLS to the destination port.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9426
		 * Having RLS frame destination is as FPORT is not yet
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9427
		 * supported and will be implemented in future, if needed.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9428
		 * Following call to get "pd" will fail if dest is FPORT
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9429
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9430
		pd = fctl_hold_remote_port_by_did(port, dest);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9431
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9432
			fcio->fcio_errno = FC_BADOBJECT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9433
			rval = ENXIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9434
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9435
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9436
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9437
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9438
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9439
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9440
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9441
		if (pd->pd_state != PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9442
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9443
			fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9444
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9445
			fcio->fcio_errno = FC_LOGINREQ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9446
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9447
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9448
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9449
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9450
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9451
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9452
		ASSERT(pd->pd_login_count >= 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9453
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9454
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9455
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9456
		 * Allocate job structure and set job_code as DUMMY,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9457
		 * because we will not go through the job thread.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9458
		 * Instead fp_sendcmd() is called directly here.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9459
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9460
		job = fctl_alloc_job(JOB_DUMMY, JOB_TYPE_FP_ASYNC,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9461
		    NULL, NULL, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9462
		ASSERT(job != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9463
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9464
		job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9465
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9466
		cmd = fp_alloc_pkt(port, sizeof (la_els_rls_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9467
		    sizeof (la_els_rls_acc_t), KM_SLEEP, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9468
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9469
			fcio->fcio_errno = FC_NOMEM;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9470
			rval = ENOMEM;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9471
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9472
			fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9473
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9474
			fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9475
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9476
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9477
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9478
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9479
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9480
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9481
		/* Allocate memory for link error status block */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9482
		rls_acc = kmem_zalloc(sizeof (*rls_acc), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9483
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9484
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9485
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9486
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9487
		cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9488
		cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9489
		cmd->cmd_flags = FP_CMD_CFLAG_UNDEFINED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9490
		cmd->cmd_retry_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9491
		cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9492
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9493
		fp_rls_init(cmd, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9494
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9495
		job->job_private = (void *)rls_acc;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9496
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9497
		pd_flags = pd->pd_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9498
		pd->pd_flags = PD_ELS_IN_PROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9499
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9500
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9501
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9502
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9503
		if (fp_sendcmd(port, cmd, port->fp_fca_handle) == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9504
			fctl_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9505
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9506
			fcio->fcio_errno = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9507
			if (job->job_result == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9508
				ASSERT(pd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9509
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9510
				 * link error status block is now available.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9511
				 * Copy it to userland
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9512
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9513
				ASSERT(job->job_private == (void *)rls_acc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9514
				if (ddi_copyout((void *)rls_acc,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9515
				    (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9516
				    sizeof (*rls_acc), mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9517
					if (fp_fcio_copyout(fcio, data,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9518
					    mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9519
						rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9520
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9521
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9522
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9523
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9524
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9525
				rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9526
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9527
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9528
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9529
			fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9530
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9531
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9532
		if (rval) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9533
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9534
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9535
			if (pd->pd_flags == PD_ELS_IN_PROGRESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9536
				pd->pd_flags = pd_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9537
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9538
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9539
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9540
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9541
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9542
		fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9543
		fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9544
		kmem_free(rls_acc, sizeof (*rls_acc));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9545
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9546
		if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9547
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9548
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9549
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9550
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9551
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9552
	case FCIO_NS: {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9553
		fc_ns_cmd_t	*ns_req;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9554
		fc_ns_cmd32_t	*ns_req32;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9555
		fctl_ns_req_t	*ns_cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9556
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9557
		if (use32 == B_TRUE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9558
			if (fcio->fcio_ilen != sizeof (*ns_req32)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9559
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9560
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9561
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9562
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9563
			ns_req = kmem_zalloc(sizeof (*ns_req), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9564
			ns_req32 = kmem_zalloc(sizeof (*ns_req32), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9565
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9566
			if (ddi_copyin(fcio->fcio_ibuf, ns_req32,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9567
			    sizeof (*ns_req32), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9568
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9569
				kmem_free(ns_req, sizeof (*ns_req));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9570
				kmem_free(ns_req32, sizeof (*ns_req32));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9571
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9572
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9573
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9574
			ns_req->ns_flags = ns_req32->ns_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9575
			ns_req->ns_cmd = ns_req32->ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9576
			ns_req->ns_req_len = ns_req32->ns_req_len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9577
			ns_req->ns_req_payload = ns_req32->ns_req_payload;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9578
			ns_req->ns_resp_len = ns_req32->ns_resp_len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9579
			ns_req->ns_resp_payload = ns_req32->ns_resp_payload;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9580
			ns_req->ns_fctl_private = ns_req32->ns_fctl_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9581
			ns_req->ns_resp_hdr = ns_req32->ns_resp_hdr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9582
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9583
			kmem_free(ns_req32, sizeof (*ns_req32));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9584
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9585
			if (fcio->fcio_ilen != sizeof (*ns_req)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9586
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9587
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9588
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9589
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9590
			ns_req = kmem_zalloc(sizeof (*ns_req), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9591
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9592
			if (ddi_copyin(fcio->fcio_ibuf, ns_req,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9593
			    sizeof (fc_ns_cmd_t), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9594
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9595
				kmem_free(ns_req, sizeof (*ns_req));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9596
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9597
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9598
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9599
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9600
		if (ns_req->ns_req_len <= 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9601
			rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9602
			kmem_free(ns_req, sizeof (*ns_req));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9603
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9604
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9605
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9606
		job = fctl_alloc_job(JOB_NS_CMD, 0, NULL, NULL, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9607
		ASSERT(job != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9608
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9609
		ns_cmd = fctl_alloc_ns_cmd(ns_req->ns_req_len,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9610
		    ns_req->ns_resp_len, ns_req->ns_resp_len,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9611
		    FCTL_NS_FILL_NS_MAP, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9612
		ASSERT(ns_cmd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9613
		ns_cmd->ns_cmd_code = ns_req->ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9614
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9615
		if (ns_cmd->ns_cmd_code == NS_GA_NXT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9616
			ns_cmd->ns_gan_max = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9617
			ns_cmd->ns_gan_index = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9618
			ns_cmd->ns_gan_sid = FCTL_GAN_START_ID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9619
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9620
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9621
		if (ddi_copyin(ns_req->ns_req_payload,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9622
		    ns_cmd->ns_cmd_buf, ns_req->ns_req_len, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9623
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9624
			fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9625
			fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9626
			kmem_free(ns_req, sizeof (*ns_req));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9627
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9628
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9629
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9630
		job->job_private = (void *)ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9631
		fctl_enque_job(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9632
		fctl_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9633
		rval = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9634
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9635
		if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9636
			if (ns_req->ns_resp_len) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9637
				if (ddi_copyout(ns_cmd->ns_data_buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9638
				    ns_req->ns_resp_payload,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9639
				    ns_cmd->ns_data_len, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9640
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9641
					fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9642
					fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9643
					kmem_free(ns_req, sizeof (*ns_req));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9644
					break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9645
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9646
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9647
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9648
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9649
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9650
		ns_req->ns_resp_hdr = ns_cmd->ns_resp_hdr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9651
		fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9652
		fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9653
		kmem_free(ns_req, sizeof (*ns_req));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9654
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9655
		if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9656
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9657
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9658
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9659
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9660
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9661
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9662
		rval = ENOTTY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9663
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9664
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9665
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9666
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9667
	 * If set, reset the EXCL busy bit to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9668
	 * receive other exclusive access commands
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9669
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9670
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9671
	if (port->fp_flag & FP_EXCL_BUSY) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9672
		port->fp_flag &= ~FP_EXCL_BUSY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9673
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9674
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9675
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9676
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9677
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9678
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9679
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9680
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9681
 * This function assumes that the response length
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9682
 * is same regardless of data model (LP32 or LP64)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9683
 * which is true for all the ioctls currently
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9684
 * supported.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9685
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9686
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9687
fp_copyout(void *from, void *to, size_t len, int mode)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9688
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9689
	return (ddi_copyout(from, to, len, mode));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9690
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9691
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9692
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9693
 * This function does the set rnid
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9694
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9695
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9696
fp_set_rnid(fc_local_port_t *port, intptr_t data, int mode, fcio_t *fcio)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9697
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9698
	int		rval = 0;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9699
	fc_rnid_t	*rnid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9700
	fc_fca_pm_t	pm;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9701
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9702
	/* Allocate memory for node id block */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9703
	rnid = kmem_zalloc(sizeof (fc_rnid_t), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9704
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9705
	if (ddi_copyin(fcio->fcio_ibuf, rnid, sizeof (fc_rnid_t), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9706
		FP_TRACE(FP_NHEAD1(3, 0), "fp_set_rnid: failed = %d", EFAULT);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9707
		kmem_free(rnid, sizeof (fc_rnid_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9708
		return (EFAULT);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9709
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9710
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9711
	/* Prepare the port management structure */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9712
	bzero((caddr_t)&pm, sizeof (pm));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9713
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9714
	pm.pm_cmd_flags = FC_FCA_PM_WRITE;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9715
	pm.pm_cmd_code	= FC_PORT_SET_NODE_ID;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9716
	pm.pm_data_len	= sizeof (*rnid);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9717
	pm.pm_data_buf	= (caddr_t)rnid;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9718
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9719
	/* Get the adapter's node data */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9720
	rval = port->fp_fca_tran->fca_port_manage(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9721
	    port->fp_fca_handle, &pm);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9722
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9723
	if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9724
		fcio->fcio_errno = rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9725
		rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9726
		if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9727
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9728
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9729
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9730
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9731
		/* copy to the port structure */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9732
		bcopy(rnid, &port->fp_rnid_params,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9733
		    sizeof (port->fp_rnid_params));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9734
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9735
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9736
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9737
	kmem_free(rnid, sizeof (fc_rnid_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9738
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9739
	if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9740
		FP_TRACE(FP_NHEAD1(3, 0), "fp_set_rnid: failed = %d", rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9741
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9742
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9743
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9744
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9745
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9746
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9747
 * This function does the local pwwn get rnid
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9748
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9749
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9750
fp_get_rnid(fc_local_port_t *port, intptr_t data, int mode, fcio_t *fcio)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9751
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9752
	fc_rnid_t		*rnid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9753
	fc_fca_pm_t		pm;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9754
	int			rval = 0;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9755
	uint32_t		ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9756
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9757
	/* Allocate memory for rnid data block */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9758
	rnid = kmem_zalloc(sizeof (fc_rnid_t), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9759
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9760
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9761
	if (port->fp_rnid_init == 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9762
		bcopy(&port->fp_rnid_params, rnid, sizeof (fc_rnid_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9763
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9764
		/* xfer node info to userland */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9765
		if (ddi_copyout((void *)rnid, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9766
		    sizeof (*rnid), mode) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9767
			if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9768
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9769
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9770
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9771
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9772
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9773
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9774
		kmem_free(rnid, sizeof (fc_rnid_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9775
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9776
		if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9777
			FP_TRACE(FP_NHEAD1(3, 0), "fp_get_rnid: failed = %d",
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9778
			    rval);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9779
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9780
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9781
		return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9782
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9783
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9784
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9785
	/* Prepare the port management structure */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9786
	bzero((caddr_t)&pm, sizeof (pm));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9787
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9788
	pm.pm_cmd_flags = FC_FCA_PM_READ;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9789
	pm.pm_cmd_code	= FC_PORT_GET_NODE_ID;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9790
	pm.pm_data_len	= sizeof (fc_rnid_t);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9791
	pm.pm_data_buf	= (caddr_t)rnid;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9792
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9793
	/* Get the adapter's node data */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9794
	ret = port->fp_fca_tran->fca_port_manage(
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9795
	    port->fp_fca_handle,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9796
	    &pm);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9797
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9798
	if (ret == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9799
		/* initialize in the port_info */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9800
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9801
		port->fp_rnid_init = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9802
		bcopy(rnid, &port->fp_rnid_params, sizeof (*rnid));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9803
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9804
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9805
		/* xfer node info to userland */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9806
		if (ddi_copyout((void *)rnid,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9807
		    (void *)fcio->fcio_obuf,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9808
		    sizeof (*rnid), mode) == 0) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9809
			if (fp_fcio_copyout(fcio, data,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9810
			    mode)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9811
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9812
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9813
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9814
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9815
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9816
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9817
		rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9818
		fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9819
		if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9820
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9821
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9822
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9823
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9824
	kmem_free(rnid, sizeof (fc_rnid_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9825
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9826
	if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9827
		FP_TRACE(FP_NHEAD1(3, 0), "fp_get_rnid: failed = %d", rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9828
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9829
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9830
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9831
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9832
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9833
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9834
fp_send_rnid(fc_local_port_t *port, intptr_t data, int mode, fcio_t *fcio,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9835
    la_wwn_t *pwwn)
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9836
{
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9837
	int			rval = 0;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9838
	fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9839
	fp_cmd_t		*cmd;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9840
	job_request_t		*job;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9841
	la_els_rnid_acc_t	*rnid_acc;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9842
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9843
	pd = fctl_get_remote_port_by_pwwn(port, pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9844
	if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9845
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9846
		 * We can safely assume that the destination port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9847
		 * is logged in. Either the user land will explicitly
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9848
		 * login before issuing RNID ioctl or the device would
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9849
		 * have been configured, meaning already logged in.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9850
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9851
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9852
		FP_TRACE(FP_NHEAD1(3, 0), "fp_send_rnid: failed = %d", ENXIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9853
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9854
		return (ENXIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9855
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9856
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9857
	 * Allocate job structure and set job_code as DUMMY,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9858
	 * because we will not go thorugh the job thread.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9859
	 * Instead fp_sendcmd() is called directly here.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9860
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9861
	job = fctl_alloc_job(JOB_DUMMY, JOB_TYPE_FP_ASYNC,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9862
	    NULL, NULL, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9863
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9864
	ASSERT(job != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9865
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9866
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9867
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9868
	cmd = fp_alloc_pkt(port, sizeof (la_els_rnid_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9869
	    sizeof (la_els_rnid_acc_t), KM_SLEEP, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9870
	if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9871
		fcio->fcio_errno = FC_NOMEM;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9872
		rval = ENOMEM;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9873
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9874
		fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9875
		if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9876
			rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9877
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9878
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9879
		FP_TRACE(FP_NHEAD1(3, 0), "fp_send_rnid: failed = %d", rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9880
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9881
		return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9882
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9883
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9884
	/* Allocate memory for node id accept block */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9885
	rnid_acc = kmem_zalloc(sizeof (la_els_rnid_acc_t), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9886
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9887
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9888
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9889
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9890
	cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9891
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9892
	cmd->cmd_flags = FP_CMD_CFLAG_UNDEFINED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9893
	cmd->cmd_retry_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9894
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9895
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9896
	fp_rnid_init(cmd, fcio->fcio_cmd_flags, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9897
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9898
	job->job_private = (void *)rnid_acc;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9899
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9900
	pd->pd_flags = PD_ELS_IN_PROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9901
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9902
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9903
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9904
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9905
	if (fp_sendcmd(port, cmd, port->fp_fca_handle) == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9906
		fctl_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9907
		fcio->fcio_errno = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9908
		if (job->job_result == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9909
			int rnid_cnt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9910
			ASSERT(pd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9911
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9912
			 * node id block is now available.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9913
			 * Copy it to userland
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9914
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9915
			ASSERT(job->job_private == (void *)rnid_acc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9916
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9917
			/* get the response length */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9918
			rnid_cnt = sizeof (ls_code_t) + sizeof (fc_rnid_hdr_t) +
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9919
			    rnid_acc->hdr.cmn_len +
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9920
			    rnid_acc->hdr.specific_len;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9921
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9922
			if (fcio->fcio_olen < rnid_cnt) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9923
				rval = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9924
			} else if (ddi_copyout((void *)rnid_acc,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9925
			    (void *)fcio->fcio_obuf,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9926
			    rnid_cnt, mode) == 0) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9927
				if (fp_fcio_copyout(fcio, data,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9928
				    mode)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9929
					rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9930
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9931
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9932
				rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9933
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9934
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9935
			rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9936
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9937
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9938
		rval = EIO;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9939
		if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9940
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9941
			pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9942
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9943
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9944
		fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9945
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9946
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9947
	fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9948
	kmem_free(rnid_acc, sizeof (la_els_rnid_acc_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9949
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9950
	if (fp_fcio_copyout(fcio, data, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9951
		rval = EFAULT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9952
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9953
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9954
	if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9955
		FP_TRACE(FP_NHEAD1(3, 0), "fp_send_rnid: failed = %d", rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9956
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9957
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9958
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9959
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9960
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9961
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9962
 * Copy out to userland
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9963
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9964
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9965
fp_fcio_copyout(fcio_t *fcio, intptr_t data, int mode)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9966
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9967
	int rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9968
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9969
#ifdef	_MULTI_DATAMODEL
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9970
	switch (ddi_model_convert_from(mode & FMODELS)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9971
	case DDI_MODEL_ILP32: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9972
		struct fcio32 fcio32;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9973
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9974
		fcio32.fcio_xfer = fcio->fcio_xfer;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9975
		fcio32.fcio_cmd = fcio->fcio_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9976
		fcio32.fcio_flags = fcio->fcio_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9977
		fcio32.fcio_cmd_flags = fcio->fcio_cmd_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9978
		fcio32.fcio_ilen = fcio->fcio_ilen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9979
		fcio32.fcio_ibuf =
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9980
		    (caddr32_t)(uintptr_t)fcio->fcio_ibuf;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9981
		fcio32.fcio_olen = fcio->fcio_olen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9982
		fcio32.fcio_obuf =
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9983
		    (caddr32_t)(uintptr_t)fcio->fcio_obuf;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9984
		fcio32.fcio_alen = fcio->fcio_alen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9985
		fcio32.fcio_abuf =
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
  9986
		    (caddr32_t)(uintptr_t)fcio->fcio_abuf;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9987
		fcio32.fcio_errno = fcio->fcio_errno;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9988
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9989
		rval = ddi_copyout((void *)&fcio32, (void *)data,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9990
		    sizeof (struct fcio32), mode);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9991
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9992
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9993
	case DDI_MODEL_NONE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9994
		rval = ddi_copyout((void *)fcio, (void *)data,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9995
		    sizeof (fcio_t), mode);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9996
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9997
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9998
#else
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
  9999
	rval = ddi_copyout((void *)fcio, (void *)data, sizeof (fcio_t), mode);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10000
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10001
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10002
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10003
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10004
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10005
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10006
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10007
fp_p2p_online(fc_local_port_t *port, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10008
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10009
	uint32_t		listlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10010
	fc_portmap_t		*changelist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10011
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10012
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10013
	ASSERT(port->fp_topology == FC_TOP_PT_PT);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10014
	ASSERT((job->job_flags & JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10015
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10016
	listlen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10017
	changelist = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10018
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10019
	if ((job->job_flags & JOB_CANCEL_ULP_NOTIFICATION) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10020
		if (port->fp_statec_busy > 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10021
			job->job_flags |= JOB_CANCEL_ULP_NOTIFICATION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10022
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10023
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10024
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10025
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10026
	if ((job->job_flags & JOB_CANCEL_ULP_NOTIFICATION) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10027
		fctl_fillout_map(port, &changelist, &listlen, 1, 0, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10028
		(void) fp_ulp_statec_cb(port, FC_STATE_ONLINE, changelist,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10029
		    listlen, listlen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10030
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10031
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10032
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10033
		ASSERT(changelist == NULL && listlen == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10034
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10035
		if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10036
			port->fp_soft_state &= ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10037
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10038
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10039
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10040
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10041
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10042
fp_fillout_p2pmap(fc_local_port_t *port, fcio_t *fcio, int mode)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10043
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10044
	int			rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10045
	int			count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10046
	int			index;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10047
	int			num_devices;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10048
	fc_remote_node_t	*node;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10049
	fc_port_dev_t		*devlist;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10050
	struct pwwn_hash	*head;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10051
	fc_remote_port_t	*pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10052
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10053
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10054
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10055
	num_devices = fcio->fcio_olen / sizeof (fc_port_dev_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10056
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10057
	devlist = kmem_zalloc(sizeof (fc_port_dev_t) * num_devices, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10058
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10059
	for (count = index = 0; index < pwwn_table_size; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10060
		head = &port->fp_pwwn_table[index];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10061
		pd = head->pwwn_head;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10062
		while (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10063
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10064
			if (pd->pd_state == PORT_DEVICE_INVALID) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10065
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10066
				pd = pd->pd_wwn_hnext;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10067
				continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10068
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10069
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10070
			devlist[count].dev_state = pd->pd_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10071
			devlist[count].dev_hard_addr = pd->pd_hard_addr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10072
			devlist[count].dev_did = pd->pd_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10073
			devlist[count].dev_did.priv_lilp_posit =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10074
			    (uint8_t)(index & 0xff);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10075
			bcopy((caddr_t)pd->pd_fc4types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10076
			    (caddr_t)devlist[count].dev_type,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10077
			    sizeof (pd->pd_fc4types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10078
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10079
			bcopy((caddr_t)&pd->pd_port_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10080
			    (caddr_t)&devlist[count].dev_pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10081
			    sizeof (la_wwn_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10082
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10083
			node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10084
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10085
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10086
			if (node) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10087
				mutex_enter(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10088
				bcopy((caddr_t)&node->fd_node_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10089
				    (caddr_t)&devlist[count].dev_nwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10090
				    sizeof (la_wwn_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10091
				mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10092
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10093
			count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10094
			if (count >= num_devices) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10095
				goto found;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10096
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10097
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10098
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10099
found:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10100
	if (fp_copyout((void *)&count, (void *)fcio->fcio_abuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10101
	    sizeof (count), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10102
		rval = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10103
	} else if (fp_copyout((void *)devlist, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10104
	    sizeof (fc_port_dev_t) * num_devices, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10105
		rval = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10106
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10107
		rval = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10108
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10109
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10110
	kmem_free(devlist, sizeof (fc_port_dev_t) * num_devices);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10111
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10112
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10113
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10114
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10115
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10116
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10117
 * Handle Fabric ONLINE
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10118
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10119
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10120
fp_fabric_online(fc_local_port_t *port, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10121
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10122
	int			index;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10123
	int			rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10124
	int			dbg_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10125
	int			count = 0;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10126
	char			ww_name[17];
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10127
	uint32_t		d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10128
	uint32_t		listlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10129
	fctl_ns_req_t		*ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10130
	struct pwwn_hash	*head;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10131
	fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10132
	fc_remote_port_t	*npd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10133
	fc_portmap_t		*changelist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10134
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10135
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10136
	ASSERT(FC_IS_TOP_SWITCH(port->fp_topology));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10137
	ASSERT((job->job_flags & JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10138
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10139
	ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10140
	    sizeof (ns_resp_gid_pn_t), sizeof (ns_resp_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10141
	    0, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10142
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10143
	ASSERT(ns_cmd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10144
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10145
	ns_cmd->ns_cmd_code = NS_GID_PN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10146
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10147
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10148
	 * Check if orphans are showing up now
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10149
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10150
	if (port->fp_orphan_count) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10151
		fc_orphan_t	*orp;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10152
		fc_orphan_t	*norp = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10153
		fc_orphan_t	*prev = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10154
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10155
		for (orp = port->fp_orphan_list; orp; orp = norp) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10156
			norp = orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10157
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10158
			orp->orp_nscan++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10159
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10160
			job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10161
			job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10162
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10163
			((ns_req_gid_pn_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10164
			    (ns_cmd->ns_cmd_buf))->pwwn = orp->orp_pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10165
			((ns_resp_gid_pn_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10166
			    ns_cmd->ns_data_buf)->pid.port_id = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10167
			((ns_resp_gid_pn_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10168
			    ns_cmd->ns_data_buf)->pid.priv_lilp_posit = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10169
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10170
			rval = fp_ns_query(port, ns_cmd, job, 1, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10171
			if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10172
				d_id =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10173
				    BE_32(*((uint32_t *)ns_cmd->ns_data_buf));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10174
				pd = fp_create_remote_port_by_ns(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10175
				    d_id, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10176
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10177
				if (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10178
					fc_wwn_to_str(&orp->orp_pwwn, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10179
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10180
					fp_printf(port, CE_WARN, FP_LOG_ONLY,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10181
					    0, NULL, "N_x Port with D_ID=%x,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10182
					    " PWWN=%s reappeared in fabric",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10183
					    d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10184
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10185
					mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10186
					if (prev) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10187
						prev->orp_next = orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10188
					} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10189
						ASSERT(orp ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10190
						    port->fp_orphan_list);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10191
						port->fp_orphan_list =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10192
						    orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10193
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10194
					port->fp_orphan_count--;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10195
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10196
					kmem_free(orp, sizeof (*orp));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10197
					count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10198
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10199
					mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10200
					pd->pd_flags = PD_ELS_MARK;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10201
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10202
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10203
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10204
					prev = orp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10205
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10206
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10207
				if (orp->orp_nscan == FC_ORPHAN_SCAN_LIMIT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10208
					fc_wwn_to_str(&orp->orp_pwwn, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10209
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10210
					fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10211
					    NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10212
					    " Port WWN %s removed from orphan"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10213
					    " list after %d scans", ww_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10214
					    orp->orp_nscan);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10215
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10216
					mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10217
					if (prev) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10218
						prev->orp_next = orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10219
					} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10220
						ASSERT(orp ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10221
						    port->fp_orphan_list);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10222
						port->fp_orphan_list =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10223
						    orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10224
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10225
					port->fp_orphan_count--;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10226
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10227
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10228
					kmem_free(orp, sizeof (*orp));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10229
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10230
					prev = orp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10231
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10232
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10233
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10234
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10235
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10236
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10237
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10238
	 * Walk the Port WWN hash table, reestablish LOGIN
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10239
	 * if a LOGIN is already performed on a particular
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10240
	 * device; Any failure to LOGIN should mark the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10241
	 * port device OLD.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10242
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10243
	for (index = 0; index < pwwn_table_size; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10244
		head = &port->fp_pwwn_table[index];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10245
		npd = head->pwwn_head;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10246
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10247
		while ((pd = npd) != NULL) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10248
			la_wwn_t	*pwwn;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10249
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10250
			npd = pd->pd_wwn_hnext;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10251
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10252
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10253
			 * Don't count in the port devices that are new
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10254
			 * unless the total number of devices visible
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10255
			 * through this port is less than FP_MAX_DEVICES
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10256
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10257
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10258
			if (port->fp_dev_count >= FP_MAX_DEVICES ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10259
			    (port->fp_options & FP_TARGET_MODE)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10260
				if (pd->pd_type == PORT_DEVICE_NEW ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10261
				    pd->pd_flags == PD_ELS_MARK ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10262
				    pd->pd_recepient != PD_PLOGI_INITIATOR) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10263
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10264
					continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10265
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10266
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10267
				if (pd->pd_flags == PD_ELS_MARK ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10268
				    pd->pd_recepient != PD_PLOGI_INITIATOR) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10269
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10270
					continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10271
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10272
				pd->pd_type = PORT_DEVICE_OLD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10273
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10274
			count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10275
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10276
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10277
			 * Consult with the name server about D_ID changes
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10278
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10279
			job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10280
			job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10281
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10282
			((ns_req_gid_pn_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10283
			    (ns_cmd->ns_cmd_buf))->pwwn = pd->pd_port_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10284
			((ns_resp_gid_pn_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10285
			    ns_cmd->ns_data_buf)->pid.port_id = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10286
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10287
			((ns_resp_gid_pn_t *)ns_cmd->ns_data_buf)->
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10288
			    pid.priv_lilp_posit = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10289
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10290
			pwwn = &pd->pd_port_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10291
			pd->pd_flags = PD_ELS_MARK;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10292
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10293
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10294
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10295
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10296
			rval = fp_ns_query(port, ns_cmd, job, 1, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10297
			if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10298
				fc_wwn_to_str(pwwn, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10299
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10300
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10301
				d_id = pd->pd_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10302
				pd->pd_type = PORT_DEVICE_DELETE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10303
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10304
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10305
				FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10306
				    "fp_fabric_online: PD "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10307
				    "disappeared; d_id=%x, PWWN=%s",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10308
				    d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10309
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10310
				FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10311
				    "N_x Port with D_ID=%x, PWWN=%s"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10312
				    " disappeared from fabric", d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10313
				    ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10314
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10315
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10316
				continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10317
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10318
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10319
			d_id = BE_32(*((uint32_t *)ns_cmd->ns_data_buf));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10320
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10321
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10322
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10323
			if (d_id != pd->pd_port_id.port_id) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10324
				fctl_delist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10325
				fc_wwn_to_str(pwwn, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10326
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10327
				FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10328
				    "D_ID of a device with PWWN %s changed."
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10329
				    " New D_ID = %x, OLD D_ID = %x", ww_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10330
				    d_id, pd->pd_port_id.port_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10331
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10332
				pd->pd_port_id.port_id = BE_32(d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10333
				pd->pd_type = PORT_DEVICE_CHANGED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10334
				fctl_enlist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10335
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10336
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10337
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10338
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10339
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10340
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10341
	if (ns_cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10342
		fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10343
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10344
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10345
	listlen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10346
	changelist = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10347
	if (count) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10348
		if (port->fp_soft_state & FP_SOFT_IN_FCA_RESET) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10349
			port->fp_soft_state &= ~FP_SOFT_IN_FCA_RESET;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10350
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10351
			delay(drv_usectohz(FLA_RR_TOV * 1000 * 1000));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10352
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10353
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10354
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10355
		dbg_count = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10356
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10357
		job->job_counter = count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10358
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10359
		for (index = 0; index < pwwn_table_size; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10360
			head = &port->fp_pwwn_table[index];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10361
			npd = head->pwwn_head;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10362
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10363
			while ((pd = npd) != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10364
				npd = pd->pd_wwn_hnext;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10365
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10366
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10367
				if (pd->pd_flags != PD_ELS_MARK) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10368
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10369
					continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10370
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10371
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10372
				dbg_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10373
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10374
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10375
				 * If it is already marked deletion, nothing
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10376
				 * else to do.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10377
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10378
				if (pd->pd_type == PORT_DEVICE_DELETE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10379
					pd->pd_type = PORT_DEVICE_OLD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10380
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10381
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10382
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10383
					fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10384
					mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10385
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10386
					continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10387
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10388
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10389
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10390
				 * If it is freshly discovered out of
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10391
				 * the orphan list, nothing else to do
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10392
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10393
				if (pd->pd_type == PORT_DEVICE_NEW) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10394
					pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10395
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10396
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10397
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10398
					fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10399
					mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10400
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10401
					continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10402
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10403
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10404
				pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10405
				d_id = pd->pd_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10406
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10407
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10408
				 * Explicitly mark all devices OLD; successful
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10409
				 * PLOGI should reset this to either NO_CHANGE
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10410
				 * or CHANGED.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10411
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10412
				if (pd->pd_type != PORT_DEVICE_CHANGED) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10413
					pd->pd_type = PORT_DEVICE_OLD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10414
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10415
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10416
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10417
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10418
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10419
				rval = fp_port_login(port, d_id, job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10420
				    FP_CMD_PLOGI_RETAIN, KM_SLEEP, pd, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10421
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10422
				if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10423
					fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10424
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10425
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10426
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10427
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10428
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10429
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10430
		ASSERT(dbg_count == count);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10431
		fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10432
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10433
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10434
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10435
		ASSERT(port->fp_statec_busy > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10436
		if ((job->job_flags & JOB_CANCEL_ULP_NOTIFICATION) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10437
			if (port->fp_statec_busy > 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10438
				job->job_flags |= JOB_CANCEL_ULP_NOTIFICATION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10439
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10440
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10441
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10442
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10443
		ASSERT(port->fp_statec_busy > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10444
		if (port->fp_statec_busy > 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10445
			job->job_flags |= JOB_CANCEL_ULP_NOTIFICATION;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10446
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10447
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10448
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10449
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10450
	if ((job->job_flags & JOB_CANCEL_ULP_NOTIFICATION) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10451
		fctl_fillout_map(port, &changelist, &listlen, 1, 0, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10452
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10453
		(void) fp_ulp_statec_cb(port, FC_STATE_ONLINE, changelist,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10454
		    listlen, listlen, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10455
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10456
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10457
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10458
		ASSERT(changelist == NULL && listlen == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10459
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10460
		if (--port->fp_statec_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10461
			port->fp_soft_state &= ~FP_SOFT_IN_STATEC_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10462
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10463
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10464
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10465
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10466
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10467
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10468
 * Fill out device list for userland ioctl in private loop
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10469
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10470
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10471
fp_fillout_loopmap(fc_local_port_t *port, fcio_t *fcio, int mode)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10472
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10473
	int			rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10474
	int			count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10475
	int			index;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10476
	int			num_devices;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10477
	fc_remote_node_t	*node;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10478
	fc_port_dev_t		*devlist;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10479
	int			lilp_device_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10480
	fc_lilpmap_t		*lilp_map;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10481
	uchar_t			*alpa_list;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10482
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10483
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10484
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10485
	num_devices = fcio->fcio_olen / sizeof (fc_port_dev_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10486
	if (port->fp_total_devices > port->fp_dev_count &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10487
	    num_devices >= port->fp_total_devices) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10488
		job_request_t	*job;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10489
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10490
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10491
		job = fctl_alloc_job(JOB_PORT_GETMAP, 0, NULL, NULL, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10492
		job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10493
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10494
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10495
		fp_get_loopmap(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10496
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10497
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10498
		fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10499
		fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10500
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10501
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10502
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10503
	devlist = kmem_zalloc(sizeof (*devlist) * num_devices, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10504
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10505
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10506
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10507
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10508
	 * Applications are accustomed to getting the device list in
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10509
	 * LILP map order. The HBA firmware usually returns the device
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10510
	 * map in the LILP map order and diagnostic applications would
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10511
	 * prefer to receive in the device list in that order too
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10512
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10513
	lilp_map = &port->fp_lilp_map;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10514
	alpa_list = &lilp_map->lilp_alpalist[0];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10515
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10516
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10517
	 * the length field corresponds to the offset in the LILP frame
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10518
	 * which begins with 1. The thing to note here is that the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10519
	 * lilp_device_count is 1 more than fp->fp_total_devices since
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10520
	 * the host adapter's alpa also shows up in the lilp map. We
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10521
	 * don't however return details of the host adapter since
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10522
	 * fctl_get_remote_port_by_did fails for the host adapter's ALPA
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10523
	 * and applications are required to issue the FCIO_GET_HOST_PARAMS
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10524
	 * ioctl to obtain details about the host adapter port.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10525
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10526
	lilp_device_count = lilp_map->lilp_length;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10527
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10528
	for (count = index = 0; index < lilp_device_count &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10529
	    count < num_devices; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10530
		uint32_t d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10531
		fc_remote_port_t *pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10532
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10533
		d_id = alpa_list[index];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10534
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10535
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10536
		pd = fctl_get_remote_port_by_did(port, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10537
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10538
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10539
		if (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10540
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10541
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10542
			if (pd->pd_state == PORT_DEVICE_INVALID) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10543
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10544
				continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10545
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10546
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10547
			devlist[count].dev_state = pd->pd_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10548
			devlist[count].dev_hard_addr = pd->pd_hard_addr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10549
			devlist[count].dev_did = pd->pd_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10550
			devlist[count].dev_did.priv_lilp_posit =
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10551
			    (uint8_t)(index & 0xff);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10552
			bcopy((caddr_t)pd->pd_fc4types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10553
			    (caddr_t)devlist[count].dev_type,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10554
			    sizeof (pd->pd_fc4types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10555
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10556
			bcopy((caddr_t)&pd->pd_port_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10557
			    (caddr_t)&devlist[count].dev_pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10558
			    sizeof (la_wwn_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10559
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10560
			node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10561
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10562
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10563
			if (node) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10564
				mutex_enter(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10565
				bcopy((caddr_t)&node->fd_node_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10566
				    (caddr_t)&devlist[count].dev_nwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10567
				    sizeof (la_wwn_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10568
				mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10569
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10570
			count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10571
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10572
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10573
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10574
	if (fp_copyout((void *)&count, (void *)fcio->fcio_abuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10575
	    sizeof (count), mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10576
		rval = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10577
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10578
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10579
	if (fp_copyout((void *)devlist, (void *)fcio->fcio_obuf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10580
	    sizeof (fc_port_dev_t) * num_devices, mode)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10581
		rval = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10582
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10583
		rval = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10584
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10585
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10586
	kmem_free(devlist, sizeof (*devlist) * num_devices);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10587
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10588
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10589
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10590
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10591
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10592
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10593
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10594
 * Completion function for responses to unsolicited commands
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10595
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10596
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10597
fp_unsol_intr(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10598
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10599
	fp_cmd_t	*cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10600
	fc_local_port_t *port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10601
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10602
	cmd = pkt->pkt_ulp_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10603
	port = cmd->cmd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10604
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10605
	mutex_enter(&port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10606
	port->fp_out_fpcmds--;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10607
	mutex_exit(&port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10608
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10609
	if (pkt->pkt_state != FC_PKT_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10610
		fp_printf(port, CE_WARN, FP_LOG_ONLY, 0, pkt,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10611
		    "couldn't post response to unsolicited request;"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10612
		    " ox_id=%x rx_id=%x", pkt->pkt_cmd_fhdr.ox_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10613
		    pkt->pkt_resp_fhdr.rx_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10614
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10615
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10616
	if (cmd == port->fp_els_resp_pkt) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10617
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10618
		port->fp_els_resp_pkt_busy = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10619
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10620
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10621
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10622
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10623
	fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10624
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10625
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10626
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10627
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10628
 * solicited LINIT ELS completion function
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10629
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10630
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10631
fp_linit_intr(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10632
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10633
	fp_cmd_t		*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10634
	job_request_t		*job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10635
	fc_linit_resp_t		acc;
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 10636
	fc_local_port_t *port = ((fp_cmd_t *)pkt->pkt_ulp_private)->cmd_port;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10637
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10638
	cmd = (fp_cmd_t *)pkt->pkt_ulp_private;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10639
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10640
	mutex_enter(&cmd->cmd_port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10641
	cmd->cmd_port->fp_out_fpcmds--;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10642
	mutex_exit(&cmd->cmd_port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10643
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10644
	if (FP_IS_PKT_ERROR(pkt)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10645
		(void) fp_common_intr(pkt, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10646
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10647
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10648
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10649
	job = cmd->cmd_job;
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 10650
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 10651
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10652
	    (uint8_t *)pkt->pkt_resp, sizeof (acc), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10653
	if (acc.status != FC_LINIT_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10654
		job->job_result = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10655
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10656
		job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10657
	}
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10658
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10659
	fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10660
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10661
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10662
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10663
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10664
 * Decode the unsolicited request; For FC-4 Device and Link data frames
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10665
 * notify the registered ULP of this FC-4 type right here. For Unsolicited
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10666
 * ELS requests, submit a request to the job_handler thread to work on it.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10667
 * The intent is to act quickly on the FC-4 unsolicited link and data frames
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10668
 * and save much of the interrupt time processing of unsolicited ELS requests
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10669
 * and hand it off to the job_handler thread.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10670
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10671
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10672
fp_unsol_cb(opaque_t port_handle, fc_unsol_buf_t *buf, uint32_t type)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10673
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10674
	uchar_t		r_ctl;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10675
	uchar_t		ls_code;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10676
	uint32_t	s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10677
	uint32_t	rscn_count = FC_INVALID_RSCN_COUNT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10678
	uint32_t	cb_arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10679
	fp_cmd_t	*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10680
	fc_local_port_t *port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10681
	job_request_t	*job;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10682
	fc_remote_port_t	*pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10683
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10684
	port = port_handle;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10685
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10686
	FP_TRACE(FP_NHEAD1(1, 0), "fp_unsol_cb: s_id=%x,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10687
	    " d_id=%x, type=%x, r_ctl=%x, f_ctl=%x"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10688
	    " seq_id=%x, df_ctl=%x, seq_cnt=%x, ox_id=%x, rx_id=%x"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10689
	    " ro=%x, buffer[0]:%x", buf->ub_frame.s_id, buf->ub_frame.d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10690
	    buf->ub_frame.type, buf->ub_frame.r_ctl, buf->ub_frame.f_ctl,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10691
	    buf->ub_frame.seq_id, buf->ub_frame.df_ctl, buf->ub_frame.seq_cnt,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10692
	    buf->ub_frame.ox_id, buf->ub_frame.rx_id, buf->ub_frame.ro,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10693
	    buf->ub_buffer[0]);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10694
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10695
	if (type & 0x80000000) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10696
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10697
		 * Huh ? Nothing much can be done without
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10698
		 * a valid buffer. So just exit.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10699
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10700
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10701
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10702
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10703
	 * If the unsolicited interrupts arrive while it isn't
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10704
	 * safe to handle unsolicited callbacks; Drop them, yes,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10705
	 * drop them on the floor
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10706
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10707
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10708
	port->fp_active_ubs++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10709
	if ((port->fp_soft_state &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10710
	    (FP_SOFT_IN_DETACH | FP_SOFT_SUSPEND | FP_SOFT_POWER_DOWN)) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10711
	    FC_PORT_STATE_MASK(port->fp_state) == FC_STATE_OFFLINE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10712
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10713
		FP_TRACE(FP_NHEAD1(3, 0), "fp_unsol_cb: port state is "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10714
		    "not ONLINE. s_id=%x, d_id=%x, type=%x, "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10715
		    "seq_id=%x, ox_id=%x, rx_id=%x"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10716
		    "ro=%x", buf->ub_frame.s_id, buf->ub_frame.d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10717
		    buf->ub_frame.type, buf->ub_frame.seq_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10718
		    buf->ub_frame.ox_id, buf->ub_frame.rx_id, buf->ub_frame.ro);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10719
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10720
		ASSERT(port->fp_active_ubs > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10721
		if (--(port->fp_active_ubs) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10722
			port->fp_soft_state &= ~FP_SOFT_IN_UNSOL_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10723
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10724
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10725
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10726
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10727
		port->fp_fca_tran->fca_ub_release(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10728
		    1, &buf->ub_token);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10729
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10730
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10731
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10732
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10733
	r_ctl = buf->ub_frame.r_ctl;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10734
	s_id = buf->ub_frame.s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10735
	if (port->fp_active_ubs == 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10736
		port->fp_soft_state |= FP_SOFT_IN_UNSOL_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10737
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10738
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10739
	if (r_ctl == R_CTL_ELS_REQ && buf->ub_buffer[0] == LA_ELS_LOGO &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10740
	    port->fp_statec_busy) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10741
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10742
		pd = fctl_get_remote_port_by_did(port, s_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10743
		if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10744
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10745
			if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10746
				FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10747
				    "LOGO for LOGGED IN D_ID %x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10748
				    buf->ub_frame.s_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10749
				pd->pd_state = PORT_DEVICE_VALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10750
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10751
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10752
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10753
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10754
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10755
		ASSERT(port->fp_active_ubs > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10756
		if (--(port->fp_active_ubs) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10757
			port->fp_soft_state &= ~FP_SOFT_IN_UNSOL_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10758
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10759
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10760
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10761
		port->fp_fca_tran->fca_ub_release(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10762
		    1, &buf->ub_token);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10763
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10764
		FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10765
		    "fp_unsol_cb() bailing out LOGO for D_ID %x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10766
		    buf->ub_frame.s_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10767
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10768
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10769
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10770
	if (port->fp_els_resp_pkt_busy == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10771
		if (r_ctl == R_CTL_ELS_REQ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10772
			ls_code = buf->ub_buffer[0];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10773
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10774
			switch (ls_code) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10775
			case LA_ELS_PLOGI:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10776
			case LA_ELS_FLOGI:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10777
				port->fp_els_resp_pkt_busy = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10778
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10779
				fp_i_handle_unsol_els(port, buf);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10780
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10781
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10782
				ASSERT(port->fp_active_ubs > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10783
				if (--(port->fp_active_ubs) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10784
					port->fp_soft_state &=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10785
					    ~FP_SOFT_IN_UNSOL_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10786
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10787
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10788
				port->fp_fca_tran->fca_ub_release(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10789
				    port->fp_fca_handle, 1, &buf->ub_token);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10790
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10791
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10792
			case LA_ELS_RSCN:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10793
				if (++(port)->fp_rscn_count ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10794
				    FC_INVALID_RSCN_COUNT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10795
					++(port)->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10796
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10797
				rscn_count = port->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10798
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10799
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10800
			default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10801
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10802
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10803
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10804
	} else if ((r_ctl == R_CTL_ELS_REQ) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10805
	    (buf->ub_buffer[0] == LA_ELS_RSCN)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10806
		if (++port->fp_rscn_count == FC_INVALID_RSCN_COUNT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10807
			++port->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10808
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10809
		rscn_count = port->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10810
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10811
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10812
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10813
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10814
	switch (r_ctl & R_CTL_ROUTING) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10815
	case R_CTL_DEVICE_DATA:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10816
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10817
		 * If the unsolicited buffer is a CT IU,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10818
		 * have the job_handler thread work on it.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10819
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10820
		if (buf->ub_frame.type == FC_TYPE_FC_SERVICES) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10821
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10822
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10823
		/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10824
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10825
	case R_CTL_FC4_SVC: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10826
		int sendup = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10827
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10828
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10829
		 * If a LOGIN isn't performed before this request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10830
		 * shut the door on this port with a reply that a
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10831
		 * LOGIN is required. We make an exception however
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10832
		 * for IP broadcast packets and pass them through
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10833
		 * to the IP ULP(s) to handle broadcast requests.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10834
		 * This is not a problem for private loop devices
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10835
		 * but for fabric topologies we don't log into the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10836
		 * remote ports during port initialization and
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10837
		 * the ULPs need to log into requesting ports on
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10838
		 * demand.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10839
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10840
		pd = fctl_get_remote_port_by_did(port, s_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10841
		if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10842
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10843
			if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10844
				sendup++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10845
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10846
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10847
		} else if ((pd == NULL) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10848
		    (buf->ub_frame.type == FC_TYPE_IS8802_SNAP) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10849
		    (buf->ub_frame.d_id == 0xffffff ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10850
		    buf->ub_frame.d_id == 0x00)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10851
			/* brodacst IP frame - so sendup via job thread */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10852
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10853
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10854
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10855
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10856
		 * Send all FC4 services via job thread too
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10857
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10858
		if ((r_ctl & R_CTL_ROUTING) == R_CTL_FC4_SVC) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10859
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10860
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10861
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10862
		if (sendup || !FC_IS_REAL_DEVICE(s_id)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10863
			fctl_ulp_unsol_cb(port, buf, buf->ub_frame.type);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10864
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10865
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10866
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10867
		if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10868
			cmd = fp_alloc_pkt(port, sizeof (la_els_rjt_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10869
			    0, KM_NOSLEEP, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10870
			if (cmd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10871
				fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10872
				    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10873
				    FC_REASON_LOGIN_REQUIRED, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10874
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10875
				if (fp_sendcmd(port, cmd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10876
				    port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10877
					fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10878
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10879
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10880
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10881
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10882
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10883
		ASSERT(port->fp_active_ubs > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10884
		if (--(port->fp_active_ubs) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10885
			port->fp_soft_state &= ~FP_SOFT_IN_UNSOL_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10886
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10887
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10888
		port->fp_fca_tran->fca_ub_release(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10889
		    1, &buf->ub_token);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10890
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10891
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10892
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10893
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10894
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10895
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10896
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10897
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10898
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10899
	 * Submit a Request to the job_handler thread to work
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10900
	 * on the unsolicited request. The potential side effect
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10901
	 * of this is that the unsolicited buffer takes a little
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10902
	 * longer to get released but we save interrupt time in
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10903
	 * the bargain.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10904
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10905
	cb_arg = (rscn_count == FC_INVALID_RSCN_COUNT) ? NULL : rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10906
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10907
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10908
	 * One way that the rscn_count will get used is described below :
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10909
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10910
	 * 1. fp_unsol_cb() gets an RSCN and updates fp_rscn_count.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10911
	 * 2. Before mutex is released, a copy of it is stored in rscn_count.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10912
	 * 3. The count is passed to job thread as JOB_UNSOL_REQUEST (below)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10913
	 *    by overloading the job_cb_arg to pass the rscn_count
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10914
	 * 4. When one of the routines processing the RSCN picks it up (ex:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10915
	 *    fp_validate_rscn_page()), it passes this count in the map
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10916
	 *    structure (as part of the map_rscn_info structure member) to the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10917
	 *    ULPs.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10918
	 * 5. When ULPs make calls back to the transport (example interfaces for
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10919
	 *    this are fc_ulp_transport(), fc_ulp_login(), fc_issue_els()), they
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10920
	 *    can now pass back this count as part of the fc_packet's
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10921
	 *    pkt_ulp_rscn_count member. fcp does this currently.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10922
	 * 6. When transport gets a call to transport a command on the wire, it
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10923
	 *    will check to see if there is a valid pkt_ulp_rsvd1 field in the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10924
	 *    fc_packet. If there is, it will match that info with the current
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10925
	 *    rscn_count on that instance of the port. If they don't match up
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10926
	 *    then there was a newer RSCN. The ULP gets back an error code which
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10927
	 *    informs it about it - FC_DEVICE_BUSY_NEW_RSCN.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10928
	 * 7. At this point the ULP is free to make up its own mind as to how to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10929
	 *    handle this. Currently, fcp will reset its retry counters and keep
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10930
	 *    retrying the operation it was doing in anticipation of getting a
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10931
	 *    new state change call back for the new RSCN.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10932
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10933
	job = fctl_alloc_job(JOB_UNSOL_REQUEST, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10934
	    (opaque_t)(uintptr_t)cb_arg, KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10935
	if (job == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10936
		fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL, "fp_unsol_cb() "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10937
		    "couldn't submit a job to the thread, failing..");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10938
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10939
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10940
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10941
		if (--port->fp_rscn_count == FC_INVALID_RSCN_COUNT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10942
			--port->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10943
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10944
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10945
		ASSERT(port->fp_active_ubs > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10946
		if (--(port->fp_active_ubs) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10947
			port->fp_soft_state &= ~FP_SOFT_IN_UNSOL_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10948
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10949
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10950
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10951
		port->fp_fca_tran->fca_ub_release(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10952
		    1, &buf->ub_token);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10953
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10954
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10955
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10956
	job->job_private = (void *)buf;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10957
	fctl_enque_job(port, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10958
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10959
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10960
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10961
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10962
 * Handle unsolicited requests
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10963
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10964
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10965
fp_handle_unsol_buf(fc_local_port_t *port, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10966
    job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10967
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10968
	uchar_t			r_ctl;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10969
	uchar_t			ls_code;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10970
	uint32_t		s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10971
	fp_cmd_t		*cmd;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 10972
	fc_remote_port_t	*pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10973
	fp_unsol_spec_t		*ub_spec;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10974
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10975
	r_ctl = buf->ub_frame.r_ctl;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10976
	s_id = buf->ub_frame.s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10977
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10978
	switch (r_ctl & R_CTL_ROUTING) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10979
	case R_CTL_EXTENDED_SVC:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10980
		if (r_ctl != R_CTL_ELS_REQ) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10981
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10982
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10983
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10984
		ls_code = buf->ub_buffer[0];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10985
		switch (ls_code) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10986
		case LA_ELS_LOGO:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10987
		case LA_ELS_ADISC:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10988
		case LA_ELS_PRLO:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10989
			pd = fctl_get_remote_port_by_did(port, s_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10990
			if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10991
				if (!FC_IS_REAL_DEVICE(s_id)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10992
					break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10993
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10994
				if (!FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10995
					break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10996
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10997
				if ((cmd = fp_alloc_pkt(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10998
				    sizeof (la_els_rjt_t), 0, KM_SLEEP,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 10999
				    NULL)) == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11000
					/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11001
					 * Can this actually fail when
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11002
					 * given KM_SLEEP?  (Could be used
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11003
					 * this way in a number of places.)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11004
					 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11005
					break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11006
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11007
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11008
				fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11009
				    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11010
				    FC_REASON_INVALID_LINK_CTRL, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11011
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11012
				if (fp_sendcmd(port, cmd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11013
				    port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11014
					fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11015
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11016
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11017
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11018
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11019
			if (ls_code == LA_ELS_LOGO) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11020
				fp_handle_unsol_logo(port, buf, pd, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11021
			} else if (ls_code == LA_ELS_ADISC) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11022
				fp_handle_unsol_adisc(port, buf, pd, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11023
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11024
				fp_handle_unsol_prlo(port, buf, pd, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11025
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11026
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11027
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11028
		case LA_ELS_PLOGI:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11029
			fp_handle_unsol_plogi(port, buf, job, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11030
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11031
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11032
		case LA_ELS_FLOGI:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11033
			fp_handle_unsol_flogi(port, buf, job, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11034
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11035
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11036
		case LA_ELS_RSCN:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11037
			fp_handle_unsol_rscn(port, buf, job, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11038
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11039
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11040
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11041
			ub_spec = kmem_zalloc(sizeof (*ub_spec), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11042
			ub_spec->port = port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11043
			ub_spec->buf = buf;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11044
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11045
			(void) taskq_dispatch(port->fp_taskq,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11046
			    fp_ulp_unsol_cb, ub_spec, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11047
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11048
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11049
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11050
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11051
	case R_CTL_BASIC_SVC:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11052
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11053
		 * The unsolicited basic link services could be ABTS
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11054
		 * and RMC (Or even a NOP). Just BA_RJT them until
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11055
		 * such time there arises a need to handle them more
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11056
		 * carefully.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11057
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11058
		if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11059
			cmd = fp_alloc_pkt(port, sizeof (la_ba_rjt_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11060
			    0, KM_SLEEP, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11061
			if (cmd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11062
				fp_ba_rjt_init(port, cmd, buf, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11063
				if (fp_sendcmd(port, cmd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11064
				    port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11065
					fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11066
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11067
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11068
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11069
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11070
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11071
	case R_CTL_DEVICE_DATA:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11072
		if (buf->ub_frame.type == FC_TYPE_FC_SERVICES) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11073
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11074
			 * Mostly this is of type FC_TYPE_FC_SERVICES.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11075
			 * As we don't like any Unsolicited FC services
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11076
			 * requests, we would do well to RJT them as
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11077
			 * well.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11078
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11079
			if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11080
				cmd = fp_alloc_pkt(port, sizeof (la_els_rjt_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11081
				    0, KM_SLEEP, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11082
				if (cmd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11083
					fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11084
					    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11085
					    FC_REASON_INVALID_LINK_CTRL, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11086
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11087
					if (fp_sendcmd(port, cmd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11088
					    port->fp_fca_handle) !=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11089
					    FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11090
						fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11091
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11092
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11093
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11094
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11095
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11096
		/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11097
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11098
	case R_CTL_FC4_SVC:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11099
		ub_spec = kmem_zalloc(sizeof (*ub_spec), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11100
		ub_spec->port = port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11101
		ub_spec->buf = buf;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11102
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11103
		(void) taskq_dispatch(port->fp_taskq,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11104
		    fp_ulp_unsol_cb, ub_spec, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11105
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11106
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11107
	case R_CTL_LINK_CTL:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11108
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11109
		 * Turn deaf ear on unsolicited link control frames.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11110
		 * Typical unsolicited link control Frame is an LCR
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11111
		 * (to reset End to End credit to the default login
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11112
		 * value and abort current sequences for all classes)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11113
		 * An intelligent microcode/firmware should handle
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11114
		 * this transparently at its level and not pass all
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11115
		 * the way up here.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11116
		 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11117
		 * Possible responses to LCR are R_RDY, F_RJT, P_RJT
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11118
		 * or F_BSY. P_RJT is chosen to be the most appropriate
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11119
		 * at this time.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11120
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11121
		/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11122
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11123
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11124
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11125
		 * Just reject everything else as an invalid request.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11126
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11127
		if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11128
			cmd = fp_alloc_pkt(port, sizeof (la_els_rjt_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11129
			    0, KM_SLEEP, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11130
			if (cmd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11131
				fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11132
				    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11133
				    FC_REASON_INVALID_LINK_CTRL, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11134
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11135
				if (fp_sendcmd(port, cmd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11136
				    port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11137
					fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11138
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11139
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11140
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11141
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11142
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11143
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11144
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11145
	ASSERT(port->fp_active_ubs > 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11146
	if (--(port->fp_active_ubs) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11147
		port->fp_soft_state &= ~FP_SOFT_IN_UNSOL_CB;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11148
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11149
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11150
	port->fp_fca_tran->fca_ub_release(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11151
	    1, &buf->ub_token);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11152
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11153
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11154
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11155
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11156
 * Prepare a BA_RJT and send it over.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11157
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11158
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11159
fp_ba_rjt_init(fc_local_port_t *port, fp_cmd_t *cmd, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11160
    job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11161
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11162
	fc_packet_t	*pkt;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11163
	la_ba_rjt_t	payload;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11164
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11165
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11166
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11167
	cmd->cmd_pkt.pkt_tran_flags = buf->ub_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11168
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_OUTBOUND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11169
	cmd->cmd_flags = FP_CMD_CFLAG_UNDEFINED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11170
	cmd->cmd_retry_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11171
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11172
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11173
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11174
	cmd->cmd_job = job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11175
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11176
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11177
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11178
	fp_unsol_resp_init(pkt, buf, R_CTL_LS_BA_RJT, FC_TYPE_BASIC_LS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11179
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11180
	payload.reserved = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11181
	payload.reason_code = FC_REASON_CMD_UNSUPPORTED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11182
	payload.explanation = FC_EXPLN_NONE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11183
	payload.vendor = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11184
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11185
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11186
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11187
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11188
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11189
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11190
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11191
 * Prepare an LS_RJT and send it over
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11192
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11193
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11194
fp_els_rjt_init(fc_local_port_t *port, fp_cmd_t *cmd, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11195
    uchar_t action, uchar_t reason, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11196
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11197
	fc_packet_t	*pkt;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11198
	la_els_rjt_t	payload;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11199
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11200
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11201
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11202
	cmd->cmd_pkt.pkt_tran_flags = buf->ub_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11203
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_OUTBOUND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11204
	cmd->cmd_flags = FP_CMD_CFLAG_UNDEFINED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11205
	cmd->cmd_retry_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11206
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11207
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11208
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11209
	cmd->cmd_job = job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11210
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11211
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11212
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11213
	fp_unsol_resp_init(pkt, buf, R_CTL_ELS_RSP, FC_TYPE_EXTENDED_LS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11214
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11215
	payload.ls_code.ls_code = LA_ELS_RJT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11216
	payload.ls_code.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11217
	payload.action = action;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11218
	payload.reason = reason;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11219
	payload.reserved = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11220
	payload.vu = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11221
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11222
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11223
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11224
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11225
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11226
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11227
 *     Function: fp_prlo_acc_init
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11228
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11229
 *  Description: Initializes an Link Service Accept for a PRLO.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11230
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11231
 *    Arguments: *port		Local port through which the PRLO was
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11232
 *				received.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11233
 *		 cmd		Command that will carry the accept.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11234
 *		 *buf		Unsolicited buffer containing the PRLO
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11235
 *				request.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11236
 *		 job		Job request.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11237
 *		 sleep		Allocation mode.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11238
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11239
 * Return Value: *cmd		Command containing the response.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11240
 *
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11241
 *	Context: Depends on the parameter sleep.
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11242
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11243
fp_cmd_t *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11244
fp_prlo_acc_init(fc_local_port_t *port, fc_remote_port_t *pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11245
    fc_unsol_buf_t *buf, job_request_t *job, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11246
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11247
	fp_cmd_t	*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11248
	fc_packet_t	*pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11249
	la_els_prlo_t	*req;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11250
	size_t		len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11251
	uint16_t	flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11252
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11253
	req = (la_els_prlo_t *)buf->ub_buffer;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11254
	len = (size_t)ntohs(req->payload_length);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11255
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11256
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11257
	 * The payload of the accept to a PRLO has to be the exact match of
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11258
	 * the payload of the request (at the exception of the code).
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11259
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11260
	cmd = fp_alloc_pkt(port, (int)len, 0, sleep, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11261
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11262
	if (cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11263
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11264
		 * The fp command was successfully allocated.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11265
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11266
		cmd->cmd_pkt.pkt_tran_flags = buf->ub_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11267
		cmd->cmd_pkt.pkt_tran_type = FC_PKT_OUTBOUND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11268
		cmd->cmd_flags = FP_CMD_CFLAG_UNDEFINED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11269
		cmd->cmd_retry_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11270
		cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11271
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11272
		cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11273
		cmd->cmd_job = job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11274
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11275
		pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11276
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11277
		fp_unsol_resp_init(pkt, buf, R_CTL_ELS_RSP,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11278
		    FC_TYPE_EXTENDED_LS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11279
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11280
		/* The code is overwritten for the copy. */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11281
		req->ls_code = LA_ELS_ACC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11282
		/* Response code is set. */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11283
		flags = ntohs(req->flags);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11284
		flags &= ~SP_RESP_CODE_MASK;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11285
		flags |= SP_RESP_CODE_REQ_EXECUTED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11286
		req->flags = htons(flags);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11287
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11288
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)req,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11289
		    (uint8_t *)pkt->pkt_cmd, len, DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11290
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11291
	return (cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11292
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11293
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11294
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11295
 * Prepare an ACC response to an ELS request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11296
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11297
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11298
fp_els_acc_init(fc_local_port_t *port, fp_cmd_t *cmd, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11299
    job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11300
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11301
	fc_packet_t	*pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11302
	ls_code_t	payload;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11303
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11304
	cmd->cmd_pkt.pkt_tran_flags = buf->ub_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11305
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_OUTBOUND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11306
	cmd->cmd_flags = FP_CMD_CFLAG_UNDEFINED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11307
	cmd->cmd_retry_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11308
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11309
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11310
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11311
	cmd->cmd_job = job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11312
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11313
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11314
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11315
	fp_unsol_resp_init(pkt, buf, R_CTL_ELS_RSP, FC_TYPE_EXTENDED_LS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11316
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11317
	payload.ls_code = LA_ELS_ACC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11318
	payload.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11319
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11320
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11321
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11322
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11323
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11324
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11325
 * Unsolicited PRLO handler
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11326
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11327
 * A Process Logout should be handled by the ULP that established it.  However,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11328
 * some devices send a PRLO to trigger a PLOGI followed by a PRLI.  This happens
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11329
 * when a device implicitly logs out an initiator (for whatever reason) and
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11330
 * tries to get that initiator to restablish the connection (PLOGI and PRLI).
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11331
 * The logical thing to do for the device would be to send a LOGO in response
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11332
 * to any FC4 frame sent by the initiator. Some devices choose, however, to send
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11333
 * a PRLO instead.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11334
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11335
 * From a Fibre Channel standpoint a PRLO calls for a PRLI. There's no reason to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11336
 * think that the Port Login has been lost.  If we follow the Fibre Channel
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11337
 * protocol to the letter a PRLI should be sent after accepting the PRLO.  If
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11338
 * the Port Login has also been lost, the remote port will reject the PRLI
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11339
 * indicating that we must PLOGI first.	 The initiator will then turn around and
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11340
 * send a PLOGI.  The way Leadville is layered and the way the ULP interface
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11341
 * is defined doesn't allow this scenario to be followed easily.  If FCP were to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11342
 * handle the PRLO and attempt the PRLI, the reject indicating that a PLOGI is
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11343
 * needed would be received by FCP. FCP would have, then, to tell the transport
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11344
 * (fp) to PLOGI.  The problem is, the transport would still think the Port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11345
 * Login is valid and there is no way for FCP to tell the transport: "PLOGI even
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11346
 * if you think it's not necessary".  To work around that difficulty, the PRLO
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11347
 * is treated by the transport as a LOGO.  The downside to it is a Port Login
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11348
 * may be disrupted (if a PLOGI wasn't actually needed) and another ULP (that
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11349
 * has nothing to do with the PRLO) may be impacted.  However, this is a
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11350
 * scenario very unlikely to happen.  As of today the only ULP in Leadville
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11351
 * using PRLI/PRLOs is FCP.  For a PRLO to disrupt another ULP (that would be
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11352
 * FCIP), a SCSI target would have to be running FCP and FCIP (which is very
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11353
 * unlikely).
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11354
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11355
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11356
fp_handle_unsol_prlo(fc_local_port_t *port, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11357
    fc_remote_port_t *pd, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11358
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11359
	int		busy;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11360
	int		rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11361
	int		retain;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11362
	fp_cmd_t	*cmd;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11363
	fc_portmap_t	*listptr;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11364
	boolean_t	tolerance;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11365
	la_els_prlo_t	*req;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11366
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11367
	req = (la_els_prlo_t *)buf->ub_buffer;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11368
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11369
	if ((ntohs(req->payload_length) !=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11370
	    (sizeof (service_parameter_page_t) + sizeof (ls_code_t))) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11371
	    (req->page_length != sizeof (service_parameter_page_t))) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11372
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11373
		 * We are being very restrictive.  Only on page per
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11374
		 * payload.  If it is not the case we reject the ELS although
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11375
		 * we should reply indicating we handle only single page
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11376
		 * per PRLO.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11377
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11378
		goto fp_reject_prlo;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11379
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11380
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11381
	if (ntohs(req->payload_length) > buf->ub_bufsize) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11382
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11383
		 * This is in case the payload advertizes a size bigger than
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11384
		 * what it really is.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11385
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11386
		goto fp_reject_prlo;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11387
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11388
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11389
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11390
	busy = port->fp_statec_busy;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11391
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11392
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11393
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11394
	tolerance = fctl_tc_increment(&pd->pd_logo_tc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11395
	if (!busy) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11396
		if (pd->pd_state != PORT_DEVICE_LOGGED_IN ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11397
		    pd->pd_state == PORT_DEVICE_INVALID ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11398
		    pd->pd_flags == PD_ELS_IN_PROGRESS ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11399
		    pd->pd_type == PORT_DEVICE_OLD) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11400
			busy++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11401
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11402
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11403
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11404
	if (busy) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11405
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11406
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11407
		FP_TRACE(FP_NHEAD1(5, 0), "Logout; D_ID=%x,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11408
		    "pd=%p - busy",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11409
		    pd->pd_port_id.port_id, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11410
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11411
		if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11412
			goto fp_reject_prlo;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11413
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11414
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11415
		retain = (pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11416
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11417
		if (tolerance) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11418
			fctl_tc_reset(&pd->pd_logo_tc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11419
			retain = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11420
			pd->pd_state = PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11421
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11422
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11423
		FP_TRACE(FP_NHEAD1(5, 0), "Accepting LOGO; d_id=%x, pd=%p,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11424
		    " tolerance=%d retain=%d", pd->pd_port_id.port_id, pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11425
		    tolerance, retain);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11426
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11427
		pd->pd_aux_flags |= PD_LOGGED_OUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11428
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11429
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11430
		cmd = fp_prlo_acc_init(port, pd, buf, job, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11431
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11432
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11433
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11434
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11435
		rval = fp_sendcmd(port, cmd, port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11436
		if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11437
			fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11438
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11439
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11440
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11441
		listptr = kmem_zalloc(sizeof (fc_portmap_t), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11442
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11443
		if (retain) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11444
			fp_unregister_login(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11445
			fctl_copy_portmap(listptr, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11446
		} else {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11447
			uint32_t	d_id;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11448
			char		ww_name[17];
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11449
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11450
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11451
			d_id = pd->pd_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11452
			fc_wwn_to_str(&pd->pd_port_name, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11453
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11454
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11455
			FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11456
			    "N_x Port with D_ID=%x, PWWN=%s logged out"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11457
			    " %d times in %d us; Giving up", d_id, ww_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11458
			    FC_LOGO_TOLERANCE_LIMIT,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11459
			    FC_LOGO_TOLERANCE_TIME_LIMIT);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11460
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11461
			fp_fillout_old_map(listptr, pd, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11462
			listptr->map_type = PORT_DEVICE_OLD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11463
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11464
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11465
		(void) fp_ulp_devc_cb(port, listptr, 1, 1, KM_SLEEP, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11466
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11467
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11468
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11469
fp_reject_prlo:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11470
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11471
	cmd = fp_alloc_pkt(port, sizeof (la_els_rjt_t), 0, KM_SLEEP, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11472
	if (cmd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11473
		fp_els_rjt_init(port, cmd, buf, FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11474
		    FC_REASON_INVALID_LINK_CTRL, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11475
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11476
		if (fp_sendcmd(port, cmd, port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11477
			fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11478
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11479
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11480
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11481
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11482
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11483
 * Unsolicited LOGO handler
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11484
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11485
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11486
fp_handle_unsol_logo(fc_local_port_t *port, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11487
    fc_remote_port_t *pd, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11488
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11489
	int		busy;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11490
	int		rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11491
	int		retain;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11492
	fp_cmd_t	*cmd;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11493
	fc_portmap_t	*listptr;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11494
	boolean_t	tolerance;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11495
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11496
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11497
	busy = port->fp_statec_busy;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11498
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11499
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11500
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11501
	tolerance = fctl_tc_increment(&pd->pd_logo_tc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11502
	if (!busy) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11503
		if (pd->pd_state != PORT_DEVICE_LOGGED_IN ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11504
		    pd->pd_state == PORT_DEVICE_INVALID ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11505
		    pd->pd_flags == PD_ELS_IN_PROGRESS ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11506
		    pd->pd_type == PORT_DEVICE_OLD) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11507
			busy++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11508
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11509
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11510
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11511
	if (busy) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11512
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11513
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11514
		FP_TRACE(FP_NHEAD1(5, 0), "Logout; D_ID=%x,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11515
		    "pd=%p - busy",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11516
		    pd->pd_port_id.port_id, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11517
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11518
		if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11519
			cmd = fp_alloc_pkt(port, sizeof (la_els_rjt_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11520
			    0, KM_SLEEP, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11521
			if (cmd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11522
				fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11523
				    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11524
				    FC_REASON_INVALID_LINK_CTRL, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11525
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11526
				if (fp_sendcmd(port, cmd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11527
				    port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11528
					fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11529
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11530
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11531
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11532
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11533
		retain = (pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11534
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11535
		if (tolerance) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11536
			fctl_tc_reset(&pd->pd_logo_tc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11537
			retain = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11538
			pd->pd_state = PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11539
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11540
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11541
		FP_TRACE(FP_NHEAD1(5, 0), "Accepting LOGO; d_id=%x, pd=%p,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11542
		    " tolerance=%d retain=%d", pd->pd_port_id.port_id, pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11543
		    tolerance, retain);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11544
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11545
		pd->pd_aux_flags |= PD_LOGGED_OUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11546
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11547
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11548
		cmd = fp_alloc_pkt(port, FP_PORT_IDENTIFIER_LEN, 0,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11549
		    KM_SLEEP, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11550
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11551
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11552
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11553
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11554
		fp_els_acc_init(port, cmd, buf, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11555
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11556
		rval = fp_sendcmd(port, cmd, port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11557
		if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11558
			fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11559
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11560
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11561
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11562
		listptr = kmem_zalloc(sizeof (fc_portmap_t), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11563
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11564
		if (retain) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11565
			job_request_t	*job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11566
			fctl_ns_req_t	*ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11567
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11568
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11569
			 * when get LOGO, first try to get PID from nameserver
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11570
			 * if failed, then we do not need
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11571
			 * send PLOGI to that remote port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11572
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11573
			job = fctl_alloc_job(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11574
			    JOB_NS_CMD, 0, NULL, (opaque_t)port, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11575
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11576
			if (job != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11577
				ns_cmd = fctl_alloc_ns_cmd(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11578
				    sizeof (ns_req_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11579
				    sizeof (ns_resp_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11580
				    sizeof (ns_resp_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11581
				    0, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11582
				if (ns_cmd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11583
					int ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11584
					job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11585
					ns_cmd->ns_cmd_code = NS_GID_PN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11586
					((ns_req_gid_pn_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11587
					    (ns_cmd->ns_cmd_buf))->pwwn =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11588
					    pd->pd_port_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11589
					ret = fp_ns_query(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11590
					    port, ns_cmd, job, 1, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11591
					if ((ret != FC_SUCCESS) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11592
					    (job->job_result != FC_SUCCESS)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11593
						fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11594
						fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11595
						FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11596
						    "NS query failed,",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11597
						    " delete pd");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11598
						goto delete_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11599
					}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11600
					fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11601
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11602
				fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11603
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11604
			fp_unregister_login(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11605
			fctl_copy_portmap(listptr, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11606
		} else {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11607
			uint32_t	d_id;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11608
			char		ww_name[17];
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11609
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11610
		delete_pd:
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11611
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11612
			d_id = pd->pd_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11613
			fc_wwn_to_str(&pd->pd_port_name, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11614
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11615
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11616
			FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11617
			    "N_x Port with D_ID=%x, PWWN=%s logged out"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11618
			    " %d times in %d us; Giving up", d_id, ww_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11619
			    FC_LOGO_TOLERANCE_LIMIT,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11620
			    FC_LOGO_TOLERANCE_TIME_LIMIT);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11621
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11622
			fp_fillout_old_map(listptr, pd, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11623
			listptr->map_type = PORT_DEVICE_OLD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11624
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11625
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11626
		(void) fp_ulp_devc_cb(port, listptr, 1, 1, KM_SLEEP, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11627
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11628
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11629
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11630
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11631
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11632
 * Perform general purpose preparation of a response to an unsolicited request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11633
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11634
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11635
fp_unsol_resp_init(fc_packet_t *pkt, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11636
    uchar_t r_ctl, uchar_t type)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11637
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11638
	pkt->pkt_cmd_fhdr.r_ctl = r_ctl;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11639
	pkt->pkt_cmd_fhdr.d_id = buf->ub_frame.s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11640
	pkt->pkt_cmd_fhdr.s_id = buf->ub_frame.d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11641
	pkt->pkt_cmd_fhdr.type = type;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11642
	pkt->pkt_cmd_fhdr.f_ctl = F_CTL_LAST_SEQ | F_CTL_XCHG_CONTEXT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11643
	pkt->pkt_cmd_fhdr.seq_id = buf->ub_frame.seq_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11644
	pkt->pkt_cmd_fhdr.df_ctl  = buf->ub_frame.df_ctl;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11645
	pkt->pkt_cmd_fhdr.seq_cnt = buf->ub_frame.seq_cnt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11646
	pkt->pkt_cmd_fhdr.ox_id = buf->ub_frame.ox_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11647
	pkt->pkt_cmd_fhdr.rx_id = buf->ub_frame.rx_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11648
	pkt->pkt_cmd_fhdr.ro = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11649
	pkt->pkt_cmd_fhdr.rsvd = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11650
	pkt->pkt_comp = fp_unsol_intr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11651
	pkt->pkt_timeout = FP_ELS_TIMEOUT;
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11652
	pkt->pkt_ub_resp_token = (opaque_t)buf;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11653
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11654
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11655
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11656
 * Immediate handling of unsolicited FLOGI and PLOGI requests. In the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11657
 * early development days of public loop soc+ firmware, numerous problems
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11658
 * were encountered (the details are undocumented and history now) which
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11659
 * led to the birth of this function.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11660
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11661
 * If a pre-allocated unsolicited response packet is free, send out an
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11662
 * immediate response, otherwise submit the request to the port thread
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11663
 * to do the deferred processing.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11664
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11665
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11666
fp_i_handle_unsol_els(fc_local_port_t *port, fc_unsol_buf_t *buf)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11667
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11668
	int			sent;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11669
	int			f_port;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11670
	int			do_acc;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11671
	fp_cmd_t		*cmd;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11672
	la_els_logi_t		*payload;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11673
	fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11674
	char			dww_name[17];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11675
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11676
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11677
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11678
	cmd = port->fp_els_resp_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11679
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11680
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11681
	do_acc = (port->fp_statec_busy == 0) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11682
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11683
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11684
	switch (buf->ub_buffer[0]) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11685
	case LA_ELS_PLOGI: {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11686
		int small;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11687
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11688
		payload = (la_els_logi_t *)buf->ub_buffer;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11689
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11690
		f_port = FP_IS_F_PORT(payload->
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11691
		    common_service.cmn_features) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11692
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11693
		small = fctl_wwn_cmp(&port->fp_service_params.nport_ww_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11694
		    &payload->nport_ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11695
		pd = fctl_get_remote_port_by_pwwn(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11696
		    &payload->nport_ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11697
		if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11698
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11699
			sent = (pd->pd_flags == PD_ELS_IN_PROGRESS) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11700
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11701
			 * Most likely this means a cross login is in
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11702
			 * progress or a device about to be yanked out.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11703
			 * Only accept the plogi if my wwn is smaller.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11704
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11705
			if (pd->pd_type == PORT_DEVICE_OLD) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11706
				sent = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11707
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11708
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11709
			 * Stop plogi request (if any)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11710
			 * attempt from local side to speedup
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11711
			 * the discovery progress.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11712
			 * Mark the pd as PD_PLOGI_RECEPIENT.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11713
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11714
			if (f_port == 0 && small < 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11715
				pd->pd_recepient = PD_PLOGI_RECEPIENT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11716
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11717
			fc_wwn_to_str(&pd->pd_port_name, dww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11718
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11719
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11720
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11721
			FP_TRACE(FP_NHEAD1(3, 0), "fp_i_handle_unsol_els: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11722
			    "Unsol PLOGI received. PD still exists in the "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11723
			    "PWWN list. pd=%p PWWN=%s, sent=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11724
			    pd, dww_name, sent);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11725
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11726
			if (f_port == 0 && small < 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11727
				FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11728
				    "fp_i_handle_unsol_els: Mark the pd"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11729
				    " as plogi recipient, pd=%p, PWWN=%s"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11730
				    ", sent=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11731
				    pd, dww_name, sent);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11732
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11733
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11734
			sent = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11735
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11736
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11737
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11738
		 * To avoid Login collisions, accept only if my WWN
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11739
		 * is smaller than the requester (A curious side note
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11740
		 * would be that this rule may not satisfy the PLOGIs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11741
		 * initiated by the switch from not-so-well known
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11742
		 * ports such as 0xFFFC41)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11743
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11744
		if ((f_port == 0 && small < 0) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11745
		    (((small > 0 && do_acc) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11746
		    FC_MUST_ACCEPT_D_ID(buf->ub_frame.s_id)) && sent == 0)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11747
			if (fp_is_class_supported(port->fp_cos,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11748
			    buf->ub_class) == FC_FAILURE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11749
				if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11750
					cmd->cmd_pkt.pkt_cmdlen =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11751
					    sizeof (la_els_rjt_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11752
					cmd->cmd_pkt.pkt_rsplen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11753
					fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11754
					    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11755
					    FC_REASON_CLASS_NOT_SUPP, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11756
					FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11757
					    "fp_i_handle_unsol_els: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11758
					    "Unsupported class. "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11759
					    "Rejecting PLOGI");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11760
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11761
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11762
					mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11763
					port->fp_els_resp_pkt_busy = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11764
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11765
					return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11766
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11767
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11768
				cmd->cmd_pkt.pkt_cmdlen =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11769
				    sizeof (la_els_logi_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11770
				cmd->cmd_pkt.pkt_rsplen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11771
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11772
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11773
				 * If fp_port_id is zero and topology is
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11774
				 * Point-to-Point, get the local port id from
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11775
				 * the d_id in the PLOGI request.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11776
				 * If the outgoing FLOGI hasn't been accepted,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11777
				 * the topology will be unknown here. But it's
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11778
				 * still safe to save the d_id to fp_port_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11779
				 * just because it will be overwritten later
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11780
				 * if the topology is not Point-to-Point.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11781
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11782
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11783
				if ((port->fp_port_id.port_id == 0) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11784
				    (port->fp_topology == FC_TOP_PT_PT ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11785
				    port->fp_topology == FC_TOP_UNKNOWN)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11786
					port->fp_port_id.port_id =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11787
					    buf->ub_frame.d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11788
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11789
				mutex_exit(&port->fp_mutex);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11790
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11791
				/*
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11792
				 * Sometime later, we should validate
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11793
				 * the service parameters instead of
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11794
				 * just accepting it.
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11795
				 */
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11796
				fp_login_acc_init(port, cmd, buf, NULL,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11797
				    KM_NOSLEEP);
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11798
				FP_TRACE(FP_NHEAD1(3, 0),
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11799
				    "fp_i_handle_unsol_els: Accepting PLOGI,"
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11800
				    " f_port=%d, small=%d, do_acc=%d,"
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11801
				    " sent=%d.", f_port, small, do_acc,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 11802
				    sent);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11803
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11804
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11805
			if (FP_IS_CLASS_1_OR_2(buf->ub_class) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11806
			    port->fp_options & FP_SEND_RJT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11807
				cmd->cmd_pkt.pkt_cmdlen = sizeof (la_els_rjt_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11808
				cmd->cmd_pkt.pkt_rsplen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11809
				fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11810
				    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11811
				    FC_REASON_LOGICAL_BSY, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11812
				FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11813
				    "fp_i_handle_unsol_els: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11814
				    "Rejecting PLOGI with Logical Busy."
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11815
				    "Possible Login collision.");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11816
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11817
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11818
				port->fp_els_resp_pkt_busy = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11819
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11820
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11821
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11822
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11823
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11824
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11825
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11826
	case LA_ELS_FLOGI:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11827
		if (fp_is_class_supported(port->fp_cos,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11828
		    buf->ub_class) == FC_FAILURE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11829
			if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11830
				cmd->cmd_pkt.pkt_cmdlen = sizeof (la_els_rjt_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11831
				cmd->cmd_pkt.pkt_rsplen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11832
				fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11833
				    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11834
				    FC_REASON_CLASS_NOT_SUPP, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11835
				FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11836
				    "fp_i_handle_unsol_els: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11837
				    "Unsupported Class. Rejecting FLOGI.");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11838
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11839
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11840
				port->fp_els_resp_pkt_busy = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11841
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11842
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11843
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11844
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11845
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11846
			if (FC_PORT_STATE_MASK(port->fp_state) !=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11847
			    FC_STATE_ONLINE || (port->fp_port_id.port_id &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11848
			    buf->ub_frame.s_id == port->fp_port_id.port_id)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11849
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11850
				if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11851
					cmd->cmd_pkt.pkt_cmdlen =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11852
					    sizeof (la_els_rjt_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11853
					cmd->cmd_pkt.pkt_rsplen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11854
					fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11855
					    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11856
					    FC_REASON_INVALID_LINK_CTRL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11857
					    NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11858
					FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11859
					    "fp_i_handle_unsol_els: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11860
					    "Invalid Link Ctrl. "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11861
					    "Rejecting FLOGI.");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11862
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11863
					mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11864
					port->fp_els_resp_pkt_busy = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11865
					mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11866
					return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11867
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11868
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11869
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11870
				cmd->cmd_pkt.pkt_cmdlen =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11871
				    sizeof (la_els_logi_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11872
				cmd->cmd_pkt.pkt_rsplen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11873
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11874
				 * Let's not aggressively validate the N_Port's
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11875
				 * service parameters until PLOGI. Suffice it
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11876
				 * to give a hint that we are an N_Port and we
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11877
				 * are game to some serious stuff here.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11878
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11879
				fp_login_acc_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11880
				    NULL, KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11881
				FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11882
				    "fp_i_handle_unsol_els: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11883
				    "Accepting FLOGI.");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11884
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11885
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11886
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11887
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11888
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11889
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11890
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11891
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11892
	if ((fp_sendcmd(port, cmd, port->fp_fca_handle)) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11893
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11894
		port->fp_els_resp_pkt_busy = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11895
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11896
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11897
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11898
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11899
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11900
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11901
 * Handle unsolicited PLOGI request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11902
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11903
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11904
fp_handle_unsol_plogi(fc_local_port_t *port, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11905
    job_request_t *job, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11906
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11907
	int			sent;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11908
	int			small;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11909
	int			f_port;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11910
	int			do_acc;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11911
	fp_cmd_t		*cmd;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11912
	la_wwn_t		*swwn;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11913
	la_wwn_t		*dwwn;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11914
	la_els_logi_t		*payload;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11915
	fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11916
	char			dww_name[17];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11917
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11918
	payload = (la_els_logi_t *)buf->ub_buffer;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11919
	f_port = FP_IS_F_PORT(payload->common_service.cmn_features) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11920
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11921
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11922
	do_acc = (port->fp_statec_busy == 0) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11923
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11924
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11925
	FP_TRACE(FP_NHEAD1(3, 0), "fp_handle_unsol_plogi: s_id=%x, d_id=%x,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11926
	    "type=%x, f_ctl=%x"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11927
	    " seq_id=%x, ox_id=%x, rx_id=%x"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11928
	    " ro=%x", buf->ub_frame.s_id, buf->ub_frame.d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11929
	    buf->ub_frame.type, buf->ub_frame.f_ctl, buf->ub_frame.seq_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11930
	    buf->ub_frame.ox_id, buf->ub_frame.rx_id, buf->ub_frame.ro);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11931
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11932
	swwn = &port->fp_service_params.nport_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11933
	dwwn = &payload->nport_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11934
	small = fctl_wwn_cmp(swwn, dwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11935
	pd = fctl_get_remote_port_by_pwwn(port, dwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11936
	if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11937
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11938
		sent = (pd->pd_flags == PD_ELS_IN_PROGRESS) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11939
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11940
		 * Most likely this means a cross login is in
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11941
		 * progress or a device about to be yanked out.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11942
		 * Only accept the plogi if my wwn is smaller.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11943
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11944
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11945
		if (pd->pd_type == PORT_DEVICE_OLD) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11946
			sent = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11947
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11948
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11949
		 * Stop plogi request (if any)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11950
		 * attempt from local side to speedup
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11951
		 * the discovery progress.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11952
		 * Mark the pd as PD_PLOGI_RECEPIENT.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11953
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11954
		if (f_port == 0 && small < 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11955
			pd->pd_recepient = PD_PLOGI_RECEPIENT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11956
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11957
		fc_wwn_to_str(&pd->pd_port_name, dww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11958
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11959
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11960
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11961
		FP_TRACE(FP_NHEAD1(3, 0), "fp_handle_unsol_plogi: Unsol PLOGI"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11962
		    " received. PD still exists in the PWWN list. pd=%p "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11963
		    "PWWN=%s, sent=%x", pd, dww_name, sent);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11964
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11965
		if (f_port == 0 && small < 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11966
			FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11967
			    "fp_handle_unsol_plogi: Mark the pd"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11968
			    " as plogi recipient, pd=%p, PWWN=%s"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11969
			    ", sent=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11970
			    pd, dww_name, sent);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11971
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11972
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11973
		sent = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11974
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11975
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11976
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11977
	 * Avoid Login collisions by accepting only if my WWN is smaller.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11978
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11979
	 * A side note: There is no need to start a PLOGI from this end in
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11980
	 *	this context if login isn't going to be accepted for the
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11981
	 *	above reason as either a LIP (in private loop), RSCN (in
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11982
	 *	fabric topology), or an FLOGI (in point to point - Huh ?
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11983
	 *	check FC-PH) would normally drive the PLOGI from this end.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11984
	 *	At this point of time there is no need for an inbound PLOGI
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11985
	 *	to kick an outbound PLOGI when it is going to be rejected
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11986
	 *	for the reason of WWN being smaller. However it isn't hard
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11987
	 *	to do that either (when such a need arises, start a timer
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11988
	 *	for a duration that extends beyond a normal device discovery
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11989
	 *	time and check if an outbound PLOGI did go before that, if
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11990
	 *	none fire one)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11991
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11992
	 *	Unfortunately, as it turned out, during booting, it is possible
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11993
	 *	to miss another initiator in the same loop as port driver
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11994
	 *	instances are serially attached. While preserving the above
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 11995
	 *	comments for belly laughs, please kick an outbound PLOGI in
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11996
	 *	a non-switch environment (which is a pt pt between N_Ports or
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11997
	 *	a private loop)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11998
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 11999
	 *	While preserving the above comments for amusement, send an
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12000
	 *	ACC if the PLOGI is going to be rejected for WWN being smaller
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12001
	 *	when no discovery is in progress at this end. Turn around
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12002
	 *	and make the port device as the PLOGI initiator, so that
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12003
	 *	during subsequent link/loop initialization, this end drives
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12004
	 *	the PLOGI (In fact both ends do in this particular case, but
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12005
	 *	only one wins)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12006
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12007
	 * Make sure the PLOGIs initiated by the switch from not-so-well-known
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12008
	 * ports (such as 0xFFFC41) are accepted too.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12009
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12010
	if ((f_port == 0 && small < 0) || (((small > 0 && do_acc) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12011
	    FC_MUST_ACCEPT_D_ID(buf->ub_frame.s_id)) && sent == 0)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12012
		if (fp_is_class_supported(port->fp_cos,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12013
		    buf->ub_class) == FC_FAILURE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12014
			if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12015
				cmd = fp_alloc_pkt(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12016
				    sizeof (la_els_logi_t), 0, sleep, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12017
				if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12018
					return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12019
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12020
				cmd->cmd_pkt.pkt_cmdlen = sizeof (la_els_rjt_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12021
				cmd->cmd_pkt.pkt_rsplen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12022
				fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12023
				    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12024
				    FC_REASON_CLASS_NOT_SUPP, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12025
				FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12026
				    "fp_handle_unsol_plogi: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12027
				    "Unsupported class. rejecting PLOGI");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12028
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12029
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12030
			cmd = fp_alloc_pkt(port, sizeof (la_els_logi_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12031
			    0, sleep, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12032
			if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12033
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12034
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12035
			cmd->cmd_pkt.pkt_cmdlen = sizeof (la_els_logi_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12036
			cmd->cmd_pkt.pkt_rsplen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12037
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12038
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12039
			 * Sometime later, we should validate the service
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12040
			 * parameters instead of just accepting it.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12041
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12042
			fp_login_acc_init(port, cmd, buf, job, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12043
			FP_TRACE(FP_NHEAD1(3, 0), "fp_handle_unsol_plogi: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12044
			    "Accepting PLOGI, f_port=%d, small=%d, "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12045
			    "do_acc=%d, sent=%d.", f_port, small, do_acc,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12046
			    sent);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12047
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12048
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12049
			 * If fp_port_id is zero and topology is
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12050
			 * Point-to-Point, get the local port id from
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12051
			 * the d_id in the PLOGI request.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12052
			 * If the outgoing FLOGI hasn't been accepted,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12053
			 * the topology will be unknown here. But it's
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12054
			 * still safe to save the d_id to fp_port_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12055
			 * just because it will be overwritten later
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12056
			 * if the topology is not Point-to-Point.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12057
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12058
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12059
			if ((port->fp_port_id.port_id == 0) &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12060
			    (port->fp_topology == FC_TOP_PT_PT ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12061
			    port->fp_topology == FC_TOP_UNKNOWN)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12062
				port->fp_port_id.port_id =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12063
				    buf->ub_frame.d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12064
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12065
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12066
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12067
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12068
		if (FP_IS_CLASS_1_OR_2(buf->ub_class) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12069
		    port->fp_options & FP_SEND_RJT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12070
			cmd = fp_alloc_pkt(port, sizeof (la_els_logi_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12071
			    0, sleep, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12072
			if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12073
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12074
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12075
			cmd->cmd_pkt.pkt_cmdlen = sizeof (la_els_rjt_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12076
			cmd->cmd_pkt.pkt_rsplen = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12077
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12078
			 * Send out Logical busy to indicate
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12079
			 * the detection of PLOGI collision
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12080
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12081
			fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12082
			    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12083
			    FC_REASON_LOGICAL_BSY, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12084
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12085
			fc_wwn_to_str(dwwn, dww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12086
			FP_TRACE(FP_NHEAD1(3, 0), "fp_handle_unsol_plogi: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12087
			    "Rejecting Unsol PLOGI with Logical Busy."
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12088
			    "possible PLOGI collision. PWWN=%s, sent=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12089
			    dww_name, sent);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12090
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12091
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12092
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12093
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12094
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12095
	if (fp_sendcmd(port, cmd, port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12096
		fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12097
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12098
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12099
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12100
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12101
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12102
 * Handle mischievous turning over of our own FLOGI requests back to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12103
 * us by the SOC+ microcode. In other words, look at the class of such
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12104
 * bone headed requests, if 1 or 2, bluntly P_RJT them, if 3 drop them
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12105
 * on the floor
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12106
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12107
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12108
fp_handle_unsol_flogi(fc_local_port_t *port, fc_unsol_buf_t *buf,
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12109
    job_request_t *job, int sleep)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12110
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12111
	uint32_t	state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12112
	uint32_t	s_id;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12113
	fp_cmd_t	*cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12114
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12115
	if (fp_is_class_supported(port->fp_cos, buf->ub_class) == FC_FAILURE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12116
		if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12117
			cmd = fp_alloc_pkt(port, sizeof (la_els_rjt_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12118
			    0, sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12119
			if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12120
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12121
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12122
			fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12123
			    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12124
			    FC_REASON_CLASS_NOT_SUPP, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12125
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12126
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12127
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12128
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12129
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12130
		FP_TRACE(FP_NHEAD1(3, 0), "fp_handle_unsol_flogi:"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12131
		    " s_id=%x, d_id=%x, type=%x, f_ctl=%x"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12132
		    " seq_id=%x, ox_id=%x, rx_id=%x, ro=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12133
		    buf->ub_frame.s_id, buf->ub_frame.d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12134
		    buf->ub_frame.type, buf->ub_frame.f_ctl,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12135
		    buf->ub_frame.seq_id, buf->ub_frame.ox_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12136
		    buf->ub_frame.rx_id, buf->ub_frame.ro);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12137
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12138
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12139
		state = FC_PORT_STATE_MASK(port->fp_state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12140
		s_id = port->fp_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12141
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12142
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12143
		if (state != FC_STATE_ONLINE ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12144
		    (s_id && buf->ub_frame.s_id == s_id)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12145
			if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12146
				cmd = fp_alloc_pkt(port, sizeof (la_els_rjt_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12147
				    0, sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12148
				if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12149
					return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12150
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12151
				fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12152
				    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12153
				    FC_REASON_INVALID_LINK_CTRL, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12154
				FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12155
				    "fp_handle_unsol_flogi: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12156
				    "Rejecting PLOGI. Invalid Link CTRL");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12157
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12158
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12159
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12160
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12161
			cmd = fp_alloc_pkt(port, sizeof (la_els_logi_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12162
			    0, sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12163
			if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12164
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12165
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12166
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12167
			 * Let's not aggressively validate the N_Port's
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12168
			 * service parameters until PLOGI. Suffice it
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12169
			 * to give a hint that we are an N_Port and we
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12170
			 * are game to some serious stuff here.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12171
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12172
			fp_login_acc_init(port, cmd, buf, job, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12173
			FP_TRACE(FP_NHEAD1(3, 0), "fp_handle_unsol_flogi: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12174
			    "Accepting PLOGI");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12175
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12176
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12177
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12178
	if (fp_sendcmd(port, cmd, port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12179
		fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12180
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12181
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12182
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12183
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12184
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12185
 * Perform PLOGI accept
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12186
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12187
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12188
fp_login_acc_init(fc_local_port_t *port, fp_cmd_t *cmd, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12189
    job_request_t *job, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12190
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12191
	fc_packet_t	*pkt;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12192
	fc_portmap_t	*listptr;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12193
	la_els_logi_t	payload;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12194
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12195
	ASSERT(buf != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12196
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12197
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12198
	 * If we are sending ACC to PLOGI and we haven't already
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12199
	 * create port and node device handles, let's create them
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12200
	 * here.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12201
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12202
	if (buf->ub_buffer[0] == LA_ELS_PLOGI &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12203
	    FC_IS_REAL_DEVICE(buf->ub_frame.s_id)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12204
		int			small;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12205
		int			do_acc;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12206
		fc_remote_port_t	*pd;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12207
		la_els_logi_t		*req;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12208
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12209
		req = (la_els_logi_t *)buf->ub_buffer;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12210
		small = fctl_wwn_cmp(&port->fp_service_params.nport_ww_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12211
		    &req->nport_ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12212
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12213
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12214
		do_acc = (port->fp_statec_busy == 0) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12215
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12216
10107
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 12217
		FP_TRACE(FP_NHEAD1(3, 0), "fp_plogi_acc_init fp %x, pd %x",
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 12218
		    port->fp_port_id.port_id, buf->ub_frame.s_id);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12219
		pd = fctl_create_remote_port(port, &req->node_ww_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12220
		    &req->nport_ww_name, buf->ub_frame.s_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12221
		    PD_PLOGI_RECEPIENT, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12222
		if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12223
			FP_TRACE(FP_NHEAD1(3, 0), "login_acc_init: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12224
			    "Couldn't create port device for d_id:0x%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12225
			    buf->ub_frame.s_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12226
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12227
			fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12228
			    "couldn't create port device d_id=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12229
			    buf->ub_frame.s_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12230
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12231
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12232
			 * usoc currently returns PLOGIs inline and
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12233
			 * the maximum buffer size is 60 bytes or so.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12234
			 * So attempt not to look beyond what is in
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12235
			 * the unsolicited buffer
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12236
			 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12237
			 * JNI also traverses this path sometimes
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12238
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12239
			if (buf->ub_bufsize >= sizeof (la_els_logi_t)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12240
				fp_register_login(NULL, pd, req, buf->ub_class);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12241
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12242
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12243
				if (pd->pd_login_count == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12244
					pd->pd_login_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12245
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12246
				pd->pd_state = PORT_DEVICE_LOGGED_IN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12247
				pd->pd_login_class = buf->ub_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12248
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12249
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12250
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12251
			listptr = kmem_zalloc(sizeof (fc_portmap_t), sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12252
			if (listptr != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12253
				fctl_copy_portmap(listptr, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12254
				(void) fp_ulp_devc_cb(port, listptr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12255
				    1, 1, sleep, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12256
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12257
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12258
			if (small > 0 && do_acc) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12259
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12260
				pd->pd_recepient = PD_PLOGI_INITIATOR;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12261
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12262
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12263
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12264
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12265
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12266
	cmd->cmd_pkt.pkt_tran_flags = buf->ub_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12267
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_OUTBOUND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12268
	cmd->cmd_flags = FP_CMD_CFLAG_UNDEFINED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12269
	cmd->cmd_retry_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12270
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12271
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12272
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12273
	cmd->cmd_job = job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12274
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12275
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12276
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12277
	fp_unsol_resp_init(pkt, buf, R_CTL_ELS_RSP, FC_TYPE_EXTENDED_LS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12278
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12279
	payload = port->fp_service_params;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12280
	payload.ls_code.ls_code = LA_ELS_ACC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12281
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12282
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12283
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12284
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12285
	FP_TRACE(FP_NHEAD1(3, 0), "login_acc_init: ELS:0x%x d_id:0x%x "
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12286
	    "bufsize:0x%x sizeof (la_els_logi):0x%x "
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12287
	    "port's wwn:0x%01x%03x%04x%08x requestor's wwn:0x%01x%03x%04x%08x "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12288
	    "statec_busy:0x%x", buf->ub_buffer[0], buf->ub_frame.s_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12289
	    buf->ub_bufsize, sizeof (la_els_logi_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12290
	    port->fp_service_params.nport_ww_name.w.naa_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12291
	    port->fp_service_params.nport_ww_name.w.nport_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12292
	    port->fp_service_params.nport_ww_name.w.wwn_hi,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12293
	    port->fp_service_params.nport_ww_name.w.wwn_lo,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12294
	    ((la_els_logi_t *)buf->ub_buffer)->nport_ww_name.w.naa_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12295
	    ((la_els_logi_t *)buf->ub_buffer)->nport_ww_name.w.nport_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12296
	    ((la_els_logi_t *)buf->ub_buffer)->nport_ww_name.w.wwn_hi,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12297
	    ((la_els_logi_t *)buf->ub_buffer)->nport_ww_name.w.wwn_lo,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12298
	    port->fp_statec_busy);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12299
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12300
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12301
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12302
#define	RSCN_EVENT_NAME_LEN	256
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12303
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12304
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12305
 * Handle RSCNs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12306
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12307
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12308
fp_handle_unsol_rscn(fc_local_port_t *port, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12309
    job_request_t *job, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12310
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12311
	uint32_t		mask;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12312
	fp_cmd_t		*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12313
	uint32_t		count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12314
	int			listindex;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12315
	int16_t			len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12316
	fc_rscn_t		*payload;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12317
	fc_portmap_t		*listptr;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12318
	fctl_ns_req_t		*ns_cmd;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12319
	fc_affected_id_t	*page;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12320
	caddr_t			nvname;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12321
	nvlist_t		*attr_list = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12322
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12323
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12324
	if (!FC_IS_TOP_SWITCH(port->fp_topology)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12325
		if (--port->fp_rscn_count == FC_INVALID_RSCN_COUNT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12326
			--port->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12327
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12328
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12329
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12330
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12331
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12332
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12333
	cmd = fp_alloc_pkt(port, FP_PORT_IDENTIFIER_LEN, 0, sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12334
	if (cmd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12335
		fp_els_acc_init(port, cmd, buf, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12336
		if (fp_sendcmd(port, cmd, port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12337
			fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12338
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12339
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12340
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12341
	payload = (fc_rscn_t *)buf->ub_buffer;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12342
	ASSERT(payload->rscn_code == LA_ELS_RSCN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12343
	ASSERT(payload->rscn_len == FP_PORT_IDENTIFIER_LEN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12344
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12345
	len = payload->rscn_payload_len - FP_PORT_IDENTIFIER_LEN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12346
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12347
	if (len <= 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12348
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12349
		if (--port->fp_rscn_count == FC_INVALID_RSCN_COUNT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12350
			--port->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12351
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12352
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12353
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12354
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12355
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12356
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12357
	ASSERT((len & 0x3) == 0);	/* Must be power of 4 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12358
	count = (len >> 2) << 1;	/* number of pages multiplied by 2 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12359
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12360
	listptr = kmem_zalloc(sizeof (fc_portmap_t) * count, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12361
	page = (fc_affected_id_t *)(buf->ub_buffer + sizeof (fc_rscn_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12362
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12363
	ASSERT((job->job_flags & JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12364
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12365
	ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gpn_id_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12366
	    sizeof (ns_resp_gpn_id_t), sizeof (ns_resp_gpn_id_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12367
	    0, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12368
	if (ns_cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12369
		kmem_free(listptr, sizeof (fc_portmap_t) * count);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12370
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12371
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12372
		if (--port->fp_rscn_count == FC_INVALID_RSCN_COUNT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12373
			--port->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12374
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12375
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12376
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12377
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12378
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12379
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12380
	ns_cmd->ns_cmd_code = NS_GPN_ID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12381
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12382
	FP_TRACE(FP_NHEAD1(3, 0), "fp_handle_unsol_rscn: s_id=%x, d_id=%x,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12383
	    "type=%x, f_ctl=%x seq_id=%x, ox_id=%x, rx_id=%x"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12384
	    " ro=%x", buf->ub_frame.s_id, buf->ub_frame.d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12385
	    buf->ub_frame.type, buf->ub_frame.f_ctl, buf->ub_frame.seq_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12386
	    buf->ub_frame.ox_id, buf->ub_frame.rx_id, buf->ub_frame.ro);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12387
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12388
	/* Only proceed if we can allocate nvname and the nvlist */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12389
	if ((nvname = kmem_zalloc(RSCN_EVENT_NAME_LEN, KM_NOSLEEP)) != NULL &&
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12390
	    nvlist_alloc(&attr_list, NV_UNIQUE_NAME_TYPE,
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12391
	    KM_NOSLEEP) == DDI_SUCCESS) {
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12392
		if (!(attr_list && nvlist_add_uint32(attr_list, "instance",
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12393
		    port->fp_instance) == DDI_SUCCESS &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12394
		    nvlist_add_byte_array(attr_list, "port-wwn",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12395
		    port->fp_service_params.nport_ww_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12396
		    sizeof (la_wwn_t)) == DDI_SUCCESS)) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12397
			nvlist_free(attr_list);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12398
			attr_list = NULL;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12399
		}
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12400
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12401
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12402
	for (listindex = 0; len; len -= FP_PORT_IDENTIFIER_LEN, page++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12403
		/* Add affected page to the event payload */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12404
		if (attr_list != NULL) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12405
			(void) snprintf(nvname, RSCN_EVENT_NAME_LEN,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12406
			    "affected_page_%d", listindex);
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12407
			if (attr_list && nvlist_add_uint32(attr_list, nvname,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12408
			    ntohl(*(uint32_t *)page)) != DDI_SUCCESS) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12409
				/* We don't send a partial event, so dump it */
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12410
				nvlist_free(attr_list);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12411
				attr_list = NULL;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12412
			}
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12413
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12414
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12415
		 * Query the NS to get the Port WWN for this
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12416
		 * affected D_ID.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12417
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12418
		mask = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12419
		switch (page->aff_format & FC_RSCN_ADDRESS_MASK) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12420
		case FC_RSCN_PORT_ADDRESS:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12421
			fp_validate_rscn_page(port, page, job, ns_cmd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12422
			    listptr, &listindex, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12423
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12424
			if (listindex == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12425
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12426
				 * We essentially did not process this RSCN. So,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12427
				 * ULPs are not going to be called and so we
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12428
				 * decrement the rscn_count
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12429
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12430
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12431
				if (--port->fp_rscn_count ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12432
				    FC_INVALID_RSCN_COUNT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12433
					--port->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12434
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12435
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12436
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12437
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12438
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12439
		case FC_RSCN_AREA_ADDRESS:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12440
			mask = 0xFFFF00;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12441
			/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12442
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12443
		case FC_RSCN_DOMAIN_ADDRESS:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12444
			if (!mask) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12445
				mask = 0xFF0000;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12446
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12447
			fp_validate_area_domain(port, page->aff_d_id, mask,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12448
			    job, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12449
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12450
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12451
		case FC_RSCN_FABRIC_ADDRESS:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12452
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12453
			 * We need to discover all the devices on this
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12454
			 * port.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12455
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12456
			fp_validate_area_domain(port, 0, 0, job, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12457
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12458
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12459
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12460
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12461
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12462
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12463
	if (attr_list != NULL) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12464
		(void) ddi_log_sysevent(port->fp_port_dip, DDI_VENDOR_SUNW,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12465
		    EC_SUNFC, ESC_SUNFC_PORT_RSCN, attr_list,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12466
		    NULL, DDI_SLEEP);
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12467
		nvlist_free(attr_list);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12468
	} else {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12469
		FP_TRACE(FP_NHEAD1(9, 0),
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12470
		    "RSCN handled, but event not sent to userland");
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12471
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12472
	if (nvname != NULL) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12473
		kmem_free(nvname, RSCN_EVENT_NAME_LEN);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12474
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12475
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12476
	if (ns_cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12477
		fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12478
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12479
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12480
	if (listindex) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12481
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12482
		page = (fc_affected_id_t *)(buf->ub_buffer +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12483
		    sizeof (fc_rscn_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12484
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12485
		if (listptr->map_did.port_id != page->aff_d_id) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12486
			FP_TRACE(FP_NHEAD1(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12487
			    "PORT RSCN: processed=%x, reporting=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12488
			    listptr->map_did.port_id, page->aff_d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12489
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12490
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12491
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12492
		(void) fp_ulp_devc_cb(port, listptr, listindex, count,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12493
		    sleep, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12494
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12495
		kmem_free(listptr, sizeof (fc_portmap_t) * count);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12496
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12497
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12498
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12499
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12500
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12501
 * Fill out old map for ULPs with fp_mutex, fd_mutex and pd_mutex held
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12502
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12503
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12504
fp_fillout_old_map_held(fc_portmap_t *map, fc_remote_port_t *pd, uchar_t flag)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12505
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12506
	int		is_switch;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12507
	int		initiator;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12508
	fc_local_port_t	*port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12509
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12510
	port = pd->pd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12511
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12512
	/* This function has the following bunch of assumptions */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12513
	ASSERT(port != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12514
	ASSERT(MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12515
	ASSERT(MUTEX_HELD(&pd->pd_remote_nodep->fd_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12516
	ASSERT(MUTEX_HELD(&pd->pd_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12517
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12518
	pd->pd_state = PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12519
	pd->pd_type = PORT_DEVICE_OLD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12520
	initiator = (pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12521
	is_switch = FC_IS_TOP_SWITCH(port->fp_topology);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12522
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12523
	fctl_delist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12524
	fctl_delist_pwwn_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12525
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12526
	FP_TRACE(FP_NHEAD1(6, 0), "fp_fillout_old_map_held: port=%p, d_id=%x"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12527
	    " removed the PD=%p from DID and PWWN tables",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12528
	    port, pd->pd_port_id.port_id, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12529
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12530
	if ((!flag) && port && initiator && is_switch) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12531
		(void) fctl_add_orphan_held(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12532
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12533
	fctl_copy_portmap_held(map, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12534
	map->map_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12535
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12536
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12537
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12538
 * Fill out old map for ULPs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12539
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12540
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12541
fp_fillout_old_map(fc_portmap_t *map, fc_remote_port_t *pd, uchar_t flag)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12542
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12543
	int		is_switch;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12544
	int		initiator;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12545
	fc_local_port_t	*port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12546
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12547
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12548
	port = pd->pd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12549
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12550
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12551
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12552
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12553
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12554
	pd->pd_state = PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12555
	pd->pd_type = PORT_DEVICE_OLD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12556
	initiator = (pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12557
	is_switch = FC_IS_TOP_SWITCH(port->fp_topology);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12558
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12559
	fctl_delist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12560
	fctl_delist_pwwn_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12561
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12562
	FP_TRACE(FP_NHEAD1(6, 0), "fp_fillout_old_map: port=%p, d_id=%x"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12563
	    " removed the PD=%p from DID and PWWN tables",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12564
	    port, pd->pd_port_id.port_id, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12565
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12566
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12567
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12568
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12569
	ASSERT(port != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12570
	if ((!flag) && port && initiator && is_switch) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12571
		(void) fctl_add_orphan(port, pd, KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12572
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12573
	fctl_copy_portmap(map, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12574
	map->map_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12575
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12576
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12577
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12578
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12579
 * Fillout Changed Map for ULPs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12580
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12581
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12582
fp_fillout_changed_map(fc_portmap_t *map, fc_remote_port_t *pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12583
    uint32_t *new_did, la_wwn_t *new_pwwn)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12584
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12585
	ASSERT(MUTEX_HELD(&pd->pd_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12586
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12587
	pd->pd_type = PORT_DEVICE_CHANGED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12588
	if (new_did) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12589
		pd->pd_port_id.port_id = *new_did;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12590
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12591
	if (new_pwwn) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12592
		pd->pd_port_name = *new_pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12593
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12594
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12595
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12596
	fctl_copy_portmap(map, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12597
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12598
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12599
	pd->pd_type = PORT_DEVICE_NOCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12600
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12601
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12602
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12603
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12604
 * Fillout New Name Server map
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12605
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12606
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12607
fp_fillout_new_nsmap(fc_local_port_t *port, ddi_acc_handle_t *handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12608
    fc_portmap_t *port_map, ns_resp_gan_t *gan_resp, uint32_t d_id)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12609
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12610
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12611
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12612
	if (handle) {
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12613
		FC_GET_RSP(port, *handle, (uint8_t *)&port_map->map_pwwn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12614
		    (uint8_t *)&gan_resp->gan_pwwn, sizeof (gan_resp->gan_pwwn),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12615
		    DDI_DEV_AUTOINCR);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12616
		FC_GET_RSP(port, *handle, (uint8_t *)&port_map->map_nwwn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12617
		    (uint8_t *)&gan_resp->gan_nwwn, sizeof (gan_resp->gan_nwwn),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12618
		    DDI_DEV_AUTOINCR);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12619
		FC_GET_RSP(port, *handle, (uint8_t *)port_map->map_fc4_types,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12620
		    (uint8_t *)gan_resp->gan_fc4types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12621
		    sizeof (gan_resp->gan_fc4types), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12622
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12623
		bcopy(&gan_resp->gan_pwwn, &port_map->map_pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12624
		    sizeof (gan_resp->gan_pwwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12625
		bcopy(&gan_resp->gan_nwwn, &port_map->map_nwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12626
		    sizeof (gan_resp->gan_nwwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12627
		bcopy(gan_resp->gan_fc4types, port_map->map_fc4_types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12628
		    sizeof (gan_resp->gan_fc4types));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12629
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12630
	port_map->map_did.port_id = d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12631
	port_map->map_did.priv_lilp_posit = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12632
	port_map->map_hard_addr.hard_addr = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12633
	port_map->map_hard_addr.rsvd = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12634
	port_map->map_state = PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12635
	port_map->map_type = PORT_DEVICE_NEW;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12636
	port_map->map_flags = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12637
	port_map->map_pd = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12638
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12639
	(void) fctl_remove_if_orphan(port, &port_map->map_pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12640
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12641
	ASSERT(port != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12642
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12643
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12644
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12645
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12646
 * Perform LINIT ELS
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12647
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12648
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12649
fp_remote_lip(fc_local_port_t *port, la_wwn_t *pwwn, int sleep,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12650
    job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12651
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12652
	int			rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12653
	uint32_t		d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12654
	uint32_t		s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12655
	uint32_t		lfa;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12656
	uchar_t			class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12657
	uint32_t		ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12658
	fp_cmd_t		*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12659
	fc_porttype_t		ptype;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12660
	fc_packet_t		*pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12661
	fc_linit_req_t		payload;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12662
	fc_remote_port_t	*pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12663
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12664
	rval = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12665
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12666
	ASSERT(job != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12667
	ASSERT((job->job_flags & JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12668
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12669
	pd = fctl_get_remote_port_by_pwwn(port, pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12670
	if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12671
		fctl_ns_req_t *ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12672
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12673
		ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12674
		    sizeof (ns_resp_gid_pn_t), sizeof (ns_resp_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12675
		    0, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12676
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12677
		if (ns_cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12678
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12679
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12680
		job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12681
		ns_cmd->ns_cmd_code = NS_GID_PN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12682
		((ns_req_gid_pn_t *)(ns_cmd->ns_cmd_buf))->pwwn = *pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12683
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12684
		ret = fp_ns_query(port, ns_cmd, job, 1, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12685
		if (ret != FC_SUCCESS || job->job_result != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12686
			fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12687
			return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12688
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12689
		bcopy(ns_cmd->ns_data_buf, (caddr_t)&d_id, sizeof (d_id));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12690
		d_id = BE_32(*((uint32_t *)ns_cmd->ns_data_buf));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12691
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12692
		fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12693
		lfa = d_id & 0xFFFF00;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12694
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12695
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12696
		 * Given this D_ID, get the port type to see if
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12697
		 * we can do LINIT on the LFA
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12698
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12699
		ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gpt_id_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12700
		    sizeof (ns_resp_gpt_id_t), sizeof (ns_resp_gpt_id_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12701
		    0, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12702
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12703
		if (ns_cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12704
			return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12705
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12706
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12707
		job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12708
		ns_cmd->ns_cmd_code = NS_GPT_ID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12709
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12710
		((ns_req_gpt_id_t *)(ns_cmd->ns_cmd_buf))->pid.port_id = d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12711
		((ns_req_gpt_id_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12712
		    (ns_cmd->ns_cmd_buf))->pid.priv_lilp_posit = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12713
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12714
		ret = fp_ns_query(port, ns_cmd, job, 1, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12715
		if (ret != FC_SUCCESS || job->job_result != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12716
			fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12717
			return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12718
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12719
		bcopy(ns_cmd->ns_data_buf, (caddr_t)&ptype, sizeof (ptype));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12720
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12721
		fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12722
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12723
		switch (ptype.port_type) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12724
		case FC_NS_PORT_NL:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12725
		case FC_NS_PORT_F_NL:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12726
		case FC_NS_PORT_FL:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12727
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12728
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12729
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12730
			return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12731
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12732
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12733
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12734
		ptype = pd->pd_porttype;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12735
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12736
		switch (pd->pd_porttype.port_type) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12737
		case FC_NS_PORT_NL:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12738
		case FC_NS_PORT_F_NL:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12739
		case FC_NS_PORT_FL:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12740
			lfa = pd->pd_port_id.port_id & 0xFFFF00;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12741
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12742
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12743
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12744
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12745
			return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12746
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12747
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12748
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12749
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12750
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12751
	s_id = port->fp_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12752
	class = port->fp_ns_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12753
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12754
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12755
	cmd = fp_alloc_pkt(port, sizeof (fc_linit_req_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12756
	    sizeof (fc_linit_resp_t), sleep, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12757
	if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12758
		return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12759
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12760
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12761
	cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12762
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12763
	cmd->cmd_flags = FP_CMD_CFLAG_UNDEFINED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12764
	cmd->cmd_retry_count = fp_retry_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12765
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12766
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12767
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12768
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12769
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12770
	fp_els_init(cmd, s_id, lfa, fp_linit_intr, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12771
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12772
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12773
	 * How does LIP work by the way ?
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12774
	 *	If the L_Port receives three consecutive identical ordered
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12775
	 *	sets whose first two characters (fully decoded) are equal to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12776
	 *	the values shown in Table 3 of FC-AL-2 then the L_Port shall
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12777
	 *	recognize a Loop Initialization Primitive sequence. The
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12778
	 *	character 3 determines the type of lip:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12779
	 *		LIP(F7)		Normal LIP
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12780
	 *		LIP(F8)		Loop Failure LIP
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12781
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12782
	 * The possible combination for the 3rd and 4th bytes are:
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12783
	 *	F7,	F7	Normal Lip	- No valid AL_PA
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12784
	 *	F8,	F8	Loop Failure	- No valid AL_PA
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12785
	 *	F7,	AL_PS	Normal Lip	- Valid source AL_PA
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12786
	 *	F8,	AL_PS	Loop Failure	- Valid source AL_PA
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12787
	 *	AL_PD	AL_PS	Loop reset of AL_PD originated by AL_PS
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12788
	 *			And Normal Lip for all other loop members
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12789
	 *	0xFF	AL_PS	Vendor specific reset of all loop members
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12790
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12791
	 * Now, it may not always be that we, at the source, may have an
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12792
	 * AL_PS (AL_PA of source) for 4th character slot, so we decide
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12793
	 * to do (Normal Lip, No Valid AL_PA), that means, in the LINIT
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12794
	 * payload we are going to set:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12795
	 *	lip_b3 = 0xF7;		Normal LIP
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12796
	 *	lip_b4 = 0xF7;		No valid source AL_PA
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12797
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12798
	payload.ls_code.ls_code = LA_ELS_LINIT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12799
	payload.ls_code.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12800
	payload.rsvd = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12801
	payload.func = 0;		/* Let Fabric determine the best way */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12802
	payload.lip_b3 = 0xF7;		/* Normal LIP */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12803
	payload.lip_b4 = 0xF7;		/* No valid source AL_PA */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12804
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12805
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12806
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12807
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12808
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12809
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12810
	ret = fp_sendcmd(port, cmd, port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12811
	if (ret == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12812
		fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12813
		rval = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12814
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12815
		rval = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12816
		fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12817
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12818
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12819
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12820
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12821
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12822
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12823
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12824
 * Fill out the device handles with GAN response
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12825
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12826
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12827
fp_stuff_device_with_gan(ddi_acc_handle_t *handle, fc_remote_port_t *pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12828
    ns_resp_gan_t *gan_resp)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12829
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12830
	fc_remote_node_t	*node;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12831
	fc_porttype_t		type;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12832
	fc_local_port_t		*port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12833
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12834
	ASSERT(pd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12835
	ASSERT(handle != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12837
	port = pd->pd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12838
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12839
	FP_TRACE(FP_NHEAD1(1, 0), "GAN PD stuffing; pd=%p,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12840
	    " port_id=%x, sym_len=%d fc4-type=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12841
	    pd, gan_resp->gan_type_id.rsvd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12842
	    gan_resp->gan_spnlen, gan_resp->gan_fc4types[0]);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12843
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12844
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12845
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12846
	FC_GET_RSP(port, *handle, (uint8_t *)&type,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12847
	    (uint8_t *)&gan_resp->gan_type_id, sizeof (type), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12848
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12849
	pd->pd_porttype.port_type = type.port_type;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12850
	pd->pd_porttype.rsvd = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12851
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12852
	pd->pd_spn_len = gan_resp->gan_spnlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12853
	if (pd->pd_spn_len) {
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12854
		FC_GET_RSP(port, *handle, (uint8_t *)pd->pd_spn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12855
		    (uint8_t *)gan_resp->gan_spname, pd->pd_spn_len,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12856
		    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12857
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12858
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12859
	FC_GET_RSP(port, *handle, (uint8_t *)pd->pd_ip_addr,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12860
	    (uint8_t *)gan_resp->gan_ip, sizeof (pd->pd_ip_addr),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12861
	    DDI_DEV_AUTOINCR);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12862
	FC_GET_RSP(port, *handle, (uint8_t *)&pd->pd_cos,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12863
	    (uint8_t *)&gan_resp->gan_cos, sizeof (pd->pd_cos),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12864
	    DDI_DEV_AUTOINCR);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12865
	FC_GET_RSP(port, *handle, (uint8_t *)pd->pd_fc4types,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12866
	    (uint8_t *)gan_resp->gan_fc4types, sizeof (pd->pd_fc4types),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12867
	    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12868
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12869
	node = pd->pd_remote_nodep;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12870
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12871
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12872
	mutex_enter(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12873
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12874
	FC_GET_RSP(port, *handle, (uint8_t *)node->fd_ipa,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12875
	    (uint8_t *)gan_resp->gan_ipa, sizeof (node->fd_ipa),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12876
	    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12877
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12878
	node->fd_snn_len = gan_resp->gan_snnlen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12879
	if (node->fd_snn_len) {
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12880
		FC_GET_RSP(port, *handle, (uint8_t *)node->fd_snn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12881
		    (uint8_t *)gan_resp->gan_snname, node->fd_snn_len,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12882
		    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12883
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12884
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12885
	mutex_exit(&node->fd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12886
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12887
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12888
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12889
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12890
 * Handles all NS Queries (also means that this function
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12891
 * doesn't handle NS object registration)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12892
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12893
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12894
fp_ns_query(fc_local_port_t *port, fctl_ns_req_t *ns_cmd, job_request_t *job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12895
    int polled, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12896
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12897
	int		rval;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12898
	fp_cmd_t	*cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12899
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12900
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12901
10107
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 12902
	if (ns_cmd->ns_cmd_code == NS_GA_NXT) {
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 12903
		FP_TRACE(FP_NHEAD1(1, 0), "fp_ns_query GA_NXT fp %x pd %x",
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 12904
		    port->fp_port_id.port_id, ns_cmd->ns_gan_sid);
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 12905
	}
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 12906
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12907
	if (ns_cmd->ns_cmd_size == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12908
		return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12909
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12910
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12911
	cmd = fp_alloc_pkt(port, sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12912
	    ns_cmd->ns_cmd_size, sizeof (fc_ct_header_t) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12913
	    ns_cmd->ns_resp_size, sleep, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12914
	if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12915
		return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12916
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12917
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12918
	fp_ct_init(port, cmd, ns_cmd, ns_cmd->ns_cmd_code, ns_cmd->ns_cmd_buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12919
	    ns_cmd->ns_cmd_size, ns_cmd->ns_resp_size, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12920
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12921
	if (polled) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12922
		job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12923
		ASSERT((job->job_flags & JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12924
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12925
	rval = fp_sendcmd(port, cmd, port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12926
	if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12927
		job->job_result = rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12928
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12929
		if (polled == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12930
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12931
			 * Return FC_SUCCESS to indicate that
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12932
			 * fp_iodone is performed already.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12933
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12934
			rval = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12935
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12936
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12937
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12938
	if (polled) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12939
		fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12940
		rval = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12941
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12942
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12943
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12944
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12945
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12946
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12947
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12948
 * Initialize Common Transport request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12949
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12950
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12951
fp_ct_init(fc_local_port_t *port, fp_cmd_t *cmd, fctl_ns_req_t *ns_cmd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12952
    uint16_t cmd_code, caddr_t cmd_buf, uint16_t cmd_len,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12953
    uint16_t resp_len, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12954
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12955
	uint32_t	s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12956
	uchar_t		class;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12957
	fc_packet_t	*pkt;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 12958
	fc_ct_header_t	ct;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12959
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12960
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12961
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12962
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12963
	s_id = port->fp_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12964
	class = port->fp_ns_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12965
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12966
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12967
	cmd->cmd_job = job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12968
	cmd->cmd_private = ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12969
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12970
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12971
	ct.ct_rev = CT_REV;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12972
	ct.ct_inid = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12973
	ct.ct_fcstype = FCSTYPE_DIRECTORY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12974
	ct.ct_fcssubtype = FCSSUB_DS_NAME_SERVER;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12975
	ct.ct_options = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12976
	ct.ct_reserved1 = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12977
	ct.ct_cmdrsp = cmd_code;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12978
	ct.ct_aiusize = resp_len >> 2;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12979
	ct.ct_reserved2 = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12980
	ct.ct_reason = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12981
	ct.ct_expln = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12982
	ct.ct_vendor = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12983
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12984
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&ct,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 12985
	    (uint8_t *)pkt->pkt_cmd, sizeof (ct), DDI_DEV_AUTOINCR);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12986
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12987
	pkt->pkt_cmd_fhdr.r_ctl = R_CTL_UNSOL_CONTROL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12988
	pkt->pkt_cmd_fhdr.d_id = 0xFFFFFC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12989
	pkt->pkt_cmd_fhdr.s_id = s_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12990
	pkt->pkt_cmd_fhdr.type = FC_TYPE_FC_SERVICES;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12991
	pkt->pkt_cmd_fhdr.f_ctl = F_CTL_SEQ_INITIATIVE |
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12992
	    F_CTL_FIRST_SEQ | F_CTL_END_SEQ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12993
	pkt->pkt_cmd_fhdr.seq_id = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12994
	pkt->pkt_cmd_fhdr.df_ctl  = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12995
	pkt->pkt_cmd_fhdr.seq_cnt = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12996
	pkt->pkt_cmd_fhdr.ox_id = 0xffff;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12997
	pkt->pkt_cmd_fhdr.rx_id = 0xffff;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12998
	pkt->pkt_cmd_fhdr.ro = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 12999
	pkt->pkt_cmd_fhdr.rsvd = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13000
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13001
	pkt->pkt_comp = fp_ns_intr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13002
	pkt->pkt_ulp_private = (opaque_t)cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13003
	pkt->pkt_timeout = FP_NS_TIMEOUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13004
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13005
	if (cmd_buf) {
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13006
		FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)cmd_buf,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13007
		    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t)),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13008
		    cmd_len, DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13009
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13010
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13011
	cmd->cmd_transport = port->fp_fca_tran->fca_transport;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13012
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13013
	cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13014
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13015
	cmd->cmd_flags = FP_CMD_PLOGI_DONT_CARE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13016
	cmd->cmd_retry_count = fp_retry_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13017
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13018
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13019
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13020
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13021
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13022
 * Name Server request interrupt routine
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13023
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13024
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13025
fp_ns_intr(fc_packet_t *pkt)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13026
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13027
	fp_cmd_t	*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13028
	fc_local_port_t	*port;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13029
	fc_ct_header_t	resp_hdr;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13030
	fc_ct_header_t	cmd_hdr;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13031
	fctl_ns_req_t	*ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13032
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13033
	cmd = pkt->pkt_ulp_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13034
	port = cmd->cmd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13035
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13036
	mutex_enter(&port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13037
	port->fp_out_fpcmds--;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13038
	mutex_exit(&port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13039
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13040
	FC_GET_RSP(port, pkt->pkt_cmd_acc, (uint8_t *)&cmd_hdr,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13041
	    (uint8_t *)pkt->pkt_cmd, sizeof (cmd_hdr), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13042
	ns_cmd = (fctl_ns_req_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13043
	    (((fp_cmd_t *)(pkt->pkt_ulp_private))->cmd_private);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13044
	if (!FP_IS_PKT_ERROR(pkt)) {
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13045
		FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&resp_hdr,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13046
		    (uint8_t *)pkt->pkt_resp, sizeof (resp_hdr),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13047
		    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13048
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13049
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13050
		 * On x86 architectures, make sure the resp_hdr is big endian.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13051
		 * This macro is a NOP on sparc architectures mainly because
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13052
		 * we don't want to end up wasting time since the end result
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13053
		 * is going to be the same.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13054
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13055
		MAKE_BE_32(&resp_hdr);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13056
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13057
		if (ns_cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13058
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13059
			 * Always copy out the response CT_HDR
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13060
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13061
			bcopy(&resp_hdr, &ns_cmd->ns_resp_hdr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13062
			    sizeof (resp_hdr));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13063
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13064
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13065
		if (resp_hdr.ct_cmdrsp == FS_RJT_IU) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13066
			pkt->pkt_state = FC_PKT_FS_RJT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13067
			pkt->pkt_reason = resp_hdr.ct_reason;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13068
			pkt->pkt_expln = resp_hdr.ct_expln;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13069
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13070
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13071
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13072
	if (FP_IS_PKT_ERROR(pkt)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13073
		if (ns_cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13074
			if (ns_cmd->ns_flags & FCTL_NS_VALIDATE_PD) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13075
				ASSERT(ns_cmd->ns_pd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13076
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13077
				/* Mark it OLD if not already done */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13078
				mutex_enter(&ns_cmd->ns_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13079
				ns_cmd->ns_pd->pd_type = PORT_DEVICE_OLD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13080
				mutex_exit(&ns_cmd->ns_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13081
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13082
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13083
			if (ns_cmd->ns_flags & FCTL_NS_ASYNC_REQUEST) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13084
				fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13085
				((fp_cmd_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13086
				    (pkt->pkt_ulp_private))->cmd_private = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13087
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13088
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13089
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13090
13096
33ad53eb7c84 6956269 WARNING:fp(0)::fp_plogi_intr on NL nodes
Rijawanemohammadhusen Nadaf<Riz.Nadaf@Sun.COM>
parents: 11617
diff changeset
 13091
		FP_TRACE(FP_NHEAD2(1, 0), "%x NS failure pkt state=%x "
10107
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 13092
		    "reason=%x, expln=%x, NSCMD=%04X, NSRSP=%04X",
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 13093
		    port->fp_port_id.port_id, pkt->pkt_state,
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 13094
		    pkt->pkt_reason, pkt->pkt_expln,
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 13095
		    cmd_hdr.ct_cmdrsp,  resp_hdr.ct_cmdrsp);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13096
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13097
		(void) fp_common_intr(pkt, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13098
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13099
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13100
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13101
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13102
	if (resp_hdr.ct_cmdrsp != FS_ACC_IU) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13103
		uint32_t	d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13104
		fc_local_port_t	*port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13105
		fp_cmd_t	*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13106
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13107
		d_id = pkt->pkt_cmd_fhdr.d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13108
		cmd = pkt->pkt_ulp_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13109
		port = cmd->cmd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13110
		FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13111
		    "Bogus NS response received for D_ID=%x", d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13112
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13113
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13114
	if (cmd_hdr.ct_cmdrsp == NS_GA_NXT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13115
		fp_gan_handler(pkt, ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13116
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13117
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13118
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13119
	if (cmd_hdr.ct_cmdrsp >= NS_GPN_ID &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13120
	    cmd_hdr.ct_cmdrsp <= NS_GID_PT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13121
		if (ns_cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13122
			if ((ns_cmd->ns_flags & FCTL_NS_NO_DATA_BUF) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13123
				fp_ns_query_handler(pkt, ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13124
				return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13125
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13126
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13127
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13128
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13129
	fp_iodone(pkt->pkt_ulp_private);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13130
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13131
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13132
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13133
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13134
 * Process NS_GAN response
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13135
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13136
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13137
fp_gan_handler(fc_packet_t *pkt, fctl_ns_req_t *ns_cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13138
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13139
	int			my_did;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13140
	fc_portid_t		d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13141
	fp_cmd_t		*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13142
	fc_local_port_t		*port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13143
	fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13144
	ns_req_gan_t		gan_req;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13145
	ns_resp_gan_t		*gan_resp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13146
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13147
	ASSERT(ns_cmd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13148
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13149
	cmd = pkt->pkt_ulp_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13150
	port = cmd->cmd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13151
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13152
	gan_resp = (ns_resp_gan_t *)(pkt->pkt_resp + sizeof (fc_ct_header_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13153
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13154
	FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&d_id,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13155
	    (uint8_t *)&gan_resp->gan_type_id, sizeof (d_id), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13156
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13157
	*(uint32_t *)&d_id = BE_32(*(uint32_t *)&d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13158
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13159
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13160
	 * In this case the priv_lilp_posit field  in reality
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13161
	 * is actually represents the relative position on a private loop.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13162
	 * So zero it while dealing with Port Identifiers.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13163
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13164
	d_id.priv_lilp_posit = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13165
	pd = fctl_get_remote_port_by_did(port, d_id.port_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13166
	if (ns_cmd->ns_gan_sid == d_id.port_id) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13167
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13168
		 * We've come a full circle; time to get out.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13169
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13170
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13171
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13172
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13173
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13174
	if (ns_cmd->ns_gan_sid == FCTL_GAN_START_ID) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13175
		ns_cmd->ns_gan_sid = d_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13176
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13177
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13178
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13179
	my_did = (d_id.port_id == port->fp_port_id.port_id) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13180
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13181
10107
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 13182
	FP_TRACE(FP_NHEAD1(1, 0), "GAN response; port=%p, fp %x pd %x", port,
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 13183
	    port->fp_port_id.port_id, d_id.port_id);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13184
	if (my_did == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13185
		la_wwn_t pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13186
		la_wwn_t nwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13187
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13188
		FP_TRACE(FP_NHEAD1(1, 0), "GAN response details; "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13189
		    "port=%p, d_id=%x, type_id=%x, "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13190
		    "pwwn=%x %x %x %x %x %x %x %x, "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13191
		    "nwwn=%x %x %x %x %x %x %x %x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13192
		    port, d_id.port_id, gan_resp->gan_type_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13193
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13194
		    gan_resp->gan_pwwn.raw_wwn[0],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13195
		    gan_resp->gan_pwwn.raw_wwn[1],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13196
		    gan_resp->gan_pwwn.raw_wwn[2],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13197
		    gan_resp->gan_pwwn.raw_wwn[3],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13198
		    gan_resp->gan_pwwn.raw_wwn[4],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13199
		    gan_resp->gan_pwwn.raw_wwn[5],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13200
		    gan_resp->gan_pwwn.raw_wwn[6],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13201
		    gan_resp->gan_pwwn.raw_wwn[7],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13202
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13203
		    gan_resp->gan_nwwn.raw_wwn[0],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13204
		    gan_resp->gan_nwwn.raw_wwn[1],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13205
		    gan_resp->gan_nwwn.raw_wwn[2],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13206
		    gan_resp->gan_nwwn.raw_wwn[3],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13207
		    gan_resp->gan_nwwn.raw_wwn[4],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13208
		    gan_resp->gan_nwwn.raw_wwn[5],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13209
		    gan_resp->gan_nwwn.raw_wwn[6],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13210
		    gan_resp->gan_nwwn.raw_wwn[7]);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13211
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13212
		FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&nwwn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13213
		    (uint8_t *)&gan_resp->gan_nwwn, sizeof (nwwn),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13214
		    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13215
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13216
		FC_GET_RSP(port, pkt->pkt_resp_acc, (uint8_t *)&pwwn,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13217
		    (uint8_t *)&gan_resp->gan_pwwn, sizeof (pwwn),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13218
		    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13219
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13220
		if (ns_cmd->ns_flags & FCTL_NS_CREATE_DEVICE && pd == NULL) {
10107
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 13221
			FP_TRACE(FP_NHEAD1(1, 0), "fp %x gan_hander create"
f4d183837185 6836302 fully connected cluster nodes may lost storage access upon reboot
duo liu - Sun Microsystems - Beijing China <Duo.Liu@Sun.COM>
parents: 10005
diff changeset
 13222
			    "pd %x", port->fp_port_id.port_id, d_id.port_id);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13223
			pd = fctl_create_remote_port(port, &nwwn, &pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13224
			    d_id.port_id, PD_PLOGI_INITIATOR, KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13225
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13226
		if (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13227
			fp_stuff_device_with_gan(&pkt->pkt_resp_acc,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13228
			    pd, gan_resp);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13229
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13230
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13231
		if (ns_cmd->ns_flags & FCTL_NS_GET_DEV_COUNT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13232
			*((int *)ns_cmd->ns_data_buf) += 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13233
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13234
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13235
		if (ns_cmd->ns_flags & FCTL_NS_FILL_NS_MAP) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13236
			ASSERT((ns_cmd->ns_flags & FCTL_NS_NO_DATA_BUF) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13237
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13238
			if (ns_cmd->ns_flags & FCTL_NS_BUF_IS_USERLAND) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13239
				fc_port_dev_t *userbuf;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13240
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13241
				userbuf = ((fc_port_dev_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13242
				    ns_cmd->ns_data_buf) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13243
				    ns_cmd->ns_gan_index++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13244
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13245
				userbuf->dev_did = d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13246
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13247
				FC_GET_RSP(port, pkt->pkt_resp_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13248
				    (uint8_t *)userbuf->dev_type,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13249
				    (uint8_t *)gan_resp->gan_fc4types,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13250
				    sizeof (userbuf->dev_type),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13251
				    DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13252
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13253
				userbuf->dev_nwwn = nwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13254
				userbuf->dev_pwwn = pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13255
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13256
				if (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13257
					mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13258
					userbuf->dev_state = pd->pd_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13259
					userbuf->dev_hard_addr =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13260
					    pd->pd_hard_addr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13261
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13262
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13263
					userbuf->dev_state =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13264
					    PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13265
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13266
			} else if (ns_cmd->ns_flags &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13267
			    FCTL_NS_BUF_IS_FC_PORTMAP) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13268
				fc_portmap_t *map;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13269
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13270
				map = ((fc_portmap_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13271
				    ns_cmd->ns_data_buf) +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13272
				    ns_cmd->ns_gan_index++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13273
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13274
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13275
				 * First fill it like any new map
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13276
				 * and update the port device info
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13277
				 * below.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13278
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13279
				fp_fillout_new_nsmap(port, &pkt->pkt_resp_acc,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13280
				    map, gan_resp, d_id.port_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13281
				if (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13282
					fctl_copy_portmap(map, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13283
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13284
					map->map_state = PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13285
					map->map_type = PORT_DEVICE_NOCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13286
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13287
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13288
				caddr_t dst_ptr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13289
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13290
				dst_ptr = ns_cmd->ns_data_buf +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13291
				    (NS_GAN_RESP_LEN) * ns_cmd->ns_gan_index++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13292
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13293
				FC_GET_RSP(port, pkt->pkt_resp_acc,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13294
				    (uint8_t *)dst_ptr, (uint8_t *)gan_resp,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13295
				    NS_GAN_RESP_LEN, DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13296
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13297
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13298
			ns_cmd->ns_gan_index++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13299
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13300
		if (ns_cmd->ns_gan_index >= ns_cmd->ns_gan_max) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13301
			fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13302
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13303
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13304
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13305
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13306
	gan_req.pid = d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13307
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13308
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&gan_req,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13309
	    (uint8_t *)(pkt->pkt_cmd + sizeof (fc_ct_header_t)),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13310
	    sizeof (gan_req), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13311
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13312
	if (cmd->cmd_transport(port->fp_fca_handle, pkt) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13313
		pkt->pkt_state = FC_PKT_TRAN_ERROR;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13314
		fp_iodone(cmd);
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13315
	} else {
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13316
		mutex_enter(&port->fp_mutex);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13317
		port->fp_out_fpcmds++;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13318
		mutex_exit(&port->fp_mutex);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13319
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13320
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13321
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13322
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13323
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13324
 * Handle NS Query interrupt
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13325
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13326
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13327
fp_ns_query_handler(fc_packet_t *pkt, fctl_ns_req_t *ns_cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13328
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13329
	fp_cmd_t	*cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13330
	fc_local_port_t	*port;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13331
	caddr_t		src_ptr;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13332
	uint32_t	xfer_len;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13333
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13334
	cmd = pkt->pkt_ulp_private;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13335
	port = cmd->cmd_port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13336
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13337
	xfer_len = ns_cmd->ns_resp_size;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13338
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13339
	FP_TRACE(FP_NHEAD1(1, 0), "NS Query response, cmd_code=%x, xfer_len=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13340
	    ns_cmd->ns_cmd_code, xfer_len);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13341
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13342
	if (ns_cmd->ns_cmd_code == NS_GPN_ID) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13343
		src_ptr = (caddr_t)pkt->pkt_resp + sizeof (fc_ct_header_t);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13344
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13345
		FP_TRACE(FP_NHEAD1(6, 0), "GPN_ID results; %x %x %x %x %x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13346
		    src_ptr[0], src_ptr[1], src_ptr[2], src_ptr[3], src_ptr[4]);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13347
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13348
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13349
	if (xfer_len <= ns_cmd->ns_data_len) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13350
		src_ptr = (caddr_t)pkt->pkt_resp + sizeof (fc_ct_header_t);
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13351
		FC_GET_RSP(port, pkt->pkt_resp_acc,
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13352
		    (uint8_t *)ns_cmd->ns_data_buf,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13353
		    (uint8_t *)src_ptr, xfer_len, DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13354
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13355
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13356
	if (ns_cmd->ns_flags & FCTL_NS_VALIDATE_PD) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13357
		ASSERT(ns_cmd->ns_pd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13358
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13359
		mutex_enter(&ns_cmd->ns_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13360
		if (ns_cmd->ns_pd->pd_type == PORT_DEVICE_OLD) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13361
			ns_cmd->ns_pd->pd_type = PORT_DEVICE_NOCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13362
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13363
		mutex_exit(&ns_cmd->ns_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13364
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13365
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13366
	if (ns_cmd->ns_flags & FCTL_NS_ASYNC_REQUEST) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13367
		fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13368
		((fp_cmd_t *)(pkt->pkt_ulp_private))->cmd_private = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13369
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13370
	fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13371
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13372
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13373
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13374
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13375
 * Handle unsolicited ADISC ELS request
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13376
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13377
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13378
fp_handle_unsol_adisc(fc_local_port_t *port, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13379
    fc_remote_port_t *pd, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13380
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13381
	int		rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13382
	fp_cmd_t	*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13383
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13384
	FP_TRACE(FP_NHEAD1(5, 0), "ADISC; port=%p, D_ID=%x state=%x, pd=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13385
	    port, pd->pd_port_id.port_id, pd->pd_state, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13386
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13387
	if (pd->pd_state != PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13388
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13389
		if (FP_IS_CLASS_1_OR_2(buf->ub_class)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13390
			cmd = fp_alloc_pkt(port, sizeof (la_els_rjt_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13391
			    0, KM_SLEEP, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13392
			if (cmd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13393
				fp_els_rjt_init(port, cmd, buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13394
				    FC_ACTION_NON_RETRYABLE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13395
				    FC_REASON_INVALID_LINK_CTRL, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13396
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13397
				if (fp_sendcmd(port, cmd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13398
				    port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13399
					fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13400
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13401
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13402
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13403
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13404
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13405
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13406
		 * Yes, yes, we don't have a hard address. But we
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13407
		 * we should still respond. Huh ? Visit 21.19.2
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13408
		 * of FC-PH-2 which essentially says that if an
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13409
		 * NL_Port doesn't have a hard address, or if a port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13410
		 * does not have FC-AL capability, it shall report
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13411
		 * zeroes in this field.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13412
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13413
		cmd = fp_alloc_pkt(port, sizeof (la_els_adisc_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13414
		    0, KM_SLEEP, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13415
		if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13416
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13417
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13418
		fp_adisc_acc_init(port, cmd, buf, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13419
		rval = fp_sendcmd(port, cmd, port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13420
		if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13421
			fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13422
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13423
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13424
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13425
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13426
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13427
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13428
 * Initialize ADISC response.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13429
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13430
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13431
fp_adisc_acc_init(fc_local_port_t *port, fp_cmd_t *cmd, fc_unsol_buf_t *buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13432
    job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13433
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13434
	fc_packet_t	*pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13435
	la_els_adisc_t	payload;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13436
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13437
	cmd->cmd_pkt.pkt_tran_flags = buf->ub_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13438
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_OUTBOUND;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13439
	cmd->cmd_flags = FP_CMD_CFLAG_UNDEFINED;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13440
	cmd->cmd_retry_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13441
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13442
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13443
	cmd->cmd_transport = port->fp_fca_tran->fca_els_send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13444
	cmd->cmd_job = job;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13445
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13446
	pkt = &cmd->cmd_pkt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13447
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13448
	fp_unsol_resp_init(pkt, buf, R_CTL_ELS_RSP, FC_TYPE_EXTENDED_LS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13449
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13450
	payload.ls_code.ls_code = LA_ELS_ACC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13451
	payload.ls_code.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13452
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13453
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13454
	payload.nport_id = port->fp_port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13455
	payload.hard_addr = port->fp_hard_addr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13456
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13457
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13458
	payload.port_wwn = port->fp_service_params.nport_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13459
	payload.node_wwn = port->fp_service_params.node_ww_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13460
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13461
	FC_SET_CMD(port, pkt->pkt_cmd_acc, (uint8_t *)&payload,
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13462
	    (uint8_t *)pkt->pkt_cmd, sizeof (payload), DDI_DEV_AUTOINCR);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13463
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13464
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13465
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13466
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13467
 * Hold and Install the requested ULP drivers
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13468
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13469
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13470
fp_load_ulp_modules(dev_info_t *dip, fc_local_port_t *port)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13471
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13472
	int		len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13473
	int		count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13474
	int		data_len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13475
	major_t		ulp_major;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13476
	caddr_t		ulp_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13477
	caddr_t		data_ptr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13478
	caddr_t		data_buf;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13479
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13480
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13481
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13482
	data_buf = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13483
	if (ddi_getlongprop(DDI_DEV_T_ANY, dip,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13484
	    DDI_PROP_DONTPASS, "load-ulp-list",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13485
	    (caddr_t)&data_buf, &data_len) != DDI_PROP_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13486
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13487
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13488
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13489
	len = strlen(data_buf);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13490
	port->fp_ulp_nload = fctl_atoi(data_buf, 10);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13491
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13492
	data_ptr = data_buf + len + 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13493
	for (count = 0; count < port->fp_ulp_nload; count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13494
		len = strlen(data_ptr) + 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13495
		ulp_name = kmem_zalloc(len, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13496
		bcopy(data_ptr, ulp_name, len);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13497
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13498
		ulp_major = ddi_name_to_major(ulp_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13499
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13500
		if (ulp_major != (major_t)-1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13501
			if (modload("drv", ulp_name) < 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13502
				fp_printf(port, CE_NOTE, FP_LOG_ONLY,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13503
				    0, NULL, "failed to load %s",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13504
				    ulp_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13505
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13506
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13507
			fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13508
			    "%s isn't a valid driver", ulp_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13509
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13510
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13511
		kmem_free(ulp_name, len);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13512
		data_ptr += len;	/* Skip to next field */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13513
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13514
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13515
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13516
	 * Free the memory allocated by DDI
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13517
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13518
	if (data_buf != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13519
		kmem_free(data_buf, data_len);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13520
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13521
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13522
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13523
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13524
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13525
 * Perform LOGO operation
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13526
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13527
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13528
fp_logout(fc_local_port_t *port, fc_remote_port_t *pd, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13529
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13530
	int		rval;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13531
	fp_cmd_t	*cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13532
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13533
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13534
	ASSERT(!MUTEX_HELD(&pd->pd_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13535
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13536
	cmd = fp_alloc_pkt(port, sizeof (la_els_logo_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13537
	    FP_PORT_IDENTIFIER_LEN, KM_SLEEP, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13538
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13539
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13540
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13541
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13542
	ASSERT(pd->pd_state == PORT_DEVICE_LOGGED_IN);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13543
	ASSERT(pd->pd_login_count == 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13544
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13545
	cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13546
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13547
	cmd->cmd_flags = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13548
	cmd->cmd_retry_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13549
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13550
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13551
	fp_logo_init(pd, cmd, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13552
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13553
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13554
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13555
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13556
	rval = fp_sendcmd(port, cmd, port->fp_fca_handle);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13557
	if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13558
		fp_iodone(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13559
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13560
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13561
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13562
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13563
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13564
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13565
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13566
 * Perform Port attach callbacks to registered ULPs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13567
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13568
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13569
fp_attach_ulps(fc_local_port_t *port, fc_attach_cmd_t cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13570
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13571
	fp_soft_attach_t *att;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13572
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13573
	att = kmem_zalloc(sizeof (*att), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13574
	att->att_cmd = cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13575
	att->att_port = port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13576
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13577
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13578
	 * We need to remember whether or not fctl_busy_port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13579
	 * succeeded so we know whether or not to call
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13580
	 * fctl_idle_port when the task is complete.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13581
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13582
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13583
	if (fctl_busy_port(port) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13584
		att->att_need_pm_idle = B_TRUE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13585
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13586
		att->att_need_pm_idle = B_FALSE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13587
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13588
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13589
	(void) taskq_dispatch(port->fp_taskq, fp_ulp_port_attach,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13590
	    att, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13591
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13592
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13593
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13594
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13595
 * Forward state change notifications on to interested ULPs.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13596
 * Spawns a call to fctl_ulp_statec_cb() in a taskq thread to do all the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13597
 * real work.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13598
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13599
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13600
fp_ulp_notify(fc_local_port_t *port, uint32_t statec, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13601
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13602
	fc_port_clist_t *clist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13603
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13604
	clist = kmem_zalloc(sizeof (*clist), sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13605
	if (clist == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13606
		return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13607
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13608
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13609
	clist->clist_state = statec;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13610
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13611
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13612
	clist->clist_flags = port->fp_topology;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13613
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13614
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13615
	clist->clist_port = (opaque_t)port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13616
	clist->clist_len = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13617
	clist->clist_size = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13618
	clist->clist_map = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13619
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13620
	(void) taskq_dispatch(port->fp_taskq, fctl_ulp_statec_cb,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13621
	    clist, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13622
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13623
	return (FC_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13624
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13625
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13626
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13627
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13628
 * Get name server map
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13629
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13630
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13631
fp_ns_getmap(fc_local_port_t *port, job_request_t *job, fc_portmap_t **map,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13632
    uint32_t *len, uint32_t sid)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13633
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13634
	int ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13635
	fctl_ns_req_t *ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13636
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13637
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13638
	 * Don't let the allocator do anything for response;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13639
	 * we have have buffer ready to fillout.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13640
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13641
	ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gan_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13642
	    sizeof (ns_resp_gan_t), 0, (FCTL_NS_FILL_NS_MAP |
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13643
	    FCTL_NS_BUF_IS_FC_PORTMAP), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13644
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13645
	ns_cmd->ns_data_len = sizeof (**map) * (*len);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13646
	ns_cmd->ns_data_buf = (caddr_t)*map;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13647
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13648
	ASSERT(ns_cmd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13649
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13650
	ns_cmd->ns_gan_index = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13651
	ns_cmd->ns_gan_sid = sid;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13652
	ns_cmd->ns_cmd_code = NS_GA_NXT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13653
	ns_cmd->ns_gan_max = *len;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13654
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13655
	ret = fp_ns_query(port, ns_cmd, job, 1, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13656
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13657
	if (ns_cmd->ns_gan_index != *len) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13658
		*len = ns_cmd->ns_gan_index;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13659
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13660
	ns_cmd->ns_data_len = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13661
	ns_cmd->ns_data_buf = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13662
	fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13663
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13664
	return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13665
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13666
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13667
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13668
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13669
 * Create a remote port in Fabric topology by using NS services
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13670
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13671
static fc_remote_port_t *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13672
fp_create_remote_port_by_ns(fc_local_port_t *port, uint32_t d_id, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13673
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13674
	int			rval;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13675
	job_request_t		*job;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13676
	fctl_ns_req_t		*ns_cmd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13677
	fc_remote_port_t	*pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13678
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13679
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13680
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13681
	FP_TRACE(FP_NHEAD1(1, 0), "PD creation begin; port=%p, d_id=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13682
	    port, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13683
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13684
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13685
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13686
	ASSERT(FC_IS_TOP_SWITCH(port->fp_topology));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13687
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13688
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13689
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13690
	job = fctl_alloc_job(JOB_NS_CMD, 0, NULL, (opaque_t)port, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13691
	if (job == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13692
		return (NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13693
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13694
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13695
	ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gan_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13696
	    sizeof (ns_resp_gan_t), 0, (FCTL_NS_CREATE_DEVICE |
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13697
	    FCTL_NS_NO_DATA_BUF), sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13698
	if (ns_cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13699
		return (NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13700
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13701
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13702
	job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13703
	ns_cmd->ns_gan_max = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13704
	ns_cmd->ns_cmd_code = NS_GA_NXT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13705
	ns_cmd->ns_gan_sid = FCTL_GAN_START_ID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13706
	((ns_req_gan_t *)(ns_cmd->ns_cmd_buf))->pid.port_id = d_id - 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13707
	((ns_req_gan_t *)(ns_cmd->ns_cmd_buf))->pid.priv_lilp_posit = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13708
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13709
	ASSERT((job->job_flags & JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13710
	rval = fp_ns_query(port, ns_cmd, job, 1, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13711
	fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13712
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13713
	if (rval != FC_SUCCESS || job->job_result != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13714
		fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13715
		return (NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13716
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13717
	fctl_dealloc_job(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13718
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13719
	pd = fctl_get_remote_port_by_did(port, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13720
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13721
	FP_TRACE(FP_NHEAD1(1, 0), "PD creation end; port=%p, d_id=%x, pd=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13722
	    port, d_id, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13723
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13724
	return (pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13725
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13726
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13727
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13728
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13729
 * Check for the permissions on an ioctl command. If it is required to have an
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13730
 * EXCLUSIVE open performed, return a FAILURE to just shut the door on it. If
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13731
 * the ioctl command isn't in one of the list built, shut the door on that too.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13732
 *
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13733
 *	Certain ioctls perform hardware accesses in FCA drivers, and it needs
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13734
 *	to be made sure that users open the port for an exclusive access while
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13735
 *	performing those operations.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13736
 *
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13737
 *	This can prevent a casual user from inflicting damage on the port by
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13738
 *	sending these ioctls from multiple processes/threads (there is no good
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13739
 *	reason why one would need to do that) without actually realizing how
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13740
 *	expensive such commands could turn out to be.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13741
 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13742
 *	It is also important to note that, even with an exclusive access,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13743
 *	multiple threads can share the same file descriptor and fire down
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13744
 *	commands in parallel. To prevent that the driver needs to make sure
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13745
 *	that such commands aren't in progress already. This is taken care of
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13746
 *	in the FP_EXCL_BUSY bit of fp_flag.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13747
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13748
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13749
fp_check_perms(uchar_t open_flag, uint16_t ioctl_cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13750
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13751
	int ret = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13752
	int count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13753
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13754
	for (count = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13755
	    count < sizeof (fp_perm_list) / sizeof (fp_perm_list[0]);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13756
	    count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13757
		if (fp_perm_list[count].fp_ioctl_cmd == ioctl_cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13758
			if (fp_perm_list[count].fp_open_flag & open_flag) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13759
				ret = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13760
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13761
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13762
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13763
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13764
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13765
	return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13766
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13767
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13768
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13769
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13770
 * Bind Port driver's unsolicited, state change callbacks
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13771
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13772
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13773
fp_bind_callbacks(fc_local_port_t *port)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13774
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13775
	fc_fca_bind_info_t	bind_info = {0};
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13776
	fc_fca_port_info_t	*port_info;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13777
	int		rval =	DDI_SUCCESS;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13778
	uint16_t	class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13779
	int		node_namelen, port_namelen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13780
	char		*nname = NULL, *pname = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13781
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13782
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13783
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13784
	if (ddi_prop_lookup_string(DDI_DEV_T_ANY, port->fp_port_dip,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13785
	    DDI_PROP_NOTPROM | DDI_PROP_DONTPASS,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13786
	    "node-name", &nname) != DDI_PROP_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13787
		FP_TRACE(FP_NHEAD1(1, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13788
		    "fp_bind_callback fail to get node-name");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13789
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13790
	if (nname) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13791
		fc_str_to_wwn(nname, &(bind_info.port_nwwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13792
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13793
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13794
	if (ddi_prop_lookup_string(DDI_DEV_T_ANY, port->fp_port_dip,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13795
	    DDI_PROP_NOTPROM | DDI_PROP_DONTPASS,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13796
	    "port-name", &pname) != DDI_PROP_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13797
		FP_TRACE(FP_NHEAD1(1, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13798
		    "fp_bind_callback fail to get port-name");
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13799
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13800
	if (pname) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13801
		fc_str_to_wwn(pname, &(bind_info.port_pwwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13802
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13803
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13804
	if (port->fp_npiv_type == FC_NPIV_PORT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13805
		bind_info.port_npiv = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13806
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13807
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13808
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13809
	 * fca_bind_port returns the FCA driver's handle for the local
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13810
	 * port instance. If the port number isn't supported it returns NULL.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13811
	 * It also sets up callback in the FCA for various
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13812
	 * things like state change, ELS etc..
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13813
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13814
	bind_info.port_statec_cb = fp_statec_cb;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13815
	bind_info.port_unsol_cb = fp_unsol_cb;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13816
	bind_info.port_num = port->fp_port_num;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13817
	bind_info.port_handle = (opaque_t)port;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13818
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13819
	port_info = kmem_zalloc(sizeof (*port_info), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13820
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13821
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13822
	 * Hold the port driver mutex as the callbacks are bound until the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13823
	 * service parameters are properly filled in (in order to be able to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13824
	 * properly respond to unsolicited ELS requests)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13825
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13826
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13827
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13828
	port->fp_fca_handle = port->fp_fca_tran->fca_bind_port(
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13829
	    port->fp_fca_dip, port_info, &bind_info);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13830
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13831
	if (port->fp_fca_handle == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13832
		rval = DDI_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13833
		goto exit;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13834
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13835
10264
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13836
	/*
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13837
	 * Only fcoei will set this bit
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13838
	 */
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13839
	if (port_info->pi_port_state & FC_STATE_FCA_IS_NODMA) {
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13840
		port->fp_soft_state |= FP_SOFT_FCA_IS_NODMA;
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13841
		port_info->pi_port_state &= ~(FC_STATE_FCA_IS_NODMA);
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13842
	}
1196af6129ec PSARC 2008/311 FCoE (Fibre Channel over Ethernet) Initiator
Zhong Wang <Zhong.Wang@Sun.COM>
parents: 10107
diff changeset
 13843
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13844
	port->fp_bind_state = port->fp_state = port_info->pi_port_state;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13845
	port->fp_service_params = port_info->pi_login_params;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13846
	port->fp_hard_addr = port_info->pi_hard_addr;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13847
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13848
	/* Copy from the FCA structure to the FP structure */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13849
	port->fp_hba_port_attrs = port_info->pi_attrs;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13850
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13851
	if (port_info->pi_rnid_params.status == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13852
		port->fp_rnid_init = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13853
		bcopy(&port_info->pi_rnid_params.params,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13854
		    &port->fp_rnid_params,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13855
		    sizeof (port->fp_rnid_params));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13856
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13857
		port->fp_rnid_init = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13858
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13859
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13860
	node_namelen = strlen((char *)&port_info->pi_attrs.sym_node_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13861
	if (node_namelen) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13862
		bcopy(&port_info->pi_attrs.sym_node_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13863
		    &port->fp_sym_node_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13864
		    node_namelen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13865
		port->fp_sym_node_namelen = node_namelen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13866
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13867
	port_namelen = strlen((char *)&port_info->pi_attrs.sym_port_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13868
	if (port_namelen) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13869
		bcopy(&port_info->pi_attrs.sym_port_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13870
		    &port->fp_sym_port_name,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13871
		    port_namelen);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13872
		port->fp_sym_port_namelen = port_namelen;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13873
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13874
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13875
	/* zero out the normally unused fields right away */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13876
	port->fp_service_params.ls_code.mbz = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13877
	port->fp_service_params.ls_code.ls_code = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13878
	bzero(&port->fp_service_params.reserved,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13879
	    sizeof (port->fp_service_params.reserved));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13880
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13881
	class = port_info->pi_login_params.class_1.class_opt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13882
	port->fp_cos |= (class & 0x8000) ? FC_NS_CLASS1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13883
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13884
	class = port_info->pi_login_params.class_2.class_opt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13885
	port->fp_cos |= (class & 0x8000) ? FC_NS_CLASS2 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13886
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13887
	class = port_info->pi_login_params.class_3.class_opt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13888
	port->fp_cos |= (class & 0x8000) ? FC_NS_CLASS3 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13889
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13890
exit:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13891
	if (nname) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13892
		ddi_prop_free(nname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13893
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13894
	if (pname) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13895
		ddi_prop_free(pname);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13896
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13897
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13898
	kmem_free(port_info, sizeof (*port_info));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13899
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13900
	return (rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13901
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13902
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13903
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13904
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13905
 * Retrieve FCA capabilities
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13906
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13907
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13908
fp_retrieve_caps(fc_local_port_t *port)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13909
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13910
	int			rval;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 13911
	int			ub_count;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13912
	fc_fcp_dma_t		fcp_dma;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13913
	fc_reset_action_t	action;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13914
	fc_dma_behavior_t	dma_behavior;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13915
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13916
	ASSERT(!MUTEX_HELD(&port->fp_mutex));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13917
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13918
	rval = port->fp_fca_tran->fca_get_cap(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13919
	    FC_CAP_UNSOL_BUF, &ub_count);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13920
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13921
	switch (rval) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13922
	case FC_CAP_FOUND:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13923
	case FC_CAP_SETTABLE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13924
		switch (ub_count) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13925
		case 0:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13926
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13927
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13928
		case -1:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13929
			ub_count = fp_unsol_buf_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13930
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13931
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13932
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13933
			/* 1/4th of total buffers is my share */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13934
			ub_count =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13935
			    (ub_count / port->fp_fca_tran->fca_numports) >> 2;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13936
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13937
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13938
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13939
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13940
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13941
		ub_count = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13942
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13943
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13944
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13945
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13946
	port->fp_ub_count = ub_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13947
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13948
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13949
	rval = port->fp_fca_tran->fca_get_cap(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13950
	    FC_CAP_POST_RESET_BEHAVIOR, &action);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13951
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13952
	switch (rval) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13953
	case FC_CAP_FOUND:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13954
	case FC_CAP_SETTABLE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13955
		switch (action) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13956
		case FC_RESET_RETURN_NONE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13957
		case FC_RESET_RETURN_ALL:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13958
		case FC_RESET_RETURN_OUTSTANDING:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13959
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13960
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13961
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13962
			action = FC_RESET_RETURN_NONE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13963
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13964
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13965
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13966
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13967
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13968
		action = FC_RESET_RETURN_NONE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13969
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13970
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13971
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13972
	port->fp_reset_action = action;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13973
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13974
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13975
	rval = port->fp_fca_tran->fca_get_cap(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13976
	    FC_CAP_NOSTREAM_ON_UNALIGN_BUF, &dma_behavior);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13977
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13978
	switch (rval) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13979
	case FC_CAP_FOUND:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13980
		switch (dma_behavior) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13981
		case FC_ALLOW_STREAMING:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13982
			/* FALLTHROUGH */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13983
		case FC_NO_STREAMING:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13984
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13985
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13986
		default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13987
			/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13988
			 * If capability was found and the value
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13989
			 * was incorrect assume the worst
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13990
			 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13991
			dma_behavior = FC_NO_STREAMING;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13992
			break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13993
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13994
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13995
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13996
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13997
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13998
		 * If capability was not defined - allow streaming; existing
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 13999
		 * FCAs should not be affected.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14000
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14001
		dma_behavior = FC_ALLOW_STREAMING;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14002
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14003
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14004
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14005
	port->fp_dma_behavior = dma_behavior;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14006
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14007
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14008
	rval = port->fp_fca_tran->fca_get_cap(port->fp_fca_handle,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14009
	    FC_CAP_FCP_DMA, &fcp_dma);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14010
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14011
	if (rval != FC_CAP_FOUND || (fcp_dma != FC_NO_DVMA_SPACE &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14012
	    fcp_dma != FC_DVMA_SPACE)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14013
		fcp_dma = FC_DVMA_SPACE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14014
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14015
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14016
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14017
	port->fp_fcp_dma = fcp_dma;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14018
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14019
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14020
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14021
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14022
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14023
 * Handle Domain, Area changes in the Fabric.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14024
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14025
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14026
fp_validate_area_domain(fc_local_port_t *port, uint32_t id, uint32_t mask,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14027
    job_request_t *job, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14028
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14029
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14030
	uint32_t		dcnt;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14031
#endif
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14032
	int			rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14033
	int			send;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14034
	int			index;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14035
	int			listindex;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14036
	int			login;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14037
	int			job_flags;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14038
	char			ww_name[17];
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14039
	uint32_t		d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14040
	uint32_t		count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14041
	fctl_ns_req_t		*ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14042
	fc_portmap_t		*list;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14043
	fc_orphan_t		*orp;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14044
	fc_orphan_t		*norp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14045
	fc_orphan_t		*prev;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14046
	fc_remote_port_t	*pd;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14047
	fc_remote_port_t	*npd;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14048
	struct pwwn_hash	*head;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14049
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14050
	ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14051
	    sizeof (ns_resp_gid_pn_t), sizeof (ns_resp_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14052
	    0, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14053
	if (ns_cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14054
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14055
		if (--port->fp_rscn_count == FC_INVALID_RSCN_COUNT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14056
			--port->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14057
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14058
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14059
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14060
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14061
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14062
	ns_cmd->ns_cmd_code = NS_GID_PN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14063
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14064
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14065
	 * We need to get a new count of devices from the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14066
	 * name server, which will also create any new devices
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14067
	 * as needed.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14068
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14069
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14070
	(void) fp_ns_get_devcount(port, job, 1, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14071
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14072
	FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14073
	    "fp_validate_area_domain: get_devcount found %d devices",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14074
	    port->fp_total_devices);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14075
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14076
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14077
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14078
	for (count = index = 0; index < pwwn_table_size; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14079
		head = &port->fp_pwwn_table[index];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14080
		pd = head->pwwn_head;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14081
		while (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14082
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14083
			if (pd->pd_flags != PD_ELS_IN_PROGRESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14084
				if ((pd->pd_port_id.port_id & mask) == id &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14085
				    pd->pd_recepient == PD_PLOGI_INITIATOR) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14086
					count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14087
					pd->pd_type = PORT_DEVICE_OLD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14088
					pd->pd_flags = PD_ELS_MARK;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14089
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14090
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14091
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14092
			pd = pd->pd_wwn_hnext;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14093
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14094
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14095
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14096
#ifdef	DEBUG
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14097
	dcnt = count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14098
#endif /* DEBUG */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14099
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14100
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14101
	 * Since port->fp_orphan_count is declared an 'int' it is
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14102
	 * theoretically possible that the count could go negative.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14103
	 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14104
	 * This would be bad and if that happens we really do want
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14105
	 * to know.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14106
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14107
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14108
	ASSERT(port->fp_orphan_count >= 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14109
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14110
	count += port->fp_orphan_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14111
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14112
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14113
	 * We add the port->fp_total_devices value to the count
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14114
	 * in the case where our port is newly attached. This is
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14115
	 * because we haven't done any discovery and we don't have
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14116
	 * any orphans in the port's orphan list. If we do not do
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14117
	 * this addition to count then we won't alloc enough kmem
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14118
	 * to do discovery with.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14119
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14120
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14121
	if (count == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14122
		count += port->fp_total_devices;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14123
		FP_TRACE(FP_NHEAD1(3, 0), "fp_validate_area_domain: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14124
		    "0x%x orphans found, using 0x%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14125
		    port->fp_orphan_count, count);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14126
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14127
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14128
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14129
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14130
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14131
	 * Allocate the change list
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14132
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14133
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14134
	list = kmem_zalloc(sizeof (fc_portmap_t) * count, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14135
	if (list == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14136
		fp_printf(port, CE_NOTE, FP_LOG_ONLY, 0, NULL,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14137
		    " Not enough memory to service RSCNs"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14138
		    " for %d ports, continuing...", count);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14139
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14140
		fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14141
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14142
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14143
		if (--port->fp_rscn_count == FC_INVALID_RSCN_COUNT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14144
			--port->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14145
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14146
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14147
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14148
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14149
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14150
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14151
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14152
	 * Attempt to validate or invalidate the devices that were
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14153
	 * already in the pwwn hash table.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14154
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14155
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14156
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14157
	for (listindex = 0, index = 0; index < pwwn_table_size; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14158
		head = &port->fp_pwwn_table[index];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14159
		npd = head->pwwn_head;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14160
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14161
		while ((pd = npd) != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14162
			npd = pd->pd_wwn_hnext;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14163
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14164
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14165
			if ((pd->pd_port_id.port_id & mask) == id &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14166
			    pd->pd_flags == PD_ELS_MARK) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14167
				la_wwn_t *pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14168
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14169
				job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14170
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14171
				((ns_req_gid_pn_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14172
				    (ns_cmd->ns_cmd_buf))->pwwn =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14173
				    pd->pd_port_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14174
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14175
				pwwn = &pd->pd_port_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14176
				d_id = pd->pd_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14177
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14178
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14179
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14180
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14181
				rval = fp_ns_query(port, ns_cmd, job, 1,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14182
				    sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14183
				if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14184
					fc_wwn_to_str(pwwn, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14185
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14186
					FP_TRACE(FP_NHEAD1(3, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14187
					    "AREA RSCN: PD disappeared; "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14188
					    "d_id=%x, PWWN=%s", d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14189
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14190
					FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14191
					    "N_x Port with D_ID=%x,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14192
					    " PWWN=%s disappeared from fabric",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14193
					    d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14194
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14195
					fp_fillout_old_map(list + listindex++,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14196
					    pd, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14197
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14198
					fctl_copy_portmap(list + listindex++,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14199
					    pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14200
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14201
					mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14202
					pd->pd_flags = PD_ELS_IN_PROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14203
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14204
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14205
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14206
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14207
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14208
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14209
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14210
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14211
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14212
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14213
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14214
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14215
	ASSERT(listindex == dcnt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14216
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14217
	job->job_counter = listindex;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14218
	job_flags = job->job_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14219
	job->job_flags |= JOB_TYPE_FP_ASYNC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14220
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14221
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14222
	 * Login (if we were the initiator) or validate devices in the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14223
	 * port map.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14224
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14225
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14226
	for (index = 0; index < listindex; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14227
		pd = list[index].map_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14228
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14229
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14230
		ASSERT((pd->pd_port_id.port_id & mask) == id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14231
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14232
		if (pd->pd_flags != PD_ELS_IN_PROGRESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14233
			ASSERT(pd->pd_type == PORT_DEVICE_OLD);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14234
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14235
			fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14236
			continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14237
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14238
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14239
		login = (pd->pd_state == PORT_DEVICE_LOGGED_IN) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14240
		send = (pd->pd_recepient == PD_PLOGI_INITIATOR) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14241
		d_id = pd->pd_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14242
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14243
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14244
		if ((d_id & mask) == id && send) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14245
			if (login) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14246
				FP_TRACE(FP_NHEAD1(6, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14247
				    "RSCN and PLOGI request;"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14248
				    " pd=%p, job=%p d_id=%x, index=%d", pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14249
				    job, d_id, index);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14250
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14251
				rval = fp_port_login(port, d_id, job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14252
				    FP_CMD_PLOGI_RETAIN, sleep, pd, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14253
				if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14254
					mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14255
					pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14256
					mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14257
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14258
					job->job_result = rval;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14259
					fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14260
				}
10339
c22e58c7f4e3 6847051 Change the log level of FP_TRACE for messages "PLOGI succeeded:no skip(1) for..."
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 10264
diff changeset
 14261
				FP_TRACE(FP_NHEAD1(1, 0),
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14262
				    "PLOGI succeeded:no skip(1) for "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14263
				    "D_ID %x", d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14264
				list[index].map_flags |=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14265
				    PORT_DEVICE_NO_SKIP_DEVICE_DISCOVERY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14266
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14267
				FP_TRACE(FP_NHEAD1(6, 0), "RSCN and NS request;"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14268
				    " pd=%p, job=%p d_id=%x, index=%d", pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14269
				    job, d_id, index);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14270
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14271
				rval = fp_ns_validate_device(port, pd, job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14272
				    0, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14273
				if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14274
					fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14275
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14276
				mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14277
				pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14278
				mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14279
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14280
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14281
			FP_TRACE(FP_NHEAD1(6, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14282
			    "RSCN and NO request sent; pd=%p,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14283
			    " d_id=%x, index=%d", pd, d_id, index);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14284
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14285
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14286
			pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14287
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14288
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14289
			fp_jobdone(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14290
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14291
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14292
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14293
	if (listindex) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14294
		fctl_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14295
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14296
	job->job_flags = job_flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14297
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14298
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14299
	 * Orphan list validation.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14300
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14301
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14302
	for (prev = NULL, orp = port->fp_orphan_list; port->fp_orphan_count &&
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14303
	    orp != NULL; orp = norp) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14304
		norp = orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14305
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14306
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14307
		job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14308
		job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14309
		ASSERT((job->job_flags & JOB_TYPE_FP_ASYNC) == 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14310
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14311
		((ns_req_gid_pn_t *)ns_cmd->ns_cmd_buf)->pwwn = orp->orp_pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14312
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14313
		((ns_resp_gid_pn_t *)ns_cmd->ns_data_buf)->pid.port_id = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14314
		((ns_resp_gid_pn_t *)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14315
		    ns_cmd->ns_data_buf)->pid.priv_lilp_posit = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14316
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14317
		rval = fp_ns_query(port, ns_cmd, job, 1, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14318
		if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14319
			d_id = BE_32(*((uint32_t *)ns_cmd->ns_data_buf));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14320
			pd = fp_create_remote_port_by_ns(port, d_id, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14321
			if (pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14322
				fc_wwn_to_str(&orp->orp_pwwn, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14323
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14324
				FP_TRACE(FP_NHEAD1(6, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14325
				    "RSCN and ORPHAN list "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14326
				    "success; d_id=%x, PWWN=%s", d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14327
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14328
				FP_TRACE(FP_NHEAD2(6, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14329
				    "N_x Port with D_ID=%x, PWWN=%s reappeared"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14330
				    " in fabric", d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14331
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14332
				mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14333
				if (prev) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14334
					prev->orp_next = orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14335
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14336
					ASSERT(orp == port->fp_orphan_list);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14337
					port->fp_orphan_list = orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14338
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14339
				port->fp_orphan_count--;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14340
				mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14341
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14342
				kmem_free(orp, sizeof (*orp));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14343
				fctl_copy_portmap(list + listindex++, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14344
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14345
				prev = orp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14346
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14347
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14348
			prev = orp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14349
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14350
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14351
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14352
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14353
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14354
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14355
	 * One more pass through the list to delist old devices from
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14356
	 * the d_id and pwwn tables and possibly add to the orphan list.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14357
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14358
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14359
	for (index = 0; index < listindex; index++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14360
		pd = list[index].map_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14361
		ASSERT(pd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14362
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14363
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14364
		 * Update PLOGI results; For NS validation
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14365
		 * of orphan list, it is redundant
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14366
		 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14367
		 * Take care to preserve PORT_DEVICE_NO_SKIP_DEVICE_DISCOVERY if
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14368
		 * appropriate as fctl_copy_portmap() will clear map_flags.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14369
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14370
		if (list[index].map_flags &
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14371
		    PORT_DEVICE_NO_SKIP_DEVICE_DISCOVERY) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14372
			fctl_copy_portmap(list + index, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14373
			list[index].map_flags |=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14374
			    PORT_DEVICE_NO_SKIP_DEVICE_DISCOVERY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14375
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14376
			fctl_copy_portmap(list + index, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14377
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14378
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14379
		FP_TRACE(FP_NHEAD1(6, 0), "RSCN with Area DOMAIN "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14380
		    "results; pd=%p, d_id=%x pwwn=%x %x %x %x %x %x %x %x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14381
		    pd, pd->pd_port_id.port_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14382
		    pd->pd_port_name.raw_wwn[0],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14383
		    pd->pd_port_name.raw_wwn[1],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14384
		    pd->pd_port_name.raw_wwn[2],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14385
		    pd->pd_port_name.raw_wwn[3],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14386
		    pd->pd_port_name.raw_wwn[4],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14387
		    pd->pd_port_name.raw_wwn[5],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14388
		    pd->pd_port_name.raw_wwn[6],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14389
		    pd->pd_port_name.raw_wwn[7]);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14390
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14391
		FP_TRACE(FP_NHEAD1(6, 0), "RSCN with Area DOMAIN "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14392
		    "results continued, pd=%p type=%x, flags=%x, state=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14393
		    pd, pd->pd_type, pd->pd_flags, pd->pd_state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14394
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14395
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14396
		if (pd->pd_type == PORT_DEVICE_OLD) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14397
			int initiator;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14398
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14399
			pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14400
			initiator = (pd->pd_recepient ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14401
			    PD_PLOGI_INITIATOR) ? 1 : 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14402
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14403
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14404
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14405
			mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14406
			mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14407
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14408
			pd->pd_state = PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14409
			fctl_delist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14410
			fctl_delist_pwwn_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14411
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14412
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14413
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14414
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14415
			if (initiator) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14416
				(void) fctl_add_orphan(port, pd, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14417
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14418
			list[index].map_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14419
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14420
			ASSERT(pd->pd_flags == PD_IDLE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14421
			if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14422
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14423
				 * Reset LOGO tolerance to zero
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14424
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14425
				fctl_tc_reset(&pd->pd_logo_tc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14426
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14427
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14428
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14429
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14430
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14431
	if (ns_cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14432
		fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14433
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14434
	if (listindex) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14435
		(void) fp_ulp_devc_cb(port, list, listindex, count,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14436
		    sleep, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14437
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14438
		kmem_free(list, sizeof (*list) * count);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14439
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14440
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14441
		if (--port->fp_rscn_count == FC_INVALID_RSCN_COUNT) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14442
			--port->fp_rscn_count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14443
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14444
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14445
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14446
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14447
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14448
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14449
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14450
 * Work hard to make sense out of an RSCN page.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14451
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14452
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14453
fp_validate_rscn_page(fc_local_port_t *port, fc_affected_id_t *page,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14454
    job_request_t *job, fctl_ns_req_t *ns_cmd, fc_portmap_t *listptr,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14455
    int *listindex, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14456
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14457
	int			rval;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14458
	char			ww_name[17];
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14459
	la_wwn_t		*pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14460
	fc_remote_port_t	*pwwn_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14461
	fc_remote_port_t	*did_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14462
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14463
	did_pd = fctl_get_remote_port_by_did(port, page->aff_d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14464
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14465
	FP_TRACE(FP_NHEAD1(6, 0), "RSCN with D_ID page; "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14466
	    "port=%p, d_id=%x, pd=%p, rscn_count:0x%x", port, page->aff_d_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14467
	    did_pd, (uint32_t)(uintptr_t)job->job_cb_arg);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14468
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14469
	if (did_pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14470
		mutex_enter(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14471
		if (did_pd->pd_flags != PD_IDLE) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14472
			mutex_exit(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14473
			FP_TRACE(FP_NHEAD1(6, 0), "RSCN with D_ID page: "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14474
			    "PD is BUSY; port=%p, d_id=%x, pd=%p",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14475
			    port, page->aff_d_id, did_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14476
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14477
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14478
		did_pd->pd_flags = PD_ELS_IN_PROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14479
		mutex_exit(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14480
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14481
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14482
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14483
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14484
	pwwn = &((ns_resp_gpn_id_t *)ns_cmd->ns_data_buf)->pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14485
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14486
	((ns_req_gpn_id_t *)ns_cmd->ns_cmd_buf)->pid.port_id = page->aff_d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14487
	((ns_req_gpn_id_t *)ns_cmd->ns_cmd_buf)->pid.priv_lilp_posit = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14488
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14489
	bzero(ns_cmd->ns_data_buf, sizeof (la_wwn_t));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14490
	rval = fp_ns_query(port, ns_cmd, job, 1, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14491
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14492
	FP_TRACE(FP_NHEAD1(1, 0), "NS Query Response for D_ID page; rev=%x,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14493
	    " in_id=%x, cmdrsp=%x, reason=%x, expln=%x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14494
	    ns_cmd->ns_resp_hdr.ct_rev, ns_cmd->ns_resp_hdr.ct_inid,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14495
	    ns_cmd->ns_resp_hdr.ct_cmdrsp, ns_cmd->ns_resp_hdr.ct_reason,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14496
	    ns_cmd->ns_resp_hdr.ct_expln);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14497
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14498
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14499
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14500
	if (rval != FC_SUCCESS || fctl_is_wwn_zero(pwwn) == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14501
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14502
		 * What this means is that the D_ID
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14503
		 * disappeared from the Fabric.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14504
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14505
		if (did_pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14506
			FP_TRACE(FP_NHEAD1(1, 0), "RSCN with D_ID page;"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14507
			    " NULL PD disappeared, rval=%x", rval);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14508
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14509
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14510
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14511
		fc_wwn_to_str(&did_pd->pd_port_name, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14512
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14513
		(listptr + *listindex)->map_rscn_info.ulp_rscn_count =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14514
		    (uint32_t)(uintptr_t)job->job_cb_arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14515
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14516
		fp_fillout_old_map(listptr + (*listindex)++, did_pd, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14517
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14518
		FP_TRACE(FP_NHEAD1(3, 0), "RSCN: PD disappeared; "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14519
		    "d_id=%x, PWWN=%s", page->aff_d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14520
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14521
		FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14522
		    "GPN_ID for D_ID=%x failed", page->aff_d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14523
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14524
		FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14525
		    "N_x Port with D_ID=%x, PWWN=%s disappeared from"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14526
		    " fabric", page->aff_d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14527
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14528
		mutex_enter(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14529
		did_pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14530
		mutex_exit(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14531
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14532
		FP_TRACE(FP_NHEAD1(3, 0), "RSCN with D_ID (%x) page; "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14533
		    "PD disappeared, pd=%p", page->aff_d_id, did_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14534
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14535
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14536
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14537
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14538
	pwwn_pd = fctl_get_remote_port_by_pwwn(port, pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14539
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14540
	if (did_pd != NULL && pwwn_pd != NULL && did_pd == pwwn_pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14541
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14542
		 * There is no change. Do PLOGI again and add it to
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14543
		 * ULP portmap baggage and return. Note: When RSCNs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14544
		 * arrive with per page states, the need for PLOGI
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14545
		 * can be determined correctly.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14546
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14547
		mutex_enter(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14548
		pwwn_pd->pd_type = PORT_DEVICE_NOCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14549
		mutex_exit(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14550
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14551
		(listptr + *listindex)->map_rscn_info.ulp_rscn_count =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14552
		    (uint32_t)(uintptr_t)job->job_cb_arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14553
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14554
		fctl_copy_portmap(listptr + (*listindex)++, pwwn_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14555
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14556
		mutex_enter(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14557
		if ((pwwn_pd->pd_state == PORT_DEVICE_LOGGED_IN) ||
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14558
		    (pwwn_pd->pd_aux_flags & PD_LOGGED_OUT)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14559
			fc_wwn_to_str(&pwwn_pd->pd_port_name, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14560
			mutex_exit(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14561
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14562
			rval = fp_port_login(port, page->aff_d_id, job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14563
			    FP_CMD_PLOGI_RETAIN, sleep, pwwn_pd, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14564
			if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14565
				fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14566
				rval = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14567
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14568
				/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14569
				 * Reset LOGO tolerance to zero
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14570
				 * Also we are the PLOGI initiator now.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14571
				 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14572
				mutex_enter(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14573
				fctl_tc_reset(&pwwn_pd->pd_logo_tc);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14574
				pwwn_pd->pd_recepient = PD_PLOGI_INITIATOR;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14575
				mutex_exit(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14576
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14577
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14578
			if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14579
				struct fc_portmap *map =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14580
				    listptr + *listindex - 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14581
10339
c22e58c7f4e3 6847051 Change the log level of FP_TRACE for messages "PLOGI succeeded:no skip(1) for..."
Raghuram Prahlada <Raghuram.Prahlada@Sun.COM>
parents: 10264
diff changeset
 14582
				FP_TRACE(FP_NHEAD1(1, 0),
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14583
				    "PLOGI succeeded: no skip(2)"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14584
				    " for D_ID %x", page->aff_d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14585
				map->map_flags |=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14586
				    PORT_DEVICE_NO_SKIP_DEVICE_DISCOVERY;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14587
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14588
				FP_TRACE(FP_NHEAD2(9, rval),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14589
				    "PLOGI to D_ID=%x failed", page->aff_d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14590
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14591
				FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14592
				    "N_x Port with D_ID=%x, PWWN=%s"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14593
				    " disappeared from fabric",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14594
				    page->aff_d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14595
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14596
				fp_fillout_old_map(listptr +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14597
				    *listindex - 1, pwwn_pd, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14598
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14599
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14600
			mutex_exit(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14601
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14602
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14603
		mutex_enter(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14604
		did_pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14605
		mutex_exit(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14606
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14607
		FP_TRACE(FP_NHEAD1(6, 0), "RSCN with D_ID (0x%x) page; "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14608
		    "Case ONE, rval=%x, result=%x pd=%p", page->aff_d_id, rval,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14609
		    job->job_result, pwwn_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14610
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14611
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14612
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14613
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14614
	if (did_pd == NULL && pwwn_pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14615
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14616
		fc_orphan_t	*orp  = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14617
		fc_orphan_t	*norp = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14618
		fc_orphan_t	*prev = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14619
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14620
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14621
		 * Hunt down the orphan list before giving up.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14622
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14623
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14624
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14625
		if (port->fp_orphan_count) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14626
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14627
			for (orp = port->fp_orphan_list; orp; orp = norp) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14628
				norp = orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14629
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14630
				if (fctl_wwn_cmp(&orp->orp_pwwn, pwwn) != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14631
					prev = orp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14632
					continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14633
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14634
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14635
				if (prev) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14636
					prev->orp_next = orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14637
				} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14638
					ASSERT(orp ==
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14639
					    port->fp_orphan_list);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14640
					port->fp_orphan_list =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14641
					    orp->orp_next;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14642
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14643
				port->fp_orphan_count--;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14644
				break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14645
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14646
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14647
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14648
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14649
		pwwn_pd = fp_create_remote_port_by_ns(port,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14650
		    page->aff_d_id, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14651
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14652
		if (pwwn_pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14653
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14654
			if (orp) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14655
				fc_wwn_to_str(&orp->orp_pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14656
				    ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14657
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14658
				FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14659
				    "N_x Port with D_ID=%x,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14660
				    " PWWN=%s reappeared in fabric",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14661
				    page->aff_d_id, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14662
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14663
				kmem_free(orp, sizeof (*orp));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14664
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14665
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14666
			(listptr + *listindex)->
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14667
			    map_rscn_info.ulp_rscn_count =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14668
			    (uint32_t)(uintptr_t)job->job_cb_arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14669
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14670
			fctl_copy_portmap(listptr +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14671
			    (*listindex)++, pwwn_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14672
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14673
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14674
		FP_TRACE(FP_NHEAD1(6, 0), "RSCN with D_ID (0x%x) page; "
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14675
		    "Case TWO", page->aff_d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14676
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14677
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14678
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14679
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14680
	if (pwwn_pd != NULL && did_pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14681
		uint32_t old_d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14682
		uint32_t d_id = page->aff_d_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14683
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14684
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14685
		 * What this means is there is a new D_ID for this
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14686
		 * Port WWN. Take out the port device off D_ID
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14687
		 * list and put it back with a new D_ID. Perform
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14688
		 * PLOGI if already logged in.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14689
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14690
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14691
		mutex_enter(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14692
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14693
		old_d_id = pwwn_pd->pd_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14694
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14695
		fctl_delist_did_table(port, pwwn_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14696
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14697
		(listptr + *listindex)->map_rscn_info.ulp_rscn_count =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14698
		    (uint32_t)(uintptr_t)job->job_cb_arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14699
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14700
		fp_fillout_changed_map(listptr + (*listindex)++, pwwn_pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14701
		    &d_id, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14702
		fctl_enlist_did_table(port, pwwn_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14703
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14704
		FP_TRACE(FP_NHEAD1(6, 0), "RSCN with D_ID page;"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14705
		    " Case THREE, pd=%p,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14706
		    " state=%x", pwwn_pd, pwwn_pd->pd_state);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14707
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14708
		if ((pwwn_pd->pd_state == PORT_DEVICE_LOGGED_IN) ||
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14709
		    (pwwn_pd->pd_aux_flags & PD_LOGGED_OUT)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14710
			fc_wwn_to_str(&pwwn_pd->pd_port_name, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14711
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14712
			mutex_exit(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14713
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14714
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14715
			FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14716
			    "N_x Port with D_ID=%x, PWWN=%s has a new"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14717
			    " D_ID=%x now", old_d_id, ww_name, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14718
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14719
			rval = fp_port_login(port, page->aff_d_id, job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14720
			    FP_CMD_PLOGI_RETAIN, sleep, pwwn_pd, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14721
			if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14722
				fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14723
				rval = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14724
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14725
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14726
			if (rval != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14727
				fp_fillout_old_map(listptr +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14728
				    *listindex - 1, pwwn_pd, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14729
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14730
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14731
			mutex_exit(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14732
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14733
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14734
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14735
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14736
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14737
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14738
	if (pwwn_pd == NULL && did_pd != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14739
		fc_portmap_t	*ptr;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14740
		uint32_t	len = 1;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14741
		char		old_ww_name[17];
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14742
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14743
		mutex_enter(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14744
		fc_wwn_to_str(&did_pd->pd_port_name, old_ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14745
		mutex_exit(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14746
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14747
		fc_wwn_to_str(pwwn, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14748
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14749
		(listptr + *listindex)->map_rscn_info.ulp_rscn_count =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14750
		    (uint32_t)(uintptr_t)job->job_cb_arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14751
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14752
		/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14753
		 * What this means is that there is a new Port WWN for
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14754
		 * this D_ID; Mark the Port device as old and provide
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14755
		 * the new PWWN and D_ID combination as new.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14756
		 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14757
		fp_fillout_old_map(listptr + (*listindex)++, did_pd, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14758
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14759
		FP_TRACE(FP_NHEAD2(9, 0),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14760
		    "N_x Port with D_ID=%x, PWWN=%s has a new PWWN=%s now",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14761
		    page->aff_d_id, old_ww_name, ww_name);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14762
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14763
		(listptr + *listindex)->map_rscn_info.ulp_rscn_count =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14764
		    (uint32_t)(uintptr_t)job->job_cb_arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14765
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14766
		ptr = listptr + (*listindex)++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14767
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14768
		job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14769
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14770
		if (fp_ns_getmap(port, job, &ptr, &len,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14771
		    page->aff_d_id - 1) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14772
			(*listindex)--;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14773
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14774
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14775
		mutex_enter(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14776
		did_pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14777
		mutex_exit(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14778
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14779
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14780
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14781
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14782
	/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14783
	 * A weird case of Port WWN and D_ID existence but not matching up
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14784
	 * between them. Trust your instincts - Take the port device handle
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14785
	 * off Port WWN list, fix it with new Port WWN and put it back, In
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14786
	 * the mean time mark the port device corresponding to the old port
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14787
	 * WWN as OLD.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14788
	 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14789
	FP_TRACE(FP_NHEAD1(6, 0), "RSCN with D_ID page; Case WEIRD, pwwn_pd=%p,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14790
	    " did_pd=%p", pwwn_pd, did_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14791
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14792
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14793
	mutex_enter(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14794
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14795
	pwwn_pd->pd_type = PORT_DEVICE_OLD;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14796
	pwwn_pd->pd_state = PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14797
	fctl_delist_did_table(port, pwwn_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14798
	fctl_delist_pwwn_table(port, pwwn_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14799
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14800
	FP_TRACE(FP_NHEAD1(6, 0), "RSCN with D_ID page; case WEIRD continued,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14801
	    " pwwn-d_id=%x pwwn-wwn=%x %x %x %x %x %x %x %x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14802
	    pwwn_pd->pd_port_id.port_id,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14803
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14804
	    pwwn_pd->pd_port_name.raw_wwn[0],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14805
	    pwwn_pd->pd_port_name.raw_wwn[1],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14806
	    pwwn_pd->pd_port_name.raw_wwn[2],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14807
	    pwwn_pd->pd_port_name.raw_wwn[3],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14808
	    pwwn_pd->pd_port_name.raw_wwn[4],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14809
	    pwwn_pd->pd_port_name.raw_wwn[5],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14810
	    pwwn_pd->pd_port_name.raw_wwn[6],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14811
	    pwwn_pd->pd_port_name.raw_wwn[7]);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14812
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14813
	mutex_exit(&pwwn_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14814
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14815
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14816
	(listptr + *listindex)->map_rscn_info.ulp_rscn_count =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14817
	    (uint32_t)(uintptr_t)job->job_cb_arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14818
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14819
	fctl_copy_portmap(listptr + (*listindex)++, pwwn_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14820
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14821
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14822
	mutex_enter(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14823
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14824
	fctl_delist_pwwn_table(port, did_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14825
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14826
	(listptr + *listindex)->map_rscn_info.ulp_rscn_count =
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14827
	    (uint32_t)(uintptr_t)job->job_cb_arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14828
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14829
	fp_fillout_changed_map(listptr + (*listindex)++, did_pd, NULL, pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14830
	fctl_enlist_pwwn_table(port, did_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14831
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14832
	FP_TRACE(FP_NHEAD1(6, 0), "RSCN with D_ID page; case WEIRD continued,"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14833
	    " d_id=%x, state=%x, did-wwn=%x %x %x %x %x %x %x %x",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14834
	    did_pd->pd_port_id.port_id, did_pd->pd_state,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14835
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14836
	    did_pd->pd_port_name.raw_wwn[0],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14837
	    did_pd->pd_port_name.raw_wwn[1],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14838
	    did_pd->pd_port_name.raw_wwn[2],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14839
	    did_pd->pd_port_name.raw_wwn[3],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14840
	    did_pd->pd_port_name.raw_wwn[4],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14841
	    did_pd->pd_port_name.raw_wwn[5],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14842
	    did_pd->pd_port_name.raw_wwn[6],
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14843
	    did_pd->pd_port_name.raw_wwn[7]);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14844
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14845
	if ((did_pd->pd_state == PORT_DEVICE_LOGGED_IN) ||
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14846
	    (did_pd->pd_aux_flags & PD_LOGGED_OUT)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14847
		mutex_exit(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14848
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14849
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14850
		rval = fp_port_login(port, page->aff_d_id, job,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14851
		    FP_CMD_PLOGI_RETAIN, sleep, did_pd, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14852
		if (rval == FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14853
			fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14854
			if (job->job_result != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14855
				fp_fillout_old_map(listptr +
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14856
				    *listindex - 1, did_pd, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14857
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14858
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14859
			fp_fillout_old_map(listptr + *listindex - 1, did_pd, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14860
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14861
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14862
		mutex_exit(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14863
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14864
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14865
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14866
	mutex_enter(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14867
	did_pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14868
	mutex_exit(&did_pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14869
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14870
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14871
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14872
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14873
 * Check with NS for the presence of this port WWN
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14874
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14875
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14876
fp_ns_validate_device(fc_local_port_t *port, fc_remote_port_t *pd,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14877
    job_request_t *job, int polled, int sleep)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14878
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14879
	la_wwn_t	pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14880
	uint32_t	flags;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14881
	fctl_ns_req_t	*ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14882
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14883
	flags = FCTL_NS_VALIDATE_PD | ((polled) ? 0: FCTL_NS_ASYNC_REQUEST);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14884
	ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14885
	    sizeof (ns_resp_gid_pn_t), sizeof (ns_resp_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14886
	    flags, sleep);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14887
	if (ns_cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14888
		return (FC_NOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14889
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14890
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14891
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14892
	pwwn = pd->pd_port_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14893
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14894
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14895
	ns_cmd->ns_cmd_code = NS_GID_PN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14896
	ns_cmd->ns_pd = pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14897
	((ns_req_gid_pn_t *)ns_cmd->ns_cmd_buf)->pwwn = pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14898
	((ns_resp_gid_pn_t *)ns_cmd->ns_data_buf)->pid.port_id = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14899
	((ns_resp_gid_pn_t *)ns_cmd->ns_data_buf)->pid.priv_lilp_posit = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14900
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14901
	return (fp_ns_query(port, ns_cmd, job, polled, sleep));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14902
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14903
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14904
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14905
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14906
 * Sanity check the LILP map returned by FCA
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14907
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14908
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14909
fp_validate_lilp_map(fc_lilpmap_t *lilp_map)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14910
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14911
	int	count;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14912
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14913
	if (lilp_map->lilp_length == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14914
		return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14915
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14916
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14917
	for (count = 0; count < lilp_map->lilp_length; count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14918
		if (fp_is_valid_alpa(lilp_map->lilp_alpalist[count]) !=
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14919
		    FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14920
			return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14921
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14922
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14923
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14924
	return (FC_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14925
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14926
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14927
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14928
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14929
 * Sanity check if the AL_PA is a valid address
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14930
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14931
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14932
fp_is_valid_alpa(uchar_t al_pa)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14933
{
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 14934
	int	count;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14935
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14936
	for (count = 0; count < sizeof (fp_valid_alpas); count++) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14937
		if (al_pa == fp_valid_alpas[count] || al_pa == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14938
			return (FC_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14939
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14940
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14941
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14942
	return (FC_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14943
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14944
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14945
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14946
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14947
 * Post unsolicited callbacks to ULPs
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14948
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14949
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14950
fp_ulp_unsol_cb(void *arg)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14951
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14952
	fp_unsol_spec_t	*ub_spec = (fp_unsol_spec_t *)arg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14953
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14954
	fctl_ulp_unsol_cb(ub_spec->port, ub_spec->buf,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14955
	    ub_spec->buf->ub_frame.type);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14956
	kmem_free(ub_spec, sizeof (*ub_spec));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14957
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14958
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14959
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14960
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14961
 * Perform message reporting in a consistent manner. Unless there is
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14962
 * a strong reason NOT to use this function (which is very very rare)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14963
 * all message reporting should go through this.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14964
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14965
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14966
fp_printf(fc_local_port_t *port, int level, fp_mesg_dest_t dest, int fc_errno,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14967
    fc_packet_t *pkt, const char *fmt, ...)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14968
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14969
	caddr_t		buf;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14970
	va_list		ap;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14971
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14972
	switch (level) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14973
	case CE_NOTE:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14974
		if ((port->fp_verbose & FP_WARNING_MESSAGES) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14975
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14976
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14977
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14978
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14979
	case CE_WARN:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14980
		if ((port->fp_verbose & FP_FATAL_MESSAGES) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14981
			return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14982
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14983
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14984
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14985
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14986
	buf = kmem_zalloc(256, KM_NOSLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14987
	if (buf == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14988
		return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14989
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14990
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14991
	(void) sprintf(buf, "fp(%d): ", port->fp_instance);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14992
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14993
	va_start(ap, fmt);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14994
	(void) vsprintf(buf + strlen(buf), fmt, ap);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14995
	va_end(ap);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14996
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14997
	if (fc_errno) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14998
		char *errmsg;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 14999
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15000
		(void) fc_ulp_error(fc_errno, &errmsg);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15001
		(void) sprintf(buf + strlen(buf), " FC Error=%s", errmsg);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15002
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15003
		if (pkt) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15004
			caddr_t	state, reason, action, expln;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15005
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15006
			(void) fc_ulp_pkt_error(pkt, &state, &reason,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15007
			    &action, &expln);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15008
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15009
			(void) sprintf(buf + strlen(buf),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15010
			    " state=%s, reason=%s", state, reason);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15011
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15012
			if (pkt->pkt_resp_resid) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15013
				(void) sprintf(buf + strlen(buf),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15014
				    " resp resid=%x\n", pkt->pkt_resp_resid);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15015
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15016
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15017
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15018
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15019
	switch (dest) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15020
	case FP_CONSOLE_ONLY:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15021
		cmn_err(level, "^%s", buf);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15022
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15023
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15024
	case FP_LOG_ONLY:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15025
		cmn_err(level, "!%s", buf);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15026
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15027
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15028
	default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15029
		cmn_err(level, "%s", buf);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15030
		break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15031
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15032
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15033
	kmem_free(buf, 256);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15034
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15035
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15036
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15037
fp_fcio_login(fc_local_port_t *port, fcio_t *fcio, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15038
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15039
	int			ret;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15040
	uint32_t		d_id;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15041
	la_wwn_t		pwwn;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15042
	fc_remote_port_t	*pd = NULL;
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15043
	fc_remote_port_t	*held_pd = NULL;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15044
	fctl_ns_req_t		*ns_cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15045
	fc_portmap_t		*changelist;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15046
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15047
	bcopy(fcio->fcio_ibuf, &pwwn, sizeof (pwwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15048
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15049
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15050
	if (FC_IS_TOP_SWITCH(port->fp_topology)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15051
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15052
		job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15053
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15054
		job->job_result = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15055
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15056
		ns_cmd = fctl_alloc_ns_cmd(sizeof (ns_req_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15057
		    sizeof (ns_resp_gid_pn_t), sizeof (ns_resp_gid_pn_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15058
		    FCTL_NS_BUF_IS_USERLAND, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15059
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15060
		ASSERT(ns_cmd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15061
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15062
		ns_cmd->ns_cmd_code = NS_GID_PN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15063
		((ns_req_gid_pn_t *)(ns_cmd->ns_cmd_buf))->pwwn = pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15064
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15065
		ret = fp_ns_query(port, ns_cmd, job, 1, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15066
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15067
		if (ret != FC_SUCCESS || job->job_result != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15068
			if (ret != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15069
				fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15070
			} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15071
				fcio->fcio_errno = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15072
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15073
			fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15074
			return (EIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15075
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15076
		d_id = BE_32(*((uint32_t *)ns_cmd->ns_data_buf));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15077
		fctl_free_ns_cmd(ns_cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15078
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15079
		mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15080
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15081
		held_pd = fctl_hold_remote_port_by_pwwn(port, &pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15082
		if (held_pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15083
			fcio->fcio_errno = FC_BADWWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15084
			return (EIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15085
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15086
		pd = held_pd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15087
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15088
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15089
		d_id = pd->pd_port_id.port_id;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15090
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15091
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15092
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15093
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15094
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15095
	pd = fctl_get_remote_port_by_did(port, d_id);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15096
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15097
	if (pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15098
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15099
		if (pd->pd_state == PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15100
			pd->pd_login_count++;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15101
			mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15102
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15103
			fcio->fcio_errno = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15104
			if (held_pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15105
				fctl_release_remote_port(held_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15106
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15107
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15108
			return (0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15109
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15110
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15111
	} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15112
		mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15113
		if (FC_IS_TOP_SWITCH(port->fp_topology)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15114
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15115
			pd = fp_create_remote_port_by_ns(port, d_id, KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15116
			if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15117
				fcio->fcio_errno = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15118
				if (held_pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15119
					fctl_release_remote_port(held_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15120
				}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15121
				return (EIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15122
			}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15123
		} else {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15124
			mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15125
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15126
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15127
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15128
	job->job_flags &= ~JOB_TYPE_FP_ASYNC;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15129
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15130
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15131
	ret = fp_port_login(port, d_id, job, FP_CMD_PLOGI_RETAIN,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15132
	    KM_SLEEP, pd, NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15133
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15134
	if (ret != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15135
		fcio->fcio_errno = ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15136
		if (held_pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15137
			fctl_release_remote_port(held_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15138
		}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15139
		return (EIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15140
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15141
	fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15142
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15143
	fcio->fcio_errno = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15144
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15145
	if (held_pd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15146
		fctl_release_remote_port(held_pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15147
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15148
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15149
	if (job->job_result != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15150
		return (EIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15151
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15152
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15153
	pd = fctl_hold_remote_port_by_pwwn(port, &pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15154
	if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15155
		fcio->fcio_errno = FC_BADDEV;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15156
		return (ENODEV);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15157
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15158
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15159
	changelist = kmem_zalloc(sizeof (*changelist), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15160
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15161
	fctl_copy_portmap(changelist, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15162
	changelist->map_type = PORT_DEVICE_USER_LOGIN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15163
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15164
	(void) fp_ulp_devc_cb(port, changelist, 1, 1, KM_SLEEP, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15165
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15166
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15167
	pd->pd_type = PORT_DEVICE_NOCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15168
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15169
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15170
	fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15171
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15172
	return (0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15173
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15174
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15175
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15176
static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15177
fp_fcio_logout(fc_local_port_t *port, fcio_t *fcio, job_request_t *job)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15178
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15179
	la_wwn_t		pwwn;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15180
	fp_cmd_t		*cmd;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15181
	fc_portmap_t		*changelist;
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15182
	fc_remote_port_t	*pd;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15183
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15184
	bcopy(fcio->fcio_ibuf, &pwwn, sizeof (pwwn));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15185
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15186
	pd = fctl_hold_remote_port_by_pwwn(port, &pwwn);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15187
	if (pd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15188
		fcio->fcio_errno = FC_BADWWN;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15189
		return (ENXIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15190
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15191
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15192
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15193
	if (pd->pd_state != PORT_DEVICE_LOGGED_IN) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15194
		fcio->fcio_errno = FC_LOGINREQ;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15195
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15196
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15197
		fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15198
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15199
		return (EINVAL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15200
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15201
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15202
	ASSERT(pd->pd_login_count >= 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15203
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15204
	if (pd->pd_flags == PD_ELS_IN_PROGRESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15205
		fcio->fcio_errno = FC_FAILURE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15206
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15207
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15208
		fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15209
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15210
		return (EBUSY);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15211
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15212
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15213
	if (pd->pd_login_count > 1) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15214
		pd->pd_login_count--;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15215
		fcio->fcio_errno = FC_SUCCESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15216
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15217
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15218
		changelist = kmem_zalloc(sizeof (*changelist), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15219
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15220
		fctl_copy_portmap(changelist, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15221
		changelist->map_type = PORT_DEVICE_USER_LOGOUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15222
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15223
		fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15224
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15225
		(void) fp_ulp_devc_cb(port, changelist, 1, 1, KM_SLEEP, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15226
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15227
		return (0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15228
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15229
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15230
	pd->pd_flags = PD_ELS_IN_PROGRESS;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15231
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15232
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15233
	job->job_counter = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15234
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15235
	cmd = fp_alloc_pkt(port, sizeof (la_els_logo_t),
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15236
	    FP_PORT_IDENTIFIER_LEN, KM_SLEEP, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15237
	if (cmd == NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15238
		fcio->fcio_errno = FC_NOMEM;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15239
		fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15240
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15241
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15242
		pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15243
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15244
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15245
		return (ENOMEM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15246
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15247
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15248
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15249
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15250
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15251
	cmd->cmd_pkt.pkt_tran_flags = FC_TRAN_INTR | pd->pd_login_class;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15252
	cmd->cmd_pkt.pkt_tran_type = FC_PKT_EXCHANGE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15253
	cmd->cmd_flags = FP_CMD_PLOGI_DONT_CARE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15254
	cmd->cmd_retry_count = 1;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15255
	cmd->cmd_ulp_pkt = NULL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15256
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15257
	fp_logo_init(pd, cmd, job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15258
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15259
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15260
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15261
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15262
	if (fp_sendcmd(port, cmd, port->fp_fca_handle) != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15263
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15264
		pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15265
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15266
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15267
		fp_free_pkt(cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15268
		fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15269
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15270
		return (EIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15271
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15272
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15273
	fp_jobwait(job);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15274
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15275
	fcio->fcio_errno = job->job_result;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15276
	if (job->job_result != FC_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15277
		mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15278
		pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15279
		mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15280
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15281
		fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15282
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15283
		return (EIO);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15284
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15285
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15286
	ASSERT(pd != NULL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15287
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15288
	changelist = kmem_zalloc(sizeof (*changelist), KM_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15289
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15290
	fctl_copy_portmap(changelist, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15291
	changelist->map_type = PORT_DEVICE_USER_LOGOUT;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15292
	changelist->map_state = PORT_DEVICE_INVALID;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15293
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15294
	mutex_enter(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15295
	mutex_enter(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15296
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15297
	fctl_delist_did_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15298
	fctl_delist_pwwn_table(port, pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15299
	pd->pd_flags = PD_IDLE;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15300
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15301
	mutex_exit(&pd->pd_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15302
	mutex_exit(&port->fp_mutex);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15303
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15304
	(void) fp_ulp_devc_cb(port, changelist, 1, 1, KM_SLEEP, 1);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15305
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15306
	fctl_release_remote_port(pd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15307
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15308
	return (0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15309
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15310
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15311
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15312
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15313
/*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15314
 * Send a syslog event for adapter port level events.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15315
 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15316
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15317
fp_log_port_event(fc_local_port_t *port, char *subclass)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15318
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15319
	nvlist_t *attr_list;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15320
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15321
	if (nvlist_alloc(&attr_list, NV_UNIQUE_NAME_TYPE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15322
	    KM_SLEEP) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15323
		goto alloc_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15324
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15325
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15326
	if (nvlist_add_uint32(attr_list, "instance",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15327
	    port->fp_instance) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15328
		goto error;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15329
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15330
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15331
	if (nvlist_add_byte_array(attr_list, "port-wwn",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15332
	    port->fp_service_params.nport_ww_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15333
	    sizeof (la_wwn_t)) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15334
		goto error;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15335
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15336
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15337
	(void) ddi_log_sysevent(port->fp_port_dip, DDI_VENDOR_SUNW, EC_SUNFC,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15338
	    subclass, attr_list, NULL, DDI_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15339
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15340
	nvlist_free(attr_list);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15341
	return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15342
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15343
error:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15344
	nvlist_free(attr_list);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15345
alloc_failed:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15346
	FP_TRACE(FP_NHEAD1(9, 0), "Unable to send %s event", subclass);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15347
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15348
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15349
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15350
static void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15351
fp_log_target_event(fc_local_port_t *port, char *subclass, la_wwn_t tgt_pwwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15352
    uint32_t port_id)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15353
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15354
	nvlist_t *attr_list;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15355
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15356
	if (nvlist_alloc(&attr_list, NV_UNIQUE_NAME_TYPE,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15357
	    KM_SLEEP) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15358
		goto alloc_failed;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15359
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15360
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15361
	if (nvlist_add_uint32(attr_list, "instance",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15362
	    port->fp_instance) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15363
		goto error;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15364
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15365
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15366
	if (nvlist_add_byte_array(attr_list, "port-wwn",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15367
	    port->fp_service_params.nport_ww_name.raw_wwn,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15368
	    sizeof (la_wwn_t)) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15369
		goto error;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15370
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15371
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15372
	if (nvlist_add_byte_array(attr_list, "target-port-wwn",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15373
	    tgt_pwwn.raw_wwn, sizeof (la_wwn_t)) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15374
		goto error;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15375
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15376
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15377
	if (nvlist_add_uint32(attr_list, "target-port-id",
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15378
	    port_id) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15379
		goto error;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15380
	}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15381
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15382
	(void) ddi_log_sysevent(port->fp_port_dip, DDI_VENDOR_SUNW, EC_SUNFC,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15383
	    subclass, attr_list, NULL, DDI_SLEEP);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15384
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15385
	nvlist_free(attr_list);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15386
	return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15387
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15388
error:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15389
	nvlist_free(attr_list);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15390
alloc_failed:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15391
	FP_TRACE(FP_NHEAD1(9, 0), "Unable to send %s event", subclass);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15392
}
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15393
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15394
static uint32_t
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15395
fp_map_remote_port_state(uint32_t rm_state)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15396
{
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
 15397
	switch (rm_state) {
8494
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15398
	case PORT_DEVICE_LOGGED_IN:
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15399
		return (FC_HBA_PORTSTATE_ONLINE);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15400
	case PORT_DEVICE_VALID:
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15401
	case PORT_DEVICE_INVALID:
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15402
	default:
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15403
		return (FC_HBA_PORTSTATE_UNKNOWN);
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15404
	}
b1310325fc32 6766897 System panic during DR operation on x86 platform
Reed <Reed.Liu@Sun.COM>
parents: 8201
diff changeset
 15405
}