linprocfs - Introduce /proc/mounts
[dragonfly.git] / sys / net / altq / if_altq.h
blob9b0da4b5d61e0670e502f95394c2ff0fef103409
1 /* $KAME: if_altq.h,v 1.11 2003/07/10 12:07:50 kjc Exp $ */
2 /* $DragonFly: src/sys/net/altq/if_altq.h,v 1.4 2008/05/14 11:59:23 sephe Exp $ */
4 /*
5 * Copyright (C) 1997-2003
6 * Sony Computer Science Laboratories Inc. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
29 #ifndef _NET_ALTQ_IF_ALTQ_H_
30 #define _NET_ALTQ_IF_ALTQ_H_
32 #ifndef _SYS_SERIALIZE_H_
33 #include <sys/serialize.h>
34 #endif
36 struct altq_pktattr;
39 * Structure defining a queue for a network interface.
41 struct ifaltq {
42 /* fields compatible with struct ifqueue */
43 struct mbuf *ifq_head;
44 struct mbuf *ifq_tail;
45 int ifq_len;
46 int ifq_maxlen;
47 int ifq_drops;
49 /* alternate queueing related fields */
50 int altq_type; /* discipline type */
51 int altq_flags; /* flags (e.g. ready, in-use) */
52 void *altq_disc; /* for discipline-specific use */
53 struct ifnet *altq_ifp; /* back pointer to interface */
55 int (*altq_enqueue)(struct ifaltq *, struct mbuf *,
56 struct altq_pktattr *);
57 struct mbuf *(*altq_dequeue)(struct ifaltq *, struct mbuf *, int);
58 int (*altq_request)(struct ifaltq *, int, void *);
60 /* classifier fields */
61 void *altq_clfier; /* classifier-specific use */
62 void *(*altq_classify)(struct ifaltq *, struct mbuf *,
63 struct altq_pktattr *);
65 /* token bucket regulator */
66 struct tb_regulator *altq_tbr;
68 struct lwkt_serialize altq_lock;
69 struct mbuf *altq_prepended; /* mbuf dequeued, but not yet xmit */
70 int altq_started; /* ifnet.if_start interlock */
73 #ifdef SMP
74 #define ALTQ_ASSERT_LOCKED(ifq) ASSERT_SERIALIZED(&(ifq)->altq_lock)
75 #define ALTQ_LOCK_INIT(ifq) lwkt_serialize_init(&(ifq)->altq_lock)
76 #define ALTQ_LOCK(ifq) lwkt_serialize_adaptive_enter(&(ifq)->altq_lock)
77 #define ALTQ_UNLOCK(ifq) lwkt_serialize_exit(&(ifq)->altq_lock)
78 #else
79 #define ALTQ_ASSERT_LOCKED(ifq) ((void)0) /* XXX */
80 #define ALTQ_LOCK_INIT(ifq) ((void)0)
81 #define ALTQ_LOCK(ifq) crit_enter()
82 #define ALTQ_UNLOCK(ifq) crit_exit()
83 #endif
85 #ifdef _KERNEL
88 * packet attributes used by queueing disciplines.
89 * pattr_class is a discipline-dependent scheduling class that is
90 * set by a classifier.
91 * pattr_hdr and pattr_af may be used by a discipline to access
92 * the header within a mbuf. (e.g. ECN needs to update the CE bit)
93 * note that pattr_hdr could be stale after m_pullup, though link
94 * layer output routines usually don't use m_pullup. link-level
95 * compression also invalidates these fields. thus, pattr_hdr needs
96 * to be verified when a discipline touches the header.
98 struct altq_pktattr {
99 void *pattr_class; /* sched class set by classifier */
100 int pattr_af; /* address family */
101 caddr_t pattr_hdr; /* saved header position in mbuf */
105 * a token-bucket regulator limits the rate that a network driver can
106 * dequeue packets from the output queue.
107 * modern cards are able to buffer a large amount of packets and dequeue
108 * too many packets at a time. this bursty dequeue behavior makes it
109 * impossible to schedule packets by queueing disciplines.
110 * a token-bucket is used to control the burst size in a device
111 * independent manner.
113 struct tb_regulator {
114 int64_t tbr_rate; /* (scaled) token bucket rate */
115 int64_t tbr_depth; /* (scaled) token bucket depth */
117 int64_t tbr_token; /* (scaled) current token */
118 int64_t tbr_filluptime; /* (scaled) time to fill up bucket */
119 uint64_t tbr_last; /* last time token was updated */
121 int tbr_lastop; /* last dequeue operation type
122 needed for poll-and-dequeue */
125 /* if_altqflags */
126 #define ALTQF_READY 0x01 /* driver supports alternate queueing */
127 #define ALTQF_ENABLED 0x02 /* altq is in use */
128 #define ALTQF_CLASSIFY 0x04 /* classify packets */
129 #define ALTQF_DRIVER1 0x40 /* driver specific */
131 /* if_altqflags set internally only: */
132 #define ALTQF_CANTCHANGE (ALTQF_READY)
134 /* altq_dequeue 2nd arg */
135 #define ALTDQ_REMOVE 1 /* dequeue mbuf from the queue */
136 #define ALTDQ_POLL 2 /* don't dequeue mbuf from the queue */
138 /* altq request types (currently only purge is defined) */
139 #define ALTRQ_PURGE 1 /* purge all packets */
141 int altq_attach(struct ifaltq *, int, void *,
142 int (*)(struct ifaltq *, struct mbuf *, struct altq_pktattr *),
143 struct mbuf *(*)(struct ifaltq *, struct mbuf *, int),
144 int (*)(struct ifaltq *, int, void *),
145 void *, void *(*)(struct ifaltq *, struct mbuf *,
146 struct altq_pktattr *));
147 int altq_detach(struct ifaltq *);
148 int altq_enable(struct ifaltq *);
149 int altq_disable(struct ifaltq *);
150 struct mbuf *tbr_dequeue(struct ifaltq *, struct mbuf *, int);
151 extern int (*altq_input)(struct mbuf *, int);
152 #endif /* _KERNEL */
154 #endif /* _NET_ALTQ_IF_ALTQ_H_ */