summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/ipp/dlcosmk/dlcosmk_impl.h
blob: 3262bd0c3e4c4266020c59c26d405f4bc4559114 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _IPP_DLCOSMK_DLCOSMK_IMPL_H
#define	_IPP_DLCOSMK_DLCOSMK_IMPL_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#include <sys/types.h>
#include <sys/cmn_err.h>
#include <ipp/ipp.h>
#include <ipp/dlcosmk/dlcosmk.h>
#include <inet/ipp_common.h>

#ifdef	__cplusplus
extern "C" {
#endif

/* Header file for implementation of DL CoS marker ipp action module */

#define	_DLCOSMK_DEBUG

/* The 3-MSB in the ToS/Dsfield are used to map to the 802.1D user priority */
#define	TOS_CLASS_MASK		5
/* 802.1D user priority is 3 bits - 0-7 */
#define	UPRI_MAP_COUNT		8
/* This will be used it the ToS/Dsfield needs to be mapped */
#define	MAP_TOS_TO_UPRI		8

#ifdef _DLCOSMK_DEBUG
#include <sys/debug.h>
#define	dlcosmk0dbg(a)		printf a
#define	dlcosmk1dbg(a)		if (dlcosmk_debug > 2) printf a
#define	dlcosmk2dbg(a)		if (dlcosmk_debug > 3) printf a
#else
#define	dlcosmk0dbg(a)
#define	dlcosmk1dbg(a)
#define	dlcosmk2dbg(a)
#endif /* _DLCOSMK_DEBUG */

/* dlcosmk stats info. available using kstats */
typedef struct dlcosmk_stat_s {
	ipp_named_t	npackets;	/* no. of pkts seen by this instance */
	ipp_named_t	ipackets;	/* no. of pkts not processed */
	ipp_named_t	epackets;	/* no. of pkts in error */
	ipp_named_t	usr_pri;	/* configured 802.1D priority */
	ipp_named_t	b_band;		/* Mapped b_band for the priority */
	ipp_named_t	dl_max;		/* Mapped dl_max for the priority */
} dlcosmk_stat_t;

/*
 * If the above structure is changed, the count will have to be updated
 * accordingly.
 */
#define	DLCOSMK_STATS_COUNT		6
#define	DLCOSMK_STATS_STRING		"dlcosmk statistics"

/*
 * Table containing 802.1D user_priority -> b_band/dl_max mappings.
 * The mappings have been taken from the VLAN driver.
 */
typedef struct usrpri_tbl_s {
	uchar_t b_band;
	t_scalar_t dl_max;
} usrpri_tbl_t;

extern usrpri_tbl_t usrpri_tbl[UPRI_MAP_COUNT];

#define	UPRI_TBL_SZ		sizeof (usrpri_tbl_t)

/* Per-instance data structure */
typedef struct dlcosmk_data_s {
	ipp_action_id_t next_action; 	/* action id of next action */
	ipp_stat_t 	*stats;		/* stats for this instance */
	uint8_t 	usr_pri;	/* 802.1d user priority */
	uchar_t 	b_band;		/* corresponding bband */
	t_scalar_t 	dl_max;		/* corresponding dl_max */
	boolean_t 	gather_stats;	/* stats collected or not */
	uint64_t 	npackets;	/* no. of pkts. for this instance */
	uint64_t 	epackets;	/* no. of pkts. in error */
	uint64_t 	ipackets;	/* no. of pkts. not processed */
} dlcosmk_data_t;

#define	DLCOSMK_DATA_SZ		sizeof (dlcosmk_data_t)

/*
 * ToS -> user_priority mapping. This mapping is local to this implementation
 * i.e., the ToS -> 802.1D mapping is not a standard.
 */
extern uint8_t tos_to_usrpri[UPRI_MAP_COUNT];

#ifdef _KERNEL
extern int dlcosmk_debug;
extern int dlcosmk_process(mblk_t **, dlcosmk_data_t *, uint32_t, ip_proc_t);
#endif /* _KERNEL */

#ifdef	__cplusplus
}
#endif

#endif /* _IPP_DLCOSMK_DLCOSMK_IMPL_H */