xref: /illumos-gate/usr/src/uts/common/sys/fibre-channel/fca/emlxs/emlxs_msg.h (revision e44e85a7f9935f0428e188393e3da61b17e83884)
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 2009 Emulex.  All rights reserved.
24  * Use is subject to License terms.
25  */
26 
27 
28 #ifndef _EMLXS_MSG_H
29 #define	_EMLXS_MSG_H
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /* Define the actual driver messages */
36 #include <emlxs_messages.h>
37 
38 /* File identification numbers */
39 #define	EMLXS_MSG_DEF(_number)    static const uint32_t _FILENO_ = _number
40 #define	EMLXS_CLOCK_C		1
41 #define	EMLXS_DIAG_C		2
42 #define	EMLXS_DOWNLOAD_C	3
43 #define	EMLXS_ELS_C		4
44 #define	EMLXS_FCP_C		5
45 #define	EMLXS_HBA_C		6
46 #define	EMLXS_MBOX_C		7
47 #define	EMLXS_MEM_C		8
48 #define	EMLXS_NODE_C		9
49 #define	EMLXS_PKT_C		10
50 #define	EMLXS_SOLARIS_C		11
51 #define	EMLXS_MSG_C		12
52 #define	EMLXS_IP_C		13
53 #define	EMLXS_THREAD_C		14
54 #define	EMLXS_DFC_C		15
55 #define	EMLXS_DHCHAP_C		16
56 #define	EMLXS_FCT_C		17
57 #define	EMLXS_DUMP_C		18
58 #define	EMLXS_SLI_C		19
59 
60 
61 #define	EMLXS_CONTEXT		port, _FILENO_, __LINE__, 0, 0
62 #define	EMLXS_CONTEXT_BP	port, _FILENO_, __LINE__
63 
64 #define	EMLXS_MSGF		emlxs_msg_printf
65 
66 #ifdef EMLXS_DBG
67 #define	EMLXS_DEBUGF		emlxs_msg_printf
68 #else	/* EMLXS_DBG */
69 #define	EMLXS_DEBUGF
70 #endif	/* EMLXS_DBG */
71 
72 #define	MAX_LOG_INFO_LENGTH	96
73 
74 typedef struct emlxs_msg_entry
75 {
76 	uint32_t	id;				/* entry id  */
77 	clock_t		time;				/* timestamp */
78 
79 	emlxs_msg_t	*msg;				/* Msg pointer */
80 
81 	uint32_t	vpi;
82 	uint32_t	instance;			/* Adapter instance */
83 	uint32_t	fileno;				/* File number */
84 	uint32_t	line;				/* Line number */
85 
86 	void		*bp;				/* Context buffer */
87 							/* pointer */
88 	uint32_t	size;				/* Context buffer */
89 							/* size */
90 	uint32_t	flag;
91 #define	EMLX_EVENT_DONE	0x00000001			/* Data has been */
92 							/* retrieved */
93 
94 	char		buffer[MAX_LOG_INFO_LENGTH];	/* Additional info */
95 							/* buffer */
96 } emlxs_msg_entry_t;
97 
98 
99 typedef struct emlxs_msg_log
100 {
101 	kmutex_t		lock;
102 	kcondvar_t		lock_cv;	/* used for events */
103 
104 	clock_t			start_time;
105 	uint32_t		instance;
106 	uint32_t		flags;
107 
108 	uint32_t		size;		/* Maximum entries in */
109 						/* circular buffer */
110 	uint32_t		count;		/* Total number of entries */
111 						/* recorded */
112 	uint32_t		next;		/* Next index into circular */
113 						/* buffer */
114 
115 	uint32_t		repeat;		/* repeat counter */
116 
117 	uint32_t		event_id[32];	/* Last id logged for an */
118 						/* event */
119 
120 	emlxs_msg_entry_t	*entry;		/* pointer to entry buffer */
121 } emlxs_msg_log_t;
122 
123 #ifdef	__cplusplus
124 }
125 #endif
126 
127 #endif	/* _EMLXS_MSG_H */
128