Home | History | Annotate | Line # | Download | only in altq
altq_rio.h revision 1.2.2.2
      1  1.2.2.2  bouyer /*	$NetBSD: altq_rio.h,v 1.2.2.2 2001/01/05 17:39:37 bouyer Exp $	*/
      2  1.2.2.2  bouyer /*	$KAME: altq_rio.h,v 1.5 2000/12/14 08:12:46 thorpej Exp $	*/
      3  1.2.2.2  bouyer 
      4  1.2.2.2  bouyer /*
      5  1.2.2.2  bouyer  * Copyright (C) 1998-2000
      6  1.2.2.2  bouyer  *	Sony Computer Science Laboratories Inc.  All rights reserved.
      7  1.2.2.2  bouyer  *
      8  1.2.2.2  bouyer  * Redistribution and use in source and binary forms, with or without
      9  1.2.2.2  bouyer  * modification, are permitted provided that the following conditions
     10  1.2.2.2  bouyer  * are met:
     11  1.2.2.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     12  1.2.2.2  bouyer  *    notice, this list of conditions and the following disclaimer.
     13  1.2.2.2  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.2.2.2  bouyer  *    notice, this list of conditions and the following disclaimer in the
     15  1.2.2.2  bouyer  *    documentation and/or other materials provided with the distribution.
     16  1.2.2.2  bouyer  *
     17  1.2.2.2  bouyer  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
     18  1.2.2.2  bouyer  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19  1.2.2.2  bouyer  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20  1.2.2.2  bouyer  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
     21  1.2.2.2  bouyer  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22  1.2.2.2  bouyer  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23  1.2.2.2  bouyer  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24  1.2.2.2  bouyer  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25  1.2.2.2  bouyer  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26  1.2.2.2  bouyer  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27  1.2.2.2  bouyer  * SUCH DAMAGE.
     28  1.2.2.2  bouyer  */
     29  1.2.2.2  bouyer 
     30  1.2.2.2  bouyer #ifndef _ALTQ_ALTQ_RIO_H_
     31  1.2.2.2  bouyer #define	_ALTQ_ALTQ_RIO_H_
     32  1.2.2.2  bouyer 
     33  1.2.2.2  bouyer #include <altq/altq_classq.h>
     34  1.2.2.2  bouyer 
     35  1.2.2.2  bouyer /*
     36  1.2.2.2  bouyer  * RIO: RED with IN/OUT bit
     37  1.2.2.2  bouyer  * (extended to support more than 2 drop precedence values)
     38  1.2.2.2  bouyer  */
     39  1.2.2.2  bouyer #define	RIO_NDROPPREC	3	/* number of drop precedence values */
     40  1.2.2.2  bouyer 
     41  1.2.2.2  bouyer struct rio_interface {
     42  1.2.2.2  bouyer 	char	rio_ifname[IFNAMSIZ];
     43  1.2.2.2  bouyer };
     44  1.2.2.2  bouyer 
     45  1.2.2.2  bouyer struct rio_stats {
     46  1.2.2.2  bouyer 	struct rio_interface iface;
     47  1.2.2.2  bouyer 	int q_len[RIO_NDROPPREC];
     48  1.2.2.2  bouyer 	struct redstats q_stats[RIO_NDROPPREC];
     49  1.2.2.2  bouyer 
     50  1.2.2.2  bouyer 	/* static red parameters */
     51  1.2.2.2  bouyer 	int q_limit;
     52  1.2.2.2  bouyer 	int weight;
     53  1.2.2.2  bouyer 	int flags;
     54  1.2.2.2  bouyer 	struct redparams q_params[RIO_NDROPPREC];
     55  1.2.2.2  bouyer };
     56  1.2.2.2  bouyer 
     57  1.2.2.2  bouyer struct rio_conf {
     58  1.2.2.2  bouyer 	struct rio_interface iface;
     59  1.2.2.2  bouyer 	struct redparams q_params[RIO_NDROPPREC];
     60  1.2.2.2  bouyer 	int rio_weight;		/* weight for EWMA */
     61  1.2.2.2  bouyer 	int rio_limit;		/* max queue length */
     62  1.2.2.2  bouyer 	int rio_pkttime;	/* average packet time in usec */
     63  1.2.2.2  bouyer 	int rio_flags;		/* see below */
     64  1.2.2.2  bouyer };
     65  1.2.2.2  bouyer 
     66  1.2.2.2  bouyer /* rio flags */
     67  1.2.2.2  bouyer #define	RIOF_ECN4	0x01	/* use packet marking for IPv4 packets */
     68  1.2.2.2  bouyer #define	RIOF_ECN6	0x02	/* use packet marking for IPv6 packets */
     69  1.2.2.2  bouyer #define	RIOF_ECN	(RIOF_ECN4 | RIOF_ECN6)
     70  1.2.2.2  bouyer #define	RIOF_CLEARDSCP	0x200	/* clear diffserv codepoint */
     71  1.2.2.2  bouyer 
     72  1.2.2.2  bouyer /*
     73  1.2.2.2  bouyer  * IOCTLs for RIO
     74  1.2.2.2  bouyer  */
     75  1.2.2.2  bouyer #define	RIO_IF_ATTACH		_IOW('Q', 1, struct rio_interface)
     76  1.2.2.2  bouyer #define	RIO_IF_DETACH		_IOW('Q', 2, struct rio_interface)
     77  1.2.2.2  bouyer #define	RIO_ENABLE		_IOW('Q', 3, struct rio_interface)
     78  1.2.2.2  bouyer #define	RIO_DISABLE		_IOW('Q', 4, struct rio_interface)
     79  1.2.2.2  bouyer #define	RIO_CONFIG		_IOWR('Q', 6, struct rio_conf)
     80  1.2.2.2  bouyer #define	RIO_GETSTATS		_IOWR('Q', 12, struct rio_stats)
     81  1.2.2.2  bouyer #define	RIO_SETDEFAULTS		_IOW('Q', 30, struct redparams[RIO_NDROPPREC])
     82  1.2.2.2  bouyer 
     83  1.2.2.2  bouyer #ifdef _KERNEL
     84  1.2.2.2  bouyer 
     85  1.2.2.2  bouyer typedef struct rio {
     86  1.2.2.2  bouyer 	/* per drop precedence structure */
     87  1.2.2.2  bouyer 	struct dropprec_state {
     88  1.2.2.2  bouyer 		/* red parameters */
     89  1.2.2.2  bouyer 		int inv_pmax;	/* inverse of max drop probability */
     90  1.2.2.2  bouyer 		int th_min;	/* red min threshold */
     91  1.2.2.2  bouyer 		int th_max;	/* red max threshold */
     92  1.2.2.2  bouyer 
     93  1.2.2.2  bouyer 		/* variables for internal use */
     94  1.2.2.2  bouyer 		int th_min_s;	/* th_min scaled by avgshift */
     95  1.2.2.2  bouyer 		int th_max_s;	/* th_max scaled by avgshift */
     96  1.2.2.2  bouyer 		int probd;	/* drop probability denominator */
     97  1.2.2.2  bouyer 
     98  1.2.2.2  bouyer 		int qlen;	/* queue length */
     99  1.2.2.2  bouyer 		int avg;	/* (scaled) queue length average */
    100  1.2.2.2  bouyer 		int count; 	/* packet count since the last dropped/marked
    101  1.2.2.2  bouyer 				   packet */
    102  1.2.2.2  bouyer 		int idle;	/* queue was empty */
    103  1.2.2.2  bouyer 		int old;	/* avg is above th_min */
    104  1.2.2.2  bouyer 		struct timeval last;  /* timestamp when queue becomes idle */
    105  1.2.2.2  bouyer 	} rio_precstate[RIO_NDROPPREC];
    106  1.2.2.2  bouyer 
    107  1.2.2.2  bouyer 	int rio_wshift;		/* log(red_weight) */
    108  1.2.2.2  bouyer 	int rio_weight;		/* weight for EWMA */
    109  1.2.2.2  bouyer 	struct wtab *rio_wtab;	/* weight table */
    110  1.2.2.2  bouyer 
    111  1.2.2.2  bouyer 	int rio_pkttime; 	/* average packet time in micro sec
    112  1.2.2.2  bouyer 				   used for idle calibration */
    113  1.2.2.2  bouyer 	int rio_flags;		/* rio flags */
    114  1.2.2.2  bouyer 
    115  1.2.2.2  bouyer 	u_int8_t rio_codepoint;		/* codepoint value to tag packets */
    116  1.2.2.2  bouyer 	u_int8_t rio_codepointmask;	/* codepoint mask bits */
    117  1.2.2.2  bouyer 
    118  1.2.2.2  bouyer 	struct redstats q_stats[RIO_NDROPPREC];	/* statistics */
    119  1.2.2.2  bouyer } rio_t;
    120  1.2.2.2  bouyer 
    121  1.2.2.2  bouyer typedef struct rio_queue {
    122  1.2.2.2  bouyer 	struct rio_queue *rq_next;	/* next red_state in the list */
    123  1.2.2.2  bouyer 	struct ifaltq *rq_ifq;		/* backpointer to ifaltq */
    124  1.2.2.2  bouyer 
    125  1.2.2.2  bouyer 	class_queue_t *rq_q;
    126  1.2.2.2  bouyer 
    127  1.2.2.2  bouyer 	rio_t *rq_rio;
    128  1.2.2.2  bouyer } rio_queue_t;
    129  1.2.2.2  bouyer 
    130  1.2.2.2  bouyer extern rio_t *rio_alloc __P((int, struct redparams *, int, int));
    131  1.2.2.2  bouyer extern void rio_destroy __P((rio_t *));
    132  1.2.2.2  bouyer extern void rio_getstats __P((rio_t *, struct redstats *));
    133  1.2.2.2  bouyer extern int rio_addq __P((rio_t *, class_queue_t *, struct mbuf *,
    134  1.2.2.2  bouyer 			 struct altq_pktattr *));
    135  1.2.2.2  bouyer extern struct mbuf *rio_getq __P((rio_t *, class_queue_t *));
    136  1.2.2.2  bouyer extern int rio_set_meter __P((rio_t *, int, int, int));
    137  1.2.2.2  bouyer 
    138  1.2.2.2  bouyer #endif /* _KERNEL */
    139  1.2.2.2  bouyer 
    140  1.2.2.2  bouyer #endif /* _ALTQ_ALTQ_RIO_H_ */
    141