xref: /titanic_51/usr/src/uts/common/sys/fibre-channel/fca/emlxs/emlxs_events.h (revision 8f23e9fa8abcb5857661066b954e63400d589b65)
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_EVENTS_H
28 #define	_EMLXS_EVENTS_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 extern void emlxs_null_func();
35 
36 #ifdef DEF_EVENT_STRUCT
37 
38 #define	DEFINE_EVT(_name, _label, _mask, _timeout, _destroy) \
39 	extern void _destroy(); \
40 	emlxs_event_t _name = {_mask, _label, _timeout, _destroy};
41 
42 #else
43 
44 #define	DEFINE_EVT(_name, _label, _mask, _timeout, _destroy) \
45 	extern void _destroy(); \
46 	extern emlxs_event_t _name;
47 
48 #endif	/* DEF_EVENT_STRUCT */
49 
50 
51 /* Event Mask Bits */
52 #define	EVT_LINK		0x00000001	/* FC_REG_LINK_EVENT */
53 #define	EVT_RSCN		0x00000002	/* FC_REG_RSCN_EVENT */
54 #define	EVT_CT			0x00000004	/* FC_REG_CT_EVENT   */
55 #define	EVT_MPULSE		0x00000008	/* FC_REG_MULTIPULSE_EVENT */
56 #define	EVT_DUMP		0x00000010	/* FC_REG_DUMP_EVENT */
57 #define	EVT_TEMP		0x00000020	/* FC_REG_TEMP_EVENT */
58 #define	EVT_VPORTRSCN		0x00000040	/* FC_REG_VPORTRSCN_EVENT */
59 #define	EVT_ASYNC		0x00000080	/* FC_REG_ASYNC_EVENT */
60 
61 #ifdef SAN_DIAG_SUPPORT
62 #define	EVT_SD_ELS		0x00001000	/* FC_REG_SD_ELS_EVENT */
63 #define	EVT_SD_FABRIC		0x00002000	/* FC_REG_SD_FABRIC_EVENT */
64 #define	EVT_SD_SCSI		0x00004000	/* FC_REG_SD_SCSI_EVENT */
65 #define	EVT_SD_BOARD		0x00008000	/* FC_REG_SD_BOARD_EVENT */
66 #endif /* SAN_DIAG_SUPPORT */
67 
68 #define	EVT_FCOE		0x80000000	/* FC_REG_FCOE_EVENT */
69 
70 
71 typedef struct emlxs_event
72 {
73 	uint32_t	mask;
74 	char		label[64];
75 	uint32_t 	timeout;
76 	void		(*destroy)();
77 
78 } emlxs_event_t;
79 
80 
81 #define	EMLXS_EVENT_PERIOD	5
82 #define	EVT_TIMEOUT_DEFAULT	60
83 #define	EVT_TIMEOUT_NEVER	0
84 #define	EVT_DESTROY_DEFAULT	emlxs_null_func
85 
86 
87 /* EVENT defines */
88 DEFINE_EVT(emlxs_link_event, \
89 	"LINK", \
90 	EVT_LINK,
91 	EVT_TIMEOUT_DEFAULT,
92 	EVT_DESTROY_DEFAULT)
93 
94 DEFINE_EVT(emlxs_rscn_event, \
95 	"RSCN", \
96 	EVT_RSCN,
97 	EVT_TIMEOUT_DEFAULT,
98 	EVT_DESTROY_DEFAULT)
99 
100 DEFINE_EVT(emlxs_vportrscn_event, \
101 	"VPORT RSCN", \
102 	EVT_VPORTRSCN,
103 	EVT_TIMEOUT_DEFAULT,
104 	EVT_DESTROY_DEFAULT)
105 
106 DEFINE_EVT(emlxs_ct_event, \
107 	"CT", \
108 	EVT_CT,
109 	EVT_TIMEOUT_DEFAULT,
110 	emlxs_ct_event_destroy)
111 
112 DEFINE_EVT(emlxs_dump_event, \
113 	"DUMP", \
114 	EVT_DUMP,
115 	EVT_TIMEOUT_DEFAULT,
116 	EVT_DESTROY_DEFAULT)
117 
118 DEFINE_EVT(emlxs_temp_event, \
119 	"TEMP", \
120 	EVT_TEMP,
121 	EVT_TIMEOUT_DEFAULT,
122 	EVT_DESTROY_DEFAULT)
123 
124 DEFINE_EVT(emlxs_fcoe_event, \
125 	"FCOE", \
126 	EVT_FCOE,
127 	EVT_TIMEOUT_DEFAULT,
128 	EVT_DESTROY_DEFAULT)
129 
130 DEFINE_EVT(emlxs_async_event, \
131 	"ASYNC", \
132 	EVT_ASYNC,
133 	EVT_TIMEOUT_DEFAULT,
134 	EVT_DESTROY_DEFAULT)
135 
136 #ifdef SAN_DIAG_SUPPORT
137 DEFINE_EVT(emlxs_sd_els_event, \
138 	"SD_ELS", \
139 	EVT_SD_ELS,
140 	EVT_TIMEOUT_DEFAULT,
141 	EVT_DESTROY_DEFAULT)
142 
143 DEFINE_EVT(emlxs_sd_fabric_event, \
144 	"SD_FC", \
145 	EVT_SD_FABRIC,
146 	EVT_TIMEOUT_DEFAULT,
147 	EVT_DESTROY_DEFAULT)
148 
149 DEFINE_EVT(emlxs_sd_scsi_event, \
150 	"SD_SCSI", \
151 	EVT_SD_SCSI,
152 	EVT_TIMEOUT_DEFAULT,
153 	EVT_DESTROY_DEFAULT)
154 
155 DEFINE_EVT(emlxs_sd_board_event, \
156 	"SD_BOARD", \
157 	EVT_SD_BOARD,
158 	EVT_TIMEOUT_DEFAULT,
159 	EVT_DESTROY_DEFAULT)
160 #endif /* SAN_DIAG_SUPPORT */
161 
162 #define	MAX_LOG_INFO_LENGTH	96
163 
164 typedef struct emlxs_event_entry
165 {
166 	struct emlxs_event_entry	*next;
167 	struct emlxs_event_entry	*prev;
168 
169 	uint32_t	id;
170 	uint32_t	timestamp;
171 	uint32_t	timer;
172 
173 	emlxs_event_t	*evt;
174 
175 	void *port;
176 
177 	void		*bp;			/* Context buffer */
178 						/* pointer */
179 	uint32_t	size;			/* Context buffer */
180 						/* size */
181 	uint32_t	flag;
182 #define	EMLXS_DFC_EVENT_DONE	0x00000001
183 #define	EMLXS_SD_EVENT_DONE	0x00000002
184 
185 } emlxs_event_entry_t;
186 
187 
188 typedef struct emlxs_event_queue
189 {
190 	kmutex_t		lock;
191 	kcondvar_t		lock_cv;
192 
193 	uint32_t		last_id[32]; /* per event */
194 	uint32_t		next_id;
195 	uint32_t		count;
196 
197 	emlxs_event_entry_t	*first;
198 	emlxs_event_entry_t	*last;
199 
200 } emlxs_event_queue_t;
201 
202 #ifdef	__cplusplus
203 }
204 #endif
205 
206 #endif	/* _EMLXS_EVENTS_H */
207