xref: /titanic_50/usr/src/uts/sun4u/opl/sys/oplmsu/oplmsu.h (revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c)
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  * All Rights Reserved, Copyright (c) FUJITSU LIMITED 2006
23  */
24 
25 #ifndef _OPLMSU_H
26 #define	_OPLMSU_H
27 
28 #pragma ident	"%Z%%M%	%I%	%E% SMI"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* ack_flag */
35 #define	ACK_RES		0
36 #define	NAK_RES		-1
37 
38 /* active_flag */
39 #define	ACTIVE_RES	0
40 #define	NOT_ACTIVE_RES	-1
41 
42 /* undefined path number */
43 #define	UNDEFINED	-1
44 
45 /* sleep and wakeup control flag */
46 #define	CV_WAKEUP	0
47 #define	CV_SLEEP	1
48 
49 /* write/read control flag */
50 #define	MSU_WRITE_SIDE	0
51 #define	MSU_READ_SIDE	1
52 
53 /* message priority */
54 #define	MSU_HIGH	1
55 #define	MSU_NORM	0
56 
57 /* miscellaneous */
58 #define	SUCCESS		0
59 #define	FAILURE		-1
60 #if !defined(BUSY)	/* warning: macro redefined */
61 #define	BUSY		-2
62 #endif
63 
64 /* timeout interval */
65 #define	MSU_TM_500MS	500000	/* 500ms */
66 
67 /* XON/XOFF code */
68 #define	MSU_XON		0x11
69 #define	MSU_XOFF	0x13
70 #define	MSU_XON_4	(MSU_XON << 24|MSU_XON << 16|MSU_XON << 8|MSU_XON)
71 #define	MSU_XOFF_4	(MSU_XOFF << 24|MSU_XOFF << 16|MSU_XOFF << 8|MSU_XOFF)
72 
73 /* main path code used by MSU_CMD_START ioctl */
74 #define	MAINPATHCODE	0x1000
75 #define	MSU_OBP_CONSOLE	-2
76 
77 /* maximum number of minor device number */
78 #define	MAXDEVMINOR	256
79 
80 /* node mask */
81 #define	USER_NODE_MASK	0x00000000	/* user control node */
82 #define	META_NODE_MASK	0x00010000	/* meta control node */
83 
84 /* node_flag */
85 #define	MSU_NODE_USER		0	/* user control node */
86 #define	MSU_NODE_META		1	/* meta control node */
87 
88 /* node_flag check macro */
89 #define	MSU_NODE_TYPE(dev) \
90 	(((dev) & (META_NODE_MASK|USER_NODE_MASK)) >> 16)
91 
92 /* termio_flag */
93 #define	MSU_TIOS_TCSETS		1	/* TCSETS */
94 #define	MSU_TIOS_MSET		2	/* TIOCMSET */
95 #define	MSU_TIOS_PPS		3	/* TIOCSPPS */
96 #define	MSU_TIOS_WINSZP		4	/* TIOCSWINSZ */
97 #define	MSU_TIOS_SOFTCAR	5	/* TIOCSSOFTCAR */
98 #define	MSU_TIOS_END		6	/* termios end */
99 
100 /* binding name */
101 #define	MSU_CMUCH_FF		"pci10cf,138f"
102 #define	MSU_CMUCH_DC		"pci10cf,1390"
103 #ifdef DEBUG
104 #define	MSU_CMUCH_DBG		"pci108e,8000"
105 #endif
106 
107 /* tty-port# properties */
108 #define	MSU_TTY_PORT_PROP	"tty-port#"
109 
110 /* board# properties */
111 #define	MSU_BOARD_PROP		"board#"
112 
113 /*
114  * oplmsu command code
115  */
116 #define	MSU_CMD			('f' << 8)
117 #define	MSU_CMD_STOP		(MSU_CMD|0x14)
118 #define	MSU_CMD_START		(MSU_CMD|0x15)
119 #define	MSU_CMD_ACTIVE		(MSU_CMD|0x1a)
120 
121 #define	MSU_PATH_ALL		(-1)	/* path all instruction */
122 
123 /*
124  * oplmsu path status for status member on upper path info table
125  */
126 #define	MSU_PSTAT_EMPTY		0
127 #define	MSU_PSTAT_ACTIVE	1
128 #define	MSU_PSTAT_STANDBY	2
129 #define	MSU_PSTAT_STOP		3
130 #define	MSU_PSTAT_FAIL		4
131 #define	MSU_PSTAT_DISCON	5
132 #define	MSU_PSTAT_ENCAP		6
133 
134 /*
135  * oplmsu additional status for traditional_status member on
136  * upper path info table
137  */
138 #define	MSU_UNLINK	 0	/* initial state */
139 #define	MSU_EMPTY	 1	/* MSU_STAT_EMPTY(00) state */
140 #define	MSU_LINK_NU	 2	/* link state(no link ID, no upper path info) */
141 #define	MSU_SETID_NU	 3	/* set ID state(link ID, no upper path info) */
142 #define	MSU_MAKE_INST	 4	/* create instance node state */
143 #define	MSU_STOP	 5	/* MSU_STAT_STOP(03) state */
144 #define	MSU_WSTR_ACK	 6	/* wait ack/nak of MSU_CMD_START state */
145 #define	MSU_STANDBY	 7	/* MSU_STAT_STANDBY(02) state */
146 #define	MSU_WTCS_ACK	 8	/* wait ack/nak of TCSETS state */
147 #define	MSU_WTMS_ACK	 9	/* wait ack/nak of TIOCMSET state */
148 #define	MSU_WPPS_ACK	10	/* wait ack/nak of TIOCSPPS state */
149 #define	MSU_WWSZ_ACK	11	/* wait ack/nak of TIOCSWINSZ state */
150 #define	MSU_WCAR_ACK	12	/* wait ack/nak of TIOCSSOFTCAR state */
151 #define	MSU_ACTIVE	13	/* MSU_STAT_ACTIVE(01) state */
152 #define	MSU_WSTP_ACK	14	/* wait ack/nak of MSU_CMD_STOP state */
153 #define	MSU_FAIL	15	/* MSU_STAT_FAIL(04) state */
154 #define	MSU_WCHK_ACK	16	/* wait ack/nak of OPLMSUSELFTEST */
155 #define	MSU_SETID	17	/* set ID state(link ID, upper path info) */
156 #define	MSU_DISCON	18	/* MSU_STAT_DISCON(05) state */
157 #define	MSU_LINK	19	/* link state(no link ID, upper path info) */
158 #define	MSU_WPTH_CHG	20	/* wait ack/nak of OPLMSUPATHCHG state */
159 
160 /*
161  * oplmsu instance status  for inst_status member on
162  * upper instance info talbe
163  */
164 #define	INST_STAT_BUSY			-1	/* busy */
165 #define	INST_STAT_ONLINE		10	/* online */
166 #define	INST_STAT_OFFLINE		11	/* offline */
167 #define	INST_STAT_UNCONFIGURED		12	/* unconfigured */
168 
169 /*
170  * oplmsu lower path Info table ext status for ext member on
171  * lower path info table
172  */
173 #define	MSU_EXT_NOTUSED			-1	/* not used (default) */
174 #define	MSU_EXT_ACTIVE_CANDIDATE	-2	/* active path candidate by */
175 						/* MSU_CMD_START */
176 #define	MSU_EXT_VOID			-3	/* void status */
177 
178 /* oplmsu/su pathname size */
179 #define	MSU_PATHNAME_SIZE		128
180 
181 /* control block(path parameter) */
182 struct msu_path {
183 	int		num;		/* total number of paths */
184 	int		reserved;	/* reserved */
185 };
186 
187 /* control block(device parameter) */
188 struct msu_dev {
189 	dev_info_t	*dip;		/* pointer to dev_info_t */
190 };
191 
192 /* serial device control block */
193 typedef struct serial_devcb {
194 	dev_info_t	*dip;		/* pointer to dev_info_t */
195 	int		lsb;		/* LSB number */
196 } ser_devcb_t;
197 
198 /* serial device countrl block list */
199 typedef struct serial_devlist {
200 	struct serial_devlist	*next;
201 	dev_info_t		*dip;	/* pointer to dev_info_t */
202 } ser_devl_t;
203 
204 /* upper path table */
205 typedef struct upper_path_table {
206 	struct upper_path_table	*u_next;
207 	struct upper_path_table	*u_prev;
208 	struct lower_path_table	*lpath;
209 	int			path_no;
210 	int			reserved;
211 	int			status;
212 	int			prev_status;
213 	ulong_t			traditional_status;
214 	ser_devcb_t		ser_devcb;
215 } upath_t;
216 
217 /* lower path table */
218 typedef struct lower_path_table {
219 	struct lower_path_table	*l_next;
220 	struct lower_path_table	*l_prev;
221 	mblk_t			*first_lpri_hi;
222 	mblk_t			*last_lpri_hi;
223 	mblk_t			*hndl_mp;
224 	queue_t			*hndl_uqueue;
225 	queue_t			*lower_queue;
226 	queue_t			*uwq_queue;
227 	struct upper_instance_table	*uinst;
228 	char			*abt_char;
229 	struct buf_tbl		*rbuftbl;
230 	bufcall_id_t		rbuf_id;
231 	timeout_id_t		rtout_id;
232 	upath_t			*src_upath;
233 	long			status;
234 	int			path_no;
235 	int			link_id;
236 	int			uwq_flag;
237 	int			sw_flag;
238 	kcondvar_t		sw_cv;
239 } lpath_t;
240 
241 /* control table */
242 typedef struct control_table {
243 	struct control_table	*c_next;
244 	struct control_table	*c_prev;
245 	mblk_t			*first_upri_hi;
246 	mblk_t			*last_upri_hi;
247 	queue_t			*queue;
248 	queue_t			*lrq_queue;
249 	queue_t			*wait_queue;
250 	minor_t			minor;
251 	int			node_type;
252 	struct buf_tbl		*wbuftbl;
253 	bufcall_id_t		wbuf_id;
254 	timeout_id_t		wtout_id;
255 	int			lrq_flag;
256 	int			sleep_flag;
257 	kcondvar_t		cvp;
258 } ctrl_t;
259 
260 #define	MSU_MAX_ABTSLEN	24	/* maximum length for abort sequence */
261 
262 /* upper instance table */
263 typedef struct upper_instance_table {
264 	upath_t		*first_upath;
265 	upath_t		*last_upath;
266 	lpath_t		*first_lpath;
267 	lpath_t		*last_lpath;
268 	ctrl_t		*meta_ctrl;
269 	ctrl_t		*user_ctrl;
270 	queue_t		*lower_queue;
271 	dev_info_t	*msu_dip;
272 	int		inst_status;
273 	int		path_num;
274 	int		reserved[2];
275 	krwlock_t	lock;
276 	kmutex_t	u_lock;
277 	kmutex_t	l_lock;
278 	kmutex_t	c_lock;
279 	mblk_t		*tcsets_p;
280 	mblk_t		*tiocmset_p;
281 	mblk_t		*tiocspps_p;
282 	mblk_t		*tiocswinsz_p;
283 	mblk_t		*tiocssoftcar_p;
284 	char		abts[MSU_MAX_ABTSLEN];
285 } uinst_t;
286 
287 /* queue table for bufcall() and timeout() */
288 struct buf_tbl {
289 	queue_t	*q;
290 	int	rw_flag;
291 };
292 
293 
294 /* rwlock macro */
295 #define	OPLMSU_RWLOCK_UPGRADE() {				\
296 	if (rw_tryupgrade(&oplmsu_uinst->lock) == 0) {		\
297 		rw_exit(&oplmsu_uinst->lock);			\
298 		rw_enter(&oplmsu_uinst->lock, RW_WRITER);	\
299 	}							\
300 }
301 
302 #ifdef DEBUG
303 typedef struct tracedata {
304 	queue_t		*q;
305 	mblk_t		*mp;
306 	char		op[3];
307 	uchar_t		msg_type;
308 	int		pathno;
309 	int		msg_cmd;
310 	ulong_t		data;
311 } msu_trc_t;
312 
313 #define	MSU_TRC_USER	('u' << 24|'s' << 16|'e' << 8|'r')
314 #define	MSU_TRC_META	('m' << 24|'e' << 16|'t' << 8|'a')
315 
316 /* oplmsu_trace_on */
317 #define	MSU_TRACE_OFF	0
318 #define	MSU_TRACE_ON	1
319 
320 /* oplmsu_debug_mode */
321 #define	MSU_DPRINT_ON	1	/* enable print log */
322 
323 /* op type */
324 #define	MSU_TRC_UI	0	/* upper input */
325 #define	MSU_TRC_UO	1	/* upper output */
326 #define	MSU_TRC_LI	2	/* lower input */
327 #define	MSU_TRC_LO	3	/* lower output */
328 #define	MSU_TRC_OPN	4	/* open */
329 #define	MSU_TRC_CLS	5	/* close */
330 
331 /* trace macro */
332 #define	OPLMSU_TRACE(q, mp, op) {		\
333 	if (oplmsu_trace_on == MSU_TRACE_ON) {	\
334 		oplmsu_cmn_trace(q, mp, op);	\
335 	}					\
336 }
337 
338 /* debug print macro */
339 #define	DBG_PRINT(args)	{				\
340 	if (oplmsu_debug_mode & MSU_DPRINT_ON) {	\
341 		cmn_err args;				\
342 	}						\
343 }
344 
345 #else	/* ! DEBUG */
346 
347 /* trace macro */
348 #define	OPLMSU_TRACE(q, mp, op)
349 
350 /* debug print macro */
351 #define	DBG_PRINT(args)
352 #endif
353 
354 #ifdef __cplusplus
355 }
356 #endif
357 
358 #endif	/* _OPLMSU_H */
359