[BACK]Return to altq_rio.h CVS log [TXT][DIR] Up to [local] / sys / altq

Annotation of sys/altq/altq_rio.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: altq_rio.h,v 1.6 2003/03/13 16:33:46 kjc Exp $        */
                      2: /*     $KAME: altq_rio.h,v 1.5 2000/12/14 08:12:46 thorpej Exp $       */
                      3:
                      4: /*
                      5:  * Copyright (C) 1998-2000
                      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_RIO_H_
                     31: #define        _ALTQ_ALTQ_RIO_H_
                     32:
                     33: #include <altq/altq_classq.h>
                     34:
                     35: /*
                     36:  * RIO: RED with IN/OUT bit
                     37:  * (extended to support more than 2 drop precedence values)
                     38:  */
                     39: #define        RIO_NDROPPREC   3       /* number of drop precedence values */
                     40:
                     41: struct rio_interface {
                     42:        char    rio_ifname[IFNAMSIZ];
                     43: };
                     44:
                     45: struct rio_stats {
                     46:        struct rio_interface    iface;
                     47:        int                     q_len[RIO_NDROPPREC];
                     48:        struct redstats         q_stats[RIO_NDROPPREC];
                     49:
                     50:        /* static red parameters */
                     51:        int                     q_limit;
                     52:        int                     weight;
                     53:        int                     flags;
                     54:        struct redparams        q_params[RIO_NDROPPREC];
                     55: };
                     56:
                     57: struct rio_conf {
                     58:        struct rio_interface    iface;
                     59:        struct redparams        q_params[RIO_NDROPPREC];
                     60:        int                     rio_weight;     /* weight for EWMA */
                     61:        int                     rio_limit;      /* max queue length */
                     62:        int                     rio_pkttime;    /* avg packet time in usec */
                     63:        int                     rio_flags;      /* see below */
                     64: };
                     65:
                     66: /* rio flags */
                     67: #define        RIOF_ECN4       0x01    /* use packet marking for IPv4 packets */
                     68: #define        RIOF_ECN6       0x02    /* use packet marking for IPv6 packets */
                     69: #define        RIOF_ECN        (RIOF_ECN4 | RIOF_ECN6)
                     70: #define        RIOF_CLEARDSCP  0x200   /* clear diffserv codepoint */
                     71:
                     72: #ifdef _KERNEL
                     73:
                     74: typedef struct rio {
                     75:        /* per drop precedence structure */
                     76:        struct dropprec_state {
                     77:                /* red parameters */
                     78:                int     inv_pmax;       /* inverse of max drop probability */
                     79:                int     th_min;         /* red min threshold */
                     80:                int     th_max;         /* red max threshold */
                     81:
                     82:                /* variables for internal use */
                     83:                int     th_min_s;       /* th_min scaled by avgshift */
                     84:                int     th_max_s;       /* th_max scaled by avgshift */
                     85:                int     probd;          /* drop probability denominator */
                     86:
                     87:                int     qlen;           /* queue length */
                     88:                int     avg;            /* (scaled) queue length average */
                     89:                int     count;          /* packet count since the last dropped/
                     90:                                           marked packet */
                     91:                int     idle;           /* queue was empty */
                     92:                int     old;            /* avg is above th_min */
                     93:                struct timeval  last;   /* timestamp when queue becomes idle */
                     94:        } rio_precstate[RIO_NDROPPREC];
                     95:
                     96:        int              rio_wshift;    /* log(red_weight) */
                     97:        int              rio_weight;    /* weight for EWMA */
                     98:        struct wtab     *rio_wtab;      /* weight table */
                     99:
                    100:        int              rio_pkttime;   /* average packet time in micro sec
                    101:                                           used for idle calibration */
                    102:        int              rio_flags;     /* rio flags */
                    103:
                    104:        u_int8_t         rio_codepoint; /* codepoint value to tag packets */
                    105:        u_int8_t         rio_codepointmask;     /* codepoint mask bits */
                    106:
                    107:        struct redstats q_stats[RIO_NDROPPREC]; /* statistics */
                    108: } rio_t;
                    109:
                    110: typedef struct rio_queue {
                    111:        struct rio_queue        *rq_next;       /* next red_state in the list */
                    112:        struct ifaltq           *rq_ifq;        /* backpointer to ifaltq */
                    113:
                    114:        class_queue_t           *rq_q;
                    115:
                    116:        rio_t                   *rq_rio;
                    117: } rio_queue_t;
                    118:
                    119: extern rio_t           *rio_alloc(int, struct redparams *, int, int);
                    120: extern void             rio_destroy(rio_t *);
                    121: extern void             rio_getstats(rio_t *, struct redstats *);
                    122: extern int              rio_addq(rio_t *, class_queue_t *, struct mbuf *,
                    123:                             struct altq_pktattr *);
                    124: extern struct mbuf     *rio_getq(rio_t *, class_queue_t *);
                    125:
                    126: #endif /* _KERNEL */
                    127:
                    128: #endif /* _ALTQ_ALTQ_RIO_H_ */

CVSweb