xref: /illumos-gate/usr/src/uts/common/io/ppp/sppptun/sppptun_impl.h (revision b31b5de1357c915fe7dab4d9646d9d84f9fe69bc)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * sppptun_impl.h - Internal sppptun data exposed for adb/mdb macros.
29  */
30 
31 #ifndef	_SPPPTUN_IMPL_H
32 #define	_SPPPTUN_IMPL_H
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /* For use with insque/remque (belongs in a system header!) */
39 struct qelem {
40 	struct qelem *q_forw;
41 	struct qelem *q_back;
42 };
43 
44 typedef struct tunll_s tunll_t;
45 typedef struct tuncl_s tuncl_t;
46 
47 typedef struct {
48 	kstat_named_t	lks_octrls;		/* sent control messages */
49 	kstat_named_t	lks_octrl_drop;		/* dropped control messages */
50 	kstat_named_t	lks_clients;		/* number of clients (tcls) */
51 	kstat_named_t	lks_walks;		/* PPPoE tcl walks */
52 	kstat_named_t	lks_in_nomatch;		/* input without match */
53 	kstat_named_t	lks_indata;		/* input data packets */
54 	kstat_named_t	lks_indata_drops;	/* input data packet drops */
55 	kstat_named_t	lks_inctrls;		/* input control packets */
56 	kstat_named_t	lks_inctrl_drops;	/* input control pkt drops */
57 } tll_kstats_t;
58 
59 #define	TLL_KSTATS_NAMES \
60 	"octrls", "octrl_drop", "clients", "walks", "in_nomatch", \
61 	"indata", "indata_drops", "inctrls", "inctrl_drops"
62 
63 typedef struct {
64 	kstat_named_t	cks_octrls;		/* sent control messages */
65 	kstat_named_t	cks_octrl_drop;		/* dropped control messages */
66 	kstat_named_t	cks_octrl_spec;		/* special control messages */
67 	kstat_named_t	cks_walks;		/* PPPoE tcl walks */
68 	kstat_named_t	cks_inctrls;		/* input control messages */
69 	kstat_named_t	cks_inctrl_drops;	/* input control pkt drops */
70 } tcl_kstats_t;
71 
72 #define	TCL_KSTATS_NAMES \
73 	"octrls", "octrl_drop", "octrl_spec", "walks", "inctrls", \
74 	"inctrl_drops"
75 
76 /*
77  * Tunnel lower layer structure; module open; connects to output device.
78  *
79  * Note: tll_flags member carefully aligned to match with tcl_flags in
80  * following structure so that we don't have to continually look at
81  * q_next to determine context.  Do not move these around.
82  *
83  * Note: this is also defined in uts/adb/common/tunll.dbg; if you change
84  * this structure, don't forget to change the adb/mdb macro.
85  */
86 struct tunll_s {
87 	uint32_t tll_flags;		/* See TLLF_* below */
88 	void *tll_next, *tll_prev;
89 
90 	int tll_error;
91 	queue_t *tll_wq;		/* Output data sent here */
92 	tuncl_t *tll_defcl;		/* Default client (daemon) */
93 	ppptun_atype tll_lcladdr;	/* Local address */
94 
95 	tuncl_t *tll_lastcl;		/* Silly PPPoE optimization */
96 
97 	ppptun_lname tll_name;
98 	int tll_index;
99 	int tll_muxid;
100 	int tll_style;			/* Interface type; PTS_* */
101 	int tll_alen;			/* Address length */
102 
103 	int tll_msg_pending;
104 	mblk_t *tll_msg_deferred;
105 
106 	mblk_t *tll_onclose;
107 
108 	tll_kstats_t tll_kstats;	/* current statistics */
109 	kstat_t *tll_ksp;		/* pointer to kstats allocation */
110 };
111 
112 /*
113  * Tunnel client structure; used for each device open.
114  *
115  * There is one of these for each PPP session plus (perhaps) one for
116  * each tunneling protocol server daemon.
117  *
118  * Note: this is also defined in uts/adb/common/tuncl.dbg; if you change
119  * this structure, don't forget to change the adb/mdb macro.
120  */
121 struct tuncl_s {
122 	uint32_t tcl_flags;		/* TCLF_ flags below */
123 
124 	tunll_t *tcl_data_tll;		/* Pointer to data interface */
125 	tunll_t *tcl_ctrl_tll;		/* Pointer to control */
126 
127 	queue_t *tcl_rq;		/* Received data sent here. */
128 
129 	uint32_t tcl_seq;
130 
131 	uint32_t tcl_ctlval;		/* Control distinguisher */
132 
133 	uint_t	tcl_style;		/* Saved style */
134 	uint_t	tcl_ltunid;		/* Local Tunnel ID (L2F/L2TP) */
135 	uint_t	tcl_rtunid;		/* Remote Tunnel ID (L2F/L2TP) */
136 	uint_t	tcl_lsessid;		/* Local Session ID (minor node) */
137 	uint_t	tcl_rsessid;		/* Remote Session ID */
138 	ppptun_atype	tcl_address;
139 
140 	int	tcl_unit;		/* PPP unit number (for debug) */
141 	struct pppstat64 tcl_stats;	/* Standard PPP statistics */
142 	tcl_kstats_t tcl_kstats;	/* current statistics */
143 	kstat_t *tcl_ksp;		/* pointer to kstats allocation */
144 };
145 
146 #define	TO_TLL(p) \
147 	((tunll_t *)((caddr_t)(p) - offsetof(tunll_t, tll_next)))
148 
149 #define	TLLF_NOTLOWER		0x00000001	/* never set */
150 #define	TLLF_CLOSING		0x00000002	/* driver detach initiated */
151 #define	TLLF_CLOSE_DONE		0x00000004	/* detach sent; waiting */
152 #define	TLLF_SHUTDOWN_DONE	0x00000008	/* detach done */
153 
154 #define	TCLF_ISCLIENT		0x00000001	/* always set */
155 #define	TCLF_FASTPATH		0x00000004	/* enable fast path recv */
156 #define	TCLF_DAEMON		0x00000010	/* server side; session 0 */
157 #define	TCLF_SPEER_DONE		0x00000020	/* SPEER ioctl done */
158 
159 #ifdef	__cplusplus
160 }
161 #endif
162 
163 #endif /* _SPPPTUN_IMPL_H */
164