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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2013 by Delphix. All rights reserved.
25 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
26 */
27
28 #include <sys/cpuvar.h>
29 #include <sys/ddi.h>
30 #include <sys/sunddi.h>
31 #include <sys/modctl.h>
32 #include <sys/socket.h>
33 #include <sys/strsubr.h>
34 #include <sys/note.h>
35 #include <sys/sdt.h>
36
37 #define IDM_CONN_SM_STRINGS
38 #define IDM_CN_NOTIFY_STRINGS
39 #include <sys/idm/idm.h>
40
41 boolean_t idm_sm_logging = B_FALSE;
42
43 extern idm_global_t idm; /* Global state */
44
45 static void
1226 break;
1227 case CS_S6_IN_LOGOUT:
1228 break;
1229 case CS_S7_LOGOUT_REQ:
1230 /* Start logout timer for target connections */
1231 if (IDM_CONN_ISTGT(ic)) {
1232 IDM_SM_TIMER_CHECK(ic);
1233 ic->ic_state_timeout = timeout(idm_logout_req_timeout,
1234 ic, drv_usectohz(IDM_LOGOUT_SECONDS*1000000));
1235 }
1236 break;
1237 case CS_S8_CLEANUP:
1238 /* Close connection (if it's not already closed) */
1239 if (IDM_CONN_ISTGT(ic)) {
1240 ic->ic_transport_ops->it_tgt_conn_disconnect(ic);
1241 } else {
1242 ic->ic_transport_ops->it_ini_conn_disconnect(ic);
1243 }
1244
1245 /* Stop executing active tasks */
1246 idm_task_abort(ic, NULL, AT_INTERNAL_SUSPEND);
1247
1248 /* Start logout timer */
1249 IDM_SM_TIMER_CHECK(ic);
1250 ic->ic_state_timeout = timeout(idm_cleanup_timeout, ic,
1251 drv_usectohz(IDM_CLEANUP_SECONDS*1000000));
1252 break;
1253 case CS_S10_IN_CLEANUP:
1254 break;
1255 case CS_S9A_REJECTED:
1256 /*
1257 * We never finished establishing the connection so no
1258 * disconnect. No client notifications because the client
1259 * rejected the connection.
1260 */
1261 idm_refcnt_async_wait_ref(&ic->ic_refcnt,
1262 &idm_conn_reject_unref);
1263 break;
1264 case CS_S9B_WAIT_SND_DONE:
1265 break;
1266 case CS_S9_INIT_ERROR:
1282 }
1283 }
1284 /*FALLTHROUGH*/
1285 case CS_S11_COMPLETE:
1286 /*
1287 * No more traffic on this connection. If this is an
1288 * initiator connection and we weren't connected yet
1289 * then don't send the "connect lost" event.
1290 * It's useful to the initiator to know whether we were
1291 * logging in at the time so send that information in the
1292 * data field.
1293 */
1294 if (IDM_CONN_ISTGT(ic) ||
1295 ((ic->ic_last_state != CS_S1_FREE) &&
1296 (ic->ic_last_state != CS_S2_XPT_WAIT))) {
1297 (void) idm_notify_client(ic, CN_CONNECT_LOST,
1298 (uintptr_t)(ic->ic_last_state == CS_S4_IN_LOGIN));
1299 }
1300
1301 /* Abort all tasks */
1302 idm_task_abort(ic, NULL, AT_INTERNAL_ABORT);
1303
1304 /*
1305 * Handle terminal state actions on the global taskq so
1306 * we can clean up all the connection resources from
1307 * a separate thread context.
1308 */
1309 idm_refcnt_async_wait_ref(&ic->ic_refcnt, &idm_conn_unref);
1310 break;
1311 case CS_S12_ENABLE_DM:
1312
1313 /*
1314 * The Enable DM state indicates the initiator to initiate
1315 * the hello sequence and the target to get ready to accept
1316 * the iSER Hello Message.
1317 */
1318 idm_status = (IDM_CONN_ISINI(ic)) ?
1319 ic->ic_transport_ops->it_ini_enable_datamover(ic) :
1320 ic->ic_transport_ops->it_tgt_enable_datamover(ic);
1321
1322 if (idm_status == IDM_STATUS_SUCCESS) {
|
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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2013 by Delphix. All rights reserved.
25 * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
26 */
27
28 #include <sys/cpuvar.h>
29 #include <sys/ddi.h>
30 #include <sys/sunddi.h>
31 #include <sys/modctl.h>
32 #include <sys/socket.h>
33 #include <sys/strsubr.h>
34 #include <sys/note.h>
35 #include <sys/sdt.h>
36
37 #define IDM_CONN_SM_STRINGS
38 #define IDM_CN_NOTIFY_STRINGS
39 #include <sys/idm/idm.h>
40
41 boolean_t idm_sm_logging = B_FALSE;
42
43 extern idm_global_t idm; /* Global state */
44
45 static void
1226 break;
1227 case CS_S6_IN_LOGOUT:
1228 break;
1229 case CS_S7_LOGOUT_REQ:
1230 /* Start logout timer for target connections */
1231 if (IDM_CONN_ISTGT(ic)) {
1232 IDM_SM_TIMER_CHECK(ic);
1233 ic->ic_state_timeout = timeout(idm_logout_req_timeout,
1234 ic, drv_usectohz(IDM_LOGOUT_SECONDS*1000000));
1235 }
1236 break;
1237 case CS_S8_CLEANUP:
1238 /* Close connection (if it's not already closed) */
1239 if (IDM_CONN_ISTGT(ic)) {
1240 ic->ic_transport_ops->it_tgt_conn_disconnect(ic);
1241 } else {
1242 ic->ic_transport_ops->it_ini_conn_disconnect(ic);
1243 }
1244
1245 /* Stop executing active tasks */
1246 (void) idm_task_abort(ic, NULL, AT_INTERNAL_SUSPEND);
1247
1248 /* Start logout timer */
1249 IDM_SM_TIMER_CHECK(ic);
1250 ic->ic_state_timeout = timeout(idm_cleanup_timeout, ic,
1251 drv_usectohz(IDM_CLEANUP_SECONDS*1000000));
1252 break;
1253 case CS_S10_IN_CLEANUP:
1254 break;
1255 case CS_S9A_REJECTED:
1256 /*
1257 * We never finished establishing the connection so no
1258 * disconnect. No client notifications because the client
1259 * rejected the connection.
1260 */
1261 idm_refcnt_async_wait_ref(&ic->ic_refcnt,
1262 &idm_conn_reject_unref);
1263 break;
1264 case CS_S9B_WAIT_SND_DONE:
1265 break;
1266 case CS_S9_INIT_ERROR:
1282 }
1283 }
1284 /*FALLTHROUGH*/
1285 case CS_S11_COMPLETE:
1286 /*
1287 * No more traffic on this connection. If this is an
1288 * initiator connection and we weren't connected yet
1289 * then don't send the "connect lost" event.
1290 * It's useful to the initiator to know whether we were
1291 * logging in at the time so send that information in the
1292 * data field.
1293 */
1294 if (IDM_CONN_ISTGT(ic) ||
1295 ((ic->ic_last_state != CS_S1_FREE) &&
1296 (ic->ic_last_state != CS_S2_XPT_WAIT))) {
1297 (void) idm_notify_client(ic, CN_CONNECT_LOST,
1298 (uintptr_t)(ic->ic_last_state == CS_S4_IN_LOGIN));
1299 }
1300
1301 /* Abort all tasks */
1302 (void) idm_task_abort(ic, NULL, AT_INTERNAL_ABORT);
1303
1304 /*
1305 * Handle terminal state actions on the global taskq so
1306 * we can clean up all the connection resources from
1307 * a separate thread context.
1308 */
1309 idm_refcnt_async_wait_ref(&ic->ic_refcnt, &idm_conn_unref);
1310 break;
1311 case CS_S12_ENABLE_DM:
1312
1313 /*
1314 * The Enable DM state indicates the initiator to initiate
1315 * the hello sequence and the target to get ready to accept
1316 * the iSER Hello Message.
1317 */
1318 idm_status = (IDM_CONN_ISINI(ic)) ?
1319 ic->ic_transport_ops->it_ini_enable_datamover(ic) :
1320 ic->ic_transport_ops->it_tgt_enable_datamover(ic);
1321
1322 if (idm_status == IDM_STATUS_SUCCESS) {
|