186d7f5d3SJohn Marino /* $KAME: altq_cbq.h,v 1.12 2003/10/03 05:05:15 kjc Exp $ */ 286d7f5d3SJohn Marino /* $DragonFly: src/sys/net/altq/altq_cbq.h,v 1.1 2005/02/11 22:25:57 joerg Exp $ */ 386d7f5d3SJohn Marino 486d7f5d3SJohn Marino /* 586d7f5d3SJohn Marino * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved. 686d7f5d3SJohn Marino * 786d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without 886d7f5d3SJohn Marino * modification, are permitted provided that the following conditions 986d7f5d3SJohn Marino * are met: 1086d7f5d3SJohn Marino * 1186d7f5d3SJohn Marino * 1. Redistributions of source code must retain the above copyright 1286d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer. 1386d7f5d3SJohn Marino * 1486d7f5d3SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 1586d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in the 1686d7f5d3SJohn Marino * documentation and/or other materials provided with the distribution. 1786d7f5d3SJohn Marino * 1886d7f5d3SJohn Marino * 3. All advertising materials mentioning features or use of this software 1986d7f5d3SJohn Marino * must display the following acknowledgement: 2086d7f5d3SJohn Marino * This product includes software developed by the SMCC Technology 2186d7f5d3SJohn Marino * Development Group at Sun Microsystems, Inc. 2286d7f5d3SJohn Marino * 2386d7f5d3SJohn Marino * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or 2486d7f5d3SJohn Marino * promote products derived from this software without specific prior 2586d7f5d3SJohn Marino * written permission. 2686d7f5d3SJohn Marino * 2786d7f5d3SJohn Marino * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE 2886d7f5d3SJohn Marino * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is 2986d7f5d3SJohn Marino * provided "as is" without express or implied warranty of any kind. 3086d7f5d3SJohn Marino * 3186d7f5d3SJohn Marino * These notices must be retained in any copies of any part of this software. 3286d7f5d3SJohn Marino */ 3386d7f5d3SJohn Marino 3486d7f5d3SJohn Marino #ifndef _ALTQ_ALTQ_CBQ_H_ 3586d7f5d3SJohn Marino #define _ALTQ_ALTQ_CBQ_H_ 3686d7f5d3SJohn Marino 3786d7f5d3SJohn Marino #include <net/altq/altq.h> 3886d7f5d3SJohn Marino #include <net/altq/altq_rmclass.h> 3986d7f5d3SJohn Marino #include <net/altq/altq_red.h> 4086d7f5d3SJohn Marino #include <net/altq/altq_rio.h> 4186d7f5d3SJohn Marino 4286d7f5d3SJohn Marino #define NULL_CLASS_HANDLE 0 4386d7f5d3SJohn Marino 4486d7f5d3SJohn Marino /* class flags should be same as class flags in rm_class.h */ 4586d7f5d3SJohn Marino #define CBQCLF_RED 0x0001 /* use RED */ 4686d7f5d3SJohn Marino #define CBQCLF_ECN 0x0002 /* use RED/ECN */ 4786d7f5d3SJohn Marino #define CBQCLF_RIO 0x0004 /* use RIO */ 4886d7f5d3SJohn Marino #define CBQCLF_CLEARDSCP 0x0008 /* clear diffserv codepoint */ 4986d7f5d3SJohn Marino #define CBQCLF_BORROW 0x0010 /* borrow from parent */ 5086d7f5d3SJohn Marino 5186d7f5d3SJohn Marino /* class flags only for root class */ 5286d7f5d3SJohn Marino #define CBQCLF_WRR 0x0100 /* weighted-round robin */ 5386d7f5d3SJohn Marino #define CBQCLF_EFFICIENT 0x0200 /* work-conserving */ 5486d7f5d3SJohn Marino 5586d7f5d3SJohn Marino /* class flags for special classes */ 5686d7f5d3SJohn Marino #define CBQCLF_ROOTCLASS 0x1000 /* root class */ 5786d7f5d3SJohn Marino #define CBQCLF_DEFCLASS 0x2000 /* default class */ 5886d7f5d3SJohn Marino #define CBQCLF_CLASSMASK 0xf000 /* class mask */ 5986d7f5d3SJohn Marino 6086d7f5d3SJohn Marino #define CBQ_MAXQSIZE 200 6186d7f5d3SJohn Marino #define CBQ_MAXPRI RM_MAXPRIO 6286d7f5d3SJohn Marino 6386d7f5d3SJohn Marino typedef struct _cbq_class_stats_ { 6486d7f5d3SJohn Marino uint32_t handle; 6586d7f5d3SJohn Marino u_int depth; 6686d7f5d3SJohn Marino 6786d7f5d3SJohn Marino struct pktcntr xmit_cnt; /* packets sent in this class */ 6886d7f5d3SJohn Marino struct pktcntr drop_cnt; /* dropped packets */ 6986d7f5d3SJohn Marino u_int over; /* # times went over limit */ 7086d7f5d3SJohn Marino u_int borrows; /* # times tried to borrow */ 7186d7f5d3SJohn Marino u_int overactions; /* # times invoked overlimit action */ 7286d7f5d3SJohn Marino u_int delays; /* # times invoked delay actions */ 7386d7f5d3SJohn Marino 7486d7f5d3SJohn Marino /* other static class parameters useful for debugging */ 7586d7f5d3SJohn Marino int priority; 7686d7f5d3SJohn Marino int maxidle; 7786d7f5d3SJohn Marino int minidle; 7886d7f5d3SJohn Marino int offtime; 7986d7f5d3SJohn Marino int qmax; 8086d7f5d3SJohn Marino int ns_per_byte; 8186d7f5d3SJohn Marino int wrr_allot; 8286d7f5d3SJohn Marino 8386d7f5d3SJohn Marino int qcnt; /* # packets in queue */ 8486d7f5d3SJohn Marino int avgidle; 8586d7f5d3SJohn Marino 8686d7f5d3SJohn Marino /* red and rio related info */ 8786d7f5d3SJohn Marino int qtype; 8886d7f5d3SJohn Marino struct redstats red[3]; 8986d7f5d3SJohn Marino } class_stats_t; 9086d7f5d3SJohn Marino 9186d7f5d3SJohn Marino #ifdef _KERNEL 9286d7f5d3SJohn Marino /* 9386d7f5d3SJohn Marino * Define macros only good for kernel drivers and modules. 9486d7f5d3SJohn Marino */ 9586d7f5d3SJohn Marino #define CBQ_WATCHDOG (hz / 20) 9686d7f5d3SJohn Marino #define CBQ_TIMEOUT 10 9786d7f5d3SJohn Marino #define CBQ_LS_TIMEOUT (20 * hz / 1000) 9886d7f5d3SJohn Marino 9986d7f5d3SJohn Marino #define CBQ_MAX_CLASSES 256 10086d7f5d3SJohn Marino 10186d7f5d3SJohn Marino /* 10286d7f5d3SJohn Marino * Define State structures. 10386d7f5d3SJohn Marino */ 10486d7f5d3SJohn Marino typedef struct cbqstate { 10586d7f5d3SJohn Marino int cbq_qlen; /* # of packets in cbq */ 10686d7f5d3SJohn Marino struct rm_class *cbq_class_tbl[CBQ_MAX_CLASSES]; 10786d7f5d3SJohn Marino 10886d7f5d3SJohn Marino struct rm_ifdat ifnp; 10986d7f5d3SJohn Marino struct callout cbq_callout; /* for timeouts */ 11086d7f5d3SJohn Marino } cbq_state_t; 11186d7f5d3SJohn Marino 11286d7f5d3SJohn Marino #endif /* _KERNEL */ 11386d7f5d3SJohn Marino 11486d7f5d3SJohn Marino #endif /* !_ALTQ_ALTQ_CBQ_H_ */ 115