iscsit_sess.c revision 30e7468f8f41aa30ada067b2c1d5d284046514da
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/sysmacros.h>
#include <sys/stmf_ioctl.h>
#define ISCSIT_SESS_SM_STRINGS
#include <iscsit.h>
typedef struct {
static void
iscsit_conn_t *ict);
static void
static void
static void
static void
static void
static void
static void
static void
static void
static uint16_t
iscsit_tsih_alloc(void)
{
/* ISCSI_UNSPEC_TSIH (0) indicates failure */
if (result > ISCSI_MAX_TSIH) {
}
}
static void
{
}
char *initiator_name, char *target_name,
{
/*
* Even if this session create "fails" for some reason we still need
* to return a valid session pointer so that we can send the failed
* login response.
*/
/* Allocate TSIH */
/* Out of TSIH's */
/*
* Continue initializing this session so we can use it
* to complete the login process.
*/
}
if (target_name) {
/* A discovery session might not have a target name */
}
/* Login code will fill in ist_stmf_sess if necessary */
/* Kick session state machine (also binds connection to session) */
/*
* As noted above we must return a session pointer even if something
* failed. The resources will get freed later.
*/
return (result);
}
static void
iscsit_sess_unref(void *ist_void)
{
/*
* State machine has run to completion, destroy session
*
* If we have an associated STMF session we should clean it
* up now.
*
* This session is no longer associated with a target at this
* point so don't touch the target.
*/
ist->ist_stmf_sess);
sizeof (scsi_devid_desc_t) +
}
}
void
{
if (ist->ist_initiator_name)
if (ist->ist_initiator_alias)
if (ist->ist_target_name)
if (ist->ist_target_alias)
}
void
{
/*
* Note in the session state that we are forcing this session
* to close so that the session state machine can avoid
* pointless delays like transitions to SS_Q4_FAILED state.
*/
}
}
}
void
{
ist->ist_conn_count++;
}
void
{
ist->ist_conn_count--;
}
void
{
}
void
{
}
{
return (result);
}
}
return (NULL);
}
{
/*
* Session reinstatement replaces a current session with a new session.
* The new session will have the same ISID as the existing session.
*/
/* Copy additional fields from original session */
/*
* Generate reinstate event
*/
}
return (new_sess);
}
int
{
int result;
/*
* Sort by initiator name, then ISID then portal group tag
*/
if (result < 0) {
return (-1);
} else if (result > 0) {
return (1);
}
/*
* Initiator names match, compare ISIDs
*/
if (result < 0) {
return (-1);
} else if (result > 0) {
return (1);
}
/*
* ISIDs match, compare portal group tags
*/
return (-1);
return (1);
}
/*
* Portal group tags match, compare TSIHs
*/
return (-1);
return (1);
}
/*
* Sessions match
*/
return (0);
}
/*
* State machine
*/
void
{
}
static void
{
/*
* Use the ist_sm_busy to keep the state machine single threaded.
* This also serves as recursion avoidance since this flag will
* always be set if we call login_sm_event from within the
* state machine code.
*/
if (!ist->ist_sm_busy) {
}
}
}
static void
{
sess_event_ctx_t *, ctx);
/* State independent actions */
switch (ctx->se_ctx_event) {
case SE_CONN_IN_LOGIN:
break;
case SE_CONN_FAIL:
break;
}
/* State dependent actions */
case SS_Q1_FREE:
break;
case SS_Q2_ACTIVE:
break;
case SS_Q3_LOGGED_IN:
break;
case SS_Q4_FAILED:
break;
case SS_Q5_CONTINUE:
break;
case SS_Q6_DONE:
break;
case SS_Q7_ERROR:
break;
default:
ASSERT(0);
break;
}
}
static void
{
switch (ctx->se_ctx_event) {
case SE_CONN_IN_LOGIN:
/* N1 */
break;
default:
ASSERT(0);
break;
}
}
static void
{
switch (ctx->se_ctx_event) {
case SE_CONN_LOGGED_IN:
/* N2 track FFP connections */
break;
case SE_CONN_IN_LOGIN:
/* N2.1, don't care stay in this state */
break;
case SE_CONN_FAIL:
/* N9 */
break;
case SE_SESSION_REINSTATE:
/* N11 */
break;
default:
ASSERT(0);
break;
}
}
static void
{
switch (ctx->se_ctx_event) {
case SE_CONN_IN_LOGIN:
case SE_CONN_FAIL:
/* N2.2, don't care */
break;
case SE_CONN_LOGGED_IN:
/* N2.2, track FFP connections */
break;
case SE_CONN_FFP_FAIL:
case SE_CONN_FFP_DISABLE:
/*
* Event data from event context is the associated connection
* which in this case happens to be the last FFP connection
* for the session. In certain cases we need to refer
* to this last valid connection (i.e. RFC3720 section 12.16)
* so we'll save off a pointer here for later use.
*/
if (ist->ist_ffp_conn_count == 0) {
/*
* N5(fail) or N3(disable)
*
* If the event is SE_CONN_FFP_FAIL but we are
* in the midst of an administrative session close
* because of a service or target offline then
* there is no need to go to "failed" state.
*/
(ist->ist_admin_close)) ?
}
break;
case SE_SESSION_CLOSE:
case SE_SESSION_REINSTATE:
/* N3 */
}
/*
* Skip this connection since it will
* see the logout response
*/
continue;
}
NULL);
}
break;
default:
ASSERT(0);
break;
}
}
static void
sess_sm_timeout(void *arg)
{
}
static void
{
/* Session timer must not be running when we leave this event */
switch (ctx->se_ctx_event) {
case SE_CONN_IN_LOGIN:
/* N7 */
break;
case SE_SESSION_REINSTATE:
/* N6 */
/*FALLTHROUGH*/
case SE_SESSION_TIMEOUT:
/* N6 */
break;
case SE_CONN_FAIL:
/* Don't care */
break;
default:
ASSERT(0);
break;
}
}
static void
{
switch (ctx->se_ctx_event) {
case SE_CONN_FAIL:
/* N5 */
break;
case SE_CONN_LOGGED_IN:
/* N10 */
break;
case SE_SESSION_REINSTATE:
/* N11 */
break;
default:
ASSERT(0);
break;
}
}
static void
{
/* Terminal state */
switch (ctx->se_ctx_event) {
case SE_CONN_FFP_FAIL:
case SE_CONN_FFP_DISABLE:
break;
case SE_CONN_FAIL:
if (ist->ist_conn_count == 0) {
}
break;
default:
break;
}
}
static void
{
/* Terminal state */
switch (ctx->se_ctx_event) {
case SE_CONN_FAIL:
if (ist->ist_conn_count == 0) {
}
break;
default:
break;
}
}
static void
{
int t2r_secs;
/*
* Validate new state
*/
"%s(%d) --> %s(%d)\n", (void *) ist,
case SS_Q1_FREE:
break;
case SS_Q2_ACTIVE:
break;
case SS_Q3_LOGGED_IN:
break;
case SS_Q4_FAILED:
t2r_secs =
break;
case SS_Q5_CONTINUE:
break;
case SS_Q6_DONE:
case SS_Q7_ERROR:
/*
* We won't need our TSIH anymore and it represents an
* implicit reference to the global TSIH pool. Get rid
* of it.
*/
}
/*
* We don't want this session to show up anymore so unbind
* it now. After this call this session cannot have any
* references outside itself (implicit or explicit).
*/
/*
* If we have more connections bound then more events
* are comming so don't wait for idle yet.
*/
if (ist->ist_conn_count == 0) {
}
break;
default:
ASSERT(0);
/*NOTREACHED*/
}
}