1e7d68516SSepherosa Ziehau /*
2e7d68516SSepherosa Ziehau * Copyright (c) 1991-1997 Regents of the University of California.
3e7d68516SSepherosa Ziehau * All rights reserved.
4e7d68516SSepherosa Ziehau *
5e7d68516SSepherosa Ziehau * Redistribution and use in source and binary forms, with or without
6e7d68516SSepherosa Ziehau * modification, are permitted provided that the following conditions
7e7d68516SSepherosa Ziehau * are met:
8e7d68516SSepherosa Ziehau * 1. Redistributions of source code must retain the above copyright
9e7d68516SSepherosa Ziehau * notice, this list of conditions and the following disclaimer.
10e7d68516SSepherosa Ziehau * 2. Redistributions in binary form must reproduce the above copyright
11e7d68516SSepherosa Ziehau * notice, this list of conditions and the following disclaimer in the
12e7d68516SSepherosa Ziehau * documentation and/or other materials provided with the distribution.
13e7d68516SSepherosa Ziehau * 3. All advertising materials mentioning features or use of this software
14e7d68516SSepherosa Ziehau * must display the following acknowledgement:
15e7d68516SSepherosa Ziehau * This product includes software developed by the Network Research
16e7d68516SSepherosa Ziehau * Group at Lawrence Berkeley Laboratory.
17e7d68516SSepherosa Ziehau * 4. Neither the name of the University nor of the Laboratory may be used
18e7d68516SSepherosa Ziehau * to endorse or promote products derived from this software without
19e7d68516SSepherosa Ziehau * specific prior written permission.
20e7d68516SSepherosa Ziehau *
21e7d68516SSepherosa Ziehau * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22e7d68516SSepherosa Ziehau * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23e7d68516SSepherosa Ziehau * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24e7d68516SSepherosa Ziehau * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25e7d68516SSepherosa Ziehau * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26e7d68516SSepherosa Ziehau * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27e7d68516SSepherosa Ziehau * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28e7d68516SSepherosa Ziehau * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29e7d68516SSepherosa Ziehau * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30e7d68516SSepherosa Ziehau * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31e7d68516SSepherosa Ziehau * SUCH DAMAGE.
32e7d68516SSepherosa Ziehau */
33e7d68516SSepherosa Ziehau /*
34e7d68516SSepherosa Ziehau * class queue definitions extracted from altq_classq.h.
35e7d68516SSepherosa Ziehau */
36e7d68516SSepherosa Ziehau
37e7d68516SSepherosa Ziehau #ifndef _NET_IF_CLASSQ_H_
38e7d68516SSepherosa Ziehau #define _NET_IF_CLASSQ_H_
39e7d68516SSepherosa Ziehau
40e7d68516SSepherosa Ziehau struct if_classq {
41e7d68516SSepherosa Ziehau struct mbuf *clq_tail; /* Tail of packet queue */
42e7d68516SSepherosa Ziehau };
43e7d68516SSepherosa Ziehau
44e7d68516SSepherosa Ziehau #ifdef _KERNEL
45e7d68516SSepherosa Ziehau
46e7d68516SSepherosa Ziehau #define classq_tail(q) (q)->clq_tail
47e7d68516SSepherosa Ziehau #define classq_head(q) ((q)->clq_tail ? (q)->clq_tail->m_nextpkt : NULL)
48e7d68516SSepherosa Ziehau
49e7d68516SSepherosa Ziehau static __inline void
classq_add(struct if_classq * q,struct mbuf * m)50e7d68516SSepherosa Ziehau classq_add(struct if_classq *q, struct mbuf *m)
51e7d68516SSepherosa Ziehau {
52e7d68516SSepherosa Ziehau struct mbuf *m0;
53e7d68516SSepherosa Ziehau
54e7d68516SSepherosa Ziehau if ((m0 = classq_tail(q)) != NULL)
55e7d68516SSepherosa Ziehau m->m_nextpkt = m0->m_nextpkt;
56e7d68516SSepherosa Ziehau else
57e7d68516SSepherosa Ziehau m0 = m;
58e7d68516SSepherosa Ziehau m0->m_nextpkt = m;
59e7d68516SSepherosa Ziehau classq_tail(q) = m;
60e7d68516SSepherosa Ziehau }
61e7d68516SSepherosa Ziehau
62e7d68516SSepherosa Ziehau static __inline struct mbuf *
classq_get(struct if_classq * q)63e7d68516SSepherosa Ziehau classq_get(struct if_classq *q)
64e7d68516SSepherosa Ziehau {
65e7d68516SSepherosa Ziehau struct mbuf *m, *m0;
66e7d68516SSepherosa Ziehau
67e7d68516SSepherosa Ziehau if ((m = classq_tail(q)) == NULL)
68e7d68516SSepherosa Ziehau return (NULL);
69e7d68516SSepherosa Ziehau if ((m0 = m->m_nextpkt) != m)
70e7d68516SSepherosa Ziehau m->m_nextpkt = m0->m_nextpkt;
71e7d68516SSepherosa Ziehau else
72e7d68516SSepherosa Ziehau classq_tail(q) = NULL;
73e7d68516SSepherosa Ziehau m0->m_nextpkt = NULL;
74e7d68516SSepherosa Ziehau return (m0);
75e7d68516SSepherosa Ziehau }
76e7d68516SSepherosa Ziehau
77*80e75f6aSSepherosa Ziehau static __inline void
classq_concat(struct if_classq * to,struct if_classq * from)78*80e75f6aSSepherosa Ziehau classq_concat(struct if_classq *to, struct if_classq *from)
79*80e75f6aSSepherosa Ziehau {
80*80e75f6aSSepherosa Ziehau struct mbuf *head, *tail;
81*80e75f6aSSepherosa Ziehau
82*80e75f6aSSepherosa Ziehau if (classq_tail(from) == NULL)
83*80e75f6aSSepherosa Ziehau return;
84*80e75f6aSSepherosa Ziehau if (classq_tail(to) == NULL) {
85*80e75f6aSSepherosa Ziehau tail = classq_tail(from);
86*80e75f6aSSepherosa Ziehau goto done;
87*80e75f6aSSepherosa Ziehau }
88*80e75f6aSSepherosa Ziehau
89*80e75f6aSSepherosa Ziehau head = classq_head(to);
90*80e75f6aSSepherosa Ziehau
91*80e75f6aSSepherosa Ziehau tail = classq_tail(to);
92*80e75f6aSSepherosa Ziehau tail->m_nextpkt = classq_head(from);
93*80e75f6aSSepherosa Ziehau
94*80e75f6aSSepherosa Ziehau tail = classq_tail(from);
95*80e75f6aSSepherosa Ziehau tail->m_nextpkt = head;
96*80e75f6aSSepherosa Ziehau done:
97*80e75f6aSSepherosa Ziehau classq_tail(to) = tail;
98*80e75f6aSSepherosa Ziehau classq_tail(from) = NULL;
99*80e75f6aSSepherosa Ziehau }
100*80e75f6aSSepherosa Ziehau
101e7d68516SSepherosa Ziehau #endif /* _KERNEL */
102e7d68516SSepherosa Ziehau
103e7d68516SSepherosa Ziehau #endif /* !_NET_IF_CLASSQ_H_ */
104