1 /* $NetBSD: altq_cbq.h,v 1.7.12.1 2006/03/18 12:08:18 peter Exp $ */
2 /* $KAME: altq_cbq.h,v 1.12 2003/10/03 05:05:15 kjc Exp $ */
5 * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
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.
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.
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
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.
31 * These notices must be retained in any copies of any part of this software.
34 #ifndef _ALTQ_ALTQ_CBQ_H_
35 #define _ALTQ_ALTQ_CBQ_H_
37 #include <altq/altq.h>
38 #include <altq/altq_rmclass.h>
39 #include <altq/altq_red.h>
40 #include <altq/altq_rio.h>
46 #define NULL_CLASS_HANDLE 0
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 */
56 /* class flags only for root class */
57 #define CBQCLF_WRR 0x0100 /* weighted-round robin */
58 #define CBQCLF_EFFICIENT 0x0200 /* work-conserving */
60 /* class flags for special classes */
61 #define CBQCLF_ROOTCLASS 0x1000 /* root class */
62 #define CBQCLF_DEFCLASS 0x2000 /* default class */
64 #define CBQCLF_CTLCLASS 0x4000 /* control class */
66 #define CBQCLF_CLASSMASK 0xf000 /* class mask */
68 #define CBQ_MAXQSIZE 200
69 #define CBQ_MAXPRI RM_MAXPRIO
71 typedef struct _cbq_class_stats_
{
75 struct pktcntr xmit_cnt
; /* packets sent in this class */
76 struct pktcntr drop_cnt
; /* dropped packets */
77 u_int over
; /* # times went over limit */
78 u_int borrows
; /* # times tried to borrow */
79 u_int overactions
; /* # times invoked overlimit action */
80 u_int delays
; /* # times invoked delay actions */
82 /* other static class parameters useful for debugging */
91 int qcnt
; /* # packets in queue */
94 /* red and rio related info */
96 struct redstats red
[3];
101 * Define structures associated with IOCTLS for cbq.
105 * Define the CBQ interface structure. This must be included in all
106 * IOCTL's such that the CBQ driver may find the appropriate CBQ module
107 * associated with the network interface to be affected.
109 struct cbq_interface
{
110 char cbq_ifacename
[IFNAMSIZ
];
113 typedef struct cbq_class_spec
{
115 u_int nano_sec_per_byte
;
120 u_int32_t parent_class_handle
;
121 u_int32_t borrow_class_handle
;
127 struct cbq_add_class
{
128 struct cbq_interface cbq_iface
;
130 cbq_class_spec_t cbq_class
;
131 u_int32_t cbq_class_handle
;
134 struct cbq_delete_class
{
135 struct cbq_interface cbq_iface
;
136 u_int32_t cbq_class_handle
;
139 struct cbq_modify_class
{
140 struct cbq_interface cbq_iface
;
142 cbq_class_spec_t cbq_class
;
143 u_int32_t cbq_class_handle
;
146 struct cbq_add_filter
{
147 struct cbq_interface cbq_iface
;
148 u_int32_t cbq_class_handle
;
149 struct flow_filter cbq_filter
;
151 u_long cbq_filter_handle
;
154 struct cbq_delete_filter
{
155 struct cbq_interface cbq_iface
;
156 u_long cbq_filter_handle
;
159 /* number of classes are returned in nclasses field */
160 struct cbq_getstats
{
161 struct cbq_interface iface
;
163 class_stats_t
*stats
;
167 * Define IOCTLs for CBQ.
169 #define CBQ_IF_ATTACH _IOW('Q', 1, struct cbq_interface)
170 #define CBQ_IF_DETACH _IOW('Q', 2, struct cbq_interface)
171 #define CBQ_ENABLE _IOW('Q', 3, struct cbq_interface)
172 #define CBQ_DISABLE _IOW('Q', 4, struct cbq_interface)
173 #define CBQ_CLEAR_HIERARCHY _IOW('Q', 5, struct cbq_interface)
174 #define CBQ_ADD_CLASS _IOWR('Q', 7, struct cbq_add_class)
175 #define CBQ_DEL_CLASS _IOW('Q', 8, struct cbq_delete_class)
176 #define CBQ_MODIFY_CLASS _IOWR('Q', 9, struct cbq_modify_class)
177 #define CBQ_ADD_FILTER _IOWR('Q', 10, struct cbq_add_filter)
178 #define CBQ_DEL_FILTER _IOW('Q', 11, struct cbq_delete_filter)
179 #define CBQ_GETSTATS _IOWR('Q', 12, struct cbq_getstats)
180 #endif /* ALTQ3_COMPAT */
184 * Define macros only good for kernel drivers and modules.
186 #define CBQ_WATCHDOG (hz / 20)
187 #define CBQ_TIMEOUT 10
188 #define CBQ_LS_TIMEOUT (20 * hz / 1000)
190 #define CBQ_MAX_CLASSES 256
193 #define CBQ_MAX_FILTERS 256
197 #endif /* ALTQ3_COMPAT */
200 * Define State structures.
202 typedef struct cbqstate
{
204 struct cbqstate
*cbq_next
;
206 int cbq_qlen
; /* # of packets in cbq */
207 struct rm_class
*cbq_class_tbl
[CBQ_MAX_CLASSES
];
209 struct rm_ifdat ifnp
;
210 struct callout cbq_callout
; /* for timeouts */
211 #ifdef ALTQ3_CLFIER_COMPAT
212 struct acc_classifier cbq_classifier
;
222 #endif /* !_ALTQ_ALTQ_CBQ_H_ */