xref: /titanic_44/usr/src/uts/common/io/ppp/spppasyn/spppasyn.h (revision 5151fb1220e0ceafdc172203863c73da4285c170)
1 /*
2  * spppasyn.h - Solaris STREAMS PPP asynchronous HDLC 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 __SPPPASYN_H
49 #define	__SPPPASYN_H
50 
51 #pragma ident	"%Z%%M%	%I%	%E% SMI"
52 
53 #ifdef	__cplusplus
54 extern "C" {
55 #endif
56 
57 typedef struct spppasyn_kstats	{
58 	kstat_named_t	pks_ioctls;		/* total ioctl count */
59 	kstat_named_t	pks_ioctlsfwd;		/* forwarded down */
60 	kstat_named_t	pks_ioctlserr;		/* returned in error */
61 	kstat_named_t	pks_ctls;		/* total ctl count */
62 	kstat_named_t	pks_ctlsfwd;		/* forwarded down */
63 	kstat_named_t	pks_ctlserr;		/* discarded due to error */
64 	kstat_named_t	pks_inbadchars;		/* chars in recv accm */
65 	kstat_named_t	pks_inbadcharmask;	/* add to recv accm */
66 	kstat_named_t	pks_inaborts;		/* aborted (7D 7E) frames */
67 	kstat_named_t	pks_inrunts;		/* too short (<4) frames */
68 	kstat_named_t	pks_inallocfails;	/* out of STREAMS buffers */
69 	kstat_named_t	pks_intoolongs;		/* too long (>MRU) frames */
70 	kstat_named_t	pks_outrunts;		/* bugs in upper modules */
71 	kstat_named_t	pks_outallocfails;	/* out of STREAMS buffers */
72 	kstat_named_t	pks_incrcerrs;		/* bad input frames */
73 	kstat_named_t	pks_unknownwrs;		/* forwarded wput messages */
74 	kstat_named_t	pks_unknownrds;		/* forwarded rput messages */
75 	kstat_named_t	pks_hangups;		/* hang-up messages */
76 	kstat_named_t	pks_datain;		/* received from serial */
77 	kstat_named_t	pks_dataout;		/* sent to serial */
78 	kstat_named_t	pks_extrabufs;		/* extra buffers needed */
79 	kstat_named_t	pks_sentmux;		/* sent mux count */
80 	kstat_named_t	pks_recvmux;		/* received mux count */
81 	kstat_named_t	pks_inmuxerrs;		/* bad input mux frames */
82 #ifdef REPORT_CRC_TYPE
83 	kstat_named_t	pks_incrctype;		/* configured input CRC bits */
84 	kstat_named_t	pks_outcrctype;		/* configured output CRC */
85 #endif
86 } spppasyn_kstats_t;
87 
88 /*
89  * Per-stream state structure
90  */
91 typedef struct sppp_ahdlc {
92 	uint32_t	sa_flags;		/* link flags */
93 	mblk_t		*sa_rx_buf;	/* ptr to receive buffer */
94 	ushort_t	sa_infcs16;	/* calculated rx HDLC FCS */
95 	ushort_t	sa_proto;	/* the last protocol in frame */
96 	uint32_t	sa_infcs32;	/* calculated rx HDLC FCS-32 */
97 	uint32_t	sa_xaccm[8];	/* 256-bit xmit ACCM */
98 	uint32_t	sa_raccm;	/* 32-bit rcv ACCM */
99 	int		sa_mru;		/* link MRU */
100 	int		sa_unit;	/* current PPP unit number */
101 	struct pppstat64 sa_stats;	/* statistic structure */
102 	hrtime_t	sa_hrtime;	/* last updated hrtime */
103 	mblk_t		*sa_mqhead;	/* pointer to the first message */
104 	mblk_t		*sa_mqtail;	/* pointer to the last message */
105 	size_t		sa_mqlen;	/* length of the frame so far */
106 	timeout_id_t	sa_timeout_id;	/* timeout id */
107 	uint32_t	sa_timeout_usec; /* value of the mux timer */
108 	kstat_t		*sa_ksp;	/* kernel statistics structure */
109 	spppasyn_kstats_t sa_kstats;	/* current statistics */
110 } sppp_ahdlc_t;
111 
112 /*
113  * Values for flags.  Note that bits 0-7 (0xFF) are used by RCV_* flags
114  * and [XR]_MUXMASK in pppio.h.
115  */
116 #define	SAF_ESCAPED	 0x00000100	/* last saw escape char on input */
117 #define	SAF_IFLUSH	 0x00000200	/* discarding due to hangup or error */
118 #define	SAF_XMITCRC32	 0x00000400	/* transmit 32 bit CRC */
119 #define	SAF_XMITCRCNONE	 0x00000800	/* transmit no CRC */
120 #define	SAF_RECVCRC32	 0x00001000	/* receive 32 bit CRC */
121 #define	SAF_RECVCRCNONE	 0x00002000	/* receive no CRC */
122 #define	SAF_XMITDUMP	 0x00004000	/* dump raw transmitted data */
123 #define	SAF_RECVDUMP	 0x00008000	/* dump raw received data */
124 #define	SAF_LASTMOD	 0x00010000	/* last PPP-aware module in stream */
125 #define	SAF_XCOMP_AC	 0x00100000	/* compress address/control */
126 #define	SAF_RDECOMP_AC	 0x00200000	/* decompress address/control */
127 #define	SAF_XCOMP_PROT	 0x00400000	/* compress PPP protocol */
128 #define	SAF_RDECOMP_PROT 0x00800000	/* decompress PPP protocol */
129 
130 #ifdef	__cplusplus
131 }
132 #endif
133 
134 #endif /* __SPPPASYN_H */
135