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