/*-1* Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6*7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9*10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* 3. All advertising materials mentioning features or use of this software15* must display the following acknowledgement:16* This product includes software developed by the SMCC Technology17* Development Group at Sun Microsystems, Inc.18*19* 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or20* promote products derived from this software without specific prior21* written permission.22*23* SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE24* SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is25* provided "as is" without express or implied warranty of any kind.26*27* These notices must be retained in any copies of any part of this software.28*29* $KAME: altq_cbq.h,v 1.12 2003/10/03 05:05:15 kjc Exp $30*/3132#ifndef _ALTQ_ALTQ_CBQ_H_33#define _ALTQ_ALTQ_CBQ_H_3435#include <net/altq/altq.h>36#include <net/altq/altq_rmclass.h>37#include <net/altq/altq_codel.h>38#include <net/altq/altq_red.h>39#include <net/altq/altq_rio.h>4041#ifdef __cplusplus42extern "C" {43#endif4445#define NULL_CLASS_HANDLE 04647/* class flags must be same as class flags in altq_rmclass.h */48#define CBQCLF_RED 0x0001 /* use RED */49#define CBQCLF_ECN 0x0002 /* use RED/ECN */50#define CBQCLF_RIO 0x0004 /* use RIO */51#define CBQCLF_FLOWVALVE 0x0008 /* use flowvalve (aka penalty-box) */52#define CBQCLF_CLEARDSCP 0x0010 /* clear diffserv codepoint */53#define CBQCLF_BORROW 0x0020 /* borrow from parent */54#define CBQCLF_CODEL 0x0040 /* use CoDel */5556#ifdef _KERNEL57CTASSERT(CBQCLF_RED == RMCF_RED);58CTASSERT(CBQCLF_ECN == RMCF_ECN);59CTASSERT(CBQCLF_RIO == RMCF_RIO);60CTASSERT(CBQCLF_FLOWVALVE == RMCF_FLOWVALVE);61CTASSERT(CBQCLF_CLEARDSCP == RMCF_CLEARDSCP);62CTASSERT(CBQCLF_CODEL == RMCF_CODEL);63#endif6465/* class flags only for root class */66#define CBQCLF_WRR 0x0100 /* weighted-round robin */67#define CBQCLF_EFFICIENT 0x0200 /* work-conserving */6869/* class flags for special classes */70#define CBQCLF_ROOTCLASS 0x1000 /* root class */71#define CBQCLF_DEFCLASS 0x2000 /* default class */72#define CBQCLF_CLASSMASK 0xf000 /* class mask */7374#define CBQ_MAXQSIZE 20075#define CBQ_MAXPRI RM_MAXPRIO7677typedef struct _cbq_class_stats_ {78u_int32_t handle;79u_int depth;8081struct pktcntr xmit_cnt; /* packets sent in this class */82struct pktcntr drop_cnt; /* dropped packets */83u_int over; /* # times went over limit */84u_int borrows; /* # times tried to borrow */85u_int overactions; /* # times invoked overlimit action */86u_int delays; /* # times invoked delay actions */8788/* other static class parameters useful for debugging */89int priority;90int maxidle;91int minidle;92int offtime;93int qmax;94int ns_per_byte;95int wrr_allot;9697int qcnt; /* # packets in queue */98int avgidle;99100/* codel, red and rio related info */101int qtype;102struct redstats red[3];103struct codel_stats codel;104} class_stats_t;105106/*107* CBQ_STATS_VERSION is defined in altq.h to work around issues stemming108* from mixing of public-API and internal bits in each scheduler-specific109* header.110*/111112#ifdef _KERNEL113/*114* Define macros only good for kernel drivers and modules.115*/116#define CBQ_WATCHDOG (hz / 20)117#define CBQ_TIMEOUT 10118#define CBQ_LS_TIMEOUT (20 * hz / 1000)119120#define CBQ_MAX_CLASSES 2048121122/*123* Define State structures.124*/125typedef struct cbqstate {126int cbq_qlen; /* # of packets in cbq */127struct rm_class *cbq_class_tbl[CBQ_MAX_CLASSES];128129struct rm_ifdat ifnp;130struct callout cbq_callout; /* for timeouts */131#ifdef ALTQ3_CLFIER_COMPAT132struct acc_classifier cbq_classifier;133#endif134} cbq_state_t;135136#endif /* _KERNEL */137138#ifdef __cplusplus139}140#endif141142#endif /* !_ALTQ_ALTQ_CBQ_H_ */143144145