xref: /illumos-gate/usr/src/uts/common/ipp/dscpmk/dscpmk_impl.h (revision d48be21240dfd051b689384ce2b23479d757f2d8)
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 #include <sys/types.h>
31 #include <sys/cmn_err.h>
32 #include <ipp/ipp.h>
33 #include <ipp/dscpmk/dscpmk.h>
34 #include <inet/ipp_common.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /* Header file for implementation of DS/ToS dscp marker ipp action module */
41 
42 #define	_DSCPMK_DEBUG
43 
44 /* Mask out all but the Traffic class for IPv6 header */
45 #ifdef _BIG_ENDIAN
46 #define	TCLASS_MASK		0xF00FFFFF
47 #else
48 #define	TCLASS_MASK		0xFFFF0FF0
49 #endif
50 
51 /* Array count for dscp_policed_array 0-63 */
52 #define	DSCPMK_ARRAY_COUNT		64
53 /* During modification, entries that are unchanged are signified with -1 */
54 #define	DSCPMK_UNCHANGED_DSCP		-1
55 
56 #ifdef _DSCPMK_DEBUG
57 #include <sys/debug.h>
58 #define	dscpmk0dbg(a)		printf a
59 #define	dscpmk1dbg(a)		if (dscpmk_debug > 2) printf a
60 #define	dscpmk2dbg(a)		if (dscpmk_debug > 3) printf a
61 #else
62 #define	dscpmk0dbg(a)
63 #define	dscpmk1dbg(a)
64 #define	dscpmk2dbg(a)
65 #endif /* _DSCPMK_DEBUG */
66 
67 /* dscpmk stats information available using kstats */
68 typedef struct dscpmk_stat_s {
69 	ipp_named_t	npackets;	/* no. of pkts seen by this instance */
70 	ipp_named_t	dscp_changed;	/* no. of pkts. with dscp changed */
71 	ipp_named_t	dscp_unchanged;	/* no. of pkts. with dscp unchanged */
72 	ipp_named_t	ipackets;	/* no. of pkts. not processed */
73 	ipp_named_t	epackets;	/* no. of pkts. in error */
74 } dscpmk_stat_t;
75 
76 typedef struct dscpmk_dscp_stats_s {
77 	ipp_named_t	dscp;		/* dscp value */
78 	ipp_named_t	npackets;	/* no. of packets for this dscp */
79 } dscpmk_dscp_stats_t;
80 
81 /*
82  * If the above structure is changed, the count will have to be updated
83  * accordingly.
84  */
85 #define	DSCPMK_STATS_COUNT		5
86 #define	DSCPMK_STATS_STRING		"dscpmk_stats"
87 
88 #define	DSCPMK_DSCP_STATS_COUNT		2
89 
90 typedef struct dscp_stats_s {
91 	boolean_t	present;	/* Stats present for this DSCP */
92 	uint64_t	npackets;	/* no. of packets for this DSCP */
93 	ipp_stat_t 	*stats;		/* stats for this DSCP */
94 } dscp_stats_t;
95 
96 /* Per-instance structure */
97 typedef struct dscpmk_data_s {
98 
99 	ipp_action_id_t next_action; 	/* action id of next action */
100 	ipp_stat_t 	*stats;		/* structure for storing stats */
101 
102 	/* inbound DSCP -> outbound DSCP mapping table */
103 	uint8_t 	dscp_map[DSCPMK_ARRAY_COUNT];
104 
105 	/* Minimal stats */
106 	boolean_t 	summary_stats;
107 	uint64_t 	npackets;	/* no. of packets processed by action */
108 	uint64_t 	changed;	/* packets with DSCP changed */
109 	uint64_t 	unchanged;	/* packets with DSCP unchanged */
110 	uint64_t 	ipackets;	/* packets not processed */
111 	uint64_t 	epackets;	/* packets in error */
112 
113 	/* per-DSCP stats */
114 	boolean_t 	detailed_stats;
115 	/* Stats count per DSCP value 0-63 */
116 	dscp_stats_t	dscp_stats[DSCPMK_ARRAY_COUNT];
117 } dscpmk_data_t;
118 
119 #define	DSCPMK_DATA_SZ		sizeof (dscpmk_data_t)
120 
121 #ifdef	_KERNEL
122 extern int dscpmk_process(mblk_t **, dscpmk_data_t *, ip_proc_t);
123 #endif /* _KERNEL */
124 
125 #ifdef	__cplusplus
126 }
127 #endif
128 
129 #endif /* _IPP_DSCPMK_DSCPMK_IMPL_H */
130