master
1/*-
2 * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the SMCC Technology
18 * Development Group at Sun Microsystems, Inc.
19 *
20 * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission.
23 *
24 * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE
25 * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is
26 * provided "as is" without express or implied warranty of any kind.
27 *
28 * These notices must be retained in any copies of any part of this software.
29 *
30 * $KAME: altq_cbq.h,v 1.12 2003/10/03 05:05:15 kjc Exp $
31 */
32
33#ifndef _ALTQ_ALTQ_CBQ_H_
34#define _ALTQ_ALTQ_CBQ_H_
35
36#include <net/altq/altq.h>
37#include <net/altq/altq_rmclass.h>
38#include <net/altq/altq_codel.h>
39#include <net/altq/altq_red.h>
40#include <net/altq/altq_rio.h>
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46#define NULL_CLASS_HANDLE 0
47
48/* class flags must be same as class flags in altq_rmclass.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#define CBQCLF_CODEL 0x0040 /* use CoDel */
56
57#ifdef _KERNEL
58CTASSERT(CBQCLF_RED == RMCF_RED);
59CTASSERT(CBQCLF_ECN == RMCF_ECN);
60CTASSERT(CBQCLF_RIO == RMCF_RIO);
61CTASSERT(CBQCLF_FLOWVALVE == RMCF_FLOWVALVE);
62CTASSERT(CBQCLF_CLEARDSCP == RMCF_CLEARDSCP);
63CTASSERT(CBQCLF_CODEL == RMCF_CODEL);
64#endif
65
66/* class flags only for root class */
67#define CBQCLF_WRR 0x0100 /* weighted-round robin */
68#define CBQCLF_EFFICIENT 0x0200 /* work-conserving */
69
70/* class flags for special classes */
71#define CBQCLF_ROOTCLASS 0x1000 /* root class */
72#define CBQCLF_DEFCLASS 0x2000 /* default class */
73#define CBQCLF_CLASSMASK 0xf000 /* class mask */
74
75#define CBQ_MAXQSIZE 200
76#define CBQ_MAXPRI RM_MAXPRIO
77
78typedef struct _cbq_class_stats_ {
79 u_int32_t handle;
80 u_int depth;
81
82 struct pktcntr xmit_cnt; /* packets sent in this class */
83 struct pktcntr drop_cnt; /* dropped packets */
84 u_int over; /* # times went over limit */
85 u_int borrows; /* # times tried to borrow */
86 u_int overactions; /* # times invoked overlimit action */
87 u_int delays; /* # times invoked delay actions */
88
89 /* other static class parameters useful for debugging */
90 int priority;
91 int maxidle;
92 int minidle;
93 int offtime;
94 int qmax;
95 int ns_per_byte;
96 int wrr_allot;
97
98 int qcnt; /* # packets in queue */
99 int avgidle;
100
101 /* codel, red and rio related info */
102 int qtype;
103 struct redstats red[3];
104 struct codel_stats codel;
105} class_stats_t;
106
107/*
108 * CBQ_STATS_VERSION is defined in altq.h to work around issues stemming
109 * from mixing of public-API and internal bits in each scheduler-specific
110 * header.
111 */
112
113#ifdef _KERNEL
114/*
115 * Define macros only good for kernel drivers and modules.
116 */
117#define CBQ_WATCHDOG (hz / 20)
118#define CBQ_TIMEOUT 10
119#define CBQ_LS_TIMEOUT (20 * hz / 1000)
120
121#define CBQ_MAX_CLASSES 2048
122
123/*
124 * Define State structures.
125 */
126typedef struct cbqstate {
127 int cbq_qlen; /* # of packets in cbq */
128 struct rm_class *cbq_class_tbl[CBQ_MAX_CLASSES];
129
130 struct rm_ifdat ifnp;
131 struct callout cbq_callout; /* for timeouts */
132#ifdef ALTQ3_CLFIER_COMPAT
133 struct acc_classifier cbq_classifier;
134#endif
135} cbq_state_t;
136
137#endif /* _KERNEL */
138
139#ifdef __cplusplus
140}
141#endif
142
143#endif /* !_ALTQ_ALTQ_CBQ_H_ */