stmf.h revision 40c3e8ff0f3a541e3a203404d3a5dc7eb0f5aee8
/*
* 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
*/
/*
*/
#ifndef _STMF_H
#define _STMF_H
#include <sys/stmf_defines.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum stmf_struct_id {
/*
* Provider callback commands
*/
#define STMF_PROVIDER_DATA_UPDATED 0x01
/*
* Provider callback flags
*/
#define STMF_PCB_STMF_ONLINING 0x0001
#define STMF_PCB_PREG_COMPLETE 0x0002
typedef void *data_seg_handle_t;
#define STMF_MAX_LU_CACHE_NTASKS 16
#define STMF_NO_HANDLE 0xffffffff
#define COMPANY_ID_NONE 0xFFFFFFFF
#define COMPANY_ID_SUN 0x00144F
/*
* contexts within stmf:
* 1) supplied by the port provider that the LU provider uses to exchange
* data with the backing store.
* 2) supplied by the LU provider that the port provider uses exchange
* data with the host initiator.
* The second format is optionally supported by the port provided as
* indicated by the command task flags.
*/
typedef struct stmf_sglist_ent {
typedef struct stmf_data_buf {
void *db_stmf_private;
void *db_port_private;
void *db_lu_private;
/*
* db_flags
*/
#define DB_DIRECTION_TO_RPORT 0x0001
#define DB_DIRECTION_FROM_RPORT 0x0002
#define DB_SEND_STATUS_GOOD 0x0004
#define DB_STATUS_GOOD_SENT 0x0008
#define DB_DONT_CACHE 0x0010
#define DB_DONT_REUSE 0x0020
#define DB_LU_DATA_BUF 0x0040
#define DB_LPORT_XFER_ACTIVE 0x8000
typedef struct scsi_task {
void *task_stmf_private;
void *task_port_private;
void *task_lu_private;
struct stmf_scsi_session *task_session;
struct stmf_local_port *task_lport;
void *task_lu_itl_handle; /* Assigned by LU */
/* CMD information from initiator */
/* Fields to manage data phase */
/* Status Phase */
/* Misc. task data */
void *task_extended_cmd;
} scsi_task_t;
/*
* Maximum expected transfer length. Can also be used when the transfer
* length is unknown when the task is allocated (e.g. SAS)
*/
#define TASK_MAX_XFER_LENGTH 0xFFFFFFFF
/*
* task_flags definitions.
*/
/*
* If TF_INITIAL_BURST is set, the dbuf passed with new_task() contains
* data from initial burst. Otherwise its just a buffer which the port
* passed to the LU.
*/
#define TF_INITIAL_BURST 0x80
/* Both READ_DATA and WRITE_DATA can be set for bidirectional xfers */
#define TF_READ_DATA 0x40
#define TF_WRITE_DATA 0x20
#define TF_ATTR_MASK 0x07
#define TF_ATTR_UNTAGGED 0x0
#define TF_ATTR_SIMPLE_QUEUE 0x1
#define TF_ATTR_ORDERED_QUEUE 0x2
#define TF_ATTR_HEAD_OF_QUEUE 0x3
#define TF_ATTR_ACA 0x4
/*
* Task Management flags.
*/
#define TM_NONE 0x00
#define TM_ABORT_TASK 0x01
#define TM_ABORT_TASK_SET 0x02
#define TM_CLEAR_ACA 0x03
#define TM_CLEAR_TASK_SET 0x04
#define TM_LUN_RESET 0x05
#define TM_TARGET_WARM_RESET 0x06
#define TM_TARGET_COLD_RESET 0x07
#define TM_TASK_REASSIGN 0x08
#define TM_TARGET_RESET 0x09
#define TM_QUERY_TASK 0x0A
/*
* additional flags
*/
#define TASK_AF_ENABLE_COMP_CONF 0x01
#define TASK_AF_PORT_LOAD_HIGH 0x02
#define TASK_AF_NO_EXPECTED_XFER_LENGTH 0x04
/*
* PP sets this flag if it can process dbufs created by the LU.
*/
#define TASK_AF_ACCEPT_LU_DBUF 0x08
/*
* scsi_task_t extension identifiers
*/
#define STMF_TASK_EXT_NONE 0
/*
* max_nbufs
*/
#define STMF_BUFS_MAX 255
/*
* Task status ctrl
*/
#define TASK_SCTRL_OVER 1
#define TASK_SCTRL_UNDER 2
/*
* The flags used by I/O flow.
*/
#define STMF_IOF_LU_DONE 0x0001
#define STMF_IOF_LPORT_DONE 0x0002
#define STMF_IOF_STATS_ONLY 0x0004
/*
* struct allocation flags
*/
#define AF_FORCE_NOSLEEP 0x0001
#define AF_DONTZERO 0x0002
typedef struct stmf_state_change_info {
char *st_additional_info;
typedef struct stmf_change_status {
char *st_additional_info;
/*
* conditions causing or affecting the change.
*/
#define STMF_RFLAG_USER_REQUEST 0x0001
#define STMF_RFLAG_FATAL_ERROR 0x0002
#define STMF_RFLAG_STAY_OFFLINED 0x0004
#define STMF_RFLAG_RESET 0x0008
#define STMF_RFLAG_COLLECT_DEBUG_DUMP 0x0010
#define STMF_RFLAG_LU_ABORT 0x0020
#define STMF_RFLAG_LPORT_ABORT 0x0040
#define STMF_CHANGE_INFO_LEN 160
/*
* cmds to stmf_abort entry point
*/
#define STMF_QUEUE_TASK_ABORT 1
#define STMF_REQUEUE_TASK_ABORT_LPORT 2
#define STMF_REQUEUE_TASK_ABORT_LU 3
#define STMF_QUEUE_ABORT_LU 4
/*
* cmds to be used by stmf ctl
*/
#define STMF_CMD_LU_OP 0x0100
#define STMF_CMD_LPORT_OP 0x0200
#define STMF_CMD_MASK 0x00ff
#define STMF_CMD_ONLINE 0x0001
#define STMF_CMD_OFFLINE 0x0002
#define STMF_CMD_GET_STATUS 0x0003
#define STMF_CMD_ONLINE_COMPLETE 0x0004
#define STMF_CMD_OFFLINE_COMPLETE 0x0005
#define STMF_ACK_ONLINE_COMPLETE 0x0006
#define STMF_ACK_OFFLINE_COMPLETE 0x0007
#define STMF_CMD_GET_LPORT_STATUS \
#define STMF_CMD_LU_ONLINE_COMPLETE \
#define STMF_CMD_LPORT_ONLINE_COMPLETE \
#define STMF_ACK_LU_ONLINE_COMPLETE \
#define STMF_ACK_LPORT_ONLINE_COMPLETE \
#define STMF_CMD_LU_OFFLINE_COMPLETE \
#define STMF_CMD_LPORT_OFFLINE_COMPLETE \
#define STMF_ACK_LU_OFFLINE_COMPLETE \
#define STMF_ACK_LPORT_OFFLINE_COMPLETE \
/*
* For LPORTs and LUs to create their own ctl cmds which dont
* conflict with stmf ctl cmds.
*/
#define STMF_LPORT_CTL_CMDS 0x1000
#define STMF_LU_CTL_CMDS 0x2000
/*
* Commands for various info routines.
*/
/* Command classifiers */
#define SI_LPORT 0x1000000
#define SI_STMF 0x2000000
#define SI_LU 0x4000000
#define SI_LPORT_FC 0x0000000
#define SI_LPORT_ISCSI 0x0010000
#define SI_LPORT_SAS 0x0020000
#define SI_STMF_LU 0x0010000
#define SI_STMF_LPORT 0x0020000
#define SI_GET_CLASS(v) ((v) & 0xFF000000)
#define SI_GET_SUBCLASS(v) ((v) & 0x00FF0000)
/* Commands for LPORT info routines */
/* XXX - Implement these. */
#if 0
#endif
/*
* Events
*/
#define STMF_EVENT_ALL ((int)-1)
#define LPORT_EVENT_INITIAL_LUN_MAPPED 0
/*
*/
#define DDI_NT_STMF "ddi_scsi_target:framework"
#define DDI_NT_STMF_LP "ddi_scsi_target:lu_provider"
#define DDI_NT_STMF_PP "ddi_scsi_target:port_provider"
/*
* VPD page bits.
*/
#define STMF_VPD_LU_ID 0x01
#define STMF_VPD_TARGET_ID 0x02
#define STMF_VPD_TP_GROUP 0x04
#define STMF_VPD_RELATIVE_TP_ID 0x08
/*
* Common macros to simplify coding
*/
void stmf_free(void *struct_ptr);
int eventid);
struct scsi_devid_desc *lu_id);
struct scsi_devid_desc *lu_id);
#ifdef __cplusplus
}
#endif
#endif /* _STMF_H */