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