fct_impl.h revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _FCT_IMPL_H
#define _FCT_IMPL_H
#ifdef __cplusplus
extern "C" {
#endif
#define RSCN_OPTION_VERIFY 0x0001
typedef enum fct_li_state {
LI_STATE_DO_FLOGI = 0, /* FLOGI handled by FCA */
LI_STATE_FINI_TOPOLOGY, /* Finalize topology */
LI_STATE_N2N_PLOGI, /* In case of a N2N connection */
LI_STATE_DO_FCLOGIN, /* Login into 0xFFFFFD */
LI_STATE_DO_SCR, /* State change registration */
LI_STATE_DO_NSLOGIN, /* Login into 0xFFFFFC */
LI_STATE_DO_RNN, /* Register node name */
LI_STATE_DO_RCS, /* Register classes of service */
LI_STATE_DO_RFT, /* Register FC-4 types */
LI_STATE_DO_RSPN, /* Register symbolic port name */
LI_STATE_DO_RSNN, /* Register symbolic node name */
LI_STATE_MAX /* Not a real state */
#define LI_STATE_START 0
#define LI_STATE_MASK 0x3F
/* Next state depends on the return value */
#define LI_STATE_FLAG_CMD_RETCHECK 0x40
/* Link init cmd is still outstanding */
#define LI_STATE_FLAG_CMD_WAITING 0x80
/* Flag to indicate that link info is not available yet */
#define LI_STATE_FLAG_NO_LI_YET 0x100
#define FCT_MAX_CACHED_CMDS 256
struct fct_i_cmd;
typedef struct fct_i_cmd {
void *icmd_cb_private;
} fct_i_cmd_t;
/*
* icmd_flags
*/
#define ICMD_SESSION_AFFECTING 0x0002
#define ICMD_IN_IRP_QUEUE 0x0004
#define ICMD_BEING_ABORTED 0x0008
#define ICMD_KNOWN_TO_FCA 0x0020
#define ICMD_FCA_ABORT_CALLED 0x0040
#define ICMD_CMD_COMPLETE 0x0080
#define ICMD_IN_TRANSITION 0x0100
#define ICMD_ABTS_RECEIVED 0x0200
#define ICMD_IMPLICIT 0x0400
#define ICMD_IMPLICIT_CMD_HAS_RESOURCE 0x0800
/* High order are debug flags */
#define ICMD_ELS_PROCESSING_STARTED 0x80000000
/*
* For solicited commands, there's only 3 states:
* 1) it's new. We need send it to FCA. ICMD_SOLCMD_NEW is set
* 2) it's running. We are waiting for completion.
* 3) it's completed. We need free it. ICMD_CMD_COMPLETE is set
* ICMD_SOLCMD_NEW and ICMD_CMD_COMPLETE should not be set in the same time
*/
#define ICMD_IN_SOLCMD_QUEUE 0x010000
#define ICMD_SOLCMD_NEW 0x020000
typedef struct fct_i_remote_port {
/* For queueing to local port */
struct fct_i_remote_port *irp_next;
/* For queueing to handle elses */
struct fct_i_remote_port *irp_discovery_next;
/*
* sa stands for session affecting, nsa is non session affecting.
* The els counts only represent elses under progress not the ones
* that are terminated. active_xchg_count covers everything including
* the ones waiting to be terminated.
*/
/*
* Most HBAs will only register symbolic node name instead of port name,
* so we use SNN as session alias.
*/
char *irp_snn;
/* items will be filled in ns cmd */
char *irp_spn; /* port symbolic name */
/*
* irp flags
*/
#define IRP_PLOGI_DONE 0x0001
#define IRP_PRLI_DONE 0x0002
#define IRP_IN_DISCOVERY_QUEUE 0x0004
#define IRP_FCP_CLEANUP 0x0008
#define IRP_HANDLE_OPENED 0x0020
#define IRP_SCSI_SESSION_STARTED 0x0040
#define IRP_RSCN_QUEUED 0x0080
#define IRP_SOL_PLOGI_IN_PROGRESS 0x0100
typedef struct fct_cmd_slot {
#define FCT_SLOT_EOL 0xffff
#define FCT_HASH_TABLE_SIZE 256
#define FCT_PORTID_HASH_FUNC(portid) \
typedef struct fct_i_local_port {
struct fct_i_local_port *iport_next;
struct fct_i_local_port *iport_prev;
char *iport_alias;
char iport_alias_mem[16];
struct fct_link_info iport_link_info;
/*
* These variables are used to manage fct_cmd_t cache for SCSI traffic
*/
/*
* Total # of cmds allocated by the driver. Some of which are free
* and sitting on iport_cached_cmdlist. And some are executing.
*/
/*
* Max active cmds in last interval (10 or 30 seconds)
*/
/*
* # of free cmds sitting on the iport_cached_cmdlist
*/
struct fct_i_cmd *iport_cached_cmdlist;
/*
* To release free cmds periodically
*/
/* cmd slots */
/* upper 16 bits is just a counter to avoid ABA issues */
/* worker thread data */
struct fct_i_event *iport_event_head;
struct fct_i_event *iport_event_tail;
struct fct_i_cmd *iport_abort_queue;
struct fct_i_cmd **iport_ppicmd_term;
/* link initialization */
enum fct_li_state iport_li_state;
/* solicited cmd link */
struct fct_i_cmd *iport_solcmd_queue;
/* rpwe = remote port with pending els(es) */
/*
* iport flags
*/
#define IPORT_WORKER_RUNNING 0x0001
#define IPORT_TERMINATE_WORKER 0x0002
#define IPORT_WORKER_DOING_TIMEDWAIT 0x0004
#define IPORT_WORKER_DOING_WAIT 0x0008
#define IPORT_FLAG_PORT_OFFLINED 0x0010
#define IPORT_ALLOW_UNSOL_FLOGI 0x0020
/* Limits for scsi task load of local port */
#define FCT_TASK_GREEN_LIMIT 80
#define FCT_TASK_YELLOW_LIMIT 90
#define FCT_TASK_RED_LIMIT 95
typedef struct fct_i_event {
struct fct_i_event *event_next;
int event_type;
typedef enum { /* Seggested action values for discovery thread */
DISC_ACTION_NO_WORK = 0,
DISC_ACTION_RESCAN = 1,
/*
* Local port state definitions
* NOTE that every time there is a state change, the newly set bit suggests
* the action. So far there are 3 actions S_PORT_CLEANUP, S_ADAPTER_FATAL
* and S_INIT_LINK.
*/
#define S_RCVD_LINK_DOWN 0x01
#define S_RCVD_LINK_UP 0x02
#define S_LINK_ONLINE 0x04
#define S_INIT_LINK 0x08
#define S_PORT_CLEANUP 0x10
#define PORT_STATE_LINK_DOWN 0x00
#define PORT_STATE_LINK_INIT_DONE (S_LINK_ONLINE)
/*
* Internal events
*/
#define FCT_I_EVENT_LINK_INIT_DONE 0x80
#define FCT_I_EVENT_CLEANUP_POLL 0x81
/*
* Offline processing states, used by worker thread.
*/
#define FCT_OPR_DONE 0
#define FCT_OPR_START 1
#define FCT_OPR_CMD_CLEANUP_WAIT 2
#define FCT_OPR_INT_CLEANUP_WAIT 3
/*
* Check time
*/
#define FCT_CMDLIST_CHECK_SECONDS 10
/*
* Define frequently used macros
*/
#define ICMD_TO_CT(x_icmd) \
#define ICMD_TO_ELS(x_icmd) \
#define ICMD_TO_IPORT(x_icmd) \
#define ICMD_TO_PORT(x_icmd) \
#define ICMD_TO_IRP(x_icmd) \
#define PORT_TO_IPORT(x_port) \
#define FCT_IS_ELS_ACC(x_icmd) \
#define FCT_IS_CT_ACC(x_icmd) \
#define IPORT_IN_NS_TOPO(x_iport) \
#define IS_LOGO_ELS(icmd) \
#ifdef __cplusplus
}
#endif
#endif /* _FCT_IMPL_H */