]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/net/altq/altq_priq.h
openssh: cherry-pick OpenSSL 1.1.1 compatibility
[FreeBSD/FreeBSD.git] / sys / net / altq / altq_priq.h
1 /*-
2  * Copyright (C) 2000-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_priq.h,v 1.7 2003/10/03 05:05:15 kjc Exp $
27  * $FreeBSD$
28  */
29
30 #ifndef _ALTQ_ALTQ_PRIQ_H_
31 #define _ALTQ_ALTQ_PRIQ_H_
32
33 #include <net/altq/altq.h>
34 #include <net/altq/altq_classq.h>
35 #include <net/altq/altq_codel.h>
36 #include <net/altq/altq_red.h>
37 #include <net/altq/altq_rio.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 #define PRIQ_MAXPRI     16      /* upper limit of the number of priorities */
44
45 #ifdef ALTQ3_COMPAT
46 struct priq_interface {
47         char    ifname[IFNAMSIZ];       /* interface name (e.g., fxp0) */
48         u_long  arg;                    /* request-specific argument */
49 };
50
51 struct priq_add_class {
52         struct priq_interface   iface;
53         int                     pri;    /* priority (0 is the lowest) */
54         int                     qlimit; /* queue size limit */
55         int                     flags;  /* misc flags (see below) */
56
57         u_int32_t               class_handle;  /* return value */
58 };
59 #endif /* ALTQ3_COMPAT */
60
61 /* priq class flags */
62 #define PRCF_RED                0x0001  /* use RED */
63 #define PRCF_ECN                0x0002  /* use RED/ECN */
64 #define PRCF_RIO                0x0004  /* use RIO */
65 #define PRCF_CODEL              0x0008  /* use CoDel */
66 #define PRCF_CLEARDSCP          0x0010  /* clear diffserv codepoint */
67 #define PRCF_DEFAULTCLASS       0x1000  /* default class */
68
69 /* special class handles */
70 #define PRIQ_NULLCLASS_HANDLE   0
71
72 #ifdef ALTQ3_COMPAT
73 struct priq_delete_class {
74         struct priq_interface   iface;
75         u_int32_t               class_handle;
76 };
77
78 struct priq_modify_class {
79         struct priq_interface   iface;
80         u_int32_t               class_handle;
81         int                     pri;
82         int                     qlimit;
83         int                     flags;
84 };
85
86 struct priq_add_filter {
87         struct priq_interface   iface;
88         u_int32_t               class_handle;
89         struct flow_filter      filter;
90
91         u_long                  filter_handle;  /* return value */
92 };
93
94 struct priq_delete_filter {
95         struct priq_interface   iface;
96         u_long                  filter_handle;
97 };
98 #endif /* ALTQ3_COMPAT */
99
100 struct priq_classstats {
101         u_int32_t               class_handle;
102
103         u_int                   qlength;
104         u_int                   qlimit;
105         u_int                   period;
106         struct pktcntr          xmitcnt;  /* transmitted packet counter */
107         struct pktcntr          dropcnt;  /* dropped packet counter */
108
109         /* codel, red and rio related info */
110         int                     qtype;
111         struct redstats         red[3]; /* rio has 3 red stats */
112         struct codel_stats      codel;
113 };
114
115 /*
116  * PRIQ_STATS_VERSION is defined in altq.h to work around issues stemming
117  * from mixing of public-API and internal bits in each scheduler-specific
118  * header.
119  */
120
121 #ifdef ALTQ3_COMPAT
122 struct priq_class_stats {
123         struct priq_interface   iface;
124         int                     maxpri;   /* in/out */
125
126         struct priq_classstats  *stats;   /* pointer to stats array */
127 };
128
129 #define PRIQ_IF_ATTACH          _IOW('Q', 1, struct priq_interface)
130 #define PRIQ_IF_DETACH          _IOW('Q', 2, struct priq_interface)
131 #define PRIQ_ENABLE             _IOW('Q', 3, struct priq_interface)
132 #define PRIQ_DISABLE            _IOW('Q', 4, struct priq_interface)
133 #define PRIQ_CLEAR              _IOW('Q', 5, struct priq_interface)
134 #define PRIQ_ADD_CLASS          _IOWR('Q', 7, struct priq_add_class)
135 #define PRIQ_DEL_CLASS          _IOW('Q', 8, struct priq_delete_class)
136 #define PRIQ_MOD_CLASS          _IOW('Q', 9, struct priq_modify_class)
137 #define PRIQ_ADD_FILTER         _IOWR('Q', 10, struct priq_add_filter)
138 #define PRIQ_DEL_FILTER         _IOW('Q', 11, struct priq_delete_filter)
139 #define PRIQ_GETSTATS           _IOWR('Q', 12, struct priq_class_stats)
140
141 #endif /* ALTQ3_COMPAT */
142
143 #ifdef _KERNEL
144
145 struct priq_class {
146         u_int32_t       cl_handle;      /* class handle */
147         class_queue_t   *cl_q;          /* class queue structure */
148         union {
149                 struct red      *cl_red;        /* RED state */
150                 struct codel    *cl_codel;      /* CoDel state */
151         } cl_aqm;
152 #define cl_red          cl_aqm.cl_red
153 #define cl_codel        cl_aqm.cl_codel
154         int             cl_pri;         /* priority */
155         int             cl_flags;       /* class flags */
156         struct priq_if  *cl_pif;        /* back pointer to pif */
157         struct altq_pktattr *cl_pktattr; /* saved header used by ECN */
158
159         /* statistics */
160         u_int           cl_period;      /* backlog period */
161         struct pktcntr  cl_xmitcnt;     /* transmitted packet counter */
162         struct pktcntr  cl_dropcnt;     /* dropped packet counter */
163 };
164
165 /*
166  * priq interface state
167  */
168 struct priq_if {
169         struct priq_if          *pif_next;      /* interface state list */
170         struct ifaltq           *pif_ifq;       /* backpointer to ifaltq */
171         u_int                   pif_bandwidth;  /* link bandwidth in bps */
172         int                     pif_maxpri;     /* max priority in use */
173         struct priq_class       *pif_default;   /* default class */
174         struct priq_class       *pif_classes[PRIQ_MAXPRI]; /* classes */
175 #ifdef ALTQ3_CLFIER_COMPAT
176         struct acc_classifier   pif_classifier; /* classifier */
177 #endif
178 };
179
180 #endif /* _KERNEL */
181
182 #ifdef __cplusplus
183 }
184 #endif
185
186 #endif /* _ALTQ_ALTQ_PRIQ_H_ */