Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/net/altq/altq_rio.h
39507 views
1
/*-
2
* Copyright (C) 1998-2003
3
* Sony Computer Science Laboratories Inc. All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
*
14
* THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
15
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
* ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
18
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
* SUCH DAMAGE.
25
*
26
* $KAME: altq_rio.h,v 1.9 2003/07/10 12:07:49 kjc Exp $
27
*/
28
29
#ifndef _ALTQ_ALTQ_RIO_H_
30
#define _ALTQ_ALTQ_RIO_H_
31
32
#include <net/altq/altq_classq.h>
33
34
/*
35
* RIO: RED with IN/OUT bit
36
* (extended to support more than 2 drop precedence values)
37
*/
38
#define RIO_NDROPPREC 3 /* number of drop precedence values */
39
40
/* rio flags */
41
#define RIOF_ECN4 0x01 /* use packet marking for IPv4 packets */
42
#define RIOF_ECN6 0x02 /* use packet marking for IPv6 packets */
43
#define RIOF_ECN (RIOF_ECN4 | RIOF_ECN6)
44
#define RIOF_CLEARDSCP 0x200 /* clear diffserv codepoint */
45
46
#ifdef _KERNEL
47
48
typedef struct rio {
49
/* per drop precedence structure */
50
struct dropprec_state {
51
/* red parameters */
52
int inv_pmax; /* inverse of max drop probability */
53
int th_min; /* red min threshold */
54
int th_max; /* red max threshold */
55
56
/* variables for internal use */
57
int th_min_s; /* th_min scaled by avgshift */
58
int th_max_s; /* th_max scaled by avgshift */
59
int probd; /* drop probability denominator */
60
61
int qlen; /* queue length */
62
int avg; /* (scaled) queue length average */
63
int count; /* packet count since the last dropped/
64
marked packet */
65
int idle; /* queue was empty */
66
int old; /* avg is above th_min */
67
struct timeval last; /* timestamp when queue becomes idle */
68
} rio_precstate[RIO_NDROPPREC];
69
70
int rio_wshift; /* log(red_weight) */
71
int rio_weight; /* weight for EWMA */
72
struct wtab *rio_wtab; /* weight table */
73
74
int rio_pkttime; /* average packet time in micro sec
75
used for idle calibration */
76
int rio_flags; /* rio flags */
77
78
u_int8_t rio_codepoint; /* codepoint value to tag packets */
79
u_int8_t rio_codepointmask; /* codepoint mask bits */
80
81
struct redstats q_stats[RIO_NDROPPREC]; /* statistics */
82
} rio_t;
83
84
extern rio_t *rio_alloc(int, struct redparams *, int, int);
85
extern void rio_destroy(rio_t *);
86
extern void rio_getstats(rio_t *, struct redstats *);
87
extern int rio_addq(rio_t *, class_queue_t *, struct mbuf *,
88
struct altq_pktattr *);
89
extern struct mbuf *rio_getq(rio_t *, class_queue_t *);
90
91
#endif /* _KERNEL */
92
93
#endif /* _ALTQ_ALTQ_RIO_H_ */
94
95