1 /* $NetBSD: altq_wfq.h,v 1.5 2006/10/12 19:59:08 peter Exp $ */
2 /* $KAME: altq_wfq.h,v 1.8 2003/07/10 12:07:49 kjc Exp $ */
5 * Copyright (C) 1997-2002
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
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
30 * March 27, 1997. Written by Hiroshi Kyusojin of Keio University
31 * (kyu@mt.cs.keio.ac.jp).
34 #ifndef _ALTQ_ALTQ_WFQ_H_
35 #define _ALTQ_ALTQ_WFQ_H_
37 #include <altq/altq.h>
39 #define DEFAULT_QSIZE 256
40 #define MAX_QSIZE 2048
43 char wfq_ifacename
[IFNAMSIZ
];
47 struct wfq_interface iface
;
48 #ifdef ALTQ3_CLFIER_COMPAT
54 struct wfq_setweight
{
55 struct wfq_interface iface
;
60 typedef struct each_queue_stats
{
61 int bytes
; /* bytes in this queue */
62 int weight
; /* weight in percent */
63 struct pktcntr xmit_cnt
;
64 struct pktcntr drop_cnt
;
68 struct wfq_interface iface
;
74 struct wfq_interface iface
;
75 int hash_policy
; /* hash policy */
76 int nqueues
; /* number of queues */
77 int qlimit
; /* queue size in bytes */
80 #define WFQ_HASH_DSTADDR 0 /* hash by dst address */
81 #define WFQ_HASH_SRCPORT 1 /* hash by src port */
82 #define WFQ_HASH_FULL 2 /* hash by all fields */
83 #define WFQ_HASH_SRCADDR 3 /* hash by src address */
85 #define WFQ_IF_ATTACH _IOW('Q', 1, struct wfq_interface)
86 #define WFQ_IF_DETACH _IOW('Q', 2, struct wfq_interface)
87 #define WFQ_ENABLE _IOW('Q', 3, struct wfq_interface)
88 #define WFQ_DISABLE _IOW('Q', 4, struct wfq_interface)
89 #define WFQ_CONFIG _IOWR('Q', 6, struct wfq_conf)
90 #define WFQ_GET_STATS _IOWR('Q', 12, struct wfq_getstats)
91 #define WFQ_GET_QID _IOWR('Q', 30, struct wfq_getqid)
92 #define WFQ_SET_WEIGHT _IOWR('Q', 31, struct wfq_setweight)
96 #define HWM (64 * 1024)
97 #define WFQ_QUOTA 512 /* quota bytes to send at a time */
98 #define WFQ_ADDQUOTA(q) ((q)->quota += WFQ_QUOTA * (q)->weight / 100)
102 typedef struct weighted_fair_queue
{
103 struct weighted_fair_queue
*next
, *prev
;
104 struct mbuf
*head
, *tail
;
105 int bytes
; /* bytes in this queue */
106 int quota
; /* bytes sent in this round */
107 int weight
; /* weight in percent */
109 struct pktcntr xmit_cnt
;
110 struct pktcntr drop_cnt
;
114 typedef struct wfqstate
{
115 struct wfqstate
*next
; /* for wfqstate list */
117 int nums
; /* number of queues */
118 int hwm
; /* high water mark */
119 int bytes
; /* total bytes in all the queues */
120 wfq
*rrp
; /* round robin pointer */
121 wfq
*queue
; /* pointer to queue list */
122 #ifdef ALTQ3_CLFIER_COMPAT
123 u_long (*hash_func
)(struct flowinfo
*, int);
125 u_int32_t fbmask
; /* filter bitmask */
130 #endif /* _ALTQ_ALTQ_WFQ_H */