xref: /freebsd/sys/net/altq/altq.h (revision 9768746b)
1 /*-
2  * Copyright (C) 1998-2003
3  *	Sony Computer Science Laboratories Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $KAME: altq.h,v 1.10 2003/07/10 12:07:47 kjc Exp $
27  * $FreeBSD$
28  */
29 #ifndef _ALTQ_ALTQ_H_
30 #define	_ALTQ_ALTQ_H_
31 
32 #if 0
33 /*
34  * allow altq-3 (altqd(8) and /dev/altq) to coexist with the new pf-based altq.
35  * altq3 is mainly for research experiments. pf-based altq is for daily use.
36  */
37 #define ALTQ3_COMPAT		/* for compatibility with altq-3 */
38 #define ALTQ3_CLFIER_COMPAT	/* for compatibility with altq-3 classifier */
39 #endif
40 
41 /* altq discipline type */
42 #define	ALTQT_NONE		0	/* reserved */
43 #define	ALTQT_CBQ		1	/* cbq */
44 #define	ALTQT_WFQ		2	/* wfq */
45 #define	ALTQT_AFMAP		3	/* afmap */
46 #define	ALTQT_FIFOQ		4	/* fifoq */
47 #define	ALTQT_RED		5	/* red */
48 #define	ALTQT_RIO		6	/* rio */
49 #define	ALTQT_LOCALQ		7	/* local use */
50 #define	ALTQT_HFSC		8	/* hfsc */
51 #define	ALTQT_CDNR		9	/* traffic conditioner */
52 #define	ALTQT_BLUE		10	/* blue */
53 #define	ALTQT_PRIQ		11	/* priority queue */
54 #define	ALTQT_JOBS		12	/* JoBS */
55 #define	ALTQT_FAIRQ		13	/* fairq */
56 #define	ALTQT_CODEL		14      /* CoDel */
57 #define	ALTQT_MAX		15	/* should be max discipline type + 1 */
58 
59 /* simple token backet meter profile */
60 struct	tb_profile {
61 	u_int64_t	rate;	/* rate in bit-per-sec */
62 	u_int32_t	depth;	/* depth in bytes */
63 };
64 
65 /*
66  * generic packet counter
67  */
68 struct pktcntr {
69 	u_int64_t	packets;
70 	u_int64_t	bytes;
71 };
72 
73 #define	PKTCNTR_ADD(cntr, len)	\
74 	do { (cntr)->packets++; (cntr)->bytes += len; } while (/*CONSTCOND*/ 0)
75 
76 #ifdef _KERNEL
77 #include <net/altq/altq_var.h>
78 #endif
79 
80 /*
81  * Can't put these versions in the scheduler-specific headers and include
82  * them all here as that will cause build failure due to cross-including
83  * each other scheduler's private bits into each scheduler's
84  * implementation.
85  */
86 #define CBQ_STATS_VERSION	0	/* Latest version of class_stats_t */
87 #define CODEL_STATS_VERSION	0	/* Latest version of codel_ifstats */
88 #define FAIRQ_STATS_VERSION	0	/* Latest version of fairq_classstats */
89 #define HFSC_STATS_VERSION	1	/* Latest version of hfsc_classstats */
90 #define PRIQ_STATS_VERSION	0	/* Latest version of priq_classstats */
91 
92 /* Return the latest stats version for the given scheduler. */
93 static inline int altq_stats_version(int scheduler)
94 {
95 	switch (scheduler) {
96 	case ALTQT_CBQ:   return (CBQ_STATS_VERSION);
97 	case ALTQT_CODEL: return (CODEL_STATS_VERSION);
98 	case ALTQT_FAIRQ: return (FAIRQ_STATS_VERSION);
99 	case ALTQT_HFSC:  return (HFSC_STATS_VERSION);
100 	case ALTQT_PRIQ:  return (PRIQ_STATS_VERSION);
101 	default: return (0);
102 	}
103 }
104 
105 #endif /* _ALTQ_ALTQ_H_ */
106