altq_cbq.h revision 1.1.1.1 1 1.1 thorpej /* $KAME: altq_cbq.h,v 1.5 2000/12/02 13:44:40 kjc Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*
4 1.1 thorpej * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved.
5 1.1 thorpej *
6 1.1 thorpej * Redistribution and use in source and binary forms, with or without
7 1.1 thorpej * modification, are permitted provided that the following conditions
8 1.1 thorpej * are met:
9 1.1 thorpej *
10 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
11 1.1 thorpej * notice, this list of conditions and the following disclaimer.
12 1.1 thorpej *
13 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
15 1.1 thorpej * documentation and/or other materials provided with the distribution.
16 1.1 thorpej *
17 1.1 thorpej * 3. All advertising materials mentioning features or use of this software
18 1.1 thorpej * must display the following acknowledgement:
19 1.1 thorpej * This product includes software developed by the SMCC Technology
20 1.1 thorpej * Development Group at Sun Microsystems, Inc.
21 1.1 thorpej *
22 1.1 thorpej * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or
23 1.1 thorpej * promote products derived from this software without specific prior
24 1.1 thorpej * written permission.
25 1.1 thorpej *
26 1.1 thorpej * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE
27 1.1 thorpej * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is
28 1.1 thorpej * provided "as is" without express or implied warranty of any kind.
29 1.1 thorpej *
30 1.1 thorpej * These notices must be retained in any copies of any part of this software.
31 1.1 thorpej */
32 1.1 thorpej
33 1.1 thorpej #ifndef _ALTQ_ALTQ_CBQ_H_
34 1.1 thorpej #define _ALTQ_ALTQ_CBQ_H_
35 1.1 thorpej
36 1.1 thorpej #include <sys/ioccom.h>
37 1.1 thorpej #include <altq/altq.h>
38 1.1 thorpej #include <altq/altq_rmclass.h>
39 1.1 thorpej #include <altq/altq_red.h>
40 1.1 thorpej #include <altq/altq_rio.h>
41 1.1 thorpej
42 1.1 thorpej /* #pragma ident "@(#)cbq.h 1.18 98/05/13 SMI" */
43 1.1 thorpej
44 1.1 thorpej #ifdef __cplusplus
45 1.1 thorpej extern "C" {
46 1.1 thorpej #endif
47 1.1 thorpej
48 1.1 thorpej /*
49 1.1 thorpej * Define a well known class handles
50 1.1 thorpej */
51 1.1 thorpej #define NULL_CLASS_HANDLE 0xffffffff
52 1.1 thorpej #define ROOT_CLASS_HANDLE 0xfffffffe
53 1.1 thorpej #define DEFAULT_CLASS_HANDLE 0xfffffffd
54 1.1 thorpej #define CTL_CLASS_HANDLE 0xfffffffc
55 1.1 thorpej
56 1.1 thorpej /*
57 1.1 thorpej * Define structures associated with IOCTLS for cbq.
58 1.1 thorpej */
59 1.1 thorpej
60 1.1 thorpej /*
61 1.1 thorpej * Define the CBQ interface structure. This must be included in all
62 1.1 thorpej * IOCTL's such that the CBQ driver may find the appropriate CBQ module
63 1.1 thorpej * associated with the network interface to be affected.
64 1.1 thorpej */
65 1.1 thorpej struct cbq_interface {
66 1.1 thorpej char cbq_ifacename[IFNAMSIZ];
67 1.1 thorpej };
68 1.1 thorpej
69 1.1 thorpej typedef struct cbq_class_spec {
70 1.1 thorpej u_int priority;
71 1.1 thorpej u_int nano_sec_per_byte;
72 1.1 thorpej u_int maxq;
73 1.1 thorpej u_int maxidle;
74 1.1 thorpej int minidle;
75 1.1 thorpej u_int offtime;
76 1.1 thorpej u_long parent_class_handle;
77 1.1 thorpej u_long borrow_class_handle;
78 1.1 thorpej
79 1.1 thorpej u_int pktsize;
80 1.1 thorpej int flags;
81 1.1 thorpej } cbq_class_spec_t;
82 1.1 thorpej
83 1.1 thorpej /* class flags shoud be same as class flags in rm_class.h */
84 1.1 thorpej #define CBQCLF_RED 0x0001 /* use RED */
85 1.1 thorpej #define CBQCLF_ECN 0x0002 /* use RED/ECN */
86 1.1 thorpej #define CBQCLF_RIO 0x0004 /* use RIO */
87 1.1 thorpej #define CBQCLF_FLOWVALVE 0x0008 /* use flowvalve (aka penalty-box) */
88 1.1 thorpej #define CBQCLF_CLEARDSCP 0x0010 /* clear diffserv codepoint */
89 1.1 thorpej
90 1.1 thorpej /* class flags only for root class */
91 1.1 thorpej #define CBQCLF_WRR 0x0100 /* weighted-round robin */
92 1.1 thorpej #define CBQCLF_EFFICIENT 0x0200 /* work-conserving */
93 1.1 thorpej
94 1.1 thorpej /* class flags for special classes */
95 1.1 thorpej #define CBQCLF_ROOTCLASS 0x1000 /* root class */
96 1.1 thorpej #define CBQCLF_DEFCLASS 0x2000 /* default class */
97 1.1 thorpej #define CBQCLF_CTLCLASS 0x4000 /* control class */
98 1.1 thorpej #define CBQCLF_CLASSMASK 0xf000 /* class mask */
99 1.1 thorpej
100 1.1 thorpej #define CBQ_MAXQSIZE 200
101 1.1 thorpej
102 1.1 thorpej struct cbq_add_class {
103 1.1 thorpej struct cbq_interface cbq_iface;
104 1.1 thorpej
105 1.1 thorpej cbq_class_spec_t cbq_class;
106 1.1 thorpej u_long cbq_class_handle;
107 1.1 thorpej };
108 1.1 thorpej
109 1.1 thorpej struct cbq_delete_class {
110 1.1 thorpej struct cbq_interface cbq_iface;
111 1.1 thorpej u_long cbq_class_handle;
112 1.1 thorpej };
113 1.1 thorpej
114 1.1 thorpej struct cbq_modify_class {
115 1.1 thorpej struct cbq_interface cbq_iface;
116 1.1 thorpej
117 1.1 thorpej cbq_class_spec_t cbq_class;
118 1.1 thorpej u_long cbq_class_handle;
119 1.1 thorpej };
120 1.1 thorpej
121 1.1 thorpej struct cbq_add_filter {
122 1.1 thorpej struct cbq_interface cbq_iface;
123 1.1 thorpej u_long cbq_class_handle;
124 1.1 thorpej struct flow_filter cbq_filter;
125 1.1 thorpej
126 1.1 thorpej u_long cbq_filter_handle;
127 1.1 thorpej };
128 1.1 thorpej
129 1.1 thorpej struct cbq_delete_filter {
130 1.1 thorpej struct cbq_interface cbq_iface;
131 1.1 thorpej u_long cbq_filter_handle;
132 1.1 thorpej };
133 1.1 thorpej
134 1.1 thorpej typedef struct _cbq_class_stats_ {
135 1.1 thorpej u_int handle;
136 1.1 thorpej u_int depth;
137 1.1 thorpej
138 1.1 thorpej struct pktcntr xmit_cnt; /* packets sent in this class */
139 1.1 thorpej struct pktcntr drop_cnt; /* dropped packets */
140 1.1 thorpej u_int over; /* # times went over limit */
141 1.1 thorpej u_int borrows; /* # times tried to borrow */
142 1.1 thorpej u_int overactions; /* # times invoked overlimit action */
143 1.1 thorpej u_int delays; /* # times invoked delay actions */
144 1.1 thorpej
145 1.1 thorpej /* other static class parameters useful for debugging */
146 1.1 thorpej int priority;
147 1.1 thorpej int maxidle;
148 1.1 thorpej int minidle;
149 1.1 thorpej int offtime;
150 1.1 thorpej int qmax;
151 1.1 thorpej int ns_per_byte;
152 1.1 thorpej int wrr_allot;
153 1.1 thorpej
154 1.1 thorpej int qcnt; /* # packets in queue */
155 1.1 thorpej int avgidle;
156 1.1 thorpej
157 1.1 thorpej /* red and rio related info */
158 1.1 thorpej int qtype;
159 1.1 thorpej struct redstats red[3];
160 1.1 thorpej } class_stats_t;
161 1.1 thorpej
162 1.1 thorpej /* number of classes are returned in nclasses field */
163 1.1 thorpej struct cbq_getstats {
164 1.1 thorpej struct cbq_interface iface;
165 1.1 thorpej int nclasses;
166 1.1 thorpej class_stats_t *stats;
167 1.1 thorpej };
168 1.1 thorpej
169 1.1 thorpej /*
170 1.1 thorpej * Define IOCTLs for CBQ.
171 1.1 thorpej */
172 1.1 thorpej #define CBQ_IF_ATTACH _IOW('Q', 1, struct cbq_interface)
173 1.1 thorpej #define CBQ_IF_DETACH _IOW('Q', 2, struct cbq_interface)
174 1.1 thorpej #define CBQ_ENABLE _IOW('Q', 3, struct cbq_interface)
175 1.1 thorpej #define CBQ_DISABLE _IOW('Q', 4, struct cbq_interface)
176 1.1 thorpej #define CBQ_CLEAR_HIERARCHY _IOW('Q', 5, struct cbq_interface)
177 1.1 thorpej #define CBQ_ADD_CLASS _IOWR('Q', 7, struct cbq_add_class)
178 1.1 thorpej #define CBQ_DEL_CLASS _IOW('Q', 8, struct cbq_delete_class)
179 1.1 thorpej #define CBQ_MODIFY_CLASS _IOWR('Q', 9, struct cbq_modify_class)
180 1.1 thorpej #define CBQ_ADD_FILTER _IOWR('Q', 10, struct cbq_add_filter)
181 1.1 thorpej #define CBQ_DEL_FILTER _IOW('Q', 11, struct cbq_delete_filter)
182 1.1 thorpej #define CBQ_GETSTATS _IOWR('Q', 12, struct cbq_getstats)
183 1.1 thorpej
184 1.1 thorpej #ifdef _KERNEL
185 1.1 thorpej /*
186 1.1 thorpej * Define macros only good for kernel drivers and modules.
187 1.1 thorpej */
188 1.1 thorpej
189 1.1 thorpej #define DISABLE 0x00
190 1.1 thorpej #define ENABLE 0x01
191 1.1 thorpej
192 1.1 thorpej #define CBQ_WATCHDOG (HZ / 20)
193 1.1 thorpej #define CBQ_TIMEOUT 10
194 1.1 thorpej #define CBQ_LS_TIMEOUT (20 * hz / 1000)
195 1.1 thorpej
196 1.1 thorpej #define CBQ_MAX_CLASSES 256
197 1.1 thorpej #define CBQ_MAX_FILTERS 256
198 1.1 thorpej
199 1.1 thorpej /*
200 1.1 thorpej * Define State structures.
201 1.1 thorpej */
202 1.1 thorpej typedef struct cbqstate {
203 1.1 thorpej struct cbqstate *cbq_next;
204 1.1 thorpej int cbq_qlen; /* # of packets in cbq */
205 1.1 thorpej struct rm_class **cbq_class_tbl;
206 1.1 thorpej
207 1.1 thorpej struct rm_ifdat ifnp;
208 1.1 thorpej struct callout cbq_callout; /* for timeouts */
209 1.1 thorpej
210 1.1 thorpej struct acc_classifier cbq_classifier;
211 1.1 thorpej } cbq_state_t;
212 1.1 thorpej
213 1.1 thorpej #endif /* _KERNEL */
214 1.1 thorpej
215 1.1 thorpej #ifdef __cplusplus
216 1.1 thorpej }
217 1.1 thorpej #endif
218 1.1 thorpej
219 1.1 thorpej #endif /* !_ALTQ_ALTQ_CBQ_H_ */
220