xref: /onnv-gate/usr/src/uts/common/sys/bufmod.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright (c) 1991, 1997-1998 by Sun Microsystems, Inc.
24*0Sstevel@tonic-gate  * All rights reserved.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_SYS_BUFMOD_H
28*0Sstevel@tonic-gate #define	_SYS_BUFMOD_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/types.h>
33*0Sstevel@tonic-gate #include <sys/types32.h>
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate #ifdef	__cplusplus
36*0Sstevel@tonic-gate extern "C" {
37*0Sstevel@tonic-gate #endif
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate /*
40*0Sstevel@tonic-gate  * Definitions for the STREAMS Buffering module.
41*0Sstevel@tonic-gate  *
42*0Sstevel@tonic-gate  * The module gathers incoming (read-side) messages together into
43*0Sstevel@tonic-gate  * "chunks" and passes completed chunks up to the next module in
44*0Sstevel@tonic-gate  * line.  The gathering process is controlled by two ioctl-settable
45*0Sstevel@tonic-gate  * parameters:
46*0Sstevel@tonic-gate  *
47*0Sstevel@tonic-gate  * timeout	The maximum delay after passing the previous chunk
48*0Sstevel@tonic-gate  *		upward before passing the current one up, even if the
49*0Sstevel@tonic-gate  *		chunk isn't full.  If the timeout value passed in is
50*0Sstevel@tonic-gate  *		a null pointer, the timeout is infinite (as in the
51*0Sstevel@tonic-gate  *		select system call); this is the default.
52*0Sstevel@tonic-gate  * chunksize	The maximum size of a chunk of accumulated messages,
53*0Sstevel@tonic-gate  *		unless a single message exceeds the chunksize, in
54*0Sstevel@tonic-gate  *		which case it's passed up in a chunk containing only
55*0Sstevel@tonic-gate  *		that message.  Note that a given message's size includes
56*0Sstevel@tonic-gate  *		the length of any leading M_PROTO blocks it may have.
57*0Sstevel@tonic-gate  *
58*0Sstevel@tonic-gate  * There is one important side-effect: setting the timeout to zero
59*0Sstevel@tonic-gate  * (polling) will force the chunksize to zero, regardless of its
60*0Sstevel@tonic-gate  * previous setting.
61*0Sstevel@tonic-gate  */
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate /*
64*0Sstevel@tonic-gate  * Ioctls.
65*0Sstevel@tonic-gate  */
66*0Sstevel@tonic-gate #define	SBIOC	('B' << 8)
67*0Sstevel@tonic-gate #define	SBIOCSTIME	(SBIOC|1)	/* set timeout info */
68*0Sstevel@tonic-gate #define	SBIOCGTIME	(SBIOC|2)	/* get timeout info */
69*0Sstevel@tonic-gate #define	SBIOCCTIME	(SBIOC|3)	/* clear timeout */
70*0Sstevel@tonic-gate #define	SBIOCSCHUNK	(SBIOC|4)	/* set chunksize */
71*0Sstevel@tonic-gate #define	SBIOCGCHUNK	(SBIOC|5)	/* get chunksize */
72*0Sstevel@tonic-gate #define	SBIOCSSNAP	(SBIOC|6)	/* set snapshot length */
73*0Sstevel@tonic-gate #define	SBIOCGSNAP	(SBIOC|7)	/* get snapshot length */
74*0Sstevel@tonic-gate #define	SBIOCSFLAGS	(SBIOC|8)	/* set buffering modes */
75*0Sstevel@tonic-gate #define	SBIOCGFLAGS	(SBIOC|9)	/* get buffering modes */
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate /*
78*0Sstevel@tonic-gate  * Default chunk size.
79*0Sstevel@tonic-gate  */
80*0Sstevel@tonic-gate #define	SB_DFLT_CHUNK	8192	/* arbitrary */
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate /*
83*0Sstevel@tonic-gate  * buffering flags
84*0Sstevel@tonic-gate  */
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate #define	SB_SEND_ON_WRITE	1	/* return buffered read data on write */
87*0Sstevel@tonic-gate #define	SB_NO_HEADER		2	/* don't add header structure to data */
88*0Sstevel@tonic-gate #define	SB_NO_PROTO_CVT		4	/* don't convert proto to data */
89*0Sstevel@tonic-gate #define	SB_DEFER_CHUNK		8	/* fast response time buffering */
90*0Sstevel@tonic-gate #define	SB_NO_DROPS		16	/* Don't drop messages */
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate /*
93*0Sstevel@tonic-gate  * buffering state
94*0Sstevel@tonic-gate  */
95*0Sstevel@tonic-gate #define	SB_FRCVD	1	/* first message in time window received */
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate /*
98*0Sstevel@tonic-gate  * When adding a given message to an accumulating chunk, the module
99*0Sstevel@tonic-gate  * first converts any leading M_PROTO data block to M_DATA.
100*0Sstevel@tonic-gate  * It then constructs an sb_hdr (defined below), prepends it to
101*0Sstevel@tonic-gate  * the message, and pads the result out to force its length to a
102*0Sstevel@tonic-gate  * multiple of a machine-dependent alignment size guaranteed to be
103*0Sstevel@tonic-gate  * at least sizeof (ulong_t).  It then adds the padded message to the
104*0Sstevel@tonic-gate  * chunk.
105*0Sstevel@tonic-gate  *
106*0Sstevel@tonic-gate  * sb_origlen is the original length of the message after the M_PROTO => M_DATA
107*0Sstevel@tonic-gate  * conversion, but before truncating or adding the header.
108*0Sstevel@tonic-gate  *
109*0Sstevel@tonic-gate  * sb_msglen is the length of the message after truncation, but before
110*0Sstevel@tonic-gate  * adding the header.
111*0Sstevel@tonic-gate  *
112*0Sstevel@tonic-gate  * sb_totlen is the length of the message after truncation, and including
113*0Sstevel@tonic-gate  * both the header itself and the trailing padding bytes.
114*0Sstevel@tonic-gate  *
115*0Sstevel@tonic-gate  * sb_drops is the cumulative number of messages dropped by the module
116*0Sstevel@tonic-gate  * due to stream read-side flow control or resource exhaustion.
117*0Sstevel@tonic-gate  *
118*0Sstevel@tonic-gate  * sb_timestamp is the packet arrival time expressed as a 'struct timeval'.
119*0Sstevel@tonic-gate  */
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate struct sb_hdr {
122*0Sstevel@tonic-gate 	uint_t	sbh_origlen;
123*0Sstevel@tonic-gate 	uint_t	sbh_msglen;
124*0Sstevel@tonic-gate 	uint_t	sbh_totlen;
125*0Sstevel@tonic-gate 	uint_t	sbh_drops;
126*0Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx)
127*0Sstevel@tonic-gate 	struct	timeval32 sbh_timestamp;
128*0Sstevel@tonic-gate #else
129*0Sstevel@tonic-gate 	struct	timeval sbh_timestamp;
130*0Sstevel@tonic-gate #endif /* !_LP64 */
131*0Sstevel@tonic-gate };
132*0Sstevel@tonic-gate 
133*0Sstevel@tonic-gate #ifdef	__cplusplus
134*0Sstevel@tonic-gate }
135*0Sstevel@tonic-gate #endif
136*0Sstevel@tonic-gate 
137*0Sstevel@tonic-gate #endif	/* _SYS_BUFMOD_H */
138