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