5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 #ifndef _IDM_CONN_SM_H_
  27 #define _IDM_CONN_SM_H_
  28 
  29 #ifdef  __cplusplus
  30 extern "C" {
  31 #endif
  32 
  33 
  34 /*
  35  * IDM connection state machine events.  Most events get generated internally
  36  * either by the state machine or by the IDM TX/RX code.  For example when IDM
  37  * receives a login request for a target connectionit will generate a
  38  * CE_LOGIN_RCV event.  Similarly when the target sends a successful login
  39  * response IDM generate a "CE_LOGIN_SUCCESS_SND" event.  The following
  40  * events are not detected on the TX/RX path and must be generated explicitly
  41  * by the client when appropriate:
  42  *
  43  * CE_LOGOUT_OTHER_CONN_RCV
  44  * CE_ASYNC_DROP_CONN_RCV   (Only because the message may be received on
 
 202 static const char *idm_cs_name[CS_MAX_STATE+1] = {
 203         "CS_S0_UNDEFINED",
 204         "CS_S1_FREE",
 205         "CS_S2_XPT_WAIT",
 206         "CS_S3_XPT_UP",
 207         "CS_S4_IN_LOGIN",
 208         "CS_S5_LOGGED_IN",
 209         "CS_S6_IN_LOGOUT",
 210         "CS_S7_LOGOUT_REQ",
 211         "CS_S8_CLEANUP",
 212         "CS_S9_INIT_ERROR",
 213         "CS_S10_IN_CLEANUP",
 214         "CS_S11_COMPLETE",
 215         "CS_S12_ENABLE_DM",
 216         "CS_S9A_REJECTED",
 217         "CS_S9B_WAIT_SND_DONE",
 218         "CS_MAX_STATE"
 219 };
 220 #endif
 221 
 222 typedef enum {
 223         CT_NONE = 0,
 224         CT_RX_PDU,
 225         CT_TX_PDU
 226 } idm_pdu_event_type_t;
 227 
 228 typedef enum {
 229         CA_TX_PROTOCOL_ERROR,   /* Send "protocol error" to state machine */
 230         CA_RX_PROTOCOL_ERROR,   /* Send "protocol error" to state machine */
 231         CA_FORWARD,             /* State machine event and forward to client */
 232         CA_DROP                 /* Drop PDU */
 233 } idm_pdu_event_action_t;
 234 
 235 typedef struct {
 236         struct idm_conn_s       *iec_ic;
 237         idm_conn_event_t        iec_event;
 238         uintptr_t               iec_info;
 239         idm_pdu_event_type_t    iec_pdu_event_type;
 240         boolean_t               iec_pdu_forwarded;
 241 } idm_conn_event_ctx_t;
 
 | 
 
 
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  26  */
  27 #ifndef _IDM_CONN_SM_H_
  28 #define _IDM_CONN_SM_H_
  29 
  30 #ifdef  __cplusplus
  31 extern "C" {
  32 #endif
  33 
  34 
  35 /*
  36  * IDM connection state machine events.  Most events get generated internally
  37  * either by the state machine or by the IDM TX/RX code.  For example when IDM
  38  * receives a login request for a target connectionit will generate a
  39  * CE_LOGIN_RCV event.  Similarly when the target sends a successful login
  40  * response IDM generate a "CE_LOGIN_SUCCESS_SND" event.  The following
  41  * events are not detected on the TX/RX path and must be generated explicitly
  42  * by the client when appropriate:
  43  *
  44  * CE_LOGOUT_OTHER_CONN_RCV
  45  * CE_ASYNC_DROP_CONN_RCV   (Only because the message may be received on
 
 203 static const char *idm_cs_name[CS_MAX_STATE+1] = {
 204         "CS_S0_UNDEFINED",
 205         "CS_S1_FREE",
 206         "CS_S2_XPT_WAIT",
 207         "CS_S3_XPT_UP",
 208         "CS_S4_IN_LOGIN",
 209         "CS_S5_LOGGED_IN",
 210         "CS_S6_IN_LOGOUT",
 211         "CS_S7_LOGOUT_REQ",
 212         "CS_S8_CLEANUP",
 213         "CS_S9_INIT_ERROR",
 214         "CS_S10_IN_CLEANUP",
 215         "CS_S11_COMPLETE",
 216         "CS_S12_ENABLE_DM",
 217         "CS_S9A_REJECTED",
 218         "CS_S9B_WAIT_SND_DONE",
 219         "CS_MAX_STATE"
 220 };
 221 #endif
 222 
 223 /*
 224  * Currently the state machine has a condition where idm_login_timeout() is
 225  * left active after the connection has been closed. This causes the system
 226  * to panic when idm_login_timeout() modifies the freed memory. In an attempt
 227  * to isolate and find this issue special attention is being placed on
 228  * the ic_state_timeout value. After each untimeout call the value will now
 229  * be cleared. Just before the value is set the code will check for 0 and
 230  * display an error. One final change is being done in idm_conn_sm_fini() which
 231  * if ic_state_machine is not 0, an error message will be displayed and
 232  * untimeout() called. That should prevent customer sites from seeing the
 233  * panic. The code also calls ASSERT(0) which should cause a panic during
 234  * system test.
 235  */
 236 #define IDM_SM_TIMER_CHECK(ic) \
 237         if (ic->ic_state_timeout) { \
 238                 cmn_err(CE_WARN, "%s: existing timeout still set. " \
 239                     "state: %s, last: %s\n", __func__, \
 240                     idm_cs_name[ic->ic_state], \
 241                     idm_cs_name[ic->ic_last_state]); \
 242                 ASSERT(0); \
 243         }
 244 
 245 #define IDM_SM_TIMER_CLEAR(ic) \
 246         (void) untimeout(ic->ic_state_timeout); \
 247         ic->ic_state_timeout = 0;
 248 
 249 typedef enum {
 250         CT_NONE = 0,
 251         CT_RX_PDU,
 252         CT_TX_PDU
 253 } idm_pdu_event_type_t;
 254 
 255 typedef enum {
 256         CA_TX_PROTOCOL_ERROR,   /* Send "protocol error" to state machine */
 257         CA_RX_PROTOCOL_ERROR,   /* Send "protocol error" to state machine */
 258         CA_FORWARD,             /* State machine event and forward to client */
 259         CA_DROP                 /* Drop PDU */
 260 } idm_pdu_event_action_t;
 261 
 262 typedef struct {
 263         struct idm_conn_s       *iec_ic;
 264         idm_conn_event_t        iec_event;
 265         uintptr_t               iec_info;
 266         idm_pdu_event_type_t    iec_pdu_event_type;
 267         boolean_t               iec_pdu_forwarded;
 268 } idm_conn_event_ctx_t;
 
 |