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 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _ISCSI_THREAD_H 27 #define _ISCSI_THREAD_H 28 29 /* 30 * Block comment which describes the contents of this file. 31 */ 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 #include <sys/types.h> 38 #include <sys/ddi.h> 39 #include <sys/sunddi.h> 40 41 #define SIG_ISCSI_THREAD 0x54485244 42 43 #define ISCSI_TH_MAX_NAME_LEN 32 44 45 #define ISCSI_THREAD_SIGNAL_KILL 0x00000001 46 #define ISCSI_THREAD_SIGNAL_WAKEUP 0x00000002 47 48 #define ISCSI_THREAD_STATE_STOPPED 0x00000001 49 #define ISCSI_THREAD_STATE_STOPPING 0x00000002 50 #define ISCSI_THREAD_STATE_STARTED 0x00000004 51 #define ISCSI_THREAD_STATE_STARTING 0x00000008 52 #define ISCSI_THREAD_STATE_DESTROYING 0x00000010 53 54 struct _iscsi_thread; 55 56 typedef void (*iscsi_thread_ep_t)(struct _iscsi_thread *, void *); 57 58 typedef struct _iscsi_thread { 59 uint32_t signature; 60 uint32_t state; 61 ddi_taskq_t *tq; 62 iscsi_thread_ep_t entry_point; 63 void *arg; 64 dev_info_t *dip; 65 boolean_t running; 66 struct { 67 uint32_t bitmap; 68 kmutex_t mtx; 69 kcondvar_t cdv; 70 } sign; 71 struct { 72 kmutex_t mtx; 73 } mgnt; 74 } iscsi_thread_t; 75 76 iscsi_thread_t * 77 iscsi_thread_create( 78 dev_info_t *dip, 79 char *name, 80 iscsi_thread_ep_t entry_point, 81 void *arg 82 ); 83 84 void 85 iscsi_thread_destroy( 86 iscsi_thread_t *thread 87 ); 88 89 boolean_t 90 iscsi_thread_start( 91 iscsi_thread_t *thread 92 ); 93 94 boolean_t 95 iscsi_thread_stop( 96 iscsi_thread_t *thread 97 ); 98 99 void 100 iscsi_thread_send_kill( 101 iscsi_thread_t *thread 102 ); 103 104 void 105 iscsi_thread_send_wakeup( 106 iscsi_thread_t *thread 107 ); 108 109 int 110 iscsi_thread_wait( 111 iscsi_thread_t *thread, 112 clock_t timeout 113 ); 114 115 uint32_t 116 iscsi_thread_check_signals( 117 iscsi_thread_t *thread 118 ); 119 120 #ifdef __cplusplus 121 } 122 #endif 123 124 #endif /* _ISCSI_THREAD_H */ 125