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