1 /**	$MirOS: src/sys/altq/altq_var.h,v 1.2 2005/03/06 21:26:53 tg Exp $	*/
2 /*	$OpenBSD: altq_var.h,v 1.14 2004/04/27 02:56:20 kjc Exp $	*/
3 /*	$KAME: altq_var.h,v 1.8 2001/02/09 09:44:41 kjc Exp $	*/
4 /*	$NetBSD: callout.h,v 1.19 2003/09/25 10:44:11 scw Exp $	*/
5 
6 /*
7  * Copyright (C) 1998-2000
8  *	Sony Computer Science Laboratories Inc.  All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31 #ifndef _ALTQ_ALTQ_VAR_H_
32 #define	_ALTQ_ALTQ_VAR_H_
33 
34 #ifdef _KERNEL
35 
36 #include <sys/param.h>
37 #include <sys/kernel.h>
38 #include <sys/queue.h>
39 
40 #ifndef ALTQ_RED
41 #define ALTQ_RED		/* RED is enabled by default */
42 #endif
43 #ifndef ALTQ_CBQ
44 #define ALTQ_CBQ		/* CBQ is enabled by default */
45 #endif
46 #ifndef ALTQ_PRIQ
47 #define ALTQ_PRIQ		/* PRIQ is enabled by default */
48 #endif
49 #ifndef ALTQ_HFSC
50 #define ALTQ_HFSC		/* HFSC is enabled by default */
51 #endif
52 
53 /*
54  * machine dependent clock
55  * a 64bit high resolution time counter.
56  */
57 extern int machclk_usepcc;
58 extern u_int32_t machclk_freq;
59 extern u_int32_t machclk_per_tick;
60 extern void init_machclk(void);
61 extern u_int64_t read_machclk(void);
62 
63 /*
64  * debug support
65  */
66 #ifdef ALTQ_DEBUG
67 #ifdef __STDC__
68 #define	ASSERT(e)	((e) ? (void)0 : altq_assert(__FILE__, __LINE__, #e))
69 #else	/* PCC */
70 #define	ASSERT(e)	((e) ? (void)0 : altq_assert(__FILE__, __LINE__, "e"))
71 #endif
72 #else
73 #define	ASSERT(e)	((void)0)
74 #endif
75 
76 /*
77  * misc stuff for compatibility
78  */
79 
80 /* macro for timeout/untimeout */
81 #include <sys/timeout.h>
82 /* callout structure as a wrapper of struct timeout */
83 struct callout {
84 	struct timeout	c_to;
85 };
86 #define	CALLOUT_INIT(c)		do { bzero((c), sizeof(*(c))); } while (0)
87 #define	CALLOUT_RESET(c,t,f,a)	do { if (!timeout_initialized(&(c)->c_to))  \
88 					 timeout_set(&(c)->c_to, (f), (a)); \
89 				     timeout_add(&(c)->c_to, (t)); } while (0)
90 #define	CALLOUT_STOP(c)		timeout_del(&(c)->c_to)
91 #define	CALLOUT_INITIALIZER	{ { { {NULL}, {NULL} }, NULL, NULL, 0, 0 } }
92 
93 typedef void (timeout_t)(void *);
94 
95 #define	m_pktlen(m)		((m)->m_pkthdr.len)
96 
97 struct ifnet; struct mbuf;
98 struct pf_altq; struct pf_qstats;
99 
100 void	*altq_lookup(char *, int);
101 u_int8_t read_dsfield(struct mbuf *, struct altq_pktattr *);
102 void	write_dsfield(struct mbuf *, struct altq_pktattr *, u_int8_t);
103 void	altq_assert(const char *, int, const char *);
104 int	tbr_set(struct ifaltq *, struct tb_profile *);
105 int	tbr_get(struct ifaltq *, struct tb_profile *);
106 int	altq_pfattach(struct pf_altq *);
107 
108 int	altq_pfdetach(struct pf_altq *);
109 int	altq_add(struct pf_altq *);
110 int	altq_remove(struct pf_altq *);
111 int	altq_add_queue(struct pf_altq *);
112 int	altq_remove_queue(struct pf_altq *);
113 int	altq_getqstats(struct pf_altq *, void *, int *);
114 
115 int	cbq_pfattach(struct pf_altq *);
116 int	cbq_add_altq(struct pf_altq *);
117 int	cbq_remove_altq(struct pf_altq *);
118 int	cbq_add_queue(struct pf_altq *);
119 int	cbq_remove_queue(struct pf_altq *);
120 int	cbq_getqstats(struct pf_altq *, void *, int *);
121 
122 int	priq_pfattach(struct pf_altq *);
123 int	priq_add_altq(struct pf_altq *);
124 int	priq_remove_altq(struct pf_altq *);
125 int	priq_add_queue(struct pf_altq *);
126 int	priq_remove_queue(struct pf_altq *);
127 int	priq_getqstats(struct pf_altq *, void *, int *);
128 
129 int	hfsc_pfattach(struct pf_altq *);
130 int	hfsc_add_altq(struct pf_altq *);
131 int	hfsc_remove_altq(struct pf_altq *);
132 int	hfsc_add_queue(struct pf_altq *);
133 int	hfsc_remove_queue(struct pf_altq *);
134 int	hfsc_getqstats(struct pf_altq *, void *, int *);
135 
136 #endif /* _KERNEL */
137 #endif /* _ALTQ_ALTQ_VAR_H_ */
138