]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sbin/pfctl/missing/altq/altq_wfq.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sbin / pfctl / missing / altq / altq_wfq.h
1 /*      $FreeBSD$       */
2 /*      $KAME: altq_wfq.h,v 1.8 2003/07/10 12:07:49 kjc Exp $   */
3
4 /*
5  * Copyright (C) 1997-2002
6  *      Sony Computer Science Laboratories Inc.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
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.
16  *
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
27  * SUCH DAMAGE.
28  */
29 /*
30  *  March 27, 1997.  Written by Hiroshi Kyusojin of Keio University
31  *  (kyu@mt.cs.keio.ac.jp).
32  */
33
34 #ifndef _ALTQ_ALTQ_WFQ_H_
35 #define _ALTQ_ALTQ_WFQ_H_
36
37 #include <altq/altq.h>
38
39 #define DEFAULT_QSIZE   256
40 #define MAX_QSIZE       2048
41
42 struct wfq_interface{
43         char wfq_ifacename[IFNAMSIZ];
44 };
45
46 struct wfq_getqid{
47         struct wfq_interface    iface;
48 #ifdef ALTQ3_CLFIER_COMPAT
49         struct flowinfo         flow;
50 #endif
51         u_long                  qid;
52 };
53
54 struct wfq_setweight {
55         struct wfq_interface    iface;
56         int                     qid;
57         int                     weight;
58 };
59
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;
65 } queue_stats;
66
67 struct wfq_getstats {
68         struct wfq_interface    iface;
69         int                     qid;
70         queue_stats             stats;
71 };
72
73 struct wfq_conf {
74         struct wfq_interface    iface;
75         int                     hash_policy;    /* hash policy */
76         int                     nqueues;        /* number of queues */
77         int                     qlimit;         /* queue size in bytes */
78 };
79
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
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)
92
93 #ifdef _KERNEL
94
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)
98 #define ENABLE                  0
99 #define DISABLE                 1
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 */
107
108         struct pktcntr xmit_cnt;
109         struct pktcntr drop_cnt;
110 } wfq;
111
112
113 typedef struct wfqstate {
114         struct wfqstate *next;          /* for wfqstate list */
115         struct ifaltq *ifq;
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);
123 #endif
124         u_int32_t fbmask;               /* filter bitmask */
125 } wfq_state_t;
126
127 #endif /* _KERNEL */
128
129 #endif /* _ALTQ_ALTQ_WFQ_H */