/*-1* Copyright (C) 1998-20032* Sony Computer Science Laboratories Inc. All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*25* $KAME: altq_rio.h,v 1.9 2003/07/10 12:07:49 kjc Exp $26*/2728#ifndef _ALTQ_ALTQ_RIO_H_29#define _ALTQ_ALTQ_RIO_H_3031#include <net/altq/altq_classq.h>3233/*34* RIO: RED with IN/OUT bit35* (extended to support more than 2 drop precedence values)36*/37#define RIO_NDROPPREC 3 /* number of drop precedence values */3839/* rio flags */40#define RIOF_ECN4 0x01 /* use packet marking for IPv4 packets */41#define RIOF_ECN6 0x02 /* use packet marking for IPv6 packets */42#define RIOF_ECN (RIOF_ECN4 | RIOF_ECN6)43#define RIOF_CLEARDSCP 0x200 /* clear diffserv codepoint */4445#ifdef _KERNEL4647typedef struct rio {48/* per drop precedence structure */49struct dropprec_state {50/* red parameters */51int inv_pmax; /* inverse of max drop probability */52int th_min; /* red min threshold */53int th_max; /* red max threshold */5455/* variables for internal use */56int th_min_s; /* th_min scaled by avgshift */57int th_max_s; /* th_max scaled by avgshift */58int probd; /* drop probability denominator */5960int qlen; /* queue length */61int avg; /* (scaled) queue length average */62int count; /* packet count since the last dropped/63marked packet */64int idle; /* queue was empty */65int old; /* avg is above th_min */66struct timeval last; /* timestamp when queue becomes idle */67} rio_precstate[RIO_NDROPPREC];6869int rio_wshift; /* log(red_weight) */70int rio_weight; /* weight for EWMA */71struct wtab *rio_wtab; /* weight table */7273int rio_pkttime; /* average packet time in micro sec74used for idle calibration */75int rio_flags; /* rio flags */7677u_int8_t rio_codepoint; /* codepoint value to tag packets */78u_int8_t rio_codepointmask; /* codepoint mask bits */7980struct redstats q_stats[RIO_NDROPPREC]; /* statistics */81} rio_t;8283extern rio_t *rio_alloc(int, struct redparams *, int, int);84extern void rio_destroy(rio_t *);85extern void rio_getstats(rio_t *, struct redstats *);86extern int rio_addq(rio_t *, class_queue_t *, struct mbuf *,87struct altq_pktattr *);88extern struct mbuf *rio_getq(rio_t *, class_queue_t *);8990#endif /* _KERNEL */9192#endif /* _ALTQ_ALTQ_RIO_H_ */939495