iscsit.h revision 4558d122136f151d62acbbc02ddb42df89a5ef66
/*
* 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 _ISCSIT_H_
#define _ISCSIT_H_
#include "iscsit_authclient.h"
/*
* For some reason iscsi_protocol.h lists the max version as "0x02" and the
* min version as "0x00". RFC3720 clearly states that the current version
* number is 0x00 so that is what we will use.
*/
#define ISCSIT_MIN_VERSION 0x00
#define ISCSIT_MAX_VERSION 0x00
#define ISCSIT_MAX_ERROR_RECOVERY_LEVEL 0
#define ISCSIT_MAX_OUTSTANDING_UNEXPECTED_PDUS 0
#define ISCSIT_DEFAULT_TPG "iscsit-default-tpg"
#define ISCSIT_DEFAULT_TPGT 1
#define ISCSI_MAX_TSIH 0xffff
#define ISCSI_UNSPEC_TSIH 0
/* Max targets per system */
#define ISCSIT_MAX_TARGETS 1024
#define ISCSIT_MAX_WINDOW 1024
#define ISCSIT_RXPDU_QUEUE_LEN 2048
#define ISCSIT_CMDSN_LT_EXPCMDSN -1
#define ISCSIT_CMDSN_EQ_EXPCMDSN 1
#define ISCSIT_CMDSN_GT_EXPCMDSN 0
/*
* MC/S: A timeout is maintained to recover from lost CmdSN (holes in the
* CmdSN ordering). When the timeout is reached, the ExpCmdSN is advanced
* past the hole to continue processing the queued commands. This value is
* system-tunable (volatile rxpdu_queue_threshold) and should be in the
* range from 5 to 30 seconds.
*/
/* Time in seconds to wait between calls to stmf_deregister_local_port */
#define TGT_DEREG_RETRY_SECONDS 1
/* Circular buffer to hold the out-of-order PDUs in MC/S */
typedef struct {
int cb_num_elems;
/*
* Used for serial number arithmetic (RFC 1982)
*/
#define ISCSIT_SNA32_CHECK 0x80000000
typedef struct {
char tpg_name[MAX_TPG_NAMELEN];
int tpg_online;
} iscsit_tpg_t;
#define IS_DEFAULT_TPGT(TPGT) \
typedef struct {
typedef struct {
struct sockaddr_storage portal_addr;
int portal_online;
void *portal_isns;
/* Target states and events, update iscsit_ts_name table whenever modified */
typedef enum {
TS_UNDEFINED = 0,
#ifdef ISCSIT_TGT_SM_STRINGS
"TS_UNDEFINED",
"TS_CREATED",
"TS_ONLINING",
"TS_ONLINE",
"TS_STMF_ONLINE",
"TS_DELETING_NEED_OFFLINE",
"TS_OFFLINING",
"TS_OFFLINE",
"TS_STMF_OFFLINE",
"TS_DELETING_STMF_DEREG",
"TS_DELETING_STMF_DEREG_FAIL",
"TS_DELETING",
"TS_MAX_STATE"
};
#endif
typedef enum {
TE_UNDEFINED = 0,
#ifdef ISCSIT_TGT_SM_STRINGS
"TE_UNDEFINED",
"TE_STMF_ONLINE_REQ",
"TE_ONLINE_SUCCESS",
"TE_ONLINE_FAIL",
"TE_STMF_ONLINE_COMPLETE_ACK",
"TE_STMF_OFFLINE_REQ",
"TE_OFFLINE_COMPLETE",
"TE_STMF_OFFLINE_COMPLETE_ACK",
"TE_DELETE",
"TE_STMF_DEREG_SUCCESS",
"TE_STMF_DEREG_FAIL",
"TE_STMF_DEREG_RETRY",
"TE_WAIT_REF_COMPLETE",
"TE_MAX_EVENT"
};
#endif
typedef struct {
char *target_name;
/* STMF lport == iSCSI target */
/* Target state */
} iscsit_tgt_t;
typedef struct {
char ini_name[MAX_ISCSI_NODENAMELEN];
} iscsit_ini_t;
/*
* iSCSI Auth Information
*/
typedef struct conn_auth {
int ca_tgt_chapsecretlen;
int ca_ini_chapsecretlen;
/* RADIUS authentication information */
struct sockaddr_storage ca_radius_server;
int ca_radius_secretlen;
/* authentication method list */
/* Target alias */
} conn_auth_t;
/*
* We have three state machines (so far) between the IDM connection state
* machine, the session state machine, and the login state machine. All
* of these states have some concept of "full feature mode". It's going
* to be obnoxious if we use a mixture of these "ffp" representations
* since it will be difficult to ensure the three state machines
* transition at exactly the same time. We should drive decisions that
* depend on FFP from the IDM state machine which is actually snooping
* the iSCSI PDU's and will always transition at the correct time.
*
* A consequence of this approach is that there is a window just after
* login completes where we may get a SCSI request but the session
* or login state machine has not quite transitioned to "FFP". Whether
* this is a problem depends on how we use those state machines. This
* is what we should use them for:
*
* IDM Connection state machine - Decisions related to command processing
* including whether a connection is in FFP
*
* Session state machine - Summarize the state of all available connections
* for the purposes of ERL1, ERL2 and MC/S. A session in LOGGED_IN state
* should always have at least one FFP connection but there may be a brief
* window where a session in ACTIVE might have one or more FFP connections
* even though ACTIVE is not strictly an FFP state according to the RFC.
*
* Login state machine -- drive the login process, collect negotiated
* parameters. Another side effect of this approach is that we may get
* the "notify ffp" callback from the IDM connection state machine before
* the login state machine has actually transitioned to FFP state.
*/
struct iscsit_conn_s;
/* Update iscsit_ss_name table whenever session states are modified */
typedef enum {
SS_UNDEFINED = 0,
/* Add new session states above SS_MAX_STATE */
#ifdef ISCSIT_SESS_SM_STRINGS
/* An array of state text values, for use in logging state transitions */
"SS_UNDEFINED",
"SS_Q1_FREE",
"SS_Q2_ACTIVE",
"SS_Q3_LOGGED_IN",
"SS_Q4_FAILED",
"SS_Q5_CONTINUE",
"SS_Q6_DONE",
"SS_Q7_ERROR",
"SS_MAX_STATE"
};
#endif
/* Update iscsit_se_name table whenever session events are modified */
typedef enum {
SE_UNDEFINED = 0,
SE_CONN_IN_LOGIN, /* From login state machine */
SE_CONN_LOGGED_IN, /* FFP enabled client notification */
SE_CONN_FFP_FAIL, /* FFP disabled client notification */
SE_CONN_FFP_DISABLE, /* FFP disabled client notification */
SE_CONN_FAIL, /* Conn destroy client notification */
SE_SESSION_CLOSE, /* FFP disabled client notification */
SE_SESSION_REINSTATE, /* From login state machine */
SE_SESSION_TIMEOUT, /* Internal */
SE_SESSION_CONTINUE, /* From login state machine */
SE_SESSION_CONTINUE_FAIL, /* From login state machine? */
/* Add new events above SE_MAX_EVENT */
#ifdef ISCSIT_SESS_SM_STRINGS
/* An array of event text values, for use in logging events */
"SE_UNDEFINED",
"SE_CONN_IN_LOGIN",
"SE_CONN_LOGGED_IN",
"SE_CONN_FFP_FAIL",
"SE_CONN_FFP_DISABLE",
"SE_CONN_FAIL",
"SE_SESSION_CLOSE",
"SE_SESSION_REINSTATE",
"SE_SESSION_TIMEOUT",
"SE_SESSION_CONTINUE",
"SE_SESSION_CONTINUE_FAIL",
"SE_MAX_EVENT"
};
#endif
/*
* Set in ist_tgt after iscsit_tgt_unbind_sess to differentiate an unbound
* session from a discovery session.
*/
#define SESS_UNBOUND_FROM_TGT -1
typedef struct {
int ist_conn_count;
int ist_ffp_conn_count;
struct iscsit_conn_s *ist_failed_conn;
char *ist_initiator_name;
char *ist_initiator_alias;
char *ist_target_name;
char *ist_target_alias;
/* Update iscsit_ils_name table whenever login states are modified */
typedef enum {
ILS_UNDEFINED = 0,
ILS_LOGIN_WAITING, /* Waiting for more login PDU's */
ILS_LOGIN_PROCESSING, /* Processing login request */
ILS_LOGIN_RESPONDING, /* Sending login response */
ILS_LOGIN_RESPONDED, /* Sent login response (no trans. to FFP) */
ILS_LOGIN_FFP, /* Sending last login PDU for final response */
ILS_LOGIN_DONE, /* Last login PDU sent (so we can free it) */
ILS_LOGIN_ERROR, /* Login error, login failed */
/* Add new login states above ILS_MAX_STATE */
#ifdef ISCSIT_LOGIN_SM_STRINGS
/* An array of login state text values, for use in logging login progress */
"ILS_UNDEFINED",
"ILS_LOGIN_INIT",
"ILS_LOGIN_WAITING",
"ILS_LOGIN_PROCESSING",
"ILS_LOGIN_RESPONDING",
"ILS_LOGIN_RESPONDED",
"ILS_LOGIN_FFP",
"ILS_LOGIN_DONE",
"ILS_LOGIN_ERROR",
"ILS_MAX_STATE"
};
#endif
/* Update iscsit_ile_name table whenever login events are modified */
typedef enum {
ILE_UNDEFINED = 0,
/* Add new login events above ILE_MAX_EVENT */
#ifdef ISCSIT_LOGIN_SM_STRINGS
/* An array of login event text values, for use in logging login events */
"ILE_UNDEFINED",
"ILE_LOGIN_RCV",
"ILE_LOGIN_RESP_READY",
"ILE_LOGIN_FFP",
"ILE_LOGIN_RESP_COMPLETE",
"ILE_LOGIN_ERROR",
"ILE_LOGIN_CONN_ERROR",
"ILE_MAX_EVENT"
};
#endif
typedef struct {
typedef struct {
int icl_auth_pass;
char *icl_target_name;
char *icl_target_alias;
char *icl_initiator_name;
char *icl_login_resp_buf;
void *icl_login_resp_itb; /* mult-pdu idm buf */
int icl_login_resp_len; /* For kmem_free */
typedef struct iscsit_conn_s {
struct iscsit_conn_s *ict_reinstate_conn;
ict_lost:1,
/*
* Parameters for processing text commands
*/
char *ict_text_rsp_buf;
#define ICT_FLAGS_DISCOVERY 0x00000001
typedef struct {
} iscsit_buf_t;
typedef struct {
it_aborted:1,
it_active:1,
it_tm_task:1,
typedef struct iscsit_isns_cfg {
/*
* State values for the iscsit service
*/
typedef enum {
ISE_UNDEFINED = 0,
typedef struct {
extern iscsit_global_t iscsit_global;
void
void
void
void
void
void
void
void
void
void
/*
* IDM conn ops
*/
/*
* lport entry points
*/
void
void
/*
* Connection functions
*/
void
void
void
void
/*
* Session functions
*/
int
char *initiator_name, char *target_name,
void
void
void
void
void
void
void
iscsit_conn_t *ict);
/*
* Target, TPGT, TPGT and portal functions
*/
void
void
void
void
iscsit_tgt_lookup(char *target_name);
iscsit_tgt_lookup_locked(char *target_name);
int
int
void
void
void
void
void
void
void
iscsit_tpg_lookup(char *tpg_name);
int
void
void
void
void
void
void
int
iscsit_ini_lookup_locked(char *ini_name);
int
int
void
void
#endif /* _ISCSIT_H_ */