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