1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #ifndef _ALTQ_ALTQ_CDNR_H_
31 #define _ALTQ_ALTQ_CDNR_H_
32
33 #include <altq/altq.h>
34
35
36
37
38 #define TCETYPE_NONE 0
39 #define TCETYPE_TOP 1
40 #define TCETYPE_ELEMENT 2
41 #define TCETYPE_TBMETER 3
42 #define TCETYPE_TRTCM 4
43 #define TCETYPE_TSWTCM 5
44
45
46
47
48 struct cdnr_block;
49
50 struct tc_action {
51 int tca_code;
52
53 union {
54 u_long un_value;
55 u_int8_t un_dscp;
56 u_long un_handle;
57 struct cdnr_block *un_next;
58 } tca_un;
59 };
60 #define tca_value tca_un.un_value
61 #define tca_dscp tca_un.un_dscp
62 #define tca_handle tca_un.un_handle
63 #define tca_next tca_un.un_next
64
65 #define TCACODE_NONE 0
66 #define TCACODE_PASS 1
67 #define TCACODE_DROP 2
68 #define TCACODE_RETURN 3
69 #define TCACODE_MARK 4
70 #define TCACODE_HANDLE 5
71 #define TCACODE_NEXT 6
72 #define TCACODE_MAX 6
73
74 #define CDNR_NULL_HANDLE 0
75
76 struct cdnr_interface {
77 char cdnr_ifname[IFNAMSIZ];
78 };
79
80
81 struct cdnr_add_element {
82 struct cdnr_interface iface;
83 struct tc_action action;
84
85 u_long cdnr_handle;
86 };
87
88 struct cdnr_delete_element {
89 struct cdnr_interface iface;
90 u_long cdnr_handle;
91 };
92
93
94 struct cdnr_add_tbmeter {
95 struct cdnr_interface iface;
96 struct tb_profile profile;
97 struct tc_action in_action;
98 struct tc_action out_action;
99
100 u_long cdnr_handle;
101 };
102
103 struct cdnr_modify_tbmeter {
104 struct cdnr_interface iface;
105 u_long cdnr_handle;
106 struct tb_profile profile;
107 };
108
109 struct cdnr_tbmeter_stats {
110 struct cdnr_interface iface;
111 u_long cdnr_handle;
112 struct pktcntr in_cnt;
113 struct pktcntr out_cnt;
114 };
115
116
117 struct cdnr_add_trtcm {
118 struct cdnr_interface iface;
119 struct tb_profile cmtd_profile;
120 struct tb_profile peak_profile;
121 struct tc_action green_action;
122 struct tc_action yellow_action;
123 struct tc_action red_action;
124 int coloraware;
125
126 u_long cdnr_handle;
127 };
128
129 struct cdnr_modify_trtcm {
130 struct cdnr_interface iface;
131 u_long cdnr_handle;
132 struct tb_profile cmtd_profile;
133 struct tb_profile peak_profile;
134 int coloraware;
135 };
136
137 struct cdnr_tcm_stats {
138 struct cdnr_interface iface;
139 u_long cdnr_handle;
140 struct pktcntr green_cnt;
141 struct pktcntr yellow_cnt;
142 struct pktcntr red_cnt;
143 };
144
145
146 struct cdnr_add_tswtcm {
147 struct cdnr_interface iface;
148 u_int32_t cmtd_rate;
149 u_int32_t peak_rate;
150 u_int32_t avg_interval;
151 struct tc_action green_action;
152 struct tc_action yellow_action;
153 struct tc_action red_action;
154
155 u_long cdnr_handle;
156 };
157
158 struct cdnr_modify_tswtcm {
159 struct cdnr_interface iface;
160 u_long cdnr_handle;
161 u_int32_t cmtd_rate;
162 u_int32_t peak_rate;
163 u_int32_t avg_interval;
164 };
165
166 struct tce_stats {
167 u_long tce_handle;
168 int tce_type;
169 struct pktcntr tce_cnts[3];
170 };
171
172 struct cdnr_get_stats {
173 struct cdnr_interface iface;
174 struct pktcntr cnts[TCACODE_MAX+1];
175
176
177 int nskip;
178 int nelements;
179 struct tce_stats *tce_stats;
180 };
181
182 #ifndef DSCP_EF
183
184 #define DSCP_MASK 0xfc
185 #define DSCP_CUMASK 0x03
186 #define DSCP_EF 0xb8
187 #define DSCP_AF11 0x28
188 #define DSCP_AF12 0x30
189 #define DSCP_AF13 0x38
190 #define DSCP_AF21 0x48
191 #define DSCP_AF22 0x50
192 #define DSCP_AF23 0x58
193 #define DSCP_AF31 0x68
194 #define DSCP_AF32 0x70
195 #define DSCP_AF33 0x78
196 #define DSCP_AF41 0x88
197 #define DSCP_AF42 0x90
198 #define DSCP_AF43 0x98
199 #define AF_CLASSMASK 0xe0
200 #define AF_DROPPRECMASK 0x18
201 #endif
202
203 #ifdef _KERNEL
204
205
206
207
208 struct cdnr_pktinfo {
209 int pkt_len;
210 u_int8_t pkt_dscp;
211 };
212
213
214
215
216 struct cdnr_block {
217 LIST_ENTRY(cdnr_block) cb_next;
218 int cb_len;
219 int cb_type;
220 int cb_ref;
221 u_long cb_handle;
222 struct top_cdnr *cb_top;
223 struct tc_action cb_action;
224 struct tc_action *(*cb_input)(struct cdnr_block *,
225 struct cdnr_pktinfo *);
226 };
227
228
229
230
231 struct top_cdnr {
232 struct cdnr_block tc_block;
233
234 LIST_ENTRY(top_cdnr) tc_next;
235 struct ifaltq *tc_ifq;
236
237 LIST_HEAD(, cdnr_block) tc_elements;
238
239 struct pktcntr tc_cnts[TCACODE_MAX+1];
240 };
241
242
243 struct tbe {
244 u_int64_t rate;
245 u_int64_t depth;
246
247 u_int64_t token;
248 u_int64_t filluptime;
249 u_int64_t last;
250 };
251
252
253 struct tbmeter {
254 struct cdnr_block cdnrblk;
255 struct tbe tb;
256 struct tc_action in_action;
257 struct tc_action out_action;
258 struct pktcntr in_cnt;
259 struct pktcntr out_cnt;
260 };
261
262
263 struct trtcm {
264 struct cdnr_block cdnrblk;
265 struct tbe cmtd_tb;
266 struct tbe peak_tb;
267 struct tc_action green_action;
268 struct tc_action yellow_action;
269 struct tc_action red_action;
270 int coloraware;
271 u_int8_t green_dscp;
272 u_int8_t yellow_dscp;
273 u_int8_t red_dscp;
274 struct pktcntr green_cnt;
275 struct pktcntr yellow_cnt;
276 struct pktcntr red_cnt;
277 };
278
279
280 struct tswtcm {
281 struct cdnr_block cdnrblk;
282
283 u_int32_t avg_rate;
284 u_int64_t t_front;
285
286 u_int64_t timewin;
287 u_int32_t cmtd_rate;
288 u_int32_t peak_rate;
289 struct tc_action green_action;
290 struct tc_action yellow_action;
291 struct tc_action red_action;
292 u_int8_t green_dscp;
293 u_int8_t yellow_dscp;
294 u_int8_t red_dscp;
295 struct pktcntr green_cnt;
296 struct pktcntr yellow_cnt;
297 struct pktcntr red_cnt;
298 };
299
300 #endif
301
302 #endif