1 /* 2 * Copyright (c) 2011-2016 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 29 /* $NetBSD: altq_hfsc.h,v 1.8 2006/10/12 19:59:08 peter Exp $ */ 30 /* $KAME: altq_hfsc.h,v 1.12 2003/12/05 05:40:46 kjc Exp $ */ 31 32 /* 33 * Copyright (c) 1997-1999 Carnegie Mellon University. All Rights Reserved. 34 * 35 * Permission to use, copy, modify, and distribute this software and 36 * its documentation is hereby granted (including for commercial or 37 * for-profit use), provided that both the copyright notice and this 38 * permission notice appear in all copies of the software, derivative 39 * works, or modified versions, and any portions thereof. 40 * 41 * THIS SOFTWARE IS EXPERIMENTAL AND IS KNOWN TO HAVE BUGS, SOME OF 42 * WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON PROVIDES THIS 43 * SOFTWARE IN ITS ``AS IS'' CONDITION, AND ANY EXPRESS OR IMPLIED 44 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 45 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 46 * DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE 47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 48 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 49 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 50 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 51 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 53 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 54 * DAMAGE. 55 * 56 * Carnegie Mellon encourages (but does not require) users of this 57 * software to return any improvements or extensions that they make, 58 * and to grant Carnegie Mellon the rights to redistribute these 59 * changes without encumbrance. 60 */ 61 #ifndef _NET_PKTSCHED_PKTSCHED_HFSC_H_ 62 #define _NET_PKTSCHED_PKTSCHED_HFSC_H_ 63 64 #ifdef PRIVATE 65 #include <net/pktsched/pktsched.h> 66 #include <net/classq/classq.h> 67 #include <net/classq/classq_red.h> 68 #include <net/classq/classq_rio.h> 69 #include <net/classq/classq_blue.h> 70 #include <net/classq/classq_sfb.h> 71 72 #ifdef __cplusplus 73 extern "C" { 74 #endif 75 76 struct service_curve { 77 u_int32_t fl; /* service curve flags */ 78 u_int64_t m1; /* slope of the first segment in bits/sec */ 79 u_int32_t d; /* the x-projection of the first segment in msec */ 80 u_int64_t m2; /* slope of the second segment in bits/sec */ 81 }; 82 83 /* valid values for service curve flags */ 84 #define HFSCF_M1_PCT 0x1 /* m1 is in percentage */ 85 #define HFSCF_M2_PCT 0x10 /* m2 is in percentage */ 86 87 #define HFSCF_USERFLAGS (HFSCF_M1_PCT | HFSCF_M2_PCT) 88 89 /* special class handles */ 90 #define HFSC_NULLCLASS_HANDLE 0 91 #define HFSC_MAX_CLASSES 64 92 93 /* hfsc class flags */ 94 #define HFCF_RED 0x0001 /* use RED */ 95 #define HFCF_ECN 0x0002 /* use ECN with RED/BLUE/SFB */ 96 #define HFCF_RIO 0x0004 /* use RIO */ 97 #define HFCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ 98 #define HFCF_BLUE 0x0100 /* use BLUE */ 99 #define HFCF_SFB 0x0200 /* use SFB */ 100 #define HFCF_FLOWCTL 0x0400 /* enable flow control advisories */ 101 #define HFCF_DEFAULTCLASS 0x1000 /* default class */ 102 #ifdef BSD_KERNEL_PRIVATE 103 #define HFCF_RSC 0x10000 /* has realtime sc */ 104 #define HFCF_FSC 0x20000 /* has linkshare sc */ 105 #define HFCF_USC 0x40000 /* has upperlimit sc */ 106 #define HFCF_LAZY 0x10000000 /* on-demand resource allocation */ 107 #endif /* BSD_KERNEL_PRIVATE */ 108 109 #define HFCF_USERFLAGS \ 110 (HFCF_RED | HFCF_ECN | HFCF_RIO | HFCF_CLEARDSCP | HFCF_BLUE | \ 111 HFCF_SFB | HFCF_FLOWCTL | HFCF_DEFAULTCLASS) 112 113 #ifdef BSD_KERNEL_PRIVATE 114 #define HFCF_BITS \ 115 "\020\1RED\2ECN\3RIO\5CLEARDSCP\11BLUE\12SFB\13FLOWCTL\15DEFAULT" \ 116 "\21RSC\22FSC\23USC\35LAZY" 117 #else 118 #define HFCF_BITS \ 119 "\020\1RED\2ECN\3RIO\5CLEARDSCP\11BLUE\12SFB\13FLOWCTL\15DEFAULT" 120 #endif /* !BSD_KERNEL_PRIVATE */ 121 122 /* service curve types */ 123 #define HFSC_REALTIMESC 1 124 #define HFSC_LINKSHARINGSC 2 125 #define HFSC_UPPERLIMITSC 4 126 #define HFSC_DEFAULTSC (HFSC_REALTIMESC|HFSC_LINKSHARINGSC) 127 128 struct hfsc_classstats { 129 u_int32_t class_id; 130 u_int32_t class_handle; 131 struct service_curve rsc; 132 struct service_curve fsc; 133 struct service_curve usc; /* upper limit service curve */ 134 135 u_int64_t total; /* total work in bytes */ 136 u_int64_t cumul; /* cumulative work in bytes */ 137 /* done by real-time criteria */ 138 u_int64_t d; /* deadline */ 139 u_int64_t e; /* eligible time */ 140 u_int64_t vt; /* virtual time */ 141 u_int64_t f; /* fit time for upper-limit */ 142 143 /* info helpful for debugging */ 144 u_int64_t initvt; /* init virtual time */ 145 u_int64_t vtoff; /* cl_vt_ipoff */ 146 u_int64_t cvtmax; /* cl_maxvt */ 147 u_int64_t myf; /* cl_myf */ 148 u_int64_t cfmin; /* cl_mincf */ 149 u_int64_t cvtmin; /* cl_mincvt */ 150 u_int64_t myfadj; /* cl_myfadj */ 151 u_int64_t vtadj; /* cl_vtadj */ 152 u_int64_t cur_time; 153 u_int32_t machclk_freq; 154 155 u_int32_t qlength; 156 u_int32_t qlimit; 157 struct pktcntr xmit_cnt; 158 struct pktcntr drop_cnt; 159 u_int32_t period; 160 161 u_int32_t vtperiod; /* vt period sequence no */ 162 u_int32_t parentperiod; /* parent's vt period seqno */ 163 int nactive; /* number of active children */ 164 165 /* RED, RIO, BLUE, SFB related info */ 166 classq_type_t qtype; 167 union { 168 /* RIO has 3 red stats */ 169 struct red_stats red[RIO_NDROPPREC]; 170 struct blue_stats blue; 171 struct sfb_stats sfb; 172 }; 173 classq_state_t qstate; 174 }; 175 176 #ifdef __cplusplus 177 } 178 #endif 179 #endif /* PRIVATE */ 180 #endif /* _NET_PKTSCHED_PKTSCHED_HFSC_H_ */ 181