1 /* $OpenBSD: altq_priq.h,v 1.6 2004/01/14 08:42:23 kjc Exp $ */
2 /* $KAME: altq_priq.h,v 1.1 2000/10/18 09:15:23 kjc Exp $ */
3 /*
4 * Copyright (C) 2000-2002
5 * Sony Computer Science Laboratories Inc. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #ifndef _ALTQ_ALTQ_PRIQ_H_
30 #define _ALTQ_ALTQ_PRIQ_H_
31
32 #include <altq/altq.h>
33 #include <altq/altq_classq.h>
34 #include <altq/altq_red.h>
35 #include <altq/altq_rio.h>
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 #define PRIQ_MAXPRI 16 /* upper limit of the number of priorities */
42
43 /* priq class flags */
44 #define PRCF_RED 0x0001 /* use RED */
45 #define PRCF_ECN 0x0002 /* use RED/ECN */
46 #define PRCF_RIO 0x0004 /* use RIO */
47 #define PRCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */
48 #define PRCF_DEFAULTCLASS 0x1000 /* default class */
49
50 /* special class handles */
51 #define PRIQ_NULLCLASS_HANDLE 0
52
53 struct priq_classstats {
54 u_int32_t class_handle;
55
56 u_int qlength;
57 u_int qlimit;
58 u_int period;
59 struct pktcntr xmitcnt; /* transmitted packet counter */
60 struct pktcntr dropcnt; /* dropped packet counter */
61
62 /* red and rio related info */
63 int qtype;
64 struct redstats red[3]; /* rio has 3 red stats */
65 };
66
67 #ifdef _KERNEL
68
69 struct priq_class {
70 u_int32_t cl_handle; /* class handle */
71 class_queue_t *cl_q; /* class queue structure */
72 struct red *cl_red; /* RED state */
73 int cl_pri; /* priority */
74 int cl_flags; /* class flags */
75 struct priq_if *cl_pif; /* back pointer to pif */
76 struct altq_pktattr *cl_pktattr; /* saved header used by ECN */
77
78 /* statistics */
79 u_int cl_period; /* backlog period */
80 struct pktcntr cl_xmitcnt; /* transmitted packet counter */
81 struct pktcntr cl_dropcnt; /* dropped packet counter */
82 };
83
84 /*
85 * priq interface state
86 */
87 struct priq_if {
88 struct priq_if *pif_next; /* interface state list */
89 struct ifaltq *pif_ifq; /* backpointer to ifaltq */
90 u_int pif_bandwidth; /* link bandwidth in bps */
91 int pif_maxpri; /* max priority in use */
92 struct priq_class *pif_default; /* default class */
93 struct priq_class *pif_classes[PRIQ_MAXPRI]; /* classes */
94 };
95
96 #endif /* _KERNEL */
97
98 #ifdef __cplusplus
99 }
100 #endif
101
102 #endif /* _ALTQ_ALTQ_PRIQ_H_ */