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