fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _FCSM_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _FCSM_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _KERNEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Message printing flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SM_LOG 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SM_CONSOLE 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SM_LOG_AND_CONSOLE 3
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Debug levels
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SMDL_TRACE 0x0001
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SMDL_IO 0x0002
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SMDL_ERR 0x0004
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SMDL_INFO 0x0008
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_DEBUG(level, args) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fcsm_debug & (level)) fcsm_display args
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t fcsm_debug;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* DEBUG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_DEBUG(level, args)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DEBUG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_INIT_INSTANCES 8 /* # of instances for soft_state_init */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open flags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_IDLE 0x00
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_OPEN 0x01
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_EXCL 0x02
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_ELS_TIMEOUT (20) /* secs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_MS_TIMEOUT (20) /* secs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_OFFLINE_TICKER (120) /* secs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Definitions for command retries */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_MAX_CMD_RETRIES 5 /* Max retries in case of failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_RETRY_INTERVAL 3 /* Retry interval in seconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_RETRY_TICKER 1 /* Retry thread execution interval */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_MAX_JOB_RETRIES 3 /* Max retries in case of job failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fcsm_job - Job structure to issue commands using command thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct fcsm_job {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t job_code; /* Command code */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t job_flags; /* Command Flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int job_port_instance; /* port driver instance */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int job_result; /* job completion result */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte opaque_t job_arg; /* Command Arguments */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte opaque_t job_caller_priv; /* Caller private */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*job_comp)(opaque_t, struct fcsm_job *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* completion func */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte opaque_t job_comp_arg; /* Arg for completion func */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t job_mutex; /* per command mutex */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ksema_t job_sema; /* To wait for completion */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fcsm_job *job_next; /* for linked list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int job_retry_count; /* Retry count */
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang void *job_priv; /* for fcsm private use */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t job_priv_flags; /* fcsm private flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} fcsm_job_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fcsm_t - FCSM Structure for per port information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct fcsm {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t sm_mutex; /* mutex for protection */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fcsm *sm_next; /* for global linked list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sm_sid; /* FCA Port ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sm_instance; /* fc port instance number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sm_port_state; /* FCA port state */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sm_port_top; /* Port topology */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sm_state; /* San Mgmt State information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sm_flags; /* San Mgmt Flags (see below) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sm_ncmds; /* # of pending commands */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sm_cb_count; /* # callbacks in progress */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_ulp_port_info_t sm_port_info; /* FCA Port Information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcsm_job_t *sm_job_head; /* port's job queue head */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcsm_job_t *sm_job_tail; /* port's job queue tail */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fcsm_cmd *sm_retry_head; /* cmd retry queue head */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fcsm_cmd *sm_retry_tail; /* cmd retry queue tail */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte timeout_id_t sm_retry_tid; /* retry timer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte timeout_id_t sm_offline_tid; /* offline timer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t sm_job_cv; /* cv for job processing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sm_dev_count; /* # of devices discovered */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_portmap_t *sm_portmap; /* device map */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kthread_t *sm_thread; /* per port job thread */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_cache_t *sm_cmd_cache; /* per port fc packet cache */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte la_els_logi_t sm_ms_service_params;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Mgmt Server Login Params */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte callb_cpr_t sm_cpr_info; /* CPR info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} fcsm_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct fcsm_cmd {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_packet_t *cmd_fp_pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcsm_job_t *cmd_job;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcsm_t *cmd_fcsm;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cmd_retry_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cmd_retry_interval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cmd_max_retries;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct fcsm_cmd *cmd_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*cmd_comp)(struct fcsm_cmd *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*cmd_transport)(opaque_t, fc_packet_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cmd_dma_flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_packet_t cmd_fc_packet;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} fcsm_cmd_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sm_flags in the per port FCSM Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_ATTACHING 0x0001
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_ATTACHED 0x0002
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_DETACHING 0x0004
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_DETACHED 0x0008
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_SUSPENDED 0x0010
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_POWER_DOWN 0x0020
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_RESTORE_RETRY_TIMEOUT 0x0040
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_RESTORE_OFFLINE_TIMEOUT 0x0080
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_RETRY_TIMER_ACTIVE 0x0100
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_SERIALIZE_JOBTHREAD 0x0200
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_CMD_RETRY_Q_SUSPENDED 0x0400
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_PORT_OFFLINE 0x0800
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_LINK_DOWN 0x1000
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_MGMT_SERVER_LOGGED_IN 0x2000
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_MGMT_SERVER_LOGIN_IN_PROG 0x4000
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang#define FCSM_USING_NODMA_FCA 0x8000
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Command flags for Job structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_JOBFLAG_SYNC 0x01
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_JOBFLAG_ASYNC 0x02
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_JOBFLAG_SERIALIZE 0x04
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_JOBFLAG_CTHEADER_BE 0X08
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Command codes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_JOB_NONE 0x00
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_JOB_THREAD_SHUTDOWN 0x01
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_JOB_LOGIN_NAME_SERVER 0x02
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_JOB_LOGIN_MGMT_SERVER 0x03
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_JOB_CT_PASSTHRU 0x04
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Private flags for command */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_JOB_PRIV_WAIT_FOR_LOGIN 0x01
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_JOB_PRIV_LOGIN_IN_PROG 0x02
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Command DMA Flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_CF_CMD_VALID_DMA_MEM 0x01
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_CF_CMD_VALID_DMA_BIND 0x02
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_CF_RESP_VALID_DMA_MEM 0x04
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_CF_RESP_VALID_DMA_BIND 0x08
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_INIT_CMD(cmd, job, tran_flags, tran_type, max_retries, func) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd)->cmd_job = (job); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd)->cmd_fc_packet.pkt_tran_flags = (tran_flags); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd)->cmd_fc_packet.pkt_tran_type = (tran_type); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd)->cmd_max_retries = max_retries; \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd)->cmd_comp = func; \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Macros to address endian issues
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang * local variable "fcsm" must exist before using these
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang#define FCSM_REP_RD(handle, hostaddr, devaddr, cnt) \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang { \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang if (!((fcsm)->sm_flags & FCSM_USING_NODMA_FCA)) { \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang ddi_rep_get8((handle), (uint8_t *)(hostaddr), \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang (uint8_t *)(devaddr), (cnt), \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang DDI_DEV_AUTOINCR); \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang } else { \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang bcopy((devaddr), (hostaddr), (cnt)); \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang } \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang }
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang#define FCSM_REP_WR(handle, hostaddr, devaddr, cnt) \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang { \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang if (!((fcsm)->sm_flags & FCSM_USING_NODMA_FCA)) { \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang ddi_rep_put8((handle), (uint8_t *)(hostaddr), \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang (uint8_t *)(devaddr), (cnt), \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang DDI_DEV_AUTOINCR); \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang } else { \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang bcopy((hostaddr), (devaddr), (cnt)); \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang } \
7ff836697c120cb94bd30d5c2204eb9b74718e4cZhong Wang }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IOCTL Definitions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct fc_ct_aiu {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_ct_header_t aiu_header;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char aiu_payload[1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* aiu_payload can be up to 'm' bytes (arbitrary length) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} fc_ct_aiu_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSMIO ('S' << 8)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSMIO_CMD (FCSMIO | 2000)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSMIO_SUB_CMD ('Y' << 8)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSMIO_CT_CMD (FCSMIO_SUB_CMD + 0x01)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSMIO_ADAPTER_LIST (FCSMIO_SUB_CMD + 0x02)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSMIO_FIND_ADAPTER (FCSMIO_SUB_CMD + 0x03)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FCSM_MAX_CT_SIZE (65536) /* 64K */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Management Server - Fabric Configuration Server Commands */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GTIN 0x0100 /* Get Topology Information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GIEL 0x0101 /* Get Interconnect Element List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GIET 0x0111 /* Get Interconnect Element Type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GDID 0x0112 /* Get Domain Identifier */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GMID 0x0113 /* Get Management Identifier */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GFN 0x0114 /* Get Fabric Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GIELN 0x0115 /* Get Interconnect Element Logical Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GMAL 0x0116 /* Get Management Address List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GIEIL 0x0117 /* Get Interconnect Element Information List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPL 0x0118 /* Get Port List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPT 0x0121 /* Get Port Type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPPN 0x0122 /* Get Physical Port Number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GAPNL 0x0124 /* Get Attached Port Name List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPS 0x0126 /* Get Port State */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GATIN 0x0128 /* Get Attached Topology Information */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPLNL 0x0191 /* Get Platform Node Name List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPLT 0x0192 /* Get Platform Type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPLML 0x0193 /* Get Platform Management Address List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GNPL 0x01a1 /* Get Platform Name - Node Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GPNL 0x01a2 /* Get Platform Name List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_GNID 0x01b1 /* Get Node Identification Data - Node Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_RIELN 0x0215 /* Register Interconnect Element Logical Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_RPL 0x0280 /* Register Platform */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_RPLN 0x0291 /* Register Platform Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_RPLT 0x0292 /* Register Platform Type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_RPLM 0x0293 /* Register Platform Management Address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_DPL 0x0380 /* Deregister Platform */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_DPLN 0x0391 /* Deregister Platform Node Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MS_CS_DPLML 0x0393 /* Deregister Platform Management Addr List */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _KERNEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Driver entry point functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_attach(dev_info_t *, ddi_attach_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_detach(dev_info_t *, ddi_detach_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_open(dev_t *, int, int, cred_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_close(dev_t, int, int, cred_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FC Transport functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_port_attach(opaque_t, fc_ulp_port_info_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_attach_cmd_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_port_detach(opaque_t, fc_ulp_port_info_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_detach_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_port_ioctl(opaque_t, opaque_t, dev_t, int, intptr_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int, cred_t *, int *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_statec_cb(opaque_t, opaque_t, uint32_t, uint32_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_portmap_t *, uint32_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_els_cb(opaque_t, opaque_t, fc_unsol_buf_t *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_data_cb(opaque_t, opaque_t, fc_unsol_buf_t *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Internal functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_handle_port_attach(fc_ulp_port_info_t *, uint32_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_handle_port_resume(opaque_t, fc_ulp_port_info_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_attach_cmd_t, uint32_t, fcsm_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_handle_port_detach(fc_ulp_port_info_t *, fcsm_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_detach_cmd_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_suspend_port(fcsm_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_resume_port(fcsm_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_cleanup_port(fcsm_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_offline_timeout(void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_fciocmd(intptr_t, int, cred_t *, fcio_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_fcio_copyout(fcio_t *, intptr_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_job_cache_constructor(void *, void *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_job_cache_destructor(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic fcsm_job_t *fcsm_alloc_job(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_dealloc_job(fcsm_job_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_init_job(fcsm_job_t *, int, uint32_t, uint32_t, opaque_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte opaque_t, void (*comp)(opaque_t, fcsm_job_t *, int),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte opaque_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_process_job(fcsm_job_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_enque_job(fcsm_t *, fcsm_job_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic fcsm_job_t *fcsm_deque_job(fcsm_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_cmd_cache_constructor(void *, void *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_cmd_cache_destructor(void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic fcsm_cmd_t *fcsm_alloc_cmd(fcsm_t *, uint32_t, uint32_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_free_cmd_dma(fcsm_cmd_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_job_thread(fcsm_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_retry_job(fcsm_t *fcsm, fcsm_job_t *job);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_jobdone(fcsm_job_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_ct_init(fcsm_t *, fcsm_cmd_t *, fc_ct_aiu_t *, size_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*comp_func)());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_ct_intr(fcsm_cmd_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_job_ct_passthru(fcsm_job_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_login_and_process_job(fcsm_t *, fcsm_job_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_login_ms_comp(opaque_t, fcsm_job_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_els_init(fcsm_cmd_t *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_xlogi_init(fcsm_t *, fcsm_cmd_t *, uint32_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*comp_func)(), uchar_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_xlogi_intr(fcsm_cmd_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_job_login_mgmt_server(fcsm_job_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fcsm_ct_passthru(int, fcio_t *, int, int,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*func)(fcio_t *));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_ct_passthru_comp(opaque_t, fcsm_job_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_pkt_common_intr(fc_packet_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_issue_cmd(fcsm_cmd_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int fcsm_retry_cmd(fcsm_cmd_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_enque_cmd(fcsm_t *, fcsm_cmd_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic fcsm_cmd_t *fcsm_deque_cmd(fcsm_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_retry_timeout(void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_force_port_detach_all(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Utility functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_disp_devlist(fcsm_t *, fc_portmap_t *, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void fcsm_display(int, int, fcsm_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_packet_t *, const char *, ...);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint fcsm_pkt_state_to_rval(uchar_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecaddr_t fcsm_port_state_to_str(uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecaddr_t fcsm_topology_to_str(uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic caddr_t fcsm_dev_type_to_str(uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _FCSM_H */