xref: /illumos-gate/usr/src/uts/common/sys/fibre-channel/fca/emlxs/emlxs_thread.h (revision a724c049b7e0dd8612bc3aaec84e96e80511050d)
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 2008 Emulex.  All rights reserved.
24  * Use is subject to License terms.
25  */
26 
27 
28 #ifndef _EMLXS_THREAD_H
29 #define	_EMLXS_THREAD_H
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 
36 #define	EMLXS_MAX_TASKQ_THREADS    4
37 
38 typedef struct emlxs_thread {
39 	struct emlxs_hba *hba;
40 
41 	kthread_t *thread;
42 	uint32_t flags;
43 
44 	void (*func) (void *);
45 	void *arg1;
46 	void *arg2;
47 
48 	kmutex_t lock;
49 	kcondvar_t cv_flag;
50 
51 } emlxs_thread_t;
52 
53 
54 typedef struct emlxs_taskq_thread {
55 	struct emlxs_taskq_thread *next;
56 	struct emlxs_taskq *taskq;
57 
58 	kthread_t *thread;
59 	uint32_t flags;
60 
61 	void (*func) (void *);
62 	void *arg;
63 
64 	kmutex_t lock;
65 	kcondvar_t cv_flag;
66 
67 } emlxs_taskq_thread_t;
68 
69 
70 typedef struct emlxs_taskq {
71 	emlxs_taskq_thread_t thread_list[EMLXS_MAX_TASKQ_THREADS];
72 
73 	void *hba;
74 
75 	emlxs_taskq_thread_t *get_head;
76 	uint32_t get_count;
77 	uint32_t open;
78 	kmutex_t get_lock;
79 
80 	emlxs_taskq_thread_t *put_head;
81 	uint32_t put_count;
82 	kmutex_t put_lock;
83 
84 } emlxs_taskq_t;
85 
86 /* flags */
87 #define	EMLXS_THREAD_INITD	0x00000001
88 #define	EMLXS_THREAD_STARTED	0x00000002
89 #define	EMLXS_THREAD_ASLEEP	0x00000004
90 #define	EMLXS_THREAD_BUSY	0x00000008
91 #define	EMLXS_THREAD_KILLED	0x00000010
92 #define	EMLXS_THREAD_ENDED	0x00000020
93 #define	EMLXS_THREAD_TRIGGERED	0x80000000
94 
95 #ifdef	__cplusplus
96 }
97 #endif
98 
99 #endif	/* _EMLXS_THREAD_H */
100