1fcf3ce44SJohn Forte /* 2fcf3ce44SJohn Forte * CDDL HEADER START 3fcf3ce44SJohn Forte * 4fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the 5fcf3ce44SJohn Forte * Common Development and Distribution License (the "License"). 6fcf3ce44SJohn Forte * You may not use this file except in compliance with the License. 7fcf3ce44SJohn Forte * 8fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing. 10fcf3ce44SJohn Forte * See the License for the specific language governing permissions 11fcf3ce44SJohn Forte * and limitations under the License. 12fcf3ce44SJohn Forte * 13fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each 14fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the 16fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying 17fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner] 18fcf3ce44SJohn Forte * 19fcf3ce44SJohn Forte * CDDL HEADER END 20fcf3ce44SJohn Forte */ 21fcf3ce44SJohn Forte /* 22*49311b35SJack Meng * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23fcf3ce44SJohn Forte * Use is subject to license terms. 24fcf3ce44SJohn Forte */ 25fcf3ce44SJohn Forte 26fcf3ce44SJohn Forte #ifndef _ISCSI_THREAD_H 27fcf3ce44SJohn Forte #define _ISCSI_THREAD_H 28fcf3ce44SJohn Forte 29fcf3ce44SJohn Forte /* 30fcf3ce44SJohn Forte * Block comment which describes the contents of this file. 31fcf3ce44SJohn Forte */ 32fcf3ce44SJohn Forte 33fcf3ce44SJohn Forte #ifdef __cplusplus 34fcf3ce44SJohn Forte extern "C" { 35fcf3ce44SJohn Forte #endif 36fcf3ce44SJohn Forte 37fcf3ce44SJohn Forte #include <sys/types.h> 38fcf3ce44SJohn Forte #include <sys/ddi.h> 39fcf3ce44SJohn Forte #include <sys/sunddi.h> 40fcf3ce44SJohn Forte 41fcf3ce44SJohn Forte #define SIG_ISCSI_THREAD 0x54485244 42fcf3ce44SJohn Forte 43fcf3ce44SJohn Forte #define ISCSI_TH_MAX_NAME_LEN 32 44fcf3ce44SJohn Forte 45fcf3ce44SJohn Forte #define ISCSI_THREAD_SIGNAL_KILL 0x00000001 46fcf3ce44SJohn Forte #define ISCSI_THREAD_SIGNAL_WAKEUP 0x00000002 47fcf3ce44SJohn Forte 48fcf3ce44SJohn Forte #define ISCSI_THREAD_STATE_STOPPED 0x00000001 49fcf3ce44SJohn Forte #define ISCSI_THREAD_STATE_STOPPING 0x00000002 50fcf3ce44SJohn Forte #define ISCSI_THREAD_STATE_STARTED 0x00000004 51fcf3ce44SJohn Forte #define ISCSI_THREAD_STATE_STARTING 0x00000008 52fcf3ce44SJohn Forte #define ISCSI_THREAD_STATE_DESTROYING 0x00000010 53fcf3ce44SJohn Forte 54fcf3ce44SJohn Forte struct _iscsi_thread; 55fcf3ce44SJohn Forte 56fcf3ce44SJohn Forte typedef void (*iscsi_thread_ep_t)(struct _iscsi_thread *, void *); 57fcf3ce44SJohn Forte 58fcf3ce44SJohn Forte typedef struct _iscsi_thread { 59fcf3ce44SJohn Forte uint32_t signature; 60fcf3ce44SJohn Forte uint32_t state; 61fcf3ce44SJohn Forte ddi_taskq_t *tq; 62fcf3ce44SJohn Forte iscsi_thread_ep_t entry_point; 63fcf3ce44SJohn Forte void *arg; 64fcf3ce44SJohn Forte dev_info_t *dip; 65fcf3ce44SJohn Forte struct { 66fcf3ce44SJohn Forte uint32_t bitmap; 67fcf3ce44SJohn Forte kmutex_t mtx; 68fcf3ce44SJohn Forte kcondvar_t cdv; 69fcf3ce44SJohn Forte } sign; 70fcf3ce44SJohn Forte struct { 71fcf3ce44SJohn Forte kmutex_t mtx; 72fcf3ce44SJohn Forte } mgnt; 73fcf3ce44SJohn Forte } iscsi_thread_t; 74fcf3ce44SJohn Forte 75fcf3ce44SJohn Forte iscsi_thread_t * 76fcf3ce44SJohn Forte iscsi_thread_create( 77fcf3ce44SJohn Forte dev_info_t *dip, 78fcf3ce44SJohn Forte char *name, 79fcf3ce44SJohn Forte iscsi_thread_ep_t entry_point, 80fcf3ce44SJohn Forte void *arg 81fcf3ce44SJohn Forte ); 82fcf3ce44SJohn Forte 83fcf3ce44SJohn Forte void 84fcf3ce44SJohn Forte iscsi_thread_destroy( 85fcf3ce44SJohn Forte iscsi_thread_t *thread 86fcf3ce44SJohn Forte ); 87fcf3ce44SJohn Forte 88fcf3ce44SJohn Forte boolean_t 89fcf3ce44SJohn Forte iscsi_thread_start( 90fcf3ce44SJohn Forte iscsi_thread_t *thread 91fcf3ce44SJohn Forte ); 92fcf3ce44SJohn Forte 93fcf3ce44SJohn Forte boolean_t 94fcf3ce44SJohn Forte iscsi_thread_stop( 95fcf3ce44SJohn Forte iscsi_thread_t *thread 96fcf3ce44SJohn Forte ); 97fcf3ce44SJohn Forte 98fcf3ce44SJohn Forte void 99fcf3ce44SJohn Forte iscsi_thread_send_kill( 100fcf3ce44SJohn Forte iscsi_thread_t *thread 101fcf3ce44SJohn Forte ); 102fcf3ce44SJohn Forte 103*49311b35SJack Meng boolean_t 104fcf3ce44SJohn Forte iscsi_thread_send_wakeup( 105fcf3ce44SJohn Forte iscsi_thread_t *thread 106fcf3ce44SJohn Forte ); 107fcf3ce44SJohn Forte 108fcf3ce44SJohn Forte int 109fcf3ce44SJohn Forte iscsi_thread_wait( 110fcf3ce44SJohn Forte iscsi_thread_t *thread, 111fcf3ce44SJohn Forte clock_t timeout 112fcf3ce44SJohn Forte ); 113fcf3ce44SJohn Forte 114fcf3ce44SJohn Forte uint32_t 115fcf3ce44SJohn Forte iscsi_thread_check_signals( 116fcf3ce44SJohn Forte iscsi_thread_t *thread 117fcf3ce44SJohn Forte ); 118fcf3ce44SJohn Forte 119fcf3ce44SJohn Forte #ifdef __cplusplus 120fcf3ce44SJohn Forte } 121fcf3ce44SJohn Forte #endif 122fcf3ce44SJohn Forte 123fcf3ce44SJohn Forte #endif /* _ISCSI_THREAD_H */ 124