2 * Copyright (c) 2005 The DragonFly Project. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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
12 * the documentation and/or other materials provided with the
14 * 3. Neither the name of The DragonFly Project nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific, prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * $DragonFly: src/sys/net/ifq_var.h,v 1.4 2005/06/15 19:29:30 joerg Exp $
33 #ifndef _NET_IFQ_VAR_H
34 #define _NET_IFQ_VAR_H
36 #include <sys/thread2.h>
40 ifq_is_enabled(struct ifaltq *_ifq)
42 return(_ifq->altq_flags & ALTQF_ENABLED);
46 ifq_is_attached(struct ifaltq *_ifq)
48 return(_ifq->altq_disc != NULL);
52 ifq_is_enabled(struct ifaltq *_ifq)
58 ifq_is_attached(struct ifaltq *_ifq)
65 ifq_is_ready(struct ifaltq *_ifq)
67 return(_ifq->altq_flags & ALTQF_READY);
71 ifq_set_ready(struct ifaltq *_ifq)
73 _ifq->altq_flags |= ALTQF_READY;
77 ifq_enqueue(struct ifaltq *_ifq, struct mbuf *_m, struct altq_pktattr *_pa)
79 return((*_ifq->altq_enqueue)(_ifq, _m, _pa));
82 static __inline struct mbuf *
83 ifq_dequeue(struct ifaltq *_ifq)
86 if (_ifq->altq_tbr != NULL)
87 return(tbr_dequeue(_ifq, ALTDQ_REMOVE));
89 return((*_ifq->altq_dequeue)(_ifq, ALTDQ_REMOVE));
92 static __inline struct mbuf *
93 ifq_poll(struct ifaltq *_ifq)
96 if (_ifq->altq_tbr != NULL)
97 return(tbr_dequeue(_ifq, ALTDQ_POLL));
99 return((*_ifq->altq_dequeue)(_ifq, ALTDQ_POLL));
103 ifq_purge(struct ifaltq *_ifq)
105 (*_ifq->altq_request)(_ifq, ALTRQ_PURGE, NULL);
109 ifq_classify(struct ifaltq *_ifq, struct mbuf *_m, uint8_t _af,
110 struct altq_pktattr *_pa)
112 if (!ifq_is_enabled(_ifq))
115 _pa->pattr_hdr = mtod(_m, caddr_t);
116 if (_ifq->altq_flags & ALTQF_CLASSIFY)
117 (*_ifq->altq_classify)(_ifq, _m, _pa);
121 ifq_handoff(struct ifnet *_ifp, struct mbuf *_m, struct altq_pktattr *_pa)
126 _error = ifq_enqueue(&_ifp->if_snd, _m, _pa);
128 _ifp->if_obytes += _m->m_pkthdr.len;
129 if (_m->m_flags & M_MCAST)
131 if ((_ifp->if_flags & IFF_OACTIVE) == 0)
132 (*_ifp->if_start)(_ifp);
139 ifq_is_empty(struct ifaltq *_ifq)
141 return(_ifq->ifq_len == 0);
145 ifq_set_maxlen(struct ifaltq *_ifq, int _len)
147 _ifq->ifq_maxlen = _len;
150 void ifq_set_classic(struct ifaltq *);