xref: /dragonfly/sys/net/altq/altq_cbq.h (revision 335b9e93)
1 /*	$KAME: altq_cbq.h,v 1.12 2003/10/03 05:05:15 kjc Exp $	*/
2 /*	$DragonFly: src/sys/net/altq/altq_cbq.h,v 1.1 2005/02/11 22:25:57 joerg Exp $ */
3 
4 /*
5  * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *
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.
17  *
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.
22  *
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
25  *      written permission.
26  *
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.
30  *
31  * These notices must be retained in any copies of any part of this software.
32  */
33 
34 #ifndef _ALTQ_ALTQ_CBQ_H_
35 #define	_ALTQ_ALTQ_CBQ_H_
36 
37 #include <net/altq/altq.h>
38 #include <net/altq/altq_rmclass.h>
39 #include <net/altq/altq_red.h>
40 #include <net/altq/altq_rio.h>
41 
42 #define	NULL_CLASS_HANDLE	0
43 
44 /* class flags should be same as class flags in rm_class.h */
45 #define	CBQCLF_RED		0x0001	/* use RED */
46 #define	CBQCLF_ECN		0x0002  /* use RED/ECN */
47 #define	CBQCLF_RIO		0x0004  /* use RIO */
48 #define	CBQCLF_CLEARDSCP	0x0008  /* clear diffserv codepoint */
49 #define	CBQCLF_BORROW		0x0010  /* borrow from parent */
50 
51 /* class flags only for root class */
52 #define	CBQCLF_WRR		0x0100	/* weighted-round robin */
53 #define	CBQCLF_EFFICIENT	0x0200  /* work-conserving */
54 
55 /* class flags for special classes */
56 #define	CBQCLF_ROOTCLASS	0x1000	/* root class */
57 #define	CBQCLF_DEFCLASS		0x2000	/* default class */
58 #define	CBQCLF_CLASSMASK	0xf000	/* class mask */
59 
60 #define	CBQ_MAXQSIZE		200
61 #define	CBQ_MAXPRI		RM_MAXPRIO
62 
63 typedef struct _cbq_class_stats_ {
64 	uint32_t	handle;
65 	u_int		depth;
66 
67 	struct pktcntr	xmit_cnt;	/* packets sent in this class */
68 	struct pktcntr	drop_cnt;	/* dropped packets */
69 	u_int		over;		/* # times went over limit */
70 	u_int		borrows;	/* # times tried to borrow */
71 	u_int		overactions;	/* # times invoked overlimit action */
72 	u_int		delays;		/* # times invoked delay actions */
73 
74 	/* other static class parameters useful for debugging */
75 	int		priority;
76 	int		maxidle;
77 	int		minidle;
78 	int		offtime;
79 	int		qmax;
80 	int		ns_per_byte;
81 	int		wrr_allot;
82 
83 	int		qcnt;		/* # packets in queue */
84 	int		avgidle;
85 
86 	/* red and rio related info */
87 	int		qtype;
88 	struct redstats	red[3];
89 } class_stats_t;
90 
91 #ifdef _KERNEL
92 /*
93  * Define macros only good for kernel drivers and modules.
94  */
95 #define	CBQ_WATCHDOG		(hz / 20)
96 #define	CBQ_TIMEOUT		10
97 #define	CBQ_LS_TIMEOUT		(20 * hz / 1000)
98 
99 #define	CBQ_MAX_CLASSES	256
100 
101 /*
102  * Define State structures.
103  */
104 typedef struct cbqstate {
105 	int			 cbq_qlen;	/* # of packets in cbq */
106 	struct rm_class		*cbq_class_tbl[CBQ_MAX_CLASSES];
107 
108 	struct rm_ifdat		 ifnp;
109 	struct callout		 cbq_callout;	/* for timeouts */
110 } cbq_state_t;
111 
112 #endif /* _KERNEL */
113 
114 #endif /* !_ALTQ_ALTQ_CBQ_H_ */
115