altq_blue.h revision 1.1 1 /* $KAME: altq_blue.h,v 1.5 2000/12/14 08:12:45 thorpej Exp $ */
2
3 /*
4 * Copyright (C) 1997-2000
5 * Sony Computer Science Laboratories Inc. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #ifndef _ALTQ_ALTQ_BLUE_H_
30 #define _ALTQ_ALTQ_BLUE_H_
31
32 #include <altq/altq_classq.h>
33
34 struct blue_interface {
35 char blue_ifname[IFNAMSIZ];
36 };
37
38 struct blue_stats {
39 struct blue_interface iface;
40 int q_len;
41 int q_limit;
42 int q_pmark;
43 u_quad_t xmit_packets;
44 u_quad_t xmit_bytes;
45 u_quad_t drop_packets;
46 u_quad_t drop_bytes;
47 u_quad_t drop_forced;
48 u_quad_t drop_unforced;
49 u_quad_t marked_packets;
50 };
51
52 struct blue_conf {
53 struct blue_interface iface;
54 int blue_limit;
55 int blue_max_pmark;
56 int blue_hold_time;
57 int blue_pkttime; /* average packet time in usec */
58 int blue_flags; /* see below */
59 };
60
61 /* blue flags */
62 #define BLUEF_ECN4 0x01 /* use packet marking for IPv4 packets */
63 #define BLUEF_ECN6 0x02 /* use packet marking for IPv6 packets */
64 #define BLUEF_ECN (BLUEF_ECN4 | BLUEF_ECN6)
65
66 /*
67 * IOCTLs for BLUE
68 */
69 #define BLUE_IF_ATTACH _IOW('Q', 1, struct blue_interface)
70 #define BLUE_IF_DETACH _IOW('Q', 2, struct blue_interface)
71 #define BLUE_ENABLE _IOW('Q', 3, struct blue_interface)
72 #define BLUE_DISABLE _IOW('Q', 4, struct blue_interface)
73 #define BLUE_CONFIG _IOWR('Q', 6, struct blue_conf)
74 #define BLUE_GETSTATS _IOWR('Q', 12, struct blue_stats)
75
76 #ifdef _KERNEL
77
78 typedef struct blue {
79 int blue_pkttime; /* average packet time in micro sec
80 used for idle calibration */
81 int blue_flags; /* blue flags */
82
83 /* blue parameters */
84 int blue_pmark; /* 0-1000 (mark probability*10000) */
85 int blue_max_pmark; /* sets precision of marking probability */
86 int blue_hold_time; /* hold time in usec */
87
88 int blue_idle; /* queue was empty */
89 struct timeval blue_last; /* timestamp when the queue becomes idle */
90
91 struct {
92 u_quad_t xmit_packets;
93 u_quad_t xmit_bytes;
94 u_quad_t drop_packets;
95 u_quad_t drop_bytes;
96 u_quad_t drop_forced;
97 u_quad_t drop_unforced;
98 u_quad_t marked_packets;
99 } blue_stats;
100 } blue_t;
101
102 typedef struct blue_queue {
103 struct blue_queue *rq_next; /* next blue_state in the list */
104 struct ifaltq *rq_ifq; /* backpointer to ifaltq */
105
106 class_queue_t *rq_q;
107
108 blue_t *rq_blue;
109 } blue_queue_t;
110
111 extern int blue_init __P((blue_t *, int, int, int, int));
112 extern int blue_addq __P((blue_t *, class_queue_t *, struct mbuf *,
113 struct altq_pktattr *));
114 extern struct mbuf *blue_getq __P((blue_t *, class_queue_t *));
115
116 #endif /* _KERNEL */
117
118 #endif /* _ALTQ_ALTQ_BLUE_H_ */
119