1 /*        $NetBSD: altq_blue.h,v 1.5 2006/10/12 19:59:08 peter Exp $  */
2 /*        $KAME: altq_blue.h,v 1.7 2002/11/29 04:36:22 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 #ifndef _ALTQ_ALTQ_BLUE_H_
31 #define   _ALTQ_ALTQ_BLUE_H_
32 
33 #include <altq/altq_classq.h>
34 
35 struct blue_interface {
36           char      blue_ifname[IFNAMSIZ];
37 };
38 
39 struct blue_stats {
40           struct blue_interface iface;
41           int q_len;
42           int q_limit;
43           int q_pmark;
44           u_quad_t xmit_packets;
45           u_quad_t xmit_bytes;
46           u_quad_t drop_packets;
47           u_quad_t drop_bytes;
48           u_quad_t drop_forced;
49           u_quad_t drop_unforced;
50           u_quad_t marked_packets;
51 };
52 
53 struct blue_conf {
54           struct blue_interface iface;
55           int blue_limit;
56           int blue_max_pmark;
57           int blue_hold_time;
58           int blue_pkttime;   /* average packet time in usec */
59           int blue_flags;               /* see below */
60 };
61 
62 /* blue flags */
63 #define   BLUEF_ECN4          0x01      /* use packet marking for IPv4 packets */
64 #define   BLUEF_ECN6          0x02      /* use packet marking for IPv6 packets */
65 #define   BLUEF_ECN (BLUEF_ECN4 | BLUEF_ECN6)
66 
67 /*
68  * IOCTLs for BLUE
69  */
70 #define   BLUE_IF_ATTACH                _IOW('Q', 1, struct blue_interface)
71 #define   BLUE_IF_DETACH                _IOW('Q', 2, struct blue_interface)
72 #define   BLUE_ENABLE                   _IOW('Q', 3, struct blue_interface)
73 #define   BLUE_DISABLE                  _IOW('Q', 4, struct blue_interface)
74 #define   BLUE_CONFIG                   _IOWR('Q', 6, struct blue_conf)
75 #define   BLUE_GETSTATS                 _IOWR('Q', 12, struct blue_stats)
76 
77 #ifdef _KERNEL
78 
79 typedef struct blue {
80           int blue_pkttime;   /* average packet time in micro sec
81                                            used for idle calibration */
82           int blue_flags;               /* blue flags */
83 
84           /* blue parameters */
85           int blue_pmark;               /* 0-1000 (mark probability*10000) */
86           int blue_max_pmark; /* sets precision of marking probability */
87           int blue_hold_time; /* hold time in usec */
88 
89           int blue_idle;                /* queue was empty */
90           struct timeval blue_last;  /* timestamp when the queue becomes idle */
91 
92           struct {
93                     u_quad_t xmit_packets;
94                     u_quad_t xmit_bytes;
95                     u_quad_t drop_packets;
96                     u_quad_t drop_bytes;
97                     u_quad_t drop_forced;
98                     u_quad_t drop_unforced;
99                     u_quad_t marked_packets;
100           } blue_stats;
101 } blue_t;
102 
103 typedef struct blue_queue {
104           struct blue_queue *rq_next;   /* next blue_state in the list */
105           struct ifaltq *rq_ifq;                  /* backpointer to ifaltq */
106 
107           class_queue_t *rq_q;
108 
109           blue_t *rq_blue;
110 } blue_queue_t;
111 
112 extern int blue_init(blue_t *, int, int, int, int);
113 extern int blue_addq(blue_t *, class_queue_t *, struct mbuf *,
114                          struct altq_pktattr *);
115 extern struct mbuf *blue_getq(blue_t *, class_queue_t *);
116 
117 #endif /* _KERNEL */
118 
119 #endif /* _ALTQ_ALTQ_BLUE_H_ */
120