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