1 /* $OpenBSD: altq_cbq.h,v 1.10 2004/01/14 08:42:23 kjc Exp $ */
2 /* $KAME: altq_cbq.h,v 1.5 2000/12/02 13:44:40 kjc Exp $ */
3
4 /*
5 * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the SMCC Technology
21 * Development Group at Sun Microsystems, Inc.
22 *
23 * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or
24 * promote products derived from this software without specific prior
25 * written permission.
26 *
27 * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE
28 * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is
29 * provided "as is" without express or implied warranty of any kind.
30 *
31 * These notices must be retained in any copies of any part of this software.
32 */
33
34 #ifndef _ALTQ_ALTQ_CBQ_H_
35 #define _ALTQ_ALTQ_CBQ_H_
36
37 #include <altq/altq.h>
38 #include <altq/altq_rmclass.h>
39 #include <altq/altq_red.h>
40 #include <altq/altq_rio.h>
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #define NULL_CLASS_HANDLE 0
47
48 /* class flags should be same as class flags in rm_class.h */
49 #define CBQCLF_RED 0x0001 /* use RED */
50 #define CBQCLF_ECN 0x0002 /* use RED/ECN */
51 #define CBQCLF_RIO 0x0004 /* use RIO */
52 #define CBQCLF_FLOWVALVE 0x0008 /* use flowvalve (aka penalty-box) */
53 #define CBQCLF_CLEARDSCP 0x0010 /* clear diffserv codepoint */
54 #define CBQCLF_BORROW 0x0020 /* borrow from parent */
55
56 /* class flags only for root class */
57 #define CBQCLF_WRR 0x0100 /* weighted-round robin */
58 #define CBQCLF_EFFICIENT 0x0200 /* work-conserving */
59
60 /* class flags for special classes */
61 #define CBQCLF_ROOTCLASS 0x1000 /* root class */
62 #define CBQCLF_DEFCLASS 0x2000 /* default class */
63 #define CBQCLF_CLASSMASK 0xf000 /* class mask */
64
65 #define CBQ_MAXQSIZE 200
66 #define CBQ_MAXPRI RM_MAXPRIO
67
68 typedef struct _cbq_class_stats_ {
69 u_int32_t handle;
70 u_int depth;
71
72 struct pktcntr xmit_cnt; /* packets sent in this class */
73 struct pktcntr drop_cnt; /* dropped packets */
74 u_int over; /* # times went over limit */
75 u_int borrows; /* # times tried to borrow */
76 u_int overactions; /* # times invoked overlimit action */
77 u_int delays; /* # times invoked delay actions */
78
79 /* other static class parameters useful for debugging */
80 int priority;
81 int maxidle;
82 int minidle;
83 int offtime;
84 int qmax;
85 int ns_per_byte;
86 int wrr_allot;
87
88 int qcnt; /* # packets in queue */
89 int avgidle;
90
91 /* red and rio related info */
92 int qtype;
93 struct redstats red[3];
94 } class_stats_t;
95
96 #ifdef _KERNEL
97 /*
98 * Define macros only good for kernel drivers and modules.
99 */
100 #define CBQ_WATCHDOG (hz / 20)
101 #define CBQ_TIMEOUT 10
102 #define CBQ_LS_TIMEOUT (20 * hz / 1000)
103
104 #define CBQ_MAX_CLASSES 256
105
106 /*
107 * Define State structures.
108 */
109 typedef struct cbqstate {
110 int cbq_qlen; /* # of packets in cbq */
111 struct rm_class *cbq_class_tbl[CBQ_MAX_CLASSES];
112
113 struct rm_ifdat ifnp;
114 struct callout cbq_callout; /* for timeouts */
115 } cbq_state_t;
116
117 #endif /* _KERNEL */
118
119 #ifdef __cplusplus
120 }
121 #endif
122
123 #endif /* !_ALTQ_ALTQ_CBQ_H_ */