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.2 2005/03/12 02:36:04 joerg Exp $
33 #ifndef _NET_IFQ_VAR_H
34 #define _NET_IFQ_VAR_H
38 ifq_is_enabled(struct ifaltq *_ifq)
40 return(_ifq->altq_flags & ALTQF_ENABLED);
44 ifq_is_attached(struct ifaltq *_ifq)
46 return(_ifq->altq_disc != NULL);
50 ifq_is_enabled(struct ifaltq *_ifq)
56 ifq_is_attached(struct ifaltq *_ifq)
63 ifq_is_ready(struct ifaltq *_ifq)
65 return(_ifq->altq_flags & ALTQF_READY);
69 ifq_set_ready(struct ifaltq *_ifq)
71 _ifq->altq_flags |= ALTQF_READY;
75 ifq_enqueue(struct ifaltq *_ifq, struct mbuf *_m, struct altq_pktattr *_pa)
77 return((*_ifq->altq_enqueue)(_ifq, _m, _pa));
80 static __inline struct mbuf *
81 ifq_dequeue(struct ifaltq *_ifq)
84 if (_ifq->altq_tbr != NULL)
85 return(tbr_dequeue(_ifq, ALTDQ_REMOVE));
87 return((*_ifq->altq_dequeue)(_ifq, ALTDQ_REMOVE));
90 static __inline struct mbuf *
91 ifq_poll(struct ifaltq *_ifq)
94 if (_ifq->altq_tbr != NULL)
95 return(tbr_dequeue(_ifq, ALTDQ_POLL));
97 return((*_ifq->altq_dequeue)(_ifq, ALTDQ_POLL));
101 ifq_purge(struct ifaltq *_ifq)
103 (*_ifq->altq_request)(_ifq, ALTRQ_PURGE, NULL);
107 ifq_classify(struct ifaltq *_ifq, struct mbuf *_m, uint8_t _af,
108 struct altq_pktattr *_pa)
110 if (!ifq_is_enabled(_ifq))
113 _pa->pattr_hdr = mtod(_m, caddr_t);
114 if (_ifq->altq_flags & ALTQF_CLASSIFY)
115 (*_ifq->altq_classify)(_ifq, _m, _pa);
119 ifq_handoff(struct ifnet *_ifp, struct mbuf *_m, struct altq_pktattr *_pa)
124 _error = ifq_enqueue(&_ifp->if_snd, _m, _pa);
126 _ifp->if_obytes += _m->m_pkthdr.len;
127 if (_m->m_flags & M_MCAST)
129 if ((_ifp->if_flags & IFF_OACTIVE) == 0)
130 (*_ifp->if_start)(_ifp);
137 ifq_is_empty(struct ifaltq *_ifq)
139 return(_ifq->ifq_len == 0);
143 ifq_set_maxlen(struct ifaltq *_ifq, int _len)
145 _ifq->ifq_maxlen = _len;