xref: /titanic_41/usr/src/uts/common/ipp/dlcosmk/dlcosmk_impl.h (revision 70025d765b044c6d8594bb965a2247a61e991a99)
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_DLCOSMK_DLCOSMK_IMPL_H
28 #define	_IPP_DLCOSMK_DLCOSMK_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/dlcosmk/dlcosmk.h>
36 #include <inet/ipp_common.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /* Header file for implementation of DL CoS marker ipp action module */
43 
44 #define	_DLCOSMK_DEBUG
45 
46 /* The 3-MSB in the ToS/Dsfield are used to map to the 802.1D user priority */
47 #define	TOS_CLASS_MASK		5
48 /* 802.1D user priority is 3 bits - 0-7 */
49 #define	UPRI_MAP_COUNT		8
50 /* This will be used it the ToS/Dsfield needs to be mapped */
51 #define	MAP_TOS_TO_UPRI		8
52 
53 #ifdef _DLCOSMK_DEBUG
54 #include <sys/debug.h>
55 #define	dlcosmk0dbg(a)		printf a
56 #define	dlcosmk1dbg(a)		if (dlcosmk_debug > 2) printf a
57 #define	dlcosmk2dbg(a)		if (dlcosmk_debug > 3) printf a
58 #else
59 #define	dlcosmk0dbg(a)
60 #define	dlcosmk1dbg(a)
61 #define	dlcosmk2dbg(a)
62 #endif /* _DLCOSMK_DEBUG */
63 
64 /* dlcosmk stats info. available using kstats */
65 typedef struct dlcosmk_stat_s {
66 	ipp_named_t	npackets;	/* no. of pkts seen by this instance */
67 	ipp_named_t	ipackets;	/* no. of pkts not processed */
68 	ipp_named_t	epackets;	/* no. of pkts in error */
69 	ipp_named_t	usr_pri;	/* configured 802.1D priority */
70 	ipp_named_t	b_band;		/* Mapped b_band for the priority */
71 	ipp_named_t	dl_max;		/* Mapped dl_max for the priority */
72 } dlcosmk_stat_t;
73 
74 /*
75  * If the above structure is changed, the count will have to be updated
76  * accordingly.
77  */
78 #define	DLCOSMK_STATS_COUNT		6
79 #define	DLCOSMK_STATS_STRING		"dlcosmk statistics"
80 
81 /*
82  * Table containing 802.1D user_priority -> b_band/dl_max mappings.
83  * The mappings have been taken from the VLAN driver.
84  */
85 typedef struct usrpri_tbl_s {
86 	uchar_t b_band;
87 	t_scalar_t dl_max;
88 } usrpri_tbl_t;
89 
90 extern usrpri_tbl_t usrpri_tbl[UPRI_MAP_COUNT];
91 
92 #define	UPRI_TBL_SZ		sizeof (usrpri_tbl_t)
93 
94 /* Per-instance data structure */
95 typedef struct dlcosmk_data_s {
96 	ipp_action_id_t next_action; 	/* action id of next action */
97 	ipp_stat_t 	*stats;		/* stats for this instance */
98 	uint8_t 	usr_pri;	/* 802.1d user priority */
99 	uchar_t 	b_band;		/* corresponding bband */
100 	t_scalar_t 	dl_max;		/* corresponding dl_max */
101 	boolean_t 	gather_stats;	/* stats collected or not */
102 	uint64_t 	npackets;	/* no. of pkts. for this instance */
103 	uint64_t 	epackets;	/* no. of pkts. in error */
104 	uint64_t 	ipackets;	/* no. of pkts. not processed */
105 } dlcosmk_data_t;
106 
107 #define	DLCOSMK_DATA_SZ		sizeof (dlcosmk_data_t)
108 
109 /*
110  * ToS -> user_priority mapping. This mapping is local to this implementation
111  * i.e., the ToS -> 802.1D mapping is not a standard.
112  */
113 extern uint8_t tos_to_usrpri[UPRI_MAP_COUNT];
114 
115 #ifdef _KERNEL
116 extern int dlcosmk_debug;
117 extern int dlcosmk_process(mblk_t **, dlcosmk_data_t *, uint32_t, ip_proc_t);
118 #endif /* _KERNEL */
119 
120 #ifdef	__cplusplus
121 }
122 #endif
123 
124 #endif /* _IPP_DLCOSMK_DLCOSMK_IMPL_H */
125