xref: /freebsd/sys/net/altq/altq.h (revision 3b2324c3a800d7599f348c408f01908d0cef05a0)
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 
42 /* altq discipline type */
43 #define	ALTQT_NONE		0	/* reserved */
44 #define	ALTQT_CBQ		1	/* cbq */
45 #define	ALTQT_WFQ		2	/* wfq */
46 #define	ALTQT_AFMAP		3	/* afmap */
47 #define	ALTQT_FIFOQ		4	/* fifoq */
48 #define	ALTQT_RED		5	/* red */
49 #define	ALTQT_RIO		6	/* rio */
50 #define	ALTQT_LOCALQ		7	/* local use */
51 #define	ALTQT_HFSC		8	/* hfsc */
52 #define	ALTQT_CDNR		9	/* traffic conditioner */
53 #define	ALTQT_BLUE		10	/* blue */
54 #define	ALTQT_PRIQ		11	/* priority queue */
55 #define	ALTQT_JOBS		12	/* JoBS */
56 #define	ALTQT_FAIRQ		13	/* fairq */
57 #define	ALTQT_CODEL		14      /* CoDel */
58 #define	ALTQT_MAX		15	/* should be max discipline type + 1 */
59 
60 
61 /* simple token backet meter profile */
62 struct	tb_profile {
63 	u_int64_t	rate;	/* rate in bit-per-sec */
64 	u_int32_t	depth;	/* depth in bytes */
65 };
66 
67 
68 /*
69  * generic packet counter
70  */
71 struct pktcntr {
72 	u_int64_t	packets;
73 	u_int64_t	bytes;
74 };
75 
76 #define	PKTCNTR_ADD(cntr, len)	\
77 	do { (cntr)->packets++; (cntr)->bytes += len; } while (/*CONSTCOND*/ 0)
78 
79 
80 #ifdef _KERNEL
81 #include <net/altq/altq_var.h>
82 #endif
83 
84 /*
85  * Can't put these versions in the scheduler-specific headers and include
86  * them all here as that will cause build failure due to cross-including
87  * each other scheduler's private bits into each scheduler's
88  * implementation.
89  */
90 #define CBQ_STATS_VERSION	0	/* Latest version of class_stats_t */
91 #define CODEL_STATS_VERSION	0	/* Latest version of codel_ifstats */
92 #define FAIRQ_STATS_VERSION	0	/* Latest version of fairq_classstats */
93 #define HFSC_STATS_VERSION	1	/* Latest version of hfsc_classstats */
94 #define PRIQ_STATS_VERSION	0	/* Latest version of priq_classstats */
95 
96 /* Return the latest stats version for the given scheduler. */
97 static inline int altq_stats_version(int scheduler)
98 {
99 	switch (scheduler) {
100 	case ALTQT_CBQ:   return (CBQ_STATS_VERSION);
101 	case ALTQT_CODEL: return (CODEL_STATS_VERSION);
102 	case ALTQT_FAIRQ: return (FAIRQ_STATS_VERSION);
103 	case ALTQT_HFSC:  return (HFSC_STATS_VERSION);
104 	case ALTQT_PRIQ:  return (PRIQ_STATS_VERSION);
105 	default: return (0);
106 	}
107 }
108 
109 #endif /* _ALTQ_ALTQ_H_ */
110