xref: /freebsd/sys/net/altq/altq_priq.h (revision 2ff63af9b88c7413b7d71715b5532625752a248e)
1772e66a6SGleb Smirnoff /*-
2772e66a6SGleb Smirnoff  * Copyright (C) 2000-2003
3772e66a6SGleb Smirnoff  *	Sony Computer Science Laboratories Inc.  All rights reserved.
4772e66a6SGleb Smirnoff  *
5772e66a6SGleb Smirnoff  * Redistribution and use in source and binary forms, with or without
6772e66a6SGleb Smirnoff  * modification, are permitted provided that the following conditions
7772e66a6SGleb Smirnoff  * are met:
8772e66a6SGleb Smirnoff  * 1. Redistributions of source code must retain the above copyright
9772e66a6SGleb Smirnoff  *    notice, this list of conditions and the following disclaimer.
10772e66a6SGleb Smirnoff  * 2. Redistributions in binary form must reproduce the above copyright
11772e66a6SGleb Smirnoff  *    notice, this list of conditions and the following disclaimer in the
12772e66a6SGleb Smirnoff  *    documentation and/or other materials provided with the distribution.
13772e66a6SGleb Smirnoff  *
14772e66a6SGleb Smirnoff  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
15772e66a6SGleb Smirnoff  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16772e66a6SGleb Smirnoff  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17772e66a6SGleb Smirnoff  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
18772e66a6SGleb Smirnoff  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19772e66a6SGleb Smirnoff  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20772e66a6SGleb Smirnoff  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21772e66a6SGleb Smirnoff  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22772e66a6SGleb Smirnoff  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23772e66a6SGleb Smirnoff  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24772e66a6SGleb Smirnoff  * SUCH DAMAGE.
25772e66a6SGleb Smirnoff  *
26772e66a6SGleb Smirnoff  * $KAME: altq_priq.h,v 1.7 2003/10/03 05:05:15 kjc Exp $
27772e66a6SGleb Smirnoff  */
28772e66a6SGleb Smirnoff 
29772e66a6SGleb Smirnoff #ifndef _ALTQ_ALTQ_PRIQ_H_
30772e66a6SGleb Smirnoff #define	_ALTQ_ALTQ_PRIQ_H_
31772e66a6SGleb Smirnoff 
32772e66a6SGleb Smirnoff #include <net/altq/altq.h>
33772e66a6SGleb Smirnoff #include <net/altq/altq_classq.h>
340a70aaf8SLuiz Otavio O Souza #include <net/altq/altq_codel.h>
35772e66a6SGleb Smirnoff #include <net/altq/altq_red.h>
36772e66a6SGleb Smirnoff #include <net/altq/altq_rio.h>
37772e66a6SGleb Smirnoff 
38772e66a6SGleb Smirnoff #ifdef __cplusplus
39772e66a6SGleb Smirnoff extern "C" {
40772e66a6SGleb Smirnoff #endif
41772e66a6SGleb Smirnoff 
42772e66a6SGleb Smirnoff #define	PRIQ_MAXPRI	16	/* upper limit of the number of priorities */
43772e66a6SGleb Smirnoff 
44772e66a6SGleb Smirnoff /* priq class flags */
45772e66a6SGleb Smirnoff #define	PRCF_RED		0x0001	/* use RED */
46772e66a6SGleb Smirnoff #define	PRCF_ECN		0x0002  /* use RED/ECN */
47772e66a6SGleb Smirnoff #define	PRCF_RIO		0x0004  /* use RIO */
480a70aaf8SLuiz Otavio O Souza #define	PRCF_CODEL		0x0008	/* use CoDel */
49772e66a6SGleb Smirnoff #define	PRCF_CLEARDSCP		0x0010  /* clear diffserv codepoint */
50772e66a6SGleb Smirnoff #define	PRCF_DEFAULTCLASS	0x1000	/* default class */
51772e66a6SGleb Smirnoff 
52772e66a6SGleb Smirnoff /* special class handles */
53772e66a6SGleb Smirnoff #define	PRIQ_NULLCLASS_HANDLE	0
54772e66a6SGleb Smirnoff 
55772e66a6SGleb Smirnoff struct priq_classstats {
56772e66a6SGleb Smirnoff 	u_int32_t		class_handle;
57772e66a6SGleb Smirnoff 
58772e66a6SGleb Smirnoff 	u_int			qlength;
59772e66a6SGleb Smirnoff 	u_int			qlimit;
60772e66a6SGleb Smirnoff 	u_int			period;
61772e66a6SGleb Smirnoff 	struct pktcntr		xmitcnt;  /* transmitted packet counter */
62772e66a6SGleb Smirnoff 	struct pktcntr		dropcnt;  /* dropped packet counter */
63772e66a6SGleb Smirnoff 
640a70aaf8SLuiz Otavio O Souza 	/* codel, red and rio related info */
65772e66a6SGleb Smirnoff 	int			qtype;
66772e66a6SGleb Smirnoff 	struct redstats		red[3];	/* rio has 3 red stats */
670a70aaf8SLuiz Otavio O Souza 	struct codel_stats	codel;
68772e66a6SGleb Smirnoff };
69772e66a6SGleb Smirnoff 
70*249cc75fSPatrick Kelsey /*
71*249cc75fSPatrick Kelsey  * PRIQ_STATS_VERSION is defined in altq.h to work around issues stemming
72*249cc75fSPatrick Kelsey  * from mixing of public-API and internal bits in each scheduler-specific
73*249cc75fSPatrick Kelsey  * header.
74*249cc75fSPatrick Kelsey  */
75*249cc75fSPatrick Kelsey 
76772e66a6SGleb Smirnoff #ifdef _KERNEL
77772e66a6SGleb Smirnoff 
78772e66a6SGleb Smirnoff struct priq_class {
79772e66a6SGleb Smirnoff 	u_int32_t	cl_handle;	/* class handle */
80772e66a6SGleb Smirnoff 	class_queue_t	*cl_q;		/* class queue structure */
810a70aaf8SLuiz Otavio O Souza 	union {
82772e66a6SGleb Smirnoff 		struct red	*cl_red;	/* RED state */
830a70aaf8SLuiz Otavio O Souza 		struct codel	*cl_codel;	/* CoDel state */
840a70aaf8SLuiz Otavio O Souza 	} cl_aqm;
850a70aaf8SLuiz Otavio O Souza #define	cl_red		cl_aqm.cl_red
860a70aaf8SLuiz Otavio O Souza #define	cl_codel	cl_aqm.cl_codel
87772e66a6SGleb Smirnoff 	int		cl_pri;		/* priority */
88772e66a6SGleb Smirnoff 	int		cl_flags;	/* class flags */
89772e66a6SGleb Smirnoff 	struct priq_if	*cl_pif;	/* back pointer to pif */
90772e66a6SGleb Smirnoff 	struct altq_pktattr *cl_pktattr; /* saved header used by ECN */
91772e66a6SGleb Smirnoff 
92772e66a6SGleb Smirnoff 	/* statistics */
93772e66a6SGleb Smirnoff 	u_int		cl_period;	/* backlog period */
94772e66a6SGleb Smirnoff 	struct pktcntr  cl_xmitcnt;	/* transmitted packet counter */
95772e66a6SGleb Smirnoff 	struct pktcntr  cl_dropcnt;	/* dropped packet counter */
96772e66a6SGleb Smirnoff };
97772e66a6SGleb Smirnoff 
98772e66a6SGleb Smirnoff /*
99772e66a6SGleb Smirnoff  * priq interface state
100772e66a6SGleb Smirnoff  */
101772e66a6SGleb Smirnoff struct priq_if {
102772e66a6SGleb Smirnoff 	struct priq_if		*pif_next;	/* interface state list */
103772e66a6SGleb Smirnoff 	struct ifaltq		*pif_ifq;	/* backpointer to ifaltq */
104772e66a6SGleb Smirnoff 	u_int			pif_bandwidth;	/* link bandwidth in bps */
105772e66a6SGleb Smirnoff 	int			pif_maxpri;	/* max priority in use */
106772e66a6SGleb Smirnoff 	struct priq_class	*pif_default;	/* default class */
107772e66a6SGleb Smirnoff 	struct priq_class	*pif_classes[PRIQ_MAXPRI]; /* classes */
108772e66a6SGleb Smirnoff #ifdef ALTQ3_CLFIER_COMPAT
109772e66a6SGleb Smirnoff 	struct acc_classifier	pif_classifier;	/* classifier */
110772e66a6SGleb Smirnoff #endif
111772e66a6SGleb Smirnoff };
112772e66a6SGleb Smirnoff 
113772e66a6SGleb Smirnoff #endif /* _KERNEL */
114772e66a6SGleb Smirnoff 
115772e66a6SGleb Smirnoff #ifdef __cplusplus
116772e66a6SGleb Smirnoff }
117772e66a6SGleb Smirnoff #endif
118772e66a6SGleb Smirnoff 
119772e66a6SGleb Smirnoff #endif /* _ALTQ_ALTQ_PRIQ_H_ */
120