1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * spppcomp.h - Solaris STREAMS PPP compression module definitions
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * Copyright 2000-2002 Sun Microsystems, Inc.  All rights reserved.
5*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
6*7c478bd9Sstevel@tonic-gate  *
7*7c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software and its
8*7c478bd9Sstevel@tonic-gate  * documentation is hereby granted, provided that the above copyright
9*7c478bd9Sstevel@tonic-gate  * notice appears in all copies.
10*7c478bd9Sstevel@tonic-gate  *
11*7c478bd9Sstevel@tonic-gate  * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF
12*7c478bd9Sstevel@tonic-gate  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
13*7c478bd9Sstevel@tonic-gate  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14*7c478bd9Sstevel@tonic-gate  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT.  SUN SHALL NOT BE LIABLE FOR
15*7c478bd9Sstevel@tonic-gate  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
16*7c478bd9Sstevel@tonic-gate  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
17*7c478bd9Sstevel@tonic-gate  *
18*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1994 The Australian National University.
19*7c478bd9Sstevel@tonic-gate  * All rights reserved.
20*7c478bd9Sstevel@tonic-gate  *
21*7c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software and its
22*7c478bd9Sstevel@tonic-gate  * documentation is hereby granted, provided that the above copyright
23*7c478bd9Sstevel@tonic-gate  * notice appears in all copies.  This software is provided without any
24*7c478bd9Sstevel@tonic-gate  * warranty, express or implied. The Australian National University
25*7c478bd9Sstevel@tonic-gate  * makes no representations about the suitability of this software for
26*7c478bd9Sstevel@tonic-gate  * any purpose.
27*7c478bd9Sstevel@tonic-gate  *
28*7c478bd9Sstevel@tonic-gate  * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
29*7c478bd9Sstevel@tonic-gate  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
30*7c478bd9Sstevel@tonic-gate  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
31*7c478bd9Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY
32*7c478bd9Sstevel@tonic-gate  * OF SUCH DAMAGE.
33*7c478bd9Sstevel@tonic-gate  *
34*7c478bd9Sstevel@tonic-gate  * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
35*7c478bd9Sstevel@tonic-gate  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
36*7c478bd9Sstevel@tonic-gate  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
37*7c478bd9Sstevel@tonic-gate  * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
38*7c478bd9Sstevel@tonic-gate  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
39*7c478bd9Sstevel@tonic-gate  * OR MODIFICATIONS.
40*7c478bd9Sstevel@tonic-gate  *
41*7c478bd9Sstevel@tonic-gate  * This driver is derived from the original SVR4 STREAMS PPP driver
42*7c478bd9Sstevel@tonic-gate  * originally written by Paul Mackerras <paul.mackerras@cs.anu.edu.au>.
43*7c478bd9Sstevel@tonic-gate  *
44*7c478bd9Sstevel@tonic-gate  * Adi Masputra <adi.masputra@sun.com> rewrote and restructured the code
45*7c478bd9Sstevel@tonic-gate  * for improved performance and scalability.
46*7c478bd9Sstevel@tonic-gate  */
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate #ifndef __SPPPCOMP_H
49*7c478bd9Sstevel@tonic-gate #define	__SPPPCOMP_H
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
52*7c478bd9Sstevel@tonic-gate extern "C" {
53*7c478bd9Sstevel@tonic-gate #endif
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate /*
56*7c478bd9Sstevel@tonic-gate  * Per-unit kstats.
57*7c478bd9Sstevel@tonic-gate  */
58*7c478bd9Sstevel@tonic-gate typedef struct spppcomp_kstats {
59*7c478bd9Sstevel@tonic-gate 	kstat_named_t	vj_out_pkts;
60*7c478bd9Sstevel@tonic-gate 	kstat_named_t	vj_out_pkts_comp;
61*7c478bd9Sstevel@tonic-gate 	kstat_named_t	vj_cs_searches;
62*7c478bd9Sstevel@tonic-gate 	kstat_named_t	vj_cs_misses;
63*7c478bd9Sstevel@tonic-gate 	kstat_named_t	vj_in_pkts_uncomp;
64*7c478bd9Sstevel@tonic-gate 	kstat_named_t	vj_in_pkts_comp;
65*7c478bd9Sstevel@tonic-gate 	kstat_named_t	vj_in_error;
66*7c478bd9Sstevel@tonic-gate 	kstat_named_t	vj_in_tossed;
67*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_errors_low;
68*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_uncomp_bytes;
69*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_uncomp_pkts;
70*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_comp_bytes;
71*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_comp_pkts;
72*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_incomp_bytes;
73*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_incomp_pkts;
74*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_errors_low;
75*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_uncomp_bytes;
76*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_uncomp_pkts;
77*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_comp_bytes;
78*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_comp_pkts;
79*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_incomp_bytes;
80*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_incomp_pkts;
81*7c478bd9Sstevel@tonic-gate #ifdef SPC_DEBUG
82*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_msg_ccp_pulledup;
83*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_msg_vj_pulledup;
84*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_msg_pulledup;
85*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_msg_copied;
86*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_queued;
87*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_handled;
88*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_queued;
89*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_handled;
90*7c478bd9Sstevel@tonic-gate #endif
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate 	/* 64 bit entries */
93*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_bytes;
94*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_pkts;
95*7c478bd9Sstevel@tonic-gate 	kstat_named_t	out_errors;
96*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_bytes;
97*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_pkts;
98*7c478bd9Sstevel@tonic-gate 	kstat_named_t	in_errors;
99*7c478bd9Sstevel@tonic-gate } spppcomp_kstats_t;
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate #define	SPPPCOMP_KSTATS_NAMES \
102*7c478bd9Sstevel@tonic-gate 	"vj_out_pkts", "vj_out_pkts_comp", "vj_cs_searches", \
103*7c478bd9Sstevel@tonic-gate 	"vj_cs_misses", "vj_in_pkts_uncomp", "vj_in_pkts_comp", \
104*7c478bd9Sstevel@tonic-gate 	"vj_in_error", "vj_in_tossed",  "out_errors_lower", \
105*7c478bd9Sstevel@tonic-gate 	"out_uncomp_bytes", "out_uncomp_pkts", "out_comp_bytes", \
106*7c478bd9Sstevel@tonic-gate 	"out_comp_pkts", "out_incomp_bytes", "out_incomp_pkts", \
107*7c478bd9Sstevel@tonic-gate 	"in_errors_lower", "in_uncomp_bytes", "in_uncomp_pkts", \
108*7c478bd9Sstevel@tonic-gate 	"in_comp_bytes", "in_comp_pkts", "in_incomp_bytes", \
109*7c478bd9Sstevel@tonic-gate 	"in_incomp_pkts"
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate #ifdef SPC_DEBUG
112*7c478bd9Sstevel@tonic-gate #define	SPCDEBUG_KSTATS_NAMES \
113*7c478bd9Sstevel@tonic-gate 	"in_msg_ccp_pulledup", "in_msg_vj_pulledup", "out_msg_pulledup", \
114*7c478bd9Sstevel@tonic-gate 	"out_msg_copied", "out_queued", "out_handled", \
115*7c478bd9Sstevel@tonic-gate 	"in_queued", "in_handled"
116*7c478bd9Sstevel@tonic-gate #endif
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate #define	SPPPCOMP_KSTATS64_NAMES \
119*7c478bd9Sstevel@tonic-gate 	"out_bytes", "out_pkts", "out_errors", \
120*7c478bd9Sstevel@tonic-gate 	"in_bytes", "in_pkts", 	"in_errors"
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate /*
123*7c478bd9Sstevel@tonic-gate  * Per-stream instance state information.
124*7c478bd9Sstevel@tonic-gate  *
125*7c478bd9Sstevel@tonic-gate  * Each instance is dynamically allocated at open() and freed at close().
126*7c478bd9Sstevel@tonic-gate  * Each per-Stream instance points to at most one per-unit kstats structure
127*7c478bd9Sstevel@tonic-gate  * using the cp_kstats field, which is allocated once per-Stream when
128*7c478bd9Sstevel@tonic-gate  * PPPCTL_UNIT is received from above.
129*7c478bd9Sstevel@tonic-gate  */
130*7c478bd9Sstevel@tonic-gate typedef struct sppp_comp {
131*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_flags;	/* miscellaneous flags */
132*7c478bd9Sstevel@tonic-gate 	ushort_t		cp_mru;		/* link layer MRU */
133*7c478bd9Sstevel@tonic-gate 	ushort_t		cp_mtu;		/* link layer MTU */
134*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_unit;	/* unique unit id */
135*7c478bd9Sstevel@tonic-gate 	struct compressor	*cp_xcomp;	/* compressor structure */
136*7c478bd9Sstevel@tonic-gate 	void			*cp_xstate;	/* compressor state */
137*7c478bd9Sstevel@tonic-gate 	struct compressor	*cp_rcomp;	/* de-compressor structure */
138*7c478bd9Sstevel@tonic-gate 	void			*cp_rstate;	/* de-compressor state */
139*7c478bd9Sstevel@tonic-gate 	struct vjcompress	cp_vj;		/* VJ compression state */
140*7c478bd9Sstevel@tonic-gate 	kmutex_t		cp_pair_lock;	/* lock for queue pair */
141*7c478bd9Sstevel@tonic-gate 	hrtime_t		cp_lastfinish;	/* last decode finish time */
142*7c478bd9Sstevel@tonic-gate 	int16_t			cp_effort;	/* configured effort level */
143*7c478bd9Sstevel@tonic-gate 	int16_t			cp_nxslots;	/* VJ compress slots */
144*7c478bd9Sstevel@tonic-gate 	uint16_t		cp_fastin;	/* count of fast inputs */
145*7c478bd9Sstevel@tonic-gate 	ppp_counter_t		cp_vj_last_ierrors; /* last VJ input errors */
146*7c478bd9Sstevel@tonic-gate 	struct pppstat64	cp_stats;	/* legacy stats structure */
147*7c478bd9Sstevel@tonic-gate 	kstat_t			*cp_kstats;	/* ptr to kstats structure */
148*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_ierr_low;	/* in error from below */
149*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_oerr_low;	/* out error from below */
150*7c478bd9Sstevel@tonic-gate #ifdef SPC_DEBUG
151*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_imsg_ccp_pull; /* msgpullup on recv */
152*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_imsg_vj_pull;  /* msgpullup on recv */
153*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_omsg_pull;	/* msgpullup on send */
154*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_omsg_dcopy;	/* copymsg on send */
155*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_out_queued;	/* did putq */
156*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_out_handled;	/* did putnext */
157*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_in_queued;	/* did putq */
158*7c478bd9Sstevel@tonic-gate 	uint32_t		cp_in_handled;	/* did putnext */
159*7c478bd9Sstevel@tonic-gate #endif
160*7c478bd9Sstevel@tonic-gate } sppp_comp_t;
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate /*
163*7c478bd9Sstevel@tonic-gate  * Bits in flags are as defined in pppio.h
164*7c478bd9Sstevel@tonic-gate  *      COMP_AC         0x00000001	compress address/control
165*7c478bd9Sstevel@tonic-gate  *      DECOMP_AC       0x00000002      decompress address/control
166*7c478bd9Sstevel@tonic-gate  *      COMP_PROT       0x00000004      compress PPP protocol
167*7c478bd9Sstevel@tonic-gate  *      DECOMP_PROT     0x00000008      decompress PPP protocol
168*7c478bd9Sstevel@tonic-gate  *      COMP_VJC        0x00000010      compress TCP/IP headers
169*7c478bd9Sstevel@tonic-gate  *      COMP_VJCCID     0x00000020      compress connection ID as well
170*7c478bd9Sstevel@tonic-gate  *      DECOMP_VJC      0x00000040      decompress TCP/IP headers
171*7c478bd9Sstevel@tonic-gate  *      DECOMP_VJCCID   0x00000080      accept compressed connection ID
172*7c478bd9Sstevel@tonic-gate  *      CCP_ISOPEN      0x00000100      look at CCP packets
173*7c478bd9Sstevel@tonic-gate  *      CCP_ISUP        0x00000200      do packet comp/decomp
174*7c478bd9Sstevel@tonic-gate  *      CCP_ERROR       0x00000400      (status) error in packet decomp
175*7c478bd9Sstevel@tonic-gate  *      CCP_FATALERROR  0x00000800      (status) fatal error ditto
176*7c478bd9Sstevel@tonic-gate  *      CCP_COMP_RUN    0x00001000      (status) seen CCP ack sent
177*7c478bd9Sstevel@tonic-gate  *      CCP_DECOMP_RUN  0x00002000      (status) seen CCP ack rcvd
178*7c478bd9Sstevel@tonic-gate  */
179*7c478bd9Sstevel@tonic-gate #define	CP_KDEBUG	0x02000000	/* log debugging stuff */
180*7c478bd9Sstevel@tonic-gate #define	CP_HASUNIT	0x04000000	/* PPPCTL_UNIT has been issued on */
181*7c478bd9Sstevel@tonic-gate #define	CP_LASTMOD	0x08000000	/* last PPP-aware module in stream */
182*7c478bd9Sstevel@tonic-gate #define	CCP_ERR		(CCP_ERROR | CCP_FATALERROR)
183*7c478bd9Sstevel@tonic-gate 
184*7c478bd9Sstevel@tonic-gate #define	IS_COMP_AC(x)	\
185*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & COMP_AC)
186*7c478bd9Sstevel@tonic-gate #define	IS_DECOMP_AC(x)	\
187*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & DECOMP_AC)
188*7c478bd9Sstevel@tonic-gate #define	IS_COMP_PROT(x)	\
189*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & COMP_PROT)
190*7c478bd9Sstevel@tonic-gate #define	IS_DECOMP_PROT(x)	\
191*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & DECOMP_PROT)
192*7c478bd9Sstevel@tonic-gate #define	IS_COMP_VJC(x)	\
193*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & COMP_VJC)
194*7c478bd9Sstevel@tonic-gate #define	IS_COMP_VJCCID(x)	\
195*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & COMP_VJCCID)
196*7c478bd9Sstevel@tonic-gate #define	IS_DECOMP_VJC(x)	\
197*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & DECOMP_VJC)
198*7c478bd9Sstevel@tonic-gate #define	IS_DECOMP_VJCCID(x)	\
199*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & DECOMP_VJCCID)
200*7c478bd9Sstevel@tonic-gate #define	IS_CCP_ISOPEN(x)	\
201*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & CCP_ISOPEN)
202*7c478bd9Sstevel@tonic-gate #define	IS_CCP_ISUP(x)	\
203*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & CCP_ISUP)
204*7c478bd9Sstevel@tonic-gate #define	IS_CCP_ERROR(x)	\
205*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & CCP_ERROR)
206*7c478bd9Sstevel@tonic-gate #define	IS_CCP_FATALERROR(x)	\
207*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & CCP_FATALERROR)
208*7c478bd9Sstevel@tonic-gate #define	IS_CCP_COMP_RUN(x)	\
209*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & CCP_COMP_RUN)
210*7c478bd9Sstevel@tonic-gate #define	IS_CCP_DECOMP_RUN(x)	\
211*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & CCP_DECOMP_RUN)
212*7c478bd9Sstevel@tonic-gate #define	IS_CP_KDEBUG(x)	\
213*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & CP_KDEBUG)
214*7c478bd9Sstevel@tonic-gate #define	IS_CP_HASUNIT(x)	\
215*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & CP_HASUNIT)
216*7c478bd9Sstevel@tonic-gate #define	IS_CP_LASTMOD(x)	\
217*7c478bd9Sstevel@tonic-gate 	((x)->cp_flags & CP_LASTMOD)
218*7c478bd9Sstevel@tonic-gate 
219*7c478bd9Sstevel@tonic-gate /*
220*7c478bd9Sstevel@tonic-gate  * Bit format (octal based) string for cmn_err/printf, which
221*7c478bd9Sstevel@tonic-gate  * represents the flags.
222*7c478bd9Sstevel@tonic-gate  */
223*7c478bd9Sstevel@tonic-gate #define	CP_FLAGSSTR		\
224*7c478bd9Sstevel@tonic-gate 	"\020"			\
225*7c478bd9Sstevel@tonic-gate 	"\1comp_ac"		\
226*7c478bd9Sstevel@tonic-gate 	"\2decomp_ac"		\
227*7c478bd9Sstevel@tonic-gate 	"\3comp_prot"		\
228*7c478bd9Sstevel@tonic-gate 	"\4decomp_prot"		\
229*7c478bd9Sstevel@tonic-gate 	"\5comp_vjc"		\
230*7c478bd9Sstevel@tonic-gate 	"\6comp_vjccid"		\
231*7c478bd9Sstevel@tonic-gate 	"\7decomp_vjc"		\
232*7c478bd9Sstevel@tonic-gate 	"\10decomp_vjccid"	\
233*7c478bd9Sstevel@tonic-gate 	"\11ccp_isopen"		\
234*7c478bd9Sstevel@tonic-gate 	"\12ccp_isup"		\
235*7c478bd9Sstevel@tonic-gate 	"\13ccp_error"		\
236*7c478bd9Sstevel@tonic-gate 	"\14ccp_fatalerror"	\
237*7c478bd9Sstevel@tonic-gate 	"\15ccp_comp_run"	\
238*7c478bd9Sstevel@tonic-gate 	"\16ccp_decomp_run"	\
239*7c478bd9Sstevel@tonic-gate 	"\32kdebug"		\
240*7c478bd9Sstevel@tonic-gate 	"\33hasunit"		\
241*7c478bd9Sstevel@tonic-gate 	"\34lastmod"
242*7c478bd9Sstevel@tonic-gate 
243*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
244*7c478bd9Sstevel@tonic-gate }
245*7c478bd9Sstevel@tonic-gate #endif
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate #endif /* __SPPPCOMP_H */
248