1772e66a6SGleb Smirnoff /*- 2772e66a6SGleb Smirnoff * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved. 3772e66a6SGleb Smirnoff * 4772e66a6SGleb Smirnoff * Redistribution and use in source and binary forms, with or without 5772e66a6SGleb Smirnoff * modification, are permitted provided that the following conditions 6772e66a6SGleb Smirnoff * are met: 7772e66a6SGleb Smirnoff * 8772e66a6SGleb Smirnoff * 1. Redistributions of source code must retain the above copyright 9772e66a6SGleb Smirnoff * notice, this list of conditions and the following disclaimer. 10772e66a6SGleb Smirnoff * 11772e66a6SGleb Smirnoff * 2. Redistributions in binary form must reproduce the above copyright 12772e66a6SGleb Smirnoff * notice, this list of conditions and the following disclaimer in the 13772e66a6SGleb Smirnoff * documentation and/or other materials provided with the distribution. 14772e66a6SGleb Smirnoff * 15772e66a6SGleb Smirnoff * 3. All advertising materials mentioning features or use of this software 16772e66a6SGleb Smirnoff * must display the following acknowledgement: 17772e66a6SGleb Smirnoff * This product includes software developed by the SMCC Technology 18772e66a6SGleb Smirnoff * Development Group at Sun Microsystems, Inc. 19772e66a6SGleb Smirnoff * 20772e66a6SGleb Smirnoff * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or 21772e66a6SGleb Smirnoff * promote products derived from this software without specific prior 22772e66a6SGleb Smirnoff * written permission. 23772e66a6SGleb Smirnoff * 24772e66a6SGleb Smirnoff * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE 25772e66a6SGleb Smirnoff * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is 26772e66a6SGleb Smirnoff * provided "as is" without express or implied warranty of any kind. 27772e66a6SGleb Smirnoff * 28772e66a6SGleb Smirnoff * These notices must be retained in any copies of any part of this software. 29772e66a6SGleb Smirnoff * 30772e66a6SGleb Smirnoff * $KAME: altq_cbq.h,v 1.12 2003/10/03 05:05:15 kjc Exp $ 31772e66a6SGleb Smirnoff */ 32772e66a6SGleb Smirnoff 33772e66a6SGleb Smirnoff #ifndef _ALTQ_ALTQ_CBQ_H_ 34772e66a6SGleb Smirnoff #define _ALTQ_ALTQ_CBQ_H_ 35772e66a6SGleb Smirnoff 36772e66a6SGleb Smirnoff #include <net/altq/altq.h> 37772e66a6SGleb Smirnoff #include <net/altq/altq_rmclass.h> 380a70aaf8SLuiz Otavio O Souza #include <net/altq/altq_codel.h> 39772e66a6SGleb Smirnoff #include <net/altq/altq_red.h> 40772e66a6SGleb Smirnoff #include <net/altq/altq_rio.h> 41772e66a6SGleb Smirnoff 42772e66a6SGleb Smirnoff #ifdef __cplusplus 43772e66a6SGleb Smirnoff extern "C" { 44772e66a6SGleb Smirnoff #endif 45772e66a6SGleb Smirnoff 46772e66a6SGleb Smirnoff #define NULL_CLASS_HANDLE 0 47772e66a6SGleb Smirnoff 48456e896dSMike Karels /* class flags must be same as class flags in altq_rmclass.h */ 49772e66a6SGleb Smirnoff #define CBQCLF_RED 0x0001 /* use RED */ 50772e66a6SGleb Smirnoff #define CBQCLF_ECN 0x0002 /* use RED/ECN */ 51772e66a6SGleb Smirnoff #define CBQCLF_RIO 0x0004 /* use RIO */ 52772e66a6SGleb Smirnoff #define CBQCLF_FLOWVALVE 0x0008 /* use flowvalve (aka penalty-box) */ 53772e66a6SGleb Smirnoff #define CBQCLF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ 54772e66a6SGleb Smirnoff #define CBQCLF_BORROW 0x0020 /* borrow from parent */ 550a70aaf8SLuiz Otavio O Souza #define CBQCLF_CODEL 0x0040 /* use CoDel */ 56772e66a6SGleb Smirnoff 57456e896dSMike Karels #ifdef _KERNEL 58456e896dSMike Karels CTASSERT(CBQCLF_RED == RMCF_RED); 59456e896dSMike Karels CTASSERT(CBQCLF_ECN == RMCF_ECN); 60456e896dSMike Karels CTASSERT(CBQCLF_RIO == RMCF_RIO); 61456e896dSMike Karels CTASSERT(CBQCLF_FLOWVALVE == RMCF_FLOWVALVE); 62456e896dSMike Karels CTASSERT(CBQCLF_CLEARDSCP == RMCF_CLEARDSCP); 63456e896dSMike Karels CTASSERT(CBQCLF_CODEL == RMCF_CODEL); 64456e896dSMike Karels #endif 65456e896dSMike Karels 66772e66a6SGleb Smirnoff /* class flags only for root class */ 67772e66a6SGleb Smirnoff #define CBQCLF_WRR 0x0100 /* weighted-round robin */ 68772e66a6SGleb Smirnoff #define CBQCLF_EFFICIENT 0x0200 /* work-conserving */ 69772e66a6SGleb Smirnoff 70772e66a6SGleb Smirnoff /* class flags for special classes */ 71772e66a6SGleb Smirnoff #define CBQCLF_ROOTCLASS 0x1000 /* root class */ 72772e66a6SGleb Smirnoff #define CBQCLF_DEFCLASS 0x2000 /* default class */ 73772e66a6SGleb Smirnoff #define CBQCLF_CLASSMASK 0xf000 /* class mask */ 74772e66a6SGleb Smirnoff 75772e66a6SGleb Smirnoff #define CBQ_MAXQSIZE 200 76772e66a6SGleb Smirnoff #define CBQ_MAXPRI RM_MAXPRIO 77772e66a6SGleb Smirnoff 78772e66a6SGleb Smirnoff typedef struct _cbq_class_stats_ { 79772e66a6SGleb Smirnoff u_int32_t handle; 80772e66a6SGleb Smirnoff u_int depth; 81772e66a6SGleb Smirnoff 82772e66a6SGleb Smirnoff struct pktcntr xmit_cnt; /* packets sent in this class */ 83772e66a6SGleb Smirnoff struct pktcntr drop_cnt; /* dropped packets */ 84772e66a6SGleb Smirnoff u_int over; /* # times went over limit */ 85772e66a6SGleb Smirnoff u_int borrows; /* # times tried to borrow */ 86772e66a6SGleb Smirnoff u_int overactions; /* # times invoked overlimit action */ 87772e66a6SGleb Smirnoff u_int delays; /* # times invoked delay actions */ 88772e66a6SGleb Smirnoff 89772e66a6SGleb Smirnoff /* other static class parameters useful for debugging */ 90772e66a6SGleb Smirnoff int priority; 91772e66a6SGleb Smirnoff int maxidle; 92772e66a6SGleb Smirnoff int minidle; 93772e66a6SGleb Smirnoff int offtime; 94772e66a6SGleb Smirnoff int qmax; 95772e66a6SGleb Smirnoff int ns_per_byte; 96772e66a6SGleb Smirnoff int wrr_allot; 97772e66a6SGleb Smirnoff 98772e66a6SGleb Smirnoff int qcnt; /* # packets in queue */ 99772e66a6SGleb Smirnoff int avgidle; 100772e66a6SGleb Smirnoff 1010a70aaf8SLuiz Otavio O Souza /* codel, red and rio related info */ 102772e66a6SGleb Smirnoff int qtype; 103772e66a6SGleb Smirnoff struct redstats red[3]; 1040a70aaf8SLuiz Otavio O Souza struct codel_stats codel; 105772e66a6SGleb Smirnoff } class_stats_t; 106772e66a6SGleb Smirnoff 107249cc75fSPatrick Kelsey /* 108249cc75fSPatrick Kelsey * CBQ_STATS_VERSION is defined in altq.h to work around issues stemming 109249cc75fSPatrick Kelsey * from mixing of public-API and internal bits in each scheduler-specific 110249cc75fSPatrick Kelsey * header. 111249cc75fSPatrick Kelsey */ 112249cc75fSPatrick Kelsey 113772e66a6SGleb Smirnoff #ifdef _KERNEL 114772e66a6SGleb Smirnoff /* 115772e66a6SGleb Smirnoff * Define macros only good for kernel drivers and modules. 116772e66a6SGleb Smirnoff */ 117772e66a6SGleb Smirnoff #define CBQ_WATCHDOG (hz / 20) 118772e66a6SGleb Smirnoff #define CBQ_TIMEOUT 10 119772e66a6SGleb Smirnoff #define CBQ_LS_TIMEOUT (20 * hz / 1000) 120772e66a6SGleb Smirnoff 121*448732b8SKristof Provost #define CBQ_MAX_CLASSES 2048 122772e66a6SGleb Smirnoff 123772e66a6SGleb Smirnoff /* 124772e66a6SGleb Smirnoff * Define State structures. 125772e66a6SGleb Smirnoff */ 126772e66a6SGleb Smirnoff typedef struct cbqstate { 127772e66a6SGleb Smirnoff int cbq_qlen; /* # of packets in cbq */ 128772e66a6SGleb Smirnoff struct rm_class *cbq_class_tbl[CBQ_MAX_CLASSES]; 129772e66a6SGleb Smirnoff 130772e66a6SGleb Smirnoff struct rm_ifdat ifnp; 131772e66a6SGleb Smirnoff struct callout cbq_callout; /* for timeouts */ 132772e66a6SGleb Smirnoff #ifdef ALTQ3_CLFIER_COMPAT 133772e66a6SGleb Smirnoff struct acc_classifier cbq_classifier; 134772e66a6SGleb Smirnoff #endif 135772e66a6SGleb Smirnoff } cbq_state_t; 136772e66a6SGleb Smirnoff 137772e66a6SGleb Smirnoff #endif /* _KERNEL */ 138772e66a6SGleb Smirnoff 139772e66a6SGleb Smirnoff #ifdef __cplusplus 140772e66a6SGleb Smirnoff } 141772e66a6SGleb Smirnoff #endif 142772e66a6SGleb Smirnoff 143772e66a6SGleb Smirnoff #endif /* !_ALTQ_ALTQ_CBQ_H_ */ 144