fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
c946faca5d4627284fb79c6b04e652b471034495allan * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LI_STATE_DO_FLOGI = 0, /* FLOGI handled by FCA */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LI_STATE_N2N_PLOGI, /* In case of a N2N connection */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LI_STATE_DO_RCS, /* Register classes of service */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LI_STATE_DO_RSPN, /* Register symbolic port name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LI_STATE_DO_RSNN, /* Register symbolic node name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Next state depends on the return value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Link init cmd is still outstanding */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Flag to indicate that link info is not available yet */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef void (* fct_icmd_cb_t)(struct fct_i_cmd *icmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_cmd *icmd_next; /* iport_abort_queue and irp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fct_i_cmd *icmd_solcmd_next; /* iport_solcmd_queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * icmd_flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* High order are debug flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For solicited commands, there's only 3 states:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1) it's new. We need send it to FCA. ICMD_SOLCMD_NEW is set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2) it's running. We are waiting for completion.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 3) it's completed. We need free it. ICMD_CMD_COMPLETE is set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ICMD_SOLCMD_NEW and ICMD_CMD_COMPLETE should not be set in the same time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* For queueing to local port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* For queueing to handle elses */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sa stands for session affecting, nsa is non session affecting.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The els counts only represent elses under progress not the ones
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that are terminated. active_xchg_count covers everything including
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the ones waiting to be terminated.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Most HBAs will only register symbolic node name instead of port name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * so we use SNN as session alias.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* items will be filled in ns cmd */
c946faca5d4627284fb79c6b04e652b471034495allan * structure used for fct_rls_cb() callback private data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IRP_SESSION_CLEANUP (IRP_FCP_CLEANUP | 0x0010)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCT_FABRIC_HASH(portid) (((portid & 0x1f00) | \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((portid & 0xFFFF00)?FCT_FABRIC_HASH(portid):FCT_LOOP_HASH(portid))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t iport_nrps_login; /* currently logged in */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * These variables are used to manage fct_cmd_t cache for SCSI traffic
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Total # of cmds allocated by the driver. Some of which are free
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and sitting on iport_cached_cmdlist. And some are executing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Max active cmds in last interval (10 or 30 seconds)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * # of free cmds sitting on the iport_cached_cmdlist
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To release free cmds periodically
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cmd slots */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* upper 16 bits is just a counter to avoid ABA issues */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t iport_login_retry; /* for flogi and N2N plogi */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t iport_li_cmd_timeout; /* for li state m/c */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* worker thread data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* link initialization */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* solicited cmd link */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* rpwe = remote port with pending els(es) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IPORT_FLOGI_DONE(iport) PORT_FLOGI_DONE(&(iport)->iport_link_info)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iport flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IS_WORKER_SLEEPING(iport) ((iport)->iport_flags & \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (IPORT_WORKER_DOING_TIMEDWAIT | IPORT_WORKER_DOING_WAIT))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Limits for scsi task load of local port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum { /* Seggested action values for discovery thread */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Local port state definitions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE that every time there is a state change, the newly set bit suggests
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the action. So far there are 3 actions S_PORT_CLEANUP, S_ADAPTER_FATAL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and S_INIT_LINK.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PORT_STATE_LINK_INIT_START (S_RCVD_LINK_UP | S_LINK_ONLINE |\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PORT_STATE_LINK_UP_CLEANING (S_RCVD_LINK_UP | S_PORT_CLEANUP)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PORT_STATE_LINK_DOWN_CLEANING (S_RCVD_LINK_DOWN | S_PORT_CLEANUP)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Internal events
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Offline processing states, used by worker thread.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Define frequently used macros
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((fct_sol_ct_t *)(x_icmd)->icmd_cmd->cmd_specific)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((fct_i_local_port_t *)(x_icmd)->icmd_cmd->cmd_port->port_fct_private)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((fct_i_remote_port_t *)(x_icmd)->icmd_cmd->cmd_rp->rp_fct_private)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CMD_TO_ICMD(x_cmd) ((fct_i_cmd_t *)(x_cmd)->cmd_fct_private)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RP_TO_IRP(x_rp) ((fct_i_remote_port_t *)(x_rp)->rp_fct_private)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((fct_i_local_port_t *)(x_port)->port_fct_private)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((x_icmd)->icmd_cmd->cmd_comp_status == FCT_SUCCESS) && \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ICMD_TO_ELS(x_icmd)->els_resp_payload[0] == ELS_OP_ACC))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((x_icmd)->icmd_cmd->cmd_comp_status == FCT_SUCCESS) && \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ICMD_TO_CT(x_icmd)->ct_resp_payload[8] == 0x80) &&\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ICMD_TO_CT(x_icmd)->ct_resp_payload[9] == 0x02))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((x_iport)->iport_link_info.port_topology & PORT_TOPOLOGY_FABRIC_BIT)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ICMD_TO_ELS(icmd)->els_req_payload[0] == ELS_OP_LOGO)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_status_t fct_xfer_scsi_data(scsi_task_t *task,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_status_t fct_send_scsi_status(scsi_task_t *task, uint32_t ioflags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_i_remote_port_t *fct_portid_to_portptr(fct_i_local_port_t *iport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_i_remote_port_t *fct_lookup_irp_by_nodewwn(fct_i_local_port_t *iport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_i_remote_port_t *fct_lookup_irp_by_portwwn(fct_i_local_port_t *iport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid fct_queue_rp(fct_i_local_port_t *iport, fct_i_remote_port_t *irp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid fct_deque_rp(fct_i_local_port_t *iport, fct_i_remote_port_t *irp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fct_implicitly_logo_all(fct_i_local_port_t *iport, int force_implicit);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint8_t fct_local_port_cleanup_done(fct_i_local_port_t *iport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid fct_q_for_termination_lock_held(fct_i_local_port_t *iport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedisc_action_t fct_handle_port_offline(fct_i_local_port_t *iport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedisc_action_t fct_cmd_terminator(fct_i_local_port_t *iport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_status_t fct_scsi_abort(stmf_local_port_t *lport, int abort_cmd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestmf_status_t fct_info(uint32_t cmd, stmf_local_port_t *lport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid fct_event_handler(stmf_local_port_t *lport, int eventid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint16_t fct_alloc_cmd_slot(fct_i_local_port_t *iport, fct_cmd_t *cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid fct_post_to_discovery_queue(fct_i_local_port_t *iport,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_cmd_t *fct_create_solct(fct_local_port_t *port, fct_remote_port_t *rp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefct_cmd_t *fct_create_solels(fct_local_port_t *port, fct_remote_port_t *rp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int implicit, uchar_t elsop, uint32_t wkdid, fct_icmd_cb_t icmdcb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid fct_post_to_solcmd_queue(fct_local_port_t *port, fct_cmd_t *cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedisc_action_t fct_process_link_init(fct_i_local_port_t *iport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _FCT_IMPL_H */