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