xref: /freebsd/sys/net/altq/altq.h (revision 2ff63af9b88c7413b7d71715b5532625752a248e)
1da8ae05dSGleb Smirnoff /*-
2772e66a6SGleb Smirnoff  * Copyright (C) 1998-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.
25da8ae05dSGleb Smirnoff  *
26da8ae05dSGleb Smirnoff  * $KAME: altq.h,v 1.10 2003/07/10 12:07:47 kjc Exp $
27772e66a6SGleb Smirnoff  */
28772e66a6SGleb Smirnoff #ifndef _ALTQ_ALTQ_H_
29772e66a6SGleb Smirnoff #define	_ALTQ_ALTQ_H_
30772e66a6SGleb Smirnoff 
31772e66a6SGleb Smirnoff #if 0
32772e66a6SGleb Smirnoff /*
33772e66a6SGleb Smirnoff  * allow altq-3 (altqd(8) and /dev/altq) to coexist with the new pf-based altq.
34772e66a6SGleb Smirnoff  * altq3 is mainly for research experiments. pf-based altq is for daily use.
35772e66a6SGleb Smirnoff  */
36772e66a6SGleb Smirnoff #define ALTQ3_COMPAT		/* for compatibility with altq-3 */
37772e66a6SGleb Smirnoff #define ALTQ3_CLFIER_COMPAT	/* for compatibility with altq-3 classifier */
38772e66a6SGleb Smirnoff #endif
39772e66a6SGleb Smirnoff 
40772e66a6SGleb Smirnoff /* altq discipline type */
41772e66a6SGleb Smirnoff #define	ALTQT_NONE		0	/* reserved */
42772e66a6SGleb Smirnoff #define	ALTQT_CBQ		1	/* cbq */
43772e66a6SGleb Smirnoff #define	ALTQT_WFQ		2	/* wfq */
44772e66a6SGleb Smirnoff #define	ALTQT_AFMAP		3	/* afmap */
45772e66a6SGleb Smirnoff #define	ALTQT_FIFOQ		4	/* fifoq */
46772e66a6SGleb Smirnoff #define	ALTQT_RED		5	/* red */
47772e66a6SGleb Smirnoff #define	ALTQT_RIO		6	/* rio */
48772e66a6SGleb Smirnoff #define	ALTQT_LOCALQ		7	/* local use */
49772e66a6SGleb Smirnoff #define	ALTQT_HFSC		8	/* hfsc */
50772e66a6SGleb Smirnoff #define	ALTQT_CDNR		9	/* traffic conditioner */
51772e66a6SGleb Smirnoff #define	ALTQT_BLUE		10	/* blue */
52772e66a6SGleb Smirnoff #define	ALTQT_PRIQ		11	/* priority queue */
53772e66a6SGleb Smirnoff #define	ALTQT_JOBS		12	/* JoBS */
54a5b789f6SErmal Luçi #define	ALTQT_FAIRQ		13	/* fairq */
550a70aaf8SLuiz Otavio O Souza #define	ALTQT_CODEL		14      /* CoDel */
560a70aaf8SLuiz Otavio O Souza #define	ALTQT_MAX		15	/* should be max discipline type + 1 */
57772e66a6SGleb Smirnoff 
58772e66a6SGleb Smirnoff /* simple token backet meter profile */
59772e66a6SGleb Smirnoff struct	tb_profile {
60*249cc75fSPatrick Kelsey 	u_int64_t	rate;	/* rate in bit-per-sec */
61*249cc75fSPatrick Kelsey 	u_int32_t	depth;	/* depth in bytes */
62772e66a6SGleb Smirnoff };
63772e66a6SGleb Smirnoff 
64772e66a6SGleb Smirnoff /*
65772e66a6SGleb Smirnoff  * generic packet counter
66772e66a6SGleb Smirnoff  */
67772e66a6SGleb Smirnoff struct pktcntr {
68772e66a6SGleb Smirnoff 	u_int64_t	packets;
69772e66a6SGleb Smirnoff 	u_int64_t	bytes;
70772e66a6SGleb Smirnoff };
71772e66a6SGleb Smirnoff 
72772e66a6SGleb Smirnoff #define	PKTCNTR_ADD(cntr, len)	\
73772e66a6SGleb Smirnoff 	do { (cntr)->packets++; (cntr)->bytes += len; } while (/*CONSTCOND*/ 0)
74772e66a6SGleb Smirnoff 
75772e66a6SGleb Smirnoff #ifdef _KERNEL
76772e66a6SGleb Smirnoff #include <net/altq/altq_var.h>
77772e66a6SGleb Smirnoff #endif
78772e66a6SGleb Smirnoff 
79*249cc75fSPatrick Kelsey /*
80*249cc75fSPatrick Kelsey  * Can't put these versions in the scheduler-specific headers and include
81*249cc75fSPatrick Kelsey  * them all here as that will cause build failure due to cross-including
82*249cc75fSPatrick Kelsey  * each other scheduler's private bits into each scheduler's
83*249cc75fSPatrick Kelsey  * implementation.
84*249cc75fSPatrick Kelsey  */
85*249cc75fSPatrick Kelsey #define CBQ_STATS_VERSION	0	/* Latest version of class_stats_t */
86*249cc75fSPatrick Kelsey #define CODEL_STATS_VERSION	0	/* Latest version of codel_ifstats */
87*249cc75fSPatrick Kelsey #define FAIRQ_STATS_VERSION	0	/* Latest version of fairq_classstats */
88*249cc75fSPatrick Kelsey #define HFSC_STATS_VERSION	1	/* Latest version of hfsc_classstats */
89*249cc75fSPatrick Kelsey #define PRIQ_STATS_VERSION	0	/* Latest version of priq_classstats */
90*249cc75fSPatrick Kelsey 
91*249cc75fSPatrick Kelsey /* Return the latest stats version for the given scheduler. */
altq_stats_version(int scheduler)92*249cc75fSPatrick Kelsey static inline int altq_stats_version(int scheduler)
93*249cc75fSPatrick Kelsey {
94*249cc75fSPatrick Kelsey 	switch (scheduler) {
95*249cc75fSPatrick Kelsey 	case ALTQT_CBQ:   return (CBQ_STATS_VERSION);
96*249cc75fSPatrick Kelsey 	case ALTQT_CODEL: return (CODEL_STATS_VERSION);
97*249cc75fSPatrick Kelsey 	case ALTQT_FAIRQ: return (FAIRQ_STATS_VERSION);
98*249cc75fSPatrick Kelsey 	case ALTQT_HFSC:  return (HFSC_STATS_VERSION);
99*249cc75fSPatrick Kelsey 	case ALTQT_PRIQ:  return (PRIQ_STATS_VERSION);
100*249cc75fSPatrick Kelsey 	default: return (0);
101*249cc75fSPatrick Kelsey 	}
102*249cc75fSPatrick Kelsey }
103*249cc75fSPatrick Kelsey 
104772e66a6SGleb Smirnoff #endif /* _ALTQ_ALTQ_H_ */
105