fcsm.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 _FCSM_H
#define _FCSM_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/*
* Message printing flags
*/
#define SM_LOG 1
#define SM_CONSOLE 2
#define SM_LOG_AND_CONSOLE 3
/*
* Debug levels
*/
#define SMDL_TRACE 0x0001
#define SMDL_IO 0x0002
#define SMDL_ERR 0x0004
#define SMDL_INFO 0x0008
#ifdef DEBUG
extern uint32_t fcsm_debug;
#else /* DEBUG */
#endif /* DEBUG */
/*
* Open flags
*/
#define FCSM_IDLE 0x00
#define FCSM_OPEN 0x01
#define FCSM_EXCL 0x02
/* Definitions for command retries */
/*
* fcsm_job - Job structure to issue commands using command thread
*/
typedef struct fcsm_job {
int job_port_instance; /* port driver instance */
int job_result; /* job completion result */
/* completion func */
int job_retry_count; /* Retry count */
void *job_priv; /* for fcsm private use */
} fcsm_job_t;
/*
* fcsm_t - FCSM Structure for per port information
*/
typedef struct fcsm {
int sm_sid; /* FCA Port ID */
int sm_instance; /* fc port instance number */
int sm_ncmds; /* # of pending commands */
int sm_cb_count; /* # callbacks in progress */
/* Mgmt Server Login Params */
} fcsm_t;
typedef struct fcsm_cmd {
int cmd_retry_count;
int cmd_retry_interval;
int cmd_max_retries;
} fcsm_cmd_t;
/*
* sm_flags in the per port FCSM Structure
*/
#define FCSM_ATTACHING 0x0001
#define FCSM_ATTACHED 0x0002
#define FCSM_DETACHING 0x0004
#define FCSM_DETACHED 0x0008
#define FCSM_SUSPENDED 0x0010
#define FCSM_POWER_DOWN 0x0020
#define FCSM_RESTORE_RETRY_TIMEOUT 0x0040
#define FCSM_RESTORE_OFFLINE_TIMEOUT 0x0080
#define FCSM_RETRY_TIMER_ACTIVE 0x0100
#define FCSM_SERIALIZE_JOBTHREAD 0x0200
#define FCSM_CMD_RETRY_Q_SUSPENDED 0x0400
#define FCSM_PORT_OFFLINE 0x0800
#define FCSM_LINK_DOWN 0x1000
#define FCSM_MGMT_SERVER_LOGGED_IN 0x2000
#define FCSM_MGMT_SERVER_LOGIN_IN_PROG 0x4000
/* Command flags for Job structure */
#define FCSM_JOBFLAG_SYNC 0x01
#define FCSM_JOBFLAG_ASYNC 0x02
#define FCSM_JOBFLAG_SERIALIZE 0x04
#define FCSM_JOBFLAG_CTHEADER_BE 0X08
/* Command codes */
#define FCSM_JOB_NONE 0x00
#define FCSM_JOB_THREAD_SHUTDOWN 0x01
#define FCSM_JOB_LOGIN_NAME_SERVER 0x02
#define FCSM_JOB_LOGIN_MGMT_SERVER 0x03
#define FCSM_JOB_CT_PASSTHRU 0x04
/* Private flags for command */
#define FCSM_JOB_PRIV_WAIT_FOR_LOGIN 0x01
#define FCSM_JOB_PRIV_LOGIN_IN_PROG 0x02
/* Command DMA Flags */
#define FCSM_CF_CMD_VALID_DMA_MEM 0x01
#define FCSM_CF_CMD_VALID_DMA_BIND 0x02
#define FCSM_CF_RESP_VALID_DMA_MEM 0x04
#define FCSM_CF_RESP_VALID_DMA_BIND 0x08
}
/*
* Macros to address endian issues
*/
/*
* Macros to perform DMA Sync
*/
#endif /* _KERNEL */
/*
* IOCTL Definitions
*/
typedef struct fc_ct_aiu {
char aiu_payload[1];
/* aiu_payload can be up to 'm' bytes (arbitrary length) */
} fc_ct_aiu_t;
/* Management Server - Fabric Configuration Server Commands */
#ifdef _KERNEL
/*
* Driver entry point functions
*/
/*
* FC Transport functions
*/
/*
* Internal functions
*/
static void fcsm_suspend_port(fcsm_t *);
static void fcsm_resume_port(fcsm_t *);
static void fcsm_cleanup_port(fcsm_t *);
static void fcsm_offline_timeout(void *);
static int fcsm_job_cache_constructor(void *, void *, int);
static void fcsm_job_cache_destructor(void *, void *);
static fcsm_job_t *fcsm_alloc_job(int);
static void fcsm_dealloc_job(fcsm_job_t *);
opaque_t);
static int fcsm_process_job(fcsm_job_t *, int);
static int fcsm_cmd_cache_constructor(void *, void *, int);
static void fcsm_cmd_cache_destructor(void *, void *);
static void fcsm_free_cmd_dma(fcsm_cmd_t *);
static void fcsm_job_thread(fcsm_t *);
static void fcsm_jobdone(fcsm_job_t *);
void (*comp_func)());
static void fcsm_ct_intr(fcsm_cmd_t *);
static void fcsm_job_ct_passthru(fcsm_job_t *);
static void fcsm_xlogi_intr(fcsm_cmd_t *);
static void fcsm_job_login_mgmt_server(fcsm_job_t *);
int fcsm_ct_passthru(int, fcio_t *, int, int,
static void fcsm_pkt_common_intr(fc_packet_t *);
static int fcsm_issue_cmd(fcsm_cmd_t *);
static int fcsm_retry_cmd(fcsm_cmd_t *);
static void fcsm_retry_timeout(void *);
static void fcsm_force_port_detach_all(void);
/*
* Utility functions
*/
static void fcsm_display(int, int, fcsm_t *,
fc_packet_t *, const char *, ...);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _FCSM_H */