1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
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 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2013, Nexenta Systems, Inc. All rights reserved.
24 */
25
26 #include <sys/cpuvar.h>
27 #include <sys/types.h>
28 #include <sys/conf.h>
29 #include <sys/stat.h>
30 #include <sys/file.h>
31 #include <sys/ddi.h>
32 #include <sys/sunddi.h>
33 #include <sys/modctl.h>
34 #include <sys/sysmacros.h>
35 #include <sys/nvpair.h>
36 #include <sys/door.h>
37 #include <sys/sdt.h>
38
39 #include <sys/stmf.h>
40 #include <sys/stmf_ioctl.h>
1231 pppt_task_free(pppt_task_t *ptask)
1232 {
1233 mutex_enter(&ptask->pt_mutex);
1234 ASSERT(ptask->pt_refcnt == 0);
1235 mutex_destroy(&ptask->pt_mutex);
1236 kmem_free(ptask, sizeof (pppt_task_t) + sizeof (pppt_buf_t) +
1237 sizeof (stmf_data_buf_t));
1238 }
1239
1240 pppt_status_t
1241 pppt_task_start(pppt_task_t *ptask)
1242 {
1243 avl_index_t where;
1244
1245 ASSERT(ptask->pt_state == PTS_INIT);
1246
1247 mutex_enter(&ptask->pt_sess->ps_mutex);
1248 mutex_enter(&ptask->pt_mutex);
1249 if (avl_find(&ptask->pt_sess->ps_task_list, ptask, &where) == NULL) {
1250 pppt_task_update_state(ptask, PTS_ACTIVE);
1251 /* Manually increment refcnt, sincd we hold the mutex... */
1252 ptask->pt_refcnt++;
1253 avl_insert(&ptask->pt_sess->ps_task_list, ptask, where);
1254 mutex_exit(&ptask->pt_mutex);
1255 mutex_exit(&ptask->pt_sess->ps_mutex);
1256 return (PPPT_STATUS_SUCCESS);
1257 }
1258 mutex_exit(&ptask->pt_mutex);
1259 mutex_exit(&ptask->pt_sess->ps_mutex);
1260
1261 return (PPPT_STATUS_FAIL);
1262 }
1263
1264 pppt_status_t
1265 pppt_task_done(pppt_task_t *ptask)
1266 {
1267 pppt_status_t pppt_status = PPPT_STATUS_SUCCESS;
1268 boolean_t remove = B_FALSE;
1269
1270 mutex_enter(&ptask->pt_mutex);
1271
|
1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
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) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2013, Nexenta Systems, Inc. All rights reserved.
25 */
26
27 #include <sys/cpuvar.h>
28 #include <sys/types.h>
29 #include <sys/conf.h>
30 #include <sys/stat.h>
31 #include <sys/file.h>
32 #include <sys/ddi.h>
33 #include <sys/sunddi.h>
34 #include <sys/modctl.h>
35 #include <sys/sysmacros.h>
36 #include <sys/nvpair.h>
37 #include <sys/door.h>
38 #include <sys/sdt.h>
39
40 #include <sys/stmf.h>
41 #include <sys/stmf_ioctl.h>
1232 pppt_task_free(pppt_task_t *ptask)
1233 {
1234 mutex_enter(&ptask->pt_mutex);
1235 ASSERT(ptask->pt_refcnt == 0);
1236 mutex_destroy(&ptask->pt_mutex);
1237 kmem_free(ptask, sizeof (pppt_task_t) + sizeof (pppt_buf_t) +
1238 sizeof (stmf_data_buf_t));
1239 }
1240
1241 pppt_status_t
1242 pppt_task_start(pppt_task_t *ptask)
1243 {
1244 avl_index_t where;
1245
1246 ASSERT(ptask->pt_state == PTS_INIT);
1247
1248 mutex_enter(&ptask->pt_sess->ps_mutex);
1249 mutex_enter(&ptask->pt_mutex);
1250 if (avl_find(&ptask->pt_sess->ps_task_list, ptask, &where) == NULL) {
1251 pppt_task_update_state(ptask, PTS_ACTIVE);
1252 /* Manually increment refcnt, since we hold the mutex... */
1253 ptask->pt_refcnt++;
1254 avl_insert(&ptask->pt_sess->ps_task_list, ptask, where);
1255 mutex_exit(&ptask->pt_mutex);
1256 mutex_exit(&ptask->pt_sess->ps_mutex);
1257 return (PPPT_STATUS_SUCCESS);
1258 }
1259 mutex_exit(&ptask->pt_mutex);
1260 mutex_exit(&ptask->pt_sess->ps_mutex);
1261
1262 return (PPPT_STATUS_FAIL);
1263 }
1264
1265 pppt_status_t
1266 pppt_task_done(pppt_task_t *ptask)
1267 {
1268 pppt_status_t pppt_status = PPPT_STATUS_SUCCESS;
1269 boolean_t remove = B_FALSE;
1270
1271 mutex_enter(&ptask->pt_mutex);
1272
|