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 2009 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 struct { 66 uint32_t bitmap; 67 kmutex_t mtx; 68 kcondvar_t cdv; 69 } sign; 70 struct { 71 kmutex_t mtx; 72 } mgnt; 73 } iscsi_thread_t; 74 75 iscsi_thread_t * 76 iscsi_thread_create( 77 dev_info_t *dip, 78 char *name, 79 iscsi_thread_ep_t entry_point, 80 void *arg 81 ); 82 83 void 84 iscsi_thread_destroy( 85 iscsi_thread_t *thread 86 ); 87 88 boolean_t 89 iscsi_thread_start( 90 iscsi_thread_t *thread 91 ); 92 93 boolean_t 94 iscsi_thread_stop( 95 iscsi_thread_t *thread 96 ); 97 98 void 99 iscsi_thread_send_kill( 100 iscsi_thread_t *thread 101 ); 102 103 boolean_t 104 iscsi_thread_send_wakeup( 105 iscsi_thread_t *thread 106 ); 107 108 int 109 iscsi_thread_wait( 110 iscsi_thread_t *thread, 111 clock_t timeout 112 ); 113 114 uint32_t 115 iscsi_thread_check_signals( 116 iscsi_thread_t *thread 117 ); 118 119 #ifdef __cplusplus 120 } 121 #endif 122 123 #endif /* _ISCSI_THREAD_H */ 124