fc_portif.h revision 7ff836697c120cb94bd30d5c2204eb9b74718e4c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _FC_PORTIF_H
#define _FC_PORTIF_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* To remove the port WWN from the orphan list; An orphan list
* scan typically happens during ONLINE processing (after a LIP
* in Public loop or link reset) or during RSCN validation.
*/
#define FC_ORPHAN_SCAN_LIMIT 15
/*
* Show a limited tolerance on the number of LOGOs that an
* from the port driver's data base. The tolerance counter
* is reset after each link reset.
*/
#define FC_LOGO_TOLERANCE_LIMIT 16
/*
* ns_flags field definitions in struct
* fctl_ns_req_t
*/
#define FCTL_NS_FILL_NS_MAP 0x01
#define FCTL_NS_GET_DEV_COUNT 0x02
#define FCTL_NS_NO_DATA_BUF 0x04
#define FCTL_NS_BUF_IS_USERLAND 0x08
#define FCTL_NS_BUF_IS_FC_PORTMAP 0x10
#define FCTL_NS_CREATE_DEVICE 0x20
#define FCTL_NS_VALIDATE_PD 0x40
#define FCTL_NS_ASYNC_REQUEST 0x80
#define FCTL_GAN_START_ID 0xFFFFFF
/*
* Values for the fp_soft_state field in the fc_local_port_t struct.
*
* Notice below that in two cases, suspend and pm-suspend,there
* is no usage of _IN_, which means the bits will stay even after
* suspend/pm-suspend is complete they are cleared at the time of
*/
/*
* FP_SOFT_IN_DETACH is set in fp_detach_handler(), which is called from
* fp_detach() for the DDI_DETACH flag. FP_SOFT_IN_DETACH is checked in
* numerous places. It is never explicitly cleared -- apparently the code
* relies on ddi_softstate_free(9F) to clear it.
*/
#define FP_SOFT_IN_DETACH 0x0002
/*
* FP_SOFT_SUSPEND is set in fp_suspend_handler() and cleared in
* fp_resume_handler. It is tested in a number of placed in fp and fctl,
* including fp_job_handler().
*/
#define FP_SOFT_SUSPEND 0x0004
/*
* FP_SOFT_POWER_DOWN is set in fp_power_down() and cleared in fp_power_up().
*/
#define FP_SOFT_POWER_DOWN 0x0008
#define FP_SOFT_IN_STATEC_CB 0x0010
#define FP_SOFT_IN_UNSOL_CB 0x0020
#define FP_SOFT_IN_LINK_RESET 0x0040
#define FP_SOFT_BAD_LINK 0x0080
#define FP_SOFT_IN_FCA_RESET 0x0100
#define FP_DETACH_INPROGRESS 0x0200
#define FP_DETACH_FAILED 0x0400
#define FP_SOFT_NO_PMCOMP 0x0800
#define FP_SOFT_FCA_IS_NODMA 0x1000
/*
* Instruct the port driver to just accept logins from these addresses
*/
#define FC_MUST_ACCEPT_D_ID(x) (FC_WELL_KNOWN_ADDR(x) || (x) == 0)
#define FC_IS_REAL_DEVICE(x) (!FC_MUST_ACCEPT_D_ID(x))
/*
* Bit definitions for fp_options field in fc_local_port_t
* structure for Feature and Hack additions to make
* the driver code a real hairball.
*/
#define FP_NS_SMART_COUNT 0x01
#define FP_SEND_RJT 0x02
#define FP_CORE_ON_OFFLINE_TIMEOUT 0x04
#define FP_RESET_CORE_ON_OFFLINE_TIMEOUT 0x08
#define FP_TARGET_MODE 0x10
/*
* Values for fp_pm_level in the fc_local_port_t struct. Tracks current PM
* level for the local port.
*/
#define FP_PM_PORT_DOWN 0
#define FP_PM_PORT_UP 1
/*
* FC port compoment for PM. Used with pm_raise_power() and friends.
*/
#define FP_PM_COMPONENT 0
#define FCTL_WWN_SIZE(wwn) \
/*
* Structure for issuing a work request to the per-instance "job handler"
* thread. Primarily allocated/initialized by fctl_alloc_job() and freed by
* fctl_dealloc_job(). fctl keeps a kmem_cache of these structs anchored by the
* fctl_job_cache global variable. The cache is created at fctl's _init(9E) and
* destroyed at fctl's _fini(9E). See also fctl_cache_constructor()
* and fctl_cache_destructor().
*/
typedef struct job_request {
/*
* ID code for the job or task to be performed. Set by fctl_alloc_job()
* and read by fp_job_handler().
*/
int job_code;
/*
* Completion status of the request. Typically FC_SUCCESS or
* FC_FAILURE, but may make use of other error code values (such as
* FC_OFFLINE, FC_BADCMD, FC_NO_MAP, and friends). The complete set
* of values is not clearly specified.
*/
int job_result;
/* Execution control flags (defined below) */
int job_flags;
/*
* This allows multiple concurrent operations using the same
* job_request_t struct, such as a PLOGI to a group of remote ports
* (see fp_plogi_group()).
*
* This is why this scheme needs the job_mutex to protect
* the job_counter variable, plus the additional job_port_sema for
* synchronizing thread(s).
*/
int job_counter;
void *job_private; /* caller's private */
void *job_arg; /* caller's argument */
/*
* Pointer for singly-liked list of outstanding job_request structs,
* maintained on a per-instance basis by the fp_port_head and
* fp_port_tail pointers in the fc_local_port_t struct.
*/
struct job_request *job_next;
#if !defined(__lint)
#endif /* __lint */
/*
* Values for the job_code field in the job_request_t struct.
*/
#define JOB_PORT_STARTUP 2
#define JOB_PORT_GETMAP 3
#define JOB_PORT_GETMAP_PLOGI_ALL 4
#define JOB_PLOGI_ONE 5
#define JOB_PLOGI_GROUP 6
#define JOB_LOGO_ONE 7
#define JOB_PORT_OFFLINE 8
#define JOB_PORT_ONLINE 9
/* Prepare the local port and the driver softstate for a DDI_DETACH. */
#define JOB_PORT_SHUTDOWN 10
/* Handle an unsolicited request in the job thread */
#define JOB_UNSOL_REQUEST 11
#define JOB_NS_CMD 12
#define JOB_LINK_RESET 13
#define JOB_ULP_NOTIFY 14
#define JOB_FCIO_LOGIN 15
#define JOB_FCIO_LOGOUT 16
/*
* This is used for requests that will not actually be dispatched to the job
* thread.
*/
#define JOB_DUMMY 127
/*
* Bitmask values for the job_flags field in the job_request_t struct.
*
* JOB_TYPE_FCTL_ASYNC is set in various places in fp and fctl. If set then
* fctl_jobdone() will call the completion function in the job_comp field and
* deallocate the job_request_t struct. If not set then fctl_jobdone() will
* sema_v() the job_fctl_sema to wake up any waiting thread. This bit is also
* checked in fc_ulp_login(): if *clear* then fc_ulp_login() will call
* fctl_jobwait() in order to block the calling thread in the job_fctl_sema, and
* then call fctl_dealloc_job() after fctl_jobwait() returns.
*
* JOB_TYPE_FP_ASYNC is set in various places in fp. If set then fp_jobdone()
* will call fctl_jobdone(); if clear then fp_jobdone() will sema_v() the
* job_port_sema in the job_request_t. fp_port_shutdown() also looks for
* JOB_TYPE_FP_ASYNC. Just to keep thing interesting, JOB_TYPE_FP_ASYNC is
* also set in fp_validate_area_domain() and cleared in fp_fcio_login() and
* fp_ns_get_devcount()
*
* The apparent purpose of all this is to allow nested job requests to
* occur in parallel.
*
* JOB_CANCEL_ULP_NOTIFICATION appears to be intended to the number of
* state change callbacks that are reported to ULPs when mutiple state
* changes are being processed in parallel.
*/
#define JOB_TYPE_FCTL_ASYNC 0x01
#define JOB_TYPE_FP_ASYNC 0x02
#define JOB_CANCEL_ULP_NOTIFICATION 0x10
typedef struct fc_port_clist {
#if !defined(__lint)
#endif /* __lint */
/*
* The cmd_size and resp_size shouldn't include the CT HEADER.
*
* For commands like GAN, the ns_resp_size should indicate the
* total number of bytes allocated in the ns_resp_buf to get all
* the NS objects.
*/
typedef struct fctl_ns_req {
int ns_result;
#if !defined(__lint)
#endif /* __lint */
/*
* Orphan list of Port WWNs
*/
typedef struct fc_orphan {
int orp_nscan; /* Number of scans */
} fc_orphan_t;
{ \
(x_flag)); \
} else { \
} \
}
{ \
(x_flag)); \
} else { \
} \
}
#if !defined(__lint)
#endif /* __lint */
struct modlinkage *linkage);
struct modlinkage *linkage);
void fctl_ulp_statec_cb(void *arg);
#ifdef __cplusplus
}
#endif
#endif /* _FC_PORTIF_H */