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 */
84 #define WFQ_IF_ATTACH _IOW('Q', 1, struct wfq_interface)
85 #define WFQ_IF_DETACH _IOW('Q', 2, struct wfq_interface)
86 #define WFQ_ENABLE _IOW('Q', 3, struct wfq_interface)
87 #define WFQ_DISABLE _IOW('Q', 4, struct wfq_interface)
88 #define WFQ_CONFIG _IOWR('Q', 6, struct wfq_conf)
89 #define WFQ_GET_STATS _IOWR('Q', 12, struct wfq_getstats)
90 #define WFQ_GET_QID _IOWR('Q', 30, struct wfq_getqid)
91 #define WFQ_SET_WEIGHT _IOWR('Q', 31, struct wfq_setweight)
95 #define HWM (64 * 1024)
96 #define WFQ_QUOTA 512 /* quota bytes to send at a time */
97 #define WFQ_ADDQUOTA(q) ((q)->quota += WFQ_QUOTA * (q)->weight / 100)
101 typedef struct weighted_fair_queue{
102 struct weighted_fair_queue *next, *prev;
103 struct mbuf *head, *tail;
104 int bytes; /* bytes in this queue */
105 int quota; /* bytes sent in this round */
106 int weight; /* weight in percent */
108 struct pktcntr xmit_cnt;
109 struct pktcntr drop_cnt;
113 typedef struct wfqstate {
114 struct wfqstate *next; /* for wfqstate list */
116 int nums; /* number of queues */
117 int hwm; /* high water mark */
118 int bytes; /* total bytes in all the queues */
119 wfq *rrp; /* round robin pointer */
120 wfq *queue; /* pointer to queue list */
121 #ifdef ALTQ3_CLFIER_COMPAT
122 u_long (*hash_func)(struct flowinfo *, int);
124 u_int32_t fbmask; /* filter bitmask */
129 #endif /* _ALTQ_ALTQ_WFQ_H */