4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_LOGINDMUX_IMPL_H
28 #define _SYS_LOGINDMUX_IMPL_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/types.h>
33 #include <sys/stream.h>
41 * This structure is shared between two logindmux peer instances and
42 * ensures that only one of the peers will be actively processing an
43 * I_UNLINK ioctl at any one time.
45 typedef struct unlinkinfo
{
46 kmutex_t state_lock
; /* serialize access to state */
47 int state
; /* state of I_UNLINK operation */
48 mblk_t
*prot_mp
; /* carries protocol messages */
52 * Logindmux state structure; one per open instance.
55 queue_t
*rdq
; /* our mux upper read queue */
56 queue_t
*muxq
; /* our mux lower write queue */
57 queue_t
*peerq
; /* peer mux lower write queue */
58 minor_t dev0
; /* our minor device number */
59 boolean_t isptm
; /* true if ptm is downstream */
60 mblk_t
*unlink_mp
; /* mblk used in logdmux_unlink_timer */
61 unlinkinfo_t
*unlinkinfop
; /* used during I_UNLINK processing */
62 bufcall_id_t wbufcid
; /* needed for recovery */
63 bufcall_id_t rbufcid
; /* needed for recovery */
64 timeout_id_t utimoutid
; /* unlink timer identifier */
65 timeout_id_t wtimoutid
; /* needed for recovery */
66 timeout_id_t rtimoutid
; /* needed for recovery */
69 #define LOGDMX_ID 107 /* module id number */
72 * The arguments for calls to qtimeout, in microseconds.
74 #define SIMWAIT 100000 /* logdmux_timer */
75 #define LOGDMUX_POLL_WAIT 10 /* logdmux_unlink_timer */
78 * State of peer linkage.
81 LOGDMUX_LINKED
= 1, /* peer instances are in linked state */
82 LOGDMUX_UNLINK_PENDING
= 2, /* a peer is actively I_UNLINKing */
83 LOGDMUX_UNLINKED
= 3 /* a peer has completed its I_UNLINK */
87 * Protocol message magic cookie.
89 #define LOGDMUX_MCTL (LOGDMX_ID << 16)
92 * peer to peer protocol messages.
94 #define LOGDMUX_UNLINK_REQ (LOGDMUX_MCTL|1) /* peer wants to unlink */
95 #define LOGDMUX_UNLINK_RESP (LOGDMUX_MCTL|2) /* ok for peer to unlink */
98 * Macro to determine if an mblk is a logindmux protocol mblk.
100 #define LOGDMUX_PROTO_MBLK(mp) \
101 ((DB_TYPE(mp) == M_CTL) && \
102 ((mp)->b_cont != NULL) && \
103 (DB_TYPE((mp)->b_cont) == M_IOCTL) && \
104 (((struct iocblk *)((mp)->b_cont->b_rptr))->ioc_cmd == I_UNLINK))
111 #endif /* _SYS_LOGINDMUX_IMPL_H */