xref: /titanic_41/usr/src/uts/common/ipp/dscpmk/dscpmk_impl.h (revision e0724c534a46ca4754330bc022bf1e2a68f5bb93)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _IPP_DSCPMK_DSCPMK_IMPL_H
28 #define	_IPP_DSCPMK_DSCPMK_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/cmn_err.h>
34 #include <ipp/ipp.h>
35 #include <ipp/dscpmk/dscpmk.h>
36 #include <inet/ipp_common.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /* Header file for implementation of DS/ToS dscp marker ipp action module */
43 
44 #define	_DSCPMK_DEBUG
45 
46 /* Mask out all but the Traffic class for IPv6 header */
47 #ifdef _BIG_ENDIAN
48 #define	TCLASS_MASK		0xF00FFFFF
49 #else
50 #define	TCLASS_MASK		0xFFFF0FF0
51 #endif
52 
53 /* Array count for dscp_policed_array 0-63 */
54 #define	DSCPMK_ARRAY_COUNT		64
55 /* During modification, entries that are unchanged are signified with -1 */
56 #define	DSCPMK_UNCHANGED_DSCP		-1
57 
58 #ifdef _DSCPMK_DEBUG
59 #include <sys/debug.h>
60 #define	dscpmk0dbg(a)		printf a
61 #define	dscpmk1dbg(a)		if (dscpmk_debug > 2) printf a
62 #define	dscpmk2dbg(a)		if (dscpmk_debug > 3) printf a
63 #else
64 #define	dscpmk0dbg(a)
65 #define	dscpmk1dbg(a)
66 #define	dscpmk2dbg(a)
67 #endif /* _DSCPMK_DEBUG */
68 
69 /* dscpmk stats information available using kstats */
70 typedef struct dscpmk_stat_s {
71 	ipp_named_t	npackets;	/* no. of pkts seen by this instance */
72 	ipp_named_t	dscp_changed;	/* no. of pkts. with dscp changed */
73 	ipp_named_t	dscp_unchanged;	/* no. of pkts. with dscp unchanged */
74 	ipp_named_t	ipackets;	/* no. of pkts. not processed */
75 	ipp_named_t	epackets;	/* no. of pkts. in error */
76 } dscpmk_stat_t;
77 
78 typedef struct dscpmk_dscp_stats_s {
79 	ipp_named_t	dscp;		/* dscp value */
80 	ipp_named_t	npackets;	/* no. of packets for this dscp */
81 } dscpmk_dscp_stats_t;
82 
83 /*
84  * If the above structure is changed, the count will have to be updated
85  * accordingly.
86  */
87 #define	DSCPMK_STATS_COUNT		5
88 #define	DSCPMK_STATS_STRING		"dscpmk_stats"
89 
90 #define	DSCPMK_DSCP_STATS_COUNT		2
91 
92 typedef struct dscp_stats_s {
93 	boolean_t	present;	/* Stats present for this DSCP */
94 	uint64_t	npackets;	/* no. of packets for this DSCP */
95 	ipp_stat_t 	*stats;		/* stats for this DSCP */
96 } dscp_stats_t;
97 
98 /* Per-instance structure */
99 typedef struct dscpmk_data_s {
100 
101 	ipp_action_id_t next_action; 	/* action id of next action */
102 	ipp_stat_t 	*stats;		/* structure for storing stats */
103 
104 	/* inbound DSCP -> outbound DSCP mapping table */
105 	uint8_t 	dscp_map[DSCPMK_ARRAY_COUNT];
106 
107 	/* Minimal stats */
108 	boolean_t 	summary_stats;
109 	uint64_t 	npackets;	/* no. of packets processed by action */
110 	uint64_t 	changed;	/* packets with DSCP changed */
111 	uint64_t 	unchanged;	/* packets with DSCP unchanged */
112 	uint64_t 	ipackets;	/* packets not processed */
113 	uint64_t 	epackets;	/* packets in error */
114 
115 	/* per-DSCP stats */
116 	boolean_t 	detailed_stats;
117 	/* Stats count per DSCP value 0-63 */
118 	dscp_stats_t	dscp_stats[DSCPMK_ARRAY_COUNT];
119 } dscpmk_data_t;
120 
121 #define	DSCPMK_DATA_SZ		sizeof (dscpmk_data_t)
122 
123 #ifdef	_KERNEL
124 extern int dscpmk_process(mblk_t **, dscpmk_data_t *, ip_proc_t);
125 #endif /* _KERNEL */
126 
127 #ifdef	__cplusplus
128 }
129 #endif
130 
131 #endif /* _IPP_DSCPMK_DSCPMK_IMPL_H */
132